Whamcloud - gitweb
Land b1_2 onto HEAD (20040304_171022)
[fs/lustre-release.git] / lustre / tests / sanity.sh
1 #!/bin/bash
2 #
3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
5 #
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
7 set -e
8
9 ONLY=${ONLY:-"$*"}
10 # bug number for skipped test: 
11 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
13
14 [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
15
16 SRCDIR=`dirname $0`
17 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
18
19 TMP=${TMP:-/tmp}
20
21 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
22 CREATETEST=${CREATETEST:-createtest}
23 LFIND=${LFIND:-lfind}
24 LSTRIPE=${LSTRIPE:-lstripe}
25 LCTL=${LCTL:-lctl}
26 MCREATE=${MCREATE:-mcreate}
27 OPENFILE=${OPENFILE:-openfile}
28 OPENUNLINK=${OPENUNLINK:-openunlink}
29 TOEXCL=${TOEXCL:-toexcl}
30 TRUNCATE=${TRUNCATE:-truncate}
31 MUNLINK=${MUNLINK:-munlink}
32 SOCKETSERVER=${SOCKETSERVER:-socketserver}
33 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
34 IOPENTEST1=${IOPENTEST1:-iopentest1}
35 IOPENTEST2=${IOPENTEST2:-iopentest2}
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 export NAME=${NAME:-local}
46
47 SAVE_PWD=$PWD
48
49 clean() {
50         echo -n "cln.."
51         sh llmountcleanup.sh > /dev/null || exit 20
52         I_MOUNTED=no
53 }
54 CLEAN=${CLEAN:-clean}
55
56 start() {
57         echo -n "mnt.."
58         sh llrmount.sh > /dev/null || exit 10
59         I_MOUNTED=yes
60         echo "done"
61 }
62 START=${START:-start}
63
64 log() {
65         echo "$*"
66         lctl mark "$*" 2> /dev/null || true
67 }
68
69 run_one() {
70         if ! mount | grep -q $DIR; then
71                 $START
72         fi
73         log "== test $1: $2"
74         export TESTNAME=test_$1
75         test_$1 || error "test_$1: exit with rc=$?"
76         unset TESTNAME
77         pass
78         cd $SAVE_PWD
79         $CLEAN
80 }
81
82 build_test_filter() {
83         for O in $ONLY; do
84             eval ONLY_${O}=true
85         done
86         for E in $EXCEPT $ALWAYS_EXCEPT; do
87             eval EXCEPT_${E}=true
88         done
89 }
90
91 _basetest() {
92     echo $*
93 }
94
95 basetest() {
96     IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
97 }
98
99 run_test() {
100          base=`basetest $1`
101          if [ "$ONLY" ]; then
102                  testname=ONLY_$1
103                  if [ ${!testname}x != x ]; then
104                         run_one $1 "$2"
105                         return $?
106                  fi
107                  testname=ONLY_$base
108                  if [ ${!testname}x != x ]; then
109                          run_one $1 "$2"
110                          return $?
111                  fi
112                  echo -n "."
113                  return 0
114         fi
115         testname=EXCEPT_$1
116         if [ ${!testname}x != x ]; then
117                  echo "skipping excluded test $1"
118                  return 0
119         fi
120         testname=EXCEPT_$base
121         if [ ${!testname}x != x ]; then
122                  echo "skipping excluded test $1 (base $base)"
123                  return 0
124         fi
125         run_one $1 "$2"
126         return $?
127 }
128
129 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
130
131 error() { 
132         log "FAIL: $@"
133         if [ "$SANITYLOG" ]; then
134                 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
135         else
136                 exit 1
137         fi
138 }
139
140 pass() { 
141         echo PASS
142 }
143
144 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
145 if [ -z "$MOUNT" ]; then
146         sh llmount.sh
147         MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
148         [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
149         I_MOUNTED=yes
150 fi
151
152 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
153
154 DIR=${DIR:-$MOUNT}
155 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
156
157 LOVNAME=`cat /proc/fs/lustre/llite/fs0/lov/common_name`
158 STRIPECOUNT=`cat /proc/fs/lustre/lov/$LOVNAME/numobd`
159
160 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
161 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
162 rm -rf $DIR/[Rdfs][1-9]*
163
164 build_test_filter
165
166 echo preparing for tests involving mounts
167 EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP}
168 touch $EXT2_DEV
169 mke2fs -F $EXT2_DEV 1000 > /dev/null
170
171 EXT3_DEV=${EXT3_DEV:-/tmp/SANITY_EXT3_DEV.LOOP}
172 touch $EXT3_DEV
173 mkfs.ext3 -F $EXT3_DEV 10000 > /dev/null
174
175 test_0() {
176         touch $DIR/f
177         $CHECKSTAT -t file $DIR/f || error
178         rm $DIR/f
179         $CHECKSTAT -a $DIR/f || error
180 }
181 run_test 0 "touch .../f ; rm .../f ============================="
182
183 test_1a() {
184         mkdir $DIR/d1
185         mkdir $DIR/d1/d2
186         $CHECKSTAT -t dir $DIR/d1/d2 || error
187 }
188 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
189
190 test_1b() {
191         rmdir $DIR/d1/d2
192         rmdir $DIR/d1
193         $CHECKSTAT -a $DIR/d1 || error
194 }
195 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
196
197 test_2a() {
198         mkdir $DIR/d2
199         touch $DIR/d2/f
200         $CHECKSTAT -t file $DIR/d2/f || error
201 }
202 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
203
204 test_2b() {
205         rm -r $DIR/d2
206         $CHECKSTAT -a $DIR/d2 || error
207 }
208 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
209
210 test_3a() {
211         mkdir $DIR/d3
212         $CHECKSTAT -t dir $DIR/d3 || error
213 }
214 run_test 3a "mkdir .../d3 ======================================"
215
216 test_3b() {
217         if [ ! -d $DIR/d3 ]; then
218                 mkdir $DIR/d3
219         fi
220         touch $DIR/d3/f
221         $CHECKSTAT -t file $DIR/d3/f || error
222 }
223 run_test 3b "touch .../d3/f ===================================="
224
225 test_3c() {
226         rm -r $DIR/d3
227         $CHECKSTAT -a $DIR/d3 || error
228 }
229 run_test 3c "rm -r .../d3 ======================================"
230
231 test_4a() {
232         mkdir $DIR/d4
233         $CHECKSTAT -t dir $DIR/d4 || error
234 }
235 run_test 4a "mkdir .../d4 ======================================"
236
237 test_4b() {
238         if [ ! -d $DIR/d4 ]; then
239                 mkdir $DIR/d4
240         fi
241         mkdir $DIR/d4/d2
242         $CHECKSTAT -t dir $DIR/d4/d2 || error
243 }
244 run_test 4b "mkdir .../d4/d2 ==================================="
245
246 test_5() {
247         mkdir $DIR/d5
248         mkdir $DIR/d5/d2
249         chmod 0707 $DIR/d5/d2
250         $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
251 }
252 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
253
254 test_6a() {
255         touch $DIR/f6a
256         chmod 0666 $DIR/f6a || error
257         $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
258 }
259 run_test 6a "touch .../f6a; chmod .../f6a ======================"
260
261 test_6b() {
262         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6b" && return
263         if [ ! -f $DIR/f6a ]; then
264                 touch $DIR/f6a
265                 chmod 0666 $DIR/f6a
266         fi
267         $RUNAS chmod 0444 $DIR/f6a && error
268         $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
269 }
270 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
271
272 test_6c() {
273         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6c" && return
274         touch $DIR/f6c
275         chown $RUNAS_ID $DIR/f6c || error
276         $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
277 }
278 run_test 6c "touch .../f6c; chown .../f6c ======================"
279
280 test_6d() {
281         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6d" && return
282         if [ ! -f $DIR/f6c ]; then
283                 touch $DIR/f6c
284                 chown $RUNAS_ID $DIR/f6c
285         fi
286         $RUNAS chown $UID $DIR/f6c && error
287         $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
288 }
289 run_test 6d "$RUNAS chown .../f6c (should return error) =="
290
291 test_6e() {
292         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6e" && return
293         touch $DIR/f6e
294         chgrp $RUNAS_ID $DIR/f6e || error
295         $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
296 }
297 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
298
299 test_6f() {
300         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6f" && return
301         if [ ! -f $DIR/f6e ]; then
302                 touch $DIR/f6e
303                 chgrp $RUNAS_ID $DIR/f6e
304         fi
305         $RUNAS chgrp $UID $DIR/f6e && error
306         $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
307 }
308 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
309
310 test_6g() {
311         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6g" && return
312         mkdir $DIR/d6g || error
313         chmod 777 $DIR/d6g || error
314         $RUNAS mkdir $DIR/d6g/d || error
315         chmod g+s $DIR/d6g/d || error
316         mkdir $DIR/d6g/d/subdir
317         $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
318 }
319 run_test 6g "Is new dir in sgid dir inheriting group?"
320
321 test_7a() {
322         mkdir $DIR/d7
323         $MCREATE $DIR/d7/f
324         chmod 0666 $DIR/d7/f
325         $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
326 }
327 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
328
329 test_7b() {
330         if [ ! -d $DIR/d7 ]; then
331                 mkdir $DIR/d7
332         fi
333         $MCREATE $DIR/d7/f2
334         echo -n foo > $DIR/d7/f2
335         [ "`cat $DIR/d7/f2`" = "foo" ] || error
336         $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
337 }
338 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
339
340 test_8() {
341         mkdir $DIR/d8
342         touch $DIR/d8/f
343         chmod 0666 $DIR/d8/f
344         $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
345 }
346 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
347
348 test_9() {
349         mkdir $DIR/d9
350         mkdir $DIR/d9/d2
351         mkdir $DIR/d9/d2/d3
352         $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
353 }
354 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
355
356 test_10() {
357         mkdir $DIR/d10
358         mkdir $DIR/d10/d2
359         touch $DIR/d10/d2/f
360         $CHECKSTAT -t file $DIR/d10/d2/f || error
361 }
362 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
363
364 test_11() {
365         mkdir $DIR/d11
366         mkdir $DIR/d11/d2
367         chmod 0666 $DIR/d11/d2
368         chmod 0705 $DIR/d11/d2
369         $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
370 }
371 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
372
373 test_12() {
374         mkdir $DIR/d12
375         touch $DIR/d12/f
376         chmod 0666 $DIR/d12/f
377         chmod 0654 $DIR/d12/f
378         $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
379 }
380 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
381
382 test_13() {
383         mkdir $DIR/d13
384         dd if=/dev/zero of=$DIR/d13/f count=10
385         >  $DIR/d13/f
386         $CHECKSTAT -t file -s 0 $DIR/d13/f || error
387 }
388 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
389
390 test_14() {
391         mkdir $DIR/d14
392         touch $DIR/d14/f
393         rm $DIR/d14/f
394         $CHECKSTAT -a $DIR/d14/f || error
395 }
396 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
397
398 test_15() {
399         mkdir $DIR/d15
400         touch $DIR/d15/f
401         mv $DIR/d15/f $DIR/d15/f2
402         $CHECKSTAT -t file $DIR/d15/f2 || error
403 }
404 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
405
406 test_16() {
407         mkdir $DIR/d16
408         touch $DIR/d16/f
409         rm -rf $DIR/d16/f
410         $CHECKSTAT -a $DIR/d16/f || error
411 }
412 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
413
414 test_17a() {
415         mkdir $DIR/d17
416         touch $DIR/d17/f
417         ln -s $DIR/d17/f $DIR/d17/l-exist
418         ls -l $DIR/d17
419         $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
420         $CHECKSTAT -f -t f $DIR/d17/l-exist || error
421         rm -f $DIR/l-exist
422         $CHECKSTAT -a $DIR/l-exist || error
423 }
424 run_test 17a "symlinks: create, remove (real) =================="
425
426 test_17b() {
427         if [ ! -d $DIR/d17 ]; then
428                 mkdir $DIR/d17
429         fi
430         ln -s no-such-file $DIR/d17/l-dangle
431         ls -l $DIR/d17
432         $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
433         $CHECKSTAT -fa $DIR/d17/l-dangle || error
434         rm -f $DIR/l-dangle
435         $CHECKSTAT -a $DIR/l-dangle || error
436 }
437 run_test 17b "symlinks: create, remove (dangling) =============="
438
439 test_18() {
440         touch $DIR/f
441         ls $DIR || error
442 }
443 run_test 18 "touch .../f ; ls ... =============================="
444
445 test_19a() {
446         touch $DIR/f19
447         ls -l $DIR
448         rm $DIR/f19
449         $CHECKSTAT -a $DIR/f19 || error
450 }
451 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
452
453 test_19b() {
454         ls -l $DIR/f19 && error || true
455 }
456 run_test 19b "ls -l .../f19 (should return error) =============="
457
458 test_19c() {
459         [ $RUNAS_ID -eq $UID ] && echo "skipping test 19c" && return
460         $RUNAS touch $DIR/f19 && error || true
461 }
462 run_test 19c "$RUNAS touch .../f19 (should return error) =="
463
464 test_19d() {
465         cat $DIR/f19 && error || true
466 }
467 run_test 19d "cat .../f19 (should return error) =============="
468
469 test_20() {
470         touch $DIR/f
471         rm $DIR/f
472         log "1 done"
473         touch $DIR/f
474         rm $DIR/f
475         log "2 done"
476         touch $DIR/f
477         rm $DIR/f
478         log "3 done"
479         $CHECKSTAT -a $DIR/f || error
480 }
481 run_test 20 "touch .../f ; ls -l ... ==========================="
482
483 test_21() {
484         mkdir $DIR/d21
485         [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
486         ln -s dangle $DIR/d21/link
487         echo foo >> $DIR/d21/link
488         cat $DIR/d21/dangle
489         $CHECKSTAT -t link $DIR/d21/link || error
490         $CHECKSTAT -f -t file $DIR/d21/link || error
491 }
492 run_test 21 "write to dangling link ============================"
493
494 test_22() {
495         mkdir $DIR/d22
496         chown $RUNAS_ID $DIR/d22
497         # Tar gets pissy if it can't access $PWD *sigh*
498         (cd /tmp;
499         $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
500         $RUNAS tar xfC - $DIR/d22)
501         ls -lR $DIR/d22/etc
502         $CHECKSTAT -t dir $DIR/d22/etc || error
503         $CHECKSTAT -u \#$RUNAS_ID $DIR/d22/etc || error
504 }
505 run_test 22 "unpack tar archive as non-root user ==============="
506
507 test_23() {
508         mkdir $DIR/d23
509         $TOEXCL $DIR/d23/f23
510         $TOEXCL -e $DIR/d23/f23 || error
511 }
512 run_test 23 "O_CREAT|O_EXCL in subdir =========================="
513
514 test_24a() {
515         echo '== rename sanity =============================================='
516         echo '-- same directory rename'
517         mkdir $DIR/R1
518         touch $DIR/R1/f
519         mv $DIR/R1/f $DIR/R1/g
520         $CHECKSTAT -t file $DIR/R1/g || error
521 }
522 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
523
524 test_24b() {
525         mkdir $DIR/R2
526         touch $DIR/R2/{f,g}
527         mv $DIR/R2/f $DIR/R2/g
528         $CHECKSTAT -a $DIR/R2/f || error
529         $CHECKSTAT -t file $DIR/R2/g || error
530 }
531 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
532
533 test_24c() {
534         mkdir $DIR/R3
535         mkdir $DIR/R3/f
536         mv $DIR/R3/f $DIR/R3/g
537         $CHECKSTAT -a $DIR/R3/f || error
538         $CHECKSTAT -t dir $DIR/R3/g || error
539 }
540 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
541
542 test_24d() {
543         mkdir $DIR/R4
544         mkdir $DIR/R4/{f,g}
545         perl -e "rename \"$DIR/R4/f\", \"$DIR/R4/g\";"
546         $CHECKSTAT -a $DIR/R4/f || error
547         $CHECKSTAT -t dir $DIR/R4/g || error
548 }
549 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
550
551 test_24e() {
552         echo '-- cross directory renames --' 
553         mkdir $DIR/R5{a,b}
554         touch $DIR/R5a/f
555         mv $DIR/R5a/f $DIR/R5b/g
556         $CHECKSTAT -a $DIR/R5a/f || error
557         $CHECKSTAT -t file $DIR/R5b/g || error
558 }
559 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
560
561 test_24f() {
562         mkdir $DIR/R6{a,b}
563         touch $DIR/R6a/f $DIR/R6b/g
564         mv $DIR/R6a/f $DIR/R6b/g
565         $CHECKSTAT -a $DIR/R6a/f || error
566         $CHECKSTAT -t file $DIR/R6b/g || error
567 }
568 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
569
570 test_24g() {
571         mkdir $DIR/R7{a,b}
572         mkdir $DIR/R7a/d
573         mv $DIR/R7a/d $DIR/R7b/e
574         $CHECKSTAT -a $DIR/R7a/d || error
575         $CHECKSTAT -t dir $DIR/R7b/e || error
576 }
577 run_test 24g "mkdir .../R7a/d; rename .../R7a/d .../R5b/e ======"
578
579 test_24h() {
580         mkdir $DIR/R8{a,b}
581         mkdir $DIR/R8a/d $DIR/R8b/e
582         perl -e "rename \"$DIR/R8a/d\", \"$DIR/R8b/e\";"
583         $CHECKSTAT -a $DIR/R8a/d || error
584         $CHECKSTAT -t dir $DIR/R8b/e || error
585 }
586 run_test 24h "mkdir .../R8{a,b} R8a/{d,e}; mv .../R8a/d .../R8b/e"
587
588 test_24i() {
589         echo "-- rename error cases"
590         mkdir $DIR/R9
591         mkdir $DIR/R9/a
592         touch $DIR/R9/f
593         perl -e "rename \"$DIR/R9/f\", \"$DIR/R9/a\";"
594         $CHECKSTAT -t file $DIR/R9/f || error
595         $CHECKSTAT -t dir  $DIR/R9/a || error
596         $CHECKSTAT -a file $DIR/R9/a/f || error
597 }
598 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
599
600 test_24j() {
601         mkdir $DIR/R10
602         perl -e "rename \"$DIR/R10/f\", \"$DIR/R10/g\"" 
603         $CHECKSTAT -t dir $DIR/R10 || error
604         $CHECKSTAT -a $DIR/R10/f || error
605         $CHECKSTAT -a $DIR/R10/g || error
606 }
607 run_test 24j "source does not exist ============================" 
608
609 test_24k() {
610         mkdir $DIR/R11a $DIR/R11a/d
611         touch $DIR/R11a/f
612         mv $DIR/R11a/f $DIR/R11a/d
613         $CHECKSTAT -a $DIR/R11a/f || error
614         $CHECKSTAT -t file $DIR/R11a/d/f || error
615 }
616 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
617
618 # bug 2429 - rename foo foo foo creates invalid file
619 test_24l() {
620         f="$DIR/f24l"
621         multiop $f OcNs || error
622 }
623 run_test 24l "Renaming a file to itself ========================"
624
625 test_24m() {
626         f="$DIR/f24m"
627         multiop $f OcLN ${f}2 ${f}2 || error
628 }
629 run_test 24m "Renaming a file to a hard link to itself ========="
630
631 test_24n() {
632     f="$DIR/f24n"
633     # this stats the old file after it was renamed, so it should fail
634     touch ${f}
635     $CHECKSTAT ${f}
636     mv ${f} ${f}.rename
637     $CHECKSTAT ${f}.rename
638     $CHECKSTAT -a ${f}
639 }
640 run_test 24n "Statting the old file after renameing (Posix rename 2)"
641
642 test_25a() {
643         echo '== symlink sanity ============================================='
644         mkdir $DIR/d25
645         ln -s d25 $DIR/s25
646         touch $DIR/s25/foo || error
647 }
648 run_test 25a "create file in symlinked directory ==============="
649
650 test_25b() {
651         if [ ! -d $DIR/d25 ]; then
652                 run_one 25a
653         fi
654         $CHECKSTAT -t file $DIR/s25/foo || error
655 }
656 run_test 25b "lookup file in symlinked directory ==============="
657
658 test_26a() {
659         mkdir $DIR/d26
660         mkdir $DIR/d26/d26-2
661         ln -s d26/d26-2 $DIR/s26
662         touch $DIR/s26/foo || error
663 }
664 run_test 26a "multiple component symlink ======================="
665
666 test_26b() {
667         mkdir -p $DIR/d26b/d26-2
668         ln -s d26b/d26-2/foo $DIR/s26-2
669         touch $DIR/s26-2 || error
670 }
671 run_test 26b "multiple component symlink at end of lookup ======"
672
673 test_26c() {
674         mkdir $DIR/d26.2
675         touch $DIR/d26.2/foo
676         ln -s d26.2 $DIR/s26.2-1
677         ln -s s26.2-1 $DIR/s26.2-2
678         ln -s s26.2-2 $DIR/s26.2-3
679         chmod 0666 $DIR/s26.2-3/foo
680 }
681 run_test 26c "chain of symlinks ================================"
682
683 # recursive symlinks (bug 439)
684 test_26d() {
685         ln -s d26-3/foo $DIR/d26-3
686 }
687 run_test 26d "create multiple component recursive symlink ======"
688
689 test_26e() {
690         if [ ! -h $DIR/d26-3 ]; then
691                 run_one 26d
692         fi
693         rm $DIR/d26-3
694 }
695 run_test 26e "unlink multiple component recursive symlink ======"
696
697 test_27a() {
698         echo '== stripe sanity =============================================='
699         mkdir $DIR/d27
700         $LSTRIPE $DIR/d27/f0 65536 0 1 || error
701         $CHECKSTAT -t file $DIR/d27/f0 || error
702         pass
703         log "== test_27b: write to one stripe file ========================="
704         cp /etc/hosts $DIR/d27/f0 || error
705 }
706 run_test 27a "one stripe file =================================="
707
708 test_27c() {
709         [ "$STRIPECOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
710         if [ ! -d $DIR/d27 ]; then
711                 mkdir $DIR/d27
712         fi
713         $LSTRIPE $DIR/d27/f01 65536 0 2 || error
714         [ `$LFIND $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
715                 error "two-stripe file doesn't have two stripes"
716         pass
717         log "== test_27d: write to two stripe file file f01 ================"
718         dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error
719 }
720 run_test 27c "create two stripe file f01 ======================="
721
722 test_27d() {
723         if [ ! -d $DIR/d27 ]; then
724                 mkdir $DIR/d27
725         fi
726         $LSTRIPE $DIR/d27/fdef 0 -1 0 || error
727         $CHECKSTAT -t file $DIR/d27/fdef || error
728         #dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
729 }
730 run_test 27d "create file with default settings ================"
731
732 test_27e() {
733         if [ ! -d $DIR/d27 ]; then
734                 mkdir $DIR/d27
735         fi
736         $LSTRIPE $DIR/d27/f12 65536 0 2 || error
737         $LSTRIPE $DIR/d27/f12 65536 0 2 && error
738         $CHECKSTAT -t file $DIR/d27/f12 || error
739 }
740 run_test 27e "lstripe existing file (should return error) ======"
741
742 test_27f() {
743         if [ ! -d $DIR/d27 ]; then
744                 mkdir $DIR/d27
745         fi
746         $LSTRIPE $DIR/d27/fbad 100 0 1 && error
747         dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error
748         $LFIND $DIR/d27/fbad || error
749 }
750 run_test 27f "lstripe with bad stripe size (should return error)"
751
752 test_27g() {
753         if [ ! -d $DIR/d27 ]; then
754                 mkdir $DIR/d27
755         fi
756         $MCREATE $DIR/d27/fnone || error
757         pass
758         log "== test 27h: lfind with no objects ============================"
759         $LFIND $DIR/d27/fnone 2>&1 | grep "no stripe info" || error
760         pass
761         log "== test 27i: lfind with some objects =========================="
762         touch $DIR/d27/fsome || error
763         $LFIND $DIR/d27/fsome | grep obdidx || error
764 }
765 run_test 27g "test lfind ======================================="
766
767 test_27j() {
768         if [ ! -d $DIR/d27 ]; then
769                 mkdir $DIR/d27
770         fi
771         $LSTRIPE $DIR/d27/f27j 65536 $STRIPECOUNT 1 && error || true
772 }
773 run_test 27j "lstripe with bad stripe offset (should return error)"
774
775 test_27k() { # bug 2844
776         FILE=$DIR/d27/f27k
777         LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
778         [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
779         $LSTRIPE $FILE 67108864 -1 0 || error "lstripe failed"
780         BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
781         [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
782         dd if=/dev/zero of=$FILE bs=4k count=1
783         BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
784         [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
785 }
786 run_test 27k "limit i_blksize for broken user apps ============="
787
788 test_28() {
789         mkdir $DIR/d28
790         $CREATETEST $DIR/d28/ct || error
791 }
792 run_test 28 "create/mknod/mkdir with bad file types ============"
793
794 cancel_lru_locks() {
795         for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
796                 echo clear > $d/lru_size
797         done
798         grep [0-9] /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
799 }
800
801 test_29() {
802         cancel_lru_locks MDC
803         mkdir $DIR/d29
804         touch $DIR/d29/foo
805         log 'first d29'
806         ls -l $DIR/d29
807         MDCDIR=${MDCDIR:-/proc/fs/lustre/ldlm/namespaces/MDC_*}
808         LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
809         LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
810         log 'second d29'
811         ls -l $DIR/d29
812         log 'done'
813         LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
814         LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
815         if [ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]; then
816                 echo "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
817                 error
818         fi
819         if [ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]; then
820                 echo "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
821                 error
822         fi
823 }
824 run_test 29 "IT_GETATTR regression  ============================"
825
826 test_30() {
827         cp `which ls` $DIR
828         $DIR/ls /
829         rm $DIR/ls
830 }
831 run_test 30 "run binary from Lustre (execve) ==================="
832
833 test_31a() {
834         $OPENUNLINK $DIR/f31 $DIR/f31 || error
835         $CHECKSTAT -a $DIR/f31 || error
836 }
837 run_test 31a "open-unlink file =================================="
838
839 test_31b() {
840         touch $DIR/f31 || error
841         ln $DIR/f31 $DIR/f31b || error
842         multiop $DIR/f31b Ouc || error
843         $CHECKSTAT -t file $DIR/f31 || error
844 }
845 run_test 31b "unlink file with multiple links while open ======="
846
847 test_31c() {
848         touch $DIR/f31 || error
849         ln $DIR/f31 $DIR/f31c || error
850         multiop $DIR/f31 O_uc &
851         MULTIPID=$!
852         multiop $DIR/f31c Ouc
853         usleep 500
854         kill -USR1 $MULTIPID
855         wait $MUTLIPID
856 }
857 run_test 31c "open-unlink file with multiple links ============="
858
859 test_31d() {
860         opendirunlink $DIR/d31d $DIR/d31d || error
861         $CHECKSTAT -a $DIR/d31d || error
862 }
863 run_test 31d "remove of open directory ========================="
864
865 test_32a() {
866         echo "== more mountpoints and symlinks ================="
867         [ -e $DIR/d32a ] && rm -fr $DIR/d32a
868         mkdir -p $DIR/d32a/ext2-mountpoint 
869         mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
870         $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error  
871         umount $DIR/d32a/ext2-mountpoint || error
872 }
873 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
874
875 test_32b() {
876         [ -e $DIR/d32b ] && rm -fr $DIR/d32b
877         mkdir -p $DIR/d32b/ext2-mountpoint 
878         mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
879         ls -al $DIR/d32b/ext2-mountpoint/.. || error
880         umount $DIR/d32b/ext2-mountpoint || error
881 }
882 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
883  
884 test_32c() {
885         [ -e $DIR/d32c ] && rm -fr $DIR/d32c
886         mkdir -p $DIR/d32c/ext2-mountpoint 
887         mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
888         mkdir -p $DIR/d32c/d2/test_dir    
889         $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
890         umount $DIR/d32c/ext2-mountpoint || error
891 }
892 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
893
894 test_32d() {
895         [ -e $DIR/d32d ] && rm -fr $DIR/d32d
896         mkdir -p $DIR/d32d/ext2-mountpoint 
897         mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
898         mkdir -p $DIR/d32d/d2/test_dir    
899         ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
900         umount $DIR/d32d/ext2-mountpoint || error
901 }
902 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
903
904 test_32e() {
905         [ -e $DIR/d32e ] && rm -fr $DIR/d32e
906         mkdir -p $DIR/d32e/tmp    
907         TMP_DIR=$DIR/d32e/tmp       
908         ln -s $DIR/d32e $TMP_DIR/symlink11 
909         ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01 
910         $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
911         $CHECKSTAT -t link $DIR/d32e/symlink01 || error
912 }
913 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
914
915 test_32f() {
916         [ -e $DIR/d32f ] && rm -fr $DIR/d32f
917         mkdir -p $DIR/d32f/tmp    
918         TMP_DIR=$DIR/d32f/tmp       
919         ln -s $DIR/d32f $TMP_DIR/symlink11 
920         ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01 
921         ls $DIR/d32f/tmp/symlink11  || error
922         ls $DIR/d32f/symlink01 || error
923 }
924 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
925
926 test_32g() {
927         [ -e $DIR/d32g ] && rm -fr $DIR/d32g
928         [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
929         mkdir -p $DIR/test_dir 
930         mkdir -p $DIR/d32g/tmp    
931         TMP_DIR=$DIR/d32g/tmp       
932         ln -s $DIR/test_dir $TMP_DIR/symlink12 
933         ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02 
934         $CHECKSTAT -t link $DIR/d32g/tmp/symlink12 || error
935         $CHECKSTAT -t link $DIR/d32g/symlink02 || error
936         $CHECKSTAT -t dir -f $DIR/d32g/tmp/symlink12 || error
937         $CHECKSTAT -t dir -f $DIR/d32g/symlink02 || error
938 }
939 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/test_dir"
940
941 test_32h() {
942         [ -e $DIR/d32h ] && rm -fr $DIR/d32h
943         [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
944         mkdir -p $DIR/test_dir 
945         mkdir -p $DIR/d32h/tmp    
946         TMP_DIR=$DIR/d32h/tmp       
947         ln -s $DIR/test_dir $TMP_DIR/symlink12 
948         ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02 
949         ls $DIR/d32h/tmp/symlink12 || error
950         ls $DIR/d32h/symlink02  || error
951 }
952 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/test_dir"
953
954 test_32i() {
955         [ -e $DIR/d32i ] && rm -fr $DIR/d32i
956         mkdir -p $DIR/d32i/ext2-mountpoint 
957         mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
958         touch $DIR/d32i/test_file
959         $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error  
960         umount $DIR/d32i/ext2-mountpoint || error
961 }
962 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
963
964 test_32j() {
965         [ -e $DIR/d32j ] && rm -fr $DIR/d32j
966         mkdir -p $DIR/d32j/ext2-mountpoint 
967         mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
968         touch $DIR/d32j/test_file
969         cat $DIR/d32j/ext2-mountpoint/../test_file || error
970         umount $DIR/d32j/ext2-mountpoint || error
971 }
972 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
973
974 test_32k() {
975         rm -fr $DIR/d32k
976         mkdir -p $DIR/d32k/ext2-mountpoint 
977         mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint  
978         mkdir -p $DIR/d32k/d2
979         touch $DIR/d32k/d2/test_file || error
980         $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
981         umount $DIR/d32k/ext2-mountpoint || error
982 }
983 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
984
985 test_32l() {
986         rm -fr $DIR/d32l
987         mkdir -p $DIR/d32l/ext2-mountpoint 
988         mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
989         mkdir -p $DIR/d32l/d2
990         touch $DIR/d32l/d2/test_file
991         cat  $DIR/d32l/ext2-mountpoint/../d2/test_file || error
992         umount $DIR/d32l/ext2-mountpoint || error
993 }
994 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
995
996 test_32m() {
997         rm -fr $DIR/d32m
998         mkdir -p $DIR/d32m/tmp    
999         TMP_DIR=$DIR/d32m/tmp       
1000         ln -s $DIR $TMP_DIR/symlink11 
1001         ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01 
1002         $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1003         $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1004 }
1005 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1006
1007 test_32n() {
1008         rm -fr $DIR/d32n
1009         mkdir -p $DIR/d32n/tmp    
1010         TMP_DIR=$DIR/d32n/tmp       
1011         ln -s $DIR $TMP_DIR/symlink11 
1012         ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01 
1013         ls -l $DIR/d32n/tmp/symlink11  || error
1014         ls -l $DIR/d32n/symlink01 || error
1015 }
1016 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1017
1018 test_32o() {
1019         rm -fr $DIR/d32o
1020         rm -f $DIR/test_file
1021         touch $DIR/test_file 
1022         mkdir -p $DIR/d32o/tmp    
1023         TMP_DIR=$DIR/d32o/tmp       
1024         ln -s $DIR/test_file $TMP_DIR/symlink12 
1025         ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02 
1026         $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1027         $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1028         $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1029         $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1030 }
1031 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/test_file"
1032
1033 test_32p() {
1034     log 32p_1
1035         rm -fr $DIR/d32p
1036     log 32p_2
1037         rm -f $DIR/test_file
1038     log 32p_3
1039         touch $DIR/test_file 
1040     log 32p_4
1041         mkdir -p $DIR/d32p/tmp    
1042     log 32p_5
1043         TMP_DIR=$DIR/d32p/tmp       
1044     log 32p_6
1045         ln -s $DIR/test_file $TMP_DIR/symlink12 
1046     log 32p_7
1047         ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02 
1048     log 32p_8
1049         cat $DIR/d32p/tmp/symlink12 || error
1050     log 32p_9
1051         cat $DIR/d32p/symlink02 || error
1052     log 32p_10
1053 }
1054 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/test_file"
1055
1056 test_32q() {
1057         [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1058         mkdir -p $DIR/d32q
1059         touch $DIR/d32q/under_the_mount
1060         mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1061         ls $DIR/d32q/under_the_mount && error || true
1062         umount $DIR/d32q || error
1063 }
1064 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1065
1066 test_32r() {
1067         [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1068         mkdir -p $DIR/d32r
1069         touch $DIR/d32r/under_the_mount
1070         mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1071         ls $DIR/d32r | grep -q under_the_mount && error || true
1072         umount $DIR/d32r || error
1073 }
1074 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1075
1076 #   chmod 444 /mnt/lustre/somefile
1077 #   open(/mnt/lustre/somefile, O_RDWR)
1078 #   Should return -1
1079 test_33() {
1080         rm -f $DIR/test_33_file
1081         touch $DIR/test_33_file
1082         chmod 444 $DIR/test_33_file
1083         chown $RUNAS_ID $DIR/test_33_file
1084         log 33_1
1085         $RUNAS $OPENFILE -f O_RDWR $DIR/test_33_file && error || true
1086         log 33_2
1087 }
1088 run_test 33 "write file with mode 444 (should return error) ===="
1089                                                                                                                                                
1090 test_33a() {
1091         rm -fr $DIR/d33
1092         mkdir -p $DIR/d33
1093         chown $RUNAS_ID $DIR/d33
1094         $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 || error
1095         $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && error || true
1096 }
1097 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1098
1099 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1100 test_34a() {
1101         rm -f $DIR/test_34_file
1102         $MCREATE $DIR/test_34_file || error
1103         $LFIND $DIR/test_34_file 2>&1 | grep -q "no stripe info" || error
1104         $TRUNCATE $DIR/test_34_file $TEST_34_SIZE || error
1105         $LFIND $DIR/test_34_file 2>&1 | grep -q "no stripe info" || error
1106         $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
1107 }
1108 run_test 34a "truncate file that has not been opened ==========="
1109
1110 test_34b() {
1111         [ ! -f $DIR/test_34_file ] && run_one 34a
1112         $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
1113         $OPENFILE -f O_RDONLY $DIR/test_34_file
1114         $LFIND $DIR/test_34_file 2>&1 | grep -q "no stripe info" || error
1115         $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
1116 }
1117 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1118
1119 test_34c() {
1120         [ ! -f $DIR/test_34_file ] && run_one 34a 
1121         $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
1122         $OPENFILE -f O_RDWR $DIR/test_34_file
1123         $LFIND $DIR/test_34_file 2>&1 | grep -q "no stripe info" && error
1124         $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
1125 }
1126 run_test 34c "O_RDWR opening file-with-size works =============="
1127
1128 test_34d() {
1129         dd if=/dev/zero of=$DIR/test_34_file conv=notrunc bs=4k count=1 || error
1130         $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
1131         rm $DIR/test_34_file
1132 }
1133 run_test 34d "write to sparse file ============================="
1134
1135 test_34e() {
1136         rm -f $DIR/test_34_file
1137         $MCREATE $DIR/test_34_file || error
1138         $TRUNCATE $DIR/test_34_file 1000 || error
1139         $CHECKSTAT -s 1000 $DIR/test_34_file || error
1140         $OPENFILE -f O_RDWR $DIR/test_34_file
1141         $CHECKSTAT -s 1000 $DIR/test_34_file || error
1142 }
1143 run_test 34e "create objects, some with size and some without =="
1144
1145 test_35a() {
1146         cp /bin/sh $DIR/test_35a_file
1147         chmod 444 $DIR/test_35a_file
1148         chown $RUNAS_ID $DIR/test_35a_file
1149         $RUNAS $DIR/test_35a_file && error || true
1150         rm $DIR/test_35a_file
1151 }
1152 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1153
1154
1155 test_36a() {
1156         rm -f $DIR/test_36_file
1157         utime $DIR/test_36_file || error
1158 }
1159 run_test 36a "MDS utime check (mknod, utime) ==================="
1160
1161 test_36b() {
1162         echo "" > $DIR/test_36_file
1163         utime $DIR/test_36_file || error
1164 }
1165 run_test 36b "OST utime check (open, utime) ===================="
1166
1167 test_36c() {
1168         rm -f $DIR/d36/test_36_file
1169         mkdir $DIR/d36
1170         chown $RUNAS_ID $DIR/d36
1171         $RUNAS utime $DIR/d36/test_36_file || error
1172 }
1173 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1174
1175 test_36d() {
1176         [ ! -d $DIR/d36 ] && run_one 36c
1177         echo "" > $DIR/d36/test_36_file
1178         $RUNAS utime $DIR/d36/test_36_file || error
1179 }
1180 run_test 36d "non-root OST utime check (open, utime) ==========="
1181
1182 test_36e() {
1183         [ $RUNAS_ID -eq $UID ] && return
1184         [ ! -d $DIR/d36 ] && mkdir $DIR/d36
1185         touch $DIR/d36/test_36_file2
1186         $RUNAS utime $DIR/d36/test_36_file2 && error || true
1187 }
1188 run_test 36e "utime on non-owned file (should return error) ===="
1189
1190 test_37() {
1191         mkdir -p $DIR/dextra
1192         echo f > $DIR/dextra/fbugfile
1193         mount -t ext2 -o loop $EXT2_DEV $DIR/dextra
1194         ls $DIR/dextra | grep "\<fbugfile\>" && error
1195         umount $DIR/dextra || error
1196         rm -f $DIR/dextra/fbugfile || error
1197 }
1198 run_test 37 "ls a mounted file system to check old content ====="
1199
1200 test_38() {
1201         o_directory $DIR/test38
1202 }
1203 run_test 38 "open a regular file with O_DIRECTORY =============="
1204
1205 test_39() {
1206         touch $DIR/test_39_file
1207         touch $DIR/test_39_file2
1208 #       ls -l  $DIR/test_39_file $DIR/test_39_file2
1209 #       ls -lu  $DIR/test_39_file $DIR/test_39_file2
1210 #       ls -lc  $DIR/test_39_file $DIR/test_39_file2
1211         sleep 2
1212         $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/test_39_file2
1213 #       ls -l  $DIR/test_39_file $DIR/test_39_file2
1214 #       ls -lu  $DIR/test_39_file $DIR/test_39_file2
1215 #       ls -lc  $DIR/test_39_file $DIR/test_39_file2
1216         [ $DIR/test_39_file2 -nt $DIR/test_39_file ] || error
1217 }
1218 run_test 39 "mtime changed on create ==========================="
1219
1220 test_40() {
1221         dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1222         $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1223         $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1224 }
1225 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1226
1227 test_41() {
1228         # bug 1553
1229         small_write $DIR/f41 18
1230 }
1231 run_test 41 "test small file write + fstat ====================="
1232
1233 count_ost_writes() {
1234         cat /proc/fs/lustre/osc/*/stats |
1235             awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1236 }
1237 start_kupdated() {
1238         # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs
1239         kill -CONT `pidof kupdated`
1240 }
1241 stop_kupdated() {
1242         # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1243         kill -STOP `pidof kupdated`
1244         trap start_kupdated EXIT
1245 }
1246
1247 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1248 # file truncation, and file removal.
1249 test_42a() {
1250         cancel_lru_locks OSC
1251         stop_kupdated
1252         sync # just to be safe
1253         BEFOREWRITES=`count_ost_writes`
1254         dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1255         AFTERWRITES=`count_ost_writes`
1256         [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1257                 error "$BEFOREWRITES < $AFTERWRITES"
1258         start_kupdated
1259 }
1260 run_test 42a "ensure that we don't flush on close =============="
1261
1262 test_42b() {
1263         cancel_lru_locks OSC
1264         stop_kupdated
1265         sync
1266         dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1267         BEFOREWRITES=`count_ost_writes`
1268         $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1269         AFTERWRITES=`count_ost_writes`
1270         [ $BEFOREWRITES -eq $AFTERWRITES ] ||
1271             error "$BEFOREWRITES < $AFTERWRITES on unlink"
1272         BEFOREWRITES=`count_ost_writes`
1273         sync || error "sync: $?"
1274         AFTERWRITES=`count_ost_writes`
1275         [ $BEFOREWRITES -eq $AFTERWRITES ] ||
1276             error "$BEFOREWRITES < $AFTERWRITES on sync"
1277         dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1278         start_kupdated
1279         return 0
1280 }
1281 run_test 42b "test destroy of file with cached dirty data ======"
1282
1283 # if these tests just want to test the effect of truncation,
1284 # they have to be very careful.  consider:
1285 # - the first open gets a {0,EOF}PR lock
1286 # - the first write conflicts and gets a {0, count-1}PW
1287 # - the rest of the writes are under {count,EOF}PW
1288 # - the open for truncate tries to match a {0,EOF}PR
1289 #   for the filesize and cancels the PWs.
1290 # any number of fixes (don't get {0,EOF} on open, match
1291 # composite locks, do smarter file size management) fix
1292 # this, but for now we want these tests to verify that
1293 # the cancellation with truncate intent works, so we
1294 # start the file with a full-file pw lock to match against
1295 # until the truncate.
1296 trunc_test() {
1297         test=$1
1298         file=$DIR/$test
1299         offset=$2
1300         cancel_lru_locks OSC
1301         stop_kupdated
1302         # prime the file with 0,EOF PW to match
1303         touch $file
1304         $TRUNCATE $file 0
1305         sync; sync
1306         # now the real test..
1307         dd if=/dev/zero of=$file bs=1024 count=100
1308         BEFOREWRITES=`count_ost_writes`
1309         $TRUNCATE $file $offset
1310         cancel_lru_locks OSC
1311         AFTERWRITES=`count_ost_writes`
1312         start_kupdated
1313 }
1314
1315 test_42c() {
1316         trunc_test 42c 1024
1317         [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1318             error "$BEFOREWRITES < $AFTERWRITES on truncate"
1319         rm $file
1320 }
1321 run_test 42c "test partial truncate of file with cached dirty data"
1322
1323 test_42d() {
1324         trunc_test 42d 0
1325         [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1326             error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1327         rm $file
1328 }
1329 run_test 42d "test complete truncate of file with cached dirty data"
1330
1331 test_43() {
1332         mkdir $DIR/d43
1333         cp -p /bin/ls $DIR/d43/f
1334         exec 100>> $DIR/d43/f
1335         $DIR/d43/f && error || true
1336         exec 100<&-
1337 }
1338 run_test 43 "execution of file opened for write should return -ETXTBSY"
1339
1340 test_43a() {
1341         mkdir -p $DIR/d43
1342         cp -p `which multiop` $DIR/d43/multiop
1343         $DIR/d43/multiop $TMP/test43.junk O_c &
1344         MULTIPID=$!
1345         sleep 1
1346         multiop $DIR/d43/multiop Oc && error "expected error, got success"
1347         kill -USR1 $MULTIPID || return 2
1348         wait $MULTIPID || return 3
1349 }
1350 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
1351
1352 test_43b() {
1353         mkdir -p $DIR/d43
1354         cp -p `which multiop` $DIR/d43/multiop
1355         $DIR/d43/multiop $TMP/test43.junk O_c &
1356         MULTIPID=$!
1357         sleep 1
1358         truncate $DIR/d43/multiop 0 && error "expected error, got success"
1359         kill -USR1 $MULTIPID || return 2
1360         wait $MULTIPID || return 3
1361 }
1362 run_test 43b "truncate of file being executed should return -ETXTBSY"
1363
1364 test_43c() {
1365         local testdir="$DIR/d43c"
1366         mkdir -p $testdir
1367         cp $SHELL $testdir/
1368         ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
1369                 ( cd $testdir && md5sum -c)
1370 }
1371 run_test 43c "md5sum of copy into lustre========================"
1372
1373 test_44() {
1374         [  "$STRIPECOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
1375         dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=127
1376         dd if=$DIR/f1 bs=4k count=1
1377 }
1378 run_test 44 "zero length read from a sparse stripe ============="
1379
1380 test_44a() {
1381     local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
1382                          awk '{print $2}'`
1383     local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
1384                       awk '{print $2}'`
1385     if [ $nstripe -eq 0 ] ; then
1386         nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
1387     fi
1388
1389     OFFSETS="0 $((stride/2)) $((stride-1))"
1390     for offset in $OFFSETS ; do
1391       for i in `seq 0 $((nstripe-1))`; do
1392         rm -f $DIR/d44a
1393         local GLOBALOFFSETS=""
1394         local size=$((((i + 2 * $nstripe )*$stride + $offset)))  # Bytes
1395         ll_sparseness_write $DIR/d44a $size  || error "ll_sparseness_write"
1396         GLOBALOFFSETS="$GLOBALOFFSETS $size"
1397         ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1398                             || error "ll_sparseness_verify $GLOBALOFFSETS"
1399
1400         for j in `seq 0 $((nstripe-1))`; do
1401             size=$((((j + $nstripe )*$stride + $offset)))  # Bytes
1402             ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1403             GLOBALOFFSETS="$GLOBALOFFSETS $size"
1404         done
1405         ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1406                             || error "ll_sparseness_verify $GLOBALOFFSETS"
1407       done
1408     done
1409 }
1410 run_test 44a "test sparse pwrite ==============================="
1411
1412 dirty_osc_total() {
1413         tot=0
1414         for d in /proc/fs/lustre/osc/*/cur_dirty_bytes; do
1415                 tot=$(($tot + `cat $d`))
1416         done
1417         echo $tot
1418 }
1419 do_dirty_record() {
1420         before=`dirty_osc_total`
1421         echo executing "\"$*\""
1422         eval $*
1423         after=`dirty_osc_total`
1424         echo before $before, after $after
1425 }
1426 test_45() {
1427         f="$DIR/f45"
1428         # Obtain grants from OST if it supports it
1429         echo blah > ${f}_grant
1430         stop_kupdated
1431         sync
1432         do_dirty_record "echo blah > $f"
1433         [ $before -eq $after ] && error "write wasn't cached"
1434         do_dirty_record "> $f"
1435         [ $before -gt $after ] || error "truncate didn't lower dirty count"
1436         do_dirty_record "echo blah > $f"
1437         [ $before -eq $after ] && error "write wasn't cached"
1438         do_dirty_record "sync"
1439         [ $before -gt $after ] || error "writeback didn't lower dirty count"
1440         do_dirty_record "echo blah > $f"
1441         [ $before -eq $after ] && error "write wasn't cached"
1442         do_dirty_record "cancel_lru_locks OSC"
1443         [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
1444         start_kupdated
1445 }
1446 run_test 45 "osc io page accounting ============================"
1447
1448 page_size() {
1449         getconf PAGE_SIZE
1450 }
1451
1452 # in a 2 stripe file (lov.sh), page 63 maps to page 31 in its object.  this
1453 # test tickles a bug where re-dirtying a page was failing to be mapped to the
1454 # objects offset and an assert hit when an rpc was built with 63's mapped 
1455 # offset 31 and 31's raw 31 offset. it also found general redirtying bugs.
1456 test_46() {
1457         f="$DIR/f46"
1458         stop_kupdated
1459         sync
1460         dd if=/dev/zero of=$f bs=`page_size` seek=31 count=1
1461         sync
1462         dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=63 count=1
1463         dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=31 count=1
1464         sync
1465         start_kupdated
1466 }
1467 run_test 46 "dirtying a previously written page ================"
1468
1469 # Check that device nodes are created and then visible correctly (#2091)
1470 test_47() {
1471         cmknod $DIR/test_47_node || error
1472 }
1473 run_test 47 "Device nodes check ================================"
1474
1475 test_48() {
1476         mkdir $DIR/d48
1477         cd $DIR/d48
1478         mv $DIR/d48 $DIR/d48.new || error "move directory failed"
1479         mkdir $DIR/d48 || error "recreate diectory failed"
1480         ls || error "can't list after recreate directory"
1481 }
1482 run_test 48 "Access renamed current working directory =========="
1483
1484 test_50() {
1485         # bug 1485
1486         mkdir $DIR/d50
1487         cd $DIR/d50
1488         ls /proc/$$/cwd || error
1489 }
1490 run_test 50 "special situations: /proc symlinks  ==============="
1491
1492 test_51() {
1493         # bug 1516 - create an empty entry right after ".." then split dir
1494         mkdir $DIR/d49
1495         touch $DIR/d49/foo
1496         $MCREATE $DIR/d49/bar
1497         rm $DIR/d49/foo
1498         createmany -m $DIR/d49/longfile 201
1499         FNUM=202
1500         while [ `ls -sd $DIR/d49 | awk '{ print $1 }'` -eq 4 ]; do
1501                 $MCREATE $DIR/d49/longfile$FNUM
1502                 FNUM=$(($FNUM + 1))
1503                 echo -n "+"
1504         done
1505         ls -l $DIR/d49 > /dev/null || error
1506 }
1507 run_test 51 "special situations: split htree with empty entry =="
1508
1509 test_52a() {
1510         [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
1511         mkdir -p $DIR/d52a
1512         touch $DIR/d52a/foo
1513         chattr =a $DIR/d52a/foo || error
1514         echo bar >> $DIR/d52a/foo || error
1515         cp /etc/hosts $DIR/d52a/foo && error
1516         rm -f $DIR/d52a/foo 2>/dev/null && error
1517         link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error
1518         echo foo >> $DIR/d52a/foo || error
1519         mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error
1520         lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error
1521         chattr -a $DIR/d52a/foo || error
1522
1523         rm -fr $DIR/d52a || error
1524 }
1525 run_test 52a "append-only flag test (should return errors) ====="
1526
1527 test_52b() {
1528         [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
1529         mkdir -p $DIR/d52b
1530         touch $DIR/d52b/foo
1531         chattr =i $DIR/d52b/foo || error
1532         cat test > $DIR/d52b/foo && error
1533         cp /etc/hosts $DIR/d52b/foo && error
1534         rm -f $DIR/d52b/foo 2>/dev/null && error
1535         link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
1536         echo foo >> $DIR/d52b/foo && error
1537         mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
1538         [ -f $DIR/d52b/foo ] || error
1539         [ -f $DIR/d52b/foo_ren ] && error
1540         lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
1541         chattr -i $DIR/d52b/foo || error
1542
1543         rm -fr $DIR/d52b || error
1544 }
1545 run_test 52b "immutable flag test (should return errors) ======="
1546
1547 test_53() {
1548         for i in `ls -d /proc/fs/lustre/osc/OSC*mds1 2> /dev/null` ; do
1549                 ostname=`echo $i | cut -d _ -f 3-4 | sed -e s/_mds1//`
1550                 ost_last=`cat /proc/fs/lustre/obdfilter/$ostname/last_id`
1551                 mds_last=`cat $i/prealloc_last_id`
1552                 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1553                 if [ $ost_last != $mds_last ]; then
1554                     error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1555                 fi
1556         done
1557 }
1558 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
1559
1560 test_54() {
1561         $SOCKETSERVER $DIR/socket &
1562         sleep 1
1563         $SOCKETCLIENT $DIR/socket || error
1564         $MUNLINK $DIR/socket
1565 }
1566 run_test 54 "unix damain socket test ==========================="
1567
1568 test_55() {
1569         rm -rf $DIR/d55
1570         mkdir $DIR/d55
1571         mount -t ext3 -o loop,iopen $EXT3_DEV $DIR/d55 || error
1572         touch $DIR/d55/foo
1573         $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error
1574         $IOPENTEST2 $DIR/d55 || error
1575         echo "check for $EXT3_DEV. Please wait..."
1576         rm -rf $DIR/d55/*
1577         umount $DIR/d55 || error
1578 }
1579 run_test 55 "check iopen_connect_dentry()======================="
1580
1581 test_56() {
1582         rm -rf $DIR/d56
1583         mkdir $DIR/d56
1584         mkdir $DIR/d56/dir
1585         NUMFILES=3
1586         NUMFILESx2=$(($NUMFILES * 2))
1587         for i in `seq 1 $NUMFILES` ; do
1588                 touch $DIR/d56/file$i
1589                 touch $DIR/d56/dir/file$i
1590         done
1591
1592         # test lfs find with --recursive
1593         FILENUM=`$LFIND --recursive $DIR/d56 | grep -c obdidx`
1594         [ $FILENUM -eq $NUMFILESx2 ] || error \
1595                 "lfs find --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
1596         FILENUM=`$LFIND $DIR/d56 | grep -c obdidx`
1597         [ $FILENUM -eq $NUMFILES ] || error \
1598                 "lfs find $DIR/d56 without --recursive wrong: found $FILENUM,
1599                 expected $NUMFILES"
1600         echo "lfs find --recursive passed."
1601
1602         # test lfs find with file instead of dir
1603         FILENUM=`$LFIND $DIR/d56/file1 | grep -c obdidx`
1604         [ $FILENUM  -eq 1 ] || error \
1605                  "lfs find $DIR/d56/file1 wrong:found $FILENUM, expected 1"
1606         echo "lfs find file passed."
1607
1608         #test lfs find with --verbose
1609         [ `$LFIND --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
1610                 error "lfs find --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
1611         [ `$LFIND $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
1612                 "lfs find $DIR/d56 without --verbose wrong: should not show lmm_magic info"
1613         echo "lfs find --verbose passed."
1614
1615         #test lfs find with --obd
1616         $LFIND --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
1617                 error "lfs find --obd wrong_uuid should return error information"
1618
1619         [  "$STRIPECOUNT" -lt 2 ] && \
1620                 echo "skipping other lfs find --obd test" && return
1621         FILENUM=`$LFIND --recursive $DIR/d56 | sed -n '/^[       ]*1[    ]/p' | wc -l`
1622         OBDUUID=`$LFIND --recursive $DIR/d56 | sed -n '/^[       ]*1:/p' | awk '{print $2}'`
1623         FOUND=`$LFIND -r --obd $OBDUUID $DIR/d56 | wc -l`
1624         [ $FOUND -eq $FILENUM ] || \
1625                 error "lfs find --obd wrong: found $FOUND, expected $FILENUM"
1626         [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | sed '/^[       ]*1[    ]/d' | \
1627                 sed -n '/^[      ]*[0-9][0-9]*[  ]/p' | wc -l` -eq 0 ] || \
1628                 error "lfs find --obd wrong: should not show file on other obd"
1629         echo "lfs find --obd passed."
1630 }
1631 run_test 56 "check lfs find ===================================="
1632
1633 test_57a() {
1634         # note test will not do anything if MDS is not local
1635         for DEV in `cat /proc/fs/lustre/mds/*/mntdev`; do
1636                 dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
1637                 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
1638                 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
1639                 rm $TMP/t57a.dump
1640         done
1641 }
1642 run_test 57a "verify MDS filesystem created with large inodes =="
1643
1644 test_57b() {
1645         FILECOUNT=100
1646         FILE1=$DIR/d57b/f1
1647         FILEN=$DIR/d57b/f$FILECOUNT
1648         rm -rf $DIR/d57b || error "removing $DIR/d57b"
1649         mkdir -p $DIR/d57b || error "creating $DIR/d57b"
1650         echo "mcreating $FILECOUNT files"
1651         createmany -m $DIR/d57b/f 1 $FILECOUNT || \
1652                 error "creating files in $DIR/d57b"
1653
1654         # verify that files do not have EAs yet
1655         $LFIND $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
1656         $LFIND $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
1657
1658         MDSFREE="`cat /proc/fs/lustre/mds/*/kbytesfree`"
1659         MDCFREE="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
1660         echo "opening files to create objects/EAs"
1661         for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
1662                 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
1663         done
1664
1665         # verify that files have EAs now
1666         $LFIND $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
1667         $LFIND $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
1668
1669         MDSFREE2="`cat /proc/fs/lustre/mds/*/kbytesfree`"
1670         MDCFREE2="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
1671         if [ "$MDCFREE" != "$MDCFREE2" ]; then
1672                 if [ "$MDSFREE" != "$MDSFREE2" ]; then
1673                         error "MDC before $MDCFREE != after $MDCFREE2"
1674                 else
1675                         echo "MDC before $MDCFREE != after $MDCFREE2"
1676                         echo "unable to confirm if MDS has large inodes"
1677                 fi
1678         fi
1679         rm -rf $DIR/d57b
1680 }
1681 run_test 57b "default LOV EAs are stored inside large inodes ==="
1682
1683 test_58() {
1684         wiretest
1685 }
1686 run_test 58 "verify cross-platform wire constants =============="
1687
1688 test_59() {
1689         echo "touch 130 files"
1690         for i in `seq 1 130` ; do
1691                 touch $DIR/59-$i
1692         done
1693         echo "rm 130 files"
1694         for i in `seq 1 130` ; do
1695                 rm -f $DIR/59-$i
1696         done
1697         sync
1698         sleep 2
1699         # wait for commitment of removal
1700 }
1701 run_test 59 "verify cancellation of llog records async ========="
1702
1703 test_60() {
1704         echo 60 "llog tests run from kernel mode"
1705         sh run-llog.sh
1706 }
1707 run_test 60 "llog sanity tests run from kernel module =========="
1708
1709 test_61() {
1710         f="$DIR/f61"
1711         dd if=/dev/zero of=$f bs=`page_size` count=1
1712         cancel_lru_locks OSC
1713         multiop $f OSMWUc || error
1714         sync
1715 }
1716 run_test 61 "mmap() writes don't make sync hang ================"
1717
1718 # bug 2330 - insufficient obd_match error checking causes LBUG
1719 test_62() {
1720         f="$DIR/f62"
1721         echo foo > $f
1722         cancel_lru_locks OSC
1723         echo 0x405 > /proc/sys/lustre/fail_loc
1724         cat $f && error "cat succeeded, expect -EIO"
1725         echo 0 > /proc/sys/lustre/fail_loc
1726 }
1727 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
1728
1729 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
1730 test_63() {
1731         MAX_DIRTY_MB=`cat /proc/fs/lustre/osc/*/max_dirty_mb | head -1`
1732         for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
1733                 echo 0 > $i
1734         done
1735         for i in `seq 10` ; do
1736                 dd if=/dev/zero of=$DIR/f63 bs=8k &
1737                 sleep 5
1738                 kill $!
1739                 sleep 1
1740         done
1741
1742         for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
1743                 echo $MAX_DIRTY_MB > $i
1744         done
1745         true
1746 }
1747 run_test 63 "Verify oig_wait interruption does not crash ======"
1748
1749 test_64a () {
1750         df $DIR
1751         grep "[0-9]" /proc/fs/lustre/osc/OSC*MNT*/cur*
1752 }
1753 run_test 64a "verify filter grant calculations (in kernel) ======"
1754
1755 test_64b () {
1756         sh oos.sh $MOUNT
1757 }
1758 run_test 64b "check out-of-space detection on client ============"
1759
1760 # on the LLNL clusters, runas will still pick up root's $TMP settings,
1761 # which will not be writable for the runas user, and then you get a CVS
1762 # error message with a corrupt path string (CVS bug) and panic.
1763 # We're not using much space, so just stick it in /tmp, which is safe.
1764 OLDTMPDIR=$TMPDIR
1765 OLDTMP=$TMP
1766 TMPDIR=/tmp
1767 TMP=/tmp
1768 OLDHOME=$HOME
1769 [ $RUNAS_ID -ne $UID ] && HOME=/tmp
1770
1771 test_99a() {
1772         mkdir -p $DIR/d99cvsroot
1773         chown $RUNAS_ID $DIR/d99cvsroot
1774         $RUNAS cvs -d $DIR/d99cvsroot init || error
1775 }
1776 run_test 99a "cvs init ========================================="
1777
1778 test_99b() {
1779         [ ! -d $DIR/d99cvsroot ] && run_one 99a
1780         cd /etc/init.d
1781         $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" d99reposname vtag rtag
1782 }
1783 run_test 99b "cvs import ======================================="
1784
1785 test_99c() {
1786         [ ! -d $DIR/d99cvsroot ] && run_one 99b
1787         cd $DIR
1788         mkdir -p $DIR/d99reposname
1789         chown $RUNAS_ID $DIR/d99reposname
1790         $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
1791 }
1792 run_test 99c "cvs checkout ====================================="
1793
1794 test_99d() {
1795         [ ! -d $DIR/d99cvsroot ] && run_one 99c
1796         cd $DIR/d99reposname
1797         $RUNAS touch foo99
1798         $RUNAS cvs add -m 'addmsg' foo99
1799 }
1800 run_test 99d "cvs add =========================================="
1801
1802 test_99e() {
1803         [ ! -d $DIR/d99cvsroot ] && run_one 99c
1804         cd $DIR/d99reposname
1805         $RUNAS cvs update
1806 }
1807 run_test 99e "cvs update ======================================="
1808
1809 test_99f() {
1810         [ ! -d $DIR/d99cvsroot ] && run_one 99d
1811         cd $DIR/d99reposname
1812         $RUNAS cvs commit -m 'nomsg' foo99
1813 }
1814 run_test 99f "cvs commit ======================================="
1815
1816 TMPDIR=$OLDTMPDIR
1817 TMP=$OLDTMP
1818 HOME=$OLDHOME
1819
1820 log "cleanup: ======================================================"
1821 if [ "`mount | grep ^$NAME`" ]; then
1822         rm -rf $DIR/[Rdfs][1-9]*
1823         if [ "$I_MOUNTED" = "yes" ]; then
1824                 sh llmountcleanup.sh || error
1825         fi
1826 fi
1827
1828 echo '=========================== finished ==============================='
1829 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true