linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shaohua Li <shli@fb.com>
To: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: linux-raid@vger.kernel.org, Kernel-team@fb.com,
	songliubraving@fb.com, hch@infradead.org, neilb@suse.de
Subject: Re: [PATCH] raid5-cache: use crc32c checksum
Date: Wed, 28 Oct 2015 08:41:25 -0700	[thread overview]
Message-ID: <20151028154124.GA439358@devbig084.prn1.facebook.com> (raw)
In-Reply-To: <5630E942.90501@sandisk.com>

On Wed, Oct 28, 2015 at 08:26:58AM -0700, Bart Van Assche wrote:
> On 10/27/2015 04:48 PM, Shaohua Li wrote:
> >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.
> 
> Hello Shaohua,
> 
> Although this patch looks fine to me I think the (void *) casts in
> the crc32c_le() calls can be left out. Had you considered to include
> that change in this patch ?

Sure, thanks!


From 558985bc46db90762447e0bc9515e2a84272e636 Mon Sep 17 00:00:00 2001
Message-Id: <558985bc46db90762447e0bc9515e2a84272e636.1446046795.git.shli@fb.com>
From: Shaohua Li <shli@fb.com>
Date: Wed, 28 Oct 2015 08:37:27 -0700
Subject: [PATCH] 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: Shaohua Li <shli@fb.com>
---
 drivers/md/raid5-cache.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 0c398ad..e9227e8 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -16,7 +16,7 @@
 #include <linux/blkdev.h>
 #include <linux/slab.h>
 #include <linux/raid/md_p.h>
-#include <linux/crc32.h>
+#include <linux/crc32c.h>
 #include <linux/random.h>
 #include "md.h"
 #include "raid5.h"
@@ -242,7 +242,7 @@ static void r5l_submit_current_io(struct r5l_log *log)
 
 	block = page_address(io->meta_page);
 	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);
 
 	log->current_io = NULL;
@@ -448,7 +448,7 @@ int r5l_write_stripe(struct r5l_log *log, struct stripe_head *sh)
 		if (test_bit(STRIPE_LOG_TRAPPED, &sh->state))
 			continue;
 		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);
 		kunmap_atomic(addr);
 	}
@@ -839,7 +839,7 @@ static int r5l_read_meta_block(struct r5l_log *log,
 	    le64_to_cpu(mb->position) != ctx->pos)
 		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)
 		return -EINVAL;
 
@@ -914,7 +914,7 @@ static int r5l_recovery_flush_one_stripe(struct r5l_log *log,
 		if (!test_bit(R5_Wantwrite, &sh->dev[disk_index].flags))
 			continue;
 		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);
 		if (checksum != sh->dev[disk_index].log_checksum)
 			goto error;
@@ -1004,7 +1004,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->seq = cpu_to_le64(seq);
 	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);
 
 	if (!sync_page_io(log->rdev, pos, PAGE_SIZE, page, WRITE_FUA, false)) {
@@ -1095,7 +1095,7 @@ static int r5l_load_log(struct r5l_log *log)
 	}
 	stored_crc = le32_to_cpu(mb->checksum);
 	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) {
 		create_super = true;
 		goto create;
@@ -1144,7 +1144,7 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
 
 	log->need_cache_flush = (rdev->bdev->bd_disk->queue->flush_flags != 0);
 
-	log->uuid_checksum = crc32_le(~0, (void *)rdev->mddev->uuid,
+	log->uuid_checksum = crc32c_le(~0, rdev->mddev->uuid,
 				      sizeof(rdev->mddev->uuid));
 
 	mutex_init(&log->io_mutex);
-- 
2.4.6


  reply	other threads:[~2015-10-28 15:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-27 23:48 [PATCH] raid5-cache: use crc32c checksum Shaohua Li
2015-10-28 15:26 ` Bart Van Assche
2015-10-28 15:41   ` Shaohua Li [this message]
2015-10-28 22:46     ` Bart Van Assche
2015-10-30  6:37       ` Neil Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151028154124.GA439358@devbig084.prn1.facebook.com \
    --to=shli@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=bart.vanassche@sandisk.com \
    --cc=hch@infradead.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=songliubraving@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).