Skip to contentSkip to conversation

nvme: set 'io_opt' to '0' if not specified

PATCH In review Hannes Reinecke 2 participants 3 messages May 14, 2020 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: set 'io_opt' to '0' if not specified

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.

---
 drivers/nvme/host/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +2 -2
index a4d8c90ee7cc..6a8a8e749d11 100644
@@ -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);
Signature · 7 lines
2.16.4


_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#1 lore raw
Quoted 21 lines · Hannes Reinecke

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.

---
 drivers/nvme/host/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +0 -1
index a4d8c90ee7cc..6a8a8e749d11 100644
@@ -1785,12 +1785,12 @@ static void nvme_update_disk_info(struct gendisk *disk,
 		atomic_bs = bs;
 	}
 	phys_bs = bs;
-	io_opt = bs;

drivers/nvme/host/core.c static void nvme_update_disk_info(struct gendisk *disk, · line 1796

Quoted 10 lines
drivers/nvme/host/core.c +2 -1
+	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.

Signature · 7 lines
Damien Le Moal
Western Digital Research

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#2 lore raw
In reply to Hannes Reinecke
Quoted 21 lines · Hannes Reinecke

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.

---
  drivers/nvme/host/core.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +0 -1
index a4d8c90ee7cc..6a8a8e749d11 100644
@@ -1785,12 +1785,12 @@ static void nvme_update_disk_info(struct gendisk *disk,
  		atomic_bs = bs;
  	}
  	phys_bs = bs;
-	io_opt = bs;

drivers/nvme/host/core.c static void nvme_update_disk_info(struct gendisk *disk, · line 1796

Quoted 10 lines
drivers/nvme/host/core.c +2 -1
+	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

Signature · 9 lines
Dr. Hannes Reinecke            Teamlead Storage & Networking
[email protected]                               +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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme