Skip to content

Commit 9ec3c2c

Browse files
committed
Don't count Done bytes for backpressure
1 parent e0f4b62 commit 9ec3c2c

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

upstairs/src/downstairs.rs

+19-12
Original file line numberDiff line numberDiff line change
@@ -2707,17 +2707,7 @@ impl Downstairs {
27072707
}
27082708
// Now that we've collected jobs to retire, remove them from the map
27092709
for &id in &retired {
2710-
let job = self.ds_active.remove(&id);
2711-
// Update pending bytes when this job is retired
2712-
let change = match &job.work {
2713-
IOop::Write { data, .. }
2714-
| IOop::WriteUnwritten { data, .. } => {
2715-
data.io_size_bytes as u64
2716-
}
2717-
_ => 0,
2718-
};
2719-
self.write_bytes_outstanding =
2720-
self.write_bytes_outstanding.checked_sub(change).unwrap();
2710+
let _ = self.ds_active.remove(&id);
27212711
}
27222712

27232713
debug!(self.log, "[rc] retire {} clears {:?}", ds_id, retired);
@@ -3205,6 +3195,24 @@ impl Downstairs {
32053195
self.ackable_work.insert(ds_id);
32063196
}
32073197

3198+
// Write bytes no longer count for backpressure once all 3x downstairs
3199+
// have returned (although they'll continue to be stored until they are
3200+
// retired by the next flush).
3201+
let wc = job.state_count();
3202+
if (wc.error + wc.skipped + wc.done) == 3 {
3203+
match &job.work {
3204+
IOop::Write { data, .. }
3205+
| IOop::WriteUnwritten { data, .. } => {
3206+
let change = data.io_size_bytes as u64;
3207+
self.write_bytes_outstanding = self
3208+
.write_bytes_outstanding
3209+
.checked_sub(change)
3210+
.unwrap();
3211+
}
3212+
_ => (),
3213+
};
3214+
}
3215+
32083216
/*
32093217
* If all 3 jobs are done, we can check here to see if we can
32103218
* remove this job from the DS list. If we have completed the ack
@@ -3218,7 +3226,6 @@ impl Downstairs {
32183226
// hasn't acked back yet. We check for NotAcked so we don't
32193227
// double count three done and return true if we already have
32203228
// AckReady set.
3221-
let wc = job.state_count();
32223229

32233230
// If we are a write or a flush with one success, then
32243231
// we must switch our state to failed. This condition is

0 commit comments

Comments
 (0)