]> 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)
committerJason Dillaman <dillaman@redhat.com>
Tue, 28 Jul 2015 20:36:35 +0000 (16:36 -0400)
Cache writeback operations will expect the owner lock to be held.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit adfa2e0070ccca7b6556d3bfc5fac7ce4d43a4d0)

src/librbd/ImageCtx.cc
src/librbd/internal.cc

index fd1fe5b76a1be383d2ea6473ecc0beee0ba249fb..5a88adb10348d581651636f73de564fd39540aac 100644 (file)
@@ -671,6 +671,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 f38b4512a70d444e2532bd525fa47b4e3b95efdc..a5c5f204dd4dabc4249e66cfc7030db8cb7b644c 100644 (file)
@@ -2399,7 +2399,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);
@@ -3224,6 +3225,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);
@@ -3296,7 +3298,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;
   }