2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
7 # Make sure we validate realtime extent size alignment for fallocate modes.
8 # This is a regression test for fe341eb151ec ("xfs: ensure that fpunch,
9 # fcollapse, and finsert operations are aligned to rt extent size")
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
30 # real QA test starts here
34 _require_xfs_io_command "fcollapse"
35 _require_xfs_io_command "finsert"
36 _require_xfs_io_command "funshare"
37 _require_xfs_io_command "fzero"
38 _require_xfs_io_command "falloc"
42 # Format filesystem with a 256k realtime extent size
43 _scratch_mkfs -r extsize=256k > $seqres.full
44 _scratch_mount >> $seqres.full
46 blksz=$(_get_block_size $SCRATCH_MNT)
47 rextsize=$($XFS_INFO_PROG $SCRATCH_MNT | grep realtime.*extsz | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g')
48 rextblks=$((rextsize / blksz))
50 echo "blksz $blksz rextsize $rextsize rextblks $rextblks" >> $seqres.full
52 # Make sure the root directory has rtinherit set so our test file will too
53 $XFS_IO_PROG -c 'chattr +t' $SCRATCH_MNT
55 sz=$((rextsize * 100))
56 range="$((blksz * 3)) $blksz"
58 for verb in fpunch finsert fcollapse fzero funshare falloc; do
60 $XFS_IO_PROG -f -c "falloc 0 $sz" "$SCRATCH_MNT/b"
61 $XFS_IO_PROG -f -c "$verb $range" "$SCRATCH_MNT/b"
62 rm -f "$SCRATCH_MNT/b"