]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: drop old Checksummer
authorSage Weil <sage@redhat.com>
Thu, 19 May 2016 10:55:43 +0000 (06:55 -0400)
committerSage Weil <sage@redhat.com>
Wed, 1 Jun 2016 15:38:51 +0000 (11:38 -0400)
blob_t uses it directly via the static methods.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/bluestore/Checksummer.h [deleted file]

index 2436fcc6616b84f83ef3e765df10599183175075..2470d5ea9f0641be0fa5ea011445c18d63c43db6 100644 (file)
@@ -29,7 +29,6 @@
 #include "FreelistManager.h"
 #include "BlueFS.h"
 #include "BlueRocksEnv.h"
-#include "Checksummer.h"
 #include "compressor/Compressor.h"
 
 #define dout_subsys ceph_subsys_bluestore
@@ -771,7 +770,6 @@ BlueStore::BlueStore(CephContext *cct, const string& path)
     kv_sync_thread(this),
     kv_stop(false),
     logger(NULL),
-    checksummer(new Checksummer),
     csum_type(bluestore_blob_t::CSUM_CRC32C)
 {
   _init_logger();
@@ -784,7 +782,6 @@ BlueStore::~BlueStore()
   assert(db == NULL);
   assert(bluefs == NULL);
   assert(fsid_fd < 0);
-  delete checksummer;
 }
 
 const char **BlueStore::get_tracked_conf_keys() const
index 133247f3e272adc42b28e0bd949934c4aadf9f1f..654cf8eb2e9f1cf160568b8e968f1c7d81f0cfea 100644 (file)
@@ -38,7 +38,6 @@
 class Allocator;
 class FreelistManager;
 class BlueFS;
-class Checksummer;
 
 enum {
   l_bluestore_first = 732430,
@@ -882,7 +881,6 @@ private:
   std::mutex reap_lock;
   list<CollectionRef> removed_collections;
 
-  Checksummer *checksummer;
   int csum_type;
 
   uint64_t block_size;     ///< block size of block device (power of 2)
diff --git a/src/os/bluestore/Checksummer.h b/src/os/bluestore/Checksummer.h
deleted file mode 100644 (file)
index 6ea4e80..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#ifndef CEPH_OS_BLUESTORE_CHECKSUMMER
-#define CEPH_OS_BLUESTORE_CHECKSUMMER
-
-#include "include/buffer.h"
-#include "xxHash/xxhash.h"
-#include "bluestore_types.h"
-
-class Checksummer {
-
-  struct crc32c {
-    typedef __le32 value_t;
-
-    // we have no execution context/state.
-    typedef int state_t;
-    static void init(state_t *state) {
-    }
-    static void fini(state_t *state) {
-    }
-
-    static value_t calc(
-      state_t state,
-      size_t len,
-      bufferlist::const_iterator& p
-      ) {
-      bufferlist t;
-      p.copy(len, t);
-      return t.crc32c(-1);
-    }
-  };
-
-  struct xxhash32 {
-    typedef __le32 value_t;
-
-    typedef XXH32_state_t *state_t;
-    static void init(state_t *s) {
-      *s = XXH32_createState();
-    }
-    static void fini(state_t *s) {
-      XXH32_freeState(*s);
-    }
-
-    static value_t calc(
-      state_t state,
-      size_t len,
-      bufferlist::const_iterator& p
-      ) {
-      XXH32_reset(state, -1);
-      while (len > 0) {
-       const char *data;
-       size_t l = p.get_ptr_and_advance(len, &data);
-       XXH32_update(state, data, l);
-       len -= l;
-      }
-      return XXH32_digest(state);
-    }
-  };
-
-  template<class Alg>
-  int calculate(
-    size_t csum_block_size,
-    size_t offset,
-    size_t length,
-    const bufferlist &bl,
-    vector<char>* csum_data
-    ) {
-    assert(length % csum_block_size == 0);
-    size_t blocks = length / csum_block_size;
-    bufferlist::const_iterator p = bl.begin();
-    assert(bl.length() >= length);
-
-    typename Alg::state_t state;
-    Alg::init(&state);
-
-    assert(csum_data->size() >= (offset + length) / csum_block_size *
-          sizeof(typename Alg::value_t));
-
-    typename Alg::value_t *pv =
-      reinterpret_cast<typename Alg::value_t*>(&(*csum_data)[0]);
-    pv += offset / csum_block_size;
-    while (blocks--) {
-      *pv = Alg::calc(state, csum_block_size, p);
-      ++pv;
-    }
-    Alg::fini(&state);
-    return 0;
-  }
-
-  template<class Alg>
-  int verify(
-    size_t csum_block_size,
-    size_t offset,
-    size_t length,
-    const bufferlist &bl,
-    const vector<char>& csum_data
-    ) {
-    assert(length % csum_block_size == 0);
-    bufferlist::const_iterator p = bl.begin();
-    assert(bl.length() >= length);
-
-    typename Alg::state_t state;
-    Alg::init(&state);
-
-    const typename Alg::value_t *pv =
-      reinterpret_cast<const typename Alg::value_t*>(&csum_data[0]);
-    pv += offset / csum_block_size;
-    size_t pos = offset;
-    while (length > 0) {
-      typename Alg::value_t v = Alg::calc(state, csum_block_size, p);
-      if (*pv != v) {
-       return pos;
-      }
-      ++pv;
-      pos += csum_block_size;
-      length -= csum_block_size;
-    }
-    Alg::fini(&state);
-    return -1;  // no errors
-  }
-
-public:
-  int calculate(
-    unsigned type,  // bluestore_blob_t::CSumType
-    size_t csum_block_size,
-    size_t offset,
-    size_t length,
-    const bufferlist &bl,
-    vector<char>* csum_data
-    ) {
-    switch (type) {
-    case bluestore_blob_t::CSUM_NONE:
-      return 0;
-    case bluestore_blob_t::CSUM_XXHASH32:
-      return calculate<xxhash32>(csum_block_size, offset, length, bl, csum_data);
-    case bluestore_blob_t::CSUM_CRC32C:
-      return calculate<crc32c>(csum_block_size, offset, length, bl, csum_data);
-    default:
-      return -EOPNOTSUPP;
-    }
-  }
-  int verify(
-    unsigned type,  // bluestore_blob_t::CSumType
-    size_t csum_block_size,
-    size_t offset,
-    size_t length,
-    const bufferlist &bl,
-    const vector<char>& csum_data
-    ) {
-    switch (type) {
-    case bluestore_blob_t::CSUM_NONE:
-      return 0;
-    case bluestore_blob_t::CSUM_XXHASH32:
-      return verify<xxhash32>(csum_block_size, offset, length, bl, csum_data);
-    case bluestore_blob_t::CSUM_CRC32C:
-      return verify<crc32c>(csum_block_size, offset, length, bl, csum_data);
-    default:
-      return -EOPNOTSUPP;
-    }
-  }
-
-};
-
-#endif