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) {
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);
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
vector<bluestore_pextent_t> 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_*
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) {
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());