generic: test deadlock on O_DIRECT|O_DSYNC
[xfstests-dev.git] / tests / generic / 385
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2008 Christoph Hellwig.
4 #
5 # FS QA Test No. 385
6 #
7 # Make sure renames accross project boundaries are properly rejected
8 # and that we don't use the wrong lock flags internally.
9 #
10 # Based on a report and testcase from Arkadiusz Miskiewicz <arekm@maven.pl>
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19
20 _cleanup()
21 {
22         cd /
23         _scratch_unmount
24         rm -f $tmp.*
25 }
26 trap "_cleanup; exit \$status" 0 1 2 3 15
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/quota
32
33 # real QA test starts here
34 _supported_fs generic
35 _supported_os Linux
36
37 _require_scratch
38 _require_quota
39 _require_xfs_quota_foreign
40
41 #
42 # Setup temporary replacements for /etc/projects and /etc/projid
43 #
44 cat >$tmp.projects <<EOF
45 42:$SCRATCH_MNT/t
46 EOF
47
48 cat >$tmp.projid <<EOF
49 answer:42
50 EOF
51
52 #
53 # And make sure we always use our replacements
54 #
55 quota_cmd="$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid"
56
57 _scratch_mkfs >/dev/null 2>&1
58 _scratch_enable_pquota
59 _qmount_option "prjquota"
60 _qmount
61 _require_prjquota $SCRATCH_DEV
62
63 #
64 # Create the project root
65 #
66 mkdir $SCRATCH_MNT/t
67
68 $quota_cmd -x -c 'project -s answer' $SCRATCH_MNT >/dev/null 2>&1
69 $quota_cmd -x -c 'limit -p bhard=100m answer' $SCRATCH_MNT
70
71 touch $SCRATCH_MNT/test
72
73 #
74 # Try renaming a file into the project.  This should fail.
75 #
76 # We repeat this a couple thousand times as a single rename couldn't
77 # always trigger the wrong unlock flags bug we had in older kernels.
78 #
79 for i in `seq 1 2000`; do
80     $here/src/rename test t/test
81 done
82
83 # success, all done
84 echo "*** done"
85 rm -f $seqres.full
86 status=0