diff mbox series

[blktests,V4] nvme: add nvme pci timeout testcase

Message ID 20240131043811.12292-1-kch@nvidia.com (mailing list archive)
State New, archived
Headers show
Series [blktests,V4] nvme: add nvme pci timeout testcase | expand

Commit Message

Chaitanya Kulkarni Jan. 31, 2024, 4:38 a.m. UTC
Trigger and test nvme-pci timeout with concurrent fio jobs.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
V4:- 

remove timeout attr save restore and remove. rescan device. (Shinichiro)

 tests/nvme/050     | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/050.out |  2 ++
 2 files changed, 57 insertions(+)
 create mode 100755 tests/nvme/050
 create mode 100644 tests/nvme/050.out

Comments

Shin'ichiro Kawasaki Feb. 1, 2024, 8:55 a.m. UTC | #1
On Jan 30, 2024 / 20:38, Chaitanya Kulkarni wrote:
> Trigger and test nvme-pci timeout with concurrent fio jobs.
> 
> Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>

I've applied it. Thanks!
diff mbox series

Patch

diff --git a/tests/nvme/050 b/tests/nvme/050
new file mode 100755
index 0000000..c710832
--- /dev/null
+++ b/tests/nvme/050
@@ -0,0 +1,55 @@ 
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Chaitanya Kulkarni
+#
+# Test NVMe-PCI timeout with FIO jobs by triggering the nvme_timeout function.
+#
+
+. tests/nvme/rc
+
+DESCRIPTION="test nvme-pci timeout with fio jobs"
+CAN_BE_ZONED=1
+
+#restrict test to nvme-pci only
+nvme_trtype=pci
+
+requires() {
+	_have_fio
+	_nvme_requires
+	_have_kernel_option FAIL_IO_TIMEOUT
+	_have_kernel_option FAULT_INJECTION_DEBUG_FS
+}
+
+test_device() {
+	local nvme_ns
+	local pdev
+
+	echo "Running ${TEST_NAME}"
+
+	pdev=$(_get_pci_dev_from_blkdev)
+	nvme_ns="$(basename "${TEST_DEV}")"
+	echo 1 > /sys/block/"${nvme_ns}"/io-timeout-fail
+
+	echo 100 > /sys/kernel/debug/fail_io_timeout/probability
+	echo   1 > /sys/kernel/debug/fail_io_timeout/interval
+	echo  -1 > /sys/kernel/debug/fail_io_timeout/times
+	echo   0 > /sys/kernel/debug/fail_io_timeout/space
+	echo   1 > /sys/kernel/debug/fail_io_timeout/verbose
+
+	fio --bs=4k --rw=randread --norandommap --numjobs="$(nproc)" \
+	    --name=reads --direct=1 --filename="${TEST_DEV}" --group_reporting \
+	    --time_based --runtime=1m >& "$FULL"
+
+	if grep -q "Input/output error" "$FULL"; then
+		echo "Test complete"
+	else
+		echo "Test failed"
+	fi
+
+	# Remove and rescan the NVME device to ensure that it has come back
+	echo 1 > "/sys/bus/pci/devices/${pdev}/remove"
+	echo 1 > /sys/bus/pci/rescan
+	if [[ ! -b ${TEST_DEV} ]]; then
+		echo "Failed to restore ${TEST_DEV}"
+	fi
+}
diff --git a/tests/nvme/050.out b/tests/nvme/050.out
new file mode 100644
index 0000000..b78b05f
--- /dev/null
+++ b/tests/nvme/050.out
@@ -0,0 +1,2 @@ 
+Running nvme/050
+Test complete