linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] nvme: Fix io_opt limit setting
@ 2020-05-14  5:56 Damien Le Moal
  2020-05-14  6:18 ` Hannes Reinecke
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Damien Le Moal @ 2020-05-14  5:56 UTC (permalink / raw)
  To: linux-nvme, Christoph Hellwig, Keith Busch, Sagi Grimberg
  Cc: linux-block, Jens Axboe

Currently, a namespace io_opt queue limit is set by default to the
physical sector size of the namespace and to the the write optimal
size (NOWS) when the namespace reports optimal IO sizes. This causes
problems with block limits stacking in blk_stack_limits() when a
namespace block device is combined with an HDD which generally do not
report any optimal transfer size (io_opt limit is 0). The code:

/* Optimal I/O a multiple of the physical block size? */
if (t->io_opt & (t->physical_block_size - 1)) {
	t->io_opt = 0;
	t->misaligned = 1;
	ret = -1;
}

in blk_stack_limits() results in an error return for this function when
the combined devices have different but compatible physical sector
sizes (e.g. 512B sector SSD with 4KB sector disks).

Fix this by not setting the optimal IO size queue limit if the namespace
does not report an optimal write size value.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---

* Changes from v1:
  - Rebased on nvme/nvme-5.8 tree

 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 805d289e6cd9..951d558dc662 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1842,7 +1842,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
 {
 	sector_t capacity = nvme_lba_to_sect(ns, le64_to_cpu(id->nsze));
 	unsigned short bs = 1 << ns->lba_shift;
-	u32 atomic_bs, phys_bs, io_opt;
+	u32 atomic_bs, phys_bs, io_opt = 0;
 
 	if (ns->lba_shift > PAGE_SHIFT) {
 		/* unsupported block size, set capacity to 0 later */
@@ -1851,7 +1851,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
 	blk_mq_freeze_queue(disk->queue);
 	blk_integrity_unregister(disk);
 
-	atomic_bs = phys_bs = io_opt = bs;
+	atomic_bs = phys_bs = bs;
 	nvme_setup_streams_ns(ns->ctrl, ns, &phys_bs, &io_opt);
 	if (id->nabo == 0) {
 		/*
-- 
2.25.4


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

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

* Re: [PATCH v2] nvme: Fix io_opt limit setting
  2020-05-14  5:56 [PATCH v2] nvme: Fix io_opt limit setting Damien Le Moal
@ 2020-05-14  6:18 ` Hannes Reinecke
  2020-05-14 13:54 ` Bart Van Assche
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Hannes Reinecke @ 2020-05-14  6:18 UTC (permalink / raw)
  To: Damien Le Moal, linux-nvme, Christoph Hellwig, Keith Busch,
	Sagi Grimberg
  Cc: linux-block, Jens Axboe

On 5/14/20 7:56 AM, Damien Le Moal wrote:
> Currently, a namespace io_opt queue limit is set by default to the
> physical sector size of the namespace and to the the write optimal
> size (NOWS) when the namespace reports optimal IO sizes. This causes
> problems with block limits stacking in blk_stack_limits() when a
> namespace block device is combined with an HDD which generally do not
> report any optimal transfer size (io_opt limit is 0). The code:
> 
> /* Optimal I/O a multiple of the physical block size? */
> if (t->io_opt & (t->physical_block_size - 1)) {
> 	t->io_opt = 0;
> 	t->misaligned = 1;
> 	ret = -1;
> }
> 
> in blk_stack_limits() results in an error return for this function when
> the combined devices have different but compatible physical sector
> sizes (e.g. 512B sector SSD with 4KB sector disks).
> 
> Fix this by not setting the optimal IO size queue limit if the namespace
> does not report an optimal write size value.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
> 
> * Changes from v1:
>    - Rebased on nvme/nvme-5.8 tree
> 
>   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 805d289e6cd9..951d558dc662 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1842,7 +1842,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
>   {
>   	sector_t capacity = nvme_lba_to_sect(ns, le64_to_cpu(id->nsze));
>   	unsigned short bs = 1 << ns->lba_shift;
> -	u32 atomic_bs, phys_bs, io_opt;
> +	u32 atomic_bs, phys_bs, io_opt = 0;
>   
>   	if (ns->lba_shift > PAGE_SHIFT) {
>   		/* unsupported block size, set capacity to 0 later */
> @@ -1851,7 +1851,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
>   	blk_mq_freeze_queue(disk->queue);
>   	blk_integrity_unregister(disk);
>   
> -	atomic_bs = phys_bs = io_opt = bs;
> +	atomic_bs = phys_bs = bs;
>   	nvme_setup_streams_ns(ns->ctrl, ns, &phys_bs, &io_opt);
>   	if (id->nabo == 0) {
>   		/*
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

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] 5+ messages in thread

* Re: [PATCH v2] nvme: Fix io_opt limit setting
  2020-05-14  5:56 [PATCH v2] nvme: Fix io_opt limit setting Damien Le Moal
  2020-05-14  6:18 ` Hannes Reinecke
@ 2020-05-14 13:54 ` Bart Van Assche
  2020-05-14 15:12 ` Christoph Hellwig
  2020-05-14 22:20 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2020-05-14 13:54 UTC (permalink / raw)
  To: Damien Le Moal, linux-nvme, Christoph Hellwig, Keith Busch,
	Sagi Grimberg
  Cc: linux-block, Jens Axboe

On 2020-05-13 22:56, Damien Le Moal wrote:
> Currently, a namespace io_opt queue limit is set by default to the
> physical sector size of the namespace and to the the write optimal
> size (NOWS) when the namespace reports optimal IO sizes. This causes
> problems with block limits stacking in blk_stack_limits() when a
> namespace block device is combined with an HDD which generally do not
> report any optimal transfer size (io_opt limit is 0). The code:

Reviewed-by: Bart van Assche <bvanassche@acm.org>

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

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

* Re: [PATCH v2] nvme: Fix io_opt limit setting
  2020-05-14  5:56 [PATCH v2] nvme: Fix io_opt limit setting Damien Le Moal
  2020-05-14  6:18 ` Hannes Reinecke
  2020-05-14 13:54 ` Bart Van Assche
@ 2020-05-14 15:12 ` Christoph Hellwig
  2020-05-14 22:20 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2020-05-14 15:12 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: Jens Axboe, Sagi Grimberg, linux-nvme, linux-block, Keith Busch,
	Christoph Hellwig

Thanks,

applied to nvme-5.8.

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

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

* Re: [PATCH v2] nvme: Fix io_opt limit setting
  2020-05-14  5:56 [PATCH v2] nvme: Fix io_opt limit setting Damien Le Moal
                   ` (2 preceding siblings ...)
  2020-05-14 15:12 ` Christoph Hellwig
@ 2020-05-14 22:20 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2020-05-14 22:20 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: Jens Axboe, Sagi Grimberg, linux-nvme, linux-block, Keith Busch,
	Christoph Hellwig


Damien,

> Fix this by not setting the optimal IO size queue limit if the
> namespace does not report an optimal write size value.

I'm also OK with this approach.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

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

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-14  5:56 [PATCH v2] nvme: Fix io_opt limit setting Damien Le Moal
2020-05-14  6:18 ` Hannes Reinecke
2020-05-14 13:54 ` Bart Van Assche
2020-05-14 15:12 ` Christoph Hellwig
2020-05-14 22:20 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).