fsx/fsstress: round blocksize properly
[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 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
28 # real QA test starts here
29 _supported_fs xfs
30 _require_realtime
31 _require_xfs_scratch_rmapbt
32 _require_test_program "punch-alternating"
33 _require_xfs_io_command "falloc"
34
35 rm -f "$seqres.full"
36
37 echo "Format and mount"
38 _scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
39 . $tmp.mkfs
40 cat $tmp.mkfs > "$seqres.full" 2>&1
41 _scratch_mount
42 blksz="$(_get_block_size $SCRATCH_MNT)"
43
44 echo "Create a three-level rtrmapbt"
45 # inode core size is at least 176 bytes; btree header is 56 bytes;
46 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
47 i_ptrs=$(( (isize - 176) / 56 ))
48 bt_ptrs=$(( (blksz - 56) / 56 ))
49 bt_recs=$(( (blksz - 56) / 32 ))
50
51 blocks=$((i_ptrs * bt_ptrs * bt_recs))
52 # Need (2 * blocks * blksz) bytes for files, and 20% more for metadata
53 _require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
54 len=$((blocks * rtextsz))
55
56 echo "Create big file"
57 $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
58 $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
59
60 echo "Explode the rtrmapbt"
61 $here/src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
62 $here/src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
63 _scratch_cycle_mount
64
65 echo "Remove half the records"
66 rm -rf $SCRATCH_MNT/f1
67 _scratch_cycle_mount
68
69 echo "Remove the rest of the records"
70 rm -rf $SCRATCH_MNT/f2
71
72 # success, all done
73 status=0
74 exit