Skip to content

Commit 8dc3f22

Browse files
Johannes Thumshirnkdave
authored andcommitted
btrfs: check for supported superblock checksum type before checksum validation
Now that we have factorerd out the superblock checksum type validation, we can check for supported superblock checksum types before doing the actual validation of the superblock read from disk. This leads the path to further simplifications of btrfs_check_super_csum() later on. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Johannes Thumshirn <[email protected]> Reviewed-by: David Sterba <[email protected]> [ add comment ] Signed-off-by: David Sterba <[email protected]>
1 parent e7e16f4 commit 8dc3f22

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/btrfs/disk-io.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,6 +2816,20 @@ int open_ctree(struct super_block *sb,
28162816
goto fail_alloc;
28172817
}
28182818

2819+
/*
2820+
* Verify the type first, if that or the the checksum value are
2821+
* corrupted, we'll find out
2822+
*/
2823+
if (!btrfs_supported_super_csum(btrfs_super_csum_type(
2824+
(struct btrfs_super_block *) bh->b_data))) {
2825+
btrfs_err(fs_info, "unsupported checksum algorithm: %u",
2826+
btrfs_super_csum_type((struct btrfs_super_block *)
2827+
bh->b_data));
2828+
err = -EINVAL;
2829+
brelse(bh);
2830+
goto fail_alloc;
2831+
}
2832+
28192833
/*
28202834
* We want to check superblock checksum, the type is stored inside.
28212835
* Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k).

0 commit comments

Comments
 (0)