]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: temporarily redirect ImageRequestWQ IO through ImageDispatcher
authorJason Dillaman <dillaman@redhat.com>
Tue, 5 May 2020 23:35:58 +0000 (19:35 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 14 May 2020 15:56:45 +0000 (11:56 -0400)
The next series of commits will work to remove ImageRequestWQ from librbd.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
13 files changed:
src/librbd/api/DiffIterate.cc
src/librbd/image/CloseRequest.cc
src/librbd/image/RefreshRequest.cc
src/librbd/io/ImageDispatchSpec.cc
src/librbd/io/ImageDispatchSpec.h
src/librbd/io/ImageDispatcher.cc
src/librbd/io/ImageDispatcher.h
src/librbd/io/ImageRequestWQ.cc
src/librbd/operation/ResizeRequest.cc
src/test/librbd/io/test_mock_ImageRequestWQ.cc
src/test/librbd/journal/test_Replay.cc
src/test/librbd/operation/test_mock_ResizeRequest.cc
src/test/rbd_mirror/test_ImageSync.cc

index 4235679507da46b4e17932ebb6e0632b7a62f8dc..d0dffb11dfd8407ab2648363820cdd54fa10b5cb 100644 (file)
@@ -254,7 +254,6 @@ int DiffIterate<I>::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) {
index 5dba010b4befed6b50d645b3fda6ac35afea0e8c..9296e42da91c644e4ba9b2a710bcf2f2e6f5bb73 100644 (file)
@@ -172,7 +172,6 @@ void CloseRequest<I>::send_flush() {
     *m_image_ctx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp,
     io::FLUSH_SOURCE_INTERNAL, {});
   req->send();
-  delete req;
 }
 
 template <typename I>
index be887664295fc62d49b5b6595639e2afc6011459..25c30816711ba113771c4def444d89b8430fc534 100644 (file)
@@ -1233,7 +1233,6 @@ Context *RefreshRequest<I>::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
index 5c21e5969f5d401fd4915600374666b8eb041f3e..2ca0d82127b1001456316e6740e022bc9e30b6ee 100644 (file)
@@ -43,54 +43,6 @@ void ImageDispatchSpec<I>::C_Dispatcher::finish(int r) {
   image_dispatch_spec->finish(r);
 }
 
-template <typename I>
-struct ImageDispatchSpec<I>::SendVisitor
-  : public boost::static_visitor<void> {
-  ImageDispatchSpec* spec;
-
-  explicit SendVisitor(ImageDispatchSpec* spec)
-    : spec(spec) {
-  }
-
-  void operator()(Read& read) const {
-    ImageRequest<I>::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<I>::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<I>::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<I>::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<I>::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<I>::aio_flush(
-      &spec->m_image_ctx, spec->aio_comp, flush.flush_source,
-      spec->parent_trace);
-  }
-};
-
 template <typename I>
 struct ImageDispatchSpec<I>::IsWriteOpVisitor
   : public boost::static_visitor<bool> {
@@ -106,7 +58,7 @@ struct ImageDispatchSpec<I>::IsWriteOpVisitor
 
 template <typename I>
 void ImageDispatchSpec<I>::send() {
-  boost::apply_visitor(SendVisitor{this}, request);
+  image_dispatcher->send(this);
 }
 
 template <typename I>
@@ -149,6 +101,7 @@ bool ImageDispatchSpec<I>::is_write_op() const {
 
 template <typename I>
 void ImageDispatchSpec<I>::start_op() {
+  tid = 0;
   aio_comp->start_op();
 }
 
index 3b17414e31a492dbeecb7b59687f53e36d87d0b0..e489e94b23a4af94bc3f0e5a180d0ef5c4c6a9f8 100644 (file)
@@ -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();
index b9e00e15c19f4c28fbeb9f94c511066eb722b2f4..c1016ea9e46b2c471226ab6b7dc3a41a2e118ed4 100644 (file)
@@ -157,7 +157,7 @@ template <typename I>
 void ImageDispatcher<I>::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 <typename I>
 bool ImageDispatcher<I>::send_dispatch(
     ImageDispatchInterface* image_dispatch,
     ImageDispatchSpec<I>* 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);
index b1de734be28b012ad13ff9c6f06263148090ee65..7628cd38d16ef1ce3937c0e55cffeab838485571 100644 (file)
@@ -11,6 +11,7 @@
 #include "librbd/io/ImageDispatchSpec.h"
 #include "librbd/io/ImageDispatcherInterface.h"
 #include "librbd/io/Types.h"
+#include <atomic>
 #include <map>
 
 struct Context;
@@ -50,6 +51,8 @@ protected:
 private:
   struct SendVisitor;
 
+  std::atomic<uint64_t> m_next_tid{0};
+
   QueueImageDispatch<ImageCtxT>* m_queue_image_dispatch = nullptr;
   QosImageDispatch<ImageCtxT>* m_qos_image_dispatch = nullptr;
 
index 968a54ce77521e59347e309c120d294a6fd0df5d..4172179286b6383f835c2267fa47175d25d86514 100644 (file)
@@ -30,21 +30,6 @@ using util::create_context_callback;
 
 namespace io {
 
-namespace {
-
-template <typename I>
-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<I>::create_flush_request(
-    image_ctx, IMAGE_DISPATCH_LAYER_API_START, aio_comp, FLUSH_SOURCE_INTERNAL,
-    {});
-  req->send();
-  delete req;
-}
-
-} // anonymous namespace
-
 template <typename I>
 struct ImageRequestWQ<I>::C_AcquireLock : public Context {
   ImageRequestWQ *work_queue;
@@ -316,12 +301,7 @@ void ImageRequestWQ<I>::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<I>::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<I>::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<I>::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<I>::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<I>::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 <typename I>
@@ -643,8 +602,7 @@ void ImageRequestWQ<I>::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 <typename I>
@@ -844,7 +802,6 @@ void ImageRequestWQ<I>::process_io(ImageDispatchSpec<I> *req,
     unblock_overlapping_io(offset, length, tid);
     unblock_flushes();
   }
-  delete req;
 }
 
 template <typename I>
@@ -909,8 +866,10 @@ void ImageRequestWQ<I>::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<I>, &ImageRequestWQ<I>::handle_blocked_writes>(this), 0);
   }
 }
 
@@ -952,8 +911,7 @@ void ImageRequestWQ<I>::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 <typename I>
@@ -970,7 +928,6 @@ void ImageRequestWQ<I>::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();
 }
 
index 6179df66b17ec89af7759d61f7d2727d2e9c145f..4d8c51bb2a3cd653bdc402516bbd8febbfb0e4d0 100644 (file)
@@ -200,7 +200,6 @@ void ResizeRequest<I>::send_flush_cache() {
     image_ctx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp,
     io::FLUSH_SOURCE_INTERNAL, {});
   req->send();
-  delete req;
 }
 
 template <typename I>
index 61929e0f84d80a027544dc10640ff647a1096b0b..b3e24ff50cf0dd29d9d00bdf80db001ddc6d89cd 100644 (file)
@@ -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));
+                    MockImageDispatchSpecimage_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);
 
index 535198e3a7c9fac6334f40a1cf2164abe95b4acd..1fa86eea49298b5a7f960766cacb9b07b328c896 100644 (file)
@@ -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
index 71992734282d1911963449af382a19704a7fb55d..96dd70127a4a32131bd3c11e307a563706cdb650 100644 (file)
@@ -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);
index 2a830609fc783f183e4968cf3adbd4339eb184be..d97804fefedb83e17c5299454be02a744ba73be5 100644 (file)
@@ -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();
 }