Commit e4faab84 authored by Dennis Zhou's avatar Dennis Zhou Committed by David Sterba

btrfs: sysfs: add UUID/debug/discard directory

Setup base sysfs directory for discard stats + tunables.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarDennis Zhou <dennis@kernel.org>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 93945cb4
...@@ -930,6 +930,7 @@ struct btrfs_fs_info { ...@@ -930,6 +930,7 @@ struct btrfs_fs_info {
#ifdef CONFIG_BTRFS_DEBUG #ifdef CONFIG_BTRFS_DEBUG
struct kobject *debug_kobj; struct kobject *debug_kobj;
struct kobject *discard_debug_kobj;
#endif #endif
}; };
......
...@@ -338,6 +338,13 @@ static const struct attribute_group btrfs_static_feature_attr_group = { ...@@ -338,6 +338,13 @@ static const struct attribute_group btrfs_static_feature_attr_group = {
#ifdef CONFIG_BTRFS_DEBUG #ifdef CONFIG_BTRFS_DEBUG
/*
* Discard statistics and tunables
*/
static const struct attribute *discard_debug_attrs[] = {
NULL,
};
/* /*
* Runtime debugging exported via sysfs * Runtime debugging exported via sysfs
* *
...@@ -776,6 +783,12 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) ...@@ -776,6 +783,12 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
kobject_put(fs_info->space_info_kobj); kobject_put(fs_info->space_info_kobj);
} }
#ifdef CONFIG_BTRFS_DEBUG #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) { if (fs_info->debug_kobj) {
sysfs_remove_files(fs_info->debug_kobj, btrfs_debug_mount_attrs); sysfs_remove_files(fs_info->debug_kobj, btrfs_debug_mount_attrs);
kobject_del(fs_info->debug_kobj); kobject_del(fs_info->debug_kobj);
...@@ -1127,6 +1140,19 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info) ...@@ -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); error = sysfs_create_files(fs_info->debug_kobj, btrfs_debug_mount_attrs);
if (error) if (error)
goto failure; 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 #endif
error = addrm_unknown_feature_attrs(fs_info, true); error = addrm_unknown_feature_attrs(fs_info, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment