]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: hold cache_lock while clearing cache nonexistence flags 19801/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 27 Sep 2017 13:40:08 +0000 (09:40 -0400)
committerNathan Cutler <ncutler@suse.com>
Fri, 5 Jan 2018 13:22:03 +0000 (14:22 +0100)
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>
(cherry picked from commit 16ef97830cde30efb96f7aee69834b3a5c2d5248)

src/librbd/image/RefreshParentRequest.cc
src/librbd/image/SetSnapRequest.cc

index 28058abe7b557f620eddd7b850979920c02ccfe7..f42121f60d6cc658dcce29281fb36bd498b5b32e 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 def86f99a5d8e89f1ede452f90679137fad4f804..e68215380ce5f6690ad1fb93e808b57f1f1f0586 100644 (file)
@@ -324,6 +324,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) {