[PATCH 05/14] target/iscsi: only listen on new portals if the TPG is enabled

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

 



Check whether the TPG is enabled prior to starting the listener thread.

Signed-off-by: David Disseldorp <ddiss@xxxxxxx>
---
 drivers/target/iscsi/iscsi_target_tpg.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
index f2dc9b0..ddf1a67 100644
--- a/drivers/target/iscsi/iscsi_target_tpg.c
+++ b/drivers/target/iscsi/iscsi_target_tpg.c
@@ -467,7 +467,7 @@ struct iscsi_tpg_np *iscsit_tpg_add_network_portal(
 {
 	struct iscsi_np *np;
 	struct iscsi_tpg_np *tpg_np;
-	int ret;
+	bool tpg_enabled;
 
 	if (!tpg_np_parent) {
 		if (iscsit_tpg_check_network_portal(tpg->tpg_tiqn, sockaddr,
@@ -492,12 +492,19 @@ struct iscsi_tpg_np *iscsit_tpg_add_network_portal(
 		return ERR_CAST(np);
 	}
 
-	ret = iscsit_enable_np_thread(np);
-	if (ret < 0) {
-		pr_err("Failed to enable network portal\n");
-		iscsit_del_np(np);
-		kfree(tpg_np);
-		return ERR_PTR(ret);
+	spin_lock(&tpg->tpg_state_lock);
+	tpg_enabled = (tpg->tpg_state == TPG_STATE_ACTIVE);
+	spin_unlock(&tpg->tpg_state_lock);
+	if (tpg_enabled) {
+		int ret;
+		/* only start listening if the TPG is enabled */
+		ret = iscsit_enable_np_thread(np);
+		if (ret < 0) {
+			pr_err("Failed to enable network portal\n");
+			iscsit_del_np(np);
+			kfree(tpg_np);
+			return ERR_PTR(ret);
+		}
 	}
 
 	INIT_LIST_HEAD(&tpg_np->tpg_np_list);
-- 
2.1.4

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



[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux