From: Chaitanya Kulkarni <kch@nvidia.com>
To: <linux-nvme@lists.infradead.org>, <linux-block@vger.kernel.org>
Cc: <shinichiro.kawasaki@wdc.com>, Chaitanya Kulkarni <kch@nvidia.com>
Subject: [PATCH blktests V3] nvme: add nvme pci timeout testcase
Date: Tue, 23 Jan 2024 14:55:47 -0800 [thread overview]
Message-ID: <20240123225547.10221-1-kch@nvidia.com> (raw)
Trigger and test nvme-pci timeout with concurrent fio jobs.
Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
V3:-
1. Add CAN_BE_ZONED.
2. Add FAULT_INJECTION_DEBUG_FS check in requires.
3. Remove _require_nvme_trtype pci in requires().
4. Remove device_requires().
5. Store fio output in FULL.
6. Revmoe shellcheck and use grep I/O error value to pass/fail testcase.
---
tests/nvme/050 | 69 ++++++++++++++++++++++++++++++++++++++++++++++
tests/nvme/050.out | 2 ++
2 files changed, 71 insertions(+)
create mode 100755 tests/nvme/050
create mode 100644 tests/nvme/050.out
diff --git a/tests/nvme/050 b/tests/nvme/050
new file mode 100755
index 0000000..cacaba6
--- /dev/null
+++ b/tests/nvme/050
@@ -0,0 +1,69 @@
+#!/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
+
+sysfs_path="/sys/kernel/debug/fail_io_timeout/"
+#restrict test to nvme-pci only
+nvme_trtype=pci
+
+# fault injection config array
+declare -A fi_array
+
+requires() {
+ _have_fio
+ _nvme_requires
+ _have_kernel_option FAIL_IO_TIMEOUT
+ _have_kernel_option FAULT_INJECTION_DEBUG_FS
+}
+
+save_fi_settings() {
+ for fi_attr in probability interval times space verbose
+ do
+ fi_array["${fi_attr}"]=$(cat "${sysfs_path}/${fi_attr}")
+ done
+}
+
+restore_fi_settings() {
+ for fi_attr in probability interval times space verbose
+ do
+ echo "${fi_array["${fi_attr}"]}" > "${sysfs_path}/${fi_attr}"
+ done
+}
+
+test_device() {
+ local nvme_ns
+ local io_fimeout_fail
+
+ echo "Running ${TEST_NAME}"
+
+ nvme_ns="$(basename "${TEST_DEV}")"
+ io_fimeout_fail="$(cat /sys/block/"${nvme_ns}"/io-timeout-fail)"
+ save_fi_settings
+ 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
+ restore_fi_settings
+ echo "${io_fimeout_fail}" > /sys/block/"${nvme_ns}"/io-timeout-fail
+}
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
--
2.40.0
next reply other threads:[~2024-01-23 22:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 22:55 Chaitanya Kulkarni [this message]
2024-01-29 11:13 ` [PATCH blktests V3] nvme: add nvme pci timeout testcase Chaitanya Kulkarni
2024-01-29 11:57 ` Shinichiro Kawasaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240123225547.10221-1-kch@nvidia.com \
--to=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=shinichiro.kawasaki@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).