From: Igor Fedotov Date: Mon, 1 Aug 2016 11:32:50 +0000 (+0300) Subject: os/bluestore: share compression/csum enums and corresponding stuff for common use X-Git-Tag: v11.1.0~539^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=24dff2b6b09dc8860f4c87cb5da85bbbf7c74064;p=ceph.git os/bluestore: share compression/csum enums and corresponding stuff for common use Signed-off-by: Igor Fedotov --- diff --git a/src/common/Checksummer.h b/src/common/Checksummer.h index 6ddbf1d12dee..09280f929d97 100644 --- a/src/common/Checksummer.h +++ b/src/common/Checksummer.h @@ -9,6 +9,53 @@ class Checksummer { public: + enum CSumType { + CSUM_NONE = 1, //intentionally set to 1 to be aligned with OSDMnitor's pool_opts_t handling - it treats 0 as unset while we need to distinguish none and unset cases + CSUM_XXHASH32 = 2, + CSUM_XXHASH64 = 3, + CSUM_CRC32C = 4, + CSUM_CRC32C_16 = 5, // low 16 bits of crc32c + CSUM_CRC32C_8 = 6, // low 8 bits of crc32c + CSUM_MAX, + }; + static const char *get_csum_type_string(unsigned t) { + switch (t) { + case CSUM_NONE: return "none"; + case CSUM_XXHASH32: return "xxhash32"; + case CSUM_XXHASH64: return "xxhash64"; + case CSUM_CRC32C: return "crc32c"; + case CSUM_CRC32C_16: return "crc32c_16"; + case CSUM_CRC32C_8: return "crc32c_8"; + 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 == "crc32c_16") + return CSUM_CRC32C_16; + if (s == "crc32c_8") + return CSUM_CRC32C_8; + return -EINVAL; + } + static size_t get_csum_value_size(int csum_type) { + switch (csum_type) { + case CSUM_NONE: return 0; + case CSUM_XXHASH32: return 4; + case CSUM_XXHASH64: return 8; + case CSUM_CRC32C: return 4; + case CSUM_CRC32C_16: return 2; + case CSUM_CRC32C_8: return 1; + default: return 0; + } + } + struct crc32c { typedef __le32 value_t; diff --git a/src/compressor/CompressionPlugin.h b/src/compressor/CompressionPlugin.h index be1f6b83a8ba..299840aa3ffc 100644 --- a/src/compressor/CompressionPlugin.h +++ b/src/compressor/CompressionPlugin.h @@ -18,6 +18,7 @@ #ifndef COMPRESSION_PLUGIN_H #define COMPRESSION_PLUGIN_H +#include #include "common/Mutex.h" #include "common/PluginRegistry.h" #include "Compressor.h" @@ -35,7 +36,7 @@ namespace ceph { virtual ~CompressionPlugin() {} virtual int factory(CompressorRef *cs, - ostream *ss) = 0; + std::ostream *ss) = 0; virtual const char* name() {return "CompressionPlugin";} }; diff --git a/src/compressor/Compressor.cc b/src/compressor/Compressor.cc index 2ef817c57cbd..46fddd9670c1 100644 --- a/src/compressor/Compressor.cc +++ b/src/compressor/Compressor.cc @@ -14,12 +14,53 @@ #include "Compressor.h" #include "CompressionPlugin.h" +#include "common/dout.h" +const char * Compressor::get_comp_alg_name(int a) { + switch (a) { + case COMP_ALG_NONE: return "none"; + case COMP_ALG_SNAPPY: return "snappy"; + case COMP_ALG_ZLIB: return "zlib"; + default: return "???"; + } +} -CompressorRef Compressor::create(CephContext *cct, const string &type) +boost::optional Compressor::get_comp_alg_type(const std::string &s) { + if (s == "snappy") + return COMP_ALG_SNAPPY; + if (s == "zlib") + return COMP_ALG_ZLIB; + if (s == "") + return COMP_ALG_NONE; + + return boost::optional(); +} + +const char *Compressor::get_comp_mode_name(int m) { + switch (m) { + case COMP_NONE: return "none"; + case COMP_PASSIVE: return "passive"; + case COMP_AGGRESSIVE: return "aggressive"; + case COMP_FORCE: return "force"; + default: return "???"; + } +} +boost::optional Compressor::get_comp_mode_type(const std::string &s) { + if (s == "force") + return COMP_FORCE; + if (s == "aggressive") + return COMP_AGGRESSIVE; + if (s == "passive") + return COMP_PASSIVE; + if (s == "none") + return COMP_NONE; + return boost::optional(); +} + +CompressorRef Compressor::create(CephContext *cct, const std::string &type) { CompressorRef cs_impl = NULL; - stringstream ss; + std::stringstream ss; PluginRegistry *reg = cct->get_plugin_registry(); CompressionPlugin *factory = dynamic_cast(reg->get_with_load("compressor", type)); if (factory == NULL) { @@ -31,3 +72,13 @@ CompressorRef Compressor::create(CephContext *cct, const string &type) lderr(cct) << __func__ << " factory return error " << err << dendl; return cs_impl; } + +CompressorRef Compressor::create(CephContext *cct, int alg) +{ + if (alg < 0 || alg >= COMP_ALG_LAST) { + lderr(cct) << __func__ << " invalid algorithm value:" << alg << dendl; + return CompressorRef(); + } + std::string type_name = get_comp_alg_name(alg); + return create(cct, type_name); +} diff --git a/src/compressor/Compressor.h b/src/compressor/Compressor.h index a9f91038938b..89687f2ddc99 100644 --- a/src/compressor/Compressor.h +++ b/src/compressor/Compressor.h @@ -15,28 +15,58 @@ #ifndef CEPH_COMPRESSOR_H #define CEPH_COMPRESSOR_H -#include "include/int_types.h" -#include "include/Context.h" +#include +#include +#include "include/memory.h" +#include "include/buffer.h" class Compressor; typedef shared_ptr CompressorRef; class Compressor { -protected: - string type; public: - Compressor(string t) : type(t) {} + enum CompressionAlgorithm { + COMP_ALG_NONE = 0, + COMP_ALG_SNAPPY = 1, + COMP_ALG_ZLIB = 2, + COMP_ALG_LAST //the last value for range checks + }; + // compression options + enum CompressionMode { + COMP_NONE, ///< compress never + COMP_PASSIVE, ///< compress if hinted COMPRESSIBLE + COMP_AGGRESSIVE, ///< compress unless hinted INCOMPRESSIBLE + COMP_FORCE ///< compress always + }; + + static const char * get_comp_alg_name(int a); + static boost::optional get_comp_alg_type(const std::string &s); + + static const char *get_comp_mode_name(int m); + static boost::optional get_comp_mode_type(const std::string &s); + + Compressor(CompressionAlgorithm a, const char* t) : alg(a), type(t) { + } virtual ~Compressor() {} - const string& get_type() const { + const std::string& get_type_name() const { return type; } + CompressionAlgorithm get_type() const { + return alg; + } virtual int compress(const bufferlist &in, bufferlist &out) = 0; virtual int decompress(const bufferlist &in, bufferlist &out) = 0; // this is a bit weird but we need non-const iterator to be in // alignment with decode methods virtual int decompress(bufferlist::iterator &p, size_t compressed_len, bufferlist &out) = 0; - static CompressorRef create(CephContext *cct, const string &type); + static CompressorRef create(CephContext *cct, const std::string &type); + static CompressorRef create(CephContext *cct, int alg); + +protected: + CompressionAlgorithm alg; + std::string type; + }; #endif diff --git a/src/compressor/snappy/CompressionPluginSnappy.cc b/src/compressor/snappy/CompressionPluginSnappy.cc index d0780f38d31b..e53444aa04af 100644 --- a/src/compressor/snappy/CompressionPluginSnappy.cc +++ b/src/compressor/snappy/CompressionPluginSnappy.cc @@ -27,7 +27,7 @@ public: {} virtual int factory(CompressorRef *cs, - ostream *ss) + std::ostream *ss) { if (compressor == 0) { SnappyCompressor *interface = new SnappyCompressor(); diff --git a/src/compressor/snappy/SnappyCompressor.h b/src/compressor/snappy/SnappyCompressor.h index f842fc9c526a..dadd17902b8b 100644 --- a/src/compressor/snappy/SnappyCompressor.h +++ b/src/compressor/snappy/SnappyCompressor.h @@ -56,7 +56,7 @@ class CEPH_BUFFER_API BufferlistSource : public snappy::Source { class SnappyCompressor : public Compressor { public: - SnappyCompressor() : Compressor("snappy") {} + SnappyCompressor() : Compressor(COMP_ALG_SNAPPY, "snappy") {} int compress(const bufferlist &src, bufferlist &dst) override { BufferlistSource source(const_cast(src).begin(), src.length()); diff --git a/src/compressor/zlib/CompressionPluginZlib.cc b/src/compressor/zlib/CompressionPluginZlib.cc index d0e90eca1976..7146bf9dca96 100644 --- a/src/compressor/zlib/CompressionPluginZlib.cc +++ b/src/compressor/zlib/CompressionPluginZlib.cc @@ -33,7 +33,7 @@ public: {} virtual int factory(CompressorRef *cs, - ostream *ss) + std::ostream *ss) { bool isal; if (cct->_conf->compressor_zlib_isal) { diff --git a/src/compressor/zlib/ZlibCompressor.h b/src/compressor/zlib/ZlibCompressor.h index c6ef12c82ba8..35f9df3ef156 100644 --- a/src/compressor/zlib/ZlibCompressor.h +++ b/src/compressor/zlib/ZlibCompressor.h @@ -22,7 +22,7 @@ class ZlibCompressor : public Compressor { bool isal_enabled; public: - ZlibCompressor(bool isal) : Compressor("zlib"), isal_enabled(isal) {} + ZlibCompressor(bool isal) : Compressor(COMP_ALG_ZLIB, "zlib"), isal_enabled(isal) {} int compress(const bufferlist &in, bufferlist &out) override; int decompress(const bufferlist &in, bufferlist &out) override; diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index e1fd1f8b3211..91576a754d7d 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -2475,7 +2475,7 @@ BlueStore::BlueStore(CephContext *cct, const string& path) kv_stop(false), logger(NULL), debug_read_error_lock("BlueStore::debug_read_error_lock"), - csum_type(bluestore_blob_t::CSUM_CRC32C), + csum_type(Checksummer::CSUM_CRC32C), sync_wal_apply(cct->_conf->bluestore_sync_wal_apply) { _init_logger(); @@ -2546,67 +2546,47 @@ void BlueStore::_set_compression() comp_min_blob_size = g_conf->bluestore_compression_min_blob_size; comp_max_blob_size = g_conf->bluestore_compression_max_blob_size; - if (g_conf->bluestore_compression == "force") { - comp_mode = COMP_FORCE; - } else if (g_conf->bluestore_compression == "aggressive") { - comp_mode = COMP_AGGRESSIVE; - } else if (g_conf->bluestore_compression == "passive") { - comp_mode = COMP_PASSIVE; - } else if (g_conf->bluestore_compression == "none") { - comp_mode = COMP_NONE; + auto m = Compressor::get_comp_mode_type(g_conf->bluestore_compression); + if (m) { + comp_mode = *m; } else { derr << __func__ << " unrecognized value '" << g_conf->bluestore_compression << "' for bluestore_compression, reverting to 'none'" << dendl; - comp_mode = COMP_NONE; + comp_mode = Compressor::COMP_NONE; } compressor = nullptr; - if (comp_mode.load() != COMP_NONE) { - const char *alg = 0; - if (g_conf->bluestore_compression_algorithm == "snappy") { - alg = "snappy"; - } else if (g_conf->bluestore_compression_algorithm == "zlib") { - alg = "zlib"; - } else if (g_conf->bluestore_compression_algorithm.length()) { - derr << __func__ << " unrecognized compression algorithm '" - << g_conf->bluestore_compression_algorithm << "'" - << ", reverting compression mode to 'none'" - << dendl; - comp_mode = COMP_NONE; - } else { - derr << __func__ << " compression algorithm not specified, " - << "reverting compression mode to 'none'" - << dendl; - comp_mode = COMP_NONE; - } + if (comp_mode.load() != Compressor::COMP_NONE) { + + auto& alg_name = g_conf->bluestore_compression_algorithm; - if (alg) { - compressor = Compressor::create(cct, alg); + if (!alg_name.empty()) { + compressor = Compressor::create(cct, alg_name); if (!compressor) { - derr << __func__ << " unable to initialize " << alg << " compressor" + derr << __func__ << " unable to initialize " << alg_name << " compressor" << ", reverting compression mode to 'none'" << dendl; - comp_mode = COMP_NONE; + comp_mode = Compressor::COMP_NONE; } } } - dout(10) << __func__ << " mode " << get_comp_mode_name(comp_mode) - << " alg " << (compressor ? compressor->get_type() : "(none)") + dout(10) << __func__ << " mode " << Compressor::get_comp_mode_name(comp_mode) + << " alg " << (compressor ? compressor->get_type_name() : "(none)") << dendl; } void BlueStore::_set_csum() { - csum_type = bluestore_blob_t::CSUM_NONE; - int t = bluestore_blob_t::get_csum_string_type(g_conf->bluestore_csum_type); - if (t > bluestore_blob_t::CSUM_NONE) + csum_type = Checksummer::CSUM_NONE; + int t = Checksummer::get_csum_string_type(g_conf->bluestore_csum_type); + if (t > Checksummer::CSUM_NONE) csum_type = t; dout(10) << __func__ << " csum_type " - << bluestore_blob_t::get_csum_type_string(csum_type) + << Checksummer::get_csum_type_string(csum_type) << dendl; } @@ -5168,7 +5148,7 @@ int BlueStore::_verify_csum(OnodeRef& o, return 0; }); assert(r == 0); - derr << __func__ << " bad " << blob->get_csum_type_string(blob->csum_type) + derr << __func__ << " bad " << Checksummer::get_csum_type_string(blob->csum_type) << "/0x" << std::hex << blob->get_csum_chunk_size() << " checksum at blob offset 0x" << bad << ", got 0x" << bad_csum << ", expected 0x" @@ -5190,15 +5170,16 @@ int BlueStore::_decompress(bufferlist& source, bufferlist* result) bufferlist::iterator i = source.begin(); bluestore_compression_header_t chdr; ::decode(chdr, i); - string name = bluestore_blob_t::get_comp_alg_name(chdr.type); + int alg = int(chdr.type); CompressorRef cp = compressor; - if (!cp || cp->get_type() != name) - cp = Compressor::create(cct, name); + if (!cp || (int)cp->get_type() != alg) { + cp = Compressor::create(cct, alg); + } if (!cp.get()) { // if compressor isn't available - error, because cannot return // decompressed data? - derr << __func__ << " can't load decompressor " << (int)chdr.type << dendl; + derr << __func__ << " can't load decompressor " << alg << dendl; r = -EIO; } else { r = cp->decompress(i, chdr.length, *result); @@ -7611,7 +7592,7 @@ int BlueStore::_do_alloc_write( assert(b_off == 0); assert(wi.blob_length == l->length()); bluestore_compression_header_t chdr; - chdr.type = bluestore_blob_t::get_comp_alg_type(c->get_type()); + chdr.type = c->get_type(); // FIXME: memory alignment here is bad bufferlist t; @@ -7880,10 +7861,10 @@ int BlueStore::_do_write( unsigned alloc_hints = o->onode.alloc_hint_flags; int comp = comp_mode.load(); wctx.compress = - (comp == COMP_FORCE) || - (comp == COMP_AGGRESSIVE && + (comp == Compressor::COMP_FORCE) || + (comp == Compressor::COMP_AGGRESSIVE && (alloc_hints & CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE) == 0) || - (comp == COMP_PASSIVE && + (comp == Compressor::COMP_PASSIVE && (alloc_hints & CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE)); if ((alloc_hints & CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_READ) && diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 39ddef7a7124..acdb8e17b91b 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1466,23 +1466,7 @@ private: bool sync_wal_apply; ///< see config option bluestore_sync_wal_apply - // compression options - enum CompressionMode { - COMP_NONE, ///< compress never - COMP_PASSIVE, ///< compress if hinted COMPRESSIBLE - COMP_AGGRESSIVE, ///< compress unless hinted INCOMPRESSIBLE - COMP_FORCE ///< compress always - }; - const char *get_comp_mode_name(int m) { - switch (m) { - case COMP_NONE: return "none"; - case COMP_PASSIVE: return "passive"; - case COMP_AGGRESSIVE: return "aggressive"; - case COMP_FORCE: return "force"; - default: return "???"; - } - } - std::atomic comp_mode = {COMP_NONE}; ///< compression mode + std::atomic comp_mode = {Compressor::COMP_NONE}; ///< compression mode CompressorRef compressor; std::atomic comp_min_blob_size = {0}; std::atomic comp_max_blob_size = {0}; diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index c7be9a2f5f7c..f24a94fd6b11 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -388,6 +388,11 @@ string bluestore_blob_t::get_flags_string(unsigned flags) return s; } +size_t bluestore_blob_t::get_csum_value_size() const +{ + return Checksummer::get_csum_value_size(csum_type); +} + void bluestore_blob_t::dump(Formatter *f) const { f->open_array_section("extents"); @@ -416,7 +421,7 @@ void bluestore_blob_t::generate_test_instances(list& ls) ls.push_back(new bluestore_blob_t); ls.back()->extents.push_back(bluestore_pextent_t(111, 222)); ls.push_back(new bluestore_blob_t); - ls.back()->init_csum(CSUM_XXHASH32, 16, 65536); + ls.back()->init_csum(Checksummer::CSUM_XXHASH32, 16, 65536); ls.back()->csum_data = buffer::claim_malloc(4, strdup("abcd")); ls.back()->add_unused(0, 3); ls.back()->add_unused(8, 8); @@ -443,7 +448,7 @@ ostream& operator<<(ostream& out, const bluestore_blob_t& o) out << " " << o.get_flags_string(); } if (o.csum_type) { - out << " " << o.get_csum_type_string(o.csum_type) + out << " " << Checksummer::get_csum_type_string(o.csum_type) << "/0x" << std::hex << (1ull << o.csum_chunk_order) << std::dec; } if (o.has_unused()) @@ -455,23 +460,23 @@ ostream& operator<<(ostream& out, const bluestore_blob_t& o) void bluestore_blob_t::calc_csum(uint64_t b_off, const bufferlist& bl) { switch (csum_type) { - case CSUM_XXHASH32: + case Checksummer::CSUM_XXHASH32: Checksummer::calculate( get_csum_chunk_size(), b_off, bl.length(), bl, &csum_data); break; - case CSUM_XXHASH64: + case Checksummer::CSUM_XXHASH64: Checksummer::calculate( get_csum_chunk_size(), b_off, bl.length(), bl, &csum_data); break;; - case CSUM_CRC32C: + case Checksummer::CSUM_CRC32C: Checksummer::calculate( get_csum_chunk_size(), b_off, bl.length(), bl, &csum_data); break; - case CSUM_CRC32C_16: + case Checksummer::CSUM_CRC32C_16: Checksummer::calculate( get_csum_chunk_size(), b_off, bl.length(), bl, &csum_data); break; - case CSUM_CRC32C_8: + case Checksummer::CSUM_CRC32C_8: Checksummer::calculate( get_csum_chunk_size(), b_off, bl.length(), bl, &csum_data); break; @@ -485,25 +490,25 @@ int bluestore_blob_t::verify_csum(uint64_t b_off, const bufferlist& bl, *b_bad_off = -1; switch (csum_type) { - case CSUM_NONE: + case Checksummer::CSUM_NONE: break; - case CSUM_XXHASH32: + case Checksummer::CSUM_XXHASH32: *b_bad_off = Checksummer::verify( get_csum_chunk_size(), b_off, bl.length(), bl, csum_data, bad_csum); break; - case CSUM_XXHASH64: + case Checksummer::CSUM_XXHASH64: *b_bad_off = Checksummer::verify( get_csum_chunk_size(), b_off, bl.length(), bl, csum_data, bad_csum); break; - case CSUM_CRC32C: + case Checksummer::CSUM_CRC32C: *b_bad_off = Checksummer::verify( get_csum_chunk_size(), b_off, bl.length(), bl, csum_data, bad_csum); break; - case CSUM_CRC32C_16: + case Checksummer::CSUM_CRC32C_16: *b_bad_off = Checksummer::verify( get_csum_chunk_size(), b_off, bl.length(), bl, csum_data, bad_csum); break; - case CSUM_CRC32C_8: + case Checksummer::CSUM_CRC32C_8: *b_bad_off = Checksummer::verify( get_csum_chunk_size(), b_off, bl.length(), bl, csum_data, bad_csum); break; diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index e1babc66ba44..470dcd0e0b68 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -22,6 +22,8 @@ #include "include/utime.h" #include "include/small_encoding.h" #include "common/hobject.h" +#include "compressor/Compressor.h" +#include "common/Checksummer.h" namespace ceph { class Formatter; @@ -273,76 +275,13 @@ struct bluestore_blob_t { }; static string get_flags_string(unsigned flags); - enum CSumType { - CSUM_NONE = 0, - CSUM_XXHASH32 = 1, - CSUM_XXHASH64 = 2, - CSUM_CRC32C = 3, - CSUM_CRC32C_16 = 4, // low 16 bits of crc32c - CSUM_CRC32C_8 = 5, // low 8 bits of crc32c - CSUM_MAX, - }; - static const char *get_csum_type_string(unsigned t) { - switch (t) { - case CSUM_NONE: return "none"; - case CSUM_XXHASH32: return "xxhash32"; - case CSUM_XXHASH64: return "xxhash64"; - case CSUM_CRC32C: return "crc32c"; - case CSUM_CRC32C_16: return "crc32c_16"; - case CSUM_CRC32C_8: return "crc32c_8"; - 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 == "crc32c_16") - return CSUM_CRC32C_16; - if (s == "crc32c_8") - return CSUM_CRC32C_8; - return -EINVAL; - } - - enum CompressionAlgorithm { - COMP_ALG_NONE = 0, - COMP_ALG_SNAPPY = 1, - COMP_ALG_ZLIB = 2, - }; - - static const char * get_comp_alg_name(int a) { - switch (a) { - case COMP_ALG_NONE: return "none"; - case COMP_ALG_SNAPPY: return "snappy"; - case COMP_ALG_ZLIB: return "zlib"; - default: return "???"; - } - } - - static int get_comp_alg_type(const std::string &s) { - if (s == "none") - return COMP_ALG_NONE; - if (s == "snappy") - return COMP_ALG_SNAPPY; - if (s == "zlib") - return COMP_ALG_ZLIB; - - assert(0 == "invalid compression algorithm"); - return COMP_ALG_NONE; - } - vector extents;///< raw data position on device uint64_t sbid = 0; ///< shared blob id (if shared) uint32_t compressed_length_orig = 0;///< original length of compressed blob if any uint32_t compressed_length = 0; ///< compressed length if any uint32_t flags = 0; ///< FLAG_* - uint8_t csum_type = CSUM_NONE; ///< CSUM_* + uint8_t csum_type = Checksummer::CSUM_NONE; ///< CSUM_* uint8_t csum_chunk_order = 0; ///< csum block size is 1<(end - start); double mbsec = (double)count * (double)bl.length() / 1000000.0 / (double)dur.count() * 1000000000.0; - cout << "csum_type " << bluestore_blob_t::get_csum_type_string(csum_type) + cout << "csum_type " << Checksummer::get_csum_type_string(csum_type) << ", " << dur << " seconds, " << mbsec << " MB/sec" << std::endl; } @@ -682,7 +682,7 @@ TEST(Blob, put_ref) bluestore_blob_t& b = B.dirty_blob(); vector r; b.extents.push_back(bluestore_pextent_t(0, mas*4)); - b.init_csum(bluestore_blob_t::CSUM_CRC32C, 14, mas * 4); + b.init_csum(Checksummer::CSUM_CRC32C, 14, mas * 4); B.get_ref(0, mas*4); ASSERT_TRUE(b.is_allocated(0, mas*4)); B.put_ref(0, mas*3, mrs, &r); @@ -715,7 +715,7 @@ TEST(bluestore_blob_t, can_split_at) a.extents.emplace_back(bluestore_pextent_t(0x20000, 0x2000)); ASSERT_TRUE(a.can_split_at(0x1000)); ASSERT_TRUE(a.can_split_at(0x1800)); - a.init_csum(bluestore_blob_t::CSUM_CRC32C, 12, 0x4000); + a.init_csum(Checksummer::CSUM_CRC32C, 12, 0x4000); ASSERT_TRUE(a.can_split_at(0x1000)); ASSERT_TRUE(a.can_split_at(0x2000)); ASSERT_TRUE(a.can_split_at(0x3000)); @@ -739,7 +739,7 @@ TEST(bluestore_blob_t, prune_tail) a.extents.emplace_back( bluestore_pextent_t(bluestore_pextent_t::INVALID_OFFSET, 0x2000)); - a.init_csum(bluestore_blob_t::CSUM_CRC32C_8, 12, 0x6000); + a.init_csum(Checksummer::CSUM_CRC32C_8, 12, 0x6000); ASSERT_EQ(6u, a.csum_data.length()); ASSERT_TRUE(a.can_prune_tail()); a.prune_tail(); @@ -764,7 +764,7 @@ TEST(Blob, split) R.shared_blob = new BlueStore::SharedBlob(-1, string(), cache); R.shared_blob->get(); // hack to avoid dtor from running L.dirty_blob().extents.emplace_back(bluestore_pextent_t(0x2000, 0x2000)); - L.dirty_blob().init_csum(bluestore_blob_t::CSUM_CRC32C, 12, 0x2000); + L.dirty_blob().init_csum(Checksummer::CSUM_CRC32C, 12, 0x2000); L.split(0x1000, &R); ASSERT_EQ(0x1000u, L.get_blob().get_logical_length()); ASSERT_EQ(4u, L.get_blob().csum_data.length()); @@ -785,7 +785,7 @@ TEST(Blob, split) R.shared_blob->get(); // hack to avoid dtor from running L.dirty_blob().extents.emplace_back(bluestore_pextent_t(0x2000, 0x1000)); L.dirty_blob().extents.emplace_back(bluestore_pextent_t(0x12000, 0x1000)); - L.dirty_blob().init_csum(bluestore_blob_t::CSUM_CRC32C, 12, 0x2000); + L.dirty_blob().init_csum(Checksummer::CSUM_CRC32C, 12, 0x2000); L.split(0x1000, &R); ASSERT_EQ(0x1000u, L.get_blob().get_logical_length()); ASSERT_EQ(4u, L.get_blob().csum_data.length());