Whamcloud - gitweb
- added recursive chmod for test_2g
[fs/lustre-release.git] / lustre / tests / sanity-gns.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 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
11 [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
12
13 SRCDIR=`dirname $0`
14 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
15 export SECURITY=${SECURITY:-"null"}
16
17 TMP=${TMP:-/tmp}
18 FSTYPE=${FSTYPE:-ext3}
19
20 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
21 CREATETEST=${CREATETEST:-createtest}
22 LFS=${LFS:-lfs}
23 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
24 LFIND=${LFIND:-"$LFS find"}
25 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
26 LCTL=${LCTL:-lctl}
27 MCREATE=${MCREATE:-mcreate}
28 OPENFILE=${OPENFILE:-openfile}
29 OPENUNLINK=${OPENUNLINK:-openunlink}
30 TOEXCL=${TOEXCL:-toexcl}
31 TRUNCATE=${TRUNCATE:-truncate}
32 MUNLINK=${MUNLINK:-munlink}
33 SOCKETSERVER=${SOCKETSERVER:-socketserver}
34 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
35 IOPENTEST1=${IOPENTEST1:-iopentest1}
36 IOPENTEST2=${IOPENTEST2:-iopentest2}
37 PTLDEBUG=${PTLDEBUG:-0}
38
39 . krb5_env.sh
40
41 if [ $UID -ne 0 ]; then
42         RUNAS_ID="$UID"
43         RUNAS=""
44 else
45         RUNAS_ID=${RUNAS_ID:-500}
46         RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
47 fi
48
49 if [ `using_krb5_sec $SECURITY` == 'y' ] ; then
50     start_krb5_kdc || exit 1
51     if [ $RUNAS_ID -ne $UID ]; then
52         $RUNAS ./krb5_refresh_cache.sh || exit 2
53     fi
54 fi
55
56 export NAME=${NAME:-local}
57
58 SAVE_PWD=$PWD
59
60 clean() {
61         echo -n "cln.."
62         sh llmountcleanup.sh > /dev/null || exit 20
63         I_MOUNTED=no
64 }
65 CLEAN=${CLEAN:-clean}
66
67 start() {
68         echo -n "mnt.."
69         sh llrmount.sh > /dev/null || exit 10
70         I_MOUNTED=yes
71         echo "done"
72 }
73 START=${START:-start}
74
75 log() {
76         echo "$*"
77         lctl mark "$*" 2> /dev/null || true
78 }
79
80 trace() {
81         log "STARTING: $*"
82         strace -o $TMP/$1.strace -ttt $*
83         RC=$?
84         log "FINISHED: $*: rc $RC"
85         return 1
86 }
87 TRACE=${TRACE:-""}
88
89 check_kernel_version() {
90         VERSION_FILE=/proc/fs/lustre/kernel_version
91         WANT_VER=$1
92         [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
93         GOT_VER=`cat $VERSION_FILE`
94         [ $GOT_VER -ge $WANT_VER ] && return 0
95         log "test needs at least kernel version $WANT_VER, running $GOT_VER"
96         return 1
97 }
98
99 run_one() {
100         if ! mount | grep -q $DIR; then
101                 $START
102         fi
103         echo $PTLDEBUG >/proc/sys/portals/debug 
104         log "== test $1: $2"
105         export TESTNAME=test_$1
106         test_$1 || error "test_$1: exit with rc=$?"
107         unset TESTNAME
108         pass
109         cd $SAVE_PWD
110         $CLEAN
111 }
112
113 build_test_filter() {
114         for O in $ONLY; do
115             eval ONLY_${O}=true
116         done
117         for E in $EXCEPT $ALWAYS_EXCEPT; do
118             eval EXCEPT_${E}=true
119         done
120 }
121
122 _basetest() {
123     echo $*
124 }
125
126 basetest() {
127     IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
128 }
129
130 run_test() {
131          base=`basetest $1`
132          if [ "$ONLY" ]; then
133                  testname=ONLY_$1
134                  if [ ${!testname}x != x ]; then
135                         run_one $1 "$2"
136                         return $?
137                  fi
138                  testname=ONLY_$base
139                  if [ ${!testname}x != x ]; then
140                          run_one $1 "$2"
141                          return $?
142                  fi
143                  echo -n "."
144                  return 0
145         fi
146         testname=EXCEPT_$1
147         if [ ${!testname}x != x ]; then
148                  echo "skipping excluded test $1"
149                  return 0
150         fi
151         testname=EXCEPT_$base
152         if [ ${!testname}x != x ]; then
153                  echo "skipping excluded test $1 (base $base)"
154                  return 0
155         fi
156         run_one $1 "$2"
157         return $?
158 }
159
160 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
161
162 error() { 
163         log "FAIL: $@"
164         if [ "$SANITYLOG" ]; then
165                 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
166         else
167                 exit 1
168         fi
169 }
170
171 pass() { 
172         echo PASS
173 }
174
175 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
176 if [ -z "$MOUNT" ]; then
177         sh llmount.sh
178         MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
179         [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
180         I_MOUNTED=yes
181 fi
182
183 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
184
185 DIR=${DIR:-$MOUNT}
186 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
187
188 rm -rf $DIR/[Rdfs][1-9]*
189 build_test_filter
190
191 echo preparing for tests involving mounts
192 EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP}
193 touch $EXT2_DEV
194 mke2fs -j -F $EXT2_DEV 8000 >/dev/null 2>&1
195
196 find_free_loop() {
197     local LOOP_DEV=""
198     test -b /dev/loop0 && 
199         base="/dev/loop" || base="/dev/loop/"
200
201     for ((i=0;i<256;i++)); do
202         test -b $base$i || continue
203         
204         losetup $base$i >/dev/null 2>&1 || {
205             LOOP_DEV="$base$i"
206             break
207         }
208     done
209     echo $LOOP_DEV
210 }
211
212 setup_loop() {
213     local LOOP_DEV=$1
214     local LOOP_FILE=$2
215     
216     dd if=/dev/zero of=$LOOP_FILE bs=1M count=10 2>/dev/null || return $?
217
218     losetup $LOOP_DEV $LOOP_FILE || {
219         rc=$?
220         cleanup_loop $LOOP_DEV $LOOP_FILE
221         return $rc
222     }
223     
224     mke2fs -F $LOOP_DEV >/dev/null 2>&1 || {
225         rc=$?
226         cleanup_loop $LOOP_DEV $LOOP_FILE
227         echo "cannot create test ext2 fs on $LOOP_DEV"
228         return $?
229     }
230     return 0
231 }
232
233 cleanup_loop() {
234     local LOOP_DEV=$1
235     local LOOP_FILE=$2
236     
237     losetup -d $LOOP_DEV >/dev/null 2>&1
238     rm -fr $LOOP_FILE >/dev/null 2>&1
239 }
240
241 setup_upcall() {
242     local INJECTION=""
243     local UPCALL=$1
244     local MODE=$2
245     local LOG=$3
246     local BG=$4
247     
248     test "x$BG" = "xBACKGROUND" && 
249         BG="&" || BG=""
250     
251     test "x$MODE" = "xDEADLOCK" &&
252         INJECTION="touch \$MNTPATH/file"
253     
254     cat > $UPCALL <<- EOF
255 #!/bin/sh
256
257 MOUNT=\`which mount 2>/dev/null\`
258 test "x\$MOUNT" = "x" && MOUNT="/bin/mount"
259
260 OPTIONS=\$1
261 MNTPATH=\$2
262
263 test "x\$OPTIONS" = "x" || "x\$MNTPATH" = "x" &&
264 exit 1
265
266 $INJECTION
267 \$MOUNT \$OPTIONS \$MNTPATH > $LOG 2>&1 $BG
268 exit \$?
269 EOF
270     chmod +x $UPCALL
271     return $?
272 }
273
274 cleanup_upcall() {
275     local UPCALL=$1
276     rm -fr $UPCALL
277 }
278
279 show_log() {
280     local LOG=$1
281     
282     test -f $LOG && {
283         echo "======================== upcall log ==========================="
284         cat $LOG
285         echo "==============================================================="
286     }
287 }
288
289 check_gns() {
290     local LOG="/tmp/gns-log"
291     local UPCALL_PATH=""
292     
293     local UPCALL=$1
294     local OBJECT1=$2
295     local OBJECT2=$3
296     local TIMOUT=$4
297     local TICK=$5
298     local MODE=$6
299     local BG=$7
300     
301     rm -fr $LOG >/dev/null 2>&1
302     UPCALL_PATH="/tmp/gns-upcall-$UPCALL.sh"
303     
304     echo "generating upcall $UPCALL_PATH"
305     setup_upcall $UPCALL_PATH $UPCALL $LOG $BG || return $rc
306
307     echo "======================== upcall script ==========================="
308     cat $UPCALL_PATH 2>/dev/null || return $?
309     echo "=================================================================="
310    
311     echo "$UPCALL_PATH" > /proc/fs/lustre/llite/fs0/gns_upcall || return $?
312     echo "upcall:  $(cat /proc/fs/lustre/llite/fs0/gns_upcall)"
313
314     case "$MODE" in
315         GENERIC)
316             echo -n "mount on open $OBJECT1/test_file1 (generic): "
317             echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 || return $?
318             ;;
319         CONCUR1)
320             local i=1
321             local nr=20
322         
323             echo -n "mount on open $OBJECT1/test_file1 ($nr threads): "
324             for ((;i<=$nr;i++)); do 
325                 echo -n "test data" > $OBJECT1/test_file$i >/dev/null 2>&1 &
326             done
327         
328             wait
329             
330             local RETVAL=$?
331             
332             [ $RETVAL -eq 0 ] || 
333                 return $RETVAL
334             ;;
335         CONCUR2)
336             test "x$OBJECT2" = "x" && {
337                 echo "not defined object2 for concurrent2 testing"
338                 return 1
339             }
340             echo -n "mount on open $OBJECT1/test_file1: "
341             echo -n "mount on open $OBJECT2/test_file1: "
342             echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 &
343             echo -n "test data" > $OBJECT2/test_file1 >/dev/null 2>&1 &
344             
345             wait
346             
347             local RETVAL=$?
348             
349             [ $RETVAL -eq 0 ] || 
350                 return $RETVAL
351             ;;
352         CONCUR3)
353             echo -n "mount on open $OBJECT1/test_file1: "
354             
355             local i=1
356             local nr=20
357             
358             for ((;i<$nr;i++)); do
359                 touch $OBJECT1/file$i &
360                 echo -n "test data" > $OBJECT1/test_file$i >/dev/null 2>&1 &
361                 mkdir $OBJECT1/dir$i &
362             done
363
364             wait
365             
366             local RETVAL=$?
367             
368             [ $RETVAL -eq 0 ] || 
369                 return $RETVAL
370             ;;
371         *)
372             echo "invalid testing mode $MODE"
373             return 1
374     esac
375     
376     local ENTRY1="`basename $OBJECT1`"
377     local ENTRY2="`basename $OBJECT2`"
378     
379     cat /proc/mounts | grep -q "$ENTRY1" || {
380         echo "fail"
381         show_log $LOG
382         return 1
383     }
384     
385     if test "x$MODE" = "xCONCUR2"; then
386         cat /proc/mounts | grep -q "$ENTRY2" || {
387             echo "fail"
388             show_log $LOG
389             return 1
390         }
391     fi
392     
393     echo "success"
394
395     local sleep_time=$TIMOUT
396     let sleep_time+=$TICK*2
397     echo -n "waiting for umount ${sleep_time}s (timeout + tick*2): "
398     sleep $sleep_time
399
400     cat /proc/mounts | grep -q "$ENTRY1" && {
401         echo "failed"
402         return 2
403     }
404     
405     if test "x$MODE" = "xCONCUR2"; then
406         cat /proc/mounts | grep -q "$ENTRY2" && {
407             echo "failed"
408             return 2
409         }
410     fi
411     
412     echo "success"
413     cleanup_upcall $UPCALL_PATH
414     return 0
415 }
416
417 setup_object() {
418     local OBJPATH=$1
419     local OBJECT=$2
420     local CONTENT=$3
421     
422     mkdir -p $OBJPATH || return $?
423     echo -n $CONTENT > $OBJPATH/$OBJECT || return $?
424     
425     echo "======================== mount object ==========================="
426     cat $OBJPATH/$OBJECT
427     echo ""
428     echo "================================================================="
429     
430     chmod u+s $OBJPATH
431     return $?
432 }
433
434 cleanup_object() {
435     local OBJPATH=$1
436
437     chmod u-s $OBJPATH
438     umount $OBJPATH >/dev/null 2>&1
439     rm -fr $OBJPATH >/dev/null 2>&1
440 }
441
442 setup_gns() {
443     local OBJECT=$1
444     local TIMOUT=$2
445     local TICK=$3
446
447     echo "$OBJECT" > /proc/fs/lustre/llite/fs0/gns_object_name || error
448     echo "$TIMOUT" > /proc/fs/lustre/llite/fs0/gns_timeout || error
449     echo "$TICK" > /proc/fs/lustre/llite/fs0/gns_tick || error
450
451     echo ""
452     echo "timeout: $(cat /proc/fs/lustre/llite/fs0/gns_timeout)s"
453     echo "object:  $(cat /proc/fs/lustre/llite/fs0/gns_object_name)"
454     echo "tick:    $(cat /proc/fs/lustre/llite/fs0/gns_tick)s"
455     echo ""
456
457 }
458
459 enable_gns()
460 {
461     echo "1" > /proc/fs/lustre/llite/fs0/gns_enabled || error
462     test "x$(cat /proc/fs/lustre/llite/fs0/gns_enabled)" = "x1" || error
463 }
464
465 disable_gns()
466 {
467     echo "0" > /proc/fs/lustre/llite/fs0/gns_enabled || error
468     test "x$(cat /proc/fs/lustre/llite/fs0/gns_enabled)" = "x0" || error
469 }
470
471 test_1a() {
472     local LOOP_DEV=$(find_free_loop 2>/dev/null)
473     local LOOP_FILE="/tmp/gns_loop_1a"
474     local OBJECT=".mntinfo"
475     local TIMOUT=5
476     local TICK=1
477
478     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
479         error "can't find free loop device"
480
481     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
482     cleanup_loop $LOOP_DEV $LOOP_FILE
483     setup_loop $LOOP_DEV $LOOP_FILE || error
484
485     echo "setting up GNS timeouts and mount object..."
486     setup_gns $OBJECT $TIMOUT $TICK || error
487     
488     disable_gns
489
490     echo "preparing mount object at $DIR/gns_test_1a/$OBJECT..."
491     setup_object $DIR/gns_test_1a $OBJECT "-t ext2 $LOOP_DEV" || error
492
493     enable_gns
494
495     echo ""
496     echo "testing GNS with GENERIC upcall 3 times on the row"
497     for ((i=0;i<3;i++)); do
498         check_gns GENERIC $DIR/gns_test_1a $DIR/gns_test_1a $TIMOUT $TICK GENERIC || {
499             disable_gns
500             cleanup_object $DIR/gns_test_1a
501             cleanup_loop $LOOP_DEV $LOOP_FILE
502             error
503         }
504     done
505     
506     disable_gns
507
508     cleanup_object $DIR/gns_test_1a
509     cleanup_loop $LOOP_DEV $LOOP_FILE
510 }
511
512 run_test 1a " general GNS test - mount/umount (GENERIC) ================"
513
514 test_1b() {
515     local LOOP_DEV=$(find_free_loop 2>/dev/null)
516     local LOOP_FILE="/tmp/gns_loop_1b"
517     local OBJECT=".mntinfo"
518     local TIMOUT=5
519     local TICK=1
520
521     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
522         error "can't find free loop device"
523
524     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
525     cleanup_loop $LOOP_DEV $LOOP_FILE
526     setup_loop $LOOP_DEV $LOOP_FILE || error
527
528     echo "setting up GNS timeouts and mount object..."
529     setup_gns $OBJECT $TIMOUT $TICK || error
530
531     disable_gns
532     
533     echo "preparing mount object at $DIR/gns_test_1b/$OBJECT..."
534     setup_object $DIR/gns_test_1b $OBJECT "-t ext2 $LOOP_DEV" || error
535     
536     enable_gns
537
538     echo ""
539     echo "testing GNS with DEADLOCK upcall 3 times on the row"
540     for ((i=0;i<3;i++)); do
541         check_gns DEADLOCK $DIR/gns_test_1b $DIR/gns_test_1b $TIMOUT $TICK GENERIC || {
542             disable_gns
543             cleanup_object $DIR/gns_test_1b
544             cleanup_loop $LOOP_DEV $LOOP_FILE
545             error
546         }
547     done
548     
549     disable_gns
550
551     cleanup_object $DIR/gns_test_1b
552     cleanup_loop $LOOP_DEV $LOOP_FILE
553 }
554
555 run_test 1b " general GNS test - mount/umount (DEADLOCK) ==============="
556
557 test_1c() {
558     local LOOP_DEV=$(find_free_loop 2>/dev/null)
559     local LOOP_FILE="/tmp/gns_loop_1c"
560     local OBJECT=".mntinfo"
561     local TIMOUT=5
562     local TICK=1
563
564     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
565         error "can't find free loop device"
566
567     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
568     cleanup_loop $LOOP_DEV $LOOP_FILE
569     setup_loop $LOOP_DEV $LOOP_FILE || error
570
571     echo "setting up GNS timeouts and mount object..."
572     setup_gns $OBJECT $TIMOUT $TICK || error
573
574     disable_gns
575
576     echo "preparing mount object at $DIR/gns_test_1c/$OBJECT..."
577     setup_object $DIR/gns_test_1c $OBJECT "-t ext2 $LOOP_DEV" || error
578
579     enable_gns
580
581     echo ""
582     echo "testing GNS with DEADLOCK upcall 4 times on the row"
583     local i=0
584     
585     for ((;i<4;i++)); do
586         local MODE="GENERIC"
587         
588         test $(($i%2)) -eq 1 && MODE="DEADLOCK"
589         
590         check_gns $MODE $DIR/gns_test_1c $DIR/gns_test_1c $TIMOUT $TICK GENERIC || {
591             disable_gns
592             cleanup_object $DIR/gns_test_1c
593             cleanup_loop $LOOP_DEV $LOOP_FILE
594             error
595         }
596     done
597     
598     disable_gns
599
600     cleanup_object $DIR/gns_test_1c
601     cleanup_loop $LOOP_DEV $LOOP_FILE
602 }
603
604 run_test 1c " general GNS test - mount/umount (GENERIC/DEADLOCK) ========"
605
606 test_1d() {
607     local LOOP_DEV=$(find_free_loop 2>/dev/null)
608     local LOOP_FILE="/tmp/gns_loop_1d"
609     local OBJECT=".mntinfo"
610     local TIMOUT=5
611     local TICK=1
612
613     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
614         error "can't find free loop device"
615
616     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
617     cleanup_loop $LOOP_DEV $LOOP_FILE
618     setup_loop $LOOP_DEV $LOOP_FILE || error
619
620     echo "setting up GNS timeouts and mount object..."
621     setup_gns $OBJECT $TIMOUT $TICK || error
622
623     disable_gns
624
625     echo "preparing mount object at $DIR/gns_test_1d/$OBJECT..."
626     setup_object $DIR/gns_test_1d $OBJECT "-t ext2 $LOOP_DEV" || error
627
628     enable_gns
629
630     echo ""
631     echo "testing GNS with GENERIC/DEADLOCK upcall 4 times on the row in CONCUR1 mode"
632     local i=0
633     
634     for ((;i<4;i++)); do
635         local MODE="GENERIC"
636         
637         test $(($i%2)) -eq 1 && MODE="DEADLOCK"
638         
639         check_gns $MODE $DIR/gns_test_1d $DIR/gns_test_1d $TIMOUT $TICK CONCUR1 || {
640             disable_gns
641             cleanup_object $DIR/gns_test_1d
642             cleanup_loop $LOOP_DEV $LOOP_FILE
643             error
644         }
645     done
646     
647     disable_gns
648
649     cleanup_object $DIR/gns_test_1d
650     cleanup_loop $LOOP_DEV $LOOP_FILE
651 }
652
653 run_test 1d " general GNS test - concurrent mount ======================="
654
655 test_1e() {
656     local LOOP_DEV=$(find_free_loop 2>/dev/null)
657     local LOOP_FILE="/tmp/gns_loop_1e"
658     local OBJECT=".mntinfo"
659     local TIMOUT=5
660     local TICK=1
661
662     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
663         error "can't find free loop device"
664
665     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
666     cleanup_loop $LOOP_DEV $LOOP_FILE
667     setup_loop $LOOP_DEV $LOOP_FILE || error
668
669     echo "setting up GNS timeouts and mount object..."
670     setup_gns $OBJECT $TIMOUT $TICK || error
671
672     disable_gns
673
674     echo "preparing mount object at $DIR/gns_test_1e1/$OBJECT..."
675     setup_object $DIR/gns_test_1e1 $OBJECT "-t ext2 $LOOP_DEV" || error
676     
677     echo "preparing mount object at $DIR/gns_test_1e2/$OBJECT..."
678     setup_object $DIR/gns_test_1e2 $OBJECT "-t ext2 $LOOP_DEV" || error
679
680     enable_gns
681
682     echo ""
683     echo "testing GNS with GENERIC upcall in CONCUR2 mode"
684     check_gns GENERIC $DIR/gns_test_1e1 $DIR/gns_test_1e2 $TIMOUT $TICK CONCUR2 || {
685         disable_gns
686         cleanup_object $DIR/gns_test_1e1
687         cleanup_object $DIR/gns_test_1e2
688         cleanup_loop $LOOP_DEV $LOOP_FILE
689         error
690     }
691     
692     disable_gns
693
694     cleanup_object $DIR/gns_test_1e1
695     cleanup_object $DIR/gns_test_1e2
696     cleanup_loop $LOOP_DEV $LOOP_FILE
697 }
698
699 run_test 1e " general GNS test - concurrent mount of 2 GNS mounts ======="
700
701 test_2a() {
702     local OBJECT=".mntinfo"
703     local TIMOUT=5
704     local TICK=1
705
706     echo "setting up GNS timeouts and mount object..."
707     setup_gns $OBJECT $TIMOUT $TICK || error
708
709     disable_gns
710
711     echo "preparing mount object at $DIR/gns_test_2a/$OBJECT..."
712     mkdir -p $DIR/gns_test_2a
713     ln -s $DIR/gns_test_2a $DIR/gns_test_2a/$OBJECT
714     chmod u+s $DIR/gns_test_2a
715     
716     enable_gns
717
718     echo ""
719     echo "testing GNS with GENERIC upcall"
720     check_gns GENERIC $DIR/gns_test_2a $DIR/gns_test_2a $TIMOUT $TICK GENERIC && {
721         disable_gns
722         chmod u-s $DIR/gns_test_2a
723         rm -fr $DIR/gns_test_2a
724         error "symlink as mount object works?"
725     }
726     
727     disable_gns
728     chmod u-s $DIR/gns_test_2a
729     rm -fr $DIR/gns_test_2a
730 }
731
732 run_test 2a " odd conditions (mount object is symlink) ============="
733
734 test_2b() {
735     local OBJECT=".mntinfo"
736     local TIMOUT=5
737     local TICK=1
738
739     echo "setting up GNS timeouts and mount object..."
740     setup_gns $OBJECT $TIMOUT $TICK || error
741
742     disable_gns
743
744     echo "preparing mount object at $DIR/gns_test_2b/$OBJECT..."
745     mkdir -p $DIR/gns_test_2b/$OBJECT
746     chmod u+s $DIR/gns_test_2b
747     
748     enable_gns
749     
750     echo ""
751     echo "testing GNS with GENERIC upcall"
752     check_gns GENERIC $DIR/gns_test_2b $DIR/gns_test_2b $TIMOUT $TICK GENERIC && {
753         disable_gns
754         chmod u-s $DIR/gns_test_2b
755         rm -fr $DIR/gns_test_2b
756         error "dir as mount object works?"
757     }
758     
759     disable_gns
760     chmod u-s $DIR/gns_test_2b
761     rm -fr $DIR/gns_test_2b
762 }
763
764 run_test 2b " odd conditions (mount object is directory) ==========="
765
766 test_2c() {
767     local OBJECT=".mntinfo"
768     local TIMOUT=5
769     local TICK=1
770
771     echo "setting up GNS timeouts and mount object..."
772     setup_gns $OBJECT $TIMOUT $TICK || error
773
774     disable_gns
775
776     echo "preparing mount object at $DIR/gns_test_2c/$OBJECT..."
777     mkdir -p $DIR/gns_test_2c/$OBJECT/$OBJECT/$OBJECT/$OBJECT
778     chmod u+s -R $DIR/gns_test_2c
779     
780     enable_gns
781     
782     echo ""
783     echo "testing GNS with GENERIC upcall"
784     check_gns GENERIC $DIR/gns_test_2c $DIR/gns_test_2c $TIMOUT $TICK GENERIC && {
785         disable_gns
786         chmod u-s -R $DIR/gns_test_2c
787         rm -fr $DIR/gns_test_2c
788         error "recursive mounting of dir as mount object works?"
789     }
790     
791     disable_gns
792     chmod u-s $DIR/gns_test_2c
793     rm -fr $DIR/gns_test_2c
794 }
795
796 run_test 2c " odd conditions (mount object is recursive dir) ======="
797
798 test_2d() {
799     local OBJECT=".mntinfo"
800     local TIMOUT=5
801     local TICK=1
802
803     echo "setting up GNS timeouts and mount object..."
804     setup_gns $OBJECT $TIMOUT $TICK || error
805
806     disable_gns
807
808     echo "preparing mount object at $DIR/gns_test_2d/$OBJECT..."
809     mkdir -p $DIR/gns_test_2d
810     chmod u+s $DIR/gns_test_2d
811     
812     enable_gns
813
814     echo ""
815     echo "testing GNS with GENERIC upcall"
816     check_gns GENERIC $DIR/gns_test_2d $DIR/gns_test_2d $TIMOUT $TICK GENERIC && {
817         disable_gns
818         chmod u-s $DIR/gns_test_2d
819         rm -fr $DIR/gns_test_2d
820         error "mount point with absent mount object works?"
821     }
822     
823     disable_gns
824     chmod u-s $DIR/gns_test_2d
825     rm -fr $DIR/gns_test_2d
826 }
827
828 run_test 2d " odd conditions (mount object is absent) =============="
829
830 test_2e() {
831     local OBJECT=".mntinfo"
832     local TIMOUT=5
833     local TICK=1
834
835     echo "setting up GNS timeouts and mount object..."
836     setup_gns $OBJECT $TIMOUT $TICK || error
837
838     echo "." > /proc/fs/lustre/llite/fs0/gns_object_name
839     test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x." && 
840         error "'.' is set as mount object name"
841
842     echo ".." > /proc/fs/lustre/llite/fs0/gns_object_name
843     test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x.." && 
844         error "'..' is set as mount object name"
845
846     echo ".a" > /proc/fs/lustre/llite/fs0/gns_object_name
847     test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x.a" || 
848         error "'.a' is not set as mount object name"
849
850     echo "..a" > /proc/fs/lustre/llite/fs0/gns_object_name
851     test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x..a" || 
852         error "'..a' is not set as mount object name"
853 }
854
855 run_test 2e " odd conditions ('.' and '..' as mount object) ============="
856
857 test_2f() {
858     local LOOP_DEV=$(find_free_loop 2>/dev/null)
859     local LOOP_FILE="/tmp/gns_loop_2f"
860     local OBJECT=".mntinfo"
861     local TIMOUT=5
862     local TICK=1
863
864     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
865         error "can't find free loop device"
866
867     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
868     cleanup_loop $LOOP_DEV $LOOP_FILE
869     setup_loop $LOOP_DEV $LOOP_FILE || error
870
871     echo "setting up GNS timeouts and mount object..."
872     setup_gns $OBJECT $TIMOUT $TICK || error
873
874     disable_gns
875
876     echo "preparing mount object at $DIR/gns_test_2f/$OBJECT..."
877     setup_object $DIR/gns_test_2f $OBJECT "-t ext2 $LOOP_DEV" || error
878
879     enable_gns
880
881     echo ""
882     echo "testing GNS with DEADLOCK upcall in CONCUR3 mode"
883     
884     local MODE="DEADLOCK"
885         
886     check_gns $MODE $DIR/gns_test_2f $DIR/gns_test_2f $TIMOUT $TICK CONCUR3 || {
887         disable_gns
888         cleanup_object $DIR/gns_test_2f
889         cleanup_loop $LOOP_DEV $LOOP_FILE
890         error
891     }
892     
893     disable_gns
894
895     cleanup_object $DIR/gns_test_2f
896     cleanup_loop $LOOP_DEV $LOOP_FILE
897 }
898
899 run_test 2f " odd conditions (mount point is modifying during mount) ===="
900
901 test_2g() {
902     local LOOP_DEV=$(find_free_loop 2>/dev/null)
903     local LOOP_FILE="/tmp/gns_loop_2g"
904     local OBJECT=".mntinfo"
905     local TIMOUT=5
906     local TICK=1
907
908     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
909         error "can't find free loop device"
910
911     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
912     cleanup_loop $LOOP_DEV $LOOP_FILE
913     setup_loop $LOOP_DEV $LOOP_FILE || error
914
915     echo "setting up GNS timeouts and mount object..."
916     setup_gns $OBJECT $TIMOUT $TICK || error
917
918     disable_gns
919
920     echo "preparing mount object at $DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT..."
921     setup_object $DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT \
922 $OBJECT "-t ext2 $LOOP_DEV" || error
923     chmod u+s $DIR/gns_test_2g
924
925     enable_gns
926
927     echo ""
928     echo "testing GNS with DEADLOCK upcall in GENERIC mode"
929     
930     local MODE="DEADLOCK"
931         
932     check_gns $MODE $DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT \
933 $DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT $TIMOUT $TICK GENERIC || {
934         disable_gns
935         cleanup_object $DIR/gns_test_2g
936         cleanup_loop $LOOP_DEV $LOOP_FILE
937         error
938     }
939     
940     disable_gns
941
942     cleanup_object $DIR/gns_test_2g
943     cleanup_loop $LOOP_DEV $LOOP_FILE
944 }
945
946 run_test 2g " odd conditions (mount point is recursive marked SUID dir) ="
947
948 test_2h() {
949     local LOOP_DEV=$(find_free_loop 2>/dev/null)
950     local LOOP_FILE="/tmp/gns_loop_2h"
951     local OBJECT=".mntinfo"
952     local TIMOUT=5
953     local TICK=1
954
955     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
956         error "can't find free loop device"
957
958     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
959     cleanup_loop $LOOP_DEV $LOOP_FILE
960     setup_loop $LOOP_DEV $LOOP_FILE || error
961
962     echo "setting up GNS timeouts and mount object..."
963     setup_gns $OBJECT $TIMOUT $TICK || error
964
965     disable_gns
966
967     echo "preparing mount object at $DIR/gns_test_2h/$OBJECT..."
968     setup_object $DIR/gns_test_2h $OBJECT "-t ext2 $LOOP_DEV" || error
969
970     enable_gns
971
972     echo ""
973     echo "testing GNS with GENERIC upcall in GENERIC mode"
974     
975     check_gns GENERIC $DIR/gns_test_2h $DIR/gns_test_2h \
976 $TIMOUT $TICK GENERIC BACKGROUND || {
977         disable_gns
978         cleanup_object $DIR/gns_test_2h
979         cleanup_loop $LOOP_DEV $LOOP_FILE
980         error
981     }
982     
983     disable_gns
984
985     cleanup_object $DIR/gns_test_2h
986     cleanup_loop $LOOP_DEV $LOOP_FILE
987 }
988
989 run_test 2h " odd conditions (mounting in background) ==================="
990
991 TMPDIR=$OLDTMPDIR
992 TMP=$OLDTMP
993 HOME=$OLDHOME
994
995 log "cleanup: ==========================================================="
996 if [ "`mount | grep ^$NAME`" ]; then
997         rm -rf $DIR/[Rdfs][1-9]*
998         if [ "$I_MOUNTED" = "yes" ]; then
999                 sh llmountcleanup.sh || error
1000         fi
1001 fi
1002
1003 echo '=========================== finished ==============================='
1004 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true