Skip to contentSkip to conversation

target:alua: fix the tg_pt_gps_count

PATCH Superseded tangwenji 2 participants 2 messages Mar 13, 2019 – Mar 20, 2019 SCSI target

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

tangwenji

author
#0 lore raw

PATCH 1/1 target:alua: fix the tg_pt_gps_count

From: tangwenji <[email protected]>

Reducing the count should be alua_tg_pt_gps_count instead of alua_tg_pt_gps_counter when free alua group.

---
 drivers/target/target_core_alua.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/target_core_alua.c +1 -1
index e09f0cf..4808654 100644
@@ -1761,7 +1761,7 @@ void core_alua_free_tg_pt_gp(
 	 */
 	spin_lock(&dev->t10_alua.tg_pt_gps_lock);
 	list_del(&tg_pt_gp->tg_pt_gp_list);
-	dev->t10_alua.alua_tg_pt_gps_counter--;
+	dev->t10_alua.alua_tg_pt_gps_count--;
 	spin_unlock(&dev->t10_alua.tg_pt_gps_lock);
 
 	/*
Signature · 1 line
2.5.0.windows.1
#1 lore raw
Quoted 14 lines · tangwenji

From: tangwenji <[email protected]>

Reducing the count should be alua_tg_pt_gps_count instead of alua_tg_pt_gps_counter when free alua group.

---
 drivers/target/target_core_alua.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/target_core_alua.c +0 -0
index e09f0cf..4808654 100644

drivers/target/target_core_alua.c void core_alua_free_tg_pt_gp( · line 1766

Quoted 7 lines
drivers/target/target_core_alua.c +1 -1
@@ -1761,7 +1761,7 @@ void core_alua_free_tg_pt_gp(
 	 */
 	spin_lock(&dev->t10_alua.tg_pt_gps_lock);
 	list_del(&tg_pt_gp->tg_pt_gp_list);
-	dev->t10_alua.alua_tg_pt_gps_counter--;
+	dev->t10_alua.alua_tg_pt_gps_count--;
 	spin_unlock(&dev->t10_alua.tg_pt_gps_lock);
 

I think because its always decremented here we could end up going negative. If userspace does not call into target_tg_pt_gp_tg_pt_gp_id_store or it fails, then we will not have done a count++ and not added it to the list in core_alua_set_tg_pt_gp_id.

I think above above we need to do:

if (tg_pt_gp_valid_id) {
    list_del(&tg_pt_gp->tg_pt_gp_list)
    dev->t10_alua.alua_tg_pt_gps_count--;
}