From: Jason Dillaman Date: Sun, 4 Sep 2016 14:48:48 +0000 (-0400) Subject: librbd: potential double-unwatch of watch handle upon error X-Git-Tag: v11.0.1~323^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F10974%2Fhead;p=ceph.git librbd: potential double-unwatch of watch handle upon error Fixes: http://tracker.ceph.com/issues/17210 Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 58031033aa7..65af9422feb 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;