Skip to content

Commit af71743

Browse files
authored
refactor(driver,iour): remove support for kernel < 5.19 (#402)
1 parent 6bf8f88 commit af71743

File tree

12 files changed

+36
-53
lines changed

12 files changed

+36
-53
lines changed

.github/workflows/ci_test.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ jobs:
2626
- os: "ubuntu-22.04"
2727
features: "polling" # fusion
2828
- os: "ubuntu-22.04"
29-
features: "io-uring-sqe128,io-uring-cqe32,io-uring-socket"
30-
- os: "ubuntu-22.04"
31-
features: "io-uring-buf-ring"
32-
- os: "ubuntu-22.04"
33-
features: "polling,io-uring-buf-ring" # fusion & buf-ring
29+
features: "io-uring-sqe128,io-uring-cqe32"
3430
- os: "ubuntu-22.04"
3531
features: "polling,ring"
3632
no_default_features: true

compio-driver/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ polling = ["dep:polling"]
8282

8383
io-uring-sqe128 = []
8484
io-uring-cqe32 = []
85-
io-uring-socket = []
86-
io-uring-buf-ring = []
8785

8886
iocp-global = []
8987
iocp-wait-packet = []

compio-driver/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
freebsd: { target_os = "freebsd" },
1515
solarish: { any(target_os = "illumos", target_os = "solaris") },
1616
aio: { any(freebsd, solarish) },
17-
buf_ring: { all(target_os = "linux", feature = "io-uring", feature = "io-uring-buf-ring") },
17+
io_uring: { all(target_os = "linux", feature = "io-uring") },
1818
fusion: { all(target_os = "linux", feature = "io-uring", feature = "polling") }
1919
}
2020
}

compio-driver/src/buffer_pool/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cfg_if::cfg_if! {
2-
if #[cfg(buf_ring)] {
2+
if #[cfg(io_uring)] {
33
cfg_if::cfg_if! {
44
if #[cfg(fusion)] {
55
mod fusion;

compio-driver/src/driver_type.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl DriverType {
3636
cfg_if::cfg_if! {
3737
if #[cfg(windows)] {
3838
DriverType::IOCP
39-
} else if #[cfg(all(target_os = "linux", feature = "polling", feature = "io-uring"))] {
39+
} else if #[cfg(fusion)] {
4040
use io_uring::opcode::*;
4141

4242
// Add more opcodes here if used
@@ -54,13 +54,6 @@ impl DriverType {
5454
OpenAt::CODE,
5555
Close::CODE,
5656
Shutdown::CODE,
57-
// Linux kernel 5.19
58-
#[cfg(any(
59-
feature = "io-uring-sqe128",
60-
feature = "io-uring-cqe32",
61-
feature = "io-uring-socket",
62-
feature = "io-uring-buf-ring"
63-
))]
6457
Socket::CODE,
6558
];
6659

@@ -75,7 +68,7 @@ impl DriverType {
7568
}
7669
})()
7770
.unwrap_or(DriverType::Poll) // Should we fail here?
78-
} else if #[cfg(all(target_os = "linux", feature = "io-uring"))] {
71+
} else if #[cfg(io_uring)] {
7972
DriverType::IoUring
8073
} else if #[cfg(unix)] {
8174
DriverType::Poll

compio-driver/src/fusion/op.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ op!(<T: IoVectoredBuf, S: AsRawFd> SendToVectored(fd: SharedFd<S>, buffer: T, ad
103103
op!(<S: AsRawFd> FileStat(fd: SharedFd<S>));
104104
op!(<> PathStat(path: CString, follow_symlink: bool));
105105

106-
#[cfg(buf_ring)]
106+
#[cfg(io_uring)]
107107
macro_rules! mop {
108108
(<$($ty:ident: $trait:ident),* $(,)?> $name:ident( $($arg:ident: $arg_t:ty),* $(,)? )) => {
109109
::paste::paste!{
@@ -198,7 +198,7 @@ macro_rules! mop {
198198
};
199199
}
200200

201-
#[cfg(buf_ring)]
201+
#[cfg(io_uring)]
202202
mop!(<S: AsRawFd> ReadManagedAt(fd: SharedFd<S>, offset: u64, pool: &BufferPool, len: usize));
203-
#[cfg(buf_ring)]
203+
#[cfg(io_uring)]
204204
mop!(<S: AsRawFd> RecvManaged(fd: SharedFd<S>, pool: &BufferPool, len: usize));

compio-driver/src/iour/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use io_uring::{
2626
types::{Fd, SubmitArgs, Timespec},
2727
};
2828
pub(crate) use libc::{sockaddr_storage, socklen_t};
29-
#[cfg(buf_ring)]
29+
#[cfg(io_uring)]
3030
use slab::Slab;
3131

3232
use crate::{AsyncifyPool, BufferPool, Entry, Key, ProactorBuilder, syscall};
@@ -84,7 +84,7 @@ pub(crate) struct Driver {
8484
notifier: Notifier,
8585
pool: AsyncifyPool,
8686
pool_completed: Arc<SegQueue<Entry>>,
87-
#[cfg(buf_ring)]
87+
#[cfg(io_uring)]
8888
buffer_group_ids: Slab<()>,
8989
}
9090

@@ -119,7 +119,7 @@ impl Driver {
119119
notifier,
120120
pool: builder.create_or_get_thread_pool(),
121121
pool_completed: Arc::new(SegQueue::new()),
122-
#[cfg(buf_ring)]
122+
#[cfg(io_uring)]
123123
buffer_group_ids: Slab::new(),
124124
})
125125
}
@@ -298,7 +298,7 @@ impl Driver {
298298
self.notifier.handle()
299299
}
300300

301-
#[cfg(buf_ring)]
301+
#[cfg(io_uring)]
302302
pub fn create_buffer_pool(
303303
&mut self,
304304
buffer_len: u16,
@@ -333,7 +333,7 @@ impl Driver {
333333
}
334334
}
335335

336-
#[cfg(not(buf_ring))]
336+
#[cfg(not(io_uring))]
337337
pub fn create_buffer_pool(
338338
&mut self,
339339
buffer_len: u16,
@@ -345,7 +345,7 @@ impl Driver {
345345
/// # Safety
346346
///
347347
/// caller must make sure release the buffer pool with correct driver
348-
#[cfg(buf_ring)]
348+
#[cfg(io_uring)]
349349
pub unsafe fn release_buffer_pool(&mut self, buffer_pool: BufferPool) -> io::Result<()> {
350350
#[cfg(fusion)]
351351
let buffer_pool = buffer_pool.into_io_uring();
@@ -360,7 +360,7 @@ impl Driver {
360360
/// # Safety
361361
///
362362
/// caller must make sure release the buffer pool with correct driver
363-
#[cfg(not(buf_ring))]
363+
#[cfg(not(io_uring))]
364364
pub unsafe fn release_buffer_pool(&mut self, _: BufferPool) -> io::Result<()> {
365365
Ok(())
366366
}

compio-driver/src/iour/op.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,9 @@ impl OpCode for HardLink {
262262

263263
impl OpCode for CreateSocket {
264264
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
265-
if cfg!(feature = "io-uring-socket") {
266-
opcode::Socket::new(self.domain, self.socket_type, self.protocol)
267-
.build()
268-
.into()
269-
} else {
270-
OpEntry::Blocking
271-
}
265+
opcode::Socket::new(self.domain, self.socket_type, self.protocol)
266+
.build()
267+
.into()
272268
}
273269

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

601-
#[cfg(buf_ring)]
597+
#[cfg(io_uring)]
602598
mod buf_ring {
603599
use std::{io, marker::PhantomPinned, os::fd::AsRawFd, pin::Pin, ptr};
604600

@@ -730,10 +726,10 @@ mod buf_ring {
730726
}
731727
}
732728

733-
#[cfg(buf_ring)]
729+
#[cfg(io_uring)]
734730
pub use buf_ring::{ReadManagedAt, RecvManaged};
735731

736-
#[cfg(not(buf_ring))]
732+
#[cfg(not(io_uring))]
737733
mod fallback {
738734
use std::pin::Pin;
739735

compio-driver/src/key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<T: ?Sized> Key<T> {
148148
/// op should be dropped because it is useless.
149149
pub(crate) fn set_result(&mut self, res: io::Result<usize>) -> bool {
150150
let this = unsafe { &mut *self.as_dyn_mut_ptr() };
151-
#[cfg(all(target_os = "linux", feature = "io-uring"))]
151+
#[cfg(io_uring)]
152152
if let Ok(res) = res {
153153
unsafe {
154154
Pin::new_unchecked(&mut this.op).set_result(res);

compio-driver/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ cfg_if::cfg_if! {
4747
if #[cfg(windows)] {
4848
#[path = "iocp/mod.rs"]
4949
mod sys;
50-
} else if #[cfg(all(target_os = "linux", feature = "polling", feature = "io-uring"))] {
50+
} else if #[cfg(fusion)] {
5151
#[path = "fusion/mod.rs"]
5252
mod sys;
53-
} else if #[cfg(all(target_os = "linux", feature = "io-uring"))] {
53+
} else if #[cfg(io_uring)] {
5454
#[path = "iour/mod.rs"]
5555
mod sys;
5656
} else if #[cfg(unix)] {
@@ -372,7 +372,7 @@ impl Entry {
372372
}
373373
}
374374

375-
#[cfg(all(target_os = "linux", feature = "io-uring"))]
375+
#[cfg(io_uring)]
376376
// this method only used by in io-uring driver
377377
pub(crate) fn set_flags(&mut self, flags: u32) {
378378
self.flags = flags;

0 commit comments

Comments
 (0)