summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore130
-rwxr-xr-xconfigure4
-rw-r--r--man/io_uring.712
-rw-r--r--src/int_flags.h1
-rw-r--r--test/232c93d07b74.c (renamed from test/232c93d07b74-test.c)0
-rw-r--r--test/35fa71a030ca.c (renamed from test/35fa71a030ca-test.c)0
-rw-r--r--test/500f9fbadef8.c (renamed from test/500f9fbadef8-test.c)0
-rw-r--r--test/7ad0e4b2f83c.c (renamed from test/7ad0e4b2f83c-test.c)0
-rw-r--r--test/8a9973408177.c (renamed from test/8a9973408177-test.c)0
-rw-r--r--test/917257daa0fe.c (renamed from test/917257daa0fe-test.c)0
-rw-r--r--test/Makefile67
-rw-r--r--test/a0908ae19763.c (renamed from test/a0908ae19763-test.c)0
-rw-r--r--test/a4c0b3decb33.c (renamed from test/a4c0b3decb33-test.c)0
-rw-r--r--test/b19062a56726.c (renamed from test/b19062a56726-test.c)0
-rw-r--r--test/b5837bd5311d.c (renamed from test/b5837bd5311d-test.c)0
-rw-r--r--test/ce593a6c480a.c (renamed from test/ce593a6c480a-test.c)0
-rw-r--r--test/d4ae271dfaae.c (renamed from test/d4ae271dfaae-test.c)0
-rw-r--r--test/d77a67ed5f27.c (renamed from test/d77a67ed5f27-test.c)0
-rw-r--r--test/drop-submit.c1
-rw-r--r--test/eeed8b54e0df.c (renamed from test/eeed8b54e0df-test.c)0
-rw-r--r--test/fc2a85cb02ef.c (renamed from test/fc2a85cb02ef-test.c)0
-rw-r--r--test/fixed-reuse.c160
-rw-r--r--test/helpers.c14
-rw-r--r--test/helpers.h6
-rw-r--r--test/submit-link-fail.c6
25 files changed, 218 insertions, 183 deletions
diff --git a/.gitignore b/.gitignore
index 6cd5878..60fddd7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,135 +16,7 @@
/examples/link-cp
/examples/ucontext-cp
-/test/232c93d07b74-test
-/test/35fa71a030ca-test
-/test/500f9fbadef8-test
-/test/7ad0e4b2f83c-test
-/test/8a9973408177-test
-/test/917257daa0fe-test
-/test/a0908ae19763-test
-/test/a4c0b3decb33-test
-/test/accept
-/test/accept-link
-/test/accept-reuse
-/test/accept-test
-/test/across-fork
-/test/b19062a56726-test
-/test/b5837bd5311d-test
-/test/ce593a6c480a-test
-/test/close-opath
-/test/config.local
-/test/connect
-/test/cq-full
-/test/cq-overflow
-/test/cq-overflow-peek
-/test/cq-peek-batch
-/test/cq-ready
-/test/cq-size
-/test/d4ae271dfaae-test
-/test/d77a67ed5f27-test
-/test/defer
-/test/double-poll-crash
-/test/drop-submit
-/test/eeed8b54e0df-test
-/test/empty-eownerdead
-/test/eventfd
-/test/eventfd-disable
-/test/eventfd-reg
-/test/eventfd-ring
-/test/exit-no-cleanup
-/test/fadvise
-/test/fallocate
-/test/fc2a85cb02ef-test
-/test/file-register
-/test/file-update
-/test/file-verify
-/test/files-exit-hang-poll
-/test/files-exit-hang-timeout
-/test/fixed-buf-iter
-/test/fixed-link
-/test/fpos
-/test/fsync
-/test/hardlink
-/test/io-cancel
-/test/io_uring_enter
-/test/io_uring_register
-/test/io_uring_setup
-/test/iopoll
-/test/lfs-openat
-/test/lfs-openat-write
-/test/link
-/test/link-timeout
-/test/link_drain
-/test/madvise
-/test/mkdir
-/test/msg-ring
-/test/nop
-/test/nop-all-sizes
-/test/open-close
-/test/open-direct-link
-/test/openat2
-/test/personality
-/test/pipe-eof
-/test/pipe-reuse
-/test/poll
-/test/poll-cancel
-/test/poll-cancel-ton
-/test/poll-link
-/test/poll-many
-/test/poll-ring
-/test/poll-v-poll
-/test/pollfree
-/test/probe
-/test/read-write
-/test/recv-msgall
-/test/recv-msgall-stream
-/test/register-restrictions
-/test/rename
-/test/ring-leak
-/test/ring-leak2
-/test/self
-/test/send_recv
-/test/send_recvmsg
-/test/sendmsg_fs_cve
-/test/shared-wq
-/test/short-read
-/test/shutdown
-/test/sigfd-deadlock
-/test/socket-rw
-/test/socket-rw-eagain
-/test/socket-rw-offset
-/test/splice
-/test/sq-full
-/test/sq-full-cpp
-/test/sq-poll-dup
-/test/sq-poll-kthread
-/test/sq-poll-share
-/test/sqpoll-disable-exit
-/test/sqpoll-exit-hang
-/test/sqpoll-sleep
-/test/sq-space_left
-/test/statx
-/test/stdout
-/test/submit-reuse
-/test/symlink
-/test/teardowns
-/test/thread-exit
-/test/timeout
-/test/timeout-new
-/test/timeout-overflow
-/test/tty-write-dpoll
-/test/unlink
-/test/wakeup-hang
-/test/multicqes_drain
-/test/poll-mshot-update
-/test/rsrc_tags
-/test/rw_merge_test
-/test/sqpoll-cancel-hang
-/test/testfile
-/test/submit-link-fail
-/test/exec-target
-/test/skip-cqe
+/test/*.t
/test/*.dmesg
/test/output/
diff --git a/configure b/configure
index 512a556..f2bf041 100755
--- a/configure
+++ b/configure
@@ -1,10 +1,12 @@
#!/bin/sh
+set -e
+
cc=${CC:-gcc}
cxx=${CXX:-g++}
for opt do
- optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
+ optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)' || true)
case "$opt" in
--help|-h) show_help=yes
;;
diff --git a/man/io_uring.7 b/man/io_uring.7
index 0a47831..39865e6 100644
--- a/man/io_uring.7
+++ b/man/io_uring.7
@@ -551,8 +551,8 @@ int io_uring_setup(unsigned entries, struct io_uring_params *p)
int io_uring_enter(int ring_fd, unsigned int to_submit,
unsigned int min_complete, unsigned int flags)
{
- return (int) syscall(__NR_io_uring_enter, ring_fd, to_submit, min_complete,
- flags, NULL, 0);
+ return (int) syscall(__NR_io_uring_enter, ring_fd, to_submit,
+ min_complete, flags, NULL, 0);
}
int app_setup_uring(void) {
@@ -696,10 +696,10 @@ int submit_to_sq(int fd, int op) {
io_uring_smp_store_release(sring_tail, tail);
/*
- * Tell the kernel we have submitted events with the io_uring_enter() system
- * call. We also pass in the IOURING_ENTER_GETEVENTS flag which causes the
- * io_uring_enter() call to wait until min_complete (the 3rd param) events
- * complete.
+ * Tell the kernel we have submitted events with the io_uring_enter()
+ * system call. We also pass in the IOURING_ENTER_GETEVENTS flag which
+ * causes the io_uring_enter() call to wait until min_complete
+ * (the 3rd param) events complete.
* */
int ret = io_uring_enter(ring_fd, 1,1,
IORING_ENTER_GETEVENTS);
diff --git a/src/int_flags.h b/src/int_flags.h
index b9270ae..90505ec 100644
--- a/src/int_flags.h
+++ b/src/int_flags.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: MIT */
#ifndef LIBURING_INT_FLAGS
#define LIBURING_INT_FLAGS
diff --git a/test/232c93d07b74-test.c b/test/232c93d07b74.c
index 4153aef..4153aef 100644
--- a/test/232c93d07b74-test.c
+++ b/test/232c93d07b74.c
diff --git a/test/35fa71a030ca-test.c b/test/35fa71a030ca.c
index f83cc9d..f83cc9d 100644
--- a/test/35fa71a030ca-test.c
+++ b/test/35fa71a030ca.c
diff --git a/test/500f9fbadef8-test.c b/test/500f9fbadef8.c
index dbd5751..dbd5751 100644
--- a/test/500f9fbadef8-test.c
+++ b/test/500f9fbadef8.c
diff --git a/test/7ad0e4b2f83c-test.c b/test/7ad0e4b2f83c.c
index 4d760e1..4d760e1 100644
--- a/test/7ad0e4b2f83c-test.c
+++ b/test/7ad0e4b2f83c.c
diff --git a/test/8a9973408177-test.c b/test/8a9973408177.c
index 94bf781..94bf781 100644
--- a/test/8a9973408177-test.c
+++ b/test/8a9973408177.c
diff --git a/test/917257daa0fe-test.c b/test/917257daa0fe.c
index 1d00ef1..1d00ef1 100644
--- a/test/917257daa0fe-test.c
+++ b/test/917257daa0fe.c
diff --git a/test/Makefile b/test/Makefile
index 8570748..cb7e15e 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -31,25 +31,25 @@ override CFLAGS += $(XCFLAGS) -DLIBURING_BUILD_TEST
override CXXFLAGS += $(XCFLAGS) -std=c++11 -DLIBURING_BUILD_TEST
LDFLAGS ?=
-override LDFLAGS += -L../src/ -luring
+override LDFLAGS += -L../src/ -luring -lpthread
test_srcs := \
- 232c93d07b74-test.c \
- 35fa71a030ca-test.c \
- 500f9fbadef8-test.c \
- 7ad0e4b2f83c-test.c \
- 8a9973408177-test.c \
- 917257daa0fe-test.c \
- a0908ae19763-test.c \
- a4c0b3decb33-test.c \
+ 232c93d07b74.c \
+ 35fa71a030ca.c \
+ 500f9fbadef8.c \
+ 7ad0e4b2f83c.c \
+ 8a9973408177.c \
+ 917257daa0fe.c \
+ a0908ae19763.c \
+ a4c0b3decb33.c \
accept.c \
accept-link.c \
accept-reuse.c \
accept-test.c \
across-fork.c \
- b19062a56726-test.c \
- b5837bd5311d-test.c \
- ce593a6c480a-test.c \
+ b19062a56726.c \
+ b5837bd5311d.c \
+ ce593a6c480a.c \
close-opath.c \
connect.c \
cq-full.c \
@@ -57,12 +57,12 @@ test_srcs := \
cq-peek-batch.c \
cq-ready.c \
cq-size.c \
- d4ae271dfaae-test.c \
- d77a67ed5f27-test.c \
+ d4ae271dfaae.c \
+ d77a67ed5f27.c \
defer.c \
double-poll-crash.c \
drop-submit.c \
- eeed8b54e0df-test.c \
+ eeed8b54e0df.c \
empty-eownerdead.c \
eventfd.c \
eventfd-disable.c \
@@ -72,7 +72,7 @@ test_srcs := \
exit-no-cleanup.c \
fadvise.c \
fallocate.c \
- fc2a85cb02ef-test.c \
+ fc2a85cb02ef.c \
file-register.c \
files-exit-hang-poll.c \
files-exit-hang-timeout.c \
@@ -80,6 +80,7 @@ test_srcs := \
file-verify.c \
fixed-buf-iter.c \
fixed-link.c \
+ fixed-reuse.c \
fpos.c \
fsync.c \
hardlink.c \
@@ -173,16 +174,18 @@ endif
ifdef CONFIG_HAVE_GLIBC_STATX
test_srcs += statx.c
endif
-all_targets += statx
+all_targets += statx.t
ifdef CONFIG_HAVE_CXX
test_srcs += sq-full-cpp.cc
endif
-all_targets += sq-full-cpp
+all_targets += sq-full-cpp.t
-test_targets := $(patsubst %.c,%,$(patsubst %.cc,%,$(test_srcs)))
+test_targets := $(patsubst %.c,%,$(test_srcs))
+test_targets := $(patsubst %.cc,%,$(test_targets))
+test_targets := $(patsubst %,%.t,$(test_targets))
all_targets += $(test_targets)
#
@@ -203,35 +206,13 @@ all: $(test_targets)
helpers.o: helpers.c
$(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
-%: %.c $(helpers) helpers.h ../src/liburing.a
+%.t: %.c $(helpers) helpers.h ../src/liburing.a
$(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(helpers) $(LDFLAGS)
-%: %.cc $(helpers) helpers.h ../src/liburing.a
+%.t: %.cc $(helpers) helpers.h ../src/liburing.a
$(QUIET_CXX)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< $(helpers) $(LDFLAGS)
-35fa71a030ca-test: override LDFLAGS += -lpthread
-232c93d07b74-test: override LDFLAGS += -lpthread
-send_recv: override LDFLAGS += -lpthread
-send_recvmsg: override LDFLAGS += -lpthread
-poll-link: override LDFLAGS += -lpthread
-accept-link: override LDFLAGS += -lpthread
-submit-reuse: override LDFLAGS += -lpthread
-poll-v-poll: override LDFLAGS += -lpthread
-across-fork: override LDFLAGS += -lpthread
-ce593a6c480a-test: override LDFLAGS += -lpthread
-wakeup-hang: override LDFLAGS += -lpthread
-pipe-eof: override LDFLAGS += -lpthread
-timeout-new: override LDFLAGS += -lpthread
-thread-exit: override LDFLAGS += -lpthread
-ring-leak2: override LDFLAGS += -lpthread
-poll-mshot-update: override LDFLAGS += -lpthread
-exit-no-cleanup: override LDFLAGS += -lpthread
-pollfree: override LDFLAGS += -lpthread
-msg-ring: override LDFLAGS += -lpthread
-recv-msgall: override LDFLAGS += -lpthread
-recv-msgall-stream: override LDFLAGS += -lpthread
-
install: $(test_targets) runtests.sh runtests-loop.sh
$(INSTALL) -D -d -m 755 $(datadir)/liburing-test/
$(INSTALL) -D -m 755 $(test_targets) $(datadir)/liburing-test/
diff --git a/test/a0908ae19763-test.c b/test/a0908ae19763.c
index 00cb559..00cb559 100644
--- a/test/a0908ae19763-test.c
+++ b/test/a0908ae19763.c
diff --git a/test/a4c0b3decb33-test.c b/test/a4c0b3decb33.c
index 34b0af2..34b0af2 100644
--- a/test/a4c0b3decb33-test.c
+++ b/test/a4c0b3decb33.c
diff --git a/test/b19062a56726-test.c b/test/b19062a56726.c
index 6a0f686..6a0f686 100644
--- a/test/b19062a56726-test.c
+++ b/test/b19062a56726.c
diff --git a/test/b5837bd5311d-test.c b/test/b5837bd5311d.c
index 57a2b58..57a2b58 100644
--- a/test/b5837bd5311d-test.c
+++ b/test/b5837bd5311d.c
diff --git a/test/ce593a6c480a-test.c b/test/ce593a6c480a.c
index 47de128..47de128 100644
--- a/test/ce593a6c480a-test.c
+++ b/test/ce593a6c480a.c
diff --git a/test/d4ae271dfaae-test.c b/test/d4ae271dfaae.c
index 397b94b..397b94b 100644
--- a/test/d4ae271dfaae-test.c
+++ b/test/d4ae271dfaae.c
diff --git a/test/d77a67ed5f27-test.c b/test/d77a67ed5f27.c
index e56fdcd..e56fdcd 100644
--- a/test/d77a67ed5f27-test.c
+++ b/test/d77a67ed5f27.c
diff --git a/test/drop-submit.c b/test/drop-submit.c
index 72e44d9..7b15f26 100644
--- a/test/drop-submit.c
+++ b/test/drop-submit.c
@@ -35,6 +35,7 @@ static int test(struct io_uring *ring, int expect_drops)
}
io_uring_prep_read(sqe, 128, buf, sizeof(buf), 0);
+ sqe->ioprio = (short) -1;
}
diff --git a/test/eeed8b54e0df-test.c b/test/eeed8b54e0df.c
index 62f6f45..62f6f45 100644
--- a/test/eeed8b54e0df-test.c
+++ b/test/eeed8b54e0df.c
diff --git a/test/fc2a85cb02ef-test.c b/test/fc2a85cb02ef.c
index bdc3c48..bdc3c48 100644
--- a/test/fc2a85cb02ef-test.c
+++ b/test/fc2a85cb02ef.c
diff --git a/test/fixed-reuse.c b/test/fixed-reuse.c
new file mode 100644
index 0000000..4cd8e37
--- /dev/null
+++ b/test/fixed-reuse.c
@@ -0,0 +1,160 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Description: link <open file><read from file><close file> with an existing
+ * file present in the opened slot, verifying that we get the new file
+ * rather than the old one.
+ *
+ */
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "liburing.h"
+#include "helpers.h"
+
+#define MAX_FILES 8
+#define FNAME1 ".slot.reuse.1"
+#define FNAME2 ".slot.reuse.2"
+#define PAT1 0xaa
+#define PAT2 0x55
+#define BSIZE 4096
+
+static int test(struct io_uring *ring)
+{
+ struct io_uring_cqe *cqe;
+ struct io_uring_sqe *sqe;
+ char buf[BSIZE];
+ int ret, i;
+
+ /* open FNAME1 in slot 0 */
+ sqe = io_uring_get_sqe(ring);
+ io_uring_prep_openat_direct(sqe, AT_FDCWD, FNAME1, O_RDONLY, 0, 0);
+ sqe->user_data = 1;
+
+ ret = io_uring_submit(ring);
+ if (ret != 1) {
+ fprintf(stderr, "sqe submit failed: %d\n", ret);
+ goto err;
+ }
+
+ ret = io_uring_wait_cqe(ring, &cqe);
+ if (ret < 0) {
+ fprintf(stderr, "wait completion %d\n", ret);
+ goto err;
+ }
+ if (cqe->res != 0) {
+ fprintf(stderr, "open res %d\n", ret);
+ goto err;
+ }
+ io_uring_cqe_seen(ring, cqe);
+
+ /*
+ * Now open FNAME2 in that same slot, verifying we get data from
+ * FNAME2 and not FNAME1.
+ */
+ sqe = io_uring_get_sqe(ring);
+ io_uring_prep_openat_direct(sqe, AT_FDCWD, FNAME2, O_RDONLY, 0, 0);
+ sqe->flags |= IOSQE_IO_LINK;
+ sqe->user_data = 2;
+
+ sqe = io_uring_get_sqe(ring);
+ io_uring_prep_read(sqe, 0, buf, sizeof(buf), 0);
+ sqe->flags |= IOSQE_FIXED_FILE;
+ sqe->flags |= IOSQE_IO_LINK;
+ sqe->user_data = 3;
+
+ sqe = io_uring_get_sqe(ring);
+ io_uring_prep_close_direct(sqe, 0);
+ sqe->user_data = 4;
+
+ ret = io_uring_submit(ring);
+ if (ret != 3) {
+ fprintf(stderr, "sqe submit failed: %d\n", ret);
+ goto err;
+ }
+
+ for (i = 0; i < 3; i++) {
+ ret = io_uring_wait_cqe(ring, &cqe);
+ if (ret < 0) {
+ fprintf(stderr, "wait completion %d\n", ret);
+ goto err;
+ }
+ switch (cqe->user_data) {
+ case 2:
+ if (cqe->res) {
+ fprintf(stderr, "bad open %d\n", cqe->res);
+ goto err;
+ }
+ break;
+ case 3:
+ if (cqe->res != sizeof(buf)) {
+ fprintf(stderr, "bad read %d\n", cqe->res);
+ goto err;
+ }
+ break;
+ case 4:
+ if (cqe->res) {
+ fprintf(stderr, "bad close %d\n", cqe->res);
+ goto err;
+ }
+ break;
+ }
+ io_uring_cqe_seen(ring, cqe);
+ }
+
+ for (i = 0; i < sizeof(buf); i++) {
+ if (buf[i] == PAT2)
+ continue;
+ fprintf(stderr, "Bad pattern %x at %d\n", buf[i], i);
+ goto err;
+ }
+
+ return 0;
+err:
+ return 1;
+}
+
+int main(int argc, char *argv[])
+{
+ struct io_uring ring;
+ struct io_uring_params p = { };
+ int ret, files[MAX_FILES];
+
+ if (argc > 1)
+ return 0;
+
+ ret = io_uring_queue_init_params(8, &ring, &p);
+ if (ret) {
+ fprintf(stderr, "ring setup failed: %d\n", ret);
+ return 1;
+ }
+ if (!(p.features & IORING_FEAT_CQE_SKIP))
+ return 0;
+
+ memset(files, -1, sizeof(files));
+ ret = io_uring_register_files(&ring, files, ARRAY_SIZE(files));
+ if (ret) {
+ fprintf(stderr, "Failed registering files\n");
+ return 1;
+ }
+
+ t_create_file_pattern(FNAME1, 4096, PAT1);
+ t_create_file_pattern(FNAME2, 4096, PAT2);
+
+ ret = test(&ring);
+ if (ret) {
+ fprintf(stderr, "test failed\n");
+ goto err;
+ }
+
+ unlink(FNAME1);
+ unlink(FNAME2);
+ return 0;
+err:
+ unlink(FNAME1);
+ unlink(FNAME2);
+ return 1;
+}
diff --git a/test/helpers.c b/test/helpers.c
index 975e7cb..491822e 100644
--- a/test/helpers.c
+++ b/test/helpers.c
@@ -49,14 +49,14 @@ void *t_calloc(size_t nmemb, size_t size)
/*
* Helper for creating file and write @size byte buf with 0xaa value in the file.
*/
-void t_create_file(const char *file, size_t size)
+static void __t_create_file(const char *file, size_t size, char pattern)
{
ssize_t ret;
char *buf;
int fd;
buf = t_malloc(size);
- memset(buf, 0xaa, size);
+ memset(buf, pattern, size);
fd = open(file, O_WRONLY | O_CREAT, 0644);
assert(fd >= 0);
@@ -68,6 +68,16 @@ void t_create_file(const char *file, size_t size)
assert(ret == size);
}
+void t_create_file(const char *file, size_t size)
+{
+ __t_create_file(file, size, 0xaa);
+}
+
+void t_create_file_pattern(const char *file, size_t size, char pattern)
+{
+ __t_create_file(file, size, pattern);
+}
+
/*
* Helper for creating @buf_num number of iovec
* with @buf_size bytes buffer of each iovec.
diff --git a/test/helpers.h b/test/helpers.h
index 7526d46..d0beb93 100644
--- a/test/helpers.h
+++ b/test/helpers.h
@@ -41,6 +41,12 @@ void *t_calloc(size_t nmemb, size_t size);
void t_create_file(const char *file, size_t size);
/*
+ * Helper for creating file and write @size byte buf with @pattern value in
+ * the file.
+ */
+void t_create_file_pattern(const char *file, size_t size, char pattern);
+
+/*
* Helper for creating @buf_num number of iovec
* with @buf_size bytes buffer of each iovec.
*/
diff --git a/test/submit-link-fail.c b/test/submit-link-fail.c
index a12bdae..45f6976 100644
--- a/test/submit-link-fail.c
+++ b/test/submit-link-fail.c
@@ -56,10 +56,12 @@ static int test_underprep_fail(bool hardlink, bool drain, bool link_last,
for (i = 0; i < link_size; i++) {
sqe = io_uring_get_sqe(&ring);
- if (i == fail_idx)
+ if (i == fail_idx) {
io_uring_prep_read(sqe, invalid_fd, buffer, 1, 0);
- else
+ sqe->ioprio = (short) -1;
+ } else {
io_uring_prep_nop(sqe);
+ }
if (i != link_size - 1 || !link_last)
sqe->flags |= link_flags;