Re: [RFC PATCH v2 4/8] dm: add BLK_FEAT_WRITE_ZEROES_UNMAP support

2025-02-07 Thread Zhang Yi
On 2025/2/8 6:14, Benjamin Marzinski wrote: > On Wed, Jan 15, 2025 at 07:46:33PM +0800, Zhang Yi wrote: >> From: Zhang Yi >> >> Set the BLK_FEAT_WRITE_ZEROES_UNMAP feature on stacking queue limits by >> default. This feature shall be disabled if any underlying de

Re: [RFC PATCH v2 1/8] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-02-07 Thread Zhang Yi
On 2025/1/29 0:46, John Garry wrote: > On 15/01/2025 11:46, Zhang Yi wrote: >> From: Zhang Yi >> >> Currently, it's hard to know whether the storage device supports unmap >> write zeroes. We cannot determine it only by checking if the disk >> supports the

Re: [RFC PATCH v2 1/8] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-02-07 Thread Zhang Yi
On 2025/2/7 20:22, Zhang Yi wrote: > On 2025/1/29 0:46, John Garry wrote: >> On 15/01/2025 11:46, Zhang Yi wrote: >>> From: Zhang Yi >>> >>> Currently, it's hard to know whether the storage device supports unmap >>> write zeroes. We cannot dete

Re: [RFC PATCH v2 2/8] nvme: set BLK_FEAT_WRITE_ZEROES_UNMAP if device supports DEAC bit

2025-02-07 Thread Zhang Yi
On 2025/1/28 14:46, Christoph Hellwig wrote: > I think you also need to add BLK_FEAT_WRITE_ZEROES_UNMAP to the list > of features supported by the nvme-mpath stacking driver in > nvme_mpath_alloc_disk, so that this gets propagated to multipathed > devices. > > Otherwise this looks good to me. Ha,

[RFC PATCH v2 4/8] dm: add BLK_FEAT_WRITE_ZEROES_UNMAP support

2025-01-15 Thread Zhang Yi
From: Zhang Yi Set the BLK_FEAT_WRITE_ZEROES_UNMAP feature on stacking queue limits by default. This feature shall be disabled if any underlying device does not support it. Signed-off-by: Zhang Yi --- drivers/md/dm-table.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a

[RFC PATCH v2 1/8] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-01-15 Thread Zhang Yi
From: Zhang Yi Currently, it's hard to know whether the storage device supports unmap write zeroes. We cannot determine it only by checking if the disk supports the write zeroes command, as for some HDDs that do submit actual zeros to the disk media even if they claim to support the write z

[RFC PATCH v2 0/8] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag

2025-01-15 Thread Zhang Yi
From: Zhang Yi Changes since v1: - Switch to add a new write zeroes operation, FALLOC_FL_WRITE_ZEROES, in fallocate, instead of just adding a supported flag to FALLOC_FL_ZERO_RANGE. - Introduce a new flag BLK_FEAT_WRITE_ZEROES_UNMAP to the block device's queue limit features

[RFC PATCH v2 3/8] scsi: sd: set BLK_FEAT_WRITE_ZEROES_UNMAP if device supports unmap zeroing mode

2025-01-15 Thread Zhang Yi
From: Zhang Yi When the device supports the Write Zeroes command and the zeroing mode is set to SD_ZERO_WS16_UNMAP or SD_ZERO_WS10_UNMAP, this means that the device supports unmap Write Zeroes, so set the corresponding BLK_FEAT_WRITE_ZEROES_UNMAP feature to the device's queue limit. Signe

[RFC PATCH v2 2/8] nvme: set BLK_FEAT_WRITE_ZEROES_UNMAP if device supports DEAC bit

2025-01-15 Thread Zhang Yi
From: Zhang Yi When the device supports the Write Zeroes command and the DEAC bit, it indicates that the deallocate bit in the Write Zeroes command is supported, and the bytes read from a deallocated logical block are zeroes. This means the device supports unmap Write Zeroes, so set the

[RFC PATCH v2 7/8] block: factor out common part in blkdev_fallocate()

2025-01-15 Thread Zhang Yi
From: Zhang Yi Only the flags passed to blkdev_issue_zeroout() differ among the three zeroing branches in blkdev_fallocate(). Therefore, do cleanup by factoring them out. Signed-off-by: Zhang Yi --- block/fops.c | 40 +++- 1 file changed, 15 insertions

[RFC PATCH v2 8/8] ext4: add FALLOC_FL_WRITE_ZEROES support

2025-01-15 Thread Zhang Yi
From: Zhang Yi Add support for FALLOC_FL_WRITE_ZEROES. This first allocates blocks as unwritten, then issues a zero command outside of the running journal handle, and finally converts them to a written state. Signed-off-by: Zhang Yi --- fs/ext4/extents.c | 59

[RFC PATCH v2 6/8] block: add FALLOC_FL_WRITE_ZEROES support

2025-01-15 Thread Zhang Yi
From: Zhang Yi Add support for FALLOC_FL_WRITE_ZEROES. It directly calls blkdev_issue_zeroout() with flags set to 0. The underlying process will attempt to use the fastest method for issuing zeroes. First, the block layer will try to issue a write zeroes command if the storage device supports it

[RFC PATCH v2 5/8] fs: introduce FALLOC_FL_WRITE_ZEROES to fallocate

2025-01-15 Thread Zhang Yi
From: Zhang Yi With the development of flash-based storage devices, we can quickly write zeros to SSDs using the WRITE_ZERO command if the devices do not actually write physical zeroes to the media. Therefore, we can use this command to quickly preallocate a real all-zero file with written

Re: [RFC PATCH v2 0/8] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag

2025-01-15 Thread Zhang Yi
On 2025/1/16 5:07, Chaitanya Kulkarni wrote: > On 1/15/25 03:46, Zhang Yi wrote: >> Currently, we can use the fallocate command to quickly create a >> pre-allocated file. However, on most filesystems, such as ext4 and XFS, >> fallocate create pre-allocation blocks in an unw

[RFC PATCH -next v3 00/10] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag

2025-03-19 Thread Zhang Yi
From: Zhang Yi Changes since RFC v2: - Rebase codes on next-20250314. - Add support for nvme multipath. - Add support for NVMeT with block device backing. - Clear FALLOC_FL_WRITE_ZEROES if dm clear limits->max_write_zeroes_sectors. - Complement the counterpart userspace tools(util-li

[PATCH xfstests 5/5] fsx: add fallocate write zeroes support

2025-03-18 Thread Zhang Yi
From: Zhang Yi Add fsx to suppoet fallocate FALLOC_FL_WRITE_ZEROES command by introducing OP_WRITE_ZEROES operation. Signed-off-by: Zhang Yi --- ltp/fsx.c | 80 +++ 1 file changed, 80 insertions(+) diff --git a/ltp/fsx.c b/ltp/fsx.c index

[RFC PATCH -next v3 07/10] fs: introduce FALLOC_FL_WRITE_ZEROES to fallocate

2025-03-18 Thread Zhang Yi
From: Zhang Yi With the development of flash-based storage devices, we can quickly write zeros to SSDs using the WRITE_ZERO command if the devices do not actually write physical zeroes to the media. Therefore, we can use this command to quickly preallocate a real all-zero file with written

[PATCH xfstests 3/5] generic/766: test fallocate write zeroes on block device

2025-03-18 Thread Zhang Yi
From: Zhang Yi Test the fallocate FALLOC_FL_WRITE_ZEROES command on a block device, including unsupported flags. Signed-off-by: Zhang Yi --- tests/generic/766 | 80 +++ tests/generic/766.out | 23 + 2 files changed, 103 insertions

[RFC PATCH -next v3 02/10] nvme: set BLK_FEAT_WRITE_ZEROES_UNMAP if device supports DEAC bit

2025-03-18 Thread Zhang Yi
From: Zhang Yi When the device supports the Write Zeroes command and the DEAC bit, it indicates that the deallocate bit in the Write Zeroes command is supported, and the bytes read from a deallocated logical block are zeroes. This means the device supports unmap Write Zeroes, so set the

[RFC PATCH -next v3 05/10] scsi: sd: set BLK_FEAT_WRITE_ZEROES_UNMAP if device supports unmap zeroing mode

2025-03-18 Thread Zhang Yi
From: Zhang Yi When the device supports the Write Zeroes command and the zeroing mode is set to SD_ZERO_WS16_UNMAP or SD_ZERO_WS10_UNMAP, this means that the device supports unmap Write Zeroes, so set the corresponding BLK_FEAT_WRITE_ZEROES_UNMAP feature to the device's queue limit. Signe

[RFC PATCH -next v3 06/10] dm: add BLK_FEAT_WRITE_ZEROES_UNMAP support

2025-03-18 Thread Zhang Yi
From: Zhang Yi Set the BLK_FEAT_WRITE_ZEROES_UNMAP feature on stacking queue limits by default. This feature shall be disabled if any underlying device does not support it. Signed-off-by: Zhang Yi --- drivers/md/dm-table.c | 7 +-- drivers/md/dm.c | 1 + 2 files changed, 6

[RFC PATCH -next v3 10/10] ext4: add FALLOC_FL_WRITE_ZEROES support

2025-03-18 Thread Zhang Yi
From: Zhang Yi Add support for FALLOC_FL_WRITE_ZEROES. This first allocates blocks as unwritten, then issues a zero command outside of the running journal handle, and finally converts them to a written state. Signed-off-by: Zhang Yi --- fs/ext4/extents.c | 59

[RFC PATCH -next v3 08/10] block: add FALLOC_FL_WRITE_ZEROES support

2025-03-18 Thread Zhang Yi
From: Zhang Yi Add support for FALLOC_FL_WRITE_ZEROES. It directly calls blkdev_issue_zeroout() with flags set to 0. The underlying process will attempt to use the fastest method for issuing zeroes. First, the block layer will try to issue a write zeroes command if the storage device supports it

[RFC PATCH -next v3 09/10] block: factor out common part in blkdev_fallocate()

2025-03-18 Thread Zhang Yi
From: Zhang Yi Only the flags passed to blkdev_issue_zeroout() differ among the three zeroing branches in blkdev_fallocate(). Therefore, do cleanup by factoring them out. Signed-off-by: Zhang Yi --- block/fops.c | 40 +++- 1 file changed, 15 insertions

[PATCH xfstests 4/5] fstress: add fallocate write zeroes support

2025-03-18 Thread Zhang Yi
From: Zhang Yi Add fstress to suppoet fallocate FALLOC_FL_WRITE_ZEROES command by introducing OP_WZERO operation. Signed-off-by: Zhang Yi --- ltp/fsstress.c | 12 src/global.h | 4 2 files changed, 16 insertions(+) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index

[RFC PATCH -next v3 03/10] nvme-multipath: add BLK_FEAT_WRITE_ZEROES_UNMAP support

2025-03-18 Thread Zhang Yi
From: Zhang Yi Set the BLK_FEAT_WRITE_ZEROES_UNMAP feature while creating multipath stacking queue limits by default. This feature shall be disabled if any attached namespace does not support it. Signed-off-by: Zhang Yi --- drivers/nvme/host/multipath.c | 3 ++- 1 file changed, 2 insertions

[RFC PATCH -next v3 01/10] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-03-18 Thread Zhang Yi
From: Zhang Yi Currently, disks primarily implement the write zeroes command (aka REQ_OP_WRITE_ZEROES) through two mechanisms: the first involves physically writing zeros to the disk media (e.g., HDDs), while the second performs an unmap operation on the logical blocks, effectively putting them

[PATCH xfsprogs] xfs_io: add FALLOC_FL_WRITE_ZEROES support

2025-03-18 Thread Zhang Yi
From: Zhang Yi The Linux kernel is planning to support FALLOC_FL_WRITE_ZEROES in fallocate(2). Add FALLOC_FL_ZERO_RANGE support to fallocate utility by introducing a new 'fwzero' command to xfs_io. Signed-off-by: Zhang Yi --- io/prealloc.c | 36 +++

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

2025-03-18 Thread Zhang Yi
From: Zhang Yi Test block device unmap write zeroes sysfs interface with NVMeT devices which are based on various SCSI debug devices. The /sys/block//queue/write_zeroes_unmap interface should return 1 if the NVMeT devices support the unmap write zeroes command, and it should return 0 otherwise

[PATCH blktests 1/3] scsi/010: add unmap write zeroes tests

2025-03-18 Thread Zhang Yi
From: Zhang Yi Test block device unmap write zeroes sysfs interface with various SCSI debug devices. The /sys/block//queue/write_zeroes_unmap interface should return 1 if the SCSI device enable the WRITE SAME command with unmap functionality, and it should return 0 otherwise. Signed-off-by

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

2025-03-18 Thread Zhang Yi
From: Zhang Yi The Linux kernel is planning to support FALLOC_FL_WRITE_ZEROES in fallocate(2). Add tests for the newly added BLK_FEAT_WRITE_ZEROES_UNMAP feature flag on the block device queue limit. These tests test block device unmap write zeroes sysfs interface /sys/block//queue

[PATCH util-linux] fallocate: add FALLOC_FL_WRITE_ZEROES support

2025-03-18 Thread Zhang Yi
From: Zhang Yi The Linux kernel is planning to supports FALLOC_FL_WRITE_ZEROES in fallocate(2). Add FALLOC_FL_ZERO_RANGE support to fallocate utility by introducing a new option -w|--write-zeroes. Signed-off-by: Zhang Yi --- sys-utils/fallocate.1.adoc | 11 +-- sys-utils/fallocate.c

[PATCH xfstests 2/5] generic/765: add generic tests for fallocate write zeroes

2025-03-18 Thread Zhang Yi
From: Zhang Yi Add generic tests for the fallocate FALLOC_FL_WRITE_ZEROES command. Signed-off-by: Zhang Yi --- tests/generic/765 | 40 +++ tests/generic/765.out | 269 ++ 2 files changed, 309 insertions(+) create mode 100755 tests/generic/765

[PATCH xfstests 0/5] fstests: add fallocate write zeroes tests

2025-04-05 Thread Zhang Yi
From: Zhang Yi The Linux kernel is planning to support FALLOC_FL_WRITE_ZEROES in fallocate(2). Add tests for the newly added fallocate FALLOC_FL_WRITE_ZEROES command. This series depends on the changes to xfs_io [1] that introduced the 'fwzero' command. - generic/764 is an extension

[RFC PATCH -next v3 04/10] nvmet: set WZDS and DRB if device supports BLK_FEAT_WRITE_ZEROES_UNMAP

2025-04-05 Thread Zhang Yi
From: Zhang Yi Set WZDS and DRB bit to the namespace dlfeat if the underlying block device supports BLK_FEAT_WRITE_ZEROES_UNMAP, make the nvme target device supports unmaped write zeroes command. Signed-off-by: Zhang Yi --- drivers/nvme/target/io-cmd-bdev.c | 4 include/linux/blkdev.h

Re: [RFC PATCH -next v3 01/10] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-04-10 Thread Zhang Yi
On 2025/4/10 16:20, Keith Busch wrote: > On Thu, Apr 10, 2025 at 09:15:59AM +0200, Christoph Hellwig wrote: >> On Thu, Apr 10, 2025 at 11:52:17AM +0800, Zhang Yi wrote: >>> >>> Thank you for your review and comments. However, I'm not sure I fully >>>

Re: [RFC PATCH -next v3 01/10] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-04-09 Thread Zhang Yi
On 2025/4/9 18:31, Christoph Hellwig wrote: > On Tue, Mar 18, 2025 at 03:35:36PM +0800, Zhang Yi wrote: >> From: Zhang Yi >> >> Currently, disks primarily implement the write zeroes command (aka >> REQ_OP_WRITE_ZEROES) through two mechanisms: the first involves >>

[RFC PATCH v4 02/11] nvme: set BLK_FEAT_WRITE_ZEROES_UNMAP if device supports DEAC bit

2025-04-20 Thread Zhang Yi
From: Zhang Yi When the device supports the Write Zeroes command and the DEAC bit, it indicates that the deallocate bit in the Write Zeroes command is supported, and the bytes read from a deallocated logical block are zeroes. This means the device supports unmap Write Zeroes, so set the

[RFC PATCH v4 01/11] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-04-20 Thread Zhang Yi
From: Zhang Yi Currently, disks primarily implement the write zeroes command (aka REQ_OP_WRITE_ZEROES) through two mechanisms: the first involves physically writing zeros to the disk media (e.g., HDDs), while the second performs an unmap operation on the logical blocks, effectively putting them

[RFC PATCH v4 06/11] dm: add BLK_FEAT_WRITE_ZEROES_UNMAP support

2025-04-20 Thread Zhang Yi
From: Zhang Yi Set the BLK_FEAT_WRITE_ZEROES_UNMAP feature on stacking queue limits by default. This feature shall be disabled if any underlying device does not support it. Signed-off-by: Zhang Yi Reviewed-by: Benjamin Marzinski --- drivers/md/dm-table.c | 7 +-- drivers/md/dm.c

[RFC PATCH v4 05/11] scsi: sd: set BLK_FEAT_WRITE_ZEROES_UNMAP if device supports unmap zeroing mode

2025-04-20 Thread Zhang Yi
From: Zhang Yi When the device supports the Write Zeroes command and the zeroing mode is set to SD_ZERO_WS16_UNMAP or SD_ZERO_WS10_UNMAP, this means that the device supports unmap Write Zeroes, so set the corresponding BLK_FEAT_WRITE_ZEROES_UNMAP feature to the device's queue limit. Signe

[RFC PATCH v4 03/11] nvme-multipath: add BLK_FEAT_WRITE_ZEROES_UNMAP support

2025-04-20 Thread Zhang Yi
From: Zhang Yi Set the BLK_FEAT_WRITE_ZEROES_UNMAP feature while creating multipath stacking queue limits by default. This feature shall be disabled if any attached namespace does not support it. Signed-off-by: Zhang Yi --- drivers/nvme/host/multipath.c | 3 ++- 1 file changed, 2 insertions

[RFC PATCH v4 08/11] fs: introduce FALLOC_FL_WRITE_ZEROES to fallocate

2025-04-20 Thread Zhang Yi
From: Zhang Yi With the development of flash-based storage devices, we can quickly write zeros to SSDs using the WRITE_ZERO command if the devices do not actually write physical zeroes to the media. Therefore, we can use this command to quickly preallocate a real all-zero file with written

[RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-04-20 Thread Zhang Yi
From: Zhang Yi Add a new attribute flag to statx to determine whether a bdev or a file supports the unmap write zeroes command. Signed-off-by: Zhang Yi --- block/bdev.c | 4 fs/ext4/inode.c | 9 ++--- include/uapi/linux/stat.h | 1 + 3 files changed, 11

[RFC PATCH v4 10/11] block: add FALLOC_FL_WRITE_ZEROES support

2025-04-20 Thread Zhang Yi
From: Zhang Yi Add support for FALLOC_FL_WRITE_ZEROES. It directly calls blkdev_issue_zeroout() with flags set to 0. The underlying process will attempt to use the fastest method for issuing zeroes. First, the block layer will try to issue a write zeroes command if the storage device supports it

[RFC PATCH v4 11/11] ext4: add FALLOC_FL_WRITE_ZEROES support

2025-04-20 Thread Zhang Yi
From: Zhang Yi Add support for FALLOC_FL_WRITE_ZEROES. This first allocates blocks as unwritten, then issues a zero command outside of the running journal handle, and finally converts them to a written state. Signed-off-by: Zhang Yi --- fs/ext4/extents.c | 59

[RFC PATCH v4 04/11] nvmet: set WZDS and DRB if device supports BLK_FEAT_WRITE_ZEROES_UNMAP

2025-04-20 Thread Zhang Yi
From: Zhang Yi Set WZDS and DRB bit to the namespace dlfeat if the underlying block device supports BLK_FEAT_WRITE_ZEROES_UNMAP, make the nvme target device supports unmaped write zeroes command. Signed-off-by: Zhang Yi --- drivers/nvme/target/io-cmd-bdev.c | 4 1 file changed, 4

[RFC PATCH v4 09/11] block: factor out common part in blkdev_fallocate()

2025-04-20 Thread Zhang Yi
From: Zhang Yi Only the flags passed to blkdev_issue_zeroout() differ among the two zeroing branches in blkdev_fallocate(). Therefore, do cleanup by factoring them out. Signed-off-by: Zhang Yi Reviewed-by: Christoph Hellwig --- block/fops.c | 32 ++-- 1 file

[RFC PATCH v4 00/11] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag

2025-04-20 Thread Zhang Yi
From: Zhang Yi Changes sicne RFC v3: - Rebase codes on 6.15-rc2. - Add a note in patch 1 to indicate that the unmap write zeros command is not always guaranteed as Christoph suggested. - Rename bdev_unmap_write_zeroes() helper and move it to patch 1 as Christoph suggested. - Introduce

Re: [RFC PATCH -next v3 07/10] fs: introduce FALLOC_FL_WRITE_ZEROES to fallocate

2025-04-17 Thread Zhang Yi
On 2025/4/9 18:50, Christian Brauner wrote: > On Wed, Apr 09, 2025 at 12:35:48PM +0200, Christoph Hellwig wrote: >> On Tue, Mar 18, 2025 at 03:35:42PM +0800, Zhang Yi wrote: >>> Users can check the disk support of unmap write zeroes command by >>> querying: &g

Re: [PATCH blktests 1/3] scsi/010: add unmap write zeroes tests

2025-04-27 Thread Zhang Yi
Hello Shinichiro! I apologize for the significant delay, and I greatly appreciate your review and suggestions. On 2025/4/3 15:26, Shinichiro Kawasaki wrote: > Hello Zhang, thank you for the patches. > > On Mar 18, 2025 / 15:28, Zhang Yi wrote: >> From: Zhang Yi >> >&

Re: [PATCH blktests 2/3] dm/003: add unmap write zeroes tests

2025-04-27 Thread Zhang Yi
On 2025/4/3 15:43, Shinichiro Kawasaki wrote: > On Mar 18, 2025 / 15:28, Zhang Yi wrote: >> From: Zhang Yi >> >> Test block device unmap write zeroes sysfs interface with device-mapper >> stacked devices. The /sys/block//queue/write_zeroes_unmap >> interface

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

2025-04-27 Thread Zhang Yi
On 2025/4/3 15:55, Shinichiro Kawasaki wrote: > On Mar 18, 2025 / 15:28, Zhang Yi wrote: >> From: Zhang Yi >> >> The Linux kernel is planning to support FALLOC_FL_WRITE_ZEROES in >> fallocate(2). Add tests for the newly added BLK_FEAT_WRITE_ZEROES_UNMAP >> featu

Re: [PATCH blktests 2/3] dm/003: add unmap write zeroes tests

2025-04-28 Thread Zhang Yi
On 2025/4/28 16:13, Shinichiro Kawasaki wrote: > On Apr 28, 2025 / 12:32, Zhang Yi wrote: >> On 2025/4/3 15:43, Shinichiro Kawasaki wrote: > [...] >>>> + >>>> +setup_test_device() { >>>> + if ! _configure_scsi_debug "$@"; then >>>

Re: [PATCH blktests 2/3] dm/003: add unmap write zeroes tests

2025-04-28 Thread Zhang Yi
On 2025/4/28 17:25, Shinichiro Kawasaki wrote: > On Apr 28, 2025 / 17:04, Zhang Yi wrote: >> On 2025/4/28 16:13, Shinichiro Kawasaki wrote: >>> On Apr 28, 2025 / 12:32, Zhang Yi wrote: >>>> On 2025/4/3 15:43, Shinichiro Kawasaki wrote: >>> [

Re: [RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-05-06 Thread Zhang Yi
On 2025/5/5 22:29, Darrick J. Wong wrote: > On Mon, May 05, 2025 at 03:22:08PM +0200, Christoph Hellwig wrote: >> On Mon, Apr 21, 2025 at 10:15:05AM +0800, Zhang Yi wrote: >>> From: Zhang Yi >>> >>> Add a new attribute flag to statx to determine whether a b

Re: [RFC PATCH v4 01/11] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-05-06 Thread Zhang Yi
Hi, Martin! On 2025/5/6 12:21, Martin K. Petersen wrote: > > Hi Zhang! > >> +[RO] Devices that explicitly support the unmap write zeroes >> +operation in which a single write zeroes request with the unmap >> +bit set to zero out the range of contiguous blocks

Re: [RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-05-06 Thread Zhang Yi
On 2025/5/6 12:39, Christoph Hellwig wrote: > On Tue, May 06, 2025 at 12:28:54PM +0800, Zhang Yi wrote: >> OK, since this statx reporting flag is not strongly tied to >> FALLOC_FL_WRITE_ZEROES in vfs_fallocate(), I'll split this patch into >> three separate patches. >

Re: [RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-05-06 Thread Zhang Yi
On 2025/5/6 13:47, Christoph Hellwig wrote: > On Mon, May 05, 2025 at 10:36:54PM -0700, Darrick J. Wong wrote: >> I think STATX_* (i.e. not STATX_ATTR_*) flags have two purposes: 1) to >> declare that specific fields in struct statx actually have meaning, most >> notably in scenarios where zeroes a

Re: [RFC PATCH -next v3 01/10] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-04-10 Thread Zhang Yi
On 2025/4/10 15:15, Christoph Hellwig wrote: > On Thu, Apr 10, 2025 at 11:52:17AM +0800, Zhang Yi wrote: >> >> Thank you for your review and comments. However, I'm not sure I fully >> understand your points. Could you please provide more details? >> >> AFAI

[PATCH xfstests 1/5] generic/764: add page boundaries tests for fallocate write zeroes

2025-04-04 Thread Zhang Yi
From: Zhang Yi Add page boundaries and boundaries that are off-by-one tests for the fallocate FALLOC_FL_WRITE_ZEROES command. Signed-off-by: Zhang Yi --- common/rc | 2 +- tests/generic/764 | 34 tests/generic/764.out | 433 ++ 3

[PATCH blktests 2/3] dm/003: add unmap write zeroes tests

2025-04-04 Thread Zhang Yi
From: Zhang Yi Test block device unmap write zeroes sysfs interface with device-mapper stacked devices. The /sys/block//queue/write_zeroes_unmap interface should return 1 if the underlying devices support the unmap write zeroes command, and it should return 0 otherwise. Signed-off-by: Zhang Yi

Re: [RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-05-08 Thread Zhang Yi
On 2025/5/8 13:01, Christoph Hellwig wrote: > On Wed, May 07, 2025 at 03:33:23PM +0800, Zhang Yi wrote: >> On 2025/5/6 20:11, Christoph Hellwig wrote: >>> On Tue, May 06, 2025 at 07:16:56PM +0800, Zhang Yi wrote: >>>> Sorry, but I don

Re: [RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-05-09 Thread Zhang Yi
On 2025/5/9 4:24, Theodore Ts'o wrote: > On Thu, May 08, 2025 at 08:17:14PM +0800, Zhang Yi wrote: >> On 2025/5/8 13:01, Christoph Hellwig wrote: >>>> >>>> My idea is not to strictly limiting the use of FALLOC_FL_WRITE_ZEROES to >>>> only bdev or

Re: [RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-05-07 Thread Zhang Yi
On 2025/5/6 20:11, Christoph Hellwig wrote: > On Tue, May 06, 2025 at 07:16:56PM +0800, Zhang Yi wrote: >> Sorry, but I don't understand your suggestion. The >> STATX_ATTR_WRITE_ZEROES_UNMAP attribute only indicate whether the bdev >> and the block device that under

Re: [RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute

2025-05-07 Thread Zhang Yi
On 2025/5/6 23:55, Darrick J. Wong wrote: > On Tue, May 06, 2025 at 02:10:12PM +0200, Christoph Hellwig wrote: >> On Tue, May 06, 2025 at 07:25:06PM +0800, Zhang Yi wrote: >>> + if (request_mask & STATX_WRITE_ZEROES_UNMAP && >>> +

[PATCH v2 5/9] dm: clear unmap write zeroes limits when disabling write zeroes

2025-06-19 Thread Zhang Yi
From: Zhang Yi The unmap write zeroes limits have been set to the stacking queue limits by default in blk_set_stacking_limits() and blk_stack_limits(), but it should be cleared if any underlying device does not support it. Signed-off-by: Zhang Yi --- drivers/md/dm-table.c | 4 +++- 1 file

[PATCH v2 3/9] nvmet: set WZDS and DRB if device enables unmap write zeroes operation

2025-06-19 Thread Zhang Yi
From: Zhang Yi Set the WZDS and DRB bits to the namespace dlfeat if the underlying block device enables the unmap write zeroes operation, make the nvme target device supports the unmap write zeroes command. Signed-off-by: Zhang Yi --- drivers/nvme/target/io-cmd-bdev.c | 4 1 file changed

[PATCH v2 0/9] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag

2025-06-19 Thread Zhang Yi
From: Zhang Yi Changes since v1: - Rebase codes on 6.16-rc2. - Use max_{hw|user}_wzeroes_unmap_sectors queue limits instead of BLK_FEAT_WRITE_ZEROES_UNMAP feature to represent the status of the unmap write zeroes operation as Christoph and Darrick suggested. This redoes the first 5

[PATCH v2 8/9] block: add FALLOC_FL_WRITE_ZEROES support

2025-06-19 Thread Zhang Yi
From: Zhang Yi Add support for FALLOC_FL_WRITE_ZEROES, if the block device enables the unmap write zeroes operation, it will issue a write zeroes command. Signed-off-by: Zhang Yi Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- block/fops.c | 12 +++- 1 file

[PATCH v2 6/9] fs: introduce FALLOC_FL_WRITE_ZEROES to fallocate

2025-06-19 Thread Zhang Yi
From: Zhang Yi With the development of flash-based storage devices, we can quickly write zeros to SSDs using the WRITE_ZERO command if the devices do not actually write physical zeroes to the media. Therefore, we can use this command to quickly preallocate a real all-zero file with written

[PATCH v2 7/9] block: factor out common part in blkdev_fallocate()

2025-06-19 Thread Zhang Yi
From: Zhang Yi Only the flags passed to blkdev_issue_zeroout() differ among the two zeroing branches in blkdev_fallocate(). Therefore, do cleanup by factoring them out. Signed-off-by: Zhang Yi Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- block/fops.c | 32

[PATCH v2 1/9] block: introduce max_{hw|user}_wzeroes_unmap_sectors to queue limits

2025-06-19 Thread Zhang Yi
From: Zhang Yi Currently, disks primarily implement the write zeroes command (aka REQ_OP_WRITE_ZEROES) through two mechanisms: the first involves physically writing zeros to the disk media (e.g., HDDs), while the second performs an unmap operation on the logical blocks, effectively putting them

[PATCH v2 2/9] nvme: set max_hw_wzeroes_unmap_sectors if device supports DEAC bit

2025-06-19 Thread Zhang Yi
From: Zhang Yi When the device supports the Write Zeroes command and the DEAC bit, it indicates that the deallocate bit in the Write Zeroes command is supported, and the bytes read from a deallocated logical block are zeroes. This means the device supports unmap Write Zeroes operation, so set

[PATCH v2 4/9] scsi: sd: set max_hw_wzeroes_unmap_sectors if device supports SD_ZERO_*_UNMAP

2025-06-19 Thread Zhang Yi
From: Zhang Yi When the device supports the Write Zeroes command and the zeroing mode is set to SD_ZERO_WS16_UNMAP or SD_ZERO_WS10_UNMAP, this means that the device supports unmap Write Zeroes, so set the corresponding max_hw_write_zeroes_unmap_sectors to max_write_zeroes_sectors on the device&#

[PATCH v2 9/9] ext4: add FALLOC_FL_WRITE_ZEROES support

2025-06-19 Thread Zhang Yi
From: Zhang Yi Add support for FALLOC_FL_WRITE_ZEROES if the underlying device enable the unmap write zeroes operation. This first allocates blocks as unwritten, then issues a zero command outside of the running journal handle, and finally converts them to a written state. Signed-off-by: Zhang

Re: [PATCH 00/10] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag

2025-06-16 Thread Zhang Yi
On 2025/6/17 0:59, Martin K. Petersen wrote: > > Christian, > >>> This looks OK to me as long as the fs folks agree on the fallocate() >>> semantics. >> >> That looks overall fine. Should I queue this up in the vfs tree? > > We're expecting another revision addressing the queue limit sysfs > ove

Re: [PATCH 01/10] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-06-12 Thread Zhang Yi
On 2025/6/12 23:03, Darrick J. Wong wrote: > On Thu, Jun 12, 2025 at 07:20:45PM +0800, Zhang Yi wrote: >> On 2025/6/12 12:47, Christoph Hellwig wrote: >>> On Wed, Jun 11, 2025 at 03:31:21PM +0800, Zhang Yi wrote: >>>>>> +/* supports unmap wri

Re: [PATCH 01/10] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-06-13 Thread Zhang Yi
On 2025/6/13 22:54, Darrick J. Wong wrote: > On Fri, Jun 13, 2025 at 07:56:30AM +0200, Christoph Hellwig wrote: >> On Fri, Jun 13, 2025 at 11:15:41AM +0800, Zhang Yi wrote: >>> Yeah, this solution looks good to me. However, we currently have only >>> two selections (

Re: [PATCH v2 0/9] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag

2025-06-26 Thread Zhang Yi
On 2025/6/23 23:08, Martin K. Petersen wrote: > > Zhang, > >> This series implements the BLK_FEAT_WRITE_ZEROES_UNMAP feature and >> BLK_FLAG_WRITE_ZEROES_UNMAP_DISABLED flag for SCSI, NVMe and >> device-mapper drivers, and add the FALLOC_FL_WRITE_ZEROES and >> STATX_ATTR_WRITE_ZEROES_UNMAP suppor

[PATCH 01/10] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-06-03 Thread Zhang Yi
From: Zhang Yi Currently, disks primarily implement the write zeroes command (aka REQ_OP_WRITE_ZEROES) through two mechanisms: the first involves physically writing zeros to the disk media (e.g., HDDs), while the second performs an unmap operation on the logical blocks, effectively putting them

[PATCH 00/10] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag

2025-06-03 Thread Zhang Yi
From: Zhang Yi Changes since RFC v4: - Rebase codes on 6.16-rc1. - Add a new queue_limit flag, and change the write_zeroes_unmap sysfs interface to RW mode. User can disable the unmap write zeroes operation by writing '0' to it when the operation is slow. - Modify the docume

[PATCH 04/10] nvmet: set WZDS and DRB if device supports BLK_FEAT_WRITE_ZEROES_UNMAP

2025-06-03 Thread Zhang Yi
From: Zhang Yi Set WZDS and DRB bit to the namespace dlfeat if the underlying block device supports BLK_FEAT_WRITE_ZEROES_UNMAP, make the nvme target device supports unmaped write zeroes command. Signed-off-by: Zhang Yi Reviewed-by: Christoph Hellwig --- drivers/nvme/target/io-cmd-bdev.c | 4

[PATCH 05/10] scsi: sd: set BLK_FEAT_WRITE_ZEROES_UNMAP if device supports unmap zeroing mode

2025-06-03 Thread Zhang Yi
From: Zhang Yi When the device supports the Write Zeroes command and the zeroing mode is set to SD_ZERO_WS16_UNMAP or SD_ZERO_WS10_UNMAP, this means that the device supports unmap Write Zeroes, so set the corresponding BLK_FEAT_WRITE_ZEROES_UNMAP feature to the device's queue limit. Signe

[PATCH 07/10] fs: introduce FALLOC_FL_WRITE_ZEROES to fallocate

2025-06-03 Thread Zhang Yi
From: Zhang Yi With the development of flash-based storage devices, we can quickly write zeros to SSDs using the WRITE_ZERO command if the devices do not actually write physical zeroes to the media. Therefore, we can use this command to quickly preallocate a real all-zero file with written

[PATCH 09/10] block: add FALLOC_FL_WRITE_ZEROES support

2025-06-03 Thread Zhang Yi
From: Zhang Yi Add support for FALLOC_FL_WRITE_ZEROES, if the block device enables the unmap write zeroes operation, it will issue a write zeroes command. Signed-off-by: Zhang Yi --- block/fops.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/block/fops.c b

[PATCH 10/10] ext4: add FALLOC_FL_WRITE_ZEROES support

2025-06-03 Thread Zhang Yi
From: Zhang Yi Add support for FALLOC_FL_WRITE_ZEROES if the underlying device enable the unmap write zeroes operation. This first allocates blocks as unwritten, then issues a zero command outside of the running journal handle, and finally converts them to a written state. Signed-off-by: Zhang

[PATCH 03/10] nvme-multipath: add BLK_FEAT_WRITE_ZEROES_UNMAP support

2025-06-03 Thread Zhang Yi
From: Zhang Yi Set the BLK_FEAT_WRITE_ZEROES_UNMAP feature while creating multipath stacking queue limits by default. This feature shall be disabled if any attached namespace does not support it. Signed-off-by: Zhang Yi Reviewed-by: Christoph Hellwig --- drivers/nvme/host/multipath.c | 3

[PATCH 08/10] block: factor out common part in blkdev_fallocate()

2025-06-03 Thread Zhang Yi
From: Zhang Yi Only the flags passed to blkdev_issue_zeroout() differ among the two zeroing branches in blkdev_fallocate(). Therefore, do cleanup by factoring them out. Signed-off-by: Zhang Yi Reviewed-by: Christoph Hellwig --- block/fops.c | 32 ++-- 1 file

[PATCH 02/10] nvme: set BLK_FEAT_WRITE_ZEROES_UNMAP if device supports DEAC bit

2025-06-03 Thread Zhang Yi
From: Zhang Yi When the device supports the Write Zeroes command and the DEAC bit, it indicates that the deallocate bit in the Write Zeroes command is supported, and the bytes read from a deallocated logical block are zeroes. This means the device supports unmap Write Zeroes, so set the

[PATCH 06/10] dm: add BLK_FEAT_WRITE_ZEROES_UNMAP support

2025-06-03 Thread Zhang Yi
From: Zhang Yi Set the BLK_FEAT_WRITE_ZEROES_UNMAP feature on stacking queue limits by default. This feature shall be disabled if any underlying device does not support it. Signed-off-by: Zhang Yi Reviewed-by: Benjamin Marzinski --- drivers/md/dm-table.c | 7 +-- drivers/md/dm.c

Re: [PATCH 01/10] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-06-11 Thread Zhang Yi
On 2025/6/11 14:09, Christoph Hellwig wrote: > On Wed, Jun 04, 2025 at 10:08:41AM +0800, Zhang Yi wrote: >> +static ssize_t queue_write_zeroes_unmap_show(struct gendisk *disk, char >> *page) > > .. > >> +static int queue_write_zeroes_unmap_store(struct gendisk *di

Re: [PATCH 07/10] fs: introduce FALLOC_FL_WRITE_ZEROES to fallocate

2025-06-12 Thread Zhang Yi
On 2025/6/11 23:05, Darrick J. Wong wrote: > [cc linux-api about a fallocate uapi change] > > On Wed, Jun 04, 2025 at 10:08:47AM +0800, Zhang Yi wrote: >> From: Zhang Yi >> >> With the development of flash-based storage devices, we can quickly >> write zeros to

Re: [PATCH 01/10] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features

2025-06-12 Thread Zhang Yi
On 2025/6/12 12:47, Christoph Hellwig wrote: > On Wed, Jun 11, 2025 at 03:31:21PM +0800, Zhang Yi wrote: >>>> +/* supports unmap write zeroes command */ >>>> +#define BLK_FEAT_WRITE_ZEROES_UNMAP ((__force blk_features_t)(1u << >>>> 17)) >>

Re: [PATCH v2 0/9] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag

2025-07-02 Thread Zhang Yi
On 2025/6/23 18:46, Christian Brauner wrote: > On Thu, 19 Jun 2025 19:17:57 +0800, Zhang Yi wrote: >> From: Zhang Yi >> >> Changes since v1: >> - Rebase codes on 6.16-rc2. >> - Use max_{hw|user}_wzeroes_unmap_sectors queue limits instead of >>BLK_FEAT_