X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Foos.sh;h=98d2c183205fe7cbbda2313400746dee69bd08ba;hb=48c78f609fb3dd8f20f8a49a22a16dbb956b3f04;hp=8519dad6769d5c67695385b0ab352cf0b059e643;hpb=15b0e514725b0c8e0acdbfc0d5382a6302639d58;p=fs%2Flustre-release.git diff --git a/lustre/tests/oos.sh b/lustre/tests/oos.sh index 8519dad..98d2c18 100755 --- a/lustre/tests/oos.sh +++ b/lustre/tests/oos.sh @@ -1,46 +1,100 @@ #!/bin/bash -export NAME=${NAME:-local} -export OSTSIZE=10000 +set -e +#set -vx +LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)} +. $LUSTRE/tests/test-framework.sh +. ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh} + +export PATH=`dirname $0`/../utils:$PATH +LFS=${LFS:-lfs} +LCTL=${LCTL:-lctl} +MOUNT=${MOUNT:-$1} MOUNT=${MOUNT:-/mnt/lustre} +OOS=$MOUNT/oosfile TMP=${TMP:-/tmp} - -echo "mnt.." -sh llmount.sh -echo "done" +LOG=$TMP/$(basename $0 .sh).log SUCCESS=1 -FREESPACE=`df |grep $MOUNT|tr -s ' '|cut -d ' ' -f4` +rm -f $OOS $LOG + +sync; sleep 1; sync # to ensure we get up-to-date statfs info + +#$LCTL set_param -n debug=-1 +#$LCTL set_param -n subsystem_debug=0x40a8 -rm -f $TMP/oosfile -dd if=/dev/zero of=$MOUNT/oosfile count=$[$FREESPACE + 1] bs=1k 2>$TMP/oosfile +#$LCTL clear +#$LCTL debug_daemon start /r/tmp/debug 1024 -RECORDSOUT=`grep "records out" $TMP/oosfile|cut -d + -f1` +STRIPECOUNT=`$LCTL get_param -n lov.*.activeobd | head -n 1` +ORIGFREE=`$LCTL get_param -n llite.*.kbytesavail | head -n 1` +MAXFREE=${MAXFREE:-$((400000 * $STRIPECOUNT))} +echo STRIPECOUNT=$STRIPECOUNT ORIGFREE=$ORIGFREE MAXFREE=$MAXFREE +if [ $ORIGFREE -gt $MAXFREE ]; then + skip "$0: ${ORIGFREE}kB free gt MAXFREE ${MAXFREE}kB, increase $MAXFREE (or reduce test fs size) to proceed" + exit 0 +fi -[ -z "`grep "No space left on device" $TMP/oosfile`" ] && \ - echo "failed:dd not return ENOSPC" && SUCCESS=0 +export LANG=C LC_LANG=C # for "No space left on device" message + +[ -f $LOG ] && error "log file wasn't removed?" + +echo BEFORE dd started +oos_full || true + +# make sure we stripe over all OSTs to avoid OOS on only a subset of OSTs +$LFS setstripe $OOS -c $STRIPECOUNT +# add 20% of margin since the metadata overhead estimated in bavail might be +# too aggressive and we might be able to write more than reported initially +# by statfs. +echo dd size $((ORIGFREE * 120 / 100))kB +if dd if=/dev/zero of=$OOS count=$((ORIGFREE * 120 / 100)) bs=1k 2> $LOG; then + echo "ERROR: dd did not fail" + SUCCESS=0 +fi -REMAINEDFREE=`df |grep $MOUNT|tr -s ' '|cut -d ' ' -f4` -[ $[$FREESPACE - $REMAINEDFREE ] -lt $RECORDSOUT ] && \ - echo "failed:the space written by dd not equal to available space" && \ - SUCCESS=0 && echo "$FREESPACE - $REMAINEDFREE $RECORDSOUT" +[ ! -s "$LOG" ] && error "LOG file is empty!" -[ $REMAINEDFREE -gt 100 ] && \ - echo "failed:too many space left $REMAINEDFREE and -ENOSPC returned" &&\ +if [ "`grep -c 'No space left on device' $LOG`" -ne 1 ]; then + echo "ERROR: dd not return ENOSPC" + sed "s/^/LOG: /" $LOG SUCCESS=0 +fi + +# flush cache to OST(s) so avail numbers are correct +sync; sleep 1 ; sync + +echo AFTER dd +if ! oos_full; then + echo "no OSTs are close to full" + SUCCESS=0 +fi + +RECORDSOUT=`grep "records out" $LOG | cut -d + -f1` +FILESIZE=`ls -l $OOS | awk '{ print $5 }'` +if [ -z "$RECORDSOUT" ]; then + echo "ERROR: no blocks written by dd?" + sed "s/^/LOG: /" $LOG + SUCCESS=0 +elif [ "$RECORDSOUT" -ne $((FILESIZE / 1024)) ]; then + echo "ERROR: blocks written by dd not equal to the size of file" + SUCCESS=0 +fi + +#$LCTL debug_daemon stop -FILESIZE=`ls -l $MOUNT/oosfile|tr -s ' '|cut -d ' ' -f5` -[ $RECORDSOUT -ne $[$FILESIZE/1024] ] && \ - echo "failed:the space written by dd not equal to the size of file" && \ - SUCCESS=0 +[ $SUCCESS != 0 ] && echo LOG file && sed "s/^/LOG: /" $LOG +rm -f $OOS -[ $SUCCESS -eq 1 ] && echo "Success!" +sync; sleep 3; sync -rm -f $MOUNT/oosfile* -rm -f $TMP/oosfile +wait_delete_completed 300 -echo "" -echo "cln.." -sh llmountcleanup.sh +if [ $SUCCESS -eq 1 ]; then + echo "Success!" + rm -f $LOG +else + exit 1 +fi