xfs/419: remove irrelevant swapfile test
[xfstests-dev.git] / tests / xfs / 208
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. 208
6 #
7 # Ensure that the effective cow extent allocation size hint is the maximum of
8 # the cowextsize and extsize inode fields.
9 # - Create two reflinked files.  Set extsz hint on second file to $blocksize
10 #   and cowextsize hint to 1MB.
11 # - Buffered write to random offsets to scatter CoW reservations.
12 # - Rewrite the whole file to use up reservations.
13 # - Check the number of extents.
14 # - Repeat, but with extsz = 1MB and cowextsz = $blocksize.
15 #
16 seq=`basename $0`
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
19
20 here=`pwd`
21 tmp=/tmp/$$
22 status=1    # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 _cleanup()
26 {
27     cd /
28     rm -rf $tmp.*
29 }
30
31 # get standard environment, filters and checks
32 . ./common/rc
33 . ./common/filter
34 . ./common/reflink
35
36 # real QA test starts here
37 _supported_fs xfs
38 _require_scratch_reflink
39 _require_cp_reflink
40 _require_xfs_io_command "fiemap"
41 _require_xfs_io_command "cowextsize"
42
43 rm -f $seqres.full
44
45 echo "Format and mount"
46 _scratch_mkfs > $seqres.full 2>&1
47 _scratch_mount >> $seqres.full 2>&1
48
49 testdir=$SCRATCH_MNT/test-$seq
50 mkdir $testdir
51
52 blksz=65536
53 nr=128
54 filesize=$((blksz * nr))
55 bufnr=16
56 bufsize=$((blksz * bufnr))
57
58 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
59 real_blksz=$(_get_file_block_size $testdir)
60 internal_blks=$((filesize / real_blksz))
61
62 echo "Create the original files"
63 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $((filesize + 1))" $testdir/file1 >> $seqres.full
64
65 $XFS_IO_PROG -f -c "extsize $real_blksz" $testdir/file2
66 $XFS_IO_PROG -f -c "cowextsize $bufsize" $testdir/file2
67 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
68 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
69
70 $XFS_IO_PROG -f -c "extsize $bufsize" $testdir/file3
71 $XFS_IO_PROG -f -c "cowextsize $real_blksz" $testdir/file3
72 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
73 _scratch_cycle_mount
74
75 echo "Compare files"
76 md5sum $testdir/file1 | _filter_scratch
77 md5sum $testdir/file2 | _filter_scratch
78 md5sum $testdir/file3 | _filter_scratch
79
80 echo "CoW and unmount"
81 echo "extsize" >> $seqres.full
82 $XFS_IO_PROG -f -c "extsize" $testdir/file2 >> $seqres.full
83 echo "cowextsize" >> $seqres.full
84 $XFS_IO_PROG -f -c "cowextsize" $testdir/file2 >> $seqres.full
85
86 $XFS_IO_PROG -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full
87 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $real_blksz 0 $((filesize + 1))" -c "fdatasync" $testdir/file2 >> $seqres.full
88
89 echo "extsize" >> $seqres.full
90 $XFS_IO_PROG -f -c "extsize" $testdir/file3 >> $seqres.full
91 echo "cowextsize" >> $seqres.full
92 $XFS_IO_PROG -f -c "cowextsize" $testdir/file3 >> $seqres.full
93
94 $XFS_IO_PROG -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $filesize" -c "fdatasync" $testdir/file3 >> $seqres.full
95 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $real_blksz 0 $((filesize + 1))" -c "fdatasync" $testdir/file3 >> $seqres.full
96 _scratch_cycle_mount
97
98 echo "Compare files"
99 md5sum $testdir/file1 | _filter_scratch
100 md5sum $testdir/file2 | _filter_scratch
101 md5sum $testdir/file3 | _filter_scratch
102
103 echo "Check extent counts"
104 old_extents=$(_count_extents $testdir/file1)
105 new_extents=$(_count_extents $testdir/file2)
106
107 echo "old extents: $old_extents" >> $seqres.full
108 echo "new extents: $new_extents" >> $seqres.full
109 echo "maximum extents: $internal_blks" >> $seqres.full
110 test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
111         || echo "file2 badly fragmented"
112
113 new_extents=$(_count_extents $testdir/file3)
114
115 echo "old extents: $old_extents" >> $seqres.full
116 echo "new extents: $new_extents" >> $seqres.full
117 echo "maximum extents: $internal_blks" >> $seqres.full
118 test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
119         || echo "file3 badly fragmented"
120
121 # success, all done
122 status=0
123 exit