Btrfs: avoid memory leak of extent state in error handling routine
authorLiu Bo <liubo2009@cn.fujitsu.com>
Thu, 14 Jun 2012 08:23:20 +0000 (02:23 -0600)
committerChris Mason <chris.mason@fusionio.com>
Fri, 15 Jun 2012 15:42:27 +0000 (11:42 -0400)
We've forgotten to clear extent states in pinned tree, which will results in
space counter mismatch and memory leak:

WARNING: at fs/btrfs/extent-tree.c:7537 btrfs_free_block_groups+0x1f3/0x2e0 [btrfs]()
...
space_info 2 has 8380416 free, is not full
space_info total=12582912, used=4096, pinned=4096, reserved=0, may_use=0, readonly=4194304
btrfs state leak: start 29364224 end 29376511 state 1 in tree ffff880075f20090 refs 1
...

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/disk-io.c

index 9a569aef72eafa6586d768c9969c46de1341c60f..63a36232788b6f0918831e6fb1e8e311ccb76ded 100644 (file)
@@ -3601,6 +3601,8 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans,
 
        btrfs_destroy_marked_extents(root, &cur_trans->dirty_pages,
                                     EXTENT_DIRTY);
+       btrfs_destroy_pinned_extent(root,
+                                   root->fs_info->pinned_extents);
 
        /*
        memset(cur_trans, 0, sizeof(*cur_trans));