[PATCH] iscsi fix xmit param

Pete Wyckoff pw
Wed Aug 15 18:09:46 CEST 2007


Repair one case in MaxRecvDataSegmentLength processing.  Default target
has always limited data segments to 8k, even if the initiator asks for
more.  It may be a good idea to increase this by, e.g:

    tgtadm --lld iscsi --mode target --op update --tid 1 \
	   --name MaxXmitDataSegmentLength --value 262144

so that target will generate up to min(initiator RDSL, 256k).  But if
you change this parameter, and initiator does not specify RDSL, target
will incorrectly use 256k instead of 8k.

Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
 usr/iscsi/iscsid.c |   10 +++++++---
 usr/iscsi/iscsid.h |    1 +
 usr/iscsi/target.c |    2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index e092462..0a1932a 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -286,8 +286,10 @@ static void text_scan_login(struct iscsi_connection *conn)
 			unsigned int val;
 			char buf[32];
 
-			if (idx == ISCSI_PARAM_MAX_RECV_DLENGTH)
+			if (idx == ISCSI_PARAM_MAX_RECV_DLENGTH) {
 				idx = ISCSI_PARAM_MAX_XMIT_DLENGTH;
+				conn->mxdsl_negotiated = 1;
+			}
 
 			if (param_str_to_val(session_keys, idx, value, &val) < 0) {
 				if (conn->session_param[idx].state
@@ -349,8 +351,6 @@ static int text_check_param(struct iscsi_connection *conn)
 		if (p[i].state == KEY_STATE_START && p[i].val != session_keys[i].def) {
 			if (conn->state == STATE_LOGIN) {
 				if (i == ISCSI_PARAM_MAX_XMIT_DLENGTH) {
-					if (p[i].val > session_keys[i].def)
-						p[i].val = session_keys[i].def;
 					p[i].state = KEY_STATE_DONE;
 					continue;
 				}
@@ -471,6 +471,10 @@ static void login_finish(struct iscsi_connection *conn)
 {
 	switch (conn->session_type) {
 	case SESSION_NORMAL:
+		if (!conn->mxdsl_negotiated)
+			/* use spec default if he did not mention MRDSL */
+			conn->session_param[ISCSI_PARAM_MAX_XMIT_DLENGTH].val =
+				session_keys[ISCSI_PARAM_MAX_XMIT_DLENGTH].def;
 		if (!conn->session)
 			session_create(conn);
 		memcpy(conn->isid, conn->session->isid, sizeof(conn->isid));
diff --git a/usr/iscsi/iscsid.h b/usr/iscsi/iscsid.h
index a8c8cb1..2b08252 100644
--- a/usr/iscsi/iscsid.h
+++ b/usr/iscsi/iscsid.h
@@ -140,6 +140,7 @@ struct iscsi_connection {
 
 	int tid;
 	struct param session_param[ISCSI_PARAM_MAX];
+	int mxdsl_negotiated;
 
 	char *initiator;
 	uint8_t isid[6];
diff --git a/usr/iscsi/target.c b/usr/iscsi/target.c
index 2653839..53d8164 100644
--- a/usr/iscsi/target.c
+++ b/usr/iscsi/target.c
@@ -265,7 +265,7 @@ int iscsi_target_create(struct target *t)
 	struct iscsi_target *target;
 	struct param default_tgt_session_param[] = {
 		[ISCSI_PARAM_MAX_RECV_DLENGTH] = {0, 8192},
-		[ISCSI_PARAM_MAX_XMIT_DLENGTH] = {0, 8192},  /* do not edit */
+		[ISCSI_PARAM_MAX_XMIT_DLENGTH] = {0, 8192},
 		[ISCSI_PARAM_HDRDGST_EN] = {0, DIGEST_NONE},
 		[ISCSI_PARAM_DATADGST_EN] = {0, DIGEST_NONE},
 		[ISCSI_PARAM_INITIAL_R2T_EN] = {0, 1},
-- 
1.5.2.4




More information about the stgt mailing list