generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 224
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 Dave Chinner.  All Rights Reserved.
4 #
5 # FS QA Test No. 224
6 #
7 # Delayed allocation at ENOSPC test
8 #
9 # Derived from a test case from Lachlan McIlroy and improved to
10 # reliably trigger a BUG in xfs_get_blocks(). Despite this XFS
11 # focus, the test can to run on any filesystem to exercise ENOSPC
12 # behaviour.
13 #
14 . ./common/preamble
15 _begin_fstest auto
16
17 # Override the default cleanup function.
18 _cleanup()
19 {
20         rm -f $tmp.*
21         rm -f $SCRATCH_MNT/testfile.*
22 }
23
24 # Import common functions.
25 . ./common/filter
26
27 # real QA test starts here
28 _supported_fs generic
29
30 _require_scratch
31
32 # make a 1GB filesystem
33 _scratch_mkfs_sized `expr 1024 \* 1024 \* 1024` > $seqres.full 2>&1
34 _scratch_mount >> $seqres.full 2>&1
35
36 # set the reserved block pool to almost empty for XFS
37 if [ "$FSTYP" = "xfs" ]; then
38         $XFS_IO_PROG -x -c "resblks 4" $SCRATCH_MNT >> $seqres.full 2>&1
39 fi
40
41 FILES=1000
42 for i in `seq 0 1 $FILES`; do
43
44         # set the file size to be 10MB - that way the direct IO will always try
45         # to read at least 10MB even if only 4k was written. This allows
46         # discarded delalloc pages that would have been beyond EOF to be
47         # tripped over.
48         (
49                 sleep 5
50                 $XFS_IO_PROG -f -c "truncate 10485760" $SCRATCH_MNT/testfile.$i
51                 dd if=/dev/zero of=$SCRATCH_MNT/testfile.$i bs=4k conv=notrunc
52         ) > /dev/null 2>&1 &
53 done
54 wait
55
56 for i in `seq 0 1 $FILES`; do
57         dd of=/dev/null if=$SCRATCH_MNT/testfile.$i bs=512k iflag=direct > /dev/null 2>&1 &
58 done
59 wait
60 echo "*** Silence is golden ***"
61
62 # unmount and check dmesg, filtering out expected warnings about mixed
63 # direct and buffered I/O
64 _scratch_unmount
65 _check_dmesg _filter_aiodio_dmesg
66
67 status=$?
68 exit