target: Simplify LUN shutdown code
authorBart Van Assche <bart.vanassche@sandisk.com>
Tue, 19 May 2015 14:16:01 +0000 (16:16 +0200)
committerNicholas Bellinger <nab@linux-iscsi.org>
Mon, 1 Jun 2015 07:25:39 +0000 (00:25 -0700)
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>
drivers/target/target_core_device.c
drivers/target/target_core_internal.h
drivers/target/target_core_tpg.c
drivers/target/target_core_transport.c
include/target/target_core_base.h

index 22f1e180d8ee64a0b2f13a66560ee9e96a018915..1e4485b1849dd5e228da957070d82fb62dc28833 100644 (file)
@@ -928,7 +928,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
 
        xcopy_lun = &dev->xcopy_lun;
        xcopy_lun->lun_se_dev = dev;
-       init_completion(&xcopy_lun->lun_shutdown_comp);
        spin_lock_init(&xcopy_lun->lun_sep_lock);
        init_completion(&xcopy_lun->lun_ref_comp);
 
index 01181aed67dcbe59730651abe12dd6557cf4cb64..23f992ed7cae75df0542284c5f701e9a3268d5dc 100644 (file)
@@ -108,7 +108,7 @@ int transport_dump_vpd_assoc(struct t10_vpd *, unsigned char *, int);
 int    transport_dump_vpd_ident_type(struct t10_vpd *, unsigned char *, int);
 int    transport_dump_vpd_ident(struct t10_vpd *, unsigned char *, int);
 bool   target_stop_cmd(struct se_cmd *cmd, unsigned long *flags);
-int    transport_clear_lun_ref(struct se_lun *);
+void   transport_clear_lun_ref(struct se_lun *);
 void   transport_send_task_abort(struct se_cmd *);
 sense_reason_t target_cmd_size_check(struct se_cmd *cmd, unsigned int size);
 void   target_qf_do_work(struct work_struct *work);
index 91f8ddb6d7832f2af9f9bdf7da7f502beffccb8b..fd531fcf31911d1700432e684d5c36f7454553f1 100644 (file)
@@ -494,7 +494,6 @@ static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg)
 
        lun->unpacked_lun = 0;
        atomic_set(&lun->lun_acl_count, 0);
-       init_completion(&lun->lun_shutdown_comp);
        spin_lock_init(&lun->lun_sep_lock);
        init_completion(&lun->lun_ref_comp);
 
@@ -606,7 +605,6 @@ struct se_lun *core_tpg_alloc_lun(
        lun->unpacked_lun = unpacked_lun;
        lun->lun_link_magic = SE_LUN_LINK_MAGIC;
        atomic_set(&lun->lun_acl_count, 0);
-       init_completion(&lun->lun_shutdown_comp);
        spin_lock_init(&lun->lun_sep_lock);
        init_completion(&lun->lun_ref_comp);
 
index 965a308e10a5d2c011a05b60bdd706b019c47776..7c0518a28186434e847d5ae3e4d239b68c51ea95 100644 (file)
@@ -2596,31 +2596,10 @@ void target_wait_for_sess_cmds(struct se_session *se_sess)
 }
 EXPORT_SYMBOL(target_wait_for_sess_cmds);
 
-static int transport_clear_lun_ref_thread(void *p)
+void transport_clear_lun_ref(struct se_lun *lun)
 {
-       struct se_lun *lun = p;
-
        percpu_ref_kill(&lun->lun_ref);
-
        wait_for_completion(&lun->lun_ref_comp);
-       complete(&lun->lun_shutdown_comp);
-
-       return 0;
-}
-
-int transport_clear_lun_ref(struct se_lun *lun)
-{
-       struct task_struct *kt;
-
-       kt = kthread_run(transport_clear_lun_ref_thread, lun,
-                       "tcm_cl_%u", lun->unpacked_lun);
-       if (IS_ERR(kt)) {
-               pr_err("Unable to start clear_lun thread\n");
-               return PTR_ERR(kt);
-       }
-       wait_for_completion(&lun->lun_shutdown_comp);
-
-       return 0;
 }
 
 /**
index 03e2ee8f833706b7adc09b3db505843322e5efde..ee7abdd6b7a2fd265dc1322729b7209a2f572962 100644 (file)
@@ -707,7 +707,6 @@ struct se_lun {
        u32                     lun_index;
        atomic_t                lun_acl_count;
        spinlock_t              lun_sep_lock;
-       struct completion       lun_shutdown_comp;
        struct se_device        *lun_se_dev;
        struct se_port          *lun_sep;
        struct config_group     lun_group;