a611474885a755fbe1a7bf000d057bdd3784f33c
[xfstests-dev.git] / tests / xfs / 002
1 #! /bin/bash
2 # FS QA Test No. 002
3 #
4 # Test that garbage in old v4 superblocks doesn't trip verifiers during growfs
5 #
6 # Older kernels sometimes left garbage in the unused portions
7 # of the superblock during growfs; with the new verifiers this initially
8 # caused failures during a subsequent growfs; see
9 # 10e6e65 xfs: be more forgiving of a v4 secondary sb w/ junk in v5 fields
10 # for further explanation.  (NB: while the commit log was good, the
11 # patch had a bug which was subsequently fixed)
12 #
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
19 #
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28 #-----------------------------------------------------------------------
29 #
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38 trap "_cleanup; exit \$status" 0 1 2 3 15
39
40 _cleanup()
41 {
42     cd /
43     rm -f $tmp.*
44 }
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49
50 # Modify as appropriate.
51 _supported_fs xfs
52 _supported_os Linux
53 _require_scratch_nocheck
54 _require_no_large_scratch_dev
55
56 # So we can explicitly turn it _off_:
57 _require_xfs_mkfs_crc
58
59 rm -f $seqres.full
60
61 _scratch_mkfs_xfs -m crc=0 -d size=128m >> $seqres.full 2>&1 || _fail "mkfs failed"
62
63 # Scribble past a couple V4 secondary superblocks to populate sb_crc
64 # (We can't write to the structure member because it doesn't exist
65 # on a v4 superblock, so we use the data type & "write fill")
66 _scratch_xfs_db -x -c "sb 1" -c "type data" -c "write fill 0xff 224 4"
67 _scratch_xfs_db -x -c "sb 2" -c "type data" -c "write fill 0xff 224 4"
68
69 _scratch_mount
70
71 # This should pass
72 $XFS_GROWFS_PROG $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "growfs failed"
73
74 # success, all done
75 status=0
76 exit