[PATCH 1/2] target: Ensure lu_gp_mem->lu_gp is never NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



->lu_gp should never be NULL, because if lu_gp_mem is not in an explicit
group, it should be in default_lu_gp. Change target_core_store_alua_lu_gp
to make this so.

Also, fix a typo in a comment in that function.

Finally, in core_alua_free_lu_gp, explicitly leave the old group before
joining default_lu_gp, allowing simpler logic.

Signed-off-by: Andy Grover <agrover@xxxxxxxxxx>
---
 drivers/target/target_core_alua.c     | 6 ++----
 drivers/target/target_core_configfs.c | 3 ++-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 12da9b3..60a6a2c 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -1599,11 +1599,9 @@ void core_alua_free_lu_gp(struct t10_alua_lu_gp *lu_gp)
 		 * we want to re-associate a given lu_gp_mem with default_lu_gp.
 		 */
 		spin_lock(&lu_gp_mem->lu_gp_mem_lock);
+		__core_alua_drop_lu_gp_mem(lu_gp_mem, lu_gp);
 		if (lu_gp != default_lu_gp)
-			__core_alua_attach_lu_gp_mem(lu_gp_mem,
-					default_lu_gp);
-		else
-			lu_gp_mem->lu_gp = NULL;
+			__core_alua_attach_lu_gp_mem(lu_gp_mem, default_lu_gp);
 		spin_unlock(&lu_gp_mem->lu_gp_mem_lock);
 
 		spin_lock(&lu_gp->lu_gp_lock);
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index f0e85b1..2a7a922 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -1693,7 +1693,7 @@ static ssize_t target_core_store_alua_lu_gp(
 		/*
 		 * core_alua_get_lu_gp_by_name() will increment reference to
 		 * struct t10_alua_lu_gp.  This reference is released with
-		 * core_alua_get_lu_gp_by_name below().
+		 * core_alua_put_lu_gp_from_name() below.
 		 */
 		lu_gp_new = core_alua_get_lu_gp_by_name(strstrip(buf));
 		if (!lu_gp_new)
@@ -1717,6 +1717,7 @@ static ssize_t target_core_store_alua_lu_gp(
 				lu_gp->lu_gp_id);
 
 			__core_alua_drop_lu_gp_mem(lu_gp_mem, lu_gp);
+			__core_alua_attach_lu_gp_mem(lu_gp_mem, default_lu_gp);
 			spin_unlock(&lu_gp_mem->lu_gp_mem_lock);
 
 			return count;
-- 
1.8.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux