xfs: no excessive warnings about dprecated mount options on remount
[xfstests-dev.git] / tests / xfs / 223
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. 223
6 #
7 # Ensuring that copy on write in direct-io mode works when the CoW
8 # range originally covers multiple extents, some delalloc, some not.
9 #   - Set cowextsize hint.
10 #   - Create a file.
11 #   - Reflink the odd blocks of the first file into the second file.
12 #   - Buffered write the even blocks of the second file.
13 #   - directio CoW across the halfway mark, starting with the unwritten extent.
14 #   - Check that the files are now different where we say they're different.
15 #
16 seq=`basename $0`
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
19
20 here=`pwd`
21 tmp=/tmp/$$
22 status=1    # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 _cleanup()
26 {
27     cd /
28     rm -rf $tmp.*
29 }
30
31 # get standard environment, filters and checks
32 . ./common/rc
33 . ./common/filter
34 . ./common/reflink
35
36 # real QA test starts here
37 _require_scratch_reflink
38 _require_xfs_io_command "falloc"
39 _require_xfs_io_command "cowextsize"
40 _require_odirect
41
42 rm -f $seqres.full
43
44 echo "Format and mount"
45 _scratch_mkfs > $seqres.full 2>&1
46 _scratch_mount >> $seqres.full 2>&1
47
48 testdir=$SCRATCH_MNT/test-$seq
49 mkdir $testdir
50
51 echo "Create the original files"
52 blksz=65536
53 nr=64
54 filesize=$((blksz * nr))
55 real_blksz=$(_get_block_size $testdir)
56 internal_blks=$((filesize / real_blksz))
57 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
58 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $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/file3.chk | _filter_scratch
65
66 echo "directio CoW across the transition"
67 cowoff=$((filesize / 4))
68 cowsz=$((filesize / 2))
69 _weave_reflink_holes_delalloc $blksz $nr $testdir/file3 >> $seqres.full
70 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
71 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
72 _scratch_cycle_mount
73
74 echo "Compare files"
75 md5sum $testdir/file1 | _filter_scratch
76 md5sum $testdir/file3 | _filter_scratch
77 md5sum $testdir/file3.chk | _filter_scratch
78
79 echo "Check extent counts"
80 old_extents=$(_count_extents $testdir/file1)
81 new_extents=$(_count_extents $testdir/file3)
82
83 echo "old extents: $old_extents" >> $seqres.full
84 echo "new extents: $new_extents" >> $seqres.full
85 echo "maximum extents: $internal_blks" >> $seqres.full
86 test $((new_extents - (nr / 2))) -lt $((internal_blks / 2)) || echo "file3 badly fragmented"
87
88 # success, all done
89 status=0
90 exit