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>
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
}