From 1068ded0cba59831a0712f347946731689a68553 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Sun, 4 Sep 2016 10:48:48 -0400 Subject: [PATCH] librbd: potential double-unwatch of watch handle upon error Fixes: http://tracker.ceph.com/issues/17210 Signed-off-by: Jason Dillaman --- src/librbd/ImageWatcher.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 58031033aa7e3..65af9422feb4d 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -140,7 +140,8 @@ void ImageWatcher::unregister_watch(Context *on_finish) { gather_ctx = new C_Gather(m_image_ctx.cct, create_async_context_callback( m_image_ctx, on_finish)); - if (m_watch_state == WATCH_STATE_REGISTERED) { + if (m_watch_state == WATCH_STATE_REGISTERED || + m_watch_state == WATCH_STATE_ERROR) { m_watch_state = WATCH_STATE_UNREGISTERED; librados::AioCompletion *aio_comp = create_rados_safe_callback( @@ -148,8 +149,6 @@ void ImageWatcher::unregister_watch(Context *on_finish) { int r = m_image_ctx.md_ctx.aio_unwatch(m_watch_handle, aio_comp); assert(r == 0); aio_comp->release(); - } else if (m_watch_state == WATCH_STATE_ERROR) { - m_watch_state = WATCH_STATE_UNREGISTERED; } } @@ -1007,7 +1006,6 @@ void ImageWatcher::handle_error(uint64_t handle, int err) { RWLock::WLocker l(m_watch_lock); if (m_watch_state == WATCH_STATE_REGISTERED) { - m_image_ctx.md_ctx.unwatch2(m_watch_handle); m_watch_state = WATCH_STATE_ERROR; FunctionContext *ctx = new FunctionContext( @@ -1047,7 +1045,9 @@ void ImageWatcher::handle_rewatch(int r) { WatchState next_watch_state = WATCH_STATE_REGISTERED; if (r < 0) { - next_watch_state = WATCH_STATE_ERROR; + // only EBLACKLISTED or ENOENT can be returned + assert(r == -EBLACKLISTED || r == -ENOENT); + next_watch_state = WATCH_STATE_UNREGISTERED; } Context *unregister_watch_ctx = nullptr; -- 2.47.3