2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2014 Red Hat Inc. All rights reserved.
5 # FSQA Test No. btrfs/069
7 # Run btrfs replace operations and scrub simultaneously with fsstress
8 # running in background.
11 _begin_fstest auto replace scrub volume
13 # Import common functions.
16 # real QA test starts here
18 # we check scratch dev after each loop
19 _require_scratch_nocheck
20 _require_scratch_dev_pool 5
21 _require_scratch_dev_pool_equal_size
22 _btrfs_get_profile_configs replace
27 local saved_scratch_dev_pool=$SCRATCH_DEV_POOL
29 echo "Test $mkfs_opts" >>$seqres.full
31 # remove the last device from the SCRATCH_DEV_POOL list so
32 # _scratch_pool_mkfs won't use all devices in pool
33 local last_dev="`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`"
34 SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$last_dev *##"`
35 _scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
36 # make sure we created btrfs with desired options
38 echo "mkfs $mkfs_opts failed"
39 SCRATCH_DEV_POOL=$saved_scratch_dev_pool
42 _scratch_mount >>$seqres.full 2>&1
43 SCRATCH_DEV_POOL=$saved_scratch_dev_pool
45 args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
46 echo "Run fsstress $args" >>$seqres.full
47 $FSSTRESS_PROG $args >/dev/null 2>&1 &
50 echo -n "Start replace worker: " >>$seqres.full
51 _btrfs_stress_replace $SCRATCH_MNT >>$seqres.full 2>&1 &
53 echo "$replace_pid" >>$seqres.full
55 echo -n "Start scrub worker: " >>$seqres.full
56 _btrfs_stress_scrub $SCRATCH_MNT >/dev/null 2>&1 &
58 echo "$scrub_pid" >>$seqres.full
60 echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
62 kill $replace_pid $scrub_pid
65 # wait for the scrub and replace operations to finish
66 while ps aux | grep "scrub start" | grep -qv grep; do
69 while ps aux | grep "replace start" | grep -qv grep; do
73 echo "Scrub the filesystem" >>$seqres.full
74 $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
76 echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
80 # we called _require_scratch_nocheck instead of _require_scratch
81 # do check after test for each profile config
85 echo "Silence is golden"
86 for t in "${_btrfs_profile_configs[@]}"; do