@@ -22,15 +22,9 @@ 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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" nqn.2014-08.org.nvmexpress.discovery
@@ -46,9 +40,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 "${port}"
echo "Test complete"
}
@@ -23,18 +23,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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -44,12 +34,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 "${port}"
echo "Test complete"
}
@@ -22,19 +22,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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -45,13 +35,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 "${port}"
echo "Test complete"
}
@@ -21,24 +21,10 @@ test() {
_setup_nvmet
local port
- local loop_dev
- truncate -s "${nvme_img_size}" "${def_file_path}"
+ port="$(_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 "${port}"
echo "Test complete"
}
@@ -21,18 +21,9 @@ test() {
local port
- truncate -s "${nvme_img_size}" "${def_file_path}"
+ port="$(_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 "${port}"
echo "Test complete"
}
@@ -22,17 +22,8 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -44,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 "${port}"
echo "Test complete"
}
@@ -22,13 +22,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -40,12 +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}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup "${port}"
echo "Test complete"
}
@@ -22,17 +22,8 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -45,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 "${def_file_path}"
+ _nvmet_target_cleanup "${port}"
echo "Test complete"
}
@@ -23,13 +23,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -42,12 +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}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup "${port}"
echo "Test complete"
}
@@ -26,17 +26,8 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -48,14 +39,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 "${port}"
echo "Test complete"
}
@@ -26,13 +26,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -44,12 +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}"
-
- rm "${def_file_path}"
+ _nvmet_target_cleanup "${port}"
echo "Test complete"
}
@@ -22,20 +22,11 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -54,14 +45,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 "${port}"
echo "Test complete"
}
@@ -26,13 +26,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -51,12 +45,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 "${port}"
echo "Test complete"
}
@@ -24,13 +24,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -48,12 +42,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 "${port}"
echo "Test complete"
}
@@ -22,19 +22,10 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -46,14 +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}"
-
- losetup -d "${loop_dev}"
-
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup "${port}"
echo "Test complete"
}
@@ -24,13 +24,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -42,12 +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}"
-
- rm -f "${def_file_path}"
+ _nvmet_target_cleanup "${port}"
echo "Test complete"
}
@@ -23,13 +23,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -43,12 +37,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 "${port}"
echo "Test complete"
}
@@ -23,13 +23,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -43,12 +37,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 "${port}"
echo "Test complete"
}
@@ -22,17 +22,8 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -46,14 +37,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 "${port}"
echo "Test complete"
}
@@ -23,13 +23,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -42,12 +36,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 "${port}"
echo "Test complete"
}
@@ -23,13 +23,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -43,12 +37,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 "${port}"
echo "Test complete"
}
@@ -23,13 +23,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -43,12 +37,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 "${port}"
echo "Test complete"
}
@@ -23,13 +23,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -40,14 +34,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 "${port}"
echo "Test complete"
}
@@ -23,13 +23,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -40,14 +34,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 "${port}"
echo "Test complete"
}
@@ -55,17 +55,8 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
@@ -83,14 +74,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 "${port}"
echo "Test complete"
}
@@ -22,17 +22,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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
udevadm settle
@@ -55,14 +48,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 "${port}"
echo "Test complete"
}
@@ -34,13 +34,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}"
+ port="$(_nvmet_target_setup --blkdev=file --hostkey "${hostkey}")"
# Test unauthenticated connection (should fail)
echo "Test unauthenticated connection (should fail)"
@@ -61,14 +55,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 "${port}"
echo "Test complete"
}
@@ -30,12 +30,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
for hmac in 0 1 2 3; do
echo "Testing hmac ${hmac}"
@@ -74,14 +69,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 "${port}"
echo "Test complete"
}
@@ -37,12 +37,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}"
+ port="$(_nvmet_target_setup --blkdev=file --hostkey "${hostkey}")"
for hash in "hmac(sha256)" "hmac(sha384)" "hmac(sha512)" ; do
@@ -76,14 +71,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 "${port}"
echo "Test complete"
}
@@ -42,13 +42,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}"
+ port="$(_nvmet_target_setup --blkdev=file --ctrlkey "${ctrlkey}" \
+ --hostkey "${hostkey}")"
_set_nvmet_dhgroup "${def_hostnqn}" "ffdhe2048"
@@ -103,14 +98,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 "${port}"
echo "Test complete"
}
@@ -46,12 +46,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}"
+ port="$(_nvmet_target_setup --blkdev=file --ctrlkey "${ctrlkey}" \
+ --hostkey "${hostkey}")"
_set_nvmet_dhgroup "${def_hostnqn}" "ffdhe2048"
@@ -116,14 +112,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 "${port}"
echo "Test complete"
}
@@ -24,18 +24,9 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
--nr-write-queues 1 || echo FAIL
@@ -55,14 +46,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 "${port}"
echo "Test complete"
}
@@ -89,14 +89,7 @@ test() {
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}"
+ port="$(_nvmet_target_setup --blkdev=file)"
if [[ -f "${cfs_path}/attr_qid_max" ]] ; then
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
@@ -118,12 +111,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 "${port}"
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() {
@@ -779,6 +785,66 @@ _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}"
+
+ echo "${port}"
+}
+
+_nvmet_target_cleanup() {
+ local port=$1
+ local blkdev
+
+ _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
+ _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 | 13 +++------- tests/nvme/004 | 20 +++------------ tests/nvme/005 | 19 ++------------- tests/nvme/006 | 18 ++------------ tests/nvme/007 | 13 ++-------- tests/nvme/008 | 20 ++------------- tests/nvme/009 | 15 ++---------- tests/nvme/010 | 20 ++------------- tests/nvme/011 | 15 ++---------- tests/nvme/012 | 20 ++------------- tests/nvme/013 | 15 ++---------- tests/nvme/014 | 20 ++------------- tests/nvme/015 | 15 ++---------- tests/nvme/018 | 15 ++---------- tests/nvme/019 | 20 ++------------- tests/nvme/020 | 15 ++---------- tests/nvme/021 | 15 ++---------- tests/nvme/022 | 15 ++---------- tests/nvme/023 | 20 ++------------- tests/nvme/024 | 15 ++---------- tests/nvme/025 | 15 ++---------- tests/nvme/026 | 15 ++---------- tests/nvme/027 | 16 +++--------- tests/nvme/028 | 16 +++--------- tests/nvme/029 | 20 ++------------- tests/nvme/040 | 18 ++------------ tests/nvme/041 | 17 ++----------- tests/nvme/042 | 16 ++---------- tests/nvme/043 | 16 ++---------- tests/nvme/044 | 18 +++----------- tests/nvme/045 | 17 +++---------- tests/nvme/047 | 20 ++------------- tests/nvme/048 | 16 ++---------- tests/nvme/rc | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 34 files changed, 138 insertions(+), 486 deletions(-)