Whamcloud - gitweb
LU-16341 quota: fix panic in qmt_site_recalc_cb
[fs/lustre-release.git] / lustre / tests / sanity-pcc.sh
index 9ce8b47..8dc3ada 100644 (file)
@@ -22,7 +22,7 @@ HSMTOOL_ARCHIVE_FORMAT=v1
 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
 
 . $LUSTRE/tests/test-framework.sh
-init_test_env $@
+init_test_env "$@"
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 init_logging
 
@@ -1510,13 +1510,18 @@ test_101a() {
        echo "creating user namespace for $RUNAS_ID"
        # Create a mount and user namespace with this command, and leave the
        # process running so we can do the rest of our steps
-       do_facet $SINGLEAGT $RUNAS unshare -Um sleep 600 &
-       # Let the child start...
-       sleep 2
-       # Get the sleep PID so we can find its namespace and kill it later
-       PID=$(do_facet $SINGLEAGT pgrep sleep)
+       local start=$SECONDS
+       local PID=$(do_facet $SINGLEAGT \
+                   "$RUNAS unshare -Um sleep 600 &>/dev/null & echo \\\$!")
+       local elapsed=$((SECONDS - start))
+       local count=0
+
+       do_facet $SINGLEAGT ps auxww | grep sleep
+       echo "Created NS: child (sleep) pid=$PID in $elapsed seconds"
+       [[ -n "$PID" ]] || error "remote sleep start failed"
        stack_trap "do_facet $SINGLEAGT kill -9 $PID" EXIT
-       echo "Created NS: child (sleep) pid $PID"
+       (( elapsed < 300 )) || error "remote sleep took $elapsed sec to start"
+
        # Map 'RUNAS' to root in the namespace, so it has rights to do whatever
        # This is handled by '-r' in unshare in newer versions
        do_facet $SINGLEAGT $RUNAS newuidmap $PID 0 $RUNAS_ID 1 ||
@@ -1610,6 +1615,47 @@ test_101a() {
 }
 run_test 101a "Test auto attach in mount namespace (simulated container)"
 
+test_102() {
+       grep -q io_uring_setup /proc/kallsyms ||
+               skip "Client OS does not support io_uring I/O engine"
+       io_uring_probe || skip "kernel does not support io_uring fully"
+
+       $LCTL get_param -n mdc.*.connect_flags | grep -q pcc_ro ||
+               skip "Server does not support PCC-RO"
+
+       which fio || skip_env "no fio installed"
+       fio --enghelp | grep -q io_uring ||
+               skip_env "fio does not support io_uring I/O engine"
+
+       local loopfile="$TMP/$tfile"
+       local mntpt="/mnt/pcc.$tdir"
+       local hsm_root="$mntpt/$tdir"
+       local file=$DIR/$tfile
+
+       setup_loopdev client $loopfile $mntpt 60
+       mkdir $hsm_root || error "mkdir $hsm_root failed"
+       setup_pcc_mapping client \
+               "projid={0}\ roid=$HSM_ARCHIVE_NUMBER\ pccro=1"
+       do_facet $SINGLEAGT $LCTL set_param llite.*.pcc_async_threshold=0
+
+       local ioengine="io_uring"
+       local numjobs=2
+       local size=10M
+
+       do_facet $SINGLEAGT fio --name=seqwrite --ioengine=$ioengine    \
+               --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs   \
+               --iodepth=64 --size=$size --filename=$file --rw=write ||
+               error "fio seqwrite $file failed"
+
+       # Read the file will trigger the buffered read from Lustre OSTs and
+       # write to PCC copy as @pcc_async_threshold is set with 0.
+       do_facet $SINGLEAGT fio --name=seqread --ioengine=$ioengine     \
+               --bs=$PAGE_SIZE --direct=1 --numjobs=$numjobs   \
+               --iodepth=64 --size=$size --filename=$file --rw=read ||
+               error "fio seqread $file failed"
+}
+run_test 102 "PCC-RO should not hange for io_uring I/O engine"
+
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status