From: Christoph Hellwig <hch@lst.de>
To: Minwoo Im <minwoo.im.dev@gmail.com>,
Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>
Cc: Kanchan Joshi <joshiiitr@gmail.com>,
Javier Gonz??lez <javier.gonz@samsung.com>,
linux-nvme@lists.infradead.org
Subject: [PATCH 02/13] nvme: cleanup setting the disk name
Date: Thu, 8 Apr 2021 14:08:31 +0200 [thread overview]
Message-ID: <20210408120842.1450092-3-hch@lst.de> (raw)
In-Reply-To: <20210408120842.1450092-1-hch@lst.de>
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>
---
drivers/nvme/host/core.c | 17 +++++++++++------
drivers/nvme/host/multipath.c | 24 ++++++++++++------------
drivers/nvme/host/nvme.h | 14 ++++----------
3 files changed, 27 insertions(+), 28 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 4d13bca83cfefa..8c60ddc47b546d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3998,8 +3998,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
struct nvme_ns *ns;
struct gendisk *disk;
struct nvme_id_ns *id;
- char disk_name[DISK_NAME_LEN];
- int node = ctrl->numa_node, flags = GENHD_FL_EXT_DEVT;
+ int node = ctrl->numa_node;
if (nvme_identify_ns(ctrl, nsid, ids, &id))
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))
goto out_free_queue;
- nvme_set_disk_name(disk_name, ns, ctrl, &flags);
disk = alloc_disk_node(0, node);
if (!disk)
@@ -4034,15 +4032,22 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
disk->fops = &nvme_bdev_ops;
disk->private_data = ns;
disk->queue = ns->queue;
- disk->flags = flags;
- memcpy(disk->disk_name, disk_name, DISK_NAME_LEN);
+ disk->flags = GENHD_FL_EXT_DEVT;
+ /*
+ * 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;
if (nvme_update_ns_info(ns, id))
goto out_put_disk;
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");
goto out_put_disk;
}
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index f2d0ce0f4d3811..0f42b7e94ce3f3 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -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
* directly.
*/
-void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
- struct nvme_ctrl *ctrl, int *flags)
-{
- if (!multipath) {
- sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance);
- } else if (ns->head->disk) {
- sprintf(disk_name, "nvme%dc%dn%d", ctrl->subsys->instance,
- ctrl->instance, ns->head->instance);
- *flags = GENHD_FL_HIDDEN;
- } else {
- sprintf(disk_name, "nvme%dn%d", ctrl->subsys->instance,
- ns->head->instance);
+bool nvme_mpath_set_disk_name(struct nvme_ns *ns, char *disk_name, int *flags)
+{
+ if (!multipath)
+ return false;
+ if (!ns->head->disk) {
+ sprintf(disk_name, "nvme%dn%d", ns->ctrl->subsys->instance,
+ ns->head->instance);
+ return true;
}
+ 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)
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 67ff5d41e7d03b..2ef0a355fbb4ae 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -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_wait_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,
- struct nvme_ctrl *ctrl, int *flags);
+bool nvme_mpath_set_disk_name(struct nvme_ns *ns, char *disk_name, int *flags);
void nvme_failover_req(struct request *req);
void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
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;
}
-/*
- * Without the multipath code enabled, multiple controller per subsystems are
- * 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)
+static inline bool nvme_mpath_set_disk_name(struct nvme_ns *ns, char *disk_name,
+ int *flags)
{
- sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance);
+ return false;
}
-
static inline void nvme_failover_req(struct request *req)
{
}
--
2.30.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2021-04-08 12:15 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20210408121108eucas1p1fb60de8498a7461b453295497c206246@eucas1p1.samsung.com>
2021-04-08 12:08 ` nvme ioctl refactor and generic per-namespace char device Christoph Hellwig
2021-04-08 12:08 ` [PATCH 01/13] nvme: add a nvme_ns_head_multipath helper Christoph Hellwig
2021-04-09 2:33 ` Chaitanya Kulkarni
2021-04-08 12:08 ` Christoph Hellwig [this message]
2021-04-08 12:08 ` [PATCH 03/13] nvme: pass a user pointer to nvme_nvm_ioctl Christoph Hellwig
2021-04-08 12:08 ` [PATCH 04/13] nvme: factor out a nvme_ns_ioctl helper Christoph Hellwig
2021-04-09 2:40 ` Chaitanya Kulkarni
2021-04-08 12:08 ` [PATCH 05/13] nvme: simplify the compat ioctl handling Christoph Hellwig
2021-04-09 2:42 ` Chaitanya Kulkarni
2021-04-09 5:39 ` Christoph Hellwig
2021-04-08 12:08 ` [PATCH 06/13] nvme: simplify block device ioctl handling for the !multipath case Christoph Hellwig
2021-04-08 12:08 ` [PATCH 07/13] nvme: don't bother to look up a namespace for controller ioctls Christoph Hellwig
2021-04-08 12:08 ` [PATCH 08/13] nvme: move the ioctl code to a separate file Christoph Hellwig
2021-04-09 2:45 ` Chaitanya Kulkarni
2021-04-08 12:08 ` [PATCH 09/13] nvme: factor out a nvme_tryget_ns_head helper Christoph Hellwig
2021-04-09 2:46 ` Chaitanya Kulkarni
2021-04-09 5:39 ` Christoph Hellwig
2021-04-09 5:40 ` Chaitanya Kulkarni
2021-04-09 9:18 ` Kanchan Joshi
2021-04-09 9:49 ` Christoph Hellwig
2021-04-08 12:08 ` [PATCH 10/13] nvme: move nvme_ns_head_ops to multipath.c Christoph Hellwig
2021-04-09 2:47 ` Chaitanya Kulkarni
2021-04-08 12:08 ` [PATCH 11/13] nvme: factor out nvme_ns_open and nvme_ns_release helpers Christoph Hellwig
2021-04-09 2:48 ` Chaitanya Kulkarni
2021-04-08 12:08 ` [PATCH 12/13] nvme: let namespace probing continue for unsupported features Christoph Hellwig
2021-04-08 22:42 ` Keith Busch
2021-04-09 5:39 ` Christoph Hellwig
2021-04-09 5:47 ` Keith Busch
2021-04-09 5:53 ` Christoph Hellwig
2021-04-08 12:08 ` [PATCH 13/13] nvme: introduce generic per-namespace chardev Christoph Hellwig
2021-04-08 16:56 ` Keith Busch
2021-04-08 17:00 ` Christoph Hellwig
2021-04-09 6:14 ` Christoph Hellwig
2021-04-09 14:29 ` Keith Busch
2021-04-09 14:35 ` Christoph Hellwig
2021-04-09 7:29 ` Minwoo Im
2021-04-09 7:54 ` Christoph Hellwig
2021-04-09 8:02 ` Minwoo Im
2021-04-09 9:52 ` Christoph Hellwig
2021-04-09 11:24 ` Minwoo Im
2021-04-12 7:44 ` Christoph Hellwig
2021-04-12 11:52 ` Javier Gonz??lez
2021-04-08 22:43 ` nvme ioctl refactor and generic per-namespace char device Keith Busch
2021-04-09 17:45 ` Javier Gonz??lez
2021-04-10 6:46 ` Christoph Hellwig
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=20210408120842.1450092-3-hch@lst.de \
--to=hch@lst.de \
--cc=javier.gonz@samsung.com \
--cc=joshiiitr@gmail.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=minwoo.im.dev@gmail.com \
--cc=sagi@grimberg.me \
/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