nvme: cleanup setting the disk name
Return false from nvme_set_disk_name and let the caller set the non-multipath name instead of duplicating the naming information in two places. Also remove the pointless local variables for the disk name and flags and the not needed ctrl argument. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Javier González <javier.gonz@samsung.com>
This commit is contained in:
parent
3089738868
commit
9953ab0c5a
@ -3998,8 +3998,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
|
|||||||
struct nvme_ns *ns;
|
struct nvme_ns *ns;
|
||||||
struct gendisk *disk;
|
struct gendisk *disk;
|
||||||
struct nvme_id_ns *id;
|
struct nvme_id_ns *id;
|
||||||
char disk_name[DISK_NAME_LEN];
|
int node = ctrl->numa_node;
|
||||||
int node = ctrl->numa_node, flags = GENHD_FL_EXT_DEVT;
|
|
||||||
|
|
||||||
if (nvme_identify_ns(ctrl, nsid, ids, &id))
|
if (nvme_identify_ns(ctrl, nsid, ids, &id))
|
||||||
return;
|
return;
|
||||||
@ -4025,7 +4024,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
|
|||||||
|
|
||||||
if (nvme_init_ns_head(ns, nsid, ids, id->nmic & NVME_NS_NMIC_SHARED))
|
if (nvme_init_ns_head(ns, nsid, ids, id->nmic & NVME_NS_NMIC_SHARED))
|
||||||
goto out_free_queue;
|
goto out_free_queue;
|
||||||
nvme_set_disk_name(disk_name, ns, ctrl, &flags);
|
|
||||||
|
|
||||||
disk = alloc_disk_node(0, node);
|
disk = alloc_disk_node(0, node);
|
||||||
if (!disk)
|
if (!disk)
|
||||||
@ -4034,15 +4032,22 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
|
|||||||
disk->fops = &nvme_bdev_ops;
|
disk->fops = &nvme_bdev_ops;
|
||||||
disk->private_data = ns;
|
disk->private_data = ns;
|
||||||
disk->queue = ns->queue;
|
disk->queue = ns->queue;
|
||||||
disk->flags = flags;
|
disk->flags = GENHD_FL_EXT_DEVT;
|
||||||
memcpy(disk->disk_name, disk_name, DISK_NAME_LEN);
|
/*
|
||||||
|
* Without the multipath code enabled, multiple controller per
|
||||||
|
* subsystems are visible as devices and thus we cannot use the
|
||||||
|
* subsystem instance.
|
||||||
|
*/
|
||||||
|
if (!nvme_mpath_set_disk_name(ns, disk->disk_name, &disk->flags))
|
||||||
|
sprintf(disk->disk_name, "nvme%dn%d", ctrl->instance,
|
||||||
|
ns->head->instance);
|
||||||
ns->disk = disk;
|
ns->disk = disk;
|
||||||
|
|
||||||
if (nvme_update_ns_info(ns, id))
|
if (nvme_update_ns_info(ns, id))
|
||||||
goto out_put_disk;
|
goto out_put_disk;
|
||||||
|
|
||||||
if ((ctrl->quirks & NVME_QUIRK_LIGHTNVM) && id->vs[0] == 0x1) {
|
if ((ctrl->quirks & NVME_QUIRK_LIGHTNVM) && id->vs[0] == 0x1) {
|
||||||
if (nvme_nvm_register(ns, disk_name, node)) {
|
if (nvme_nvm_register(ns, disk->disk_name, node)) {
|
||||||
dev_warn(ctrl->device, "LightNVM init failure\n");
|
dev_warn(ctrl->device, "LightNVM init failure\n");
|
||||||
goto out_put_disk;
|
goto out_put_disk;
|
||||||
}
|
}
|
||||||
|
@ -50,19 +50,19 @@ void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)
|
|||||||
* and those that have a single controller and use the controller node
|
* and those that have a single controller and use the controller node
|
||||||
* directly.
|
* directly.
|
||||||
*/
|
*/
|
||||||
void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
|
bool nvme_mpath_set_disk_name(struct nvme_ns *ns, char *disk_name, int *flags)
|
||||||
struct nvme_ctrl *ctrl, int *flags)
|
|
||||||
{
|
{
|
||||||
if (!multipath) {
|
if (!multipath)
|
||||||
sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance);
|
return false;
|
||||||
} else if (ns->head->disk) {
|
if (!ns->head->disk) {
|
||||||
sprintf(disk_name, "nvme%dc%dn%d", ctrl->subsys->instance,
|
sprintf(disk_name, "nvme%dn%d", ns->ctrl->subsys->instance,
|
||||||
ctrl->instance, ns->head->instance);
|
ns->head->instance);
|
||||||
*flags = GENHD_FL_HIDDEN;
|
return true;
|
||||||
} else {
|
|
||||||
sprintf(disk_name, "nvme%dn%d", ctrl->subsys->instance,
|
|
||||||
ns->head->instance);
|
|
||||||
}
|
}
|
||||||
|
sprintf(disk_name, "nvme%dc%dn%d", ns->ctrl->subsys->instance,
|
||||||
|
ns->ctrl->instance, ns->head->instance);
|
||||||
|
*flags = GENHD_FL_HIDDEN;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nvme_failover_req(struct request *req)
|
void nvme_failover_req(struct request *req)
|
||||||
|
@ -668,8 +668,7 @@ static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
|
|||||||
void nvme_mpath_unfreeze(struct nvme_subsystem *subsys);
|
void nvme_mpath_unfreeze(struct nvme_subsystem *subsys);
|
||||||
void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys);
|
void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys);
|
||||||
void nvme_mpath_start_freeze(struct nvme_subsystem *subsys);
|
void nvme_mpath_start_freeze(struct nvme_subsystem *subsys);
|
||||||
void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
|
bool nvme_mpath_set_disk_name(struct nvme_ns *ns, char *disk_name, int *flags);
|
||||||
struct nvme_ctrl *ctrl, int *flags);
|
|
||||||
void nvme_failover_req(struct request *req);
|
void nvme_failover_req(struct request *req);
|
||||||
void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
|
void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
|
||||||
int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
|
int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
|
||||||
@ -708,16 +707,11 @@ static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*
|
static inline bool nvme_mpath_set_disk_name(struct nvme_ns *ns, char *disk_name,
|
||||||
* Without the multipath code enabled, multiple controller per subsystems are
|
int *flags)
|
||||||
* visible as devices and thus we cannot use the subsystem instance.
|
|
||||||
*/
|
|
||||||
static inline void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
|
|
||||||
struct nvme_ctrl *ctrl, int *flags)
|
|
||||||
{
|
{
|
||||||
sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void nvme_failover_req(struct request *req)
|
static inline void nvme_failover_req(struct request *req)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user