diff options
author | Josef Bacik <jbacik@redhat.com> | 2008-12-02 09:58:23 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-12-02 09:58:23 -0500 |
commit | 1148e55804c814094dd86fe9651eface01b745b4 (patch) | |
tree | bd05668325535d77f0fded51fbed459026e7f73a /disk-io.c | |
parent | 76b8244a7a8214819eb7cfb7b8ffc3bf26b70642 (diff) |
btrfs-progs: support for different csum algorithims
This is the btrfs-progs version of the patch to add the ability to have
different csum algorithims. Note I didn't change the image maker since it
seemed a bit more complicated than just changing some stuff around so I will let
Yan take care of that.
Everything else was converted and for now a mkfs just
sets the type to be BTRFS_CSUM_TYPE_CRC32.
Signed-off-by: Josef Bacik <jbacik@redhat.com>
Diffstat (limited to 'disk-io.c')
-rw-r--r-- | disk-io.c | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -67,30 +67,44 @@ void btrfs_csum_final(u32 crc, char *result) *(__le32 *)result = ~cpu_to_le32(crc); } -int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, - int verify) +int csum_tree_block_size(struct extent_buffer *buf, u16 csum_size, + int verify) { - char result[BTRFS_CRC32_SIZE]; + char *result; u32 len; u32 crc = ~(u32)0; + result = malloc(csum_size * sizeof(char)); + if (!result) + return 1; + len = buf->len - BTRFS_CSUM_SIZE; crc = crc32c(crc, buf->data + BTRFS_CSUM_SIZE, len); btrfs_csum_final(crc, result); if (verify) { - if (memcmp_extent_buffer(buf, result, 0, BTRFS_CRC32_SIZE)) { + if (memcmp_extent_buffer(buf, result, 0, csum_size)) { printk("checksum verify failed on %llu wanted %X " "found %X\n", (unsigned long long)buf->start, *((int *)result), *((int *)buf)); + free(result); return 1; } } else { - write_extent_buffer(buf, result, 0, BTRFS_CRC32_SIZE); + write_extent_buffer(buf, result, 0, csum_size); } + free(result); return 0; } +int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, + int verify) +{ + u16 csum_size = + btrfs_super_csum_size(&root->fs_info->super_copy); + return csum_tree_block_size(buf, csum_size, verify); +} + struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize) { |