From 1479161b74cc98eacfef09467c6d06bca640ae86 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 18 Mar 2015 10:38:09 -0400 Subject: [PATCH] librbd: add hooks for rebuild object map to ImageWatcher Signed-off-by: Jason Dillaman --- src/librbd/ImageWatcher.cc | 23 +++++++++++++++++++++++ src/librbd/ImageWatcher.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 218f1a394e467..4bc8558f4c0a3 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -480,6 +480,19 @@ int ImageWatcher::notify_snap_create(const std::string &snap_name) { return notify_lock_owner(bl); } +int ImageWatcher::notify_rebuild_object_map(uint64_t request_id, + ProgressContext &prog_ctx) { + assert(m_image_ctx.owner_lock.is_locked()); + assert(!is_lock_owner()); + + AsyncRequestId async_request_id(get_client_id(), request_id); + + bufferlist bl; + ::encode(NotifyMessage(RebuildObjectMapPayload(async_request_id)), bl); + + return notify_async_request(async_request_id, bl, prog_ctx); +} + void ImageWatcher::notify_header_update(librados::IoCtx &io_ctx, const std::string &oid) { @@ -894,6 +907,16 @@ void ImageWatcher::handle_payload(const SnapCreatePayload &payload, } } +void ImageWatcher::handle_payload(const RebuildObjectMapPayload& payload, + bufferlist *out) { + RWLock::RLocker l(m_image_ctx.owner_lock); + if (m_lock_owner_state == LOCK_OWNER_STATE_LOCKED) { + ldout(m_image_ctx.cct, 10) << "remote rebuild_object_map request" << dendl; + + // TODO + ::encode(ResponseMessage(0), *out); + } +} void ImageWatcher::handle_payload(const UnknownPayload &payload, bufferlist *out) { RWLock::RLocker l(m_image_ctx.owner_lock); diff --git a/src/librbd/ImageWatcher.h b/src/librbd/ImageWatcher.h index d75e2fe22223f..7da9f07191b1a 100644 --- a/src/librbd/ImageWatcher.h +++ b/src/librbd/ImageWatcher.h @@ -49,6 +49,8 @@ namespace librbd { int notify_resize(uint64_t request_id, uint64_t size, ProgressContext &prog_ctx); int notify_snap_create(const std::string &snap_name); + int notify_rebuild_object_map(uint64_t request_id, + ProgressContext &prog_ctx); static void notify_header_update(librados::IoCtx &io_ctx, const std::string &oid); @@ -257,6 +259,8 @@ namespace librbd { bufferlist *out); void handle_payload(const WatchNotify::SnapCreatePayload& payload, bufferlist *out); + void handle_payload(const WatchNotify::RebuildObjectMapPayload& payload, + bufferlist *out); void handle_payload(const WatchNotify::UnknownPayload& payload, bufferlist *out); -- 2.39.5