From 41987c8611f254a71f8f2aa73824d0e80a76fb6a Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 15 Jan 2016 10:38:54 -0500 Subject: [PATCH] librbd: avoid recursive callback when replaying journal Signed-off-by: Jason Dillaman --- src/librbd/journal/Replay.cc | 8 ++++---- src/test/librbd/journal/test_mock_Replay.cc | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/librbd/journal/Replay.cc b/src/librbd/journal/Replay.cc index f224214f9b5a1..c2cddde6a7095 100644 --- a/src/librbd/journal/Replay.cc +++ b/src/librbd/journal/Replay.cc @@ -47,6 +47,8 @@ void Replay::process(bufferlist::iterator *it, Context *on_ready, CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << this << " " << __func__ << dendl; + on_ready = util::create_async_context_callback(m_image_ctx, on_ready); + journal::EventEntry event_entry; try { ::decode(event_entry, *it); @@ -255,8 +257,7 @@ void Replay::handle_event(const journal::SnapCreateEvent &event, // do not process more events until the state machine is ready // since it will affect IO op_event->op_in_progress = true; - op_event->on_start_ready = util::create_async_context_callback( - m_image_ctx, on_ready); + op_event->on_start_ready = on_ready; } template @@ -393,8 +394,7 @@ void Replay::handle_event(const journal::ResizeEvent &event, // do not process more events until the state machine is ready // since it will affect IO op_event->op_in_progress = true; - op_event->on_start_ready = util::create_async_context_callback( - m_image_ctx, on_ready); + op_event->on_start_ready = on_ready; } template diff --git a/src/test/librbd/journal/test_mock_Replay.cc b/src/test/librbd/journal/test_mock_Replay.cc index 90475f65cc975..81e8dd152a5eb 100644 --- a/src/test/librbd/journal/test_mock_Replay.cc +++ b/src/test/librbd/journal/test_mock_Replay.cc @@ -447,6 +447,7 @@ TEST_F(TestMockJournalReplay, OpEventError) { MockImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); + expect_op_work_queue(mock_image_ctx); InSequence seq; Context *on_finish; @@ -513,6 +514,7 @@ TEST_F(TestMockJournalReplay, SnapRemoveEvent) { MockImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); + expect_op_work_queue(mock_image_ctx); InSequence seq; Context *on_finish; @@ -543,6 +545,7 @@ TEST_F(TestMockJournalReplay, SnapRenameEvent) { MockImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); + expect_op_work_queue(mock_image_ctx); InSequence seq; Context *on_finish; @@ -574,6 +577,7 @@ TEST_F(TestMockJournalReplay, SnapProtectEvent) { MockImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); + expect_op_work_queue(mock_image_ctx); InSequence seq; Context *on_finish; @@ -604,6 +608,7 @@ TEST_F(TestMockJournalReplay, SnapUnprotectEvent) { MockImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); + expect_op_work_queue(mock_image_ctx); InSequence seq; Context *on_finish; @@ -634,6 +639,7 @@ TEST_F(TestMockJournalReplay, SnapRollbackEvent) { MockImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); + expect_op_work_queue(mock_image_ctx); InSequence seq; Context *on_finish; @@ -664,6 +670,7 @@ TEST_F(TestMockJournalReplay, RenameEvent) { MockImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); + expect_op_work_queue(mock_image_ctx); InSequence seq; Context *on_finish; @@ -730,6 +737,7 @@ TEST_F(TestMockJournalReplay, FlattenEvent) { MockImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); + expect_op_work_queue(mock_image_ctx); InSequence seq; Context *on_finish; @@ -760,6 +768,7 @@ TEST_F(TestMockJournalReplay, UnknownEvent) { MockImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); + expect_op_work_queue(mock_image_ctx); InSequence seq; -- 2.39.5