Module Name:    src
Committed By:   mlelstv
Date:           Sun Jun  5 05:07:23 UTC 2016

Modified Files:
        src/sys/dev/iscsi: iscsi_globals.h iscsi_rcv.c

Log Message:
Fix serial number check and account for commands in flight to avoid
unnecessary recovery actions.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/iscsi/iscsi_globals.h
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/iscsi/iscsi_rcv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/iscsi/iscsi_globals.h
diff -u src/sys/dev/iscsi/iscsi_globals.h:1.17 src/sys/dev/iscsi/iscsi_globals.h:1.18
--- src/sys/dev/iscsi/iscsi_globals.h:1.17	Sun Jun  5 04:48:17 2016
+++ src/sys/dev/iscsi/iscsi_globals.h	Sun Jun  5 05:07:23 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_globals.h,v 1.17 2016/06/05 04:48:17 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_globals.h,v 1.18 2016/06/05 05:07:23 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@ effectively says "don't bother testing t
 now only in iscsi_send.c.
  */
 #define ISCSI_THROTTLING_ENABLED	1
-#define ISCSI_SERVER_TRUSTED	1
+#define ISCSI_SERVER_TRUSTED		0
 
 /*
    NOTE: CCBS_PER_SESSION must not exceed 256 due to the way the ITT

Index: src/sys/dev/iscsi/iscsi_rcv.c
diff -u src/sys/dev/iscsi/iscsi_rcv.c:1.14 src/sys/dev/iscsi/iscsi_rcv.c:1.15
--- src/sys/dev/iscsi/iscsi_rcv.c:1.14	Sun Jun  5 04:51:57 2016
+++ src/sys/dev/iscsi/iscsi_rcv.c	Sun Jun  5 05:07:23 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_rcv.c,v 1.14 2016/06/05 04:51:57 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_rcv.c,v 1.15 2016/06/05 05:07:23 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -376,7 +376,8 @@ check_CmdSN(connection_t *conn, uint32_t
 		DEBC(conn, 10,
 			("CheckCmdSN - CmdSN=%d, ExpCmdSn=%d, waiting=%p, flags=%x\n",
 			ccb->CmdSN, sn, ccb->pdu_waiting, ccb->flags));
-		if (ccb->pdu_waiting != NULL && ccb->CmdSN > sn &&
+		if (ccb->pdu_waiting != NULL &&
+			sn_a_lt_b(sn, ccb->CmdSN) &&
 			!(ccb->flags & CCBF_GOT_RSP)) {
 			DEBC(conn, 1, ("CheckCmdSN resending - CmdSN=%d, ExpCmdSn=%d\n",
 			               ccb->CmdSN, sn));
@@ -385,14 +386,24 @@ check_CmdSN(connection_t *conn, uint32_t
 
 			if (++ccb->num_timeouts > MAX_CCB_TIMEOUTS ||
 				ccb->total_tries > MAX_CCB_TRIES) {
-				handle_connection_error(conn, ISCSI_STATUS_TIMEOUT,
-					(ccb->total_tries <= MAX_CCB_TRIES) ? RECOVER_CONNECTION
-														: LOGOUT_CONNECTION);
+				handle_connection_error(conn,
+					ISCSI_STATUS_TIMEOUT,
+					(ccb->total_tries <= MAX_CCB_TRIES)
+						? RECOVER_CONNECTION
+						: LOGOUT_CONNECTION);
 				break;
 			} else {
 				resend_pdu(ccb);
 			}
 		}
+
+		/*
+		 * The target can respond to a NOP-In before subsequent
+		 * commands are processed. So our CmdSN can exceed the
+		 * returned ExpCmdSN by the number of commands that are
+		 * in flight. Adjust the expected value accordingly.
+		 */
+		sn++;
 	}
 }
 

Reply via email to