xfs: Check for extent overflow when trivally adding a new extent
[xfstests-dev.git] / tests / btrfs / 068
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/068
6 #
7 # Run btrfs subvolume create/mount/umount/delete and remount with
8 # different compress algorithms simultaneously, with fsstress running
9 # in background.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs btrfs
32 # we check scratch dev after each loop
33 _require_scratch_nocheck
34 _require_scratch_dev_pool 4
35 _btrfs_get_profile_configs
36
37 rm -f $seqres.full
38
39 run_test()
40 {
41         local mkfs_opts=$1
42         local subvol_mnt=$TEST_DIR/$seq.mnt
43         local stop_file=$TEST_DIR/$seq.stop.$$
44
45         echo "Test $mkfs_opts with $with_compress" >>$seqres.full
46
47         _scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1
48         # make sure we created btrfs with desired options
49         if [ $? -ne 0 ]; then
50                 echo "mkfs $mkfs_opts failed"
51                 return
52         fi
53         _scratch_mount >>$seqres.full 2>&1
54
55         args=`_scale_fsstress_args -p 20 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
56         echo "Run fsstress $args" >>$seqres.full
57         $FSSTRESS_PROG $args >/dev/null 2>&1 &
58         fsstress_pid=$!
59
60         # make sure the stop sign is not there
61         rm -f $stop_file
62         echo -n "Start subvolume worker: " >>$seqres.full
63         _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
64         subvol_pid=$!
65         echo "$subvol_pid" >>$seqres.full
66
67         echo -n "Start remount worker: " >>$seqres.full
68         _btrfs_stress_remount_compress $SCRATCH_MNT >/dev/null 2>&1 &
69         remount_pid=$!
70         echo "$remount_pid" >>$seqres.full
71
72         echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
73         wait $fsstress_pid
74
75         touch $stop_file
76         kill $remount_pid
77         wait
78         # wait for the remount loop process to finish
79         while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
80                 sleep 1
81         done
82
83         echo "Scrub the filesystem" >>$seqres.full
84         $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
85         if [ $? -ne 0 ]; then
86                 echo "Scrub find errors in \"$mkfs_opts\" test" | tee -a $seqres.full
87         fi
88
89         # in case the subvolume is still mounted
90         $UMOUNT_PROG $subvol_mnt >/dev/null 2>&1
91         _scratch_unmount
92         # we called _require_scratch_nocheck instead of _require_scratch
93         # do check after test for each profile config
94         _check_scratch_fs
95 }
96
97 echo "Silence is golden"
98 for t in "${_btrfs_profile_configs[@]}"; do
99         run_test "$t"
100 done
101
102 status=0
103 exit