btrfs/012: check free size of scratch device before copying files
[xfstests-dev.git] / tests / ext4 / 302
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # FSQA Test No. 302
6 #
7 # Ext4 defragmentation stress test
8 # Perform defragmentation on file under buffered io
9 # while third task does direct io to donor file
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 fio_config=$tmp.fio
17 status=1        # failure is the default!
18 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
19
20 # get standard environment, filters and checks
21 . ./common/rc
22 . ./common/filter
23 . ./common/defrag
24
25 # real QA test starts here
26 _supported_fs ext4
27 _require_scratch
28 _require_defrag
29 _require_odirect
30
31 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
32 # We need space for 2 files (test file, and donor one)
33 # reserve 30% in order to avoid ENOSPC
34 FILE_SIZE=$((BLK_DEV_SIZE * (512 / (2 + 1))))
35
36 cat >$fio_config <<EOF
37 # Common e4defrag regression tests
38 [global]
39 ioengine=ioe_e4defrag
40 iodepth=1
41 directory=${SCRATCH_MNT}
42 filesize=${FILE_SIZE}
43 size=999G
44 buffered=0
45 fadvise_hint=0
46 continue_on_error=write
47 ignore_error=,EBUSY
48
49 ##########################################
50 # Test2
51 # Perform defragmentation on file under buffered io
52 # while third task does direct io to donor file
53 #
54 # Continuous sequential defrag activity
55 [defrag-4k]
56 stonewall
57 ioengine=e4defrag
58 iodepth=1
59 bs=128k
60 donorname=test2.def
61 filename=test2
62 inplace=0
63 rw=write
64 numjobs=${LOAD_FACTOR}
65 runtime=30*${TIME_FACTOR}
66 time_based
67
68 # Run DIO/AIO for donor file
69 [donor-file-fuzzer]
70 ioengine=libaio
71 iodepth=128*${LOAD_FACTOR}
72 numjobs=${LOAD_FACTOR}
73 verify=0
74 direct=1
75 bs=64k
76 rw=randwrite
77 filename=test2.def
78 runtime=30*${TIME_FACTOR}
79 time_based
80
81 # Verifier thread
82 [aio-dio-verifier]
83 ioengine=libaio
84 iodepth=128*${LOAD_FACTOR}
85 numjobs=1
86 verify=crc32c-intel
87 verify_fatal=1
88 verify_dump=1
89 verify_backlog=1024
90 verify_async=1
91 verifysort=1
92 buffered=1
93 bs=64k
94 rw=randrw
95 filename=test2
96 runtime=30*${TIME_FACTOR}
97 time_based
98
99 EOF
100
101 _workout()
102 {
103         echo ""
104         echo " Start defragment activity"
105         echo ""
106         cat $fio_config >>  $seqres.full
107         run_check $FIO_PROG $fio_config
108 }
109
110 _require_fio $fio_config
111
112 rm -f $seqres.full
113 _scratch_mkfs  >> $seqres.full 2>&1
114 _scratch_mount
115
116 if ! _workout; then
117         _scratch_unmount 2>/dev/null
118         exit
119 fi
120
121 if ! _scratch_unmount; then
122         echo "failed to umount"
123         status=1
124         exit
125 fi
126 status=0
127 exit