Commit Graph

44 Commits

Author SHA1 Message Date
Jens Axboe
39e0ebd4fc Rename completion helpers
We have io_uring_get_sqe() on the submission side, yet the completion
side is named _completion. Rename as follows:

io_uring_get_completion()	io_uring_peek_cqe()
iO_uring_wait_completion()	io_uring_wait_cqe()

This better tells the user what the _get variant does by calling it
_peek instead, and we move to using _cqe() as the postfix instead
of _completion.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-18 08:38:08 -06:00
Jens Axboe
76b61ebf1b Add io_uring_cqe_seen()
There's a failure case where an application gets a cqe entry, but
the kernel can then overwrite it before the application is done
reading it. This can happen since the io_uring_{get,wait}_completion()
interface both returns a CQE pointer AND increments the ring index.
If the kernel reuses this entry before the applications is done reading
it, the contents may be corrupted.

Remove the CQ head increment from the CQE retrieval, and put it into
a separate helper, io_uring_cqe_seen(). The application must call this
helper when it got a new CQE entry through one of the above calls, and
it's now done reading it.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-17 09:42:23 -06:00
Jens Axboe
8115820eb9 test/nop: add NOP test case
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-11 09:01:16 -06:00
Jens Axboe
9864409788 test/fsync: update for IOSQE_IO_DRAIN approach
I generalized the barrier flag to be applicable to all commands, so
let's drop the fsync special flag.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-10 21:56:54 -06:00
Zach Bjornson
1245d8320a Add io_uring_cqe_get_data()
Signed-off-by: Zach Bjornson <zbbjornson@gmail.com>

Add uintptr_t cast to avoid 32-bit warnings.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-07 18:35:30 -06:00
Jens Axboe
61c27f73f8 Add barrier fsync test case
Also changes the fsync prep helper to require passing in the actual
flag, not just a boolean for fsync vs fdatasync.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-06 21:50:15 -06:00
Jens Axboe
f8b12e48bf Remove IOCQE_FLAG_CACHEHIT
This cache hint has been removed from the io_uring series, as there's
some hesitation to leak this information to userspace. Remove it from
the header file and the man page. We can always re-introduce it later,
if we get some variant of this included.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-03-19 10:01:55 -06:00
Jens Axboe
a86522197d queue: ensure io_uring_submit() returns the system call value
A previous fix that ensured we pass back the right error messed
up the normal return, which is number of entries submitted.
This makes the poll test cases fail.

Fixes: 8260029608 ("queue: ensure io_uring_submit() returns the right error")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-03-13 08:48:45 -06:00
Jens Axboe
8260029608 queue: ensure io_uring_submit() returns the right error
We weren't passing back -errno for the system call failure.
This meant any error got turned into EPERM as far as the
caller was concerned.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-03-05 20:12:48 -07:00
Jens Axboe
432fa1d3d1 Add read/write fixed prep support
Also unify the setup, all the read/write variants can use the same
helper.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-28 13:38:41 -07:00
Jens Axboe
5b5e6fe360 src/queue: kill bogus ktail_next == head check
This really wants to be a "will we over-fill the ring?" kind of
check, but the sqe_head/sqe_tail should not be that far apart. If they
are, that's a bug elsewhere. So just kill the check.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-15 10:43:03 -07:00
Jens Axboe
f62fdcd852 Sync io_uring.h with the kernel
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-10 09:36:24 -07:00
Jens Axboe
520efcd606 src/queue: add comments on the read and write barriers
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-10 08:19:54 -07:00
Jens Axboe
6726376f32 test/fsync: add simple fsync tester
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-08 21:02:00 -07:00
Jeff Moyer
996b5a65a5 add io_uring_queue_mmap
io_uring_queue_init does not allow the caller to specify sq_thread_cpu
or sq_thread_idle.  Users that want to specify those parameters need to
call io_uring_setup(2) themselves.  Add a helper so that they don't also
have to hand-craft the code to map the submission and completion queues,
and setup the sqe ring.  This allows those applications to still make
use of io_uring_submit and get/wait_completion.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-08 12:56:35 -07:00
Jens Axboe
e377c38ca7 io_uring_enter: don't expose sigset_size argument
Applications should not need to care about this, we can pass it in
ourselves. Once the libc support is there, we won't expose this
parameter either.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-08 11:40:17 -07:00
Jeff Moyer
3ceb15c132 Add sigmask parameter to io_uring_enter
Update liburing and io_uring_enter.2 to match the kernel.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-08 11:33:28 -07:00
Jens Axboe
9f3bec5b09 syscall: update io_uring_enter() to match kernel type
We would randomly fail depending on what garbage was passed in
the two sigset related fields.

Reported-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-08 10:33:00 -07:00
Jeff Moyer
450033065f io_uring_register takes 4 args
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-05 11:37:19 -07:00
Jens Axboe
be33b0a219 src/io_uring.h: sync with kernel header
Just a removal of the IORING_MAX_ENTRIES user visible define.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-31 22:58:02 -07:00
Jens Axboe
27ad3317fb Update kernel io_uring header
- struct io_uring_params changed (u16 -> u32 for sq options)
- Use unsigned for the flag types

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-29 06:32:13 -07:00
Jens Axboe
bceccde79a System calls have been renumbered
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-23 08:03:41 -07:00
Jens Axboe
3640699bea Switch to IORING_OP_POLL_ADD/REMOVE
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-18 07:00:14 -07:00
Jens Axboe
213d6f39ef Split src/io_uring.c up
Let's have the various helpers be in usefully named functions, no
need to bundle them all into the same one.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-17 21:40:30 -07:00
Jens Axboe
257578052a liburing: ensure prep helpers actually set iovec count
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-17 21:33:39 -07:00
Jens Axboe
5789a6351a Add sqe prep helpers
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-17 18:12:22 -07:00
Jens Axboe
768d4559d0 Update POLL API
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-17 14:24:28 -07:00
Jens Axboe
ce899b79f9 Add test case for IORING_OP_POLL
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-17 11:40:24 -07:00
Jens Axboe
6110279661 Update barriers for x86/x86-64
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-16 09:04:02 -07:00
Jens Axboe
b93edf5b9e Sync with upstream API
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-16 09:00:50 -07:00
Jens Axboe
f16b83b293 Add configure script
Some older installs don't have __kernel_rwf_t in linux/fs.h, so
add a check for that.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-15 11:19:16 -07:00
Jens Axboe
89167b457f Add x86 32-bit support
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-13 11:03:04 -07:00
Jens Axboe
4fe9645fa4 io_uring_get_iocb() -> io_uring_get_sqe()
Missed this part when the switch was made to full 'sqe'.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-13 09:19:20 -07:00
Jens Axboe
58004cd7a6 Sync io_uring.h with the kernel
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-13 09:18:11 -07:00
Jens Axboe
ff52073504 Sync with kernel API
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-11 10:36:28 -07:00
Jens Axboe
a992ffa482 io_queue_init: pass in flags, not io_uring_params
We don't need any of the information in there in the caller, and
this makes it harder to abuse as we don't require the caller to
have memset() the struct first.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-10 15:11:07 -07:00
Jens Axboe
d5b4ae1c58 Update to newer API
- Fixed buffers are now available through io_uring_register()
- Various thread/wq options are now dead and automatic instead
- sqe->index is now sqe->buf_index
- Fixed buffers require flag, not separate opcode

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-10 14:28:10 -07:00
Jens Axboe
6cdce17753 Update API
- io_uring_sqe added a data field that's passed back at completion
- io_uring_sqe added an index field, for fixed buffer locations
- io_uring_setup(2) system call added a 'nr_iovecs' field

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-10 09:35:34 -07:00
Jens Axboe
7bf7e8e8e5 Update to newer API
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-09 15:26:20 -07:00
Jens Axboe
66a7d05bd8 liburing: include the ring fd in the io_uring
No point in keeping these separate.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-08 16:01:59 -07:00
Jens Axboe
7f7a66e385 Change API to provide io_uring struct abstraction
This is cleaner than having the app juggle an SQ and CQ ring,
just wrap them in struct io_uring and have the API always take
that. This means the app doesn't need to worry about the different
types of rings, and that we only need to pass in one argument
for setup/teardown.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-08 15:38:05 -07:00
Jens Axboe
f47f24cea7 liburing: add io_uring_iocb_from_ev() helper
Returns the iocb associated with a completion event.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-08 15:38:03 -07:00
Jens Axboe
6a44c6e0f7 Add option for getting a completion without waiting
This now exposes two helpers:

io_uring_get_completion()
	Return a completion, if we have one (or more) available in
	the ring

io_uring_wait_completion()
	Return a completion, waiting for it if necessary

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-08 15:38:01 -07:00
Jens Axboe
f93c84e1b0 Initial commit
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-01-08 07:38:15 -07:00