btrfs: fsync after hole punching with no-holes mode
[xfstests-dev.git] / tests / btrfs / 007
1 #! /bin/bash
2 # FSQA Test No. 007
3 #
4 # Run fsstress to create a reasonably strange file system, make a
5 # snapshot (base) and run more fsstress. Then take another snapshot
6 # (incr) and send both snapshots to a temp file. Remake the file
7 # system and receive from the files. Check both states with fssum.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (C) 2013 STRATO.  All rights reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #
25 #-----------------------------------------------------------------------
26 #
27 # creator
28 owner=list.btrfs@jan-o-sch.net
29
30 seq=`basename $0`
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
33
34 tmp=`mktemp -d`
35 status=1
36
37 _cleanup()
38 {
39         echo "*** unmount"
40         _scratch_unmount 2>/dev/null
41         rm -f $tmp.*
42 }
43 trap "_cleanup; exit \$status" 0 1 2 3 15
44
45 # get standard environment, filters and checks
46 . ./common/rc
47 . ./common/filter
48
49 # real QA test starts here
50 _supported_fs btrfs
51 _supported_os Linux
52 _require_scratch
53 _require_fssum
54 _require_seek_data_hole
55
56 rm -f $seqres.full
57
58 workout()
59 {
60         fsz=$1
61         ops=$2
62
63         _scratch_unmount >/dev/null 2>&1
64         echo "*** mkfs -dsize=$fsz"    >>$seqres.full
65         echo ""                                     >>$seqres.full
66         _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
67                 || _fail "size=$fsz mkfs failed"
68         _scratch_mount "-o noatime"
69
70         run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n $ops $FSSTRESS_AVOID -x \
71                 "$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/base"
72
73         _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/incr
74
75         echo "# $BTRFS_UTIL_PROG send $SCRATCH_MNT/base > $tmp/base.snap" \
76                 >> $seqres.full
77         $BTRFS_UTIL_PROG send $SCRATCH_MNT/base > $tmp/base.snap 2>> $seqres.full \
78                 || _fail "failed: '$@'"
79         echo "# $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/base\
80                 $SCRATCH_MNT/incr > $tmp/incr.snap" >> $seqres.full
81         $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/base \
82                 $SCRATCH_MNT/incr > $tmp/incr.snap 2>> $seqres.full \
83                 || _fail "failed: '$@'"
84
85         run_check $FSSUM_PROG -A -f -w $tmp/base.fssum $SCRATCH_MNT/base
86         run_check $FSSUM_PROG -A -f -w $tmp/incr.fssum -x $SCRATCH_MNT/incr/base \
87                 $SCRATCH_MNT/incr
88
89         _scratch_unmount >/dev/null 2>&1
90         echo "*** mkfs -dsize=$fsz"    >>$seqres.full
91         echo ""                                     >>$seqres.full
92         _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
93                 || _fail "size=$fsz mkfs failed"
94         _scratch_mount "-o noatime"
95
96         _run_btrfs_util_prog receive $SCRATCH_MNT < $tmp/base.snap
97         run_check $FSSUM_PROG -r $tmp/base.fssum $SCRATCH_MNT/base
98
99         _run_btrfs_util_prog receive $SCRATCH_MNT < $tmp/incr.snap
100         run_check $FSSUM_PROG -r $tmp/incr.fssum $SCRATCH_MNT/incr
101 }
102
103 echo "*** test send / receive"
104
105 fssize=`expr 2000 \* 1024 \* 1024`
106 ops=200
107
108 workout $fssize $ops
109
110 echo "*** done"
111 status=0
112 exit