xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 109
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 109
6 #
7 # ENOSPC deadlock case from Asano Masahiro.
8 #
9 . ./common/preamble
10 _begin_fstest metadata auto
11
12 # Import common functions.
13 . ./common/filter
14
15 # real QA test starts here
16 _supported_fs xfs
17 _require_scratch
18
19 populate()
20 {
21         # "faststart" lets us effectively skip (re-)population
22         [ "X$faststart" != "X" ] && rm -f $SCRATCH_MNT/F*
23
24         # create many small files using most available space
25         echo "creating small files..."
26         i=0
27         while [ $i -le $files -a "X$faststart" = "X" ]; do
28                 file=$SCRATCH_MNT/f$i
29                 $XFS_IO_PROG -f -d -c 'pwrite -b 64k 0 64k' $file >/dev/null
30                 let i=$i+1
31         done
32
33         # remove every second file, freeing up lots of space
34         echo "removing small files..."
35         i=1
36         while [ $i -le $files -a "X$faststart" = "X" ]; do
37                 rm $SCRATCH_MNT/f$i
38                 let i=$i+2
39         done
40
41         echo "flushing changes via umount/mount."
42         _scratch_unmount
43         _scratch_mount
44 }
45
46 allocate()
47 {
48         # now try to hit the deadlock
49         echo "starting parallel allocators..."
50         i=0
51         while [ $i -le 10 ]; do
52                 file=$SCRATCH_MNT/F$i
53                 {
54                         j=0
55                         while [ $j -lt 100 ]; do
56                                 $XFS_IO_PROG -f -c 'pwrite -b 64k 0 16m' $file \
57                                         >/dev/null 2>&1
58                                 test -e $file && rm $file
59                                 let j=$j+1
60                         done
61                 } &
62                 let i=$i+1
63         done
64
65         wait
66         echo "all done!"
67 }
68
69 # real QA test starts here
70 _scratch_mkfs_xfs >> $seqres.full
71 _scratch_mount
72
73 # see if faststart is possible (and requested)
74 files=2000
75 faststart=""
76 if [ -n "$FASTSTART" -a -f $SCRATCH_MNT/f0 ]; then
77         faststart="-N"  # causes us to skip the mkfs step
78 fi
79 _scratch_unmount
80
81 _scratch_mkfs_xfs -dsize=160m,agcount=4 $faststart | _filter_mkfs 2>$tmp.mkfs
82 cat $tmp.mkfs >>$seqres.full
83 _scratch_mount
84
85 populate
86 allocate
87 status=0
88 exit