generic: test deadlock on O_DIRECT|O_DSYNC
[xfstests-dev.git] / tests / generic / 320
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011-2012 Fujitsu, Inc.  All Rights Reserved.
4 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
5 #
6 # FS QA Test No. generic/320
7 #
8 # heavy rm workload
9 #
10 # Regression test for commit:
11 # 9a3a5da xfs: check for stale inode before acquiring iflock on push
12 #
13 # Based on generic/273
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1        # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 _cleanup()
25 {
26         cd /
27         rm -rf $tmp.*
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 # real QA test starts here
35 _supported_fs generic
36 _supported_os Linux
37 _require_scratch
38
39 threads=100
40 count=2
41 fs_size=$((2 * 1024 * 1024 * 1024))
42 ORIGIN=$SCRATCH_MNT/origin
43
44 threads_set()
45 {
46         threads=$((LOAD_FACTOR * 100))
47         if [ $threads -gt 200 ]
48         then
49                 threads=200
50         fi
51 }
52
53 file_create()
54 {
55         i=0
56         mkdir $ORIGIN
57
58         disksize=$(($fs_size / 3))
59         num=$(($disksize / $count / $threads / 4096))
60         while [ $i -lt $num ]; do
61                 $XFS_IO_PROG -f -c "pwrite 0 $((4096*count))" \
62                         $ORIGIN/file_$i >>$seqres.full 2>&1
63                 i=$(($i + 1))
64         done
65 }
66
67 worker()
68 {
69         suffix=$1
70
71         mkdir $SCRATCH_MNT/sub_$suffix
72
73         cp -r $ORIGIN/* $SCRATCH_MNT/sub_$suffix >>$seqres.full 2>&1
74         rm -rf $SCRATCH_MNT/sub_$suffix
75 }
76
77 do_workload()
78 {
79         pids=""
80         loop=1
81
82         threads_set
83         file_create
84
85         while [ $loop -lt $threads ]; do
86                 worker $loop &
87                 pids="$pids $!"
88                 loop=$(($loop + 1))
89         done
90
91         wait $pids
92 }
93
94 echo "Silence is golden"
95
96 rm -f $seqres.full
97
98 _scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
99 _scratch_mount >>$seqres.full 2>&1
100
101 do_workload
102
103 status=0
104 exit