3 # Test basic functionality of the filesystem using simple
11 LUSTRE=${LUSTRE:-$(dirname $0)/..}
12 . $LUSTRE/tests/test-framework.sh
16 ALWAYS_EXCEPT="$SANITY_BENCHMARK_EXCEPT"
17 [ "$SLOW" = "no" ] && EXCEPT_SLOW="iozone"
21 MAX_THREADS=${MAX_THREADS:-20}
22 RAMKB=$(awk '/MemTotal:/ { print $2 }' /proc/meminfo)
23 if [ -z "$THREADS" ]; then
24 THREADS=$((RAMKB / 16384))
25 [ $THREADS -gt $MAX_THREADS ] && THREADS=$MAX_THREADS
27 SIZE=${SIZE:-$((RAMKB * 2))}
30 DEBUG_LVL=${DEBUG_LVL:-0}
31 DEBUG_OFF=${DEBUG_OFF:-"eval lctl set_param debug=\"$DEBUG_LVL\""}
32 DEBUG_ON=${DEBUG_ON:-"eval lctl set_param debug=0x33f0484"}
33 DIRECTIO=${DIRECTIO:-directio}
35 check_and_setup_lustre
38 rm -rf $DIR/[df][0-9]*
41 if ! which dbench > /dev/null 2>&1 ; then
42 skip_env "No dbench installed"
46 local DBENCHDIR=$DIR/d0.$HOSTNAME
48 local SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
49 DB_THREADS=$((SPACE / 50000))
50 [ $THREADS -lt $DB_THREADS ] && DB_THREADS=$THREADS
56 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
57 { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; }
58 chown $myUID:$myGID $DBENCHDIR
60 [ "$SLOW" = "no" ] && duration=" -t 120"
61 if [ "$SLOW" != "no" -o $DB_THREADS -eq 1 ]; then
62 $myRUNAS bash rundbench -D $DBENCHDIR 1 $duration || error "dbench failed!"
65 if [ $DB_THREADS -gt 1 ]; then
67 $myRUNAS bash rundbench -D $DBENCHDIR $DB_THREADS $duration
72 run_test dbench "dbench"
75 if ! which bonnie++ > /dev/null 2>&1; then
76 skip_env "No bonnie++ installed"
79 local BONDIR=$DIR/d0.bonnie
81 $LFS setstripe -c -1 $BONDIR
83 local MIN=`lctl get_param -n osc.*.kbytesavail | sort -n | head -n1`
84 local SPACE=$(( OSTCOUNT * MIN ))
85 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
86 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
91 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
92 { myRUNAS="" && myUID=$UID && myGID=`id -$USER`; }
93 chown $myUID:$myGID $BONDIR
94 $myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myGID -d$BONDIR
97 run_test bonnie "bonnie++"
100 if ! which iozone > /dev/null 2>&1; then
101 skip_env "No iozone installed"
107 local IOZDIR=$DIR/d0.iozone
108 wait_delete_completed || true
110 $LFS setstripe -c -1 $IOZDIR
112 local MIN=`lctl get_param -n osc.*.kbytesavail | sort -n | head -n1`
113 local SPACE=$(( OSTCOUNT * MIN ))
114 [ $SPACE -lt $SIZE ] && SIZE=$((SPACE * 3 / 4))
115 log "min OST has ${MIN}kB available, using ${SIZE}kB file size"
116 IOZONE_OPTS="-i 0 -i 1 -i 2 -e -+d -r $RSIZE"
117 IOZFILE="$IOZDIR/iozone"
118 IOZLOG=$TMP/iozone.log
119 # $SPACE was calculated with all OSTs
124 FAIL_ON_ERROR=false check_runas_id_ret $myUID $myGID $myRUNAS || \
125 { myRUNAS="" && myUID=$UID && myGID=`id -g $USER`; }
126 chown $myUID:$myGID $IOZDIR
127 $myRUNAS iozone $IOZONE_OPTS -s $SIZE -f $IOZFILE 2>&1 | tee $IOZLOG
128 tail -1 $IOZLOG | grep -q complete || \
129 { error "iozone (1) failed" && return 1; }
131 wait_delete_completed || true
134 # check if O_DIRECT support is implemented in kernel
135 if [ -z "$O_DIRECT" ]; then
137 if ! $DIRECTIO write $DIR/f.iozone 0 1; then
138 log "SKIP iozone DIRECT IO test"
142 wait_delete_completed || true
144 if [ "$O_DIRECT" != "no" -a "$IOZONE_DIR" != "no" ]; then
146 $myRUNAS iozone -I $IOZONE_OPTS -s $SIZE -f $IOZFILE.odir 2>&1 | tee $IOZLOG
147 tail -1 $IOZLOG | grep -q complete || \
148 { error "iozone (2) failed" && return 1; }
150 wait_delete_completed || true
154 SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
155 IOZ_THREADS=$((SPACE / SIZE * 2 / 3 ))
156 [ $THREADS -lt $IOZ_THREADS ] && IOZ_THREADS=$THREADS
157 IOZVER=`iozone -v | awk '/Revision:/ {print $3}' | tr -d .`
158 if [ "$IOZ_THREADS" -gt 1 -a "$IOZVER" -ge 3145 ]; then
159 $LFS setstripe -c -1 $IOZDIR
163 while [ $THREAD -le $IOZ_THREADS ]; do
164 IOZFILE="$IOZFILE $IOZDIR/iozone.$THREAD"
165 THREAD=$((THREAD + 1))
167 $myRUNAS iozone $IOZONE_OPTS -s $((SIZE / IOZ_THREADS)) -t $IOZ_THREADS -F $IOZFILE 2>&1 | tee $IOZLOG
168 tail -1 $IOZLOG | grep -q complete || \
169 { error "iozone (3) failed" && return 1; }
171 wait_delete_completed || true
173 elif [ $IOZVER -lt 3145 ]; then
174 VER=`iozone -v | awk '/Revision:/ { print $3 }'`
175 echo "iozone $VER too old for multi-thread test"
178 run_test iozone "iozone"
181 local testfile=$DIR/f0.fsxfile
184 local SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
188 [ $SPACE -lt $FSX_SIZE ] && FSX_SIZE=$((SPACE * 3 / 4))
190 FSX_SEED=${FSX_SEED:-$RANDOM}
192 $LFS setstripe -c -1 $testfile
193 CMD="$FSX -c 50 -p 1000 -S $FSX_SEED -P $TMP -l $FSX_SIZE \
194 -N $((FSX_COUNT * 100)) $FSXOPT $testfile"
196 $CMD || error "fsx failed"
202 test_fsx_partial_punch() {
203 local fsx_count=100000
204 local testfile=$DIR/f0.fsxfile
205 local fsx_size=5407677 # upper bound file size
211 $LFS setstripe -c -1 $testfile
214 # $fsx_seed, $fsx_count and $fsx_size combination almost
215 # always reproduces the LASSERT under LU-14640. Therefore these
216 # constants are used as reproducer vs using a random value and
217 # hoping it hits the error condition
219 CMD="$FSX -c 50 -p 1000 -S $fsx_seed -P $TMP -l $fsx_size \
220 -N $fsx_count $testfile"
222 $CMD || error "fsx failed"
225 run_test fsx_partial_punch "Verify fsx with partial punch via fallocate"
228 check_and_cleanup_lustre