From: Jason Dillaman Date: Mon, 26 Oct 2020 12:11:12 +0000 (-0400) Subject: librbd/migration: native format should not issue a new read request X-Git-Tag: v17.0.0~784^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=65a05a0aa6be392ba94a53f9c93963b454749b33;p=ceph-ci.git librbd/migration: native format should not issue a new read request 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 --- diff --git a/src/librbd/migration/FormatInterface.h b/src/librbd/migration/FormatInterface.h index 27669dd5116..d13521d1193 100644 --- a/src/librbd/migration/FormatInterface.h +++ b/src/librbd/migration/FormatInterface.h @@ -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; diff --git a/src/librbd/migration/ImageDispatch.cc b/src/librbd/migration/ImageDispatch.cc index bde0a6951c7..3aa2eeb0bcb 100644 --- a/src/librbd/migration/ImageDispatch.cc +++ b/src/librbd/migration/ImageDispatch.cc @@ -44,10 +44,9 @@ bool ImageDispatch::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 diff --git a/src/librbd/migration/NativeFormat.cc b/src/librbd/migration/NativeFormat.cc index b613f74e7ad..d7112b1fe6b 100644 --- a/src/librbd/migration/NativeFormat.cc +++ b/src/librbd/migration/NativeFormat.cc @@ -115,27 +115,6 @@ void NativeFormat::get_image_size(uint64_t snap_id, uint64_t* size, on_finish->complete(0); } -template -void NativeFormat::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 void NativeFormat::list_snaps(io::Extents&& image_extents, io::SnapIds&& snap_ids, int list_snaps_flags, diff --git a/src/librbd/migration/NativeFormat.h b/src/librbd/migration/NativeFormat.h index 0468be46594..b2ece89e767 100644 --- a/src/librbd/migration/NativeFormat.h +++ b/src/librbd/migration/NativeFormat.h @@ -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, diff --git a/src/librbd/migration/RawFormat.cc b/src/librbd/migration/RawFormat.cc index bce5b27585a..529a4da3773 100644 --- a/src/librbd/migration/RawFormat.cc +++ b/src/librbd/migration/RawFormat.cc @@ -95,7 +95,7 @@ void RawFormat::get_image_size(uint64_t snap_id, uint64_t* size, } template -void RawFormat::read( +bool RawFormat::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::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::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 diff --git a/src/librbd/migration/RawFormat.h b/src/librbd/migration/RawFormat.h index 28f98f08ddc..3bf1c3474d5 100644 --- a/src/librbd/migration/RawFormat.h +++ b/src/librbd/migration/RawFormat.h @@ -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; diff --git a/src/test/librbd/migration/test_mock_RawFormat.cc b/src/test/librbd/migration/test_mock_RawFormat.cc index 886a0e269b6..41337056401 100644 --- a/src/test/librbd/migration/test_mock_RawFormat.cc +++ b/src/test/librbd/migration/test_mock_RawFormat.cc @@ -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);