From: Yao Sang <sangyao@kylinos.cn>
To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me
Cc: john.g.garry@oracle.com, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, Yao Sang <sangyao@kylinos.cn>
Subject: [PATCH v3 1/5] nvme: factor namespace-head queue-limit update
Date: Fri, 21 Aug 2026 18:10:46 +0800 [thread overview]
Message-ID: <20260821101050.1464087-2-sangyao@kylinos.cn> (raw)
In-Reply-To: <20260821101050.1464087-1-sangyao@kylinos.cn>
Move the namespace-head queue-limit update out of nvme_update_ns_info().
The update is self-contained, and moving it into a separate helper makes
the namespace scan easier to follow.
There is no behavior change.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Yao Sang <sangyao@kylinos.cn>
---
drivers/nvme/host/core.c | 103 +++++++++++++++++++++------------------
1 file changed, 55 insertions(+), 48 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 1322c678f4eb..8e2b44ed4366 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2538,6 +2538,59 @@ static void nvme_stack_zone_resources(struct queue_limits *t,
min_not_zero(t->max_active_zones, b->max_active_zones);
}
+static int nvme_update_ns_head_limits(struct nvme_ns *ns,
+ struct nvme_ns_info *info, bool unsupported)
+{
+ struct queue_limits *ns_lim = &ns->disk->queue->limits;
+ struct request_queue *head_q = ns->head->disk->queue;
+ struct queue_limits lim;
+ unsigned int memflags;
+ int ret;
+
+ lim = queue_limits_start_update(head_q);
+ memflags = blk_mq_freeze_queue(head_q);
+ /*
+ * queue_limits mixes hardware limitations for bio splitting with device
+ * configuration.
+ *
+ * For NVMe the device configuration can change after e.g. a Format
+ * command, and we really want to pick up the new format value here. But
+ * we must still stack the queue limits to the least common denominator
+ * for multipathing to split the bios properly.
+ *
+ * To work around this, we explicitly set the device configuration to
+ * those that we just queried, but only stack the splitting limits in to
+ * make sure we still obey possibly lower limitations of other
+ * controllers.
+ */
+ lim.logical_block_size = ns_lim->logical_block_size;
+ lim.physical_block_size = ns_lim->physical_block_size;
+ lim.io_min = ns_lim->io_min;
+ lim.io_opt = ns_lim->io_opt;
+ queue_limits_stack_bdev(&lim, ns->disk->part0, 0,
+ ns->head->disk->disk_name);
+ if (lim.features & BLK_FEAT_ZONED)
+ nvme_stack_zone_resources(&lim, ns_lim);
+ if (unsupported)
+ ns->head->disk->flags |= GENHD_FL_HIDDEN;
+ else
+ nvme_init_integrity(ns->head, &lim, info);
+ lim.max_write_streams = ns_lim->max_write_streams;
+ lim.write_stream_granularity = ns_lim->write_stream_granularity;
+ ret = queue_limits_commit_update(head_q, &lim);
+ if (ret)
+ goto unfreeze_head_queue;
+
+ set_capacity_and_notify(ns->head->disk, get_capacity(ns->disk));
+ set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info));
+ nvme_mpath_revalidate_paths(ns->head);
+ ret = nvme_mpath_revalidate_zones(ns->head);
+
+unfreeze_head_queue:
+ blk_mq_unfreeze_queue(head_q, memflags);
+ return ret;
+}
+
static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
{
bool unsupported = false;
@@ -2576,54 +2629,8 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
ret = 0;
}
- if (!ret && nvme_ns_head_multipath(ns->head)) {
- struct queue_limits *ns_lim = &ns->disk->queue->limits;
- struct queue_limits lim;
- unsigned int memflags;
-
- lim = queue_limits_start_update(ns->head->disk->queue);
- memflags = blk_mq_freeze_queue(ns->head->disk->queue);
- /*
- * queue_limits mixes values that are the hardware limitations
- * for bio splitting with what is the device configuration.
- *
- * For NVMe the device configuration can change after e.g. a
- * Format command, and we really want to pick up the new format
- * value here. But we must still stack the queue limits to the
- * least common denominator for multipathing to split the bios
- * properly.
- *
- * To work around this, we explicitly set the device
- * configuration to those that we just queried, but only stack
- * the splitting limits in to make sure we still obey possibly
- * lower limitations of other controllers.
- */
- lim.logical_block_size = ns_lim->logical_block_size;
- lim.physical_block_size = ns_lim->physical_block_size;
- lim.io_min = ns_lim->io_min;
- lim.io_opt = ns_lim->io_opt;
- queue_limits_stack_bdev(&lim, ns->disk->part0, 0,
- ns->head->disk->disk_name);
- if (lim.features & BLK_FEAT_ZONED)
- nvme_stack_zone_resources(&lim, ns_lim);
- if (unsupported)
- ns->head->disk->flags |= GENHD_FL_HIDDEN;
- else
- nvme_init_integrity(ns->head, &lim, info);
- lim.max_write_streams = ns_lim->max_write_streams;
- lim.write_stream_granularity = ns_lim->write_stream_granularity;
- ret = queue_limits_commit_update(ns->head->disk->queue, &lim);
- if (ret)
- goto unfreeze_head_queue;
-
- set_capacity_and_notify(ns->head->disk, get_capacity(ns->disk));
- set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info));
- nvme_mpath_revalidate_paths(ns->head);
- ret = nvme_mpath_revalidate_zones(ns->head);
-
-unfreeze_head_queue:
- blk_mq_unfreeze_queue(ns->head->disk->queue, memflags);
- }
+ if (!ret && nvme_ns_head_multipath(ns->head))
+ ret = nvme_update_ns_head_limits(ns, info, unsupported);
return ret;
}
--
2.25.1
next prev parent reply other threads:[~2026-08-21 10:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 10:10 [PATCH v3 0/5] block, nvme: support same-LBA multipath limit stacking Yao Sang
2026-08-21 10:10 ` Yao Sang [this message]
2026-08-21 10:10 ` [PATCH v3 2/5] block: factor mapped-range topology out of blk_stack_limits Yao Sang
2026-08-21 10:10 ` [PATCH v3 3/5] block: factor path limits " Yao Sang
2026-08-21 10:10 ` [PATCH v3 4/5] block: factor atomic write hardware limit stacking Yao Sang
2026-08-21 10:10 ` [PATCH v3 5/5] block, nvme: add same-LBA multipath limit helpers Yao Sang
2026-09-07 9:44 ` John Garry
2026-08-31 8:03 ` [PATCH v3 0/5] block, nvme: support same-LBA multipath limit stacking Yao Sang
2026-09-07 9:34 ` John Garry
2026-09-10 10:08 ` Yao Sang
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=20260821101050.1464087-2-sangyao@kylinos.cn \
--to=sangyao@kylinos.cn \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=john.g.garry@oracle.com \
--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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox