* misc nvme ioctl cleanups
@ 2021-05-20 5:44 Christoph Hellwig
2021-05-20 5:44 ` [PATCH 1/7] nvme: open code nvme_put_ns_from_disk in nvme_ns_head_chr_ioctl Christoph Hellwig
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-05-20 5:44 UTC (permalink / raw)
To: Keith Busch, Sagi Grimberg; +Cc: Minwoo Im, linux-nvme
Hi all,
this series untangles some of our ioctl code a little more.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/7] nvme: open code nvme_put_ns_from_disk in nvme_ns_head_chr_ioctl
2021-05-20 5:44 misc nvme ioctl cleanups Christoph Hellwig
@ 2021-05-20 5:44 ` Christoph Hellwig
2021-05-20 5:44 ` [PATCH 2/7] nvne: open code nvme_{get, put}_ns_from_disk in nvme_ns_head_ioctl Christoph Hellwig
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-05-20 5:44 UTC (permalink / raw)
To: Keith Busch, Sagi Grimberg; +Cc: Minwoo Im, linux-nvme
nvme_ns_head_chr_ioctl is always used on multipath nodes, so just call
srcu_read_unlock and consolidate the two unlock paths.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/ioctl.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 9557ead02de1..0341767ff2e7 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -419,21 +419,19 @@ long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,
container_of(cdev, struct nvme_ns_head, cdev);
void __user *argp = (void __user *)arg;
struct nvme_ns *ns;
- int srcu_idx, ret;
+ int srcu_idx, ret = -EWOULDBLOCK;
srcu_idx = srcu_read_lock(&head->srcu);
ns = nvme_find_path(head);
- if (!ns) {
- srcu_read_unlock(&head->srcu, srcu_idx);
- return -EWOULDBLOCK;
- }
+ if (!ns)
+ goto out_unlock;
if (is_ctrl_ioctl(cmd))
return nvme_ns_head_ctrl_ioctl(ns, cmd, argp, head, srcu_idx);
ret = nvme_ns_ioctl(ns, cmd, argp);
- nvme_put_ns_from_disk(head, srcu_idx);
-
+out_unlock:
+ srcu_read_unlock(&head->srcu, srcu_idx);
return ret;
}
#endif /* CONFIG_NVME_MULTIPATH */
--
2.30.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/7] nvne: open code nvme_{get, put}_ns_from_disk in nvme_ns_head_ioctl
2021-05-20 5:44 misc nvme ioctl cleanups Christoph Hellwig
2021-05-20 5:44 ` [PATCH 1/7] nvme: open code nvme_put_ns_from_disk in nvme_ns_head_chr_ioctl Christoph Hellwig
@ 2021-05-20 5:44 ` Christoph Hellwig
2021-05-20 5:44 ` [PATCH 3/7] nvme: open code nvme_put_ns_from_disk in nvme_ns_head_ctrl_ioctl Christoph Hellwig
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-05-20 5:44 UTC (permalink / raw)
To: Keith Busch, Sagi Grimberg; +Cc: Minwoo Im, linux-nvme
nvme_ns_head_ioctl is always used on multipath nodes, no need to
deal with the de-multiplexers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/ioctl.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 0341767ff2e7..3f84bd3b9259 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -387,14 +387,15 @@ static int nvme_ns_head_ctrl_ioctl(struct nvme_ns *ns, unsigned int cmd,
int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
- struct nvme_ns_head *head = NULL;
+ struct nvme_ns_head *head = bdev->bd_disk->private_data;
void __user *argp = (void __user *)arg;
struct nvme_ns *ns;
- int srcu_idx, ret;
+ int srcu_idx, ret = -EWOULDBLOCK;
- ns = nvme_get_ns_from_disk(bdev->bd_disk, &head, &srcu_idx);
- if (unlikely(!ns))
- return -EWOULDBLOCK;
+ srcu_idx = srcu_read_lock(&head->srcu);
+ ns = nvme_find_path(head);
+ if (!ns)
+ goto out_unlock;
/*
* Handle ioctls that apply to the controller instead of the namespace
@@ -402,12 +403,11 @@ int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode,
* deadlock when deleting namespaces using the passthrough interface.
*/
if (is_ctrl_ioctl(cmd))
- ret = nvme_ns_head_ctrl_ioctl(ns, cmd, argp, head, srcu_idx);
- else {
- ret = nvme_ns_ioctl(ns, cmd, argp);
- nvme_put_ns_from_disk(head, srcu_idx);
- }
+ return nvme_ns_head_ctrl_ioctl(ns, cmd, argp, head, srcu_idx);
+ ret = nvme_ns_ioctl(ns, cmd, argp);
+out_unlock:
+ srcu_read_unlock(&head->srcu, srcu_idx);
return ret;
}
--
2.30.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/7] nvme: open code nvme_put_ns_from_disk in nvme_ns_head_ctrl_ioctl
2021-05-20 5:44 misc nvme ioctl cleanups Christoph Hellwig
2021-05-20 5:44 ` [PATCH 1/7] nvme: open code nvme_put_ns_from_disk in nvme_ns_head_chr_ioctl Christoph Hellwig
2021-05-20 5:44 ` [PATCH 2/7] nvne: open code nvme_{get, put}_ns_from_disk in nvme_ns_head_ioctl Christoph Hellwig
@ 2021-05-20 5:44 ` Christoph Hellwig
2021-05-20 5:44 ` [PATCH 4/7] nvme: add a sparse annotation to nvme_ns_head_ctrl_ioctl Christoph Hellwig
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-05-20 5:44 UTC (permalink / raw)
To: Keith Busch, Sagi Grimberg; +Cc: Minwoo Im, linux-nvme
nvme_ns_head_ctrl_ioctl is always used on multipath nodes, so just call
srcu_read_unlock directly.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/ioctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 3f84bd3b9259..2c6969ffe85c 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -377,7 +377,7 @@ static int nvme_ns_head_ctrl_ioctl(struct nvme_ns *ns, unsigned int cmd,
int ret;
nvme_get_ctrl(ns->ctrl);
- nvme_put_ns_from_disk(head, srcu_idx);
+ srcu_read_unlock(&head->srcu, srcu_idx);
ret = nvme_ctrl_ioctl(ns->ctrl, cmd, argp);
nvme_put_ctrl(ctrl);
--
2.30.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/7] nvme: add a sparse annotation to nvme_ns_head_ctrl_ioctl
2021-05-20 5:44 misc nvme ioctl cleanups Christoph Hellwig
` (2 preceding siblings ...)
2021-05-20 5:44 ` [PATCH 3/7] nvme: open code nvme_put_ns_from_disk in nvme_ns_head_ctrl_ioctl Christoph Hellwig
@ 2021-05-20 5:44 ` Christoph Hellwig
2021-05-20 5:44 ` [PATCH 5/7] nvme: move the CSI sanity check into nvme_ns_report_zones Christoph Hellwig
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-05-20 5:44 UTC (permalink / raw)
To: Keith Busch, Sagi Grimberg; +Cc: Minwoo Im, linux-nvme
Add the __releases annotation to tell sparse that nvme_ns_head_ctrl_ioctl
is expected to unlock head->srcu.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/ioctl.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 2c6969ffe85c..2e7780ea0354 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -372,6 +372,7 @@ long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
#ifdef CONFIG_NVME_MULTIPATH
static int nvme_ns_head_ctrl_ioctl(struct nvme_ns *ns, unsigned int cmd,
void __user *argp, struct nvme_ns_head *head, int srcu_idx)
+ __releases(&head->srcu)
{
struct nvme_ctrl *ctrl = ns->ctrl;
int ret;
--
2.30.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/7] nvme: move the CSI sanity check into nvme_ns_report_zones
2021-05-20 5:44 misc nvme ioctl cleanups Christoph Hellwig
` (3 preceding siblings ...)
2021-05-20 5:44 ` [PATCH 4/7] nvme: add a sparse annotation to nvme_ns_head_ctrl_ioctl Christoph Hellwig
@ 2021-05-20 5:44 ` Christoph Hellwig
2021-05-20 5:44 ` [PATCH 6/7] nvme: split nvme_report_zones Christoph Hellwig
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-05-20 5:44 UTC (permalink / raw)
To: Keith Busch, Sagi Grimberg; +Cc: Minwoo Im, linux-nvme
Move the CSI check into nvme_ns_report_zones to clean up the code
a little bit and prepare for further refactoring.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/zns.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 475dd45c3db4..31e789ecd940 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -180,6 +180,9 @@ static int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
unsigned int nz, i;
size_t buflen;
+ if (ns->head->ids.csi != NVME_CSI_ZNS)
+ return -EINVAL;
+
report = nvme_zns_alloc_report_buffer(ns, nr_zones, &buflen);
if (!report)
return -ENOMEM;
@@ -237,11 +240,7 @@ int nvme_report_zones(struct gendisk *disk, sector_t sector,
ns = nvme_get_ns_from_disk(disk, &head, &srcu_idx);
if (unlikely(!ns))
return -EWOULDBLOCK;
-
- if (ns->head->ids.csi == NVME_CSI_ZNS)
- ret = nvme_ns_report_zones(ns, sector, nr_zones, cb, data);
- else
- ret = -EINVAL;
+ ret = nvme_ns_report_zones(ns, sector, nr_zones, cb, data);
nvme_put_ns_from_disk(head, srcu_idx);
return ret;
--
2.30.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/7] nvme: split nvme_report_zones
2021-05-20 5:44 misc nvme ioctl cleanups Christoph Hellwig
` (4 preceding siblings ...)
2021-05-20 5:44 ` [PATCH 5/7] nvme: move the CSI sanity check into nvme_ns_report_zones Christoph Hellwig
@ 2021-05-20 5:44 ` Christoph Hellwig
2021-05-20 5:44 ` [PATCH 7/7] nvme: remove nvme_{get,put}_ns_from_disk Christoph Hellwig
2021-05-20 15:38 ` misc nvme ioctl cleanups Keith Busch
7 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-05-20 5:44 UTC (permalink / raw)
To: Keith Busch, Sagi Grimberg; +Cc: Minwoo Im, linux-nvme
Split multipath support out of nvme_report_zones into a separate helper
and simplify the non-multipath version as a result.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/core.c | 11 +++++++++++
drivers/nvme/host/multipath.c | 21 ++++++++++++++++++++-
drivers/nvme/host/nvme.h | 7 ++-----
drivers/nvme/host/zns.c | 20 ++------------------
4 files changed, 35 insertions(+), 24 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e7441ccaa8db..309b7b3635f0 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2073,6 +2073,17 @@ int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,
EXPORT_SYMBOL_GPL(nvme_sec_submit);
#endif /* CONFIG_BLK_SED_OPAL */
+#ifdef CONFIG_BLK_DEV_ZONED
+static int nvme_report_zones(struct gendisk *disk, sector_t sector,
+ unsigned int nr_zones, report_zones_cb cb, void *data)
+{
+ return nvme_ns_report_zones(disk->private_data, sector, nr_zones, cb,
+ data);
+}
+#else
+#define nvme_report_zones NULL
+#endif /* CONFIG_BLK_DEV_ZONED */
+
static const struct block_device_operations nvme_bdev_ops = {
.owner = THIS_MODULE,
.ioctl = nvme_ioctl,
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index f81871c7128a..127a17b4c13d 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -349,6 +349,25 @@ static void nvme_ns_head_release(struct gendisk *disk, fmode_t mode)
nvme_put_ns_head(disk->private_data);
}
+#ifdef CONFIG_BLK_DEV_ZONED
+static int nvme_ns_head_report_zones(struct gendisk *disk, sector_t sector,
+ unsigned int nr_zones, report_zones_cb cb, void *data)
+{
+ struct nvme_ns_head *head = disk->private_data;
+ struct nvme_ns *ns;
+ int srcu_idx, ret = -EWOULDBLOCK;
+
+ srcu_idx = srcu_read_lock(&head->srcu);
+ ns = nvme_find_path(head);
+ if (ns)
+ ret = nvme_ns_report_zones(ns, sector, nr_zones, cb, data);
+ srcu_read_unlock(&head->srcu, srcu_idx);
+ return ret;
+}
+#else
+#define nvme_ns_head_report_zones NULL
+#endif /* CONFIG_BLK_DEV_ZONED */
+
const struct block_device_operations nvme_ns_head_ops = {
.owner = THIS_MODULE,
.submit_bio = nvme_ns_head_submit_bio,
@@ -356,7 +375,7 @@ const struct block_device_operations nvme_ns_head_ops = {
.release = nvme_ns_head_release,
.ioctl = nvme_ns_head_ioctl,
.getgeo = nvme_getgeo,
- .report_zones = nvme_report_zones,
+ .report_zones = nvme_ns_head_report_zones,
.pr_ops = &nvme_pr_ops,
};
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 0015860ec12b..01f41b2bf915 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -810,17 +810,14 @@ static inline void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)
#endif /* CONFIG_NVME_MULTIPATH */
int nvme_revalidate_zones(struct nvme_ns *ns);
+int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
+ unsigned int nr_zones, report_zones_cb cb, void *data);
#ifdef CONFIG_BLK_DEV_ZONED
int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf);
-int nvme_report_zones(struct gendisk *disk, sector_t sector,
- unsigned int nr_zones, report_zones_cb cb, void *data);
-
blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns, struct request *req,
struct nvme_command *cmnd,
enum nvme_zone_mgmt_action action);
#else
-#define nvme_report_zones NULL
-
static inline blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns,
struct request *req, struct nvme_command *cmnd,
enum nvme_zone_mgmt_action action)
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 31e789ecd940..d95010481fce 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -171,8 +171,8 @@ static int nvme_zone_parse_entry(struct nvme_ns *ns,
return cb(&zone, idx, data);
}
-static int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
- unsigned int nr_zones, report_zones_cb cb, void *data)
+int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
+ unsigned int nr_zones, report_zones_cb cb, void *data)
{
struct nvme_zone_report *report;
struct nvme_command c = { };
@@ -230,22 +230,6 @@ static int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
return ret;
}
-int nvme_report_zones(struct gendisk *disk, sector_t sector,
- unsigned int nr_zones, report_zones_cb cb, void *data)
-{
- struct nvme_ns_head *head = NULL;
- struct nvme_ns *ns;
- int srcu_idx, ret;
-
- ns = nvme_get_ns_from_disk(disk, &head, &srcu_idx);
- if (unlikely(!ns))
- return -EWOULDBLOCK;
- ret = nvme_ns_report_zones(ns, sector, nr_zones, cb, data);
- nvme_put_ns_from_disk(head, srcu_idx);
-
- return ret;
-}
-
blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns, struct request *req,
struct nvme_command *c, enum nvme_zone_mgmt_action action)
{
--
2.30.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/7] nvme: remove nvme_{get,put}_ns_from_disk
2021-05-20 5:44 misc nvme ioctl cleanups Christoph Hellwig
` (5 preceding siblings ...)
2021-05-20 5:44 ` [PATCH 6/7] nvme: split nvme_report_zones Christoph Hellwig
@ 2021-05-20 5:44 ` Christoph Hellwig
2021-05-20 15:38 ` misc nvme ioctl cleanups Keith Busch
7 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2021-05-20 5:44 UTC (permalink / raw)
To: Keith Busch, Sagi Grimberg; +Cc: Minwoo Im, linux-nvme
Now that only one caller is left remove the helpers by restructuring
nvme_pr_command so that it has two helpers for sending a command of to a
given nsid using either the ns_head for multipath, or the namespace
stored in the gendisk.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/core.c | 68 ++++++++++++++++------------------------
drivers/nvme/host/nvme.h | 5 +--
2 files changed, 28 insertions(+), 45 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 309b7b3635f0..6c36bf426c3e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1542,36 +1542,6 @@ static void nvme_enable_aen(struct nvme_ctrl *ctrl)
queue_work(nvme_wq, &ctrl->async_event_work);
}
-/*
- * Issue ioctl requests on the first available path. Note that unlike normal
- * block layer requests we will not retry failed request on another controller.
- */
-struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk,
- struct nvme_ns_head **head, int *srcu_idx)
-{
-#ifdef CONFIG_NVME_MULTIPATH
- if (disk->fops == &nvme_ns_head_ops) {
- struct nvme_ns *ns;
-
- *head = disk->private_data;
- *srcu_idx = srcu_read_lock(&(*head)->srcu);
- ns = nvme_find_path(*head);
- if (!ns)
- srcu_read_unlock(&(*head)->srcu, *srcu_idx);
- return ns;
- }
-#endif
- *head = NULL;
- *srcu_idx = -1;
- return disk->private_data;
-}
-
-void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx)
-{
- if (head)
- srcu_read_unlock(&head->srcu, idx);
-}
-
static int nvme_ns_open(struct nvme_ns *ns)
{
@@ -1968,30 +1938,46 @@ static char nvme_pr_type(enum pr_type type)
}
};
+static int nvme_send_ns_head_pr_command(struct block_device *bdev,
+ struct nvme_command *c, u8 data[16])
+{
+ struct nvme_ns_head *head = bdev->bd_disk->private_data;
+ int srcu_idx = srcu_read_lock(&head->srcu);
+ struct nvme_ns *ns = nvme_find_path(head);
+ int ret = -EWOULDBLOCK;
+
+ if (ns) {
+ c->common.nsid = cpu_to_le32(ns->head->ns_id);
+ ret = nvme_submit_sync_cmd(ns->queue, c, data, 16);
+ }
+ srcu_read_unlock(&head->srcu, srcu_idx);
+ return ret;
+}
+
+static int nvme_send_ns_pr_command(struct nvme_ns *ns, struct nvme_command *c,
+ u8 data[16])
+{
+ c->common.nsid = cpu_to_le32(ns->head->ns_id);
+ return nvme_submit_sync_cmd(ns->queue, c, data, 16);
+}
+
static int nvme_pr_command(struct block_device *bdev, u32 cdw10,
u64 key, u64 sa_key, u8 op)
{
- struct nvme_ns_head *head = NULL;
- struct nvme_ns *ns;
struct nvme_command c;
- int srcu_idx, ret;
u8 data[16] = { 0, };
- ns = nvme_get_ns_from_disk(bdev->bd_disk, &head, &srcu_idx);
- if (unlikely(!ns))
- return -EWOULDBLOCK;
-
put_unaligned_le64(key, &data[0]);
put_unaligned_le64(sa_key, &data[8]);
memset(&c, 0, sizeof(c));
c.common.opcode = op;
- c.common.nsid = cpu_to_le32(ns->head->ns_id);
c.common.cdw10 = cpu_to_le32(cdw10);
- ret = nvme_submit_sync_cmd(ns->queue, &c, data, 16);
- nvme_put_ns_from_disk(head, srcu_idx);
- return ret;
+ if (IS_ENABLED(CONFIG_NVME_MULTIPATH) &&
+ bdev->bd_disk->fops == &nvme_ns_head_ops)
+ return nvme_send_ns_head_pr_command(bdev, &c, data);
+ return nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c, data);
}
static int nvme_pr_register(struct block_device *bdev, u64 old,
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 01f41b2bf915..1f397ecba16c 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -674,9 +674,6 @@ int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
void nvme_queue_scan(struct nvme_ctrl *ctrl);
int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
void *log, size_t size, u64 offset);
-struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk,
- struct nvme_ns_head **head, int *srcu_idx);
-void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx);
bool nvme_tryget_ns_head(struct nvme_ns_head *head);
void nvme_put_ns_head(struct nvme_ns_head *head);
int nvme_cdev_add(struct cdev *cdev, struct device *cdev_device,
@@ -697,6 +694,7 @@ extern const struct attribute_group *nvme_ns_id_attr_groups[];
extern const struct pr_ops nvme_pr_ops;
extern const struct block_device_operations nvme_ns_head_ops;
+struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
#ifdef CONFIG_NVME_MULTIPATH
static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
{
@@ -718,7 +716,6 @@ void nvme_mpath_uninit(struct nvme_ctrl *ctrl);
void nvme_mpath_stop(struct nvme_ctrl *ctrl);
bool nvme_mpath_clear_current_path(struct nvme_ns *ns);
void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl);
-struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
{
--
2.30.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: misc nvme ioctl cleanups
2021-05-20 5:44 misc nvme ioctl cleanups Christoph Hellwig
` (6 preceding siblings ...)
2021-05-20 5:44 ` [PATCH 7/7] nvme: remove nvme_{get,put}_ns_from_disk Christoph Hellwig
@ 2021-05-20 15:38 ` Keith Busch
2021-05-20 22:36 ` Sagi Grimberg
7 siblings, 1 reply; 10+ messages in thread
From: Keith Busch @ 2021-05-20 15:38 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Sagi Grimberg, Minwoo Im, linux-nvme
These all look good to me.
Reviewed-by: Keith Busch <kbusch@kernel.org>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: misc nvme ioctl cleanups
2021-05-20 15:38 ` misc nvme ioctl cleanups Keith Busch
@ 2021-05-20 22:36 ` Sagi Grimberg
0 siblings, 0 replies; 10+ messages in thread
From: Sagi Grimberg @ 2021-05-20 22:36 UTC (permalink / raw)
To: Keith Busch, Christoph Hellwig; +Cc: Minwoo Im, linux-nvme
Me too,
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-05-20 22:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-20 5:44 misc nvme ioctl cleanups Christoph Hellwig
2021-05-20 5:44 ` [PATCH 1/7] nvme: open code nvme_put_ns_from_disk in nvme_ns_head_chr_ioctl Christoph Hellwig
2021-05-20 5:44 ` [PATCH 2/7] nvne: open code nvme_{get, put}_ns_from_disk in nvme_ns_head_ioctl Christoph Hellwig
2021-05-20 5:44 ` [PATCH 3/7] nvme: open code nvme_put_ns_from_disk in nvme_ns_head_ctrl_ioctl Christoph Hellwig
2021-05-20 5:44 ` [PATCH 4/7] nvme: add a sparse annotation to nvme_ns_head_ctrl_ioctl Christoph Hellwig
2021-05-20 5:44 ` [PATCH 5/7] nvme: move the CSI sanity check into nvme_ns_report_zones Christoph Hellwig
2021-05-20 5:44 ` [PATCH 6/7] nvme: split nvme_report_zones Christoph Hellwig
2021-05-20 5:44 ` [PATCH 7/7] nvme: remove nvme_{get,put}_ns_from_disk Christoph Hellwig
2021-05-20 15:38 ` misc nvme ioctl cleanups Keith Busch
2021-05-20 22:36 ` Sagi Grimberg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.