diff mbox series

[01/17] btrfs: use btrfs_csum_data() instead of directly calling crc32c

Message ID 20190510111547.15310-2-jthumshirn@suse.de (mailing list archive)
State New, archived
Headers show
Series Add support for SHA-256 checksums | expand

Commit Message

Johannes Thumshirn May 10, 2019, 11:15 a.m. UTC
btrfsic_test_for_metadata() directly calls the crc32c() library function
for calculating the CRC32C checksum, but then uses btrfs_csum_final() to
invert the result.

To ease further refactoring and development around checksumming in BTRFS
convert to calling btrfs_csum_data(), which is a wrapper around crc32c().

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 fs/btrfs/check-integrity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nikolay Borisov May 10, 2019, 4:16 p.m. UTC | #1
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote:
> btrfsic_test_for_metadata() directly calls the crc32c() library function
> for calculating the CRC32C checksum, but then uses btrfs_csum_final() to
> invert the result.
> 
> To ease further refactoring and development around checksumming in BTRFS
> convert to calling btrfs_csum_data(), which is a wrapper around crc32c().
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/check-integrity.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> index b0c8094528d1..85774e2fa3e5 100644
> --- a/fs/btrfs/check-integrity.c
> +++ b/fs/btrfs/check-integrity.c
> @@ -1728,7 +1728,7 @@ static int btrfsic_test_for_metadata(struct btrfsic_state *state,
>  		size_t sublen = i ? PAGE_SIZE :
>  				    (PAGE_SIZE - BTRFS_CSUM_SIZE);
>  
> -		crc = crc32c(crc, data, sublen);
> +		crc = btrfs_csum_data(data, crc, sublen);
>  	}
>  	btrfs_csum_final(crc, csum);
>  	if (memcmp(csum, h->csum, state->csum_size))
>
diff mbox series

Patch

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index b0c8094528d1..85774e2fa3e5 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -1728,7 +1728,7 @@  static int btrfsic_test_for_metadata(struct btrfsic_state *state,
 		size_t sublen = i ? PAGE_SIZE :
 				    (PAGE_SIZE - BTRFS_CSUM_SIZE);
 
-		crc = crc32c(crc, data, sublen);
+		crc = btrfs_csum_data(data, crc, sublen);
 	}
 	btrfs_csum_final(crc, csum);
 	if (memcmp(csum, h->csum, state->csum_size))