]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: add ObjectContext::wait_recovery_read()
authorKefu Chai <kchai@redhat.com>
Mon, 14 Sep 2020 06:22:40 +0000 (14:22 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 15 Sep 2020 08:45:48 +0000 (16:45 +0800)
instead of reusing ObjectContext::get_recovery_read() for both
sync call and async call. just add a new method for the async call
for better readability

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

index 40bda6592e84a9777bf27cd61aeff36274e8e7a1..80b64cd55359505bfec5cd2dc45017b4b607a05e 100644 (file)
@@ -203,14 +203,16 @@ public:
   void drop_read() {
     return put_lock_type(RWState::RWREAD);
   }
-  seastar::future<bool> get_recovery_read(bool can_wait = false) {
-    if (bool acquired = rwstate.get_recovery_read();
-        acquired || !can_wait) {
-      return seastar::make_ready_future<bool>(acquired);
+  bool get_recovery_read() {
+    return rwstate.get_recovery_read();
+  }
+  seastar::future<> wait_recovery_read() {
+    if (rwstate.get_recovery_read()) {
+      return seastar::make_ready_future<>();
     }
     return with_queue([this] {
       return rwstate.get_recovery_read();
-    }).then([] {return seastar::make_ready_future<bool>(true); });
+    });
   }
   void drop_recovery_read() {
     ceph_assert(rwstate.recovery_read_marker);
index 473be5f9747603a768997e293d257c958f2e4f53..95121f292f6931fa712decf94fab8fb97211d789 100644 (file)
@@ -322,7 +322,7 @@ void PGRecovery::on_local_recover(
       obc->obs.oi = recovery_info.oi;
       // obc is loaded the excl lock
       obc->put_lock_type(RWState::RWEXCL);
-      ceph_assert_always(obc->get_recovery_read().get0());
+      ceph_assert_always(obc->get_recovery_read());
     }
     if (!pg->is_unreadable_object(soid)) {
       pg->get_recovery_backend()->get_recovering(soid).set_readable();
index e888d4e9142b656f211d61b0415051dcd32c363a..57f64652af7e62f2f52fed554eb9fab83e59f2e9 100644 (file)
@@ -133,14 +133,7 @@ seastar::future<> ReplicatedRecoveryBackend::load_obc_for_recovery(
       // obc is loaded with excl lock
       recovery_waiter.obc->put_lock_type(RWState::RWEXCL);
     }
-    bool got = recovery_waiter.obc->get_recovery_read().get0();
-    ceph_assert_always(pulled ? got : 1);
-    if (got) {
-      return seastar::make_ready_future<>();
-    }
-    return recovery_waiter.obc->get_recovery_read(true).then([](bool) {
-      return seastar::now();
-    });
+    return recovery_waiter.obc->wait_recovery_read();
   }, crimson::osd::PG::load_obc_ertr::all_same_way(
       [this, &recovery_waiter, soid](const std::error_code& e) {
       auto [obc, existed] =
@@ -150,7 +143,7 @@ seastar::future<> ReplicatedRecoveryBackend::load_obc_for_recovery(
       recovery_waiter.obc = obc;
       // obc is loaded with excl lock
       recovery_waiter.obc->put_lock_type(RWState::RWEXCL);
-      ceph_assert_always(recovery_waiter.obc->get_recovery_read().get0());
+      ceph_assert_always(recovery_waiter.obc->get_recovery_read());
       return seastar::make_ready_future<>();
     })
   );