From 864516e29129cb209435b4cc3ba513a9f453d383 Mon Sep 17 00:00:00 2001 From: "Alexander.Boyko" Date: Fri, 3 Feb 2012 11:20:01 +0400 Subject: [PATCH 1/1] LU-1025 checksum: add final bit inversion for crc32c The linux kernel implementations of crc32c perform final bit inversion after loop calculation of checksum. Signed-off-by: Alexander Boyko Change-Id: I5fa6af60c51f6f86f394f3cc71aa2672be614f7b Reviewed-on: http://review.whamcloud.com/2018 Tested-by: Hudson Reviewed-by: Shuichi Ihara Reviewed-by: Andreas Dilger Tested-by: Maloo --- lustre/include/obd_cksum.h | 7 +++++++ lustre/osc/osc_request.c | 2 +- lustre/ost/ost_handler.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lustre/include/obd_cksum.h b/lustre/include/obd_cksum.h index ef76b66..ddebbba 100644 --- a/lustre/include/obd_cksum.h +++ b/lustre/include/obd_cksum.h @@ -163,6 +163,13 @@ static inline __u32 init_checksum(cksum_type_t cksum_type) return 0; } +static inline __u32 fini_checksum(__u32 cksum, cksum_type_t cksum_type) +{ + if (cksum_type == OBD_CKSUM_CRC32C) + return ~cksum; + return cksum; +} + static inline __u32 compute_checksum(__u32 cksum, unsigned char const *p, size_t len, cksum_type_t cksum_type) { diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 5429b14..a1aaaeb 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -1267,7 +1267,7 @@ static obd_count osc_checksum_bulk(int nob, obd_count pg_count, if (opc == OST_WRITE && OBD_FAIL_CHECK(OBD_FAIL_OSC_CHECKSUM_SEND)) cksum++; - return cksum; + return fini_checksum(cksum, cksum_type); } static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 59ab298..ee41fe4 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -545,7 +545,7 @@ static __u32 ost_checksum_bulk(struct ptlrpc_bulk_desc *desc, int opc, kunmap(page); } - return cksum; + return fini_checksum(cksum, cksum_type); } static int ost_brw_lock_get(int mode, struct obd_export *exp, -- 1.8.3.1