All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] raid5-cache: use crc32c checksum
@ 2015-10-27 23:48 Shaohua Li
  2015-10-28 15:26 ` Bart Van Assche
  0 siblings, 1 reply; 5+ messages in thread
From: Shaohua Li @ 2015-10-27 23:48 UTC (permalink / raw)
  To: linux-raid; +Cc: Kernel-team, songliubraving, hch, bart.vanassche, neilb

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.

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..e61f4de 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, (void *)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, (void *)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, (void *)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, (void *)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, (void *)rdev->mddev->uuid,
 				      sizeof(rdev->mddev->uuid));
 
 	mutex_init(&log->io_mutex);
-- 
2.4.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] raid5-cache: use crc32c checksum
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2015-10-28 15:26 UTC (permalink / raw)
  To: Shaohua Li, linux-raid; +Cc: Kernel-team, songliubraving, hch, neilb

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 ?

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] raid5-cache: use crc32c checksum
  2015-10-28 15:26 ` Bart Van Assche
@ 2015-10-28 15:41   ` Shaohua Li
  2015-10-28 22:46     ` Bart Van Assche
  0 siblings, 1 reply; 5+ messages in thread
From: Shaohua Li @ 2015-10-28 15:41 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: linux-raid, Kernel-team, songliubraving, hch, neilb

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] raid5-cache: use crc32c checksum
  2015-10-28 15:41   ` Shaohua Li
@ 2015-10-28 22:46     ` Bart Van Assche
  2015-10-30  6:37       ` Neil Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2015-10-28 22:46 UTC (permalink / raw)
  To: Shaohua Li; +Cc: linux-raid, Kernel-team, songliubraving, hch, neilb

On 10/28/2015 08:41 AM, 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.
>
> V2: delete unnecessary type conversion as pointed out by Bart

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] raid5-cache: use crc32c checksum
  2015-10-28 22:46     ` Bart Van Assche
@ 2015-10-30  6:37       ` Neil Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Neil Brown @ 2015-10-30  6:37 UTC (permalink / raw)
  To: Bart Van Assche, Shaohua Li; +Cc: linux-raid, Kernel-team, songliubraving, hch

[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

On Thu, Oct 29 2015, Bart Van Assche wrote:

> On 10/28/2015 08:41 AM, 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.
>>
>> V2: delete unnecessary type conversion as pointed out by Bart
>
> Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>

Thanks.  I've applied the second version and added your reviewed-by.

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-30  6:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2015-10-28 22:46     ` Bart Van Assche
2015-10-30  6:37       ` Neil Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.