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