Skip to content

Commit

Permalink
feat(eventing): host event specific details
Browse files Browse the repository at this point in the history
Signed-off-by: Vandana Varakantham <[email protected]>
  • Loading branch information
datacore-vvarakantham committed Dec 7, 2023
1 parent 033dc9d commit 888c3c6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
35 changes: 33 additions & 2 deletions io-engine/src/eventing/host_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,49 @@ use events_api::event::{
};

use crate::{
core::MayastorEnvironment,
bdev::Nexus,
core::{LogicalVolume, MayastorEnvironment},
eventing::{EventMetaGen, EventWithMeta},
lvs::Lvol,
subsys::NvmfSubsystem,
};
use spdk_rs::NvmfController;

/// A trait definition to include target details in host events meta data
pub(crate) trait HostTargetMeta {
/// Add target detaails to host event meta
fn host_target_meta(&self, meta: EventMeta) -> EventMeta;
}

impl<'n> HostTargetMeta for Nexus<'n> {
fn host_target_meta(&self, mut meta: EventMeta) -> EventMeta {
if let Some(source) = meta.source {
let event_source =
source.with_host_target_data("nexus", &self.uuid().to_string());
meta.source = Some(event_source);
}
meta
}
}

impl HostTargetMeta for Lvol {
fn host_target_meta(&self, mut meta: EventMeta) -> EventMeta {
if let Some(source) = meta.source {
let event_source =
source.with_host_target_data("replica", &self.uuid());
meta.source = Some(event_source);
}
meta
}
}

impl EventMetaGen for NvmfSubsystem {
fn meta(&self) -> EventMeta {
let nqn = self.get_nqn();
let event_source = EventSource::new(
MayastorEnvironment::global_or_default().node_name,
)
.with_subsystem_data(&self.get_nqn());
.with_subsystem_data(&nqn);

EventMeta::from_source(event_source)
}
Expand Down
2 changes: 1 addition & 1 deletion io-engine/src/eventing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod host_events;
pub(crate) mod host_events;
mod nexus_child_events;
pub(crate) mod nexus_events;
mod pool_events;
Expand Down
15 changes: 10 additions & 5 deletions io-engine/src/subsys/nvmf/subsystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use crate::{
bdev::{nexus::NEXUS_MODULE_NAME, nvmx::NVME_CONTROLLERS, Nexus},
constants::{NVME_CONTROLLER_MODEL_ID, NVME_NQN_PREFIX},
core::{Bdev, Reactors, UntypedBdev},
eventing::{EventMetaGen, EventWithMeta},
eventing::{host_events::HostTargetMeta, EventMetaGen, EventWithMeta},
ffihelper::{cb_arg, done_cb, AsStr, FfiResult, IntoCString},
lvs::Lvol,
subsys::{
Expand All @@ -73,7 +73,6 @@ use crate::{
Config,
},
};

use events_api::event::EventAction;

/// TODO
Expand Down Expand Up @@ -256,9 +255,15 @@ impl NvmfSubsystem {
);
}

let event_meta = match nqn_tgt {
NqnTarget::Nexus(n) => n.host_target_meta(s.meta()),
NqnTarget::Replica(ref r) => r.host_target_meta(s.meta()),
NqnTarget::None => s.meta(),
};

match event {
NvmfSubsystemEvent::HostConnect(c) => {
c.event(EventAction::NvmeConnect, s.meta()).generate();
c.event(EventAction::NvmeConnect, event_meta).generate();

match nqn_tgt {
NqnTarget::Nexus(n) => s.host_connect_nexus(c, n),
Expand All @@ -267,7 +272,7 @@ impl NvmfSubsystem {
}
}
NvmfSubsystemEvent::HostDisconnect(c) => {
c.event(EventAction::NvmeDisconnect, s.meta()).generate();
c.event(EventAction::NvmeDisconnect, event_meta).generate();

match nqn_tgt {
NqnTarget::Nexus(n) => s.host_disconnect_nexus(c, n),
Expand All @@ -276,7 +281,7 @@ impl NvmfSubsystem {
}
}
NvmfSubsystemEvent::HostKeepAliveTimeout(c) => {
c.event(EventAction::NvmeKeepAliveTimeout, s.meta())
c.event(EventAction::NvmeKeepAliveTimeout, event_meta)
.generate();

match nqn_tgt {
Expand Down

0 comments on commit 888c3c6

Please sign in to comment.