]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: switch to lightweight striper for hot IO path
authorJason Dillaman <dillaman@redhat.com>
Thu, 9 May 2019 03:03:31 +0000 (23:03 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 13 May 2019 17:30:09 +0000 (13:30 -0400)
Optimize non-complex IO requests using the new lightweight object
striper that avoids heap allocations for small requests.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
21 files changed:
src/librbd/cache/ObjectCacherObjectDispatch.cc
src/librbd/cache/ObjectCacherObjectDispatch.h
src/librbd/cache/WriteAroundObjectDispatch.cc
src/librbd/cache/WriteAroundObjectDispatch.h
src/librbd/io/ImageRequest.cc
src/librbd/io/ImageRequest.h
src/librbd/io/ObjectDispatch.cc
src/librbd/io/ObjectDispatch.h
src/librbd/io/ObjectDispatchInterface.h
src/librbd/io/ObjectDispatchSpec.h
src/librbd/io/ReadResult.cc
src/librbd/io/ReadResult.h
src/librbd/io/SimpleSchedulerObjectDispatch.cc
src/librbd/io/SimpleSchedulerObjectDispatch.h
src/librbd/io/Types.h
src/librbd/io/Utils.cc
src/librbd/io/Utils.h
src/librbd/journal/ObjectDispatch.cc
src/librbd/journal/ObjectDispatch.h
src/test/librbd/io/test_mock_SimpleSchedulerObjectDispatch.cc
src/test/librbd/mock/io/MockObjectDispatch.h

index d6e84101046431197b9a8049887d0a02b1bb768d..5e6f9dcf5b7bb486dc24a139a2ba2aa12ecbc49d 100644 (file)
@@ -10,6 +10,7 @@
 #include "librbd/cache/ObjectCacherWriteback.h"
 #include "librbd/io/ObjectDispatchSpec.h"
 #include "librbd/io/ObjectDispatcher.h"
+#include "librbd/io/Types.h"
 #include "librbd/io/Utils.h"
 #include "osd/osd_types.h"
 #include "osdc/WritebackHandler.h"
@@ -296,7 +297,7 @@ bool ObjectCacherObjectDispatch<I>::write(
 template <typename I>
 bool ObjectCacherObjectDispatch<I>::write_same(
     uint64_t object_no, uint64_t object_off, uint64_t object_len,
-    io::Extents&& buffer_extents, ceph::bufferlist&& data,
+    io::LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
     const ::SnapContext &snapc, int op_flags,
     const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
     uint64_t* journal_tid, io::DispatchResult* dispatch_result,
@@ -306,8 +307,7 @@ bool ObjectCacherObjectDispatch<I>::write_same(
                  << object_len << dendl;
 
   // ObjectCacher doesn't support write-same so convert to regular write
-  ObjectExtent extent(data_object_name(m_image_ctx, object_no), object_no,
-                      object_off, object_len, 0);
+  io::LightweightObjectExtent extent(object_no, object_off, object_len, 0);
   extent.buffer_extents = std::move(buffer_extents);
 
   bufferlist ws_data;
index 3d19023bce43237041c9e8f26ec9d299227b53dc..22a9cf3586f4b913660bc711668be43ed03d4fbd 100644 (file)
@@ -65,7 +65,7 @@ public:
 
   bool write_same(
       uint64_t object_no, uint64_t object_off, uint64_t object_len,
-      io::Extents&& buffer_extents, ceph::bufferlist&& data,
+      io::LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
       const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
       uint64_t* journal_tid, io::DispatchResult* dispatch_result,
index 2e4380eeb8ba249f31ff964324c51e55fde86f8a..88e9e218453f84d8d3a0d563e392d3492b9b6b85 100644 (file)
@@ -99,7 +99,7 @@ bool WriteAroundObjectDispatch<I>::write(
 template <typename I>
 bool WriteAroundObjectDispatch<I>::write_same(
     uint64_t object_no, uint64_t object_off, uint64_t object_len,
-    io::Extents&& buffer_extents, ceph::bufferlist&& data,
+    io::LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
     const ::SnapContext &snapc, int op_flags,
     const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
     uint64_t* journal_tid, io::DispatchResult* dispatch_result,
index d47e0d0b08127ad42bcbc85d4992ee27defc8751..28721ce1172ea7d783e0e111ff5536010e4d60f9 100644 (file)
@@ -65,7 +65,7 @@ public:
 
   bool write_same(
       uint64_t object_no, uint64_t object_off, uint64_t object_len,
-      io::Extents&& buffer_extents, ceph::bufferlist&& data,
+      io::LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
       const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
       uint64_t* journal_tid, io::DispatchResult* dispatch_result,
index 33bd92b91b9f9ecb2845923029b1227c58a3c20f..5db5195fd1bf6fdef4aef5db86844019af286402 100644 (file)
@@ -29,6 +29,7 @@
 namespace librbd {
 namespace io {
 
+using librbd::util::data_object_name;
 using librbd::util::get_image_ctx;
 
 namespace {
@@ -36,20 +37,21 @@ namespace {
 template <typename I>
 struct C_RBD_Readahead : public Context {
   I *ictx;
-  object_t oid;
+  uint64_t object_no;
   uint64_t offset;
   uint64_t length;
 
   bufferlist read_data;
   io::ExtentMap extent_map;
 
-  C_RBD_Readahead(I *ictx, object_t oid, uint64_t offset, uint64_t length)
-    : ictx(ictx), oid(oid), offset(offset), length(length) {
+  C_RBD_Readahead(I *ictx, uint64_t object_no, uint64_t offset, uint64_t length)
+    : ictx(ictx), object_no(object_no), offset(offset), length(length) {
     ictx->readahead.inc_pending();
   }
 
   void finish(int r) override {
-    ldout(ictx->cct, 20) << "C_RBD_Readahead on " << oid << ": "
+    ldout(ictx->cct, 20) << "C_RBD_Readahead on "
+                         << data_object_name(ictx, object_no) << ": "
                          << offset << "~" << length << dendl;
     ictx->readahead.dec_pending();
   }
@@ -83,25 +85,25 @@ void readahead(I *ictx, const Extents& image_extents) {
   if (readahead_length > 0) {
     ldout(ictx->cct, 20) << "(readahead logical) " << readahead_offset << "~"
                          << readahead_length << dendl;
-    std::map<object_t, std::vector<ObjectExtent> > readahead_object_extents;
-    Striper::file_to_extents(ictx->cct, ictx->format_string, &ictx->layout,
-                             readahead_offset, readahead_length, 0,
-                             readahead_object_extents);
-    for (auto& readahead_object_extent : readahead_object_extents) {
-      for (auto& object_extent : readahead_object_extent.second) {
-        ldout(ictx->cct, 20) << "(readahead) oid " << object_extent.oid << " "
-                             << object_extent.offset << "~"
-                             << object_extent.length << dendl;
-
-        auto req_comp = new C_RBD_Readahead<I>(ictx, object_extent.oid,
-                                               object_extent.offset,
-                                               object_extent.length);
-        auto req = io::ObjectDispatchSpec::create_read(
-          ictx, io::OBJECT_DISPATCH_LAYER_NONE, object_extent.objectno,
-          object_extent.offset, object_extent.length, snap_id, 0, {},
-          &req_comp->read_data, &req_comp->extent_map, req_comp);
-        req->send();
-      }
+    LightweightObjectExtents readahead_object_extents;
+    Striper::file_to_extents(ictx->cct, &ictx->layout,
+                             readahead_offset, readahead_length, 0, 0,
+                             &readahead_object_extents);
+    for (auto& object_extent : readahead_object_extents) {
+      ldout(ictx->cct, 20) << "(readahead) "
+                           << data_object_name(ictx,
+                                               object_extent.object_no) << " "
+                           << object_extent.offset << "~"
+                           << object_extent.length << dendl;
+
+      auto req_comp = new C_RBD_Readahead<I>(ictx, object_extent.object_no,
+                                             object_extent.offset,
+                                             object_extent.length);
+      auto req = io::ObjectDispatchSpec::create_read(
+        ictx, io::OBJECT_DISPATCH_LAYER_NONE, object_extent.object_no,
+        object_extent.offset, object_extent.length, snap_id, 0, {},
+        &req_comp->read_data, &req_comp->extent_map, req_comp);
+      req->send();
     }
 
     ictx->perfcounter->inc(l_librbd_readahead);
@@ -348,52 +350,42 @@ void ImageReadRequest<I>::send_request() {
     readahead(get_image_ctx(&image_ctx), image_extents);
   }
 
-  AioCompletion *aio_comp = this->m_aio_comp;
   librados::snap_t snap_id;
-  map<object_t,vector<ObjectExtent> > object_extents;
   uint64_t buffer_ofs = 0;
   {
     // prevent image size from changing between computing clip and recording
     // pending async operation
     RWLock::RLocker image_locker(image_ctx.image_lock);
     snap_id = image_ctx.snap_id;
+  }
 
-    // map image extents to object extents
-    for (auto &extent : image_extents) {
-      if (extent.second == 0) {
-        continue;
-      }
-
-      Striper::file_to_extents(cct, image_ctx.format_string, &image_ctx.layout,
-                               extent.first, extent.second, 0, object_extents,
-                               buffer_ofs);
-      buffer_ofs += extent.second;
+  // map image extents to object extents
+  LightweightObjectExtents object_extents;
+  for (auto &extent : image_extents) {
+    if (extent.second == 0) {
+      continue;
     }
-  }
 
-  // pre-calculate the expected number of read requests
-  uint32_t request_count = 0;
-  for (auto &object_extent : object_extents) {
-    request_count += object_extent.second.size();
+    Striper::file_to_extents(cct, &image_ctx.layout, extent.first,
+                             extent.second, 0, buffer_ofs, &object_extents);
+    buffer_ofs += extent.second;
   }
-  aio_comp->set_request_count(request_count);
 
   // issue the requests
-  for (auto &object_extent : object_extents) {
-    for (auto &extent : object_extent.second) {
-      ldout(cct, 20) << "oid " << extent.oid << " " << extent.offset << "~"
-                     << extent.length << " from " << extent.buffer_extents
-                     << dendl;
-
-      auto req_comp = new io::ReadResult::C_ObjectReadRequest(
-        aio_comp, extent.offset, extent.length,
-        std::move(extent.buffer_extents));
-      auto req = ObjectDispatchSpec::create_read(
-        &image_ctx, OBJECT_DISPATCH_LAYER_NONE, extent.objectno, extent.offset,
-        extent.length, snap_id, m_op_flags, this->m_trace, &req_comp->bl,
-        &req_comp->extent_map, req_comp);
-      req->send();
-    }
+  AioCompletion *aio_comp = this->m_aio_comp;
+  aio_comp->set_request_count(object_extents.size());
+  for (auto &oe : object_extents) {
+    ldout(cct, 20) << data_object_name(&image_ctx, oe.object_no) << " "
+                   << oe.offset << "~" << oe.length << " from "
+                   << oe.buffer_extents << dendl;
+
+    auto req_comp = new io::ReadResult::C_ObjectReadRequest(
+      aio_comp, oe.offset, oe.length, std::move(oe.buffer_extents));
+    auto req = ObjectDispatchSpec::create_read(
+      &image_ctx, OBJECT_DISPATCH_LAYER_NONE, oe.object_no, oe.offset,
+      oe.length, snap_id, m_op_flags, this->m_trace, &req_comp->bl,
+      &req_comp->extent_map, req_comp);
+    req->send();
   }
 
   image_ctx.perfcounter->inc(l_librbd_rd);
@@ -423,8 +415,6 @@ void AbstractImageWriteRequest<I>::send_request() {
   bool journaling = false;
 
   AioCompletion *aio_comp = this->m_aio_comp;
-  uint64_t clip_len = 0;
-  ObjectExtents object_extents;
   ::SnapContext snapc;
   {
     // prevent image size from changing between computing clip and recording
@@ -435,28 +425,31 @@ void AbstractImageWriteRequest<I>::send_request() {
       return;
     }
 
-    for (auto &extent : this->m_image_extents) {
-      if (extent.second == 0) {
-        continue;
-      }
-
-      // map to object extents
-      Striper::file_to_extents(cct, image_ctx.format_string, &image_ctx.layout,
-                               extent.first, extent.second, 0, object_extents);
-      clip_len += extent.second;
-    }
-
     snapc = image_ctx.snapc;
     journaling = (image_ctx.journal != nullptr &&
                   image_ctx.journal->is_journal_appending());
   }
 
+  uint64_t clip_len = 0;
+  LightweightObjectExtents object_extents;
+  for (auto &extent : this->m_image_extents) {
+    if (extent.second == 0) {
+      continue;
+    }
+
+    // map to object extents
+    Striper::file_to_extents(cct, &image_ctx.layout, extent.first,
+                             extent.second, 0, clip_len, &object_extents);
+    clip_len += extent.second;
+  }
+
   int ret = prune_object_extents(&object_extents);
   if (ret < 0) {
     aio_comp->fail(ret);
     return;
   }
 
+  aio_comp->set_request_count(object_extents.size());
   if (!object_extents.empty()) {
     uint64_t journal_tid = 0;
     if (journaling) {
@@ -465,11 +458,7 @@ void AbstractImageWriteRequest<I>::send_request() {
       journal_tid = append_journal_event(m_synchronous);
     }
 
-    aio_comp->set_request_count(object_extents.size());
     send_object_requests(object_extents, snapc, journal_tid);
-  } else {
-    // no IO to perform -- fire completion
-    aio_comp->set_request_count(0);
   }
 
   update_stats(clip_len);
@@ -477,18 +466,18 @@ void AbstractImageWriteRequest<I>::send_request() {
 
 template <typename I>
 void AbstractImageWriteRequest<I>::send_object_requests(
-    const ObjectExtents &object_extents, const ::SnapContext &snapc,
+    const LightweightObjectExtents &object_extents, const ::SnapContext &snapc,
     uint64_t journal_tid) {
   I &image_ctx = this->m_image_ctx;
   CephContext *cct = image_ctx.cct;
 
   AioCompletion *aio_comp = this->m_aio_comp;
-  for (ObjectExtents::const_iterator p = object_extents.begin();
-       p != object_extents.end(); ++p) {
-    ldout(cct, 20) << "oid " << p->oid << " " << p->offset << "~" << p->length
-                   << " from " << p->buffer_extents << dendl;
+  for (auto& oe : object_extents) {
+    ldout(cct, 20) << data_object_name(&image_ctx, oe.object_no) << " "
+                   << oe.offset << "~" << oe.length << " from "
+                   << oe.buffer_extents << dendl;
     C_AioRequest *req_comp = new C_AioRequest(aio_comp);
-    auto request = create_object_request(*p, snapc, journal_tid, req_comp);
+    auto request = create_object_request(oe, snapc, journal_tid, req_comp);
 
     // if journaling, stash the request for later; otherwise send
     if (request != NULL) {
@@ -498,8 +487,8 @@ void AbstractImageWriteRequest<I>::send_object_requests(
 }
 
 template <typename I>
-void ImageWriteRequest<I>::assemble_extent(const ObjectExtent &object_extent,
-                                           bufferlist *bl) {
+void ImageWriteRequest<I>::assemble_extent(
+    const LightweightObjectExtent &object_extent, bufferlist *bl) {
   for (auto q = object_extent.buffer_extents.begin();
        q != object_extent.buffer_extents.end(); ++q) {
     bufferlist sub_bl;
@@ -541,14 +530,14 @@ void ImageWriteRequest<I>::send_image_cache_request() {
 
 template <typename I>
 ObjectDispatchSpec *ImageWriteRequest<I>::create_object_request(
-    const ObjectExtent &object_extent, const ::SnapContext &snapc,
+    const LightweightObjectExtent &object_extent, const ::SnapContext &snapc,
     uint64_t journal_tid, Context *on_finish) {
   I &image_ctx = this->m_image_ctx;
 
   bufferlist bl;
   assemble_extent(object_extent, &bl);
   auto req = ObjectDispatchSpec::create_write(
-    &image_ctx, OBJECT_DISPATCH_LAYER_NONE, object_extent.objectno,
+    &image_ctx, OBJECT_DISPATCH_LAYER_NONE, object_extent.object_no,
     object_extent.offset, std::move(bl), snapc, m_op_flags, journal_tid,
     this->m_trace, on_finish);
   return req;
@@ -597,11 +586,11 @@ void ImageDiscardRequest<I>::send_image_cache_request() {
 
 template <typename I>
 ObjectDispatchSpec *ImageDiscardRequest<I>::create_object_request(
-    const ObjectExtent &object_extent, const ::SnapContext &snapc,
+    const LightweightObjectExtent &object_extent, const ::SnapContext &snapc,
     uint64_t journal_tid, Context *on_finish) {
   I &image_ctx = this->m_image_ctx;
   auto req = ObjectDispatchSpec::create_discard(
-    &image_ctx, OBJECT_DISPATCH_LAYER_NONE, object_extent.objectno,
+    &image_ctx, OBJECT_DISPATCH_LAYER_NONE, object_extent.object_no,
     object_extent.offset, object_extent.length, snapc,
     OBJECT_DISCARD_FLAG_DISABLE_CLONE_REMOVE, journal_tid, this->m_trace,
     on_finish);
@@ -617,7 +606,7 @@ void ImageDiscardRequest<I>::update_stats(size_t length) {
 
 template <typename I>
 int ImageDiscardRequest<I>::prune_object_extents(
-    ObjectExtents* object_extents) const {
+    LightweightObjectExtents* object_extents) const {
   if (m_discard_granularity_bytes == 0) {
     return 0;
   }
@@ -633,7 +622,7 @@ int ImageDiscardRequest<I>::prune_object_extents(
                                             object_size);
   auto xform_lambda =
     [discard_granularity_bytes, object_size, &prune_required]
-    (ObjectExtent& object_extent) {
+    (LightweightObjectExtent& object_extent) {
       auto& offset = object_extent.offset;
       auto& length = object_extent.length;
       auto next_offset = offset + length;
@@ -656,7 +645,7 @@ int ImageDiscardRequest<I>::prune_object_extents(
   if (prune_required) {
     // one or more object extents were skipped
     auto remove_lambda =
-      [](const ObjectExtent& object_extent) {
+      [](const LightweightObjectExtent& object_extent) {
         return (object_extent.length == 0);
       };
     object_extents->erase(
@@ -757,7 +746,7 @@ void ImageWriteSameRequest<I>::send_image_cache_request() {
 
 template <typename I>
 ObjectDispatchSpec *ImageWriteSameRequest<I>::create_object_request(
-    const ObjectExtent &object_extent, const ::SnapContext &snapc,
+    const LightweightObjectExtent &object_extent, const ::SnapContext &snapc,
     uint64_t journal_tid, Context *on_finish) {
   I &image_ctx = this->m_image_ctx;
 
@@ -765,17 +754,17 @@ ObjectDispatchSpec *ImageWriteSameRequest<I>::create_object_request(
   ObjectDispatchSpec *req;
 
   if (util::assemble_write_same_extent(object_extent, m_data_bl, &bl, false)) {
-    Extents buffer_extents{object_extent.buffer_extents};
+    auto buffer_extents{object_extent.buffer_extents};
 
     req = ObjectDispatchSpec::create_write_same(
-      &image_ctx, OBJECT_DISPATCH_LAYER_NONE, object_extent.objectno,
+      &image_ctx, OBJECT_DISPATCH_LAYER_NONE, object_extent.object_no,
       object_extent.offset, object_extent.length, std::move(buffer_extents),
       std::move(bl), snapc, m_op_flags, journal_tid,
       this->m_trace, on_finish);
     return req;
   }
   req = ObjectDispatchSpec::create_write(
-    &image_ctx, OBJECT_DISPATCH_LAYER_NONE, object_extent.objectno,
+    &image_ctx, OBJECT_DISPATCH_LAYER_NONE, object_extent.object_no,
     object_extent.offset, std::move(bl), snapc, m_op_flags, journal_tid,
     this->m_trace, on_finish);
   return req;
@@ -808,7 +797,7 @@ uint64_t ImageCompareAndWriteRequest<I>::append_journal_event(
 
 template <typename I>
 void ImageCompareAndWriteRequest<I>::assemble_extent(
-  const ObjectExtent &object_extent, bufferlist *bl) {
+  const LightweightObjectExtent &object_extent, bufferlist *bl) {
   for (auto q = object_extent.buffer_extents.begin();
        q != object_extent.buffer_extents.end(); ++q) {
     bufferlist sub_bl;
@@ -832,7 +821,7 @@ void ImageCompareAndWriteRequest<I>::send_image_cache_request() {
 
 template <typename I>
 ObjectDispatchSpec *ImageCompareAndWriteRequest<I>::create_object_request(
-    const ObjectExtent &object_extent,
+    const LightweightObjectExtent &object_extent,
     const ::SnapContext &snapc,
     uint64_t journal_tid, Context *on_finish) {
   I &image_ctx = this->m_image_ctx;
@@ -842,7 +831,7 @@ ObjectDispatchSpec *ImageCompareAndWriteRequest<I>::create_object_request(
   bufferlist bl;
   assemble_extent(object_extent, &bl);
   auto req = ObjectDispatchSpec::create_compare_and_write(
-    &image_ctx, OBJECT_DISPATCH_LAYER_NONE, object_extent.objectno,
+    &image_ctx, OBJECT_DISPATCH_LAYER_NONE, object_extent.object_no,
     object_extent.offset, std::move(m_cmp_bl), std::move(bl), snapc,
     m_mismatch_offset, m_op_flags, journal_tid, this->m_trace, on_finish);
   return req;
@@ -857,14 +846,14 @@ void ImageCompareAndWriteRequest<I>::update_stats(size_t length) {
 
 template <typename I>
 int ImageCompareAndWriteRequest<I>::prune_object_extents(
-    ObjectExtents* object_extents) const {
+    LightweightObjectExtents* object_extents) const {
   if (object_extents->size() > 1)
     return -EINVAL;
 
   I &image_ctx = this->m_image_ctx;
   uint64_t sector_size = 512ULL;
   uint64_t su = image_ctx.layout.stripe_unit;
-  ObjectExtent object_extent = object_extents->front();
+  auto& object_extent = object_extents->front();
   if (object_extent.offset % sector_size + object_extent.length > sector_size ||
       (su != 0 && (object_extent.offset % su + object_extent.length > su)))
     return -EINVAL;
index d7d10019d3ed0618c390fe6eef764f59c496dd07..2a684fb1e3537c8c6f89c14f5b0f5ccd663baeea 100644 (file)
@@ -129,8 +129,6 @@ protected:
   using typename ImageRequest<ImageCtxT>::ObjectRequests;
   using typename ImageRequest<ImageCtxT>::Extents;
 
-  typedef std::vector<ObjectExtent> ObjectExtents;
-
   AbstractImageWriteRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp,
                             Extents &&image_extents, const char *trace_name,
                            const ZTracer::Trace &parent_trace)
@@ -141,14 +139,15 @@ protected:
 
   void send_request() override;
 
-  virtual int prune_object_extents(ObjectExtents* object_extents) const {
+  virtual int prune_object_extents(
+      LightweightObjectExtents* object_extents) const {
     return 0;
   }
 
-  void send_object_requests(const ObjectExtents &object_extents,
+  void send_object_requests(const LightweightObjectExtents &object_extents,
                             const ::SnapContext &snapc, uint64_t journal_tid);
   virtual ObjectDispatchSpec *create_object_request(
-      const ObjectExtent &object_extent, const ::SnapContext &snapc,
+      const LightweightObjectExtent &object_extent, const ::SnapContext &snapc,
       uint64_t journal_tid, Context *on_finish) = 0;
 
   virtual uint64_t append_journal_event(bool synchronous) = 0;
@@ -173,7 +172,6 @@ public:
 
 protected:
   using typename ImageRequest<ImageCtxT>::ObjectRequests;
-  using typename AbstractImageWriteRequest<ImageCtxT>::ObjectExtents;
 
   aio_type_t get_aio_type() const override {
     return AIO_TYPE_WRITE;
@@ -182,13 +180,14 @@ protected:
     return "aio_write";
   }
 
-  void assemble_extent(const ObjectExtent &object_extent, bufferlist *bl);
+  void assemble_extent(const LightweightObjectExtent &object_extent,
+                       bufferlist *bl);
 
   void send_image_cache_request() override;
 
 
   ObjectDispatchSpec *create_object_request(
-      const ObjectExtent &object_extent, const ::SnapContext &snapc,
+      const LightweightObjectExtent &object_extent, const ::SnapContext &snapc,
       uint64_t journal_tid, Context *on_finish) override;
 
   uint64_t append_journal_event(bool synchronous) override;
@@ -213,7 +212,6 @@ public:
 
 protected:
   using typename ImageRequest<ImageCtxT>::ObjectRequests;
-  using typename AbstractImageWriteRequest<ImageCtxT>::ObjectExtents;
 
   aio_type_t get_aio_type() const override {
     return AIO_TYPE_DISCARD;
@@ -225,13 +223,14 @@ protected:
   void send_image_cache_request() override;
 
   ObjectDispatchSpec *create_object_request(
-      const ObjectExtent &object_extent, const ::SnapContext &snapc,
+      const LightweightObjectExtent &object_extent, const ::SnapContext &snapc,
       uint64_t journal_tid, Context *on_finish) override;
 
   uint64_t append_journal_event(bool synchronous) override;
   void update_stats(size_t length) override;
 
-  int prune_object_extents(ObjectExtents* object_extents) const override;
+  int prune_object_extents(
+      LightweightObjectExtents* object_extents) const override;
 
 private:
   uint32_t m_discard_granularity_bytes;
@@ -284,7 +283,6 @@ public:
 
 protected:
   using typename ImageRequest<ImageCtxT>::ObjectRequests;
-  using typename AbstractImageWriteRequest<ImageCtxT>::ObjectExtents;
 
   aio_type_t get_aio_type() const override {
     return AIO_TYPE_WRITESAME;
@@ -296,7 +294,7 @@ protected:
   void send_image_cache_request() override;
 
   ObjectDispatchSpec *create_object_request(
-      const ObjectExtent &object_extent, const ::SnapContext &snapc,
+      const LightweightObjectExtent &object_extent, const ::SnapContext &snapc,
       uint64_t journal_tid, Context *on_finish) override;
 
   uint64_t append_journal_event(bool synchronous) override;
@@ -310,7 +308,6 @@ template <typename ImageCtxT = ImageCtx>
 class ImageCompareAndWriteRequest : public AbstractImageWriteRequest<ImageCtxT> {
 public:
   using typename ImageRequest<ImageCtxT>::ObjectRequests;
-  using typename AbstractImageWriteRequest<ImageCtxT>::ObjectExtents;
 
   ImageCompareAndWriteRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp,
                               Extents &&image_extents, bufferlist &&cmp_bl,
@@ -325,10 +322,11 @@ public:
 protected:
   void send_image_cache_request() override;
 
-  void assemble_extent(const ObjectExtent &object_extent, bufferlist *bl);
+  void assemble_extent(const LightweightObjectExtent &object_extent,
+                       bufferlist *bl);
 
   ObjectDispatchSpec *create_object_request(
-      const ObjectExtent &object_extent, const ::SnapContext &snapc,
+      const LightweightObjectExtent &object_extent, const ::SnapContext &snapc,
       uint64_t journal_tid, Context *on_finish) override;
 
   uint64_t append_journal_event(bool synchronous) override;
@@ -341,7 +339,8 @@ protected:
     return "aio_compare_and_write";
   }
 
-  int prune_object_extents(ObjectExtents* object_extents) const override;
+  int prune_object_extents(
+      LightweightObjectExtents* object_extents) const override;
 
 private:
   bufferlist m_cmp_bl;
index 422c62ea0a3d4c4f5fd5a621a91c97932bec8a37..4f3baa451f7e739b0283e5176f9c7f32a34203f3 100644 (file)
@@ -92,7 +92,7 @@ bool ObjectDispatch<I>::write(
 template <typename I>
 bool ObjectDispatch<I>::write_same(
     uint64_t object_no, uint64_t object_off, uint64_t object_len,
-    Extents&& buffer_extents, ceph::bufferlist&& data,
+    LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
     const ::SnapContext &snapc, int op_flags,
     const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
     uint64_t* journal_tid, DispatchResult* dispatch_result,
index deb688541e9b192f69ce8c3927ba8cc8cd96952d..8f04143e4fa112132c3db8d982ad8a20655b0e63 100644 (file)
@@ -57,7 +57,7 @@ public:
 
   bool write_same(
       uint64_t object_no, uint64_t object_off, uint64_t object_len,
-      Extents&& buffer_extents, ceph::bufferlist&& data,
+      LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
       const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
       uint64_t* journal_tid, DispatchResult* dispatch_result,
index ee91f9d042c379bbfdf89d2445e1ee77de7f4412..168d8006d1448273b6851667a599a756536cc396 100644 (file)
@@ -50,7 +50,7 @@ struct ObjectDispatchInterface {
 
   virtual bool write_same(
       uint64_t object_no, uint64_t object_off, uint64_t object_len,
-      Extents&& buffer_extents, ceph::bufferlist&& data,
+      LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
       const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
       uint64_t* journal_tid, DispatchResult* dispatch_result,
index a8c0660422d8a176bf62f4e56082eacea8fc6bbb..654ed3dd31cd0473aff13b31d1cf97f13c8b31b6 100644 (file)
@@ -94,11 +94,12 @@ public:
 
   struct WriteSameRequest : public WriteRequestBase {
     uint64_t object_len;
-    Extents buffer_extents;
+    LightweightBufferExtents buffer_extents;
     ceph::bufferlist data;
 
     WriteSameRequest(uint64_t object_no, uint64_t object_off,
-                     uint64_t object_len, Extents&& buffer_extents,
+                     uint64_t object_len,
+                     LightweightBufferExtents&& buffer_extents,
                      ceph::bufferlist&& data, const ::SnapContext& snapc,
                      uint64_t journal_tid)
     : WriteRequestBase(object_no, object_off, snapc, journal_tid),
@@ -196,7 +197,7 @@ public:
   static ObjectDispatchSpec* create_write_same(
       ImageCtxT* image_ctx, ObjectDispatchLayer object_dispatch_layer,
       uint64_t object_no, uint64_t object_off, uint64_t object_len,
-      Extents&& buffer_extents, ceph::bufferlist&& data,
+      LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
       const ::SnapContext &snapc, int op_flags, uint64_t journal_tid,
       const ZTracer::Trace &parent_trace, Context *on_finish) {
     return new ObjectDispatchSpec(image_ctx->io_object_dispatcher,
index dbf8ef48c3e3d402fbece8bbb386c901f8455187..61bf78682bcbdf7cab6f7e1a447df302590901ca 100644 (file)
@@ -120,7 +120,7 @@ void ReadResult::C_ImageReadRequest::finish(int r) {
 
 ReadResult::C_ObjectReadRequest::C_ObjectReadRequest(
     AioCompletion *aio_completion, uint64_t object_off, uint64_t object_len,
-    Extents&& buffer_extents)
+    LightweightBufferExtents&& buffer_extents)
   : aio_completion(aio_completion), object_off(object_off),
     object_len(object_len), buffer_extents(std::move(buffer_extents)) {
   aio_completion->add_request();
index 9efdcb0105cd5dddcc243cf662f6b8cca208822b..ea62a05aabd5489806eaf27ea326be06a4bf8019 100644 (file)
@@ -40,13 +40,14 @@ public:
     AioCompletion *aio_completion;
     uint64_t object_off;
     uint64_t object_len;
-    Extents buffer_extents;
+    LightweightBufferExtents buffer_extents;
 
     bufferlist bl;
     ExtentMap extent_map;
 
     C_ObjectReadRequest(AioCompletion *aio_completion, uint64_t object_off,
-                        uint64_t object_len, Extents&& buffer_extents);
+                        uint64_t object_len,
+                        LightweightBufferExtents&& buffer_extents);
 
     void finish(int r) override;
   };
index b3486e2430aad5e2468e9e7a0586d444687f4c53..ab2ef38032c69a02af4701ff2ca78b0bee37d31d 100644 (file)
@@ -158,8 +158,8 @@ void SimpleSchedulerObjectDispatch<I>::ObjectRequests::dispatch_delayed_requests
           }
         });
 
-    auto req = io::ObjectDispatchSpec::create_write(
-        image_ctx, io::OBJECT_DISPATCH_LAYER_SCHEDULER,
+    auto req = ObjectDispatchSpec::create_write(
+        image_ctx, OBJECT_DISPATCH_LAYER_SCHEDULER,
         m_object_no, offset, std::move(merged_requests.data), m_snapc,
         m_op_flags, 0, {}, ctx);
 
@@ -213,8 +213,8 @@ template <typename I>
 bool SimpleSchedulerObjectDispatch<I>::read(
     uint64_t object_no, uint64_t object_off, uint64_t object_len,
     librados::snap_t snap_id, int op_flags, const ZTracer::Trace &parent_trace,
-    ceph::bufferlist* read_data, io::ExtentMap* extent_map,
-    int* object_dispatch_flags, io::DispatchResult* dispatch_result,
+    ceph::bufferlist* read_data, ExtentMap* extent_map,
+    int* object_dispatch_flags, DispatchResult* dispatch_result,
     Context** on_finish, Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
   ldout(cct, 20) << data_object_name(m_image_ctx, object_no) << " "
@@ -233,7 +233,7 @@ bool SimpleSchedulerObjectDispatch<I>::discard(
     uint64_t object_no, uint64_t object_off, uint64_t object_len,
     const ::SnapContext &snapc, int discard_flags,
     const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
-    uint64_t* journal_tid, io::DispatchResult* dispatch_result,
+    uint64_t* journal_tid, DispatchResult* dispatch_result,
     Context** on_finish, Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
   ldout(cct, 20) << data_object_name(m_image_ctx, object_no) << " "
@@ -251,7 +251,7 @@ bool SimpleSchedulerObjectDispatch<I>::write(
     uint64_t object_no, uint64_t object_off, ceph::bufferlist&& data,
     const ::SnapContext &snapc, int op_flags,
     const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
-    uint64_t* journal_tid, io::DispatchResult* dispatch_result,
+    uint64_t* journal_tid, DispatchResult* dispatch_result,
     Context** on_finish, Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
   ldout(cct, 20) << data_object_name(m_image_ctx, object_no) << " "
@@ -260,7 +260,7 @@ bool SimpleSchedulerObjectDispatch<I>::write(
   Mutex::Locker locker(m_lock);
   if (try_delay_write(object_no, object_off, std::move(data), snapc, op_flags,
                       *object_dispatch_flags, on_dispatched)) {
-    *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
+    *dispatch_result = DISPATCH_RESULT_COMPLETE;
     return true;
   }
 
@@ -273,10 +273,10 @@ bool SimpleSchedulerObjectDispatch<I>::write(
 template <typename I>
 bool SimpleSchedulerObjectDispatch<I>::write_same(
     uint64_t object_no, uint64_t object_off, uint64_t object_len,
-    io::Extents&& buffer_extents, ceph::bufferlist&& data,
+    LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
     const ::SnapContext &snapc, int op_flags,
     const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
-    uint64_t* journal_tid, io::DispatchResult* dispatch_result,
+    uint64_t* journal_tid, DispatchResult* dispatch_result,
     Context** on_finish, Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
   ldout(cct, 20) << data_object_name(m_image_ctx, object_no) << " "
@@ -295,7 +295,7 @@ bool SimpleSchedulerObjectDispatch<I>::compare_and_write(
     ceph::bufferlist&& write_data, const ::SnapContext &snapc, int op_flags,
     const ZTracer::Trace &parent_trace, uint64_t* mismatch_offset,
     int* object_dispatch_flags, uint64_t* journal_tid,
-    io::DispatchResult* dispatch_result, Context** on_finish,
+    DispatchResult* dispatch_result, Context** on_finish,
     Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
   ldout(cct, 20) << data_object_name(m_image_ctx, object_no) << " "
@@ -310,8 +310,8 @@ bool SimpleSchedulerObjectDispatch<I>::compare_and_write(
 
 template <typename I>
 bool SimpleSchedulerObjectDispatch<I>::flush(
-    io::FlushSource flush_source, const ZTracer::Trace &parent_trace,
-    uint64_t* journal_tid, io::DispatchResult* dispatch_result,
+    FlushSource flush_source, const ZTracer::Trace &parent_trace,
+    uint64_t* journal_tid, DispatchResult* dispatch_result,
     Context** on_finish, Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
   ldout(cct, 20) << dendl;
index 67fd09ab92d94e0c77e3e03874eea8116b8efec0..90f7747173e4cca299f7c671b2a6315e0c4379f4 100644 (file)
@@ -28,7 +28,7 @@ class LatencyStats;
  * Simple scheduler plugin for object dispatcher layer.
  */
 template <typename ImageCtxT = ImageCtx>
-class SimpleSchedulerObjectDispatch : public io::ObjectDispatchInterface {
+class SimpleSchedulerObjectDispatch : public ObjectDispatchInterface {
 private:
   // mock unit testing support
   typedef ::librbd::io::TypeTraits<ImageCtxT> TypeTraits;
@@ -41,8 +41,8 @@ public:
   SimpleSchedulerObjectDispatch(ImageCtxT* image_ctx);
   ~SimpleSchedulerObjectDispatch() override;
 
-  io::ObjectDispatchLayer get_object_dispatch_layer() const override {
-    return io::OBJECT_DISPATCH_LAYER_SCHEDULER;
+  ObjectDispatchLayer get_object_dispatch_layer() const override {
+    return OBJECT_DISPATCH_LAYER_SCHEDULER;
   }
 
   void init();
@@ -52,30 +52,30 @@ public:
       uint64_t object_no, uint64_t object_off, uint64_t object_len,
       librados::snap_t snap_id, int op_flags,
       const ZTracer::Trace &parent_trace, ceph::bufferlist* read_data,
-      io::ExtentMap* extent_map, int* object_dispatch_flags,
-      io::DispatchResult* dispatch_result, Context** on_finish,
+      ExtentMap* extent_map, int* object_dispatch_flags,
+      DispatchResult* dispatch_result, Context** on_finish,
       Context* on_dispatched) override;
 
   bool discard(
       uint64_t object_no, uint64_t object_off, uint64_t object_len,
       const ::SnapContext &snapc, int discard_flags,
       const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
-      uint64_t* journal_tid, io::DispatchResult* dispatch_result,
+      uint64_t* journal_tid, DispatchResult* dispatch_result,
       Context** on_finish, Context* on_dispatched) override;
 
   bool write(
       uint64_t object_no, uint64_t object_off, ceph::bufferlist&& data,
       const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
-      uint64_t* journal_tid, io::DispatchResult* dispatch_result,
+      uint64_t* journal_tid, DispatchResult* dispatch_result,
       Context** on_finish, Context* on_dispatched) override;
 
   bool write_same(
       uint64_t object_no, uint64_t object_off, uint64_t object_len,
-      io::Extents&& buffer_extents, ceph::bufferlist&& data,
+      LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
       const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
-      uint64_t* journal_tid, io::DispatchResult* dispatch_result,
+      uint64_t* journal_tid, DispatchResult* dispatch_result,
       Context** on_finish, Context* on_dispatched) override;
 
   bool compare_and_write(
@@ -83,12 +83,12 @@ public:
       ceph::bufferlist&& write_data, const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, uint64_t* mismatch_offset,
       int* object_dispatch_flags, uint64_t* journal_tid,
-      io::DispatchResult* dispatch_result, Context** on_finish,
+      DispatchResult* dispatch_result, Context** on_finish,
       Context* on_dispatched) override;
 
   bool flush(
-      io::FlushSource flush_source, const ZTracer::Trace &parent_trace,
-      uint64_t* journal_tid, io::DispatchResult* dispatch_result,
+      FlushSource flush_source, const ZTracer::Trace &parent_trace,
+      uint64_t* journal_tid, DispatchResult* dispatch_result,
       Context** on_finish, Context* on_dispatched) override;
 
   bool invalidate_cache(Context* on_finish) override {
index d25f5c8aeddd2b10ce6bd78bd9f68036efd9956b..4847d11dfca40ae37447a71a1b1d327722bfd36a 100644 (file)
@@ -5,6 +5,7 @@
 #define CEPH_LIBRBD_IO_TYPES_H
 
 #include "include/int_types.h"
+#include "osdc/StriperTypes.h"
 #include <map>
 #include <vector>
 
@@ -75,6 +76,10 @@ enum {
   OBJECT_DISPATCH_FLAG_WILL_RETRY_ON_ERROR      = 1UL << 1
 };
 
+using striper::LightweightBufferExtents;
+using striper::LightweightObjectExtent;
+using striper::LightweightObjectExtents;
+
 typedef std::vector<std::pair<uint64_t, uint64_t> > Extents;
 typedef std::map<uint64_t, uint64_t> ExtentMap;
 
index 1b50561a795d0a6cf097e9196a6e5c7ae445c39c..bf06663388c8e710cb315500db0fa79df9855cfb 100644 (file)
@@ -10,7 +10,7 @@ namespace io {
 namespace util {
 
 bool assemble_write_same_extent(
-    const ObjectExtent &object_extent, const ceph::bufferlist& data,
+    const LightweightObjectExtent &object_extent, const ceph::bufferlist& data,
     ceph::bufferlist *ws_data, bool force_write) {
   size_t data_len = data.length();
 
index c1f373d40bc69781e0b96511659a419f0c0a5ae5..285985036de280e44bdb090f41c9fa70fb7d7026 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "include/int_types.h"
 #include "include/buffer_fwd.h"
+#include "librbd/io/Types.h"
 #include <map>
 
 class ObjectExtent;
@@ -14,7 +15,7 @@ namespace librbd {
 namespace io {
 namespace util {
 
-bool assemble_write_same_extent(const ObjectExtent &object_extent,
+bool assemble_write_same_extent(const LightweightObjectExtent &object_extent,
                                 const ceph::bufferlist& data,
                                 ceph::bufferlist *ws_data,
                                 bool force_write);
index 5ae95a8acf54091f0da65f5fc91945d30246caaa..77728e6a4d28c93ea54b054e47dbfffb418ea67d 100644 (file)
@@ -129,7 +129,7 @@ bool ObjectDispatch<I>::write(
 template <typename I>
 bool ObjectDispatch<I>::write_same(
     uint64_t object_no, uint64_t object_off, uint64_t object_len,
-    io::Extents&& buffer_extents, ceph::bufferlist&& data,
+    io::LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
     const ::SnapContext &snapc, int op_flags,
     const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
     uint64_t* journal_tid, io::DispatchResult* dispatch_result,
index fe3e22f5ff24156992157c7a119645708fba4ac0..47b19524a93f204c56b22473e5ceabaf54c9c723 100644 (file)
@@ -63,7 +63,7 @@ public:
 
   bool write_same(
       uint64_t object_no, uint64_t object_off, uint64_t object_len,
-      io::Extents&& buffer_extents, ceph::bufferlist&& data,
+      io::LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
       const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
       uint64_t* journal_tid, io::DispatchResult* dispatch_result,
index 57123b32905a330fbfef453508e0c6e138cc6380..d76acab323d1480f9def2880f64b84e1dda8e9e9 100644 (file)
@@ -167,7 +167,7 @@ TEST_F(TestMockIoSimpleSchedulerObjectDispatch, WriteSame) {
   MockSimpleSchedulerObjectDispatch
       mock_simple_scheduler_object_dispatch(&mock_image_ctx);
 
-  io::Extents buffer_extents;
+  io::LightweightBufferExtents buffer_extents;
   ceph::bufferlist data;
   C_SaferCond cond;
   Context *on_finish = &cond;
index 5a81acb8b01856f4c7e70c09fce5f866a830d5df..bd3d28693e933f5e14847e6f48696d8179acc8a6 100644 (file)
@@ -67,12 +67,13 @@ public:
   }
 
   MOCK_METHOD10(execute_write_same,
-                bool(uint64_t, uint64_t, uint64_t, const Extents&,
+                bool(uint64_t, uint64_t, uint64_t,
+                     const LightweightBufferExtents&,
                      const ceph::bufferlist&, const ::SnapContext &, int*,
                      uint64_t*, DispatchResult*, Context *));
   bool write_same(
       uint64_t object_no, uint64_t object_off, uint64_t object_len,
-      Extents&& buffer_extents, ceph::bufferlist&& data,
+      LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data,
       const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, int* dispatch_flags,
       uint64_t* journal_tid, DispatchResult* dispatch_result,