This patch adds support for testing FUSE-over-io_uring. It can be
enabled by setting the environment variable FUSE_OVER_IO_URING=1.

    $ FUSE_OVER_IO_URING=1 ./check -fuse

Additionally, the unmount detection logic is switched from `df` to
`mount`. Using `df` triggers `statfs()`, which attempts to communicate
with the FUSE daemon. During test teardown (when the daemon is being
killed), this often fails or returns stale data, causing the test to
misjudge the mount status.

Suggested-by: Kevin Wolf <[email protected]>
Suggested-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Brian Song <[email protected]>
---
 tests/qemu-iotests/check     |  2 ++
 tests/qemu-iotests/common.rc | 47 +++++++++++++++++++++++++-----------
 2 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 545f9ec7bd..c6fa0f9e3d 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -94,6 +94,8 @@ def make_argparser() -> argparse.ArgumentParser:
         mg.add_argument('-' + fmt, dest='imgfmt', action='store_const',
                         const=fmt, help=f'test {fmt}')

+    # To test FUSE-over-io_uring, set the environment variable
+    # FUSE_OVER_IO_URING=1. This applies only when using the 'fuse' protocol
     protocol_list = ['file', 'rbd', 'nbd', 'ssh', 'nfs', 'fuse']
     g_prt = p.add_argument_group(
         '  image protocol options',
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index e977cb4eb6..a3e0ccb3d2 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -546,10 +546,37 @@ _make_test_img()
         # iotests.  The default allow-other=auto has the downside of printing a
         # fusermount error on its first attempt if allow_other is not
         # permissible, which we would need to filter.
-        QSD_NEED_PID=y $QSD \
-              --blockdev 
file,node-name=export-node,filename=$img_name,discard=unmap \
-              --export 
fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=on,allow-other=off
 \
-              &
+        if [ -n "$FUSE_OVER_IO_URING" ]; then
+            # The current Linux kernel requires registering `nr_cpu` Ring 
Queues
+            # when FUSE-over-io_uring is enabled. Here, we set half of the
+            # Ring Queues to FUSE Queues (`nr_iothreads`) to test the queue
+            # distribution feature.
+            # See the comments in fuse.c regarding the round-robin distribution
+            # between Ring Queues and FUSE Queues.
+            nr_cpu=$(nproc 2>/dev/null || echo 1)
+            nr_iothreads=$((nr_cpu / 2))
+            if [ $nr_iothreads -lt 1 ]; then
+                nr_iothreads=1
+            fi
+
+            iothread_args=""
+            iothread_export_args=""
+            for ((i=0; i<$nr_iothreads; i++)); do
+                iothread_args="$iothread_args --object iothread,id=iothread$i"
+                
iothread_export_args="$iothread_export_args,iothread.$i=iothread$i"
+            done
+
+            QSD_NEED_PID=y $QSD \
+                    $iothread_args \
+                    --blockdev 
file,node-name=export-node,filename=$img_name,discard=unmap \
+                    --export 
fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=on,allow-other=off,io-uring=on$iothread_export_args
 \
+                &
+        else
+            QSD_NEED_PID=y $QSD \
+                --blockdev 
file,node-name=export-node,filename=$img_name,discard=unmap \
+                --export 
fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=on,allow-other=off
 \
+                &
+        fi

         pidfile="$QEMU_TEST_DIR/qemu-storage-daemon.pid"

@@ -595,16 +622,8 @@ _rm_test_img()
         # Wait until the mount is gone
         timeout=10 # *0.5 s
         while true; do
-            # Will show the mount point; if the mount is still there,
-            # it will be $img.
-            df_output=$(df "$img" 2>/dev/null)
-
-            # But df may also show an error ("Transpoint endpoint not
-            # connected"), so retry in such cases
-            if [ -n "$df_output" ]; then
-                if ! echo "$df_output" | grep -q "$img"; then
-                    break
-                fi
+            if ! mount | grep -q "$img"; then
+                break
             fi

             sleep 0.5
--
2.43.0


Reply via email to