xfs/530: skip test if user MKFS_OPTIONS screw up formatting
[xfstests-dev.git] / tests / xfs / 335
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. 335
6 #
7 # Exercise expanding and shrinking the realtime rmap btree.
8 #
9 . ./common/preamble
10 _begin_fstest auto rmap realtime
11
12 # Import common functions.
13 . ./common/filter
14
15 # real QA test starts here
16 _supported_fs xfs
17 _require_realtime
18 _require_xfs_scratch_rmapbt
19 _require_test_program "punch-alternating"
20 _require_xfs_io_command "falloc"
21
22 rm -f "$seqres.full"
23
24 echo "Format and mount"
25 _scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
26 . $tmp.mkfs
27 cat $tmp.mkfs > "$seqres.full" 2>&1
28 _scratch_mount
29 blksz="$(_get_block_size $SCRATCH_MNT)"
30
31 echo "Create a three-level rtrmapbt"
32 # inode core size is at least 176 bytes; btree header is 56 bytes;
33 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
34 i_ptrs=$(( (isize - 176) / 56 ))
35 bt_ptrs=$(( (blksz - 56) / 56 ))
36 bt_recs=$(( (blksz - 56) / 32 ))
37
38 blocks=$((i_ptrs * bt_ptrs * bt_recs))
39 # Need (2 * blocks * blksz) bytes for files, and 20% more for metadata
40 _require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
41 len=$((blocks * rtextsz))
42
43 echo "Create big file"
44 $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
45 $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
46
47 echo "Explode the rtrmapbt"
48 $here/src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
49 $here/src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
50 _scratch_cycle_mount
51
52 echo "Remove half the records"
53 rm -rf $SCRATCH_MNT/f1
54 _scratch_cycle_mount
55
56 echo "Remove the rest of the records"
57 rm -rf $SCRATCH_MNT/f2
58
59 # success, all done
60 status=0
61 exit