From 942950007f9c424949eacf1d1cf3a74ef3b95725 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 26 Jul 2016 20:48:13 -0400 Subject: [PATCH] librbd: optionally support disabling journal appends via policy Signed-off-by: Jason Dillaman (cherry picked from commit f7eeacd02f8f80c5d1d5d9cfed35bbd23f64b018) --- src/librbd/journal/Policy.h | 1 + src/librbd/journal/StandardPolicy.h | 3 +++ src/test/librbd/mock/MockJournalPolicy.h | 1 + src/tools/rbd_mirror/ImageDeleter.cc | 4 ++++ src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc | 5 +++++ 5 files changed, 14 insertions(+) diff --git a/src/librbd/journal/Policy.h b/src/librbd/journal/Policy.h index 826562228a021..85373cd1abc56 100644 --- a/src/librbd/journal/Policy.h +++ b/src/librbd/journal/Policy.h @@ -14,6 +14,7 @@ struct Policy { virtual ~Policy() { } + virtual bool append_disabled() const = 0; virtual void allocate_tag_on_lock(Context *on_finish) = 0; virtual void cancel_external_replay(Context *on_finish) = 0; }; diff --git a/src/librbd/journal/StandardPolicy.h b/src/librbd/journal/StandardPolicy.h index c49ec9cb46730..e2b1ad7bc8359 100644 --- a/src/librbd/journal/StandardPolicy.h +++ b/src/librbd/journal/StandardPolicy.h @@ -17,6 +17,9 @@ public: StandardPolicy(ImageCtx *image_ctx) : m_image_ctx(image_ctx) { } + virtual bool append_disabled() const { + return false; + } virtual void allocate_tag_on_lock(Context *on_finish); virtual void cancel_external_replay(Context *on_finish); diff --git a/src/test/librbd/mock/MockJournalPolicy.h b/src/test/librbd/mock/MockJournalPolicy.h index e7debfaf535cc..c10fd6fbf1f87 100644 --- a/src/test/librbd/mock/MockJournalPolicy.h +++ b/src/test/librbd/mock/MockJournalPolicy.h @@ -11,6 +11,7 @@ namespace librbd { struct MockJournalPolicy : public journal::Policy { + MOCK_CONST_METHOD0(append_disabled, bool()); MOCK_METHOD1(allocate_tag_on_lock, void(Context*)); MOCK_METHOD1(cancel_external_replay, void(Context*)); diff --git a/src/tools/rbd_mirror/ImageDeleter.cc b/src/tools/rbd_mirror/ImageDeleter.cc index e4ad55ae60f3e..7c5caee640a23 100644 --- a/src/tools/rbd_mirror/ImageDeleter.cc +++ b/src/tools/rbd_mirror/ImageDeleter.cc @@ -74,6 +74,10 @@ private: }; struct DeleteJournalPolicy : public librbd::journal::Policy { + virtual bool append_disabled() const { + return true; + } + virtual void allocate_tag_on_lock(Context *on_finish) { on_finish->complete(0); } diff --git a/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc b/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc index 35b6863098b46..0286e522664c4 100644 --- a/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc @@ -43,6 +43,11 @@ struct MirrorJournalPolicy : public librbd::journal::Policy { MirrorJournalPolicy(ContextWQ *work_queue) : work_queue(work_queue) { } + virtual bool append_disabled() const { + // avoid recording any events to the local journal + return true; + } + virtual void allocate_tag_on_lock(Context *on_finish) { // rbd-mirror will manually create tags by copying them from the peer work_queue->queue(on_finish, 0); -- 2.39.5