[PATCH] nvme-multipath: revalidate zones for namespace heads
Damien Le Moal
dlemoal at kernel.org
Tue Jun 9 17:01:24 PDT 2026
On 2026/06/09 14:31, Yao Sang wrote:
> Zoned multipath namespace heads get BLK_FEAT_ZONED and their limits are
> refreshed from the paths, but the zone state for the head disk is never
> initialized. The previous nr_zones assignment only updated a single
> field and did not allocate or populate the block layer's per-zone state.
>
> That leaves the head disk without valid zone condition information. Code
> using the head device, such as bdev_zone_is_seq(), can then treat a
> sequential zone as non-sequential and submit regular writes to it.
>
> Add a small helper to run blk_revalidate_disk_zones() for a live zoned
> namespace head after the path limits have been committed and when a path
> becomes live. Return the error to the namespace update path, and keep the
> live path transition as a warning-only update. Drop the nr_zones copy, as
> blk_revalidate_disk_zones() updates it together with the rest of the zoned
> disk state.
>
> Signed-off-by: Yao Sang <sangyao at kylinos.cn>
> ---
> The failure was found with xfstests xfs/643 and xfs/646 on an NVMe
> ZNS multipath namespace. Tracing showed regular REQ_OP_WRITE I/O being
> submitted to sequential zones through the multipath head.
>
> The head queue had the zoned limits stacked from the path, but the head
> gendisk had not gone through blk_revalidate_disk_zones(). That left the
> block layer per-zone state missing on the head disk, so users of the head
> device could treat sequential zones as non-sequential.
Mentioning the test case that triggered the issue is good, so it would be nice
to include this text in the commit message.
> +#ifdef CONFIG_BLK_DEV_ZONED
> +int nvme_mpath_revalidate_zones(struct nvme_ns_head *head)
> +{
> + struct gendisk *disk = head->disk;
> + int ret;
> +
> + if (!disk || !blk_queue_is_zoned(disk->queue) ||
> + !test_bit(NVME_NSHEAD_DISK_LIVE, &head->flags))
> + return 0;
> +
> + ret = blk_revalidate_disk_zones(disk);
> + if (ret)
> + dev_warn_ratelimited(disk_to_dev(disk),
> + "failed to revalidate zoned namespace head: %d\n",
> + ret);
> + return ret;
> +}
> +#endif /* CONFIG_BLK_DEV_ZONED */
Maybe define this helper in nvme/host/zns.c ? But either way, this depends on
both CONFIG_BLK_DEV_ZONED and CONFIG_NVME_MULTIPATH, so this is also fine as is.
So regardless, with the commit message updated,
Reviewed-by: Damien Le Moal <dlemoal at kernel.org>
--
Damien Le Moal
Western Digital Research
More information about the Linux-nvme
mailing list