generic/611: Use _getfattr instead of GETFATTR_PROG
[xfstests-dev.git] / tests / generic / 195
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 195
6 #
7 # Ensuring that copy on write in buffered mode works when the CoW
8 # range originally covers multiple extents, some delalloc, some not.
9 #   - Create a file.
10 #   - Reflink the odd blocks of the first file into the second file.
11 #   - Buffered write the even blocks of the second file.
12 #   - CoW across the halfway mark, starting with the unwritten extent.
13 #   - Check that the files are now different where we say they're different.
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1    # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 _cleanup()
25 {
26     cd /
27     rm -rf $tmp.* $testdir
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33 . ./common/reflink
34
35 # real QA test starts here
36 _require_scratch_reflink
37 _require_xfs_io_command "falloc"
38
39 rm -f $seqres.full
40
41 echo "Format and mount"
42 _scratch_mkfs > $seqres.full 2>&1
43 _scratch_mount >> $seqres.full 2>&1
44
45 testdir=$SCRATCH_MNT/test-$seq
46 mkdir $testdir
47
48 echo "Create the original files"
49 blksz=65536
50 nr=64
51 filesize=$((blksz * nr))
52 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $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/file3.chk | _filter_scratch
59
60 echo "CoW across the transition"
61 cowoff=$((filesize / 4))
62 cowsz=$((filesize / 2))
63 _weave_reflink_holes_delalloc $blksz $nr $testdir/file3 >> $seqres.full
64 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
65 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
66 _scratch_cycle_mount
67
68 echo "Compare files"
69 md5sum $testdir/file1 | _filter_scratch
70 md5sum $testdir/file3 | _filter_scratch
71 md5sum $testdir/file3.chk | _filter_scratch
72
73 # success, all done
74 status=0
75 exit