xfs: test what happens when we reset the root dir and it has xattrs
[xfstests-dev.git] / tests / xfs / 265
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. 265
6 #
7 # Ensure that we can create enough distinct reflink entries to force creation
8 # of a multi-level refcount btree by reflinking a file a number of times and
9 # truncating the copies at successively lower sizes.  Delete and recreate a few
10 # times to exercise the refcount btree grow/shrink functions.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23     cd /
24     umount $SCRATCH_MNT > /dev/null 2>&1
25     rm -rf $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/reflink
32
33 # real QA test starts here
34 _supported_fs xfs
35 _require_scratch_reflink
36 _require_cp_reflink
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
46 echo "Create the original file blocks"
47 blksz="$(_get_block_size $testdir)"
48 nr_blks=$((2 * blksz / 12))
49
50 for i in 1 2 x; do
51         _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
52
53         echo "$i: Reflink a bunch of times"
54         seq 1 $nr_blks | while read nr; do
55                 _cp_reflink $testdir/file1 $testdir/file1.$nr >> $seqres.full
56         done
57         sync
58
59         echo "$i: Truncate files"
60         seq 1 $nr_blks | while read nr; do
61                 truncate -s $((blksz * (nr_blks - nr))) $testdir/file1.$nr >> $seqres.full
62         done
63
64         umount $SCRATCH_MNT
65         _check_scratch_fs
66         _scratch_mount
67
68         test $i = "x" && break
69
70         echo "$i: Delete both files"
71         rm -rf $testdir
72         mkdir -p $testdir
73         umount $SCRATCH_MNT
74         _check_scratch_fs
75         _scratch_mount
76 done
77
78 # success, all done
79 status=0
80 exit