btrfs/139: require 2GB scratch dev
[xfstests-dev.git] / tests / btrfs / 036
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/036
6 #
7 # Regression test for running snapshots and send concurrently.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 snapshots_pid=0
17
18 _cleanup()
19 {
20         # kill backgroud snapshots
21         if [ $snapshots_pid -ne 0 ] && ps -p $snapshots_pid | grep -q $snapshots_pid; then
22                 kill -TERM $snapshots_pid 2> /dev/null
23                 wait $snapshots_pid
24         fi
25         rm -f $tmp.*
26 }
27
28 do_snapshots()
29 {
30         # Wait for any running 'btrfs subvolume snapshot' subcommand before
31         # exitting so that after the test kills the subshell running this
32         # function, it does not fail with EBUSY when unmounting the scratch
33         # device.
34         trap "wait; exit" SIGTERM
35
36         i=2
37         while [ 1 ]
38         do
39                 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/snap_1 \
40                         $SCRATCH_MNT/snap_$i >> $seqres.full 2>&1
41                 let i=$i+1
42                 sleep 1
43         done
44 }
45
46 trap "_cleanup ; exit \$status" 0 1 2 3 15
47
48 # get standard environment, filters and checks
49 . ./common/rc
50 . ./common/filter
51
52 # real QA test starts here
53 _supported_fs btrfs
54 _supported_os Linux
55 _require_scratch
56
57 _scratch_mkfs > /dev/null 2>&1
58 _scratch_mount
59
60 touch $SCRATCH_MNT/foo
61
62 # get file with fragments by using backwards writes.
63 for i in `seq 10240 -1 1`; do
64         $XFS_IO_PROG -f -d -c "pwrite $(($i * 4096)) 4096" \
65                 $SCRATCH_MNT/foo > /dev/null | _filter_xfs_io
66 done
67
68 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
69         $SCRATCH_MNT/snap_1 >> $seqres.full 2>&1
70
71 do_snapshots &
72 snapshots_pid=$!
73
74 $BTRFS_UTIL_PROG send -f /dev/null $SCRATCH_MNT/snap_1 2>&1 | _filter_scratch
75
76 status=0 ; exit