]> www.infradead.org Git - users/hch/blktests.git/commitdiff
nvme: Add new test case about nvme rescan/reset/remove during IO
authorYi Zhang <yi.zhang@redhat.com>
Wed, 11 Sep 2019 08:53:43 +0000 (16:53 +0800)
committerOmar Sandoval <osandov@fb.com>
Tue, 15 Oct 2019 23:20:36 +0000 (16:20 -0700)
Add one test to cover NVMe SSD rescan/reset/remove operation during
IO, the steps found several issues during my previous testing, check
them here:
http://lists.infradead.org/pipermail/linux-nvme/2017-February/008358.html
http://lists.infradead.org/pipermail/linux-nvme/2017-May/010259.html

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
[Omar: allow all attributes to be missing and check for directory
 existence]
Signed-off-by: Omar Sandoval <osandov@fb.com>
tests/nvme/032 [new file with mode: 0755]
tests/nvme/032.out [new file with mode: 0644]

diff --git a/tests/nvme/032 b/tests/nvme/032
new file mode 100755 (executable)
index 0000000..a91a473
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2019 Yi Zhang <yi.zhang@redhat.com>
+#
+# Test nvme pci adapter rescan/reset/remove operation during I/O
+#
+# Regression test for bellow two commits:
+# http://lists.infradead.org/pipermail/linux-nvme/2017-May/010367.html
+# 986f75c876db nvme: avoid to use blk_mq_abort_requeue_list()
+# 806f026f9b90 nvme: use blk_mq_start_hw_queues() in nvme_kill_queues()
+
+. tests/nvme/rc
+
+DESCRIPTION="test nvme pci adapter rescan/reset/remove during I/O"
+QUICK=1
+
+requires() {
+       _have_fio
+}
+
+device_requires() {
+       _test_dev_is_nvme
+}
+
+test_device() {
+       echo "Running ${TEST_NAME}"
+
+       local sysfs
+       local attr
+       local m
+
+       pdev="$(_get_pci_dev_from_blkdev)"
+       sysfs="/sys/bus/pci/devices/${pdev}"
+
+       # start fio job
+       _run_fio_rand_io --filename="$TEST_DEV" --size=1g \
+               --group_reporting  &> /dev/null &
+
+       sleep 5
+
+       if [[ ! -d "$sysfs" ]]; then
+               echo "$sysfs doesn't exist"
+       fi
+
+       # do rescan/reset/remove operation
+       for attr in rescan reset remove; do
+               if [[ -f "$sysfs/$attr" ]]; then
+                       echo 1 > "$sysfs/$attr"
+               fi
+       done
+
+       { kill $!; wait; } &> /dev/null
+
+       echo 1 > /sys/bus/pci/rescan
+
+       # wait nvme reinitialized
+       for ((m = 0; m < 10; m++)); do
+               if [[ -b "${TEST_DEV}" ]]; then
+                       break
+               fi
+               sleep 0.5
+       done
+       if (( m > 9 )); then
+               echo "nvme still not reinitialized after 5 seconds!"
+       fi
+       udevadm settle
+
+       echo "Test complete"
+}
diff --git a/tests/nvme/032.out b/tests/nvme/032.out
new file mode 100644 (file)
index 0000000..deefe73
--- /dev/null
@@ -0,0 +1,2 @@
+Running nvme/032
+Test complete