generic: test MADV_POPULATE_READ with IO errors
[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 . ./common/preamble
16 _begin_fstest auto rw
17
18 # Import common functions.
19 . ./common/filter
20
21 # real QA test starts here
22 _supported_fs generic
23 _require_scratch
24
25 threads=100
26 count=2
27 fs_size=$((2 * 1024 * 1024 * 1024))
28 ORIGIN=$SCRATCH_MNT/origin
29
30 threads_set()
31 {
32         threads=$((LOAD_FACTOR * 100))
33         if [ $threads -gt 200 ]
34         then
35                 threads=200
36         fi
37 }
38
39 file_create()
40 {
41         i=0
42         mkdir $ORIGIN
43
44         disksize=$(($fs_size / 3))
45         num=$(($disksize / $count / $threads / 4096))
46         while [ $i -lt $num ]; do
47                 $XFS_IO_PROG -f -c "pwrite 0 $((4096*count))" \
48                         $ORIGIN/file_$i >>$seqres.full 2>&1
49                 i=$(($i + 1))
50         done
51 }
52
53 worker()
54 {
55         suffix=$1
56
57         mkdir $SCRATCH_MNT/sub_$suffix
58
59         cp -r $ORIGIN/* $SCRATCH_MNT/sub_$suffix >>$seqres.full 2>&1
60         rm -rf $SCRATCH_MNT/sub_$suffix
61 }
62
63 do_workload()
64 {
65         pids=""
66         loop=1
67
68         threads_set
69         file_create
70
71         while [ $loop -lt $threads ]; do
72                 worker $loop &
73                 pids="$pids $!"
74                 loop=$(($loop + 1))
75         done
76
77         wait $pids
78 }
79
80 echo "Silence is golden"
81
82 _scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
83 _scratch_mount >>$seqres.full 2>&1
84
85 do_workload
86
87 status=0
88 exit