[PATCH blktests v2 0/3] blktest: add unmap write zeroes tests

Zhang Yi posted 3 patches 1 month, 3 weeks ago
common/rc          | 10 +++++
tests/dm/003       | 86 +++++++++++++++++++++++++++++++++++++++++
tests/dm/003.out   |  2 +
tests/nvme/065     | 96 ++++++++++++++++++++++++++++++++++++++++++++++
tests/nvme/065.out |  4 ++
tests/scsi/010     | 84 ++++++++++++++++++++++++++++++++++++++++
tests/scsi/010.out |  2 +
7 files changed, 284 insertions(+)
create mode 100755 tests/dm/003
create mode 100644 tests/dm/003.out
create mode 100755 tests/nvme/065
create mode 100644 tests/nvme/065.out
create mode 100755 tests/scsi/010
create mode 100644 tests/scsi/010.out
[PATCH blktests v2 0/3] blktest: add unmap write zeroes tests
Posted by Zhang Yi 1 month, 3 weeks ago
From: Zhang Yi <yi.zhang@huawei.com>

Change since v2:
 - Modify the sysfs interfaces according to the kernel implementation.
 - Determine whether the kernel supports it by directly checking the
   existence of the sysfs interface, instead of using device_requries(). 
 - Drop _short_dev() helper and directly use _real_dev() to acquire dm
   path.
 - Check the return value of setup_test_device().
 - Fix the '"make check'" errors.


The Linux kernel (since version 6.17)[1] supports FALLOC_FL_WRITE_ZEROES
in fallocate(2) and add max_{hw|user}_wzeroes_unmap_sectors parameters
to the block device queue limit. These tests test those block device
unmap write zeroes sysfs interface

        /sys/block/<disk>/queue/write_zeroes_max_bytes
        /sys/block/<disk>/queue/write_zeroes_unmap_max_hw_bytes

with various SCSI/NVMe/device-mapper devices.

The value of /sys/block//queue/write_zeroes_unmap_max_hw_bytes should be
equal to a nonzero value of /sys/block//queue/write_zeroes_max_bytes if
the block device supports the unmap write zeroes command; otherwise, it
should return 0. We can also disable unmap write zeroes command by
setting /sys/block/<disk>/queue/write_zeroes_max_bytes to 0.

 - scsi/010 test SCSI devices.
 - dm/003 test device mapper stacked devices.
 - nvme/065 test NVMe devices.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=278c7d9b5e0c

Thanks,
Yi.

Zhang Yi (3):
  scsi/010: add unmap write zeroes tests
  dm/003: add unmap write zeroes tests
  nvme/065: add unmap write zeroes tests

 common/rc          | 10 +++++
 tests/dm/003       | 86 +++++++++++++++++++++++++++++++++++++++++
 tests/dm/003.out   |  2 +
 tests/nvme/065     | 96 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/065.out |  4 ++
 tests/scsi/010     | 84 ++++++++++++++++++++++++++++++++++++++++
 tests/scsi/010.out |  2 +
 7 files changed, 284 insertions(+)
 create mode 100755 tests/dm/003
 create mode 100644 tests/dm/003.out
 create mode 100755 tests/nvme/065
 create mode 100644 tests/nvme/065.out
 create mode 100755 tests/scsi/010
 create mode 100644 tests/scsi/010.out

-- 
2.39.2
Re: [PATCH blktests v2 0/3] blktest: add unmap write zeroes tests
Posted by Shinichiro Kawasaki 1 month, 2 weeks ago
On Aug 13, 2025 / 10:44, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
> 
> Change since v2:
>  - Modify the sysfs interfaces according to the kernel implementation.
>  - Determine whether the kernel supports it by directly checking the
>    existence of the sysfs interface, instead of using device_requries(). 
>  - Drop _short_dev() helper and directly use _real_dev() to acquire dm
>    path.
>  - Check the return value of setup_test_device().
>  - Fix the '"make check'" errors.
> 
> 
> The Linux kernel (since version 6.17)[1] supports FALLOC_FL_WRITE_ZEROES
> in fallocate(2) and add max_{hw|user}_wzeroes_unmap_sectors parameters
> to the block device queue limit. These tests test those block device
> unmap write zeroes sysfs interface
> 
>         /sys/block/<disk>/queue/write_zeroes_max_bytes
>         /sys/block/<disk>/queue/write_zeroes_unmap_max_hw_bytes
> 
> with various SCSI/NVMe/device-mapper devices.
> 
> The value of /sys/block//queue/write_zeroes_unmap_max_hw_bytes should be
> equal to a nonzero value of /sys/block//queue/write_zeroes_max_bytes if
> the block device supports the unmap write zeroes command; otherwise, it
> should return 0. We can also disable unmap write zeroes command by
> setting /sys/block/<disk>/queue/write_zeroes_max_bytes to 0.
> 
>  - scsi/010 test SCSI devices.
>  - dm/003 test device mapper stacked devices.
>  - nvme/065 test NVMe devices.
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=278c7d9b5e0c

I applied this v2 series. Of note is that I amended the 2nd and 3rd patches to
fix the shellcheck warnings below. Anyway, thanks for the patches!

$ make check
shellcheck -x -e SC2119 -f gcc check common/* \
        tests/*/rc tests/*/[0-9]*[0-9] src/*.sh
common/rc:679:7: note: Double quote to prevent globbing and word splitting. [SC2086]
tests/nvme/065:44:7: warning: Quote this to prevent word splitting. [SC2046]
tests/nvme/065:44:7: note: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'. [SC2005]
make: *** [Makefile:21: check] Error 1
Re: [PATCH blktests v2 0/3] blktest: add unmap write zeroes tests
Posted by Zhang Yi 1 month, 2 weeks ago
On 8/17/2025 2:14 PM, Shinichiro Kawasaki wrote:
> On Aug 13, 2025 / 10:44, Zhang Yi wrote:
>> From: Zhang Yi <yi.zhang@huawei.com>
>>
>> Change since v2:
>>  - Modify the sysfs interfaces according to the kernel implementation.
>>  - Determine whether the kernel supports it by directly checking the
>>    existence of the sysfs interface, instead of using device_requries(). 
>>  - Drop _short_dev() helper and directly use _real_dev() to acquire dm
>>    path.
>>  - Check the return value of setup_test_device().
>>  - Fix the '"make check'" errors.
>>
>>
>> The Linux kernel (since version 6.17)[1] supports FALLOC_FL_WRITE_ZEROES
>> in fallocate(2) and add max_{hw|user}_wzeroes_unmap_sectors parameters
>> to the block device queue limit. These tests test those block device
>> unmap write zeroes sysfs interface
>>
>>         /sys/block/<disk>/queue/write_zeroes_max_bytes
>>         /sys/block/<disk>/queue/write_zeroes_unmap_max_hw_bytes
>>
>> with various SCSI/NVMe/device-mapper devices.
>>
>> The value of /sys/block//queue/write_zeroes_unmap_max_hw_bytes should be
>> equal to a nonzero value of /sys/block//queue/write_zeroes_max_bytes if
>> the block device supports the unmap write zeroes command; otherwise, it
>> should return 0. We can also disable unmap write zeroes command by
>> setting /sys/block/<disk>/queue/write_zeroes_max_bytes to 0.
>>
>>  - scsi/010 test SCSI devices.
>>  - dm/003 test device mapper stacked devices.
>>  - nvme/065 test NVMe devices.
>>
>> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=278c7d9b5e0c
> 
> I applied this v2 series. Of note is that I amended the 2nd and 3rd patches to
> fix the shellcheck warnings below. Anyway, thanks for the patches!
> 
> $ make check
> shellcheck -x -e SC2119 -f gcc check common/* \
>         tests/*/rc tests/*/[0-9]*[0-9] src/*.sh
> common/rc:679:7: note: Double quote to prevent globbing and word splitting. [SC2086]
> tests/nvme/065:44:7: warning: Quote this to prevent word splitting. [SC2046]
> tests/nvme/065:44:7: note: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'. [SC2005]
> make: *** [Makefile:21: check] Error 1

Sorry for missing these warnings, and thank you for fixing them! :-)

Thanks.
Yi.