mirror of
https://github.com/ceph/ceph
synced 2025-02-23 02:57:21 +00:00
os/BlueStore: Adding compressed_length field to blob and fixing corresponding issues at read path
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
This commit is contained in:
parent
b0ed038707
commit
75d79a95f2
@ -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
|
||||
|
@ -253,6 +253,7 @@ struct bluestore_blob_t {
|
||||
|
||||
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_*
|
||||
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user