Skip to content

Commit

Permalink
Make the "unstable" feature have no effect (#162)
Browse files Browse the repository at this point in the history
Dependent crates that rely on "unstable" functionality need to restrict
the set of supported io-uring versions to a predetermined closed range
(e.g. >=0.5.6, <=0.5.8), just in case a future release breaks
compatibility. This makes io-uring version incompatibilities in a
dependency graph more likely, and can complicate packaging for
distributions (see [1] for an example).

Let's rely on the fact that we're pre-1.0 to safely try out new APIs
instead. Still, keep an unused "unstable" feature on the io-uring crate
to avoid breaking compatibility.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=2124697#c76

Signed-off-by: Alberto Faria <afaria@redhat.com>

Signed-off-by: Alberto Faria <afaria@redhat.com>
  • Loading branch information
albertofaria committed Dec 17, 2022
1 parent e085834 commit 8346194
Show file tree
Hide file tree
Showing 19 changed files with 3 additions and 147 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
command: test
use-cross: true
args: --features unstable --target ${{ matrix.target }}
args: --target ${{ matrix.target }}
- uses: actions-rs/cargo@v1
with:
command: run
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --target ${{ matrix.target }} --features unstable
args: --target ${{ matrix.target }}


fmt:
Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,3 @@ bindgen = { version = "0.61", optional = true }
anyhow = "1"
socket2 = "0.4"
slab = "0.4"

[package.metadata.docs.rs]
features = [ "unstable" ]
4 changes: 0 additions & 4 deletions io-uring-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = [ "unstable" ]
unstable = [ "io-uring/unstable" ]

[dependencies]
io-uring = { path = ".." }
iou = "0.3"
Expand Down
10 changes: 0 additions & 10 deletions io-uring-bench/src/iai_new_nop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ fn bench_io_uring() {
}
}

#[cfg(feature = "unstable")]
fn bench_io_uring_batch() {
use io_uring::{opcode, IoUring};
use std::mem;
Expand Down Expand Up @@ -188,19 +187,10 @@ fn bench_uring_sys_batch() {
}
}

#[cfg(feature = "unstable")]
iai::main!(
bench_io_uring,
bench_io_uring_batch,
bench_iou,
bench_uring_sys,
bench_uring_sys_batch
);

#[cfg(not(feature = "unstable"))]
iai::main!(
bench_io_uring,
bench_iou,
bench_uring_sys,
bench_uring_sys_batch
);
2 changes: 0 additions & 2 deletions io-uring-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ once_cell = "1"
socket2 = "0.4"

[features]
default = [ "unstable" ]
unstable = [ "io-uring/unstable" ]
direct-syscall = [ "io-uring/direct-syscall" ]
ci = []
9 changes: 1 addition & 8 deletions io-uring-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() -> anyhow::Result<()> {

test::<squeue::Entry, cqueue::Entry>(IoUring::new(entries)?)?;

#[cfg(all(feature = "unstable", not(feature = "ci")))]
#[cfg(not(feature = "ci"))]
{
match IoUring::<squeue::Entry128, cqueue::Entry>::generic_new(entries) {
Ok(r) => test(r)?,
Expand Down Expand Up @@ -70,13 +70,10 @@ fn test<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
tests::queue::test_queue_split(&mut ring, &test)?;
tests::queue::test_debug_print(&mut ring, &test)?;

#[cfg(feature = "unstable")]
tests::queue::test_batch(&mut ring, &test)?;

// register
#[cfg(feature = "unstable")]
tests::register::test_register_files_sparse(&mut ring, &test)?;
#[cfg(feature = "unstable")]
tests::register_buf_ring::test_register_buf_ring(&mut ring, &test)?;

// fs
Expand All @@ -93,7 +90,6 @@ fn test<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
tests::fs::test_file_direct_write_read(&mut ring, &test)?;
#[cfg(not(feature = "ci"))]
tests::fs::test_statx(&mut ring, &test)?;
#[cfg(feature = "unstable")]
tests::fs::test_file_splice(&mut ring, &test)?;

// timeout
Expand All @@ -102,19 +98,16 @@ fn test<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
tests::timeout::test_timeout_remove(&mut ring, &test)?;
tests::timeout::test_timeout_cancel(&mut ring, &test)?;
tests::timeout::test_timeout_abs(&mut ring, &test)?;
#[cfg(feature = "unstable")]
tests::timeout::test_timeout_submit_args(&mut ring, &test)?;

// net
tests::net::test_tcp_write_read(&mut ring, &test)?;
tests::net::test_tcp_writev_readv(&mut ring, &test)?;
tests::net::test_tcp_send_recv(&mut ring, &test)?;
#[cfg(feature = "unstable")]
tests::net::test_tcp_zero_copy_send_recv(&mut ring, &test)?;
tests::net::test_tcp_sendmsg_recvmsg(&mut ring, &test)?;
tests::net::test_tcp_accept(&mut ring, &test)?;
tests::net::test_tcp_connect(&mut ring, &test)?;
#[cfg(feature = "unstable")]
tests::net::test_tcp_buffer_select(&mut ring, &test)?;

// queue
Expand Down
1 change: 0 additions & 1 deletion io-uring-test/src/tests/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ pub fn test_file_direct_write_read<S: squeue::EntryMarker, C: cqueue::EntryMarke
Ok(())
}

#[cfg(feature = "unstable")]
pub fn test_file_splice<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
ring: &mut IoUring<S, C>,
test: &Test,
Expand Down
1 change: 0 additions & 1 deletion io-uring-test/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ pub mod net;
pub mod poll;
pub mod queue;
pub mod register;
#[cfg(feature = "unstable")]
pub mod register_buf_ring;
pub mod timeout;
2 changes: 0 additions & 2 deletions io-uring-test/src/tests/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ pub fn test_tcp_send_recv<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
Ok(())
}

#[cfg(feature = "unstable")]
pub fn test_tcp_zero_copy_send_recv<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
ring: &mut IoUring<S, C>,
test: &Test,
Expand Down Expand Up @@ -351,7 +350,6 @@ pub fn test_tcp_connect<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
Ok(())
}

#[cfg(feature = "unstable")]
pub fn test_tcp_buffer_select<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
ring: &mut IoUring<S, C>,
test: &Test,
Expand Down
1 change: 0 additions & 1 deletion io-uring-test/src/tests/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub fn test_nop<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
Ok(())
}

#[cfg(feature = "unstable")]
pub fn test_batch<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
ring: &mut IoUring<S, C>,
test: &Test,
Expand Down
3 changes: 0 additions & 3 deletions io-uring-test/src/tests/register.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#[cfg(feature = "unstable")]
use crate::Test;
#[cfg(feature = "unstable")]
use io_uring::{cqueue, opcode, squeue, IoUring};

#[cfg(feature = "unstable")]
pub fn test_register_files_sparse<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
ring: &mut IoUring<S, C>,
test: &Test,
Expand Down
1 change: 0 additions & 1 deletion io-uring-test/src/tests/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ pub fn test_timeout_abs<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
Ok(())
}

#[cfg(feature = "unstable")]
pub fn test_timeout_submit_args<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
ring: &mut IoUring<S, C>,
test: &Test,
Expand Down
14 changes: 0 additions & 14 deletions src/cqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::fmt::{self, Debug};
use std::mem;
#[cfg(feature = "unstable")]
use std::mem::MaybeUninit;
use std::sync::atomic;

Expand Down Expand Up @@ -49,15 +48,13 @@ pub trait EntryMarker: Clone + Debug + Into<Entry> + Sealed {}
pub struct Entry(pub(crate) sys::io_uring_cqe);

/// A 32-byte completion queue entry (CQE), representing a complete I/O operation.
#[cfg(feature = "unstable")]
#[repr(C)]
#[derive(Clone)]
pub struct Entry32(pub(crate) Entry, pub(crate) [u64; 2]);

#[test]
fn test_entry_sizes() {
assert_eq!(mem::size_of::<Entry>(), 16);
#[cfg(feature = "unstable")]
assert_eq!(mem::size_of::<Entry32>(), 32);
}

Expand Down Expand Up @@ -120,9 +117,6 @@ impl<E: EntryMarker> CompletionQueue<'_, E> {
/// Whether eventfd notifications are disabled when a request is completed and queued to the CQ
/// ring. This library currently does not provide a way to set it, so this will always be
/// `false`.
///
/// Requires the `unstable` feature.
#[cfg(feature = "unstable")]
pub fn eventfd_disabled(&self) -> bool {
unsafe {
(*self.queue.flags).load(atomic::Ordering::Acquire) & sys::IORING_CQ_EVENTFD_DISABLED
Expand Down Expand Up @@ -150,7 +144,6 @@ impl<E: EntryMarker> CompletionQueue<'_, E> {
self.len() == self.capacity()
}

#[cfg(feature = "unstable")]
#[inline]
pub fn fill<'a>(&mut self, entries: &'a mut [MaybeUninit<E>]) -> &'a mut [E] {
let len = std::cmp::min(self.len(), entries.len());
Expand Down Expand Up @@ -254,7 +247,6 @@ impl Debug for Entry {
}
}

#[cfg(feature = "unstable")]
impl Entry32 {
/// The operation-specific result code. For example, for a [`Read`](crate::opcode::Read)
/// operation this is equivalent to the return value of the `read(2)` system call.
Expand Down Expand Up @@ -287,22 +279,18 @@ impl Entry32 {
}
}

#[cfg(feature = "unstable")]
impl Sealed for Entry32 {
const ADDITIONAL_FLAGS: u32 = sys::IORING_SETUP_CQE32;
}

#[cfg(feature = "unstable")]
impl EntryMarker for Entry32 {}

#[cfg(feature = "unstable")]
impl From<Entry32> for Entry {
fn from(entry32: Entry32) -> Self {
entry32.0
}
}

#[cfg(feature = "unstable")]
impl Debug for Entry32 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Entry32")
Expand All @@ -314,7 +302,6 @@ impl Debug for Entry32 {
}
}

#[cfg(feature = "unstable")]
pub fn buffer_select(flags: u32) -> Option<u16> {
if flags & sys::IORING_CQE_F_BUFFER != 0 {
let id = flags >> sys::IORING_CQE_BUFFER_SHIFT;
Expand All @@ -328,7 +315,6 @@ pub fn buffer_select(flags: u32) -> Option<u16> {
}
}

#[cfg(feature = "unstable")]
pub fn more(flags: u32) -> bool {
flags & sys::IORING_CQE_F_MORE != 0
}
12 changes: 0 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ impl<S: squeue::EntryMarker, C: cqueue::EntryMarker> IoUring<S, C> {
///
/// Unlike [`IoUring::new`], this function is available for any combination of submission queue
/// entry (SQE) and completion queue entry (CQE) types.
#[cfg(feature = "unstable")]
pub fn generic_new(entries: u32) -> io::Result<Self> {
Self::generic_builder().build(entries)
}
Expand All @@ -113,7 +112,6 @@ impl<S: squeue::EntryMarker, C: cqueue::EntryMarker> IoUring<S, C> {
/// Unlike [`IoUring::builder`], this function is available for any combination of submission
/// queue entry (SQE) and completion queue entry (CQE) types.
#[must_use]
#[cfg(feature = "unstable")]
pub fn generic_builder() -> Builder<S, C> {
Builder {
dontfork: false,
Expand Down Expand Up @@ -356,15 +354,11 @@ impl<S: squeue::EntryMarker, C: cqueue::EntryMarker> Builder<S, C> {
/// events. You are only able to [register restrictions](Submitter::register_restrictions) when
/// the rings are disabled due to concurrency issues. You can enable the rings with
/// [`Submitter::register_enable_rings`].
///
/// Requires the `unstable` feature.
#[cfg(feature = "unstable")]
pub fn setup_r_disabled(&mut self) -> &mut Self {
self.params.flags |= sys::IORING_SETUP_R_DISABLED;
self
}

#[cfg(feature = "unstable")]
pub fn setup_coop_taskrun(&mut self) -> &mut Self {
self.params.flags |= sys::IORING_SETUP_COOP_TASKRUN;
self
Expand Down Expand Up @@ -447,9 +441,6 @@ impl Parameters {
/// See [the commit message that introduced
/// it](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d7718a9d25a61442da8ee8aeeff6a0097f0ccfd6)
/// for more details.
///
/// Requires the `unstable` feature.
#[cfg(feature = "unstable")]
pub fn is_feature_fast_poll(&self) -> bool {
self.0.features & sys::IORING_FEAT_FAST_POLL != 0
}
Expand All @@ -460,17 +451,14 @@ impl Parameters {
self.0.features & sys::IORING_FEAT_POLL_32BITS != 0
}

#[cfg(feature = "unstable")]
pub fn is_feature_sqpoll_nonfixed(&self) -> bool {
self.0.features & sys::IORING_FEAT_SQPOLL_NONFIXED != 0
}

#[cfg(feature = "unstable")]
pub fn is_feature_ext_arg(&self) -> bool {
self.0.features & sys::IORING_FEAT_EXT_ARG != 0
}

#[cfg(feature = "unstable")]
pub fn is_feature_native_workers(&self) -> bool {
self.0.features & sys::IORING_FEAT_NATIVE_WORKERS != 0
}
Expand Down

0 comments on commit 8346194

Please sign in to comment.