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

Shin'ichiro Kawasaki
2024-11-29T13:26:29Z

From: Hannes Reinecke <hare@suse.de>

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

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@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