2 # FSQA Test No. btrfs/074
4 # Run btrfs defrag operations and remount with different compress algorithms
5 # simultaneously with fsstress running in background.
7 #-----------------------------------------------------------------------
8 # Copyright (C) 2014 Red Hat Inc. All rights reserved.
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.
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.
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
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
33 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
45 # real QA test starts here
48 # we check scratch dev after each loop
49 _require_scratch_nocheck
50 _require_scratch_dev_pool 4
51 _btrfs_get_profile_configs
58 local with_compress=$2
60 echo "Test $mkfs_opts with $with_compress" >>$seqres.full
62 _scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
63 # make sure we created btrfs with desired options
65 echo "mkfs $mkfs_opts failed"
68 _scratch_mount >>$seqres.full 2>&1
70 args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
71 echo "Run fsstress $args" >>$seqres.full
72 $FSSTRESS_PROG $args >/dev/null 2>&1 &
75 echo -n "Start defrag worker: " >>$seqres.full
76 _btrfs_stress_defrag $SCRATCH_MNT $with_compress >/dev/null 2>&1 &
78 echo "$defrag_pid" >>$seqres.full
80 echo -n "Start remount worker: " >>$seqres.full
81 _btrfs_stress_remount_compress $SCRATCH_MNT >/dev/null 2>&1 &
83 echo "$remount_pid" >>$seqres.full
85 echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
87 kill $defrag_pid $remount_pid
89 # wait for the defrag and remount operations to finish
90 while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
93 while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
97 echo "Scrub the filesystem" >>$seqres.full
98 $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
100 echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
104 # we called _require_scratch_nocheck instead of _require_scratch
105 # do check after test for each profile config
109 echo "Silence is golden"
110 for t in "${_btrfs_profile_configs[@]}"; do
111 run_test "$t" nocompress
112 run_test "$t" compress