Skip to content

Commit 4da07df

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 4da07df

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

tests/nvme/050

Lines changed: 9 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,14 @@ 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+
# fio will not fail on the nvme multipath device
45+
if _nvme_dev_support_native_multipath; then
46+
$io_error && echo "Test failed" || echo "Test complete"
4547
else
46-
echo "Test failed"
48+
$io_error && echo "Test complete" || echo "Test failed"
4749
fi
4850

4951
# 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 /sys/block/$(basename "${TEST_DEV}")/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)