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