diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 564996985f9c6..87c710e9be447 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -1019,10 +1019,7 @@ struct C_InvalidateCache : public Context { void ImageCtx::notify_update() { state->handle_update_notification(); - - C_SaferCond ctx; - image_watcher->notify_header_update(&ctx); - ctx.wait(); + ImageWatcher::notify_header_update(md_ctx, header_oid); } void ImageCtx::notify_update(Context *on_finish) { diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 965e22f9d3914..3e291ba83f3b3 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -321,6 +321,14 @@ void ImageWatcher::notify_header_update(Context *on_finish) { m_notifier.notify(bl, nullptr, on_finish); } +void ImageWatcher::notify_header_update(librados::IoCtx &io_ctx, + const std::string &oid) { + // supports legacy (empty buffer) clients + bufferlist bl; + ::encode(NotifyMessage(HeaderUpdatePayload()), bl); + io_ctx.notify2(oid, bl, image_watcher::Notifier::NOTIFY_TIMEOUT, nullptr); +} + void ImageWatcher::schedule_cancel_async_requests() { FunctionContext *ctx = new FunctionContext( boost::bind(&ImageWatcher::cancel_async_requests, this)); diff --git a/src/librbd/ImageWatcher.h b/src/librbd/ImageWatcher.h index da1c11b332b5b..0ae5245a23908 100644 --- a/src/librbd/ImageWatcher.h +++ b/src/librbd/ImageWatcher.h @@ -54,6 +54,8 @@ class ImageWatcher { void notify_request_lock(); void notify_header_update(Context *on_finish); + static void notify_header_update(librados::IoCtx &io_ctx, + const std::string &oid); uint64_t get_watch_handle() const { RWLock::RLocker watch_locker(m_watch_lock);