From d16762ce008b7e51ea682a346a1749c738ea9eff Mon Sep 17 00:00:00 2001 From: Jeffry Molanus Date: Tue, 11 Aug 2020 16:59:10 +0200 Subject: [PATCH] CAS-370: hot remove child from parent During shutdown, when a child is removed that is still open the hot remove callback should release it. --- mayastor/src/core/bdev.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mayastor/src/core/bdev.rs b/mayastor/src/core/bdev.rs index 74875b794..2d4d1655b 100644 --- a/mayastor/src/core/bdev.rs +++ b/mayastor/src/core/bdev.rs @@ -29,6 +29,7 @@ use spdk_sys::{ }; use crate::{ + bdev::nexus::instances, core::{ share::{Protocol, Share}, uuid::Uuid, @@ -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.