aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-05-31 13:04:36 -0400
committerChris Mason <chris.mason@fusionio.com>2013-06-08 15:07:53 -0400
commita9995eece39a0630ebbfc1ab38570bce6c8a8f5b (patch)
tree1dab3bca657f98015fed634bf08e2cc9742741f6 /fs
parent6379ef9fb2482a92b5fe09f927d6ce1f989c0c6d (diff)
Btrfs: init relocate extent_io_tree with a mapping
Dave reported a NULL pointer deref. This is caused because he thought he'd be smart and add sanity checks to the extent_io bit operations, but he didn't expect a tree to have a NULL mapping. To fix this we just need to init the relocation's processed_blocks with the btree_inode->i_mapping. Thanks, Reported-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/relocation.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 395b82031a42..4febca4fc2de 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4082,7 +4082,7 @@ out:
4082 return inode; 4082 return inode;
4083} 4083}
4084 4084
4085static struct reloc_control *alloc_reloc_control(void) 4085static struct reloc_control *alloc_reloc_control(struct btrfs_fs_info *fs_info)
4086{ 4086{
4087 struct reloc_control *rc; 4087 struct reloc_control *rc;
4088 4088
@@ -4093,7 +4093,8 @@ static struct reloc_control *alloc_reloc_control(void)
4093 INIT_LIST_HEAD(&rc->reloc_roots); 4093 INIT_LIST_HEAD(&rc->reloc_roots);
4094 backref_cache_init(&rc->backref_cache); 4094 backref_cache_init(&rc->backref_cache);
4095 mapping_tree_init(&rc->reloc_root_tree); 4095 mapping_tree_init(&rc->reloc_root_tree);
4096 extent_io_tree_init(&rc->processed_blocks, NULL); 4096 extent_io_tree_init(&rc->processed_blocks,
4097 fs_info->btree_inode->i_mapping);
4097 return rc; 4098 return rc;
4098} 4099}
4099 4100
@@ -4110,7 +4111,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)
4110 int rw = 0; 4111 int rw = 0;
4111 int err = 0; 4112 int err = 0;
4112 4113
4113 rc = alloc_reloc_control(); 4114 rc = alloc_reloc_control(fs_info);
4114 if (!rc) 4115 if (!rc)
4115 return -ENOMEM; 4116 return -ENOMEM;
4116 4117
@@ -4311,7 +4312,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
4311 if (list_empty(&reloc_roots)) 4312 if (list_empty(&reloc_roots))
4312 goto out; 4313 goto out;
4313 4314
4314 rc = alloc_reloc_control(); 4315 rc = alloc_reloc_control(root->fs_info);
4315 if (!rc) { 4316 if (!rc) {
4316 err = -ENOMEM; 4317 err = -ENOMEM;
4317 goto out; 4318 goto out;