2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that we can create enough distinct rmap entries to force creation
8 # of a multi-level rmap btree, and that metadump will successfully copy
12 _begin_fstest auto quick rmap punch
14 # Override the default cleanup function.
18 _scratch_unmount > /dev/null 2>&1
19 rm -rf $tmp.* $metadump_file $TEST_DIR/image
22 # Import common functions.
25 # real QA test starts here
28 _require_xfs_scratch_rmapbt
29 _require_xfs_io_command "fpunch"
31 _scratch_mkfs >/dev/null 2>&1
34 testdir=$SCRATCH_MNT/test-$seq
36 metadump_file=$TEST_DIR/${seq}_metadump
38 echo "Create the original file blocks"
39 blksz="$(_get_block_size $testdir)"
40 nr_blks=$((4 * blksz / 12))
41 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
44 echo "Punch every other block"
45 seq 1 2 $((nr_blks - 1)) | while read nr; do
46 $XFS_IO_PROG -c "fpunch $((nr * blksz)) $blksz" $testdir/file1 >> $seqres.full
49 echo "Create metadump file"
51 _scratch_xfs_metadump $metadump_file
53 # Now restore the obfuscated one back and take a look around
54 echo "Restore metadump"
55 xfs_mdrestore $metadump_file $TEST_DIR/image
56 SCRATCH_DEV=$TEST_DIR/image _scratch_mount
57 SCRATCH_DEV=$TEST_DIR/image _scratch_unmount
59 echo "Check restored fs"
60 _check_generic_filesystem $metadump_file