]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/BlueStore: Adding compressed_length field to blob and fixing corresponding issues...
authorIgor Fedotov <ifedotov@mirantis.com>
Mon, 6 Jun 2016 14:57:47 +0000 (17:57 +0300)
committerIgor Fedotov <ifedotov@mirantis.com>
Wed, 8 Jun 2016 13:40:26 +0000 (16:40 +0300)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/bluestore_types.h

index 0eac105779422b823a9ba741175fbc64f078878e..416bb1435b77e5c728a50de2188c5dc9c42412bf 100644 (file)
@@ -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
index 4942358e188ddea0b1a45604b3009946a714b5f1..4b04937b9dc3ae2f2e343b912dc4b81ea2cd7e27 100644 (file)
@@ -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());