[RFC PATCH v4 07/11] fs: statx add write zeroes unmap attribute
Zhang Yi
yi.zhang at huaweicloud.com
Mon May 5 21:28:54 PDT 2025
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 <yi.zhang at huawei.com>
>>>
>>> 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 <yi.zhang at huawei.com>
>>> ---
>>> block/bdev.c | 4 ++++
>>> fs/ext4/inode.c | 9 ++++++---
>>> include/uapi/linux/stat.h | 1 +
>>> 3 files changed, 11 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/block/bdev.c b/block/bdev.c
>>> index 4844d1e27b6f..29b0e5feb138 100644
>>> --- a/block/bdev.c
>>> +++ b/block/bdev.c
>>> @@ -1304,6 +1304,10 @@ void bdev_statx(struct path *path, struct kstat *stat,
>>> queue_atomic_write_unit_max_bytes(bd_queue));
>>> }
>>>
>>> + if (bdev_write_zeroes_unmap(bdev))
>>> + stat->attributes |= STATX_ATTR_WRITE_ZEROES_UNMAP;
>>> + stat->attributes_mask |= STATX_ATTR_WRITE_ZEROES_UNMAP;
>>
>> Hmm, shouldn't this always be set by stat? But I might just be
>> really confused what attributes_mask is, and might in fact have
>> misapplied it in past patches of my own..
>
> attributes_mask contains attribute flags known to the filesystem,
> whereas attributes contains flags actually set on the file.
> "known_attributes" would have been a better name, but that's water under
> the bridge. :P
>
>> Also shouldn't the patches to report the flag go into the bdev/ext4
>> patches that actually implement the feature for the respective files
>> to keep bisectability?
>
> /I/ think so...
>
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.
Thanks,
Yi.
More information about the Linux-nvme
mailing list