btrfs: factor out sysfs code for deleting block group and space infos

The helpers to create block group and space info directories already
live in sysfs.c, move the deletion part there too.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba
2019-08-01 18:50:16 +02:00
parent 5b28692e0c
commit b5865babb7
3 changed files with 24 additions and 13 deletions

View File

@@ -800,6 +800,28 @@ void btrfs_sysfs_add_block_group_type(struct btrfs_block_group_cache *cache)
space_info->block_group_kobjs[index] = &rkobj->kobj;
}
/*
* Remove sysfs directories for all block group types of a given space info and
* the space info as well
*/
void btrfs_sysfs_remove_space_info(struct btrfs_space_info *space_info)
{
int i;
for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) {
struct kobject *kobj;
kobj = space_info->block_group_kobjs[i];
space_info->block_group_kobjs[i] = NULL;
if (kobj) {
kobject_del(kobj);
kobject_put(kobj);
}
}
kobject_del(&space_info->kobj);
kobject_put(&space_info->kobj);
}
static const char *alloc_name(u64 flags)
{
switch (flags) {