Skip to content

Commit 6c03d29

Browse files
authored
Remove unnecessary division of live-repair functions (#1469)
Previously, we broke live-repair into two phases: - Check for the next live-repair job - Perform that job (and subsequent jobs that were made ready) This division was to "avoid locking the `GuestWork` structure if live-repair can't continue" (according to the docstring). However, the `GuestWork` is now owned by the `Upstairs` (without a lock), so the two-phase operation is no longer necessary.
1 parent a866642 commit 6c03d29

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

upstairs/src/downstairs.rs

+11-20
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ impl Downstairs {
11741174
///
11751175
/// This must be called before `Downstairs::ack_jobs`, because it looks for
11761176
/// the repair job in `self.ackable_work` to decide if it's done.
1177-
pub(crate) fn check_live_repair(&mut self) -> Option<JobId> {
1177+
fn get_live_repair_job(&mut self) -> Option<JobId> {
11781178
if let Some(repair) = &self.repair {
11791179
let ds_id = repair.state.active_job_id();
11801180
if self.ackable_work.contains(&ds_id) {
@@ -1192,33 +1192,24 @@ impl Downstairs {
11921192
}
11931193
}
11941194

1195-
/// Pushes live-repair forward, starting at the given job
1195+
/// Pushes live-repair forward, if possible
11961196
///
1197-
/// `self.repair` must be waiting on the job given by `ds_id`, and that job
1198-
/// must be (1) in `self.ackable_work` and (2) not yet acked.
1199-
///
1200-
/// As such, this function should only be called after
1201-
/// `self.check_live_repair` provides the value for `ds_id`; they're broken
1202-
/// into separate functions to avoid locking the `GuestWork` structure if
1203-
/// live-repair can't continue.
1204-
///
1205-
/// It's possible that handling this job will make subsequent live-repair
1206-
/// jobs ackable immediately (`test_repair_extent_fail_noop_out_of_order`
1207-
/// exercises this case). As such, this function will continue running
1208-
/// until the next live-repair job is not ready.
1209-
pub(crate) fn continue_live_repair(
1197+
/// It's possible that handling the current live-repair job will make
1198+
/// subsequent live-repair jobs ackable immediately
1199+
/// (`test_repair_extent_fail_noop_out_of_order` exercises this case). As
1200+
/// such, this function will continue running until the next live-repair job
1201+
/// is not ready.
1202+
pub(crate) fn check_and_continue_live_repair(
12101203
&mut self,
1211-
ds_id: JobId,
12121204
gw: &mut GuestWork,
12131205
up_state: &UpstairsState,
12141206
) {
1215-
self.continue_live_repair_inner(ds_id, gw, up_state);
1216-
while let Some(ds_id) = self.check_live_repair() {
1217-
self.continue_live_repair_inner(ds_id, gw, up_state);
1207+
while let Some(ds_id) = self.get_live_repair_job() {
1208+
self.continue_live_repair(ds_id, gw, up_state);
12181209
}
12191210
}
12201211

1221-
fn continue_live_repair_inner(
1212+
fn continue_live_repair(
12221213
&mut self,
12231214
ds_id: JobId,
12241215
gw: &mut GuestWork,

upstairs/src/upstairs.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -622,13 +622,10 @@ impl Upstairs {
622622
//
623623
// This must be called before acking jobs, because it looks in
624624
// `Downstairs::ackable_jobs` to see which jobs are done.
625-
if let Some(job_id) = self.downstairs.check_live_repair() {
626-
self.downstairs.continue_live_repair(
627-
job_id,
628-
&mut self.guest.guest_work,
629-
&self.state,
630-
);
631-
}
625+
self.downstairs.check_and_continue_live_repair(
626+
&mut self.guest.guest_work,
627+
&self.state,
628+
);
632629

633630
// Send jobs downstairs as they become available. This must be called
634631
// after `continue_live_repair`, which may enqueue jobs.

0 commit comments

Comments
 (0)