Skip to contentSkip to conversation

nvme-multipath: clear NVME_NS_SYSFS_ATTR_LINK when disk is not added

PATCH In review Hannes Reinecke 3 participants 3 messages Apr 14, 2025 – Apr 15, 2025 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-multipath: clear NVME_NS_SYSFS_ATTR_LINK when disk is not added

If the namespace disk is not added we need to clear NVME_NS_SYSFS_ATTR_LINK, otherwise the link will never be created upon rescan.

Fixes 4dbd2b2ebe4c ("nvme-multipath: Add visibility for round-robin io-policy")
---
 drivers/nvme/host/multipath.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/multipath.c +3 -1
index 05eccd96d34a..5c28f0dc6fad 100644
@@ -1069,8 +1069,10 @@ void nvme_mpath_add_sysfs_link(struct nvme_ns_head *head)
 		 * Ensure that ns path disk node is already added otherwise we
 		 * may get invalid kobj name for target
 		 */
-		if (!test_bit(GD_ADDED, &ns->disk->state))
+		if (!test_bit(GD_ADDED, &ns->disk->state)) {
+			clear_bit(NVME_NS_SYSFS_ATTR_LINK, &ns->flags);
 			continue;
+		}
 
 		target = disk_to_dev(ns->disk);
 		/*
Signature · 1 line
2.35.3
maintainer
#1 lore raw
Quoted 17 lines · Hannes Reinecke

If the namespace disk is not added we need to clear NVME_NS_SYSFS_ATTR_LINK, otherwise the link will never be created upon rescan.

Fixes 4dbd2b2ebe4c ("nvme-multipath: Add visibility for round-robin io-policy")
---
  drivers/nvme/host/multipath.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/multipath.c +0 -0
index 05eccd96d34a..5c28f0dc6fad 100644
@@ -1069,8 +1069,10 @@ void nvme_mpath_add_sysfs_link(struct nvme_ns_head *head)
  		 * Ensure that ns path disk node is already added otherwise we

drivers/nvme/host/multipath.c void nvme_mpath_add_sysfs_link(struct nvme_ns_head *head) · line 1078

Quoted 10 lines
drivers/nvme/host/multipath.c +3 -1
  		 * may get invalid kobj name for target
  		 */
-		if (!test_bit(GD_ADDED, &ns->disk->state))
+		if (!test_bit(GD_ADDED, &ns->disk->state)) {
+			clear_bit(NVME_NS_SYSFS_ATTR_LINK, &ns->flags);
  			continue;
+		}
 
  		target = disk_to_dev(ns->disk);
  		/*

Why not change the ordering of GD_ADDED and NVME_NS_SYSFS_ATTR_LINK checks?

#2 lore raw
Quoted 23 lines · Sagi Grimberg
Quoted 20 lines · Hannes Reinecke

If the namespace disk is not added we need to clear NVME_NS_SYSFS_ATTR_LINK, otherwise the link will never be created upon rescan.

Fixes 4dbd2b2ebe4c ("nvme-multipath: Add visibility for round-robin io-policy")

---
  drivers/nvme/host/multipath.c | 4 +++-

  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/multipath.c +0 -1
index 05eccd96d34a..5c28f0dc6fad 100644
@@ -1069,8 +1069,10 @@ void nvme_mpath_add_sysfs_link(struct nvme_ns_head *head)
            * Ensure that ns path disk node is already added otherwise we
            * may get invalid kobj name for target
            */
-        if (!test_bit(GD_ADDED, &ns->disk->state))
Quoted 8 lines

drivers/nvme/host/multipath.c void nvme_mpath_add_sysfs_link(struct nvme_ns_head *head) · line 1078

Quoted 6 lines
drivers/nvme/host/multipath.c +3 -0
+        if (!test_bit(GD_ADDED, &ns->disk->state)) {
+            clear_bit(NVME_NS_SYSFS_ATTR_LINK, &ns->flags);
               continue;
+        }
             target = disk_to_dev(ns->disk);
           /*

Why not change the ordering of GD_ADDED and NVME_NS_SYSFS_ATTR_LINK checks?

This is exactly same issue I also encountered last week while unit testing changes while adding support for this feature in libnvme. Then I fixed it locally and queued it up for upstream. But anyways, I'm glad that you already fixed it and send the fix upstream :)

However my changes were exactly same as Sagi suggested. I just changed the order of setting NVME_NS_SYSFS_ATTR_LINK and GD_ADDED. So I also recommend we may just switch the order and fix it.

Thanks,
--Nilay