diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-10-15 16:14:48 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:03:56 -0400 |
commit | f510cfecfc98759d75283823cfccf0cc0d59a4c6 (patch) | |
tree | dfc2f788df4e2a437d976f78a2a2a675375f7134 /fs/btrfs/disk-io.c | |
parent | ae5252bd51a252b7b8b02289337c36774835101c (diff) |
Btrfs: Fix extent_buffer and extent_state leaks
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 8242933a1d8b..09f4e694624d 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -46,18 +46,25 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, | |||
46 | u64 blocknr) | 46 | u64 blocknr) |
47 | { | 47 | { |
48 | struct inode *btree_inode = root->fs_info->btree_inode; | 48 | struct inode *btree_inode = root->fs_info->btree_inode; |
49 | return find_extent_buffer(&BTRFS_I(btree_inode)->extent_tree, | 49 | struct extent_buffer *eb; |
50 | eb = find_extent_buffer(&BTRFS_I(btree_inode)->extent_tree, | ||
50 | blocknr * root->sectorsize, | 51 | blocknr * root->sectorsize, |
51 | root->sectorsize, GFP_NOFS); | 52 | root->sectorsize, GFP_NOFS); |
53 | if (eb) | ||
54 | eb->alloc_addr = (unsigned long)__builtin_return_address(0); | ||
55 | return eb; | ||
52 | } | 56 | } |
53 | 57 | ||
54 | struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, | 58 | struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, |
55 | u64 blocknr) | 59 | u64 blocknr) |
56 | { | 60 | { |
57 | struct inode *btree_inode = root->fs_info->btree_inode; | 61 | struct inode *btree_inode = root->fs_info->btree_inode; |
58 | return alloc_extent_buffer(&BTRFS_I(btree_inode)->extent_tree, | 62 | struct extent_buffer *eb; |
63 | eb = alloc_extent_buffer(&BTRFS_I(btree_inode)->extent_tree, | ||
59 | blocknr * root->sectorsize, | 64 | blocknr * root->sectorsize, |
60 | root->sectorsize, GFP_NOFS); | 65 | root->sectorsize, GFP_NOFS); |
66 | eb->alloc_addr = (unsigned long)__builtin_return_address(0); | ||
67 | return eb; | ||
61 | } | 68 | } |
62 | 69 | ||
63 | struct extent_map *btree_get_extent(struct inode *inode, struct page *page, | 70 | struct extent_map *btree_get_extent(struct inode *inode, struct page *page, |
@@ -226,6 +233,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 blocknr) | |||
226 | return NULL; | 233 | return NULL; |
227 | read_extent_buffer_pages(&BTRFS_I(btree_inode)->extent_tree, | 234 | read_extent_buffer_pages(&BTRFS_I(btree_inode)->extent_tree, |
228 | buf, 1); | 235 | buf, 1); |
236 | buf->alloc_addr = (unsigned long)__builtin_return_address(0); | ||
229 | return buf; | 237 | return buf; |
230 | } | 238 | } |
231 | 239 | ||
@@ -426,7 +434,6 @@ struct btrfs_root *open_ctree(struct super_block *sb) | |||
426 | } | 434 | } |
427 | init_bit_radix(&fs_info->pinned_radix); | 435 | init_bit_radix(&fs_info->pinned_radix); |
428 | init_bit_radix(&fs_info->pending_del_radix); | 436 | init_bit_radix(&fs_info->pending_del_radix); |
429 | init_bit_radix(&fs_info->extent_map_radix); | ||
430 | init_bit_radix(&fs_info->extent_ins_radix); | 437 | init_bit_radix(&fs_info->extent_ins_radix); |
431 | INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_NOFS); | 438 | INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_NOFS); |
432 | INIT_RADIX_TREE(&fs_info->block_group_radix, GFP_KERNEL); | 439 | INIT_RADIX_TREE(&fs_info->block_group_radix, GFP_KERNEL); |
@@ -449,6 +456,8 @@ struct btrfs_root *open_ctree(struct super_block *sb) | |||
449 | extent_map_tree_init(&BTRFS_I(fs_info->btree_inode)->extent_tree, | 456 | extent_map_tree_init(&BTRFS_I(fs_info->btree_inode)->extent_tree, |
450 | fs_info->btree_inode->i_mapping, | 457 | fs_info->btree_inode->i_mapping, |
451 | GFP_NOFS); | 458 | GFP_NOFS); |
459 | extent_map_tree_init(&fs_info->free_space_cache, | ||
460 | fs_info->btree_inode->i_mapping, GFP_NOFS); | ||
452 | fs_info->do_barriers = 1; | 461 | fs_info->do_barriers = 1; |
453 | fs_info->closing = 0; | 462 | fs_info->closing = 0; |
454 | 463 | ||
@@ -594,8 +603,10 @@ int close_ctree(struct btrfs_root *root) | |||
594 | 603 | ||
595 | if (fs_info->extent_root->node) | 604 | if (fs_info->extent_root->node) |
596 | free_extent_buffer(fs_info->extent_root->node); | 605 | free_extent_buffer(fs_info->extent_root->node); |
606 | |||
597 | if (fs_info->tree_root->node) | 607 | if (fs_info->tree_root->node) |
598 | free_extent_buffer(fs_info->tree_root->node); | 608 | free_extent_buffer(fs_info->tree_root->node); |
609 | |||
599 | free_extent_buffer(fs_info->sb_buffer); | 610 | free_extent_buffer(fs_info->sb_buffer); |
600 | truncate_inode_pages(fs_info->btree_inode->i_mapping, 0); | 611 | truncate_inode_pages(fs_info->btree_inode->i_mapping, 0); |
601 | iput(fs_info->btree_inode); | 612 | iput(fs_info->btree_inode); |