Skip to content

Commit

Permalink
CAS-370: hot remove child from parent
Browse files Browse the repository at this point in the history
During shutdown, when a child is removed that is still open
the hot remove callback should release it.
  • Loading branch information
gila committed Aug 11, 2020
1 parent 2f5daf8 commit d16762c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mayastor/src/core/bdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use spdk_sys::{
};

use crate::{
bdev::nexus::instances,
core::{
share::{Protocol, Share},
uuid::Uuid,
Expand Down Expand Up @@ -142,7 +143,15 @@ impl Share for Bdev {
impl Bdev {
extern "C" fn hot_remove(ctx: *mut c_void) {
let bdev = Bdev(NonNull::new(ctx as *mut spdk_bdev).unwrap());
debug!("called hot remove cb for nexus {:?}", bdev);

instances().iter_mut().for_each(|n| {
n.children.iter_mut().for_each(|b| {
if b.bdev.as_ref().unwrap().name() == bdev.name() {
info!("hot remove {} from {}", b.name, b.parent);
b.close();
}
})
});
}

/// open a bdev by its name in read_write mode.
Expand Down

0 comments on commit d16762c

Please sign in to comment.