generic/233,270: unlimit the max locked memory size for io_uring
[xfstests-dev.git] / tests / btrfs / 066
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/066
6 #
7 # Run btrfs subvolume create/mount/umount/delete and btrfs scrub
8 # operation 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         local subvol_mnt=$TEST_DIR/$seq.mnt
42         local stop_file=$TEST_DIR/$seq.stop.$$
43
44         echo "Test $mkfs_opts" >>$seqres.full
45
46         _scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
47         # make sure we created btrfs with desired options
48         if [ $? -ne 0 ]; then
49                 echo "mkfs $mkfs_opts failed"
50                 return
51         fi
52         _scratch_mount >>$seqres.full 2>&1
53
54         args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
55         echo "Run fsstress $args" >>$seqres.full
56         $FSSTRESS_PROG $args >/dev/null 2>&1 &
57         fsstress_pid=$!
58
59         # make sure the stop sign is not there
60         rm -f $stop_file
61         echo -n "Start subvolume worker: " >>$seqres.full
62         _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
63         subvol_pid=$!
64         echo "$subvol_pid" >>$seqres.full
65
66         echo -n "Start scrub worker: " >>$seqres.full
67         _btrfs_stress_scrub $SCRATCH_MNT >/dev/null 2>&1 &
68         scrub_pid=$!
69         echo "$scrub_pid" >>$seqres.full
70
71         echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
72         wait $fsstress_pid
73
74         touch $stop_file
75         kill $scrub_pid
76         wait
77         # wait for the scrub operation to finish
78         while ps aux | grep "scrub start" | grep -qv grep; do
79                 sleep 1
80         done
81
82         echo "Scrub the filesystem" >>$seqres.full
83         $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
84         if [ $? -ne 0 ]; then
85                 echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
86         fi
87
88         # in case the subvolume is still mounted
89         $UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
90         _scratch_unmount
91         # we called _require_scratch_nocheck instead of _require_scratch
92         # do check after test for each profile config
93         _check_scratch_fs
94 }
95
96 echo "Silence is golden"
97 for t in "${_btrfs_profile_configs[@]}"; do
98         run_test "$t"
99 done
100
101 status=0
102 exit