summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/sysfs.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2019-08-01 18:50:16 +0200
committerDavid Sterba <dsterba@suse.com>2019-09-09 14:59:07 +0200
commitb5865babb7b44308f0d0ece39756d55ef7628742 (patch)
treed5952c5d4cf74eab0b288de80d43ace609bfbe1e /fs/btrfs/sysfs.c
parentbtrfs: factor out sysfs code for sending device uevent (diff)
downloadlinux-b5865babb7b44308f0d0ece39756d55ef7628742.tar.xz
linux-b5865babb7b44308f0d0ece39756d55ef7628742.zip
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>
Diffstat (limited to 'fs/btrfs/sysfs.c')
-rw-r--r--fs/btrfs/sysfs.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 5562ce1f7090..4de9bae3e186 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -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) {