public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Niklas Cassel <nks@flawful.org>
To: Keith Busch <kbusch@meta.com>
Cc: linux-nvme@lists.infradead.org, hch@lst.de, sagi@grimberg.me,
	Keith Busch <kbusch@kernel.org>, Tom Yan <tom.ty89@gmail.com>,
	Laurence Oberman <loberman@redhat.com>
Subject: Re: [PATCH] nvme: fix discard support without oncs
Date: Tue, 4 Apr 2023 17:12:47 +0200	[thread overview]
Message-ID: <ZCw+b9dpTp/cnms9@x1-carbon> (raw)
In-Reply-To: <20230403200925.1641963-1-kbusch@meta.com>

On Mon, Apr 03, 2023 at 01:09:25PM -0700, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> The device can report discard support without setting the ONCS DSM bit.
> When not set, the driver clears max_discard_size expecting it to be set
> later. We don't know the size until we have the namespace format,
> though, so setting it is deferred until configuring one, but the driver
> was abandoning the discard settings due to that initial clearing.
> 
> Move the max_discard_size calculation above the check for a '0' discard
> size.
> 
> Fixes: 1a86924e4f46475 ("nvme: fix interpretation of DMRSL")
> Cc: Tom Yan <tom.ty89@gmail.com>
> Reported-by: Laurence Oberman <loberman@redhat.com>
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
>  drivers/nvme/host/core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 53ef028596c61..d6a9bac91a4cd 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1674,6 +1674,9 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
>  	struct request_queue *queue = disk->queue;
>  	u32 size = queue_logical_block_size(queue);
>  
> +	if (ctrl->dmrsl && ctrl->dmrsl <= nvme_sect_to_lba(ns, UINT_MAX))
> +		ctrl->max_discard_sectors = nvme_lba_to_sect(ns, ctrl->dmrsl);
> +
>  	if (ctrl->max_discard_sectors == 0) {
>  		blk_queue_max_discard_sectors(queue, 0);
>  		return;
> @@ -1688,9 +1691,6 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
>  	if (queue->limits.max_discard_sectors)
>  		return;
>  
> -	if (ctrl->dmrsl && ctrl->dmrsl <= nvme_sect_to_lba(ns, UINT_MAX))
> -		ctrl->max_discard_sectors = nvme_lba_to_sect(ns, ctrl->dmrsl);
> -
>  	blk_queue_max_discard_sectors(queue, ctrl->max_discard_sectors);
>  	blk_queue_max_discard_segments(queue, ctrl->max_discard_segments);
>  
> -- 
> 2.34.1
> 
> 

Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>


  parent reply	other threads:[~2023-04-04 15:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03 20:09 [PATCH] nvme: fix discard support without oncs Keith Busch
2023-04-03 20:57 ` Laurence Oberman
2023-04-03 22:40 ` Sagi Grimberg
2023-04-04 15:12 ` Niklas Cassel [this message]
2023-04-05 15:13 ` Christoph Hellwig

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=ZCw+b9dpTp/cnms9@x1-carbon \
    --to=nks@flawful.org \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=kbusch@meta.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=loberman@redhat.com \
    --cc=sagi@grimberg.me \
    --cc=tom.ty89@gmail.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