xfs/029: filter out "extended-header: cycle: 1" from output
[xfstests-dev.git] / tests / xfs / 336
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. 336
6 #
7 # Exercise metadump on realtime rmapbt preservation.
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".* $metadump_file
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # real QA test starts here
29 _supported_os Linux
30 _supported_fs xfs
31 _require_realtime
32 _require_xfs_scratch_rmapbt
33 _require_test_program "punch-alternating"
34 _require_xfs_io_command "falloc"
35
36 rm -f "$seqres.full"
37
38 echo "Format and mount"
39 _scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
40 . $tmp.mkfs
41 cat $tmp.mkfs > "$seqres.full" 2>&1
42 _scratch_mount
43 blksz="$(_get_block_size $SCRATCH_MNT)"
44
45 metadump_file=$TEST_DIR/${seq}_metadump
46 rm -rf $metadump_file
47
48 echo "Create a three-level rtrmapbt"
49 # inode core size is at least 176 bytes; btree header is 56 bytes;
50 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
51 i_ptrs=$(( (isize - 176) / 56 ))
52 bt_ptrs=$(( (blksz - 56) / 56 ))
53 bt_recs=$(( (blksz - 56) / 32 ))
54
55 blocks=$((i_ptrs * bt_ptrs * bt_recs))
56 _require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
57 len=$((blocks * rtextsz))
58
59 echo "Create big file"
60 $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
61 $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
62
63 echo "Explode the rtrmapbt"
64 $here/src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
65 $here/src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
66 _scratch_cycle_mount
67
68 echo "Create metadump file"
69 _scratch_unmount
70 _scratch_metadump $metadump_file
71
72 # Now restore the obfuscated one back and take a look around
73 echo "Restore metadump"
74 xfs_mdrestore $metadump_file $TEST_DIR/image
75 SCRATCH_DEV=$TEST_DIR/image _scratch_mount
76 SCRATCH_DEV=$TEST_DIR/image _scratch_unmount
77
78 echo "Check restored fs"
79 _check_scratch_fs $TEST_DIR/image
80
81 # success, all done
82 status=0
83 exit