From: [email protected]
To: [email protected]
Subject: SQPOLL behaviour with openat
Date: Sat, 4 Jan 2020 17:22:11 +0100 [thread overview]
Message-ID: <[email protected]> (raw)
Hello,
I am trying to understand SQPOLL behaviour using liburing. I modified the
test in liburing (see below). The test is failing when we use `openat`
with SQPOLL:
cqe res -9
test_io failed 0/0/1/0/0
Is `openat` supported with SQPOLL? If not I would expect -EINVAL as a
return value, but maybe I'm missing something.
note: I also tested without io_uring_register_files call.
--
William
---
test/read-write.c | 47 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 44 insertions(+), 3 deletions(-)
diff --git a/test/read-write.c b/test/read-write.c
index d150f44..05baf0f 100644
--- a/test/read-write.c
+++ b/test/read-write.c
@@ -58,7 +58,7 @@ static int test_io(const char *file, int write, int buffered, int sqthread,
struct io_uring_cqe *cqe;
struct io_uring ring;
int open_flags, ring_flags;
- int i, fd, ret;
+ int i, dirfd, fd, use_fd, ret;
#ifdef VERBOSE
fprintf(stdout, "%s: start %d/%d/%d/%d/%d: ", __FUNCTION__, write,
@@ -79,7 +79,7 @@ static int test_io(const char *file, int write, int buffered, int sqthread,
if (!buffered)
open_flags |= O_DIRECT;
- fd = open(file, open_flags);
+ dirfd = open(".", O_RDONLY);
if (fd < 0) {
perror("file open");
goto err;
@@ -95,6 +95,46 @@ static int test_io(const char *file, int write, int buffered, int sqthread,
goto err;
}
+ use_fd = dirfd;
+ if (sqthread) {
+ ret = io_uring_register_files(&ring, &dirfd, 1);
+ if (ret) {
+ fprintf(stderr, "file reg failed: %d\n", ret);
+ goto err;
+ }
+ use_fd = 0;
+ }
+ sqe = io_uring_get_sqe(&ring);
+ if (!sqe) {
+ fprintf(stderr, "sqe get failed\n");
+ goto err;
+ }
+ io_uring_prep_openat(sqe, use_fd, file, open_flags, 0);
+ ret = io_uring_submit(&ring);
+ if (ret != 1) {
+ fprintf(stderr, "submit got %d\n", ret);
+ goto err;
+ }
+ ret = io_uring_wait_cqe(&ring, &cqe);
+ if (ret) {
+ fprintf(stderr, "wait_cqe=%d\n", ret);
+ goto err;
+ }
+ if (cqe->res < 0) {
+ fprintf(stderr, "cqe res %d\n", cqe->res);
+ goto err;
+ }
+ fd = cqe->res;
+ io_uring_cqe_seen(&ring, cqe);
+
+ if (sqthread) {
+ ret = io_uring_unregister_files(&ring);
+ if (ret) {
+ fprintf(stderr, "file unreg failed: %d\n", ret);
+ goto err;
+ }
+ }
+
if (fixed) {
ret = io_uring_register_buffers(&ring, vecs, BUFFERS);
if (ret) {
@@ -121,7 +161,7 @@ static int test_io(const char *file, int write, int buffered, int sqthread,
offset = BS * (rand() % BUFFERS);
if (write) {
int do_fixed = fixed;
- int use_fd = fd;
+ use_fd = fd;
if (sqthread)
use_fd = 0;
@@ -193,6 +233,7 @@ static int test_io(const char *file, int write, int buffered, int sqthread,
io_uring_queue_exit(&ring);
close(fd);
+ close(dirfd);
#ifdef VERBOSE
printf("PASS\n");
#endif
--
2.24.1
next reply other threads:[~2020-01-04 16:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-04 16:22 wdauchy [this message]
2020-01-04 16:28 ` SQPOLL behaviour with openat Jens Axboe
2020-01-04 16:41 ` William Dauchy
2020-01-04 17:41 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox