From: Sage Weil Date: Tue, 10 May 2016 17:26:30 +0000 (-0400) Subject: os/bluestore/bluestore_types: blob_t csum additions X-Git-Tag: v11.0.0~359^2~107 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5893231aa2c27facba75bca076a9565c06e5ab69;p=ceph.git os/bluestore/bluestore_types: blob_t csum additions Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index 9bffb084c1af..d485a0586ead 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -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 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;