Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ANA support #146

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
78b7506
nvme/038: use nvme_trtype instead of hardcoding
hreinecke Sep 26, 2024
5b35c28
nvme: make trtype argument to _create_nvmet_port() optional
hreinecke Sep 27, 2024
77fdd21
nvme: sanitize transport parameter in _create_nvmet_port()
hreinecke Sep 27, 2024
7a1f281
nvme: return error from _find_nvme_ns()
hreinecke Oct 1, 2024
75c68a0
nvme: simplify _get_nvmet_ports()
hreinecke Sep 29, 2024
c5c1348
nvme: check for controller device in _nvme_connect_subsys()
hreinecke Oct 8, 2024
1bfeee1
nvme: pass in port parameter to _nvme_connect_subsys()
hreinecke Sep 27, 2024
1994b24
common/nvme, nvme/{rc,054}: remove "local -n" from _get_nvmet_ports()
kawasaki Oct 8, 2024
dd65b11
nvme: delete all namespaces in _remove_nvmet_subsystem()
hreinecke Oct 4, 2024
46669ad
nvme: support only long options for _create_nvmet_ns()
hreinecke Oct 4, 2024
a2162e7
nvme: support only long options for _create_nvmet_subsystem()
hreinecke Oct 9, 2024
88e67d0
nvme/rc: Implement --blkdev none for _nvmet_target_setup()
hreinecke Oct 4, 2024
7d0069f
nvme: move _nvmet_target_setup() to common/nvme
hreinecke Oct 9, 2024
4cef26a
nvme/016: do not create namespace when setting up the target
hreinecke Oct 4, 2024
48c8518
nvme/017: do not create namespace when setting up the target
hreinecke Oct 4, 2024
89c5bf6
nvme/052: do not create namespace when setting up the target
hreinecke Oct 4, 2024
8aa02ae
nvme/003: open-code _nvmet_setup
hreinecke Oct 9, 2024
e9aabff
nvme/031: open-code helper functions
hreinecke Oct 9, 2024
5545881
nvme: rework fcloop
hreinecke Oct 2, 2024
5f889bb
nvme: drop arguments from _create_nvmet_port()
hreinecke Oct 9, 2024
6685f89
nvme: add _setup_nvmet_port_ana()
hreinecke Sep 26, 2024
e0ad900
nvme: add _setup_nvmet_ns_ana()
hreinecke Sep 26, 2024
8d7cd69
nvme/rc: add argument '--ports' to _nvmet_target_setup()
hreinecke Sep 28, 2024
9f949ba
nvme: delete all ana_groups when removing a port
hreinecke Oct 2, 2024
a3f7272
test/nvme: add test for basic ANA support
hreinecke Sep 30, 2024
5ad1068
test/nvme: add test for rapid namespace remapping
hreinecke Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
432 changes: 336 additions & 96 deletions common/nvme

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/md/001
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ setup_nvme_over_tcp() {
_setup_nvmet

local port
port="$(_create_nvmet_port "${nvme_trtype}")"
port="$(_create_nvmet_port)"

_create_nvmet_subsystem "${def_subsysnqn}" "/dev/mapper/ram0_big_optio" "${def_subsys_uuid}"
_create_nvmet_subsystem --blkdev "/dev/mapper/ram0_big_optio"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"

_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
Expand Down
5 changes: 3 additions & 2 deletions tests/nvme/002
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ test() {

local iterations=1000
local port
port="$(_create_nvmet_port "${nvme_trtype}")"
port="$(_create_nvmet_port)"

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

local genctr=1

for ((i = 0; i < iterations; i++)); do
_create_nvmet_subsystem "blktests-subsystem-$i" "${loop_dev}"
_create_nvmet_subsystem --subsysnqn "blktests-subsystem-$i" \
--blkdev "${loop_dev}"
_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-$i"
done

Expand Down
8 changes: 6 additions & 2 deletions tests/nvme/003
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ test() {

_setup_nvmet

_nvmet_target_setup
_create_nvmet_subsystem
port="$(_create_nvmet_port)"
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys --subsysnqn "nqn.2014-08.org.nvmexpress.discovery"
_nvme_connect_subsys --port "${port}" --no-wait \
--subsysnqn "nqn.2014-08.org.nvmexpress.discovery"

# This is ugly but checking for the absence of error messages is ...
sleep 10
Expand Down
13 changes: 5 additions & 8 deletions tests/nvme/016
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,21 @@ test() {
loop_dev="$(losetup -f)"
local genctr=1

_create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}"
_create_nvmet_subsystem

for ((i = 2; i <= iterations; i++)); do
_create_nvmet_ns "${def_subsysnqn}" "${i}" "${loop_dev}"
for i in $(seq 1 "${iterations}"); do
_create_nvmet_ns --nsid "${i}" \
--blkdev "${loop_dev}" > /dev/null
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")

_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_port "${port}"

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

_remove_nvmet_subsystem "${def_subsysnqn}"

echo "Test complete"
Expand Down
15 changes: 5 additions & 10 deletions tests/nvme/017
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,21 @@ test() {

local genctr=1

_create_nvmet_subsystem "${def_subsysnqn}" "$(_nvme_def_file_path)" \
"${def_subsys_uuid}"
_create_nvmet_subsystem

for ((i = 2; i <= iterations; i++)); do
_create_nvmet_ns "${def_subsysnqn}" "${i}" \
"$(_nvme_def_file_path)"
for i in $(seq 1 "${iterations}"); do
_create_nvmet_ns --nsid "${i}" \
--blkdev "$(_nvme_def_file_path)" > /dev/null
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")

_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
_remove_nvmet_port "${port}"

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

_remove_nvmet_subsystem "${def_subsysnqn}"

rm "$(_nvme_def_file_path)"
Expand Down
8 changes: 5 additions & 3 deletions tests/nvme/030
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ test() {
local genctr
local subsys="blktests-subsystem-"

port="$(_create_nvmet_port "${nvme_trtype}")"
port="$(_create_nvmet_port)"

_create_nvmet_subsystem "${subsys}1" "$(losetup -f)"
_create_nvmet_subsystem --subsysnqn "${subsys}1" \
--blkdev "$(losetup -f)"
_add_nvmet_subsys_to_port "${port}" "${subsys}1"
_create_nvmet_host "${subsys}1" "${def_hostnqn}"

genctr=$(_discovery_genctr)

_create_nvmet_subsystem "${subsys}2" "$(losetup -f)"
_create_nvmet_subsystem --subsysnqn "${subsys}2" \
--blkdev "$(losetup -f)"
_add_nvmet_subsys_to_port "${port}" "${subsys}2"

genctr=$(_check_genctr "${genctr}" "adding a subsystem to a port")
Expand Down
16 changes: 10 additions & 6 deletions tests/nvme/031
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,21 @@ 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" \
subsysnqn=$(printf "blktests-subsystem-%d" "$i")
_create_nvmet_subsystem --subsysnqn "${subsysnqn}" \
--blkdev "${loop_dev}"
_add_nvmet_subsys_to_port "${port}" "${subsysnqn}"
_create_nvmet_host "${subsysnqn}" "${def_hostnqn}"

_nvme_connect_subsys --subsysnqn "${subsys}$i"
_nvme_disconnect_subsys --subsysnqn "${subsys}$i" >> "${FULL}" 2>&1
_nvme_connect_subsys --subsysnqn "${subsysnqn}"
_nvme_disconnect_subsys --subsysnqn "${subsysnqn}" >> "${FULL}" 2>&1

_nvmet_target_cleanup --subsysnqn "${subsys}$i" \
--blkdev "${loop_dev}"
_remove_nvmet_subsystem_from_port "${port}" "${subsysnqn}"
_remove_nvmet_subsystem "${subsysnqn}"
_remove_nvmet_host "${def_hostnqn}"
done

_remove_nvmet_port "${port}"
Expand Down
2 changes: 1 addition & 1 deletion tests/nvme/038
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test() {
mkdir -p "${subsys_path}"
rmdir "${subsys_path}"

port=$(_create_nvmet_port loop)
port="$(_create_nvmet_port)"
_remove_nvmet_port "${port}"

echo "Test complete"
Expand Down
23 changes: 11 additions & 12 deletions tests/nvme/052
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ test() {

local iterations=20

_nvmet_target_setup
_nvmet_target_setup --blkdev none

_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
# 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="$(uuidgen -r)"
for i in $(seq 1 "${iterations}"); do
local file_path

_create_nvmet_ns "${def_subsysnqn}" "${i}" "$(_nvme_def_file_path).$i" "${uuid}"
file_path="$(_nvme_def_file_path).${i}"
truncate -s "${NVME_IMG_SIZE}" "${file_path}"

uuid=$(_create_nvmet_ns --subsysnqn "${def_subsysnqn}" \
--nsid "${i}" --blkdev "${file_path}")

# 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 "${file_path}"
break
fi

Expand All @@ -78,12 +78,11 @@ test() {
# 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 "${file_path}"
break
fi

rm "$(_nvme_def_file_path).$i"
}
rm "${file_path}"
done

_nvme_disconnect_subsys >> "${FULL}" 2>&1
Expand Down
97 changes: 97 additions & 0 deletions tests/nvme/054
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+
# Copyright (C) 2024 Hannes Reinecke (SUSE) <[email protected]>
#
# Test nvme fabrics controller ANA failover during I/O

. tests/nvme/rc

DESCRIPTION="test nvme fabrics controller ANA failover during I/O"

requires() {
_nvme_requires
_have_loop
_have_fio
_require_nvme_trtype_is_fabrics
}

set_conditions() {
_set_nvme_trtype "$@"
}

failback() {
local portno=0

for port in "$@"; do
if (( portno == 0 )); then
_setup_nvmet_port_ana "${port}" 1 "optimized"
elif (( portno == 1 )); then
_setup_nvmet_port_ana "${port}" 1 "non-optimized"
else
_setup_nvmet_port_ana "${port}" 1 "inaccessible"
fi
portno=$(( portno + 1 ))
done
}

failover() {
local portno=0

for port in "$@"; do
if (( portno == 2 )); then
_setup_nvmet_port_ana "${port}" 1 "optimized"
elif (( portno == 3 )); then
_setup_nvmet_port_ana "${port}" 1 "non-optimized"
else
_setup_nvmet_port_ana "${port}" 1 "inaccessible"
fi
portno=$(( portno + 1))
done
}

test() {
local fio_pid
local -a ports
local port
local ns

echo "Running ${TEST_NAME}"

_setup_nvmet

_nvmet_target_setup --ports 4

read -ra ports < <(_get_nvmet_ports)
failback "${ports[@]}"

for port in "${ports[@]}"; do
_nvme_connect_subsys --port "${port}"
done

# start fio job
ns=$(_find_nvme_ns "$def_subsys_uuid")
_run_fio_verify_io --filename="/dev/${ns}" \
--group_reporting --ramp-time=5 \
--time_based --runtime=1m &> "$FULL" &
fio_pid=$!
sleep 5

# switch port status
echo "ANA failover"
failover "${ports[@]}"

sleep 10

# switch back to original state
echo "ANA failback"
failback "${ports[@]}"

sleep 10

{ kill "${fio_pid}"; wait; } &> /dev/null

_nvme_disconnect_subsys
_nvmet_target_cleanup

echo "Test complete"
}
5 changes: 5 additions & 0 deletions tests/nvme/054.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Running nvme/054
ANA failover
ANA failback
disconnected 4 controller(s)
Test complete
Loading
Loading