]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
checksum: Fix incorrect use of __le16/32/64
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Mon, 2 Sep 2019 19:23:13 +0000 (21:23 +0200)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 5 Sep 2019 08:50:04 +0000 (10:50 +0200)
Use ceph_le16/32/64 instead of __le16/32/64 (which are no-op outside
of kernel code).

Note that I've changed the Alg::calc routines to return the
init_value_t type instead of value_t, to avoid having to
introduce explicit byte-swapping calls to init_le16/32/64 in
many places.  (This way, the byte-swapping happens implicitly
at the very end, wher the init_value_t value is assigned via
a value_t pointer.)

Fixes (partially): https://tracker.ceph.com/issues/41605

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
src/common/Checksummer.h

index 2137c1d6609e1c5d787b925d5234b3de707faff4..ceb551bcbf45813a88cfbcfde772939eb42050de 100644 (file)
@@ -5,6 +5,7 @@
 #define CEPH_OS_BLUESTORE_CHECKSUMMER
 
 #include "xxHash/xxhash.h"
+#include "include/byteorder.h"
 
 class Checksummer {
 public:
@@ -69,7 +70,7 @@ public:
 
   struct crc32c {
     typedef uint32_t init_value_t;
-    typedef __le32 value_t;
+    typedef ceph_le32 value_t;
 
     // we have no execution context/state.
     typedef int state_t;
@@ -78,7 +79,7 @@ public:
     static void fini(state_t *state) {
     }
 
-    static value_t calc(
+    static init_value_t calc(
       state_t state,
       init_value_t init_value,
       size_t len,
@@ -90,7 +91,7 @@ public:
 
   struct crc32c_16 {
     typedef uint32_t init_value_t;
-    typedef __le16 value_t;
+    typedef ceph_le16 value_t;
 
     // we have no execution context/state.
     typedef int state_t;
@@ -99,7 +100,7 @@ public:
     static void fini(state_t *state) {
     }
 
-    static value_t calc(
+    static init_value_t calc(
       state_t state,
       init_value_t init_value,
       size_t len,
@@ -120,7 +121,7 @@ public:
     static void fini(state_t *state) {
     }
 
-    static value_t calc(
+    static init_value_t calc(
       state_t state,
       init_value_t init_value,
       size_t len,
@@ -132,7 +133,7 @@ public:
 
   struct xxhash32 {
     typedef uint32_t init_value_t;
-    typedef __le32 value_t;
+    typedef ceph_le32 value_t;
 
     typedef XXH32_state_t *state_t;
     static void init(state_t *s) {
@@ -142,7 +143,7 @@ public:
       XXH32_freeState(*s);
     }
 
-    static value_t calc(
+    static init_value_t calc(
       state_t state,
       init_value_t init_value,
       size_t len,
@@ -161,7 +162,7 @@ public:
 
   struct xxhash64 {
     typedef uint64_t init_value_t;
-    typedef __le64 value_t;
+    typedef ceph_le64 value_t;
 
     typedef XXH64_state_t *state_t;
     static void init(state_t *s) {
@@ -171,7 +172,7 @@ public:
       XXH64_freeState(*s);
     }
 
-    static value_t calc(
+    static init_value_t calc(
       state_t state,
       init_value_t init_value,
       size_t len,
@@ -250,7 +251,7 @@ public:
     pv += offset / csum_block_size;
     size_t pos = offset;
     while (length > 0) {
-      typename Alg::value_t v = Alg::calc(state, -1, csum_block_size, p);
+      typename Alg::init_value_t v = Alg::calc(state, -1, csum_block_size, p);
       if (*pv != v) {
        if (bad_csum) {
          *bad_csum = v;