From: Radoslaw Zarzynski Date: Tue, 21 Apr 2020 18:45:21 +0000 (+0200) Subject: crimson/osd: sketch the backfill machine and its interfaces. X-Git-Tag: v16.1.0~1720^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dfaf3191fe8015f87a24511b691e4ac135bfedc9;p=ceph.git crimson/osd: sketch the backfill machine and its interfaces. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/osd/backfill_state.h b/src/crimson/osd/backfill_state.h new file mode 100644 index 00000000000..21015a46cb1 --- /dev/null +++ b/src/crimson/osd/backfill_state.h @@ -0,0 +1,119 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include "osd/recovery_types.h" + +namespace crimson::osd { + +namespace sc = boost::statechart; + +struct BackfillState { + struct BackfillListener; + + // events comes first + struct PrimaryScanned : sc::event { + BackfillInterval result; + }; + + struct ReplicaScanned : sc::event { + pg_shard_t from; + BackfillInterval result; + }; + + struct Flushed : sc::event { + }; + + struct Triggered : sc::event { + }; + + struct Initial; + struct Enqueuing; + + class BackfillMachine : public sc::state_machine { + }; + + // states + struct Crashed : sc::state, NamedState { + }; + + struct Initial : sc::state, NamedState { + using reactions = boost::mpl::list< + sc::custom_reaction, + sc::transition>; + // initialize after triggering backfill by on_activate_complete(). + // transit to Enqueuing. + sc::result react(const Triggered&); + }; + + struct Enqueuing : sc::state, NamedState { + using reactions = boost::mpl::list< + sc::transition>; + }; + + struct PrimaryScanning : sc::state, + NamedState { + using reactions = boost::mpl::list< + sc::custom_reaction, + sc::transition>; + // collect scanning result and transit to Enqueuing. + sc::result react(const PrimaryScanned&); + }; + + struct ReplicasScanning : sc::state, + NamedState { + using reactions = boost::mpl::list< + sc::custom_reaction, + sc::transition>; + // collect scanning result; if all results are collected, transition + // to Enqueuing will happen. + sc::result react(const ReplicaScanned&); + }; + + struct Flushing : sc::simple_state, + NamedState { + using reactions = boost::mpl::list< + sc::transition, + sc::transition>; + }; +}; + +struct BackfillState::BackfillListener { + virtual void request_replica_scan( + const pg_shard_t& target, + const hobject_t& begin, + const hobject_t& end) = 0; + + virtual void request_primary_scan( + const hobject_t& begin) = 0; + + virtual void enqueue_push( + const pg_shard_t& target, + const hobject_t& obj, + const eversion_t& v) = 0; + + virtual void enqueue_drop( + const pg_shard_t& target, + const hobject_t& obj, + const eversion_t& v) = 0; + + virtual void update_peers_last_backfill( + const hobject_t& new_last_backfill) = 0; + + virtual bool budget_available() const = 0; + + virtual void backfilled() = 0; + + virtual ~BackfillListener() = default; +}; + +} // namespace crimson::osd