Skip to content

Commit

Permalink
btrfs: sysfs, add UUID/devinfo kobject
Browse files Browse the repository at this point in the history
Create directory /sys/fs/btrfs/UUID/devinfo to hold devices directories
by the id (unlike /devices).

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Anand Jain authored and David Sterba committed Feb 12, 2020
1 parent 28553fa commit a013d14
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fs/btrfs/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,12 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)

static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
{
if (fs_devs->devinfo_kobj) {
kobject_del(fs_devs->devinfo_kobj);
kobject_put(fs_devs->devinfo_kobj);
fs_devs->devinfo_kobj = NULL;
}

if (fs_devs->devices_kobj) {
kobject_del(fs_devs->devices_kobj);
kobject_put(fs_devs->devices_kobj);
Expand Down Expand Up @@ -1369,6 +1375,15 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs)
return -ENOMEM;
}

fs_devs->devinfo_kobj = kobject_create_and_add("devinfo",
&fs_devs->fsid_kobj);
if (!fs_devs->devinfo_kobj) {
btrfs_err(fs_devs->fs_info,
"failed to init sysfs devinfo kobject");
btrfs_sysfs_remove_fsid(fs_devs);
return -ENOMEM;
}

return 0;
}

Expand Down
1 change: 1 addition & 0 deletions fs/btrfs/volumes.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ struct btrfs_fs_devices {
/* sysfs kobjects */
struct kobject fsid_kobj;
struct kobject *devices_kobj;
struct kobject *devinfo_kobj;
struct completion kobj_unregister;
};

Expand Down

0 comments on commit a013d14

Please sign in to comment.