@@ -35,11 +35,13 @@ static int check_csum_superblock(void *sb)
{
u8 result[csum_size];
u32 crc = ~(u32)0;
+ u16 csum_type = btrfs_super_csum_type(sb);
- crc = btrfs_csum_data((char *)sb + BTRFS_CSUM_SIZE,
+ crc = btrfs_csum_data(csum_type,
+ (char *)sb + BTRFS_CSUM_SIZE,
(u8 *)&crc,
BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);
- btrfs_csum_final(crc, result);
+ btrfs_csum_final(csum_type, crc, result);
return !memcmp(sb, &result, csum_size);
}
@@ -49,17 +51,20 @@ static void update_block_csum(void *block, int is_sb)
u8 result[csum_size];
struct btrfs_header *hdr;
u32 crc = ~(u32)0;
+ u16 csum_type = btrfs_super_csum_type(block);
if (is_sb) {
- crc = btrfs_csum_data((char *)block + BTRFS_CSUM_SIZE,
+ crc = btrfs_csum_data(csum_type,
+ (char *)block + BTRFS_CSUM_SIZE,
(u8 *)&crc,
BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);
} else {
- crc = btrfs_csum_data((char *)block + BTRFS_CSUM_SIZE,
+ crc = btrfs_csum_data(csum_type,
+ (char *)block + BTRFS_CSUM_SIZE,
(u8 *)&crc,
BLOCKSIZE - BTRFS_CSUM_SIZE);
}
- btrfs_csum_final(crc, result);
+ btrfs_csum_final(csum_type, crc, result);
memset(block, 0, BTRFS_CSUM_SIZE);
hdr = (struct btrfs_header *)block;
memcpy(&hdr->csum, result, csum_size);
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> --- btrfs-sb-mod.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)