fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / xfs / 240
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 240
6 #
7 # Test AIO CoW behavior when the write temporarily fails.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.* $TEST_DIR/moo
22     _dmerror_cleanup
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/reflink
29 . ./common/dmerror
30
31 # real QA test starts here
32 _supported_os Linux
33 _supported_fs xfs
34 _require_scratch_reflink
35 _require_cp_reflink
36 _require_dm_target error
37 _require_xfs_io_command "cowextsize"
38 _require_aiodio "aiocp"
39 AIO_TEST="src/aio-dio-regress/aiocp"
40
41 rm -f $seqres.full
42
43
44 echo "Format and mount"
45 _scratch_mkfs > $seqres.full 2>&1
46 _dmerror_init
47 _dmerror_mount >> $seqres.full 2>&1
48
49 testdir=$SCRATCH_MNT/test-$seq
50 mkdir $testdir
51
52 blksz=65536
53 nr=640
54 bufnr=128
55 filesize=$((blksz * nr))
56 bufsize=$((blksz * bufnr))
57 filesize=$filesize
58 bufsize=$bufsize
59
60 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
61
62 echo "Create the original files"
63 $XFS_IO_PROG -c "cowextsize $((bufsize * 2))" $testdir
64 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
65 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
66 _dmerror_unmount
67 _dmerror_mount
68
69 echo "Compare files"
70 md5sum $testdir/file1 | _filter_scratch
71 md5sum $testdir/file2 | _filter_scratch
72
73 echo "CoW and unmount"
74 $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
75 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
76 sync
77 _dmerror_load_error_table
78 $AIO_TEST -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
79 $XFS_IO_PROG -c "fdatasync" $testdir/file2
80 _dmerror_load_working_table
81 _dmerror_unmount
82 _dmerror_mount
83
84 echo "Compare files"
85 md5sum $testdir/file1 | _filter_scratch
86 md5sum $testdir/file2 | _filter_scratch
87
88 echo "Check for damage"
89 _dmerror_unmount
90 _dmerror_cleanup
91 _repair_scratch_fs >> $seqres.full
92
93 # success, all done
94 status=0
95 exit