xfs/172: disable test when file writes don't use delayed allocation
[xfstests-dev.git] / tests / xfs / 172
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 172
6 #
7 # Check the filestreams allocator is doing its job.
8 # Multi-file data streams should always write into seperate AGs.
9 #
10 . ./common/preamble
11 _begin_fstest rw filestreams
12
13 # Import common functions.
14 . ./common/filter
15 . ./common/filestreams
16
17 # real QA test starts here
18 _supported_fs xfs
19 _require_command "$FILEFRAG_PROG" filefrag
20 _require_scratch
21
22 # The first _test_streams call sets up the filestreams allocator to fail and
23 # then checks that it actually failed.  It does this by creating a very small
24 # filesystem, writing a lot of data in parallel to separate streams, and then
25 # flushes the dirty data, also in parallel.  To trip the allocator, the test
26 # relies on writeback combining adjacent dirty ranges into large allocation
27 # requests which eventually bleed across AGs.  This happens either because the
28 # big writes are slow enough that filestreams contexts expire between
29 # allocation requests, or because the AGs are so full at allocation time that
30 # the bmapi allocator decides to scan for a less full AG.  Either way, stream
31 # directories share AGs, which is what the test considers a success.
32 #
33 # However, this only happens if writes use the delayed allocation code paths.
34 # If the kernel allocates small amounts of space at the time of each write()
35 # call, the successive small allocations never trip the bmapi allocator's
36 # rescan thresholds and will keep pushing out the expiration time, with the
37 # result that the filestreams allocator succeeds in maintaining the streams.
38 # The test considers this a failure.
39 #
40 # Make sure that a regular buffered write produces delalloc reservations.
41 # This effectively disables the test for files with extent size hints or DAX
42 # mode set.
43 _scratch_mkfs > $seqres.full
44 _scratch_mount
45 $XFS_IO_PROG -f -c 'pwrite 0 64k' $SCRATCH_MNT/testy &> /dev/null
46 $FILEFRAG_PROG -v $SCRATCH_MNT/testy 2>&1 | grep -q delalloc || \
47         _notrun "test requires delayed allocation buffered writes"
48 _scratch_unmount
49
50 _check_filestreams_support || _notrun "filestreams not available"
51
52 # test reaper works by setting timeout low. Expected to fail
53 # for buffered, succeed for direct I/O.
54 _set_stream_timeout_centisecs 50
55
56 _test_streams 8 16 4 8 3 1 0 fail
57 _test_streams 64 16 20 10 1 0 1
58
59 status=0
60 exit
61