Skip to content

Commit

Permalink
bdev: ensure iSCSI bdevs are unshared
Browse files Browse the repository at this point in the history
  • Loading branch information
gila committed Aug 11, 2020
1 parent 0a3b64e commit 2f5daf8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
7 changes: 1 addition & 6 deletions mayastor/src/core/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,7 @@ async fn do_shutdown(arg: *mut c_void) {
}

nats::message_bus_stop();

let cfg = Config::get();
if cfg.nexus_opts.iscsi_enable {
iscsi::fini();
debug!("iSCSI target down");
};
iscsi::fini();

unsafe {
spdk_rpc_finish();
Expand Down
25 changes: 21 additions & 4 deletions mayastor/src/target/iscsi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use spdk_sys::{
};

use crate::{
core::Bdev,
core::{Bdev, Protocol, Reactor, Share},
ffihelper::{cb_arg, done_errno_cb, ErrnoResult},
subsys::Config,
target::Side,
Expand Down Expand Up @@ -165,9 +165,26 @@ fn destroy_iscsi_groups() {
}

pub fn fini() {
// dont destroy things as this is handled by the subsystem
// to fix any error messages we should implement the hotremove
// callbacks
// as the nvmf target is fully implemented as its own submodule, we also
// fully handle the setup and tear down. For iSCSI however, we use the
// native subsystem as such, we must undo what we did prior to shutting
// down.

Reactor::block_on(async {
if let Some(bdevs) = Bdev::bdev_first() {
for b in bdevs {
if let Some(Protocol::Iscsi) = b.shared() {
if let Err(e) = b.unshare().await {
error!(
"{} shared but failed to unshare {}",
b.name(),
e.to_string()
)
}
}
}
}
});
}

fn share_as_iscsi_target(
Expand Down

0 comments on commit 2f5daf8

Please sign in to comment.