fstests: _fail test by default when _scratch_mount fails
[xfstests-dev.git] / tests / xfs / 121
1 #! /bin/bash
2 # FS QA Test No. 121
3 #
4 # To test log replay for the unlinked list.
5 # So we create unlinked and still referenced inodes
6 # and make sure that no clearing of the unlinked AGI buckets
7 # are happening.
8 # See pv#953263.
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2006 Silicon Graphics, 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
29 seq=`basename $0`
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
37
38 # get standard environment, filters and checks
39 . ./common/rc
40 . ./common/filter
41 . ./common/log
42
43 # real QA test starts here
44 _supported_fs xfs
45 _supported_os Linux
46
47 rm -f $seqres.full
48 rm -f $tmp.log
49
50 _require_scratch
51
52 echo "mkfs"
53 _scratch_mkfs_xfs >>$seqres.full 2>&1 \
54     || _fail "mkfs scratch failed"
55
56 echo "mount"
57 _scratch_mount
58
59 # num_files must be greater than 64 (XFS_AGI_UNLINKED_BUCKETS)
60 # so that there will be at least one linked list from one of
61 # the 64 buckets, so that we can decode a di_next_unlinked field
62 num_files=200
63 delay=5
64 echo "open and unlink $num_files files"
65 src/multi_open_unlink -f $SCRATCH_MNT/test_file -n $num_files -s $delay &
66
67 # time to create and unlink all the files
68 sleep 3
69
70 echo "godown"
71 src/godown -v -f $SCRATCH_MNT >> $seqres.full
72
73 # time for multi_open_unlink to exit out after its delay
74 # so we have no references and can unmount
75 wait 2>/dev/null
76
77 echo "unmount"
78 _scratch_unmount
79
80 echo "logprint after going down..."
81 _print_logstate
82
83 echo "mount with replay"
84 _try_scratch_mount $mnt >>$seqres.full 2>&1 \
85     || _fail "mount failed: $mnt $MOUNT_OPTIONS"
86
87 echo "godown"
88 src/godown -v -f $SCRATCH_MNT >> $seqres.full
89
90 echo "unmount"
91 _scratch_unmount
92
93 echo "logprint after going down..."
94 _print_logstate
95
96 echo "logprint to check for CLEAR_AGI_BUCKET..."
97 if _scratch_xfs_logprint -t | tee -a $seqres.full | grep CLEAR; then
98         echo 'CLEAR_AGI_BUCKET transactions found!!'
99         echo 'Are you running with an old xfs kernel - where the bug still exists?'
100 else
101         echo 'No CLEAR_AGI_BUCKET found in transactions - great - test passed :)'
102 fi
103
104 # clean up dirty log with log recovery on mount
105 _scratch_mount
106
107 # success, all done
108 status=0
109 exit