]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ceph_mutex: add more ceph_mutex_is_*() helpers 35393/head
authorKefu Chai <kchai@redhat.com>
Sun, 7 Jul 2019 08:17:35 +0000 (16:17 +0800)
committerNathan Cutler <ncutler@suse.com>
Thu, 4 Jun 2020 13:46:17 +0000 (15:46 +0200)
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>
(cherry picked from commit 307ccc42f09421b2bf1df3792a29a4b86bdd2b1a)

src/common/ceph_mutex.h
src/common/shared_mutex_debug.h

index bb1088f9069e1a2950011d31a60fd0bc5f842ed3..fbb69be63a41c583cd7a25ff2922829fa053ee57 100644 (file)
@@ -86,8 +86,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
@@ -126,7 +129,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 e6071e9de2983bad3dc5b7d9d078830e6c02f8cf..57d95b0c1d55fb5f62197f7ebc2ad0a9cee6ad57 100644 (file)
@@ -38,7 +38,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;