Avoid an additional pointer indirection to ring_mask and ring_entries,
since their values can't change after the ring is created.
The fields kring_mask and kring_entries are no longer needed,
but kept for backwards compatibility since liburing.h exposes them.
They can be removed in a future major release, saving 8 bytes per queue.
Signed-off-by: Caleb Sander <csander@purestorage.com>
add test to exercise the overflow codepath for multishot accept.
this doesn't actually fail previously, but does at least exerceise
the codepath and ensure that some invariants hold wrt flags and
IORING_CQE_F_MORE.
Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220630164918.3958710-8-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
These are skipped because they are not applicable if files/devices are
provided for a special test run. Note this in the return status.
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
For maintainability and clarity, eschew the use of integer literals in
reporting test statuses. Instead, use a helper enum which contains
various values from the GNU exitcode protocol. Returning 0 or 1 is
obvious, and in the previous commit the ability to read "skip" (77) was
implemented. The final exit status is 99, which indicates some kind of
error in running the test itself.
A partial migration of existing pass/fail values in test sources is
included.
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
This does three things:
- change multishot_mask from uint to uint32_t
- change multishot_mask != UINT_MAX check to ~multishot_mask != 0
The above two avoid compiler and arch influence. Make the logic more robost.
- other cleaning to make code clearer.
Signed-off-by: Hao Xu <howeyxu@tencent.com>
Link: https://lore.kernel.org/r/20220617143603.179277-4-hao.xu@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This fixes a bug in accept_conn handling in the accept tests that caused it
to incorrectly skip the multishot tests and also lose the warning message
to a closed stdout. This can be seen in the strace output below.
close(1) = 0
io_uring_setup(32, { ...
...
write(1, "Fixed Multishot Accept not suppo"..., 47) = -1 EINVAL
Unfortunately this exposes a a bug with gcc -O2 where multishot_mask logic
gets optimized incorrectly and "Fixed Multishot Accept misses events" is
wrongly reported. I am investigating this separately.
Fixes: 828b363184 ("test/accept.c: add test for multishot mode accept")
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20220617143603.179277-2-hao.xu@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
To keep things consistent between 2.1 and later versions of liburing,
make io_uring_prep_cancel() take a void * pointer again instead of a
__u64 type. Add io_uring_prep_cancel64() that takes a 64-bit type.
Link: https://github.com/axboe/liburing/discussions/601
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Add tests for accept sockets with O_NONBLOCK. Add a test for queueing the
accept both before and after connect(), which tests slightly different
code paths. After connect() has always worked, but before required changes
to the kernel.
Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220324143547.2882041-1-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
For the commands where we use it as a lookup key, then we don't want to
rob 32-bit applications from the potential of using the full 64-bit
type. This includes commands like:
poll_remove, poll_update, prep_cancel
Also provide 64-bit u64 types of the sqe set data and the cqe get data
helpers, along with a define that allows applications to check for the
presence of it.
NOTE: this may trigger compile warnings in applications that
currently use these helpers, which is also why a few test cases had
to get adapted. The fixup is trivial, and the above define can help
applications check if one or the other is the current one.
Link: https://github.com/axboe/liburing/issues/490
Reported-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
When we call `bind()` or `connect()`, the `addr` and `port` should be
in big endian value representation.
Portability notes:
- Do not hard code the address with integer like this `0x0100007fU`.
Instead, use `inet_addr("127.0.0.1")` to ensure portability for
the machine with different endianess. It's also cleaner and more
readable to use `inet_addr()` from `#include <arpa/inet.h>`.
- Use `htons(port_number)` to make sure the port_number is properly
choosen instead directly assign it with integer (still about
endianess problem).
This commit fixes endianess issue in these files:
test/232c93d07b74-test.c
test/accept-link.c
test/accept.c
test/poll-link.c
test/shutdown.c
test/socket-rw-eagain.c
test/socket-rw.c
Fixes: 08bd815170 ("Un-DOSify test/232c93d07b74-test.c")
Fixes: 4bce856d43 ("Improve reliability of poll/accept-link tests")
Fixes: 904989c0f1 ("Add nonblock empty socket read test")
Fixes: 7de6253569 ("test/accept: code reuse cleanup")
Fixes: 5068da320a ("Add IORING_OP_SHUTDOWN test case")
Fixes: 2b52a1be2d ("Moves function calls out of assert().")
Suggested-by: Louvian Lyndal <louvianlyndal@gmail.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
As brought up in an issue, this makes it confusing as to what could
potentially be liburing functions. Make it clear that these are test
helpers, hence use the t_ prefix for them.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
As axboe said, Right now a lot of basic stuff is duplicated,
and it makes the tests bigger than they should be.
Here, we try to add helpers.h which will contains various
utilities that tests could use, then that'd help make tests simpler.
In this patch, we just add one helper io_uring_malloc(), which
will call assert() if allocating memory fails.
We will add more helpers in subsequent patches
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
We prep the sqe, but don't submit it. Hence we are at the mercy of
the stack not going away, which it will. This ensures the data sent
is sane.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
We have a few where we try to use SQTHREAD, which will fail if the
effective user isn't root. Just skip these tests if we're not root.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This will exit with 0 in both the normal and failure case, but
the failure case will leave workers idle once done. We check
for that in runtests.sh now.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
- Don't re-init the io_uring
- SQPOLL can fail with -EBADF or -EINVAL, depends on which path the
sqe takes.
Signed-off-by: Jens Axboe <axboe@kernel.dk>