From: Zhang Yi <yi.zhang@huaweicloud.com>
To: Robert Pang <robertpang@google.com>
Cc: Zhang Yi <yi.zhang@huawei.com>,
bmarzins@redhat.com, brauner@kernel.org, chaitanyak@nvidia.com,
chengzhihao1@huawei.com, djwong@kernel.org,
dm-devel@lists.linux.dev, hch@lst.de, john.g.garry@oracle.com,
linux-block@vger.kernel.org, linux-ext4@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org,
linux-xfs@vger.kernel.org, martin.petersen@oracle.com,
shinichiro.kawasaki@wdc.com, tytso@mit.edu, yangerkun@huawei.com,
yukuai3@huawei.com
Subject: Re: [PATCH v2 2/9] nvme: set max_hw_wzeroes_unmap_sectors if device supports DEAC bit
Date: Thu, 26 Feb 2026 19:09:42 +0800 [thread overview]
Message-ID: <8a45c55f-8abe-4cdf-be70-208550edf320@huaweicloud.com> (raw)
In-Reply-To: <CAJhEC05L7QEc9iY7gFZVK3SPYvFhtFyURss6xQgZ-qWwZZkFjA@mail.gmail.com>
On 2/26/2026 5:43 AM, Robert Pang wrote:
> Dear Zhang Yi
>
> Thank you for your quick response. Please see my comments below:
>
> On Tue, Feb 24, 2026 at 6:32 PM Zhang Yi <yi.zhang@huaweicloud.com> wrote:
>>
>> Hi Robert!
>>
>> On 2/25/2026 8:05 AM, Robert Pang wrote:
>>> Dear Zhang Yi,
>>>
>>> In reviewing your patch series implementing support for the
>>> FALLOC_FL_WRITE_ZEROES flag, I noted the logic propagating
>>> max_write_zeroes_sectors to max_hw_wzeroes_unmap_sectors in commit 545fb46e5bc6
>>> "nvme: set max_hw_wzeroes_unmap_sectors if device supports DEAC bit" [1]. This
>>> appears to be intended for devices that support the Write Zeroes command
>>> alongside the DEAC bit to indicate unmap capability.
>>>
>>> Furthermore, within core.c, the NVME_QUIRK_DEALLOCATE_ZEROES quirk already
>>> identifies devices that deterministically return zeroes after a deallocate
>>> command [2]. This quirk currently enables Write Zeroes support via discard in
>>> existing implementations [3, 4].
>>>
>>> Given this, would it be appropriate to respect NVME_QUIRK_DEALLOCATE_ZEROES also
>>> to enable unmap Write Zeroes for these devices, following the prior commit
>>> 6e02318eaea5 "nvme: add support for the Write Zeroes command" [5]? I have
>>> included a proposed change to nvme_update_ns_info_block() below for your
>>> consideration.
>>>
>>
>> Thank you for your point. Overall, this makes sense to me, but I have one
>> question below.
>>
>>> Best regards
>>> Robert Pang
>>>
>>> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
>>> index f5ebcaa2f859..9c7e2cabfab3 100644
>>> --- a/drivers/nvme/host/core.c
>>> +++ b/drivers/nvme/host/core.c
>>> @@ -2422,7 +2422,9 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
>>> * require that, it must be a no-op if reads from deallocated data
>>> * do not return zeroes.
>>> */
>>> - if ((id->dlfeat & 0x7) == 0x1 && (id->dlfeat & (1 << 3))) {
>>> + if ((id->dlfeat & 0x7) == 0x1 && (id->dlfeat & (1 << 3)) ||
>>> + (ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES) &&
>>> + (ns->ctrl->oncs & NVME_CTRL_ONCS_DSM)) {
>> ^^^^^^^^^^^^^^^^^^
>> Why do you want to add a check for NVME_CTRL_ONCS_DSM? In nvme_config_discard(),
>> it appears that we prioritize ctrl->dmrsl, allowing discard to still be
>> supported even on some non-standard devices where NVME_CTRL_ONCS_DSM is not set.
>> In nvme_update_disk_info(), if the device only has NVME_QUIRK_DEALLOCATE_ZEROES,
>> we still populate lim->max_write_zeroes_sectors (which might be non-zero on
>> devices that support NVME_CTRL_ONCS_WRITE_ZEROES). Right? So I'm not sure if we
>> only need to check for NVME_QUIRK_DEALLOCATE_ZEROES here.
>>
> The check for NVME_CTRL_ONCS_DSM is to follow the same check in [3]. There, the
> check was added by 58a0c875ce02 "nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES
> when DSM is not supported" [6]. The idea is to limit
> NVME_QUIRK_DEALLOCATE_ZEROES
> to those devices that support DSM.
>
OK.
>>> ns->head->features |= NVME_NS_DEAC;
>>
>> I think we should not set NVME_NS_DEAC for the quirks case.
>>
> Make sense. In that case, will it be more appropriate to set
> max_hw_wzeroes_unmap_sectors in nvme_update_disk_info() where
> NVME_QUIRK_DEALLOCATE_ZEROES is checked? I.e.
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index f5ebcaa2f859..3f5dd3f867e9 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2120,9 +2120,10 @@ static bool nvme_update_disk_info(struct
> nvme_ns *ns, struct nvme_id_ns *id,
> lim->io_min = phys_bs;
> lim->io_opt = io_opt;
> if ((ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES) &&
> - (ns->ctrl->oncs & NVME_CTRL_ONCS_DSM))
> + (ns->ctrl->oncs & NVME_CTRL_ONCS_DSM)) {
> lim->max_write_zeroes_sectors = UINT_MAX;
> - else
> + lim->max_hw_wzeroes_unmap_sectors = UINT_MAX;
> + } else
> lim->max_write_zeroes_sectors = ns->ctrl->max_zeroes_sectors;
> return valid;
> }
>
Yeah, it looks good to me.
Best regards,
Yi.
> Best regards
> Robert
>
>> Cheers,
>> Yi.
>>
>>> lim.max_hw_wzeroes_unmap_sectors = lim.max_write_zeroes_sectors;
>>> }
>>>
>>> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=545fb46e5bc6
>>> [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/nvme/host/nvme.h#n72
>>> [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/nvme/host/core.c#n938
>>> [4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/nvme/host/core.c#n2122
>>> [5] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6e02318eaea5
> [6] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=58a0c875ce02
next prev parent reply other threads:[~2026-02-26 11:09 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-19 11:17 [PATCH v2 0/9] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag Zhang Yi
2025-06-19 11:17 ` [PATCH v2 1/9] block: introduce max_{hw|user}_wzeroes_unmap_sectors to queue limits Zhang Yi
2025-06-23 5:39 ` Christoph Hellwig
2025-08-21 12:55 ` John Garry
2025-08-23 4:37 ` Zhang Yi
2025-06-19 11:17 ` [PATCH v2 2/9] nvme: set max_hw_wzeroes_unmap_sectors if device supports DEAC bit Zhang Yi
2025-06-23 5:40 ` Christoph Hellwig
2026-02-25 0:05 ` Robert Pang
2026-02-25 2:32 ` Zhang Yi
2026-02-25 21:43 ` Robert Pang
2026-02-26 11:09 ` Zhang Yi [this message]
2026-02-27 1:34 ` Robert Pang
2025-06-19 11:18 ` [PATCH v2 3/9] nvmet: set WZDS and DRB if device enables unmap write zeroes operation Zhang Yi
2025-06-23 5:40 ` Christoph Hellwig
2025-06-19 11:18 ` [PATCH v2 4/9] scsi: sd: set max_hw_wzeroes_unmap_sectors if device supports SD_ZERO_*_UNMAP Zhang Yi
2025-06-19 11:18 ` [PATCH v2 5/9] dm: clear unmap write zeroes limits when disabling write zeroes Zhang Yi
2025-06-19 11:18 ` [PATCH v2 6/9] fs: introduce FALLOC_FL_WRITE_ZEROES to fallocate Zhang Yi
2025-06-19 11:18 ` [PATCH v2 7/9] block: factor out common part in blkdev_fallocate() Zhang Yi
2025-06-19 11:18 ` [PATCH v2 8/9] block: add FALLOC_FL_WRITE_ZEROES support Zhang Yi
2025-06-19 11:18 ` [PATCH v2 9/9] ext4: " Zhang Yi
2025-06-23 10:46 ` [PATCH v2 0/9] fallocate: introduce FALLOC_FL_WRITE_ZEROES flag Christian Brauner
2025-07-03 3:35 ` Zhang Yi
2025-07-04 8:39 ` Christian Brauner
2025-06-23 15:08 ` Martin K. Petersen
2025-06-26 13:57 ` 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=8a45c55f-8abe-4cdf-be70-208550edf320@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=robertpang@google.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
all inboxes | Powered by JetHome®