From: Zhang Yi <yi.zhang@huaweicloud.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>,
linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
linux-block@vger.kernel.org, dm-devel@lists.linux.dev,
linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
tytso@mit.edu, john.g.garry@oracle.com, bmarzins@redhat.com,
chaitanyak@nvidia.com, shinichiro.kawasaki@wdc.com,
brauner@kernel.org, martin.petersen@oracle.com,
yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com,
yangerkun@huawei.com
Subject: Re: [PATCH 01/10] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features
Date: Fri, 13 Jun 2025 11:15:41 +0800 [thread overview]
Message-ID: <3569a77f-1f38-4764-b1e3-d0075775c7bb@huaweicloud.com> (raw)
In-Reply-To: <20250612150347.GK6138@frogsfrogsfrogs>
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 write zeroes command */
>>>>>> +#define BLK_FEAT_WRITE_ZEROES_UNMAP ((__force blk_features_t)(1u << 17))
>>>>>
>>>>>
>>>>> Should this be exposed through sysfs as a read-only value?
>>>>
>>>> Uh, are you suggesting adding another sysfs interface to expose
>>>> this feature?
>>>
>>> That was the idea. Or do we have another way to report this capability?
>>>
>>
>> Exposing this feature looks useful, but I think adding a new interface
>> might be somewhat redundant, and it's also difficult to name the new
>> interface. What about extend this interface to include 3 types? When
>> read, it exposes the following:
>>
>> - none : the device doesn't support BLK_FEAT_WRITE_ZEROES_UNMAP.
>> - enabled : the device supports BLK_FEAT_WRITE_ZEROES_UNMAP, but the
>> BLK_FLAG_WRITE_ZEROES_UNMAP_DISABLED is not set.
>> - disabled : the device supports BLK_FEAT_WRITE_ZEROES_UNMAP, and the
>> BLK_FLAG_WRITE_ZEROES_UNMAP_DISABLED is set.
>>
>> Users can write '0' and '1' to disable and enable this operation if it
>> is not 'none', thoughts?
>
> Perhaps it should reuse the enumeration pattern elsewhere in sysfs?
> For example,
>
> # cat /sys/block/sda/queue/scheduler
> none [mq-deadline]
> # echo none > /sys/block/sda/queue/scheduler
> # cat /sys/block/sda/queue/scheduler
> [none] mq-deadline
>
> (Annoying that this seems to be opencoded wherever it appears...)
>
Yeah, this solution looks good to me. However, we currently have only
two selections (none and unmap). What if we keep it as is and simply
hide this interface if BLK_FEAT_WRITE_ZEROES_UNMAP is not set, making
it visible only when the device supports this feature? Something like
below:
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index e918b2c93aed..204ee4d5f63f 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -747,6 +747,9 @@ static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
attr == &queue_max_active_zones_entry.attr) &&
!blk_queue_is_zoned(q))
return 0;
+ if (attr == &queue_write_zeroes_unmap_entry.attr &&
+ !(q->limits.features & BLK_FEAT_WRITE_ZEROES_UNMAP))
+ return 0;
return attr->mode;
}
Thanks,
Yi.
next prev parent reply other threads:[~2025-06-13 3:15 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-04 2:08 [PATCH 00/10] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag Zhang Yi
2025-06-04 2:08 ` [PATCH 01/10] block: introduce BLK_FEAT_WRITE_ZEROES_UNMAP to queue limits features Zhang Yi
2025-06-11 6:09 ` Christoph Hellwig
2025-06-11 7:31 ` Zhang Yi
2025-06-12 4:47 ` Christoph Hellwig
2025-06-12 11:20 ` Zhang Yi
2025-06-12 15:03 ` Darrick J. Wong
2025-06-13 3:15 ` Zhang Yi [this message]
2025-06-13 5:56 ` Christoph Hellwig
2025-06-13 14:54 ` Darrick J. Wong
2025-06-14 4:48 ` Zhang Yi
2025-06-16 5:39 ` Christoph Hellwig
2025-06-04 2:08 ` [PATCH 02/10] nvme: set BLK_FEAT_WRITE_ZEROES_UNMAP if device supports DEAC bit Zhang Yi
2025-06-04 2:08 ` [PATCH 03/10] nvme-multipath: add BLK_FEAT_WRITE_ZEROES_UNMAP support Zhang Yi
2025-06-04 2:08 ` [PATCH 04/10] nvmet: set WZDS and DRB if device supports BLK_FEAT_WRITE_ZEROES_UNMAP Zhang Yi
2025-06-04 2:08 ` [PATCH 05/10] scsi: sd: set BLK_FEAT_WRITE_ZEROES_UNMAP if device supports unmap zeroing mode Zhang Yi
2025-06-04 2:08 ` [PATCH 06/10] dm: add BLK_FEAT_WRITE_ZEROES_UNMAP support Zhang Yi
2025-06-04 2:08 ` [PATCH 07/10] fs: introduce FALLOC_FL_WRITE_ZEROES to fallocate Zhang Yi
2025-06-11 15:05 ` Darrick J. Wong
2025-06-12 11:37 ` Zhang Yi
2025-06-04 2:08 ` [PATCH 08/10] block: factor out common part in blkdev_fallocate() Zhang Yi
2025-06-04 2:08 ` [PATCH 09/10] block: add FALLOC_FL_WRITE_ZEROES support Zhang Yi
2025-06-11 6:10 ` Christoph Hellwig
2025-06-04 2:08 ` [PATCH 10/10] ext4: " Zhang Yi
2025-06-10 1:47 ` [PATCH 00/10] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag Martin K. Petersen
2025-06-16 14:27 ` Christian Brauner
2025-06-16 16:59 ` Martin K. Petersen
2025-06-17 2:25 ` Zhang Yi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3569a77f-1f38-4764-b1e3-d0075775c7bb@huaweicloud.com \
--to=yi.zhang@huaweicloud.com \
--cc=bmarzins@redhat.com \
--cc=brauner@kernel.org \
--cc=chaitanyak@nvidia.com \
--cc=chengzhihao1@huawei.com \
--cc=djwong@kernel.org \
--cc=dm-devel@lists.linux.dev \
--cc=hch@lst.de \
--cc=john.g.garry@oracle.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=shinichiro.kawasaki@wdc.com \
--cc=tytso@mit.edu \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).