[stgt] [PATCH 1/3] Use function arguments for target names

Chandra Seetharaman sekharan at us.ibm.com
Wed Aug 4 03:16:38 CEST 2010


Remove the dependence of iscsi_targets_list in isns_scn_register()
and isns_target_register(). Instead use target's name as the argument
to the function.

This is in preparation of the following patch that registers targets
that are already defined when iSNS is turned On.

Signed-Off-By: Chandra Seetharaman <sekharan at us.ibm.com>
---
 usr/iscsi/isns.c |   17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

Index: tgt-469b574/usr/iscsi/isns.c
===================================================================
--- tgt-469b574.orig/usr/iscsi/isns.c
+++ tgt-469b574/usr/iscsi/isns.c
@@ -240,15 +240,14 @@ static int isns_scn_deregister(char *nam
 #define set_scn_flag(x)
 #endif
 
-static int isns_scn_register(void)
+static int isns_scn_register(char *name)
 {
 	int err;
 	uint16_t flags, length = 0;
 	uint32_t scn_flags;
-	char buf[4096], *name;
+	char buf[4096];
 	struct isns_hdr *hdr = (struct isns_hdr *) buf;
 	struct isns_tlv *tlv;
-	struct iscsi_target *target;
 
 	if (list_empty(&iscsi_targets_list))
 		return 0;
@@ -260,10 +259,6 @@ static int isns_scn_register(void)
 	memset(buf, 0, sizeof(buf));
 	tlv = (struct isns_tlv *) hdr->pdu;
 
-	target = list_first_entry(&iscsi_targets_list,
-				  struct iscsi_target, tlist);
-	name = tgt_targetname(target->tid);
-
 	length += isns_tlv_set_string(&tlv, ISNS_ATTR_ISCSI_NAME, name);
 	length += isns_tlv_set_string(&tlv, ISNS_ATTR_ISCSI_NAME, name);
 	length += isns_tlv_set(&tlv, 0, 0, 0);
@@ -392,7 +387,6 @@ int isns_target_register(char *name)
 	uint32_t port = htonl(iscsi_listen_port);
 	uint32_t node = htonl(ISNS_NODE_TARGET);
 	uint32_t type = htonl(2);
-	struct iscsi_target *target;
 	int err, initial = list_length_is_one(&iscsi_targets_list);
 
 	if (!use_isns)
@@ -405,10 +399,7 @@ int isns_target_register(char *name)
 	memset(buf, 0, sizeof(buf));
 	tlv = (struct isns_tlv *) hdr->pdu;
 
-        target = list_first_entry(&iscsi_targets_list,
-				  struct iscsi_target, tlist);
-        length += isns_tlv_set_string(&tlv, ISNS_ATTR_ISCSI_NAME,
-				      tgt_targetname(target->tid));
+	length += isns_tlv_set_string(&tlv, ISNS_ATTR_ISCSI_NAME, name);
 	length += isns_tlv_set_string(&tlv, ISNS_ATTR_ENTITY_IDENTIFIER, eid);
 
 	length += isns_tlv_set(&tlv, 0, 0, 0);
@@ -443,7 +434,7 @@ int isns_target_register(char *name)
 		eprintf("%d %m\n", length);
 
 	if (scn_listen_port)
-		isns_scn_register();
+		isns_scn_register(name);
 
 	isns_attr_query(name);
 
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list