From: Damien Le Moal <damien.lemoal@wdc.com> To: linux-nvme@lists.infradead.org, Christoph Hellwig <hch@lst.de>, Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>, linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk> Subject: [PATCH] nvme: Fix io_opt limit setting Date: Thu, 14 May 2020 10:54:52 +0900 [thread overview] Message-ID: <20200514015452.1055278-1-damien.lemoal@wdc.com> (raw) 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 this value. 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; } results in blk_stack_limits() to return an error 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 optiomal IO size limit if the namespace does not report an optimal write size value. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> --- drivers/nvme/host/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index f3c037f5a9ba..0729173053ed 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1809,7 +1809,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 */ @@ -1832,12 +1832,11 @@ static void nvme_update_disk_info(struct gendisk *disk, atomic_bs = bs; } phys_bs = bs; - io_opt = bs; 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); @@ -1848,7 +1847,8 @@ static void nvme_update_disk_info(struct gendisk *disk, */ blk_queue_physical_block_size(disk->queue, min(phys_bs, atomic_bs)); blk_queue_io_min(disk->queue, phys_bs); - blk_queue_io_opt(disk->queue, io_opt); + if (io_opt) + blk_queue_io_opt(disk->queue, io_opt); if (ns->ms && !ns->ext && (ns->ctrl->ops->flags & NVME_F_METADATA_SUPPORTED)) -- 2.25.4
WARNING: multiple messages have this Message-ID (diff)
From: Damien Le Moal <damien.lemoal@wdc.com> To: linux-nvme@lists.infradead.org, Christoph Hellwig <hch@lst.de>, Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>, linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk> Subject: [PATCH] nvme: Fix io_opt limit setting Date: Thu, 14 May 2020 10:54:52 +0900 [thread overview] Message-ID: <20200514015452.1055278-1-damien.lemoal@wdc.com> (raw) 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 this value. 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; } results in blk_stack_limits() to return an error 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 optiomal IO size limit if the namespace does not report an optimal write size value. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> --- drivers/nvme/host/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index f3c037f5a9ba..0729173053ed 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1809,7 +1809,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 */ @@ -1832,12 +1832,11 @@ static void nvme_update_disk_info(struct gendisk *disk, atomic_bs = bs; } phys_bs = bs; - io_opt = bs; 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); @@ -1848,7 +1847,8 @@ static void nvme_update_disk_info(struct gendisk *disk, */ blk_queue_physical_block_size(disk->queue, min(phys_bs, atomic_bs)); blk_queue_io_min(disk->queue, phys_bs); - blk_queue_io_opt(disk->queue, io_opt); + if (io_opt) + blk_queue_io_opt(disk->queue, io_opt); if (ns->ms && !ns->ext && (ns->ctrl->ops->flags & NVME_F_METADATA_SUPPORTED)) -- 2.25.4 _______________________________________________ linux-nvme mailing list linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme
next reply other threads:[~2020-05-14 1:54 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-14 1:54 Damien Le Moal [this message] 2020-05-14 1:54 ` [PATCH] nvme: Fix io_opt limit setting Damien Le Moal 2020-05-14 3:29 ` Martin K. Petersen 2020-05-14 3:29 ` Martin K. Petersen 2020-05-14 3:40 ` Keith Busch 2020-05-14 3:40 ` Keith Busch 2020-05-14 3:47 ` Damien Le Moal 2020-05-14 3:47 ` Damien Le Moal 2020-05-14 4:12 ` Keith Busch 2020-05-14 4:12 ` Keith Busch 2020-05-14 4:13 ` Damien Le Moal 2020-05-14 4:13 ` Damien Le Moal 2020-05-14 4:47 ` Bart Van Assche 2020-05-14 4:47 ` Bart Van Assche 2020-05-14 4:49 ` Damien Le Moal 2020-05-14 4:49 ` Damien Le Moal 2020-05-14 22:19 ` Martin K. Petersen 2020-05-14 22:19 ` Martin K. Petersen 2020-05-14 6:11 ` Hannes Reinecke 2020-05-14 6:11 ` Hannes Reinecke
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=20200514015452.1055278-1-damien.lemoal@wdc.com \ --to=damien.lemoal@wdc.com \ --cc=axboe@kernel.dk \ --cc=hch@lst.de \ --cc=kbusch@kernel.org \ --cc=linux-block@vger.kernel.org \ --cc=linux-nvme@lists.infradead.org \ --cc=sagi@grimberg.me \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.