Skip to content

Commit 9fdf500

Browse files
committed
mds/SimpleLock: add is_xlocked_by()
This eliminates more reference counter manipulations. Signed-off-by: Max Kellermann <[email protected]>
1 parent fc48d88 commit 9fdf500

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
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/MDCache.cc

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

src/mds/SimpleLock.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,9 @@ class SimpleLock {
468468
bool has_xlock_by() const noexcept {
469469
return have_more() && more()->xlock_by;
470470
}
471+
bool is_xlocked_by(const MutationRef &who) const noexcept {
472+
return have_more() && more()->xlock_by == who;
473+
}
471474

472475
// lease
473476
bool is_leased() const {

0 commit comments

Comments
 (0)