2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Test AIO CoW behavior when the write temporarily fails.
10 _begin_fstest auto quick clone eio
12 # Override the default cleanup function.
16 rm -rf $tmp.* $TEST_DIR/moo
20 # Import common functions.
25 # real QA test starts here
27 _require_scratch_reflink
29 _require_dm_target error
30 _require_xfs_io_command "cowextsize"
31 _require_aiodio "aiocp"
32 AIO_TEST="$here/src/aio-dio-regress/aiocp"
34 echo "Format and mount"
35 _scratch_mkfs > $seqres.full 2>&1
37 _dmerror_mount >> $seqres.full 2>&1
39 testdir=$SCRATCH_MNT/test-$seq
45 filesize=$((blksz * nr))
46 bufsize=$((blksz * bufnr))
50 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
52 echo "Create the original files"
53 $XFS_IO_PROG -c "cowextsize $((bufsize * 2))" $testdir
54 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
55 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
60 md5sum $testdir/file1 | _filter_scratch
61 md5sum $testdir/file2 | _filter_scratch
63 echo "CoW and unmount"
64 $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
65 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
67 _dmerror_load_error_table
68 $AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
69 $XFS_IO_PROG -c "fdatasync" $testdir/file2
70 _dmerror_load_working_table
75 md5sum $testdir/file1 | _filter_scratch
76 md5sum $testdir/file2 | _filter_scratch
78 echo "Check for damage"
81 _repair_scratch_fs >> $seqres.full