2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Fujitsu. All Rights Reserved.
7 # Test fs behavior when large write request can't be met by one single extent
9 # Inspired by a bug in a btrfs fix, which doesn't get exposed by current test
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
31 # remove previous $seqres.full before test
34 # real QA test starts here
36 # Modify as appropriate.
41 fs_size=$((128 * 1024 * 1024))
42 page_size=$(get_page_size)
44 # We will never reach this number though
45 nr_files=$(($fs_size / $page_size))
47 # Use small fs to make the fill more faster
48 _scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
55 for i in $(seq -w $nr_files); do
56 # xfs_io can't return correct value when it hit ENOSPC, use
57 # dd here to detect ENOSPC
58 dd if=/dev/zero of=$SCRATCH_MNT/$i bs=$page_size count=1 \
68 # remount to sync every thing into fs, and drop all cache
71 # remove all files with odd file names, which should free near half
73 rm $SCRATCH_MNT/*[13579]
76 # We should be able to write at least 1/8 of the whole fs size
77 # The number 1/8 is for btrfs, which only has about 47M for data.
78 # And half of the 47M is already taken up, so only 1/8 is safe here
79 $XFS_IO_PROG -f -c "pwrite 0 $(($fs_size / 8))" $SCRATCH_MNT/large_file | \