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>
This commit is contained in:
parent
d60c23e455
commit
46e7422cda
1 changed files with 49 additions and 49 deletions
|
@ -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));
|
set_disk_ro(ns->disk, nvme_ns_is_readonly(ns, info));
|
||||||
blk_mq_unfreeze_queue(ns->disk->queue);
|
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 */
|
/* Hide the block-interface for these devices */
|
||||||
ns->disk->flags |= GENHD_FL_HIDDEN;
|
return -ENODEV;
|
||||||
set_bit(NVME_NS_READY, &ns->flags);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nvme_update_ns_info_block(struct nvme_ns *ns,
|
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 */
|
/* namespace not allocated or attached */
|
||||||
info->is_removed = true;
|
info->is_removed = true;
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto error;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
blk_mq_freeze_queue(ns->disk->queue);
|
blk_mq_freeze_queue(ns->disk->queue);
|
||||||
|
@ -2162,20 +2149,39 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
|
||||||
goto out;
|
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;
|
ret = 0;
|
||||||
out:
|
out:
|
||||||
|
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);
|
||||||
|
ret = nvme_update_ns_info_generic(ns, info);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ret = nvme_update_ns_info_block(ns, info);
|
||||||
|
break;
|
||||||
|
case NVME_CSI_NVM:
|
||||||
|
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);
|
||||||
|
ret = nvme_update_ns_info_generic(ns, info);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If probing fails due an unsupported feature, hide the block device,
|
* If probing fails due an unsupported feature, hide the block device,
|
||||||
* but still allow other access.
|
* but still allow other access.
|
||||||
|
@ -2183,33 +2189,27 @@ out:
|
||||||
if (ret == -ENODEV) {
|
if (ret == -ENODEV) {
|
||||||
ns->disk->flags |= GENHD_FL_HIDDEN;
|
ns->disk->flags |= GENHD_FL_HIDDEN;
|
||||||
set_bit(NVME_NS_READY, &ns->flags);
|
set_bit(NVME_NS_READY, &ns->flags);
|
||||||
|
unsupported = true;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
error:
|
if (!ret && nvme_ns_head_multipath(ns->head)) {
|
||||||
kfree(id);
|
blk_mq_freeze_queue(ns->head->disk->queue);
|
||||||
return ret;
|
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);
|
||||||
|
|
||||||
static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
|
disk_update_readahead(ns->head->disk);
|
||||||
{
|
blk_mq_unfreeze_queue(ns->head->disk->queue);
|
||||||
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);
|
|
||||||
}
|
|
||||||
return nvme_update_ns_info_block(ns, info);
|
|
||||||
case NVME_CSI_NVM:
|
|
||||||
return nvme_update_ns_info_block(ns, info);
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_BLK_SED_OPAL
|
#ifdef CONFIG_BLK_SED_OPAL
|
||||||
|
|
Loading…
Add table
Reference in a new issue