4 # Ensure that we can create enough distinct reflink entries to force creation
5 # of a multi-level refcount btree, and that metadump will successfully copy
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
37 umount "$SCRATCH_MNT" > /dev/null 2>&1
38 rm -rf "$tmp".* "$TESTDIR" "$METADUMP_FILE" "$TEST_DIR/image"
41 # get standard environment, filters and checks
46 # real QA test starts here
50 _require_scratch_reflink
54 _scratch_mkfs >/dev/null 2>&1
57 TESTDIR="$SCRATCH_MNT/test-$seq"
60 METADUMP_FILE="$TEST_DIR/${seq}_metadump"
62 echo "Create the original file blocks"
63 BLKSZ="$(stat -f "$TESTDIR" -c '%S')"
64 NR_BLKS=$((4 * BLKSZ / 12))
65 _pwrite_byte 0x61 0 $((BLKSZ * NR_BLKS)) "$TESTDIR/file1" >> "$seqres.full"
67 echo "Reflink every other block"
68 seq 1 $((NR_BLKS / 2)) | while read nr; do
69 _reflink_range "$TESTDIR/file1" $((nr * 2 * BLKSZ)) \
70 "$TESTDIR/file2" $((nr * 2 * BLKSZ)) $BLKSZ >> "$seqres.full"
73 echo "Create metadump file"
75 _scratch_metadump "$METADUMP_FILE"
77 # Now restore the obfuscated one back and take a look around
78 echo "Restore metadump"
79 xfs_mdrestore "$METADUMP_FILE" "$TEST_DIR/image"
80 _mount -t $FSTYP "$TEST_DIR/image" "$SCRATCH_MNT"
83 echo "Check restored fs"
84 _check_generic_filesystem "$METADUMP_FILE"