linux/drivers/s390/scsi
Steffen Maier ef4021fe5f scsi: zfcp: fix to prevent port_remove with pure auto scan LUNs (only sdevs)
When the user tries to remove a zfcp port via sysfs, we only rejected it if
there are zfcp unit children under the port. With purely automatically
scanned LUNs there are no zfcp units but only SCSI devices. In such cases,
the port_remove erroneously continued. We close the port and this
implicitly closes all LUNs under the port. The SCSI devices survive with
their private zfcp_scsi_dev still holding a reference to the "removed"
zfcp_port (still allocated but invisible in sysfs) [zfcp_get_port_by_wwpn
in zfcp_scsi_slave_alloc]. This is not a problem as long as the fc_rport
stays blocked. Once (auto) port scan brings back the removed port, we
unblock its fc_rport again by design.  However, there is no mechanism that
would recover (open) the LUNs under the port (no "ersfs_3" without
zfcp_unit [zfcp_erp_strategy_followup_success]).  Any pending or new I/O to
such LUN leads to repeated:

  Done: NEEDS_RETRY Result: hostbyte=DID_IMM_RETRY driverbyte=DRIVER_OK

See also v4.10 commit 6f2ce1c6af ("scsi: zfcp: fix rport unblock race
with LUN recovery"). Even a manual LUN recovery
(echo 0 > /sys/bus/scsi/devices/H:C:T:L/zfcp_failed)
does not help, as the LUN links to the old "removed" port which remains
to lack ZFCP_STATUS_COMMON_RUNNING [zfcp_erp_required_act].
The only workaround is to first ensure that the fc_rport is blocked
(e.g. port_remove again in case it was re-discovered by (auto) port scan),
then delete the SCSI devices, and finally re-discover by (auto) port scan.
The port scan includes an fc_rport unblock, which in turn triggers
a new scan on the scsi target to freshly get new pure auto scan LUNs.

Fix this by rejecting port_remove also if there are SCSI devices
(even without any zfcp_unit) under this port. Re-use mechanics from v3.7
commit d99b601b63 ("[SCSI] zfcp: restore refcount check on port_remove").
However, we have to give up zfcp_sysfs_port_units_mutex earlier in unit_add
to prevent a deadlock with scsi_host scan taking shost->scan_mutex first
and then zfcp_sysfs_port_units_mutex now in our zfcp_scsi_slave_alloc().

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Fixes: b62a8d9b45 ("[SCSI] zfcp: Use SCSI device data zfcp scsi dev instead of zfcp unit")
Fixes: f8210e3488 ("[SCSI] zfcp: Allow midlayer to scan for LUNs when running in NPIV mode")
Cc: <stable@vger.kernel.org> #2.6.37+
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-05-29 21:52:31 -04:00
..
Makefile s390: add a few more SPDX identifiers 2017-12-05 07:51:09 +01:00
zfcp_aux.c scsi: zfcp: fix sysfs block queue limit output for max_segment_size 2019-01-29 01:14:59 -05:00
zfcp_ccw.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
zfcp_dbf.c scsi: zfcp: silence all W=1 build warnings for existing kdoc 2018-11-15 15:01:18 -05:00
zfcp_dbf.h scsi: zfcp: silence remaining kdoc warnings in header files 2018-11-15 15:01:18 -05:00
zfcp_def.h scsi: zfcp: use enum zfcp_erp_steps for struct zfcp_erp_action.step 2018-11-15 15:01:18 -05:00
zfcp_erp.c scsi: zfcp: fix scsi_eh host reset with port_forced ERP for non-NPIV FCP devices 2019-03-27 21:26:12 -04:00
zfcp_ext.h scsi: zfcp: fix to prevent port_remove with pure auto scan LUNs (only sdevs) 2019-05-29 21:52:31 -04:00
zfcp_fc.c scsi: zfcp: reduce flood of fcrscn1 trace records on multi-element RSCN 2019-03-27 21:26:12 -04:00
zfcp_fc.h scsi: zfcp: silence remaining kdoc warnings in header files 2018-11-15 15:01:18 -05:00
zfcp_fsf.c scsi: zfcp: silence all W=1 build warnings for existing kdoc 2018-11-15 15:01:18 -05:00
zfcp_fsf.h scsi: zfcp: silence remaining kdoc warnings in header files 2018-11-15 15:01:18 -05:00
zfcp_qdio.c s390/qdio: make SBAL address array type-safe 2019-02-07 11:57:07 +01:00
zfcp_qdio.h scsi: zfcp: silence remaining kdoc warnings in header files 2018-11-15 15:01:18 -05:00
zfcp_reqlist.h scsi: zfcp: silence remaining kdoc warnings in header files 2018-11-15 15:01:18 -05:00
zfcp_scsi.c scsi: zfcp: fix to prevent port_remove with pure auto scan LUNs (only sdevs) 2019-05-29 21:52:31 -04:00
zfcp_sysfs.c scsi: zfcp: fix to prevent port_remove with pure auto scan LUNs (only sdevs) 2019-05-29 21:52:31 -04:00
zfcp_unit.c scsi: zfcp: fix to prevent port_remove with pure auto scan LUNs (only sdevs) 2019-05-29 21:52:31 -04:00