diff options
author | Josef Bacik <jbacik@fusionio.com> | 2013-03-18 11:07:03 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2013-03-18 19:44:32 +0100 |
commit | 87c09f70b5e334f68cc19c0514d412f666b4eb14 (patch) | |
tree | e2ffc811284807caf2a18ae20018db716e8b7196 /extent-tree.c | |
parent | e9393c220f45f8501d7c0c94e83f99fc91273272 (diff) |
Btrfs-progs: fix memory leaks on cleanup
I've been working on btrfs-image and I kept seeing these leaks pop up on
valgrind so I'm just fixing them. We don't properly cleanup the device cache,
the chunk tree mapping cache, or the space infos on close. With this patch
valgrind doesn't complain about any memory leaks running btrfs-image. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'extent-tree.c')
-rw-r--r-- | extent-tree.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/extent-tree.c b/extent-tree.c index da93cb17..2d829777 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -3003,10 +3003,12 @@ out: int btrfs_free_block_groups(struct btrfs_fs_info *info) { + struct btrfs_space_info *sinfo; u64 start; u64 end; u64 ptr; int ret; + while(1) { ret = find_first_extent_bit(&info->block_group_cache, 0, &start, &end, (unsigned int)-1); @@ -3026,6 +3028,13 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info) clear_extent_dirty(&info->free_space_cache, start, end, GFP_NOFS); } + + while (!list_empty(&info->space_info)) { + sinfo = list_entry(info->space_info.next, + struct btrfs_space_info, list); + list_del_init(&sinfo->list); + kfree(sinfo); + } return 0; } |