btrfs: fsync after hole punching with no-holes mode
[xfstests-dev.git] / tests / btrfs / 078
1 #! /bin/bash
2 # FSQA Test No. 078
3 #
4 # Regression test for a btrfs issue where creation of readonly snapshots caused
5 # the filesystem to get into an inconsistent state.
6 #
7 # This regression was introduced in the 3.17 kernel and fixed by reverting the
8 # following linux kernel commit:
9 #
10 #     Btrfs: race free update of commit root for ro snapshots
11 #     9c3b306e1c9e6be4be09e99a8fe2227d1005effc
12 #
13 #-----------------------------------------------------------------------
14 #
15 # Copyright (C) 2014 SUSE Linux Products GmbH. All Rights Reserved.
16 # Author: Filipe Manana <fdmanana@suse.com>
17 #
18 # This program is free software; you can redistribute it and/or
19 # modify it under the terms of the GNU General Public License as
20 # published by the Free Software Foundation.
21 #
22 # This program is distributed in the hope that it would be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 # GNU General Public License for more details.
26 #
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write the Free Software Foundation,
29 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30 #-----------------------------------------------------------------------
31 #
32
33 seq=`basename $0`
34 seqres=$RESULT_DIR/$seq
35 echo "QA output created by $seq"
36
37 tmp=`mktemp -d`
38 status=1        # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 _cleanup()
42 {
43         rm -fr $tmp
44 }
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49
50 # real QA test starts here
51 _supported_fs btrfs
52 _supported_os Linux
53 _require_scratch
54
55 rm -f $seqres.full
56
57 workout()
58 {
59         ops=$1
60         procs=$2
61         num_snapshots=$3
62
63         _scratch_mkfs >> $seqres.full 2>&1
64         _scratch_mount
65
66         snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT"
67         snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`"
68         run_check $FSSTRESS_PROG -p $procs \
69             -x "$snapshot_cmd" -X $num_snapshots -d $SCRATCH_MNT -n $ops
70 }
71
72 ops=8000
73 procs=4
74 snapshots=100
75 workout $ops $procs $snapshots
76
77 # The fstests framework runs a file system check against the scratch device
78 # automatically when a test case finishes (if the test calls _require_scratch).
79 # That filesystem check (btrfsck, btrfs.fsck) failed reporting several fs
80 # inconsistencies. Therefore there's no need to call _check_scratch_fs here.
81
82 echo "Silence is golden"
83 status=0
84 exit