Skip to content

Commit

Permalink
common/nvme, nvme/{016,017,051,052}: introduce def_nsid
Browse files Browse the repository at this point in the history
Use def_nsid instead of hard code, the default of def_nsid is 1.

Signed-off-by: Guixin Liu <[email protected]>
Reviewed-by: Daniel Wagner <[email protected]>
Reviewed-by: Chaitanya Kulkarni <[email protected]>
[Shin'ichiro: resolved conflicts with "prepare for ANA support" series]
Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
  • Loading branch information
guixinliu1995 authored and kawasaki committed Nov 5, 2024
1 parent fe6cd13 commit 87d4c0c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
5 changes: 3 additions & 2 deletions common/nvme
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def_hostid="0f01fb42-9f7f-4856-b0b3-51e60b8de349"
def_hostnqn="nqn.2014-08.org.nvmexpress:uuid:${def_hostid}"
export def_subsysnqn="blktests-subsystem-1"
export def_subsys_uuid="91fdba0d-f87b-4c25-b80f-db7be1418b9e"
export def_nsid="1"
_check_conflict_and_set_default NVMET_TRTYPES nvme_trtype "loop"
_check_conflict_and_set_default NVME_IMG_SIZE nvme_img_size 1G
_check_conflict_and_set_default NVME_NUM_ITER nvme_num_iter 1000
Expand Down Expand Up @@ -512,7 +513,7 @@ _remove_nvmet_port() {

_create_nvmet_ns() {
local subsysnqn="${def_subsysnqn}"
local nsid="1"
local nsid="${def_nsid}"
local grpid="1"
local blkdev
local uuid
Expand Down Expand Up @@ -667,7 +668,7 @@ _remove_nvmet_subsystem() {
local nvmet_subsystem="$1"
local subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}"

_remove_nvmet_ns "${nvmet_subsystem}" "1"
_remove_nvmet_ns "${nvmet_subsystem}" "${def_nsid}"
rm -f "${subsys_path}"/allowed_hosts/*
rmdir "${subsys_path}"
}
Expand Down
7 changes: 5 additions & 2 deletions tests/nvme/016
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ test() {
local port
local iterations="${NVME_NUM_ITER}"
local loop_dev
local nsid

loop_dev="$(losetup -f)"
local genctr=1

_create_nvmet_subsystem --blkdev "${loop_dev}"

for ((i = 2; i <= iterations; i++)); do
_create_nvmet_ns --nsid "${i}" \
nsid=$((def_nsid + i - 1))
_create_nvmet_ns --nsid "${nsid}" \
--blkdev "${loop_dev}" > /dev/null
done

Expand All @@ -46,7 +48,8 @@ test() {
_remove_nvmet_port "${port}"

for ((i = iterations; i > 1; i--)); do
_remove_nvmet_ns "${def_subsysnqn}" "$i"
nsid=$((def_nsid + i - 1))
_remove_nvmet_ns "${def_subsysnqn}" "${nsid}"
done

_remove_nvmet_subsystem "${def_subsysnqn}"
Expand Down
7 changes: 5 additions & 2 deletions tests/nvme/017
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ test() {

local port
local iterations="${NVME_NUM_ITER}"
local nsid

truncate -s "${NVME_IMG_SIZE}" "$(_nvme_def_file_path)"

Expand All @@ -32,7 +33,8 @@ test() {
_create_nvmet_subsystem --blkdev "$(_nvme_def_file_path)"

for ((i = 2; i <= iterations; i++)); do
_create_nvmet_ns --nsid "${i}" \
nsid=$((def_nsid + i - 1))
_create_nvmet_ns --nsid "${nsid}" \
--blkdev "$(_nvme_def_file_path)" > /dev/null
done

Expand All @@ -46,7 +48,8 @@ test() {
_remove_nvmet_port "${port}"

for ((i = iterations; i > 1; i--)); do
_remove_nvmet_ns "${def_subsysnqn}" "$i"
nsid=$((def_nsid + i - 1))
_remove_nvmet_ns "${def_subsysnqn}" "${nsid}"
done

_remove_nvmet_subsystem "${def_subsysnqn}"
Expand Down
2 changes: 1 addition & 1 deletion tests/nvme/051
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test() {
_setup_nvmet

_nvmet_target_setup
ns="${NVMET_CFS}subsystems/${def_subsysnqn}/namespaces/1"
ns="${NVMET_CFS}subsystems/${def_subsysnqn}/namespaces/${def_nsid}"

# fire off two enable/disable loops concurrently and wait
# for them to complete...
Expand Down
22 changes: 11 additions & 11 deletions tests/nvme/052
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,38 @@ test() {
_setup_nvmet

local iterations=20
local uuid
local uuid nsid filepath

_nvmet_target_setup

_nvme_connect_subsys

# start iteration from ns-id 2 because ns-id 1 is created
# by default when nvme target is setup. Also ns-id 1 is
# start iteration from def_nsid+1 because def_nsid is created
# by default when nvme target is setup. Also def_nsid is
# deleted when nvme target is cleaned up.
for ((i = 2; i <= iterations; i++)); do {
truncate -s "${NVME_IMG_SIZE}" "$(_nvme_def_file_path).$i"

uuid=$(_create_nvmet_ns --blkdev "$(_nvme_def_file_path).$i" \
--nsid "${i}")
nsid=$((def_nsid + i - 1))
filepath="$(_nvme_def_file_path).${nsid}"
truncate -s "${NVME_IMG_SIZE}" "$filepath"
uuid=$(_create_nvmet_ns --blkdev "$filepath" --nsid "${nsid}")

# wait until async request is processed and ns is created
if ! nvmf_wait_for_ns "${uuid}" created; then
echo "FAIL"
rm "$(_nvme_def_file_path).$i"
rm "$filepath"
break
fi

_remove_nvmet_ns "${def_subsysnqn}" "${i}"
_remove_nvmet_ns "${def_subsysnqn}" "${nsid}"

# wait until async request is processed and ns is removed
if ! nvmf_wait_for_ns "${uuid}" removed; then
echo "FAIL"
rm "$(_nvme_def_file_path).$i"
rm "$filepath"
break
fi

rm "$(_nvme_def_file_path).$i"
rm "$filepath"
}
done

Expand Down

0 comments on commit 87d4c0c

Please sign in to comment.