1
0
Fork 0
alistair23-linux/block
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
..
partitions partitions/ldm: switch to use uuid_t 2017-06-05 16:59:14 +02:00
Kconfig block: Add rdma affinity based queue mapping helper 2017-08-08 14:58:03 -04:00
Kconfig.iosched block, bfq: add full hierarchical scheduling and cgroups support 2017-04-19 08:30:26 -06:00
Makefile block: Add rdma affinity based queue mapping helper 2017-08-08 14:58:03 -04:00
badblocks.c block: Add fallthrough markers to switch statements 2017-06-21 11:46:07 -06:00
bfq-cgroup.c bfq: Declare local functions static 2017-09-01 13:56:37 -06:00
bfq-iosched.c block, bfq: fix unbalanced decrements of burst size 2017-10-09 09:54:58 -06:00
bfq-iosched.h Merge branch 'for-4.14/block' of git://git.kernel.dk/linux-block 2017-09-07 11:59:42 -07:00
bfq-wf2q.c block, bfq: guarantee update_next_in_service always returns an eligible entity 2017-08-31 08:20:31 -06:00
bio-integrity.c block: remove unnecessary NULL checks in bioset_integrity_free() 2017-10-06 13:03:12 -06:00
bio.c block: fix Sphinx kernel-doc warning 2017-10-16 13:00:12 -06:00
blk-cgroup.c blkcg: add sanity check for blkcg policy operations 2017-11-04 12:31:15 -06:00
blk-core.c block, scsi: Make SCSI quiesce and resume work reliably 2017-11-10 19:53:25 -07:00
blk-exec.c block: introduce new block status code type 2017-06-09 09:27:32 -06:00
blk-flush.c blk-mq: don't allocate driver tag upfront for flush rq 2017-11-04 12:40:13 -06:00
blk-integrity.c block: switch bios to blk_status_t 2017-06-09 09:27:32 -06:00
blk-ioc.c Merge branch 'for-linus' of git://git.kernel.dk/linux-block 2017-03-03 10:53:35 -08:00
blk-lib.c block: cope with WRITE ZEROES failing in blkdev_issue_zeroout() 2017-10-25 12:28:23 -06:00
blk-map.c blk-map: call blk_queue_bounce from blk_rq_append_bio 2017-06-27 12:13:21 -06:00
blk-merge.c block: replace bi_bdev with a gendisk pointer and partitions index 2017-08-23 12:49:55 -06:00
blk-mq-cpumap.c blk-mq: map queues to all present CPUs 2017-07-24 10:01:31 -06:00
blk-mq-debugfs.c block: Add the QUEUE_FLAG_PREEMPT_ONLY request queue flag 2017-11-10 19:53:25 -07:00
blk-mq-debugfs.h mq-deadline: add debugfs attributes 2017-05-04 08:25:17 -06:00
blk-mq-pci.c blk-mq-pci: add a fallback when pci_irq_get_affinity returns NULL 2017-08-18 08:08:14 -06:00
blk-mq-rdma.c block: Add rdma affinity based queue mapping helper 2017-08-08 14:58:03 -04:00
blk-mq-sched.c Revert "blk-mq: don't handle TAG_SHARED in restart" 2017-11-10 19:53:25 -07:00
blk-mq-sched.h blk-mq: don't restart queue when .get_budget returns BLK_STS_RESOURCE 2017-11-01 08:20:34 -06:00
blk-mq-sysfs.c blk-mq: untangle debugfs and sysfs 2017-05-04 08:24:13 -06:00
blk-mq-tag.c block: remove blk_mq_reinit_tagset 2017-10-18 19:27:49 +02:00
blk-mq-tag.h blk-mq-tag: kill unused tag enums 2017-10-01 01:26:21 -06:00
blk-mq-virtio.c blk-mq: provide a default queue mapping for virtio device 2017-02-27 20:54:05 +02:00
blk-mq.c block, scsi: Make SCSI quiesce and resume work reliably 2017-11-10 19:53:25 -07:00
blk-mq.h blk-mq: move blk_mq_put_driver_tag*() into blk-mq.h 2017-11-04 12:39:57 -06:00
blk-settings.c block: remove __bio_kmap_atomic 2017-11-10 19:53:25 -07:00
blk-softirq.c smp: Avoid using two cache lines for struct call_single_data 2017-08-29 15:14:38 +02:00
blk-stat.c blk-stat: delete useless code 2017-10-10 13:48:14 -06:00
blk-stat.h blk-stat: kill blk_stat_rq_ddir() 2017-04-21 07:56:23 -06:00
blk-sysfs.c block: fix warning when I/O elevator is changed as request_queue is being removed 2017-08-28 10:52:44 -06:00
blk-tag.c block: Unexport blk_queue_end_tag() 2017-08-18 08:36:58 -06:00
blk-throttle.c blk-throttle: fix null pointer dereference while throttling writeback IOs 2017-10-10 13:09:34 -06:00
blk-timeout.c block: Fix a race between blk_cleanup_queue() and timeout handling 2017-10-30 13:28:10 -06:00
blk-wbt.c block,bfq: Disable writeback throttling 2017-10-09 08:29:21 -06:00
blk-wbt.h block: Make writeback throttling defaults consistent for SQ devices 2017-04-19 08:49:03 -06:00
blk-zoned.c block: replace bi_bdev with a gendisk pointer and partitions index 2017-08-23 12:49:55 -06:00
blk.h blk-mq: document the need to have STARTED and COMPLETED share a byte 2017-10-04 11:22:24 -06:00
bounce.c block: remove the queue_bounce_pfn helper 2017-06-27 12:13:45 -06:00
bsg-lib.c bsg-lib: don't free job in bsg_prepare_job 2017-09-25 08:56:05 -06:00
bsg.c block: pass full fmode_t to blk_verify_command 2017-11-10 19:53:25 -07:00
cfq-iosched.c block/cfq: cache rightmost rb_node 2017-09-08 18:26:49 -07:00
cmdline-parser.c block: remove unrelated header files and export symbol 2014-01-21 20:18:26 -08:00
compat_ioctl.c compat_hdio_ioctl: Fix a declaration 2017-08-31 17:32:41 -04:00
deadline-iosched.c block, scheduler: convert xxx_var_store to void 2017-08-28 10:01:08 -06:00
elevator.c elevator: allow name aliases 2017-10-25 12:36:50 -06:00
genhd.c block: introduce GENHD_FL_HIDDEN 2017-11-03 10:31:48 -06:00
ioctl.c block: move CAP_SYS_ADMIN check in blkdev_roset() 2017-10-25 12:25:00 -06:00
ioprio.c block: Add fallthrough markers to switch statements 2017-06-21 11:46:07 -06:00
kyber-iosched.c block: kyber: check if there are requests in ctx in kyber_has_work() 2017-11-01 08:20:02 -06:00
mq-deadline.c mq-deadline: add 'deadline' as a name alias 2017-10-25 12:36:55 -06:00
noop-iosched.c block: move existing elevator ops to union 2017-01-17 10:03:33 -07:00
opal_proto.h block: sed-opal: Set MBRDone on S3 resume path if TPER is MBREnabled 2017-09-11 09:45:52 -06:00
partition-generic.c block: fix a crash caused by wrong API 2017-09-25 08:56:05 -06:00
scsi_ioctl.c block: pass full fmode_t to blk_verify_command 2017-11-10 19:53:25 -07:00
sed-opal.c block: sed-opal: Set MBRDone on S3 resume path if TPER is MBREnabled 2017-09-11 09:45:52 -06:00
t10-pi.c t10-pi: Move opencoded contants to common header 2017-07-03 16:56:25 -06:00