[stgt] [PATCH 14/15] Fix iSCSI Data-Out solicitation

Arne Redlich arne.redlich at googlemail.com
Tue Jun 9 18:22:59 CEST 2009


Currently the iSCSI driver only solicits MaxXmitDSL(!) bytes with each R2T,
although it could solicit MaxBurstLength bytes.

This was introduced with the iSER driver and a RDMA_TRANSFER_SIZE constant to
limit the size of RDMA transfers. However, MaxBurstLength can and should be
used for that.

Signed-off-by: Arne Redlich <arne.redlich at googlemail.com>
---
Only lightly tested / untested (iSER), so review and test feedback very
much appreciated.

 usr/iscsi/conn.c       |    2 --
 usr/iscsi/iscsi_rdma.c |   14 ++------------
 usr/iscsi/iscsid.c     |   27 +++++++++++++--------------
 usr/iscsi/iscsid.h     |    1 -
 4 files changed, 15 insertions(+), 29 deletions(-)

diff --git a/usr/iscsi/conn.c b/usr/iscsi/conn.c
index 915f76f..56ba2c4 100644
--- a/usr/iscsi/conn.c
+++ b/usr/iscsi/conn.c
@@ -57,8 +57,6 @@ int conn_init(struct iscsi_connection *conn)
 	conn->refcount = 1;
 	conn->state = STATE_FREE;
 	param_set_defaults(conn->session_param, session_keys);
-	conn->data_inout_max_length =
-		conn->session_param[ISCSI_PARAM_MAX_XMIT_DLENGTH].val;
 
 	INIT_LIST_HEAD(&conn->clist);
 	INIT_LIST_HEAD(&conn->tx_clist);
diff --git a/usr/iscsi/iscsi_rdma.c b/usr/iscsi/iscsi_rdma.c
index 289b72d..b25abf7 100644
--- a/usr/iscsi/iscsi_rdma.c
+++ b/usr/iscsi/iscsi_rdma.c
@@ -241,7 +241,7 @@ static int waiting_rdma_slot;
  * per connection, but many tasks might be in progress on the connection.
  * Internal flow control stops tasks when there are no slots.
  *
- * RDMA size tradeoffs:
+ * RDMA size tradeoffs (MaxBurstLength):
  *    big RDMA operations are more efficient
  *    small RDMA operations better for fairness with many clients
  *    small RDMA operations allow better pipelining
@@ -249,8 +249,6 @@ static int waiting_rdma_slot;
  *        entire buffer to transport in one go
  */
 #define RDMA_PER_CONN 20
-#define RDMA_TRANSFER_SIZE (512 * 1024)
-
 
 #define MAX_POLL_WC 8
 
@@ -1244,17 +1242,9 @@ static int iscsi_rdma_login_complete(struct iscsi_connection *conn)
 	ci->rsize = hdrsz + trdsl;
 	ci->max_outst_pdu = outst_pdu;
 	ret = iser_init_comm(ci);
-	if (ret) {
+	if (ret)
 		eprintf("iser_init_comm failed\n");
-		goto out;
-	}
 
-	/*
-	 * How much data to grab in an RDMA operation, read or write.
-	 */
-	conn->data_inout_max_length = RDMA_TRANSFER_SIZE;
-
-out:
 	return ret;
 }
 
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 8e9876a..df7ce1f 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -528,13 +528,6 @@ static void login_finish(struct iscsi_connection *conn)
 	switch (conn->session_type) {
 	case SESSION_NORMAL:
 		/*
-		 * update based on negotiations (but ep_login_complete
-		 * could override)
-		 */
-		conn->data_inout_max_length =
-			conn->session_param[ISCSI_PARAM_MAX_XMIT_DLENGTH].val;
-
-		/*
 		 * Allocate transport resources for this connection.
 		 */
 		ret = conn->tp->ep_login_complete(conn);
@@ -977,7 +970,7 @@ static int iscsi_data_rsp_build(struct iscsi_task *task)
 {
 	struct iscsi_connection *conn = task->conn;
 	struct iscsi_data_rsp *rsp = (struct iscsi_data_rsp *) &conn->rsp.bhs;
-	int datalen;
+	int datalen, maxdatalen;
 	int result = scsi_get_result(&task->scmd);
 
 	memset(rsp, 0, sizeof(*rsp));
@@ -991,10 +984,15 @@ static int iscsi_data_rsp_build(struct iscsi_task *task)
 	datalen = min_t(uint32_t, scsi_get_in_length(&task->scmd), task->len);
 	datalen -= task->offset;
 
-	dprintf("%d %d %d %d %x\n", datalen, scsi_get_in_length(&task->scmd),
-		task->len, conn->data_inout_max_length, rsp->itt);
+	maxdatalen = conn->tp->rdma ?
+		conn->session_param[ISCSI_PARAM_MAX_BURST].val :
+		conn->session_param[ISCSI_PARAM_MAX_XMIT_DLENGTH].val;
+
+	dprintf("%d %d %d %" PRIu32 "%x\n", datalen,
+		scsi_get_in_length(&task->scmd), task->len, maxdatalen,
+		rsp->itt);
 
-	if (datalen <= conn->data_inout_max_length) {
+	if (datalen <= maxdatalen) {
 		rsp->flags = ISCSI_FLAG_CMD_FINAL;
 
 		/* collapse status into final packet if successful */
@@ -1007,7 +1005,7 @@ static int iscsi_data_rsp_build(struct iscsi_task *task)
 			calc_residual((struct iscsi_cmd_rsp *) rsp, task);
 		}
 	} else
-		datalen = conn->data_inout_max_length;
+		datalen = maxdatalen;
 
 	rsp->exp_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn);
 	rsp->max_cmdsn = cpu_to_be32(conn->session->exp_cmd_sn + MAX_QUEUE_CMD);
@@ -1026,7 +1024,7 @@ static int iscsi_r2t_build(struct iscsi_task *task)
 {
 	struct iscsi_connection *conn = task->conn;
 	struct iscsi_r2t_rsp *rsp = (struct iscsi_r2t_rsp *) &conn->rsp.bhs;
-	int length;
+	uint32_t length;
 
 	memset(rsp, 0, sizeof(*rsp));
 
@@ -1040,7 +1038,8 @@ static int iscsi_r2t_build(struct iscsi_task *task)
 	/* return next statsn for this conn w/o advancing it */
 	rsp->statsn = cpu_to_be32(conn->stat_sn);
 	rsp->ttt = (unsigned long) task;
-	length = min(task->r2t_count, conn->data_inout_max_length);
+	length = min_t(uint32_t, task->r2t_count,
+		       conn->session_param[ISCSI_PARAM_MAX_BURST].val);
 	rsp->data_length = cpu_to_be32(length);
 
 	return 0;
diff --git a/usr/iscsi/iscsid.h b/usr/iscsi/iscsid.h
index 7897c41..b301c78 100644
--- a/usr/iscsi/iscsid.h
+++ b/usr/iscsi/iscsid.h
@@ -146,7 +146,6 @@ struct iscsi_connection {
 
 	int tid;
 	struct param session_param[ISCSI_PARAM_MAX];
-	int data_inout_max_length;
 
 	char *initiator;
 	uint8_t isid[6];
-- 
1.6.0.4



--
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