]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #pragma once | |
5 | /** | |
6 | * \file the PgScrubber interface used by the scrub FSM | |
7 | */ | |
8 | #include "common/version.h" | |
9 | #include "include/Context.h" | |
10 | ||
11 | #include "osd_types.h" | |
12 | ||
13 | namespace Scrub { | |
14 | ||
15 | /// used when PgScrubber is called by the scrub-machine, to tell the FSM | |
16 | /// how to continue | |
17 | enum class FsmNext { do_discard, next_chunk, goto_notactive }; | |
18 | enum class PreemptionNoted { no_preemption, preempted }; | |
19 | ||
20 | /// the interface exposed by the PgScrubber into its internal | |
21 | /// preemption_data object | |
22 | struct preemption_t { | |
23 | ||
24 | virtual ~preemption_t(){}; | |
25 | ||
26 | [[nodiscard]] virtual bool is_preemptable() const = 0; | |
27 | ||
28 | [[nodiscard]] virtual bool was_preempted() const = 0; | |
29 | ||
30 | virtual void adjust_parameters() = 0; | |
31 | ||
32 | /** | |
33 | * Try to preempt the scrub. | |
34 | * 'true' (i.e. - preempted) if: | |
35 | * preemptable && not already preempted | |
36 | */ | |
37 | virtual bool do_preempt() = 0; | |
38 | ||
39 | /** | |
40 | * disables preemptions. | |
41 | * Returns 'true' if we were already preempted | |
42 | */ | |
43 | virtual bool disable_and_test() = 0; | |
44 | }; | |
45 | ||
46 | } // namespace Scrub | |
47 | ||
48 | struct ScrubMachineListener { | |
49 | ||
50 | virtual ~ScrubMachineListener(){}; | |
51 | ||
52 | virtual bool select_range() = 0; | |
53 | ||
54 | /// walk the log to find the latest update that affects our chunk | |
55 | virtual eversion_t search_log_for_updates() const = 0; | |
56 | ||
57 | virtual eversion_t get_last_update_applied() const = 0; | |
58 | ||
59 | virtual int pending_active_pushes() const = 0; | |
60 | ||
61 | virtual int build_primary_map_chunk() = 0; | |
62 | ||
63 | virtual int build_replica_map_chunk() = 0; | |
64 | ||
65 | virtual void scrub_compare_maps() = 0; | |
66 | ||
67 | virtual void on_init() = 0; | |
68 | ||
69 | virtual void on_replica_init() = 0; | |
70 | ||
71 | virtual void replica_handling_done() = 0; | |
72 | ||
73 | // no virtual void discard_reservation_by_primary() = 0; | |
74 | ||
75 | /// the version of 'scrub_clear_state()' that does not try to invoke FSM services | |
76 | /// (thus can be called from FSM reactions) | |
77 | virtual void clear_pgscrub_state() = 0; | |
78 | ||
79 | virtual void add_delayed_scheduling() = 0; | |
80 | ||
81 | /** | |
82 | * @returns have we asked at least one replica? | |
83 | * 'false' means we are configured with no replicas, and | |
84 | * should expect no maps to arrive. | |
85 | */ | |
86 | virtual bool get_replicas_maps(bool replica_can_preempt) = 0; | |
87 | ||
88 | virtual Scrub::FsmNext on_digest_updates() = 0; | |
89 | ||
90 | virtual void send_replica_map(Scrub::PreemptionNoted was_preempted) = 0; | |
91 | ||
92 | [[nodiscard]] virtual bool has_pg_marked_new_updates() const = 0; | |
93 | ||
94 | virtual void set_subset_last_update(eversion_t e) = 0; | |
95 | ||
96 | [[nodiscard]] virtual bool was_epoch_changed() const = 0; | |
97 | ||
98 | virtual Scrub::preemption_t& get_preemptor() = 0; | |
99 | ||
100 | /** | |
101 | * a "technical" collection of the steps performed once all | |
102 | * rep maps are available: | |
103 | * - the maps are compared | |
104 | * - the scrub region markers (start_ & end_) are advanced | |
105 | * - callbacks and ops that were pending are free to run | |
106 | */ | |
107 | virtual void maps_compare_n_cleanup() = 0; | |
108 | ||
109 | /** | |
110 | * order the PgScrubber to initiate the process of reserving replicas' scrub | |
111 | * resources. | |
112 | */ | |
113 | virtual void reserve_replicas() = 0; | |
114 | ||
115 | virtual void unreserve_replicas() = 0; | |
116 | ||
117 | /** | |
118 | * the FSM interface into the "are we waiting for maps, either our own or from | |
119 | * replicas" state. | |
120 | * The FSM can only: | |
121 | * - mark the local map as available, and | |
122 | * - query status | |
123 | */ | |
124 | virtual void mark_local_map_ready() = 0; | |
125 | ||
126 | [[nodiscard]] virtual bool are_all_maps_available() const = 0; | |
127 | ||
128 | /// a log/debug interface | |
129 | virtual std::string dump_awaited_maps() const = 0; | |
130 | }; |