Whamcloud - gitweb
- mark 45 HEAD_EXCEPT as it fails in HEAD (failure is not related to 17310 where...
[fs/lustre-release.git] / lustre / tests / conf-sanity.sh
1 #!/bin/bash
2 # requirement:
3 #       add uml1 uml2 uml3 in your /etc/hosts
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: 13739   17617
15 HEAD_EXCEPT="                  32a 32b 45"
16
17 # bug number for skipped test:                                 
18 ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT $HEAD_EXCEPT"
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
20
21 SRCDIR=`dirname $0`
22 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
23
24 PTLDEBUG=${PTLDEBUG:--1}
25 SAVE_PWD=$PWD
26 LUSTRE=${LUSTRE:-`dirname $0`/..}
27 RLUSTRE=${RLUSTRE:-$LUSTRE}
28
29 . $LUSTRE/tests/test-framework.sh
30 init_test_env $@
31 # STORED_MDSSIZE is used in test_18
32 if [ -n "$MDSSIZE" ]; then
33     STORED_MDSSIZE=$MDSSIZE
34 fi
35 # use small MDS + OST size to speed formatting time
36 MDSSIZE=40000
37 OSTSIZE=40000
38 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
39
40 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
41 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
42
43 #
44 [ "$SLOW" = "no" ] && EXCEPT_SLOW="0 1 2 3 6 7 15 18 24b 25 30 31 32 33 34a 45"
45
46 assert_DIR
47
48 reformat() {
49         formatall
50 }
51
52 writeconf() {
53     local facet=$SINGLEMDS
54     local dev=${facet}_dev
55     shift
56     stop ${facet} -f
57     rm -f ${facet}active
58     # who knows if/where $TUNEFS is installed?  Better reformat if it fails...
59     do_facet ${facet} "$TUNEFS --writeconf ${!dev}" || echo "tunefs failed, reformatting instead" && reformat
60 }
61
62 gen_config() {
63         reformat
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         sleep 5
69         stop_ost
70         stop_mds
71 }
72
73 start_mds() {
74         local facet=$SINGLEMDS
75         # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
76         local num=$(echo $facet | tr -d "mds")
77         local dev=$(mdsdevname $num)
78         echo "start mds service on `facet_active_host $facet`"
79         start $facet ${dev} $MDS_MOUNT_OPTS || return 94
80 }
81
82 stop_mds() {
83         echo "stop mds service on `facet_active_host $SINGLEMDS`"
84         # These tests all use non-failover stop
85         stop $SINGLEMDS -f  || return 97
86 }
87
88 start_ost() {
89         echo "start ost1 service on `facet_active_host ost1`"
90         start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95
91 }
92
93 stop_ost() {
94         echo "stop ost1 service on `facet_active_host ost1`"
95         # These tests all use non-failover stop
96         stop ost1 -f  || return 98
97 }
98
99 start_ost2() {
100         echo "start ost2 service on `facet_active_host ost2`"
101         start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92
102 }
103
104 stop_ost2() {
105         echo "stop ost2 service on `facet_active_host ost2`"
106         # These tests all use non-failover stop
107         stop ost2 -f  || return 93
108 }
109
110 mount_client() {
111         local MOUNTPATH=$1
112         echo "mount $FSNAME on ${MOUNTPATH}....."
113         zconf_mount `hostname` $MOUNTPATH  || return 96
114 }
115
116 remount_client() {
117         local SAVEMOUNTOPT=$MOUNTOPT
118         MOUNTOPT="remount,$1"
119         local MOUNTPATH=$2
120         echo "remount '$1' lustre on ${MOUNTPATH}....."
121         zconf_mount `hostname`  $MOUNTPATH  || return 96
122         MOUNTOPT=$SAVEMOUNTOPT
123 }
124
125 umount_client() {
126         local MOUNTPATH=$1
127         echo "umount lustre on ${MOUNTPATH}....."
128         zconf_umount `hostname` $MOUNTPATH || return 97
129 }
130
131 manual_umount_client(){
132         echo "manual umount lustre on ${MOUNT}...."
133         do_facet client "umount -d $MOUNT"
134 }
135
136 setup() {
137         start_ost
138         start_mds
139         mount_client $MOUNT
140 }
141
142 cleanup_nocli() {
143         stop_mds || return 201
144         stop_ost || return 202
145         unload_modules || return 203
146 }
147
148 cleanup() {
149         umount_client $MOUNT || return 200
150         cleanup_nocli || return $?
151 }
152
153 check_mount() {
154         do_facet client "cp /etc/passwd $DIR/a" || return 71
155         do_facet client "rm $DIR/a" || return 72
156         # make sure lustre is actually mounted (touch will block, 
157         # but grep won't, so do it after) 
158         do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
159         echo "setup single mount lustre success"
160 }
161
162 check_mount2() {
163         do_facet client "touch $DIR/a" || return 71     
164         do_facet client "rm $DIR/a" || return 72        
165         do_facet client "touch $DIR2/a" || return 73    
166         do_facet client "rm $DIR2/a" || return 74       
167         echo "setup double mount lustre success"
168 }
169
170 build_test_filter
171
172 if [ "$ONLY" == "setup" ]; then
173         setup
174         exit
175 fi
176
177 if [ "$ONLY" == "cleanup" ]; then
178         cleanup
179         exit
180 fi
181
182 #create single point mountpoint
183
184 gen_config
185
186 init_gss
187
188 test_0() {
189         setup
190         check_mount || return 41
191         cleanup || return $?
192 }
193 run_test 0 "single mount setup"
194
195 test_1() {
196         start_ost
197         echo "start ost second time..."
198         setup
199         check_mount || return 42
200         cleanup || return $?
201 }
202 run_test 1 "start up ost twice (should return errors)"
203
204 test_2() {
205         start_ost
206         start_mds
207         echo "start mds second time.."
208         start_mds
209         mount_client $MOUNT
210         check_mount || return 43
211         cleanup || return $?
212 }
213 run_test 2 "start up mds twice (should return err)"
214
215 test_3() {
216         setup
217         #mount.lustre returns an error if already in mtab
218         mount_client $MOUNT && return $?
219         check_mount || return 44
220         cleanup || return $?
221 }
222 run_test 3 "mount client twice (should return err)"
223
224 test_4() {
225         setup
226         touch $DIR/$tfile || return 85
227         stop_ost -f
228         cleanup
229         eno=$?
230         # ok for ost to fail shutdown
231         if [ 202 -ne $eno ]; then
232                 return $eno;
233         fi
234         return 0
235 }
236 run_test 4 "force cleanup ost, then cleanup"
237
238 test_5a() {     # was test_5
239         setup
240         touch $DIR/$tfile || return 1
241         fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
242
243         stop_mds -f || return 2
244
245         # cleanup may return an error from the failed
246         # disconnects; for now I'll consider this successful
247         # if all the modules have unloaded.
248         umount -d $MOUNT &
249         UMOUNT_PID=$!
250         sleep 6
251         echo "killing umount"
252         kill -TERM $UMOUNT_PID
253         echo "waiting for umount to finish"
254         wait $UMOUNT_PID
255         if grep " $MOUNT " /proc/mounts; then
256                 echo "test 5: /proc/mounts after failed umount"
257                 umount $MOUNT &
258                 UMOUNT_PID=$!
259                 sleep 2
260                 echo "killing umount"
261                 kill -TERM $UMOUNT_PID
262                 echo "waiting for umount to finish"
263                 wait $UMOUNT_PID
264                 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
265         fi
266
267         manual_umount_client
268         # stop_mds is a no-op here, and should not fail
269         cleanup_nocli || return $?
270         # df may have lingering entry
271         manual_umount_client
272         # mtab may have lingering entry
273         local WAIT=0
274         local MAX_WAIT=20
275         local sleep=1
276         while [ "$WAIT" -ne "$MAX_WAIT" ]; do
277                 sleep $sleep
278                 grep -q $MOUNT" " /etc/mtab || break
279                 echo "Waiting /etc/mtab updated ... "
280                 WAIT=$(( WAIT + sleep))
281         done
282         [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
283         echo "/etc/mtab updated in $WAIT secs"
284 }
285 run_test 5a "force cleanup mds, then cleanup"
286
287 test_5b() {
288         start_ost
289         [ -d $MOUNT ] || mkdir -p $MOUNT
290         grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
291         mount_client $MOUNT && return 1
292         grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
293         umount_client $MOUNT
294         # stop_mds is a no-op here, and should not fail
295         cleanup_nocli || return $?
296         return 0
297 }
298 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
299
300 test_5c() {
301         start_ost
302         start_mds
303         [ -d $MOUNT ] || mkdir -p $MOUNT
304         grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
305         local oldfs="${FSNAME}"
306         FSNAME="wrong.${FSNAME}"
307         mount_client $MOUNT || :
308         FSNAME=${oldfs}
309         grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
310         umount_client $MOUNT
311         cleanup_nocli  || return $?
312 }
313 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
314
315 test_5d() {
316         start_ost
317         start_mds
318         stop_ost -f
319         grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
320         mount_client $MOUNT || return 1
321         cleanup  || return $?
322         grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
323         return 0
324 }
325 run_test 5d "mount with ost down"
326
327 test_5e() {
328         start_ost
329         start_mds
330
331 #define OBD_FAIL_PTLRPC_DELAY_SEND       0x506
332         do_facet client "lctl set_param fail_loc=0x80000506"
333         grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
334         mount_client $MOUNT || echo "mount failed (not fatal)"
335         cleanup  || return $?
336         grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
337         return 0
338 }
339 run_test 5e "delayed connect, don't crash (bug 10268)"
340
341 test_6() {
342         setup
343         manual_umount_client
344         mount_client ${MOUNT} || return 87
345         touch $DIR/a || return 86
346         cleanup  || return $?
347 }
348 run_test 6 "manual umount, then mount again"
349
350 test_7() {
351         setup
352         manual_umount_client
353         cleanup_nocli || return $?
354 }
355 run_test 7 "manual umount, then cleanup"
356
357 test_8() {
358         setup
359         mount_client $MOUNT2
360         check_mount2 || return 45
361         umount_client $MOUNT2
362         cleanup  || return $?
363 }
364 run_test 8 "double mount setup"
365
366 test_9() {
367         start_ost
368
369         do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
370         do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
371
372         CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
373         if [ "$CHECK_PTLDEBUG" ] && [ "$CHECK_PTLDEBUG" = "trace inode" ];then
374            echo "lnet.debug success"
375         else
376            echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
377            return 1
378         fi
379         CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
380         if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
381            echo "lnet.subsystem_debug success"
382         else
383            echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
384            return 1
385         fi
386         stop_ost || return $?
387 }
388
389 run_test 9 "test ptldebug and subsystem for mkfs"
390
391 # LOGS/PENDING do not exist anymore since CMD3
392 test_16() {
393         local TMPMTPT="${TMP}/conf16"
394         local dev=${SINGLEMDS}_dev
395         local MDSDEV=${!dev}
396         if [ ! -e "$MDSDEV" ]; then
397             log "no $MDSDEV existing, so mount Lustre to create one"
398             setup
399             check_mount || return 41
400             cleanup || return $?
401         fi
402
403         [ -f "$MDSDEV" ] && LOOPOPT="-o loop"
404
405         log "change the mode of $MDSDEV/OBJECTS to 555"
406         do_facet $SINGLEMDS "mkdir -p $TMPMTPT &&
407                       mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
408                       chmod 555 $TMPMTPT/OBJECTS &&
409                       umount $TMPMTPT" || return $?
410
411         log "mount Lustre to change the mode of OBJECTS, then umount Lustre"
412         setup
413         check_mount || return 41
414         cleanup || return $?
415
416         log "read the mode of OBJECTS and check if they has been changed properly"
417         EXPECTEDOBJECTSMODE=`do_facet $SINGLEMDS "debugfs -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
418
419         if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
420                 log "Success:Lustre change the mode of OBJECTS correctly"
421         else
422                 error "Lustre does not change mode of OBJECTS properly"
423         fi
424 }
425 run_test 16 "verify that lustre will correct the mode of OBJECTS"
426
427 test_17() {
428         local dev=${SINGLEMDS}_dev
429         local MDSDEV=${!dev}
430
431         if [ ! -e "$MDSDEV" ]; then
432             echo "no $MDSDEV existing, so mount Lustre to create one"
433             setup
434             check_mount || return 41
435             cleanup || return $?
436         fi
437
438         echo "Remove mds config log"
439         do_facet $SINGLEMDS "debugfs -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
440
441         start_ost
442         start_mds && return 42
443         gen_config
444 }
445 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
446
447 test_18() {
448         [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
449
450         local dev=${SINGLEMDS}_dev
451         local MDSDEV=${!dev}
452
453         local MIN=2000000
454
455         local OK=
456         # check if current MDSSIZE is large enough
457         [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
458                 log "use MDSSIZE=$MDSSIZE"
459
460         # check if the global config has a large enough MDSSIZE
461         [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
462                 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
463                 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
464
465         # check if the block device is large enough
466         [ -z "$OK" -a -b $MDSDEV ] && \
467                 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
468                      awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
469                 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
470
471         # check if a loopback device has enough space for fs metadata (5%)
472         [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
473                 SPACE=$(df -P $(dirname $MDSDEV) |
474                         awk '($1 != "Filesystem") {print $4}') &&
475                 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
476                         log "use file $MDSDEV with MIN=$MIN"
477
478         [ -z "$OK" ] && skip "$MDSDEV too small for ${MIN}kB MDS" && return
479
480
481         echo "mount mds with large journal..."
482         local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
483
484         MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
485
486         gen_config
487         echo "mount lustre system..."
488         setup
489         check_mount || return 41
490
491         echo "check journal size..."
492         local FOUNDSIZE=`do_facet mds "debugfs -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
493         if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
494                 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
495         else
496                 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
497         fi
498
499         cleanup || return $?
500
501         MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
502         gen_config
503 }
504 run_test 18 "check mkfs creates large journals"
505
506 test_19a() {
507         start_mds || return 1
508         stop_mds -f || return 2
509 }
510 run_test 19a "start/stop MDS without OSTs"
511
512 test_19b() {
513         start_ost || return 1
514         stop_ost -f || return 2
515 }
516 run_test 19b "start/stop OSTs without MDS"
517
518 test_20() {
519         # first format the ost/mdt
520         start_ost
521         start_mds
522         mount_client $MOUNT
523         check_mount || return 43
524         rm -f $DIR/$tfile
525         remount_client ro $MOUNT || return 44
526         touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
527         [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
528         remount_client rw $MOUNT || return 47
529         touch $DIR/$tfile
530         [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
531         MCNT=`grep -c $MOUNT /etc/mtab`
532         [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
533         umount_client $MOUNT
534         stop_mds
535         stop_ost
536 }
537 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
538
539 test_21a() {
540         start_mds
541         start_ost
542         stop_ost
543         stop_mds
544 }
545 run_test 21a "start mds before ost, stop ost first"
546
547 test_21b() {
548         start_ost
549         start_mds
550         stop_mds
551         stop_ost
552 }
553 run_test 21b "start ost before mds, stop mds first"
554
555 test_21c() {
556         start_ost
557         start_mds
558         start_ost2
559         stop_ost
560         stop_ost2
561         stop_mds
562 }
563 run_test 21c "start mds between two osts, stop mds last"
564
565 test_22() {
566         #reformat to remove all logs
567         reformat
568         start_mds
569         echo Client mount before any osts are in the logs
570         mount_client $MOUNT
571         check_mount && return 41
572         pass
573
574         echo Client mount with ost in logs, but none running
575         start_ost
576         stop_ost
577         mount_client $MOUNT
578         # check_mount will block trying to contact ost
579         umount_client $MOUNT
580         pass
581
582         echo Client mount with a running ost
583         start_ost
584         if $GSS; then
585                 # if gss enabled, wait full time to let connection from
586                 # mds to ost be established, due to the mismatch between
587                 # initial connect timeout and gss context negotiation timeout.
588                 # This perhaps could be remove after AT landed.
589                 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
590                 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
591         fi
592         mount_client $MOUNT
593         check_mount || return 41
594         pass
595
596         cleanup
597 }
598 run_test 22 "start a client before osts (should return errs)"
599
600 test_23a() {    # was test_23
601         setup
602         # fail mds
603         stop $SINGLEMDS   
604         # force down client so that recovering mds waits for reconnect
605         local running=$(grep -c $MOUNT /proc/mounts) || true
606         if [ $running -ne 0 ]; then
607                 echo "Stopping client $MOUNT (opts: -f)"
608                 umount -f $MOUNT
609         fi
610
611         # enter recovery on mds
612         start_mds
613         # try to start a new client
614         mount_client $MOUNT &
615         sleep 5
616         MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
617         MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
618         echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
619         ps --ppid $MOUNT_PID
620         ps --ppid $MOUNT_LUSTRE_PID
621         # FIXME why o why can't I kill these? Manual "ctrl-c" works...
622         kill -TERM $MOUNT_LUSTRE_PID
623         echo "waiting for mount to finish"
624         ps -ef | grep mount
625         # we can not wait $MOUNT_PID because it is not a child of this shell
626         local PID1
627         local PID2
628         local WAIT=0
629         local MAX_WAIT=20
630         local sleep=1
631         while [ "$WAIT" -lt "$MAX_WAIT" ]; do
632                 sleep $sleep
633                 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
634                 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
635                 echo PID1=$PID1
636                 echo PID2=$PID2
637                 [ -z "$PID1" -a -z "$PID2" ] && break
638                 echo "waiting for mount to finish ... "
639                 WAIT=$(( WAIT + sleep))
640         done
641         [ "$WAIT" -eq "$MAX_WAIT" ] && error "MOUNT_PID $MOUNT_PID and \
642                 MOUNT__LUSTRE_PID $MOUNT__LUSTRE_PID still not killed in $WAIT secs"
643         ps -ef | grep mount
644         stop_mds || error
645         stop_ost || error
646 }
647 run_test 23a "interrupt client during recovery mount delay"
648
649 umount_client $MOUNT
650 cleanup_nocli
651
652 test_23b() {    # was test_23
653         start_ost
654         start_mds
655         # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
656         lctl set_param fail_loc=0x80000313
657         mount_client $MOUNT
658         cleanup
659 }
660 run_test 23b "Simulate -EINTR during mount"
661
662 fs2mds_HOST=$mds_HOST
663 fs2ost_HOST=$ost_HOST
664
665 cleanup_24a() {
666         trap 0
667         echo "umount $MOUNT2 ..."
668         umount $MOUNT2 || true
669         echo "stopping fs2mds ..."
670         stop fs2mds -f || true
671         echo "stopping fs2ost ..."
672         stop fs2ost -f || true
673 }
674
675 test_24a() {
676         #set up fs1 
677         gen_config
678         #set up fs2
679         [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
680         if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
681                 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
682                 skip "mixed loopback and real device not working" && return
683         fi
684
685         local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
686         local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
687
688         # test 8-char fsname as well
689         local FSNAME2=test1234
690         add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
691
692         add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
693
694         setup
695         start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
696         start fs2ost $fs2ostdev $OST_MOUNT_OPTS
697         mkdir -p $MOUNT2
698         mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
699         # 1 still works
700         check_mount || return 2
701         # files written on 1 should not show up on 2
702         cp /etc/passwd $DIR/$tfile
703         sleep 10
704         [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
705         # 2 should work
706         sleep 5
707         cp /etc/passwd $MOUNT2/b || return 3
708         rm $MOUNT2/b || return 4
709         # 2 is actually mounted
710         grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
711         # failover 
712         facet_failover fs2mds
713         facet_failover fs2ost
714         df
715         umount_client $MOUNT 
716         # the MDS must remain up until last MDT
717         stop_mds
718         MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
719         [ -z "$MDS" ] && error "No MDT" && return 8
720         cleanup_24a
721         cleanup_nocli || return 6
722 }
723 run_test 24a "Multiple MDTs on a single node"
724
725 test_24b() {
726         if [ -z "$fs2mds_DEV" ]; then
727                 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
728                 skip "mixed loopback and real device not working" && return
729         fi
730
731         local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
732
733         add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10 
734         setup
735         start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
736         cleanup || return 6
737 }
738 run_test 24b "Multiple MGSs on a single node (should return err)"
739
740 test_25() {
741         setup
742         check_mount || return 2
743         local MODULES=$($LCTL modules | awk '{ print $2 }')
744         rmmod $MODULES 2>/dev/null || true
745         cleanup || return 6
746 }
747 run_test 25 "Verify modules are referenced"
748
749 test_26() {
750     load_modules
751     # we need modules before mount for sysctl, so make sure...
752     do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
753 #define OBD_FAIL_MDS_FS_SETUP            0x135
754     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
755     start_mds && echo MDS started && return 1
756     lctl get_param -n devices
757     DEVS=$(lctl get_param -n devices | wc -l)
758     [ $DEVS -gt 0 ] && return 2
759     unload_modules || return 203
760 }
761 run_test 26 "MDT startup failure cleans LOV (should return errs)"
762
763 set_and_check() {
764         local myfacet=$1
765         local TEST=$2
766         local PARAM=$3
767         local ORIG=$(do_facet $myfacet "$TEST") 
768         if [ $# -gt 3 ]; then
769             local FINAL=$4
770         else
771             local -i FINAL
772             FINAL=$(($ORIG + 5))
773         fi
774         echo "Setting $PARAM from $ORIG to $FINAL"
775         do_facet $SINGLEMDS "$LCTL conf_param $PARAM=$FINAL" || error conf_param failed
776         local RESULT
777         local MAX=90
778         local WAIT=0
779         while [ 1 ]; do
780             sleep 5
781             RESULT=$(do_facet $myfacet "$TEST") 
782             if [ $RESULT -eq $FINAL ]; then
783                 echo "Updated config after $WAIT sec (got $RESULT)"
784                 break
785             fi
786             WAIT=$((WAIT + 5))
787             if [ $WAIT -eq $MAX ]; then
788                 echo "Config update not seen: wanted $FINAL got $RESULT"
789                 return 3
790             fi
791             echo "Waiting $(($MAX - $WAIT)) secs for config update" 
792         done
793 }
794
795 test_27a() {
796         start_ost || return 1
797         start_mds || return 2
798         echo "Requeue thread should have started: " 
799         ps -e | grep ll_cfg_requeue 
800         set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
801         cleanup_nocli
802 }
803 run_test 27a "Reacquire MGS lock if OST started first"
804
805 test_27b() {
806         # FIXME. ~grev
807         setup
808         local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
809
810         facet_failover $SINGLEMDS
811         set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
812         set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
813         check_mount
814         cleanup
815 }
816 run_test 27b "Reacquire MGS lock after failover"
817
818 test_28() {
819         setup
820         TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
821         PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
822         ORIG=$($TEST)
823         FINAL=$(($ORIG + 1))
824         set_and_check client "$TEST" "$PARAM" $FINAL || return 3
825         FINAL=$(($FINAL + 1))
826         set_and_check client "$TEST" "$PARAM" $FINAL || return 4
827         umount_client $MOUNT || return 200
828         mount_client $MOUNT
829         RESULT=$($TEST)
830         if [ $RESULT -ne $FINAL ]; then
831             echo "New config not seen: wanted $FINAL got $RESULT"
832             return 4
833         else
834             echo "New config success: got $RESULT"
835         fi
836         set_and_check client "$TEST" "$PARAM" $ORIG || return 5
837         cleanup
838 }
839 run_test 28 "permanent parameter setting"
840
841 test_29() {
842         [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2, skipping" && return
843         setup > /dev/null 2>&1
844         start_ost2
845         sleep 10
846
847         local PARAM="$FSNAME-OST0001.osc.active"
848         local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
849         local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
850
851         ACTV=$(lctl get_param -n $PROC_ACT)
852         DEAC=$((1 - $ACTV))
853         set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
854         # also check ost_server_uuid status
855         RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
856         if [ -z "$RESULT" ]; then
857             echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
858             return 3
859         else
860             echo "Live client success: got $RESULT"
861         fi
862
863         # check MDT too 
864         local MPROC="osc.$FSNAME-OST0001-osc-[M]*.active"
865         local MAX=30
866         local WAIT=0
867         while [ 1 ]; do
868             sleep 5
869             RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
870             [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
871             if [ $RESULT -eq $DEAC ]; then
872                 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
873                 break
874             fi
875             WAIT=$((WAIT + 5))
876             if [ $WAIT -eq $MAX ]; then
877                 echo "MDT not deactivated: wanted $DEAC got $RESULT"
878                 return 4
879             fi
880             echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
881         done
882
883         # test new client starts deactivated
884         umount_client $MOUNT || return 200
885         mount_client $MOUNT
886         RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
887         if [ -z "$RESULT" ]; then
888             echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
889             return 5
890         else
891             echo "New client success: got $RESULT"
892         fi
893
894         # make sure it reactivates
895         set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
896
897         umount_client $MOUNT
898         stop_ost2
899         cleanup_nocli
900         #writeconf to remove all ost2 traces for subsequent tests
901         writeconf
902         start_mds
903         start_ost
904         cleanup
905 }
906 run_test 29 "permanently remove an OST"
907
908 test_30() {
909         setup
910
911         TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
912         ORIG=$($TEST)
913         LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
914         for i in ${LIST[@]}; do
915             set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
916         done
917         # make sure client restart still works 
918         umount_client $MOUNT
919         mount_client $MOUNT || return 4
920         [ "$($TEST)" -ne "$i" ] && return 5   
921         set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
922         cleanup
923 }
924 run_test 30 "Big config llog"
925
926 test_31() { # bug 10734
927         # ipaddr must not exist
928         mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
929         cleanup
930 }
931 run_test 31 "Connect to non-existent node (shouldn't crash)"
932
933 test_32a() {
934         # XXX - make this test verify 1.8 -> 2.0 upgrade is working
935         # XXX - make this run on client-only systems with real hardware on
936         #       the OST and MDT
937         #       there appears to be a lot of assumption here about loopback
938         #       devices
939         # or maybe this test is just totally useless on a client-only system
940         [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
941         [ "$mds_HOST" = "`hostname`" ] || { skip "remote MDS" && return 0; }
942         [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
943                 { skip "remote OST" && return 0; }
944
945         [ -z "$TUNEFS" ] && skip "No tunefs" && return
946         local DISK1_8=$LUSTRE/tests/disk1_8.tgz
947         [ ! -r $DISK1_8 ] && skip "Cannot find $DISK1_8" && return 0
948
949         mkdir -p $TMP/$tdir
950         tar xjvf $DISK1_8 -C $TMP/$tdir || \
951                 { skip "Cannot untar $DISK1_8" && return 0; }
952
953         load_modules
954         lctl set_param debug=$PTLDEBUG
955
956         $TUNEFS $tmpdir/mds || error "tunefs failed"
957         # nids are wrong, so client wont work, but server should start
958         start mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" || return 3
959         local UUID=$(lctl get_param -n mdt.lustre-MDT0000.uuid)
960         echo MDS uuid $UUID
961         [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID" 
962
963         $TUNEFS --mgsnode=`hostname` $tmpdir/ost1 || error "tunefs failed"
964         start ost1 $tmpdir/ost1 "-o loop" || return 5
965         UUID=$(lctl get_param -n obdfilter.lustre-OST0000.uuid)
966         echo OST uuid $UUID
967         [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID" 
968
969         local NID=$($LCTL list_nids | head -1)
970
971         echo "OSC changes should return err:" 
972         $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 && return 7
973         $LCTL conf_param lustre-OST0000.failover.node=$NID && return 8
974         echo "ok."
975         echo "MDC changes should succeed:" 
976         $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
977         $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
978         echo "ok."
979
980         # With a new good MDT failover nid, we should be able to mount a client
981         # (but it cant talk to OST)
982         local OLDMOUNTOPT=$MOUNTOPT
983         MOUNTOPT="exclude=lustre-OST0000"
984         mount_client $MOUNT
985         MOUNTOPT=$OLDMOUNTOPT
986         set_and_check client "lctl get_param -n mdc.*.max_rpcs_in_flight" "lustre-MDT0000.mdc.max_rpcs_in_flight" ||
987                 return 11
988
989         zconf_umount `hostname` $MOUNT -f
990         cleanup_nocli
991         load_modules
992
993         # mount a second time to make sure we didnt leave upgrade flag on
994         load_modules
995         $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
996         load_modules
997         start mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" || return 12
998         cleanup_nocli
999
1000         rm -rf $tmpdir || true  # true is only for TMP on NFS
1001 }
1002 run_test 32a "Upgrade from 1.8 (not live)"
1003
1004 test_32b() {
1005         # XXX - make this test verify 1.8 -> 2.0 upgrade is working
1006         # XXX - make this run on client-only systems with real hardware on
1007         #       the OST and MDT
1008         #       there appears to be a lot of assumption here about loopback
1009         #       devices
1010         # or maybe this test is just totally useless on a client-only system
1011         [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1012         [ "$mds_HOST" = "`hostname`" ] || { skip "remote MDS" && return 0; }
1013         [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1014                 { skip "remote OST" && return 0; }
1015
1016         [ -z "$TUNEFS" ] && skip "No tunefs" && return
1017         local DISK1_8=$LUSTRE/tests/disk1_8.tgz
1018         [ ! -r $DISK1_8 ] && skip "Cannot find $DISK1_8" && return 0
1019         mkdir -p $TMP/$tdir
1020         tar xjvf $DISK1_8 -C $TMP/$tdir || \
1021                 { skip "Cannot untar $DISK1_8" && return ; }
1022
1023         load_modules
1024         lctl set_param debug=$PTLDEBUG
1025         NEWNAME=sofia
1026
1027         # writeconf will cause servers to register with their current nids
1028         $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1029         start mds $tmpdir/mds "-o loop" || return 3
1030         local UUID=$(lctl get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1031         echo MDS uuid $UUID
1032         [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID" 
1033
1034         $TUNEFS --mgsnode=`hostname` --fsname=$NEWNAME --writeconf $tmpdir/ost1 || error "tunefs failed"
1035         start ost1 $tmpdir/ost1 "-o loop" || return 5
1036         UUID=$(lctl get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1037         echo OST uuid $UUID
1038         [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
1039
1040         echo "OSC changes should succeed:" 
1041         $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1042         $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1043         echo "ok."
1044         echo "MDC changes should succeed:" 
1045         $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1046         echo "ok."
1047
1048         # MDT and OST should have registered with new nids, so we should have
1049         # a fully-functioning client
1050         echo "Check client and old fs contents"
1051         OLDFS=$FSNAME
1052         FSNAME=$NEWNAME
1053         mount_client $MOUNT
1054         FSNAME=$OLDFS
1055         set_and_check client "lctl get_param -n mdc.*.max_rpcs_in_flight" "${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight" || return 11
1056         [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "2479747619 779" ] || return 12  
1057         echo "ok."
1058
1059         cleanup
1060         rm -rf $tmpdir || true  # true is only for TMP on NFS
1061 }
1062 run_test 32b "Upgrade from 1.8 with writeconf"
1063
1064 test_33a() { # bug 12333, was test_33
1065         local rc=0
1066         local FSNAME2=test-123
1067         [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1068
1069         if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1070                 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1071                 skip "mixed loopback and real device not working" && return
1072         fi
1073
1074         local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1075         local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1076         add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1077         add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1078
1079         start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1080         start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1081         do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1082         mkdir -p $MOUNT2
1083         mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1084         echo "ok."
1085
1086         cp /etc/hosts $MOUNT2/ || rc=3 
1087         $LFS getstripe $MOUNT2/hosts
1088
1089         umount -d $MOUNT2
1090         stop fs2ost -f
1091         stop fs2mds -f
1092         rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1093         cleanup_nocli || rc=6
1094         return $rc
1095 }
1096 run_test 33a "Mount ost with a large index number"
1097
1098 test_33b() {    # was test_34
1099         setup
1100
1101         do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1102         # Drop lock cancelation reply during umount
1103         #define OBD_FAIL_LDLM_CANCEL             0x304
1104         do_facet client lctl set_param fail_loc=0x80000304
1105         #lctl set_param debug=-1
1106         umount_client $MOUNT
1107         cleanup
1108 }
1109 run_test 33b "Drop cancel during umount"
1110
1111 test_34a() {
1112         setup
1113         do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1114         manual_umount_client
1115         rc=$?
1116         do_facet client killall -USR1 multiop
1117         if [ $rc -eq 0 ]; then
1118                 error "umount not fail!"
1119         fi
1120         sleep 1
1121         cleanup
1122 }
1123 run_test 34a "umount with opened file should be fail"
1124
1125
1126 test_34b() {
1127         setup
1128         touch $DIR/$tfile || return 1
1129         stop_mds --force || return 2
1130
1131         manual_umount_client --force
1132         rc=$?
1133         if [ $rc -ne 0 ]; then
1134                 error "mtab after failed umount - rc $rc"
1135         fi
1136
1137         cleanup
1138         return 0
1139 }
1140 run_test 34b "force umount with failed mds should be normal"
1141
1142 test_34c() {
1143         setup
1144         touch $DIR/$tfile || return 1
1145         stop_ost --force || return 2
1146
1147         manual_umount_client --force
1148         rc=$?
1149         if [ $rc -ne 0 ]; then
1150                 error "mtab after failed umount - rc $rc"
1151         fi
1152
1153         cleanup
1154         return 0
1155 }
1156 run_test 34c "force umount with failed ost should be normal"
1157
1158 test_35() { # bug 12459
1159         setup
1160
1161         DBG_SAVE="`lctl get_param -n debug`"
1162         lctl set_param debug="ha"
1163
1164         log "Set up a fake failnode for the MDS"
1165         FAKENID="127.0.0.2"
1166         local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1167         do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1168
1169         log "Wait for RECONNECT_INTERVAL seconds (10s)"
1170         sleep 10
1171
1172         MSG="conf-sanity.sh test_35 `date +%F%kh%Mm%Ss`"
1173         $LCTL clear
1174         log "$MSG"
1175         log "Stopping the MDT:"
1176         stop_mds || return 5
1177
1178         df $MOUNT > /dev/null 2>&1 &
1179         DFPID=$!
1180         log "Restarting the MDT:"
1181         start_mds || return 6
1182         log "Wait for df ($DFPID) ... "
1183         wait $DFPID
1184         log "done"
1185         lctl set_param debug="$DBG_SAVE"
1186
1187         # retrieve from the log the first server that the client tried to
1188         # contact after the connection loss
1189         $LCTL dk $TMP/lustre-log-$TESTNAME.log
1190         NEXTCONN=`awk "/${MSG}/ {start = 1;}
1191                        /import_select_connection.$device-mdc.* using connection/ {
1192                                 if (start) {
1193                                         if (\\\$NF ~ /$FAKENID/)
1194                                                 print \\\$NF;
1195                                         else
1196                                                 print 0;
1197                                         exit;
1198                                 }
1199                        }" $TMP/lustre-log-$TESTNAME.log`
1200         [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1201         cleanup
1202 }
1203 run_test 35 "Reconnect to the last active server first"
1204
1205 test_36() { # 12743
1206         local rc
1207         local FSNAME2=test1234
1208         local fs3ost_HOST=$ost_HOST
1209
1210         [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1211         rc=0
1212
1213         if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1214                 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1215                 skip "mixed loopback and real device not working" && return
1216         fi
1217         [ $OSTCOUNT -lt 2 ] && skip "skipping test for single OST" && return
1218
1219         [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1220                 { skip "remote OST" && return 0; }
1221
1222         local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1223         local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1224         local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1225         add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1226         # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1227         # other argument
1228         add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1229         add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1230
1231         start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1232         start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1233         start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1234         mkdir -p $MOUNT2
1235         mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1236
1237         sleep 5 # until 11778 fixed
1238
1239         dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1240
1241         BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1242         BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1243         BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1244         STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1245         DFTOTAL=`echo $STRING | cut -d, -f1`
1246         DFUSED=`echo $STRING  | cut -d, -f2`
1247         DFAVAIL=`echo $STRING | cut -d, -f3`
1248         DFFREE=$(($DFTOTAL - $DFUSED))
1249
1250         ALLOWANCE=$((64 * $OSTCOUNT))
1251
1252         if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||  
1253            [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1254                 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1255                 rc=1
1256         fi
1257         if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] || 
1258            [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1259                 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1260                 rc=2
1261         fi
1262         if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] || 
1263            [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1264                 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1265                 rc=3
1266        fi
1267
1268         umount -d $MOUNT2
1269         stop fs3ost -f || return 200
1270         stop fs2ost -f || return 201
1271         stop fs2mds -f || return 202
1272         rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1273         unload_modules || return 203
1274         return $rc
1275 }
1276 run_test 36 "df report consistency on OSTs with different block size"
1277
1278 test_37() {
1279         [ -n "$CLIENTONLY" -o -n "$CLIENTMODSONLY" ] && skip "client only testing" && return 0
1280         LOCAL_MDSDEV="$TMP/mdt.img"
1281         SYM_MDSDEV="$TMP/sym_mdt.img"
1282
1283         echo "MDS :     $LOCAL_MDSDEV"
1284         echo "SYMLINK : $SYM_MDSDEV"
1285         rm -f $LOCAL_MDSDEV
1286
1287         touch $LOCAL_MDSDEV
1288         mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1289                 error "mkfs.lustre $LOCAL_MDSDEV failed"
1290         ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1291
1292         echo "mount symlink device - $SYM_MDSDEV"
1293
1294         mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1295         umount -d ${MOUNT%/*}/mds
1296         rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1297
1298         if [ -n "$mount_op" ]; then
1299                 error "**** FAIL: set tunables failed for symlink device"
1300         fi
1301         return 0
1302 }
1303 run_test 37 "verify set tunables works for symlink device"
1304
1305 test_38() { # bug 14222
1306         setup
1307         # like runtests
1308         COUNT=10
1309         SRC="/etc /bin"
1310         FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1311         log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1312         mkdir -p $DIR/$tdir
1313         tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1314                 error "copying $SRC to $DIR/$tdir"
1315         sync
1316         umount_client $MOUNT
1317         stop_mds
1318         log "rename lov_objid file on MDS"
1319         rm -f $TMP/lov_objid.orig
1320
1321         local dev=${SINGLEMDS}_dev
1322         local MDSDEV=${!dev}
1323         do_facet $SINGLEMDS "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1324         do_facet $SINGLEMDS "debugfs -w -R \\\"rm lov_objid\\\" $MDSDEV"
1325
1326         do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1327         # check create in mds_lov_connect
1328         start_mds
1329         mount_client $MOUNT
1330         for f in $FILES; do
1331                 [ $V ] && log "verifying $DIR/$tdir/$f"
1332                 diff -q $f $DIR/$tdir/$f || ERROR=y
1333         done
1334         do_facet $SINGLEMDS "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\"  $MDSDEV"
1335         do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1336         [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1337
1338         # check it's updates in sync
1339         umount_client $MOUNT
1340         stop_mds
1341
1342         do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1343         do_facet $SINGLEMDS "debugfs -w -R \\\"rm lov_objid\\\" $MDSDEV"
1344         do_facet $SINGLEMDS "debugfs -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1345
1346         start_mds
1347         mount_client $MOUNT
1348         for f in $FILES; do
1349                 [ $V ] && log "verifying $DIR/$tdir/$f"
1350                 diff -q $f $DIR/$tdir/$f || ERROR=y
1351         done
1352         do_facet $SINGLEMDS "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1353         do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1354         umount_client $MOUNT
1355         stop_mds
1356         [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1357
1358         log "files compared the same"
1359         cleanup
1360 }
1361 run_test 38 "MDS recreates missing lov_objid file from OST data"
1362
1363 test_39() {
1364         PTLDEBUG=+malloc
1365         setup
1366         cleanup
1367         perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' && 
1368                 error "memory leak detected" || true
1369 }
1370 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1371
1372 test_40() { # bug 15759
1373         start_ost
1374         #define OBD_FAIL_TGT_TOOMANY_THREADS     0x706
1375         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1376         start_mds
1377         cleanup
1378 }
1379 run_test 40 "race during service thread startup"
1380
1381 test_41() { #bug 14134
1382         local rc
1383         local dev=${SINGLEMDS}_dev
1384         local MDSDEV=${!dev}
1385
1386         start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1387         start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1388         start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs
1389         mkdir -p $MOUNT
1390         mount_client $MOUNT || return 1
1391         sleep 5
1392
1393         echo "blah blah" > $MOUNT/$tfile
1394         cat $MOUNT/$tfile
1395
1396         umount_client $MOUNT
1397         stop ost1 -f || return 201
1398         stop_mds -f || return 202
1399         stop_mds -f || return 203
1400         unload_modules || return 204
1401         return $rc
1402 }
1403 run_test 41 "mount mds with --nosvc and --nomgs"
1404
1405 test_42() { #bug 14693
1406         setup
1407         check_mount || return 2
1408         do_facet client lctl conf_param lustre.llite.some_wrong_param=10
1409         umount_client $MOUNT
1410         mount_client $MOUNT || return 1
1411         cleanup
1412         return 0
1413 }
1414 run_test 42 "invalid config param should not prevent client from mounting"
1415
1416 umount_client $MOUNT
1417 cleanup_nocli
1418 cleanup_gss
1419
1420 test_45() { #17310
1421         setup
1422         check_mount || return 2
1423         stop_mds
1424         df -h $MOUNT &
1425         log "sleep 60 sec"
1426         sleep 60
1427 #define OBD_FAIL_PTLRPC_LONG_UNLINK   0x50f
1428         do_facet client "lctl set_param fail_loc=0x50f"
1429         log "sleep 10 sec"
1430         sleep 10
1431         manual_umount_client --force || return 3
1432         do_facet client "lctl set_param fail_loc=0x0"
1433         start_mds
1434         mount_client $MOUNT || return 4
1435         cleanup
1436         return 0
1437 }
1438 run_test 45 "long unlink handling in ptlrpcd"
1439
1440
1441 equals_msg `basename $0`: test complete
1442 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true