nvme: let namespace probing continue for unsupported features
authorChristoph Hellwig <hch@lst.de>
Wed, 7 Apr 2021 13:03:16 +0000 (15:03 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 15 Apr 2021 06:12:56 +0000 (08:12 +0200)
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>
drivers/nvme/host/core.c
drivers/nvme/host/zns.c

index ded60d50fc564f7b1b9c054e5de9d3c6f355a25b..288ac47ff5b47091db5c7d91d7ba7f029855fa9a 100644 (file)
@@ -1832,7 +1832,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
        if (blk_queue_is_zoned(ns->queue)) {
                ret = nvme_revalidate_zones(ns);
                if (ret && !nvme_first_scan(ns->disk))
-                       return ret;
+                       goto out;
        }
 
        if (nvme_ns_head_multipath(ns->head)) {
@@ -1847,6 +1847,15 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
 
 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;
 }
 
index bc2f344f0ae01864caf8e477552f6bccbf6c0512..475dd45c3db49ba87fd62ff76b17027a4601db92 100644 (file)
@@ -96,7 +96,7 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
                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;
        }
 
@@ -105,7 +105,7 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
                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;
        }