diff options
author | Josef Bacik <josef@redhat.com> | 2010-03-19 16:49:55 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-03-30 21:19:09 -0400 |
commit | 1b1d1f6625e517a08640ddb4b8f8a0e025243fe3 (patch) | |
tree | d662fe7e7d9ddec1214982b3dcd955228e18562f /fs/btrfs/extent-tree.c | |
parent | 6cf8bfbf5e88edfb09a2bf0631a067060f534592 (diff) |
Btrfs: fail to mount if we have problems reading the block groups
We don't actually check the return value of btrfs_read_block_groups, so we can
possibly succeed to mount, but then fail to say read the superblock xattr for
selinux which will cause the vfs code to deactivate the super.
This is a problem because in find_free_extent we just assume that we
will find the right space_info for the allocation we want. But if we
failed to read the block groups, we won't have setup any space_info's,
and we'll hit a NULL pointer deref in find_free_extent.
This patch fixes that problem by checking the return value of
btrfs_read_block_groups, and failing out properly. I've also added a
check in find_free_extent so if for some reason we don't find an
appropriate space_info, we just return -ENOSPC.
Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 503a18eaef52..4c910359c807 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -4170,6 +4170,10 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans, | |||
4170 | ins->offset = 0; | 4170 | ins->offset = 0; |
4171 | 4171 | ||
4172 | space_info = __find_space_info(root->fs_info, data); | 4172 | space_info = __find_space_info(root->fs_info, data); |
4173 | if (!space_info) { | ||
4174 | printk(KERN_ERR "No space info for %d\n", data); | ||
4175 | return -ENOSPC; | ||
4176 | } | ||
4173 | 4177 | ||
4174 | if (orig_root->ref_cows || empty_size) | 4178 | if (orig_root->ref_cows || empty_size) |
4175 | allowed_chunk_alloc = 1; | 4179 | allowed_chunk_alloc = 1; |
@@ -7372,7 +7376,6 @@ static int find_first_block_group(struct btrfs_root *root, | |||
7372 | } | 7376 | } |
7373 | path->slots[0]++; | 7377 | path->slots[0]++; |
7374 | } | 7378 | } |
7375 | ret = -ENOENT; | ||
7376 | out: | 7379 | out: |
7377 | return ret; | 7380 | return ret; |
7378 | } | 7381 | } |