Blob Blame History Raw
From: Christoph Hellwig <hch@lst.de>
Date: Wed, 7 Apr 2021 15:03:16 +0200
Subject: nvme: let namespace probing continue for unsupported features
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Patch-mainline: v5.13-rc1
Git-commit: a9e0e6bc728ebcfe9f6acdca84e5c6cafee895cf
References: git-fixes

Instead of failing to scan the namespace entirely when unsupported
features are detected, just mark the gendisk hidden but allow other
access like the upcoming per-namespace character device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Javier González <javier.gonz@samsung.com>
Acked-by: Daniel Wagner <dwagner@suse.de>
---
 drivers/nvme/host/core.c |   11 ++++++++++-
 drivers/nvme/host/zns.c  |    4 ++--
 2 files changed, 12 insertions(+), 3 deletions(-)

--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2192,7 +2192,7 @@ static int nvme_update_ns_info(struct nv
 	if (blk_queue_is_zoned(ns->queue)) {
 		ret = nvme_revalidate_zones(ns);
 		if (ret)
-			return ret;
+			goto out;
 	}
 
 #ifdef CONFIG_NVME_MULTIPATH
@@ -2208,6 +2208,15 @@ static int nvme_update_ns_info(struct nv
 
 out_unfreeze:
 	blk_mq_unfreeze_queue(ns->disk->queue);
+out:
+	/*
+	 * If probing fails due an unsupported feature, hide the block device,
+	 * but still allow other access.
+	 */
+	if (ret == -ENODEV) {
+		ns->disk->flags |= GENHD_FL_HIDDEN;
+		ret = 0;
+	}
 	return ret;
 }
 
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -91,7 +91,7 @@ int nvme_update_zone_info(struct nvme_ns
 		dev_warn(ns->ctrl->device,
 			"zone operations:%x not supported for namespace:%u\n",
 			le16_to_cpu(id->zoc), ns->head->ns_id);
-		status = -EINVAL;
+		status = -ENODEV;
 		goto free_data;
 	}
 
@@ -100,7 +100,7 @@ int nvme_update_zone_info(struct nvme_ns
 		dev_warn(ns->ctrl->device,
 			"invalid zone size:%llu for namespace:%u\n",
 			ns->zsze, ns->head->ns_id);
-		status = -EINVAL;
+		status = -ENODEV;
 		goto free_data;
 	}