Skip to content

Commit 46e7422

Browse files
Christoph Hellwigkeithbusch
authored andcommitted
nvme: move common logic into nvme_update_ns_info
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> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent d60c23e commit 46e7422

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

drivers/nvme/host/core.c

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,21 +2070,8 @@ static int nvme_update_ns_info_generic(struct nvme_ns *ns,
20702070
set_disk_ro(ns->disk, nvme_ns_is_readonly(ns, info));
20712071
blk_mq_unfreeze_queue(ns->disk->queue);
20722072

2073-
if (nvme_ns_head_multipath(ns->head)) {
2074-
blk_mq_freeze_queue(ns->head->disk->queue);
2075-
set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info));
2076-
nvme_mpath_revalidate_paths(ns);
2077-
blk_stack_limits(&ns->head->disk->queue->limits,
2078-
&ns->queue->limits, 0);
2079-
ns->head->disk->flags |= GENHD_FL_HIDDEN;
2080-
blk_mq_unfreeze_queue(ns->head->disk->queue);
2081-
}
2082-
20832073
/* Hide the block-interface for these devices */
2084-
ns->disk->flags |= GENHD_FL_HIDDEN;
2085-
set_bit(NVME_NS_READY, &ns->flags);
2086-
2087-
return 0;
2074+
return -ENODEV;
20882075
}
20892076

20902077
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,
21042091
/* namespace not allocated or attached */
21052092
info->is_removed = true;
21062093
ret = -ENODEV;
2107-
goto error;
2094+
goto out;
21082095
}
21092096

21102097
blk_mq_freeze_queue(ns->disk->queue);
@@ -2162,54 +2149,67 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
21622149
goto out;
21632150
}
21642151

2165-
if (nvme_ns_head_multipath(ns->head)) {
2166-
blk_mq_freeze_queue(ns->head->disk->queue);
2167-
nvme_init_integrity(ns->head->disk, ns->head);
2168-
set_capacity_and_notify(ns->head->disk, get_capacity(ns->disk));
2169-
set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info));
2170-
nvme_mpath_revalidate_paths(ns);
2171-
blk_stack_limits(&ns->head->disk->queue->limits,
2172-
&ns->queue->limits, 0);
2173-
disk_update_readahead(ns->head->disk);
2174-
blk_mq_unfreeze_queue(ns->head->disk->queue);
2175-
}
2176-
21772152
ret = 0;
21782153
out:
2179-
/*
2180-
* If probing fails due an unsupported feature, hide the block device,
2181-
* but still allow other access.
2182-
*/
2183-
if (ret == -ENODEV) {
2184-
ns->disk->flags |= GENHD_FL_HIDDEN;
2185-
set_bit(NVME_NS_READY, &ns->flags);
2186-
ret = 0;
2187-
}
2188-
2189-
error:
21902154
kfree(id);
21912155
return ret;
21922156
}
21932157

21942158
static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
21952159
{
2160+
bool unsupported = false;
2161+
int ret;
2162+
21962163
switch (info->ids.csi) {
21972164
case NVME_CSI_ZNS:
21982165
if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED)) {
21992166
dev_info(ns->ctrl->device,
22002167
"block device for nsid %u not supported without CONFIG_BLK_DEV_ZONED\n",
22012168
info->nsid);
2202-
return nvme_update_ns_info_generic(ns, info);
2169+
ret = nvme_update_ns_info_generic(ns, info);
2170+
break;
22032171
}
2204-
return nvme_update_ns_info_block(ns, info);
2172+
ret = nvme_update_ns_info_block(ns, info);
2173+
break;
22052174
case NVME_CSI_NVM:
2206-
return nvme_update_ns_info_block(ns, info);
2175+
ret = nvme_update_ns_info_block(ns, info);
2176+
break;
22072177
default:
22082178
dev_info(ns->ctrl->device,
22092179
"block device for nsid %u not supported (csi %u)\n",
22102180
info->nsid, info->ids.csi);
2211-
return nvme_update_ns_info_generic(ns, info);
2181+
ret = nvme_update_ns_info_generic(ns, info);
2182+
break;
22122183
}
2184+
2185+
/*
2186+
* If probing fails due an unsupported feature, hide the block device,
2187+
* but still allow other access.
2188+
*/
2189+
if (ret == -ENODEV) {
2190+
ns->disk->flags |= GENHD_FL_HIDDEN;
2191+
set_bit(NVME_NS_READY, &ns->flags);
2192+
unsupported = true;
2193+
ret = 0;
2194+
}
2195+
2196+
if (!ret && nvme_ns_head_multipath(ns->head)) {
2197+
blk_mq_freeze_queue(ns->head->disk->queue);
2198+
if (unsupported)
2199+
ns->head->disk->flags |= GENHD_FL_HIDDEN;
2200+
else
2201+
nvme_init_integrity(ns->head->disk, ns->head);
2202+
set_capacity_and_notify(ns->head->disk, get_capacity(ns->disk));
2203+
set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info));
2204+
nvme_mpath_revalidate_paths(ns);
2205+
blk_stack_limits(&ns->head->disk->queue->limits,
2206+
&ns->queue->limits, 0);
2207+
2208+
disk_update_readahead(ns->head->disk);
2209+
blk_mq_unfreeze_queue(ns->head->disk->queue);
2210+
}
2211+
2212+
return ret;
22132213
}
22142214

22152215
#ifdef CONFIG_BLK_SED_OPAL

0 commit comments

Comments
 (0)