From: Jason Dillaman Date: Fri, 23 Jan 2015 17:56:56 +0000 (-0500) Subject: librbd: potential deadlock on close_image X-Git-Tag: v0.93~194^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6f6facb981db47d056d209779ba219f47b99495c;p=ceph.git librbd: potential deadlock on close_image 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 --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 119ab4e2613a..6fda4d883af6 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -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(); }