Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jan 2017 20:41:45 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r312195 - head/usr.sbin/iscsid
Message-ID:  <201701142041.v0EKfjg1054733@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Jan 14 20:41:44 2017
New Revision: 312195
URL: https://svnweb.freebsd.org/changeset/base/312195

Log:
  Alike to r312190 decouple iSCSI connection limits from defaults.
  
  Connection parameters should remain at defaults until negotiated.
  
  While there, remove sythetic limits, applied if kernel provided none.
  iscsid has no own limitations, no configuration and no any idea what
  values are good.  Assume kernel knows what it requests.

Modified:
  head/usr.sbin/iscsid/iscsid.c
  head/usr.sbin/iscsid/iscsid.h
  head/usr.sbin/iscsid/login.c

Modified: head/usr.sbin/iscsid/iscsid.c
==============================================================================
--- head/usr.sbin/iscsid/iscsid.c	Sat Jan 14 20:29:26 2017	(r312194)
+++ head/usr.sbin/iscsid/iscsid.c	Sat Jan 14 20:41:44 2017	(r312195)
@@ -172,8 +172,10 @@ connection_new(int iscsi_fd, const struc
 	conn->conn_data_digest = CONN_DIGEST_NONE;
 	conn->conn_initial_r2t = true;
 	conn->conn_immediate_data = true;
-	conn->conn_max_burst_length = MAX_BURST_LENGTH;
-	conn->conn_first_burst_length = FIRST_BURST_LENGTH;
+	conn->conn_max_recv_data_segment_length = 8192;
+	conn->conn_max_send_data_segment_length = 8192;
+	conn->conn_max_burst_length = 262144;
+	conn->conn_first_burst_length = 65536;
 	conn->conn_iscsi_fd = iscsi_fd;
 
 	conn->conn_session_id = request->idr_session_id;
@@ -190,31 +192,28 @@ connection_new(int iscsi_fd, const struc
 	 */
 	isl = &conn->conn_limits;
 	memcpy(isl, &request->idr_limits, sizeof(*isl));
-	if (isl->isl_max_recv_data_segment_length == 0) {
-		conn->conn_max_recv_data_segment_length = 8192;
-		conn->conn_max_send_data_segment_length = 8192;
-		isl->isl_max_recv_data_segment_length = 8192;
-	} else {
-		conn->conn_max_recv_data_segment_length =
-		    isl->isl_max_recv_data_segment_length;
-		conn->conn_max_send_data_segment_length =
-		    isl->isl_max_recv_data_segment_length;
-	}
-	if (isl->isl_max_send_data_segment_length == 0) {
+	if (isl->isl_max_recv_data_segment_length == 0)
+		isl->isl_max_recv_data_segment_length = (1 << 24) - 1;
+	if (isl->isl_max_send_data_segment_length == 0)
 		isl->isl_max_send_data_segment_length =
 		    isl->isl_max_recv_data_segment_length;
-	} else {
+	if (isl->isl_max_burst_length == 0)
+		isl->isl_max_burst_length = (1 << 24) - 1;
+	if (isl->isl_first_burst_length == 0)
+		isl->isl_first_burst_length = (1 << 24) - 1;
+	if (isl->isl_first_burst_length > isl->isl_max_burst_length)
+		isl->isl_first_burst_length = isl->isl_max_burst_length;
+
+	/*
+	 * Limit default send length in case it won't be negotiated.
+	 * We can't do it for other limits, since they may affect both
+	 * sender and receiver operation, and we must obey defaults.
+	 */
+	if (conn->conn_max_send_data_segment_length >
+	    isl->isl_max_send_data_segment_length) {
 		conn->conn_max_send_data_segment_length =
 		    isl->isl_max_send_data_segment_length;
 	}
-	if (isl->isl_max_burst_length == 0)
-		isl->isl_max_burst_length = conn->conn_max_burst_length;
-	if (isl->isl_first_burst_length == 0) {
-		if (isl->isl_max_burst_length < (int)conn->conn_first_burst_length)
-			isl->isl_first_burst_length = isl->isl_max_burst_length;
-		else
-			isl->isl_first_burst_length = conn->conn_first_burst_length;
-	}
 
 	from_addr = conn->conn_conf.isc_initiator_addr;
 	to_addr = conn->conn_conf.isc_target_addr;

Modified: head/usr.sbin/iscsid/iscsid.h
==============================================================================
--- head/usr.sbin/iscsid/iscsid.h	Sat Jan 14 20:29:26 2017	(r312194)
+++ head/usr.sbin/iscsid/iscsid.h	Sat Jan 14 20:41:44 2017	(r312195)
@@ -44,8 +44,6 @@
 
 #define	CONN_MUTUAL_CHALLENGE_LEN	1024
 #define	SOCKBUF_SIZE			1048576
-#define	MAX_BURST_LENGTH		(256 * 1024)
-#define	FIRST_BURST_LENGTH		(128 * 1024)
 
 struct connection {
 	int			conn_iscsi_fd;

Modified: head/usr.sbin/iscsid/login.c
==============================================================================
--- head/usr.sbin/iscsid/login.c	Sat Jan 14 20:29:26 2017	(r312194)
+++ head/usr.sbin/iscsid/login.c	Sat Jan 14 20:41:44 2017	(r312195)
@@ -397,6 +397,9 @@ login_negotiate_key(struct connection *c
 			tmp = isl->isl_max_send_data_segment_length;
 		}
 		conn->conn_max_send_data_segment_length = tmp;
+		/* We received target's limit, that means it accepted our's. */
+		conn->conn_max_recv_data_segment_length =
+		    isl->isl_max_recv_data_segment_length;
 	} else if (strcmp(name, "MaxBurstLength") == 0) {
 		tmp = strtoul(value, NULL, 10);
 		if (tmp <= 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701142041.v0EKfjg1054733>