misc: move exit status into trap handler
[xfstests-dev.git] / tests / ext4 / 304
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # FSQA Test No. 304
6 #
7 # Ext4 defragmentation stress test
8 # Several threads perform defragmentation at random position
9 # using 'inplace' mode (allocate and free blocks inside defrag event)
10 # which significantly improve load pressure on block allocator.
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 fio_config=$tmp.fio
18 status=1        # failure is the default!
19 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20
21 # get standard environment, filters and checks
22 . ./common/rc
23 . ./common/filter
24 . ./common/defrag
25
26 # real QA test starts here
27 _supported_fs ext4
28 _require_scratch
29 _require_defrag
30 _require_odirect
31
32 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
33 # We need space for 2 files (test file, and donor one)
34 # reserve 30% in order to avoid ENOSPC
35 FILE_SIZE=$((BLK_DEV_SIZE * (512 / (2 + 1))))
36
37 cat >$fio_config <<EOF
38 # Common e4defrag regression tests
39 [global]
40 ioengine=ioe_e4defrag
41 iodepth=1
42 directory=${SCRATCH_MNT}
43 filesize=${FILE_SIZE}
44 size=999G
45 buffered=0
46 fadvise_hint=0
47 continue_on_error=write
48 ignore_error=,EINVAL:61
49
50 #################################
51 # Test4
52 # Stress test defragmentation engine
53 # Several threads perform defragmentation at random position
54 # use inplace=1 will allocate and free blocks inside defrag event
55 # which highly increase defragmentation
56 [defrag-fuzzer]
57 ioengine=e4defrag
58 iodepth=1
59 bs=8k
60 donorname=test4.def
61 filename=test4
62 inplace=1
63 rw=randwrite
64 numjobs=4*${LOAD_FACTOR}
65 runtime=30*${TIME_FACTOR}
66 time_based
67
68 [aio-dio-verifier]
69 ioengine=libaio
70 iodepth=128
71 iomem_align=4k
72 numjobs=1
73 verify=crc32c-intel
74 verify_fatal=1
75 verify_dump=1
76 verify_backlog=1024
77 verify_async=1
78 verifysort=1
79 direct=1
80 bs=64k
81 rw=write
82 filename=test4
83 runtime=30*${TIME_FACTOR}
84 time_based
85
86 EOF
87
88 _workout()
89 {
90         echo ""
91         echo " Start defragment activity"
92         echo ""
93         cat $fio_config >>  $seqres.full
94         run_check $FIO_PROG $fio_config
95 }
96
97 _require_fio $fio_config
98
99 rm -f $seqres.full
100 _scratch_mkfs  >> $seqres.full 2>&1
101 _scratch_mount
102
103 if ! _workout; then
104         _scratch_unmount 2>/dev/null
105         exit
106 fi
107
108 if ! _scratch_unmount; then
109         echo "failed to umount"
110         status=1
111         exit
112 fi
113 status=0
114 exit