Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

target: Simplify LUN shutdown code

Instead of starting a thread from transport_clear_lun_ref() that
waits for LUN shutdown, wait in that function for LUN shutdown
to finish. Additionally, change the return type of
transport_clear_lun_ref() from int to void.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

authored by

Bart Van Assche and committed by
Nicholas Bellinger
b3eeea66 3effdb90

+2 -27
-1
drivers/target/target_core_device.c
··· 928 928 929 929 xcopy_lun = &dev->xcopy_lun; 930 930 xcopy_lun->lun_se_dev = dev; 931 - init_completion(&xcopy_lun->lun_shutdown_comp); 932 931 spin_lock_init(&xcopy_lun->lun_sep_lock); 933 932 init_completion(&xcopy_lun->lun_ref_comp); 934 933
+1 -1
drivers/target/target_core_internal.h
··· 108 108 int transport_dump_vpd_ident_type(struct t10_vpd *, unsigned char *, int); 109 109 int transport_dump_vpd_ident(struct t10_vpd *, unsigned char *, int); 110 110 bool target_stop_cmd(struct se_cmd *cmd, unsigned long *flags); 111 - int transport_clear_lun_ref(struct se_lun *); 111 + void transport_clear_lun_ref(struct se_lun *); 112 112 void transport_send_task_abort(struct se_cmd *); 113 113 sense_reason_t target_cmd_size_check(struct se_cmd *cmd, unsigned int size); 114 114 void target_qf_do_work(struct work_struct *work);
-2
drivers/target/target_core_tpg.c
··· 494 494 495 495 lun->unpacked_lun = 0; 496 496 atomic_set(&lun->lun_acl_count, 0); 497 - init_completion(&lun->lun_shutdown_comp); 498 497 spin_lock_init(&lun->lun_sep_lock); 499 498 init_completion(&lun->lun_ref_comp); 500 499 ··· 605 606 lun->unpacked_lun = unpacked_lun; 606 607 lun->lun_link_magic = SE_LUN_LINK_MAGIC; 607 608 atomic_set(&lun->lun_acl_count, 0); 608 - init_completion(&lun->lun_shutdown_comp); 609 609 spin_lock_init(&lun->lun_sep_lock); 610 610 init_completion(&lun->lun_ref_comp); 611 611
+1 -22
drivers/target/target_core_transport.c
··· 2596 2596 } 2597 2597 EXPORT_SYMBOL(target_wait_for_sess_cmds); 2598 2598 2599 - static int transport_clear_lun_ref_thread(void *p) 2599 + void transport_clear_lun_ref(struct se_lun *lun) 2600 2600 { 2601 - struct se_lun *lun = p; 2602 - 2603 2601 percpu_ref_kill(&lun->lun_ref); 2604 - 2605 2602 wait_for_completion(&lun->lun_ref_comp); 2606 - complete(&lun->lun_shutdown_comp); 2607 - 2608 - return 0; 2609 - } 2610 - 2611 - int transport_clear_lun_ref(struct se_lun *lun) 2612 - { 2613 - struct task_struct *kt; 2614 - 2615 - kt = kthread_run(transport_clear_lun_ref_thread, lun, 2616 - "tcm_cl_%u", lun->unpacked_lun); 2617 - if (IS_ERR(kt)) { 2618 - pr_err("Unable to start clear_lun thread\n"); 2619 - return PTR_ERR(kt); 2620 - } 2621 - wait_for_completion(&lun->lun_shutdown_comp); 2622 - 2623 - return 0; 2624 2603 } 2625 2604 2626 2605 /**
-1
include/target/target_core_base.h
··· 707 707 u32 lun_index; 708 708 atomic_t lun_acl_count; 709 709 spinlock_t lun_sep_lock; 710 - struct completion lun_shutdown_comp; 711 710 struct se_device *lun_se_dev; 712 711 struct se_port *lun_sep; 713 712 struct config_group lun_group;