fstests: _fail test by default when _scratch_mount fails
[xfstests-dev.git] / tests / xfs / 433
1 #! /bin/bash
2 # FS QA Test No. 433
3 #
4 # Regression test for an XFS NULL xattr buffer problem during unlink. XFS had a
5 # bug where the attr fork walk during file removal could go off the rails due to
6 # a stale reference to content of a released buffer. Memory pressure could cause
7 # this reference to point to free or reused memory and cause subsequent
8 # attribute fork lookups to fail, return a NULL buffer and possibly crash.
9 #
10 # This test emulates this behavior using an error injection knob to explicitly
11 # disable buffer LRU caching. This forces the attr walk to execute under
12 # conditions where each buffer is immediately freed on release.
13 #
14 # Commit f35c5e10c6ed ("xfs: reinit btree pointer on attr tree inactivation
15 # walk") fixed the bug.
16 #
17 #-----------------------------------------------------------------------
18 # Copyright (c) 2017 Red Hat, Inc.  All Rights Reserved.
19 #
20 # This program is free software; you can redistribute it and/or
21 # modify it under the terms of the GNU General Public License as
22 # published by the Free Software Foundation.
23 #
24 # This program is distributed in the hope that it would be useful,
25 # but WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27 # GNU General Public License for more details.
28 #
29 # You should have received a copy of the GNU General Public License
30 # along with this program; if not, write the Free Software Foundation,
31 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
32 #-----------------------------------------------------------------------
33 #
34
35 seq=`basename $0`
36 seqres=$RESULT_DIR/$seq
37 echo "QA output created by $seq"
38
39 here=`pwd`
40 tmp=/tmp/$$
41 status=1        # failure is the default!
42 trap "_cleanup; exit \$status" 0 1 2 3 15
43
44 _cleanup()
45 {
46         cd /
47         rm -f $tmp.*
48 }
49
50 # get standard environment, filters and checks
51 . ./common/rc
52 . ./common/attr
53 . ./common/inject
54
55 # remove previous $seqres.full before test
56 rm -f $seqres.full
57
58 # real QA test starts here
59
60 # Modify as appropriate.
61 _supported_fs generic
62 _supported_os Linux
63 _require_xfs_io_error_injection buf_lru_ref
64 _require_scratch
65 _require_attrs
66
67 _scratch_mkfs > $seqres.full 2>&1
68 _scratch_mount
69
70 file=$SCRATCH_MNT/testfile
71
72 # create a bunch of xattrs to form a multi-level attr tree
73 touch $file
74 for i in $(seq 0 499); do
75         $SETFATTR_PROG -n trusted.user.$i -v 0 $file
76 done
77
78 # cycle the mount to clear any buffer references
79 _scratch_cycle_mount || _fail "cycle mount failure"
80
81 # disable the lru cache and unlink the file
82 _scratch_inject_error buf_lru_ref 1
83 rm -f $file
84 _scratch_inject_error buf_lru_ref 0
85
86 echo Silence is golden
87
88 # success, all done
89 status=0
90 exit