]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: introduce bluestore_blob_t::get_chunk_size method
authorIgor Fedotov <ifedotov@mirantis.com>
Fri, 24 Jun 2016 13:30:45 +0000 (16:30 +0300)
committerSage Weil <sage@redhat.com>
Mon, 27 Jun 2016 15:05:30 +0000 (08:05 -0700)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/bluestore_types.h

index 58a22f0ecaff168db6b564cb0446118d4a958fcd..3fee4fca06de94fea9682927e04a9259acd46ef8 100644 (file)
@@ -3501,7 +3501,7 @@ int BlueStore::_do_read(
     } else {
       for (auto reg : b2r_it->second) {
        // determine how much of the blob to read
-       unsigned chunk_size = MAX(block_size, bptr->blob.get_csum_chunk_size());
+       uint64_t chunk_size = bptr->blob.get_chunk_size(block_size);
        uint64_t r_off = reg.blob_xoffset;
        uint64_t r_len = reg.length;
        unsigned front = r_off % chunk_size;
@@ -5634,7 +5634,7 @@ void BlueStore::_do_write_small(
             << " bstart 0x" << std::hex << bstart << std::dec << dendl;
 
     // can we pad our head/tail out with zeros?
-    uint64_t chunk_size = MAX(block_size, b->blob.get_csum_chunk_size());
+    uint64_t chunk_size = b->blob.get_chunk_size(block_size);
     uint64_t head_pad = offset % chunk_size;
     if (head_pad && o->onode.has_any_lextents(offset - head_pad, chunk_size)) {
       head_pad = 0;
index 0b916ca85f0421df2d0f886497e21c32a4451760..b8c404a29a820704615828e5e5e90c8c04c0b1ce 100644 (file)
@@ -233,6 +233,17 @@ struct bluestore_blob_t {
   bool is_compressed() const {
     return has_flag(FLAG_COMPRESSED);
   }
+  bool has_csum() const {
+    return has_flag(FLAG_CSUM);
+  }
+
+  /// return chunk (i.e. min readable block) size for the blob
+  uint64_t get_chunk_size(uint64_t dev_block_size) {
+    return has_csum() ? MAX(dev_block_size, get_csum_chunk_size()) : dev_block_size;
+  }
+  uint32_t get_csum_chunk_size() const {
+    return 1 << csum_chunk_order;
+  }
   uint32_t get_compressed_payload_length() const {
     return is_compressed() ? compressed_length : 0;
   }
@@ -349,13 +360,6 @@ struct bluestore_blob_t {
     return len;
   }
 
-  bool has_csum() const {
-    return has_flag(FLAG_CSUM);
-  }
-
-  uint32_t get_csum_chunk_size() const {
-    return 1 << csum_chunk_order;
-  }
 
   size_t get_csum_value_size() const {
     switch (csum_type) {