Skip to content

Commit

Permalink
remove temporarily tokio-uring
Browse files Browse the repository at this point in the history
The pendding PRs has been merged, We should use `crate.io` directly
instead of this temporary copy.

tokio-rs/tokio-uring#87
tokio-rs/tokio-uring#88

Signed-off-by: wanglei01 <wllenyj@linux.alibaba.com>
  • Loading branch information
wllenyj committed Nov 13, 2022
1 parent ffc5b24 commit 83dba75
Show file tree
Hide file tree
Showing 46 changed files with 16 additions and 3,745 deletions.
9 changes: 3 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mio = { version = "0.8", features = ["os-poll", "os-ext"]}
nix = "0.24"
lazy_static = "1.4"
tokio = { version = "1", optional = true }
tokio-uring = { version = "0.4.0", optional = true }
vmm-sys-util = { version = "0.10", optional = true }
vm-memory = { version = "0.9", features = ["backend-mmap"] }
virtio-queue = { version = "0.4", optional = true }
Expand All @@ -36,11 +37,7 @@ core-foundation-sys = { version = ">=0.8", optional = true }

[target.'cfg(target_os = "linux")'.dependencies]
caps = { version = "0.5", optional = true }
tokio-uring = "0.3"
io-uring = { version = "0.5", features = ["unstable"] }
socket2 = { version = "0.4.4", features = ["all"] }
scoped-tls = "1.0.0"
slab = "0.4.6"
tokio-uring = "0.4"

[dev-dependencies]
tokio-test = "0.4.2"
Expand All @@ -49,7 +46,7 @@ vm-memory = { version = "0.9", features = ["backend-mmap", "backend-bitmap"] }

[features]
default = ["fusedev"]
async-io = ["async-trait", "tokio/fs", "tokio/net", "tokio/sync", "tokio/rt", "tokio/macros"]
async-io = ["async-trait", "tokio-uring", "tokio/fs", "tokio/net", "tokio/sync", "tokio/rt", "tokio/macros"]
fusedev = ["vmm-sys-util", "caps", "core-foundation-sys"]
virtiofs = ["virtio-queue", "caps"]
vhost-user-fs = ["virtiofs", "vhost", "caps"]
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,3 @@ impl FuseServer {
This project is licensed under
- [Apache License](http://www.apache.org/licenses/LICENSE-2.0), Version 2.0
- [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

Source code under [src/tokio-uring] is temporarily copied from [tokio-uring](https://github.com/tokio-rs/tokio-uring)
with modifications, which is licensed under [MIT](https://github.com/tokio-rs/tokio-uring/blob/master/LICENSE).

We will use `crate.io` directly instead of this temporary copy when the pendding PRs is merged.
https://github.com/tokio-rs/tokio-uring/pull/87
https://github.com/tokio-rs/tokio-uring/pull/88
12 changes: 6 additions & 6 deletions src/common/async_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl File {
.await
.map(File::Tokio),
#[cfg(target_os = "linux")]
2 => crate::tokio_uring::fs::OpenOptions::new()
2 => tokio_uring::fs::OpenOptions::new()
.read(true)
.write(write)
.create(create)
Expand Down Expand Up @@ -79,7 +79,7 @@ impl File {
// Safety: we rely on tokio_uring::fs::File internal implementation details.
// It should be implemented as self.async_try_clone().await.unwrap().read_at,
// but that causes two more syscalls.
let file = unsafe { crate::tokio_uring::fs::File::from_raw_fd(*fd) };
let file = unsafe { tokio_uring::fs::File::from_raw_fd(*fd) };
let res = file.read_at(buf, offset).await;
std::mem::forget(file);
res
Expand All @@ -105,7 +105,7 @@ impl File {
// Safety: we rely on tokio_uring::fs::File internal implementation details.
// It should be implemented as self.async_try_clone().await.unwrap().readv_at,
// but that causes two more syscalls.
let file = unsafe { crate::tokio_uring::fs::File::from_raw_fd(*fd) };
let file = unsafe { tokio_uring::fs::File::from_raw_fd(*fd) };
let res = file.readv_at(bufs, offset).await;
std::mem::forget(file);
res
Expand All @@ -132,7 +132,7 @@ impl File {
// Safety: we rely on tokio_uring::fs::File internal implementation details.
// It should be implemented as self.async_try_clone().await.unwrap().write_at,
// but that causes two more syscalls.
let file = unsafe { crate::tokio_uring::fs::File::from_raw_fd(*fd) };
let file = unsafe { tokio_uring::fs::File::from_raw_fd(*fd) };
let res = file.write_at(buf, offset).await;
std::mem::forget(file);
res
Expand All @@ -158,7 +158,7 @@ impl File {
// Safety: we rely on tokio_uring::fs::File internal implementation details.
// It should be implemented as self.async_try_clone().await.unwrap().writev_at,
// but that causes two more syscalls.
let file = unsafe { crate::tokio_uring::fs::File::from_raw_fd(*fd) };
let file = unsafe { tokio_uring::fs::File::from_raw_fd(*fd) };
let res = file.writev_at(bufs, offset).await;
std::mem::forget(file);
res
Expand Down Expand Up @@ -214,7 +214,7 @@ impl Drop for File {
fn drop(&mut self) {
#[cfg(target_os = "linux")]
if let File::Uring(fd) = self {
let _ = unsafe { crate::tokio_uring::fs::File::from_raw_fd(*fd) };
let _ = unsafe { tokio_uring::fs::File::from_raw_fd(*fd) };
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/common/async_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub enum Runtime {
Tokio(tokio::runtime::Runtime),
#[cfg(target_os = "linux")]
/// Tokio-uring Runtime.
Uring(std::sync::Mutex<crate::tokio_uring::Runtime>),
Uring(std::sync::Mutex<tokio_uring::Runtime>),
}

impl Runtime {
Expand All @@ -28,7 +28,7 @@ impl Runtime {
#[cfg(target_os = "linux")]
{
// TODO: use io-uring probe to detect supported operations.
if let Ok(rt) = crate::tokio_uring::Runtime::new() {
if let Ok(rt) = tokio_uring::Runtime::new(&tokio_uring::builder()) {
return Runtime::Uring(std::sync::Mutex::new(rt));
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ pub fn spawn<T: std::future::Future + 'static>(task: T) -> tokio::task::JoinHand
CURRENT_RUNTIME.with(|rt| match rt {
Runtime::Tokio(_) => tokio::task::spawn_local(task),
#[cfg(target_os = "linux")]
Runtime::Uring(_) => crate::tokio_uring::spawn(task),
Runtime::Uring(_) => tokio_uring::spawn(task),
})
}

Expand Down
9 changes: 3 additions & 6 deletions src/common/file_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,11 @@ impl FileVolatileBuf {
}
}

#[cfg(all(feature = "async-io", target_os = "linux"))]
pub use crate::tokio_uring::buf::{IoBuf, IoBufMut, Slice};

#[cfg(all(feature = "async-io", target_os = "linux"))]
mod async_io {
use super::*;

unsafe impl crate::tokio_uring::buf::IoBuf for FileVolatileBuf {
unsafe impl tokio_uring::buf::IoBuf for FileVolatileBuf {
fn stable_ptr(&self) -> *const u8 {
self.addr as *const u8
}
Expand All @@ -375,7 +372,7 @@ mod async_io {
}
}

unsafe impl crate::tokio_uring::buf::IoBufMut for FileVolatileBuf {
unsafe impl tokio_uring::buf::IoBufMut for FileVolatileBuf {
fn stable_mut_ptr(&mut self) -> *mut u8 {
self.addr as *mut u8
}
Expand All @@ -388,7 +385,7 @@ mod async_io {
#[cfg(test)]
mod tests {
use super::*;
use crate::tokio_uring::buf::{IoBuf, IoBufMut};
use tokio_uring::buf::{IoBuf, IoBufMut};

#[test]
fn test_new_file_volatile_buf() {
Expand Down
2 changes: 1 addition & 1 deletion src/common/file_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,11 @@ mod async_io {
use std::sync::Arc;

use tokio::join;
use tokio_uring::buf::IoBuf;

use super::*;
use crate::async_file::File;
use crate::file_buf::FileVolatileBuf;
use crate::tokio_uring::buf::IoBuf;

/// Extension of [FileReadWriteVolatile] to support io-uring based asynchronous IO.
///
Expand Down
7 changes: 0 additions & 7 deletions src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ pub mod async_runtime;
#[cfg(feature = "async-io")]
pub mod mpmc;

// Temporarily include all source code tokio-uring.
// Will switch to upstream once our enhancement have been merged and new version available.
#[cfg(all(feature = "async-io", target_os = "linux"))]
pub mod tokio_uring;
#[cfg(all(feature = "async-io", target_os = "linux"))]
pub(crate) use self::tokio_uring::{buf, driver, fs, future, BufResult};

#[cfg(target_os = "linux")]
#[doc(hidden)]
pub use libc::{off64_t, pread64, preadv64, pwrite64, pwritev64};
Expand Down
162 changes: 0 additions & 162 deletions src/common/tokio_uring/buf/io_buf.rs

This file was deleted.

Loading

0 comments on commit 83dba75

Please sign in to comment.