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"}
33 PIOSBIN=${PIOSBIN:-$(which pios 2> /dev/null || true)}
35 pios_THREADCOUNT=${pios_THREADCOUNT:-"1,8,40"}
36 [ "$SLOW" = "no" ] && pios_THREADCOUNT=8
38 pios_REGIONCOUNT=${pios_REGIONCOUNT:-1024}
39 pios_CHUNKSIZE=${pios_CHUNKSIZE:-1M}
40 pios_REGIONSIZE=${pios_REGIONSIZE:-8M}
41 pios_OFFSET=${pios_OFFSET:-16M}
43 [ "$SLOW" = "no" ] && EXCEPT_SLOW="iozone"
46 check_and_setup_lustre
49 rm -rf $DIR/[df][0-9]*
52 if ! which dbench > /dev/null 2>&1 ; then
53 skip_env "No dbench installed"
57 local DBENCHDIR=$DIR/d0.$HOSTNAME
59 local SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
60 DB_THREADS=$((SPACE / 50000))
61 [ $THREADS -lt $DB_THREADS ] && DB_THREADS=$THREADS
67 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
68 { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; }
69 chown $myUID:$myGID $DBENCHDIR
71 [ "$SLOW" = "no" ] && duration=" -t 120"
72 if [ "$SLOW" != "no" -o $DB_THREADS -eq 1 ]; then
73 $myRUNAS bash rundbench -D $DBENCHDIR 1 $duration || error "dbench failed!"
76 if [ $DB_THREADS -gt 1 ]; then
78 $myRUNAS bash rundbench -D $DBENCHDIR $DB_THREADS $duration
83 run_test dbench "dbench"
86 if ! which bonnie++ > /dev/null 2>&1; then
87 skip_env "No bonnie++ installed"
90 local BONDIR=$DIR/d0.bonnie
92 $LFS setstripe -c -1 $BONDIR
94 local MIN=`lctl get_param -n osc.*.kbytesavail | sort -n | head -n1`
95 local SPACE=$(( OSTCOUNT * MIN ))
96 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
97 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
102 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
103 { myRUNAS="" && myUID=$UID && myGID=`id -$USER`; }
104 chown $myUID:$myGID $BONDIR
105 $myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myGID -d$BONDIR
108 run_test bonnie "bonnie++"
111 if ! which iozone > /dev/null 2>&1; then
112 skip_env "No iozone installed"
118 local IOZDIR=$DIR/d0.iozone
120 $LFS setstripe -c -1 $IOZDIR
122 local MIN=`lctl get_param -n osc.*.kbytesavail | sort -n | head -n1`
123 local SPACE=$(( OSTCOUNT * MIN ))
124 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
125 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
126 IOZONE_OPTS="-i 0 -i 1 -i 2 -e -+d -r $RSIZE"
127 IOZFILE="$IOZDIR/iozone"
128 IOZLOG=$TMP/iozone.log
129 # $SPACE was calculated with all OSTs
134 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
135 { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; }
136 chown $myUID:$myGID $IOZDIR
137 $myRUNAS iozone $IOZONE_OPTS -s $SIZE -f $IOZFILE 2>&1 | tee $IOZLOG
138 tail -1 $IOZLOG | grep -q complete || \
139 { error "iozone (1) failed" && return 1; }
143 # check if O_DIRECT support is implemented in kernel
144 if [ -z "$O_DIRECT" ]; then
146 if ! ./directio write $DIR/f.iozone 0 1; then
147 log "SKIP iozone DIRECT IO test"
152 if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then
154 $myRUNAS iozone -I $IOZONE_OPTS -s $SIZE -f $IOZFILE.odir 2>&1 | tee $IOZLOG
155 tail -1 $IOZLOG | grep -q complete || \
156 { error "iozone (2) failed" && return 1; }
161 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
162 IOZ_THREADS=$((SPACE / SIZE * 2 / 3 ))
163 [ $THREADS -lt $IOZ_THREADS ] && IOZ_THREADS=$THREADS
164 IOZVER=`iozone -v | awk '/Revision:/ {print $3}' | tr -d .`
165 if [ "$IOZ_THREADS" -gt 1 -a "$IOZVER" -ge 3145 ]; then
166 $LFS setstripe -c -1 $IOZDIR
170 while [ $THREAD -le $IOZ_THREADS ]; do
171 IOZFILE="$IOZFILE $IOZDIR/iozone.$THREAD"
172 THREAD=$((THREAD + 1))
174 $myRUNAS iozone $IOZONE_OPTS -s $((SIZE / IOZ_THREADS)) -t $IOZ_THREADS -F $IOZFILE 2>&1 | tee $IOZLOG
175 tail -1 $IOZLOG | grep -q complete || \
176 { error "iozone (3) failed" && return 1; }
179 elif [ $IOZVER -lt 3145 ]; then
180 VER=`iozone -v | awk '/Revision:/ { print $3 }'`
181 echo "iozone $VER too old for multi-thread test"
184 run_test iozone "iozone"
187 local testfile=$DIR/f0.fsxfile
190 local SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
191 [ $SPACE -lt $FSX_SIZE ] && FSX_SIZE=$((SPACE * 3 / 4))
193 FSX_SEED=${FSX_SEED:-$RANDOM}
195 $LFS setstripe -c -1 $testfile
196 echo Using FSX_SEED=$FSX_SEED FSX_SIZE=$FSX_SIZE FSX_COUNT=$FSX_COUNT
197 fsx -c 50 -p 1000 -S $FSX_SEED -P $TMP -l $FSX_SIZE \
198 -N $(($FSX_COUNT * 100)) $testfile
205 ############################################################
211 local num=${str:0:${#str}-1}
212 case ${str:${#str}-1} in
213 k|K ) num=$((num << 10));; #
214 m|M ) num=$((num << 20));; # emacs is confsued by the << and
215 g|G ) num=$((num << 30));; # these comments help it out.
216 t|T ) num=$((num << 40));; #
223 # pios.c: check_device_size ()
224 # /* Adding 10% to total test size for filesystem overhead */
225 # size = size + (double)(size) * (double) (0.1);
226 # pios.c: set_actual_streams ()
227 # total_test_size = runarg->regioncount * runarg->regionsize
229 local size=$(($(iterpr_KMGT $pios_REGIONCOUNT) * \
230 $(iterpr_KMGT $pios_REGIONSIZE) ))
235 local testdir=$DIR/$tdir
236 local stripe=$($LFS getstripe -c $testdir)
238 # if stripe_count = 1 the size should be less than min ost size, bug 24294
239 local space=$($LFS df $testdir | grep "filesystem summary:" | awk '{print $3}')
240 [ $stripe -eq 1 ] && space=$(min_ost_size)
242 local size=$(pios_file_size)
243 size=$(( size + size / 10 ))
244 # we can not use pios --cleanup|-x because we need the files exist for pios --verify,
245 # so, we need space available for each of pios_THREADCOUNT value run
246 local num_runs=$(echo ${pios_THREADCOUNT//,/ } | wc -w)
247 size=$(( size * $num_runs))
248 space=$((space * 1024))
249 echo size=$size space=$space
250 if [ $space -le $size ]; then
251 local ratio=$(( size / space + 1 ))
252 echo "Need free space atleast $size, available $space, ratio=$ratio"
253 local rgcount=$(( pios_REGIONCOUNT / ratio ))
254 echo "reducing pios_REGIONCOUNT=$pios_REGIONCOUNT on $ratio"
255 if [ $rgcount -eq 0 ]; then
256 echo "fs is too small, reduced pios_REGIONCOUNT=$rgcount"
259 pios_REGIONCOUNT=$(( pios_REGIONCOUNT / ratio ))
260 echo using pios_REGIONCOUNT=$pios_REGIONCOUNT size=$(pios_file_size)
265 local testdir=$DIR/$tdir
269 [ "$1" == "--stripe" ] && stripes=-1
270 $LFS setstripe $testdir -c $stripes
271 echo "Test directory $testdir stripe count: $stripes"
276 local testdir=$DIR/$tdir
277 if [ $rc -eq 0 ]; then
278 echo cleanup: testdir=$testdir rc=$rc
280 wait_delete_completed || true
285 local testdir=$DIR/$tdir
286 local cmd="$PIOSBIN -t $pios_THREADCOUNT -n $pios_REGIONCOUNT \
287 -c $pios_CHUNKSIZE -s $pios_REGIONSIZE \
288 -o $pios_OFFSET $@ -p $testdir"
290 if [ ! -d $testdir ]; then
291 error "No test directory created, setup_pios must have failed"
305 if [ -z "$PIOSBIN" ]; then
306 skip_env "$0 : pios not found PIOSBIN=$PIOSBIN"
311 pios_setup --stripe || return
312 if ! space_check; then
313 skip_env "not enough space"
318 run_pios --verify || rc=$?
322 run_test pios_ssf "pios shared single file"
325 if [ -z "$PIOSBIN" ]; then
326 skip_env "pios not found PIOSBIN=$PIOSBIN"
332 if ! space_check; then
333 skip_env "not enough space"
337 run_pios -L fpp || return
338 run_pios -L fpp --verify || rc=$?
342 run_test pios_fpp "pios file per process"
344 complete $(basename $0) $SECONDS
345 check_and_cleanup_lustre