]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: optimize the fast path of get_recovery_read()
authorKefu Chai <kchai@redhat.com>
Thu, 10 Sep 2020 11:38:02 +0000 (19:38 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 10 Sep 2020 13:21:39 +0000 (21:21 +0800)
no need to enqueue if the lock can be acquired without waiting for it.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/object_context.h

index 6a2ba9f2c877cf2de722db75565f65afd20d4efd..40bda6592e84a9777bf27cd61aeff36274e8e7a1 100644 (file)
@@ -204,8 +204,9 @@ public:
     return put_lock_type(RWState::RWREAD);
   }
   seastar::future<bool> get_recovery_read(bool can_wait = false) {
-    if (!can_wait) {
-      return seastar::make_ready_future<bool>(rwstate.get_recovery_read());
+    if (bool acquired = rwstate.get_recovery_read();
+        acquired || !can_wait) {
+      return seastar::make_ready_future<bool>(acquired);
     }
     return with_queue([this] {
       return rwstate.get_recovery_read();