106 Commits

Author SHA1 Message Date
Jens Axboe 4e41621717 Merge branch 'missing-header' of https://github.com/flamingcow66/liburing
* 'missing-header' of https://github.com/flamingcow66/liburing:
  Fix liburing.h memset() missing declaration
2019-05-18 16:47:01 -06:00
Ian Gulliver f218f76b82 Fix liburing.h memset() missing declaration
liburing.h uses memset() but doesn't include string.h.
If nothing else includes it, this causes compile errors.
Add the include.

Signed-off-by: Ian Gulliver <git@flamingcow.io>
2019-05-18 13:53:40 -07:00
Jens Axboe 1a90a51ecd io_uring.h: sync with kernel
Add sync_range_file opcode and related fields, and the
io_uring_register(2) commands for eventfd registration.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-18 12:58:47 -06:00
Ian Gulliver 3200e997d0 Fix manpage mmap() syntax
The examples in the io_uring_setup.2 man patch erroneously ORs
the protection bits and mmap flags, fix it up.

Signed-off-by: Ian Gulliver <git@flamingcow.io>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-18 12:49:55 -06:00
Jens Axboe 6350583c6f Include man dir/pages in spec file install
Also kill reference to long dead TODO file.

Patch from Hrvoje Zeba <zeba.hrvoje@gmail.com>

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-16 20:35:19 -06:00
Jens Axboe 9511863658 examples/link-cp: improve memory use
Put the data at the end so we don't have to offset the actual buffer.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-15 14:11:10 -06:00
Jens Axboe 5c6e5d2745 examples/link-cp: improvements
Add short read requeue and abort on error.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-15 14:07:52 -06:00
Jens Axboe 7e8902e14c examples/link-cp: fix a few issues
Still need to handle broken chains, must resubmit those.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-14 20:46:12 -06:00
Jens Axboe bb2c80ff0f test/io_uring_register: don't fail max fd test if we run out of mem
We need a lot of RAM for this case, my vm always fails it. Don't
hard fail due to ENOMEM, just skip the test.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-14 20:11:43 -06:00
Jens Axboe 1982bfd44d Add chain failure handling test case
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-14 19:08:37 -06:00
Jens Axboe 0ba9503f79 Add link SQE support
Just a basic test case that does various forms of linked nops, and
a sample bare bones copy program using linked reads and writes.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-13 16:16:07 -06:00
Kevin Vigor 40c6f8454b liburing: add extern "C" to liburing.h
Make header includable from C++ projects.

Signed-off-by: Kevin Vigor <kvigor@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-06 15:45:01 -06:00
Kevin Vigor a17aec8458 liburing: do not build static library with -fPIC
Static libraries are generally built without -fPIC for slight
performance gain, make that the case for liburing.

Signed-off-by: Kevin Vigor <kvigor@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-06 15:44:59 -06:00
Kevin Vigor 54cc960db0 liburing: improve 'make install'
'make install' did not install all the headers necessary to use the
library; fix.

Additionally allow specifying the install prefix, which was previously
hardcoded to /usr.

Signed-off-by: Kevin Vigor <kvigor@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-06 15:44:58 -06:00
Jens Axboe 7b989f3419 test/eeed8b54e0df-test: define RWF_NOWAIT if we don't have it
Older installs/distros don't have this in fs.h.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-01 16:12:06 -06:00
Jens Axboe 10a5903db8 test/io_uring_setup: don't fail SQPOLL test case for non-root
SQPOLL requires root, if the tests are run as a user, we'll get
EPERM instead of EINVAL. Don't fail the test because of that, just
mention it in the log.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-01 16:06:59 -06:00
Jens Axboe ff73ac71a1 man/io_uring_enter.2: clarify io_uring_enter(2) return values
With the recent change to ensure that submission side errors that
happen on behalf of an sqe are returned in the form of a cqe rather
than -1/errno from the system call, make sure that the man page
reflects that.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-01 15:54:29 -06:00
Jens Axboe 60b330558f test/eeed8b54e0df-test: check write(2) return value
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-01 10:07:37 -06:00
Shenghui Wang eb9d065415 liburing: improve output for test/io_uring_setup.c
For the IORING_SETUP_SQPOLL|IORING_SETUP_SQ_AFF test case, add_pipe is
not set, and the output is like:
"...flags: IORING_SETUP_SQPOLLIORING_SETUP_SQ_AFF...".

Set add_pipe for IORING_SETUP_SQPOLL flag so that the output is like:
"...flags: IORING_SETUP_SQPOLL|IORING_SETUP_SQ_AFF...".

Acked-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Shenghui Wang <shhuiw@foxmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-01 10:06:02 -06:00
Jens Axboe ce8e2bc298 Update tests for 'sqe submit always posts a cqe'
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-30 14:50:36 -06:00
Jens Axboe 49d2017b3d test/runtests.sh: list all failed tests when done
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-30 14:50:20 -06:00
Shenghui Wang 6cd873cec6 liburing: install man pages on running 'make install'
Install man pages on running 'make install', so that
we can run commands like 'man 2 io_uring_setup'.

Signed-off-by: Shenghui Wang <shhuiw@foxmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-26 06:42:42 -06:00
Jens Axboe cb1e01af25 Add test case for -EAGAIN issue
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-25 09:58:55 -06:00
Jens Axboe 78f59df333 Add regression test cases for three recent issues
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-23 12:06:18 -06:00
Jens Axboe ad45ed1d67 Actually add test/runtests.sh
This adds the missing shell script that runs the tests.

Fixes: 4916320ec3 ("Separate test cases from examples")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-23 12:04:19 -06:00
Jens Axboe 87e2c401aa man/io_uring_enter.2: add another ENOTSUPP instance
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-23 10:35:46 -06:00
Jens Axboe 4a1a9dfe1f man/io_uring_register.2: add another ENXIO case
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-22 10:42:08 -06:00
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 4916320ec3 Separate test cases from examples
Also adds a runtests makefile target.
2019-04-17 11:39:39 -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 26993e9872 Add SQ/CQ overflow tests
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-17 08:57:25 -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 093e902c28 test/fsync: error out if we submit less than we wanted
This failure is expected on kernels that don't support the DRAIN
primitive.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-11 09:00:47 -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
Jens Axboe 0656d71c96 man/io_uring_setup.2: add EPERM case for IORING_SETUP_SQPOLL
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-10 08:41:42 -06:00
Jens Axboe db11f116c7 Use io_uring_cqe_get_data() internally
Replace all cqe->user_data casts with io_uring_cqe_get_data().

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-04-07 18:36:43 -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 a231fdcaa1 test/io_uring-cp: add some comments
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-03-06 08:31:26 -07:00
Jens Axboe 5fefee2333 Add generated files to .gitignore
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-03-06 08:31:11 -07:00
Jens Axboe f7dac56b4a test/io_uring-cp: make it more efficient
Clean it up, and just use a single io_uring for both the reads
and the writes.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-03-05 20:41:34 -07: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 b080d0680c Makefile: add cscope target
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-03-05 16:19:59 -07:00
Jeff Moyer 765ba233c8 add syscall unit tests
Add tests for io_uring_setup, io_uring_register and io_uring_enter.
The test coverage is nowhere near complete and the reporting is not
uniform.  But, it's a start.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-03-04 15:37:40 -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
Jeff Moyer 10a57a0823 io_uring_enter.2: clarify min_complete
min_complete means slightly different things depending on how the ring
was setup.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-14 17:13:44 -07:00
Jens Axboe 1a3020e7b4 man/io_uring_enter.2: clarify -EMFILE per-user case
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-02-12 14:11:34 -07:00