Skip to content

Commit 1051088

Browse files
committed
Merge PR ceph#60996 into main
* refs/pull/60996/head: mds/SimpleLock: add is_xlocked_by() mds/SimpleLock: add has_xlock_by() Reviewed-by: Patrick Donnelly <[email protected]> Reviewed-by: Venky Shankar <[email protected]>
2 parents b6a0e49 + 9fdf500 commit 1051088

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/mds/CDentry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class CDentry : public MDSCacheObject, public LRUObject, public Counter<CDentry>
232232

233233
bool use_projected(client_t client, const MutationRef& mut) const {
234234
return lock.can_read_projected(client) ||
235-
lock.get_xlock_by() == mut;
235+
lock.is_xlocked_by(mut);
236236
}
237237
linkage_t *get_linkage(client_t client, const MutationRef& mut) {
238238
return use_projected(client, mut) ? get_projected_linkage() : get_linkage();

src/mds/LocalLockC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class LocalLockC : public SimpleLock {
3030
}
3131

3232
bool can_xlock_local() const {
33-
return !is_wrlocked() && (get_xlock_by() == MutationRef());
33+
return !is_wrlocked() && !has_xlock_by();
3434
}
3535

3636
bool can_wrlock() const {

src/mds/MDCache.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8527,7 +8527,7 @@ int MDCache::path_traverse(const MDRequestRef& mdr, MDSContextFactory& cf,
85278527
}
85288528
} else if (!path_locked &&
85298529
!dn->lock.can_read(client) &&
8530-
!(dn->lock.is_xlocked() && dn->lock.get_xlock_by() == mdr)) {
8530+
!(dn->lock.is_xlocked() && dn->lock.is_xlocked_by(mdr))) {
85318531
dout(10) << "traverse: non-readable dentry at " << *dn << dendl;
85328532
dn->lock.add_waiter(SimpleLock::WAIT_RD, cf.build());
85338533
if (mds->logger)

src/mds/SimpleLock.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ class SimpleLock {
420420

421421
// xlock
422422
void get_xlock(MutationRef who, client_t client) {
423-
ceph_assert(get_xlock_by() == MutationRef());
423+
ceph_assert(!has_xlock_by());
424424
ceph_assert(state == LOCK_XLOCK || is_locallock() ||
425425
state == LOCK_LOCK /* if we are a peer */);
426426
parent->get(MDSCacheObject::PIN_LOCK);
@@ -465,6 +465,12 @@ class SimpleLock {
465465
MutationRef get_xlock_by() const {
466466
return have_more() ? more()->xlock_by : MutationRef();
467467
}
468+
bool has_xlock_by() const noexcept {
469+
return have_more() && more()->xlock_by;
470+
}
471+
bool is_xlocked_by(const MutationRef &who) const noexcept {
472+
return have_more() && more()->xlock_by == who;
473+
}
468474

469475
// lease
470476
bool is_leased() const {

0 commit comments

Comments
 (0)