]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: disable copy-on-read when not exclusive lock owner
authorJason Dillaman <dillaman@redhat.com>
Tue, 5 Jan 2016 21:32:41 +0000 (16:32 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 5 Jan 2016 21:34:24 +0000 (16:34 -0500)
Fixes: #14167
Backport: infernalis, hammer
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/AioObjectRequest.cc
src/librbd/CopyupRequest.cc

index 5b3d6165613747f6d04d67880f9870eda5bad1e4..e02ebd37f5d19a493e669840d5fd507d68746779 100644 (file)
@@ -84,9 +84,12 @@ namespace librbd {
   }
 
   static inline bool is_copy_on_read(ImageCtx *ictx, librados::snap_t snap_id) {
+    assert(ictx->owner_lock.is_locked());
     assert(ictx->snap_lock.is_locked());
-    return (ictx->clone_copy_on_read) &&
-           (!ictx->read_only) && (snap_id == CEPH_NOSNAP);
+    return (ictx->clone_copy_on_read &&
+            !ictx->read_only && snap_id == CEPH_NOSNAP &&
+            (ictx->exclusive_lock == nullptr ||
+             ictx->exclusive_lock->is_lock_owner()));
   }
 
   /** read **/
@@ -132,6 +135,7 @@ namespace librbd {
       // This is the step to read from parent
       if (!m_tried_parent && r == -ENOENT) {
         {
+          RWLock::RLocker owner_locker(m_ictx->owner_lock);
           RWLock::RLocker snap_locker(m_ictx->snap_lock);
           RWLock::RLocker parent_locker(m_ictx->parent_lock);
           if (m_ictx->parent == NULL) {
@@ -240,9 +244,12 @@ namespace librbd {
   void AioObjectRead::send_copyup()
   {
     {
+      RWLock::RLocker owner_locker(m_ictx->owner_lock);
       RWLock::RLocker snap_locker(m_ictx->snap_lock);
       RWLock::RLocker parent_locker(m_ictx->parent_lock);
-      if (!compute_parent_extents()) {
+      if (!compute_parent_extents() ||
+          (m_ictx->exclusive_lock != nullptr &&
+           !m_ictx->exclusive_lock->is_lock_owner())) {
         return;
       }
     }
index 9adf3383ef0cbaf53cb3ff9f61ebcc8478f76e01..2fd18dd24495fea6b398cf6f70ce38aa4d77002d 100644 (file)
@@ -277,12 +277,7 @@ private:
       RWLock::RLocker snap_locker(m_ictx->snap_lock);
       if (m_ictx->object_map != nullptr) {
         bool copy_on_read = m_pending_requests.empty();
-        if (!m_ictx->exclusive_lock->is_lock_owner()) {
-          ldout(m_ictx->cct, 20) << "exclusive lock not held for copyup request"
-                                 << dendl;
-          assert(copy_on_read);
-          return true;
-        }
+        assert(m_ictx->exclusive_lock->is_lock_owner());
 
         RWLock::WLocker object_map_locker(m_ictx->object_map_lock);
         if (copy_on_read &&