Skip to content

Commit

Permalink
Merge #1538
Browse files Browse the repository at this point in the history
1538: fix(subsys): getting back posix socket options r=dsavitskiy a=dsavitskiy

Settings POSIX socket options was accidentally removed. This commit brings it back.

Co-authored-by: Dmitry Savitskiy <[email protected]>
  • Loading branch information
mayastor-bors and dsavitskiy committed Nov 2, 2023
2 parents a7b0f05 + 122fcae commit 49495cc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
5 changes: 5 additions & 0 deletions io-engine/src/subsys/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::{
NexusOpts,
NvmeBdevOpts,
NvmfTgtConfig,
PosixSocketOpts,
},
};

Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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(),
}
}
Expand Down Expand Up @@ -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);
Expand Down
27 changes: 21 additions & 6 deletions io-engine/src/subsys/config/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -525,15 +529,21 @@ impl GetOpts for PosixSocketOpts {
};

let size = std::mem::size_of::<spdk_sock_impl_opts>() 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
}
}

Expand All @@ -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
}
}

Expand Down

0 comments on commit 49495cc

Please sign in to comment.