xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / btrfs / 073
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2014 Red Hat Inc. All rights reserved.
4 #
5 # FSQA Test No. btrfs/073
6 #
7 # Run btrfs scrub and remount with different compress algorithms
8 # simultaneously with fsstress running in background.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # real QA test starts here
30 _supported_fs btrfs
31 # we check scratch dev after each loop
32 _require_scratch_nocheck
33 _require_scratch_dev_pool 4
34 _btrfs_get_profile_configs
35
36 rm -f $seqres.full
37
38 run_test()
39 {
40         local mkfs_opts=$1
41
42         echo "Test $mkfs_opts" >>$seqres.full
43
44         _scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
45         # make sure we created btrfs with desired options
46         if [ $? -ne 0 ]; then
47                 echo "mkfs $mkfs_opts failed"
48                 return
49         fi
50         _scratch_mount >>$seqres.full 2>&1
51
52         args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
53         echo "Run fsstress $args" >>$seqres.full
54         $FSSTRESS_PROG $args >/dev/null 2>&1 &
55         fsstress_pid=$!
56
57         echo -n "Start scrub worker: " >>$seqres.full
58         _btrfs_stress_scrub $SCRATCH_MNT >/dev/null 2>&1 &
59         scrub_pid=$!
60         echo "$scrub_pid" >>$seqres.full
61
62         echo -n "Start remount worker: " >>$seqres.full
63         _btrfs_stress_remount_compress $SCRATCH_MNT >/dev/null 2>&1 &
64         remount_pid=$!
65         echo "$remount_pid" >>$seqres.full
66
67         echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
68         wait $fsstress_pid
69         kill $scrub_pid $remount_pid
70         wait
71         # wait for the scrub and remount operations to finish
72         while ps aux | grep "scrub start" | grep -qv grep; do
73                 sleep 1
74         done
75         while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
76                 sleep 1
77         done
78
79         echo "Scrub the filesystem" >>$seqres.full
80         $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
81         if [ $? -ne 0 ]; then
82                 echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
83         fi
84
85         _scratch_unmount
86         # we called _require_scratch_nocheck instead of _require_scratch
87         # do check after test for each profile config
88         _check_scratch_fs
89 }
90
91 echo "Silence is golden"
92 for t in "${_btrfs_profile_configs[@]}"; do
93         run_test "$t"
94 done
95
96 status=0
97 exit