Skip to content

Commit 08937bc

Browse files
Hannes ReineckeChristoph Hellwig
authored andcommitted
nvme-multipath: sysfs links may not be created for devices
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>
1 parent 26d7fb4 commit 08937bc

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
@@ -1050,6 +1050,13 @@ void nvme_mpath_add_sysfs_link(struct nvme_ns_head *head)
10501050
srcu_idx = srcu_read_lock(&head->srcu);
10511051

10521052
list_for_each_entry_rcu(ns, &head->list, siblings) {
1053+
/*
1054+
* Ensure that ns path disk node is already added otherwise we
1055+
* may get invalid kobj name for target
1056+
*/
1057+
if (!test_bit(GD_ADDED, &ns->disk->state))
1058+
continue;
1059+
10531060
/*
10541061
* Avoid creating link if it already exists for the given path.
10551062
* When path ana state transitions from optimized to non-
@@ -1065,13 +1072,6 @@ void nvme_mpath_add_sysfs_link(struct nvme_ns_head *head)
10651072
if (test_and_set_bit(NVME_NS_SYSFS_ATTR_LINK, &ns->flags))
10661073
continue;
10671074

1068-
/*
1069-
* Ensure that ns path disk node is already added otherwise we
1070-
* may get invalid kobj name for target
1071-
*/
1072-
if (!test_bit(GD_ADDED, &ns->disk->state))
1073-
continue;
1074-
10751075
target = disk_to_dev(ns->disk);
10761076
/*
10771077
* Create sysfs link from head gendisk kobject @kobj to the

0 commit comments

Comments
 (0)