From 122fcaef81058ab601e8b95908e3051cf65cc89b Mon Sep 17 00:00:00 2001 From: Dmitry Savitskiy Date: Tue, 31 Oct 2023 22:30:40 +0300 Subject: [PATCH] fix(subsys): getting back posix socket options Settings POSIX socket options was accidentally removed. This commit brings it back. Signed-off-by: Dmitry Savitskiy --- io-engine/src/subsys/config/mod.rs | 5 +++++ io-engine/src/subsys/config/opts.rs | 27 +++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/io-engine/src/subsys/config/mod.rs b/io-engine/src/subsys/config/mod.rs index bc3443962..58a8add39 100644 --- a/io-engine/src/subsys/config/mod.rs +++ b/io-engine/src/subsys/config/mod.rs @@ -29,6 +29,7 @@ use crate::{ NexusOpts, NvmeBdevOpts, NvmfTgtConfig, + PosixSocketOpts, }, }; @@ -128,6 +129,8 @@ pub struct Config { pub bdev_opts: BdevOpts, /// nexus specific options pub nexus_opts: NexusOpts, + /// socket specific options + pub socket_opts: PosixSocketOpts, /// iobuf specific options pub iobuf_opts: IoBufOpts, } @@ -191,6 +194,7 @@ impl Config { nvme_bdev_opts: self.nvme_bdev_opts.get(), bdev_opts: self.bdev_opts.get(), nexus_opts: self.nexus_opts.get(), + socket_opts: self.socket_opts.get(), iobuf_opts: self.iobuf_opts.get(), } } @@ -220,6 +224,7 @@ impl Config { info!("Applying Mayastor configuration settings"); assert!(self.nvme_bdev_opts.set()); assert!(self.bdev_opts.set()); + assert!(self.socket_opts.set()); assert!(self.iobuf_opts.set()); debug!("{:#?}", self); diff --git a/io-engine/src/subsys/config/opts.rs b/io-engine/src/subsys/config/opts.rs index 23af1aa37..377293783 100644 --- a/io-engine/src/subsys/config/opts.rs +++ b/io-engine/src/subsys/config/opts.rs @@ -282,8 +282,10 @@ impl GetOpts for NvmeBdevOpts { let opts = Box::new(self.into()); debug!("{:?}", &opts); if unsafe { bdev_nvme_set_opts(Box::into_raw(opts)) } != 0 { + warn!("Failed to apply NVMe Bdev options"); return false; } + info!("NVMe Bdev options successfully applied"); true } } @@ -400,8 +402,10 @@ impl GetOpts for BdevOpts { fn set(&self) -> bool { let opts = Box::new(self.into()); if unsafe { spdk_bdev_set_opts(Box::into_raw(opts)) } != 0 { + warn!("Failed to apply Bdev options"); return false; } + info!("Bdev options successfully applied"); true } } @@ -525,15 +529,21 @@ impl GetOpts for PosixSocketOpts { }; let size = std::mem::size_of::() as u64; - unsafe { - let name = std::ffi::CString::new("posix").unwrap(); - let rc = spdk_sock_impl_set_opts( + let name = std::ffi::CString::new("posix").unwrap(); + + if unsafe { + spdk_sock_impl_set_opts( name.as_ptr(), &opts as *const _ as *mut spdk_sock_impl_opts, size, - ); - rc == 0 + ) + } != 0 + { + warn!("Failed to apply socket options"); + return false; } + info!("Socket options successfully applied"); + true } } @@ -559,7 +569,12 @@ impl GetOpts for IoBufOpts { } fn set(&self) -> bool { - unsafe { spdk_iobuf_set_opts(&self.into()) == 0 } + if unsafe { spdk_iobuf_set_opts(&self.into()) } != 0 { + warn!("Failed to apply I/O buffer options"); + return false; + } + info!("I/O buffer options successfully applied"); + true } }