[PATCH blktests 3/7] nvme: add _setup_nvmet_ns_ana()

Shin'ichiro Kawasaki shinichiro.kawasaki at wdc.com
Fri Nov 29 05:26:13 PST 2024


From: Hannes Reinecke <hare at suse.de>

Add a function to set the ANA groupid for a namespace.

Signed-off-by: Hannes Reinecke <hare at suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki at wdc.com>
---
 common/nvme | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/common/nvme b/common/nvme
index e11776b..9786e4e 100644
--- a/common/nvme
+++ b/common/nvme
@@ -564,6 +564,19 @@ _create_nvmet_ns() {
 	echo "${uuid}"
 }
 
+_setup_nvmet_ns_ana() {
+	local nvmet_subsystem="$1"
+	local nsid="$2"
+	local anagrpid="${3:-def_anagrpid}"
+	local subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}"
+	local ns_path="${subsys_path}/namespaces/${nsid}"
+
+	if [[ ! -d "${ns_path}" ]]; then
+		return
+	fi
+	echo "${anagrpid}" > "${ns_path}/anagrpid"
+}
+
 _create_nvmet_subsystem() {
 	local subsystem="${def_subsysnqn}"
 	local blkdev
-- 
2.47.0




More information about the Linux-nvme mailing list