6 # bug number for skipped test: 3192 4035
7 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"14b 14c"}
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
10 [ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \
11 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`"
14 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
17 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
18 CREATETEST=${CREATETEST:-createtest}
20 LSTRIPE=${LSTRIPE:-lstripe}
22 MCREATE=${MCREATE:-mcreate}
23 OPENFILE=${OPENFILE:-openfile}
24 OPENUNLINK=${OPENUNLINK:-openunlink}
25 TOEXCL=${TOEXCL:-toexcl}
26 TRUNCATE=${TRUNCATE:-truncate}
27 export TMP=${TMP:-/tmp}
29 if [ $UID -ne 0 ]; then
33 RUNAS_ID=${RUNAS_ID:-500}
34 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
41 sh llmountcleanup.sh ${FORCE} > /dev/null || exit 20
47 sh llmount.sh > /dev/null || exit 10
54 lctl mark "$*" 2> /dev/null || true
59 strace -o $TMP/$1.strace -ttt $*
61 log "FINISHED: $*: rc $RC"
67 if ! mount | grep -q $DIR1; then
71 log "== test $1: $2= `date +%H:%M:%S` ($BEFORE)"
72 export TESTNAME=test_$1
73 export tfile=f${testnum}
75 test_$1 || error "test_$1: exit with rc=$?"
77 pass "($((`date +%s` - $BEFORE))s)"
84 if [ "`echo $1 | grep '\<'$O'[a-z]*\>'`" ]; then
92 for X in $EXCEPT $ALWAYS_EXCEPT $SANITYN_EXCEPT; do
93 if [ "`echo $1 | grep '\<'$X'[a-z]*\>'`" ]; then
94 echo "skipping excluded test $1"
98 if [ -z "$ONLY" ]; then
104 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
107 log "FAIL: $TESTNAME $@"
108 if [ "$SANITYLOG" ]; then
109 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
119 export MOUNT1=`mount| awk '/ lustre/ { print $3 }'| head -n 1`
120 export MOUNT2=`mount| awk '/ lustre/ { print $3 }'| tail -n 1`
121 [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
122 [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
123 [ `mount| awk '/ lustre/ { print $3 }'| wc -l` -ne 2 ] && \
124 error "NAME=$NAME mounted more than twice"
126 export DIR1=${DIR1:-$MOUNT1}
127 export DIR2=${DIR2:-$MOUNT2}
128 [ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96
129 [ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95
131 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
135 [ -f $DIR2/f1 ] || error
137 run_test 1a "check create on 2 mtpt's =========================="
141 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
144 run_test 1b "check attribute updates on 2 mtpt's ==============="
147 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
149 run_test 1c "check after remount attribute updates on 2 mtpt's ="
153 $CHECKSTAT -a $DIR1/f1 || error
155 run_test 1d "unlink on one mountpoint removes file on other ===="
161 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
163 run_test 2a "check cached attribute updates on 2 mtpt's ========"
169 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
171 run_test 2b "check cached attribute updates on 2 mtpt's ========"
173 # NEED TO SAVE ROOT DIR MODE
176 $CHECKSTAT -t dir -p 0777 $DIR2 || error
178 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
182 $CHECKSTAT -t dir -p 0755 $DIR2 || error
184 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
187 ( cd $DIR1 ; ln -s this/is/good lnk )
188 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
191 run_test 3 "symlink on one mtpt, readlink on another ==========="
194 multifstat $DIR1/f4 $DIR2/f4
196 run_test 4 "fstat validation on multiple mount points =========="
200 truncate $DIR2/f5 100
201 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
204 run_test 5 "create a file on one mount, truncate it on the other"
207 openunlink $DIR1/f6 $DIR2/f6 || error
209 run_test 6 "remove of open file on other node =================="
212 opendirunlink $DIR1/d7 $DIR2/d7 || error
214 run_test 7 "remove of open directory on other node ============="
217 opendevunlink $DIR1/dev8 $DIR2/dev8 || error
219 run_test 8 "remove of open special file on other node =========="
224 for C in a b c d e f g h i j k l; do
225 DIR=`eval echo \\$DIR$MTPT`
226 echo -n $C >> $DIR/f9
227 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
229 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
230 error "`od -a $DIR1/f9` != abcdefghijkl"
232 run_test 9 "append of file with sub-page size on multiple mounts"
238 for C in a b c d e f g h i j k l; do
239 DIR=`eval echo \\$DIR$MTPT`
240 echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
241 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
242 OFFSET=`expr $OFFSET + 1`
244 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
245 error "`od -a $DIR1/f10` != abcdefghijkl"
247 run_test 10a "write of file with sub-page size on multiple mounts "
250 yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
252 truncate $DIR1/f10b 4096 || error "truncate 4096"
254 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
256 # create a test file locally to compare
257 yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
258 truncate $TMP/f10b 4096 || error "truncate 4096"
259 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
260 rm $TMP/f10b $TMP/f10b-lustre
262 run_test 10b "write of file with sub-page size on multiple mounts "
266 multiop $DIR1/d11/f O_c &
269 cp -p /bin/ls $DIR1/d11/f
273 wait $MULTIPID || error
274 [ $RC -eq 0 ] && error || true
276 run_test 11 "execution of file opened for write should return error ===="
281 run_test 12 "test lock ordering (link, stat, unlink) ==========="
283 test_13() { # bug 2451 - directory coherency
285 mkdir $DIR1/d13 || error
286 cd $DIR1/d13 || error
288 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
290 rm -f $DIR2/d13/f13 || error
291 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
292 # need to run it twice
293 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
295 rm -f $DIR2/d13/f13 || error
296 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
298 run_test 13 "test directory page revocation ===================="
302 cp -p /bin/ls $DIR1/d14/ls
303 exec 100>> $DIR1/d14/ls
304 $DIR2/d14/ls && error || true
307 run_test 14 "execution of file open for write returns -ETXTBSY ="
311 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
312 $DIR1/d14/multiop $TMP/test14.junk O_c &
315 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
316 kill -USR1 $MULTIPID || return 2
317 wait $MULTIPID || return 3
320 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
322 test_14b() { # bug 3192
324 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
325 $DIR1/d14/multiop $TMP/test14.junk O_c &
328 truncate $DIR2/d14/multiop 0 && error "expected error, got success"
329 kill -USR1 $MULTIPID || return 2
330 wait $MULTIPID || return 3
333 run_test 14b "truncate of executing file returns -ETXTBSY ======"
335 test_14c() { # bug 3430
337 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
338 $DIR1/d14/multiop $TMP/test14.junk O_c &
341 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
342 kill -USR1 $MULTIPID || return 2
343 wait $MULTIPID || return 3
344 #cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
347 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
349 test_15() { # bug 974 - ENOSPC
351 sh oos2.sh $MOUNT1 $MOUNT2
353 run_test 15 "test out-of-space with multiple writers ==========="
356 fsx -c 50 -p 100 -N 2500 -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
358 run_test 16 "2500 iterations of dual-mount fsx ================="
361 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
362 echo clear > $d/lru_size
364 grep "[0-9]" /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
367 test_17() { # bug 3513, 3667
368 [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
370 cp /etc/termcap $DIR1/f17
371 cancel_lru_locks OSC > /dev/null
372 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
373 echo 0x8000030a > /proc/sys/lustre/fail_loc
374 ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
375 ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
377 diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
379 run_test 17 "resource creation/LVB creation race ==============="
382 ./mmap_sanity -d $MOUNT1 -m $MOUNT2
385 run_test 18 "mmap sanity check ================================="
387 test_19() { # bug3811
388 [ -d /proc/fs/lustre/obdfilter ] || return 0
390 MAX=`cat /proc/fs/lustre/obdfilter/*/readcache_max_filesize | head -n 1`
391 for O in /proc/fs/lustre/obdfilter/OST*; do
392 echo 4096 > $O/readcache_max_filesize
394 dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
395 SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
396 cp $TMP/f19b $DIR1/f19b
397 for i in `seq 1 20`; do
398 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
399 cancel_lru_locks OSC > /dev/null
400 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
401 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
403 [ "`cat $TMP/sum1`" = "$SUM" ] || \
404 error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
405 [ "`cat $TMP/sum2`" = "$SUM" ] || \
406 error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
408 for O in /proc/fs/lustre/obdfilter/OST*; do
409 echo $MAX > $O/readcache_max_filesize
413 #run_test 19 "test concurrent uncached read races ==============="
418 CNT=$((`cat /proc/fs/lustre/llite/fs0/dump_page_cache | wc -l`))
419 multiop $DIR1/f20 Ow8190c
420 multiop $DIR2/f20 Oz8194w8190c
421 multiop $DIR1/f20 Oz0r8190c
423 CNTD=$((`cat /proc/fs/lustre/llite/fs0/dump_page_cache | wc -l` - $CNT))
425 error $CNTD" page left in cache after lock cancel" || true
427 run_test 20 "test extra readahead page left in cache ===="
434 test_21() { # Bug 5907
436 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
438 rmdir -v $DIR1/d21 && error "Removed mounted directory"
439 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
440 test -d $DIR1/d21 || error "Mounted directory disappeared"
442 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
445 run_test 21 " Try to remove mountpoint on another dir ===="
447 JOIN=${JOIN:-"lfs join"}
449 test_22() { # Bug 9926
451 dd if=/dev/urandom of=$DIR1/d21/128k bs=1024 count=128
452 cp -p $DIR1/d21/128k $DIR1/d21/f_head
453 for ((i=0;i<10;i++)); do
454 cp -p $DIR1/d21/128k $DIR1/d21/f_tail
455 $JOIN $DIR1/d21/f_head $DIR1/d21/f_tail || error "join error"
456 $CHECKSTAT -a $DIR1/d21/f_tail || error "tail file exist after join"
458 echo aaaaaaaaaaa >> $DIR1/d21/no_joined
460 mv $DIR2/d21/f_head $DIR2/
461 munlink $DIR2/f_head || error "unlink joined file error"
462 cat $DIR2/d21/no_joined || error "cat error"
463 rm -rf $DIR2/d21/no_joined || error "unlink normal file error"
465 run_test 22 " After joining in one dir, open/close unlink file in anther dir"
467 log "cleanup: ======================================================"
468 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
470 echo '=========================== finished ==============================='
471 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true