]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: potential double-unwatch of watch handle upon error 10974/head
authorJason Dillaman <dillaman@redhat.com>
Sun, 4 Sep 2016 14:48:48 +0000 (10:48 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 5 Sep 2016 01:52:38 +0000 (21:52 -0400)
Fixes: http://tracker.ceph.com/issues/17210
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ImageWatcher.cc

index 58031033aa7e3f14324e291f5e5a1d37317c551c..65af9422feb4db287915d81da2d9b54e6fb80dcb 100644 (file)
@@ -140,7 +140,8 @@ void ImageWatcher<I>::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<I>::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<I>::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<I>::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;