Skip to content

Commit de8fe75

Browse files
committed
nvme/050: add support for NVMe multipath devices
Add two helper functions to tests/nvme/rc: - _nvme_dev_support_native_multipath(): Check if the test device is an NVMe native multipath device by examining the sysfs device path. - _nvme_get_pci_from_dev_sysfs(): Get the PCI address for an NVMe device, handling multipath devices by reading from the multipath subdirectory. Update nvme/050 to handle multipath devices correctly. When testing I/O timeout on a multipath device, fio will not encounter I/O errors because the multipath layer provides failover to alternate paths. Adjust the test pass/fail logic accordingly: - For multipath devices: pass if no I/O error (expected behavior) - For non-multipath devices: pass if I/O error occurs (original behavior) Signed-off-by: Yi Zhang <[email protected]>
1 parent e387a7e commit de8fe75

2 files changed

Lines changed: 31 additions & 7 deletions

File tree

tests/nvme/050

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ requires() {
2020
}
2121

2222
test_device() {
23-
local nvme_ns
24-
local pdev
25-
local i
23+
local nvme_ns pdev io_error i
2624

2725
echo "Running ${TEST_NAME}"
2826

29-
pdev=$(_get_pci_dev_from_blkdev)
27+
pdev=$(_nvme_get_pci_from_dev_sysfs)
3028
nvme_ns="$(basename "${TEST_DEV}")"
3129
echo 1 > /sys/block/"${nvme_ns}"/io-timeout-fail
3230

@@ -40,10 +38,19 @@ test_device() {
4038
--name=reads --direct=1 --filename="${TEST_DEV}" --group_reporting \
4139
--time_based --runtime=1m >& "$FULL"
4240

43-
if grep -q "Input/output error" "$FULL"; then
44-
echo "Test complete"
41+
io_error=false
42+
grep -q "Input/output error" "$FULL" && io_error=true
43+
44+
# The timeout failure injection causes an I/O to fail immediately. For
45+
# a single-path device, the failed I/O is propagated up the stack and
46+
# eventually reported to user space as an error. For multipath devices,
47+
# the block layer evaluates whether the I/O is eligible for retry via
48+
# failover to an alternate path. Because the I/O fails before the
49+
# per-I/O timeout expires, it remains eligible for retry.
50+
if _nvme_dev_support_native_multipath; then
51+
$io_error && echo "Test failed" || echo "Test complete"
4552
else
46-
echo "Test failed"
53+
$io_error && echo "Test complete" || echo "Test failed"
4754
fi
4855

4956
# Remove and rescan the NVME device to ensure that it has come back

tests/nvme/rc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,23 @@ _require_test_dev_is_not_nvme_multipath() {
8787
return 0
8888
}
8989

90+
_nvme_dev_support_native_multipath() {
91+
if [[ "$(readlink -f "$TEST_DEV_SYSFS/device")" =~ /nvme-subsystem/ ]]; then
92+
return 0
93+
fi
94+
return 1
95+
}
96+
97+
_nvme_get_pci_from_dev_sysfs() {
98+
if _nvme_dev_support_native_multipath; then
99+
readlink --canonicalize "$TEST_DEV_SYSFS"/multipath/nvme*c*n*/device | \
100+
grep -Eo '[0-9a-f]{4,5}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]' | \
101+
tail -1
102+
else
103+
_get_pci_dev_from_blkdev
104+
fi
105+
}
106+
90107
_require_test_dev_support_sed() {
91108
if ! nvme sed discover "$TEST_DEV" &> /dev/null; then
92109
SKIP_REASONS+=("$TEST_DEV doesn't support SED operations")

0 commit comments

Comments
 (0)