common/rc: add _scratch_{u}mount_idmapped() helpers
[xfstests-dev.git] / tests / xfs / 169
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. 169
6 #
7 # Ensure that we can create enough distinct reflink entries to force creation
8 # of a multi-level refcount btree.  Delete and recreate a few times to
9 # exercise the refcount btree grow/shrink functions.
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     umount $SCRATCH_MNT > /dev/null 2>&1
24     rm -rf $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30 . ./common/reflink
31
32 # real QA test starts here
33 _supported_fs xfs
34 _require_scratch_reflink
35
36 rm -f $seqres.full
37
38 _scratch_mkfs >/dev/null 2>&1
39 _scratch_mount
40
41 testdir=$SCRATCH_MNT/test-$seq
42 mkdir $testdir
43
44 echo "Create the original file blocks"
45 blksz="$(_get_file_block_size $testdir)"
46 nr_blks=$((8 * blksz / 12))
47
48 for i in 1 2 x; do
49         _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
50
51         echo "$i: Reflink every other block"
52         seq 1 2 $((nr_blks - 1)) | while read nr; do
53                 _reflink_range  $testdir/file1 $((nr * blksz)) \
54                                 $testdir/file2 $((nr * blksz)) $blksz >> $seqres.full
55         done
56         umount $SCRATCH_MNT
57         _check_scratch_fs
58         _scratch_mount
59
60         test $i = "x" && break
61
62         echo "$i: Delete both files"
63         rm -rf $testdir/file1 $testdir/file2
64         umount $SCRATCH_MNT
65         _check_scratch_fs
66         _scratch_mount
67 done
68
69 # success, all done
70 status=0
71 exit