@@ -31,7 +31,7 @@ test() {
_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-$i"
done
- nvme discover -t loop | _filter_discovery
+ _nvme_discover "loop" | _filter_discovery
for ((i = iterations - 1; i >= 0; i--)); do
_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-$i"
@@ -29,7 +29,7 @@ test() {
_create_nvmet_subsystem "blktests-subsystem-1" "${loop_dev}"
_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
- nvme connect -t loop -n nqn.2014-08.org.nvmexpress.discovery
+ _nvme_connect_subsys "loop" "nqn.2014-08.org.nvmexpress.discovery"
# This is ugly but checking for the absence of error messages is ...
sleep 10
@@ -42,7 +42,7 @@ test() {
echo "Fail"
fi
- nvme disconnect -n nqn.2014-08.org.nvmexpress.discovery
+ _nvme_disconnect_subsys "nqn.2014-08.org.nvmexpress.discovery"
_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
_remove_nvmet_subsystem "blktests-subsystem-1"
_remove_nvmet_port "${port}"
@@ -33,14 +33,14 @@ test() {
"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
- nvme connect -t loop -n blktests-subsystem-1
+ _nvme_connect_subsys "loop" "blktests-subsystem-1"
local nvmedev
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
cat "/sys/block/${nvmedev}n1/wwid"
- nvme disconnect -n "blktests-subsystem-1"
+ _nvme_disconnect_subsys "blktests-subsystem-1"
_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
_remove_nvmet_subsystem "blktests-subsystem-1"
_remove_nvmet_port "${port}"
@@ -33,7 +33,7 @@ test() {
"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
- nvme connect -t loop -n blktests-subsystem-1
+ _nvme_connect_subsys "loop" "blktests-subsystem-1"
local nvmedev
nvmedev="$(_find_nvme_loop_dev)"
@@ -42,7 +42,7 @@ test() {
echo 1 > "/sys/class/nvme/${nvmedev}/reset_controller"
- nvme disconnect -d "${nvmedev}"
+ _nvme_disconnect_ctrl "${nvmedev}"
_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
_remove_nvmet_port "${port}"
@@ -34,7 +34,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -42,7 +42,7 @@ test() {
udevadm settle
- nvme disconnect -n "${subsys_name}"
+ _nvme_disconnect_subsys "${subsys_name}"
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -30,7 +30,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -38,7 +38,7 @@ test() {
udevadm settle
- nvme disconnect -n "${subsys_name}"
+ _nvme_disconnect_subsys "${subsys_name}"
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -34,7 +34,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -42,7 +42,7 @@ test() {
_run_fio_verify_io --size=950m --filename="/dev/${nvmedev}n1"
- nvme disconnect -n "${subsys_name}"
+ _nvme_disconnect_subsys "${subsys_name}"
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -32,7 +32,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -40,7 +40,7 @@ test() {
_run_fio_verify_io --size=950m --filename="/dev/${nvmedev}n1"
- nvme disconnect -n "${subsys_name}"
+ _nvme_disconnect_subsys "${subsys_name}"
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -38,7 +38,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -54,7 +54,7 @@ test() {
umount "${mount_dir}" > /dev/null 2>&1
- nvme disconnect -n "${subsys_name}"
+ _nvme_disconnect_subsys "${subsys_name}"
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -35,7 +35,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -51,7 +51,7 @@ test() {
umount "${mount_dir}" > /dev/null 2>&1
- nvme disconnect -n "${subsys_name}"
+ _nvme_disconnect_subsys "${subsys_name}"
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -34,7 +34,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -44,7 +44,7 @@ test() {
nvme flush "/dev/${nvmedev}" -n 1
- nvme disconnect -n "${subsys_name}"
+ _nvme_disconnect_subsys "${subsys_name}"
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -31,7 +31,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -41,7 +41,7 @@ test() {
nvme flush "/dev/${nvmedev}n1" -n 1
- nvme disconnect -n "${subsys_name}"
+ _nvme_disconnect_subsys "${subsys_name}"
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -33,7 +33,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "$port" "${subsys_nqn}"
- nvme discover -t loop | _filter_discovery
+ _nvme_discover "loop" | _filter_discovery
_remove_nvmet_subsystem_from_port "${port}" "${subsys_nqn}"
_remove_nvmet_port "${port}"
@@ -36,7 +36,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme discover -t loop | _filter_discovery
+ _nvme_discover "loop" | _filter_discovery
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_port "${port}"
@@ -32,7 +32,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -46,7 +46,7 @@ test() {
nvme read "/dev/${nvmedev}n1" -s "$sectors" -c 0 -z "$bs" &>"$FULL" \
&& echo "ERROR: nvme read for out of range LBA was not rejected"
- nvme disconnect -n "${subsys_name}"
+ _nvme_disconnect_subsys "${subsys_name}"
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -36,7 +36,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -44,7 +44,7 @@ test() {
nvme dsm "/dev/${nvmedev}" -n 1 -d -s "${sblk_range}" -b "${nblk_range}"
- nvme disconnect -n "${subsys_name}"
+ _nvme_disconnect_subsys "${subsys_name}"
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -32,7 +32,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -40,7 +40,7 @@ test() {
nvme dsm "/dev/${nvmedev}" -n 1 -d -s "${sblk_range}" -b "${nblk_range}"
- nvme disconnect -n "${subsys_name}"
+ _nvme_disconnect_subsys "${subsys_name}"
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -31,7 +31,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -41,7 +41,7 @@ test() {
echo "ERROR: device not listed"
fi
- nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+ _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -31,7 +31,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -41,7 +41,7 @@ test() {
echo "ERROR: reset failed"
fi
- nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+ _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -34,7 +34,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -44,7 +44,7 @@ test() {
echo "ERROR: smart-log bdev-ns failed"
fi
- nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+ _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -31,7 +31,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -40,7 +40,7 @@ test() {
if ! nvme smart-log "/dev/${nvmedev}" -n 1 >> "$FULL" 2>&1; then
echo "ERROR: smart-log file-ns failed"
fi
- nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+ _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -31,7 +31,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -41,7 +41,7 @@ test() {
echo "ERROR: effects-log failed"
fi
- nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+ _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -31,7 +31,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -41,7 +41,7 @@ test() {
echo "ERROR: ns-desc failed"
fi
- nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+ _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -31,7 +31,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -40,7 +40,7 @@ test() {
if ! nvme ns-rescan "/dev/${nvmedev}" >> "$FULL" 2>&1; then
echo "ERROR: ns-rescan failed"
fi
- nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+ _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -31,7 +31,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -40,7 +40,7 @@ test() {
if ! nvme list-subsys 2>> "$FULL" | grep -q loop; then
echo "ERROR: list-subsys"
fi
- nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+ _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -67,7 +67,7 @@ test() {
port="$(_create_nvmet_port "loop")"
_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
- nvme connect -t loop -n "${subsys_name}"
+ _nvme_connect_subsys "loop" "${subsys_name}"
nvmedev="$(_find_nvme_loop_dev)"
cat "/sys/block/${nvmedev}n1/uuid"
@@ -81,7 +81,7 @@ test() {
test_user_io "$dev" 511 1023 > "$FULL" 2>&1 || echo FAIL
test_user_io "$dev" 511 1025 > "$FULL" 2>&1 || echo FAIL
- nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+ _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
_remove_nvmet_subsystem "${subsys_name}"
@@ -41,8 +41,8 @@ test() {
for ((i = 0; i < iterations; i++)); do
_create_nvmet_subsystem "${subsys}$i" "${loop_dev}"
_add_nvmet_subsys_to_port "${port}" "${subsys}$i"
- nvme connect -t loop -n "${subsys}$i"
- nvme disconnect -n "${subsys}$i" >> "${FULL}" 2>&1
+ _nvme_connect_subsys "loop" "${subsys}$i"
+ _nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1
_remove_nvmet_subsystem_from_port "${port}" "${subsys}$i"
_remove_nvmet_subsystem "${subsys}$i"
done
@@ -64,7 +64,7 @@ _cleanup_nvmet() {
transport="$(cat "/sys/class/nvme/${dev}/transport")"
if [[ "$transport" == "loop" ]]; then
echo "WARNING: Test did not clean up loop device: ${dev}"
- nvme disconnect -d "${dev}"
+ _nvme_disconnect_ctrl "${dev}"
fi
done
@@ -97,6 +97,33 @@ _setup_nvmet() {
modprobe nvme-loop
}
+_nvme_disconnect_ctrl() {
+ local ctrl="$1"
+
+ nvme disconnect -d ${ctrl}
+}
+
+_nvme_disconnect_subsys() {
+ local subsysnqn="$1"
+
+ nvme disconnect -n ${subsysnqn}
+}
+
+_nvme_connect_subsys() {
+ local trtype="$1"
+ local subsysnqn="$2"
+
+ cmd="nvme connect -t ${trtype} -n ${subsysnqn}"
+ eval $cmd
+}
+
+_nvme_discover() {
+ local trtype="$1"
+
+ cmd="nvme discover -t ${trtype}"
+ eval $cmd
+}
+
_create_nvmet_port() {
local trtype="$1"
@@ -206,6 +233,6 @@ _filter_discovery() {
}
_discovery_genctr() {
- nvme discover -t loop |
+ _nvme_discover "loop" |
sed -n -e 's/^.*Generation counter \([0-9]\+\).*$/\1/p'
}
Signed-off-by: Sagi Grimberg <sagi@grimberg.me> --- tests/nvme/002 | 2 +- tests/nvme/003 | 4 ++-- tests/nvme/004 | 4 ++-- tests/nvme/005 | 4 ++-- tests/nvme/008 | 4 ++-- tests/nvme/009 | 4 ++-- tests/nvme/010 | 4 ++-- tests/nvme/011 | 4 ++-- tests/nvme/012 | 4 ++-- tests/nvme/013 | 4 ++-- tests/nvme/014 | 4 ++-- tests/nvme/015 | 4 ++-- tests/nvme/016 | 2 +- tests/nvme/017 | 2 +- tests/nvme/018 | 4 ++-- tests/nvme/019 | 4 ++-- tests/nvme/020 | 4 ++-- tests/nvme/021 | 4 ++-- tests/nvme/022 | 4 ++-- tests/nvme/023 | 4 ++-- tests/nvme/024 | 4 ++-- tests/nvme/025 | 4 ++-- tests/nvme/026 | 4 ++-- tests/nvme/027 | 4 ++-- tests/nvme/028 | 4 ++-- tests/nvme/029 | 4 ++-- tests/nvme/031 | 4 ++-- tests/nvme/rc | 31 +++++++++++++++++++++++++++++-- 28 files changed, 80 insertions(+), 53 deletions(-)