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

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
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -930,6 +930,7 @@ struct btrfs_fs_info {

#ifdef CONFIG_BTRFS_DEBUG
	struct kobject *debug_kobj;
	struct kobject *discard_debug_kobj;
#endif
};

+26 −0
Original line number Diff line number Diff line
@@ -338,6 +338,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
 *
@@ -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);