generic: shutdown fs after log recovery
[xfstests-dev.git] / tests / generic / 359
1 #! /bin/bash
2 # FS QA Test No. 359
3 #
4 # Make sure that the reference counting mechanism can handle the case
5 # where we share the first 1/4 of an extent with a file, share the
6 # last 1/4 of the extent with a second file, share the first half of
7 # the extent with N files, and share the second half of the extent
8 # with a different set of N files.  The key point here is to test that
9 # we handle the case where a refcount extent record doesn't coincide
10 # exactly with the block mapping records.
11 #
12 #-----------------------------------------------------------------------
13 # Copyright (c) 2016 Oracle, Inc.  All Rights Reserved.
14 #
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
18 #
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27 #-----------------------------------------------------------------------
28 #
29
30 seq=`basename $0`
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
33
34 here=`pwd`
35 tmp=/tmp/$$
36 status=1        # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 7 15
38
39 _cleanup()
40 {
41         cd /
42         rm -rf $tmp.*
43         wait
44 }
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49 . ./common/reflink
50
51 # real QA test starts here
52 _supported_os Linux
53 _require_scratch_reflink
54
55 echo "Format and mount"
56 _scratch_mkfs > $seqres.full 2>&1
57 _scratch_mount >> $seqres.full 2>&1
58
59 testdir=$SCRATCH_MNT/test-$seq
60 mkdir $testdir
61
62 blocks=64
63 blksz=65536
64 nr=4
65 halfway=$((blocks / 2 * blksz))
66 quarter=$((blocks / 4 * blksz))
67
68 echo "Initialize file"
69 _pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file >> $seqres.full
70
71 echo "Share the first half of the extent"
72 seq 1 $nr | while read nr; do
73         _reflink_range $testdir/file 0 $testdir/file$nr.0 0 $halfway >> $seqres.full
74 done
75
76 echo "Share the last half of the extent"
77 seq 1 $nr | while read nr; do
78         _reflink_range $testdir/file $halfway $testdir/file$nr.1 0 $halfway >> $seqres.full
79 done
80
81 echo "Share the first quarter of the extent"
82 _reflink_range $testdir/file 0 $testdir/file.2 0 $quarter >> $seqres.full
83
84 echo "Share the last quarter of the extent"
85 _reflink_range $testdir/file $((quarter * 3)) $testdir/file.3 0 $quarter >> $seqres.full
86
87 _scratch_cycle_mount
88
89 echo "Check output"
90 md5sum $testdir/file $testdir/file* | _filter_scratch
91
92 # success, all done
93 status=0
94 exit