[PATCH] nvme: core: freeze multipath queue early in nvme_update_ns_info()
Sagi Grimberg
sagi at grimberg.me
Sun Aug 25 01:28:51 PDT 2024
The patch title should explain what it is fixing, i.e. the reason of
its existence.
Perhaps something like:
nvme: shorten multipath ns update duration
On 22/08/2024 23:14, Martin Wilck wrote:
> For multipath devices, nvme_update_ns_info() needs to freeze both
> the queue of the path and the queue of the multipath device. For
> both operations, it waits for one RCU grace period to pass, ~25ms
> on my test system. By calling blk_freeze_queue_start() for the
> multipath queue early, we avoid waiting twice; tests using ftrace
> have shown that the second blk_mq_freeze_queue_wait() call finishes
> in just a few microseconds. The path queue is unfrozen before
> calling blk_mq_freeze_queue_wait() on the multipath queue, so that
> possibly outstanding IO in the multipath queue can be flushed.
>
> I tested this using the "controller rescan under I/O load" test
> I submitted recently [1].
>
> [1] https://lore.kernel.org/linux-nvme/20240822193814.106111-3-mwilck@suse.com/T/#u
>
> Signed-off-by: Martin Wilck <mwilck at suse.com>
> ---
> drivers/nvme/host/core.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 33fa01c599ad..e2454398c660 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2217,6 +2217,9 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
> bool unsupported = false;
> int ret;
>
> + if (nvme_ns_head_multipath(ns->head))
> + blk_freeze_queue_start(ns->head->disk->queue);
Lets add a small comment here.
> +
> switch (info->ids.csi) {
> case NVME_CSI_ZNS:
> if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED)) {
> @@ -2254,7 +2257,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
> struct queue_limits *ns_lim = &ns->disk->queue->limits;
> struct queue_limits lim;
>
> - blk_mq_freeze_queue(ns->head->disk->queue);
> + blk_mq_freeze_queue_wait(ns->head->disk->queue);
> /*
> * queue_limits mixes values that are the hardware limitations
> * for bio splitting with what is the device configuration.
> @@ -2288,7 +2291,8 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
> nvme_mpath_revalidate_paths(ns);
>
> blk_mq_unfreeze_queue(ns->head->disk->queue);
> - }
> + } else if (nvme_ns_head_multipath(ns->head))
> + blk_mq_unfreeze_queue(ns->head->disk->queue);
Right now if ret!=0 you are unfreezing without waiting, you need to wait
for the freeze to
complete before unfreezing.
You should restructure the code to make it so that the freeze_start,
freeze_wait, unfreeze are
paired regardless of the code flows.
More information about the Linux-nvme
mailing list