diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 9769597f8..dbed14cc7 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -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 diff --git a/compio-driver/Cargo.toml b/compio-driver/Cargo.toml index 6d54198d8..538f35d61 100644 --- a/compio-driver/Cargo.toml +++ b/compio-driver/Cargo.toml @@ -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 = [] diff --git a/compio-driver/build.rs b/compio-driver/build.rs index 13979cca0..b7b16bb93 100644 --- a/compio-driver/build.rs +++ b/compio-driver/build.rs @@ -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") } } } diff --git a/compio-driver/src/buffer_pool/mod.rs b/compio-driver/src/buffer_pool/mod.rs index 345a09841..32ced4f1f 100644 --- a/compio-driver/src/buffer_pool/mod.rs +++ b/compio-driver/src/buffer_pool/mod.rs @@ -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; diff --git a/compio-driver/src/driver_type.rs b/compio-driver/src/driver_type.rs index a93ea0fa0..e0d8839f5 100644 --- a/compio-driver/src/driver_type.rs +++ b/compio-driver/src/driver_type.rs @@ -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 @@ -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, ]; @@ -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 diff --git a/compio-driver/src/fusion/op.rs b/compio-driver/src/fusion/op.rs index fcdf665d3..c01b8e4fc 100644 --- a/compio-driver/src/fusion/op.rs +++ b/compio-driver/src/fusion/op.rs @@ -103,7 +103,7 @@ op!( SendToVectored(fd: SharedFd, buffer: T, ad op!( FileStat(fd: SharedFd)); 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!{ @@ -198,7 +198,7 @@ macro_rules! mop { }; } -#[cfg(buf_ring)] +#[cfg(io_uring)] mop!( ReadManagedAt(fd: SharedFd, offset: u64, pool: &BufferPool, len: usize)); -#[cfg(buf_ring)] +#[cfg(io_uring)] mop!( RecvManaged(fd: SharedFd, pool: &BufferPool, len: usize)); diff --git a/compio-driver/src/iour/mod.rs b/compio-driver/src/iour/mod.rs index 392a7c856..387cab80d 100644 --- a/compio-driver/src/iour/mod.rs +++ b/compio-driver/src/iour/mod.rs @@ -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}; @@ -84,7 +84,7 @@ pub(crate) struct Driver { notifier: Notifier, pool: AsyncifyPool, pool_completed: Arc>, - #[cfg(buf_ring)] + #[cfg(io_uring)] buffer_group_ids: Slab<()>, } @@ -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(), }) } @@ -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, @@ -333,7 +333,7 @@ impl Driver { } } - #[cfg(not(buf_ring))] + #[cfg(not(io_uring))] pub fn create_buffer_pool( &mut self, buffer_len: u16, @@ -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(); @@ -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(()) } diff --git a/compio-driver/src/iour/op.rs b/compio-driver/src/iour/op.rs index 86abc7e8d..8926cc292 100644 --- a/compio-driver/src/iour/op.rs +++ b/compio-driver/src/iour/op.rs @@ -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 { @@ -598,7 +594,7 @@ impl OpCode for PollOnce { } } -#[cfg(buf_ring)] +#[cfg(io_uring)] mod buf_ring { use std::{io, marker::PhantomPinned, os::fd::AsRawFd, pin::Pin, ptr}; @@ -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; diff --git a/compio-driver/src/key.rs b/compio-driver/src/key.rs index 58042ede3..88f3c85b7 100644 --- a/compio-driver/src/key.rs +++ b/compio-driver/src/key.rs @@ -148,7 +148,7 @@ impl Key { /// op should be dropped because it is useless. pub(crate) fn set_result(&mut self, res: io::Result) -> 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); diff --git a/compio-driver/src/lib.rs b/compio-driver/src/lib.rs index 4648abd7c..18cc2b065 100644 --- a/compio-driver/src/lib.rs +++ b/compio-driver/src/lib.rs @@ -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)] { @@ -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; diff --git a/compio-driver/src/op.rs b/compio-driver/src/op.rs index 83de834f6..a7c76b2b5 100644 --- a/compio-driver/src/op.rs +++ b/compio-driver/src/op.rs @@ -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, @@ -268,7 +268,7 @@ impl Connect { } } -#[cfg(any(not(buf_ring), fusion))] +#[cfg(any(not(io_uring), fusion))] pub(crate) mod managed { use std::io; @@ -290,7 +290,7 @@ pub(crate) mod managed { pool: &BufferPool, len: usize, ) -> io::Result { - #[cfg(all(buf_ring, fusion))] + #[cfg(fusion)] let pool = pool.as_poll(); Ok(Self { op: ReadAt::new(fd, offset, pool.get_buffer(len)?), @@ -309,12 +309,12 @@ pub(crate) mod managed { _: u32, ) -> io::Result { 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) } @@ -328,7 +328,7 @@ pub(crate) mod managed { impl RecvManaged { /// Create [`RecvManaged`]. pub fn new(fd: SharedFd, pool: &BufferPool, len: usize) -> io::Result { - #[cfg(all(buf_ring, fusion))] + #[cfg(fusion)] let pool = pool.as_poll(); Ok(Self { op: Recv::new(fd, pool.get_buffer(len)?), @@ -347,17 +347,17 @@ pub(crate) mod managed { _: u32, ) -> io::Result> { 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::*; diff --git a/compio-driver/src/poll/mod.rs b/compio-driver/src/poll/mod.rs index aee5fa974..066a26575 100644 --- a/compio-driver/src/poll/mod.rs +++ b/compio-driver/src/poll/mod.rs @@ -447,14 +447,14 @@ impl Driver { buffer_len: u16, buffer_size: usize, ) -> io::Result { - #[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)) }