aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2018-11-27 18:51:57 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2018-12-07 21:20:07 -0500
commita95be3842c51c9ac32fe17faedf2c156ccf81bd7 (patch)
treec5b002c36310bc179f1b71c5039ea7d9b9d384fd /drivers/target
parent5d6cd9fe318b4a6ed2ecee83306db3f543a4f9c4 (diff)
scsi: target/core: Simplify transport_clear_lun_ref()
Since transport_clear_lun_ref() already waits until the percpu-refcount .release() method is called, it is not necessary to wait first until percpu_ref_kill_and_confirm() has finished transitioning the refcount into atomic mode. Remove the code that waits for percpu_ref_kill_and_confirm() to complete and also the completion object that is used by that code. This patch does not change the behavior of the SCSI target code. Cc: Nicholas Bellinger <nab@linux-iscsi.org> Cc: Mike Christie <mchristi@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: David Disseldorp <ddiss@suse.de> Cc: Hannes Reinecke <hare@suse.de> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_device.c1
-rw-r--r--drivers/target/target_core_tpg.c1
-rw-r--r--drivers/target/target_core_transport.c35
3 files changed, 5 insertions, 32 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index cffd7430bb99..1d51df2b3e77 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -823,7 +823,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
823 823
824 xcopy_lun = &dev->xcopy_lun; 824 xcopy_lun = &dev->xcopy_lun;
825 rcu_assign_pointer(xcopy_lun->lun_se_dev, dev); 825 rcu_assign_pointer(xcopy_lun->lun_se_dev, dev);
826 init_completion(&xcopy_lun->lun_ref_comp);
827 init_completion(&xcopy_lun->lun_shutdown_comp); 826 init_completion(&xcopy_lun->lun_shutdown_comp);
828 INIT_LIST_HEAD(&xcopy_lun->lun_deve_list); 827 INIT_LIST_HEAD(&xcopy_lun->lun_deve_list);
829 INIT_LIST_HEAD(&xcopy_lun->lun_dev_link); 828 INIT_LIST_HEAD(&xcopy_lun->lun_dev_link);
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 16e7a6500be4..e2ace1059437 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -577,7 +577,6 @@ struct se_lun *core_tpg_alloc_lun(
577 } 577 }
578 lun->unpacked_lun = unpacked_lun; 578 lun->unpacked_lun = unpacked_lun;
579 atomic_set(&lun->lun_acl_count, 0); 579 atomic_set(&lun->lun_acl_count, 0);
580 init_completion(&lun->lun_ref_comp);
581 init_completion(&lun->lun_shutdown_comp); 580 init_completion(&lun->lun_shutdown_comp);
582 INIT_LIST_HEAD(&lun->lun_deve_list); 581 INIT_LIST_HEAD(&lun->lun_deve_list);
583 INIT_LIST_HEAD(&lun->lun_dev_link); 582 INIT_LIST_HEAD(&lun->lun_dev_link);
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 4d1651e46ea9..0c8eca6ae30f 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2911,38 +2911,13 @@ void target_wait_for_sess_cmds(struct se_session *se_sess)
2911} 2911}
2912EXPORT_SYMBOL(target_wait_for_sess_cmds); 2912EXPORT_SYMBOL(target_wait_for_sess_cmds);
2913 2913
2914static void target_lun_confirm(struct percpu_ref *ref) 2914/*
2915{ 2915 * Prevent that new percpu_ref_tryget_live() calls succeed and wait until
2916 struct se_lun *lun = container_of(ref, struct se_lun, lun_ref); 2916 * all references to the LUN have been released. Called during LUN shutdown.
2917 2917 */
2918 complete(&lun->lun_ref_comp);
2919}
2920
2921void transport_clear_lun_ref(struct se_lun *lun) 2918void transport_clear_lun_ref(struct se_lun *lun)
2922{ 2919{
2923 /* 2920 percpu_ref_kill(&lun->lun_ref);
2924 * Mark the percpu-ref as DEAD, switch to atomic_t mode, drop
2925 * the initial reference and schedule confirm kill to be
2926 * executed after one full RCU grace period has completed.
2927 */
2928 percpu_ref_kill_and_confirm(&lun->lun_ref, target_lun_confirm);
2929 /*
2930 * The first completion waits for percpu_ref_switch_to_atomic_rcu()
2931 * to call target_lun_confirm after lun->lun_ref has been marked
2932 * as __PERCPU_REF_DEAD on all CPUs, and switches to atomic_t
2933 * mode so that percpu_ref_tryget_live() lookup of lun->lun_ref
2934 * fails for all new incoming I/O.
2935 */
2936 wait_for_completion(&lun->lun_ref_comp);
2937 /*
2938 * The second completion waits for percpu_ref_put_many() to
2939 * invoke ->release() after lun->lun_ref has switched to
2940 * atomic_t mode, and lun->lun_ref.count has reached zero.
2941 *
2942 * At this point all target-core lun->lun_ref references have
2943 * been dropped via transport_lun_remove_cmd(), and it's safe
2944 * to proceed with the remaining LUN shutdown.
2945 */
2946 wait_for_completion(&lun->lun_shutdown_comp); 2921 wait_for_completion(&lun->lun_shutdown_comp);
2947} 2922}
2948 2923