fstests: move test group info to test files
[xfstests-dev.git] / tests / xfs / 345
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. 345
6 #
7 # Test fragmentation after a lot of random CoW:
8 # - Create two reflinked files.  Set zero extsz hint on second file.
9 # - Buffered write to random offsets to scatter CoW reservations.
10 # - Check the number of extents.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick clone
14
15 # Import common functions.
16 . ./common/filter
17 . ./common/reflink
18
19 # real QA test starts here
20 _supported_fs xfs
21 _require_scratch_reflink
22 _require_cp_reflink
23 _require_xfs_io_command "fiemap"
24 _require_xfs_io_command "cowextsize"
25 _require_xfs_io_command "funshare"
26
27 echo "Format and mount"
28 _scratch_mkfs > $seqres.full 2>&1
29 _scratch_mount >> $seqres.full 2>&1
30
31 testdir=$SCRATCH_MNT/test-$seq
32 mkdir $testdir
33
34 blksz=65536
35 nr=128
36 filesize=$((blksz * nr))
37 bufnr=16
38 bufsize=$((blksz * bufnr))
39
40 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
41 real_blksz=$(_get_file_block_size $testdir)
42 internal_blks=$((filesize / real_blksz))
43
44 echo "Create the original files"
45 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $((filesize + 1))" $testdir/file1 >> $seqres.full
46 $XFS_IO_PROG -f -c "cowextsize $real_blksz" $testdir/file2
47 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
48 _scratch_cycle_mount
49
50 echo "Compare files"
51 md5sum $testdir/file1 | _filter_scratch
52 md5sum $testdir/file2 | _filter_scratch
53
54 echo "CoW and unmount"
55 $XFS_IO_PROG -f -c "cowextsize" $testdir/file2 >> $seqres.full
56 $XFS_IO_PROG -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full
57 $XFS_IO_PROG -f -c "funshare 0 $filesize" $testdir/file2 >> $seqres.full
58 _scratch_cycle_mount
59
60 echo "Compare files"
61 md5sum $testdir/file1 | _filter_scratch
62
63 echo "Check extent counts"
64 old_extents=$(_count_extents $testdir/file1)
65 new_extents=$(_count_extents $testdir/file2)
66
67 echo "old extents: $old_extents" >> $seqres.full
68 echo "new extents: $new_extents" >> $seqres.full
69 echo "maximum extents: $internal_blks" >> $seqres.full
70
71 # success, all done
72 status=0
73 exit