From 966343f8f67a236925805deec4903ecb57ab938a Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 7 Jul 2019 16:17:35 +0800 Subject: [PATCH] common/ceph_mutex: add more ceph_mutex_is_*() helpers 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 (cherry picked from commit 307ccc42f09421b2bf1df3792a29a4b86bdd2b1a) --- src/common/ceph_mutex.h | 8 ++++++++ src/common/shared_mutex_debug.h | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common/ceph_mutex.h b/src/common/ceph_mutex.h index bb1088f9069e1..fbb69be63a41c 100644 --- a/src/common/ceph_mutex.h +++ b/src/common/ceph_mutex.h @@ -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 diff --git a/src/common/shared_mutex_debug.h b/src/common/shared_mutex_debug.h index e6071e9de2983..57d95b0c1d55f 100644 --- a/src/common/shared_mutex_debug.h +++ b/src/common/shared_mutex_debug.h @@ -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; -- 2.39.5