X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Flibrbd%2FMirroringWatcher.cc;fp=src%2Fceph%2Fsrc%2Flibrbd%2FMirroringWatcher.cc;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=df287506f096b725f9f7bbd5aa1a7aa933db4843;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/librbd/MirroringWatcher.cc b/src/ceph/src/librbd/MirroringWatcher.cc deleted file mode 100644 index df28750..0000000 --- a/src/ceph/src/librbd/MirroringWatcher.cc +++ /dev/null @@ -1,141 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#include "librbd/MirroringWatcher.h" -#include "include/rbd_types.h" -#include "include/rados/librados.hpp" -#include "common/errno.h" -#include "librbd/Utils.h" -#include "librbd/watcher/Utils.h" - -#define dout_subsys ceph_subsys_rbd -#undef dout_prefix -#define dout_prefix *_dout << "librbd::MirroringWatcher: " - -namespace librbd { - -using namespace mirroring_watcher; -using namespace watcher; - -using librbd::util::create_rados_callback; - -namespace { - -static const uint64_t NOTIFY_TIMEOUT_MS = 5000; - -} // anonymous namespace - -template -MirroringWatcher::MirroringWatcher(librados::IoCtx &io_ctx, - ContextWQ *work_queue) - : Watcher(io_ctx, work_queue, RBD_MIRRORING) { -} - -template -int MirroringWatcher::notify_mode_updated(librados::IoCtx &io_ctx, - cls::rbd::MirrorMode mirror_mode) { - C_SaferCond ctx; - notify_mode_updated(io_ctx, mirror_mode, &ctx); - return ctx.wait(); -} - -template -void MirroringWatcher::notify_mode_updated(librados::IoCtx &io_ctx, - cls::rbd::MirrorMode mirror_mode, - Context *on_finish) { - CephContext *cct = reinterpret_cast(io_ctx.cct()); - ldout(cct, 20) << dendl; - - bufferlist bl; - ::encode(NotifyMessage{ModeUpdatedPayload{mirror_mode}}, bl); - - librados::AioCompletion *comp = create_rados_callback(on_finish); - int r = io_ctx.aio_notify(RBD_MIRRORING, comp, bl, NOTIFY_TIMEOUT_MS, - nullptr); - assert(r == 0); - comp->release(); -} - -template -int MirroringWatcher::notify_image_updated( - librados::IoCtx &io_ctx, cls::rbd::MirrorImageState mirror_image_state, - const std::string &image_id, const std::string &global_image_id) { - C_SaferCond ctx; - notify_image_updated(io_ctx, mirror_image_state, image_id, global_image_id, - &ctx); - return ctx.wait(); -} - -template -void MirroringWatcher::notify_image_updated( - librados::IoCtx &io_ctx, cls::rbd::MirrorImageState mirror_image_state, - const std::string &image_id, const std::string &global_image_id, - Context *on_finish) { - - CephContext *cct = reinterpret_cast(io_ctx.cct()); - ldout(cct, 20) << dendl; - - bufferlist bl; - ::encode(NotifyMessage{ImageUpdatedPayload{ - mirror_image_state, image_id, global_image_id}}, bl); - - librados::AioCompletion *comp = create_rados_callback(on_finish); - int r = io_ctx.aio_notify(RBD_MIRRORING, comp, bl, NOTIFY_TIMEOUT_MS, - nullptr); - assert(r == 0); - comp->release(); - -} - -template -void MirroringWatcher::handle_notify(uint64_t notify_id, uint64_t handle, - uint64_t notifier_id, bufferlist &bl) { - CephContext *cct = this->m_cct; - ldout(cct, 15) << ": notify_id=" << notify_id << ", " - << "handle=" << handle << dendl; - - - NotifyMessage notify_message; - try { - bufferlist::iterator iter = bl.begin(); - ::decode(notify_message, iter); - } catch (const buffer::error &err) { - lderr(cct) << ": error decoding image notification: " << err.what() - << dendl; - Context *ctx = new C_NotifyAck(this, notify_id, handle); - ctx->complete(0); - return; - } - - apply_visitor(watcher::util::HandlePayloadVisitor>( - this, notify_id, handle), notify_message.payload); -} - -template -bool MirroringWatcher::handle_payload(const ModeUpdatedPayload &payload, - Context *on_notify_ack) { - CephContext *cct = this->m_cct; - ldout(cct, 20) << ": mode updated: " << payload.mirror_mode << dendl; - handle_mode_updated(payload.mirror_mode); - return true; -} - -template -bool MirroringWatcher::handle_payload(const ImageUpdatedPayload &payload, - Context *on_notify_ack) { - CephContext *cct = this->m_cct; - ldout(cct, 20) << ": image state updated" << dendl; - handle_image_updated(payload.mirror_image_state, payload.image_id, - payload.global_image_id); - return true; -} - -template -bool MirroringWatcher::handle_payload(const UnknownPayload &payload, - Context *on_notify_ack) { - return true; -} - -} // namespace librbd - -template class librbd::MirroringWatcher;