Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eventing): host event specific details #1556

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 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,48 @@ 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_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_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
2 changes: 1 addition & 1 deletion utils/dependencies
Loading