From: Pavel Begunkov <asml.silence@gmail.com> To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 1/1] tests/rsrc_tags: partial registration failure tags Date: Fri, 4 Apr 2025 16:54:03 +0100 [thread overview] Message-ID: <8791bcaf3c7d444724055a719c98903a83d7c731.1743782006.git.asml.silence@gmail.com> (raw) Make sure we don't post tags for a failed table registration. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> --- test/rsrc_tags.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/rsrc_tags.c b/test/rsrc_tags.c index e78cfe40..0f7d9b69 100644 --- a/test/rsrc_tags.c +++ b/test/rsrc_tags.c @@ -408,6 +408,53 @@ static int test_notag(void) return 0; } +static char buffer[16]; + +static int test_tagged_register_partial_fail(void) +{ + __u64 tags[2] = { 1, 2 }; + int fds[2] = { pipes[0], -1 }; + struct iovec iovec[2]; + struct io_uring ring; + int ret; + + iovec[0].iov_base = buffer; + iovec[0].iov_len = 1; + iovec[1].iov_base = (void *)1UL; + iovec[1].iov_len = 1; + + ret = io_uring_queue_init(1, &ring, 0); + if (ret) { + printf("ring setup failed\n"); + return 1; + } + + ret = io_uring_register_buffers_tags(&ring, iovec, tags, 2); + if (ret >= 0) { + fprintf(stderr, "io_uring_register_buffers_tags returned %i\n", ret); + return -EFAULT; + } + + if (!check_cq_empty(&ring)) { + fprintf(stderr, "stray buffer CQEs found\n"); + return -EFAULT; + } + + ret = io_uring_register_files_tags(&ring, fds, tags, 2); + if (ret >= 0) { + fprintf(stderr, "io_uring_register_files_tags returned %i\n", ret); + return -EFAULT; + } + + if (!check_cq_empty(&ring)) { + fprintf(stderr, "stray file CQEs found\n"); + return -EFAULT; + } + + io_uring_queue_exit(&ring); + return 0; +} + int main(int argc, char *argv[]) { int ring_flags[] = {0, IORING_SETUP_IOPOLL, IORING_SETUP_SQPOLL, @@ -426,6 +473,12 @@ int main(int argc, char *argv[]) return 1; } + ret = test_tagged_register_partial_fail(); + if (ret) { + printf("test_tagged_register_partial_fail() failed\n"); + return ret; + } + ret = test_notag(); if (ret) { printf("test_notag failed\n"); -- 2.48.1
WARNING: multiple messages have this Message-ID (diff)
From: Pavel Begunkov <asml.silence@gmail.com> To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 1/1] tests/rsrc_tags: partial registration failure tags Date: Fri, 4 Apr 2025 17:18:21 +0100 [thread overview] Message-ID: <8791bcaf3c7d444724055a719c98903a83d7c731.1743782006.git.asml.silence@gmail.com> (raw) Message-ID: <20250404161821.kfKsClHNyF4ydAhgjGN9M_0jYAtdXp0bCBcH6M751M4@z> (raw) Make sure we don't post tags for a failed table registration. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> --- test/rsrc_tags.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/rsrc_tags.c b/test/rsrc_tags.c index e78cfe40..0f7d9b69 100644 --- a/test/rsrc_tags.c +++ b/test/rsrc_tags.c @@ -408,6 +408,53 @@ static int test_notag(void) return 0; } +static char buffer[16]; + +static int test_tagged_register_partial_fail(void) +{ + __u64 tags[2] = { 1, 2 }; + int fds[2] = { pipes[0], -1 }; + struct iovec iovec[2]; + struct io_uring ring; + int ret; + + iovec[0].iov_base = buffer; + iovec[0].iov_len = 1; + iovec[1].iov_base = (void *)1UL; + iovec[1].iov_len = 1; + + ret = io_uring_queue_init(1, &ring, 0); + if (ret) { + printf("ring setup failed\n"); + return 1; + } + + ret = io_uring_register_buffers_tags(&ring, iovec, tags, 2); + if (ret >= 0) { + fprintf(stderr, "io_uring_register_buffers_tags returned %i\n", ret); + return -EFAULT; + } + + if (!check_cq_empty(&ring)) { + fprintf(stderr, "stray buffer CQEs found\n"); + return -EFAULT; + } + + ret = io_uring_register_files_tags(&ring, fds, tags, 2); + if (ret >= 0) { + fprintf(stderr, "io_uring_register_files_tags returned %i\n", ret); + return -EFAULT; + } + + if (!check_cq_empty(&ring)) { + fprintf(stderr, "stray file CQEs found\n"); + return -EFAULT; + } + + io_uring_queue_exit(&ring); + return 0; +} + int main(int argc, char *argv[]) { int ring_flags[] = {0, IORING_SETUP_IOPOLL, IORING_SETUP_SQPOLL, @@ -426,6 +473,12 @@ int main(int argc, char *argv[]) return 1; } + ret = test_tagged_register_partial_fail(); + if (ret) { + printf("test_tagged_register_partial_fail() failed\n"); + return ret; + } + ret = test_notag(); if (ret) { printf("test_notag failed\n"); -- 2.48.1
next reply other threads:[~2025-04-04 15:52 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-04-04 15:54 Pavel Begunkov [this message] 2025-04-04 16:10 ` [PATCH liburing 1/1] tests/rsrc_tags: partial registration failure tags Jens Axboe 2025-04-04 16:18 ` Pavel Begunkov 2025-04-04 16:21 ` Pavel Begunkov
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 \ --in-reply-to=8791bcaf3c7d444724055a719c98903a83d7c731.1743782006.git.asml.silence@gmail.com \ --to=asml.silence@gmail.com \ --cc=io-uring@vger.kernel.org \ /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: linkBe 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