generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 330
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. 330
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 _require_scratch_reflink
25 _require_cp_reflink
26 _require_aiodio "aiocp"
27
28 echo "Format and mount"
29 _scratch_mkfs > $seqres.full 2>&1
30 _scratch_mount >> $seqres.full 2>&1
31
32 testdir=$SCRATCH_MNT/test-$seq
33 mkdir $testdir
34
35 blksz=65536
36 nr=640
37 bufnr=128
38 filesize=$((blksz * nr))
39 bufsize=$((blksz * bufnr))
40 alignment=`_min_dio_alignment $TEST_DEV`
41
42 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
43
44 echo "Create the original files"
45 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
46 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
47 _scratch_cycle_mount
48
49 echo "Compare files"
50 md5sum $testdir/file1 | _filter_scratch
51 md5sum $testdir/file2 | _filter_scratch
52
53 echo "CoW and unmount"
54 $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
55 sync
56 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $TEST_DIR/moo >> $seqres.full
57 $AIO_TEST -a $alignment -f DIRECT -b $bufsize $TEST_DIR/moo $testdir/file2 >> $seqres.full
58 _scratch_cycle_mount
59
60 echo "Compare files"
61 md5sum $testdir/file1 | _filter_scratch
62 md5sum $testdir/file2 | _filter_scratch
63
64 echo "Check for damage"
65 umount $SCRATCH_MNT
66 _repair_scratch_fs >> $seqres.full
67
68 # success, all done
69 status=0
70 exit