]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ceph_mutex: add more ceph_mutex_is_*() helpers
authorKefu Chai <kchai@redhat.com>
Sun, 7 Jul 2019 08:17:35 +0000 (16:17 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 3 Aug 2019 03:27:19 +0000 (11:27 +0800)
we have caller sites like

ceph_assert(!client->client_lock.is_locked_by_me())

in `src/client/Client.cc` and `src/librados/RadosClient.cc`.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/ceph_mutex.h
src/common/shared_mutex_debug.h

index 7683aef0aa136274bcfaa1b98de4a765b39a728f..4e888d72bb19c02939f18a43dfc42831241d1d64 100644 (file)
@@ -100,8 +100,11 @@ namespace ceph {
 
   // debug methods
   #define ceph_mutex_is_locked(m) ((m).is_locked())
+  #define ceph_mutex_is_not_locked(m) (!(m).is_locked())
+  #define ceph_mutex_is_rlocked(m) ((m).is_rlocked())
   #define ceph_mutex_is_wlocked(m) ((m).is_wlocked())
   #define ceph_mutex_is_locked_by_me(m) ((m).is_locked_by_me())
+  #define ceph_mutex_is_not_locked_by_me(m) (!(m).is_locked_by_me())
 }
 
 #else
@@ -140,7 +143,12 @@ namespace ceph {
   // because any code that does anything other than assert these
   // are true is broken.
   #define ceph_mutex_is_locked(m) true
+  #define ceph_mutex_is_not_locked(m) true
+  #define ceph_mutex_is_rlocked(m) true
+  #define ceph_mutex_is_wlocked(m) true
   #define ceph_mutex_is_locked_by_me(m) true
+  #define ceph_mutex_is_not_locked_by_me(m) true
+
 }
 
 #endif // CEPH_DEBUG_MUTEX
index 58569e14f48128e80ce3223e3f2de7b99c3758f0..853ab0a271af69626241bb2ce38b55f01cd2920c 100644 (file)
@@ -34,7 +34,9 @@ public:
   void lock_shared();
   bool try_lock_shared();
   void unlock_shared();
-
+  bool is_rlocked() const {
+    return nrlock > 0;
+  }
   // either of them
   bool is_locked() const {
     return nlock > 0 || nrlock > 0;