overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / generic / 027
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. generic/027
6 #
7 # Run 8 processes writing 1k files to seperate files in seperate dirs to
8 # hit ENOSPC on small fs with little free space. Loop for 100 iterations.
9 #
10 # Regression test for
11 # 34cf865 ext4: fix deadlock when writing in ENOSPC conditions
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26 }
27
28 create_file()
29 {
30         local dir=$1
31         local direct=$2
32         local i=0
33
34         mkdir -p $dir >/dev/null 2>&1
35         while $XFS_IO_PROG -f $direct -c "pwrite 0 1k" $dir/file_$i >/dev/null 2>&1; do
36                 let i=$i+1
37         done
38 }
39
40 # get standard environment, filters and checks
41 . ./common/rc
42 . ./common/filter
43
44 # real QA test starts here
45 _supported_fs generic
46 _supported_os Linux
47
48 _require_scratch
49
50 rm -f $seqres.full
51 echo "Silence is golden"
52
53 _scratch_mkfs_sized $((256 * 1024 * 1024)) >>$seqres.full 2>&1
54 _scratch_mount
55
56 echo "Reserve 2M space" >>$seqres.full
57 $XFS_IO_PROG -f -c "pwrite 0 2m" $SCRATCH_MNT/testfile >>$seqres.full 2>&1
58 echo "Fulfill the fs" >>$seqres.full
59 $XFS_IO_PROG -f -c "pwrite 0 254m" $SCRATCH_MNT/bigfile >>$seqres.full 2>&1
60 echo "Remove reserved file" >>$seqres.full
61 rm -f $SCRATCH_MNT/testfile
62
63 loop=100
64 # btrfs takes much longer time, reduce the loop count
65 if [ "$FSTYP" == "btrfs" ]; then
66         loop=10
67 fi
68
69 dir=$SCRATCH_MNT/testdir
70 echo -n "iteration" >>$seqres.full
71 i=1
72 while [ $i -le $loop ]; do
73         echo -n " $i" >>$seqres.full
74         nr_worker=8
75         while [ $nr_worker -gt 0 ]; do
76                 # half buffered I/O half direct I/O
77                 if [ `expr $nr_worker % 2` -eq 0 ]; then
78                         create_file $dir/$nr_worker -d >>$seqres.full &
79                 else
80                         create_file $dir/$nr_worker >>$seqres.full &
81                 fi
82                 let nr_worker=$nr_worker-1
83         done
84         wait
85         rm -rf $dir
86         let i=$i+1
87 done
88 _scratch_unmount
89
90 status=0
91 exit