common/rc: introduce _require_scratch_delalloc()
[xfstests-dev.git] / tests / xfs / 258
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. 258
6 #
7 # Ensuring that copy on write in directio mode to the source file when the
8 # CoW range covers delalloc blocks and regular shared blocks.
9 #   - Set cowextsz.
10 #   - Create two files.
11 #   - Truncate the first file.
12 #   - Write the odd blocks of the first file.
13 #   - Reflink the odd blocks of the first file into the second file.
14 #   - Write the even blocks of the first file.
15 #   - DIO CoW the first file across the halfway mark, starting with the
16 #     regular extent.
17 #   - Check that the files are now different where we say they're different.
18 #
19 . ./common/preamble
20 _begin_fstest auto quick clone
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/reflink
25
26 # real QA test starts here
27 _require_scratch_reflink
28 _require_scratch_delalloc
29 _require_xfs_io_command "falloc"
30 _require_xfs_io_command "cowextsize"
31 _require_odirect
32
33 echo "Format and mount"
34 _scratch_mkfs > $seqres.full 2>&1
35 _scratch_mount >> $seqres.full 2>&1
36
37 testdir=$SCRATCH_MNT/test-$seq
38 mkdir $testdir
39
40 echo "Create the original files"
41 blksz=65536
42 nr=64
43 filesize=$((blksz * nr))
44 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
45 _sweave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
46 _scratch_cycle_mount
47
48 echo "Compare files"
49 md5sum $testdir/file1 | _filter_scratch
50 md5sum $testdir/file3 | _filter_scratch
51 md5sum $testdir/file1.chk | _filter_scratch
52
53 echo "CoW across the transition"
54 cowoff=$((filesize / 4))
55 cowsz=$((filesize / 2))
56 _sweave_reflink_holes_delalloc $blksz $nr $testdir/file1 >> $seqres.full
57 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file1 >> $seqres.full
58 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file1.chk >> $seqres.full
59 _scratch_cycle_mount
60
61 echo "Compare files"
62 md5sum $testdir/file1 | _filter_scratch
63 md5sum $testdir/file3 | _filter_scratch
64 md5sum $testdir/file1.chk | _filter_scratch
65
66 # success, all done
67 status=0
68 exit