@@ -22,15 +22,8 @@ test() {
_setup_nvmet
- local loop_dev
- local port
- port="$(_create_nvmet_port "${nvme_trtype}")"
-
- loop_dev="$(losetup -f)"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" nqn.2014-08.org.nvmexpress.discovery
@@ -46,9 +39,8 @@ test() {
fi
_nvme_disconnect_subsys nqn.2014-08.org.nvmexpress.discovery
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
+
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -22,19 +22,8 @@ test() {
_setup_nvmet
- local port
- local loop_dev
- port="$(_create_nvmet_port "${nvme_trtype}")"
-
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "${def_subsys_uuid}"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -44,12 +33,8 @@ test() {
cat "/sys/block/${nvmedev}n1/wwid"
_nvme_disconnect_subsys ${def_subsysnqn}
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
- losetup -d "$loop_dev"
- rm "${def_file_path}"
+
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -21,20 +21,9 @@ test() {
_setup_nvmet
- local port
- local loop_dev
local nvmedev
- port="$(_create_nvmet_port "${nvme_trtype}")"
-
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "${def_subsys_uuid}"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -45,13 +34,8 @@ test() {
echo 1 > "/sys/class/nvme/${nvmedev}/reset_controller"
_nvme_disconnect_ctrl "${nvmedev}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_host "${def_hostnqn}"
- losetup -d "$loop_dev"
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,25 +20,10 @@ test() {
_setup_nvmet
- local port
- local loop_dev
- truncate -s "${nvme_img_size}" "${def_file_path}"
+ _nvmet_target_setup --blkdev=device
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
-
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
-
- losetup -d "$loop_dev"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -19,20 +19,10 @@ test() {
_setup_nvmet
- local port
- truncate -s "${nvme_img_size}" "${def_file_path}"
+ _nvmet_target_setup --blkdev=file
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
-
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,19 +20,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- local loop_dev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -44,14 +34,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- losetup -d "${loop_dev}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -19,16 +19,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -40,12 +33,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,19 +20,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- local loop_dev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -45,14 +35,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- losetup -d "${loop_dev}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,16 +20,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -42,12 +35,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -24,19 +24,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- local loop_dev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -48,14 +38,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- losetup -d "${loop_dev}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -23,16 +23,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -44,12 +37,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,22 +20,12 @@ test() {
_setup_nvmet
- local port
local nvmedev
- local loop_dev
local size
local bs
local count
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -54,14 +44,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- losetup -d "${loop_dev}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,19 +20,12 @@ test() {
_setup_nvmet
- local port
local nvmedev
local size
local bs
local count
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -51,12 +44,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -21,16 +21,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -48,12 +41,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,21 +20,11 @@ test() {
_setup_nvmet
- local port
local nvmedev
- local loop_dev
local nblk_range="10,10,10,10,10,10,10,10,10,10"
local sblk_range="100,200,300,400,500,600,700,800,900,1000"
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -46,14 +36,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- losetup -d "${loop_dev}"
-
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -19,18 +19,11 @@ test() {
_setup_nvmet
- local port
local nvmedev
local nblk_range="10,10,10,10,10,10,10,10,10,10"
local sblk_range="100,200,300,400,500,600,700,800,900,1000"
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -42,12 +35,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,16 +20,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -43,12 +36,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,16 +20,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -43,12 +36,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,19 +20,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- local loop_dev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -46,14 +36,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- losetup -d "${loop_dev}"
-
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,16 +20,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -42,12 +35,7 @@ test() {
fi
_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,16 +20,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -43,12 +36,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,16 +20,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -43,12 +36,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,16 +20,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -40,14 +33,10 @@ test() {
if ! nvme ns-rescan "/dev/${nvmedev}" >> "$FULL" 2>&1; then
echo "ERROR: ns-rescan failed"
fi
- _nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
+ _nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -20,16 +20,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -40,14 +33,10 @@ test() {
if ! nvme list-subsys 2>> "$FULL" | grep -q "${nvme_trtype}"; then
echo "ERROR: list-subsys"
fi
- _nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
+ _nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -53,19 +53,9 @@ test() {
_setup_nvmet
- local port
local nvmedev
- local loop_dev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -83,14 +73,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- losetup -d "${loop_dev}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -21,18 +21,10 @@ test() {
_setup_nvmet
- local port
- local loop_dev
local nvmedev
local fio_pid
- truncate -s "${nvme_img_size}" "${def_file_path}"
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
udevadm settle
@@ -55,14 +47,7 @@ test() {
{ kill "${fio_pid}"; wait; } &> /dev/null
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- losetup -d "${loop_dev}"
-
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -24,7 +24,6 @@ test() {
_setup_nvmet
- local port
local hostkey
local ctrldev
@@ -34,13 +33,7 @@ test() {
return 1
fi
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" "${hostkey}"
+ _nvmet_target_setup --blkdev=file --hostkey "${hostkey}"
# Test unauthenticated connection (should fail)
echo "Test unauthenticated connection (should fail)"
@@ -61,14 +54,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
-
- _remove_nvmet_port "${port}"
-
- _remove_nvmet_host "${def_hostnqn}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -24,18 +24,12 @@ test() {
_setup_nvmet
- local port
local hmac
local key_len
local hostkey
local ctrldev
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
for hmac in 0 1 2 3; do
echo "Testing hmac ${hmac}"
@@ -74,14 +68,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
done
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
-
- _remove_nvmet_port "${port}"
-
- _remove_nvmet_host "${def_hostnqn}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -25,7 +25,6 @@ test() {
_setup_nvmet
- local port
local hash
local dhgroup
local hostkey
@@ -37,12 +36,7 @@ test() {
return 1
fi
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" "${hostkey}"
+ _nvmet_target_setup --blkdev=file --hostkey "${hostkey}"
for hash in "hmac(sha256)" "hmac(sha384)" "hmac(sha512)" ; do
@@ -76,14 +70,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
done
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
-
- _remove_nvmet_port "${port}"
-
- _remove_nvmet_host "${def_hostnqn}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -25,7 +25,6 @@ test() {
_setup_nvmet
- local port
local hostkey
local ctrlkey
local ctrldev
@@ -42,13 +41,8 @@ test() {
return 1
fi
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" \
- "${hostkey}" "${ctrlkey}"
+ _nvmet_target_setup --blkdev=file --ctrlkey "${ctrlkey}" \
+ --hostkey "${hostkey}"
_set_nvmet_dhgroup "${def_hostnqn}" "ffdhe2048"
@@ -103,14 +97,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
-
- _remove_nvmet_port "${port}"
-
- _remove_nvmet_host "${def_hostnqn}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -26,7 +26,6 @@ test() {
_setup_nvmet
- local port
local hostkey
local new_hostkey
local ctrlkey
@@ -46,12 +45,8 @@ test() {
return 1
fi
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" "${hostkey}" "${ctrlkey}"
+ _nvmet_target_setup --blkdev=file --ctrlkey "${ctrlkey}" \
+ --hostkey "${hostkey}"
_set_nvmet_dhgroup "${def_hostnqn}" "ffdhe2048"
@@ -116,14 +111,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}"
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
-
- _remove_nvmet_port "${port}"
-
- _remove_nvmet_host "${def_hostnqn}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -22,20 +22,10 @@ test() {
_setup_nvmet
- local port
local nvmedev
- local loop_dev
local rand_io_size
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- loop_dev="$(losetup -f --show "${def_file_path}")"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=device
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
--nr-write-queues 1 || echo FAIL
@@ -55,14 +45,7 @@ test() {
_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- losetup -d "${loop_dev}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
echo "Test complete"
}
@@ -87,16 +87,8 @@ test() {
local cfs_path="${NVMET_CFS}/subsystems/${def_subsysnqn}"
local skipped=false
- local port
- truncate -s "${nvme_img_size}" "${def_file_path}"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${def_file_path}" \
- "${def_subsys_uuid}"
- port="$(_create_nvmet_port "${nvme_trtype}")"
-
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
- _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+ _nvmet_target_setup --blkdev=file
if [[ -f "${cfs_path}/attr_qid_max" ]] ; then
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
@@ -118,12 +110,7 @@ test() {
skipped=true
fi
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
- _remove_nvmet_host "${def_hostnqn}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup
if [[ "${skipped}" = true ]] ; then
return 1
@@ -359,6 +359,12 @@ _cleanup_nvmet() {
if [[ "${nvme_trtype}" == "rdma" ]]; then
stop_soft_rdma
fi
+
+ blkdev="$(losetup -l | awk '$6 == "'"${def_file_path}"'" { print $1 }')"
+ for dev in ${blkdev}; do
+ losetup -d "${dev}"
+ done
+ rm -f "${def_file_path}"
}
_setup_nvmet() {
@@ -712,6 +718,19 @@ _remove_nvmet_subsystem_from_port() {
rm "${NVMET_CFS}/ports/${port}/subsystems/${nvmet_subsystem}"
}
+_get_nvmet_ports() {
+ local nvmet_subsystem="$1"
+ local -n nvmet_ports="$2"
+ local cfs_path="${NVMET_CFS}/ports"
+ local sarg
+
+ sarg="s;^${cfs_path}/\([0-9]\+\)/subsystems/${nvmet_subsystem}$;\1;p"
+
+ for path in "${cfs_path}/"*"/subsystems/${nvmet_subsystem}"; do
+ nvmet_ports+=("$(echo "${path}" | sed -n -s "${sarg}")")
+ done
+}
+
_set_nvmet_hostkey() {
local nvmet_hostnqn="$1"
local nvmet_hostkey="$2"
@@ -779,6 +798,69 @@ _find_nvme_passthru_loop_dev() {
echo "/dev/${dev}n${nsid}"
}
+_nvmet_target_setup() {
+ local blkdev_type="device"
+ local blkdev
+ local ctrlkey=""
+ local hostkey=""
+ local port
+
+ while [[ $# -gt 0 ]]; do
+ case $1 in
+ --blkdev)
+ blkdev_type="$2"
+ shift 2
+ ;;
+ --ctrlkey)
+ ctrlkey="$2"
+ shift 2
+ ;;
+ --hostkey)
+ hostkey="$2"
+ shift 2
+ ;;
+ *)
+ shift
+ ;;
+ esac
+ done
+
+ truncate -s "${nvme_img_size}" "${def_file_path}"
+ if [[ "${blkdev_type}" == "device" ]]; then
+ blkdev="$(losetup -f --show "${def_file_path}")"
+ else
+ blkdev="${def_file_path}"
+ fi
+
+ _create_nvmet_subsystem "${def_subsysnqn}" "${blkdev}" \
+ "${def_subsys_uuid}"
+ port="$(_create_nvmet_port "${nvme_trtype}")"
+ _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" \
+ "${hostkey}" "${ctrlkey}"
+}
+
+_nvmet_target_cleanup() {
+ local ports
+ local port
+ local blkdev
+
+ _get_nvmet_ports "${def_subsysnqn}" ports
+
+ for port in "${ports[@]}"; do
+ _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
+ done
+ _remove_nvmet_subsystem "${def_subsysnqn}"
+ _remove_nvmet_port "${port}"
+ _remove_nvmet_host "${def_hostnqn}"
+
+ blkdev="$(losetup -l | awk '$6 == "'"${def_file_path}"'" { print $1 }')"
+ if [[ -n "${blkdev}" ]] ; then
+ losetup -d "${blkdev}"
+ fi
+ rm "${def_file_path}"
+}
+
_nvmet_passthru_target_setup() {
local subsys_name=$1
Almost all fabric tests have the identically code for setting up and cleaning up the target side. Introduce two new helpers. Signed-off-by: Daniel Wagner <dwagner@suse.de> --- tests/nvme/003 | 14 ++------- tests/nvme/004 | 21 ++----------- tests/nvme/005 | 20 ++---------- tests/nvme/006 | 19 ++---------- tests/nvme/007 | 14 ++------- tests/nvme/008 | 21 ++----------- tests/nvme/009 | 16 ++-------- tests/nvme/010 | 21 ++----------- tests/nvme/011 | 16 ++-------- tests/nvme/012 | 21 ++----------- tests/nvme/013 | 16 ++-------- tests/nvme/014 | 21 ++----------- tests/nvme/015 | 16 ++-------- tests/nvme/018 | 16 ++-------- tests/nvme/019 | 21 ++----------- tests/nvme/020 | 16 ++-------- tests/nvme/021 | 16 ++-------- tests/nvme/022 | 16 ++-------- tests/nvme/023 | 21 ++----------- tests/nvme/024 | 16 ++-------- tests/nvme/025 | 16 ++-------- tests/nvme/026 | 16 ++-------- tests/nvme/027 | 17 ++--------- tests/nvme/028 | 17 ++--------- tests/nvme/029 | 21 ++----------- tests/nvme/040 | 19 ++---------- tests/nvme/041 | 18 ++--------- tests/nvme/042 | 17 ++--------- tests/nvme/043 | 17 ++--------- tests/nvme/044 | 19 ++---------- tests/nvme/045 | 18 ++--------- tests/nvme/047 | 21 ++----------- tests/nvme/048 | 17 ++--------- tests/nvme/rc | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ 34 files changed, 154 insertions(+), 519 deletions(-)