Skip to content

Commit

Permalink
fix(nexus): shutdown nexuses upon graceful shutdown
Browse files Browse the repository at this point in the history
Upon graceful I/O agent shutdown all nexuses are now also properly
shutdown (clear shutdown flag is set to ‘true’) and persisted in ETCD.

Signed-off-by: Mikhail Tcymbaliuk <[email protected]>
  • Loading branch information
mtzaurus committed Sep 28, 2022
1 parent d373ba4 commit 448b5e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
17 changes: 11 additions & 6 deletions mayastor/src/bdev/nexus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,17 @@ pub fn register_module() {

/// called during shutdown so that all nexus children are in Destroying state
/// so that a possible remove event from SPDK also results in bdev removal
pub async fn nexus_children_to_destroying_state() {
info!("setting all nexus children to destroying state...");
for nexus in nexus_iter() {
for child in nexus.children.iter() {
child.set_state(nexus_child::ChildState::Destroying);
pub async fn shutdown_nexuses() {
info!("Shutting down nexuses...");
for mut nexus in nexus_iter_mut() {
// Destroy nexus and persist its state in the ETCd.
if let Err(error) = nexus.as_mut().destroy().await {
error!(
name = %nexus.name,
error = %error.verbose(),
"Failed to destroy nexus"
);
}
}
info!("set all nexus children to destroying state");
info!("All nexus have been shutdown.");
}
2 changes: 1 addition & 1 deletion mayastor/src/core/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ async fn do_shutdown(arg: *mut c_void) {
warn!("Mayastor stopped non-zero: {}", rc);
}

nexus::nexus_children_to_destroying_state().await;
nexus::shutdown_nexuses().await;
crate::lvs::Lvs::export_all().await;
unsafe {
spdk_rpc_finish();
Expand Down
5 changes: 2 additions & 3 deletions mayastor/tests/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ async fn persist_unexpected_restart() {
let value = response.kvs().first().unwrap().value();
let nexus_info: NexusInfo = serde_json::from_slice(value).unwrap();

// Check the persisted nexus info remains unchanged.

assert!(!nexus_info.clean_shutdown);
// Check the persisted nexus info changed to reflect clean shutdown.
assert!(nexus_info.clean_shutdown);

let child = child_info(&nexus_info, &uuid(&child1));
assert!(child.healthy);
Expand Down

0 comments on commit 448b5e0

Please sign in to comment.