4 # Test fragmentation after writing and dropping CoW extent hint reservation:
5 # - Create two reflinked files. Set extsz hint on second file.
6 # - Directio write to random offsets to scatter CoW reservations.
7 # - Unmount, remount, repeat (twice more).
8 # - Check the number of extents.
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
47 # real QA test starts here
50 _require_scratch_reflink
53 _require_xfs_io_command "cowextsize"
54 _require_xfs_io_command "funshare"
59 echo "Format and mount"
60 _scratch_mkfs > $seqres.full 2>&1
61 _scratch_mount >> $seqres.full 2>&1
63 testdir=$SCRATCH_MNT/test-$seq
68 filesize=$((blksz * nr))
70 bufsize=$((blksz * bufnr))
72 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
73 real_blksz=$(get_block_size $testdir)
74 internal_blks=$((filesize / real_blksz))
76 echo "Create the original files"
77 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $((filesize + 1))" $testdir/file1 >> $seqres.full
78 $XFS_IO_PROG -f -c "cowextsize $bufsize" $testdir/file2
79 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
83 md5sum $testdir/file1 | _filter_scratch
84 md5sum $testdir/file2 | _filter_scratch
86 echo "CoW and unmount"
87 $XFS_IO_PROG -f -c "cowextsize" $testdir/file2 >> $seqres.full
88 seq 1 10 | while read i; do
89 $XFS_IO_PROG -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $filesize" $testdir/file2 >> $seqres.full
92 $XFS_IO_PROG -f -c "funshare 0 $filesize" $testdir/file2 >> $seqres.full
96 md5sum $testdir/file1 | _filter_scratch
98 echo "Check extent counts"
99 old_extents=$(_count_extents $testdir/file1)
100 new_extents=$(_count_extents $testdir/file2)
102 echo "old extents: $old_extents" >> $seqres.full
103 echo "new extents: $new_extents" >> $seqres.full
104 echo "maximum extents: $internal_blks" >> $seqres.full