fix crc64 code in for-test
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 4099529..d6dd858 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 de8fd7ef4008863a80d17a384633e7c160c54035 Mon Sep 17 00:00:00 2001
+From 73d4830984a4bf86c1cf8e565a6ac59becc3323b 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
diff --git a/for-test/libcrc64/0002-lib-crc64-add-crc64-entries-into-lib-Makefile.patch b/for-test/libcrc64/0002-lib-crc64-add-crc64-entries-into-lib-Makefile.patch
index f243528..1828975 100644
--- a/for-test/libcrc64/0002-lib-crc64-add-crc64-entries-into-lib-Makefile.patch
+++ b/for-test/libcrc64/0002-lib-crc64-add-crc64-entries-into-lib-Makefile.patch
@@ -1,4 +1,4 @@
-From c04df2708de19f1d809cd337588f110359c68748 Mon Sep 17 00:00:00 2001
+From 475dc0239a72070e69b6658446326bdf712d9a9d Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Wed, 23 May 2018 13:29:54 +0800
Subject: [PATCH 2/4] lib/crc64: add crc64 entries into lib/Makefile
diff --git a/for-test/libcrc64/0003-lib-crc64-add-64bits-CRC-calculation.patch b/for-test/libcrc64/0003-lib-crc64-add-64bits-CRC-calculation.patch
index 99c2b85..b7cec2a 100644
--- a/for-test/libcrc64/0003-lib-crc64-add-64bits-CRC-calculation.patch
+++ b/for-test/libcrc64/0003-lib-crc64-add-64bits-CRC-calculation.patch
@@ -1,4 +1,4 @@
-From cf396110e32ef0f4caa7dc06f79876711453fc94 Mon Sep 17 00:00:00 2001
+From 933315666eadef3824b2c355f07b518b17979827 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Wed, 23 May 2018 15:18:43 +0800
Subject: [PATCH 3/4] lib/crc64: add 64bits CRC calculation
@@ -27,16 +27,17 @@
Cc: Kent Overstreet <kent.overstreet@gmail.com>
---
include/linux/crc64.h | 15 +++++++++
- lib/crc64.c | 70 ++++++++++++++++++++++++++++++++++++++++++
+ lib/.gitignore | 2 ++
+ lib/crc64.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++
lib/gen_crc64table.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 169 insertions(+)
+ 4 files changed, 179 insertions(+)
create mode 100644 include/linux/crc64.h
create mode 100644 lib/crc64.c
create mode 100644 lib/gen_crc64table.c
diff --git a/include/linux/crc64.h b/include/linux/crc64.h
new file mode 100644
-index 000000000000..d626bf95c2f2
+index 000000000000..dd32906c229e
--- /dev/null
+++ b/include/linux/crc64.h
@@ -0,0 +1,15 @@
@@ -53,14 +54,26 @@
+
+__le64 crc64_le_update(__le64 crc, const void *_p, size_t len);
+__le64 crc64_le(const void *p, size_t len);
-+
++__le64 crc64_le_we(const void *p, size_t len);
+#endif /* _LINUX_CRC64_H */
+diff --git a/lib/.gitignore b/lib/.gitignore
+index 09aae85418ab..f2a39c9e5485 100644
+--- a/lib/.gitignore
++++ b/lib/.gitignore
+@@ -2,5 +2,7 @@
+ # Generated files
+ #
+ gen_crc32table
++gen_crc64table
+ crc32table.h
++crc64table.h
+ oid_registry_data.c
diff --git a/lib/crc64.c b/lib/crc64.c
new file mode 100644
-index 000000000000..34d5cd26c1f0
+index 000000000000..8393b2cb17c3
--- /dev/null
+++ b/lib/crc64.c
-@@ -0,0 +1,70 @@
+@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Normal 64bit CRC calculation.
@@ -105,8 +118,6 @@
+MODULE_DESCRIPTION("CRC64 calculations");
+MODULE_LICENSE("GPL");
+
-+#define CRC64_ECMA182_START 0x0000000000000000ULL
-+
+__le64 crc64_le_update(__le64 crc, const void *_p, size_t len)
+{
+ size_t i, t;
@@ -124,13 +135,23 @@
+
+__le64 crc64_le(const void *p, size_t len)
+{
-+ __le64 crc = CRC64_ECMA182_START;
++ __le64 crc = 0x0000000000000000ULL;
+
+ crc = crc64_le_update(crc, p, len);
+
-+ return (crc ^ 0xffffffffffffffffULL);
++ return crc;
+}
+EXPORT_SYMBOL_GPL(crc64_le);
++
++__le64 crc64_le_we(const void *p, size_t len)
++{
++ __le64 crc = 0xFFFFFFFFFFFFFFFFULL;
++
++ crc = crc64_le_update(crc, p, len);
++
++ return (crc ^ 0xFFFFFFFFFFFFFFFFULL);
++}
++EXPORT_SYMBOL_GPL(crc64_le_we);
diff --git a/lib/gen_crc64table.c b/lib/gen_crc64table.c
new file mode 100644
index 000000000000..6cd6cd807b2a
diff --git a/for-test/libcrc64/0004-bcache-use-routines-from-lib-crc64.c-for-CRC64-calcu.patch b/for-test/libcrc64/0004-bcache-use-routines-from-lib-crc64.c-for-CRC64-calcu.patch
index c6ae132..c493e91 100644
--- a/for-test/libcrc64/0004-bcache-use-routines-from-lib-crc64.c-for-CRC64-calcu.patch
+++ b/for-test/libcrc64/0004-bcache-use-routines-from-lib-crc64.c-for-CRC64-calcu.patch
@@ -1,4 +1,4 @@
-From 752df948bc295224d1deda6d0d46802b1881a731 Mon Sep 17 00:00:00 2001
+From 3422438ae433843295dbe85c363f1921a594e51b Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Wed, 23 May 2018 16:02:35 +0800
Subject: [PATCH 4/4] bcache: use routines from lib/crc64.c for CRC64
@@ -12,16 +12,16 @@
Cc: Michael Lyle <mlyle@lyle.org>
Cc: Kent Overstreet <kent.overstreet@gmail.com>
---
- drivers/md/bcache/bcache.h | 3 +-
+ 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, 8 insertions(+), 140 deletions(-)
+ 6 files changed, 10 insertions(+), 142 deletions(-)
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
-index 3a0cfb237af9..39cce593ef18 100644
+index 3a0cfb237af9..edcbd1a0a8db 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -189,6 +189,7 @@
@@ -32,14 +32,18 @@
#include "bset.h"
#include "util.h"
-@@ -801,7 +802,7 @@ static inline bool ptr_available(struct cache_set *c, const struct bkey *k,
+@@ -801,9 +802,9 @@ static inline bool ptr_available(struct cache_set *c, const struct bkey *k,
* jset: The checksum is _always_ the first 8 bytes of these structs
*/
#define csum_set(i) \
- bch_crc64(((void *) (i)) + sizeof(uint64_t), \
-+ crc64_le(((void *) (i)) + sizeof(uint64_t), \
- ((void *) bset_bkey_last(i)) - \
- (((void *) (i)) + sizeof(uint64_t)))
+- ((void *) bset_bkey_last(i)) - \
+- (((void *) (i)) + sizeof(uint64_t)))
++ crc64_le_we(((void *) (i)) + sizeof(uint64_t), \
++ ((void *) bset_bkey_last(i)) - \
++ (((void *) (i)) + sizeof(uint64_t)))
+
+ /* Error handling macros */
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 17936b2dc7d6..7867e65ed686 100644
@@ -68,7 +72,7 @@
}
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
-index 3dea06b41d43..696971ec6091 100644
+index 3dea06b41d43..ead7c7e12862 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -567,7 +567,7 @@ void bch_prio_write(struct cache *ca)
@@ -76,7 +80,7 @@
p->next_bucket = ca->prio_buckets[i + 1];
p->magic = pset_magic(&ca->sb);
- p->csum = bch_crc64(&p->magic, bucket_bytes(ca) - 8);
-+ p->csum = crc64_le(&p->magic, bucket_bytes(ca) - 8);
++ p->csum = crc64_le_we(&p->magic, bucket_bytes(ca) - 8);
bucket = bch_bucket_alloc(ca, RESERVE_PRIO, true);
BUG_ON(bucket == -1);
@@ -85,8 +89,8 @@
prio_io(ca, bucket, REQ_OP_READ, 0);
- if (p->csum != bch_crc64(&p->magic, bucket_bytes(ca) - 8))
-+ if (p->csum != crc64_le(&p->magic,
-+ bucket_bytes(ca) - 8))
++ if (p->csum != crc64_le_64(&p->magic,
++ bucket_bytes(ca) - 8))
pr_warn("bad csum reading priorities");
if (p->magic != pset_magic(&ca->sb))