From 55762cca2bf586d037cb9f32775ec158dc3287c1 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Thu, 29 Sep 2016 16:55:22 +0300 Subject: [PATCH] journal: complete action only after notification completed Signed-off-by: Mykola Golub --- src/journal/JournalMetadata.cc | 4 ++-- src/journal/JournalMetadata.h | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/journal/JournalMetadata.cc b/src/journal/JournalMetadata.cc index 8688a50fa43..db104870009 100644 --- a/src/journal/JournalMetadata.cc +++ b/src/journal/JournalMetadata.cc @@ -1014,10 +1014,10 @@ void JournalMetadata::notify_update() { m_ioctx.notify2(m_oid, bl, 5000, NULL); } -void JournalMetadata::async_notify_update() { +void JournalMetadata::async_notify_update(Context *on_safe) { ldout(m_cct, 10) << "async notifying journal header update" << dendl; - C_AioNotify *ctx = new C_AioNotify(this); + C_AioNotify *ctx = new C_AioNotify(this, on_safe); librados::AioCompletion *comp = librados::Rados::aio_create_completion(ctx, NULL, utils::rados_ctx_callback); diff --git a/src/journal/JournalMetadata.h b/src/journal/JournalMetadata.h index 61b16967d4d..c50c481dcce 100644 --- a/src/journal/JournalMetadata.h +++ b/src/journal/JournalMetadata.h @@ -151,7 +151,7 @@ public: void committed(uint64_t commit_tid, const CreateContext &create_context); void notify_update(); - void async_notify_update(); + void async_notify_update(Context *on_safe); private: typedef std::map AllocatedEntryTids; @@ -220,9 +220,10 @@ private: struct C_AioNotify : public Context { JournalMetadata* journal_metadata; + Context *on_safe; - C_AioNotify(JournalMetadata *_journal_metadata) - : journal_metadata(_journal_metadata) { + C_AioNotify(JournalMetadata *_journal_metadata, Context *_on_safe) + : journal_metadata(_journal_metadata), on_safe(_on_safe) { journal_metadata->m_async_op_tracker.start_op(); } virtual ~C_AioNotify() { @@ -230,6 +231,9 @@ private: } virtual void finish(int r) { journal_metadata->handle_notified(r); + if (on_safe != nullptr) { + on_safe->complete(0); + } } }; @@ -246,7 +250,8 @@ private: } virtual void finish(int r) { if (r == 0) { - journal_metadata->async_notify_update(); + journal_metadata->async_notify_update(on_safe); + return; } if (on_safe != NULL) { on_safe->complete(r); -- 2.39.5