generic/371: disable speculative preallocation regressions on XFS
[xfstests-dev.git] / tests / generic / 371
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test 371
6 #
7 # Run write(2) and fallocate(2) in parallel and the total needed data space
8 # for these operations don't exceed whole fs free data space, to see whether
9 # we will get any unexpected ENOSPC error.
10 #
11 . ./common/preamble
12 _begin_fstest auto quick enospc prealloc
13
14 # Import common functions.
15 . ./common/filter
16
17 # Modify as appropriate.
18 _supported_fs generic
19 _require_scratch
20 _require_xfs_io_command "falloc"
21 test "$FSTYP" = "xfs" && _require_xfs_io_command "extsize"
22
23 _scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
24 _scratch_mount
25
26 # Disable speculative post-EOF preallocation on XFS, which can grow fast enough
27 # that a racing fallocate then fails.
28 if [ "$FSTYP" = "xfs" ]; then
29         alloc_sz="$(_get_file_block_size $SCRATCH_MNT)"
30         $XFS_IO_PROG -c "extsize $alloc_sz" $SCRATCH_MNT >> $seqres.full
31 fi
32
33 testfile1=$SCRATCH_MNT/testfile1
34 testfile2=$SCRATCH_MNT/testfile2
35
36 echo "Silence is golden"
37 for ((i=0; i<100; i++)); do
38         $XFS_IO_PROG -fc "pwrite 0 80M" $testfile1 >/dev/null
39         rm -f $testfile1
40 done &
41 pids=$!
42
43 for ((i=0; i<100; i++)); do
44         $XFS_IO_PROG -fc "falloc 0 80M" $testfile2 >/dev/null
45         rm -f $testfile2
46 done &
47 pids="$pids $!"
48
49 wait $pids
50 status=0
51 exit