Module Name:    src
Committed By:   mlelstv
Date:           Sun Jun  5 14:00:13 UTC 2016

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

Log Message:
Don't resume throttled CCBs when connection is terminating, except for
those being actively waited for. Stop unthrottling when reaching MaxCmdSN
again.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 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_rcv.c
diff -u src/sys/dev/iscsi/iscsi_rcv.c:1.19 src/sys/dev/iscsi/iscsi_rcv.c:1.20
--- src/sys/dev/iscsi/iscsi_rcv.c:1.19	Sun Jun  5 11:01:39 2016
+++ src/sys/dev/iscsi/iscsi_rcv.c	Sun Jun  5 14:00:12 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_rcv.c,v 1.19 2016/06/05 11:01:39 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_rcv.c,v 1.20 2016/06/05 14:00:12 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -1148,6 +1148,7 @@ receive_pdu(connection_t *conn, pdu_t *p
 
 	if (sn_a_lt_b(sess->MaxCmdSN, MaxCmdSN)) {
 		sess->MaxCmdSN = MaxCmdSN;
+
 		if (TAILQ_FIRST(&sess->ccbs_throttled) == NULL) {
 			mutex_exit(&sess->lock);
 			return 0;
@@ -1157,24 +1158,39 @@ receive_pdu(connection_t *conn, pdu_t *p
 
 		TAILQ_INIT(&waiting);
 		while ((req_ccb = TAILQ_FIRST(&sess->ccbs_throttled)) != NULL) {
-			throttle_ccb(req_ccb, FALSE);
-			TAILQ_INSERT_TAIL(&waiting, req_ccb, chain);
+			if (!conn->terminating ||
+			    (req_ccb->flags & CCBF_WAITING) != 0) {
+				throttle_ccb(req_ccb, FALSE);
+				TAILQ_INSERT_TAIL(&waiting, req_ccb, chain);
+			}
 		}
-		mutex_exit(&sess->lock);
 
 		while ((req_ccb = TAILQ_FIRST(&waiting)) != NULL) {
+			if (!sernum_in_window(sess))
+				break;
+			mutex_exit(&sess->lock);
+
 			TAILQ_REMOVE(&waiting, req_ccb, chain);
 
 			DEBC(conn, 10, ("Unthrottling - ccb = %p, disp = %d\n",
 					req_ccb, req_ccb->disp));
 
-			if (req_ccb->flags & CCBF_WAITING) {
+			if ((req_ccb->flags & CCBF_WAITING) != 0) {
 				cv_broadcast(&conn->ccb_cv);
-			} else
+			} else {
 				send_command(req_ccb, req_ccb->disp, FALSE, FALSE);
+			}
+
+			mutex_enter(&sess->lock);
 		}
-	} else
-		mutex_exit(&sess->lock);
+
+		while ((req_ccb = TAILQ_FIRST(&waiting)) != NULL) {
+			TAILQ_REMOVE(&waiting, req_ccb, chain);
+			throttle_ccb(req_ccb, TRUE);
+		}
+	}
+
+	mutex_exit(&sess->lock);
 
 	return 0;
 }

Reply via email to