From: Jason Dillaman Date: Tue, 5 May 2020 23:35:58 +0000 (-0400) Subject: librbd: temporarily redirect ImageRequestWQ IO through ImageDispatcher X-Git-Tag: v16.1.0~2318^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5687d923e318d05c0006ac99789716dfcd99ee6e;p=ceph.git librbd: temporarily redirect ImageRequestWQ IO through ImageDispatcher The next series of commits will work to remove ImageRequestWQ from librbd. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/api/DiffIterate.cc b/src/librbd/api/DiffIterate.cc index 4235679507da..d0dffb11dfd8 100644 --- a/src/librbd/api/DiffIterate.cc +++ b/src/librbd/api/DiffIterate.cc @@ -254,7 +254,6 @@ int DiffIterate::diff_iterate(I *ictx, *ictx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, io::FLUSH_SOURCE_INTERNAL, {}); req->send(); - delete req; } int r = flush_ctx.wait(); if (r < 0) { diff --git a/src/librbd/image/CloseRequest.cc b/src/librbd/image/CloseRequest.cc index 5dba010b4bef..9296e42da91c 100644 --- a/src/librbd/image/CloseRequest.cc +++ b/src/librbd/image/CloseRequest.cc @@ -172,7 +172,6 @@ void CloseRequest::send_flush() { *m_image_ctx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, io::FLUSH_SOURCE_INTERNAL, {}); req->send(); - delete req; } template diff --git a/src/librbd/image/RefreshRequest.cc b/src/librbd/image/RefreshRequest.cc index be887664295f..25c30816711b 100644 --- a/src/librbd/image/RefreshRequest.cc +++ b/src/librbd/image/RefreshRequest.cc @@ -1233,7 +1233,6 @@ Context *RefreshRequest::send_flush_aio() { m_image_ctx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, io::FLUSH_SOURCE_INTERNAL, {}); req->send(); - delete req; return nullptr; } else if (m_error_result < 0) { // propagate saved error back to caller diff --git a/src/librbd/io/ImageDispatchSpec.cc b/src/librbd/io/ImageDispatchSpec.cc index 5c21e5969f5d..2ca0d82127b1 100644 --- a/src/librbd/io/ImageDispatchSpec.cc +++ b/src/librbd/io/ImageDispatchSpec.cc @@ -43,54 +43,6 @@ void ImageDispatchSpec::C_Dispatcher::finish(int r) { image_dispatch_spec->finish(r); } -template -struct ImageDispatchSpec::SendVisitor - : public boost::static_visitor { - ImageDispatchSpec* spec; - - explicit SendVisitor(ImageDispatchSpec* spec) - : spec(spec) { - } - - void operator()(Read& read) const { - ImageRequest::aio_read( - &spec->m_image_ctx, spec->aio_comp, std::move(spec->image_extents), - std::move(read.read_result), spec->op_flags, spec->parent_trace); - } - - void operator()(Discard& discard) const { - ImageRequest::aio_discard( - &spec->m_image_ctx, spec->aio_comp, std::move(spec->image_extents), - discard.discard_granularity_bytes, spec->parent_trace); - } - - void operator()(Write& write) const { - ImageRequest::aio_write( - &spec->m_image_ctx, spec->aio_comp, std::move(spec->image_extents), - std::move(write.bl), spec->op_flags, spec->parent_trace); - } - - void operator()(WriteSame& write_same) const { - ImageRequest::aio_writesame( - &spec->m_image_ctx, spec->aio_comp, std::move(spec->image_extents), - std::move(write_same.bl), spec->op_flags, spec->parent_trace); - } - - void operator()(CompareAndWrite& compare_and_write) const { - ImageRequest::aio_compare_and_write( - &spec->m_image_ctx, spec->aio_comp, std::move(spec->image_extents), - std::move(compare_and_write.cmp_bl), std::move(compare_and_write.bl), - compare_and_write.mismatch_offset, spec->op_flags, - spec->parent_trace); - } - - void operator()(Flush& flush) const { - ImageRequest::aio_flush( - &spec->m_image_ctx, spec->aio_comp, flush.flush_source, - spec->parent_trace); - } -}; - template struct ImageDispatchSpec::IsWriteOpVisitor : public boost::static_visitor { @@ -106,7 +58,7 @@ struct ImageDispatchSpec::IsWriteOpVisitor template void ImageDispatchSpec::send() { - boost::apply_visitor(SendVisitor{this}, request); + image_dispatcher->send(this); } template @@ -149,6 +101,7 @@ bool ImageDispatchSpec::is_write_op() const { template void ImageDispatchSpec::start_op() { + tid = 0; aio_comp->start_op(); } diff --git a/src/librbd/io/ImageDispatchSpec.h b/src/librbd/io/ImageDispatchSpec.h index 3b17414e31a4..e489e94b23a4 100644 --- a/src/librbd/io/ImageDispatchSpec.h +++ b/src/librbd/io/ImageDispatchSpec.h @@ -203,13 +203,11 @@ private: : dispatcher_ctx(this), image_dispatcher(image_ctx.io_image_dispatcher), dispatch_layer(image_dispatch_layer), aio_comp(aio_comp), image_extents(std::move(image_extents)), request(std::move(request)), - op_flags(op_flags), parent_trace(parent_trace), tid(tid), - m_image_ctx(image_ctx) { + op_flags(op_flags), parent_trace(parent_trace), tid(tid) { + aio_comp->image_dispatcher_ctx = &dispatcher_ctx; aio_comp->get(); } - ImageCtxT& m_image_ctx; - void finish(int r); uint64_t extents_length(); diff --git a/src/librbd/io/ImageDispatcher.cc b/src/librbd/io/ImageDispatcher.cc index b9e00e15c19f..c1016ea9e46b 100644 --- a/src/librbd/io/ImageDispatcher.cc +++ b/src/librbd/io/ImageDispatcher.cc @@ -157,7 +157,7 @@ template void ImageDispatcher::finish(int r, ImageDispatchLayer image_dispatch_layer, uint64_t tid) { auto cct = this->m_image_ctx->cct; - ldout(cct, 20) << "tid=" << tid << dendl; + ldout(cct, 20) << "r=" << r << ", tid=" << tid << dendl; // loop in reverse order from last invoked dispatch layer calling its // handle_finished method @@ -189,6 +189,10 @@ template bool ImageDispatcher::send_dispatch( ImageDispatchInterface* image_dispatch, ImageDispatchSpec* image_dispatch_spec) { + if (image_dispatch_spec->tid == 0) { + image_dispatch_spec->tid = ++m_next_tid; + } + return boost::apply_visitor( SendVisitor{image_dispatch, image_dispatch_spec}, image_dispatch_spec->request); diff --git a/src/librbd/io/ImageDispatcher.h b/src/librbd/io/ImageDispatcher.h index b1de734be28b..7628cd38d16e 100644 --- a/src/librbd/io/ImageDispatcher.h +++ b/src/librbd/io/ImageDispatcher.h @@ -11,6 +11,7 @@ #include "librbd/io/ImageDispatchSpec.h" #include "librbd/io/ImageDispatcherInterface.h" #include "librbd/io/Types.h" +#include #include struct Context; @@ -50,6 +51,8 @@ protected: private: struct SendVisitor; + std::atomic m_next_tid{0}; + QueueImageDispatch* m_queue_image_dispatch = nullptr; QosImageDispatch* m_qos_image_dispatch = nullptr; diff --git a/src/librbd/io/ImageRequestWQ.cc b/src/librbd/io/ImageRequestWQ.cc index 968a54ce7752..4172179286b6 100644 --- a/src/librbd/io/ImageRequestWQ.cc +++ b/src/librbd/io/ImageRequestWQ.cc @@ -30,21 +30,6 @@ using util::create_context_callback; namespace io { -namespace { - -template -void flush_image(I& image_ctx, Context* on_finish) { - auto aio_comp = librbd::io::AioCompletion::create_and_start( - on_finish, util::get_image_ctx(&image_ctx), librbd::io::AIO_TYPE_FLUSH); - auto req = librbd::io::ImageDispatchSpec::create_flush_request( - image_ctx, IMAGE_DISPATCH_LAYER_API_START, aio_comp, FLUSH_SOURCE_INTERNAL, - {}); - req->send(); - delete req; -} - -} // anonymous namespace - template struct ImageRequestWQ::C_AcquireLock : public Context { ImageRequestWQ *work_queue; @@ -316,12 +301,7 @@ void ImageRequestWQ::aio_write(AioCompletion *c, uint64_t off, uint64_t len, op_flags, trace, tid); std::shared_lock owner_locker{m_image_ctx.owner_lock}; - if (m_image_ctx.non_blocking_aio || writes_blocked()) { - queue(req); - } else { - process_io(req, false); - finish_in_flight_io(); - } + queue(req); trace.event("finish"); } @@ -363,12 +343,7 @@ void ImageRequestWQ::aio_discard(AioCompletion *c, uint64_t off, discard_granularity_bytes, trace, tid); std::shared_lock owner_locker{m_image_ctx.owner_lock}; - if (m_image_ctx.non_blocking_aio || writes_blocked()) { - queue(req); - } else { - process_io(req, false); - finish_in_flight_io(); - } + queue(req); trace.event("finish"); } @@ -410,12 +385,7 @@ void ImageRequestWQ::aio_flush(AioCompletion *c, bool native_async) { } std::shared_lock owner_locker{m_image_ctx.owner_lock}; - if (m_image_ctx.non_blocking_aio || writes_blocked() || !writes_empty()) { - queue(req); - } else { - process_io(req, false); - finish_in_flight_io(); - } + queue(req); trace.event("finish"); } @@ -457,12 +427,7 @@ void ImageRequestWQ::aio_writesame(AioCompletion *c, uint64_t off, op_flags, trace, tid); std::shared_lock owner_locker{m_image_ctx.owner_lock}; - if (m_image_ctx.non_blocking_aio || writes_blocked()) { - queue(req); - } else { - process_io(req, false); - finish_in_flight_io(); - } + queue(req); trace.event("finish"); } @@ -506,12 +471,7 @@ void ImageRequestWQ::aio_compare_and_write(AioCompletion *c, std::move(cmp_bl), std::move(bl), mismatch_off, op_flags, trace, tid); std::shared_lock owner_locker{m_image_ctx.owner_lock}; - if (m_image_ctx.non_blocking_aio || writes_blocked()) { - queue(req); - } else { - process_io(req, false); - finish_in_flight_io(); - } + queue(req); trace.event("finish"); } @@ -623,8 +583,7 @@ void ImageRequestWQ::shut_down(Context *on_shutdown) { } } - // ensure that all in-flight IO is flushed - flush_image(m_image_ctx, on_shutdown); + m_image_ctx.op_work_queue->queue(on_shutdown, 0); } template @@ -643,8 +602,7 @@ void ImageRequestWQ::block_writes(Context *on_blocked) { } } - // ensure that all in-flight IO is flushed - flush_image(m_image_ctx, on_blocked); + m_image_ctx.op_work_queue->queue(on_blocked, 0); } template @@ -844,7 +802,6 @@ void ImageRequestWQ::process_io(ImageDispatchSpec *req, unblock_overlapping_io(offset, length, tid); unblock_flushes(); } - delete req; } template @@ -909,8 +866,10 @@ void ImageRequestWQ::finish_in_flight_write() { writes_blocked = true; } } + if (writes_blocked) { - flush_image(m_image_ctx, new C_BlockedWrites(this)); + m_image_ctx.op_work_queue->queue(create_context_callback< + ImageRequestWQ, &ImageRequestWQ::handle_blocked_writes>(this), 0); } } @@ -952,8 +911,7 @@ void ImageRequestWQ::finish_in_flight_io() { CephContext *cct = m_image_ctx.cct; ldout(cct, 5) << "completing shut down" << dendl; - ceph_assert(on_shutdown != nullptr); - flush_image(m_image_ctx, on_shutdown); + on_shutdown->complete(0); } template @@ -970,7 +928,6 @@ void ImageRequestWQ::fail_in_flight_io( finish_queued_io(write_op); remove_in_flight_write_ios(offset, length, write_op, tid); - delete req; finish_in_flight_io(); } diff --git a/src/librbd/operation/ResizeRequest.cc b/src/librbd/operation/ResizeRequest.cc index 6179df66b17e..4d8c51bb2a3c 100644 --- a/src/librbd/operation/ResizeRequest.cc +++ b/src/librbd/operation/ResizeRequest.cc @@ -200,7 +200,6 @@ void ResizeRequest::send_flush_cache() { image_ctx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, io::FLUSH_SOURCE_INTERNAL, {}); req->send(); - delete req; } template diff --git a/src/test/librbd/io/test_mock_ImageRequestWQ.cc b/src/test/librbd/io/test_mock_ImageRequestWQ.cc index 61929e0f84d8..b3e24ff50cf0 100644 --- a/src/test/librbd/io/test_mock_ImageRequestWQ.cc +++ b/src/test/librbd/io/test_mock_ImageRequestWQ.cc @@ -180,8 +180,8 @@ struct TestMockIoImageRequestWQ : public TestMockFixture { } void expect_front(MockImageRequestWQ &image_request_wq, - MockImageDispatchSpec *image_request) { - EXPECT_CALL(image_request_wq, front()).WillOnce(Return(image_request)); + MockImageDispatchSpec& image_request) { + EXPECT_CALL(image_request_wq, front()).WillOnce(Return(&image_request)); } void expect_is_refresh_request(MockTestImageCtx &mock_image_ctx, @@ -191,8 +191,8 @@ struct TestMockIoImageRequestWQ : public TestMockFixture { } void expect_dequeue(MockImageRequestWQ &image_request_wq, - MockImageDispatchSpec *image_request) { - EXPECT_CALL(image_request_wq, dequeue()).WillOnce(Return(image_request)); + MockImageDispatchSpec &image_request) { + EXPECT_CALL(image_request_wq, dequeue()).WillOnce(Return(&image_request)); } void expect_get_exclusive_lock_policy(MockTestImageCtx &mock_image_ctx, @@ -257,16 +257,16 @@ TEST_F(TestMockIoImageRequestWQ, AcquireLockError) { MockExclusiveLock mock_exclusive_lock; mock_image_ctx.exclusive_lock = &mock_exclusive_lock; - auto mock_queued_image_request = new MockImageDispatchSpec(); - expect_get_image_extents(*mock_queued_image_request, {}); - expect_get_tid(*mock_queued_image_request, 0); + MockImageDispatchSpec mock_queued_image_request; + expect_get_image_extents(mock_queued_image_request, {}); + expect_get_tid(mock_queued_image_request, 0); InSequence seq; MockImageRequestWQ mock_image_request_wq(&mock_image_ctx, "io", 60, nullptr); expect_signal(mock_image_request_wq); mock_image_request_wq.set_require_lock(DIRECTION_WRITE, true); - expect_is_write_op(*mock_queued_image_request, true); + expect_is_write_op(mock_queued_image_request, true); expect_queue(mock_image_request_wq); auto *aio_comp = new librbd::io::AioCompletion(); mock_image_request_wq.aio_write(aio_comp, 0, 0, {}, 0); @@ -274,7 +274,7 @@ TEST_F(TestMockIoImageRequestWQ, AcquireLockError) { librbd::exclusive_lock::MockPolicy mock_exclusive_lock_policy; expect_front(mock_image_request_wq, mock_queued_image_request); expect_is_refresh_request(mock_image_ctx, false); - expect_is_write_op(*mock_queued_image_request, true); + expect_is_write_op(mock_queued_image_request, true); expect_dequeue(mock_image_request_wq, mock_queued_image_request); expect_get_exclusive_lock_policy(mock_image_ctx, mock_exclusive_lock_policy); expect_may_auto_request_lock(mock_exclusive_lock_policy, true); @@ -284,8 +284,8 @@ TEST_F(TestMockIoImageRequestWQ, AcquireLockError) { ASSERT_TRUE(on_acquire != nullptr); expect_process_finish(mock_image_request_wq); - expect_fail(*mock_queued_image_request, -EPERM); - expect_is_write_op(*mock_queued_image_request, true); + expect_fail(mock_queued_image_request, -EPERM); + expect_is_write_op(mock_queued_image_request, true); expect_signal(mock_image_request_wq); on_acquire->complete(-EPERM); @@ -304,16 +304,16 @@ TEST_F(TestMockIoImageRequestWQ, AcquireLockBlacklisted) { MockExclusiveLock mock_exclusive_lock; mock_image_ctx.exclusive_lock = &mock_exclusive_lock; - auto mock_queued_image_request = new MockImageDispatchSpec(); - expect_get_image_extents(*mock_queued_image_request, {}); - expect_get_tid(*mock_queued_image_request, 0); + MockImageDispatchSpec mock_queued_image_request; + expect_get_image_extents(mock_queued_image_request, {}); + expect_get_tid(mock_queued_image_request, 0); InSequence seq; MockImageRequestWQ mock_image_request_wq(&mock_image_ctx, "io", 60, nullptr); expect_signal(mock_image_request_wq); mock_image_request_wq.set_require_lock(DIRECTION_WRITE, true); - expect_is_write_op(*mock_queued_image_request, true); + expect_is_write_op(mock_queued_image_request, true); expect_queue(mock_image_request_wq); auto *aio_comp = new librbd::io::AioCompletion(); mock_image_request_wq.aio_write(aio_comp, 0, 0, {}, 0); @@ -321,15 +321,15 @@ TEST_F(TestMockIoImageRequestWQ, AcquireLockBlacklisted) { librbd::exclusive_lock::MockPolicy mock_exclusive_lock_policy; expect_front(mock_image_request_wq, mock_queued_image_request); expect_is_refresh_request(mock_image_ctx, false); - expect_is_write_op(*mock_queued_image_request, true); + expect_is_write_op(mock_queued_image_request, true); expect_dequeue(mock_image_request_wq, mock_queued_image_request); expect_get_exclusive_lock_policy(mock_image_ctx, mock_exclusive_lock_policy); expect_may_auto_request_lock(mock_exclusive_lock_policy, false); EXPECT_CALL(*mock_image_ctx.exclusive_lock, get_unlocked_op_error()) .WillOnce(Return(-EBLACKLISTED)); expect_process_finish(mock_image_request_wq); - expect_fail(*mock_queued_image_request, -EBLACKLISTED); - expect_is_write_op(*mock_queued_image_request, true); + expect_fail(mock_queued_image_request, -EBLACKLISTED); + expect_is_write_op(mock_queued_image_request, true); expect_signal(mock_image_request_wq); ASSERT_TRUE(mock_image_request_wq.invoke_dequeue() == nullptr); @@ -344,21 +344,21 @@ TEST_F(TestMockIoImageRequestWQ, RefreshError) { MockTestImageCtx mock_image_ctx(*ictx); - auto mock_queued_image_request = new MockImageDispatchSpec(); - expect_get_image_extents(*mock_queued_image_request, {}); - expect_get_tid(*mock_queued_image_request, 0); + MockImageDispatchSpec mock_queued_image_request; + expect_get_image_extents(mock_queued_image_request, {}); + expect_get_tid(mock_queued_image_request, 0); InSequence seq; MockImageRequestWQ mock_image_request_wq(&mock_image_ctx, "io", 60, nullptr); - expect_is_write_op(*mock_queued_image_request, true); + expect_is_write_op(mock_queued_image_request, true); expect_queue(mock_image_request_wq); auto *aio_comp = new librbd::io::AioCompletion(); mock_image_request_wq.aio_write(aio_comp, 0, 0, {}, 0); expect_front(mock_image_request_wq, mock_queued_image_request); expect_is_refresh_request(mock_image_ctx, true); - expect_is_write_op(*mock_queued_image_request, true); + expect_is_write_op(mock_queued_image_request, true); expect_dequeue(mock_image_request_wq, mock_queued_image_request); Context *on_refresh = nullptr; expect_refresh(mock_image_ctx, &on_refresh); @@ -366,8 +366,8 @@ TEST_F(TestMockIoImageRequestWQ, RefreshError) { ASSERT_TRUE(on_refresh != nullptr); expect_process_finish(mock_image_request_wq); - expect_fail(*mock_queued_image_request, -EPERM); - expect_is_write_op(*mock_queued_image_request, true); + expect_fail(mock_queued_image_request, -EPERM); + expect_is_write_op(mock_queued_image_request, true); expect_signal(mock_image_request_wq); on_refresh->complete(-EPERM); diff --git a/src/test/librbd/journal/test_Replay.cc b/src/test/librbd/journal/test_Replay.cc index 535198e3a7c9..1fa86eea4929 100644 --- a/src/test/librbd/journal/test_Replay.cc +++ b/src/test/librbd/journal/test_Replay.cc @@ -865,7 +865,6 @@ TEST_F(TestJournalReplay, ObjectPosition) { *ictx, librbd::io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, librbd::io::FLUSH_SOURCE_INTERNAL, {}); req->send(); - delete req; ASSERT_EQ(0, flush_ctx.wait()); // check the commit position updated diff --git a/src/test/librbd/operation/test_mock_ResizeRequest.cc b/src/test/librbd/operation/test_mock_ResizeRequest.cc index 71992734282d..96dd70127a4a 100644 --- a/src/test/librbd/operation/test_mock_ResizeRequest.cc +++ b/src/test/librbd/operation/test_mock_ResizeRequest.cc @@ -251,8 +251,8 @@ TEST_F(TestMockOperationResizeRequest, ShrinkSuccess) { expect_unblock_writes(mock_image_ctx); MockTrimRequest mock_trim_request; - auto mock_io_image_dispatch_spec = new MockIoImageDispatchSpec(); - expect_flush_cache(mock_image_ctx, *mock_io_image_dispatch_spec, 0); + MockIoImageDispatchSpec mock_io_image_dispatch_spec; + expect_flush_cache(mock_image_ctx, mock_io_image_dispatch_spec, 0); expect_invalidate_cache(mock_image_ctx, 0); expect_trim(mock_image_ctx, mock_trim_request, 0); expect_block_writes(mock_image_ctx, 0); @@ -314,8 +314,8 @@ TEST_F(TestMockOperationResizeRequest, TrimError) { expect_unblock_writes(mock_image_ctx); MockTrimRequest mock_trim_request; - auto mock_io_image_dispatch_spec = new MockIoImageDispatchSpec(); - expect_flush_cache(mock_image_ctx, *mock_io_image_dispatch_spec, 0); + MockIoImageDispatchSpec mock_io_image_dispatch_spec; + expect_flush_cache(mock_image_ctx, mock_io_image_dispatch_spec, 0); expect_invalidate_cache(mock_image_ctx, -EBUSY); expect_trim(mock_image_ctx, mock_trim_request, -EINVAL); expect_commit_op_event(mock_image_ctx, -EINVAL); @@ -340,8 +340,8 @@ TEST_F(TestMockOperationResizeRequest, FlushCacheError) { expect_unblock_writes(mock_image_ctx); MockTrimRequest mock_trim_request; - auto mock_io_image_dispatch_spec = new MockIoImageDispatchSpec(); - expect_flush_cache(mock_image_ctx, *mock_io_image_dispatch_spec, -EINVAL); + MockIoImageDispatchSpec mock_io_image_dispatch_spec; + expect_flush_cache(mock_image_ctx, mock_io_image_dispatch_spec, -EINVAL); expect_commit_op_event(mock_image_ctx, -EINVAL); ASSERT_EQ(-EINVAL, when_resize(mock_image_ctx, ictx->size / 2, true, 0, false)); } @@ -364,8 +364,8 @@ TEST_F(TestMockOperationResizeRequest, InvalidateCacheError) { expect_unblock_writes(mock_image_ctx); MockTrimRequest mock_trim_request; - auto mock_io_image_dispatch_spec = new MockIoImageDispatchSpec(); - expect_flush_cache(mock_image_ctx, *mock_io_image_dispatch_spec, 0); + MockIoImageDispatchSpec mock_io_image_dispatch_spec; + expect_flush_cache(mock_image_ctx, mock_io_image_dispatch_spec, 0); expect_invalidate_cache(mock_image_ctx, -EINVAL); expect_commit_op_event(mock_image_ctx, -EINVAL); ASSERT_EQ(-EINVAL, when_resize(mock_image_ctx, ictx->size / 2, true, 0, false)); @@ -388,8 +388,8 @@ TEST_F(TestMockOperationResizeRequest, PostBlockWritesError) { expect_unblock_writes(mock_image_ctx); MockTrimRequest mock_trim_request; - auto mock_io_image_dispatch_spec = new MockIoImageDispatchSpec(); - expect_flush_cache(mock_image_ctx, *mock_io_image_dispatch_spec, 0); + MockIoImageDispatchSpec mock_io_image_dispatch_spec; + expect_flush_cache(mock_image_ctx, mock_io_image_dispatch_spec, 0); expect_invalidate_cache(mock_image_ctx, 0); expect_trim(mock_image_ctx, mock_trim_request, 0); expect_block_writes(mock_image_ctx, -EINVAL); diff --git a/src/test/rbd_mirror/test_ImageSync.cc b/src/test/rbd_mirror/test_ImageSync.cc index 2a830609fc78..d97804fefedb 100644 --- a/src/test/rbd_mirror/test_ImageSync.cc +++ b/src/test/rbd_mirror/test_ImageSync.cc @@ -39,7 +39,6 @@ int flush(librbd::ImageCtx *image_ctx) { *image_ctx, librbd::io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, librbd::io::FLUSH_SOURCE_INTERNAL, {}); req->send(); - delete req; return ctx.wait(); }