summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2016-07-21 02:44:12 +0200
committerDavid Sterba <dsterba@suse.com>2016-09-26 17:59:49 +0200
commitc79a175175d5a908a7c4d923d44f36808f56536e (patch)
treeb1eac23b00d931a0d6f5ebd72ba330096ddd6921 /fs/btrfs/extent-tree.c
parentLinux 4.8-rc8 (diff)
downloadlinux-c79a175175d5a908a7c4d923d44f36808f56536e.tar.xz
linux-c79a175175d5a908a7c4d923d44f36808f56536e.zip
Btrfs: fix memory leak of block group cache
While processing delayed refs, we may update block group's statistics and attach it to cur_trans->dirty_bgs, and later writing dirty block groups will process the list, which happens during btrfs_commit_transaction(). For whatever reason, the transaction is aborted and dirty_bgs is not processed in cleanup_transaction(), we end up with memory leak of these dirty block group cache. Since btrfs_start_dirty_block_groups() doesn't make it go to the commit critical section, this also adds the cleanup work inside it. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to '')
-rw-r--r--fs/btrfs/extent-tree.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 665da8f66ff1..616c45580c23 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3694,6 +3694,8 @@ again:
goto again;
}
spin_unlock(&cur_trans->dirty_bgs_lock);
+ } else if (ret < 0) {
+ btrfs_cleanup_dirty_bgs(cur_trans, root);
}
btrfs_free_path(path);