]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: potential deadlock on close_image 3479/head
authorJason Dillaman <dillaman@redhat.com>
Fri, 23 Jan 2015 17:56:56 +0000 (12:56 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 23 Jan 2015 18:00:40 +0000 (13:00 -0500)
The owner_lock was incorrectly held when unregistering the image
watcher.  It was possible for the ImageWatcher finisher to be
running code that was then deadlocked waiting to acquire the
owner_lock while the close_image thread was attempting to shutdown
the deadlocked finisher.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/internal.cc

index 119ab4e2613a67066ac73c465c232f6703b5b964..6fda4d883af6ef44601f1e22bbca2227d3319e1a 100644 (file)
@@ -2291,13 +2291,15 @@ reprotect_and_return_err:
     }
 
     if (ictx->image_watcher) {
-      RWLock::WLocker l(ictx->owner_lock);
-      if (ictx->image_watcher->is_lock_owner()) {
-        int r = ictx->image_watcher->unlock();
-        if (r < 0) {
-         lderr(ictx->cct) << "error unlocking object map: " << cpp_strerror(r)
-                          << dendl;
-        }
+      {
+       RWLock::WLocker l(ictx->owner_lock);
+       if (ictx->image_watcher->is_lock_owner()) {
+         int r = ictx->image_watcher->unlock();
+         if (r < 0) {
+           lderr(ictx->cct) << "error unlocking image: " << cpp_strerror(r)
+                            << dendl;
+         }
+       }
       }
       ictx->unregister_watch();
     }