2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Exercise metadump on realtime rmapbt preservation.
10 seqres="$RESULT_DIR/$seq"
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
21 rm -rf "$tmp".* $metadump_file
24 # get standard environment, filters and checks
28 # real QA test starts here
31 _require_xfs_scratch_rmapbt
32 _require_test_program "punch-alternating"
33 _require_xfs_io_command "falloc"
37 echo "Format and mount"
38 _scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
40 cat $tmp.mkfs > "$seqres.full" 2>&1
42 blksz="$(_get_file_block_size $SCRATCH_MNT)"
44 metadump_file=$TEST_DIR/${seq}_metadump
47 echo "Create a three-level rtrmapbt"
48 # inode core size is at least 176 bytes; btree header is 56 bytes;
49 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
50 i_ptrs=$(( (isize - 176) / 56 ))
51 bt_ptrs=$(( (blksz - 56) / 56 ))
52 bt_recs=$(( (blksz - 56) / 32 ))
54 blocks=$((i_ptrs * bt_ptrs * bt_recs))
55 _require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
56 len=$((blocks * rtextsz))
58 echo "Create big file"
59 $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
60 $XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
62 echo "Explode the rtrmapbt"
63 $here/src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
64 $here/src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
67 echo "Create metadump file"
69 _scratch_metadump $metadump_file
71 # Now restore the obfuscated one back and take a look around
72 echo "Restore metadump"
73 xfs_mdrestore $metadump_file $TEST_DIR/image
74 SCRATCH_DEV=$TEST_DIR/image _scratch_mount
75 SCRATCH_DEV=$TEST_DIR/image _scratch_unmount
77 echo "Check restored fs"
78 _check_scratch_fs $TEST_DIR/image