generic: shutdown fs after log recovery
[xfstests-dev.git] / tests / generic / 358
1 #! /bin/bash
2 # FS QA Test No. 358
3 #
4 # Share an extent amongst a bunch of files such that the refcount
5 # stays the same while the rate of change of the set of owners is
6 # steadily increasing.  For example, an extent of 32 blocks is owned
7 # by 32 files.  At block 1, change one of the owners.  At block 2,
8 # change 2 of the owners, and so on.
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2016 Oracle, Inc.  All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
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 7 15
36
37 _cleanup()
38 {
39         cd /
40         rm -rf $tmp.*
41         wait
42 }
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/filter
47 . ./common/reflink
48
49 # real QA test starts here
50 _supported_os Linux
51 _require_scratch_reflink
52
53 echo "Format and mount"
54 _scratch_mkfs > $seqres.full 2>&1
55 _scratch_mount >> $seqres.full 2>&1
56
57 testdir=$SCRATCH_MNT/test-$seq
58 mkdir $testdir
59
60 blocks=64
61 blksz=65536
62
63 echo "Initialize file"
64 _pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file >> $seqres.full
65
66 echo "Share the file n-ways"
67 seq 1 $((blocks - 1)) | while read nr; do
68         _reflink_range $testdir/file 0 $testdir/file$nr.0 0 $((nr * blksz)) >> $seqres.full
69         seq $nr $((blocks - 1)) | while read nnr; do
70                 _reflink_range $testdir/file $((nnr * blksz)) $testdir/file$nr.$nnr $((nnr * blksz)) $blksz >> $seqres.full
71         done
72 done
73 _scratch_cycle_mount
74
75 echo "Check output"
76 md5sum $testdir/file $testdir/file*.0 | _filter_scratch
77
78 # success, all done
79 status=0
80 exit