reflink: ensure that we can handle reflinking a lot of extents
[xfstests-dev.git] / tests / generic / 013
1 #! /bin/bash
2 # FS QA Test No. 013
3 #
4 # fsstress
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=0        # success is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     cd /
37     # we might get here with a RO FS
38     _test_remount
39     # now remove fsstress directory.
40     # N.B. rm(1) on IRIX can find problems when building up a long pathname
41     # such that what it has is greater the 1024 chars and will
42     # stop and complain - so get rid of complaint
43     # Ref. pv#935754
44     rm -rf $TEST_DIR/fsstress.$$.* 2>&1 | grep -v 'Path too long'
45 }
46
47 _filesize()
48 {
49     ls -l $1 | $AWK_PROG '{print "    filesize = " $5}'
50 }
51
52 # get standard environment, filters and checks
53 . ./common/rc
54 . ./common/filter
55
56 _do_test()
57 {
58     _n="$1"
59     _param="$2"
60     _count="$3"
61
62     out=$TEST_DIR/fsstress.$$.$_n
63     rm -rf $out
64     if ! mkdir $out
65     then
66         echo "    failed to mkdir $out"
67         status=1
68         exit
69     fi
70
71     echo ""
72     echo "-----------------------------------------------"
73     echo "fsstress.$_n : $_param"
74     echo "-----------------------------------------------"
75     # -m limits number of users/groups so check doesn't fail (malloc) later
76     dbgoutfile=$seqres.full
77     if ! $FSSTRESS_PROG $_param $FSSTRESS_AVOID -v -m 8 -n $_count -d $out >>$dbgoutfile 2>&1
78     then
79         echo "    fsstress (count=$_count) returned $? - see $seqres.full"
80         echo "--------------------------------------"       >>$seqres.full
81         echo "$_n - output from fsstress:"                  >>$seqres.full
82         echo "--------------------------------------"       >>$seqres.full
83         echo "<NOT LOGGED>"                                 >>$seqres.full
84         #cat $tmp.out                                       >>$seqres.full
85         status=1
86     fi
87
88     _check_test_fs
89 }
90
91 # real QA test starts here
92 _supported_fs generic
93 _supported_os IRIX Linux
94 _require_test
95
96 rm -f $seqres.full
97 echo "brevity is wit..."
98
99 count=1000
100 procs=20
101
102 _check_test_fs
103
104 # the default
105
106 _do_test 1 "-r" $count
107
108 # and the default with multiprocess
109
110 _do_test 2 "-p $procs -r" $count
111
112 # from Glen's notes
113
114 _do_test 3 "-p 4 -z -f rmdir=10 -f link=10 -f creat=10 -f mkdir=10 -f rename=30 -f stat=30 -f unlink=30 -f truncate=20" $count
115
116 # if all ok by here then probably don't need $seqres.full
117 rm -f $seqres.full
118
119 exit
120
121 # Test with error injection:
122 #
123 # (error injection)
124 # fsstress -n 1000 -d $scratch -p 4 -z -f rmdir=10 -f link=10 -f creat=10 \
125 #          -f mkdir=10 -f rename=30 -f stat=30 -f unlink=30 -f truncate=20 \
126 #          -e 1
127 #
128 # Error values 1 - 6 test IFLUSH
129 #         1 - corrupt buffer being flushed to di_core.di_magic
130 #         2 - corrupt inode being flushed i_d.di_magic
131 #         3 - corrupt S_IFREG format check
132 #         4 - corrupt S_IFDIR format check
133 #         5 - corrupt i_d.di_nextents
134 #         6 - corrupt i_d.di_forkoff > sb_inodesize