From 90000aa5172d9915702303ae8661dffb41aac93a Mon Sep 17 00:00:00 2001 From: Vandana Varakantham Date: Thu, 7 Dec 2023 07:45:57 +0000 Subject: [PATCH] feat(eventing): host event specific details Signed-off-by: Vandana Varakantham --- io-engine/src/eventing/host_events.rs | 34 ++++++++++++++++++++++++-- io-engine/src/eventing/mod.rs | 2 +- io-engine/src/subsys/nvmf/subsystem.rs | 15 ++++++++---- utils/dependencies | 2 +- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/io-engine/src/eventing/host_events.rs b/io-engine/src/eventing/host_events.rs index e0b548b78..76d4b37ed 100644 --- a/io-engine/src/eventing/host_events.rs +++ b/io-engine/src/eventing/host_events.rs @@ -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) } diff --git a/io-engine/src/eventing/mod.rs b/io-engine/src/eventing/mod.rs index 3c823a5dc..de8cd5ab2 100644 --- a/io-engine/src/eventing/mod.rs +++ b/io-engine/src/eventing/mod.rs @@ -1,4 +1,4 @@ -mod host_events; +pub(crate) mod host_events; mod nexus_child_events; pub(crate) mod nexus_events; mod pool_events; diff --git a/io-engine/src/subsys/nvmf/subsystem.rs b/io-engine/src/subsys/nvmf/subsystem.rs index e716dfd4c..e913580b2 100644 --- a/io-engine/src/subsys/nvmf/subsystem.rs +++ b/io-engine/src/subsys/nvmf/subsystem.rs @@ -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::{ @@ -73,7 +73,6 @@ use crate::{ Config, }, }; - use events_api::event::EventAction; /// TODO @@ -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), @@ -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), @@ -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 { diff --git a/utils/dependencies b/utils/dependencies index b591fb073..2c0e0c1e6 160000 --- a/utils/dependencies +++ b/utils/dependencies @@ -1 +1 @@ -Subproject commit b591fb07351f3600a0189c3ee817858d0e11ae8f +Subproject commit 2c0e0c1e65381949ab60cb5f7329305105136822