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