From: Jason Dillaman Date: Wed, 22 Jun 2016 22:03:22 +0000 (-0400) Subject: Merge pull request #9207 from rjfd/wip-15670 X-Git-Tag: v11.0.0~69 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=48d18030fdbb8243b63378a6782ee8f6ec17fa59;p=ceph.git Merge pull request #9207 from rjfd/wip-15670 rbd-mirror: image resync Reviewed-by: Jason Dillaman --- 48d18030fdbb8243b63378a6782ee8f6ec17fa59 diff --cc src/librbd/Journal.h index 083aef564ae1,c5cee0f3f2cf..7f085dfc6c4a --- a/src/librbd/Journal.h +++ b/src/librbd/Journal.h @@@ -155,9 -156,16 +156,16 @@@ public } void start_external_replay(journal::Replay **journal_replay, - Context *on_finish); + Context *on_start, Context *on_close_request); void stop_external_replay(); + void add_listener(journal::ListenerType type, + journal::JournalListenerPtr listener); + void remove_listener(journal::ListenerType type, + journal::JournalListenerPtr listener); + + int check_resync_requested(bool *do_resync); + private: ImageCtxT &m_image_ctx; @@@ -286,8 -294,24 +294,25 @@@ bool m_blocking_writes; journal::Replay *m_journal_replay; + Context *m_on_replay_close_request = nullptr; + struct MetadataListener : public ::journal::JournalMetadataListener { + Journal *journal; + + MetadataListener(Journal *journal) : journal(journal) { } + + void handle_update(::journal::JournalMetadata *) { + FunctionContext *ctx = new FunctionContext([this](int r) { + journal->handle_metadata_updated(); + }); + journal->m_work_queue->queue(ctx, 0); + } + } m_metadata_listener; + + typedef std::map > ListenerMap; + ListenerMap m_listener_map; + uint64_t append_io_events(journal::EventType event_type, const Bufferlists &bufferlists, const AioObjectRequests &requests, diff --cc src/tools/rbd_mirror/ImageReplayer.cc index 89aef4748ceb,90605f0130f5..19da8882f7ed --- a/src/tools/rbd_mirror/ImageReplayer.cc +++ b/src/tools/rbd_mirror/ImageReplayer.cc @@@ -525,22 -552,8 +567,21 @@@ void ImageReplayer::handle_start_rep dout(20) << "m_remote_journaler=" << *m_remote_journaler << dendl; } - on_replay_interrupted(); } +template +void ImageReplayer::handle_stop_replay_request(int r) { + if (r < 0) { + // error starting or we requested the stop -- ignore + return; + } + + // journal close has been requested, stop replay so the journal + // can be closed (since it will wait on replay to finish) + dout(20) << dendl; + on_stop_journal_replay(); +} + template void ImageReplayer::on_start_fail(int r, const std::string &desc) { diff --cc src/tools/rbd_mirror/ImageReplayer.h index df8488845446,8ae79afdd6c4..5d2a9a4ce5c6 --- a/src/tools/rbd_mirror/ImageReplayer.h +++ b/src/tools/rbd_mirror/ImageReplayer.h @@@ -15,9 -15,9 +15,10 @@@ #include "cls/journal/cls_journal_types.h" #include "cls/rbd/cls_rbd_types.h" #include "journal/ReplayEntry.h" +#include "librbd/ImageCtx.h" #include "librbd/journal/Types.h" #include "librbd/journal/TypeTraits.h" + #include "ImageDeleter.h" #include "ProgressContext.h" #include "types.h" #include