generic: shutdown fs after log recovery
[xfstests-dev.git] / tests / generic / 179
1 #! /bin/bash
2 # FS QA Test No. 179
3 #
4 # Ensure that unaligned punch-hole steps around reflinked ranges:
5 #   - Create a reflink clone of a file
6 #   - Perform an unaligned punch in the middle of the file.
7 #   - Check that the reflinked areas are still there.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1    # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37     cd /
38     rm -rf $tmp.* $testdir
39 }
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44 . ./common/reflink
45
46 # real QA test starts here
47 _supported_os Linux
48 _require_test_reflink
49 _require_cp_reflink
50 _require_xfs_io_command "fpunch"
51
52 rm -f $seqres.full
53
54 testdir=$TEST_DIR/test-$seq
55 rm -rf $testdir
56 mkdir $testdir
57
58 echo "Create the original files"
59 blksz=65536
60 _pwrite_byte 0x61 0 $((blksz * 3)) $testdir/file1 >> $seqres.full
61
62 _cp_reflink $testdir/file1 $testdir/file2
63
64 _pwrite_byte 0x61 0 $((blksz * 3)) $testdir/file2.chk >> $seqres.full
65 _pwrite_byte 0x00 $((blksz - 17)) $((blksz + 17)) $testdir/file2.chk >> $seqres.full
66 _test_cycle_mount
67
68 md5sum $testdir/file1 | _filter_test_dir
69 md5sum $testdir/file2 | _filter_test_dir
70 md5sum $testdir/file2.chk | _filter_test_dir
71
72 c1=$(_md5_checksum $testdir/file1)
73 c2=$(_md5_checksum $testdir/file2)
74
75 test ${c1} = ${c2} || echo "file1 and file2 should match"
76
77 echo "fpunch files"
78 $XFS_IO_PROG -f -c "fpunch $((blksz - 17)) $((blksz + 17))" $testdir/file2
79 _test_cycle_mount
80
81 echo "Compare files"
82 md5sum $testdir/file1 | _filter_test_dir
83 md5sum $testdir/file2 | _filter_test_dir
84 md5sum $testdir/file2.chk | _filter_test_dir
85
86 c1=$(_md5_checksum $testdir/file1)
87 c2=$(_md5_checksum $testdir/file2)
88
89 test ${c1} != ${c2} || echo "file1 and file2 should not match"
90
91 echo "Compare against check files"
92 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
93
94 # success, all done
95 status=0
96 exit