Blame SOURCES/0001-enable-MaxOutstandingR2T-negotiation.patch

36b27b
From a54966e121ef5deaee2e113d1c912a7dd85aca86 Mon Sep 17 00:00:00 2001
36b27b
From: Chris Leech <cleech@redhat.com>
36b27b
Date: Wed, 20 Jun 2018 22:09:35 -0700
36b27b
Subject: [PATCH 1/1] enable MaxOutstandingR2T negotiation
36b27b
36b27b
The iscsi_tcp kernel side R2T handling is in libiscsi_tcp and is shared
36b27b
with at least cxgbi3, and the drivers claim CAP_MULTI_R2T. But the
36b27b
iscsid login parameter negotiation code never enabled MaxOutstandingR2T.
36b27b
36b27b
I've tested this against an LIO target, negotiating to 2 and 4 R2Ts.
36b27b
The network traces looked good, with the initiator keeping track of
36b27b
multiple outstanding R2Ts and using the correct next identifier.
36b27b
Throughput of bulk write data was improved, even over low latency virtio
36b27b
links.
36b27b
36b27b
Signed-off-by: Chris Leech <cleech@redhat.com>
36b27b
---
36b27b
 usr/initiator.h        |  1 +
36b27b
 usr/initiator_common.c |  3 ++-
36b27b
 usr/login.c            | 14 +++++---------
36b27b
 3 files changed, 8 insertions(+), 10 deletions(-)
36b27b
36b27b
diff --git a/usr/initiator.h b/usr/initiator.h
36b27b
index 4f96d6b6e2c5..3ee1454b6de2 100644
36b27b
--- a/usr/initiator.h
36b27b
+++ b/usr/initiator.h
36b27b
@@ -212,6 +212,7 @@ typedef struct iscsi_session {
36b27b
 	int erl;
36b27b
 	uint32_t imm_data_en;
36b27b
 	uint32_t initial_r2t_en;
36b27b
+	uint32_t max_r2t;
36b27b
 	uint32_t fast_abort;
36b27b
 	uint32_t first_burst;
36b27b
 	uint32_t max_burst;
36b27b
diff --git a/usr/initiator_common.c b/usr/initiator_common.c
36b27b
index 191e779bb942..d00bd9e7469b 100644
36b27b
--- a/usr/initiator_common.c
36b27b
+++ b/usr/initiator_common.c
36b27b
@@ -173,6 +173,7 @@ iscsi_copy_operational_params(struct iscsi_conn *conn,
36b27b
 
36b27b
 	/* session's operational parameters */
36b27b
 	session->initial_r2t_en = session_conf->InitialR2T;
36b27b
+	session->max_r2t = session_conf->MaxOutstandingR2T;
36b27b
 	session->imm_data_en = session_conf->ImmediateData;
36b27b
 	session->first_burst = align_32_down(session_conf->FirstBurstLength);
36b27b
 	/*
36b27b
@@ -375,7 +376,7 @@ int iscsi_session_set_neg_params(struct iscsi_conn *conn)
36b27b
 			.conn_only = 0,
36b27b
 		}, {
36b27b
 			.param = ISCSI_PARAM_MAX_R2T,
36b27b
-			.value = &one, /* FIXME: session->max_r2t */
36b27b
+			.value = &session->max_r2t,
36b27b
 			.type = ISCSI_INT,
36b27b
 			.conn_only = 0,
36b27b
 		}, {
36b27b
diff --git a/usr/login.c b/usr/login.c
36b27b
index 294ad0bf73fd..d7dad21180cf 100644
36b27b
--- a/usr/login.c
36b27b
+++ b/usr/login.c
36b27b
@@ -524,14 +524,9 @@ get_op_params_text_keys(iscsi_session_t *session, int cid,
36b27b
 		text = value_end;
36b27b
 	} else if (iscsi_find_key_value("MaxOutstandingR2T", text, end, &value,
36b27b
 					 &value_end)) {
36b27b
-		if (session->type == ISCSI_SESSION_TYPE_NORMAL) {
36b27b
-			if (strcmp(value, "1")) {
36b27b
-				log_error("Login negotiation "
36b27b
-					       "failed, can't accept Max"
36b27b
-					       "OutstandingR2T %s", value);
36b27b
-				return LOGIN_NEGOTIATION_FAILED;
36b27b
-			}
36b27b
-		} else
36b27b
+		if (session->type == ISCSI_SESSION_TYPE_NORMAL)
36b27b
+			session->max_r2t = strtoul(value, NULL, 0);
36b27b
+		else
36b27b
 			session->irrelevant_keys_bitmap |=
36b27b
 						IRRELEVANT_MAXOUTSTANDINGR2T;
36b27b
 		text = value_end;
36b27b
@@ -810,8 +805,9 @@ add_params_normal_session(iscsi_session_t *session, struct iscsi_hdr *pdu,
36b27b
 		return 0;
36b27b
 
36b27b
 	/* these we must have */
36b27b
+	sprintf(value, "%d", session->max_r2t);
36b27b
 	if (!iscsi_add_text(pdu, data, max_data_length,
36b27b
-			    "MaxOutstandingR2T", "1"))
36b27b
+			    "MaxOutstandingR2T", value))
36b27b
 		return 0;
36b27b
 	if (!iscsi_add_text(pdu, data, max_data_length,
36b27b
 			    "MaxConnections", "1"))
36b27b
-- 
36b27b
2.14.4
36b27b