3 # Test basic functionality of the filesystem using simple
11 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
12 . $LUSTRE/tests/test-framework.sh
14 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
17 ALWAYS_EXCEPT="$SANITY_BENCHMARK_EXCEPT"
19 MAX_THREADS=${MAX_THREADS:-20}
20 RAMKB=`awk '/MemTotal:/ { print $2 }' /proc/meminfo`
21 if [ -z "$THREADS" ]; then
22 THREADS=$((RAMKB / 16384))
23 [ $THREADS -gt $MAX_THREADS ] && THREADS=$MAX_THREADS
25 SIZE=${SIZE:-$((RAMKB * 2))}
28 DEBUG_LVL=${DEBUG_LVL:-0}
29 DEBUG_OFF=${DEBUG_OFF:-"eval lctl set_param debug=\"$DEBUG_LVL\""}
30 DEBUG_ON=${DEBUG_ON:-"eval lctl set_param debug=0x33f0484"}
32 PIOSBIN=${PIOSBIN:-$(which pios 2> /dev/null || true)}
34 pios_THREADCOUNT=${pios_THREADCOUNT:-"1,8,40"}
35 [ "$SLOW" = "no" ] && pios_THREADCOUNT=8
37 pios_REGIONCOUNT=${pios_REGIONCOUNT:-1024}
38 pios_CHUNKSIZE=${pios_CHUNKSIZE:-1M}
39 pios_REGIONSIZE=${pios_REGIONSIZE:-8M}
40 pios_OFFSET=${pios_OFFSET:-16M}
42 [ "$SLOW" = "no" ] && EXCEPT_SLOW="iozone"
45 check_and_setup_lustre
48 rm -rf $DIR/[df][0-9]*
51 if ! which dbench > /dev/null 2>&1 ; then
52 skip_env "No dbench installed"
56 local DBENCHDIR=$DIR/d0.$HOSTNAME
58 local SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
59 DB_THREADS=$((SPACE / 50000))
60 [ $THREADS -lt $DB_THREADS ] && DB_THREADS=$THREADS
66 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
67 { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; }
68 chown $myUID:$myGID $DBENCHDIR
70 [ "$SLOW" = "no" ] && duration=" -t 120"
71 if [ "$SLOW" != "no" -o $DB_THREADS -eq 1 ]; then
72 $myRUNAS bash rundbench -D $DBENCHDIR 1 $duration || error "dbench failed!"
75 if [ $DB_THREADS -gt 1 ]; then
77 $myRUNAS bash rundbench -D $DBENCHDIR $DB_THREADS $duration
82 run_test dbench "dbench"
85 if ! which bonnie++ > /dev/null 2>&1; then
86 skip_env "No bonnie++ installed"
89 local BONDIR=$DIR/d0.bonnie
91 $LFS setstripe -c -1 $BONDIR
93 local MIN=`lctl get_param -n osc.*.kbytesavail | sort -n | head -n1`
94 local SPACE=$(( OSTCOUNT * MIN ))
95 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
96 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
101 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
102 { myRUNAS="" && myUID=$UID && myGID=`id -$USER`; }
103 chown $myUID:$myGID $BONDIR
104 $myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myGID -d$BONDIR
107 run_test bonnie "bonnie++"
110 if ! which iozone > /dev/null 2>&1; then
111 skip_env "No iozone installed"
117 local IOZDIR=$DIR/d0.iozone
119 $LFS setstripe -c -1 $IOZDIR
121 local MIN=`lctl get_param -n osc.*.kbytesavail | sort -n | head -n1`
122 local SPACE=$(( OSTCOUNT * MIN ))
123 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
124 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
125 IOZONE_OPTS="-i 0 -i 1 -i 2 -e -+d -r $RSIZE"
126 IOZFILE="$IOZDIR/iozone"
127 IOZLOG=$TMP/iozone.log
128 # $SPACE was calculated with all OSTs
133 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
134 { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; }
135 chown $myUID:$myGID $IOZDIR
136 $myRUNAS iozone $IOZONE_OPTS -s $SIZE -f $IOZFILE 2>&1 | tee $IOZLOG
137 tail -1 $IOZLOG | grep -q complete || \
138 { error "iozone (1) failed" && return 1; }
142 # check if O_DIRECT support is implemented in kernel
143 if [ -z "$O_DIRECT" ]; then
145 if ! ./directio write $DIR/f.iozone 0 1; then
146 log "SKIP iozone DIRECT IO test"
151 if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then
153 $myRUNAS iozone -I $IOZONE_OPTS -s $SIZE -f $IOZFILE.odir 2>&1 | tee $IOZLOG
154 tail -1 $IOZLOG | grep -q complete || \
155 { error "iozone (2) failed" && return 1; }
160 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
161 IOZ_THREADS=$((SPACE / SIZE * 2 / 3 ))
162 [ $THREADS -lt $IOZ_THREADS ] && IOZ_THREADS=$THREADS
163 IOZVER=`iozone -v | awk '/Revision:/ {print $3}' | tr -d .`
164 if [ "$IOZ_THREADS" -gt 1 -a "$IOZVER" -ge 3145 ]; then
165 $LFS setstripe -c -1 $IOZDIR
169 while [ $THREAD -le $IOZ_THREADS ]; do
170 IOZFILE="$IOZFILE $IOZDIR/iozone.$THREAD"
171 THREAD=$((THREAD + 1))
173 $myRUNAS iozone $IOZONE_OPTS -s $((SIZE / IOZ_THREADS)) -t $IOZ_THREADS -F $IOZFILE 2>&1 | tee $IOZLOG
174 tail -1 $IOZLOG | grep -q complete || \
175 { error "iozone (3) failed" && return 1; }
178 elif [ $IOZVER -lt 3145 ]; then
179 VER=`iozone -v | awk '/Revision:/ { print $3 }'`
180 echo "iozone $VER too old for multi-thread test"
183 run_test iozone "iozone"
186 local testfile=$DIR/f0.fsxfile
189 local SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
190 [ $SPACE -lt $FSX_SIZE ] && FSX_SIZE=$((SPACE * 3 / 4))
192 FSX_SEED=${FSX_SEED:-$RANDOM}
194 $LFS setstripe -c -1 $testfile
195 echo Using FSX_SEED=$FSX_SEED FSX_SIZE=$FSX_SIZE FSX_COUNT=$FSX_COUNT
196 fsx -c 50 -p 1000 -S $FSX_SEED -P $TMP -l $FSX_SIZE \
197 -N $(($FSX_COUNT * 100)) $DIR/fsxfile
203 ############################################################
209 local num=${str:0:${#str}-1}
210 case ${str:${#str}-1} in
211 k|K ) num=$((num << 10));; #
212 m|M ) num=$((num << 20));; # emacs is confsued by the << and
213 g|G ) num=$((num << 30));; # these comments help it out.
214 t|T ) num=$((num << 40));; #
221 # pios.c: check_device_size ()
222 # /* Adding 10% to total test size for filesystem overhead */
223 # size = size + (double)(size) * (double) (0.1);
224 # pios.c: set_actual_streams ()
225 # total_test_size = runarg->regioncount * runarg->regionsize
227 local size=$(($(iterpr_KMGT $pios_REGIONCOUNT) * \
228 $(iterpr_KMGT $pios_REGIONSIZE) ))
233 local testdir=$DIR/$tdir
234 local stripe=$($LFS getstripe -c $testdir)
236 # if stripe_count = 1 the size should be less than min ost size, bug 24294
237 local space=$($LFS df $testdir | grep "filesystem summary:" | awk '{print $3}')
238 [ $stripe -eq 1 ] && space=$(min_ost_size)
240 local size=$(pios_file_size)
241 size=$(( size + size / 10 ))
242 # we can not use pios --cleanup|-x because we need the files exist for pios --verify,
243 # so, we need space available for each of pios_THREADCOUNT value run
244 local num_runs=$(echo ${pios_THREADCOUNT//,/ } | wc -w)
245 size=$(( size * $num_runs))
246 space=$((space * 1024))
247 echo size=$size space=$space
248 if [ $space -le $size ]; then
249 local ratio=$(( size / space + 1 ))
250 echo "Need free space atleast $size, available $space, ratio=$ratio"
251 local rgcount=$(( pios_REGIONCOUNT / ratio ))
252 echo "reducing pios_REGIONCOUNT=$pios_REGIONCOUNT on $ratio"
253 if [ $rgcount -eq 0 ]; then
254 echo "fs is too small, reduced pios_REGIONCOUNT=$rgcount"
257 pios_REGIONCOUNT=$(( pios_REGIONCOUNT / ratio ))
258 echo using pios_REGIONCOUNT=$pios_REGIONCOUNT size=$(pios_file_size)
263 local testdir=$DIR/$tdir
267 [ "$1" == "--stripe" ] && stripes=-1
268 $LFS setstripe $testdir -c $stripes
269 echo "Test directory $testdir stripe count: $stripes"
274 local testdir=$DIR/$tdir
275 if [ $rc -eq 0 ]; then
276 echo cleanup: testdir=$testdir rc=$rc
278 wait_delete_completed || true
283 local testdir=$DIR/$tdir
284 local cmd="$PIOSBIN -t $pios_THREADCOUNT -n $pios_REGIONCOUNT \
285 -c $pios_CHUNKSIZE -s $pios_REGIONSIZE \
286 -o $pios_OFFSET $@ -p $testdir"
288 if [ ! -d $testdir ]; then
289 error "No test directory created, setup_pios must have failed"
303 if [ -z "$PIOSBIN" ]; then
304 skip_env "$0 : pios not found PIOSBIN=$PIOSBIN"
309 pios_setup --stripe || return
310 if ! space_check; then
311 skip_env "not enough space"
316 run_pios --verify || rc=$?
320 run_test pios_ssf "pios shared single file"
323 if [ -z "$PIOSBIN" ]; then
324 skip_env "pios not found PIOSBIN=$PIOSBIN"
330 if ! space_check; then
331 skip_env "not enough space"
335 run_pios -L fpp || return
336 run_pios -L fpp --verify || rc=$?
340 run_test pios_fpp "pios file per process"
342 complete $(basename $0) $SECONDS
343 check_and_cleanup_lustre