]> git.hungrycats.org Git - linux/commitdiff
btrfs: export dev_item.type in /sys/fs/btrfs/<uuid>/devinfo/<devid>/type
authorKai Krakow <kai@kaishome.de>
Fri, 10 Jul 2026 22:22:50 +0000 (00:22 +0200)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 2 Nov 2026 02:17:16 +0000 (21:17 -0500)
Co-authored-by: Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: Kai Krakow <kai@kaishome.de>
fs/btrfs/sysfs.c

index 89b0a4ef4063edb33340060c6a2d9282014ef98d..6a68149318d84bd94d59f56310a6a52ee6fe98b3 100644 (file)
@@ -1984,6 +1984,18 @@ static ssize_t btrfs_devinfo_error_stats_show(struct kobject *kobj,
 }
 BTRFS_ATTR(devid, error_stats, btrfs_devinfo_error_stats_show);
 
+#ifdef CONFIG_BTRFS_ALLOCATOR_HINTS
+static ssize_t btrfs_devinfo_type_show(struct kobject *kobj,
+                                      struct kobj_attribute *a, char *buf)
+{
+       struct btrfs_device *device = container_of(kobj, struct btrfs_device,
+                                                  devid_kobj);
+
+       return scnprintf(buf, PAGE_SIZE, "0x%016llx\n", device->type);
+}
+BTRFS_ATTR(devid, type, btrfs_devinfo_type_show);
+#endif /* CONFIG_BTRFS_ALLOCATOR_HINTS */
+
 /*
  * Information about one device.
  *
@@ -1997,6 +2009,9 @@ static struct attribute *devid_attrs[] = {
        BTRFS_ATTR_PTR(devid, replace_target),
        BTRFS_ATTR_PTR(devid, scrub_speed_max),
        BTRFS_ATTR_PTR(devid, writeable),
+#ifdef CONFIG_BTRFS_ALLOCATOR_HINTS
+       BTRFS_ATTR_PTR(devid, type),
+#endif /* CONFIG_BTRFS_ALLOCATOR_HINTS */
        NULL
 };
 ATTRIBUTE_GROUPS(devid);