[PATCH blktests 02/15] nvme, md/001: make trtype argument to _create_nvmet_port() optional
Shin'ichiro Kawasaki
shinichiro.kawasaki at wdc.com
Wed Oct 23 18:00:12 PDT 2024
From: Hannes Reinecke <hare at suse.de>
All invocations are using 'nvme_trtype' as argument to
_create_nvmet_ports(), so we can also make it optional and default
to nvme_trtype.
Signed-off-by: Hannes Reinecke <hare at suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki at wdc.com>
---
common/nvme | 17 ++++++++++-------
tests/md/001 | 2 +-
tests/nvme/002 | 2 +-
tests/nvme/016 | 2 +-
tests/nvme/017 | 2 +-
tests/nvme/030 | 2 +-
tests/nvme/031 | 2 +-
tests/nvme/038 | 2 +-
tests/nvme/rc | 4 ++--
9 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/common/nvme b/common/nvme
index c1aa8d6..99ff959 100644
--- a/common/nvme
+++ b/common/nvme
@@ -423,10 +423,11 @@ _nvme_ns_ready() {
}
_create_nvmet_port() {
- local trtype="$1"
+ local trtype="${1:-$nvme_trtype}"
local traddr="${2:-$def_traddr}"
local adrfam="${3:-$def_adrfam}"
local trsvcid="${4:-$def_trsvcid}"
+ local portcfs
local port
for ((port = 0; ; port++)); do
@@ -435,12 +436,14 @@ _create_nvmet_port() {
fi
done
- mkdir "${NVMET_CFS}/ports/${port}"
- echo "${trtype}" > "${NVMET_CFS}/ports/${port}/addr_trtype"
- echo "${traddr}" > "${NVMET_CFS}/ports/${port}/addr_traddr"
- echo "${adrfam}" > "${NVMET_CFS}/ports/${port}/addr_adrfam"
- if [[ "${adrfam}" != "fc" ]]; then
- echo "${trsvcid}" > "${NVMET_CFS}/ports/${port}/addr_trsvcid"
+ portcfs="${NVMET_CFS}/ports/${port}"
+ mkdir "${portcfs}"
+ echo "${trtype}" > "${portcfs}/addr_trtype"
+ echo "${traddr}" > "${portcfs}/addr_traddr"
+ echo "${adrfam}" > "${portcfs}/addr_adrfam"
+ if [[ "${adrfam}" != "fc" ]] && \
+ [[ "${adrfam}" != "loop" ]] ; then
+ echo "${trsvcid}" > "${portcfs}/addr_trsvcid"
fi
echo "${port}"
diff --git a/tests/md/001 b/tests/md/001
index 98da51d..5d0752f 100755
--- a/tests/md/001
+++ b/tests/md/001
@@ -50,7 +50,7 @@ setup_nvme_over_tcp() {
_setup_nvmet
local port
- port="$(_create_nvmet_port "${nvme_trtype}")"
+ port="$(_create_nvmet_port)"
_create_nvmet_subsystem --subsysnqn "${def_subsysnqn}" \
--blkdev "/dev/mapper/ram0_big_optio" \
diff --git a/tests/nvme/002 b/tests/nvme/002
index 043ab1c..e5b751d 100755
--- a/tests/nvme/002
+++ b/tests/nvme/002
@@ -26,7 +26,7 @@ test() {
local iterations=1000
local port
- port="$(_create_nvmet_port "${nvme_trtype}")"
+ port="$(_create_nvmet_port)"
local loop_dev
loop_dev="$(losetup -f)"
diff --git a/tests/nvme/016 b/tests/nvme/016
index 1143cab..8ab9d22 100755
--- a/tests/nvme/016
+++ b/tests/nvme/016
@@ -38,7 +38,7 @@ test() {
--blkdev "${loop_dev}"
done
- port="$(_create_nvmet_port "${nvme_trtype}")"
+ port="$(_create_nvmet_port)"
_add_nvmet_subsys_to_port "$port" "${def_subsysnqn}"
genctr=$(_check_genctr "${genctr}" "adding a subsystem to a port")
diff --git a/tests/nvme/017 b/tests/nvme/017
index 5721000..dd302fc 100755
--- a/tests/nvme/017
+++ b/tests/nvme/017
@@ -39,7 +39,7 @@ test() {
--blkdev "$(_nvme_def_file_path)"
done
- port="$(_create_nvmet_port "${nvme_trtype}")"
+ port="$(_create_nvmet_port)"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
genctr=$(_check_genctr "${genctr}" "adding a subsystem to a port")
diff --git a/tests/nvme/030 b/tests/nvme/030
index 5db20c0..1ba1274 100755
--- a/tests/nvme/030
+++ b/tests/nvme/030
@@ -28,7 +28,7 @@ test() {
local genctr
local subsys="blktests-subsystem-"
- port="$(_create_nvmet_port "${nvme_trtype}")"
+ port="$(_create_nvmet_port)"
_create_nvmet_subsystem --subsysnqn "${subsys}1" \
--blkdev "$(losetup -f)"
diff --git a/tests/nvme/031 b/tests/nvme/031
index 00d3d18..cd69e8e 100755
--- a/tests/nvme/031
+++ b/tests/nvme/031
@@ -41,7 +41,7 @@ test() {
loop_dev="$(losetup -f --show "$(_nvme_def_file_path)")"
- port="$(_create_nvmet_port "${nvme_trtype}")"
+ port="$(_create_nvmet_port)"
for ((i = 0; i < iterations; i++)); do
_nvmet_target_setup --subsysnqn "${subsys}$i" \
diff --git a/tests/nvme/038 b/tests/nvme/038
index 497cc88..4271ee3 100755
--- a/tests/nvme/038
+++ b/tests/nvme/038
@@ -33,7 +33,7 @@ test() {
mkdir -p "${subsys_path}"
rmdir "${subsys_path}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
+ port="$(_create_nvmet_port)"
_remove_nvmet_port "${port}"
echo "Test complete"
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 357cab9..5b4629d 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -370,7 +370,7 @@ _nvmet_target_setup() {
--blkdev "${blkdev}" \
--uuid "${subsys_uuid}" \
${resv_enable}
- port="$(_create_nvmet_port "${nvme_trtype}")"
+ port="$(_create_nvmet_port)"
_add_nvmet_subsys_to_port "${port}" "${subsysnqn}"
_create_nvmet_host "${subsysnqn}" "${def_hostnqn}" \
"${hostkey}" "${ctrlkey}"
@@ -394,7 +394,7 @@ _nvmet_passthru_target_setup() {
done
_create_nvmet_passthru "${subsysnqn}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
+ port="$(_create_nvmet_port)"
_add_nvmet_subsys_to_port "${port}" "${subsysnqn}"
_create_nvmet_host "${subsysnqn}" "${def_hostnqn}"
}
--
2.45.2
More information about the Linux-nvme
mailing list