aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2018-07-17 00:46:38 +0800
committerColy Li <colyli@suse.de>2018-07-17 00:46:38 +0800
commit06e93482db0f8a282140e9df952330fe950dbaad (patch)
treeb17deeedc35d28d9b38cd1c29091fa4bba0728cf
parentea3bb0c654a08f48a7467b030577e6c15d2e76eb (diff)
downloadbcache-patches-06e93482db0f8a282140e9df952330fe950dbaad.tar.gz
for-test: update crc64 code
-rw-r--r--for-test/libcrc64/0000-cover-letter.patch18
-rw-r--r--for-test/libcrc64/0001-lib-crc64-add-crc64-option-to-lib-Kconfig.patch4
-rw-r--r--for-test/libcrc64/0002-lib-add-crc64-calculation-routines.patch15
-rw-r--r--for-test/libcrc64/0003-bcache-use-routines-from-lib-crc64.c-for-CRC64-calcu.patch23
-rw-r--r--for-test/libcrc64/0004-lib-test_crc-Add-test-cases-for-crc-calculation.patch14
5 files changed, 52 insertions, 22 deletions
diff --git a/for-test/libcrc64/0000-cover-letter.patch b/for-test/libcrc64/0000-cover-letter.patch
index 727989e..c2aba24 100644
--- a/for-test/libcrc64/0000-cover-letter.patch
+++ b/for-test/libcrc64/0000-cover-letter.patch
@@ -7,13 +7,21 @@ This patch set adds basic implementation of crc64 calculation as Linux
kernel library. Since bcache already does crc64 by itself, this patch
set also modifies bcache code to use the new crc64 library routine.
-Because crc64 is used by bcache as storage checksum, inconsistent
-calculation result by future possible change may make bcache 'think' the
-on-disk is corrupted, such future changes should be avoided or detected
-as early as possible. The last patch in this series adds a crc test
-framework, to check consistency of different calculations.
+bcache uses crc64 as storage checksum, if a change of crc lib routines
+results an inconsistent result, the unmatched checksum may make bcache
+'think' the on-disk is corrupted, such change should be avoided or
+detected as early as possible. Therefore the last patch in this series
+adds a crc test framework, to check consistency of different calculations.
Coly Li
+
+Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: Luis R. Rodriguez <mcgrof@suse.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: Michael Lyle <mlyle@lyle.org>
+Cc: Kent Overstreet <kent.overstreet@gmail.com>
---
Andy Shevchenko (1):
lib/crc64: add crc64 option to lib/Kconfig
diff --git a/for-test/libcrc64/0001-lib-crc64-add-crc64-option-to-lib-Kconfig.patch b/for-test/libcrc64/0001-lib-crc64-add-crc64-option-to-lib-Kconfig.patch
index 306f4ca..3eff1bb 100644
--- a/for-test/libcrc64/0001-lib-crc64-add-crc64-option-to-lib-Kconfig.patch
+++ b/for-test/libcrc64/0001-lib-crc64-add-crc64-option-to-lib-Kconfig.patch
@@ -1,4 +1,4 @@
-From a8db527ec7ae6f762e0a8144982d0e8b4725d51d Mon Sep 17 00:00:00 2001
+From 3940d3fc4dbed6e5b56549bb02bdab5a9e8c1a12 Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Wed, 23 May 2018 13:23:32 +0800
Subject: [PATCH 1/4] lib/crc64: add crc64 option to lib/Kconfig
@@ -11,6 +11,8 @@ Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
---
lib/Kconfig | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/for-test/libcrc64/0002-lib-add-crc64-calculation-routines.patch b/for-test/libcrc64/0002-lib-add-crc64-calculation-routines.patch
index 1931d3e..0627c1d 100644
--- a/for-test/libcrc64/0002-lib-add-crc64-calculation-routines.patch
+++ b/for-test/libcrc64/0002-lib-add-crc64-calculation-routines.patch
@@ -1,4 +1,4 @@
-From 31a6632d9e5b428d5f87c41542e6b5a3f27a7d29 Mon Sep 17 00:00:00 2001
+From 5703a85f7485b9e838a59ddf2a5039e126349d80 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Thu, 28 Jun 2018 11:19:24 +0800
Subject: [PATCH 2/4] lib: add crc64 calculation routines
@@ -26,13 +26,15 @@ Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Michael Lyle <mlyle@lyle.org>
Cc: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/crc64.h | 15 +++++++++
lib/.gitignore | 2 ++
lib/Makefile | 11 +++++++
- lib/crc64.c | 71 ++++++++++++++++++++++++++++++++++++++++
- lib/gen_crc64table.c | 76 +++++++++++++++++++++++++++++++++++++++++++
- 5 files changed, 175 insertions(+)
+ lib/crc64.c | 71 +++++++++++++++++++++++++++++++++++++++
+ lib/gen_crc64table.c | 77 +++++++++++++++++++++++++++++++++++++++++++
+ 5 files changed, 176 insertions(+)
create mode 100644 include/linux/crc64.h
create mode 100644 lib/crc64.c
create mode 100644 lib/gen_crc64table.c
@@ -186,10 +188,10 @@ index 000000000000..03f078303bd3
+EXPORT_SYMBOL_GPL(crc64_le_bch);
diff --git a/lib/gen_crc64table.c b/lib/gen_crc64table.c
new file mode 100644
-index 000000000000..d0526813b1db
+index 000000000000..5f292f287498
--- /dev/null
+++ b/lib/gen_crc64table.c
-@@ -0,0 +1,76 @@
+@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Generate lookup table for the talbe-driven CRC64 calculation.
@@ -210,6 +212,7 @@ index 000000000000..d0526813b1db
+#include <inttypes.h>
+#include <linux/swab.h>
+#include <stdio.h>
++#include "../usr/include/asm/byteorder.h"
+
+#define CRC64_ECMA182_POLY 0x42F0E1EBA9EA3693ULL
+
diff --git a/for-test/libcrc64/0003-bcache-use-routines-from-lib-crc64.c-for-CRC64-calcu.patch b/for-test/libcrc64/0003-bcache-use-routines-from-lib-crc64.c-for-CRC64-calcu.patch
index 9fa2f78..9f47a42 100644
--- a/for-test/libcrc64/0003-bcache-use-routines-from-lib-crc64.c-for-CRC64-calcu.patch
+++ b/for-test/libcrc64/0003-bcache-use-routines-from-lib-crc64.c-for-CRC64-calcu.patch
@@ -1,4 +1,4 @@
-From 2a5f4442c9595627c076095c9e48f131624e340c Mon Sep 17 00:00:00 2001
+From 59c2c6880468298a681fadddee1c06c397c0d10a Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Wed, 23 May 2018 16:02:35 +0800
Subject: [PATCH 3/4] bcache: use routines from lib/crc64.c for CRC64
@@ -12,15 +12,30 @@ Signed-off-by: Coly Li <colyli@suse.de>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Michael Lyle <mlyle@lyle.org>
Cc: Kent Overstreet <kent.overstreet@gmail.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
---
+ drivers/md/bcache/Kconfig | 1 +
drivers/md/bcache/bcache.h | 7 +-
drivers/md/bcache/btree.c | 2 +-
drivers/md/bcache/request.c | 2 +-
drivers/md/bcache/super.c | 5 +-
drivers/md/bcache/util.c | 131 ------------------------------------
drivers/md/bcache/util.h | 5 +-
- 6 files changed, 10 insertions(+), 142 deletions(-)
+ 7 files changed, 11 insertions(+), 142 deletions(-)
+diff --git a/drivers/md/bcache/Kconfig b/drivers/md/bcache/Kconfig
+index 17bf109c58e9..af247298409a 100644
+--- a/drivers/md/bcache/Kconfig
++++ b/drivers/md/bcache/Kconfig
+@@ -1,6 +1,7 @@
+
+ config BCACHE
+ tristate "Block device as cache"
++ select CRC64
+ ---help---
+ Allows a block device to be used as cache for other devices; uses
+ a btree for indexing and the layout is optimized for SSDs.
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index d6bf294f3907..3f7934f56648 100644
--- a/drivers/md/bcache/bcache.h
@@ -73,7 +88,7 @@ index ae67f5fa8047..4efe6550df94 100644
}
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
-index fa4058e43202..f45d92c5eca7 100644
+index fa4058e43202..61beb68b9048 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -549,7 +549,7 @@ void bch_prio_write(struct cache *ca)
@@ -90,7 +105,7 @@ index fa4058e43202..f45d92c5eca7 100644
prio_io(ca, bucket, REQ_OP_READ, 0);
- if (p->csum != bch_crc64(&p->magic, bucket_bytes(ca) - 8))
-+ if (p->csum != crc64_le_64(&p->magic,
++ if (p->csum != crc64_le_bch(&p->magic,
+ bucket_bytes(ca) - 8))
pr_warn("bad csum reading priorities");
diff --git a/for-test/libcrc64/0004-lib-test_crc-Add-test-cases-for-crc-calculation.patch b/for-test/libcrc64/0004-lib-test_crc-Add-test-cases-for-crc-calculation.patch
index 4bce45c..f2b4e50 100644
--- a/for-test/libcrc64/0004-lib-test_crc-Add-test-cases-for-crc-calculation.patch
+++ b/for-test/libcrc64/0004-lib-test_crc-Add-test-cases-for-crc-calculation.patch
@@ -1,4 +1,4 @@
-From 1e0422a3f41133120f171bc12d8aafef97660a0d Mon Sep 17 00:00:00 2001
+From a40200bea47aae92003f23d27d4265ed438e8b86 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Wed, 6 Jun 2018 21:20:46 +0800
Subject: [PATCH 4/4] lib/test_crc: Add test cases for crc calculation
@@ -25,6 +25,8 @@ testings. For now, there are only test caes for 3 crc routines,
Signed-off-by: Coly Li <colyli@suse.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
---
lib/Kconfig.debug | 11 ++++
lib/Makefile | 1 +
@@ -68,7 +70,7 @@ index 40c215181687..224d047d026a 100644
CFLAGS_test_kasan.o += -fno-builtin
diff --git a/lib/test_crc.c b/lib/test_crc.c
new file mode 100644
-index 000000000000..e90b5402640c
+index 000000000000..3a9442252de5
--- /dev/null
+++ b/lib/test_crc.c
@@ -0,0 +1,136 @@
@@ -165,21 +167,21 @@ index 000000000000..e90b5402640c
+ .data = { 0x42F0E1EBA9EA3693, 0x85E1C3D753D46D26,
+ 0xC711223CFA3E5BB5, 0x493366450E42ECDF },
+ .initval = 0,
-+ .expval = 0x4e6b1ff972fa8c55,
++ .expval = 0xe2b9911e7b997201,
+ .handler = test_crc64_le,
+ },
+ { .name = "crc64_le_bch",
+ .data = { 0x42F0E1EBA9EA3693, 0x85E1C3D753D46D26,
+ 0xC711223CFA3E5BB5, 0x493366450E42ECDF },
+ .initval = 0,
-+ .expval = 0x0e4f1391d7a4a62e,
++ .expval = 0xd2753a20fd862892,
+ .handler = test_crc64_le_bch,
+ },
+ { .name = "crc64_le_update",
+ .data = { 0x42F0E1EBA9EA3693, 0x85E1C3D753D46D26,
+ 0xC711223CFA3E5BB5, 0x493366450E42ECDF },
+ .initval = 0x61C8864680B583EB,
-+ .expval = 0x03d4d0d85685d9a1,
++ .expval = 0xb2c863673f4292bf,
+ .handler = test_crc64_le_update,
+ },
+ { .name = NULL, }
@@ -194,7 +196,7 @@ index 000000000000..e90b5402640c
+ pr_info("Kernel crc consitency testing:");
+ for (i = 0; test_data[i].name; i++) {
+ v = test_data[i].handler(&test_data[i]);
-+ if (v < 0 && ret != 0)
++ if (v < 0 && ret == 0)
+ ret = -EINVAL;
+ }
+