summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2025-05-22 09:25:47 -0600
committerJens Axboe <axboe@kernel.dk>2025-05-22 09:25:47 -0600
commit115c011f5db7e5f1a1f4404a8f5b5c87a3534362 (patch)
tree5276968b245c401c23bf37fb786c0cfd8f5fc44c
parent355341e4359b2d5edf0ed5e117f7e9e7a0a5dac0 (diff)
parent49b9f86a594a5403641e6e60508788a7310fd293 (diff)
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
-rw-r--r--drivers/nvme/host/sysfs.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index 6d31226f7a4f..a5bc3bb483d5 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -306,13 +306,41 @@ static const struct attribute_group nvme_ns_attr_group = {
};
#ifdef CONFIG_NVME_MULTIPATH
+/*
+ * NOTE: The dummy attribute does not appear in sysfs. It exists solely to allow
+ * control over the visibility of the multipath sysfs node. Without at least one
+ * attribute defined in nvme_ns_mpath_attrs[], the sysfs implementation does not
+ * invoke the multipath_sysfs_group_visible() method. As a result, we would not
+ * be able to control the visibility of the multipath sysfs node.
+ */
+static struct attribute dummy_attr = {
+ .name = "dummy",
+};
+
static struct attribute *nvme_ns_mpath_attrs[] = {
+ &dummy_attr,
NULL,
};
+static bool multipath_sysfs_group_visible(struct kobject *kobj)
+{
+ struct device *dev = container_of(kobj, struct device, kobj);
+
+ return nvme_disk_is_ns_head(dev_to_disk(dev));
+}
+
+static bool multipath_sysfs_attr_visible(struct kobject *kobj,
+ struct attribute *attr, int n)
+{
+ return false;
+}
+
+DEFINE_SYSFS_GROUP_VISIBLE(multipath_sysfs)
+
const struct attribute_group nvme_ns_mpath_attr_group = {
.name = "multipath",
.attrs = nvme_ns_mpath_attrs,
+ .is_visible = SYSFS_GROUP_VISIBLE(multipath_sysfs),
};
#endif