Skip to content

Commit 115c011

Browse files
committed
Merge tag 'nvme-6.15-2025-05-22' of git://git.infradead.org/nvme into block-6.15
Pull NVMe fix from Christoph: "nvme fixes for Linux 6.15 - do not create the newly added multipath sysfs group for non-multipath nodes (Nilay Shroff)" * tag 'nvme-6.15-2025-05-22' of git://git.infradead.org/nvme: nvme: avoid creating multipath sysfs group under namespace path devices
2 parents 355341e + 49b9f86 commit 115c011

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)