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 rmapbt entries to force creation
8 # of a multi-level rmap btree. Delete and recreate a few times to
9 # exercise the rmap btree grow/shrink functions.
12 _begin_fstest auto rmap punch
14 # Override the default cleanup function.
18 umount $SCRATCH_MNT > /dev/null 2>&1
22 # Import common functions.
25 # real QA test starts here
27 _require_xfs_scratch_rmapbt
28 _require_xfs_io_command "fpunch"
30 _scratch_mkfs >/dev/null 2>&1
33 testdir=$SCRATCH_MNT/test-$seq
36 echo "Create the original file blocks"
37 blksz="$(_get_block_size $testdir)"
38 nr_blks=$((8 * blksz / 12))
41 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
42 _pwrite_byte 0x62 0 $((blksz * nr_blks)) $testdir/file2 >> $seqres.full
45 echo "$i: Reflink every other block"
46 seq 1 2 $((nr_blks - 1)) | while read nr; do
47 $XFS_IO_PROG -c "fpunch $((nr * blksz)) $blksz" $testdir/file2 >> $seqres.full
53 test $i = "x" && break
55 echo "$i: Delete both files"
56 rm -rf $testdir/file1 $testdir/file2