xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / xfs / 433
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 433
6 #
7 # Regression test for an XFS NULL xattr buffer problem during unlink. XFS had a
8 # bug where the attr fork walk during file removal could go off the rails due to
9 # a stale reference to content of a released buffer. Memory pressure could cause
10 # this reference to point to free or reused memory and cause subsequent
11 # attribute fork lookups to fail, return a NULL buffer and possibly crash.
12 #
13 # This test emulates this behavior using an error injection knob to explicitly
14 # disable buffer LRU caching. This forces the attr walk to execute under
15 # conditions where each buffer is immediately freed on release.
16 #
17 # Commit f35c5e10c6ed ("xfs: reinit btree pointer on attr tree inactivation
18 # walk") fixed the bug.
19 #
20 seq=`basename $0`
21 seqres=$RESULT_DIR/$seq
22 echo "QA output created by $seq"
23
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 _cleanup()
30 {
31         cd /
32         rm -f $tmp.*
33 }
34
35 # get standard environment, filters and checks
36 . ./common/rc
37 . ./common/attr
38 . ./common/inject
39
40 # remove previous $seqres.full before test
41 rm -f $seqres.full
42
43 # real QA test starts here
44
45 # Modify as appropriate.
46 _supported_fs generic
47 _require_xfs_io_error_injection buf_lru_ref
48 _require_scratch
49 _require_attrs
50
51 _scratch_mkfs > $seqres.full 2>&1
52 _scratch_mount
53
54 file=$SCRATCH_MNT/testfile
55
56 # create a bunch of xattrs to form a multi-level attr tree
57 touch $file
58 for i in $(seq 0 499); do
59         $SETFATTR_PROG -n trusted.user.$i -v 0 $file
60 done
61
62 # cycle the mount to clear any buffer references
63 _scratch_cycle_mount || _fail "cycle mount failure"
64
65 # disable the lru cache and unlink the file
66 _scratch_inject_error buf_lru_ref 1
67 rm -f $file
68 _scratch_inject_error buf_lru_ref 0
69
70 echo Silence is golden
71
72 # success, all done
73 status=0
74 exit