hmwill / tokio-linux-aio Goto Github PK
View Code? Open in Web Editor NEWSupport for Linux kernel aio within Tokio.
Home Page: https://docs.rs/tokio-linux-aio/
License: MIT License
Support for Linux kernel aio within Tokio.
Home Page: https://docs.rs/tokio-linux-aio/
License: MIT License
The io_submit call supports the RWF_DSYNC and RWF_SYNC flag values, which ensue that the write operation completes according to requirements of synchronized I/O data integrity.
Add support for the missing command types following the structure that has been laid out thus far.
Hi,
Thanks for the great work on this crate. However, it's not much maintained and outdated at the time. I have mostly finished the huge refactoringwith support for tokio 0.2, and async/await, and with a few improvements on performance and stability. I'd like to continue maintaining it, and wondering, if it would be possible to pass the ownership of the tokio-linux-aio
crate to me?
We need a centralized task to pull I/O completion from the kernel context, because io_getevents does not allow us to retrieve completion status for a specific previously submitted request.
Even though meant to be non-blocking. io_submit can block in some cases. io_submit supports a flag RWF_NOWAIT that can be used to require the call to be non-blocking. Specifically, this option means:
Don't wait if the I/O will block for operations such as file block allocations, dirty page flush, mutex locks, or a congested block device inside the kernel.
When RMF_NOWAIT is set, I/O requests may fail immediately with EAGAIN.
This issue is about investigating if RWF_NOWAIT can be meaningfully integrated into this API.
Linux's libaio put how many bytes read/write in io_event.res
using a positive integer.
I did not find the document, but the kernel code proves that ╮( ̄▽ ̄)╭
https://github.com/torvalds/linux/blob/3717f613f48df0222311f974cf8a06c8a6c97bae/fs/aio.c#L1535-L1541
usually, it is the device block size, but actually, it is equal with the blocking system call read(2)
.
The simplest way is change fn retrieve_result(&mut self) -> Result<futures::Async<()>, io::Error>
to fn retrieve_result(&mut self) -> Result<futures::Async<u64>, io::Error>
It will be a lot of broken change.
diff --git a/src/lib.rs b/src/lib.rs
index 537f6d8..0751418 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -207,7 +207,7 @@ impl AioBaseFuture {
// Attempt to retrieve the result of a previously submitted I/O request; this may need to
// wait until the I/O operation has been completed
- fn retrieve_result(&mut self) -> Result<futures::Async<()>, io::Error> {
+ fn retrieve_result(&mut self) -> Result<futures::Async<u64>, io::Error> {
// Check if we have received a notification indicating completion of the I/O request
let result_code = match self.state.as_mut().unwrap().completed_receiver.poll() {
Err(err) => return Err(io::Error::new(io::ErrorKind::Other, err)),
@@ -229,17 +229,17 @@ impl AioBaseFuture {
if result_code < 0 {
Err(io::Error::from_raw_os_error(result_code as i32))
} else {
- Ok(futures::Async::Ready(()))
+ Ok(futures::Async::Ready(result_code as u64))
}
}
}
// Common future base type for all asynchronous operations supperted by this API
impl futures::Future for AioBaseFuture {
- type Item = ();
+ type Item = u64;
type Error = io::Error;
- fn poll(&mut self) -> Result<futures::Async<()>, io::Error> {
+ fn poll(&mut self) -> Result<futures::Async<u64>, io::Error> {
let result = self.submit_request();
match result {
@@ -298,13 +298,13 @@ impl<ReadWriteHandle> futures::Future for AioReadResultFuture<ReadWriteHandle>
where
ReadWriteHandle: convert::AsMut<[u8]>,
{
- type Item = ReadWriteHandle;
+ type Item = (ReadWriteHandle, u64);
type Error = AioError<ReadWriteHandle>;
fn poll(&mut self) -> Result<futures::Async<Self::Item>, Self::Error> {
self.base
.poll()
- .map(|val| val.map(|_| self.buffer.take().unwrap()))
+ .map(|val| val.map(|nbytes| (self.buffer.take().unwrap(), nbytes)))
.map_err(|err| AioError {
buffer: self.buffer.take().unwrap(),
error: err,
@@ -329,13 +329,13 @@ impl<ReadOnlyHandle> futures::Future for AioWriteResultFuture<ReadOnlyHandle>
where
ReadOnlyHandle: convert::AsRef<[u8]>,
{
- type Item = ReadOnlyHandle;
+ type Item = (ReadOnlyHandle, u64);
type Error = AioError<ReadOnlyHandle>;
fn poll(&mut self) -> Result<futures::Async<Self::Item>, Self::Error> {
self.base
.poll()
- .map(|val| val.map(|_| self.buffer.take().unwrap()))
+ .map(|val| val.map(|nbytes| (self.buffer.take().unwrap(), nbytes)))
.map_err(|err| AioError {
buffer: self.buffer.take().unwrap(),
error: err,
@@ -353,7 +353,7 @@ pub struct AioSyncResultFuture
impl futures::Future for AioSyncResultFuture
{
- type Item = ();
+ type Item = u64;
type Error = io::Error;
fn poll(&mut self) -> Result<futures::Async<Self::Item>, Self::Error> {
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.