Skip to contentSkip to conversation

blktests: nvme/{033-037,039}: skip passthru tests on multipath devices

PATCH Applied Martin Wilck 2 participants 4 messages Sep 3, 2024 – Sep 6, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/3 blktests: nvme/{033-037,039}: skip passthru tests on multipath devices

NVMe multipath devices have no associated character device that can be used for NVMe passtrhu. Skip them.

---
v3: improve patch subject (Shinichiro Kawasaki)
v2: used more expressive function name for non-multipath test (Daniel Wagner)

---
 tests/nvme/033 | 4 ++++
 tests/nvme/034 | 4 ++++
 tests/nvme/035 | 1 +
 tests/nvme/036 | 4 ++++
 tests/nvme/037 | 4 ++++
 tests/nvme/039 | 4 ++++
 tests/nvme/rc  | 8 ++++++++
 7 files changed, 29 insertions(+)
tests/nvme/033 +4 -0
index 7a69b94..5e05175 100755
@@ -13,6 +13,10 @@ requires() {
 	_have_kernel_option NVME_TARGET_PASSTHRU
 }
 
+device_requires() {
+	_require_test_dev_is_not_nvme_multipath
+}
+
 set_conditions() {
 	_set_nvme_trtype "$@"
 }
tests/nvme/034 +4 -0
index 239757c..154fc91 100755
@@ -14,6 +14,10 @@ requires() {
 	_have_fio
 }
 
+device_requires() {
+	_require_test_dev_is_not_nvme_multipath
+}
+
 set_conditions() {
 	_set_nvme_trtype "$@"
 }
tests/nvme/035 +1 -0
index 8286178..ff217d6 100755
@@ -17,6 +17,7 @@ requires() {
 }
 
 device_requires() {
+	_require_test_dev_is_not_nvme_multipath
 	_require_test_dev_size "${NVME_IMG_SIZE}"
 }
 
tests/nvme/036 +4 -0
index ef6c29d..442ffe7 100755
@@ -13,6 +13,10 @@ requires() {
 	_have_kernel_option NVME_TARGET_PASSTHRU
 }
 
+device_requires() {
+	_require_test_dev_is_not_nvme_multipath
+}
+
 set_conditions() {
 	_set_nvme_trtype "$@"
 }
tests/nvme/037 +4 -0
index ef7ac59..f7ddc2d 100755
@@ -12,6 +12,10 @@ requires() {
 	_have_kernel_option NVME_TARGET_PASSTHRU
 }
 
+device_requires() {
+	_require_test_dev_is_not_nvme_multipath
+}
+
 set_conditions() {
 	_set_nvme_trtype "$@"
 }
tests/nvme/039 +4 -0
index a0f135c..e8020a7 100755
@@ -18,6 +18,10 @@ requires() {
 	    _have_kernel_option FAULT_INJECTION_DEBUG_FS
 }
 
+device_requires() {
+	_require_test_dev_is_not_nvme_multipath
+}
+
 # Get the last dmesg lines as many as specified. Exclude the lines to indicate
 # suppression by rate limit.
 last_dmesg()
tests/nvme/rc +8 -0
index dedc412..5c554b6 100644
@@ -130,6 +130,14 @@ _require_test_dev_is_nvme() {
 	return 0
 }
 
+_require_test_dev_is_not_nvme_multipath() {
+	if [[ "$(readlink -f "$TEST_DEV_SYSFS/device")" =~ /nvme-subsystem/ ]]; then
+		SKIP_REASONS+=("$TEST_DEV is a NVMe multipath device")
+		return 1
+	fi
+	return 0
+}
+
 _require_nvme_test_img_size() {
 	local require_sz_mb
 	local nvme_img_size_mb
Signature · 1 line
2.46.0
#1 lore raw

PATCH v4 2/3 blktests: nvme/032: skip on non-PCI devices

nvme/032 is a PCI-specific test.

---
 tests/nvme/032 | 2 +-
 tests/nvme/rc  | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
tests/nvme/032 +1 -1
index 5353e96..512d7ea 100755
@@ -24,7 +24,7 @@ requires() {
 }
 
 device_requires() {
-	_require_test_dev_is_nvme
+	_require_test_dev_is_nvme_pci
 }
 
 test_device() {
tests/nvme/rc +8 -0
index 5c554b6..b702a57 100644
@@ -130,6 +130,14 @@ _require_test_dev_is_nvme() {
 	return 0
 }
 
+_require_test_dev_is_nvme_pci() {
+	if [[ ! "$(readlink -f "$TEST_DEV_SYSFS/device")" =~ devices/pci ]]; then
+		SKIP_REASONS+=("$TEST_DEV is not a PCI NVMe device")
+		return 1
+	fi
+	return 0
+}
+
 _require_test_dev_is_not_nvme_multipath() {
 	if [[ "$(readlink -f "$TEST_DEV_SYSFS/device")" =~ /nvme-subsystem/ ]]; then
 		SKIP_REASONS+=("$TEST_DEV is a NVMe multipath device")
Signature · 1 line
2.46.0
#2 lore raw

PATCH v4 3/3 blktests: nvme: add test for controller rescan under I/O load

In reply to Martin Wilck

Add a test that repeatedly rescans nvme controllers while doing IO on an nvme namespace connected to these controllers. The purpose of the test is to make sure that no I/O errors or data corruption occurs because of the rescan operations. The test uses sub-second sleeps, which can't be easily accomplished in bash because of missing floating-point arithmetic (and because usleep(1) isn't portable). Therefore an awk program is used to trigger the device rescans.

---
v4: - use while loop for array assignment (Shinichiro Kawasaki)
- add "blktests" to subject line
v3: (all changes suggested by Shinichiro Kawasaki)
- add "Link:" tag
- add comment with patch description
- declare variable "st" local
- use "mapfile -t" for array assignment
v2: - don't use usleep (Nilay Shroff). Use an awk program to do floating
point arithmetic and achieve more accurate sub-second sleep times.
- add 053.out (Nilay Shroff).

---
 tests/nvme/053     | 76 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/053.out |  2 ++
 tests/nvme/rc      | 18 +++++++++++
 3 files changed, 96 insertions(+)
 create mode 100755 tests/nvme/053
 create mode 100644 tests/nvme/053.out
tests/nvme/053 new file +76 -0
new file mode 100755
index 0000000..3ade8d3
@@ -0,0 +1,76 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Martin Wilck, SUSE LLC
+#
+# Repeatedly rescans nvme controllers while doing IO on an nvme namespace
+# connected to these controllers, and make sure that no I/O errors or data
+# corruption occurs.
+
+. tests/nvme/rc
+
+DESCRIPTION="test controller rescan under I/O load"
+TIMED=1
+: "${TIMEOUT:=60}"
+
+rescan_controller() {
+	local path
+	path="$1/rescan_controller"
+
+	[[ -f "$path" ]] || {
+		echo "cannot rescan $1"
+		return 1
+	}
+
+	awk -f "$TMPDIR/rescan.awk" \
+	    -v path="$path" -v timeout="$TIMEOUT" -v seed="$2" &
+}
+
+create_rescan_script() {
+	cat >"$TMPDIR/rescan.awk" <<EOF
+@load "time"
+
+BEGIN {
+    srand(seed);
+    finish = gettimeofday() + strtonum(timeout);
+    while (gettimeofday() < finish) {
+	sleep(0.1 + 5 * rand());
+	printf("1\n") > path;
+	close(path);
+    }
+}
+EOF
+}
+
+test_device() {
+	local -a ctrls
+	local i st line
+
+	echo "Running ${TEST_NAME}"
+	create_rescan_script
+
+	while IFS= read -r line; do
+		ctrls+=("$line")
+	done < <(_nvme_get_ctrl_list)
+	_run_fio_verify_io --filename="$TEST_DEV" --time_based &> "$FULL" &
+
+	for i in "${!ctrls[@]}"; do
+		rescan_controller "${ctrls[$i]}" "$i"
+	done
+
+	while true; do
+		wait -n &>/dev/null
+		st=$?
+		case $st in
+			127)
+				break
+				;;
+			0)
+				;;
+			*)
+				echo "child process exited with $st!"
+				;;
+		esac
+	done
+
+	echo "Test complete"
+}
tests/nvme/053.out new file +2 -0
new file mode 100644
index 0000000..e8086ce
@@ -0,0 +1,2 @@
+Running nvme/053
+Test complete
tests/nvme/rc +18 -0
index b702a57..a877de3 100644
@@ -192,6 +192,24 @@ _test_dev_nvme_nsid() {
 	cat "${TEST_DEV_SYSFS}/nsid"
 }
 
+_nvme_get_ctrl_list() {
+	local subsys
+	local c
+
+	subsys=$(readlink  "${TEST_DEV_SYSFS}/device/subsystem")
+	case $subsys in
+		*/nvme)
+			readlink -f "${TEST_DEV_SYSFS}/device"
+			;;
+		*/nvme-subsystem)
+			for c in "${TEST_DEV_SYSFS}"/device/nvme*; do
+				[[ -L "$c" ]] || continue
+				[[ -f "$c/dev" ]] && readlink -f "$c"
+			done
+			;;
+	esac
+}
+
 _nvme_calc_rand_io_size() {
 	local img_size_mb
 	local io_size_kb
Signature · 1 line
2.46.0
#3 lore raw
In reply to Martin Wilck
Quoted 7 lines · Martin Wilck

NVMe multipath devices have no associated character device that can be used for NVMe passtrhu. Skip them.

---
v3: improve patch subject (Shinichiro Kawasaki)
v2: used more expressive function name for non-multipath test (Daniel Wagner)

I applied the seires. Thank you for this work!

(I removed the prefix "blktests:" from the commit titles, which I think redundant.)