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}
18 ALWAYS_EXCEPT="$SANITY_BENCHMARK_EXCEPT"
20 MAX_THREADS=${MAX_THREADS:-20}
21 RAMKB=`awk '/MemTotal:/ { print $2 }' /proc/meminfo`
22 if [ -z "$THREADS" ]; then
23 THREADS=$((RAMKB / 16384))
24 [ $THREADS -gt $MAX_THREADS ] && THREADS=$MAX_THREADS
26 SIZE=${SIZE:-$((RAMKB * 2))}
29 DEBUG_LVL=${DEBUG_LVL:-0}
30 DEBUG_OFF=${DEBUG_OFF:-"eval lctl set_param debug=\"$DEBUG_LVL\""}
31 DEBUG_ON=${DEBUG_ON:-"eval lctl set_param debug=0x33f0484"}
32 DIRECTIO=${DIRECTIO:-directio}
34 PIOSBIN=${PIOSBIN:-$(which pios 2> /dev/null || true)}
36 pios_THREADCOUNT=${pios_THREADCOUNT:-"1,8,40"}
37 [ "$SLOW" = "no" ] && pios_THREADCOUNT=8
39 pios_REGIONCOUNT=${pios_REGIONCOUNT:-1024}
40 pios_CHUNKSIZE=${pios_CHUNKSIZE:-1M}
41 pios_REGIONSIZE=${pios_REGIONSIZE:-8M}
42 pios_OFFSET=${pios_OFFSET:-16M}
44 [ "$SLOW" = "no" ] && EXCEPT_SLOW="iozone"
47 check_and_setup_lustre
50 rm -rf $DIR/[df][0-9]*
53 if ! which dbench > /dev/null 2>&1 ; then
54 skip_env "No dbench installed"
58 local DBENCHDIR=$DIR/d0.$HOSTNAME
60 local SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
61 DB_THREADS=$((SPACE / 50000))
62 [ $THREADS -lt $DB_THREADS ] && DB_THREADS=$THREADS
68 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
69 { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; }
70 chown $myUID:$myGID $DBENCHDIR
72 [ "$SLOW" = "no" ] && duration=" -t 120"
73 if [ "$SLOW" != "no" -o $DB_THREADS -eq 1 ]; then
74 $myRUNAS bash rundbench -D $DBENCHDIR 1 $duration || error "dbench failed!"
77 if [ $DB_THREADS -gt 1 ]; then
79 $myRUNAS bash rundbench -D $DBENCHDIR $DB_THREADS $duration
84 run_test dbench "dbench"
87 if ! which bonnie++ > /dev/null 2>&1; then
88 skip_env "No bonnie++ installed"
91 local BONDIR=$DIR/d0.bonnie
93 $LFS setstripe -c -1 $BONDIR
95 local MIN=`lctl get_param -n osc.*.kbytesavail | sort -n | head -n1`
96 local SPACE=$(( OSTCOUNT * MIN ))
97 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
98 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
103 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
104 { myRUNAS="" && myUID=$UID && myGID=`id -$USER`; }
105 chown $myUID:$myGID $BONDIR
106 $myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myGID -d$BONDIR
109 run_test bonnie "bonnie++"
112 if ! which iozone > /dev/null 2>&1; then
113 skip_env "No iozone installed"
119 local IOZDIR=$DIR/d0.iozone
121 $LFS setstripe -c -1 $IOZDIR
123 local MIN=`lctl get_param -n osc.*.kbytesavail | sort -n | head -n1`
124 local SPACE=$(( OSTCOUNT * MIN ))
125 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
126 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
127 IOZONE_OPTS="-i 0 -i 1 -i 2 -e -+d -r $RSIZE"
128 IOZFILE="$IOZDIR/iozone"
129 IOZLOG=$TMP/iozone.log
130 # $SPACE was calculated with all OSTs
135 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
136 { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; }
137 chown $myUID:$myGID $IOZDIR
138 $myRUNAS iozone $IOZONE_OPTS -s $SIZE -f $IOZFILE 2>&1 | tee $IOZLOG
139 tail -1 $IOZLOG | grep -q complete || \
140 { error "iozone (1) failed" && return 1; }
144 # check if O_DIRECT support is implemented in kernel
145 if [ -z "$O_DIRECT" ]; then
147 if ! $DIRECTIO write $DIR/f.iozone 0 1; then
148 log "SKIP iozone DIRECT IO test"
153 if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then
155 $myRUNAS iozone -I $IOZONE_OPTS -s $SIZE -f $IOZFILE.odir 2>&1 | tee $IOZLOG
156 tail -1 $IOZLOG | grep -q complete || \
157 { error "iozone (2) failed" && return 1; }
162 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
163 IOZ_THREADS=$((SPACE / SIZE * 2 / 3 ))
164 [ $THREADS -lt $IOZ_THREADS ] && IOZ_THREADS=$THREADS
165 IOZVER=`iozone -v | awk '/Revision:/ {print $3}' | tr -d .`
166 if [ "$IOZ_THREADS" -gt 1 -a "$IOZVER" -ge 3145 ]; then
167 $LFS setstripe -c -1 $IOZDIR
171 while [ $THREAD -le $IOZ_THREADS ]; do
172 IOZFILE="$IOZFILE $IOZDIR/iozone.$THREAD"
173 THREAD=$((THREAD + 1))
175 $myRUNAS iozone $IOZONE_OPTS -s $((SIZE / IOZ_THREADS)) -t $IOZ_THREADS -F $IOZFILE 2>&1 | tee $IOZLOG
176 tail -1 $IOZLOG | grep -q complete || \
177 { error "iozone (3) failed" && return 1; }
180 elif [ $IOZVER -lt 3145 ]; then
181 VER=`iozone -v | awk '/Revision:/ { print $3 }'`
182 echo "iozone $VER too old for multi-thread test"
185 run_test iozone "iozone"
188 local testfile=$DIR/f0.fsxfile
191 local SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
192 [ $SPACE -lt $FSX_SIZE ] && FSX_SIZE=$((SPACE * 3 / 4))
194 FSX_SEED=${FSX_SEED:-$RANDOM}
196 $LFS setstripe -c -1 $testfile
197 CMD="fsx -c 50 -p 1000 -S $FSX_SEED -P $TMP -l $FSX_SIZE \
198 -N $((FSX_COUNT * 100)) $FSXOPT $testfile"
200 $CMD || error "fsx failed"
207 ############################################################
213 local num=${str:0:${#str}-1}
214 case ${str:${#str}-1} in
215 k|K ) num=$((num << 10));; #
216 m|M ) num=$((num << 20));; # emacs is confsued by the << and
217 g|G ) num=$((num << 30));; # these comments help it out.
218 t|T ) num=$((num << 40));; #
225 # pios.c: check_device_size ()
226 # /* Adding 10% to total test size for filesystem overhead */
227 # size = size + (double)(size) * (double) (0.1);
228 # pios.c: set_actual_streams ()
229 # total_test_size = runarg->regioncount * runarg->regionsize
231 local size=$(($(iterpr_KMGT $pios_REGIONCOUNT) * \
232 $(iterpr_KMGT $pios_REGIONSIZE) ))
237 local testdir=$DIR/$tdir
238 local stripe=$($LFS getstripe -c $testdir)
239 local min_space_available=0
241 # if stripe_count = 1 the size should be less than min ost size,
243 min_space_available=$(lfs df | grep "^$FSNAME-OST" | \
244 awk '{print $4}' | sort -un | head -1)
245 local space=$((min_space_available * OSTCOUNT))
247 [ $stripe -eq 1 ] && space=$(min_ost_size)
249 local size=$(pios_file_size)
250 size=$(( size + size / 10 ))
251 # we can not use pios --cleanup|-x because we need the files exist for
252 # pios --verify, so, we need space available for each of
253 # pios_THREADCOUNT value run
254 local num_runs=$(echo ${pios_THREADCOUNT//,/ } | wc -w)
255 size=$(( size * $num_runs))
256 space=$((space * 1024))
257 echo size=$size space=$space
258 if [ $space -le $size ]; then
259 local ratio=$(( size / space + 1 ))
260 echo "Need free space atleast $size, \
261 available $space, ratio=$ratio"
262 local rgcount=$(( pios_REGIONCOUNT / ratio ))
263 echo "reducing pios_REGIONCOUNT=$pios_REGIONCOUNT on $ratio"
264 if [ $rgcount -eq 0 ]; then
265 echo "fs is too small, \
266 reduced pios_REGIONCOUNT=$rgcount"
269 pios_REGIONCOUNT=$(( pios_REGIONCOUNT / ratio ))
270 echo using pios_REGIONCOUNT=$pios_REGIONCOUNT \
271 size=$(pios_file_size)
276 local testdir=$DIR/$tdir
280 [ "$1" == "--stripe" ] && stripes=-1
281 $LFS setstripe $testdir -c $stripes
282 echo "Test directory $testdir stripe count: $stripes"
287 local testdir=$DIR/$tdir
288 if [ $rc -eq 0 ]; then
289 echo cleanup: testdir=$testdir rc=$rc
291 wait_delete_completed || true
296 local testdir=$DIR/$tdir
297 local cmd="$PIOSBIN -t $pios_THREADCOUNT -n $pios_REGIONCOUNT \
298 -c $pios_CHUNKSIZE -s $pios_REGIONSIZE \
299 -o $pios_OFFSET $@ -p $testdir"
301 if [ ! -d $testdir ]; then
302 error "No test directory created, setup_pios must have failed"
316 if [ -z "$PIOSBIN" ]; then
317 skip_env "$0 : pios not found PIOSBIN=$PIOSBIN"
322 pios_setup --stripe || return
323 if ! space_check; then
324 skip_env "not enough space"
329 run_pios --verify || rc=$?
333 run_test pios_ssf "pios shared single file"
336 if [ -z "$PIOSBIN" ]; then
337 skip_env "pios not found PIOSBIN=$PIOSBIN"
343 if ! space_check; then
344 skip_env "not enough space"
348 run_pios -L fpp || return
349 run_pios -L fpp --verify || rc=$?
353 run_test pios_fpp "pios file per process"
356 check_and_cleanup_lustre