btrfs: make thaw time super block check to also verify checksum
authorQu Wenruo <wqu@suse.com>
Tue, 18 Oct 2022 01:56:38 +0000 (09:56 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Oct 2022 13:28:29 +0000 (15:28 +0200)
commit3d17adea74a56a4965f7a603d8ed8c66bb9356d9
tree422fb6b536dc882ea54c1183d86ce1d15966c91f
parent968b71583130b6104c9f33ba60446d598e327a8b
btrfs: make thaw time super block check to also verify checksum

Previous commit a05d3c915314 ("btrfs: check superblock to ensure the fs
was not modified at thaw time") only checks the content of the super
block, but it doesn't really check if the on-disk super block has a
matching checksum.

This patch will add the checksum verification to thaw time superblock
verification.

This involves the following extra changes:

- Export btrfs_check_super_csum()
  As we need to call it in super.c.

- Change the argument list of btrfs_check_super_csum()
  Instead of passing a char *, directly pass struct btrfs_super_block *
  pointer.

- Verify that our checksum type didn't change before checking the
  checksum value, like it's done at mount time

Fixes: a05d3c915314 ("btrfs: check superblock to ensure the fs was not modified at thaw time")
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c
fs/btrfs/disk-io.h
fs/btrfs/super.c