Skip to content

Commit cd2035c

Browse files
nvme-multipath: sysfs links may not be created for devices
JIRA: https://issues.redhat.com/browse/RHEL-72531 When rapidly rescanning for new namespaces nvme_mpath_add_sysfs_link() may be called for a block device not added to sysfs. But NVME_NS_SYSFS_ATTR_LINK had already been set, so when checking this device a second time we will fail to create the link. Fix this by exchanging the order of the block device check and the NVME_NS_SYSFS_ATTR_LINK bit check. Fixes: 4dbd2b2 ("nvme-multipath: Add visibility for round-robin io-policy") Signed-off-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>** Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Christoph Hellwig <hch@lst.de> (cherry picked from commit 08937bc) Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
1 parent c7489cb commit cd2035c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/nvme/host/multipath.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,13 @@ void nvme_mpath_add_sysfs_link(struct nvme_ns_head *head)
10561056
srcu_idx = srcu_read_lock(&head->srcu);
10571057

10581058
list_for_each_entry_rcu(ns, &head->list, siblings) {
1059+
/*
1060+
* Ensure that ns path disk node is already added otherwise we
1061+
* may get invalid kobj name for target
1062+
*/
1063+
if (!test_bit(GD_ADDED, &ns->disk->state))
1064+
continue;
1065+
10591066
/*
10601067
* Avoid creating link if it already exists for the given path.
10611068
* When path ana state transitions from optimized to non-
@@ -1071,13 +1078,6 @@ void nvme_mpath_add_sysfs_link(struct nvme_ns_head *head)
10711078
if (test_and_set_bit(NVME_NS_SYSFS_ATTR_LINK, &ns->flags))
10721079
continue;
10731080

1074-
/*
1075-
* Ensure that ns path disk node is already added otherwise we
1076-
* may get invalid kobj name for target
1077-
*/
1078-
if (!test_bit(GD_ADDED, &ns->disk->state))
1079-
continue;
1080-
10811081
target = disk_to_dev(ns->disk);
10821082
/*
10831083
* Create sysfs link from head gendisk kobject @kobj to the

0 commit comments

Comments
 (0)