diff options
author | Johannes Thumshirn <jthumshirn@suse.de> | 2019-06-03 16:58:54 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-07-01 13:35:01 +0200 |
commit | 8dc3f22c8ba02c5a5b889406259c50b3eaa61c65 (patch) | |
tree | b906abdd2ffb118fb59b29b7ca312a2515a33d52 /fs/btrfs/disk-io.c | |
parent | e7e16f4882edb5935ff0ba81a0df25ae0b80b549 (diff) |
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 <nborisov@suse.com>
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: David Sterba <dsterba@suse.com>
[ add comment ]
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 3f3bb70ca437..ce6dc95effae 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2817,6 +2817,20 @@ int open_ctree(struct super_block *sb, } /* + * Verify the type first, if that or the the checksum value are + * corrupted, we'll find out + */ + if (!btrfs_supported_super_csum(btrfs_super_csum_type( + (struct btrfs_super_block *) bh->b_data))) { + btrfs_err(fs_info, "unsupported checksum algorithm: %u", + btrfs_super_csum_type((struct btrfs_super_block *) + bh->b_data)); + err = -EINVAL; + brelse(bh); + goto fail_alloc; + } + + /* * We want to check superblock checksum, the type is stored inside. * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k). */ |