From: Samuel Just Date: Wed, 16 Oct 2019 18:12:12 +0000 (-0700) Subject: crimson/osd: convert PG::wait_for_active to a blocking_future X-Git-Tag: v15.1.0~687^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e5a0499b68228dede3eaef60cfb933b29772e4a5;p=ceph-ci.git crimson/osd: convert PG::wait_for_active to a blocking_future Signed-off-by: Samuel Just --- diff --git a/src/crimson/osd/osd_operations/client_request.cc b/src/crimson/osd/osd_operations/client_request.cc index 320de146947..3661d042734 100644 --- a/src/crimson/osd/osd_operations/client_request.cc +++ b/src/crimson/osd/osd_operations/client_request.cc @@ -76,7 +76,7 @@ seastar::future<> ClientRequest::start() return with_blocking_future( handle.enter(pp(pg).wait_for_active)); }).then([this, &pg]() mutable { - return pg.wait_for_active(); + return with_blocking_future(pg.wait_for_active_blocker.wait()); }).then([this, &pg]() mutable { if (m->finish_decode()) { m->clear_payload(); diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index 9db75b01053..01cad4a2d2e 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -110,7 +110,8 @@ PG::PG( osdmap->get_pool_name(pgid.pool())), osdmap, this, - this) + this), + wait_for_active_blocker(this) { peering_state.set_backend_predicates( new ReadablePredicate(pg_whoami), @@ -200,8 +201,7 @@ void PG::on_activate(interval_set) void PG::on_activate_complete() { - active_promise.set_value(); - active_promise = {}; + wait_for_active_blocker.on_active(); if (peering_state.needs_recovery()) { shard_services.start_operation( @@ -402,13 +402,23 @@ std::ostream& operator<<(std::ostream& os, const PG& pg) return os; } -seastar::future<> PG::wait_for_active() +void PG::WaitForActiveBlocker::dump_detail(Formatter *f) const { - logger().debug("wait_for_active: {}", peering_state.get_pg_state_string()); - if (peering_state.is_active()) { - return seastar::now(); + f->dump_stream("pgid") << pg->pgid; +} + +void PG::WaitForActiveBlocker::on_active() +{ + p.set_value(); + p = {}; +} + +blocking_future<> PG::WaitForActiveBlocker::wait() +{ + if (pg->peering_state.is_active()) { + return make_blocking_future(seastar::now()); } else { - return active_promise.get_shared_future(); + return make_blocking_future(p.get_shared_future()); } } diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index fd6c90dbadf..462d77a771b 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -515,8 +515,22 @@ private: PeeringState peering_state; eversion_t projected_last_update; - seastar::shared_promise<> active_promise; - seastar::future<> wait_for_active(); + class WaitForActiveBlocker : public BlockerT { + PG *pg; + + const spg_t pgid; + seastar::shared_promise<> p; + + protected: + void dump_detail(Formatter *f) const; + + public: + static constexpr const char *type_name = "WaitForActiveBlocker"; + + WaitForActiveBlocker(PG *pg) : pg(pg) {} + void on_active(); + blocking_future<> wait(); + } wait_for_active_blocker; friend std::ostream& operator<<(std::ostream&, const PG& pg); friend class ClientRequest;