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