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