Linux-NVME Archive on 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

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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox