6 # bug number for skipped test: 1768 3192 3192
7 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"4 14b 14c"}
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
10 [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
13 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
16 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
17 CREATETEST=${CREATETEST:-createtest}
19 LSTRIPE=${LSTRIPE:-lstripe}
21 MCREATE=${MCREATE:-mcreate}
22 OPENFILE=${OPENFILE:-openfile}
23 OPENUNLINK=${OPENUNLINK:-openunlink}
24 TOEXCL=${TOEXCL:-toexcl}
25 TRUNCATE=${TRUNCATE:-truncate}
26 export TMP=${TMP:-/tmp}
28 if [ $UID -ne 0 ]; then
32 RUNAS_ID=${RUNAS_ID:-500}
33 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
40 sh llmountcleanup.sh > /dev/null || exit 20
46 sh llrmount.sh > /dev/null || exit 10
53 lctl mark "$*" 2> /dev/null || true
58 strace -o $TMP/$1.strace -ttt $*
60 log "FINISHED: $*: rc $RC"
66 if ! mount | grep -q $DIR1; then
70 log "== test $1: $2= `date +%H:%M:%S` ($BEFORE)"
71 export TESTNAME=test_$1
72 test_$1 || error "test_$1: exit with rc=$?"
74 pass "($((`date +%s` - $BEFORE))s)"
81 if [ "`echo $1 | grep '\<'$O'[a-z]*\>'`" ]; then
89 for X in $EXCEPT $ALWAYS_EXCEPT; do
90 if [ "`echo $1 | grep '\<'$X'[a-z]*\>'`" ]; then
91 echo "skipping excluded test $1"
95 if [ -z "$ONLY" ]; then
101 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
104 log "FAIL: $TESTNAME $@"
105 if [ "$SANITYLOG" ]; then
106 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
116 export MOUNT1=`mount| awk '/ lustre/ { print $3 }'| head -n 1`
117 export MOUNT2=`mount| awk '/ lustre/ { print $3 }'| tail -n 1`
118 [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
119 [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
120 [ `mount| awk '/ lustre/ { print $3 }'| wc -l` -ne 2 ] && \
121 error "NAME=$NAME mounted more than twice"
123 export DIR1=${DIR1:-$MOUNT1}
124 export DIR2=${DIR2:-$MOUNT2}
125 [ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96
126 [ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95
128 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
132 [ -f $DIR2/f1 ] || error
134 run_test 1a "check create on 2 mtpt's =========================="
138 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
141 run_test 1b "check attribute updates on 2 mtpt's ==============="
144 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
146 run_test 1c "check after remount attribute updates on 2 mtpt's ="
150 $CHECKSTAT -a $DIR1/f1 || error
152 run_test 1d "unlink on one mountpoint removes file on other ===="
158 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
160 run_test 2a "check cached attribute updates on 2 mtpt's ========"
166 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
168 run_test 2b "check cached attribute updates on 2 mtpt's ========"
170 # NEED TO SAVE ROOT DIR MODE
173 $CHECKSTAT -t dir -p 0777 $DIR2 || error
175 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
179 $CHECKSTAT -t dir -p 0755 $DIR2 || error
181 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
184 ( cd $DIR1 ; ln -s this/is/good lnk )
185 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
188 run_test 3 "symlink on one mtpt, readlink on another ==========="
191 multifstat $DIR1/f4 $DIR2/f4
193 run_test 4 "fstat validation on multiple mount points =========="
197 truncate $DIR2/f5 100
198 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
201 run_test 5 "create a file on one mount, truncate it on the other"
204 openunlink $DIR1/f6 $DIR2/f6 || error
206 run_test 6 "remove of open file on other node =================="
209 opendirunlink $DIR1/d7 $DIR2/d7 || error
211 run_test 7 "remove of open directory on other node ============="
214 opendevunlink $DIR1/dev8 $DIR2/dev8 || error
216 run_test 8 "remove of open special file on other node =========="
221 for C in a b c d e f g h i j k l; do
222 DIR=`eval echo \\$DIR$MTPT`
223 echo -n $C >> $DIR/f9
224 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
226 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
227 error "`od -a $DIR1/f9` != abcdefghijkl"
229 run_test 9 "append of file with sub-page size on multiple mounts"
235 for C in a b c d e f g h i j k l; do
236 DIR=`eval echo \\$DIR$MTPT`
237 echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
238 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
239 OFFSET=`expr $OFFSET + 1`
241 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
242 error "`od -a $DIR1/f10` != abcdefghijkl"
244 run_test 10a "write of file with sub-page size on multiple mounts "
247 yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
249 truncate $DIR1/f10b 4096 || error "truncate 4096"
251 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
253 # create a test file locally to compare
254 yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
255 truncate $TMP/f10b 4096 || error "truncate 4096"
256 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
258 run_test 10b "write of file with sub-page size on multiple mounts "
262 multiop $DIR1/d11/f O_c &
265 cp -p /bin/ls $DIR1/d11/f
269 wait $MULTIPID || error
270 [ $RC -eq 0 ] && error || true
272 run_test 11 "execution of file opened for write should return error ===="
277 run_test 12 "test lock ordering (link, stat, unlink) ==========="
279 test_13() { # bug 2451 - directory coherency
281 mkdir $DIR1/d13 || error
282 cd $DIR1/d13 || error
284 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
286 rm -f $DIR2/d13/f13 || error
287 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
288 # need to run it twice
289 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
291 rm -f $DIR2/d13/f13 || error
292 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
294 run_test 13 "test directory page revocation ===================="
298 cp -p /bin/ls $DIR1/d14/ls
299 exec 100>> $DIR1/d14/ls
300 $DIR2/d14/ls && error || true
303 run_test 14 "execution of file open for write returns -ETXTBSY ="
307 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
308 $DIR1/d14/multiop $TMP/test14.junk O_c &
311 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
312 kill -USR1 $MULTIPID || return 2
313 wait $MULTIPID || return 3
315 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
317 test_14b() { # bug 3192
319 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
320 $DIR1/d14/multiop $TMP/test14.junk O_c &
323 truncate $DIR2/d14/multiop 0 && error "expected error, got success"
324 kill -USR1 $MULTIPID || return 2
325 wait $MULTIPID || return 3
327 run_test 14b "truncate of executing file returns -ETXTBSY ======"
329 test_14c() { # bug 3430
331 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
332 $DIR1/d14/multiop $TMP/test14.junk O_c &
335 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
336 kill -USR1 $MULTIPID || return 2
337 wait $MULTIPID || return 3
338 #cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
340 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
342 test_15() { # bug 974 - ENOSPC
344 sh oos2.sh $MOUNT1 $MOUNT2
346 run_test 15 "test out-of-space with multiple writers ==========="
349 fsx -R -W -c 50 -p 100 -N 2500 $MOUNT1/fsxfile $MOUNT2/fsxfile
351 run_test 16 "2500 iterations of dual-mount fsx ================="
354 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
355 echo clear > $d/lru_size
357 grep "[0-9]" /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
360 test_17() { # bug 3513, 3667
361 [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
363 cp /etc/termcap $DIR1/f17
364 cancel_lru_locks OSC > /dev/null
365 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
366 echo 0x8000030a > /proc/sys/lustre/fail_loc
367 ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
368 ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
370 diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
372 run_test 17 "resource creation/LVB creation race ==============="
375 ./mmap_sanity -d $MOUNT1 -m $MOUNT2
378 #run_test 18 "mmap sanity check ================================="
380 test_19() { # bug3811
381 [ -d /proc/fs/lustre/obdfilter ] || return 0
383 MAX=`cat /proc/fs/lustre/obdfilter/*/readcache_max_filesize | head -n 1`
384 for O in /proc/fs/lustre/obdfilter/OST*; do
385 echo 4096 > $O/readcache_max_filesize
387 dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
388 SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
389 cp $TMP/f19b $DIR1/f19b
390 for i in `seq 1 20`; do
391 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
392 cancel_lru_locks OSC > /dev/null
393 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
394 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
396 [ "`cat $TMP/sum1`" = "$SUM" ] || \
397 error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
398 [ "`cat $TMP/sum2`" = "$SUM" ] || \
399 error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
401 for O in /proc/fs/lustre/obdfilter/OST*; do
402 echo $MAX > $O/readcache_max_filesize
406 #run_test 19 "test concurrent uncached read races ==============="
411 CNT=$((`cat /proc/fs/lustre/llite/fs0/dump_page_cache | wc -l`))
412 multiop $DIR1/f20 Ow8190c
413 multiop $DIR2/f20 Oz8194w8190c
414 multiop $DIR1/f20 Oz0r8190c
416 CNTD=$((`cat /proc/fs/lustre/llite/fs0/dump_page_cache | wc -l` - $CNT))
418 error $CNTD" page left in cache after lock cancel" || true
421 run_test 20 "test extra readahead page left in cache ===="
424 log "cleanup: ======================================================"
425 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
427 echo '=========================== finished ==============================='
428 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true