6 # bug number for skipped test: 1768 3192
7 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"4 14b"}
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
15 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
16 CREATETEST=${CREATETEST:-createtest}
18 LSTRIPE=${LSTRIPE:-lstripe}
20 MCREATE=${MCREATE:-mcreate}
21 OPENFILE=${OPENFILE:-openfile}
22 OPENUNLINK=${OPENUNLINK:-openunlink}
23 TOEXCL=${TOEXCL:-toexcl}
24 TRUNCATE=${TRUNCATE:-truncate}
26 if [ $UID -ne 0 ]; then
30 RUNAS_ID=${RUNAS_ID:-500}
31 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
38 sh llmountcleanup.sh > /dev/null || exit 20
44 sh llrmount.sh > /dev/null || exit 10
51 lctl mark "$*" 2> /dev/null || true
55 if ! mount | grep -q $DIR1; then
59 export TESTNAME=test_$1
60 test_$1 || error "test_$1: exit with rc=$?"
69 if [ "`echo $1 | grep '\<'$O'[a-z]*\>'`" ]; then
77 for X in $EXCEPT $ALWAYS_EXCEPT; do
78 if [ "`echo $1 | grep '\<'$X'[a-z]*\>'`" ]; then
79 echo "skipping excluded test $1"
83 if [ -z "$ONLY" ]; then
89 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
92 log "FAIL: $TESTNAME $@"
93 if [ "$SANITYLOG" ]; then
94 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
104 export MOUNT1=`mount| awk '/ lustre/ { print $3 }'| head -n 1`
105 export MOUNT2=`mount| awk '/ lustre/ { print $3 }'| tail -n 1`
106 [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
107 [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
108 [ `mount| awk '/ lustre/ { print $3 }'| wc -l` -ne 2 ] && \
109 error "NAME=$NAME mounted more than twice"
111 export DIR1=${DIR1:-$MOUNT1}
112 export DIR2=${DIR2:-$MOUNT2}
113 [ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96
114 [ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95
116 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
120 [ -f $DIR2/f1 ] || error
122 run_test 1a "check create on 2 mtpt's =========================="
126 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
129 run_test 1b "check attribute updates on 2 mtpt's ==============="
132 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
134 run_test 1c "check after remount attribute updates on 2 mtpt's ="
138 $CHECKSTAT -a $DIR1/f1 || error
140 run_test 1d "unlink on one mountpoint removes file on other ===="
146 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
148 run_test 2a "check cached attribute updates on 2 mtpt's ========"
154 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
156 run_test 2b "check cached attribute updates on 2 mtpt's ========"
158 # NEED TO SAVE ROOT DIR MODE
161 $CHECKSTAT -t dir -p 0777 $DIR2 || error
163 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
167 $CHECKSTAT -t dir -p 0755 $DIR2 || error
169 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
172 ( cd $DIR1 ; ln -s this/is/good lnk )
173 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
176 run_test 3 "symlink on one mtpt, readlink on another ==========="
179 multifstat $DIR1/f4 $DIR2/f4
181 run_test 4 "fstat validation on multiple mount points =========="
185 truncate $DIR2/f5 100
186 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
189 run_test 5 "create a file on one mount, truncate it on the other"
192 openunlink $DIR1/f6 $DIR2/f6 || error
194 run_test 6 "remove of open file on other node =================="
197 opendirunlink $DIR1/d7 $DIR2/d7 || error
199 run_test 7 "remove of open directory on other node ============="
202 opendevunlink $DIR1/dev8 $DIR2/dev8 || error
204 run_test 8 "remove of open special file on other node =========="
209 for C in a b c d e f g h i j k l; do
210 DIR=`eval echo \\$DIR$MTPT`
211 echo -n $C >> $DIR/f9
212 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
214 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
215 error "`od -a $DIR1/f9` != abcdefghijkl"
217 run_test 9 "append of file with sub-page size on multiple mounts"
223 for C in a b c d e f g h i j k l; do
224 DIR=`eval echo \\$DIR$MTPT`
225 echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
226 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
227 OFFSET=`expr $OFFSET + 1`
229 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
230 error "`od -a $DIR1/f10` != abcdefghijkl"
232 run_test 10a "write of file with sub-page size on multiple mounts "
235 yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
237 truncate $DIR1/f10b 4096 || error "truncate 4096"
239 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
241 # create a test file locally to compare
242 yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
243 truncate $TMP/f10b 4096 || error "truncate 4096"
244 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
246 run_test 10b "write of file with sub-page size on multiple mounts "
250 multiop $DIR1/d11/f O_c &
253 cp -p /bin/ls $DIR1/d11/f
257 wait $MULTIPID || error
258 [ $RC -eq 0 ] && error || true
260 run_test 11 "execution of file opened for write should return error ===="
265 run_test 12 "test lock ordering (link, stat, unlink) ==========="
267 test_13() { # bug 2451 - directory coherency
269 mkdir $DIR1/d13 || error
270 cd $DIR1/d13 || error
272 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
274 rm -f $DIR2/d13/f13 || error
275 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
276 # need to run it twice
277 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
279 rm -f $DIR2/d13/f13 || error
280 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
282 run_test 13 "test directory page revocation ===================="
286 cp -p /bin/ls $DIR1/d14/ls
287 exec 100>> $DIR1/d14/ls
288 $DIR2/d14/ls && error || true
291 run_test 14 "execution of file open for write returns -ETXTBSY ="
295 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
296 $DIR1/d14/multiop $TMP/test14.junk O_c &
299 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
300 kill -USR1 $MULTIPID || return 2
301 wait $MULTIPID || return 3
303 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
305 test_14b() { # bug 3192
307 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
308 $DIR1/d14/multiop $TMP/test14.junk O_c &
311 truncate $DIR2/d14/multiop 0 && error "expected error, got success"
312 kill -USR1 $MULTIPID || return 2
313 wait $MULTIPID || return 3
315 run_test 14b "truncate of executing file returns -ETXTBSY ======"
317 test_14c() { # bug 3430
319 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
320 $DIR1/d14/multiop $TMP/test14.junk O_c &
323 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
324 kill -USR1 $MULTIPID || return 2
325 wait $MULTIPID || return 3
326 #cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
328 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
330 test_15() { # bug 974 - ENOSPC
332 sh oos2.sh $MOUNT1 $MOUNT2
334 run_test 15 "test out-of-space with multiple writers ==========="
337 fsx -R -W -c 50 -p 100 -N 2500 $MOUNT1/fsxfile $MOUNT2/fsxfile
339 run_test 16 "2500 iterations of dual-mount fsx ================="
342 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
343 echo clear > $d/lru_size
345 grep [0-9] /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
348 test_17() { # bug 3513, 3667
349 [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
351 cp /etc/termcap $DIR1/f17
352 cancel_lru_locks OSC > /dev/null
353 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
354 echo 0x8000030a > /proc/sys/lustre/fail_loc
355 ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
356 ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
358 diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
360 run_test 17 "resource creation/LVB creation race ==============="
362 log "cleanup: ======================================================"
363 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
365 echo '=========================== finished ==============================='
366 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true