diff options
author | Song Liu <songliubraving@fb.com> | 2016-12-07 18:42:05 +0100 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2016-12-08 19:34:03 +0100 |
commit | 5c88f403a5d2bd75911c6faaacc9bea97ac7d121 (patch) | |
tree | 63a30076fc9664afc1c991dbb72caa3ad73be565 /drivers/md | |
parent | md/raid5-cache: no recovery is required when create super-block (diff) | |
download | linux-5c88f403a5d2bd75911c6faaacc9bea97ac7d121.tar.xz linux-5c88f403a5d2bd75911c6faaacc9bea97ac7d121.zip |
md/raid5-cache: fix crc in rewrite_data_only_stripes()
r5l_recovery_create_empty_meta_block() creates crc for the empty
metablock. After the metablock is updated, we need clear the
checksum before recalculate it.
Shaohua: moved checksum calculation out of
r5l_recovery_create_empty_meta_block. We should calculate it after all fields
are updated.
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/raid5-cache.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c index 7c732c5f87c9..aa990bde1fe2 100644 --- a/drivers/md/raid5-cache.c +++ b/drivers/md/raid5-cache.c @@ -1522,7 +1522,6 @@ r5l_recovery_create_empty_meta_block(struct r5l_log *log, sector_t pos, u64 seq) { struct r5l_meta_block *mb; - u32 crc; mb = page_address(page); clear_page(mb); @@ -1531,19 +1530,21 @@ r5l_recovery_create_empty_meta_block(struct r5l_log *log, mb->meta_size = cpu_to_le32(sizeof(struct r5l_meta_block)); mb->seq = cpu_to_le64(seq); mb->position = cpu_to_le64(pos); - crc = crc32c_le(log->uuid_checksum, mb, PAGE_SIZE); - mb->checksum = cpu_to_le32(crc); } static int r5l_log_write_empty_meta_block(struct r5l_log *log, sector_t pos, u64 seq) { struct page *page; + struct r5l_meta_block *mb; page = alloc_page(GFP_KERNEL); if (!page) return -ENOMEM; r5l_recovery_create_empty_meta_block(log, page, pos, seq); + mb = page_address(page); + mb->checksum = cpu_to_le32(crc32c_le(log->uuid_checksum, + mb, PAGE_SIZE)); if (!sync_page_io(log->rdev, pos, PAGE_SIZE, page, REQ_OP_WRITE, WRITE_FUA, false)) { __free_page(page); @@ -2117,7 +2118,8 @@ r5c_recovery_rewrite_data_only_stripes(struct r5l_log *log, } } mb->meta_size = cpu_to_le32(offset); - mb->checksum = crc32c_le(log->uuid_checksum, mb, PAGE_SIZE); + mb->checksum = cpu_to_le32(crc32c_le(log->uuid_checksum, + mb, PAGE_SIZE)); sync_page_io(log->rdev, ctx->pos, PAGE_SIZE, page, REQ_OP_WRITE, WRITE_FUA, false); sh->log_start = ctx->pos; |