diff mbox series

[blktests,3/3] nvme/060: add unmap write zeroes tests

Message ID 20250318072835.3508696-4-yi.zhang@huaweicloud.com (mailing list archive)
State New
Headers show
Series blktest: add unmap write zeroes tests | expand

Commit Message

Zhang Yi March 18, 2025, 7:28 a.m. UTC
From: Zhang Yi <yi.zhang@huawei.com>

Test block device unmap write zeroes sysfs interface with NVMeT devices
which are based on various SCSI debug devices. The
/sys/block/<disk>/queue/write_zeroes_unmap interface should return 1 if
the NVMeT devices support the unmap write zeroes command, and it should
return 0 otherwise.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
---
 tests/nvme/060     | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/060.out |  4 +++
 2 files changed, 72 insertions(+)
 create mode 100755 tests/nvme/060
 create mode 100644 tests/nvme/060.out

Comments

Shinichiro Kawasaki April 3, 2025, 7:49 a.m. UTC | #1
On Mar 18, 2025 / 15:28, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
> 
> Test block device unmap write zeroes sysfs interface with NVMeT devices
> which are based on various SCSI debug devices. The
> /sys/block/<disk>/queue/write_zeroes_unmap interface should return 1 if
> the NVMeT devices support the unmap write zeroes command, and it should
> return 0 otherwise.
> 
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> ---
>  tests/nvme/060     | 68 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/nvme/060.out |  4 +++
>  2 files changed, 72 insertions(+)
>  create mode 100755 tests/nvme/060
>  create mode 100644 tests/nvme/060.out
> 
> diff --git a/tests/nvme/060 b/tests/nvme/060
> new file mode 100755
> index 0000000..524176f
> --- /dev/null
> +++ b/tests/nvme/060
> @@ -0,0 +1,68 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-3.0+
> +# Copyright (C) 2025 Huawei.
> +#
> +# Test block device unmap write zeroes sysfs interface with nvmet scsi
> +# debug devices.
> +
> +. tests/nvme/rc
> +. common/scsi_debug
> +
> +DESCRIPTION="test unmap write zeroes sysfs interface with nvmet devices"
> +QUICK=1
> +
> +nvme_trtype=loop
> +nvmet_blkdev_type="device"
> +
> +requires() {
> +	_have_scsi_debug
> +	_nvme_requires
> +	_require_nvme_trtype_is_loop
> +}
> +
> +device_requries() {
> +	_require_test_dev_sysfs queue/write_zeroes_unmap
> +}

Same comment as the 1st and the 2nd patches.

> +
> +setup_test_device() {
> +	if ! _configure_scsi_debug "$@"; then
> +		return 1
> +	fi

I suggest the same change as the 2nd patch to check
queue/write_zeroes_unmap here...

> +
> +	local port="$(_create_nvmet_port)"
> +	_create_nvmet_subsystem --blkdev "/dev/${SCSI_DEBUG_DEVICES[0]}"
> +	_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
> +
> +	_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
> +	_nvme_connect_subsys
> +}
> +
> +cleanup_test_device() {
> +	_nvme_disconnect_subsys
> +	_nvmet_target_cleanup --subsysnqn "${def_subsysnqn}"
> +	_exit_scsi_debug
> +}
> +
> +test() {
> +	echo "Running ${TEST_NAME}"
> +
> +	_setup_nvmet
> +
> +	# disable WRITE SAME with unmap
> +	setup_test_device lbprz=0

and here, to check the setup_test_device() return value.
diff mbox series

Patch

diff --git a/tests/nvme/060 b/tests/nvme/060
new file mode 100755
index 0000000..524176f
--- /dev/null
+++ b/tests/nvme/060
@@ -0,0 +1,68 @@ 
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2025 Huawei.
+#
+# Test block device unmap write zeroes sysfs interface with nvmet scsi
+# debug devices.
+
+. tests/nvme/rc
+. common/scsi_debug
+
+DESCRIPTION="test unmap write zeroes sysfs interface with nvmet devices"
+QUICK=1
+
+nvme_trtype=loop
+nvmet_blkdev_type="device"
+
+requires() {
+	_have_scsi_debug
+	_nvme_requires
+	_require_nvme_trtype_is_loop
+}
+
+device_requries() {
+	_require_test_dev_sysfs queue/write_zeroes_unmap
+}
+
+setup_test_device() {
+	if ! _configure_scsi_debug "$@"; then
+		return 1
+	fi
+
+	local port="$(_create_nvmet_port)"
+	_create_nvmet_subsystem --blkdev "/dev/${SCSI_DEBUG_DEVICES[0]}"
+	_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+
+	_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
+	_nvme_connect_subsys
+}
+
+cleanup_test_device() {
+	_nvme_disconnect_subsys
+	_nvmet_target_cleanup --subsysnqn "${def_subsysnqn}"
+	_exit_scsi_debug
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	_setup_nvmet
+
+	# disable WRITE SAME with unmap
+	setup_test_device lbprz=0
+	umap="$(cat "/sys/block/$(_find_nvme_ns "${def_subsys_uuid}")/queue/write_zeroes_unmap")"
+	if [[ $umap -ne 0 ]]; then
+		echo "Test disable WRITE SAME with unmap failed."
+	fi
+	cleanup_test_device
+
+	# enable WRITE SAME with unmap
+	setup_test_device lbprz=1 lbpws=1
+	umap="$(cat "/sys/block/$(_find_nvme_ns "${def_subsys_uuid}")/queue/write_zeroes_unmap")"
+	if [[ $umap -ne 1 ]]; then
+		echo "Test enable WRITE SAME with unmap failed."
+	fi
+	cleanup_test_device
+
+	echo "Test complete"
+}
diff --git a/tests/nvme/060.out b/tests/nvme/060.out
new file mode 100644
index 0000000..e60714d
--- /dev/null
+++ b/tests/nvme/060.out
@@ -0,0 +1,4 @@ 
+Running nvme/060
+disconnected 1 controller(s)
+disconnected 1 controller(s)
+Test complete