All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: set 'io_opt' to '0' if not specified
@ 2020-05-14  6:05 Hannes Reinecke
  2020-05-14  6:15 ` Damien Le Moal
  2020-05-14  6:17 ` Hannes Reinecke
  0 siblings, 2 replies; 3+ messages in thread
From: Hannes Reinecke @ 2020-05-14  6:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Damien LeMoal, Mike Snitzer, Keith Busch, linux-nvme,
	Hannes Reinecke, Martin K. Petersen, Sagi Grimberg

When no optimal I/O size is report we should set the value of
io_opt to '0', not the block size.
This avoids any potential miscalculation of the block limits
for stacking devices.

Reported-by: Damien LeMoal <damien.lemoal@wdc.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/nvme/host/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index a4d8c90ee7cc..6a8a8e749d11 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1785,12 +1785,12 @@ static void nvme_update_disk_info(struct gendisk *disk,
 		atomic_bs = bs;
 	}
 	phys_bs = bs;
-	io_opt = bs;
+	io_opt = 0;
 	if (id->nsfeat & (1 << 4)) {
 		/* NPWG = Namespace Preferred Write Granularity */
 		phys_bs *= 1 + le16_to_cpu(id->npwg);
 		/* NOWS = Namespace Optimal Write Size */
-		io_opt *= 1 + le16_to_cpu(id->nows);
+		io_opt = bs * 1 + le16_to_cpu(id->nows);
 	}
 
 	blk_queue_logical_block_size(disk->queue, bs);
-- 
2.16.4


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme: set 'io_opt' to '0' if not specified
  2020-05-14  6:05 [PATCH] nvme: set 'io_opt' to '0' if not specified Hannes Reinecke
@ 2020-05-14  6:15 ` Damien Le Moal
  2020-05-14  6:17 ` Hannes Reinecke
  1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2020-05-14  6:15 UTC (permalink / raw)
  To: Hannes Reinecke, Christoph Hellwig
  Cc: Keith Busch, linux-nvme, Mike Snitzer, Sagi Grimberg, Martin K. Petersen

On 2020/05/14 15:05, Hannes Reinecke wrote:
> When no optimal I/O size is report we should set the value of
> io_opt to '0', not the block size.
> This avoids any potential miscalculation of the block limits
> for stacking devices.
> 
> Reported-by: Damien LeMoal <damien.lemoal@wdc.com>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>  drivers/nvme/host/core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index a4d8c90ee7cc..6a8a8e749d11 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1785,12 +1785,12 @@ static void nvme_update_disk_info(struct gendisk *disk,
>  		atomic_bs = bs;
>  	}
>  	phys_bs = bs;
> -	io_opt = bs;
> +	io_opt = 0;
>  	if (id->nsfeat & (1 << 4)) {
>  		/* NPWG = Namespace Preferred Write Granularity */
>  		phys_bs *= 1 + le16_to_cpu(id->npwg);
>  		/* NOWS = Namespace Optimal Write Size */
> -		io_opt *= 1 + le16_to_cpu(id->nows);
> +		io_opt = bs * 1 + le16_to_cpu(id->nows);
>  	}
>  
>  	blk_queue_logical_block_size(disk->queue, bs);
> 

Haha ! I beat you to it :) Just sent a patch for that.

-- 
Damien Le Moal
Western Digital Research

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme: set 'io_opt' to '0' if not specified
  2020-05-14  6:05 [PATCH] nvme: set 'io_opt' to '0' if not specified Hannes Reinecke
  2020-05-14  6:15 ` Damien Le Moal
@ 2020-05-14  6:17 ` Hannes Reinecke
  1 sibling, 0 replies; 3+ messages in thread
From: Hannes Reinecke @ 2020-05-14  6:17 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Damien LeMoal, Mike Snitzer, Keith Busch, linux-nvme,
	Martin K. Petersen, Sagi Grimberg

On 5/14/20 8:05 AM, Hannes Reinecke wrote:
> When no optimal I/O size is report we should set the value of
> io_opt to '0', not the block size.
> This avoids any potential miscalculation of the block limits
> for stacking devices.
> 
> Reported-by: Damien LeMoal <damien.lemoal@wdc.com>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   drivers/nvme/host/core.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index a4d8c90ee7cc..6a8a8e749d11 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1785,12 +1785,12 @@ static void nvme_update_disk_info(struct gendisk *disk,
>   		atomic_bs = bs;
>   	}
>   	phys_bs = bs;
> -	io_opt = bs;
> +	io_opt = 0;
>   	if (id->nsfeat & (1 << 4)) {
>   		/* NPWG = Namespace Preferred Write Granularity */
>   		phys_bs *= 1 + le16_to_cpu(id->npwg);
>   		/* NOWS = Namespace Optimal Write Size */
> -		io_opt *= 1 + le16_to_cpu(id->nows);
> +		io_opt = bs * 1 + le16_to_cpu(id->nows);
>   	}
>   
>   	blk_queue_logical_block_size(disk->queue, bs);
> 
Right; Damien beat me to it.
Please ignore this patch.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke            Teamlead Storage & Networking
hare@suse.de                               +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-14  6:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-14  6:05 [PATCH] nvme: set 'io_opt' to '0' if not specified Hannes Reinecke
2020-05-14  6:15 ` Damien Le Moal
2020-05-14  6:17 ` Hannes Reinecke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.