generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 234
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 Jan Kara.  All Rights Reserved.
4 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
5 #
6 # FS QA Test No. 234
7 #
8 # Stress setquota and setinfo handling.
9 #
10 . ./common/preamble
11 _begin_fstest auto quota
12
13 # Import common functions.
14 . ./common/filter
15 . ./common/quota
16
17 test_setting()
18 {
19         echo; echo "### test limits and info setting"
20         count=2000
21         procs=5
22         idmod=200000
23         seed=$RANDOM
24         RANDOM=$seed
25         echo "Starting test with procs=$procs, idmod=$idmod, and seed=$seed" >>$seqres.full
26
27         for (( i = 0; i < $procs; i++ )); do
28                 ( SETUCOUNT=1; SETGCOUNT=1; SETUIDS[0]=0; SETGIDS[0]=0
29                 for (( j = 0; j < $count; j++ )); do
30                         OP=$(($RANDOM%22))
31                         UG=$(($OP%2))
32                         OP=$(($OP/2))
33                         if [ $UG -eq 1 ]; then
34                                 type='u'
35                         else
36                                 type='g'
37                         fi
38                         if [ $OP -eq 10 ]; then
39                                 setquota -t -$type $j $j $SCRATCH_MNT
40                         elif [ $OP -lt 5 ]; then
41                                 ID=$((($RANDOM*32768+$RANDOM)%$idmod))
42                                 if [ $UG -eq 1 ]; then
43                                         SETUIDS[$SETUCOUNT]=$ID
44                                         SETUCOUNT=$(($SETUCOUNT+1))
45                                 else
46                                         SETGIDS[$SETGCOUNT]=$ID
47                                         SETGCOUNT=$(($SETGCOUNT+1))
48                                 fi
49                                 setquota -$type $ID $j $j $j $j $SCRATCH_MNT
50                         else
51                                 if [ $UG -eq 1 ]; then
52                                         ID=${SETUIDS[$(($RANDOM%$SETUCOUNT))]}
53                                 else
54                                         ID=${SETGIDS[$(($RANDOM%$SETGCOUNT))]}
55                                 fi
56                                 setquota -$type $ID 0 0 0 0 $SCRATCH_MNT
57                         fi
58                 done )&
59         done
60         wait
61         echo "### done with testing"
62 }
63
64 # real QA test starts here
65 _supported_fs generic
66 _require_scratch
67 _require_quota
68
69 # real QA test starts here
70
71 _scratch_mkfs >> $seqres.full 2>&1
72 _scratch_mount "-o usrquota,grpquota"
73 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
74 quotaon -u -g $SCRATCH_MNT 2>/dev/null
75 test_setting
76 _scratch_unmount
77
78 status=0
79 exit