xfs/530: skip test if user MKFS_OPTIONS screw up formatting
[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 . ./common/preamble
10 _begin_fstest auto rmap realtime
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15         cd /
16         rm -rf "$tmp".* $metadump_file
17 }
18
19 # Import common functions.
20 . ./common/filter
21
22 # real QA test starts here
23 _supported_fs xfs
24 _require_realtime
25 _require_xfs_scratch_rmapbt
26 _require_test_program "punch-alternating"
27 _require_xfs_io_command "falloc"
28
29 rm -f "$seqres.full"
30
31 echo "Format and mount"
32 _scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
33 . $tmp.mkfs
34 cat $tmp.mkfs > "$seqres.full" 2>&1
35 _scratch_mount
36 blksz="$(_get_file_block_size $SCRATCH_MNT)"
37
38 metadump_file=$TEST_DIR/${seq}_metadump
39 rm -rf $metadump_file
40
41 echo "Create a three-level rtrmapbt"
42 # inode core size is at least 176 bytes; btree header is 56 bytes;
43 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
44 i_ptrs=$(( (isize - 176) / 56 ))
45 bt_ptrs=$(( (blksz - 56) / 56 ))
46 bt_recs=$(( (blksz - 56) / 32 ))
47
48 blocks=$((i_ptrs * bt_ptrs * bt_recs))
49 _require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
50 len=$((blocks * rtextsz))
51
52 echo "Create big file"
53 $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
54 $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
55
56 echo "Explode the rtrmapbt"
57 $here/src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
58 $here/src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
59 _scratch_cycle_mount
60
61 echo "Create metadump file"
62 _scratch_unmount
63 _scratch_xfs_metadump $metadump_file
64
65 # Now restore the obfuscated one back and take a look around
66 echo "Restore metadump"
67 xfs_mdrestore $metadump_file $TEST_DIR/image
68 SCRATCH_DEV=$TEST_DIR/image _scratch_mount
69 SCRATCH_DEV=$TEST_DIR/image _scratch_unmount
70
71 echo "Check restored fs"
72 _check_scratch_fs $TEST_DIR/image
73
74 # success, all done
75 status=0
76 exit