]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: pass read flags via image-extent dispatch layers
authorJason Dillaman <dillaman@redhat.com>
Thu, 3 Sep 2020 14:02:05 +0000 (10:02 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 21 Sep 2020 11:51:56 +0000 (07:51 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
26 files changed:
src/librbd/api/Io.cc
src/librbd/cache/ImageWriteback.cc
src/librbd/deep_copy/ObjectCopyRequest.cc
src/librbd/exclusive_lock/ImageDispatch.cc
src/librbd/exclusive_lock/ImageDispatch.h
src/librbd/internal.cc
src/librbd/io/CopyupRequest.cc
src/librbd/io/ImageDispatch.cc
src/librbd/io/ImageDispatch.h
src/librbd/io/ImageDispatchInterface.h
src/librbd/io/ImageDispatchSpec.h
src/librbd/io/ImageDispatcher.cc
src/librbd/io/ImageRequest.cc
src/librbd/io/ImageRequest.h
src/librbd/io/QosImageDispatch.cc
src/librbd/io/QosImageDispatch.h
src/librbd/io/QueueImageDispatch.cc
src/librbd/io/QueueImageDispatch.h
src/librbd/io/RefreshImageDispatch.cc
src/librbd/io/RefreshImageDispatch.h
src/librbd/io/Utils.cc
src/librbd/io/WriteBlockImageDispatch.h
src/test/librbd/deep_copy/test_mock_ObjectCopyRequest.cc
src/test/librbd/io/test_mock_CopyupRequest.cc
src/test/librbd/io/test_mock_ImageRequest.cc
src/test/librbd/mock/io/MockImageDispatch.h

index 900e607a3496e748675f6b796a114671de619f46..31b48b3f6b8d56b77167dfa8a6bb8e132b25595c 100644 (file)
@@ -232,7 +232,8 @@ void Io<I>::aio_read(I &image_ctx, io::AioCompletion *aio_comp, uint64_t off,
 
   auto req = io::ImageDispatchSpec::create_read(
     image_ctx, io::IMAGE_DISPATCH_LAYER_API_START, aio_comp, {{off, len}},
-    std::move(read_result), image_ctx.get_data_io_context(), op_flags, trace);
+    std::move(read_result), image_ctx.get_data_io_context(), op_flags, 0,
+    trace);
   req->send();
 }
 
index dbc22778b7f6b690c0663459efe2ab60c8b8d73b..af39090e4bfebc93013204df43d0abc9010cd0fe 100644 (file)
@@ -35,7 +35,7 @@ void ImageWriteback<I>::aio_read(Extents &&image_extents, bufferlist *bl,
   io::ImageReadRequest<> req(*image_ctx, aio_comp, std::move(image_extents),
                               io::ReadResult{bl},
                               image_ctx->get_data_io_context(), fadvise_flags,
-                              {});
+                              0, {});
   req.set_bypass_image_cache();
   req.send();
 }
index a4a18cd5fe1afdee6d333643a44c51e1d9c958d9..0ece45aafa95fd386977d975f926ad181bea4f9d 100644 (file)
@@ -267,7 +267,7 @@ void ObjectCopyRequest<I>::send_read_from_parent() {
   io::ImageRequest<I>::aio_read(src_image_ctx->parent, comp,
                                 std::move(image_extents),
                                 io::ReadResult{&m_read_from_parent_data},
-                                src_image_ctx->get_data_io_context(), 0,
+                                src_image_ctx->get_data_io_context(), 0, 0,
                                 ZTracer::Trace());
 }
 
index e980efc391bb76080e968657f81890c955c8eb32..c4e04970a7cdf433438c900c5df137dbadf94d6f 100644 (file)
@@ -106,7 +106,7 @@ template <typename I>
 bool ImageDispatch<I>::read(
     io::AioCompletion* aio_comp, io::Extents &&image_extents,
     io::ReadResult &&read_result, IOContext io_context, int op_flags,
-    const ZTracer::Trace &parent_trace, uint64_t tid,
+    int read_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
     std::atomic<uint32_t>* image_dispatch_flags,
     io::DispatchResult* dispatch_result, Context** on_finish,
     Context* on_dispatched) {
index 1ce28a21cfc07bc50c14880083e0ab7d3568fe41..c6c0058949c6de57be32c336fa49fee66815b5f3 100644 (file)
@@ -52,7 +52,7 @@ public:
   bool read(
       io::AioCompletion* aio_comp, io::Extents &&image_extents,
       io::ReadResult &&read_result, IOContext io_context, int op_flags,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
+      int read_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
       std::atomic<uint32_t>* image_dispatch_flags,
       io::DispatchResult* dispatch_result, Context** on_finish,
       Context* on_dispatched) override;
index 3dcf674fbd76ab38a3ab75de5050fc5c8b90fff9..d8bd8b7147e67f82b3845a6758f9395117416e30 100644 (file)
@@ -1331,7 +1331,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
 
       io::ImageReadRequest<> req(*src, comp, {{offset, len}},
                                 io::ReadResult{bl}, src->get_data_io_context(),
-                                 fadvise_flags, std::move(trace));
+                                 fadvise_flags, 0, std::move(trace));
       ctx->read_trace = req.get_trace();
 
       req.send();
@@ -1542,7 +1542,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
                                                    io::AIO_TYPE_READ);
       io::ImageRequest<>::aio_read(ictx, c, {{off, read_len}},
                                    io::ReadResult{&bl},
-                                   ictx->get_data_io_context(), 0,
+                                   ictx->get_data_io_context(), 0, 0,
                                    std::move(trace));
 
       int ret = ctx.wait();
index 7ab03928ed11717ef9f561d3874c974833c55c39..11e5e3733b951886f77f12406d80dbef230daea8 100644 (file)
@@ -176,12 +176,12 @@ void CopyupRequest<I>::read_from_parent() {
     ImageRequest<I>::aio_read(
       m_image_ctx->parent, comp, std::move(m_image_extents),
       ReadResult{&m_copyup_extent_map, &m_copyup_data},
-      m_image_ctx->parent->get_data_io_context(), 0, m_trace);
+      m_image_ctx->parent->get_data_io_context(), 0, 0, m_trace);
   } else {
     ImageRequest<I>::aio_read(
       m_image_ctx->parent, comp, std::move(m_image_extents),
       ReadResult{&m_copyup_data},
-      m_image_ctx->parent->get_data_io_context(), 0, m_trace);
+      m_image_ctx->parent->get_data_io_context(), 0, 0, m_trace);
   }
 }
 
index 161dac5025602441230d95a74d8e16319af434ad..2413b16b994b185a18748d9aa8362845dd6bcd99 100644 (file)
@@ -34,8 +34,9 @@ void ImageDispatch<I>::shut_down(Context* on_finish) {
 template <typename I>
 bool ImageDispatch<I>::read(
     AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result,
-    IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
-    uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
+    IOContext io_context, int op_flags, int read_flags,
+    const ZTracer::Trace &parent_trace, uint64_t tid,
+    std::atomic<uint32_t>* image_dispatch_flags,
     DispatchResult* dispatch_result, Context** on_finish,
     Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
@@ -46,7 +47,7 @@ bool ImageDispatch<I>::read(
   *dispatch_result = DISPATCH_RESULT_COMPLETE;
   ImageRequest<I>::aio_read(
     m_image_ctx, aio_comp, std::move(image_extents), std::move(read_result),
-    io_context, op_flags, parent_trace);
+    io_context, op_flags, read_flags, parent_trace);
   return true;
 }
 
index d12d9e7c79d980a4ac7d6f34c1ad7b23ea9730e7..512f28e2420de25b68eea925e7fd07fc72523f0c 100644 (file)
@@ -36,7 +36,7 @@ public:
   bool read(
       AioCompletion* aio_comp, Extents &&image_extents,
       ReadResult &&read_result, IOContext io_context, int op_flags,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
+      int read_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
       std::atomic<uint32_t>* image_dispatch_flags,
       DispatchResult* dispatch_result, Context** on_finish,
       Context* on_dispatched) override;
index 973f6fe13ee1d7e4da2989ebd1042055a10ac4b5..1e563a634fe2cd25177a5771b4f7b64020ffa338 100644 (file)
@@ -34,7 +34,7 @@ struct ImageDispatchInterface {
   virtual bool read(
       AioCompletion* aio_comp, Extents &&image_extents,
       ReadResult &&read_result, IOContext io_context, int op_flags,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
+      int read_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
       std::atomic<uint32_t>* image_dispatch_flags,
       DispatchResult* dispatch_result, Context** on_finish,
       Context* on_dispatched) = 0;
index 4ed8788092f4fe0e6c4ca1cfe305d3ed182d711a..4b62c356ed05630c97f235ff057339644f1272e6 100644 (file)
@@ -39,8 +39,10 @@ private:
 public:
   struct Read {
     ReadResult read_result;
+    int read_flags;
 
-    Read(ReadResult &&read_result) : read_result(std::move(read_result)) {
+    Read(ReadResult &&read_result, int read_flags)
+      : read_result(std::move(read_result)), read_flags(read_flags) {
     }
   };
 
@@ -125,11 +127,11 @@ public:
       ImageCtxT &image_ctx, ImageDispatchLayer image_dispatch_layer,
       AioCompletion *aio_comp, Extents &&image_extents,
       ReadResult &&read_result, IOContext io_context, int op_flags,
-      const ZTracer::Trace &parent_trace) {
+      int read_flags, const ZTracer::Trace &parent_trace) {
     return new ImageDispatchSpec(image_ctx.io_image_dispatcher,
                                  image_dispatch_layer, aio_comp,
                                  std::move(image_extents),
-                                 Read{std::move(read_result)},
+                                 Read{std::move(read_result), read_flags},
                                  io_context, op_flags, parent_trace);
   }
 
index 728baf24a08daa7d66ae883c9fb2056faaabcaab..6c2863bccbb67653fa058d9688f4ff0ddacc2745 100644 (file)
@@ -41,8 +41,8 @@ struct ImageDispatcher<I>::SendVisitor : public boost::static_visitor<bool> {
       image_dispatch_spec->aio_comp,
       std::move(image_dispatch_spec->image_extents),
       std::move(read.read_result), image_dispatch_spec->io_context,
-      image_dispatch_spec->op_flags, image_dispatch_spec->parent_trace,
-      image_dispatch_spec->tid,
+      image_dispatch_spec->op_flags, read.read_flags,
+      image_dispatch_spec->parent_trace, image_dispatch_spec->tid,
       &image_dispatch_spec->image_dispatch_flags,
       &image_dispatch_spec->dispatch_result,
       &image_dispatch_spec->aio_comp->image_dispatcher_ctx,
index b9b624b5975156b313c323b9053f6983b9dbbc7f..f57857c323a56b29eed4bdaaea14cf7aa673b0c0 100644 (file)
@@ -237,11 +237,11 @@ template <typename I>
 void ImageRequest<I>::aio_read(I *ictx, AioCompletion *c,
                                Extents &&image_extents,
                                ReadResult &&read_result, IOContext io_context,
-                               int op_flags,
+                               int op_flags, int read_flags,
                               const ZTracer::Trace &parent_trace) {
   ImageReadRequest<I> req(*ictx, c, std::move(image_extents),
                           std::move(read_result), io_context, op_flags,
-                          parent_trace);
+                          read_flags, parent_trace);
   req.send();
 }
 
@@ -423,10 +423,11 @@ ImageReadRequest<I>::ImageReadRequest(I &image_ctx, AioCompletion *aio_comp,
                                       Extents &&image_extents,
                                       ReadResult &&read_result,
                                       IOContext io_context, int op_flags,
-                                     const ZTracer::Trace &parent_trace)
+                                     int read_flags,
+                                      const ZTracer::Trace &parent_trace)
   : ImageRequest<I>(image_ctx, aio_comp, std::move(image_extents),
                     io_context, "read", parent_trace),
-    m_op_flags(op_flags) {
+    m_op_flags(op_flags), m_read_flags(read_flags) {
   aio_comp->read_result = std::move(read_result);
 }
 
@@ -482,8 +483,8 @@ void ImageReadRequest<I>::send_request() {
       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}}, this->m_io_context, m_op_flags, 0, this->m_trace,
-      &req_comp->bl, &req_comp->extent_map, nullptr, req_comp);
+      {{oe.offset, oe.length}}, this->m_io_context, m_op_flags, m_read_flags,
+      this->m_trace, &req_comp->bl, &req_comp->extent_map, nullptr, req_comp);
     req->send();
   }
 
index 65ac9ca37fc2eb7a7d519d8ba53366c416d5a599..dabda6b6d85a415df628c7ea6fd2c06aa65056a2 100644 (file)
@@ -35,7 +35,7 @@ public:
 
   static void aio_read(ImageCtxT *ictx, AioCompletion *c,
                        Extents &&image_extents, ReadResult &&read_result,
-                       IOContext io_context, int op_flags,
+                       IOContext io_context, int op_flags, int read_flags,
                        const ZTracer::Trace &parent_trace);
   static void aio_write(ImageCtxT *ictx, AioCompletion *c,
                         Extents &&image_extents, bufferlist &&bl,
@@ -111,7 +111,7 @@ public:
 
   ImageReadRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp,
                    Extents &&image_extents, ReadResult &&read_result,
-                   IOContext io_context, int op_flags,
+                   IOContext io_context, int op_flags, int read_flags,
                    const ZTracer::Trace &parent_trace);
 
 protected:
@@ -128,6 +128,7 @@ protected:
   }
 private:
   int m_op_flags;
+  int m_read_flags;
 };
 
 template <typename ImageCtxT = ImageCtx>
index 0901f80e668f7241f36c0e350eee9f36ebd794b3..9ca88ac1916aa0c625ffd6526818f29c0d33b2a6 100644 (file)
@@ -116,8 +116,9 @@ void QosImageDispatch<I>::apply_qos_limit(uint64_t flag, uint64_t limit,
 template <typename I>
 bool QosImageDispatch<I>::read(
     AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result,
-    IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
-    uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
+    IOContext io_context, int op_flags, int read_flags,
+    const ZTracer::Trace &parent_trace, uint64_t tid,
+    std::atomic<uint32_t>* image_dispatch_flags,
     DispatchResult* dispatch_result, Context** on_finish,
     Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
index 9e73ddf8ce900be802c5b0ce79fc5f84c042179e..8ea12d64b8373abe95e27946f226f6b312c8fb09 100644 (file)
@@ -53,7 +53,7 @@ public:
   bool read(
       AioCompletion* aio_comp, Extents &&image_extents,
       ReadResult &&read_result, IOContext io_context, int op_flags,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
+      int read_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
       std::atomic<uint32_t>* image_dispatch_flags,
       DispatchResult* dispatch_result, Context** on_finish,
       Context* on_dispatched) override;
index d2f1ec3e9bd859c89e55023a64675ecf400ba1c6..e80d39e44210e64994ae3a66b9c5877aa4e2b2a0 100644 (file)
@@ -40,8 +40,9 @@ void QueueImageDispatch<I>::shut_down(Context* on_finish) {
 template <typename I>
 bool QueueImageDispatch<I>::read(
     AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result,
-    IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
-    uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
+    IOContext io_context, int op_flags, int read_flags,
+    const ZTracer::Trace &parent_trace, uint64_t tid,
+    std::atomic<uint32_t>* image_dispatch_flags,
     DispatchResult* dispatch_result, Context** on_finish,
     Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
index 83a683ff2716785a43f7a8bd14b653b7296ba8f7..ec94b61d84624496fb066728b96176925c6417f8 100644 (file)
@@ -40,7 +40,7 @@ public:
   bool read(
       AioCompletion* aio_comp, Extents &&image_extents,
       ReadResult &&read_result, IOContext io_context, int op_flags,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
+      int read_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
       std::atomic<uint32_t>* image_dispatch_flags,
       DispatchResult* dispatch_result, Context** on_finish,
       Context* on_dispatched) override;
index 9017804209a5d7007ca64f0f81c22fd1f3a08dd1..5199f01d85d8f257cad62e86d9ce84103f856bdd 100644 (file)
@@ -30,8 +30,9 @@ void RefreshImageDispatch<I>::shut_down(Context* on_finish) {
 template <typename I>
 bool RefreshImageDispatch<I>::read(
     AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result,
-    IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
-    uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
+    IOContext io_context, int op_flags, int read_flags,
+    const ZTracer::Trace &parent_trace, uint64_t tid,
+    std::atomic<uint32_t>* image_dispatch_flags,
     DispatchResult* dispatch_result, Context** on_finish,
     Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
index 976960cc4bf9941208675c36f46a1abd34e29c2f..144d97bafe8e0bc2c9d664b75c90478a7af742c6 100644 (file)
@@ -36,7 +36,7 @@ public:
   bool read(
       AioCompletion* aio_comp, Extents &&image_extents,
       ReadResult &&read_result, IOContext io_context, int op_flags,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
+      int read_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
       std::atomic<uint32_t>* image_dispatch_flags,
       DispatchResult* dispatch_result, Context** on_finish,
       Context* on_dispatched) override;
index a4f143d74f2ac7844388ca12ac15a699b3f441a4..797006471ec3f710c2b2281fa6e38ca9564b5470 100644 (file)
@@ -119,7 +119,7 @@ void read_parent(I *image_ctx, uint64_t object_no, const Extents &extents,
 
   ImageRequest<I>::aio_read(
     image_ctx->parent, comp, std::move(parent_extents), ReadResult{data},
-    image_ctx->parent->get_data_io_context(), 0, trace);
+    image_ctx->parent->get_data_io_context(), 0, 0, trace);
 }
 
 } // namespace util
index 4af6e25eb14a450f0988b7e0e8bae5902c014ec7..e8b9407cf543373b9219f10e558a75101ab27010 100644 (file)
@@ -49,7 +49,7 @@ public:
   bool read(
       AioCompletion* aio_comp, Extents &&image_extents,
       ReadResult &&read_result, IOContext io_context, int op_flags,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
+      int read_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
       std::atomic<uint32_t>* image_dispatch_flags,
       DispatchResult* dispatch_result, Context** on_finish,
       Context* on_dispatched) override {
index 5ef42ba9852aca68fea5bc431f804a89d78223e0..cd3e255144aa11bb98b578df79ca19a3601024f5 100644 (file)
@@ -49,6 +49,7 @@ struct ImageRequest<MockTestImageCtx> {
   static void aio_read(MockTestImageCtx *ictx, AioCompletion *c,
                        Extents &&image_extents, ReadResult &&read_result,
                        IOContext io_context, int op_flags,
+                       int read_flags,
                        const ZTracer::Trace &parent_trace) {
     ceph_assert(s_instance != nullptr);
     s_instance->aio_read(c, image_extents);
index f00ec1861a9322b93af6a0cc0135f21f46708aa8..69aaab7c8eed22ee226309f0a589cef3e5b80c47 100644 (file)
@@ -105,7 +105,7 @@ struct ImageRequest<librbd::MockTestImageCtx> {
   static ImageRequest *s_instance;
   static void aio_read(librbd::MockImageCtx *ictx, AioCompletion *c,
                        Extents &&image_extents, ReadResult &&read_result,
-                       IOContext io_context, int op_flags,
+                       IOContext io_context, int op_flags, int read_flags,
                        const ZTracer::Trace &parent_trace) {
     s_instance->aio_read(c, image_extents, &read_result);
   }
index 196a5c70a90896c778e7c39eb2f6dda30ecdc894..968207fb218202c7090a6802a11d6138c7c6e7be 100644 (file)
@@ -265,7 +265,7 @@ TEST_F(TestMockIoImageRequest, AioReadAccessTimestamp) {
   ReadResult rr;
   MockImageReadRequest mock_aio_image_read_1(
     mock_image_ctx, aio_comp_1, {{0, 1}}, std::move(rr),
-    mock_image_ctx.get_data_io_context(), 0, {});
+    mock_image_ctx.get_data_io_context(), 0, 0, {});
   {
     std::shared_lock owner_locker{mock_image_ctx.owner_lock};
     mock_aio_image_read_1.send();
@@ -278,7 +278,7 @@ TEST_F(TestMockIoImageRequest, AioReadAccessTimestamp) {
 
   MockImageReadRequest mock_aio_image_read_2(
     mock_image_ctx, aio_comp_2, {{0, 1}}, std::move(rr),
-    mock_image_ctx.get_data_io_context(), 0, {});
+    mock_image_ctx.get_data_io_context(), 0, 0, {});
   {
     std::shared_lock owner_locker{mock_image_ctx.owner_lock};
     mock_aio_image_read_2.send();
index 40804d2431ca02254d89e6125dd1d1a3c010834a..ebd2d829f6f296a9ff1893d4f673b4d124a81fd9 100644 (file)
@@ -23,7 +23,7 @@ public:
   bool read(
       AioCompletion* aio_comp, Extents &&image_extents,
       ReadResult &&read_result, IOContext io_context, int op_flags,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
+      int read_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
       std::atomic<uint32_t>* image_dispatch_flags,
       DispatchResult* dispatch_result, Context** on_finish,
       Context* on_dispatched) override {