From: Christoph Hellwig <hch@lst.de>
To: Hector Martin <marcan@marcan.st>, Sven Peter <sven@svenpeter.dev>,
Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
James Smart <james.smart@broadcom.com>,
Chaitanya Kulkarni <kch@nvidia.com>
Cc: Alyssa Rosenzweig <alyssa@rosenzweig.io>,
asahi@lists.linux.dev, linux-nvme@lists.infradead.org
Subject: [PATCH 10/16] nvme: move common logic into nvme_update_ns_info
Date: Mon, 4 Mar 2024 07:04:54 -0700 [thread overview]
Message-ID: <20240304140500.78583-11-hch@lst.de> (raw)
In-Reply-To: <20240304140500.78583-1-hch@lst.de>
nvme_update_ns_info_generic and nvme_update_ns_info_block share a
fair amount of logic related to not fully supported namespace
formats and updating the multipath information. Move this logic
into the common caller.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/core.c | 84 ++++++++++++++++++++--------------------
1 file changed, 42 insertions(+), 42 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ce70bfb66242e2..f0686a872d0e30 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2070,21 +2070,8 @@ static int nvme_update_ns_info_generic(struct nvme_ns *ns,
set_disk_ro(ns->disk, nvme_ns_is_readonly(ns, info));
blk_mq_unfreeze_queue(ns->disk->queue);
- if (nvme_ns_head_multipath(ns->head)) {
- blk_mq_freeze_queue(ns->head->disk->queue);
- set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info));
- nvme_mpath_revalidate_paths(ns);
- blk_stack_limits(&ns->head->disk->queue->limits,
- &ns->queue->limits, 0);
- ns->head->disk->flags |= GENHD_FL_HIDDEN;
- blk_mq_unfreeze_queue(ns->head->disk->queue);
- }
-
/* Hide the block-interface for these devices */
- ns->disk->flags |= GENHD_FL_HIDDEN;
- set_bit(NVME_NS_READY, &ns->flags);
-
- return 0;
+ return -ENODEV;
}
static int nvme_update_ns_info_block(struct nvme_ns *ns,
@@ -2104,7 +2091,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
/* namespace not allocated or attached */
info->is_removed = true;
ret = -ENODEV;
- goto error;
+ goto out;
}
blk_mq_freeze_queue(ns->disk->queue);
@@ -2162,54 +2149,67 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
goto out;
}
- if (nvme_ns_head_multipath(ns->head)) {
- blk_mq_freeze_queue(ns->head->disk->queue);
- nvme_init_integrity(ns->head->disk, ns->head);
- set_capacity_and_notify(ns->head->disk, get_capacity(ns->disk));
- set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info));
- nvme_mpath_revalidate_paths(ns);
- blk_stack_limits(&ns->head->disk->queue->limits,
- &ns->queue->limits, 0);
- disk_update_readahead(ns->head->disk);
- blk_mq_unfreeze_queue(ns->head->disk->queue);
- }
-
ret = 0;
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;
- set_bit(NVME_NS_READY, &ns->flags);
- ret = 0;
- }
-
-error:
kfree(id);
return ret;
}
static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
{
+ bool unsupported = false;
+ int ret;
+
switch (info->ids.csi) {
case NVME_CSI_ZNS:
if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED)) {
dev_info(ns->ctrl->device,
"block device for nsid %u not supported without CONFIG_BLK_DEV_ZONED\n",
info->nsid);
- return nvme_update_ns_info_generic(ns, info);
+ ret = nvme_update_ns_info_generic(ns, info);
+ break;
}
- return nvme_update_ns_info_block(ns, info);
+ ret = nvme_update_ns_info_block(ns, info);
+ break;
case NVME_CSI_NVM:
- return nvme_update_ns_info_block(ns, info);
+ ret = nvme_update_ns_info_block(ns, info);
+ break;
default:
dev_info(ns->ctrl->device,
"block device for nsid %u not supported (csi %u)\n",
info->nsid, info->ids.csi);
- return nvme_update_ns_info_generic(ns, info);
+ ret = nvme_update_ns_info_generic(ns, info);
+ break;
}
+
+ /*
+ * 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;
+ set_bit(NVME_NS_READY, &ns->flags);
+ unsupported = true;
+ ret = 0;
+ }
+
+ if (!ret && nvme_ns_head_multipath(ns->head)) {
+ blk_mq_freeze_queue(ns->head->disk->queue);
+ if (unsupported)
+ ns->head->disk->flags |= GENHD_FL_HIDDEN;
+ else
+ nvme_init_integrity(ns->head->disk, ns->head);
+ set_capacity_and_notify(ns->head->disk, get_capacity(ns->disk));
+ set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info));
+ nvme_mpath_revalidate_paths(ns);
+ blk_stack_limits(&ns->head->disk->queue->limits,
+ &ns->queue->limits, 0);
+
+ disk_update_readahead(ns->head->disk);
+ blk_mq_unfreeze_queue(ns->head->disk->queue);
+ }
+
+ return ret;
}
#ifdef CONFIG_BLK_SED_OPAL
--
2.39.2
next prev parent reply other threads:[~2024-03-04 14:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 14:04 convert nvme to atomic queue limits updates v2 Christoph Hellwig
2024-03-04 14:04 ` [PATCH 01/16] nvme: set max_hw_sectors unconditionally Christoph Hellwig
2024-03-04 15:56 ` John Garry
2024-03-04 14:04 ` [PATCH 02/16] nvme: move NVME_QUIRK_DEALLOCATE_ZEROES out of nvme_config_discard Christoph Hellwig
2024-03-04 14:04 ` [PATCH 03/16] nvme: remove nvme_revalidate_zones Christoph Hellwig
2024-03-04 14:04 ` [PATCH 04/16] nvme: move max_integrity_segments handling out of nvme_init_integrity Christoph Hellwig
2024-03-04 14:04 ` [PATCH 05/16] nvme: cleanup the nvme_init_integrity calling conventions Christoph Hellwig
2024-03-04 14:04 ` [PATCH 06/16] nvme: move blk_integrity_unregister into nvme_init_integrity Christoph Hellwig
2024-03-04 14:04 ` [PATCH 07/16] nvme: don't use nvme_update_disk_info for the multipath disk Christoph Hellwig
2024-03-04 14:04 ` [PATCH 08/16] nvme: move a few things out of nvme_update_disk_info Christoph Hellwig
2024-03-04 14:04 ` [PATCH 09/16] nvme: move setting the write cache flags out of nvme_set_queue_limits Christoph Hellwig
2024-03-04 14:04 ` Christoph Hellwig [this message]
2024-03-04 14:04 ` [PATCH 11/16] nvme: split out a nvme_identify_ns_nvm helper Christoph Hellwig
2024-03-04 14:04 ` [PATCH 12/16] nvme: don't query identify data in configure_metadata Christoph Hellwig
2024-03-04 14:04 ` [PATCH 13/16] nvme: cleanup nvme_configure_metadata Christoph Hellwig
2024-03-04 14:04 ` [PATCH 14/16] nvme: use the atomic queue limits update API Christoph Hellwig
2024-03-26 10:24 ` Kanchan Joshi
2024-03-26 14:52 ` Christoph Hellwig
2024-03-04 14:04 ` [PATCH 15/16] nvme-multipath: pass queue_limits to blk_alloc_disk Christoph Hellwig
2024-03-04 14:05 ` [PATCH 16/16] nvme-multipath: use atomic queue limits API for stacking limits Christoph Hellwig
2024-03-04 16:27 ` convert nvme to atomic queue limits updates v2 Keith Busch
2024-03-07 8:39 ` Sagi Grimberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240304140500.78583-11-hch@lst.de \
--to=hch@lst.de \
--cc=alyssa@rosenzweig.io \
--cc=asahi@lists.linux.dev \
--cc=james.smart@broadcom.com \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-nvme@lists.infradead.org \
--cc=marcan@marcan.st \
--cc=sagi@grimberg.me \
--cc=sven@svenpeter.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox