Whamcloud - gitweb
448aa09d4c8b1f84cfa9a36bd98057c9aef348dc
[fs/lustre-release.git] / lustre / tests / conf-sanity.sh
1 #!/bin/bash
2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:autoindent:shiftwidth=4:tabstop=4:
4
5 # FIXME - there is no reason to use all of these different
6 #   return codes, espcially when most of them are mapped to something
7 #   else anyway.  The combination of test number and return code
8 #   figure out what failed.
9
10 set -e
11
12 ONLY=${ONLY:-"$*"}
13
14 # bug number for skipped test:
15 #               15977
16 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
17 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18
19 SRCDIR=`dirname $0`
20 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
21
22 PTLDEBUG=${PTLDEBUG:--1}
23 SAVE_PWD=$PWD
24 LUSTRE=${LUSTRE:-`dirname $0`/..}
25 RLUSTRE=${RLUSTRE:-$LUSTRE}
26
27 . $LUSTRE/tests/test-framework.sh
28 init_test_env $@
29 init_logging
30 # STORED_MDSSIZE is used in test_18
31 if [ -n "$MDSSIZE" ]; then
32     STORED_MDSSIZE=$MDSSIZE
33 fi
34 # use small MDS + OST size to speed formatting time
35 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
36 MDSSIZE=200000
37 OSTSIZE=200000
38 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
39
40 require_dsh_mds || exit 0
41 require_dsh_ost || exit 0
42
43 [ "$SLOW" = "no" ] && EXCEPT_SLOW="0 1 2 3 6 7 15 18 24b 25 30 31 32 33 34a 45"
44
45 assert_DIR
46
47 reformat() {
48         formatall
49 }
50
51 writeconf() {
52         local facet=$SINGLEMDS
53         local dev=${facet}_dev
54         shift
55         stop ${facet} -f
56         rm -f ${facet}active
57         # who knows if/where $TUNEFS is installed?  Better reformat if it fails...
58         do_facet ${facet} "$TUNEFS --writeconf ${!dev}" ||
59                 echo "tunefs failed, reformatting instead" && reformat_and_config
60
61 }
62
63 gen_config() {
64         # The MGS must be started before the OSTs for a new fs, so start
65         # and stop to generate the startup logs.
66         start_mds
67         start_ost
68         wait_osc_import_state mds ost FULL
69         stop_ost
70         stop_mds
71 }
72
73 reformat_and_config() {
74         reformat
75         if ! combined_mgs_mds ; then
76                 start_mgs
77         fi
78         gen_config
79 }
80
81 start_mgs () {
82         echo "start mgs"
83         start mgs $MGSDEV $mgs_MOUNT_OPTS
84 }
85
86 start_mds() {
87         local facet=$SINGLEMDS
88         # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
89         local num=$(echo $facet | tr -d "mds")
90         local dev=$(mdsdevname $num)
91         echo "start mds service on `facet_active_host $facet`"
92         start $facet ${dev} $MDS_MOUNT_OPTS || return 94
93 }
94
95 stop_mds() {
96         echo "stop mds service on `facet_active_host $SINGLEMDS`"
97         # These tests all use non-failover stop
98         stop $SINGLEMDS -f  || return 97
99 }
100
101 start_ost() {
102         echo "start ost1 service on `facet_active_host ost1`"
103         start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95
104 }
105
106 stop_ost() {
107         echo "stop ost1 service on `facet_active_host ost1`"
108         # These tests all use non-failover stop
109         stop ost1 -f  || return 98
110 }
111
112 start_ost2() {
113         echo "start ost2 service on `facet_active_host ost2`"
114         start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92
115 }
116
117 stop_ost2() {
118         echo "stop ost2 service on `facet_active_host ost2`"
119         # These tests all use non-failover stop
120         stop ost2 -f  || return 93
121 }
122
123 mount_client() {
124         local MOUNTPATH=$1
125         echo "mount $FSNAME on ${MOUNTPATH}....."
126         zconf_mount `hostname` $MOUNTPATH  || return 96
127 }
128
129 remount_client() {
130         local SAVEMOUNTOPT=$MOUNTOPT
131         MOUNTOPT="remount,$1"
132         local MOUNTPATH=$2
133         echo "remount '$1' lustre on ${MOUNTPATH}....."
134         zconf_mount `hostname`  $MOUNTPATH  || return 96
135         MOUNTOPT=$SAVEMOUNTOPT
136 }
137
138 umount_client() {
139         local MOUNTPATH=$1
140         echo "umount lustre on ${MOUNTPATH}....."
141         zconf_umount `hostname` $MOUNTPATH || return 97
142 }
143
144 manual_umount_client(){
145         local rc
146         local FORCE=$1
147         echo "manual umount lustre on ${MOUNT}...."
148         do_facet client "umount -d ${FORCE} $MOUNT"
149         rc=$?
150         return $rc
151 }
152
153 setup() {
154         start_ost
155         start_mds
156         mount_client $MOUNT
157 }
158
159 setup_noconfig() {
160         if ! combined_mgs_mds ; then
161                 start_mgs
162         fi
163
164         start_mds
165         start_ost
166         mount_client $MOUNT
167 }
168
169 cleanup_nocli() {
170         stop_mds || return 201
171         stop_ost || return 202
172         unload_modules || return 203
173 }
174
175 cleanup() {
176         umount_client $MOUNT || return 200
177         cleanup_nocli || return $?
178 }
179
180 check_mount() {
181         do_facet client "cp /etc/passwd $DIR/a" || return 71
182         do_facet client "rm $DIR/a" || return 72
183         # make sure lustre is actually mounted (touch will block,
184         # but grep won't, so do it after)
185         do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
186         echo "setup single mount lustre success"
187 }
188
189 check_mount2() {
190         do_facet client "touch $DIR/a" || return 71
191         do_facet client "rm $DIR/a" || return 72
192         do_facet client "touch $DIR2/a" || return 73
193         do_facet client "rm $DIR2/a" || return 74
194         echo "setup double mount lustre success"
195 }
196
197 build_test_filter
198
199 if [ "$ONLY" == "setup" ]; then
200         setup
201         exit
202 fi
203
204 if [ "$ONLY" == "cleanup" ]; then
205         cleanup
206         exit
207 fi
208
209 init_gss
210
211 #create single point mountpoint
212
213 reformat_and_config
214
215 test_0() {
216         setup
217         check_mount || return 41
218         cleanup || return $?
219 }
220 run_test 0 "single mount setup"
221
222 test_1() {
223         start_ost
224         echo "start ost second time..."
225         setup
226         check_mount || return 42
227         cleanup || return $?
228 }
229 run_test 1 "start up ost twice (should return errors)"
230
231 test_2() {
232         start_ost
233         start_mds
234         echo "start mds second time.."
235         start_mds
236         mount_client $MOUNT
237         check_mount || return 43
238         cleanup || return $?
239 }
240 run_test 2 "start up mds twice (should return err)"
241
242 test_3() {
243         setup
244         #mount.lustre returns an error if already in mtab
245         mount_client $MOUNT && return $?
246         check_mount || return 44
247         cleanup || return $?
248 }
249 run_test 3 "mount client twice (should return err)"
250
251 test_4() {
252         setup
253         touch $DIR/$tfile || return 85
254         stop_ost -f
255         cleanup
256         eno=$?
257         # ok for ost to fail shutdown
258         if [ 202 -ne $eno ]; then
259                 return $eno;
260         fi
261         return 0
262 }
263 run_test 4 "force cleanup ost, then cleanup"
264
265 test_5a() {     # was test_5
266         setup
267         touch $DIR/$tfile || return 1
268         fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
269
270         stop_mds -f || return 2
271
272         # cleanup may return an error from the failed
273         # disconnects; for now I'll consider this successful
274         # if all the modules have unloaded.
275         umount -d $MOUNT &
276         UMOUNT_PID=$!
277         sleep 6
278         echo "killing umount"
279         kill -TERM $UMOUNT_PID
280         echo "waiting for umount to finish"
281         wait $UMOUNT_PID
282         if grep " $MOUNT " /proc/mounts; then
283                 echo "test 5: /proc/mounts after failed umount"
284                 umount $MOUNT &
285                 UMOUNT_PID=$!
286                 sleep 2
287                 echo "killing umount"
288                 kill -TERM $UMOUNT_PID
289                 echo "waiting for umount to finish"
290                 wait $UMOUNT_PID
291                 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
292         fi
293
294         manual_umount_client
295         # stop_mds is a no-op here, and should not fail
296         cleanup_nocli || return $?
297         # df may have lingering entry
298         manual_umount_client
299         # mtab may have lingering entry
300         local WAIT=0
301         local MAX_WAIT=20
302         local sleep=1
303         while [ "$WAIT" -ne "$MAX_WAIT" ]; do
304                 sleep $sleep
305                 grep -q $MOUNT" " /etc/mtab || break
306                 echo "Waiting /etc/mtab updated ... "
307                 WAIT=$(( WAIT + sleep))
308         done
309         [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
310         echo "/etc/mtab updated in $WAIT secs"
311 }
312 run_test 5a "force cleanup mds, then cleanup"
313
314 test_5b() {
315         start_ost
316         [ -d $MOUNT ] || mkdir -p $MOUNT
317         grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
318         mount_client $MOUNT && return 1
319         grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
320         umount_client $MOUNT
321         # stop_mds is a no-op here, and should not fail
322         cleanup_nocli || return $?
323         return 0
324 }
325 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
326
327 test_5c() {
328         start_ost
329         start_mds
330         [ -d $MOUNT ] || mkdir -p $MOUNT
331         grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
332         local oldfs="${FSNAME}"
333         FSNAME="wrong.${FSNAME}"
334         mount_client $MOUNT || :
335         FSNAME=${oldfs}
336         grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
337         umount_client $MOUNT
338         cleanup_nocli  || return $?
339 }
340 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
341
342 test_5d() {
343         start_ost
344         start_mds
345         stop_ost -f
346         grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
347         mount_client $MOUNT || return 1
348         cleanup  || return $?
349         grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
350         return 0
351 }
352 run_test 5d "mount with ost down"
353
354 test_5e() {
355         start_ost
356         start_mds
357
358 #define OBD_FAIL_PTLRPC_DELAY_SEND       0x506
359         do_facet client "lctl set_param fail_loc=0x80000506"
360         grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
361         mount_client $MOUNT || echo "mount failed (not fatal)"
362         cleanup  || return $?
363         grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
364         return 0
365 }
366 run_test 5e "delayed connect, don't crash (bug 10268)"
367
368 test_6() {
369         setup
370         manual_umount_client
371         mount_client ${MOUNT} || return 87
372         touch $DIR/a || return 86
373         cleanup  || return $?
374 }
375 run_test 6 "manual umount, then mount again"
376
377 test_7() {
378         setup
379         manual_umount_client
380         cleanup_nocli || return $?
381 }
382 run_test 7 "manual umount, then cleanup"
383
384 test_8() {
385         setup
386         mount_client $MOUNT2
387         check_mount2 || return 45
388         umount_client $MOUNT2
389         cleanup  || return $?
390 }
391 run_test 8 "double mount setup"
392
393 test_9() {
394         start_ost
395
396         do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
397         do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
398
399         CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
400         if [ "$CHECK_PTLDEBUG" ] && { \
401            [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
402            [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
403            echo "lnet.debug success"
404         else
405            echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
406            return 1
407         fi
408         CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
409         if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
410            echo "lnet.subsystem_debug success"
411         else
412            echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
413            return 1
414         fi
415         stop_ost || return $?
416 }
417
418 run_test 9 "test ptldebug and subsystem for mkfs"
419
420 # LOGS/PENDING do not exist anymore since CMD3
421 test_16() {
422         local TMPMTPT="${TMP}/conf16"
423         local dev=${SINGLEMDS}_dev
424         local MDSDEV=${!dev}
425         if [ ! -e "$MDSDEV" ]; then
426             log "no $MDSDEV existing, so mount Lustre to create one"
427             setup
428             check_mount || return 41
429             cleanup || return $?
430         fi
431
432         [ -f "$MDSDEV" ] && LOOPOPT="-o loop"
433
434         log "change the mode of $MDSDEV/OBJECTS to 555"
435         do_facet $SINGLEMDS "mkdir -p $TMPMTPT &&
436                       mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
437                       chmod 555 $TMPMTPT/OBJECTS &&
438                       umount $TMPMTPT" || return $?
439
440         log "mount Lustre to change the mode of OBJECTS, then umount Lustre"
441         setup
442         check_mount || return 41
443         cleanup || return $?
444
445         log "read the mode of OBJECTS and check if they has been changed properly"
446         EXPECTEDOBJECTSMODE=`do_facet $SINGLEMDS "$DEBUGFS -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
447
448         if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
449                 log "Success:Lustre change the mode of OBJECTS correctly"
450         else
451                 error "Lustre does not change mode of OBJECTS properly"
452         fi
453 }
454 run_test 16 "verify that lustre will correct the mode of OBJECTS"
455
456 test_17() {
457         local dev=${SINGLEMDS}_dev
458         local MDSDEV=${!dev}
459
460         if [ ! -e "$MDSDEV" ]; then
461             echo "no $MDSDEV existing, so mount Lustre to create one"
462             setup
463             check_mount || return 41
464             cleanup || return $?
465         fi
466
467         echo "Remove mds config log"
468         do_facet $SINGLEMDS "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
469
470         start_ost
471         start_mds && return 42
472         reformat_and_config
473 }
474 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
475
476 test_18() {
477         [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
478
479         local dev=${SINGLEMDS}_dev
480         local MDSDEV=${!dev}
481
482         local MIN=2000000
483
484         local OK=
485         # check if current MDSSIZE is large enough
486         [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
487                 log "use MDSSIZE=$MDSSIZE"
488
489         # check if the global config has a large enough MDSSIZE
490         [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
491                 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
492                 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
493
494         # check if the block device is large enough
495         [ -z "$OK" -a -b $MDSDEV ] && \
496                 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
497                      awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
498                 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
499
500         # check if a loopback device has enough space for fs metadata (5%)
501         [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
502                 SPACE=$(df -P $(dirname $MDSDEV) |
503                         awk '($1 != "Filesystem") {print $4}') &&
504                 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
505                         log "use file $MDSDEV with MIN=$MIN"
506
507         [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
508
509
510         echo "mount mds with large journal..."
511         local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
512
513         MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
514
515         reformat_and_config
516         echo "mount lustre system..."
517         setup
518         check_mount || return 41
519
520         echo "check journal size..."
521         local FOUNDSIZE=`do_facet mds "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
522         if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
523                 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
524         else
525                 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
526         fi
527
528         cleanup || return $?
529
530         MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
531         reformat_and_config
532 }
533 run_test 18 "check mkfs creates large journals"
534
535 test_19a() {
536         start_mds || return 1
537         stop_mds -f || return 2
538 }
539 run_test 19a "start/stop MDS without OSTs"
540
541 test_19b() {
542         start_ost || return 1
543         stop_ost -f || return 2
544 }
545 run_test 19b "start/stop OSTs without MDS"
546
547 test_20() {
548         # first format the ost/mdt
549         start_ost
550         start_mds
551         mount_client $MOUNT
552         check_mount || return 43
553         rm -f $DIR/$tfile
554         remount_client ro $MOUNT || return 44
555         touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
556         [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
557         remount_client rw $MOUNT || return 47
558         touch $DIR/$tfile
559         [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
560         MCNT=`grep -c $MOUNT /etc/mtab`
561         [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
562         umount_client $MOUNT
563         stop_mds
564         stop_ost
565 }
566 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
567
568 test_21a() {
569         start_mds
570         start_ost
571         wait_osc_import_state mds ost FULL
572         stop_ost
573         stop_mds
574 }
575 run_test 21a "start mds before ost, stop ost first"
576
577 test_21b() {
578         start_ost
579         start_mds
580         wait_osc_import_state mds ost FULL
581         stop_mds
582         stop_ost
583 }
584 run_test 21b "start ost before mds, stop mds first"
585
586 test_21c() {
587         start_ost
588         start_mds
589         start_ost2
590         wait_osc_import_state mds ost2 FULL
591         stop_ost
592         stop_ost2
593         stop_mds
594         #writeconf to remove all ost2 traces for subsequent tests
595         writeconf
596 }
597 run_test 21c "start mds between two osts, stop mds last"
598
599 test_22() {
600         start_mds
601
602         echo Client mount with ost in logs, but none running
603         start_ost
604         # wait until mds connected to ost and open client connection
605         wait_osc_import_state mds ost FULL
606         stop_ost
607         mount_client $MOUNT
608         # check_mount will block trying to contact ost
609         mcreate $DIR/$tfile || return 40
610         rm -f $DIR/$tfile || return 42
611         umount_client $MOUNT
612         pass
613
614         echo Client mount with a running ost
615         start_ost
616         if $GSS; then
617                 # if gss enabled, wait full time to let connection from
618                 # mds to ost be established, due to the mismatch between
619                 # initial connect timeout and gss context negotiation timeout.
620                 # This perhaps could be remove after AT landed.
621                 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
622                 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
623         fi
624         mount_client $MOUNT
625         check_mount || return 41
626         pass
627
628         cleanup
629 }
630 run_test 22 "start a client before osts (should return errs)"
631
632 test_23a() {    # was test_23
633         setup
634         # fail mds
635         stop $SINGLEMDS
636         # force down client so that recovering mds waits for reconnect
637         local running=$(grep -c $MOUNT /proc/mounts) || true
638         if [ $running -ne 0 ]; then
639                 echo "Stopping client $MOUNT (opts: -f)"
640                 umount -f $MOUNT
641         fi
642
643         # enter recovery on mds
644         start_mds
645         # try to start a new client
646         mount_client $MOUNT &
647         sleep 5
648         MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
649         MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
650         echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
651         ps --ppid $MOUNT_PID
652         ps --ppid $MOUNT_LUSTRE_PID
653         # FIXME why o why can't I kill these? Manual "ctrl-c" works...
654         kill -TERM $MOUNT_LUSTRE_PID
655         echo "waiting for mount to finish"
656         ps -ef | grep mount
657         # we can not wait $MOUNT_PID because it is not a child of this shell
658         local PID1
659         local PID2
660         local WAIT=0
661         local MAX_WAIT=30
662         local sleep=1
663         while [ "$WAIT" -lt "$MAX_WAIT" ]; do
664                 sleep $sleep
665                 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
666                 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
667                 echo PID1=$PID1
668                 echo PID2=$PID2
669                 [ -z "$PID1" -a -z "$PID2" ] && break
670                 echo "waiting for mount to finish ... "
671                 WAIT=$(( WAIT + sleep))
672         done
673         if [ "$WAIT" -eq "$MAX_WAIT" ]; then
674                 error "MOUNT_PID $MOUNT_PID and "\
675                 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
676                 ps -ef | grep mount
677         fi
678         stop_mds || error
679         stop_ost || error
680 }
681 run_test 23a "interrupt client during recovery mount delay"
682
683 umount_client $MOUNT
684 cleanup_nocli
685
686 test_23b() {    # was test_23
687         start_ost
688         start_mds
689         # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
690         lctl set_param fail_loc=0x80000313
691         mount_client $MOUNT
692         cleanup
693 }
694 run_test 23b "Simulate -EINTR during mount"
695
696 fs2mds_HOST=$mds_HOST
697 fs2ost_HOST=$ost_HOST
698
699 cleanup_24a() {
700         trap 0
701         echo "umount $MOUNT2 ..."
702         umount $MOUNT2 || true
703         echo "stopping fs2mds ..."
704         stop fs2mds -f || true
705         echo "stopping fs2ost ..."
706         stop fs2ost -f || true
707 }
708
709 test_24a() {
710         #set up fs1
711         gen_config
712         #set up fs2
713         [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
714         if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
715                 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
716                 skip_env "mixed loopback and real device not working" && return
717         fi
718
719         local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
720         local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
721
722         # test 8-char fsname as well
723         local FSNAME2=test1234
724         add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
725
726         add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
727
728         setup
729         start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
730         start fs2ost $fs2ostdev $OST_MOUNT_OPTS
731         mkdir -p $MOUNT2
732         mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
733         # 1 still works
734         check_mount || return 2
735         # files written on 1 should not show up on 2
736         cp /etc/passwd $DIR/$tfile
737         sleep 10
738         [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
739         # 2 should work
740         sleep 5
741         cp /etc/passwd $MOUNT2/b || return 3
742         rm $MOUNT2/b || return 4
743         # 2 is actually mounted
744         grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
745         # failover
746         facet_failover fs2mds
747         facet_failover fs2ost
748         df
749         umount_client $MOUNT
750         # the MDS must remain up until last MDT
751         stop_mds
752         MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
753         [ -z "$MDS" ] && error "No MDT" && return 8
754         cleanup_24a
755         cleanup_nocli || return 6
756 }
757 run_test 24a "Multiple MDTs on a single node"
758
759 test_24b() {
760         if [ -z "$fs2mds_DEV" ]; then
761                 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
762                 skip_env "mixed loopback and real device not working" && return
763         fi
764
765         local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
766
767         add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
768         setup
769         start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
770         cleanup || return 6
771 }
772 run_test 24b "Multiple MGSs on a single node (should return err)"
773
774 test_25() {
775         setup
776         check_mount || return 2
777         local MODULES=$($LCTL modules | awk '{ print $2 }')
778         rmmod $MODULES 2>/dev/null || true
779         cleanup || return 6
780 }
781 run_test 25 "Verify modules are referenced"
782
783 test_26() {
784     load_modules
785     # we need modules before mount for sysctl, so make sure...
786     do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
787 #define OBD_FAIL_MDS_FS_SETUP            0x135
788     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
789     start_mds && echo MDS started && return 1
790     lctl get_param -n devices
791     DEVS=$(lctl get_param -n devices | wc -l)
792     [ $DEVS -gt 0 ] && return 2
793     unload_modules || return 203
794 }
795 run_test 26 "MDT startup failure cleans LOV (should return errs)"
796
797 set_and_check() {
798         local myfacet=$1
799         local TEST=$2
800         local PARAM=$3
801         local ORIG=$(do_facet $myfacet "$TEST")
802         if [ $# -gt 3 ]; then
803             local FINAL=$4
804         else
805             local -i FINAL
806             FINAL=$(($ORIG + 5))
807         fi
808         echo "Setting $PARAM from $ORIG to $FINAL"
809         do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
810
811         wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
812 }
813
814 test_27a() {
815         start_ost || return 1
816         start_mds || return 2
817         echo "Requeue thread should have started: "
818         ps -e | grep ll_cfg_requeue
819         set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
820         cleanup_nocli
821 }
822 run_test 27a "Reacquire MGS lock if OST started first"
823
824 test_27b() {
825         # FIXME. ~grev
826         setup
827         local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
828
829         facet_failover $SINGLEMDS
830         set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
831         set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
832         check_mount
833         cleanup
834 }
835 run_test 27b "Reacquire MGS lock after failover"
836
837 test_28() {
838         setup
839         TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
840         PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
841         ORIG=$($TEST)
842         FINAL=$(($ORIG + 1))
843         set_and_check client "$TEST" "$PARAM" $FINAL || return 3
844         FINAL=$(($FINAL + 1))
845         set_and_check client "$TEST" "$PARAM" $FINAL || return 4
846         umount_client $MOUNT || return 200
847         mount_client $MOUNT
848         RESULT=$($TEST)
849         if [ $RESULT -ne $FINAL ]; then
850             echo "New config not seen: wanted $FINAL got $RESULT"
851             return 4
852         else
853             echo "New config success: got $RESULT"
854         fi
855         set_and_check client "$TEST" "$PARAM" $ORIG || return 5
856         cleanup
857 }
858 run_test 28 "permanent parameter setting"
859
860 test_29() {
861         [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
862         setup > /dev/null 2>&1
863         start_ost2
864         sleep 10
865
866         local PARAM="$FSNAME-OST0001.osc.active"
867         local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
868         local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
869
870         ACTV=$(lctl get_param -n $PROC_ACT)
871         DEAC=$((1 - $ACTV))
872         set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
873         # also check ost_server_uuid status
874         RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
875         if [ -z "$RESULT" ]; then
876             echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
877             return 3
878         else
879             echo "Live client success: got $RESULT"
880         fi
881
882         # check MDT too
883         local MPROC="osc.$FSNAME-OST0001-osc-[M]*.active"
884         local MAX=30
885         local WAIT=0
886         while [ 1 ]; do
887             sleep 5
888             RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
889             [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
890             if [ $RESULT -eq $DEAC ]; then
891                 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
892                 break
893             fi
894             WAIT=$((WAIT + 5))
895             if [ $WAIT -eq $MAX ]; then
896                 echo "MDT not deactivated: wanted $DEAC got $RESULT"
897                 return 4
898             fi
899             echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
900         done
901
902         # test new client starts deactivated
903         umount_client $MOUNT || return 200
904         mount_client $MOUNT
905         RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
906         if [ -z "$RESULT" ]; then
907             echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
908             return 5
909         else
910             echo "New client success: got $RESULT"
911         fi
912
913         # make sure it reactivates
914         set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
915
916         umount_client $MOUNT
917         stop_ost2
918         cleanup_nocli
919         #writeconf to remove all ost2 traces for subsequent tests
920         writeconf
921 }
922 run_test 29 "permanently remove an OST"
923
924 test_30() {
925         setup
926
927         TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
928         ORIG=$($TEST)
929         LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
930         for i in ${LIST[@]}; do
931             set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
932         done
933         # make sure client restart still works
934         umount_client $MOUNT
935         mount_client $MOUNT || return 4
936         [ "$($TEST)" -ne "$i" ] && return 5
937         set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
938         cleanup
939 }
940 run_test 30 "Big config llog"
941
942 test_31() { # bug 10734
943         # ipaddr must not exist
944         mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
945         cleanup
946 }
947 run_test 31 "Connect to non-existent node (shouldn't crash)"
948
949 # Use these start32/stop32 fn instead of t-f start/stop fn,
950 # for local devices, to skip global facet vars init
951 stop32 () {
952         local facet=$1
953         shift
954         echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
955         umount -d $@ ${MOUNT%/*}/${facet}
956         losetup -a
957 }
958
959 start32 () {
960         local facet=$1
961         shift
962         local device=$1
963         shift
964         mkdir -p ${MOUNT%/*}/${facet}
965
966         echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
967         mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
968         local RC=$?
969         if [ $RC -ne 0 ]; then
970                 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
971                 echo "Start of ${device} of local ${facet} failed ${RC}"
972         fi
973         losetup -a
974         return $RC
975 }
976
977 cleanup_nocli32 () {
978         stop32 mds1 -f
979         stop32 ost1 -f
980         wait_exit_ST client
981 }
982
983 cleanup_32() {
984         trap 0
985         echo "Cleanup test_32 umount $MOUNT ..."
986         umount -f $MOUNT || true
987         echo "Cleanup local mds ost1 ..."
988         cleanup_nocli32
989         unload_modules
990 }
991
992 test_32a() {
993         client_only && skip "client only testing" && return 0
994         [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
995         [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
996
997         local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
998         [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
999         local tmpdir=$TMP/conf32a
1000         mkdir -p $tmpdir
1001         tar xjvf $DISK1_8 -C $tmpdir || \
1002                 { skip_env "Cannot untar $DISK1_8" && return 0; }
1003
1004         load_modules
1005         $LCTL set_param debug=$PTLDEBUG
1006
1007         $TUNEFS $tmpdir/mds || error "tunefs failed"
1008
1009         # nids are wrong, so client wont work, but server should start
1010         start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1011                 trap cleanup_32 EXIT INT || return 3
1012
1013         local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1014         echo MDS uuid $UUID
1015         [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1016
1017         $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1018         start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1019         UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1020         echo OST uuid $UUID
1021         [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1022
1023         local NID=$($LCTL list_nids | head -1)
1024
1025         echo "OSC changes should succeed:"
1026         $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1027         $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1028         echo "ok."
1029
1030         echo "MDC changes should succeed:"
1031         $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1032         $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1033         echo "ok."
1034
1035         echo "LOV changes should succeed:"
1036         $LCTL pool_new lustre.interop || return 11
1037         $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1038         echo "ok."
1039
1040         cleanup_32
1041
1042         # mount a second time to make sure we didnt leave upgrade flag on
1043         load_modules
1044         $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1045         start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1046                 trap cleanup_32 EXIT INT || return 12
1047
1048         cleanup_32
1049
1050         rm -rf $tmpdir || true  # true is only for TMP on NFS
1051 }
1052 run_test 32a "Upgrade from 1.8 (not live)"
1053
1054 test_32b() {
1055         client_only && skip "client only testing" && return 0
1056         [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1057         [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1058
1059         local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1060         [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1061         local tmpdir=$TMP/conf32b
1062         mkdir -p $tmpdir
1063         tar xjvf $DISK1_8 -C $tmpdir || \
1064                 { skip_env "Cannot untar $DISK1_8" && return ; }
1065
1066         load_modules
1067         $LCTL set_param debug="config"
1068         local NEWNAME=lustre
1069
1070         # writeconf will cause servers to register with their current nids
1071         $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1072         start32 mds1 $tmpdir/mds "-o loop" && \
1073                 trap cleanup_32 EXIT INT || return 3
1074
1075         local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1076         echo MDS uuid $UUID
1077         [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1078
1079         $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 ||\
1080             error "tunefs failed"
1081         start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1082         UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1083         echo OST uuid $UUID
1084         [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1085
1086         local NID=$($LCTL list_nids | head -1)
1087
1088         echo "OSC changes should succeed:"
1089         $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1090         $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1091         echo "ok."
1092
1093         echo "MDC changes should succeed:"
1094         $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1095         $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1096         echo "ok."
1097
1098         echo "LOV changes should succeed:"
1099         $LCTL pool_new ${NEWNAME}.interop || return 11
1100         $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1101         echo "ok."
1102
1103         # MDT and OST should have registered with new nids, so we should have
1104         # a fully-functioning client
1105         echo "Check client and old fs contents"
1106
1107         local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1108         echo "Starting local client: $HOSTNAME: $device $MOUNT"
1109         mount -t lustre $device $MOUNT || return 1
1110
1111         local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1112         local new=$((old + 5))
1113         $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1114         wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1115
1116         [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1117         echo "ok."
1118
1119         cleanup_32
1120
1121         rm -rf $tmpdir || true  # true is only for TMP on NFS
1122 }
1123 run_test 32b "Upgrade from 1.8 with writeconf"
1124
1125 test_33a() { # bug 12333, was test_33
1126         local rc=0
1127         local FSNAME2=test-123
1128         [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1129
1130         if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1131                 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1132                 skip_env "mixed loopback and real device not working" && return
1133         fi
1134
1135         local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1136         local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1137         add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1138         add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1139
1140         start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1141         start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1142         do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1143         mkdir -p $MOUNT2
1144         mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1145         echo "ok."
1146
1147         cp /etc/hosts $MOUNT2/ || rc=3
1148         $LFS getstripe $MOUNT2/hosts
1149
1150         umount -d $MOUNT2
1151         stop fs2ost -f
1152         stop fs2mds -f
1153         rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1154         cleanup_nocli || rc=6
1155         return $rc
1156 }
1157 run_test 33a "Mount ost with a large index number"
1158
1159 test_33b() {    # was test_34
1160         setup
1161
1162         do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1163         # Drop lock cancelation reply during umount
1164         #define OBD_FAIL_LDLM_CANCEL             0x304
1165         do_facet client lctl set_param fail_loc=0x80000304
1166         #lctl set_param debug=-1
1167         umount_client $MOUNT
1168         cleanup
1169 }
1170 run_test 33b "Drop cancel during umount"
1171
1172 test_34a() {
1173         setup
1174         do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1175         manual_umount_client
1176         rc=$?
1177         do_facet client killall -USR1 multiop
1178         if [ $rc -eq 0 ]; then
1179                 error "umount not fail!"
1180         fi
1181         sleep 1
1182         cleanup
1183 }
1184 run_test 34a "umount with opened file should be fail"
1185
1186
1187 test_34b() {
1188         setup
1189         touch $DIR/$tfile || return 1
1190         stop_mds --force || return 2
1191
1192         manual_umount_client --force
1193         rc=$?
1194         if [ $rc -ne 0 ]; then
1195                 error "mtab after failed umount - rc $rc"
1196         fi
1197
1198         cleanup
1199         return 0
1200 }
1201 run_test 34b "force umount with failed mds should be normal"
1202
1203 test_34c() {
1204         setup
1205         touch $DIR/$tfile || return 1
1206         stop_ost --force || return 2
1207
1208         manual_umount_client --force
1209         rc=$?
1210         if [ $rc -ne 0 ]; then
1211                 error "mtab after failed umount - rc $rc"
1212         fi
1213
1214         cleanup
1215         return 0
1216 }
1217 run_test 34c "force umount with failed ost should be normal"
1218
1219 test_35a() { # bug 12459
1220         setup
1221
1222         DBG_SAVE="`lctl get_param -n debug`"
1223         lctl set_param debug="ha"
1224
1225         log "Set up a fake failnode for the MDS"
1226         FAKENID="127.0.0.2"
1227         local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1228         do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1229
1230         log "Wait for RECONNECT_INTERVAL seconds (10s)"
1231         sleep 10
1232
1233         MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1234         $LCTL clear
1235         log "$MSG"
1236         log "Stopping the MDT:"
1237         stop_mds || return 5
1238
1239         df $MOUNT > /dev/null 2>&1 &
1240         DFPID=$!
1241         log "Restarting the MDT:"
1242         start_mds || return 6
1243         log "Wait for df ($DFPID) ... "
1244         wait $DFPID
1245         log "done"
1246         lctl set_param debug="$DBG_SAVE"
1247
1248         # retrieve from the log the first server that the client tried to
1249         # contact after the connection loss
1250         $LCTL dk $TMP/lustre-log-$TESTNAME.log
1251         NEXTCONN=`awk "/${MSG}/ {start = 1;}
1252                        /import_select_connection.*$device-mdc.* using connection/ {
1253                                 if (start) {
1254                                         if (\\\$NF ~ /$FAKENID/)
1255                                                 print \\\$NF;
1256                                         else
1257                                                 print 0;
1258                                         exit;
1259                                 }
1260                        }" $TMP/lustre-log-$TESTNAME.log`
1261         [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1262         cleanup
1263 }
1264 run_test 35a "Reconnect to the last active server first"
1265
1266 test_35b() { # bug 18674
1267         remote_mds || { skip "local MDS" && return 0; }
1268         setup
1269
1270         debugsave
1271         $LCTL set_param debug="ha"
1272         $LCTL clear
1273         MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1274         log "$MSG"
1275
1276         log "Set up a fake failnode for the MDS"
1277         FAKENID="127.0.0.2"
1278         local device=$(do_facet mds "$LCTL get_param -n devices" | \
1279                         awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1280         do_facet mds "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1281                 return 1
1282
1283         local at_max_saved=0
1284         # adaptive timeouts may prevent seeing the issue 
1285         if at_is_enabled; then
1286                 at_max_saved=$(at_max_get mds)
1287                 at_max_set 0 mds client
1288         fi
1289
1290         mkdir -p $MOUNT/testdir
1291         touch $MOUNT/testdir/test
1292
1293         log "Injecting EBUSY on MDS"
1294         # Setting OBD_FAIL_MDS_RESEND=0x136
1295         do_facet mds "$LCTL set_param fail_loc=0x80000136" || return 2
1296
1297         log "Stat on a test file"
1298         stat $MOUNT/testdir/test
1299
1300         log "Stop injecting EBUSY on MDS"
1301         do_facet mds "$LCTL set_param fail_loc=0" || return 3
1302         rm -f $MOUNT/testdir/test
1303
1304         log "done"
1305         # restore adaptive timeout
1306         [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1307
1308         $LCTL dk $TMP/lustre-log-$TESTNAME.log
1309
1310         # retrieve from the log if the client has ever tried to
1311         # contact the fake server after the loss of connection
1312         FAILCONN=`awk "BEGIN {ret = 0;}
1313                        /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1314                                 ret = 1;
1315                                 if (\\\$NF ~ /$FAKENID/) {
1316                                         ret = 2;
1317                                         exit;
1318                                 }
1319                        }
1320                        END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1321
1322         [ "$FAILCONN" == "0" ] && \
1323                 log "ERROR: The client reconnection has not been triggered" && \
1324                 return 4
1325         [ "$FAILCONN" == "2" ] && \
1326                 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1327                 return 5
1328
1329         cleanup
1330 }
1331 run_test 35b "Continue reconnection retries, if the active server is busy"
1332
1333 test_36() { # 12743
1334         local rc
1335         local FSNAME2=test1234
1336         local fs3ost_HOST=$ost_HOST
1337
1338         [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1339         rc=0
1340
1341         if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1342                 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1343                 skip_env "mixed loopback and real device not working" && return
1344         fi
1345         [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1346
1347         [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1348                 { skip "remote OST" && return 0; }
1349
1350         local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1351         local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1352         local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1353         add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1354         # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1355         # other argument
1356         add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1357         add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1358
1359         start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1360         start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1361         start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1362         mkdir -p $MOUNT2
1363         mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1364
1365         sleep 5 # until 11778 fixed
1366
1367         dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1368
1369         BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1370         BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1371         BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1372         STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1373         DFTOTAL=`echo $STRING | cut -d, -f1`
1374         DFUSED=`echo $STRING  | cut -d, -f2`
1375         DFAVAIL=`echo $STRING | cut -d, -f3`
1376         DFFREE=$(($DFTOTAL - $DFUSED))
1377
1378         ALLOWANCE=$((64 * $OSTCOUNT))
1379
1380         if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1381            [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1382                 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1383                 rc=1
1384         fi
1385         if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1386            [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1387                 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1388                 rc=2
1389         fi
1390         if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1391            [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1392                 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1393                 rc=3
1394        fi
1395
1396         umount -d $MOUNT2
1397         stop fs3ost -f || return 200
1398         stop fs2ost -f || return 201
1399         stop fs2mds -f || return 202
1400         rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1401         unload_modules || return 203
1402         return $rc
1403 }
1404 run_test 36 "df report consistency on OSTs with different block size"
1405
1406 test_37() {
1407         client_only && skip "client only testing" && return 0
1408         LOCAL_MDSDEV="$TMP/mdt.img"
1409         SYM_MDSDEV="$TMP/sym_mdt.img"
1410
1411         echo "MDS :     $LOCAL_MDSDEV"
1412         echo "SYMLINK : $SYM_MDSDEV"
1413         rm -f $LOCAL_MDSDEV
1414
1415         touch $LOCAL_MDSDEV
1416         mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1417                 error "mkfs.lustre $LOCAL_MDSDEV failed"
1418         ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1419
1420         echo "mount symlink device - $SYM_MDSDEV"
1421
1422         mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1423         umount -d ${MOUNT%/*}/mds
1424         rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1425
1426         if [ -n "$mount_op" ]; then
1427                 error "**** FAIL: set tunables failed for symlink device"
1428         fi
1429         return 0
1430 }
1431 run_test 37 "verify set tunables works for symlink device"
1432
1433 test_38() { # bug 14222
1434         setup
1435         # like runtests
1436         COUNT=10
1437         SRC="/etc /bin"
1438         FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1439         log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1440         mkdir -p $DIR/$tdir
1441         tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1442                 error "copying $SRC to $DIR/$tdir"
1443         sync
1444         umount_client $MOUNT
1445         stop_mds
1446         log "rename lov_objid file on MDS"
1447         rm -f $TMP/lov_objid.orig
1448
1449         local dev=${SINGLEMDS}_dev
1450         local MDSDEV=${!dev}
1451         do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1452         do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1453
1454         do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1455         # check create in mds_lov_connect
1456         start_mds
1457         mount_client $MOUNT
1458         for f in $FILES; do
1459                 [ $V ] && log "verifying $DIR/$tdir/$f"
1460                 diff -q $f $DIR/$tdir/$f || ERROR=y
1461         done
1462         do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\"  $MDSDEV"
1463         do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1464         [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1465
1466         # check it's updates in sync
1467         umount_client $MOUNT
1468         stop_mds
1469
1470         do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1471         do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1472         do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1473
1474         start_mds
1475         mount_client $MOUNT
1476         for f in $FILES; do
1477                 [ $V ] && log "verifying $DIR/$tdir/$f"
1478                 diff -q $f $DIR/$tdir/$f || ERROR=y
1479         done
1480         do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1481         do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1482         umount_client $MOUNT
1483         stop_mds
1484         [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1485
1486         log "files compared the same"
1487         cleanup
1488 }
1489 run_test 38 "MDS recreates missing lov_objid file from OST data"
1490
1491 test_39() {
1492         PTLDEBUG=+malloc
1493         setup
1494         cleanup
1495         perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1496                 error "memory leak detected" || true
1497 }
1498 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1499
1500 test_40() { # bug 15759
1501         start_ost
1502         #define OBD_FAIL_TGT_TOOMANY_THREADS     0x706
1503         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1504         start_mds
1505         cleanup
1506 }
1507 run_test 40 "race during service thread startup"
1508
1509 test_41() { #bug 14134
1510         local rc
1511         local dev=${SINGLEMDS}_dev
1512         local MDSDEV=${!dev}
1513
1514         start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1515         start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1516         start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1517         mkdir -p $MOUNT
1518         mount_client $MOUNT || return 1
1519         sleep 5
1520
1521         echo "blah blah" > $MOUNT/$tfile
1522         cat $MOUNT/$tfile
1523
1524         umount_client $MOUNT
1525         stop ost1 -f || return 201
1526         stop_mds -f || return 202
1527         stop_mds -f || return 203
1528         unload_modules || return 204
1529         return $rc
1530 }
1531 run_test 41 "mount mds with --nosvc and --nomgs"
1532
1533 test_42() { #bug 14693
1534         setup
1535         check_mount || return 2
1536         do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1537         umount_client $MOUNT
1538         mount_client $MOUNT || return 1
1539         cleanup
1540         return 0
1541 }
1542 run_test 42 "invalid config param should not prevent client from mounting"
1543
1544 test_43() {
1545     [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1546     setup
1547     chmod ugo+x $DIR || error "chmod 0 failed"
1548     set_and_check mds                                        \
1549         "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash"  \
1550         "$FSNAME.mdt.root_squash"                            \
1551         "0:0"
1552     set_and_check mds                                        \
1553        "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1554        "$FSNAME.mdt.nosquash_nids"                           \
1555        "NONE"
1556
1557     #
1558     # create set of test files
1559     #
1560     echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1561     chmod go-rw $DIR/$tfile-userfile  || error "chmod 1 failed"
1562     chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1563
1564     echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1565     chmod go-rw $DIR/$tfile-rootfile  || error "chmod 2 faield"
1566
1567     mkdir $DIR/$tdir-rootdir -p       || error "mkdir failed"
1568     chmod go-rwx $DIR/$tdir-rootdir   || error "chmod 3 failed"
1569     touch $DIR/$tdir-rootdir/tfile-1  || error "touch failed"
1570
1571     #
1572     # check root_squash:
1573     #   set root squash UID:GID to RUNAS_ID
1574     #   root should be able to access only files owned by RUNAS_ID
1575     #
1576     set_and_check mds                                        \
1577        "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash"   \
1578        "$FSNAME.mdt.root_squash"                             \
1579        "$RUNAS_ID:$RUNAS_ID"
1580
1581     ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1582     dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1583         error "$ST: root read permission is denied"
1584     echo "$ST: root read permission is granted - ok"
1585
1586     echo "444" | \
1587     dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1588         error "$ST: root write permission is denied"
1589     echo "$ST: root write permission is granted - ok"
1590
1591     ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1592     dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1593         error "$ST: root read permission is granted"
1594     echo "$ST: root read permission is denied - ok"
1595
1596     echo "555" | \
1597     dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1598         error "$ST: root write permission is granted"
1599     echo "$ST: root write permission is denied - ok"
1600
1601     ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1602     rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1603         error "$ST: root unlink permission is granted"
1604     echo "$ST: root unlink permission is denied - ok"
1605
1606     touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1607         error "$ST: root create permission is granted"
1608     echo "$ST: root create permission is denied - ok"
1609
1610     #
1611     # check nosquash_nids:
1612     #   put client's NID into nosquash_nids list,
1613     #   root should be able to access root file after that
1614     #
1615     local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1616     NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1617     NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1618     set_and_check mds                                        \
1619        "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1620        "$FSNAME-MDTall.mdt.nosquash_nids"                    \
1621        "$NIDLIST"
1622
1623     ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1624     dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1625         error "$ST: root read permission is denied"
1626     echo "$ST: root read permission is granted - ok"
1627
1628     echo "666" | \
1629     dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1630         error "$ST: root write permission is denied"
1631     echo "$ST: root write permission is granted - ok"
1632
1633     ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1634     rm $DIR/$tdir-rootdir/tfile-1 || \
1635         error "$ST: root unlink permission is denied"
1636     echo "$ST: root unlink permission is granted - ok"
1637     touch $DIR/$tdir-rootdir/tfile-2 || \
1638         error "$ST: root create permission is denied"
1639     echo "$ST: root create permission is granted - ok"
1640
1641     return 0
1642 }
1643 run_test 43 "check root_squash and nosquash_nids"
1644
1645 umount_client $MOUNT
1646 cleanup_nocli
1647
1648 test_44() { # 16317
1649         setup
1650         check_mount || return 2
1651         UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1652         STATS_FOUND=no
1653         UUIDS=$(do_facet mds "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1654         for VAL in $UUIDS; do
1655                 NID=$(echo $VAL | cut -d= -f1)
1656                 CLUUID=$(echo $VAL | cut -d= -f2)
1657                 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1658         done
1659         [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1660         cleanup
1661         return 0
1662 }
1663 run_test 44 "mounted client proc entry exists"
1664
1665 test_45() { #17310
1666         setup
1667         check_mount || return 2
1668         stop_mds
1669         df -h $MOUNT &
1670         log "sleep 60 sec"
1671         sleep 60
1672 #define OBD_FAIL_PTLRPC_LONG_UNLINK   0x50f
1673         do_facet client "lctl set_param fail_loc=0x50f"
1674         log "sleep 10 sec"
1675         sleep 10
1676         manual_umount_client --force || return 3
1677         do_facet client "lctl set_param fail_loc=0x0"
1678         start_mds
1679         mount_client $MOUNT || return 4
1680         cleanup
1681         return 0
1682 }
1683 run_test 45 "long unlink handling in ptlrpcd"
1684
1685 cleanup_46a() {
1686         trap 0
1687         local rc=0
1688         local count=$1
1689
1690         umount_client $MOUNT2 || rc=$?
1691         umount_client $MOUNT || rc=$?
1692         while [ $count -gt 0 ]; do
1693                 stop ost${count} -f || rc=$?
1694                 let count=count-1
1695         done    
1696         stop_mds || rc=$? 
1697         # writeconf is needed after the test, otherwise,
1698         # we might end up with extra OSTs
1699         writeconf || rc=$?
1700         cleanup_nocli || rc=$?
1701         return $rc
1702 }
1703
1704 test_46a() {
1705         echo "Testing with $OSTCOUNT OSTs"
1706         reformat_and_config
1707         start_mds || return 1
1708         #first client should see only one ost
1709         start_ost || return 2
1710         wait_osc_import_state mds ost FULL
1711         #start_client
1712         mount_client $MOUNT || return 3
1713         trap "cleanup_46a $OSTCOUNT" EXIT ERR
1714
1715         local i 
1716         for (( i=2; i<=$OSTCOUNT; i++ )); do
1717             start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1718         done
1719
1720         # wait until osts in sync
1721         for (( i=2; i<=$OSTCOUNT; i++ )); do
1722             wait_osc_import_state mds ost$i FULL
1723         done
1724
1725
1726         #second client see all ost's
1727
1728         mount_client $MOUNT2 || return 8
1729         $LFS setstripe $MOUNT2 -c -1 || return 9
1730         $LFS getstripe $MOUNT2 || return 10
1731
1732         echo "ok" > $MOUNT2/widestripe
1733         $LFS getstripe $MOUNT2/widestripe || return 11
1734         # fill acl buffer for avoid expand lsm to them
1735         awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1736             setfacl -m $acl $MOUNT2/widestripe
1737         done
1738
1739         # will be deadlock
1740         stat $MOUNT/widestripe || return 12
1741
1742         cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1743         return 0
1744 }
1745 run_test 46a "handle ost additional - wide striped file"
1746
1747 test_47() { #17674
1748         reformat
1749         setup_noconfig
1750         check_mount || return 2
1751         $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1752
1753         local lru_size=[]
1754         local count=0
1755         for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1756             if echo $ns | grep "MDT[[:digit:]]*"; then
1757                 continue
1758             fi
1759             lrs=$(echo $ns | sed 's/.*lru_size=//')
1760             lru_size[count]=$lrs
1761             let count=count+1
1762         done
1763
1764         facet_failover ost1
1765         facet_failover $SINGLEMDS
1766         client_up || return 3
1767
1768         count=0
1769         for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1770             if echo $ns | grep "MDT[[:digit:]]*"; then
1771                 continue
1772             fi
1773             lrs=$(echo $ns | sed 's/.*lru_size=//')
1774             if ! test "$lrs" -eq "${lru_size[count]}"; then
1775                 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1776                 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1777             fi
1778             let count=count+1
1779         done
1780
1781         cleanup
1782         return 0
1783 }
1784 run_test 47 "server restart does not make client loss lru_resize settings"
1785
1786 cleanup_48() {
1787         trap 0
1788
1789         # reformat after this test is needed - if test will failed
1790         # we will have unkillable file at FS
1791         reformat_and_config
1792 }
1793
1794 test_48() { # bug 17636
1795         reformat
1796         setup_noconfig
1797         check_mount || return 2
1798
1799         $LFS setstripe $MOUNT -c -1 || return 9
1800         $LFS getstripe $MOUNT || return 10
1801
1802         echo "ok" > $MOUNT/widestripe
1803         $LFS getstripe $MOUNT/widestripe || return 11
1804
1805         trap cleanup_48 EXIT ERR
1806
1807         # fill acl buffer for avoid expand lsm to them
1808         getent passwd | awk -F : '{ print "u:"$1":rwx" }' |  while read acl; do
1809             setfacl -m $acl $MOUNT/widestripe
1810         done
1811
1812         stat $MOUNT/widestripe || return 12
1813
1814         cleanup_48
1815         return 0
1816 }
1817 run_test 48 "too many acls on file"
1818
1819 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1820 test_49() { # bug 17710
1821         local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1822         local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1823         local LOCAL_TIMEOUT=20
1824
1825
1826         OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1827
1828         reformat
1829         setup_noconfig
1830         check_mount || return 1
1831
1832         echo "check ldlm_timout..."
1833         LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1834         LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1835         LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1836
1837         if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1838                 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1839         fi
1840
1841         if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1842                 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1843         fi
1844
1845         umount_client $MOUNT
1846         stop_ost || return 2
1847         stop_mds || return 3
1848
1849         OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$((LOCAL_TIMEOUT - 1)) $MKFSOPT $OSTOPT"
1850
1851         reformat
1852         setup_noconfig
1853         check_mount || return 7
1854
1855         LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1856         LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1857         LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1858
1859         if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1860                 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1861         fi
1862
1863         if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1864                 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1865         fi
1866
1867         cleanup || return $?
1868
1869         MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1870         OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1871 }
1872 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1873
1874 lazystatfs() {
1875         # Test both statfs and lfs df and fail if either one fails
1876         multiop_bg_pause $1 f_
1877         RC1=$?
1878         PID=$!
1879         killall -USR1 multiop
1880         [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
1881         wait $PID || { RC1=$?; log "multiop return error "; }
1882
1883         $LFS df &
1884         PID=$!
1885         sleep 5
1886         kill -s 0 $PID
1887         RC2=$?
1888         if [ $RC2 -eq 0 ]; then
1889             kill -s 9 $PID
1890             log "lazystatfs df failed"
1891         fi
1892
1893         RC=0
1894         [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
1895         return $RC
1896 }
1897
1898 test_50a() {
1899         setup
1900         lctl set_param llite.$FSNAME-*.lazystatfs=1
1901         touch $DIR/$tfile
1902
1903         lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
1904
1905         cleanup || return $?
1906 }
1907 run_test 50a "lazystatfs all servers available =========================="
1908
1909 test_50b() {
1910         setup
1911         lctl set_param llite.$FSNAME-*.lazystatfs=1
1912         touch $DIR/$tfile
1913
1914         # Wait for client to detect down OST
1915         stop_ost || error "Unable to stop OST1"
1916         wait_osc_import_state mds ost DISCONN
1917
1918         lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
1919
1920         umount_client $MOUNT || error "Unable to unmount client"
1921         stop_mds || error "Unable to stop MDS"
1922 }
1923 run_test 50b "lazystatfs all servers down =========================="
1924
1925 test_50c() {
1926         start_mds || error "Unable to start MDS"
1927         start_ost || error "Unable to start OST1"
1928         start_ost2 || error "Unable to start OST2"
1929         mount_client $MOUNT || error "Unable to mount client"
1930         lctl set_param llite.$FSNAME-*.lazystatfs=1
1931         touch $DIR/$tfile
1932
1933         # Wait for client to detect down OST
1934         stop_ost || error "Unable to stop OST1"
1935         wait_osc_import_state mds ost DISCONN
1936         lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1937
1938         umount_client $MOUNT || error "Unable to unmount client"
1939         stop_ost2 || error "Unable to stop OST2"
1940         stop_mds || error "Unable to stop MDS"
1941 }
1942 run_test 50c "lazystatfs one server down =========================="
1943
1944 test_50d() {
1945         start_mds || error "Unable to start MDS"
1946         start_ost || error "Unable to start OST1"
1947         start_ost2 || error "Unable to start OST2"
1948         mount_client $MOUNT || error "Unable to mount client"
1949         lctl set_param llite.$FSNAME-*.lazystatfs=1
1950         touch $DIR/$tfile
1951
1952         # Issue the statfs during the window where the client still
1953         # belives the OST to be available but it is in fact down.
1954         # No failure just a statfs which hangs for a timeout interval.
1955         stop_ost || error "Unable to stop OST1"
1956         lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1957
1958         umount_client $MOUNT || error "Unable to unmount client"
1959         stop_ost2 || error "Unable to stop OST2"
1960         stop_mds || error "Unable to stop MDS"
1961 }
1962 run_test 50d "lazystatfs client/server conn race =========================="
1963
1964 test_50e() {
1965         local RC1
1966         local pid
1967
1968         reformat_and_config
1969         start_mds || return 1
1970         #first client should see only one ost
1971         start_ost || return 2
1972         wait_osc_import_state mds ost FULL
1973
1974         # Wait for client to detect down OST
1975         stop_ost || error "Unable to stop OST1"
1976         wait_osc_import_state mds ost DISCONN
1977
1978         mount_client $MOUNT || error "Unable to mount client"
1979         lctl set_param llite.$FSNAME-*.lazystatfs=0
1980
1981         multiop_bg_pause $MOUNT _f
1982         RC1=$?
1983         pid=$!
1984
1985         if [ $RC1 -ne 0 ]; then
1986                 log "multiop failed $RC1"
1987         else
1988             kill -USR1 $pid
1989             sleep $(( $TIMEOUT+1 ))
1990             kill -0 $pid
1991             [ $? -ne 0 ] && error "process isn't sleep"
1992             start_ost || error "Unable to start OST1"
1993             wait $pid || error "statfs failed"
1994         fi
1995
1996         umount_client $MOUNT || error "Unable to unmount client"
1997         stop_ost || error "Unable to stop OST1"
1998         stop_mds || error "Unable to stop MDS"
1999 }
2000 run_test 50e "normal statfs all servers down =========================="
2001
2002 test_50f() {
2003         local RC1
2004         local pid
2005         CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2006
2007         start_mds || error "Unable to start mds"
2008         #first client should see only one ost
2009         start_ost || error "Unable to start OST1"
2010         wait_osc_import_state mds ost FULL
2011
2012         start_ost2 || error "Unable to start OST2"
2013         wait_osc_import_state mds ost2 FULL
2014
2015         # Wait for client to detect down OST
2016         stop_ost2 || error "Unable to stop OST2"
2017
2018         wait_osc_import_state mds ost2 DISCONN
2019         mount_client $MOUNT || error "Unable to mount client"
2020         lctl set_param llite.$FSNAME-*.lazystatfs=0
2021
2022         multiop_bg_pause $MOUNT _f
2023         RC1=$?
2024         pid=$!
2025
2026         if [ $RC1 -ne 0 ]; then
2027                 log "lazystatfs multiop failed $RC1"
2028         else
2029             kill -USR1 $pid
2030             sleep $(( $TIMEOUT+1 ))
2031             kill -0 $pid
2032             [ $? -ne 0 ] && error "process isn't sleep"
2033             start_ost2 || error "Unable to start OST2"
2034             wait $pid || error "statfs failed"
2035             stop_ost2 || error "Unable to stop OST2"
2036         fi
2037
2038         umount_client $MOUNT || error "Unable to unmount client"
2039         stop_ost || error "Unable to stop OST1"
2040         stop_mds || error "Unable to stop MDS"
2041         writeconf
2042 }
2043 run_test 50f "normal statfs one server in down =========================="
2044
2045 test_50g() {
2046         [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2047         setup
2048         start_ost2 || error "Unable to start OST2"
2049
2050         local PARAM="${FSNAME}-OST0001.osc.active"
2051
2052         $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2053         do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2054
2055         umount_client $MOUNT || error "Unable to unmount client"
2056         mount_client $MOUNT || error "Unable to mount client"
2057         # This df should not cause a panic
2058         df -k $MOUNT
2059
2060         do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2061         rm -f $DIR/$tfile
2062         umount_client $MOUNT || error "Unable to unmount client"
2063         stop_ost2 || error "Unable to stop OST2"
2064         stop_ost || error "Unable to stop OST1"
2065         stop_mds || error "Unable to stop MDS"
2066         writeconf
2067 }
2068 run_test 50g "deactivated OST should not cause panic====================="
2069
2070 test_51() {
2071         local LOCAL_TIMEOUT=20
2072
2073         reformat
2074         setup_noconfig
2075         check_mount || return 1
2076
2077         mkdir $MOUNT/d1
2078         $LFS setstripe -c -1 $MOUNT/d1
2079         #define OBD_FAIL_MDS_REINT_DELAY         0x142
2080         do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2081         touch $MOUNT/d1/f1 &
2082         local pid=$!
2083         sleep 2
2084         start_ost2 || return 2
2085         wait $pid
2086         stop_ost2 || return 3
2087         cleanup
2088 }
2089 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2090
2091 copy_files_xattrs()
2092 {
2093         local node=$1
2094         local dest=$2
2095         local xattrs=$3
2096         shift 3
2097
2098         do_node $node mkdir -p $dest
2099         [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2100
2101         do_node $node  'tar cf - '$@' | tar xf - -C '$dest';
2102                         [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2103         [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2104
2105         do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2106         [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2107 }
2108
2109 diff_files_xattrs()
2110 {
2111         local node=$1
2112         local backup=$2
2113         local xattrs=$3
2114         shift 3
2115
2116         local backup2=${TMP}/backup2
2117
2118         do_node $node mkdir -p $backup2
2119         [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2120
2121         do_node $node  'tar cf - '$@' | tar xf - -C '$backup2';
2122                         [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2123         [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2124
2125         do_node $node "diff -rq $backup $backup2"
2126         [ $? -eq 0 ] || { error "contents differ"; return 3; }
2127
2128         local xattrs2=${TMP}/xattrs2
2129         do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2130         [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2131
2132         do_node $node "diff $xattrs $xattrs2"
2133         [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2134
2135         do_node $node "rm -rf $backup2 $xattrs2"
2136         [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2137 }
2138
2139 test_52() {
2140         start_mds
2141         [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2142         start_ost
2143         [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2144         mount_client $MOUNT
2145         [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2146
2147         local nrfiles=8
2148         local ost1mnt=${MOUNT%/*}/ost1
2149         local ost1node=$(facet_active_host ost1)
2150         local ost1tmp=$TMP/conf52
2151
2152         mkdir -p $DIR/$tdir
2153         [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2154         touch $TMP/modified_first
2155         [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2156         do_node $ost1node "mkdir -p $ost1tmp && touch $ost1tmp/modified_first"
2157         [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2158         sleep 1
2159
2160         $LFS setstripe $DIR/$tdir -c -1 -s 1M
2161         [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2162
2163         for (( i=0; i < nrfiles; i++ )); do
2164                 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2165                 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2166                 echo -n .
2167         done
2168         echo
2169
2170         # backup files
2171         echo backup files to $TMP/files
2172         local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2173         copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2174         [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2175
2176         umount_client $MOUNT
2177         [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2178         stop_ost
2179         [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2180
2181         echo mount ost1 as ldiskfs
2182         do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2183         [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2184
2185         # backup objects
2186         echo backup objects to $ost1tmp/objects
2187         local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2188                         '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2189         copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2190         [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2191
2192         # move objects to lost+found
2193         do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2194         [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2195
2196         # recover objects
2197         do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2198         [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2199
2200         # compare restored objects against saved ones
2201         diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2202         [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2203
2204         do_node $ost1node "umount $ost1_dev"
2205         [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2206
2207         start_ost
2208         [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2209         mount_client $MOUNT
2210         [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2211
2212         # compare files
2213         diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2214         [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2215
2216         rm -rf $TMP/files $TMP/file_xattrs
2217         [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2218         do_node $ost1node "rm -rf $ost1tmp"
2219         [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2220         cleanup
2221 }
2222 run_test 52 "check recovering objects from lost+found"
2223
2224 # Checks threads_min/max/started for some service
2225 #
2226 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2227 # parameter pattern prefix like 'ost.*.ost'.
2228 thread_sanity() {
2229         local modname=$1
2230         local facet=$2
2231         local parampat=$3
2232         local opts=$4
2233         local tmin
2234         local tmin2
2235         local tmax
2236         local tmax2
2237         local tstarted
2238         local paramp
2239         local msg="Insane $modname thread counts"
2240         shift 4
2241
2242         setup
2243         check_mount || return 41
2244
2245         # We need to expand $parampat, but it may match multiple parameters, so
2246         # we'll pick the first one
2247         if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2248                 error "Couldn't expand ${parampat}.threads_min parameter name"
2249                 return 22
2250         fi
2251
2252         # Remove the .threads_min part
2253         paramp=${paramp%.threads_min}
2254
2255         # Check for sanity in defaults
2256         tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2257         tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2258         tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2259         lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2260         lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= tmax ))' || return $?
2261
2262         # Check that we can lower min/max
2263         do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin - 1))"
2264         do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 10))"
2265         tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2266         tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2267         lassert 25 "$msg" '(($tmin2 == ($tmin - 1) && $tmax2 == ($tmax -10)))' || return $?
2268
2269         # Check that we can set min/max to the same value
2270         do_facet $facet "lctl set_param ${paramp}.threads_min=$tmin"
2271         do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2272         tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2273         tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2274         lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2275
2276         # Check that we can't set max < min
2277         do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2278         tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2279         tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2280         lassert 27 "$msg" '(($tmin <= $tmax2))' || return $?
2281
2282         # We need to ensure that we get the module options desired; to do this
2283         # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2284         LOAD_MODULES_REMOTE=true
2285         cleanup
2286         local oldvalue
2287         setmodopts -a $modname "$opts" oldvalue
2288
2289         load_modules
2290         setup
2291         check_mount || return 41
2292
2293         # Restore previous setting of MODOPTS_*
2294         setmodopts $modname "$oldvalue"
2295
2296         # Check that $opts took
2297         tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2298         tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2299         tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2300         lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2301         cleanup
2302
2303         # Workaround a YALA bug where YALA expects that modules will remain
2304         # loaded on the servers
2305         LOAD_MODULES_REMOTE=false
2306         setup
2307         cleanup
2308 }
2309
2310 test_53a() {
2311         thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2312 }
2313 run_test 53a "check OSS thread count params"
2314
2315 test_53b() {
2316         thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2317 }
2318 run_test 53b "check MDT thread count params"
2319
2320 if ! combined_mgs_mds ; then
2321         stop mgs
2322 fi
2323
2324 run_llverfs()
2325 {
2326         local dir=$1
2327         local partial_arg=""
2328         local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
2329
2330         # Run in partial (fast) mode if the size
2331         # of a partition > 10 GB
2332         [ $size -gt 10 ] && partial_arg="-p"
2333
2334         llverfs $partial_arg $dir
2335 }
2336
2337 test_54a() {
2338     do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
2339     [ $? -eq 0 ] || error "llverdev failed!"
2340     reformat_and_config
2341 }
2342 run_test 54a "llverdev"
2343
2344 test_54b() {
2345     setup
2346     run_llverfs $MOUNT
2347     [ $? -eq 0 ] || error "llverfs failed!"
2348     cleanup
2349 }
2350 run_test 54b "llverfs"
2351
2352 cleanup_gss
2353 equals_msg `basename $0`: test complete
2354 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true