public inbox for [email protected]
 help / color / mirror / Atom feed
From: Zorro Lang <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH v2 1/3] fsstress: check io_uring_queue_init errno properly
Date: Tue, 12 Mar 2024 00:20:27 +0800	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

As the manual of io_uring_queue_init says "io_uring_queue_init(3)
returns 0 on success and -errno on failure". We should check if the
return value is -ENOSYS, not the errno.

Fixes: d15b1721f284 ("ltp/fsstress: don't fail on io_uring ENOSYS")
Signed-off-by: Zorro Lang <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Reviewed-by: Jeff Moyer <[email protected]>
---
 ltp/fsstress.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 63c75767..4fc50efb 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -763,13 +763,17 @@ int main(int argc, char **argv)
 #ifdef URING
 			have_io_uring = true;
 			/* If ENOSYS, just ignore uring, other errors are fatal. */
-			if (io_uring_queue_init(URING_ENTRIES, &ring, 0)) {
-				if (errno == ENOSYS) {
-					have_io_uring = false;
-				} else {
-					fprintf(stderr, "io_uring_queue_init failed\n");
-					exit(1);
-				}
+			c = io_uring_queue_init(URING_ENTRIES, &ring, 0);
+			switch(c){
+			case 0:
+				have_io_uring = true;
+				break;
+			case -ENOSYS:
+				have_io_uring = false;
+				break;
+			default:
+				fprintf(stderr, "io_uring_queue_init failed\n");
+				exit(1);
 			}
 #endif
 			for (i = 0; keep_looping(i, loops); i++)
-- 
2.43.0


  reply	other threads:[~2024-03-11 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11 16:20 [PATCH v2 0/3] fstests: fix io_uring testing Zorro Lang
2024-03-11 16:20 ` Zorro Lang [this message]
2024-03-11 16:20 ` [PATCH v2 2/3] fsstress: bypass io_uring testing if io_uring_queue_init returns EPERM Zorro Lang
2024-03-11 16:20 ` [PATCH v2 3/3] common/rc: notrun if io_uring is disabled by sysctl Zorro Lang
2024-03-11 16:29   ` Darrick J. Wong

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] \
    [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