From 9fdf5008743b6b9dc38ce14ae48c2ae977eb420d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 30 Oct 2024 11:51:54 +0100 Subject: [PATCH] mds/SimpleLock: add is_xlocked_by() This eliminates more reference counter manipulations. Signed-off-by: Max Kellermann --- src/mds/CDentry.h | 2 +- src/mds/MDCache.cc | 2 +- src/mds/SimpleLock.h | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mds/CDentry.h b/src/mds/CDentry.h index ca36da0354f38..205e85b5d3550 100644 --- a/src/mds/CDentry.h +++ b/src/mds/CDentry.h @@ -232,7 +232,7 @@ public: bool use_projected(client_t client, const MutationRef& mut) const { return lock.can_read_projected(client) || - lock.get_xlock_by() == mut; + lock.is_xlocked_by(mut); } linkage_t *get_linkage(client_t client, const MutationRef& mut) { return use_projected(client, mut) ? get_projected_linkage() : get_linkage(); diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 3af0d8c6b1ec5..0c8f8c3665d2a 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -8524,7 +8524,7 @@ int MDCache::path_traverse(const MDRequestRef& mdr, MDSContextFactory& cf, } } else if (!path_locked && !dn->lock.can_read(client) && - !(dn->lock.is_xlocked() && dn->lock.get_xlock_by() == mdr)) { + !(dn->lock.is_xlocked() && dn->lock.is_xlocked_by(mdr))) { dout(10) << "traverse: non-readable dentry at " << *dn << dendl; dn->lock.add_waiter(SimpleLock::WAIT_RD, cf.build()); if (mds->logger) diff --git a/src/mds/SimpleLock.h b/src/mds/SimpleLock.h index 8ce8970b560af..0749635287837 100644 --- a/src/mds/SimpleLock.h +++ b/src/mds/SimpleLock.h @@ -468,6 +468,9 @@ public: bool has_xlock_by() const noexcept { return have_more() && more()->xlock_by; } + bool is_xlocked_by(const MutationRef &who) const noexcept { + return have_more() && more()->xlock_by == who; + } // lease bool is_leased() const { -- 2.39.5