summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-03-20 01:42:33 -0400
committerDavid Sterba <dsterba@suse.com>2019-04-29 13:02:32 -0400
commit075cb3c78fe7976c9f29ca1fa23f9728634ecefc (patch)
tree15961e83f25f21a2b9ab09d629b3b5d3f7dce7c0 /fs/btrfs/volumes.c
parentbf871c3b43b1dcc3f2a076ff39a8f1ce7959d958 (diff)
btrfs: tree-checker: Check chunk item at tree block read time
Since we have btrfs_check_chunk_valid() in tree-checker, let's do chunk item verification in tree-checker too. Since the tree-checker is run at endio time, if one chunk leaf fails chunk verification, we can still retry the other copy, making btrfs more robust to fuzzed image as we may still get a good chunk item. Also since we have done chunk verification in tree block read time, skip the btrfs_check_chunk_valid() call in read_one_chunk() if we're reading chunk items from leaf. Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 5f39d86d41ec..97dbd7f37674 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6745,9 +6745,15 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key,
6745 length = btrfs_chunk_length(leaf, chunk); 6745 length = btrfs_chunk_length(leaf, chunk);
6746 num_stripes = btrfs_chunk_num_stripes(leaf, chunk); 6746 num_stripes = btrfs_chunk_num_stripes(leaf, chunk);
6747 6747
6748 ret = btrfs_check_chunk_valid(fs_info, leaf, chunk, logical); 6748 /*
6749 if (ret) 6749 * Only need to verify chunk item if we're reading from sys chunk array,
6750 return ret; 6750 * as chunk item in tree block is already verified by tree-checker.
6751 */
6752 if (leaf->start == BTRFS_SUPER_INFO_OFFSET) {
6753 ret = btrfs_check_chunk_valid(fs_info, leaf, chunk, logical);
6754 if (ret)
6755 return ret;
6756 }
6751 6757
6752 read_lock(&map_tree->map_tree.lock); 6758 read_lock(&map_tree->map_tree.lock);
6753 em = lookup_extent_mapping(&map_tree->map_tree, logical, 1); 6759 em = lookup_extent_mapping(&map_tree->map_tree, logical, 1);