Skip to content

Commit

Permalink
mds: set the correct WRLOCK flag always in wrlock_force()
Browse files Browse the repository at this point in the history
When the locks are added as REMOTE_WRLOCK and later when they need
to force wrlock in local MDS it will reuse the existing lock item
from the 'mdr->locks'. That means the latter force wrlock will fail
to set the WRLOCK flag. So when cleaning the requests it will try
to release the remote locks and then removes lock items directly,
which will miss releasing the wrlock reference locally.

Fixes: https://tracker.ceph.com/issues/65630
Signed-off-by: Xiubo Li <xiubli@redhat.com>
  • Loading branch information
lxbsz committed Apr 25, 2024
1 parent 472cc2b commit 96415f9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/mds/Locker.cc
Expand Up @@ -1832,7 +1832,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)
Expand Down Expand Up @@ -2054,7 +2055,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;
}
Expand Down Expand Up @@ -5138,7 +5140,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

Expand Down Expand Up @@ -5529,7 +5532,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;
}

Expand Down

0 comments on commit 96415f9

Please sign in to comment.