Skip to content

Commit 7934f0e

Browse files
nvme: avoid creating multipath sysfs group under namespace path devices
JIRA: https://issues.redhat.com/browse/RHEL-95382 Commit 4dbd2b2 ("nvme-multipath: Add visibility for round-robin io-policy") introduced the creation of the multipath sysfs group under the NVMe head gendisk device node. However, it also inadvertently added the same sysfs group under each namespace path device which head node refers to and that is incorrect. The multipath sysfs group should only be exposed through the namespace head gendisk node. This is sufficient, as the head device already provides symbolic links to the individual namespace paths it manages. This patch fixes the issue by preventing the creation of the multipath sysfs group under namespace path devices, ensuring it only appears under the head disk node. Fixes: 4dbd2b2 ("nvme-multipath: Add visibility for round-robin io-policy") Signed-off-by: Nilay Shroff <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> (cherry picked from commit 49b9f86) Signed-off-by: Maurizio Lombardi <[email protected]>
1 parent 2f9423b commit 7934f0e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

drivers/nvme/host/sysfs.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,41 @@ static const struct attribute_group nvme_ns_attr_group = {
306306
};
307307

308308
#ifdef CONFIG_NVME_MULTIPATH
309+
/*
310+
* NOTE: The dummy attribute does not appear in sysfs. It exists solely to allow
311+
* control over the visibility of the multipath sysfs node. Without at least one
312+
* attribute defined in nvme_ns_mpath_attrs[], the sysfs implementation does not
313+
* invoke the multipath_sysfs_group_visible() method. As a result, we would not
314+
* be able to control the visibility of the multipath sysfs node.
315+
*/
316+
static struct attribute dummy_attr = {
317+
.name = "dummy",
318+
};
319+
309320
static struct attribute *nvme_ns_mpath_attrs[] = {
321+
&dummy_attr,
310322
NULL,
311323
};
312324

325+
static bool multipath_sysfs_group_visible(struct kobject *kobj)
326+
{
327+
struct device *dev = container_of(kobj, struct device, kobj);
328+
329+
return nvme_disk_is_ns_head(dev_to_disk(dev));
330+
}
331+
332+
static bool multipath_sysfs_attr_visible(struct kobject *kobj,
333+
struct attribute *attr, int n)
334+
{
335+
return false;
336+
}
337+
338+
DEFINE_SYSFS_GROUP_VISIBLE(multipath_sysfs)
339+
313340
const struct attribute_group nvme_ns_mpath_attr_group = {
314341
.name = "multipath",
315342
.attrs = nvme_ns_mpath_attrs,
343+
.is_visible = SYSFS_GROUP_VISIBLE(multipath_sysfs),
316344
};
317345
#endif
318346

0 commit comments

Comments
 (0)