generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 060
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/060
6 #
7 # Run btrfs balance and subvolume create/mount/umount/delete simultaneously,
8 # with fsstress running in background.
9 #
10 . ./common/preamble
11 _begin_fstest auto balance subvol
12
13 # Import common functions.
14 . ./common/filter
15
16 # real QA test starts here
17 _supported_fs btrfs
18 # we check scratch dev after each loop
19 _require_scratch_nocheck
20 _require_scratch_dev_pool 4
21 _btrfs_get_profile_configs
22
23 run_test()
24 {
25         local mkfs_opts=$1
26         local subvol_mnt=$TEST_DIR/$seq.mnt
27         local stop_file=$TEST_DIR/$seq.stop.$$
28
29         echo "Test $mkfs_opts" >>$seqres.full
30
31         _scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
32         # make sure we created btrfs with desired options
33         if [ $? -ne 0 ]; then
34                 echo "mkfs $mkfs_opts failed" | tee -a $seqres.full
35                 return
36         fi
37         _scratch_mount >>$seqres.full 2>&1
38
39         args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
40         echo "Run fsstress $args" >>$seqres.full
41         $FSSTRESS_PROG $args >/dev/null 2>&1 &
42         fsstress_pid=$!
43
44         echo -n "Start balance worker: " >>$seqres.full
45         _btrfs_stress_balance $SCRATCH_MNT >/dev/null 2>&1 &
46         balance_pid=$!
47         echo "$balance_pid" >>$seqres.full
48
49         # make sure the stop sign is not there
50         rm -f $stop_file
51         echo -n "Start subvolume worker: " >>$seqres.full
52         _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
53         subvol_pid=$!
54         echo "$subvol_pid" >>$seqres.full
55
56         echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
57         wait $fsstress_pid
58
59         touch $stop_file
60         kill $balance_pid
61         wait
62         # wait for the balance operation to finish
63         while ps aux | grep "balance start" | grep -qv grep; do
64                 sleep 1
65         done
66
67         echo "Scrub the filesystem" >>$seqres.full
68         $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
69         if [ $? -ne 0 ]; then
70                 echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
71         fi
72
73         # in case the subvolume is still mounted
74         $UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
75         _scratch_unmount
76         # we called _require_scratch_nocheck instead of _require_scratch
77         # do check after test for each profile config
78         _check_scratch_fs
79 }
80
81 echo "Silence is golden"
82 for t in "${_btrfs_profile_configs[@]}"; do
83         run_test "$t"
84 done
85
86 status=0
87 exit