]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: flush operations need to acquire owner lock
authorJason Dillaman <dillaman@redhat.com>
Tue, 9 Jun 2015 17:20:54 +0000 (13:20 -0400)
committerJosh Durgin <jdurgin@redhat.com>
Thu, 18 Jun 2015 01:22:04 +0000 (18:22 -0700)
Cache writeback operations will expect the owner lock to be held.

Fixes: #11938
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
Reviewed-by: Josh Durgin <jdurgin@redhat.com>
src/librbd/ImageCtx.cc
src/librbd/internal.cc

index 7f74ec01869364ed8dcb7e5057f83044b9af908c..5b6b59249e2fcd72d8b0da2088348def3e8ffa22 100644 (file)
@@ -643,6 +643,7 @@ public:
   }
 
   void ImageCtx::flush_cache_aio(Context *onfinish) {
+    assert(owner_lock.is_locked());
     cache_lock.Lock();
     object_cacher->flush_set(object_set, onfinish);
     cache_lock.Unlock();
index ddd499ff445dd957914ee7614dd9c011ab4f61fe..44ecf54fcb0e82d3a207ae2be70430997cf86558 100644 (file)
@@ -2752,7 +2752,8 @@ reprotect_and_return_err:
     if (ictx->object_cacher) {
       // complete pending writes before we're set to a snapshot and
       // get -EROFS for writes
-      RWLock::WLocker l(ictx->md_lock);
+      RWLock::RLocker owner_locker(ictx->owner_lock);
+      RWLock::WLocker md_locker(ictx->md_lock);
       ictx->flush_cache();
     }
     int r = _snap_set(ictx, snap_name);
@@ -3668,6 +3669,7 @@ reprotect_and_return_err:
       return;
     }
 
+    RWLock::RLocker owner_locker(ictx->owner_lock);
     ictx->user_flushed();
 
     C_AioWrite *flush_ctx = new C_AioWrite(cct, c);
@@ -3740,7 +3742,8 @@ reprotect_and_return_err:
 
     ictx->flush_async_operations();
 
-    RWLock::WLocker l(ictx->md_lock);
+    RWLock::RLocker owner_locker(ictx->owner_lock);
+    RWLock::WLocker md_locker(ictx->md_lock);
     r = ictx->invalidate_cache();
     return r;
   }