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>
This commit is contained in:
Dennis Zhou 2019-12-13 16:22:19 -08:00 committed by David Sterba
parent 93945cb43e
commit e4faab844a
2 changed files with 27 additions and 0 deletions

View File

@ -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
}; };

View File

@ -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)
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)
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);