[PATCH] btrfs/333: also exercise io_uring encoded write
Yang Xiuwei <[email protected]>
| Newsgroups | org.kernel.vger.linux-btrfs,org.kernel.vger.fstests |
|---|---|
| Message-ID | <[email protected]> |
btrfs_encoded_write already supports io_uring, but the test only wrote via ioctl. Also write via io_uring and verify each write with both ioctl and io_uring reads. Signed-off-by: Yang Xiuwei <[email protected]> --- common/btrfs | 36 ++++++++++++++++++++++++++++++++++++ tests/btrfs/333 | 37 +++++++++++++++++++++---------------- 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/common/btrfs b/common/btrfs index 30288f07..937cc49b 100644 --- a/common/btrfs +++ b/common/btrfs @@ -1073,3 +1073,39 @@ _require_btrfs_iouring_encoded_read() _notrun "btrfs io_uring encoded read failed with -EOPNOTSUPP" fi } + +_require_btrfs_iouring_encoded_write() +{ + local fn + local tmpfile + local datafile + local ret + + _require_command src/btrfs_encoded_write + + _scratch_mkfs &> /dev/null + _scratch_mount + + fn=`mktemp -p $SCRATCH_MNT` + tmpfile=`mktemp` + datafile=`mktemp` + + dd if=/dev/urandom of=$datafile bs=64 count=1 status=none + src/btrfs_encoded_write io_uring $fn 0 64 64 0 1 < $datafile > $tmpfile + ret=$? + + _scratch_unmount + rm -f $datafile + + if [[ $ret -ne 0 ]]; then + rm -f $tmpfile + _fail "btrfs_encoded_write failed" + fi + + read ret < $tmpfile + rm $tmpfile + + if [[ $ret == -95 ]]; then + _notrun "btrfs io_uring encoded write failed with -EOPNOTSUPP" + fi +} diff --git a/tests/btrfs/333 b/tests/btrfs/333 index 6214d7c5..463af5d2 100755 --- a/tests/btrfs/333 +++ b/tests/btrfs/333 @@ -4,7 +4,7 @@ # # FS QA Test No. btrfs/333 # -# Test btrfs encoded reads +# Test btrfs encoded reads and writes (ioctl and io_uring) . ./common/preamble _begin_fstest auto quick compress rw io_uring ioctl @@ -14,6 +14,7 @@ _begin_fstest auto quick compress rw io_uring ioctl _require_command src/btrfs_encoded_read _require_command src/btrfs_encoded_write _require_btrfs_iouring_encoded_read +_require_btrfs_iouring_encoded_write # Encoded writes are reject for inodes with the NODATASUM flag, so we must skip # the test if running with either the nodatasum or nodatacow (which implies # nodatasum) mount options. @@ -124,7 +125,7 @@ echo "$fn: btrfs encoded read had encryption of $encryption, expected 0" \ do_encoded_write() { local fn=$1 - local exp_ret=$2 + local type=$2 local len=$3 local unencoded_len=$4 local unencoded_offset=$5 @@ -133,9 +134,9 @@ do_encoded_write() local tmpfile=`mktemp` -echo "running btrfs_encoded_write ioctl $fn 0 $len $unencoded_len $unencoded_offset $compression < $data_file > $tmpfile" \ +echo "running btrfs_encoded_write $type $fn 0 $len $unencoded_len $unencoded_offset $compression < $data_file > $tmpfile" \ >>$seqres.full - src/btrfs_encoded_write ioctl $fn 0 $len $unencoded_len \ + src/btrfs_encoded_write $type $fn 0 $len $unencoded_len \ $unencoded_offset $compression < $data_file > $tmpfile if [[ $? -ne 0 ]]; then @@ -172,27 +173,31 @@ test_file() local unencoded_len=$3 local unencoded_offset=$4 local compression=$5 + local wtype - local tmpfile=`mktemp -p $SCRATCH_MNT` local randfile=`mktemp` dd if=/dev/urandom of=$randfile bs=$size count=1 status=none local md5=`md5sum $randfile | cut -d ' ' -f 1` - do_encoded_write $tmpfile $size $len $unencoded_len $unencoded_offset \ - $compression $randfile \ - || _fail "encoded write ioctl failed" + for wtype in ioctl io_uring; do + local tmpfile=`mktemp -p $SCRATCH_MNT` - rm $randfile + do_encoded_write $tmpfile $wtype $len $unencoded_len \ + $unencoded_offset $compression $randfile \ + || _fail "encoded write $wtype failed" - do_encoded_read $tmpfile ioctl $size $len $unencoded_len \ - $unencoded_offset $compression $md5 \ - || _fail "encoded read ioctl failed" - do_encoded_read $tmpfile io_uring $size $len $unencoded_len \ - $unencoded_offset $compression $md5 \ - || _fail "encoded read io_uring failed" + do_encoded_read $tmpfile ioctl $size $len $unencoded_len \ + $unencoded_offset $compression $md5 \ + || _fail "encoded read ioctl failed after $wtype write" + do_encoded_read $tmpfile io_uring $size $len $unencoded_len \ + $unencoded_offset $compression $md5 \ + || _fail "encoded read io_uring failed after $wtype write" - rm $tmpfile + rm $tmpfile + done + + rm $randfile } _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed" -- 2.25.1