Skip to content

Commit ca5228d

Browse files
committed
fix(nexus): set children to destroying state on shutdown
The existing call to destroy all nexuses on shutdown uses a reference to the list of nexuses, which is itself mutated when a nexus is destroyed. This can lead to a segfault on some platforms. Destroying a nexus also leads to the child states being saved to the config file, which is unintended. Set all children to Destroying state instead to address both issues. Fixes: 3ae2903 ("fix(nexus): allow re-adding child removed by AEN")
1 parent 0a94597 commit ca5228d

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

mayastor/src/bdev/nexus/mod.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,14 @@ pub fn nexus_instance_new(name: String, size: u64, children: Vec<String>) {
6060
list.push(Nexus::new(&name, size, None, Some(&children)));
6161
}
6262

63-
/// called during shutdown so that the bdevs for each child is destroyed first
64-
pub async fn nexus_destroy_all() {
65-
info!("destroying all nexuses...");
63+
/// called during shutdown so that all nexus children are in Destroying state
64+
/// so that a possible remove event from SPDK also results in bdev removal
65+
pub async fn nexus_children_to_destroying_state() {
66+
info!("setting all nexus children to destroying state...");
6667
for nexus in instances() {
67-
if let Err(e) = nexus.destroy().await {
68-
error!(
69-
"failed to destroy nexus {} during shutdown: {}",
70-
nexus.name, e
71-
);
68+
for child in nexus.children.iter() {
69+
child.set_state(nexus_child::ChildState::Destroying);
7270
}
7371
}
74-
info!("destroyed all nexuses");
72+
info!("set all nexus children to destroying state");
7573
}

mayastor/src/core/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ async fn do_shutdown(arg: *mut c_void) {
279279
}
280280

281281
iscsi::fini();
282-
nexus::nexus_destroy_all().await;
282+
nexus::nexus_children_to_destroying_state().await;
283283
unsafe {
284284
spdk_rpc_finish();
285285
spdk_subsystem_fini(Some(reactors_stop), arg);

0 commit comments

Comments
 (0)