Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/iscsi Fix serial number check and account for comman...



details:   https://anonhg.NetBSD.org/src/rev/b0f084ac20a0
branches:  trunk
changeset: 345687:b0f084ac20a0
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Jun 05 05:07:23 2016 +0000

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

diffstat:

 sys/dev/iscsi/iscsi_globals.h |   4 ++--
 sys/dev/iscsi/iscsi_rcv.c     |  21 ++++++++++++++++-----
 2 files changed, 18 insertions(+), 7 deletions(-)

diffs (65 lines):

diff -r b2add7d583cd -r b0f084ac20a0 sys/dev/iscsi/iscsi_globals.h
--- a/sys/dev/iscsi/iscsi_globals.h     Sun Jun 05 04:53:22 2016 +0000
+++ b/sys/dev/iscsi/iscsi_globals.h     Sun Jun 05 05:07:23 2016 +0000
@@ -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 @@
 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
diff -r b2add7d583cd -r b0f084ac20a0 sys/dev/iscsi/iscsi_rcv.c
--- a/sys/dev/iscsi/iscsi_rcv.c Sun Jun 05 04:53:22 2016 +0000
+++ b/sys/dev/iscsi/iscsi_rcv.c Sun Jun 05 05:07:23 2016 +0000
@@ -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 @@
                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 @@
 
                        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++;
        }
 }
 



Home | Main Index | Thread Index | Old Index