Skip to content

Commit 8e5da47

Browse files
rzarzynskixxhdx1985126
authored andcommitted
crimson/osd: BackfillMachine does support cancel and resume now
Signed-off-by: Radoslaw Zarzynski <[email protected]>
1 parent b9d6a00 commit 8e5da47

File tree

2 files changed

+52
-8
lines changed

2 files changed

+52
-8
lines changed

src/crimson/osd/backfill_state.cc

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ BackfillState::Initial::react(const BackfillState::Triggered& evt)
101101
}
102102
}
103103

104+
boost::statechart::result
105+
BackfillState::Cancelled::react(const BackfillState::Triggered& evt)
106+
{
107+
logger().debug("{}: backfill re-triggered", __func__);
108+
ceph_assert(peering_state().is_backfilling());
109+
if (Enqueuing::all_enqueued(peering_state(),
110+
backfill_state().backfill_info,
111+
backfill_state().peer_backfill_info)) {
112+
logger().debug("{}: switching to Done state", __func__);
113+
return transit<BackfillState::Done>();
114+
} else {
115+
logger().debug("{}: switching to Enqueuing state", __func__);
116+
return transit<BackfillState::Enqueuing>();
117+
}
118+
}
104119

105120
// -- Enqueuing
106121
void BackfillState::Enqueuing::maybe_update_range()
@@ -451,6 +466,15 @@ BackfillState::ReplicasScanning::react(ReplicaScanned evt)
451466
return discard_event();
452467
}
453468

469+
boost::statechart::result
470+
BackfillState::ReplicasScanning::react(CancelBackfill evt)
471+
{
472+
logger().debug("{}: cancelled within ReplicasScanning",
473+
__func__);
474+
waiting_on_backfill.clear();
475+
return transit<Cancelled>();
476+
}
477+
454478
boost::statechart::result
455479
BackfillState::ReplicasScanning::react(ObjectPushed evt)
456480
{
@@ -499,11 +523,10 @@ BackfillState::Crashed::Crashed()
499523
}
500524

501525
// -- Cancelled
502-
BackfillState::Cancelled::Cancelled()
526+
BackfillState::Cancelled::Cancelled(my_context ctx)
527+
: my_base(ctx)
503528
{
504-
backfill_state().backfill_info.clear();
505-
backfill_state().peer_backfill_info.clear();
506-
backfill_state().progress_tracker.reset();
529+
ceph_assert(peering_state().get_backfill_targets().size());
507530
}
508531

509532
// ProgressTracker is an intermediary between the BackfillListener and

src/crimson/osd/backfill_state.h

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,27 @@ struct BackfillState {
135135
explicit Crashed();
136136
};
137137

138-
struct Cancelled : sc::simple_state<Cancelled, BackfillMachine>,
139-
StateHelper<Cancelled> {
140-
explicit Cancelled();
138+
struct Cancelled : sc::state<Cancelled, BackfillMachine>,
139+
StateHelper<Cancelled> {
140+
using reactions = boost::mpl::list<
141+
sc::custom_reaction<Triggered>,
142+
sc::custom_reaction<PrimaryScanned>,
143+
sc::custom_reaction<ReplicaScanned>,
144+
sc::custom_reaction<ObjectPushed>,
145+
sc::transition<sc::event_base, Crashed>>;
146+
explicit Cancelled(my_context);
147+
// resume after triggering backfill by on_activate_complete().
148+
// transit to Enqueuing.
149+
sc::result react(const Triggered&);
150+
sc::result react(const PrimaryScanned&) {
151+
return discard_event();
152+
}
153+
sc::result react(const ReplicaScanned&) {
154+
return discard_event();
155+
}
156+
sc::result react(const ObjectPushed&) {
157+
return discard_event();
158+
}
141159
};
142160

143161
struct Initial : sc::state<Initial, BackfillMachine>,
@@ -159,6 +177,8 @@ struct BackfillState {
159177
sc::transition<RequestPrimaryScanning, PrimaryScanning>,
160178
sc::transition<RequestReplicasScanning, ReplicasScanning>,
161179
sc::transition<RequestWaiting, Waiting>,
180+
sc::transition<RequestDone, Done>,
181+
sc::transition<CancelBackfill, Cancelled>,
162182
sc::transition<sc::event_base, Crashed>>;
163183
explicit Enqueuing(my_context);
164184

@@ -229,14 +249,15 @@ struct BackfillState {
229249
using reactions = boost::mpl::list<
230250
sc::custom_reaction<ObjectPushed>,
231251
sc::custom_reaction<ReplicaScanned>,
252+
sc::custom_reaction<CancelBackfill>,
232253
sc::transition<RequestDone, Done>,
233-
sc::transition<CancelBackfill, Cancelled>,
234254
sc::transition<sc::event_base, Crashed>>;
235255
explicit ReplicasScanning(my_context);
236256
// collect scanning result; if all results are collected, transition
237257
// to Enqueuing will happen.
238258
sc::result react(ObjectPushed);
239259
sc::result react(ReplicaScanned);
260+
sc::result react(CancelBackfill);
240261

241262
// indicate whether a particular peer should be scanned to retrieve
242263
// BackfillInterval for new range of hobject_t namespace.

0 commit comments

Comments
 (0)