From: Max Kellermann Date: Wed, 30 Oct 2024 10:51:54 +0000 (+0100) Subject: mds/SimpleLock: add is_xlocked_by() X-Git-Tag: v20.0.0~313^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9fdf5008743b6b9dc38ce14ae48c2ae977eb420d;p=ceph.git mds/SimpleLock: add is_xlocked_by() This eliminates more reference counter manipulations. Signed-off-by: Max Kellermann --- 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 {