From: Jason Dillaman Date: Wed, 22 Jun 2016 22:19:52 +0000 (-0400) Subject: librbd: fix crash while using advisory locks with R/O image X-Git-Tag: v11.0.0~60^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F9882%2Fhead;p=ceph.git librbd: fix crash while using advisory locks with R/O image Fixes: http://tracker.ceph.com/issues/16364 Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 564996985f9c..87c710e9be44 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 9cd643c68f3a..9e18339c459d 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 da1c11b332b5..0ae5245a2390 100644 --- a/src/librbd/ImageWatcher.h +++ b/src/librbd/ImageWatcher.h @@ -54,6 +54,8 @@ public: 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);