linux/drivers/scsi
Bart Van Assche 3a0a529971 block, scsi: Make SCSI quiesce and resume work reliably
The contexts from which a SCSI device can be quiesced or resumed are:
* Writing into /sys/class/scsi_device/*/device/state.
* SCSI parallel (SPI) domain validation.
* The SCSI device power management methods. See also scsi_bus_pm_ops.

It is essential during suspend and resume that neither the filesystem
state nor the filesystem metadata in RAM changes. This is why while
the hibernation image is being written or restored that SCSI devices
are quiesced. The SCSI core quiesces devices through scsi_device_quiesce()
and scsi_device_resume(). In the SDEV_QUIESCE state execution of
non-preempt requests is deferred. This is realized by returning
BLKPREP_DEFER from inside scsi_prep_state_check() for quiesced SCSI
devices. Avoid that a full queue prevents power management requests
to be submitted by deferring allocation of non-preempt requests for
devices in the quiesced state. This patch has been tested by running
the following commands and by verifying that after each resume the
fio job was still running:

for ((i=0; i<10; i++)); do
  (
    cd /sys/block/md0/md &&
    while true; do
      [ "$(<sync_action)" = "idle" ] && echo check > sync_action
      sleep 1
    done
  ) &
  pids=($!)
  for d in /sys/class/block/sd*[a-z]; do
    bdev=${d#/sys/class/block/}
    hcil=$(readlink "$d/device")
    hcil=${hcil#../../../}
    echo 4 > "$d/queue/nr_requests"
    echo 1 > "/sys/class/scsi_device/$hcil/device/queue_depth"
    fio --name="$bdev" --filename="/dev/$bdev" --buffered=0 --bs=512 \
      --rw=randread --ioengine=libaio --numjobs=4 --iodepth=16       \
      --iodepth_batch=1 --thread --loops=$((2**31)) &
    pids+=($!)
  done
  sleep 1
  echo "$(date) Hibernating ..." >>hibernate-test-log.txt
  systemctl hibernate
  sleep 10
  kill "${pids[@]}"
  echo idle > /sys/block/md0/md/sync_action
  wait
  echo "$(date) Done." >>hibernate-test-log.txt
done

Reported-by: Oleksandr Natalenko <oleksandr@natalenko.name>
References: "I/O hangs after resuming from suspend-to-ram" (https://marc.info/?l=linux-block&m=150340235201348).
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Tested-by: Martin Steigerwald <martin@lichtvoll.de>
Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2017-11-10 19:53:25 -07:00
..
aacraid Merge branch 'fixes' into misc 2017-09-07 12:12:43 -07:00
aic7xxx scsi: aic7xxx: regenerate firmware files 2017-08-10 19:36:51 -04:00
aic94xx scsi: libsas: move bus_reset_handler() to target_reset_handler() 2017-08-25 17:21:10 -04:00
arcmsr arcmsr: add const to bin_attribute structures 2017-08-10 19:40:50 -04:00
arm scsi: acornscsi: fix build error 2017-09-14 21:02:03 -04:00
be2iscsi scsi: be2iscsi: Replace PCI pool old API 2017-08-07 14:04:01 -04:00
bfa scsi: bfa: move bus reset to target reset 2017-08-25 17:21:10 -04:00
bnx2fc Merge branch 'fixes' into misc 2017-09-07 12:12:43 -07:00
bnx2i scsi: bnx2i: Simplify cpu hotplug code 2017-07-26 21:51:25 -04:00
csiostor Merge branch 'fixes' into misc 2017-09-07 12:12:43 -07:00
cxgbi Merge branch 'fixes' into misc 2017-09-07 12:12:43 -07:00
cxlflash scsi: cxlflash: Fix vlun resize failure in the shrink path 2017-08-25 18:24:04 -04:00
device_handler scsi: scsi_dh_alua: remove synchronous STPG support 2017-06-26 12:44:35 -04:00
dpt sched/wait: Rename wait_queue_t => wait_queue_entry_t 2017-06-20 12:18:27 +02:00
esas2r scsi: esas2r: constify pci_device_id. 2017-08-24 22:28:52 -04:00
fcoe scsi: make device_type const 2017-08-25 17:29:29 -04:00
fnic scsi: fnic: do not call host reset from command abort 2017-08-25 17:21:10 -04:00
hisi_sas scsi: libsas: move bus_reset_handler() to target_reset_handler() 2017-08-25 17:21:10 -04:00
ibmvscsi scsi: ibmvfc: ibmvscsi: ibmvscsi_tgt: constify vio_device_id 2017-08-25 17:42:42 -04:00
ibmvscsi_tgt scsi: ibmvfc: ibmvscsi: ibmvscsi_tgt: constify vio_device_id 2017-08-25 17:42:42 -04:00
isci scsi: libsas: move bus_reset_handler() to target_reset_handler() 2017-08-25 17:21:10 -04:00
libfc scsi: fc_fcp: do not call fc_block_scsi_eh() from host reset 2017-08-25 17:21:10 -04:00
libsas scsi: scsi_transport_sas: switch to bsg-lib for SMP passthrough 2017-08-29 21:51:45 -04:00
lpfc lpfc: tie in to new dev_loss_tmo interface in nvme transport 2017-11-10 19:53:25 -07:00
megaraid Merge branch 'fixes' into misc 2017-09-07 12:12:43 -07:00
mpt3sas scsi: scsi_transport_sas: switch to bsg-lib for SMP passthrough 2017-08-29 21:51:45 -04:00
mvsas scsi: libsas: move bus_reset_handler() to target_reset_handler() 2017-08-25 17:21:10 -04:00
osd blk-map: call blk_queue_bounce from blk_rq_append_bio 2017-06-27 12:13:21 -06:00
pcmcia scsi: qlogicfas: move bus_reset to host_reset 2017-08-25 17:21:11 -04:00
pm8001 scsi: libsas: move bus_reset_handler() to target_reset_handler() 2017-08-25 17:21:10 -04:00
qedf Merge branch 'fixes' into misc 2017-09-07 12:12:43 -07:00
qedi Merge branch 'fixes' into misc 2017-09-07 12:12:43 -07:00
qla2xxx qla2xxx: remove use of FC-specific error codes 2017-09-25 08:56:05 -06:00
qla4xxx scsi: qla4xxx: fix spelling mistake: "Tempalate" -> "Template" 2017-04-26 18:34:34 -04:00
smartpqi scsi: smartpqi: remove the smp_handler stub 2017-08-29 21:51:44 -04:00
snic scsi: snic: fix a couple of spelling mistakes/typos 2017-07-01 17:13:56 -04:00
sym53c8xx_2 drivers/scsi/sym53c8xx_2/sym_hipd.c: convert to use memset32 2017-09-08 18:26:48 -07:00
ufs scsi: ufs: reqs and tasks were put in the wrong order 2017-08-24 22:29:45 -04:00
.gitignore
3w-9xxx.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
3w-9xxx.h scsi: Update 3ware driver email addresses 2016-12-14 15:25:12 -05:00
3w-sas.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
3w-sas.h scsi: Update 3ware driver email addresses 2016-12-14 15:25:12 -05:00
3w-xxxx.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
3w-xxxx.h scsi: Update 3ware driver email addresses 2016-12-14 15:25:12 -05:00
53c700_d.h_shipped
53c700.c scsi: 53c700: move bus reset to host reset 2017-08-25 17:21:11 -04:00
53c700.h scsi: remove current_cmnd field from struct scsi_device 2016-07-13 22:33:23 -04:00
53c700.scr
a100u2w.c scsi: a100u2w: trivial typo in printk 2015-08-07 15:03:42 +02:00
a100u2w.h
a2091.c scsi: drop bus reset for wd33c93-compatible boards 2017-08-25 17:21:10 -04:00
a2091.h
a3000.c scsi: drop bus reset for wd33c93-compatible boards 2017-08-25 17:21:10 -04:00
a3000.h
a4000t.c
advansys.c scsi: advansys: fix uninitialized data access 2017-04-04 19:39:39 -04:00
aha152x.c scsi: aha152x: drop host reset 2017-08-25 17:21:11 -04:00
aha152x.h
aha1542.c scsi: aha1542: constify pnp_device_id 2017-08-24 22:29:07 -04:00
aha1542.h aha1542: fix include guard and remove useless changelog 2015-04-09 18:08:31 -07:00
aha1740.c scsi: Do not set cmd_per_lun to 1 in the host template 2015-05-31 18:06:28 -07:00
aha1740.h scsi: Do not set cmd_per_lun to 1 in the host template 2015-05-31 18:06:28 -07:00
am53c974.c am53c974: Fix crash during modprobe 2015-04-17 10:13:56 -07:00
atari_scsi.c scsi: NCR5380: Move bus reset to host reset 2017-08-25 17:21:11 -04:00
atp870u.c atp870u: Introduce atp870_init() 2015-11-25 22:08:55 -05:00
atp870u.h atp870u: Remove scam_on from struct atp_unit 2015-11-25 22:08:52 -05:00
BusLogic.c scsi: BusLogic: fix incorrect spelling of adatper_reset_req 2017-04-21 10:31:33 -04:00
BusLogic.h scsi: BusLogic: fix incorrect spelling of adatper_reset_req 2017-04-21 10:31:33 -04:00
bvme6000_scsi.c
ch.c scsi: ch: add refcounting 2017-08-24 22:29:06 -04:00
constants.c scsi: fix upper bounds check of sense key in scsi_sense_key_string() 2016-08-16 00:49:32 -04:00
dc395x.c scsi: print single-character strings with seq_putc 2015-02-02 09:57:46 -08:00
dc395x.h
dmx3191d.c scsi: NCR5380: Move bus reset to host reset 2017-08-25 17:21:11 -04:00
dpt_i2o.c scsi: dpt_i2o: remove redundant null check on array device 2017-08-10 19:55:35 -04:00
dpti.h
eata_generic.h
eata_pio.c eata_pio: missing break statement 2016-05-10 22:01:07 -04:00
eata_pio.h
eata.c scsi: eata: remove 'arg_done' from eata2x_eh_host_reset() 2017-08-25 17:21:12 -04:00
esp_scsi.c scsi: esp_scsi: Always clear msg_out_len after MESSAGE OUT phase 2017-08-10 19:55:35 -04:00
esp_scsi.h scsi: esp_scsi: Clean up control flow and dead code 2017-08-10 19:55:34 -04:00
fdomain.c scsi: fdomain: move bus reset to host reset 2017-08-25 17:21:10 -04:00
fdomain.h scsi: fdomain: move bus reset to host reset 2017-08-25 17:21:10 -04:00
FlashPoint.c FlashPoint: fix build warning 2015-11-09 16:32:14 -08:00
g_NCR5380.c scsi: NCR5380: Move bus reset to host reset 2017-08-25 17:21:11 -04:00
gdth_ioctl.h
gdth_proc.c scsi: gdth: increase the procfs event buffer size 2017-08-07 14:04:02 -04:00
gdth_proc.h
gdth.c scsi: gdth: avoid buffer overflow warning 2017-08-07 14:04:01 -04:00
gdth.h
gvp11.c scsi: drop bus reset for wd33c93-compatible boards 2017-08-25 17:21:10 -04:00
gvp11.h
hosts.c scsi: Remove Scsi_Host.uspace_req_q 2017-09-05 08:18:42 -04:00
hpsa_cmd.h scsi: hpsa: update identify physical device structure 2017-06-12 20:48:00 -04:00
hpsa.c scsi: hpsa: remove the smp_handler stub 2017-08-29 21:51:44 -04:00
hpsa.h scsi: hpsa: add support for legacy boards 2017-08-24 22:28:55 -04:00
hptiop.c scsi: hptiop: Simplify reset handling 2017-08-25 17:21:10 -04:00
hptiop.h hptiop: Support HighPoint RR36xx HBAs and Support SAS tape and SAS media changer 2015-08-12 13:14:57 -07:00
imm.c scsi: imm: drop duplicate bus_reset handler 2017-08-25 17:21:11 -04:00
imm.h
initio.c SCSI: initio: remove duplicate module device table 2015-11-20 11:39:03 -05:00
initio.h
ipr.c scsi: ipr: Set no_report_opcodes for RAID arrays 2017-08-22 22:23:36 -04:00
ipr.h scsi: ipr: Fix scsi-mq lockdep issue 2017-08-08 11:49:51 -04:00
ips.c sched/wait: Rename wait_queue_t => wait_queue_entry_t 2017-06-20 12:18:27 +02:00
ips.h sched/wait: Rename wait_queue_t => wait_queue_entry_t 2017-06-20 12:18:27 +02:00
iscsi_boot_sysfs.c ibft: Expose iBFT acpi header via sysfs 2016-05-16 11:14:29 -04:00
iscsi_tcp.c scsi: iscsi_tcp: Remove a set-but-not-used variable 2017-08-25 17:08:08 -04:00
iscsi_tcp.h iscsi_tcp: Use ahash 2016-01-27 20:36:10 +08:00
jazz_esp.c
Kconfig block: fix CDROM dependency on BLK_DEV 2017-11-02 08:26:55 -06:00
lasi700.c parisc/scsi/lasi700: Fix section mismatches 2017-08-22 16:34:36 +02:00
libiscsi_tcp.c iscsi_tcp: Use ahash 2016-01-27 20:36:10 +08:00
libiscsi.c scsi: libiscsi: Fix indentation 2017-08-25 17:08:08 -04:00
mac53c94.c scsi: Convert to using %pOF instead of full_name 2017-08-07 14:04:02 -04:00
mac53c94.h
mac_esp.c scsi: mac_esp: Fix PIO transfers for MESSAGE IN phase 2017-08-10 19:55:34 -04:00
mac_scsi.c scsi: NCR5380: Move bus reset to host reset 2017-08-25 17:21:11 -04:00
Makefile scsi: Implement blk_mq_ops.show_rq() 2017-04-26 15:09:04 -06:00
megaraid.c scsi: megaraid: fix format-overflow warning 2017-08-07 14:04:01 -04:00
megaraid.h
mesh.c PCI: Remove includes of asm/pci-bridge.h 2016-02-05 16:29:28 -06:00
mesh.h
mvme16x_scsi.c
mvme147.c scsi: drop bus reset for wd33c93-compatible boards 2017-08-25 17:21:10 -04:00
mvme147.h
mvumi.c scsi: mvumi: remove code handling zero scsi_sg_count(scmd) case 2017-04-24 18:16:49 -04:00
mvumi.h
ncr53c8xx.c
ncr53c8xx.h
NCR53c406a.c scsi: Do not set cmd_per_lun to 1 in the host template 2015-05-31 18:06:28 -07:00
NCR5380.c scsi: NCR5380: Move bus reset to host reset 2017-08-25 17:21:11 -04:00
NCR5380.h scsi: ncr5380: Clean up dead code and redundant macro usage 2017-01-31 21:37:44 -05:00
NCR_D700.c
NCR_D700.h
NCR_Q720.c dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags 2017-09-01 11:59:17 +02:00
NCR_Q720.h
nsp32_debug.c
nsp32_io.h
nsp32.c scsi: nsp32: drop bus reset 2017-08-25 17:21:11 -04:00
nsp32.h
osst_detect.h
osst_options.h
osst.c scsi: osst: silence underflow warning in osst_verify_frame() 2017-08-24 22:29:01 -04:00
osst.h
pmcraid.c scsi: pmcraid: fix duplicated code for different branches 2017-08-24 22:29:05 -04:00
pmcraid.h scsi: pmcraid: Replace PCI pool old API 2017-08-07 14:04:01 -04:00
ppa.c scsi: ppa: drop duplicate bus_reset handler 2017-08-25 17:21:11 -04:00
ppa.h
ps3rom.c scsi: Do not set cmd_per_lun to 1 in the host template 2015-05-31 18:06:28 -07:00
qla1280.c ia64, scsi: update references for the device-io book 2017-05-16 08:44:21 -03:00
qla1280.h
qlogicfas408.c scsi: qlogicfas: move bus_reset to host_reset 2017-08-25 17:21:11 -04:00
qlogicfas408.h scsi: qlogicfas: move bus_reset to host_reset 2017-08-25 17:21:11 -04:00
qlogicfas.c scsi: qlogicfas: move bus_reset to host_reset 2017-08-25 17:21:11 -04:00
qlogicpti.c scsi: qlogicpti: fixup qlogicpti_reset() definition 2017-08-28 22:15:46 -04:00
qlogicpti.h qlogicpti: Fix compiler warnings 2016-11-28 15:51:31 -05:00
raid_class.c
script_asm.pl
scsi_common.c scsi: always zero sshdr in scsi_normalize_sense 2017-02-22 19:33:00 -05:00
scsi_debug.c treewide: make "nr_cpu_ids" unsigned 2017-09-08 18:26:48 -07:00
scsi_debugfs.c scsi: Show .retries and .jiffies_at_alloc in debugfs 2017-08-31 23:09:11 -04:00
scsi_debugfs.h scsi: Implement blk_mq_ops.show_rq() 2017-04-26 15:09:04 -06:00
scsi_devinfo.c scsi: scsi_devinfo: remove synchronous ALUA for NETAPP devices 2016-12-07 18:13:52 -05:00
scsi_dh.c scsi: use 'scsi_device_from_queue()' for scsi_dh 2017-02-22 18:41:42 -05:00
scsi_error.c scsi: Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer 2017-08-25 17:08:07 -04:00
scsi_ioctl.c scsi: Suppress gcc 7 fall-through warnings reported with W=1 2017-08-25 17:08:07 -04:00
scsi_lib_dma.c
scsi_lib.c block, scsi: Make SCSI quiesce and resume work reliably 2017-11-10 19:53:25 -07:00
scsi_logging.c scsi_logging: return void for dev_printk() functions 2015-02-04 08:00:24 -08:00
scsi_logging.h
scsi_module.c
scsi_netlink.c netlink: extended ACK reporting 2017-04-13 13:58:20 -04:00
scsi_pm.c scsi: Set request queue runtime PM status back to active on resume 2016-02-19 10:52:45 -05:00
scsi_priv.h scsi: Document which queue type a function is intended for 2017-08-25 17:08:07 -04:00
scsi_proc.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
scsi_sas_internal.h scsi_transport_sas: add 'scsi_target_id' sysfs attribute 2016-03-14 21:05:04 -04:00
scsi_scan.c scsi: Document which queue type a function is intended for 2017-08-25 17:08:07 -04:00
scsi_sysctl.c
scsi_sysfs.c scsi: Rework handling of scsi_device.vpd_pg8[03] 2017-08-29 21:51:42 -04:00
scsi_trace.c scsi-trace: define ZBC_IN and ZBC_OUT 2016-04-11 16:57:09 -04:00
scsi_transport_api.h
scsi_transport_fc.c scsi: scsi_transport_fc: fix NULL pointer dereference in fc_bsg_job_timeout 2017-09-14 20:40:58 -04:00
scsi_transport_iscsi.c scsi: bsg-lib: pass the release callback through bsg_setup_queue 2017-08-29 21:51:43 -04:00
scsi_transport_sas.c scsi: scsi_transport_sas: switch to bsg-lib for SMP passthrough 2017-08-29 21:51:45 -04:00
scsi_transport_spi.c scsi: merge __scsi_execute into scsi_execute 2017-02-23 16:57:19 -05:00
scsi_transport_srp.c scsi: scsi_transport_srp: Suppress a W=1 compiler warning 2017-08-25 17:08:08 -04:00
scsi_typedefs.h
scsi.c Merge branch 'fixes' into misc 2017-09-07 12:12:43 -07:00
scsi.h
scsicam.c scsi: fix some kernel-doc markups 2017-05-16 08:44:15 -03:00
sd_dif.c scsi: sd: Move DIF protection types to t10-pi.h 2016-09-15 09:51:14 -04:00
sd_zbc.c scsi: sd_zbc: Write unlock zone from sd_uninit_cmnd() 2017-08-16 20:01:31 -04:00
sd.c scsi: sd: Remove unnecessary condition in sd_read_block_limits() 2017-09-15 15:14:28 -04:00
sd.h sd: add support for TCG OPAL self encrypting disks 2017-06-29 10:21:15 -04:00
sense_codes.h scsi: move Additional Sense Codes to separate file 2016-04-11 16:57:09 -04:00
ses.c Merge branch 'fixes' into misc 2017-09-07 12:12:43 -07:00
sg.c block: pass full fmode_t to blk_verify_command 2017-11-10 19:53:25 -07:00
sgiwd93.c scsi: drop bus reset for wd33c93-compatible boards 2017-08-25 17:21:10 -04:00
sim710.c scsi: sim710: fix build warning 2016-02-23 21:27:02 -05:00
sni_53c710.c scsi: remove incorrect __exit markups 2017-03-15 19:27:46 -04:00
sr_ioctl.c scsi: merge __scsi_execute into scsi_execute 2017-02-23 16:57:19 -05:00
sr_vendor.c
sr.c scsi: sd: sr: Convert two assignments into warning statements 2017-08-25 17:08:08 -04:00
sr.h
st_options.h
st.c scsi: st: fix blk_get_queue usage 2017-08-08 11:49:51 -04:00
st.h st: Remove obsolete scsi_tape.max_pfn 2015-11-18 11:59:09 -05:00
stex.c scsi: stex: make S6flag static 2017-04-26 18:32:29 -04:00
storvsc_drv.c scsi: storvsc: fix memory leak on ring buffer busy 2017-08-30 21:53:13 -04:00
sun3_scsi_vme.c
sun3_scsi.c scsi: NCR5380: Move bus reset to host reset 2017-08-25 17:21:11 -04:00
sun3x_esp.c arch, drivers: don't include <asm/io.h> directly, use <linux/io.h> instead 2015-08-10 23:07:05 -04:00
sun_esp.c scsi: sun_esp: fix device reference leaks 2017-06-27 21:46:55 -04:00
sym53c416.c scsi: Do not set cmd_per_lun to 1 in the host template 2015-05-31 18:06:28 -07:00
sym53c416.h
virtio_scsi.c scsi: virtio: virtio_scsi: Set can_queue to the length of the virtqueue. 2017-08-24 22:28:51 -04:00
vmw_pvscsi.c scsi: vmw_pvscsi: handle the return value from pci_alloc_irq_vectors correctly 2017-03-06 22:27:33 -05:00
vmw_pvscsi.h scsi: vmw_pvscsi: switch to pci_alloc_irq_vectors 2017-01-11 22:31:03 -05:00
wd33c93.c scsi: drop bus reset for wd33c93-compatible boards 2017-08-25 17:21:10 -04:00
wd33c93.h
wd719x.c drivers/scsi/wd719x.c: remove last declaration using DEFINE_PCI_DEVICE_TABLE 2016-09-01 17:52:01 -07:00
wd719x.h scsi: Do not set cmd_per_lun to 1 in the host template 2015-05-31 18:06:28 -07:00
xen-scsifront.c scsi: xen-scsifront: Remove code that zeroes driver-private command data 2017-06-12 21:02:04 -04:00
zalon.c parisc/scsi/zalon: Fix section mismatches 2017-08-22 16:34:36 +02:00
zorro7xx.c