]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: set the correct WRLOCK flag always in wrlock_force() 58496/head
authorXiubo Li <xiubli@redhat.com>
Thu, 25 Apr 2024 04:06:25 +0000 (12:06 +0800)
committerJos Collin <jcollin@redhat.com>
Wed, 10 Jul 2024 04:30:57 +0000 (10:00 +0530)
The wrlock is not like the xlock, which needs to be acquired in
the CInode's auth always, and it is based on the CDir's auths instead.

When a remote_wrlock is acquired and the local MDS will add a lock
item and marks it as REMOTE_WRLOCK. And later when the local MDS try
to force wrlock in the emplace_lock() will just return the existing
lock item without updating the WRLOCK flag. So when cleaning the
requests later it will just release the remote locks and then removes
lock items directly, which will miss releasing the local wrlock
reference.

Fixes: https://tracker.ceph.com/issues/65630
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit 9a6f249b96faed085a7dea251b0fd81a28330025)

src/mds/Locker.cc

index 8e45504b74d246086ee12eca292c6b4ca9413b4e..e8d2d672d16f1cbe88325d6ab2ac635a8aac2c86 100644 (file)
@@ -1906,7 +1906,8 @@ void Locker::wrlock_force(SimpleLock *lock, MutationRef& mut)
   dout(7) << "wrlock_force  on " << *lock
          << " on " << *lock->get_parent() << dendl;  
   lock->get_wrlock(true);
-  mut->emplace_lock(lock, MutationImpl::LockOp::WRLOCK);
+  auto it = mut->emplace_lock(lock, MutationImpl::LockOp::WRLOCK);
+  it->flags |= MutationImpl::LockOp::WRLOCK; // may already remote_wrlocked
 }
 
 bool Locker::wrlock_try(SimpleLock *lock, const MutationRef& mut, client_t client)
@@ -2128,7 +2129,8 @@ bool Locker::xlock_start(SimpleLock *lock, const MDRequestRef& mut)
            in && in->issued_caps_need_gather(lock))) { // xlocker does not hold shared cap
        lock->set_state(LOCK_XLOCK);
        lock->get_xlock(mut, client);
-       mut->emplace_lock(lock, MutationImpl::LockOp::XLOCK);
+       auto it = mut->emplace_lock(lock, MutationImpl::LockOp::XLOCK);
+       ceph_assert(it->is_xlock());
        mut->finish_locking(lock);
        return true;
       }
@@ -5214,7 +5216,8 @@ void Locker::scatter_writebehind(ScatterLock *lock)
 
   // forcefully take a wrlock
   lock->get_wrlock(true);
-  mut->emplace_lock(lock, MutationImpl::LockOp::WRLOCK);
+  auto it = mut->emplace_lock(lock, MutationImpl::LockOp::WRLOCK);
+  ceph_assert(it->is_wrlock());
 
   in->pre_cow_old_inode();  // avoid cow mayhem
 
@@ -5605,7 +5608,8 @@ bool Locker::local_xlock_start(LocalLockC *lock, const MDRequestRef& mut)
   }
 
   lock->get_xlock(mut, mut->get_client());
-  mut->emplace_lock(lock, MutationImpl::LockOp::XLOCK);
+  auto it = mut->emplace_lock(lock, MutationImpl::LockOp::XLOCK);
+  ceph_assert(it->is_xlock());
   return true;
 }