From 60679fc53a1defa5cac84ae2aec6f0992e60bb7f Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 6 Apr 2016 17:30:11 -0400 Subject: [PATCH] librbd: restore out-of-band future callbacks to avoid lock cycles Signed-off-by: Jason Dillaman --- src/librbd/Journal.cc | 10 ++++++---- src/test/librbd/test_mock_Journal.cc | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/librbd/Journal.cc b/src/librbd/Journal.cc index df30cb349e6..265a869d36f 100644 --- a/src/librbd/Journal.cc +++ b/src/librbd/Journal.cc @@ -827,7 +827,8 @@ uint64_t Journal::append_io_event(AioCompletion *aio_comp, << "length=" << length << ", " << "flush=" << flush_entry << ", tid=" << tid << dendl; - Context *on_safe = new C_IOEventSafe(this, tid); + Context *on_safe = create_async_context_callback( + m_image_ctx, new C_IOEventSafe(this, tid)); if (flush_entry) { future.flush(on_safe); } else { @@ -942,8 +943,9 @@ void Journal::commit_op_event(uint64_t op_tid, int r) { op_finish_future = m_journaler->append(m_tag_tid, bl); } - op_finish_future.flush(new C_OpEventSafe(this, op_tid, op_start_future, - op_finish_future)); + op_finish_future.flush(create_async_context_callback( + m_image_ctx, new C_OpEventSafe(this, op_tid, op_start_future, + op_finish_future))); } template @@ -971,7 +973,7 @@ void Journal::flush_event(uint64_t tid, Context *on_safe) { } if (future.is_valid()) { - future.flush(NULL); + future.flush(nullptr); } } diff --git a/src/test/librbd/test_mock_Journal.cc b/src/test/librbd/test_mock_Journal.cc index 881ac16573f..9ebea8f3e70 100644 --- a/src/test/librbd/test_mock_Journal.cc +++ b/src/test/librbd/test_mock_Journal.cc @@ -944,6 +944,7 @@ TEST_F(TestMockJournal, EventAndIOCommitOrder) { // commit journal event followed by IO event (standard) on_journal_safe1->complete(0); + ictx->op_work_queue->drain(); expect_future_committed(mock_journaler); mock_journal.commit_io_event(1U, 0); @@ -954,6 +955,7 @@ TEST_F(TestMockJournal, EventAndIOCommitOrder) { C_SaferCond event_ctx; mock_journal.wait_event(2U, &event_ctx); on_journal_safe2->complete(0); + ictx->op_work_queue->drain(); ASSERT_EQ(0, event_ctx.wait()); } @@ -1054,6 +1056,7 @@ TEST_F(TestMockJournal, IOCommitError) { // failed IO remains uncommitted in journal on_journal_safe->complete(0); + ictx->op_work_queue->drain(); mock_journal.commit_io_event(1U, -EINVAL); } -- 2.47.3