Skip to content
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
6 changes: 1 addition & 5 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ jobs:
- os: "ubuntu-22.04"
features: "polling" # fusion
- os: "ubuntu-22.04"
features: "io-uring-sqe128,io-uring-cqe32,io-uring-socket"
- os: "ubuntu-22.04"
features: "io-uring-buf-ring"
- os: "ubuntu-22.04"
features: "polling,io-uring-buf-ring" # fusion & buf-ring
features: "io-uring-sqe128,io-uring-cqe32"
- os: "ubuntu-22.04"
features: "polling,ring"
no_default_features: true
Expand Down
2 changes: 0 additions & 2 deletions compio-driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ polling = ["dep:polling"]

io-uring-sqe128 = []
io-uring-cqe32 = []
io-uring-socket = []
io-uring-buf-ring = []

iocp-global = []
iocp-wait-packet = []
Expand Down
2 changes: 1 addition & 1 deletion compio-driver/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() {
freebsd: { target_os = "freebsd" },
solarish: { any(target_os = "illumos", target_os = "solaris") },
aio: { any(freebsd, solarish) },
buf_ring: { all(target_os = "linux", feature = "io-uring", feature = "io-uring-buf-ring") },
io_uring: { all(target_os = "linux", feature = "io-uring") },
fusion: { all(target_os = "linux", feature = "io-uring", feature = "polling") }
}
}
2 changes: 1 addition & 1 deletion compio-driver/src/buffer_pool/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cfg_if::cfg_if! {
if #[cfg(buf_ring)] {
if #[cfg(io_uring)] {
cfg_if::cfg_if! {
if #[cfg(fusion)] {
mod fusion;
Expand Down
11 changes: 2 additions & 9 deletions compio-driver/src/driver_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl DriverType {
cfg_if::cfg_if! {
if #[cfg(windows)] {
DriverType::IOCP
} else if #[cfg(all(target_os = "linux", feature = "polling", feature = "io-uring"))] {
} else if #[cfg(fusion)] {
use io_uring::opcode::*;

// Add more opcodes here if used
Expand All @@ -54,13 +54,6 @@ impl DriverType {
OpenAt::CODE,
Close::CODE,
Shutdown::CODE,
// Linux kernel 5.19
#[cfg(any(
feature = "io-uring-sqe128",
feature = "io-uring-cqe32",
feature = "io-uring-socket",
feature = "io-uring-buf-ring"
))]
Socket::CODE,
];

Expand All @@ -75,7 +68,7 @@ impl DriverType {
}
})()
.unwrap_or(DriverType::Poll) // Should we fail here?
} else if #[cfg(all(target_os = "linux", feature = "io-uring"))] {
} else if #[cfg(io_uring)] {
DriverType::IoUring
} else if #[cfg(unix)] {
DriverType::Poll
Expand Down
6 changes: 3 additions & 3 deletions compio-driver/src/fusion/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ op!(<T: IoVectoredBuf, S: AsRawFd> SendToVectored(fd: SharedFd<S>, buffer: T, ad
op!(<S: AsRawFd> FileStat(fd: SharedFd<S>));
op!(<> PathStat(path: CString, follow_symlink: bool));

#[cfg(buf_ring)]
#[cfg(io_uring)]
macro_rules! mop {
(<$($ty:ident: $trait:ident),* $(,)?> $name:ident( $($arg:ident: $arg_t:ty),* $(,)? )) => {
::paste::paste!{
Expand Down Expand Up @@ -198,7 +198,7 @@ macro_rules! mop {
};
}

#[cfg(buf_ring)]
#[cfg(io_uring)]
mop!(<S: AsRawFd> ReadManagedAt(fd: SharedFd<S>, offset: u64, pool: &BufferPool, len: usize));
#[cfg(buf_ring)]
#[cfg(io_uring)]
mop!(<S: AsRawFd> RecvManaged(fd: SharedFd<S>, pool: &BufferPool, len: usize));
14 changes: 7 additions & 7 deletions compio-driver/src/iour/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use io_uring::{
types::{Fd, SubmitArgs, Timespec},
};
pub(crate) use libc::{sockaddr_storage, socklen_t};
#[cfg(buf_ring)]
#[cfg(io_uring)]
use slab::Slab;

use crate::{AsyncifyPool, BufferPool, Entry, Key, ProactorBuilder, syscall};
Expand Down Expand Up @@ -84,7 +84,7 @@ pub(crate) struct Driver {
notifier: Notifier,
pool: AsyncifyPool,
pool_completed: Arc<SegQueue<Entry>>,
#[cfg(buf_ring)]
#[cfg(io_uring)]
buffer_group_ids: Slab<()>,
}

Expand Down Expand Up @@ -119,7 +119,7 @@ impl Driver {
notifier,
pool: builder.create_or_get_thread_pool(),
pool_completed: Arc::new(SegQueue::new()),
#[cfg(buf_ring)]
#[cfg(io_uring)]
buffer_group_ids: Slab::new(),
})
}
Expand Down Expand Up @@ -298,7 +298,7 @@ impl Driver {
self.notifier.handle()
}

#[cfg(buf_ring)]
#[cfg(io_uring)]
pub fn create_buffer_pool(
&mut self,
buffer_len: u16,
Expand Down Expand Up @@ -333,7 +333,7 @@ impl Driver {
}
}

#[cfg(not(buf_ring))]
#[cfg(not(io_uring))]
pub fn create_buffer_pool(
&mut self,
buffer_len: u16,
Expand All @@ -345,7 +345,7 @@ impl Driver {
/// # Safety
///
/// caller must make sure release the buffer pool with correct driver
#[cfg(buf_ring)]
#[cfg(io_uring)]
pub unsafe fn release_buffer_pool(&mut self, buffer_pool: BufferPool) -> io::Result<()> {
#[cfg(fusion)]
let buffer_pool = buffer_pool.into_io_uring();
Expand All @@ -360,7 +360,7 @@ impl Driver {
/// # Safety
///
/// caller must make sure release the buffer pool with correct driver
#[cfg(not(buf_ring))]
#[cfg(not(io_uring))]
pub unsafe fn release_buffer_pool(&mut self, _: BufferPool) -> io::Result<()> {
Ok(())
}
Expand Down
16 changes: 6 additions & 10 deletions compio-driver/src/iour/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,9 @@ impl OpCode for HardLink {

impl OpCode for CreateSocket {
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
if cfg!(feature = "io-uring-socket") {
opcode::Socket::new(self.domain, self.socket_type, self.protocol)
.build()
.into()
} else {
OpEntry::Blocking
}
opcode::Socket::new(self.domain, self.socket_type, self.protocol)
.build()
.into()
}

fn call_blocking(self: Pin<&mut Self>) -> io::Result<usize> {
Expand Down Expand Up @@ -598,7 +594,7 @@ impl<S: AsRawFd> OpCode for PollOnce<S> {
}
}

#[cfg(buf_ring)]
#[cfg(io_uring)]
mod buf_ring {
use std::{io, marker::PhantomPinned, os::fd::AsRawFd, pin::Pin, ptr};

Expand Down Expand Up @@ -730,10 +726,10 @@ mod buf_ring {
}
}

#[cfg(buf_ring)]
#[cfg(io_uring)]
pub use buf_ring::{ReadManagedAt, RecvManaged};

#[cfg(not(buf_ring))]
#[cfg(not(io_uring))]
mod fallback {
use std::pin::Pin;

Expand Down
2 changes: 1 addition & 1 deletion compio-driver/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl<T: ?Sized> Key<T> {
/// op should be dropped because it is useless.
pub(crate) fn set_result(&mut self, res: io::Result<usize>) -> bool {
let this = unsafe { &mut *self.as_dyn_mut_ptr() };
#[cfg(all(target_os = "linux", feature = "io-uring"))]
#[cfg(io_uring)]
if let Ok(res) = res {
unsafe {
Pin::new_unchecked(&mut this.op).set_result(res);
Expand Down
6 changes: 3 additions & 3 deletions compio-driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ cfg_if::cfg_if! {
if #[cfg(windows)] {
#[path = "iocp/mod.rs"]
mod sys;
} else if #[cfg(all(target_os = "linux", feature = "polling", feature = "io-uring"))] {
} else if #[cfg(fusion)] {
#[path = "fusion/mod.rs"]
mod sys;
} else if #[cfg(all(target_os = "linux", feature = "io-uring"))] {
} else if #[cfg(io_uring)] {
#[path = "iour/mod.rs"]
mod sys;
} else if #[cfg(unix)] {
Expand Down Expand Up @@ -372,7 +372,7 @@ impl Entry {
}
}

#[cfg(all(target_os = "linux", feature = "io-uring"))]
#[cfg(io_uring)]
// this method only used by in io-uring driver
pub(crate) fn set_flags(&mut self, flags: u32) {
self.flags = flags;
Expand Down
18 changes: 9 additions & 9 deletions compio-driver/src/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub use crate::sys::op::{
CreateDir, CreateSocket, FileStat, HardLink, Interest, OpenFile, PathStat, PollOnce,
ReadVectoredAt, Rename, Symlink, Unlink, WriteVectoredAt,
};
#[cfg(buf_ring)]
#[cfg(io_uring)]
pub use crate::sys::op::{ReadManagedAt, RecvManaged};
use crate::{
OwnedFd, SharedFd,
Expand Down Expand Up @@ -268,7 +268,7 @@ impl<S> Connect<S> {
}
}

#[cfg(any(not(buf_ring), fusion))]
#[cfg(any(not(io_uring), fusion))]
pub(crate) mod managed {
use std::io;

Expand All @@ -290,7 +290,7 @@ pub(crate) mod managed {
pool: &BufferPool,
len: usize,
) -> io::Result<Self> {
#[cfg(all(buf_ring, fusion))]
#[cfg(fusion)]
let pool = pool.as_poll();
Ok(Self {
op: ReadAt::new(fd, offset, pool.get_buffer(len)?),
Expand All @@ -309,12 +309,12 @@ pub(crate) mod managed {
_: u32,
) -> io::Result<BorrowedBuffer> {
let result = result?;
#[cfg(all(buf_ring, fusion))]
#[cfg(fusion)]
let buffer_pool = buffer_pool.as_poll();
let slice = self.op.into_inner();
// Safety: result is valid
let res = unsafe { buffer_pool.create_proxy(slice, result) };
#[cfg(all(buf_ring, fusion))]
#[cfg(fusion)]
let res = BorrowedBuffer::new_poll(res);
Ok(res)
}
Expand All @@ -328,7 +328,7 @@ pub(crate) mod managed {
impl<S> RecvManaged<S> {
/// Create [`RecvManaged`].
pub fn new(fd: SharedFd<S>, pool: &BufferPool, len: usize) -> io::Result<Self> {
#[cfg(all(buf_ring, fusion))]
#[cfg(fusion)]
let pool = pool.as_poll();
Ok(Self {
op: Recv::new(fd, pool.get_buffer(len)?),
Expand All @@ -347,17 +347,17 @@ pub(crate) mod managed {
_: u32,
) -> io::Result<Self::Buffer<'_>> {
let result = result?;
#[cfg(all(buf_ring, fusion))]
#[cfg(fusion)]
let buffer_pool = buffer_pool.as_poll();
let slice = self.op.into_inner();
// Safety: result is valid
let res = unsafe { buffer_pool.create_proxy(slice, result) };
#[cfg(all(buf_ring, fusion))]
#[cfg(fusion)]
let res = BorrowedBuffer::new_poll(res);
Ok(res)
}
}
}

#[cfg(not(buf_ring))]
#[cfg(not(io_uring))]
pub use managed::*;
4 changes: 2 additions & 2 deletions compio-driver/src/poll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,14 @@ impl Driver {
buffer_len: u16,
buffer_size: usize,
) -> io::Result<BufferPool> {
#[cfg(all(buf_ring, fusion))]
#[cfg(fusion)]
{
Ok(BufferPool::new_poll(crate::FallbackBufferPool::new(
buffer_len,
buffer_size,
)))
}
#[cfg(not(all(buf_ring, fusion)))]
#[cfg(not(fusion))]
{
Ok(BufferPool::new(buffer_len, buffer_size))
}
Expand Down
Loading