xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 239
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. 239
6 #
7 # Test AIO DIO CoW behavior.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick clone
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15     cd /
16     rm -rf $tmp.* $TEST_DIR/moo
17 }
18
19 # Import common functions.
20 . ./common/filter
21 . ./common/reflink
22
23 # real QA test starts here
24 _supported_fs xfs
25 _require_scratch_reflink
26 _require_cp_reflink
27 _require_xfs_io_command "cowextsize"
28 _require_aiodio "aiocp"
29
30 echo "Format and mount"
31 _scratch_mkfs > $seqres.full 2>&1
32 _scratch_mount >> $seqres.full 2>&1
33
34 testdir=$SCRATCH_MNT/test-$seq
35 mkdir $testdir
36
37 blksz=65536
38 nr=640
39 bufnr=128
40 filesize=$((blksz * nr))
41 bufsize=$((blksz * bufnr))
42 filesize=$filesize
43 bufsize=$bufsize
44 alignment=`_min_dio_alignment $TEST_DEV`
45
46 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
47
48 echo "Create the original files"
49 $XFS_IO_PROG -c "cowextsize $((bufsize * 2))" $testdir
50 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
51 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
52 _scratch_cycle_mount
53
54 echo "Compare files"
55 md5sum $testdir/file1 | _filter_scratch
56 md5sum $testdir/file2 | _filter_scratch
57
58 echo "CoW and unmount"
59 $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
60 sync
61 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
62 $AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
63 _scratch_cycle_mount
64
65 echo "Compare files"
66 md5sum $testdir/file1 | _filter_scratch
67 md5sum $testdir/file2 | _filter_scratch
68
69 echo "Check for damage"
70 umount $SCRATCH_MNT
71 _repair_scratch_fs >> $seqres.full
72
73 # success, all done
74 status=0
75 exit