]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/bluestore_types: blob_t csum additions
authorSage Weil <sage@redhat.com>
Tue, 10 May 2016 17:26:30 +0000 (13:26 -0400)
committerSage Weil <sage@redhat.com>
Wed, 1 Jun 2016 15:38:45 +0000 (11:38 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/bluestore_types.h

index 9bffb084c1af22d6477510eb0781549eae21473a..d485a0586ead5b570228515af3068d16a3abcde0 100644 (file)
@@ -230,6 +230,19 @@ struct bluestore_blob_t {
     default: return "???";
     }
   }
+  static int get_csum_string_type(const std::string &s) {
+    if (s == "none")
+      return CSUM_NONE;
+    if (s == "xxhash32")
+      return CSUM_XXHASH32;
+    if (s == "xxhash64")
+      return CSUM_XXHASH64;
+    if (s == "crc32c")
+      return CSUM_CRC32C;
+    if (s == "crc16")
+      return CSUM_CRC16;
+    return -EINVAL;
+  }
 
   vector<bluestore_pextent_t> extents; ///< raw data position on device
   uint32_t length;                 ///< logical (decompressed) length
@@ -335,6 +348,10 @@ struct bluestore_blob_t {
     return len;
   }
 
+  bool has_csum_data() const {
+    return csum_data.size() > 0;
+  }
+
   uint32_t get_csum_block_size() const {
     return 1 << csum_block_order;
   }
@@ -371,6 +388,14 @@ struct bluestore_blob_t {
       assert(0 == "unrecognized csum word size");
     }
   }
+  const char *get_csum_item_ptr(unsigned i) const {
+    size_t cs = get_csum_value_size();
+    return &csum_data[cs * i];
+  }
+  char *get_csum_item_ptr(unsigned i) {
+    size_t cs = get_csum_value_size();
+    return &csum_data[cs * i];
+  }
 
   void init_csum(unsigned type, unsigned order) {
     csum_type = type;