]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: inline and simplify _read_whole_blob
authorSage Weil <sage@redhat.com>
Tue, 7 Jun 2016 19:26:25 +0000 (15:26 -0400)
committerSage Weil <sage@redhat.com>
Wed, 15 Jun 2016 20:21:54 +0000 (16:21 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc

index 349fb1aa1d769defda451648c95efe93543892f1..f118254250470a1f2d09d3ab87a3d9a53bb2ca8c 100644 (file)
@@ -3284,9 +3284,16 @@ int BlueStore::_do_read(
     if (bptr->blob.has_flag(bluestore_blob_t::FLAG_COMPRESSED)) {
       bufferlist compressed_bl, raw_bl;
 
-      int r = _read_whole_blob(&bptr->blob, o, &compressed_bl);
-      if (r < 0)
-       return r;
+      IOContext ioc(NULL);   // FIXME?
+      bptr->blob.map(
+       0, bptr->blob.get_ondisk_length(),
+       [&](uint64_t offset, uint64_t length) {
+         bufferlist t;
+         int r = bdev->read(offset, length, &t, &ioc, false);
+         assert(r == 0);
+         compressed_bl.claim_append(t);
+       });
+
       if (bptr->blob.csum_type != bluestore_blob_t::CSUM_NONE) {
        r = _verify_csum(&bptr->blob, 0, compressed_bl);
        if (r < 0) {
@@ -3407,41 +3414,6 @@ int BlueStore::_do_read(
   return r;
 }
 
-int BlueStore::_read_whole_blob(const bluestore_blob_t* blob, OnodeRef o,
-                               bufferlist* result)
-{
-  IOContext ioc(NULL);   // FIXME?
-
-  result->clear();
-
-  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) {
-    uint32_t r_len = MIN(l, it->length);
-    uint32_t x_len = ROUND_UP_TO(r_len, block_size);
-
-    bufferlist bl;
-    int r = bdev->read(it->offset, x_len, &bl, &ioc, false);
-    if (r < 0) {
-      return r;
-    }
-
-    if (x_len == r_len) {
-      result->claim_append(bl);
-    } else {
-      bufferlist u;
-      u.substr_of(bl, 0, r_len);
-      result->claim_append(u);
-    }
-    l -= r_len;
-    ext_pos += it->length;
-    ++it;
-  }
-
-  return 0;
-}
-
 int BlueStore::_verify_csum(const bluestore_blob_t* blob, uint64_t blob_xoffset,
                            const bufferlist& bl) const
 {