linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Revert "nvme: cleanup zone information initialization"
@ 2021-03-08 10:42 Niklas Cassel
  2021-03-08 16:32 ` Kanchan Joshi
  0 siblings, 1 reply; 3+ messages in thread
From: Niklas Cassel @ 2021-03-08 10:42 UTC (permalink / raw)
  To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg
  Cc: Niklas Cassel, linux-nvme, linux-kernel

From: Niklas Cassel <niklas.cassel@wdc.com>

This reverts commit 73d90386b559d6f4c3c5db5e6bb1b68aae8fd3e7.

Commit 73d90386b559 ("nvme: cleanup zone information initialization")
introduced the following warning at boot:
WARNING: CPU: 0 PID: 7 at block/blk-settings.c:252 blk_queue_max_zone_append_sectors+0x7d/0x90

The warning is the result of chunk_sectors being 0.

Worse, this causes the sysfs attribute zone_append_max_bytes to
be incorrectly reported as 0, which will break user space applications
relying on this attribute.

Looking at the commit, it probably assumes that calling
nvme_set_chunk_sectors() will cause chunk_sectors to be set.

However, looking at nvme_set_chunk_sectors(), chunk_sectors
is only set if namespace optimal i/o boundary (noiob) is non-zero.

A noiob value of zero is perfectly valid according to the spec,
and simply means that the namespace does not report an optimal i/o
boundary. Hence, we cannot assume that chunk_sectors is set after
nvme_set_chunk_sectors() has been called.

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
---
 drivers/nvme/host/core.c | 11 +++++------
 drivers/nvme/host/zns.c  | 11 ++++++++---
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e68a8c4ac5a6..a38b509eeb80 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2210,18 +2210,17 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
 	ns->lba_shift = id->lbaf[lbaf].ds;
 	nvme_set_queue_limits(ns->ctrl, ns->queue);
 
-	ret = nvme_configure_metadata(ns, id);
-	if (ret)
-		goto out_unfreeze;
-	nvme_set_chunk_sectors(ns, id);
-	nvme_update_disk_info(ns->disk, ns, id);
-
 	if (ns->head->ids.csi == NVME_CSI_ZNS) {
 		ret = nvme_update_zone_info(ns, lbaf);
 		if (ret)
 			goto out_unfreeze;
 	}
 
+	ret = nvme_configure_metadata(ns, id);
+	if (ret)
+		goto out_unfreeze;
+	nvme_set_chunk_sectors(ns, id);
+	nvme_update_disk_info(ns->disk, ns, id);
 	blk_mq_unfreeze_queue(ns->disk->queue);
 
 	if (blk_queue_is_zoned(ns->queue)) {
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index c7e3ec561ba0..1dfe9a3500e3 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -9,7 +9,13 @@
 
 int nvme_revalidate_zones(struct nvme_ns *ns)
 {
-	return blk_revalidate_disk_zones(ns->disk, NULL);
+	struct request_queue *q = ns->queue;
+	int ret;
+
+	ret = blk_revalidate_disk_zones(ns->disk, NULL);
+	if (!ret)
+		blk_queue_max_zone_append_sectors(q, ns->ctrl->max_zone_append);
+	return ret;
 }
 
 static int nvme_set_max_append(struct nvme_ctrl *ctrl)
@@ -103,11 +109,10 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
 		goto free_data;
 	}
 
-	blk_queue_set_zoned(ns->disk, BLK_ZONED_HM);
+	q->limits.zoned = BLK_ZONED_HM;
 	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
 	blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
 	blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
-	blk_queue_max_zone_append_sectors(q, ns->ctrl->max_zone_append);
 free_data:
 	kfree(id);
 	return status;
-- 
2.29.2

_______________________________________________
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] Revert "nvme: cleanup zone information initialization"
  2021-03-08 10:42 [PATCH] Revert "nvme: cleanup zone information initialization" Niklas Cassel
@ 2021-03-08 16:32 ` Kanchan Joshi
  2021-03-08 16:51   ` Niklas Cassel
  0 siblings, 1 reply; 3+ messages in thread
From: Kanchan Joshi @ 2021-03-08 16:32 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	linux-nvme, linux-kernel

On Mon, Mar 8, 2021 at 4:21 PM Niklas Cassel <Niklas.Cassel@wdc.com> wrote:
>
> From: Niklas Cassel <niklas.cassel@wdc.com>
>
> This reverts commit 73d90386b559d6f4c3c5db5e6bb1b68aae8fd3e7.
>
> Commit 73d90386b559 ("nvme: cleanup zone information initialization")
> introduced the following warning at boot:
> WARNING: CPU: 0 PID: 7 at block/blk-settings.c:252 blk_queue_max_zone_append_sectors+0x7d/0x90
>
> The warning is the result of chunk_sectors being 0.

This looks same as what Chaitanya posted the fix for -
https://lore.kernel.org/linux-nvme/20210303224717.51633-1-chaitanya.kulkarni@wdc.com/

_______________________________________________
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] Revert "nvme: cleanup zone information initialization"
  2021-03-08 16:32 ` Kanchan Joshi
@ 2021-03-08 16:51   ` Niklas Cassel
  0 siblings, 0 replies; 3+ messages in thread
From: Niklas Cassel @ 2021-03-08 16:51 UTC (permalink / raw)
  To: Kanchan Joshi
  Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	linux-nvme, linux-kernel

On Mon, Mar 08, 2021 at 10:02:05PM +0530, Kanchan Joshi wrote:
> On Mon, Mar 8, 2021 at 4:21 PM Niklas Cassel <Niklas.Cassel@wdc.com> wrote:
> >
> > From: Niklas Cassel <niklas.cassel@wdc.com>
> >
> > This reverts commit 73d90386b559d6f4c3c5db5e6bb1b68aae8fd3e7.
> >
> > Commit 73d90386b559 ("nvme: cleanup zone information initialization")
> > introduced the following warning at boot:
> > WARNING: CPU: 0 PID: 7 at block/blk-settings.c:252 blk_queue_max_zone_append_sectors+0x7d/0x90
> >
> > The warning is the result of chunk_sectors being 0.
> 
> This looks same as what Chaitanya posted the fix for -
> https://lore.kernel.org/linux-nvme/20210303224717.51633-1-chaitanya.kulkarni@wdc.com/

Hello Kanchan,

Indeed, thanks for telling me.

Kind regards,
Niklas
_______________________________________________
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:[~2021-03-08 16:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08 10:42 [PATCH] Revert "nvme: cleanup zone information initialization" Niklas Cassel
2021-03-08 16:32 ` Kanchan Joshi
2021-03-08 16:51   ` Niklas Cassel

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).