6 # bug number for skipped test: 1768 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
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
45 sh llrmount.sh > /dev/null || exit 10
53 lctl mark "$*" 2> /dev/null || true
57 if ! mount | grep -q $DIR1; then
61 export TESTNAME=test_$1
62 test_$1 || error "test_$1: exit with rc=$?"
71 if [ "`echo $1 | grep '\<'$O'[a-z]*\>'`" ]; then
79 for X in $EXCEPT $ALWAYS_EXCEPT; do
80 if [ "`echo $1 | grep '\<'$X'[a-z]*\>'`" ]; then
81 echo "skipping excluded test $1"
85 if [ -z "$ONLY" ]; then
91 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
94 log "FAIL: $TESTNAME $@"
95 if [ "$SANITYLOG" ]; then
96 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
106 export MOUNT1=`mount| awk '/ lustre/ { print $3 }'| head -n 1`
107 export MOUNT2=`mount| awk '/ lustre/ { print $3 }'| tail -n 1`
108 [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
109 [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
110 [ `mount| awk '/ lustre/ { print $3 }'| wc -l` -ne 2 ] && \
111 error "NAME=$NAME mounted more than twice"
113 export DIR1=${DIR1:-$MOUNT1}
114 export DIR2=${DIR2:-$MOUNT2}
115 [ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96
116 [ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95
118 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
122 [ -f $DIR2/f1 ] || error
124 run_test 1a "check create on 2 mtpt's =========================="
128 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
131 run_test 1b "check attribute updates on 2 mtpt's ==============="
134 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
136 run_test 1c "check after remount attribute updates on 2 mtpt's ="
140 $CHECKSTAT -a $DIR1/f1 || error
142 run_test 1d "unlink on one mountpoint removes file on other ===="
148 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
150 run_test 2a "check cached attribute updates on 2 mtpt's ========"
156 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
158 run_test 2b "check cached attribute updates on 2 mtpt's ========"
160 # NEED TO SAVE ROOT DIR MODE
163 $CHECKSTAT -t dir -p 0777 $DIR2 || error
165 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
169 $CHECKSTAT -t dir -p 0755 $DIR2 || error
171 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
174 ( cd $DIR1 ; ln -s this/is/good lnk )
175 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
178 run_test 3 "symlink on one mtpt, readlink on another ==========="
181 multifstat $DIR1/f4 $DIR2/f4
183 run_test 4 "fstat validation on multiple mount points =========="
187 truncate $DIR2/f5 100
188 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
191 run_test 5 "create a file on one mount, truncate it on the other"
194 openunlink $DIR1/f6 $DIR2/f6 || error
196 run_test 6 "remove of open file on other node =================="
199 opendirunlink $DIR1/d7 $DIR2/d7 || error
201 run_test 7 "remove of open directory on other node ============="
204 opendevunlink $DIR1/dev8 $DIR2/dev8 || error
206 run_test 8 "remove of open special file on other node =========="
211 for C in a b c d e f g h i j k l; do
212 DIR=`eval echo \\$DIR$MTPT`
213 echo -n $C >> $DIR/f9
214 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
216 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
217 error "`od -a $DIR1/f9` != abcdefghijkl"
219 run_test 9 "append of file with sub-page size on multiple mounts"
225 for C in a b c d e f g h i j k l; do
226 DIR=`eval echo \\$DIR$MTPT`
227 echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
228 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
229 OFFSET=`expr $OFFSET + 1`
231 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
232 error "`od -a $DIR1/f10` != abcdefghijkl"
234 run_test 10a "write of file with sub-page size on multiple mounts "
237 yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
239 truncate $DIR1/f10b 4096 || error "truncate 4096"
241 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
243 # create a test file locally to compare
244 yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
245 truncate $TMP/f10b 4096 || error "truncate 4096"
246 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
248 run_test 10b "write of file with sub-page size on multiple mounts "
252 multiop $DIR1/d11/f O_c &
255 cp -p /bin/ls $DIR1/d11/f
259 wait $MULTIPID || error
260 [ $RC -eq 0 ] && error || true
262 run_test 11 "execution of file opened for write should return error ===="
267 run_test 12 "test lock ordering (link, stat, unlink) ==========="
269 test_13() { # bug 2451 - directory coherency
271 mkdir $DIR1/d13 || error
272 cd $DIR1/d13 || error
274 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
276 rm -f $DIR2/d13/f13 || error
277 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
278 # need to run it twice
279 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
281 rm -f $DIR2/d13/f13 || error
282 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
284 run_test 13 "test directory page revocation ===================="
288 cp -p /bin/ls $DIR1/d14/ls
289 exec 100>> $DIR1/d14/ls
290 $DIR2/d14/ls && error || true
293 run_test 14 "execution of file open for write returns -ETXTBSY ="
297 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
298 $DIR1/d14/multiop $TMP/test14.junk O_c &
301 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
302 kill -USR1 $MULTIPID || return 2
303 wait $MULTIPID || return 3
305 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
307 test_14b() { # bug 3192
309 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
310 $DIR1/d14/multiop $TMP/test14.junk O_c &
313 truncate $DIR2/d14/multiop 0 && error "expected error, got success"
314 kill -USR1 $MULTIPID || return 2
315 wait $MULTIPID || return 3
317 run_test 14b "truncate of executing file returns -ETXTBSY ======"
319 test_14c() { # bug 3430
321 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
322 $DIR1/d14/multiop $TMP/test14.junk O_c &
325 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
326 kill -USR1 $MULTIPID || return 2
327 wait $MULTIPID || return 3
328 #cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
330 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
332 test_15() { # bug 974 - ENOSPC
334 sh oos2.sh $MOUNT1 $MOUNT2
336 run_test 15 "test out-of-space with multiple writers ==========="
339 fsx -c 50 -p 100 -N 2500 $MOUNT1/fsxfile $MOUNT2/fsxfile
341 run_test 16 "2500 iterations of dual-mount fsx ================="
344 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
345 echo clear > $d/lru_size
347 grep [0-9] /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
350 test_17() { # bug 3513, 3667
351 [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
353 cp /etc/termcap $DIR1/f17
354 cancel_lru_locks OSC > /dev/null
355 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
356 echo 0x8000030a > /proc/sys/lustre/fail_loc
357 ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
358 ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
360 diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
362 run_test 17 "resource creation/LVB creation race ==============="
365 ./mmap_sanity -d $MOUNT1 -m $MOUNT2
367 run_test 18 "mmap sanity check ================================="
370 log "cleanup: ======================================================"
371 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
373 echo '=========================== finished ==============================='
374 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true