diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2016-06-22 21:31:27 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-07-26 07:52:25 -0400 |
commit | 6fb37b756acce6d6e045f79c3764206033f617b4 (patch) | |
tree | 0279142b07c97a236b5dc5eea48db7bc10c80179 /fs/btrfs/extent-tree.c | |
parent | c1fd5c30d1328e0a0c3aafc3768b9cea94d7b28f (diff) |
Btrfs: check inconsistence between chunk and block group
With btrfs-corrupt-block, one can drop one chunk item and mounting
will end up with a panic in btrfs_full_stripe_len().
This doesn't not remove the BUG_ON, but instead checks it a bit
earlier when we find the block group item.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 9fcb8c97083b..cab2f9c8d321 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -9887,7 +9887,22 @@ static int find_first_block_group(struct btrfs_root *root, | |||
9887 | 9887 | ||
9888 | if (found_key.objectid >= key->objectid && | 9888 | if (found_key.objectid >= key->objectid && |
9889 | found_key.type == BTRFS_BLOCK_GROUP_ITEM_KEY) { | 9889 | found_key.type == BTRFS_BLOCK_GROUP_ITEM_KEY) { |
9890 | ret = 0; | 9890 | struct extent_map_tree *em_tree; |
9891 | struct extent_map *em; | ||
9892 | |||
9893 | em_tree = &root->fs_info->mapping_tree.map_tree; | ||
9894 | read_lock(&em_tree->lock); | ||
9895 | em = lookup_extent_mapping(em_tree, found_key.objectid, | ||
9896 | found_key.offset); | ||
9897 | read_unlock(&em_tree->lock); | ||
9898 | if (!em) { | ||
9899 | btrfs_err(root->fs_info, | ||
9900 | "logical %llu len %llu found bg but no related chunk", | ||
9901 | found_key.objectid, found_key.offset); | ||
9902 | ret = -ENOENT; | ||
9903 | } else { | ||
9904 | ret = 0; | ||
9905 | } | ||
9891 | goto out; | 9906 | goto out; |
9892 | } | 9907 | } |
9893 | path->slots[0]++; | 9908 | path->slots[0]++; |