Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 May 2019 17:58:29 +0000 (UTC)
From:      "Kenneth D. Merry" <ken@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r348247 - head/sys/dev/isp
Message-ID:  <201905241758.x4OHwTQj025936@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ken
Date: Fri May 24 17:58:29 2019
New Revision: 348247
URL: https://svnweb.freebsd.org/changeset/base/348247

Log:
  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
  MFC after:	3 days

Modified:
  head/sys/dev/isp/isp.c
  head/sys/dev/isp/isp_freebsd.c

Modified: head/sys/dev/isp/isp.c
==============================================================================
--- head/sys/dev/isp/isp.c	Fri May 24 17:19:06 2019	(r348246)
+++ head/sys/dev/isp/isp.c	Fri May 24 17:58:29 2019	(r348247)
@@ -3251,7 +3251,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,
@@ -3282,6 +3283,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: head/sys/dev/isp/isp_freebsd.c
==============================================================================
--- head/sys/dev/isp/isp_freebsd.c	Fri May 24 17:19:06 2019	(r348246)
+++ head/sys/dev/isp/isp_freebsd.c	Fri May 24 17:58:29 2019	(r348247)
@@ -3789,7 +3789,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);
 



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