Skip to content

Commit

Permalink
Remove more unnecessary DsState variants (#1550)
Browse files Browse the repository at this point in the history
- `DsState::Migrating` is not yet implemented
- `DsState::Disconnected` is another transient state (see #1526). It's
assigned in `DownstairsClient::restart_connection` (which halts the IO
task), then we switch to `DsState::New` once the IO task halts. Those
two states are never actually handled differently, so we can switch to
`DsState::New` immediately
  • Loading branch information
mkeeter authored Nov 5, 2024
1 parent a9d614a commit 6277bf3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 44 deletions.
2 changes: 0 additions & 2 deletions cmon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,11 @@ fn short_state(dss: DsState) -> String {
DsState::New => "NEW".to_string(),
DsState::WaitActive => "WAC".to_string(),
DsState::WaitQuorum => "WAQ".to_string(),
DsState::Disconnected => "DIS".to_string(),
DsState::Reconcile => "REC".to_string(),
DsState::Active => "ACT".to_string(),
DsState::Faulted => "FLT".to_string(),
DsState::LiveRepairReady => "LRR".to_string(),
DsState::LiveRepair => "LR".to_string(),
DsState::Migrating => "MIG".to_string(),
DsState::Offline => "OFF".to_string(),
DsState::Deactivated => "DAV".to_string(),
DsState::Disabled => "DIS".to_string(),
Expand Down
2 changes: 0 additions & 2 deletions openapi/crucible-control.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,11 @@
"new",
"wait_active",
"wait_quorum",
"disconnected",
"reconcile",
"active",
"faulted",
"live_repair_ready",
"live_repair",
"migrating",
"offline",
"deactivated",
"disabled",
Expand Down
17 changes: 2 additions & 15 deletions upstairs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,6 @@ impl DownstairsClient {

DsState::Deactivated
| DsState::Reconcile
| DsState::Disconnected
| DsState::WaitQuorum
| DsState::WaitActive
| DsState::Disabled => Some(DsState::New),
Expand All @@ -591,8 +590,6 @@ impl DownstairsClient {
| DsState::Faulted
| DsState::New
| DsState::Replaced => None,

DsState::Migrating => panic!(),
};

// Jobs are skipped and replayed in `Downstairs::reinitialize`, which is
Expand Down Expand Up @@ -846,7 +843,6 @@ impl DownstairsClient {
let new_state = match self.state {
DsState::Active => DsState::Offline,
DsState::Offline => DsState::Offline,
DsState::Migrating => DsState::Faulted,
DsState::Faulted => DsState::Faulted,
DsState::Deactivated => DsState::New,
DsState::Reconcile => DsState::New,
Expand All @@ -859,7 +855,7 @@ impl DownstairsClient {
* downstairs to receive IO, so we go to the back of the
* line and have to re-verify it again.
*/
DsState::Disconnected
DsState::New
}
};

Expand Down Expand Up @@ -960,11 +956,9 @@ impl DownstairsClient {
DsState::New
| DsState::WaitActive
| DsState::WaitQuorum
| DsState::Disconnected
| DsState::Reconcile
| DsState::Deactivated
| DsState::Disabled
| DsState::Migrating => panic!(
| DsState::Disabled => panic!(
"enqueue should not be called from state {:?}",
self.state
),
Expand Down Expand Up @@ -1045,7 +1039,6 @@ impl DownstairsClient {
}
} else if old_state != DsState::New
&& old_state != DsState::Faulted
&& old_state != DsState::Disconnected
&& old_state != DsState::Replaced
{
panic!(
Expand Down Expand Up @@ -1157,12 +1150,6 @@ impl DownstairsClient {
// A move to Disabled can happen at any time we are talking
// to a downstairs.
}
_ => {
panic!(
"[{}] Missing check for transition {} to {}",
self.client_id, old_state, new_state
);
}
}

if old_state != new_state {
Expand Down
34 changes: 9 additions & 25 deletions upstairs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,17 +715,17 @@ pub(crate) struct RawReadResponse {
* ┌─────────────► New ╞═════◄════════════════╗ ║
* │ ┌─────► ├─────◄──────┐ ║ ║
* │ │ └────┬───┬──┘ │ ║ ║
* │ │ ▼ └───►───┐ │ ║ ║
* │ bad│ ┌────┴──────┐ │ ║ ║
* │ region│ │ Wait │ │ ║ ║
* │ │ ▼ └───►───┐ other │ ║ ║
* │ bad│ ┌────┴──────┐ │ failures ║ ║
* │ region│ │ Wait │ │ ║ ║
* │ │ │ Active ├─►┐ │ │ ║ ║
* │ │ └────┬──────┘ │ │ ┌────┴───────┐ ║ ║
* │ │ ┌────┴──────┐ │ └──┤ ║ ║
* │ │ │ Wait │ └────┤Disconnected│ ║ ║
* │ └─────┤ Quorum ├──►────┤ ║ ║
* │ └────┬──────┘ └────┬───────┘ ║ ║
* │ │ └────┬──────┘ │ │ ║ ║
* │ │ ┌────┴──────┐ │ └───────┤ ║ ║
* │ │ │ Wait │ └─────────┤ ║ ║
* │ └─────┤ Quorum ├──►─────────┤ ║ ║
* │ └────┬──────┘ ║ ║
* │ ........▼.......... │ ║ ║
* │failed : ┌────┴──────┐ : ║ ║
* │failed : ┌────┴──────┐ : ║ ║
* │reconcile : │ Reconcile │ : │ ╔═╝ ║
* └─────────────┤ ├──►─────────┘ ║ ║
* : └────┬──────┘ : ║ ║
Expand Down Expand Up @@ -786,12 +786,6 @@ pub enum DsState {
* Waiting for the minimum number of downstairs to be present.
*/
WaitQuorum,
/*
* We were connected, but did not transition all the way to
* active before the connection went away. Arriving here means the
* downstairs has to go back through the whole negotiation process.
*/
Disconnected,
/*
* Initial startup, downstairs are repairing from each other.
*/
Expand All @@ -815,10 +809,6 @@ pub enum DsState {
* This downstairs is undergoing LiveRepair
*/
LiveRepair,
/*
* This downstairs is being migrated to a new location
*/
Migrating,
/*
* This downstairs was active, but is now no longer connected.
* We may have work for it in memory, so a replay is possible
Expand Down Expand Up @@ -858,9 +848,6 @@ impl std::fmt::Display for DsState {
DsState::WaitQuorum => {
write!(f, "WaitQuorum")
}
DsState::Disconnected => {
write!(f, "Disconnected")
}
DsState::Reconcile => {
write!(f, "Reconcile")
}
Expand All @@ -876,9 +863,6 @@ impl std::fmt::Display for DsState {
DsState::LiveRepair => {
write!(f, "LiveRepair")
}
DsState::Migrating => {
write!(f, "Migrating")
}
DsState::Offline => {
write!(f, "Offline")
}
Expand Down

0 comments on commit 6277bf3

Please sign in to comment.