Re: [PATCH v2] nvme: skip the zoned limits update if the zone info query failed

From: Christoph Hellwig

Date: Mon Aug 17 2026 - 02:58:08 EST


On Sun, Aug 16, 2026 at 03:17:29PM -0400, Chao Shi wrote:
> nvme_query_zone_info() returns either a negative errno or a positive
> NVMe status code, but nvme_update_ns_info_block() only tests for the
> negative case:
>
> ret = nvme_query_zone_info(ns, lbaf, &zi);
> if (ret < 0)
> goto out;
>
> If the device fails the Identify Namespace (I/O Command Set specific)
> command, or the Identify Controller command issued by
> nvme_set_max_append(), the positive status falls through and setup
> continues with the zero-initialized zone info. nvme_update_zone_info()
> then marks the queue zoned with chunk_sectors and ns->head->zsze set to
> zero.
>
> blk_validate_zoned_limits() does not check chunk_sectors, so the limits
> commit succeeds. blk_revalidate_disk_zones() does reject the zero zone
> size, but by then the limits are live and nothing rolls them back, so
> I/O keeps being submitted to a zoned queue with a zero zone size and
> disk_zone_no() shifts by ilog2(0):

Did you do error injections to get here?

> + /*
> + * A failed zone info query leaves zi zero-initialized. Leave the
> + * namespace registered so that it can still be used as a device
> + * handle, but do not configure the zoned limits from it.
> + */
> if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
> - ns->head->ids.csi == NVME_CSI_ZNS)
> + ns->head->ids.csi == NVME_CSI_ZNS && zi.zone_size)
> nvme_update_zone_info(ns, &lim, &zi);

The most common case for this is probably during revalidation of some
kind, and then we'll just keep the old values. Which in general
should be fine, but might be worth mentioning in this comment?

Also we should probably log a message that we either just register
the handle or keep the old values?