btrfs: test incremental send after renaming and linking file
[xfstests-dev.git] / tests / btrfs / 063
1 #! /bin/bash
2 # FSQA Test No. btrfs/063
3 #
4 # Run btrfs balance and remount with different compress algorithms
5 # simultaneously, with fsstress running in background.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (C) 2014 Red Hat Inc. All rights reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37         cd /
38         rm -f $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_fs btrfs
47 _supported_os Linux
48 # we check scratch dev after each loop
49 _require_scratch_nocheck
50 _require_scratch_dev_pool 4
51 _btrfs_get_profile_configs
52
53 rm -f $seqres.full
54
55 run_test()
56 {
57         local mkfs_opts=$1
58
59         echo "Test $mkfs_opts" >>$seqres.full
60
61         _scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
62         # make sure we created btrfs with desired options
63         if [ $? -ne 0 ]; then
64                 echo "mkfs $mkfs_opts failed"
65                 return
66         fi
67         _scratch_mount >>$seqres.full 2>&1
68
69         args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
70         echo "Run fsstress $args" >>$seqres.full
71         $FSSTRESS_PROG $args >/dev/null 2>&1 &
72         fsstress_pid=$!
73
74         echo -n "Start balance worker: " >>$seqres.full
75         _btrfs_stress_balance $SCRATCH_MNT >/dev/null 2>&1 &
76         balance_pid=$!
77         echo "$balance_pid" >>$seqres.full
78
79         echo -n "Start remount worker: " >>$seqres.full
80         _btrfs_stress_remount_compress $SCRATCH_MNT >/dev/null 2>&1 &
81         remount_pid=$!
82         echo "$remount_pid" >>$seqres.full
83
84         echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
85         wait $fsstress_pid
86         kill $balance_pid $remount_pid
87         wait
88         # wait for the balance and remount loop to finish
89         while ps aux | grep "balance start" | grep -qv grep; do
90                 sleep 1
91         done
92         while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
93                 sleep 1
94         done
95
96         echo "Scrub the filesystem" >>$seqres.full
97         $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
98         if [ $? -ne 0 ]; then
99                 echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
100         fi
101
102         _scratch_unmount
103         # we called _require_scratch_nocheck instead of _require_scratch
104         # do check after test for each profile config
105         _check_scratch_fs
106 }
107
108 echo "Silence is golden"
109 for t in "${_btrfs_profile_configs[@]}"; do
110         run_test "$t"
111 done
112
113 status=0
114 exit