xfs: convert tests to SPDX license tags
[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 _supported_os Linux
48 _require_xfs_io_error_injection buf_lru_ref
49 _require_scratch
50 _require_attrs
51
52 _scratch_mkfs > $seqres.full 2>&1
53 _scratch_mount
54
55 file=$SCRATCH_MNT/testfile
56
57 # create a bunch of xattrs to form a multi-level attr tree
58 touch $file
59 for i in $(seq 0 499); do
60         $SETFATTR_PROG -n trusted.user.$i -v 0 $file
61 done
62
63 # cycle the mount to clear any buffer references
64 _scratch_cycle_mount || _fail "cycle mount failure"
65
66 # disable the lru cache and unlink the file
67 _scratch_inject_error buf_lru_ref 1
68 rm -f $file
69 _scratch_inject_error buf_lru_ref 0
70
71 echo Silence is golden
72
73 # success, all done
74 status=0
75 exit