From ddb4ee6a17c4869eaf43b1d069912df5d159b171 Mon Sep 17 00:00:00 2001 From: Diwakar Sharma Date: Thu, 3 Oct 2024 06:22:37 +0000 Subject: [PATCH] feat: add mayastor nvmf rdma capability flag in features Signed-off-by: Diwakar Sharma --- io-engine/src/core/env.rs | 4 +++- io-engine/src/core/mod.rs | 7 +++++++ io-engine/src/grpc/v1/host.rs | 1 + io-engine/src/subsys/nvmf/target.rs | 19 ++++++++++++++----- io-engine/src/subsys/nvmf/transport.rs | 1 - utils/dependencies | 2 +- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/io-engine/src/core/env.rs b/io-engine/src/core/env.rs index ed4c545f9..82984c8e3 100644 --- a/io-engine/src/core/env.rs +++ b/io-engine/src/core/env.rs @@ -292,11 +292,13 @@ impl MayastorFeatures { let lvm = env::var("ENABLE_LVM").as_deref() == Ok("true"); let snapshot_rebuild = env::var("ENABLE_SNAPSHOT_REBUILD").as_deref() == Ok("true"); - + let rdma_capable_target = + env::var("ENABLE_RDMA").as_deref() == Ok("true"); MayastorFeatures { asymmetric_namespace_access: ana, logical_volume_manager: lvm, snapshot_rebuild, + rdma_capable_target, } } /// Get all the supported and enabled features. diff --git a/io-engine/src/core/mod.rs b/io-engine/src/core/mod.rs index cbb9e3a1a..1233b36f4 100644 --- a/io-engine/src/core/mod.rs +++ b/io-engine/src/core/mod.rs @@ -530,12 +530,19 @@ pub struct MayastorFeatures { pub logical_volume_manager: bool, /// When set to true, support for snapshot rebuild is enabled. pub snapshot_rebuild: bool, + /// When set to true, the io-engine instance supports RDMA transport. + pub rdma_capable_target: bool, } impl MayastorFeatures { /// Check if LVM feature is enabled. pub fn lvm(&self) -> bool { self.logical_volume_manager } + + /// Get nvmf target's rdma feature state. + pub fn rdma_capable_target(&self) -> bool { + self.rdma_capable_target + } } /// Bugfix information to expose to the control-plane. diff --git a/io-engine/src/grpc/v1/host.rs b/io-engine/src/grpc/v1/host.rs index c270dd892..a731c0109 100644 --- a/io-engine/src/grpc/v1/host.rs +++ b/io-engine/src/grpc/v1/host.rs @@ -104,6 +104,7 @@ impl From for host_rpc::MayastorFeatures { asymmetric_namespace_access: f.asymmetric_namespace_access, logical_volume_manager: Some(f.logical_volume_manager), snapshot_rebuild: Some(f.snapshot_rebuild), + rdma_capable_target: Some(f.rdma_capable_target), } } } diff --git a/io-engine/src/subsys/nvmf/target.rs b/io-engine/src/subsys/nvmf/target.rs index 2763460a9..e50151584 100644 --- a/io-engine/src/subsys/nvmf/target.rs +++ b/io-engine/src/subsys/nvmf/target.rs @@ -104,7 +104,10 @@ impl Target { tgt: NonNull::dangling(), poll_group_count: 0, next_state: TargetState::Init, - rdma: MayastorEnvironment::global_or_default().rdma(), + // If mayastor args/env requests this to be true then it'll + // be set to true after ensuring rdma transport is created and + // listener is enabled. + rdma: false, } } @@ -284,16 +287,22 @@ impl Target { trid_replica.trsvcid.as_str(), ); - if self.rdma { + if MayastorEnvironment::global_or_default().rdma() { // listen RDMA also. - let _ = self.listen_rdma().map_err(|e| { - warn!( + let _ = self + .listen_rdma() + .map(|_| { + self.rdma = true; + }) + .map_err(|e| { + warn!( "failed to listen rdma on address. err: {e}:\ The target will however keep running with \ only tcp listener, with performance expectations of tcp" ); - }); + }); } + self.next_state(); Ok(()) } diff --git a/io-engine/src/subsys/nvmf/transport.rs b/io-engine/src/subsys/nvmf/transport.rs index 1f3be04bd..6e1267e74 100644 --- a/io-engine/src/subsys/nvmf/transport.rs +++ b/io-engine/src/subsys/nvmf/transport.rs @@ -77,7 +77,6 @@ pub async fn create_and_add_transports(add_rdma: bool) -> Result<(), Error> { }); if let Err(e) = ret { - // XXX: How to reset Target.rdma = false // todo: add event mechanism for Target and Nvmfsubsystem warn!( "RDMA enablement failed {e}.\ diff --git a/utils/dependencies b/utils/dependencies index ec2e3b4bc..00e39a664 160000 --- a/utils/dependencies +++ b/utils/dependencies @@ -1 +1 @@ -Subproject commit ec2e3b4bc082f237d8b0947d02076933d0704149 +Subproject commit 00e39a6645fdc940792e6c6da2cff60eb9905310