5cc363aab11d58410d7b8f18fd50a7582759142b
[xfstests-dev.git] / tests / xfs / 147
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 147
6 #
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")
10
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1    # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs xfs
32 _require_scratch
33 _require_realtime
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"
39
40 rm -f $seqres.full
41
42 # Format filesystem with a 256k realtime extent size
43 _scratch_mkfs -r extsize=256k > $seqres.full
44 _scratch_mount >> $seqres.full
45
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))
49
50 echo "blksz $blksz rextsize $rextsize rextblks $rextblks" >> $seqres.full
51
52 # Make sure the root directory has rtinherit set so our test file will too
53 _xfs_force_bdev realtime $SCRATCH_MNT
54
55 sz=$((rextsize * 100))
56 range="$((blksz * 3)) $blksz"
57
58 for verb in fpunch finsert fcollapse fzero funshare falloc; do
59         echo "test $verb"
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"
63         _scratch_cycle_mount
64 done
65
66 # success, all done
67 status=0
68 exit