From: Igor Fedotov Date: Mon, 6 Jun 2016 14:57:47 +0000 (+0300) Subject: os/BlueStore: Adding compressed_length field to blob and fixing corresponding issues... X-Git-Tag: v11.0.0~271^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=75d79a95f291f2cb5611f3d404778a54d64192ba;p=ceph.git os/BlueStore: Adding compressed_length field to blob and fixing corresponding issues at read path Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 0eac10577942..416bb1435b77 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -3269,7 +3269,7 @@ int BlueStore::_read_whole_blob(const bluestore_blob_t* blob, OnodeRef o, buffer result->clear(); - uint32_t l = blob->length; + uint32_t l = blob->get_aligned_payload_length(block_size); uint64_t ext_pos = 0; auto it = blob->extents.cbegin(); while (it != blob->extents.cend() && l > 0) { @@ -3377,8 +3377,10 @@ int BlueStore::_blob2read_to_extents2read( while (l > 0 && ext_it != ext_end) { assert(blob->length >= ext_pos + r_offs); + auto plen = blob->get_aligned_payload_length(block_size); + assert(plen >= ext_pos + r_offs); + uint64_t r_len = MIN(plen - ext_pos - r_offs, ext_it->length - r_offs); - uint64_t r_len = MIN(blob->length - ext_pos - r_offs, ext_it->length - r_offs); if (r_len > 0) { r_len = MIN(r_len, l); const bluestore_pextent_t* eptr = &(*ext_it); @@ -5842,7 +5844,7 @@ int BlueStore::_do_alloc_write( l = &compressed_bl; final_length = newlen; csum_length = newlen; - b->set_flag(bluestore_blob_t::FLAG_COMPRESSED); + b->set_compressed(rawlen); } else { dout(20) << __func__ << hex << " compressed 0x" << l->length() << " -> 0x" << rawlen << " with " << chdr.type diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index 4942358e188d..4b04937b9dc3 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -253,6 +253,7 @@ struct bluestore_blob_t { vector extents; ///< raw data position on device uint32_t length; ///< logical (decompressed) length + uint32_t compressed_length; ///< compressed length if any uint32_t flags; ///< FLAG_* uint8_t csum_type; ///< CSUM_* @@ -264,6 +265,7 @@ struct bluestore_blob_t { bluestore_blob_t(uint32_t l = 0, uint32_t f = 0) : length(l), + compressed_length(0), flags(f), csum_type(CSUM_NONE), csum_block_order(12) { @@ -295,13 +297,27 @@ struct bluestore_blob_t { return get_flags_string(flags); } + void set_compressed(uint64_t clen) { + set_flag(FLAG_COMPRESSED); + compressed_length = clen; + } bool is_mutable() const { return has_flag(FLAG_MUTABLE); } bool is_compressed() const { return has_flag(FLAG_COMPRESSED); } - + uint32_t get_payload_length() const { + return is_compressed() ? compressed_length : length; + } + uint32_t get_aligned_payload_length(uint64_t block_size) const { + uint32_t pl = get_payload_length(); + pl = ROUND_UP_TO(pl, block_size); + if(csum_type != CSUM_NONE) { + pl = ROUND_UP_TO(pl, get_csum_block_size()); + } + return pl; + } uint64_t calc_offset(uint64_t x_off, uint64_t *plen) const { auto p = extents.begin(); assert(p != extents.end());