summaryrefslogtreecommitdiff
path: root/super1.c
diff options
context:
space:
mode:
authorSong Liu <songliubraving@fb.com>2015-10-28 12:06:06 -0700
committerNeilBrown <neilb@suse.com>2015-10-30 17:38:28 +1100
commit198d54787c89872bc72d2824ba3c9d1a783e31ae (patch)
tree520b9cf3de7ce1f067829a756849d9ff965d6c5b /super1.c
parent356e69de7963540465ed584e106175491e2cff9c (diff)
downloadmdadm-198d54787c89872bc72d2824ba3c9d1a783e31ae.tar.gz
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.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/super1.c b/super1.c
index 58e6f9d..1735c2d 100644
--- a/super1.c
+++ b/super1.c
@@ -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");