WSL2-Linux-Kernel/drivers/scsi
Mike Christie 4edd8cd4e8 scsi: core: sysfs: Fix hang when device state is set via sysfs
This fixes a regression added with:

commit f0f82e2476 ("scsi: core: Fix capacity set to zero after
offlinining device")

The problem is that after iSCSI recovery, iscsid will call into the kernel
to set the dev's state to running, and with that patch we now call
scsi_rescan_device() with the state_mutex held. If the SCSI error handler
thread is just starting to test the device in scsi_send_eh_cmnd() then it's
going to try to grab the state_mutex.

We are then stuck, because when scsi_rescan_device() tries to send its I/O
scsi_queue_rq() calls -> scsi_host_queue_ready() -> scsi_host_in_recovery()
which will return true (the host state is still in recovery) and I/O will
just be requeued. scsi_send_eh_cmnd() will then never be able to grab the
state_mutex to finish error handling.

To prevent the deadlock move the rescan-related code to after we drop the
state_mutex.

This also adds a check for if we are already in the running state. This
prevents extra scans and helps the iscsid case where if the transport class
has already onlined the device during its recovery process then we don't
need userspace to do it again plus possibly block that daemon.

Link: https://lore.kernel.org/r/20211105221048.6541-3-michael.christie@oracle.com
Fixes: f0f82e2476 ("scsi: core: Fix capacity set to zero after offlinining device")
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: lijinlin <lijinlin3@huawei.com>
Cc: Wu Bo <wubo40@huawei.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Wu Bo <wubo40@huawei.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-11-16 19:42:30 -05:00
..
aacraid scsi: aacraid: Switch to attribute groups 2021-10-16 21:45:54 -04:00
aic7xxx scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
aic94xx treewide: Replace open-coded flex arrays in unions 2021-10-18 12:28:53 -07:00
arcmsr scsi: arcmsr: Switch to attribute groups 2021-10-16 21:45:54 -04:00
arm scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
be2iscsi scsi: be2iscsi: Switch to attribute groups 2021-10-16 21:45:54 -04:00
bfa scsi: bfa: Switch to attribute groups 2021-10-16 21:45:54 -04:00
bnx2fc scsi: bnx2fc: Switch to attribute groups 2021-10-16 21:45:54 -04:00
bnx2i scsi: bnx2i: Switch to attribute groups 2021-10-16 21:45:55 -04:00
csiostor scsi: csiostor: Switch to attribute groups 2021-10-16 21:45:55 -04:00
cxgbi ethernet: fix PTP_1588_CLOCK dependencies 2021-08-13 17:49:05 -07:00
cxlflash scsi: cxlflash: Switch to attribute groups 2021-10-16 21:45:55 -04:00
device_handler scsi: scsi_dh_rdac: Avoid crash during rdac_bus_attach() 2021-07-29 21:58:35 -04:00
dpt
elx scsi: elx: Use 'bitmap_zalloc()' when applicable 2021-10-26 23:28:33 -04:00
esas2r scsi: esas2r: Call scsi_done() directly 2021-10-16 21:28:46 -04:00
fcoe scsi: fcoe: Use netif_is_bond_master() instead of open code 2021-10-18 22:38:34 -04:00
fnic scsi: fnic: Switch to attribute groups 2021-10-16 21:45:55 -04:00
hisi_sas SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
ibmvscsi SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
ibmvscsi_tgt scsi: target: ibm_vscsi: Replace enable attr with ops.enable 2021-10-04 23:27:38 -04:00
isci scsi: isci: Switch to attribute groups 2021-10-16 21:45:56 -04:00
libfc scsi: libfc: Call scsi_done() directly 2021-10-16 21:28:48 -04:00
libsas scsi: libsas: Call scsi_done() directly 2021-10-16 21:28:48 -04:00
lpfc SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
megaraid scsi: megaraid_sas: Switch to attribute groups 2021-10-16 21:45:57 -04:00
mpi3mr SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
mpt3sas SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
mvsas scsi: mvsas: Switch to attribute groups 2021-10-16 21:45:57 -04:00
pcmcia scsi: sym53c500_cs: Switch to attribute groups 2021-10-16 21:45:57 -04:00
pm8001 scsi: pm8001: Switch to attribute groups 2021-10-16 21:45:58 -04:00
qedf SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
qedi SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
qla2xxx SCSI misc on 20211112 2021-11-12 12:25:50 -08:00
qla4xxx SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
smartpqi scsi: smartpqi: Switch to attribute groups 2021-10-16 21:45:59 -04:00
snic scsi: snic: Switch to attribute groups 2021-10-16 21:45:59 -04:00
sym53c8xx_2 scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
ufs scsi: ufs: core: Improve SCSI abort handling 2021-11-16 19:42:29 -05:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
3w-9xxx.c scsi: 3w-9xxx: Switch to attribute groups 2021-10-16 21:45:53 -04:00
3w-9xxx.h scsi: 3w-9xxx: Fix endianness issues in command packets 2021-05-15 18:01:34 -04:00
3w-sas.c scsi: 3w-sas: Switch to attribute groups 2021-10-16 21:45:53 -04:00
3w-sas.h scsi: 3w-sas: Whitespace cleanup 2021-01-22 21:14:08 -05:00
3w-xxxx.c scsi: 3w-xxx: Remove redundant initialization of variable retval 2021-10-18 22:38:34 -04:00
3w-xxxx.h scsi: 3w-xxxx: Whitespace cleanup 2021-01-22 21:14:07 -05:00
53c700.c scsi: 53c700: Switch to attribute groups 2021-10-16 21:45:54 -04:00
53c700.h treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
53c700.scr
53c700_d.h_shipped
BusLogic.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
BusLogic.h scsi: BusLogic: Fix 64-bit system enumeration error for Buslogic 2021-05-14 22:19:04 -04:00
FlashPoint.c Merge branch '5.14/scsi-result' into 5.14/scsi-staging 2021-06-02 01:37:04 -04:00
Kconfig scsi: core: Rename CONFIG_BLK_SCSI_REQUEST to CONFIG_SCSI_COMMON 2021-07-28 22:24:27 -04:00
Makefile scsi: core: Fix missing FORCE for scsi_devinfo_tbl.c build rule 2021-08-23 23:07:05 -04:00
NCR5380.c scsi: NCR5380: Call scsi_done() directly 2021-10-16 21:28:44 -04:00
NCR5380.h scsi: NCR5380: Remove context check 2020-12-07 20:24:09 -05:00
a100u2w.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
a100u2w.h
a2091.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
a2091.h
a3000.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
a3000.h
a4000t.c
advansys.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
aha152x.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
aha152x.h
aha1542.c scsi: aha1542: Use memcpy_{from,to}_bvec() 2021-10-19 14:07:19 -04:00
aha1542.h scsi: aha1542: Clarify 'struct ccb' comments 2021-01-13 00:14:07 -05:00
aha1740.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
aha1740.h
am53c974.c
atari_scsi.c scsi: atari_scsi: Fix race condition between .queuecommand and EH 2020-11-23 22:12:09 -05:00
atp870u.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
atp870u.h scsi: atp870u: Whitespace cleanup 2021-01-22 21:14:08 -05:00
bvme6000_scsi.c
ch.c scsi: scsi_ioctl: Call scsi_cmd_ioctl() from scsi_ioctl() 2021-07-28 22:24:25 -04:00
constants.c scsi: core: Introduce enums for the SAM and host status codes 2021-06-02 23:09:39 -04:00
dc395x.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
dc395x.h scsi: dc395x: Drop internal SCSI message definitions 2021-01-22 21:14:10 -05:00
dmx3191d.c
dpt_i2o.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
dpti.h
esp_scsi.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
esp_scsi.h
fdomain.c scsi: fdomain: Call scsi_done() directly 2021-10-16 21:28:47 -04:00
fdomain.h scsi: fdomain: Mark 'fdomain_pm_ops' as __maybe_unused 2020-07-08 01:12:44 -04:00
fdomain_isa.c isa: Make the remove callback for isa drivers return void 2021-01-26 07:42:27 +01:00
fdomain_pci.c
g_NCR5380.c isa: Make the remove callback for isa drivers return void 2021-01-26 07:42:27 +01:00
gvp11.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
gvp11.h
hosts.c SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
hpsa.c scsi: hpsa: Switch to attribute groups 2021-10-16 21:45:55 -04:00
hpsa.h scsi: hpsa: Update copyright 2020-09-02 22:49:06 -04:00
hpsa_cmd.h scsi: hpsa: Add an assert to prevent __packed reintroduction 2021-04-01 22:52:40 -04:00
hptiop.c scsi: hptiop: Switch to attribute groups 2021-10-16 21:45:55 -04:00
hptiop.h
imm.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
imm.h
initio.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
initio.h scsi: initio: Drop internal SCSI message definition 2021-01-22 21:14:10 -05:00
ipr.c scsi: ipr: Switch to attribute groups 2021-10-16 21:45:56 -04:00
ipr.h scsi: ipr: System crashes when seeing type 20 error 2021-06-29 16:46:08 -04:00
ips.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
ips.h treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
iscsi_boot_sysfs.c scsi: iscsi: Fix reference count leak in iscsi_boot_create_kobj 2020-06-02 21:23:47 -04:00
iscsi_tcp.c scsi: iscsi: iscsi_tcp: Start socket shutdown during conn stop 2021-06-02 01:28:20 -04:00
iscsi_tcp.h
jazz_esp.c scsi: jazz_esp: Add IRQ check 2021-04-13 00:20:48 -04:00
lasi700.c parisc: Make struct parisc_driver::remove() return void 2021-08-30 10:18:25 +02:00
libiscsi.c scsi: libiscsi: Call scsi_done() directly 2021-10-16 21:28:48 -04:00
libiscsi_tcp.c scsi: libiscsi: Drop taskqueuelock 2021-02-08 22:39:03 -05:00
mac53c94.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
mac53c94.h
mac_esp.c scsi: mac_esp: Use module_platform_driver to simplify the code 2020-10-02 21:52:53 -04:00
mac_scsi.c scsi: NCR5380: Remove context check 2020-12-07 20:24:09 -05:00
megaraid.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
megaraid.h
mesh.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
mesh.h
mvme16x_scsi.c
mvme147.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
mvme147.h
mvumi.c scsi: mvumi: Call scsi_done() directly 2021-10-16 21:29:15 -04:00
mvumi.h
myrb.c scsi: myrb: Switch to attribute groups 2021-10-16 21:45:57 -04:00
myrb.h
myrs.c scsi: myrs: Switch to attribute groups 2021-10-16 21:45:57 -04:00
myrs.h
ncr53c8xx.c scsi: ncr53c8xx: Switch to attribute groups 2021-10-16 21:45:57 -04:00
ncr53c8xx.h scsi: ncr53c8xx: Use SAM status values 2021-01-22 21:14:12 -05:00
nsp32.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
nsp32.h
nsp32_debug.c
nsp32_io.h
pmcraid.c scsi: pmcraid: Switch to attribute groups 2021-10-16 21:45:58 -04:00
pmcraid.h scsi: pmcraid: Fix typos 2021-05-21 16:59:33 -04:00
ppa.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
ppa.h
ps3rom.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
qla1280.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
qla1280.h
qlogicfas.c
qlogicfas408.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
qlogicfas408.h
qlogicpti.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
qlogicpti.h
raid_class.c
script_asm.pl
scsi.c SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
scsi.h
scsi_bsg.c block: remove blk_{get,put}_request 2021-10-29 06:50:52 -06:00
scsi_common.c scsi: core: Rename CONFIG_BLK_SCSI_REQUEST to CONFIG_SCSI_COMMON 2021-07-28 22:24:27 -04:00
scsi_debug.c SCSI misc on 20211112 2021-11-12 12:25:50 -08:00
scsi_debugfs.c scsi: remove the unchecked_isa_dma flag 2021-04-06 09:28:17 -06:00
scsi_debugfs.h
scsi_devinfo.c scsi: core: Add BLIST_IGN_MEDIA_CHANGE for Ultra HS-SD/MMC USB card readers 2021-07-21 23:49:02 -04:00
scsi_dh.c scsi: scsi_dh: Fix a typo 2021-03-24 23:03:43 -04:00
scsi_error.c SCSI misc on 20211112 2021-11-12 12:25:50 -08:00
scsi_ioctl.c SCSI misc on 20211112 2021-11-12 12:25:50 -08:00
scsi_lib.c SCSI misc on 20211112 2021-11-12 12:25:50 -08:00
scsi_lib_dma.c
scsi_logging.c scsi: core: Use scsi_cmd_to_rq() instead of scsi_cmnd.request 2021-08-11 22:25:37 -04:00
scsi_logging.h
scsi_netlink.c
scsi_pm.c scsi: core: pm: Only runtime resume if necessary 2021-10-16 21:08:39 -04:00
scsi_priv.h scsi: core: Remove two host template members that are no longer used 2021-10-16 21:45:59 -04:00
scsi_proc.c
scsi_sas_internal.h
scsi_scan.c SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
scsi_sysctl.c
scsi_sysfs.c scsi: core: sysfs: Fix hang when device state is set via sysfs 2021-11-16 19:42:30 -05:00
scsi_trace.c
scsi_transport_api.h
scsi_transport_fc.c scsi: scsi_transport_fc: Use scsi_cmd_to_rq() instead of scsi_cmnd.request 2021-08-11 22:25:37 -04:00
scsi_transport_iscsi.c scsi: iscsi: Unblock session then wake up error handler 2021-11-16 19:42:30 -05:00
scsi_transport_sas.c scsi: scsi_transport_sas: Add 22.5 Gbps link rate definitions 2021-10-19 14:07:19 -04:00
scsi_transport_spi.c scsi: scsi_transport_spi: Use scsi_cmd_to_rq() instead of scsi_cmnd.request 2021-08-11 22:25:37 -04:00
scsi_transport_srp.c scsi: scsi_transport_srp: Don't block target in SRP_PORT_LOST state 2021-04-05 23:14:53 -04:00
scsicam.c include: remove pagemap.h from blkdev.h 2021-05-06 19:24:11 -07:00
sd.c SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
sd.h scsi: sd: add concurrent positioning ranges support 2021-10-26 21:01:48 -06:00
sd_dif.c block: move integrity handling out of <linux/blkdev.h> 2021-10-18 06:17:02 -06:00
sd_zbc.c scsi: sd_zbc: Support disks with more than 2**32 logical blocks 2021-09-21 23:52:55 -04:00
sense_codes.h scsi: core: Update additional sense codes list 2020-09-15 20:28:06 -04:00
ses.c scsi: ses: Fix unsigned comparison with less than zero 2021-09-28 22:42:06 -04:00
sg.c block: remove blk_{get,put}_request 2021-10-29 06:50:52 -06:00
sgiwd93.c sgiwd93: convert to dma_alloc_noncoherent 2020-09-25 06:20:44 +02:00
sim710.c scsi: sim710: Remove unused variable 'err' from sim710_init() 2021-03-18 22:52:29 -04:00
sni_53c710.c treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
sr.c SCSI misc on 20211112 2021-11-12 12:25:50 -08:00
sr.h
sr_ioctl.c scsi: sr: Fix spelling mistake "does'nt" -> "doesn't" 2021-09-13 22:15:49 -04:00
sr_vendor.c
st.c block: remove blk_{get,put}_request 2021-10-29 06:50:52 -06:00
st.h st: do not allocate a gendisk 2021-08-23 12:54:30 -06:00
st_options.h
stex.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
storvsc_drv.c SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
sun3_scsi.c scsi: sun3_scsi: Use scsi_cmd_to_rq() instead of scsi_cmnd.request 2021-08-11 22:25:41 -04:00
sun3_scsi_vme.c
sun3x_esp.c scsi: sun3x_esp: Add IRQ check 2021-04-13 00:20:48 -04:00
sun_esp.c scsi: sun_esp: Use module_platform_driver to simplify the code 2020-10-02 21:52:55 -04:00
virtio_scsi.c SCSI misc on 20211105 2021-11-05 08:42:02 -07:00
vmw_pvscsi.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
vmw_pvscsi.h scsi: vmw_pvscsi: MAINTAINERS: Update maintainer 2021-03-04 17:21:25 -05:00
wd33c93.c scsi: core: Remove the 'done' argument from SCSI queuecommand_lck functions 2021-10-16 21:32:16 -04:00
wd33c93.h
wd719x.c scsi: wd719x: Call scsi_done() directly 2021-10-16 21:31:43 -04:00
wd719x.h
xen-scsifront.c scsi: xen-scsifront: Call scsi_done() directly 2021-10-16 21:31:43 -04:00
zalon.c parisc: Make struct parisc_driver::remove() return void 2021-08-30 10:18:25 +02:00
zorro7xx.c
zorro_esp.c mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00