]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/rc: notrun if io_uring is disabled by sysctl
authorZorro Lang <zlang@kernel.org>
Mon, 11 Mar 2024 16:20:29 +0000 (00:20 +0800)
committerZorro Lang <zlang@kernel.org>
Tue, 12 Mar 2024 03:39:52 +0000 (11:39 +0800)
If kernel supports io_uring, userspace still can/might disable that
supporting by set /proc/sys/kernel/io_uring_disabled=2. Let's notrun
if io_uring is disabled by that way.

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
README
common/rc
src/feature.c

diff --git a/README b/README
index c46690c4eabb0a6a0ffa1df3f495320638f71813..477136deb0d01a2fb5993d20699c776e0103a228 100644 (file)
--- a/README
+++ b/README
@@ -142,6 +142,12 @@ Setup Environment
    https://www.lscdweb.com/registered/udf_verifier.html, then copy the udf_test
    binary to xfstests/src/.
 
+8. (optional) To do io_uring related testing, please make sure below 3 things:
+     1) kernel is built with CONFIG_IO_URING=y
+     2) sysctl -w kernel.io_uring_disabled=0 (or set it to 2 to disable io_uring
+        testing dynamically if kernel supports)
+     3) install liburing development package contains liburing.h before building
+        fstests
 
 For example, to run the tests with loopback partitions:
 
index f619a0ebd5a1f5993b338cccb816aca45c2ccf0a..10f4817ad4518f174951df68b3f022c1fc1e41a0 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2334,6 +2334,8 @@ _require_aiodio()
 # this test requires that the kernel supports IO_URING
 _require_io_uring()
 {
+       local n
+
        $here/src/feature -R
        case $? in
        0)
@@ -2341,6 +2343,14 @@ _require_io_uring()
        1)
                _notrun "kernel does not support IO_URING"
                ;;
+       2)
+               n=$(sysctl -n kernel.io_uring_disabled 2>/dev/null)
+               if [ "$n" != "0" ];then
+                       _notrun "io_uring isn't enabled totally by admin"
+               else
+                       _fail "unexpected EPERM error, please check selinux or something else"
+               fi
+               ;;
        *)
                _fail "unexpected error testing for IO_URING support"
                ;;
index 941f96fb309710b17cba398252d35a952620e035..7e474ce558e623113c887f9a85e1d1bf9498b6aa 100644 (file)
@@ -232,15 +232,20 @@ check_uring_support(void)
        int err;
 
        err = io_uring_queue_init(1, &ring, 0);
-       if (err == 0)
+       switch (err) {
+       case 0:
                return 0;
-
-       if (err == -ENOSYS) /* CONFIG_IO_URING=n */
+       case -ENOSYS:
+               /* CONFIG_IO_URING=n */
                return 1;
-
-       fprintf(stderr, "unexpected error from io_uring_queue_init(): %s\n",
-               strerror(-err));
-       return 2;
+       case -EPERM:
+               /* Might be due to sysctl io_uring_disabled isn't 0 */
+               return 2;
+       default:
+               fprintf(stderr, "unexpected error from io_uring_queue_init(): %s\n",
+                       strerror(-err));
+               return 100;
+       }
 #else
        /* liburing is unavailable, assume IO_URING is unsupported */
        return 1;