xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 248
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. 248
6 #
7 # Ensuring that copy on write in buffered mode to the source file when the
8 # CoW range covers regular unshared and regular shared blocks.
9 #   - Set cowextsz.
10 #   - Create two files.
11 #   - Reflink the odd blocks of the first file into the second file.
12 #   - CoW the first file across the halfway mark, starting with the
13 #     regular extent.
14 #   - Check that the files are now different where we say they're different.
15 #
16 . ./common/preamble
17 _begin_fstest auto quick clone
18
19 # Import common functions.
20 . ./common/filter
21 . ./common/reflink
22
23 # real QA test starts here
24 _require_scratch_reflink
25 _require_xfs_io_command "falloc"
26 _require_xfs_io_command "cowextsize"
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 echo "Create the original files"
36 blksz=65536
37 nr=64
38 filesize=$((blksz * nr))
39 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
40 _sweave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
41 _scratch_cycle_mount
42
43 echo "Compare files"
44 md5sum $testdir/file1 | _filter_scratch
45 md5sum $testdir/file3 | _filter_scratch
46 md5sum $testdir/file1.chk | _filter_scratch
47
48 echo "CoW across the transition"
49 cowoff=$((filesize / 4))
50 cowsz=$((filesize / 2))
51 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file1 >> $seqres.full
52 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file1.chk >> $seqres.full
53 _scratch_cycle_mount
54
55 echo "Compare files"
56 md5sum $testdir/file1 | _filter_scratch
57 md5sum $testdir/file3 | _filter_scratch
58 md5sum $testdir/file1.chk | _filter_scratch
59
60 # success, all done
61 status=0
62 exit