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
This commit is contained in:
Kenneth D. Merry 2019-05-24 17:58:29 +00:00
parent a9c7546a1d
commit e26059ca18
2 changed files with 4 additions and 2 deletions

View File

@ -3251,7 +3251,8 @@ isp_pdb_add_update(ispsoftc_t *isp, int chan, isp_pdb_t *pdb)
if (lp->portid == pdb->portid && if (lp->portid == pdb->portid &&
lp->handle == pdb->handle && lp->handle == pdb->handle &&
lp->prli_word3 == pdb->prli_word3 && 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) if (lp->state != FC_PORTDB_STATE_NEW)
lp->state = FC_PORTDB_STATE_VALID; lp->state = FC_PORTDB_STATE_VALID;
isp_prt(isp, ISP_LOG_SANCFG, isp_prt(isp, ISP_LOG_SANCFG,
@ -3282,6 +3283,7 @@ isp_pdb_add_update(ispsoftc_t *isp, int chan, isp_pdb_t *pdb)
lp->probational = 0; lp->probational = 0;
lp->state = FC_PORTDB_STATE_NEW; lp->state = FC_PORTDB_STATE_NEW;
lp->portid = lp->new_portid = pdb->portid; 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->prli_word3 = lp->new_prli_word3 = pdb->prli_word3;
lp->handle = pdb->handle; lp->handle = pdb->handle;
lp->port_wwn = wwpn; lp->port_wwn = wwpn;

View File

@ -3789,7 +3789,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
xpt_async(AC_CONTRACT, fc->path, &ac); 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)) (crn_reset_done == 0))
isp_fcp_reset_crn(isp, bus, tgt, /*tgt_set*/ 1); isp_fcp_reset_crn(isp, bus, tgt, /*tgt_set*/ 1);