Message ID | c6b85bfa502c4db5d57a1c3db7e4c828cc8c1dba.1564046972.git.jthumshirn@suse.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Support xxhash64 checksums | expand |
On 25.07.19 г. 12:34 ч., Johannes Thumshirn wrote: > update_block_csum() in btrfs-sb-mod.c is always called with the 'is_sb' > argument set to 1. > > Get rid of the special case for is_sb == 0. > > Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Nikolay Borisov <nborisov@suse.com> > --- > btrfs-sb-mod.c | 19 ++++++------------- > 1 file changed, 6 insertions(+), 13 deletions(-) > > diff --git a/btrfs-sb-mod.c b/btrfs-sb-mod.c > index d9630f187d0f..9e64b34d2b8f 100644 > --- a/btrfs-sb-mod.c > +++ b/btrfs-sb-mod.c > @@ -46,24 +46,17 @@ static int check_csum_superblock(void *sb) > return !memcmp(sb, &result, csum_size); > } > > -static void update_block_csum(void *block, int is_sb) > +static void update_block_csum(void *block) > { > 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(csum_type, > - (char *)block + BTRFS_CSUM_SIZE, > - (u8 *)&crc, > - BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); > - } else { > - crc = btrfs_csum_data(csum_type, > - (char *)block + BTRFS_CSUM_SIZE, > - (u8 *)&crc, > - BLOCKSIZE - BTRFS_CSUM_SIZE); > - } > + crc = btrfs_csum_data(csum_type, (char *)block + BTRFS_CSUM_SIZE, > + (u8 *)&crc, > + BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); > + > btrfs_csum_final(csum_type, crc, result); > memset(block, 0, BTRFS_CSUM_SIZE); > hdr = (struct btrfs_header *)block; > @@ -354,7 +347,7 @@ int main(int argc, char **argv) { > > if (changed) { > printf("Update csum\n"); > - update_block_csum(buf, 1); > + update_block_csum(buf); > ret = pwrite(fd, buf, BLOCKSIZE, off); > if (ret <= 0) { > printf("pwrite error %d at offset %llu\n", >
diff --git a/btrfs-sb-mod.c b/btrfs-sb-mod.c index d9630f187d0f..9e64b34d2b8f 100644 --- a/btrfs-sb-mod.c +++ b/btrfs-sb-mod.c @@ -46,24 +46,17 @@ static int check_csum_superblock(void *sb) return !memcmp(sb, &result, csum_size); } -static void update_block_csum(void *block, int is_sb) +static void update_block_csum(void *block) { 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(csum_type, - (char *)block + BTRFS_CSUM_SIZE, - (u8 *)&crc, - BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); - } else { - crc = btrfs_csum_data(csum_type, - (char *)block + BTRFS_CSUM_SIZE, - (u8 *)&crc, - BLOCKSIZE - BTRFS_CSUM_SIZE); - } + crc = btrfs_csum_data(csum_type, (char *)block + BTRFS_CSUM_SIZE, + (u8 *)&crc, + BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); + btrfs_csum_final(csum_type, crc, result); memset(block, 0, BTRFS_CSUM_SIZE); hdr = (struct btrfs_header *)block; @@ -354,7 +347,7 @@ int main(int argc, char **argv) { if (changed) { printf("Update csum\n"); - update_block_csum(buf, 1); + update_block_csum(buf); ret = pwrite(fd, buf, BLOCKSIZE, off); if (ret <= 0) { printf("pwrite error %d at offset %llu\n",
update_block_csum() in btrfs-sb-mod.c is always called with the 'is_sb' argument set to 1. Get rid of the special case for is_sb == 0. Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> --- btrfs-sb-mod.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)