[PATCH v2] nvme: add regression test for concurrently enable/disable nvmet ns

Sagi Grimberg sagi at grimberg.me
Wed May 22 02:05:40 PDT 2024


Reproduce a hang in nvmet when concurrently disabling/enabling
an nvmet namespace.

Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
Changes from v1:
- remove local variable
- fix shellcheck warnings

 tests/nvme/051     | 47 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/051.out |  2 ++
 2 files changed, 49 insertions(+)
 create mode 100755 tests/nvme/051
 create mode 100644 tests/nvme/051.out

diff --git a/tests/nvme/051 b/tests/nvme/051
new file mode 100755
index 000000000000..624b42f432eb
--- /dev/null
+++ b/tests/nvme/051
@@ -0,0 +1,47 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Sagi Grimberg
+#
+# Regression test for kernel hang when enabling/disabling nvmet
+# namespace concurrently
+
+. tests/nvme/rc
+
+DESCRIPTION="test nvmet concurrent ns enable/disable"
+QUICK=1
+
+requires() {
+	_nvme_requires
+	_require_nvme_trtype_is_fabrics
+}
+
+set_conditions() {
+	_set_nvme_trtype "$@"
+}
+
+ns_enable_disable_loop() {
+	local ns="$1"
+	for ((i = 1; i <= 200; i++)); do
+		echo 0 > "${ns}/enable"
+		echo 1 > "${ns}/enable"
+	done
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	_setup_nvmet
+
+	_nvmet_target_setup
+	ns="${NVMET_CFS}subsystems/${def_subsysnqn}/namespaces/1"
+
+	# fire off two enable/disable loops concurrently and wait
+	# for them to complete...
+	ns_enable_disable_loop $ns &
+	ns_enable_disable_loop $ns &
+	wait
+
+	_nvmet_target_cleanup
+
+	echo "Test complete"
+}
diff --git a/tests/nvme/051.out b/tests/nvme/051.out
new file mode 100644
index 000000000000..156f0687aab2
--- /dev/null
+++ b/tests/nvme/051.out
@@ -0,0 +1,2 @@
+Running nvme/051
+Test complete
-- 
2.40.1




More information about the Linux-nvme mailing list