summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-09-19 15:33:47 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2016-09-19 15:33:47 -0800
commit5cbd071a32b3ae999aec5f73be90046e045c42a6 (patch)
tree6e809ec4f897d69f0a6c516b55a669f393f56687
parent543524b43060f98bc95ca08cb8ef11d91d22e46b (diff)
Revert "bcache: fix 64 bit crc truncation"
This reverts commit 58e239ee3991422245ececa1e4ca541d83da2438. turned out to break crc32c for metadata, too...
-rw-r--r--drivers/md/bcache/checksum.c44
-rw-r--r--drivers/md/bcache/checksum.h2
2 files changed, 9 insertions, 37 deletions
diff --git a/drivers/md/bcache/checksum.c b/drivers/md/bcache/checksum.c
index b618f08e3b63..beae0b26e570 100644
--- a/drivers/md/bcache/checksum.c
+++ b/drivers/md/bcache/checksum.c
@@ -129,34 +129,6 @@ u64 bch_crc64_update(u64 crc, const void *_data, size_t len)
return crc;
}
-static u64 bch_checksum_init(unsigned type)
-{
- switch (type) {
- case BCH_CSUM_NONE:
- return 0;
- case BCH_CSUM_CRC32C:
- return U32_MAX;
- case BCH_CSUM_CRC64:
- return U64_MAX;
- default:
- BUG();
- }
-}
-
-static u64 bch_checksum_final(unsigned type, u64 crc)
-{
- switch (type) {
- case BCH_CSUM_NONE:
- return 0;
- case BCH_CSUM_CRC32C:
- return crc ^ U32_MAX;
- case BCH_CSUM_CRC64:
- return crc ^ U64_MAX;
- default:
- BUG();
- }
-}
-
u64 bch_checksum_update(unsigned type, u64 crc, const void *data, size_t len)
{
switch (type) {
@@ -173,18 +145,18 @@ u64 bch_checksum_update(unsigned type, u64 crc, const void *data, size_t len)
u64 bch_checksum(unsigned type, const void *data, size_t len)
{
- u64 crc = bch_checksum_init(type);
+ u64 crc = 0xffffffffffffffffULL;
crc = bch_checksum_update(type, crc, data, len);
- return bch_checksum_final(type, crc);
+ return crc ^ 0xffffffffffffffffULL;
}
-u64 bch_checksum_bio(struct bio *bio, unsigned type)
+u32 bch_checksum_bio(struct bio *bio, unsigned type)
{
struct bio_vec bv;
struct bvec_iter iter;
- u64 crc = bch_checksum_init(type);
+ u32 csum = U32_MAX;
if (type == BCH_CSUM_NONE)
return 0;
@@ -192,11 +164,11 @@ u64 bch_checksum_bio(struct bio *bio, unsigned type)
bio_for_each_segment(bv, bio, iter) {
void *p = kmap_atomic(bv.bv_page);
- crc = bch_checksum_update(type, crc,
- p + bv.bv_offset,
- bv.bv_len);
+ csum = bch_checksum_update(type, csum,
+ p + bv.bv_offset,
+ bv.bv_len);
kunmap_atomic(p);
}
- return bch_checksum_final(type, crc);
+ return csum ^= U32_MAX;
}
diff --git a/drivers/md/bcache/checksum.h b/drivers/md/bcache/checksum.h
index f84f9884d466..169a24a527a8 100644
--- a/drivers/md/bcache/checksum.h
+++ b/drivers/md/bcache/checksum.h
@@ -5,7 +5,7 @@ u64 bch_crc64_update(uint64_t, const void *, size_t);
u64 bch_checksum_update(unsigned, u64, const void *, size_t);
u64 bch_checksum(unsigned, const void *, size_t);
-u64 bch_checksum_bio(struct bio *, unsigned);
+u32 bch_checksum_bio(struct bio *, unsigned);
/*
* This is used for various on disk data structures - cache_sb, prio_set, bset,