Author: ken
Date: Fri May 31 20:36:32 2019
New Revision: 348483
URL: https://svnweb.freebsd.org/changeset/base/348483

Log:
  MFC r348247:
    ------------------------------------------------------------------------
    r348247 | ken | 2019-05-24 13:58:29 -0400 (Fri, 24 May 2019) | 57 lines
  
    Fix FC-Tape bugs caused in part by r345008.
  
    The point of r345008 was to reset the Command Reference Number (CRN)
    in some situations where a device stayed in the topology, but had
    changed somehow.
  
    This can include moving from a switch connection to a direct
    connection or vice versa, or a device that temporarily goes away
    and comes back.  (e.g. moving to a different switch port)
  
    There were a couple of bugs in that change:
    - We were reporting that a device had not changed whenever the
      Establish Image Pair bit was not set.  That is not quite correct.
      Instead, if the Establish Image Pair bit stays the same (set or
      not), the device hasn't changed in that way.
  
    - We weren't setting PRLI Word0 in the port database when a new
      device arrived, so comparisons with the old value for the
      Establish Image Pair bit weren't really possible.  So, make sure
      PRLI Word0 is set in the port database for new devices.
  
    - We were resetting the CRN whenever the Establish Image Pair bit
      was set for a device, even when the device had stayed the same
      and the value of the bit hadn't changed.  Now, only reset the
      CRN for devices that have changed, not devices that sayed the
      same.
  
    The result of all of this was that if we had a single FC device on
    an FC port and it went away and came back, we would wind up
    correctly resetting the CRN.
  
    But, if we had multiple devices connected via a switch, and there
    was any change in one or more of those devices, all of the devices
    that stayed the same would also have their CRN values reset.
  
    The result, from a user standpoint, is that the tape drives, etc.
    would all start to time out commands and the initiator would send
    aborts.
  
    sys/dev/isp/isp.c:
        In isp_pdb_add_update(), look at whether the Establish
        Image Pair bit has changed as part of the check to
        determine whether a device is still the same.   This was
        causing erroneous change notifications.  Also, when
        creating a new port database entry, initialize the
        PRLI Word 0 values.
  
    sys/dev/isp/isp_freebsd.c:
        In isp_async(), in the changed/stayed case, instead of
        looking at the Establish Image Pair bit to determine
        whether to reset the CRN, look at the command value.
        (Changed vs. Stayed.)  Only reset the CRN for devices
        that have changed.
    ------------------------------------------------------------------------
  
  Sponsored by: Spectra Logic
  Approved by:  re (gjb)

Modified:
  stable/11/sys/dev/isp/isp.c
  stable/11/sys/dev/isp/isp_freebsd.c

Modified: stable/11/sys/dev/isp/isp.c
==============================================================================
--- stable/11/sys/dev/isp/isp.c Fri May 31 20:26:56 2019        (r348482)
+++ stable/11/sys/dev/isp/isp.c Fri May 31 20:36:32 2019        (r348483)
@@ -3249,7 +3249,8 @@ isp_pdb_add_update(ispsoftc_t *isp, int chan, isp_pdb_
                if (lp->portid == pdb->portid &&
                    lp->handle == pdb->handle &&
                    lp->prli_word3 == pdb->prli_word3 &&
-                   ((pdb->prli_word0 & PRLI_WD0_EST_IMAGE_PAIR) == 0)) {
+                   ((pdb->prli_word0 & PRLI_WD0_EST_IMAGE_PAIR) ==
+                    (lp->prli_word0 & PRLI_WD0_EST_IMAGE_PAIR))) {
                        if (lp->state != FC_PORTDB_STATE_NEW)
                                lp->state = FC_PORTDB_STATE_VALID;
                        isp_prt(isp, ISP_LOG_SANCFG,
@@ -3280,6 +3281,7 @@ isp_pdb_add_update(ispsoftc_t *isp, int chan, isp_pdb_
        lp->probational = 0;
        lp->state = FC_PORTDB_STATE_NEW;
        lp->portid = lp->new_portid = pdb->portid;
+       lp->prli_word0 = lp->new_prli_word0 = pdb->prli_word0;
        lp->prli_word3 = lp->new_prli_word3 = pdb->prli_word3;
        lp->handle = pdb->handle;
        lp->port_wwn = wwpn;

Modified: stable/11/sys/dev/isp/isp_freebsd.c
==============================================================================
--- stable/11/sys/dev/isp/isp_freebsd.c Fri May 31 20:26:56 2019        
(r348482)
+++ stable/11/sys/dev/isp/isp_freebsd.c Fri May 31 20:36:32 2019        
(r348483)
@@ -3787,7 +3787,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
                        xpt_async(AC_CONTRACT, fc->path, &ac);
                }
 
-               if ((lp->new_prli_word0 & PRLI_WD0_EST_IMAGE_PAIR) &&
+               if ((cmd == ISPASYNC_DEV_CHANGED) &&
                    (crn_reset_done == 0))
                        isp_fcp_reset_crn(isp, bus, tgt, /*tgt_set*/ 1);
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to