generic/520: Remove sync in clean_dir
[xfstests-dev.git] / tests / generic / 270
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 270
6 #
7 # Run fsstress and ENSPC hitters in parallel, check quota and 
8 # fs consistency an the end
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        # failure is the default!
17 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
18
19 # get standard environment, filters and checks
20 . ./common/rc
21 . ./common/filter
22 . ./common/quota
23
24 # Disable all sync operations to get higher load
25 FSSTRESS_AVOID="$FSSTRESS_AVOID -ffsync=0 -fsync=0 -ffdatasync=0"
26 _workout()
27 {
28         echo ""
29         echo "Run fsstress"
30         echo ""
31         num_iterations=10
32         enospc_time=2
33         out=$SCRATCH_MNT/fsstress.$$
34         args=`_scale_fsstress_args -p128 -n999999999 -f setattr=1 $FSSTRESS_AVOID -d $out`
35         echo "fsstress $args" >> $seqres.full
36         # Grant chown capability 
37         cp $FSSTRESS_PROG  $tmp.fsstress.bin
38         $SETCAP_PROG cap_chown=epi  $tmp.fsstress.bin
39
40         (su $qa_user -c "$tmp.fsstress.bin $args" &) > /dev/null 2>&1
41         pid=$!
42
43         echo "Run dd writers in parallel"
44         for ((i=0; i < num_iterations; i++))
45         do
46                 # File will be opened with O_TRUNC each time
47                 su $qa_user -c "dd if=/dev/zero \
48                         of=$SCRATCH_MNT/SPACE_CONSUMER bs=1M " \
49                         >> $seqres.full 2>&1
50                 sleep $enospc_time
51         done
52
53         $KILLALL_PROG $tmp.fsstress.bin
54         wait $pid
55 }
56
57 # real QA test starts here
58 _supported_fs generic
59 _supported_os Linux
60 _require_quota
61 _require_user
62 _require_scratch
63 _require_command "$KILLALL_PROG" killall
64 _require_command "$SETCAP_PROG" setcap
65
66 rm -f $seqres.full
67 _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
68 _scratch_mount "-o usrquota,grpquota"
69 chmod 777 $SCRATCH_MNT
70 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
71 quotaon -u -g $SCRATCH_MNT 2>/dev/null
72
73 if ! _workout; then
74         _scratch_unmount 2>/dev/null
75         exit
76 fi
77
78 if ! _check_quota_usage; then
79         _scratch_unmount 2>/dev/null
80         status=1
81         exit
82 fi
83
84 echo Comparing filesystem consistency
85 if ! _scratch_unmount; then
86         echo "failed to umount"
87         status=1
88         exit
89 fi
90 status=0
91 exit