From: Xuehan Xu Date: Sat, 19 Dec 2020 10:21:21 +0000 (+0800) Subject: crimson/osd: make sure the read lock is acquired when trying to get recovery read X-Git-Tag: v17.0.0~232^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F38646%2Fhead;p=ceph.git crimson/osd: make sure the read lock is acquired when trying to get recovery read Signed-off-by: Xuehan Xu --- diff --git a/src/crimson/common/tri_mutex.h b/src/crimson/common/tri_mutex.h index 3092c6f305cc9..03e6474c40a44 100644 --- a/src/crimson/common/tri_mutex.h +++ b/src/crimson/common/tri_mutex.h @@ -93,6 +93,9 @@ public: void unlock_for_read(); void promote_from_read(); void demote_to_read(); + unsigned get_readers() const { + return readers; + } // for shared writers seastar::future<> lock_for_write(bool greedy); @@ -100,11 +103,17 @@ public: void unlock_for_write(); void promote_from_write(); void demote_to_write(); + unsigned get_writers() const { + return writers; + } // for exclusive users seastar::future<> lock_for_excl(); bool try_lock_for_excl() noexcept; void unlock_for_excl(); + bool is_excl_acquired() const { + return exclusively_used; + } bool is_acquired() const; diff --git a/src/crimson/osd/object_context.h b/src/crimson/osd/object_context.h index 2527dd98262c2..be238851e6a92 100644 --- a/src/crimson/osd/object_context.h +++ b/src/crimson/osd/object_context.h @@ -155,6 +155,7 @@ public: } } void wait_recovery_read() { + assert(lock.get_readers() > 0); recovery_read_marker = true; } void drop_recovery_read() {