2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2007 Silicon Graphics, Inc. All Rights Reserved.
7 # Check the filestreams allocator is doing its job.
8 # Multi-file data streams should always write into seperate AGs.
11 _begin_fstest rw filestreams
13 # Import common functions.
15 . ./common/filestreams
17 # real QA test starts here
19 _require_command "$FILEFRAG_PROG" filefrag
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.
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.
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
43 _scratch_mkfs > $seqres.full
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"
50 _check_filestreams_support || _notrun "filestreams not available"
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
56 _test_streams 8 16 4 8 3 1 0 fail
57 _test_streams 64 16 20 10 1 0 1