nvme: add namespace paths links
PATCH 1/1 nvme: add namespace paths links
It is really annoying to always have to loop through the entire /sys/block directory just to find the namespace path links for a single namespace in libnvme/nvme-cli.
So provide links to the namespace paths for efficient lookup.
--- drivers/nvme/host/core.c | 3 +++ drivers/nvme/host/multipath.c | 10 ++++++++++ 2 files changed, 13 insertions(+)
drivers/nvme/host/core.c +3 -0
@@ -3681,6 +3681,9 @@ static void nvme_ns_remove(struct nvme_ns *ns)if (!nvme_ns_head_multipath (ns->head))nvme_cdev_del (&ns->cdev, &ns->cdev_device); +else +sysfs_remove_link (&disk_to_dev (ns->head->disk)->kobj, + ns->disk->disk_name);del_gendisk (ns->disk);down_write (&ns->ctrl->namespaces_rwsem);
drivers/nvme/host/multipath.c +10 -0
@@ -875,6 +875,16 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid)if (blk_queue_is_zoned (ns->queue) && ns->head->disk) ns->head->disk->nr_zones = ns->disk->nr_zones;#endif +if (ns->head->disk) { +int ret; + + ret =sysfs_create_link (&disk_to_dev (ns->head->disk)->kobj, + &disk_to_dev (ns->disk)->kobj, + ns->disk->disk_name); +if (ret) +dev_warn (ns->ctrl->device, +"failed to create namespace path link\n" ); + } }void nvme_mpath_shutdown_disk (struct nvme_ns_head *head)
Signature · 1 line
2.35.3
Sagi Grimberg
maintainerQuoted 31 lines
It is really annoying to always have to loop through the entire
/sys/blockdirectory just to find the namespace path links for a single namespace in libnvme/nvme-cli.
So provide links to the namespace paths for efficient lookup.Signed-off-by Hannes Reinecke <[email protected]>--- drivers/nvme/host/core.c | 3 +++ drivers/nvme/host/multipath.c | 10 ++++++++++ 2 files changed, 13 insertions(+)drivers/nvme/host/core.c +3
-0@@ -3681,6 +3681,9 @@ static void nvme_ns_remove(struct nvme_ns *ns)if (!nvme_ns_head_multipath (ns->head))nvme_cdev_del (&ns->cdev, &ns->cdev_device); +else +sysfs_remove_link (&disk_to_dev (ns->head->disk)->kobj, + ns->disk->disk_name);del_gendisk (ns->disk);down_write (&ns->ctrl->namespaces_rwsem);drivers/nvme/host/multipath.c +0
-0
drivers/nvme/host/multipath.c void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid) · line 878
Quoted 4 lines
drivers/nvme/host/multipath.c +1
-0@@ -875,6 +875,16 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid)if (blk_queue_is_zoned (ns->queue) && ns->head->disk) ns->head->disk->nr_zones = ns->disk->nr_zones;#endif +if (ns->head->disk) {
Why are the two conditions not identical?
drivers/nvme/host/multipath.c void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid) · line 890
Quoted 12 lines
drivers/nvme/host/multipath.c +9
-0+int ret; + + ret =sysfs_create_link (&disk_to_dev (ns->head->disk)->kobj, + &disk_to_dev (ns->disk)->kobj, + ns->disk->disk_name); +if (ret) +dev_warn (ns->ctrl->device, +"failed to create namespace path link\n" ); + } }void nvme_mpath_shutdown_disk (struct nvme_ns_head *head)
What will these links be used for?
Quoted 28 lines · Sagi Grimberg
Quoted 28 lines
It is really annoying to always have to loop through the entire
/sys/blockdirectory just to find the namespace path links for a single namespace in libnvme/nvme-cli.
So provide links to the namespace paths for efficient lookup.Signed-off-by Hannes Reinecke <[email protected]>---
drivers/nvme/host/core.c | 3 +++
drivers/nvme/host/multipath.c| 10 ++++++++++2 files changed, 13 insertions(+)drivers/nvme/host/core.c +3
-0@@ -3681,6 +3681,9 @@ static void nvme_ns_remove(struct nvme_ns *ns) if (!nvme_ns_head_multipath(ns->head)) nvme_cdev_del(&ns->cdev, &ns->cdev_device); + else + sysfs_remove_link(&disk_to_dev(ns->head->disk)->kobj, + ns->disk->disk_name); del_gendisk(ns->disk); down_write(&ns->ctrl->namespaces_rwsem);drivers/nvme/host/multipath.c +0
-0
Quoted 9 lines
drivers/nvme/host/multipath.c void nvme_mpath_add_disk(struct nvme_ns *ns, · line 879
Quoted 6 lines
drivers/nvme/host/multipath.c +1
-0@@ -875,6 +875,16 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid) if (blk_queue_is_zoned(ns->queue) && ns->head->disk) ns->head->disk->nr_zones = ns->disk->nr_zones; #endif + if (ns->head->disk) {Why are the two conditions not identical?
Which two?
Quoted 12 lines
drivers/nvme/host/multipath.c void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid) · line 890
Quoted 11 lines
drivers/nvme/host/multipath.c +9
-0+ int ret; + + ret = sysfs_create_link(&disk_to_dev(ns->head->disk)->kobj, + &disk_to_dev(ns->disk)->kobj, + ns->disk->disk_name); + if (ret) + dev_warn(ns->ctrl->device, + "failed to create namespace path link\n"); + } } void nvme_mpath_shutdown_disk(struct nvme_ns_head *head)
Quoted 1 line
What will these links be used for?
Mapping for nvme-cli, as explained in the description. Clearly it doesn't do it _now_, but once the patch is in we can simplify nvme-cli to take advantage of it.
Cheers,
Hannes
Sagi Grimberg
maintainerQuoted 37 lines
Quoted 28 lines
Quoted 28 lines
It is really annoying to always have to loop through the entire
/sys/blockdirectory just to find the namespace path links for a single namespace in libnvme/nvme-cli.
So provide links to the namespace paths for efficient lookup.Signed-off-by Hannes Reinecke <[email protected]>---
drivers/nvme/host/core.c | 3 +++
drivers/nvme/host/multipath.c| 10 ++++++++++2 files changed, 13 insertions(+)drivers/nvme/host/core.c +3
-0@@ -3681,6 +3681,9 @@ static void nvme_ns_remove(struct nvme_ns *ns) if (!nvme_ns_head_multipath(ns->head)) nvme_cdev_del(&ns->cdev, &ns->cdev_device); + else + sysfs_remove_link(&disk_to_dev(ns->head->disk)->kobj, + ns->disk->disk_name); del_gendisk(ns->disk); down_write(&ns->ctrl->namespaces_rwsem);drivers/nvme/host/multipath.c +0
-0Quoted 9 lines
drivers/nvme/host/multipath.c void nvme_mpath_add_disk(struct nvme_ns *ns, · line 879
Quoted 6 lines
drivers/nvme/host/multipath.c +1
-0@@ -875,6 +875,16 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid) if (blk_queue_is_zoned(ns->queue) && ns->head->disk) ns->head->disk->nr_zones = ns->disk->nr_zones; #endif + if (ns->head->disk) {Why are the two conditions not identical?
Quoted 1 line
Which two?
ns->head->disk and nvme_ns_head_multipath()
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/nvme/host/multipath.c +9
-0+ int ret; + + ret = sysfs_create_link(&disk_to_dev(ns->head->disk)->kobj, + &disk_to_dev(ns->disk)->kobj, + ns->disk->disk_name); + if (ret) + dev_warn(ns->ctrl->device, + "failed to create namespace path link\n"); + } } void nvme_mpath_shutdown_disk(struct nvme_ns_head *head)
Quoted 5 lines
Quoted 1 line
What will these links be used for?
Mapping for nvme-cli, as explained in the description. Clearly it doesn't do it _now_, but once the patch is in we can simplify nvme-cli to take advantage of it.
you mean for nvme list -v ?
Don't really mind having it, but would want to hear from others as well.
Quoted 37 lines · Sagi Grimberg
Quoted 37 lines
Quoted 37 lines
Quoted 29 lines
It is really annoying to always have to loop through the entire
/sys/blockdirectory just to find the namespace path links for a single namespace in libnvme/nvme-cli.
So provide links to the namespace paths for efficient lookup.Signed-off-by Hannes Reinecke <[email protected]>---
drivers/nvme/host/core.c | 3 +++
drivers/nvme/host/multipath.c| 10 ++++++++++2 files changed, 13 insertions(+)drivers/nvme/host/core.c +3
-0@@ -3681,6 +3681,9 @@ static void nvme_ns_remove(struct nvme_ns *ns) if (!nvme_ns_head_multipath(ns->head)) nvme_cdev_del(&ns->cdev, &ns->cdev_device); + else + sysfs_remove_link(&disk_to_dev(ns->head->disk)->kobj, + ns->disk->disk_name); del_gendisk(ns->disk); down_write(&ns->ctrl->namespaces_rwsem);drivers/nvme/host/multipath.c +0
-0drivers/nvme/host/multipath.c void nvme_mpath_add_disk(struct nvme_ns *ns, · line 879
Quoted 5 lines
drivers/nvme/host/multipath.c +1
-0@@ -875,6 +875,16 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid) if (blk_queue_is_zoned(ns->queue) && ns->head->disk) ns->head->disk->nr_zones = ns->disk->nr_zones; #endif + if (ns->head->disk) {Why are the two conditions not identical?
Quoted 4 lines
Quoted 1 line
Which two?
ns->head->diskandnvme_ns_head_multipath()
How can we have one without the other? I thought that both are mutually dependent .. but yeah, we should be using 'nvme_ns_head_multipath()' here.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
drivers/nvme/host/multipath.c void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid) · line 890
Quoted 12 lines
drivers/nvme/host/multipath.c +9
-0+ int ret; + + ret = sysfs_create_link(&disk_to_dev(ns->head->disk)->kobj, + &disk_to_dev(ns->disk)->kobj, + ns->disk->disk_name); + if (ret) + dev_warn(ns->ctrl->device, + "failed to create namespace path link\n"); + } } void nvme_mpath_shutdown_disk(struct nvme_ns_head *head)What will these links be used for?
Quoted 8 lines
Quoted 3 lines
Mapping for nvme-cli, as explained in the description. Clearly it doesn't do it _now_, but once the patch is in we can simplify nvme-cli to take advantage of it.
you mean for nvme list -v ?
Don't really mind having it, but would want to hear from others as well.
Ok.
Cheers,
Hannes
Sagi Grimberg
maintainerQuoted 63 lines · Hannes Reinecke
Quoted 37 lines · Sagi Grimberg
Quoted 37 lines
Quoted 37 lines
Quoted 29 lines
It is really annoying to always have to loop through the entire
/sys/blockdirectory just to find the namespace path links for a single namespace in libnvme/nvme-cli.
So provide links to the namespace paths for efficient lookup.Signed-off-by Hannes Reinecke <[email protected]>---
drivers/nvme/host/core.c | 3 +++
drivers/nvme/host/multipath.c| 10 ++++++++++2 files changed, 13 insertions(+)drivers/nvme/host/core.c +3
-0@@ -3681,6 +3681,9 @@ static void nvme_ns_remove(struct nvme_ns *ns) if (!nvme_ns_head_multipath(ns->head)) nvme_cdev_del(&ns->cdev, &ns->cdev_device); + else + sysfs_remove_link(&disk_to_dev(ns->head->disk)->kobj, + ns->disk->disk_name); del_gendisk(ns->disk); down_write(&ns->ctrl->namespaces_rwsem);drivers/nvme/host/multipath.c +0
-0drivers/nvme/host/multipath.c void nvme_mpath_add_disk(struct nvme_ns *ns, · line 879
Quoted 5 lines
drivers/nvme/host/multipath.c +1
-0@@ -875,6 +875,16 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid) if (blk_queue_is_zoned(ns->queue) && ns->head->disk) ns->head->disk->nr_zones = ns->disk->nr_zones; #endif + if (ns->head->disk) {Why are the two conditions not identical?
Quoted 4 lines
Quoted 1 line
Which two?
ns->head->diskandnvme_ns_head_multipath()How can we have one without the other? I thought that both are mutually dependent .. but yeah, we should be using '
nvme_ns_head_multipath()' here.Quoted 19 lines
Quoted 18 lines
Quoted 13 lines
drivers/nvme/host/multipath.c void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid) · line 890
Quoted 12 lines
drivers/nvme/host/multipath.c +9
-0+ int ret; + + ret = sysfs_create_link(&disk_to_dev(ns->head->disk)->kobj, + &disk_to_dev(ns->disk)->kobj, + ns->disk->disk_name); + if (ret) + dev_warn(ns->ctrl->device, + "failed to create namespace path link\n"); + } } void nvme_mpath_shutdown_disk(struct nvme_ns_head *head)Quoted 1 line
What will these links be used for?
Mapping for nvme-cli, as explained in the description. Clearly it doesn't do it _now_, but once the patch is in we can simplify nvme-cli to take advantage of it.
Quoted 6 lines
Quoted 4 lines
you mean for nvme list -v ?
Don't really mind having it, but would want to hear from others as well.
Ok.
Hey Hannes,
Has this gone anywhere?
Quoted 68 lines · Sagi Grimberg
Quoted 65 lines · Hannes Reinecke
Quoted 37 lines · Sagi Grimberg
Quoted 37 lines
Quoted 37 lines
Quoted 29 lines
It is really annoying to always have to loop through the entire
/sys/blockdirectory just to find the namespace path links for a single namespace in libnvme/nvme-cli.
So provide links to the namespace paths for efficient lookup.Signed-off-by Hannes Reinecke <[email protected]>---
drivers/nvme/host/core.c | 3 +++
drivers/nvme/host/multipath.c| 10 ++++++++++2 files changed, 13 insertions(+)drivers/nvme/host/core.c +3
-0@@ -3681,6 +3681,9 @@ static void nvme_ns_remove(struct nvme_ns *ns) if (!nvme_ns_head_multipath(ns->head)) nvme_cdev_del(&ns->cdev, &ns->cdev_device); + else + sysfs_remove_link(&disk_to_dev(ns->head->disk)->kobj, + ns->disk->disk_name); del_gendisk(ns->disk); down_write(&ns->ctrl->namespaces_rwsem);drivers/nvme/host/multipath.c +0
-0drivers/nvme/host/multipath.c void nvme_mpath_add_disk(struct nvme_ns *ns, · line 879
Quoted 5 lines
drivers/nvme/host/multipath.c +1
-0@@ -875,6 +875,16 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid) if (blk_queue_is_zoned(ns->queue) && ns->head->disk) ns->head->disk->nr_zones = ns->disk->nr_zones; #endif + if (ns->head->disk) {Why are the two conditions not identical?
Quoted 4 lines
Quoted 1 line
Which two?
ns->head->diskandnvme_ns_head_multipath()How can we have one without the other? I thought that both are mutually dependent .. but yeah, we should be using '
nvme_ns_head_multipath()' here.Quoted 21 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/nvme/host/multipath.c +9
-0+ int ret; + + ret = sysfs_create_link(&disk_to_dev(ns->head->disk)->kobj, + &disk_to_dev(ns->disk)->kobj, + ns->disk->disk_name); + if (ret) + dev_warn(ns->ctrl->device, + "failed to create namespace path link\n"); + } } void nvme_mpath_shutdown_disk(struct nvme_ns_head *head)Quoted 5 lines
Quoted 1 line
What will these links be used for?
Mapping for nvme-cli, as explained in the description. Clearly it doesn't do it _now_, but once the patch is in we can simplify nvme-cli to take advantage of it.
you mean for nvme list -v ?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Don't really mind having it, but would want to hear from others as well.
Ok.
Hey Hannes,
Has this gone anywhere?
Sadly, no. Everyone said "Yeah, good idea, but let's wait for the others." I _dearly_ would love to have it as it will simplify the logic in nvme-cli/libnvme drastically.
Shall I repost?
Cheers,
Hannes
Sagi Grimberg
maintainerQuoted 67 lines
Quoted 67 lines
Quoted 67 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 29 lines
It is really annoying to always have to loop through the entire
/sys/blockdirectory just to find the namespace path links for a single namespace in libnvme/nvme-cli.
So provide links to the namespace paths for efficient lookup.Signed-off-by Hannes Reinecke <[email protected]>---
drivers/nvme/host/core.c | 3 +++
drivers/nvme/host/multipath.c| 10 ++++++++++2 files changed, 13 insertions(+)drivers/nvme/host/core.c +3
-0@@ -3681,6 +3681,9 @@ static void nvme_ns_remove(struct nvme_ns *ns) if (!nvme_ns_head_multipath(ns->head)) nvme_cdev_del(&ns->cdev, &ns->cdev_device); + else + sysfs_remove_link(&disk_to_dev(ns->head->disk)->kobj, + ns->disk->disk_name); del_gendisk(ns->disk); down_write(&ns->ctrl->namespaces_rwsem);drivers/nvme/host/multipath.c +0
-0drivers/nvme/host/multipath.c void nvme_mpath_add_disk(struct nvme_ns *ns, · line 879
Quoted 5 lines
drivers/nvme/host/multipath.c +1
-0@@ -875,6 +875,16 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, __le32 anagrpid) if (blk_queue_is_zoned(ns->queue) && ns->head->disk) ns->head->disk->nr_zones = ns->disk->nr_zones; #endif + if (ns->head->disk) {Why are the two conditions not identical?
Quoted 4 lines
Quoted 1 line
Which two?
ns->head->diskandnvme_ns_head_multipath()How can we have one without the other? I thought that both are mutually dependent .. but yeah, we should be using '
nvme_ns_head_multipath()' here.Quoted 23 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/nvme/host/multipath.c +9
-0+ int ret; + + ret = sysfs_create_link(&disk_to_dev(ns->head->disk)->kobj, + &disk_to_dev(ns->disk)->kobj, + ns->disk->disk_name); + if (ret) + dev_warn(ns->ctrl->device, + "failed to create namespace path link\n"); + } } void nvme_mpath_shutdown_disk(struct nvme_ns_head *head)Quoted 5 lines
Quoted 1 line
What will these links be used for?
Mapping for nvme-cli, as explained in the description. Clearly it doesn't do it _now_, but once the patch is in we can simplify nvme-cli to take advantage of it.
you mean for nvme list -v ?
Don't really mind having it, but would want to hear from others as well.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Ok.
Hey Hannes,
Has this gone anywhere?Sadly, no. Everyone said "Yeah, good idea, but let's wait for the others." I _dearly_ would love to have it as it will simplify the logic in nvme-cli/libnvme drastically.
Shall I repost?
Yes, and I personally don't mind having it, so if no one voices any concern, I don't see why we should prevent it.
Quoted 7 lines · Sagi Grimberg
Sadly, no. Everyone said "Yeah, good idea, but let's wait for the
Quoted 3 lines
others." I _dearly_ would love to have it as it will simplify the logic in nvme-cli/libnvme drastically.
Shall I repost?Yes, and I personally don't mind having it, so if no one voices any concern, I don't see why we should prevent it.
I'd like to get the sysfs link too, so no concerns from my side.