From 145e0a066e107c8b18fc260332c45685af862833 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 3 Oct 2023 20:45:12 +0000 Subject: [PATCH] common/ceph_mutex: note whether mutex debug methods are usable So we can do checks like: ceph_assert(!ceph::mutex_debugging || !ceph_mutex_is_locked_by_me(lock)); Without this boolean, this check: ceph_assert(!ceph_mutex_is_locked_by_me(lock)); will fail for all crimson/release builds because the method always returns true. Signed-off-by: Patrick Donnelly (cherry picked from commit a8bd314bbd78dbe73371e7a8beaaa1929577b76e) --- src/common/ceph_mutex.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/ceph_mutex.h b/src/common/ceph_mutex.h index 8d87e605b84..5f7bfbed57e 100644 --- a/src/common/ceph_mutex.h +++ b/src/common/ceph_mutex.h @@ -83,6 +83,7 @@ namespace ceph { return {}; } + static constexpr bool mutex_debugging = false; #define ceph_mutex_is_locked(m) true #define ceph_mutex_is_locked_by_me(m) true } @@ -130,6 +131,8 @@ namespace ceph { return {std::forward(args)...}; } + static constexpr bool mutex_debugging = true; + // debug methods #define ceph_mutex_is_locked(m) ((m).is_locked()) #define ceph_mutex_is_not_locked(m) (!(m).is_locked()) @@ -183,6 +186,8 @@ namespace ceph { return {}; } + static constexpr bool mutex_debugging = false; + // debug methods. Note that these can blindly return true // because any code that does anything other than assert these // are true is broken. -- 2.39.5