linux_dsm_epyc7002/drivers/scsi
Li Jinlin 3e4963bf13 scsi: core: Fix hang of freezing queue between blocking and running device
commit 02c6dcd543f8f051973ee18bfbc4dc3bd595c558 upstream.

We found a hang, the steps to reproduce  are as follows:

  1. blocking device via scsi_device_set_state()

  2. dd if=/dev/sda of=/mnt/t.log bs=1M count=10

  3. echo none > /sys/block/sda/queue/scheduler

  4. echo "running" >/sys/block/sda/device/state

Step 3 and 4 should complete after step 4, but they hang.

  CPU#0               CPU#1                CPU#2
  ---------------     ----------------     ----------------
                                           Step 1: blocking device

                                           Step 2: dd xxxx
                                                  ^^^^^^ get request
                                                         q_usage_counter++

                      Step 3: switching scheculer
                      elv_iosched_store
                        elevator_switch
                          blk_mq_freeze_queue
                            blk_freeze_queue
                              > blk_freeze_queue_start
                                ^^^^^^ mq_freeze_depth++

                              > blk_mq_run_hw_queues
                                ^^^^^^ can't run queue when dev blocked

                              > blk_mq_freeze_queue_wait
                                ^^^^^^ Hang here!!!
                                       wait q_usage_counter==0

  Step 4: running device
  store_state_field
    scsi_rescan_device
      scsi_attach_vpd
        scsi_vpd_inquiry
          __scsi_execute
            blk_get_request
              blk_mq_alloc_request
                blk_queue_enter
                ^^^^^^ Hang here!!!
                       wait mq_freeze_depth==0

    blk_mq_run_hw_queues
    ^^^^^^ dispatch IO, q_usage_counter will reduce to zero

                            blk_mq_unfreeze_queue
                            ^^^^^ mq_freeze_depth--

To fix this, we need to run queue before rescanning device when the device
state changes to SDEV_RUNNING.

Link: https://lore.kernel.org/r/20210824025921.3277629-1-lijinlin3@huawei.com
Fixes: f0f82e2476f6 ("scsi: core: Fix capacity set to zero after offlinining device")
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
Signed-off-by: Qiu Laibin <qiulaibin@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-07-05 18:57:30 +02:00
..
aacraid
aic7xxx scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8 2021-07-25 14:36:16 +02:00
aic94xx scsi: libsas: Add LUN number check in .slave_alloc callback 2021-07-25 14:36:16 +02:00
arcmsr scsi: arcmsr: Fix doorbell status being updated late on ARC-1886 2021-07-20 16:05:39 +02:00
arm
be2iscsi init: add dsm gpl source 2024-07-05 18:00:04 +02:00
bfa
bnx2fc scsi: bnx2fc: Return failure if io_req is already in ABTS processing 2021-06-16 12:01:36 +02:00
bnx2i init: add dsm gpl source 2024-07-05 18:00:04 +02:00
csiostor
cxgbi init: add dsm gpl source 2024-07-05 18:00:04 +02:00
cxlflash
device_handler scsi: scsi_dh_rdac: Avoid crash during rdac_bus_attach() 2024-07-05 18:55:31 +02:00
dpt
esas2r
fcoe
fnic
hisi_sas scsi: libsas: Add LUN number check in .slave_alloc callback 2021-07-25 14:36:16 +02:00
ibmvscsi
ibmvscsi_tgt
isci scsi: libsas: Add LUN number check in .slave_alloc callback 2021-07-25 14:36:16 +02:00
libfc scsi: libfc: Fix array index out of bound exception 2021-07-25 14:36:16 +02:00
libsas scsi: libsas: Add LUN number check in .slave_alloc callback 2021-07-25 14:36:16 +02:00
lpfc scsi: lpfc: Move initialization of phba->poll_list earlier to avoid crash 2024-07-05 18:53:59 +02:00
megaraid scsi: megaraid_mm: Fix end of loop tests for list_for_each_entry() 2024-07-05 18:55:31 +02:00
mpt3sas scsi: mpt3sas: Fix deadlock while cancelling the running firmware event 2021-07-20 16:05:40 +02:00
mvsas scsi: libsas: Add LUN number check in .slave_alloc callback 2021-07-25 14:36:16 +02:00
pcmcia
pm8001 scsi: pm80xx: Fix TMF task completion race condition 2024-07-05 18:55:31 +02:00
qedf scsi: qedf: Add check to synchronize abort and flush 2021-07-25 14:36:16 +02:00
qedi init: add dsm gpl source 2024-07-05 18:00:04 +02:00
qla2xxx scsi: target: qla2xxx: Wait for stop_phase1 at WWN removal 2021-06-16 12:01:37 +02:00
qla4xxx init: add dsm gpl source 2024-07-05 18:00:04 +02:00
smartpqi
snic
sym53c8xx_2
ufs scsi: ufs: ufs-mediatek: Fix power down spec violation 2021-06-03 09:00:43 +02:00
.gitignore
3w-9xxx.c
3w-9xxx.h
3w-sas.c
3w-sas.h
3w-xxxx.c
3w-xxxx.h
53c700_d.h_shipped
53c700.c
53c700.h
53c700.scr
a100u2w.c
a100u2w.h
a2091.c
a2091.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
a3000.c
a3000.h
a4000t.c
advansys.c scsi: advansys: Replace zero-length array with flexible-array member 2020-02-18 00:39:54 -05:00
aha152x.c
aha152x.h
aha1542.c
aha1542.h
aha1740.c
aha1740.h
am53c974.c
atari_scsi.c
atp870u.c
atp870u.h
BusLogic.c scsi: BusLogic: Fix 64-bit system enumeration error for Buslogic 2021-06-03 09:00:43 +02:00
BusLogic.h scsi: BusLogic: Fix 64-bit system enumeration error for Buslogic 2021-06-03 09:00:43 +02:00
bvme6000_scsi.c
ch.c scsi: ch: remove ch_mutex() 2020-02-24 14:54:25 -05:00
constants.c
dc395x.c
dc395x.h
dmx3191d.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
dpt_i2o.c
dpti.h
esp_scsi.c
esp_scsi.h
fdomain_isa.c
fdomain_pci.c
fdomain.c
fdomain.h
FlashPoint.c scsi: FlashPoint: Rename si_flags field 2021-07-14 16:56:40 +02:00
g_NCR5380.c
gdth_ioctl.h
gdth_proc.c
gdth_proc.h
gdth.c
gdth.h
gvp11.c
gvp11.h
hosts.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
hpsa_cmd.h
hpsa.c
hpsa.h
hptiop.c
hptiop.h
imm.c
imm.h
initio.c
initio.h
ipr.c
ipr.h
ips.c
ips.h
iscsi_boot_sysfs.c
iscsi_tcp.c
iscsi_tcp.h
jazz_esp.c
Kconfig
lasi700.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
libiscsi_tcp.c
libiscsi.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
libsyno_report.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
libsyno_report.h init: add dsm gpl source 2024-07-05 18:00:04 +02:00
mac53c94.c
mac53c94.h
mac_esp.c
mac_scsi.c
Makefile init: add dsm gpl source 2024-07-05 18:00:04 +02:00
megaraid.c
megaraid.h
mesh.c
mesh.h
mvme16x_scsi.c
mvme147.c
mvme147.h
mvumi.c
mvumi.h
myrb.c
myrb.h
myrs.c
myrs.h
ncr53c8xx.c
ncr53c8xx.h
NCR5380.c
NCR5380.h
nsp32_debug.c
nsp32_io.h
nsp32.c
nsp32.h
pmcraid.c
pmcraid.h
ppa.c
ppa.h
ps3rom.c
qla1280.c
qla1280.h
qlogicfas408.c
qlogicfas408.h
qlogicfas.c
qlogicpti.c
qlogicpti.h
raid_class.c
script_asm.pl
scsi_common.c
scsi_debug.c
scsi_debugfs.c
scsi_debugfs.h
scsi_devinfo.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
scsi_dh.c
scsi_error.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
scsi_ioctl.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
scsi_lib_dma.c
scsi_lib.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
scsi_logging.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
scsi_logging.h
scsi_netlink.c
scsi_pm.c
scsi_priv.h
scsi_proc.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
scsi_sas_internal.h
scsi_scan.c scsi: core: Avoid printing an error if target_alloc() returns -ENXIO 2024-07-05 18:55:31 +02:00
scsi_sysctl.c
scsi_sysfs.c scsi: core: Fix hang of freezing queue between blocking and running device 2024-07-05 18:57:30 +02:00
scsi_trace.c
scsi_transport_api.h
scsi_transport_fc.c
scsi_transport_iscsi.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
scsi_transport_sas.c scsi: core: Fixup calling convention for scsi_mode_sense() 2021-07-20 16:05:40 +02:00
scsi_transport_spi.c
scsi_transport_srp.c
scsi.c
scsi.h
scsicam.c
sd_dif.c
sd_zbc.c
sd.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
sd.h init: add dsm gpl source 2024-07-05 18:00:04 +02:00
sense_codes.h
ses.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
sg.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
sgiwd93.c
sim710.c
sni_53c710.c
sr_ioctl.c
sr_vendor.c
sr.c scsi: sr: Return correct event when media event code is 3 2024-07-05 18:51:28 +02:00
sr.h
st_options.h
st.c
st.h
stex.c
storvsc_drv.c scsi: storvsc: Correctly handle multiple flags in srb_status 2021-07-20 16:05:43 +02:00
sun3_scsi_vme.c
sun3_scsi.c
sun3x_esp.c
sun_esp.c
virtio_scsi.c init: add dsm gpl source 2024-07-05 18:00:04 +02:00
vmw_pvscsi.c scsi: vmw_pvscsi: Set correct residual data length 2021-06-16 12:01:37 +02:00
vmw_pvscsi.h
wd33c93.c
wd33c93.h
wd719x.c
wd719x.h
xen-scsifront.c
zalon.c
zorro7xx.c
zorro_esp.c