]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/SimpleLock: add has_xlock_by()
authorMax Kellermann <max.kellermann@ionos.com>
Wed, 30 Oct 2024 07:02:39 +0000 (08:02 +0100)
committerMax Kellermann <max.kellermann@ionos.com>
Mon, 9 Dec 2024 11:58:22 +0000 (12:58 +0100)
This replaces get_xlock_by() in cases where only a not-nullptr check
is needed; this eliminates costly implicit reference counter
manipulations.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/mds/LocalLockC.h
src/mds/SimpleLock.h

index a4df37bbcfed55fcd2b91af460e03587789e7c42..cea832204c0594cca2ce62ec3603b62df04a88eb 100644 (file)
@@ -30,7 +30,7 @@ public:
   }
 
   bool can_xlock_local() const {
-    return !is_wrlocked() && (get_xlock_by() == MutationRef());
+    return !is_wrlocked() && !has_xlock_by();
   }
 
   bool can_wrlock() const {
index 55621549a8ff7488330ff8dc21dec8b9741eae7e..8ce8970b560afbea9d97fff85158229512feaff9 100644 (file)
@@ -420,7 +420,7 @@ public:
 
   // xlock
   void get_xlock(MutationRef who, client_t client) { 
-    ceph_assert(get_xlock_by() == MutationRef());
+    ceph_assert(!has_xlock_by());
     ceph_assert(state == LOCK_XLOCK || is_locallock() ||
           state == LOCK_LOCK /* if we are a peer */);
     parent->get(MDSCacheObject::PIN_LOCK);
@@ -465,6 +465,9 @@ public:
   MutationRef get_xlock_by() const {
     return have_more() ? more()->xlock_by : MutationRef();
   }
+  bool has_xlock_by() const noexcept {
+    return have_more() && more()->xlock_by;
+  }
   
   // lease
   bool is_leased() const {