diff options
author | Dennis Zhou <dennis@kernel.org> | 2019-12-14 03:22:19 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-01-20 18:40:58 +0300 |
commit | e4faab844a55edb9b628bf1f982fbc30f07b9700 (patch) | |
tree | b3beacada4e714022fe6ba708fd9d70f6d392bb8 /fs | |
parent | 93945cb43ead1e22e0d5ab50ae361a62cb783ab2 (diff) | |
download | linux-e4faab844a55edb9b628bf1f982fbc30f07b9700.tar.xz |
btrfs: sysfs: add UUID/debug/discard directory
Setup base sysfs directory for discard stats + tunables.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Dennis Zhou <dennis@kernel.org>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ctree.h | 1 | ||||
-rw-r--r-- | fs/btrfs/sysfs.c | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0626e5562993..71317047c321 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -930,6 +930,7 @@ struct btrfs_fs_info { #ifdef CONFIG_BTRFS_DEBUG struct kobject *debug_kobj; + struct kobject *discard_debug_kobj; #endif }; diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 5a09c7a14124..0eec1a8d45bd 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -339,6 +339,13 @@ static const struct attribute_group btrfs_static_feature_attr_group = { #ifdef CONFIG_BTRFS_DEBUG /* + * Discard statistics and tunables + */ +static const struct attribute *discard_debug_attrs[] = { + NULL, +}; + +/* * Runtime debugging exported via sysfs * * /sys/fs/btrfs/debug - applies to module or all filesystems @@ -776,6 +783,12 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) kobject_put(fs_info->space_info_kobj); } #ifdef CONFIG_BTRFS_DEBUG + if (fs_info->discard_debug_kobj) { + sysfs_remove_files(fs_info->discard_debug_kobj, + discard_debug_attrs); + kobject_del(fs_info->discard_debug_kobj); + kobject_put(fs_info->discard_debug_kobj); + } if (fs_info->debug_kobj) { sysfs_remove_files(fs_info->debug_kobj, btrfs_debug_mount_attrs); kobject_del(fs_info->debug_kobj); @@ -1127,6 +1140,19 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info) error = sysfs_create_files(fs_info->debug_kobj, btrfs_debug_mount_attrs); if (error) goto failure; + + /* Discard directory */ + fs_info->discard_debug_kobj = kobject_create_and_add("discard", + fs_info->debug_kobj); + if (!fs_info->discard_debug_kobj) { + error = -ENOMEM; + goto failure; + } + + error = sysfs_create_files(fs_info->discard_debug_kobj, + discard_debug_attrs); + if (error) + goto failure; #endif error = addrm_unknown_feature_attrs(fs_info, true); |