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.
40 fs_size=$((128 * 1024 * 1024))
41 page_size=$(get_page_size)
43 # We will never reach this number though
44 nr_files=$(($fs_size / $page_size))
46 # Use small fs to make the fill more faster
47 _scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
54 for i in $(seq -w $nr_files); do
55 # xfs_io can't return correct value when it hit ENOSPC, use
56 # dd here to detect ENOSPC
57 dd if=/dev/zero of=$SCRATCH_MNT/$i bs=$page_size count=1 \
67 # remount to sync every thing into fs, and drop all cache
70 # remove all files with odd file names, which should free near half
72 rm $SCRATCH_MNT/*[13579]
75 # We should be able to write at least 1/8 of the whole fs size
76 # The number 1/8 is for btrfs, which only has about 47M for data.
77 # And half of the 47M is already taken up, so only 1/8 is safe here
78 $XFS_IO_PROG -f -c "pwrite 0 $(($fs_size / 8))" $SCRATCH_MNT/large_file | \