xfs: convert tests to SPDX license tags
[xfstests-dev.git] / tests / xfs / 234
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. 234
6 #
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
9 # said block.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1    # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22     cd /
23     _scratch_unmount > /dev/null 2>&1
24     rm -rf $tmp.* $metadump_file $TEST_DIR/image
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_os Linux
33 _supported_fs xfs
34 _require_loop
35 _require_xfs_scratch_rmapbt
36 _require_xfs_io_command "fpunch"
37
38 rm -f $seqres.full
39
40 _scratch_mkfs >/dev/null 2>&1
41 _scratch_mount
42
43 testdir=$SCRATCH_MNT/test-$seq
44 mkdir $testdir
45 metadump_file=$TEST_DIR/${seq}_metadump
46
47 echo "Create the original file blocks"
48 blksz="$(_get_block_size $testdir)"
49 nr_blks=$((4 * blksz / 12))
50 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
51 sync
52
53 echo "Punch every other block"
54 seq 1 2 $((nr_blks - 1)) | while read nr; do
55         $XFS_IO_PROG -c "fpunch $((nr * blksz)) $blksz" $testdir/file1 >> $seqres.full
56 done
57
58 echo "Create metadump file"
59 _scratch_unmount
60 _scratch_metadump $metadump_file
61
62 # Now restore the obfuscated one back and take a look around
63 echo "Restore metadump"
64 xfs_mdrestore $metadump_file $TEST_DIR/image
65 SCRATCH_DEV=$TEST_DIR/image _scratch_mount
66 SCRATCH_DEV=$TEST_DIR/image _scratch_unmount
67
68 echo "Check restored fs"
69 _check_generic_filesystem $metadump_file
70
71 # success, all done
72 status=0
73 exit