1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
6 #include <boost/statechart/event_base.hpp>
8 #include "crimson/net/Connection.h"
9 #include "crimson/osd/osd_operation.h"
10 #include "crimson/osd/recovery_backend.h"
11 #include "crimson/common/type_helpers.h"
12 #include "crimson/osd/osd_operations/peering_event.h"
13 #include "crimson/osd/pg.h"
15 namespace crimson::osd
{
20 class BackgroundRecoveryT
: public PhasedOperationT
<T
> {
22 static constexpr OperationTypeCode type
= OperationTypeCode::background_recovery
;
27 epoch_t epoch_started
,
28 crimson::osd::scheduler::scheduler_class_t scheduler_class
, float delay
= 0);
30 virtual void print(std::ostream
&) const;
31 seastar::future
<> start();
35 const epoch_t epoch_started
;
39 virtual void dump_detail(Formatter
*f
) const;
40 crimson::osd::scheduler::params_t
get_scheduler_params() const {
47 using do_recovery_ret_t
= typename PhasedOperationT
<T
>::template interruptible_future
<bool>;
48 virtual do_recovery_ret_t
do_recovery() = 0;
50 const crimson::osd::scheduler::scheduler_class_t scheduler_class
;
53 /// represent a recovery initiated for serving a client request
55 /// unlike @c PglogBasedRecovery and @c BackfillRecovery,
56 /// @c UrgentRecovery is not throttled by the scheduler. and it
57 /// utilizes @c RecoveryBackend directly to recover the unreadable
59 class UrgentRecovery final
: public BackgroundRecoveryT
<UrgentRecovery
> {
62 const hobject_t
& soid
,
63 const eversion_t
& need
,
66 epoch_t epoch_started
);
67 void print(std::ostream
&) const final
;
70 OperationThrottler::BlockingEvent
,
71 RecoveryBackend::RecoveryBlockingEvent
75 void dump_detail(Formatter
* f
) const final
;
76 interruptible_future
<bool> do_recovery() override
;
78 const eversion_t need
;
81 class PglogBasedRecovery final
: public BackgroundRecoveryT
<PglogBasedRecovery
> {
86 epoch_t epoch_started
,
90 OperationThrottler::BlockingEvent
,
91 RecoveryBackend::RecoveryBlockingEvent
95 interruptible_future
<bool> do_recovery() override
;
98 class BackfillRecovery final
: public BackgroundRecoveryT
<BackfillRecovery
> {
101 template <class EventT
>
105 epoch_t epoch_started
,
108 PipelineHandle
& get_handle() { return handle
; }
111 OperationThrottler::BlockingEvent
,
112 PGPeeringPipeline::Process::BlockingEvent
116 boost::intrusive_ptr
<const boost::statechart::event_base
> evt
;
117 PipelineHandle handle
;
119 static PGPeeringPipeline
&bp(PG
&pg
);
120 interruptible_future
<bool> do_recovery() override
;
123 template <class EventT
>
124 BackfillRecovery::BackfillRecovery(
127 const epoch_t epoch_started
,
129 : BackgroundRecoveryT(
133 crimson::osd::scheduler::scheduler_class_t::background_best_effort
),
134 evt(evt
.intrusive_from_this())
139 #if FMT_VERSION >= 90000
140 template <> struct fmt::formatter
<crimson::osd::BackfillRecovery
> : fmt::ostream_formatter
{};
141 template <> struct fmt::formatter
<crimson::osd::PglogBasedRecovery
> : fmt::ostream_formatter
{};
142 template <> struct fmt::formatter
<crimson::osd::UrgentRecovery
> : fmt::ostream_formatter
{};
143 template <class T
> struct fmt::formatter
<crimson::osd::BackgroundRecoveryT
<T
>> : fmt::ostream_formatter
{};