[Bug Report] nvme-cli fails re-formatting NVMe namespace

Christoph Hellwig hch at infradead.org
Sun Mar 17 19:18:21 PDT 2024


Hi Nilay,

thanks for the report!

I'm currently travelling without easy hardware access, but can you try
the patch below?  This simply rebuilds the limits from scratch.  It
probably wants a bit of a cleanup if it works, but this should be
fine for testing:

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 00864a63447099..9ef41e65fc83bd 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2215,10 +2215,13 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
 		set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info));
 		nvme_mpath_revalidate_paths(ns);
 
-		lim = queue_limits_start_update(ns->head->disk->queue);
+		blk_set_stacking_limits(&lim);
+		lim.dma_alignment = 3;
+		if (info->ids.csi != NVME_CSI_ZNS)
+			lim.max_zone_append_sectors = 0;
 		queue_limits_stack_bdev(&lim, ns->disk->part0, 0,
 					ns->head->disk->disk_name);
-		ret = queue_limits_commit_update(ns->head->disk->queue, &lim);
+		ret = queue_limits_set(ns->head->disk->queue, &lim);
 		blk_mq_unfreeze_queue(ns->head->disk->queue);
 	}
 



More information about the Linux-nvme mailing list