From: John Garry <john.g.garry@oracle.com>
To: Yao Sang <sangyao@kylinos.cn>, Jens Axboe <axboe@kernel.dk>,
Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagi@grimberg.me>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Subject: Re: [PATCH v2 1/4] nvme: factor namespace-head queue-limit update
Date: Mon, 17 Aug 2026 17:32:50 +0100 [thread overview]
Message-ID: <6d737efc-e7dc-401a-a265-5cbc4beaa8fa@oracle.com> (raw)
In-Reply-To: <20260806024658.4193386-2-sangyao@kylinos.cn>
On 06/08/2026 03:46, Yao Sang wrote:
> Move the namespace head queue-limit update out of nvme_update_ns_info().
> The new helper keeps the current queue_limits_stack_bdev() based behavior
> intact, including zoned resource handling, write-stream assignment,
> integrity setup, capacity and readonly updates, path revalidation, and
> namespace-head zone revalidation.
>
> Keep queue-limit commit failures on the existing short-circuit path so
> capacity and namespace-head state are only updated after a successful
> limits update.
>
> The helper gives namespace-head queue-limit updates a single NVMe-local
> entry point while keeping the namespace information refresh sequencing
> unchanged.
Like the cover letter, this message is too verbose. So much so that I
lose track of what is important to note - that being the motivation for
the change.
The motivation seems to be to just factor out the NS head update into a
separate function as it deserves its own function and the code will be
neater, but not because it will in future have multiple callsites.
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Yao Sang <sangyao@kylinos.cn>
> ---
> drivers/nvme/host/core.c | 104 +++++++++++++++++++++------------------
> 1 file changed, 56 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index cb93ada4376a..e3d27c0440db 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2528,6 +2528,60 @@ 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 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(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;
> @@ -2566,54 +2620,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;
> }
next prev parent reply other threads:[~2026-08-17 16:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 2:46 [PATCH v2 0/4] block/nvme: split path limits for namespace heads Yao Sang
2026-08-06 2:46 ` [PATCH v2 1/4] nvme: factor namespace-head queue-limit update Yao Sang
2026-08-17 8:04 ` Christoph Hellwig
2026-08-17 16:32 ` John Garry [this message]
2026-08-06 2:46 ` [PATCH v2 2/4] block: factor block size and alignment handling out of blk_stack_limits Yao Sang
2026-08-17 8:05 ` Christoph Hellwig
2026-08-17 17:05 ` John Garry
2026-08-06 2:46 ` [PATCH v2 3/4] block: factor out path limit stacking Yao Sang
2026-08-17 8:10 ` Christoph Hellwig
2026-08-06 2:46 ` [PATCH v2 4/4] block, nvme: use lower-level limit helpers for namespace heads Yao Sang
2026-08-17 8:13 ` Christoph Hellwig
2026-08-10 8:50 ` [PATCH v2 0/4] block/nvme: split path limits " 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=6d737efc-e7dc-401a-a265-5cbc4beaa8fa@oracle.com \
--to=john.g.garry@oracle.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 \
--cc=sangyao@kylinos.cn \
/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