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