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