Whamcloud - gitweb
LU-1025 checksum: add final bit inversion for crc32c
authorAlexander.Boyko <alexander_boyko@xyratex.com>
Fri, 3 Feb 2012 07:20:01 +0000 (11:20 +0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 8 Feb 2012 16:30:05 +0000 (11:30 -0500)
The linux kernel implementations of crc32c perform final bit
inversion after loop calculation of checksum.

Signed-off-by: Alexander Boyko <alexander_boyko@xyratex.com>
Change-Id: I5fa6af60c51f6f86f394f3cc71aa2672be614f7b
Reviewed-on: http://review.whamcloud.com/2018
Tested-by: Hudson
Reviewed-by: Shuichi Ihara <sihara@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/include/obd_cksum.h
lustre/osc/osc_request.c
lustre/ost/ost_handler.c

index ef76b66..ddebbba 100644 (file)
@@ -163,6 +163,13 @@ static inline __u32 init_checksum(cksum_type_t cksum_type)
         return 0;
 }
 
         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)
 {
 static inline __u32 compute_checksum(__u32 cksum, unsigned char const *p,
                                      size_t len, cksum_type_t cksum_type)
 {
index 5429b14..a1aaaeb 100644 (file)
@@ -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++;
 
         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,
 }
 
 static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa,
index 59ab298..ee41fe4 100644 (file)
@@ -545,7 +545,7 @@ static __u32 ost_checksum_bulk(struct ptlrpc_bulk_desc *desc, int opc,
                 kunmap(page);
         }
 
                 kunmap(page);
         }
 
-        return cksum;
+        return fini_checksum(cksum, cksum_type);
 }
 
 static int ost_brw_lock_get(int mode, struct obd_export *exp,
 }
 
 static int ost_brw_lock_get(int mode, struct obd_export *exp,