common/rc: factor out _scratch_xfs_[get|set]_sb_field
[xfstests-dev.git] / tests / xfs / 236
1 #! /bin/bash
2 # FS QA Test No. 236
3 #
4 # Ensure that we can create enough distinct rmapbt entries to force creation
5 # of a multi-level rmap btree.  Delete and recreate a few times to
6 # exercise the rmap btree grow/shrink functions.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
10 #
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.
14 #
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.
19 #
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 #-----------------------------------------------------------------------
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1    # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     cd /
37     umount $SCRATCH_MNT > /dev/null 2>&1
38     rm -rf $tmp.*
39 }
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44
45 # real QA test starts here
46 _supported_os Linux
47 _supported_fs xfs
48 _require_xfs_scratch_rmapbt
49 _require_xfs_io_command "fpunch"
50
51 rm -f $seqres.full
52
53 _scratch_mkfs >/dev/null 2>&1
54 _scratch_mount
55
56 testdir=$SCRATCH_MNT/test-$seq
57 mkdir $testdir
58
59 echo "Create the original file blocks"
60 blksz="$(_get_block_size $testdir)"
61 nr_blks=$((8 * blksz / 12))
62
63 for i in 1 2 x; do
64         _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
65         _pwrite_byte 0x62 0 $((blksz * nr_blks)) $testdir/file2 >> $seqres.full
66         sync
67
68         echo "$i: Reflink every other block"
69         seq 1 2 $((nr_blks - 1)) | while read nr; do
70                 $XFS_IO_PROG -c "fpunch $((nr * blksz)) $blksz" $testdir/file2 >> $seqres.full
71         done
72         umount $SCRATCH_MNT
73         _check_scratch_fs
74         _scratch_mount
75
76         test $i = "x" && break
77
78         echo "$i: Delete both files"
79         rm -rf $testdir/file1 $testdir/file2
80         umount $SCRATCH_MNT
81         _check_scratch_fs
82         _scratch_mount
83 done
84
85 # success, all done
86 status=0
87 exit