}
void start_external_replay(journal::Replay<ImageCtxT> **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;
bool m_blocking_writes;
journal::Replay<ImageCtxT> *m_journal_replay;
+ Context *m_on_replay_close_request = nullptr;
+ struct MetadataListener : public ::journal::JournalMetadataListener {
+ Journal<ImageCtxT> *journal;
+
+ MetadataListener(Journal<ImageCtxT> *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<journal::ListenerType,
+ std::list<journal::JournalListenerPtr> > ListenerMap;
+ ListenerMap m_listener_map;
+
uint64_t append_io_events(journal::EventType event_type,
const Bufferlists &bufferlists,
const AioObjectRequests &requests,
dout(20) << "m_remote_journaler=" << *m_remote_journaler << dendl;
}
- on_replay_interrupted();
}
+template <typename I>
+void ImageReplayer<I>::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 <typename I>
void ImageReplayer<I>::on_start_fail(int r, const std::string &desc)
{
#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 <boost/optional.hpp>