xfs/331: don't run this test if fallocate isn't supported
[xfstests-dev.git] / tests / xfs / 331
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 331
6 #
7 # Create a big enough rmapbt that we tickle a fdblocks accounting bug.
8 #
9 seq=`basename "$0"`
10 seqres="$RESULT_DIR/$seq"
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -rf "$tmp".*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/reflink
28
29 # real QA test starts here
30 _supported_os Linux
31 _supported_fs xfs
32 _require_scratch
33 _require_xfs_scratch_rmapbt
34 _require_scratch_reflink
35 _require_xfs_io_command "falloc"
36 _require_test_program "punch-alternating"
37
38 rm -f "$seqres.full"
39
40 echo "+ create scratch fs"
41 _scratch_mkfs > "$seqres.full" 2>&1
42
43 echo "+ mount fs image"
44 _scratch_mount
45 blksz="$(_get_block_size $SCRATCH_MNT)"
46
47 # btree header is 56 bytes; an rmapbt record is 24 bytes; and
48 # a rmapbt key/pointer pair is 44 bytes.
49 bt_ptrs=$(( (blksz - 56) / 44 ))
50 bt_recs=$(( (blksz - 56) / 24 ))
51
52 blocks=$((bt_ptrs * bt_recs + 1))
53 # Need (2 * blocks * blksz) bytes for files, and 20% for metadata
54 _require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
55 len=$((blocks * blksz))
56
57 echo "+ make some files"
58 $XFS_IO_PROG -f -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
59 $XFS_IO_PROG -f -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
60 $here/src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
61 $here/src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
62
63 # success, all done
64 status=0
65 exit