Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / tests / sanityN.sh
1 #!/bin/bash
2
3 set -e
4
5 ONLY=${ONLY:-"$*"}
6 # bug number for skipped test:  3192 9977
7 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"14b  28"}
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
9
10 [ "$SLOW" = "no" ] && EXCEPT="$EXCEPT 16"
11
12 # Tests that fail on uml
13 [ "$UML" = "true" ] && EXCEPT="$EXCEPT 7"
14
15 SRCDIR=`dirname $0`
16 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
17
18 SIZE=${SIZE:-40960}
19 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
20 CREATETEST=${CREATETEST:-createtest}
21 GETSTRIPE=${GETSTRIPE:-lfs getstripe}
22 SETSTRIPE=${SETSTRIPE:-lstripe}
23 LCTL=${LCTL:-lctl}
24 MCREATE=${MCREATE:-mcreate}
25 OPENFILE=${OPENFILE:-openfile}
26 OPENUNLINK=${OPENUNLINK:-openunlink}
27 TOEXCL=${TOEXCL:-toexcl}
28 TRUNCATE=${TRUNCATE:-truncate}
29 export TMP=${TMP:-/tmp}
30
31 if [ $UID -ne 0 ]; then
32         RUNAS_ID="$UID"
33         RUNAS=""
34 else
35         RUNAS_ID=${RUNAS_ID:-500}
36         RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
37 fi
38
39 SAVE_PWD=$PWD
40
41 LUSTRE=${LUSTRE:-`dirname $0`/..}
42 . $LUSTRE/tests/test-framework.sh
43 init_test_env $@
44 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
45
46 cleanup() {
47         echo -n "cln.."
48         grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 ${FORCE}
49         cleanupall ${FORCE} > /dev/null || { echo "FAILed to clean up"; exit 20; }
50 }
51 CLEANUP=${CLEANUP:-:}
52
53 setup() {
54         echo -n "mnt.."
55         setupall || exit 10
56         echo "done"
57 }
58 SETUP=${SETUP:-:}
59
60 log() {
61         echo "$*"
62         lctl mark "$*" 2> /dev/null || true
63 }
64
65 trace() {
66         log "STARTING: $*"
67         strace -o $TMP/$1.strace -ttt $*
68         RC=$?
69         log "FINISHED: $*: rc $RC"
70         return 1
71 }
72 TRACE=${TRACE:-""}
73
74 LPROC=/proc/fs/lustre
75
76 run_one() {
77         if ! grep -q $DIR /proc/mounts; then
78                 $SETUP
79         fi
80         testnum=$1
81         message=$2
82         BEFORE=`date +%s`
83         log "== test $testnum: $message= `date +%H:%M:%S` ($BEFORE)"
84         export TESTNAME=test_$testnum
85         export tfile=f${testnum}
86         export tdir=d${base}
87         test_$1 || error "exit with rc=$?"
88         unset TESTNAME
89         pass "($((`date +%s` - $BEFORE))s)"
90         cd $SAVE_PWD
91         $CLEANUP
92 }
93
94 build_test_filter() {
95         [ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \
96             echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`"
97
98         for O in $ONLY; do
99             eval ONLY_${O}=true
100         done
101         for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_EXCEPT; do
102             eval EXCEPT_${E}=true
103         done
104 }
105
106 _basetest() {
107     echo $*
108 }
109
110 basetest() {
111     IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
112 }
113
114 build_test_filter() {
115         [ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \
116             echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`"
117
118         for O in $ONLY; do
119             eval ONLY_${O}=true
120         done
121         for E in $EXCEPT $ALWAYS_EXCEPT $SANITYN_EXCEPT; do
122             eval EXCEPT_${E}=true
123         done
124 }
125
126 _basetest() {
127     echo $*
128 }
129
130 basetest() {
131     IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
132 }
133
134 run_test() {
135          export base=`basetest $1`
136          if [ "$ONLY" ]; then
137                  testname=ONLY_$1
138                  if [ ${!testname}x != x ]; then
139                         run_one $1 "$2"
140                         return $?
141                  fi
142                  testname=ONLY_$base
143                  if [ ${!testname}x != x ]; then
144                          run_one $1 "$2"
145                          return $?
146                  fi
147                  echo -n "."
148                  return 0
149         fi
150         testname=EXCEPT_$1
151         if [ ${!testname}x != x ]; then
152                  echo "skipping excluded test $1"
153                  return 0
154         fi
155         testname=EXCEPT_$base
156         if [ ${!testname}x != x ]; then
157                  echo "skipping excluded test $1 (base $base)"
158                  return 0
159         fi
160         run_one $1 "$2"
161         return $?
162 }
163
164 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
165
166 error () {
167         sysctl -w lustre.fail_loc=0 2> /dev/null || true
168         log "$0: FAIL: $TESTNAME $@"
169         if [ "$SANITYLOG" ]; then
170                 echo "$0: FAIL: $TESTNAME $@" >> $SANITYLOG
171         else
172                 exit 1
173         fi
174 }
175
176 pass() {
177         echo PASS $@
178 }
179
180 mounted_lustre_filesystems() {
181         awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
182 }
183 MOUNTED="`mounted_lustre_filesystems`"
184 if [ -z "$MOUNTED" ]; then
185     formatall
186     setupall
187     mount_client $MOUNT2
188     MOUNTED="`mounted_lustre_filesystems`"
189     [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
190     I_MOUNTED=yes
191 fi
192 export MOUNT1=`mounted_lustre_filesystems | head -n 1`
193 [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
194 export MOUNT2=`mounted_lustre_filesystems | tail -n 1`
195 [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
196 [ `mounted_lustre_filesystems | wc -l` -ne 2 ] && \
197         error "NAME=$NAME mounted more than twice"
198
199 export DIR1=${DIR1:-$MOUNT1}
200 export DIR2=${DIR2:-$MOUNT2}
201 [ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96
202 [ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95
203
204 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
205
206 build_test_filter
207
208 test_1a() {
209         touch $DIR1/f1
210         [ -f $DIR2/f1 ] || error
211 }
212 run_test 1a "check create on 2 mtpt's =========================="
213
214 test_1b() {
215         chmod 777 $DIR2/f1
216         $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
217         chmod a-x $DIR2/f1
218 }
219 run_test 1b "check attribute updates on 2 mtpt's ==============="
220
221 test_1c() {
222         $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
223 }
224 run_test 1c "check after remount attribute updates on 2 mtpt's ="
225
226 test_1d() {
227         rm $DIR2/f1
228         $CHECKSTAT -a $DIR1/f1 || error
229 }
230 run_test 1d "unlink on one mountpoint removes file on other ===="
231
232 test_2a() {
233         touch $DIR1/f2a
234         ls -l $DIR2/f2a
235         chmod 777 $DIR2/f2a
236         $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
237 }
238 run_test 2a "check cached attribute updates on 2 mtpt's ========"
239
240 test_2b() {
241         touch $DIR1/f2b
242         ls -l $DIR2/f2b
243         chmod 777 $DIR1/f2b
244         $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
245 }
246 run_test 2b "check cached attribute updates on 2 mtpt's ========"
247
248 # NEED TO SAVE ROOT DIR MODE
249 test_2c() {
250         chmod 777 $DIR1
251         $CHECKSTAT -t dir -p 0777 $DIR2 || error
252 }
253 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
254
255 test_2d() {
256         chmod 755 $DIR1
257         $CHECKSTAT -t dir -p 0755 $DIR2 || error
258 }
259 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
260
261 test_2e() {
262         chmod 755 $DIR1
263         ls -l $DIR1
264         ls -l $DIR2
265         chmod 777 $DIR1
266         $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
267 }
268 run_test 2e "check chmod on root is propagated to others"
269
270 test_3() {
271         ( cd $DIR1 ; ln -s this/is/good lnk )
272         [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
273                 error
274 }
275 run_test 3 "symlink on one mtpt, readlink on another ==========="
276
277 test_4() {
278         multifstat $DIR1/f4 $DIR2/f4
279 }
280 run_test 4 "fstat validation on multiple mount points =========="
281
282 test_5() {
283         mcreate $DIR1/f5
284         truncate $DIR2/f5 100
285         $CHECKSTAT -t file -s 100 $DIR1/f5 || error
286         rm $DIR1/f5
287 }
288 run_test 5 "create a file on one mount, truncate it on the other"
289
290 test_6() {
291         openunlink $DIR1/$tfile $DIR2/$tfile || \
292                 error "openunlink $DIR1/$tfile $DIR2/$tfile"
293 }
294 run_test 6 "remove of open file on other node =================="
295
296 test_7() {
297         opendirunlink $DIR1/$tdir $DIR2/$tdir || \
298                 error "opendirunlink $DIR1/$tdir $DIR2/$tdir"
299 }
300 run_test 7 "remove of open directory on other node ============="
301
302 test_8() {
303         opendevunlink $DIR1/$tfile $DIR2/$tfile || \
304                 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
305 }
306 run_test 8 "remove of open special file on other node =========="
307
308 test_9() {
309         MTPT=1
310         > $DIR2/f9
311         for C in a b c d e f g h i j k l; do
312                 DIR=`eval echo \\$DIR$MTPT`
313                 echo -n $C >> $DIR/f9
314                 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
315         done
316         [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
317                 error "`od -a $DIR1/f9` != abcdefghijkl"
318 }
319 run_test 9 "append of file with sub-page size on multiple mounts"
320
321 test_10a() {
322         MTPT=1
323         OFFSET=0
324         > $DIR2/f10
325         for C in a b c d e f g h i j k l; do
326                 DIR=`eval echo \\$DIR$MTPT`
327                 echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
328                 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
329                 OFFSET=`expr $OFFSET + 1`
330         done
331         [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
332                 error "`od -a $DIR1/f10` != abcdefghijkl"
333 }
334 run_test 10a "write of file with sub-page size on multiple mounts "
335
336 test_10b() {
337         yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
338
339         truncate $DIR1/f10b 4096 || error "truncate 4096"
340
341         dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
342
343         # create a test file locally to compare
344         yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
345         truncate $TMP/f10b 4096 || error "truncate 4096"
346         cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
347         rm $TMP/f10b $TMP/f10b-lustre
348 }
349 run_test 10b "write of file with sub-page size on multiple mounts "
350
351 test_11() {
352         mkdir $DIR1/d11
353         multiop $DIR1/d11/f O_c &
354         MULTIPID=$!
355         usleep 200
356         cp -p /bin/ls $DIR1/d11/f
357         $DIR2/d11/f
358         RC=$?
359         kill -USR1 $MULTIPID
360         wait $MULTIPID || error
361         [ $RC -eq 0 ] && error || true
362 }
363 run_test 11 "execution of file opened for write should return error ===="
364
365 test_12() {
366        sh lockorder.sh
367 }
368 run_test 12 "test lock ordering (link, stat, unlink) ==========="
369
370 test_13() {     # bug 2451 - directory coherency
371        rm -rf $DIR1/d13
372        mkdir $DIR1/d13 || error
373        cd $DIR1/d13 || error
374        ls
375        ( touch $DIR1/d13/f13 ) # needs to be a separate shell
376        ls
377        rm -f $DIR2/d13/f13 || error
378        ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
379        # need to run it twice
380        ( touch $DIR1/d13/f13 ) # needs to be a separate shell
381        ls
382        rm -f $DIR2/d13/f13 || error
383        ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
384 }
385 run_test 13 "test directory page revocation ===================="
386
387 test_14() {
388         mkdir $DIR1/d14
389         cp -p /bin/ls $DIR1/d14/ls
390         exec 100>> $DIR1/d14/ls
391         $DIR2/d14/ls && error || true
392         exec 100<&-
393 }
394 run_test 14 "execution of file open for write returns -ETXTBSY ="
395
396 test_14a() {
397         mkdir -p $DIR1/d14
398         cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
399         $DIR1/d14/multiop $TMP/test14.junk O_c &
400         MULTIPID=$!
401         sleep 1
402         multiop $DIR2/d14/multiop Oc && error "expected error, got success"
403         kill -USR1 $MULTIPID || return 2
404         wait $MULTIPID || return 3
405         rm $TMP/test14.junk
406 }
407 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
408
409 test_14b() { # bug 3192, 7040
410         mkdir -p $DIR1/d14
411         cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
412         $DIR1/d14/multiop $TMP/test14.junk O_c &
413         MULTIPID=$!
414         sleep 1
415         truncate $DIR2/d14/multiop 0 && kill -9 $MULTIPID && \
416                 error "expected truncate error, got success"
417         kill -USR1 $MULTIPID || return 2
418         wait $MULTIPID || return 3
419         cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
420         rm $TMP/test14.junk
421 }
422 run_test 14b "truncate of executing file returns -ETXTBSY ======"
423
424 test_14c() { # bug 3430, 7040
425         mkdir -p $DIR1/d14
426         cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
427         $DIR1/d14/multiop $TMP/test14.junk O_c &
428         MULTIPID=$!
429         sleep 1
430         cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
431         kill -USR1 $MULTIPID || return 2
432         wait $MULTIPID || return 3
433         cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
434         rm $TMP/test14.junk
435 }
436 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
437
438 test_14d() { # bug 10921
439         mkdir -p $DIR1/d14
440         cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
441         $DIR1/d14/multiop $TMP/test14.junk O_c &
442         MULTIPID=$!
443         sleep 1
444         log chmod
445         chmod 600 $DIR1/d14/multiop || error "chmod failed"
446         kill -USR1 $MULTIPID || return 2
447         wait $MULTIPID || return 3
448         cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
449         rm $TMP/test14.junk
450 }
451 run_test 14d "chmod of executing file is still possible ========"
452
453 test_15() {     # bug 974 - ENOSPC
454         echo "PATH=$PATH"
455         sh oos2.sh $MOUNT1 $MOUNT2
456 }
457 run_test 15 "test out-of-space with multiple writers ==========="
458
459 test_16() {
460         fsx -c 50 -p 100 -N 2500 -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
461 }
462 run_test 16 "2500 iterations of dual-mount fsx ================="
463
464 test_17() { # bug 3513, 3667
465         [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
466
467         cp /etc/termcap $DIR1/f17
468         cancel_lru_locks osc > /dev/null
469         #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE    0x30a
470         sysctl -w lustre.fail_loc=0x8000030a
471         ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
472         ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
473         wait
474         diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
475 }
476 run_test 17 "resource creation/LVB creation race ==============="
477
478 test_18() {
479         ./mmap_sanity -d $MOUNT1 -m $MOUNT2
480         sync; sleep 1; sync
481 }
482 run_test 18 "mmap sanity check ================================="
483
484 test_19() { # bug3811
485         [ -d /proc/fs/lustre/obdfilter ] || return 0
486
487         MAX=`cat /proc/fs/lustre/obdfilter/*/readcache_max_filesize | head -n 1`
488         for O in /proc/fs/lustre/obdfilter/*OST*; do
489                 echo 4096 > $O/readcache_max_filesize
490         done
491         dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
492         SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
493         cp $TMP/f19b $DIR1/f19b
494         for i in `seq 1 20`; do
495                 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
496                 cancel_lru_locks osc > /dev/null
497                 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
498                 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
499                 wait
500                 [ "`cat $TMP/sum1`" = "$SUM" ] || \
501                         error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
502                 [ "`cat $TMP/sum2`" = "$SUM" ] || \
503                         error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
504         done
505         for O in /proc/fs/lustre/obdfilter/*OST*; do
506                 echo $MAX > $O/readcache_max_filesize
507         done
508         rm $DIR1/f19b
509 }
510 #run_test 19 "test concurrent uncached read races ==============="
511
512 test_20() {
513         mkdir $DIR1/d20
514         cancel_lru_locks osc
515         CNT=$((`cat /proc/fs/lustre/llite/*/dump_page_cache | wc -l`))
516         multiop $DIR1/f20 Ow8190c
517         multiop $DIR2/f20 Oz8194w8190c
518         multiop $DIR1/f20 Oz0r8190c
519         cancel_lru_locks osc
520         CNTD=$((`cat /proc/fs/lustre/llite/*/dump_page_cache | wc -l` - $CNT))
521         [ $CNTD -gt 0 ] && \
522             error $CNTD" page left in cache after lock cancel" || true
523 }
524 run_test 20 "test extra readahead page left in cache ===="
525
526 cleanup_21() {
527         trap 0
528         umount $DIR1/d21
529 }
530
531 test_21() { # Bug 5907
532         mkdir $DIR1/d21
533         mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
534         trap cleanup_21 EXIT
535         rmdir -v $DIR1/d21 && error "Removed mounted directory"
536         rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
537         test -d $DIR1/d21 || error "Mounted directory disappeared"
538         cleanup_21
539         test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
540         true
541 }
542 run_test 21 " Try to remove mountpoint on another dir ===="
543
544 JOIN=${JOIN:-"lfs join"}
545
546 test_22() { # Bug 9926
547         mkdir $DIR1/d21
548         dd if=/dev/urandom of=$DIR1/d21/128k bs=1024 count=128
549         cp -p $DIR1/d21/128k $DIR1/d21/f_head
550         for ((i=0;i<10;i++)); do
551                 cp -p $DIR1/d21/128k $DIR1/d21/f_tail
552                 $JOIN $DIR1/d21/f_head $DIR1/d21/f_tail || error "join error"
553                 $CHECKSTAT -a $DIR1/d21/f_tail || error "tail file exist after join"
554         done
555         echo aaaaaaaaaaa >> $DIR1/d21/no_joined
556
557         mv $DIR2/d21/f_head $DIR2/
558         munlink $DIR2/f_head || error "unlink joined file error"
559         cat $DIR2/d21/no_joined || error "cat error"
560         rm -rf $DIR2/d21/no_joined || error "unlink normal file error"
561 }
562 run_test 22 " After joining in one dir,  open/close unlink file in anther dir" 
563
564 test_23() { # Bug 5972
565         echo "others should see updated atime while another read" > $DIR1/f23
566         
567         # clear the lock(mode: LCK_PW) gotten from creating operation
568         cancel_lru_locks osc
569         
570         time1=`date +%s`        
571         sleep 2
572         
573         multiop $DIR1/f23 or20_c &
574         MULTIPID=$!
575
576         sleep 2
577         time2=`stat -c "%X" $DIR2/f23`
578
579         if (( $time2 <= $time1 )); then
580                 kill -USR1 $MULTIPID
581                 error "atime doesn't update among nodes"
582         fi
583
584         kill -USR1 $MULTIPID || return 1
585         rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
586         true
587 }
588 run_test 23 " others should see updated atime while another read===="
589
590 test_24() {
591         touch $DIR1/$tfile
592         lfs df || error "lfs df failed"
593         lfs df -ih || error "lfs df -ih failed"
594         lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
595         lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
596         lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
597         lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
598         
599         OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
600         lctl --device %$OSC deactivate
601         lfs df -i || error "lfs df -i with deactivated OSC failed"
602         lctl --device %$OSC recover
603         lfs df || error "lfs df with reactivated OSC failed"
604 }
605 run_test 24 "lfs df [-ih] [path] test ========================="
606
607 test_25() {
608         [ `cat $LPROC/mdc/*-mdc-*/connect_flags | grep -c acl` -lt 2 ] && echo "skipping $TESTNAME (must have acl)" && return
609
610         mkdir $DIR1/$tdir || error "mkdir $DIR1/$tdir"
611         touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
612         chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
613
614         $RUNAS checkstat $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
615         setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #1"
616         $RUNAS checkstat $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
617         setfacl -m u:$RUNAS_ID:r-x $DIR1/$tdir || error "setfacl $DIR2/$tdir #2"
618         $RUNAS checkstat $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
619         setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #3"
620         $RUNAS checkstat $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
621         setfacl -x u:$RUNAS_ID: $DIR1/$tdir || error "setfacl $DIR2/$tdir #4"
622         $RUNAS checkstat $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
623
624         rm -rf $DIR1/$tdir
625 }
626 run_test 25 "change ACL on one mountpoint be seen on another ==="
627
628 test_26a() {
629         utime $DIR1/f26a -s $DIR2/f26a || error
630 }
631 run_test 26a "allow mtime to get older"
632
633 test_26b() {
634         touch $DIR1/$tfile
635         sleep 1
636         echo "aaa" >> $DIR1/$tfile
637         sleep 1
638         chmod a+x $DIR2/$tfile
639         mt1=`stat -c %Y $DIR1/$tfile`
640         mt2=`stat -c %Y $DIR2/$tfile`
641         
642         if [ x"$mt1" != x"$mt2" ]; then 
643                 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
644         fi
645 }
646 run_test 26b "sync mtime between ost and mds"
647
648 test_27() {
649         cancel_lru_locks OSC
650         lctl clear
651         dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
652         DD2_PID=$!
653         usleep 50
654         log "dd 1 started"
655         
656         dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
657         DD1_PID=$!
658         log "dd 2 started"
659         
660         sleep 1
661         dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
662         log "dd 3 finished"
663         echo > $LPROC/ldlm/dump_namespaces
664         wait $DD1_PID $DD2_PID
665         [ $? -ne 0 ] && lctl dk $TMP/debug || true
666 }
667 run_test 27 "align non-overlapping extent locks from request ==="
668
669 test_28() { # bug 9977
670         ECHO_UUID="ECHO_osc1_UUID"
671         tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1`
672
673         lfs setstripe $DIR1/$tfile 1048576 0 2
674         tOBJID=`lfs getstripe $DIR1/$tfile |grep "^[[:space:]]\+1" |awk '{print $2}'`
675         dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
676
677         $LCTL <<-EOF
678                 newdev
679                 attach echo_client ECHO_osc1 $ECHO_UUID
680                 setup $tOST
681         EOF
682
683         tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{print $1}'`
684         $LCTL --device $tECHOID destroy "${tOBJID}:0"
685     
686         $LCTL <<-EOF
687                 cfg_device ECHO_osc1
688                 cleanup
689                 detach
690         EOF
691
692         # reading of 1st stripe should pass
693         dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
694         # reading of 2nd stripe should fail (this stripe was destroyed)
695         dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
696
697         # now, recreating test file
698         dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
699         # reading of 1st stripe should pass
700         dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
701         # reading of 2nd stripe should pass
702         dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
703 }
704 run_test 28 "read/write/truncate file with lost stripes"
705
706 test_29() { # bug 10999
707         touch $DIR1/$tfile
708         #define OBD_FAIL_LDLM_GLIMPSE  0x30f
709         sysctl -w lustre.fail_loc=0x8000030f
710         ls -l $DIR2/$tfile &
711         usleep 500
712         dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
713         wait
714 }
715 #bug 11549 - permanently turn test off in b1_5
716 #run_test 29 "lock put race between glimpse and enqueue ========="
717
718 test_30() { #bug #11110
719     rm -rf $DIR1/$tdir
720     mkdir -p $DIR1/$tdir
721     cp -f /bin/bash $DIR1/$tdir/bash
722     /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
723     err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
724     wait
725     [ $err -ne 116 ] && error "return code ($err) != -ESTALE" && return
726     true
727 }
728
729 run_test 30 "recreate file race ========="
730
731 log "cleanup: ======================================================"
732 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
733 if [ "$I_MOUNTED" = "yes" ]; then
734     cleanup
735 fi
736
737 echo '=========================== finished ==============================='
738 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true
739 echo "$0: completed"
740