]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/migration: native format should not issue a new read request
authorJason Dillaman <dillaman@redhat.com>
Mon, 26 Oct 2020 12:11:12 +0000 (08:11 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 26 Oct 2020 16:01:11 +0000 (12:01 -0400)
Tweak the format interface's 'read' call to just let the existing
read request continue passed the migration layer if the native
format is in use. Otherwise, the provided AioCompletion would need to
be wrapped with another AioCompletion to prevent the original
image dispatch spec from getting lost.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/migration/FormatInterface.h
src/librbd/migration/ImageDispatch.cc
src/librbd/migration/NativeFormat.cc
src/librbd/migration/NativeFormat.h
src/librbd/migration/RawFormat.cc
src/librbd/migration/RawFormat.h
src/test/librbd/migration/test_mock_RawFormat.cc

index 27669dd51169a8c138b922aa80f147c842fa53e5..d13521d1193da0369290b81e193b0814bff33ea1 100644 (file)
@@ -35,7 +35,7 @@ struct FormatInterface {
   virtual void get_image_size(uint64_t snap_id, uint64_t* size,
                               Context* on_finish) = 0;
 
-  virtual void read(io::AioCompletion* aio_comp, uint64_t snap_id,
+  virtual bool read(io::AioCompletion* aio_comp, uint64_t snap_id,
                     io::Extents&& image_extents, io::ReadResult&& read_result,
                     int op_flags, int read_flags,
                     const ZTracer::Trace &parent_trace) = 0;
index bde0a6951c7d893a7354b578c36d3733679a7be7..3aa2eeb0bcb0a9a7096b53cc985f1ec7069758cf 100644 (file)
@@ -44,10 +44,9 @@ bool ImageDispatch<I>::read(
   ldout(cct, 20) << dendl;
 
   *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
-  m_format->read(aio_comp, io_context->read_snap().value_or(CEPH_NOSNAP),
-                 std::move(image_extents), std::move(read_result), op_flags,
-                 read_flags, parent_trace);
-  return true;
+  return m_format->read(aio_comp, io_context->read_snap().value_or(CEPH_NOSNAP),
+                        std::move(image_extents), std::move(read_result),
+                        op_flags, read_flags, parent_trace);
 }
 
 template <typename I>
index b613f74e7ad9f97544a08dd75dbd80ce57a0d6db..d7112b1fe6b4dc6d7e7c5c38fabeb5e69b78484a 100644 (file)
@@ -115,27 +115,6 @@ void NativeFormat<I>::get_image_size(uint64_t snap_id, uint64_t* size,
   on_finish->complete(0);
 }
 
-template <typename I>
-void NativeFormat<I>::read(
-    io::AioCompletion* aio_comp, uint64_t snap_id, io::Extents&& image_extents,
-    io::ReadResult&& read_result, int op_flags, int read_flags,
-    const ZTracer::Trace &parent_trace) {
-  auto cct = m_image_ctx->cct;
-  ldout(cct, 20) << "snap_id=" << snap_id << ", "
-                 << "image_extents=" << image_extents << dendl;
-
-  auto io_context = m_image_ctx->duplicate_data_io_context();
-  if (snap_id != CEPH_NOSNAP) {
-    io_context->read_snap(snap_id);
-  }
-
-  auto req = io::ImageDispatchSpec::create_read(
-    *m_image_ctx, io::IMAGE_DISPATCH_LAYER_MIGRATION, aio_comp,
-    std::move(image_extents), std::move(read_result), io_context, op_flags,
-    read_flags, {});
-  req->send();
-}
-
 template <typename I>
 void NativeFormat<I>::list_snaps(io::Extents&& image_extents,
                                  io::SnapIds&& snap_ids, int list_snaps_flags,
index 0468be46594366821fa2e407a698b6a28d937115..b2ece89e767bacc3a1f3b0de3fd99193ae47265d 100644 (file)
@@ -42,10 +42,12 @@ public:
   void get_image_size(uint64_t snap_id, uint64_t* size,
                       Context* on_finish) override;
 
-  void read(io::AioCompletion* aio_comp, uint64_t snap_id,
+  bool read(io::AioCompletion* aio_comp, uint64_t snap_id,
             io::Extents&& image_extents, io::ReadResult&& read_result,
             int op_flags, int read_flags,
-            const ZTracer::Trace &parent_trace) override;
+            const ZTracer::Trace &parent_trace) override {
+    return false;
+  }
 
   void list_snaps(io::Extents&& image_extents, io::SnapIds&& snap_ids,
                   int list_snaps_flags, io::SnapshotDelta* snapshot_delta,
index bce5b27585a7afa8caa84cf496d3cb2f7addc089..529a4da377382dff4b3af97827d2a1cbaea15983 100644 (file)
@@ -95,7 +95,7 @@ void RawFormat<I>::get_image_size(uint64_t snap_id, uint64_t* size,
 }
 
 template <typename I>
-void RawFormat<I>::read(
+bool RawFormat<I>::read(
     io::AioCompletion* aio_comp, uint64_t snap_id, io::Extents&& image_extents,
     io::ReadResult&& read_result, int op_flags, int read_flags,
     const ZTracer::Trace &parent_trace) {
@@ -104,7 +104,7 @@ void RawFormat<I>::read(
 
   if (snap_id != CEPH_NOSNAP) {
     aio_comp->fail(-EINVAL);
-    return;
+    return true;
   }
 
   aio_comp->read_result = std::move(read_result);
@@ -116,6 +116,7 @@ void RawFormat<I>::read(
 
   // raw directly maps the image-extent IO down to a byte IO extent
   m_stream->read(std::move(image_extents), &ctx->bl, ctx);
+  return true;
 }
 
 template <typename I>
index 28f98f08ddc263c682ce2cb861d5e4785055970a..3bf1c3474d5c06765c99b8b7c95fb1f1dcf79601 100644 (file)
@@ -40,7 +40,7 @@ public:
   void get_image_size(uint64_t snap_id, uint64_t* size,
                       Context* on_finish) override;
 
-  void read(io::AioCompletion* aio_comp, uint64_t snap_id,
+  bool read(io::AioCompletion* aio_comp, uint64_t snap_id,
             io::Extents&& image_extents, io::ReadResult&& read_result,
             int op_flags, int read_flags,
             const ZTracer::Trace &parent_trace) override;
index 886a0e269b6f3da6b7f0be63f24befaf7d144d81..4133705640163a9846eb971adf7cc66196c4dd4d 100644 (file)
@@ -237,8 +237,8 @@ TEST_F(TestMockMigrationRawFormat, Read) {
     &ctx2, m_image_ctx, io::AIO_TYPE_READ);
   bufferlist bl;
   io::ReadResult read_result{&bl};
-  mock_raw_format.read(aio_comp, CEPH_NOSNAP, {{123, 123}},
-                       std::move(read_result), 0, 0, {});
+  ASSERT_TRUE(mock_raw_format.read(aio_comp, CEPH_NOSNAP, {{123, 123}},
+                                   std::move(read_result), 0, 0, {}));
   ASSERT_EQ(123, ctx2.wait());
   ASSERT_EQ(expect_bl, bl);