[PATCH blktests] test/nvme/050: test the reservation feature

Guixin Liu kanie at linux.alibaba.com
Sun Jan 14 01:26:11 PST 2024


Test the reservation feature, includes register, acquire, release
and report.

Signed-off-by: Guixin Liu <kanie at linux.alibaba.com>
---
 tests/nvme/050     |  67 ++++++++++++++++++++++++++
 tests/nvme/050.out | 114 +++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/rc      |   3 ++
 3 files changed, 184 insertions(+)
 create mode 100644 tests/nvme/050
 create mode 100644 tests/nvme/050.out

diff --git a/tests/nvme/050 b/tests/nvme/050
new file mode 100644
index 0000000..a499f66
--- /dev/null
+++ b/tests/nvme/050
@@ -0,0 +1,67 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Guixin Liu
+# Copyright (C) 2024 Alibaba Group.
+#
+# Test the reservation
+#
+. tests/nvme/rc
+
+DESCRIPTION="test the reservation"
+QUICK=1
+
+requires() {
+	_nvme_requires
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	_setup_nvmet
+
+	local nvmedev
+
+	_nvmet_target_setup --blkdev file
+
+	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+
+	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
+
+	echo "Register"
+	nvme resv-report "/dev/${nvmedev}n1" --cdw11=1
+	nvme resv-register "/dev/${nvmedev}n1" --nrkey=4 --rrega=0
+	nvme resv-report "/dev/${nvmedev}n1" --cdw11=1
+
+	echo "Replace"
+	nvme resv-register "/dev/${nvmedev}n1" --crkey=4 --nrkey=5 --rrega=2
+	nvme resv-report "/dev/${nvmedev}n1" --cdw11=1
+
+	echo "Unregister"
+	nvme resv-register "/dev/${nvmedev}n1" --crkey=5 --rrega=1
+	nvme resv-report "/dev/${nvmedev}n1" --cdw11=1
+
+	echo "Acquire"
+	nvme resv-register "/dev/${nvmedev}n1" --nrkey=4 --rrega=0
+	nvme resv-acquire "/dev/${nvmedev}n1" --crkey=4 --rtype=1 --racqa=0
+	nvme resv-report "/dev/${nvmedev}n1" --cdw11=1
+
+	echo "Preempt"
+	nvme resv-acquire "/dev/${nvmedev}n1" --crkey=4 --rtype=2 --racqa=1
+	nvme resv-report "/dev/${nvmedev}n1" --cdw11=1
+
+	echo "Release"
+	nvme resv-release "/dev/${nvmedev}n1" --crkey=4 --rtype=2 --rrela=0
+	nvme resv-report "/dev/${nvmedev}n1" --cdw11=1
+
+	echo "Clear"
+	nvme resv-register "/dev/${nvmedev}n1" --nrkey=4 --rrega=0
+	nvme resv-acquire "/dev/${nvmedev}n1" --crkey=4 --rtype=1 --racqa=0
+	nvme resv-report "/dev/${nvmedev}n1" --cdw11=1
+	nvme resv-release "/dev/${nvmedev}n1" --crkey=4 --rrela=1
+
+	_nvme_disconnect_subsys "${def_subsysnqn}"
+
+	_nvmet_target_cleanup
+
+	echo "Test complete"
+}
diff --git a/tests/nvme/050.out b/tests/nvme/050.out
new file mode 100644
index 0000000..3be417d
--- /dev/null
+++ b/tests/nvme/050.out
@@ -0,0 +1,114 @@
+Running nvme/050
+Register
+
+NVME Reservation status:
+
+gen       : 0
+rtype     : 0
+regctl    : 0
+ptpls     : 0
+
+NVME Reservation  success
+
+NVME Reservation status:
+
+gen       : 1
+rtype     : 0
+regctl    : 1
+ptpls     : 0
+regctlext[0] :
+  cntlid     : 1
+  rcsts      : 0
+  rkey       : 4
+  hostid     : f1fb429f7f4856b0b351e6b8de349
+
+Replace
+NVME Reservation  success
+
+NVME Reservation status:
+
+gen       : 2
+rtype     : 0
+regctl    : 1
+ptpls     : 0
+regctlext[0] :
+  cntlid     : 1
+  rcsts      : 0
+  rkey       : 5
+  hostid     : f1fb429f7f4856b0b351e6b8de349
+
+Unregister
+NVME Reservation  success
+
+NVME Reservation status:
+
+gen       : 3
+rtype     : 0
+regctl    : 0
+ptpls     : 0
+
+Acquire
+NVME Reservation  success
+NVME Reservation Acquire success
+
+NVME Reservation status:
+
+gen       : 4
+rtype     : 1
+regctl    : 1
+ptpls     : 0
+regctlext[0] :
+  cntlid     : 1
+  rcsts      : 1
+  rkey       : 4
+  hostid     : f1fb429f7f4856b0b351e6b8de349
+
+Preempt
+NVME Reservation Acquire success
+
+NVME Reservation status:
+
+gen       : 5
+rtype     : 2
+regctl    : 1
+ptpls     : 0
+regctlext[0] :
+  cntlid     : 1
+  rcsts      : 1
+  rkey       : 4
+  hostid     : f1fb429f7f4856b0b351e6b8de349
+
+Release
+NVME Reservation Release success
+
+NVME Reservation status:
+
+gen       : 5
+rtype     : 0
+regctl    : 1
+ptpls     : 0
+regctlext[0] :
+  cntlid     : 1
+  rcsts      : 0
+  rkey       : 4
+  hostid     : f1fb429f7f4856b0b351e6b8de349
+
+Clear
+NVME Reservation  success
+NVME Reservation Acquire success
+
+NVME Reservation status:
+
+gen       : 6
+rtype     : 1
+regctl    : 1
+ptpls     : 0
+regctlext[0] :
+  cntlid     : 1
+  rcsts      : 1
+  rkey       : 4
+  hostid     : f1fb429f7f4856b0b351e6b8de349
+
+NVME Reservation Release success
+disconnected 1 controller(s)
+Test complete
diff --git a/tests/nvme/rc b/tests/nvme/rc
index b0ef1ee..8de59e2 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -670,6 +670,9 @@ _create_nvmet_ns() {
 	mkdir "${ns_path}"
 	printf "%s" "${blkdev}" > "${ns_path}/device_path"
 	printf "%s" "${uuid}" > "${ns_path}/device_uuid"
+	if [[ -f "${ns_path}/resv_enable" ]]; then
+		printf 1 > "${ns_path}/resv_enable"
+	fi
 	printf 1 > "${ns_path}/enable"
 }
 
-- 
2.30.1 (Apple Git-130)




More information about the Linux-nvme mailing list