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

+1-5
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

-2
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

+1-1
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

+1-1
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

+2-9
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

+3-3
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

+7-7
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

+6-10
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

+1-1
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

+3-3
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;

compio-driver/src/op.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub use crate::sys::op::{
2020
CreateDir, CreateSocket, FileStat, HardLink, Interest, OpenFile, PathStat, PollOnce,
2121
ReadVectoredAt, Rename, Symlink, Unlink, WriteVectoredAt,
2222
};
23-
#[cfg(buf_ring)]
23+
#[cfg(io_uring)]
2424
pub use crate::sys::op::{ReadManagedAt, RecvManaged};
2525
use crate::{
2626
OwnedFd, SharedFd,
@@ -268,7 +268,7 @@ impl<S> Connect<S> {
268268
}
269269
}
270270

271-
#[cfg(any(not(buf_ring), fusion))]
271+
#[cfg(any(not(io_uring), fusion))]
272272
pub(crate) mod managed {
273273
use std::io;
274274

@@ -290,7 +290,7 @@ pub(crate) mod managed {
290290
pool: &BufferPool,
291291
len: usize,
292292
) -> io::Result<Self> {
293-
#[cfg(all(buf_ring, fusion))]
293+
#[cfg(fusion)]
294294
let pool = pool.as_poll();
295295
Ok(Self {
296296
op: ReadAt::new(fd, offset, pool.get_buffer(len)?),
@@ -309,12 +309,12 @@ pub(crate) mod managed {
309309
_: u32,
310310
) -> io::Result<BorrowedBuffer> {
311311
let result = result?;
312-
#[cfg(all(buf_ring, fusion))]
312+
#[cfg(fusion)]
313313
let buffer_pool = buffer_pool.as_poll();
314314
let slice = self.op.into_inner();
315315
// Safety: result is valid
316316
let res = unsafe { buffer_pool.create_proxy(slice, result) };
317-
#[cfg(all(buf_ring, fusion))]
317+
#[cfg(fusion)]
318318
let res = BorrowedBuffer::new_poll(res);
319319
Ok(res)
320320
}
@@ -328,7 +328,7 @@ pub(crate) mod managed {
328328
impl<S> RecvManaged<S> {
329329
/// Create [`RecvManaged`].
330330
pub fn new(fd: SharedFd<S>, pool: &BufferPool, len: usize) -> io::Result<Self> {
331-
#[cfg(all(buf_ring, fusion))]
331+
#[cfg(fusion)]
332332
let pool = pool.as_poll();
333333
Ok(Self {
334334
op: Recv::new(fd, pool.get_buffer(len)?),
@@ -347,17 +347,17 @@ pub(crate) mod managed {
347347
_: u32,
348348
) -> io::Result<Self::Buffer<'_>> {
349349
let result = result?;
350-
#[cfg(all(buf_ring, fusion))]
350+
#[cfg(fusion)]
351351
let buffer_pool = buffer_pool.as_poll();
352352
let slice = self.op.into_inner();
353353
// Safety: result is valid
354354
let res = unsafe { buffer_pool.create_proxy(slice, result) };
355-
#[cfg(all(buf_ring, fusion))]
355+
#[cfg(fusion)]
356356
let res = BorrowedBuffer::new_poll(res);
357357
Ok(res)
358358
}
359359
}
360360
}
361361

362-
#[cfg(not(buf_ring))]
362+
#[cfg(not(io_uring))]
363363
pub use managed::*;

compio-driver/src/poll/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,14 @@ impl Driver {
447447
buffer_len: u16,
448448
buffer_size: usize,
449449
) -> io::Result<BufferPool> {
450-
#[cfg(all(buf_ring, fusion))]
450+
#[cfg(fusion)]
451451
{
452452
Ok(BufferPool::new_poll(crate::FallbackBufferPool::new(
453453
buffer_len,
454454
buffer_size,
455455
)))
456456
}
457-
#[cfg(not(all(buf_ring, fusion)))]
457+
#[cfg(not(fusion))]
458458
{
459459
Ok(BufferPool::new(buffer_len, buffer_size))
460460
}

0 commit comments

Comments
 (0)