From: Thomas Weißschuh Date: Fri, 18 Nov 2022 19:07:37 +0000 (+0100) Subject: libblkid: btrfs: add support for xxhash checksums X-Git-Tag: v2.39-rc1~410^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fe26258e3ae00f2c638ebeef5d2160c2c7774552;p=thirdparty%2Futil-linux.git libblkid: btrfs: add support for xxhash checksums --- diff --git a/libblkid/src/superblocks/btrfs.c b/libblkid/src/superblocks/btrfs.c index de39b70fb8..b9cf4bd370 100644 --- a/libblkid/src/superblocks/btrfs.c +++ b/libblkid/src/superblocks/btrfs.c @@ -20,15 +20,18 @@ #include "superblocks.h" #include "crc32c.h" #include "sha256.h" +#include "xxhash.h" enum btrfs_super_block_csum_type { BTRFS_SUPER_BLOCK_CSUM_TYPE_CRC32C = 0, + BTRFS_SUPER_BLOCK_CSUM_TYPE_XXHASH = 1, BTRFS_SUPER_BLOCK_CSUM_TYPE_SHA256 = 2, }; union btrfs_super_block_csum { uint8_t bytes[32]; uint32_t crc32c; + XXH64_hash_t xxh64; uint8_t sha256[UL_SHA256LENGTH]; }; @@ -227,6 +230,11 @@ static int btrfs_verify_csum(blkid_probe pr, const struct btrfs_super_block *bfs return blkid_probe_verify_csum(pr, crc, le32_to_cpu(bfs->csum.crc32c)); } + case BTRFS_SUPER_BLOCK_CSUM_TYPE_XXHASH: { + XXH64_hash_t xxh64 = XXH64(csum_data, csum_data_size, 0); + return blkid_probe_verify_csum(pr, xxh64, + le64_to_cpu(bfs->csum.xxh64)); + } case BTRFS_SUPER_BLOCK_CSUM_TYPE_SHA256: { uint8_t sha256[UL_SHA256LENGTH]; ul_SHA256(sha256, csum_data, csum_data_size);