common/xfs: refactor commands to select a particular xfs backing device
[xfstests-dev.git] / tests / xfs / 181
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 181
6 #
7 # Like 121 only creating large EAs
8 # As part of the iunlink processing in recovery it will call VN_RELE
9 # which will inactivate the inodes and if they have EAs (which they
10 # will here) also call xfs_inactive_attrs.
11 # We want to test out this xfs_inactive_attrs code being called in recovery.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 _cleanup()
18 {
19     rm -f $tmp.*
20     [ -n "$pid" ] && kill $pid
21 }
22
23 pid=""
24 here=`pwd`
25 tmp=/tmp/$$
26 status=1        # failure is the default!
27 trap "_cleanup; exit \$status" 0 1 2 3 15
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/log
33
34 # real QA test starts here
35 _supported_fs xfs
36
37 rm -f $seqres.full
38 rm -f $tmp.log
39
40 _require_scratch
41
42 echo "mkfs"
43 _scratch_mkfs_xfs >>$seqres.full 2>&1 \
44     || _fail "mkfs scratch failed"
45
46 echo "mount"
47 _scratch_mount
48
49 # num_files must be greater than 64 (XFS_AGI_UNLINKED_BUCKETS)
50 # so that there will be at least one linked list from one of
51 # the 64 buckets, so that we can decode a di_next_unlinked field
52 num_files=200
53 num_eas=1
54 ea_val_size=`expr 32 \* 1024`
55
56 # sleep for ages and we will kill this pid when we are ready
57 delay=100
58
59 echo "open and unlink $num_files files with EAs"
60 $here/src/multi_open_unlink -f $SCRATCH_MNT/test_file -n $num_files -s $delay -e $num_eas -v $ea_val_size &
61 pid=$!
62
63 # time to create and unlink all the files
64 sleep 10
65
66 echo "godown"
67 _scratch_shutdown -v -f >> $seqres.full
68
69 # kill the multi_open_unlink
70 kill $pid 2>/dev/null
71 wait $pid 2>/dev/null
72 pid=""
73
74 echo "unmount"
75 _scratch_unmount
76
77 echo "logprint after going down..."
78 _print_logstate
79
80 echo "mount with replay"
81 _scratch_mount $mnt >>$seqres.full 2>&1 \
82     || _fail "mount failed: $mnt $MOUNT_OPTIONS"
83
84 echo "godown"
85 _scratch_shutdown -v -f >> $seqres.full
86
87 echo "unmount"
88 _scratch_unmount
89
90 echo "logprint after going down..."
91 _print_logstate
92
93 echo "logprint to check for CLEAR_AGI_BUCKET..."
94 if _scratch_xfs_logprint -t | tee -a $seqres.full | grep CLEAR; then
95         echo 'CLEAR_AGI_BUCKET transactions found!!'
96         echo 'Are you running with an old xfs kernel - where the bug still exists?'
97 else
98         echo 'No CLEAR_AGI_BUCKET found in transactions - great - test passed :)'
99 fi
100
101 # clean up dirty log with log recovery on mount
102 _scratch_mount >> $seqres.full 2>&1 \
103     || _fail "mount failed"
104
105 # success, all done
106 status=0
107 exit