summaryrefslogtreecommitdiff
path: root/drivers/target/target_core_pr.c
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2015-05-20 21:21:08 -0700
committerNicholas Bellinger <nab@linux-iscsi.org>2015-06-01 00:27:56 -0700
commit9e37d042cfcb003b885bb4c531cd6f07f62647d1 (patch)
tree8f198eb93f269c0ebe7a69b018293e2814316aee /drivers/target/target_core_pr.c
parent4cc987eaff9144182cde88d6d132420c28d3f81b (diff)
target: Drop se_lun->lun_active for existing percpu lun_ref
With se_port_t and t10_alua_tg_pt_gp_member being absored into se_lun, there is no need for an extra atomic_t based reference count for PR ALL_TG_PT=1 and ALUA access state transition. Go ahead and use the existing percpu se_lun->lun_ref instead, and convert the two special cases to percpu_ref_tryget_live() to avoid se_lun if transport_clear_lun_ref() has already been invoked to shutdown the se_lun. Cc: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_pr.c')
-rw-r--r--drivers/target/target_core_pr.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 60624bb6c598..94935eaa7fa7 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -704,7 +704,8 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration(
*/
spin_lock(&dev->se_port_lock);
list_for_each_entry_safe(lun_tmp, next, &dev->dev_sep_list, lun_dev_link) {
- atomic_inc_mb(&lun_tmp->lun_active);
+ if (!percpu_ref_tryget_live(&lun_tmp->lun_ref))
+ continue;
spin_unlock(&dev->se_port_lock);
spin_lock_bh(&lun_tmp->lun_deve_lock);
@@ -751,7 +752,7 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration(
if (ret < 0) {
pr_err("core_scsi3_lunacl_depend"
"_item() failed\n");
- atomic_dec_mb(&lun->lun_active);
+ percpu_ref_put(&lun_tmp->lun_ref);
kref_put(&deve_tmp->pr_kref, target_pr_kref_release);
goto out;
}
@@ -770,7 +771,7 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration(
deve_tmp->mapped_lun, NULL,
sa_res_key, all_tg_pt, aptpl);
if (!pr_reg_atp) {
- atomic_dec_mb(&lun_tmp->lun_active);
+ percpu_ref_put(&lun_tmp->lun_ref);
core_scsi3_lunacl_undepend_item(deve_tmp);
goto out;
}
@@ -782,7 +783,7 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration(
spin_unlock_bh(&lun_tmp->lun_deve_lock);
spin_lock(&dev->se_port_lock);
- atomic_dec_mb(&lun_tmp->lun_active);
+ percpu_ref_put(&lun_tmp->lun_ref);
}
spin_unlock(&dev->se_port_lock);