]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: hold cache_lock while clearing cache nonexistence flags 17992/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 27 Sep 2017 13:40:08 +0000 (09:40 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 27 Sep 2017 13:40:08 +0000 (09:40 -0400)
When transitioning from a snapshot that had an associated parent
to a snapshot where the parent was flattened and removed, the cache
was being referenced without holding the required lock.

Fixes: http://tracker.ceph.com/issues/21558
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/image/RefreshParentRequest.cc
src/librbd/image/SetSnapRequest.cc

index 3245ff11158bf643939297880ca00d8fcf102366..86001da82c60a490fdc2207ed328da3965e352de 100644 (file)
@@ -69,12 +69,13 @@ void RefreshParentRequest<I>::send() {
 
 template <typename I>
 void RefreshParentRequest<I>::apply() {
+  assert(m_child_image_ctx.cache_lock.is_locked());
+  assert(m_child_image_ctx.snap_lock.is_wlocked());
+  assert(m_child_image_ctx.parent_lock.is_wlocked());
   if (m_child_image_ctx.parent != nullptr) {
     // closing parent image
     m_child_image_ctx.clear_nonexistence_cache();
   }
-  assert(m_child_image_ctx.snap_lock.is_wlocked());
-  assert(m_child_image_ctx.parent_lock.is_wlocked());
   std::swap(m_child_image_ctx.parent, m_parent_image_ctx);
 }
 
index ae7776c87c0a6a27ae3a17aa3747b9914a5ec723..fc632edb77ad3a2c7150411ef8b44f8ad627db3d 100644 (file)
@@ -326,6 +326,7 @@ int SetSnapRequest<I>::apply() {
   ldout(cct, 10) << __func__ << dendl;
 
   RWLock::WLocker owner_locker(m_image_ctx.owner_lock);
+  Mutex::Locker cache_locker(m_image_ctx.cache_lock);
   RWLock::WLocker snap_locker(m_image_ctx.snap_lock);
   RWLock::WLocker parent_locker(m_image_ctx.parent_lock);
   if (m_snap_id != CEPH_NOSNAP) {