2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # fcollapse a file at midway through a CoW region.
9 # This test is dependent on the system page size, so we cannot use md5 in
10 # the golden output; we can only compare to a check file.
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
32 # real QA test starts here
33 _require_scratch_reflink
35 _require_xfs_io_command "fcollapse"
40 echo "Format and mount"
41 _scratch_mkfs > $seqres.full 2>&1
42 _scratch_mount >> $seqres.full 2>&1
44 testdir=$SCRATCH_MNT/test-$seq
49 filesize=$((blksz * nr))
51 echo "Create the original files"
52 _pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full
53 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
54 _pwrite_byte 0x61 0 $filesize $testdir/file2.chk >> $seqres.full
58 md5sum $testdir/file1 | _filter_scratch
59 md5sum $testdir/file2 | _filter_scratch
60 md5sum $testdir/file2.chk | _filter_scratch
62 echo "CoW and unmount"
63 $XFS_IO_PROG -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "fcollapse $((blksz * 2)) $blksz" $testdir/file2 >> $seqres.full
65 $XFS_IO_PROG -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "truncate $((blksz * (nr - 1)))" $testdir/file2.chk >> $seqres.full
69 md5sum $testdir/file1 | _filter_scratch
70 md5sum $testdir/file2 | _filter_scratch
71 md5sum $testdir/file2.chk | _filter_scratch