]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
block/011: recover test target NVME device capacity
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fri, 26 May 2023 04:58:43 +0000 (13:58 +0900)
committerShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fri, 9 Jun 2023 04:53:11 +0000 (13:53 +0900)
The test case runs fio while disabling and enabling PCI device of the
test target block device. When the block device is a NVME PCI device,
the test triggers NVME controller reset. When an error happens during
the reset, NVME PCI driver marks zero capacity for the device. This
zero capacity device causes failures of the following test cases.

To avoid the failures by zero device capacity, check the capacity at the
test end. If it is zero, remove the device and rescan PCI bus to detect
the device again, and regain the correct capacity.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
tests/block/011

index 069993615fa35392f71c2aa1db64f21ff9c0b0f0..a4230f468982299746bfba01e313c9c21650354d 100755 (executable)
@@ -59,4 +59,18 @@ test_device() {
        done
 
        echo "Test complete"
+
+       # This test triggers NVME controller resets. When any failure happens
+       # during the resets, the driver marks the NVME block devices with zero
+       # capacity. Then following tests fail with the zero capacity devices. To
+       # get back the correct capacity, remove and rescan the devices.
+       if ((!$(<"$TEST_DEV_SYSFS/size"))); then
+               echo "$TEST_DEV has zero capacity" >> "$FULL"
+               if [[ -w $TEST_DEV_SYSFS/device/device/remove ]] &&
+                          [[ -w /sys/bus/pci/rescan ]]; then
+                       echo "Rescan to tegain the correct capacity" >> "$FULL"
+                       echo 1 > "$TEST_DEV_SYSFS/device/device/remove"
+                       echo 1 > /sys/bus/pci/rescan
+               fi
+       fi
 }