Commit 5cb2fbd6 authored by Shaohua Li's avatar Shaohua Li Committed by NeilBrown

raid5-cache: use crc32c checksum

crc32c has lower overhead with cpu acceleration. It's a shame I didn't
use it in first post, sorry. This changes disk format, but we are still
ok in current stage.

V2: delete unnecessary type conversion as pointed out by Bart
Signed-off-by: default avatarShaohua Li <shli@fb.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Reviewed-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
parent 355810d1
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/raid/md_p.h> #include <linux/raid/md_p.h>
#include <linux/crc32.h> #include <linux/crc32c.h>
#include <linux/random.h> #include <linux/random.h>
#include "md.h" #include "md.h"
#include "raid5.h" #include "raid5.h"
...@@ -282,7 +282,7 @@ static void r5l_submit_current_io(struct r5l_log *log) ...@@ -282,7 +282,7 @@ static void r5l_submit_current_io(struct r5l_log *log)
block = page_address(io->meta_page); block = page_address(io->meta_page);
block->meta_size = cpu_to_le32(io->meta_offset); block->meta_size = cpu_to_le32(io->meta_offset);
crc = crc32_le(log->uuid_checksum, (void *)block, PAGE_SIZE); crc = crc32c_le(log->uuid_checksum, block, PAGE_SIZE);
block->checksum = cpu_to_le32(crc); block->checksum = cpu_to_le32(crc);
log->current_io = NULL; log->current_io = NULL;
...@@ -484,8 +484,8 @@ int r5l_write_stripe(struct r5l_log *log, struct stripe_head *sh) ...@@ -484,8 +484,8 @@ int r5l_write_stripe(struct r5l_log *log, struct stripe_head *sh)
if (test_bit(STRIPE_LOG_TRAPPED, &sh->state)) if (test_bit(STRIPE_LOG_TRAPPED, &sh->state))
continue; continue;
addr = kmap_atomic(sh->dev[i].page); addr = kmap_atomic(sh->dev[i].page);
sh->dev[i].log_checksum = crc32_le(log->uuid_checksum, sh->dev[i].log_checksum = crc32c_le(log->uuid_checksum,
addr, PAGE_SIZE); addr, PAGE_SIZE);
kunmap_atomic(addr); kunmap_atomic(addr);
} }
parity_pages = 1 + !!(sh->qd_idx >= 0); parity_pages = 1 + !!(sh->qd_idx >= 0);
...@@ -744,7 +744,7 @@ static int r5l_read_meta_block(struct r5l_log *log, ...@@ -744,7 +744,7 @@ static int r5l_read_meta_block(struct r5l_log *log,
le64_to_cpu(mb->position) != ctx->pos) le64_to_cpu(mb->position) != ctx->pos)
return -EINVAL; return -EINVAL;
crc = crc32_le(log->uuid_checksum, (void *)mb, PAGE_SIZE); crc = crc32c_le(log->uuid_checksum, mb, PAGE_SIZE);
if (stored_crc != crc) if (stored_crc != crc)
return -EINVAL; return -EINVAL;
...@@ -819,7 +819,7 @@ static int r5l_recovery_flush_one_stripe(struct r5l_log *log, ...@@ -819,7 +819,7 @@ static int r5l_recovery_flush_one_stripe(struct r5l_log *log,
if (!test_bit(R5_Wantwrite, &sh->dev[disk_index].flags)) if (!test_bit(R5_Wantwrite, &sh->dev[disk_index].flags))
continue; continue;
addr = kmap_atomic(sh->dev[disk_index].page); addr = kmap_atomic(sh->dev[disk_index].page);
checksum = crc32_le(log->uuid_checksum, addr, PAGE_SIZE); checksum = crc32c_le(log->uuid_checksum, addr, PAGE_SIZE);
kunmap_atomic(addr); kunmap_atomic(addr);
if (checksum != sh->dev[disk_index].log_checksum) if (checksum != sh->dev[disk_index].log_checksum)
goto error; goto error;
...@@ -909,7 +909,7 @@ static int r5l_log_write_empty_meta_block(struct r5l_log *log, sector_t pos, ...@@ -909,7 +909,7 @@ static int r5l_log_write_empty_meta_block(struct r5l_log *log, sector_t pos,
mb->meta_size = cpu_to_le32(sizeof(struct r5l_meta_block)); mb->meta_size = cpu_to_le32(sizeof(struct r5l_meta_block));
mb->seq = cpu_to_le64(seq); mb->seq = cpu_to_le64(seq);
mb->position = cpu_to_le64(pos); mb->position = cpu_to_le64(pos);
crc = crc32_le(log->uuid_checksum, (void *)mb, PAGE_SIZE); crc = crc32c_le(log->uuid_checksum, mb, PAGE_SIZE);
mb->checksum = cpu_to_le32(crc); mb->checksum = cpu_to_le32(crc);
if (!sync_page_io(log->rdev, pos, PAGE_SIZE, page, WRITE_FUA, false)) { if (!sync_page_io(log->rdev, pos, PAGE_SIZE, page, WRITE_FUA, false)) {
...@@ -1000,7 +1000,7 @@ static int r5l_load_log(struct r5l_log *log) ...@@ -1000,7 +1000,7 @@ static int r5l_load_log(struct r5l_log *log)
} }
stored_crc = le32_to_cpu(mb->checksum); stored_crc = le32_to_cpu(mb->checksum);
mb->checksum = 0; mb->checksum = 0;
expected_crc = crc32_le(log->uuid_checksum, (void *)mb, PAGE_SIZE); expected_crc = crc32c_le(log->uuid_checksum, mb, PAGE_SIZE);
if (stored_crc != expected_crc) { if (stored_crc != expected_crc) {
create_super = true; create_super = true;
goto create; goto create;
...@@ -1047,8 +1047,8 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev) ...@@ -1047,8 +1047,8 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
return -ENOMEM; return -ENOMEM;
log->rdev = rdev; log->rdev = rdev;
log->uuid_checksum = crc32_le(~0, (void *)rdev->mddev->uuid, log->uuid_checksum = crc32c_le(~0, rdev->mddev->uuid,
sizeof(rdev->mddev->uuid)); sizeof(rdev->mddev->uuid));
mutex_init(&log->io_mutex); mutex_init(&log->io_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment