generic/520: Remove sync in clean_dir
[xfstests-dev.git] / tests / generic / 252
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. 252
6 #
7 # Create an unwritten extent, set up dm-error, try an AIO DIO write, then
8 # make sure we can't read back old disk contents.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1    # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     cd /
22     rm -rf $tmp.* $testdir $TEST_DIR/moo
23     _dmerror_cleanup
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/dmerror
30
31 # real QA test starts here
32 _supported_os Linux
33 _require_scratch
34 _require_dm_target error
35 _require_xfs_io_command "falloc"
36 # This test uses "dm" without taking into account the data could be on
37 # realtime subvolume, thus the test will fail with rtinherit=1
38 _require_no_rtinherit
39 _require_aiodio "aiocp"
40 AIO_TEST="$here/src/aio-dio-regress/aiocp"
41
42 rm -f $seqres.full
43
44
45 fssize=$((196 * 1048576))
46 echo "Format and mount"
47 $XFS_IO_PROG -d -c "pwrite -S 0x69 -b 1048576 0 $fssize" $SCRATCH_DEV >> $seqres.full
48 _scratch_mkfs_sized $fssize > $seqres.full 2>&1
49 _dmerror_init
50 _dmerror_mount >> $seqres.full 2>&1
51 _dmerror_unmount
52 _dmerror_mount
53
54 testdir=$SCRATCH_MNT/test-$seq
55 mkdir $testdir
56
57 blksz=65536
58 nr=640
59 bufnr=128
60 filesize=$((blksz * nr))
61 bufsize=$((blksz * bufnr))
62 alignment=`_min_dio_alignment $TEST_DEV`
63
64 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 5 / 4))
65
66 echo "Create the original files"
67 $XFS_IO_PROG -f -c "falloc 0 $filesize" $testdir/file2 >> $seqres.full
68 _dmerror_unmount
69 _dmerror_mount
70
71 echo "Compare files"
72 md5sum $testdir/file2 | _filter_scratch
73
74 echo "CoW and unmount"
75 $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
76 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
77 sync
78 _dmerror_load_error_table
79 $AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
80 _dmerror_load_working_table
81 _dmerror_unmount
82 _dmerror_mount
83
84 echo "Compare files"
85 md5sum $testdir/file2 | _filter_scratch
86
87 echo "Check for damage"
88 _dmerror_unmount
89 _dmerror_cleanup
90 _repair_scratch_fs >> $seqres.full
91
92 # success, all done
93 status=0
94 exit