generic: test for file fsync after moving it to a new parent directory
[xfstests-dev.git] / tests / generic / 403
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 403
6 #
7 # Test racing getxattr requests against large xattr add and remove loop. This
8 # reproduces a bug on XFS where a getxattr of an existing attribute spuriously
9 # returned failure due to races with attribute fork conversion.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/attr
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34
35 # Modify as appropriate.
36 _supported_fs generic
37 _supported_os Linux
38 _require_scratch
39 _require_attrs
40
41 _scratch_mkfs > $seqres.full 2>&1 || _fail "mkfs"
42 _scratch_mount
43
44 # create xattr small enough for local format on XFS
45 touch $SCRATCH_MNT/file
46 $SETFATTR_PROG -n trusted.small -v a $SCRATCH_MNT/file
47
48 # start a background getxattr loop for the existing xattr
49 runfile="$tmp.getfattr"
50 touch $runfile
51 while [ -e $runfile ]; do
52         _getfattr --absolute-names -n trusted.small $SCRATCH_MNT/file \
53                 > /dev/null || break
54 done &
55 getfattr_pid=$!
56
57 # while the above is spinning, add and remove a large attribute to cause back
58 # and forth inode attribute fork conversion
59 largeval=`for i in $(seq 0 511); do echo -n a; done`
60 for i in $(seq 0 99); do
61         $SETFATTR_PROG -n trusted.big -v $largeval $SCRATCH_MNT/file
62         $SETFATTR_PROG -x trusted.big $SCRATCH_MNT/file
63 done
64
65 rm -f $runfile
66 wait > /dev/null 2>&1
67
68 echo Silence is golden
69
70 # success, all done
71 status=0
72 exit