Skip to content

Commit be2bab6

Browse files
authored
Test read from 3x faulted Downstairs (#1470)
This should return an error, because the IO is skipped on all 3x Downstairs. Previously, it did not!
1 parent 6c03d29 commit be2bab6

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

upstairs/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ impl DownstairsIO {
10581058
let wc = self.state_count();
10591059

10601060
let bad_job = match &self.work {
1061-
IOop::Read { .. } => wc.error == 3,
1061+
IOop::Read { .. } => wc.done == 0,
10621062
IOop::Write { .. }
10631063
| IOop::WriteUnwritten { .. }
10641064
| IOop::Flush { .. } => wc.skipped + wc.error > 1,

upstairs/src/upstairs.rs

+37
Original file line numberDiff line numberDiff line change
@@ -4276,4 +4276,41 @@ pub(crate) mod test {
42764276
assert_eq!(up.deferred_ops.len(), 2);
42774277
assert_eq!(up.deferred_msgs.len(), 0);
42784278
}
4279+
4280+
/// What happens when a guest submits a read after three downstairs have
4281+
/// faulted?
4282+
#[tokio::test]
4283+
async fn three_faulted_downstairs_read() {
4284+
let mut up = make_upstairs();
4285+
up.force_active().unwrap();
4286+
set_all_active(&mut up.downstairs);
4287+
4288+
up.downstairs.clients[ClientId::new(0)]
4289+
.checked_state_transition(&UpstairsState::Active, DsState::Faulted);
4290+
up.downstairs.clients[ClientId::new(1)]
4291+
.checked_state_transition(&UpstairsState::Active, DsState::Faulted);
4292+
up.downstairs.clients[ClientId::new(2)]
4293+
.checked_state_transition(&UpstairsState::Active, DsState::Faulted);
4294+
4295+
let data = Buffer::new(1, 512);
4296+
let offset = BlockIndex(7);
4297+
let (res, done) = BlockOpWaiter::pair();
4298+
up.apply(UpstairsAction::Guest(BlockOp::Read { offset, data, done }));
4299+
4300+
let reply = res.wait_raw().await.unwrap();
4301+
match reply {
4302+
// Alan says "If none of the reads returned, then the guest had
4303+
// better get an error."
4304+
Err((_, _)) => {
4305+
// ok!
4306+
}
4307+
4308+
Ok(_) => {
4309+
// Alan says "If we return OK, then what data are we giving the
4310+
// guest?"
4311+
eprintln!("{reply:?}");
4312+
panic!("returned Ok!");
4313+
}
4314+
}
4315+
}
42794316
}

0 commit comments

Comments
 (0)