diff options
author | Song Liu <songliubraving@fb.com> | 2015-10-28 20:06:06 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.com> | 2015-10-30 07:38:28 +0100 |
commit | 198d54787c89872bc72d2824ba3c9d1a783e31ae (patch) | |
tree | 520b9cf3de7ce1f067829a756849d9ff965d6c5b /super1.c | |
parent | mdadm: add test script for raid456 journal (diff) | |
download | mdadm-198d54787c89872bc72d2824ba3c9d1a783e31ae.tar.xz mdadm-198d54787c89872bc72d2824ba3c9d1a783e31ae.zip |
add crc32c and use it for r5l checksum
In kernel space, r5l checksum will use crc32c:
http://marc.info/?l=linux-raid&m=144598970529191
mdadm need to change too.
This patch ports a simplified crc32c algorithm from kernel code,
and used in super1.c:write_empty_r5l_meta_block();
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Diffstat (limited to 'super1.c')
-rw-r--r-- | super1.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -1625,10 +1625,7 @@ static unsigned long choose_bm_space(unsigned long devsize) static void free_super1(struct supertype *st); #define META_BLOCK_SIZE 4096 -unsigned long crc32( - unsigned long crc, - const unsigned char *buf, - unsigned len); +__u32 crc32c_le(__u32 crc, unsigned char const *p, size_t len); static int write_empty_r5l_meta_block(struct supertype *st, int fd) { @@ -1652,9 +1649,9 @@ static int write_empty_r5l_meta_block(struct supertype *st, int fd) mb->seq = __cpu_to_le64(random32()); mb->position = __cpu_to_le64(0); - crc = crc32(0xffffffff, sb->set_uuid, sizeof(sb->set_uuid)); - crc = crc32(crc, (void *)mb, META_BLOCK_SIZE); - mb->checksum = __cpu_to_le32(crc); + crc = crc32c_le(0xffffffff, sb->set_uuid, sizeof(sb->set_uuid)); + crc = crc32c_le(crc, (void *)mb, META_BLOCK_SIZE); + mb->checksum = crc; if (lseek64(fd, (sb->data_offset) * 512, 0) < 0LL) { pr_err("cannot seek to offset of the meta block\n"); |