From: Kefu Chai Date: Sun, 7 Jul 2019 08:17:35 +0000 (+0800) Subject: common/ceph_mutex: add more ceph_mutex_is_*() helpers X-Git-Tag: v14.2.10~7^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F35393%2Fhead;p=ceph.git 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) --- 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;