3 # add uml1 uml2 uml3 in your /etc/hosts
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.
14 # These tests don't apply to mountconf
15 MOUNTCONFSKIP="9 10 11 12 13 13b 14 15"
17 # bug number for skipped test: 2661 10510 12743
18 ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT $MOUNTCONFSKIP 16 23 36"
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
22 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
24 PTLDEBUG=${PTLDEBUG:--1}
26 LUSTRE=${LUSTRE:-`dirname $0`/..}
27 RLUSTRE=${RLUSTRE:-$LUSTRE}
28 MOUNTLUSTRE=${MOUNTLUSTRE:-/sbin/mount.lustre}
29 MKFSLUSTRE=${MKFSLUSTRE:-/usr/sbin/mkfs.lustre}
32 . $LUSTRE/tests/test-framework.sh
34 # use small MDS + OST size to speed formatting time
37 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
48 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
49 do_facet ${facet} "$TUNEFS --writeconf $MDSDEV" || echo "tunefs failed, reformatting instead" && reformat
54 # The MGS must be started before the OSTs for a new fs, so start
55 # and stop to generate the startup logs.
64 echo "start mds service on `facet_active_host mds`"
65 start mds $MDSDEV $MDS_MOUNT_OPTS || return 94
69 echo "stop mds service on `facet_active_host mds`"
70 # These tests all use non-failover stop
71 stop mds -f || return 97
75 echo "start ost1 service on `facet_active_host ost1`"
76 start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95
80 echo "stop ost1 service on `facet_active_host ost1`"
81 # These tests all use non-failover stop
82 stop ost1 -f || return 98
86 echo "start ost2 service on `facet_active_host ost2`"
87 start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92
91 echo "stop ost2 service on `facet_active_host ost2`"
92 # These tests all use non-failover stop
93 stop ost2 -f || return 93
98 echo "mount $FSNAME on ${MOUNTPATH}....."
99 zconf_mount `hostname` $MOUNTPATH || return 96
103 local SAVEMOUNTOPT=$MOUNTOPT
104 MOUNTOPT="remount,$1"
106 echo "remount '$1' lustre on ${MOUNTPATH}....."
107 zconf_mount `hostname` $MOUNTPATH || return 96
108 MOUNTOPT=$SAVEMOUNTOPT
113 echo "umount lustre on ${MOUNTPATH}....."
114 zconf_umount `hostname` $MOUNTPATH || return 97
117 manual_umount_client(){
118 echo "manual umount lustre on ${MOUNT}...."
119 do_facet client "umount -d $MOUNT"
129 stop_mds || return 201
130 stop_ost || return 202
131 unload_modules || return 203
135 umount_client $MOUNT || return 200
136 cleanup_nocli || return $?
140 do_facet client "cp /etc/passwd $DIR/a" || return 71
141 do_facet client "rm $DIR/a" || return 72
142 # make sure lustre is actually mounted (touch will block,
143 # but grep won't, so do it after)
144 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
145 echo "setup single mount lustre success"
149 do_facet client "touch $DIR/a" || return 71
150 do_facet client "rm $DIR/a" || return 72
151 do_facet client "touch $DIR2/a" || return 73
152 do_facet client "rm $DIR2/a" || return 74
153 echo "setup double mount lustre success"
158 if [ "$ONLY" == "setup" ]; then
163 if [ "$ONLY" == "cleanup" ]; then
168 #create single point mountpoint
176 check_mount || return 41
179 run_test 0 "single mount setup"
183 echo "start ost second time..."
185 check_mount || return 42
188 run_test 1 "start up ost twice (should return errors)"
193 echo "start mds second time.."
196 check_mount || return 43
199 run_test 2 "start up mds twice (should return err)"
203 #mount.lustre returns an error if already in mtab
204 mount_client $MOUNT && return $?
205 check_mount || return 44
208 run_test 3 "mount client twice (should return err)"
212 touch $DIR/$tfile || return 85
216 # ok for ost to fail shutdown
217 if [ 202 -ne $eno ]; then
222 run_test 4 "force cleanup ost, then cleanup"
226 touch $DIR/$tfile || return 1
227 stop_mds -f || return 2
229 # cleanup may return an error from the failed
230 # disconnects; for now I'll consider this successful
231 # if all the modules have unloaded.
235 echo "killing umount"
236 kill -TERM $UMOUNT_PID
237 echo "waiting for umount to finish"
239 if grep " $MOUNT " /etc/mtab; then
240 echo "test 5: mtab after failed umount"
244 echo "killing umount"
245 kill -TERM $UMOUNT_PID
246 echo "waiting for umount to finish"
248 grep " $MOUNT " /etc/mtab && echo "test 5: mtab after second umount" && return 11
252 # stop_mds is a no-op here, and should not fail
253 cleanup_nocli || return $?
254 # df may have lingering entry
256 # mtab may have lingering entry
257 grep -v $MOUNT" " /etc/mtab > $TMP/mtabtemp
258 mv $TMP/mtabtemp /etc/mtab
260 run_test 5 "force cleanup mds, then cleanup"
264 [ -d $MOUNT ] || mkdir -p $MOUNT
265 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
266 mount_client $MOUNT && return 1
267 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
269 # stop_mds is a no-op here, and should not fail
270 cleanup_nocli || return $?
273 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
278 [ -d $MOUNT ] || mkdir -p $MOUNT
279 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
280 mount -t lustre $MGSNID:/wrong.$FSNAME $MOUNT || :
281 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
283 cleanup_nocli || return $?
285 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
291 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
292 mount_client $MOUNT || return 1
294 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
297 run_test 5d "mount with ost down"
302 # give MDS a chance to connect to OSTs (bz 10476)
305 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
306 do_facet client "sysctl -w lustre.fail_loc=0x80000506"
307 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
308 mount_client $MOUNT || echo "mount failed (not fatal)"
310 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
313 run_test 5e "delayed connect, don't crash (bug 10268)"
318 mount_client ${MOUNT} || return 87
319 touch $DIR/a || return 86
322 run_test 6 "manual umount, then mount again"
327 cleanup_nocli || return $?
329 run_test 7 "manual umount, then cleanup"
334 check_mount2 || return 45
335 umount_client $MOUNT2
338 run_test 8 "double mount setup"
343 do_facet ost1 sysctl lnet.debug=\'inode trace\' || return 1
344 do_facet ost1 sysctl lnet.subsystem_debug=\'mds ost\' || return 1
346 CHECK_PTLDEBUG="`do_facet ost1 sysctl -n lnet.debug`"
347 if [ "$CHECK_PTLDEBUG" ] && [ "$CHECK_PTLDEBUG" = "trace inode" ];then
348 echo "lnet.debug success"
350 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
353 CHECK_SUBSYS="`do_facet ost1 sysctl -n lnet.subsystem_debug`"
354 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
355 echo "lnet.subsystem_debug success"
357 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
360 stop_ost || return $?
363 run_test 9 "test ptldebug and subsystem for mkfs"
366 echo "generate configuration with the same name for node and mds"
367 OLDXMLCONFIG=$XMLCONFIG
368 XMLCONFIG="broken.xml"
369 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
373 echo "the name for node and mds is the same"
374 do_lmc --add mds --node ${facet}_facet --mds ${facet}_facet \
375 --dev $MDSDEV --size $MDSSIZE || return $?
376 do_lmc --add lov --mds ${facet}_facet --lov lov1 --stripe_sz \
377 $STRIPE_BYTES --stripe_cnt $STRIPES_PER_OBJ \
378 --stripe_pattern 0 || return $?
379 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
381 add_facet $facet --lustre_upcall $UPCALL
382 do_lmc --add mtpt --node ${facet}_facet --mds mds_facet \
383 --lov lov1 --path $MOUNT
389 check_mount || return 41
393 XMLCONFIG=$OLDXMLCONFIG
395 run_test 10 "mount lustre with the same name for node and mds"
398 OLDXMLCONFIG=$XMLCONFIG
399 XMLCONFIG="conf11.xml"
401 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
402 add_mds mds --dev $MDSDEV --size $MDSSIZE
403 add_ost ost --dev $OSTDEV --size $OSTSIZE
404 add_client client mds --path $MOUNT --ost ost_svc || return $?
405 echo "Default lov config success!"
407 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
408 add_mds mds --dev $MDSDEV --size $MDSSIZE
409 add_ost ost --dev $OSTDEV --size $OSTSIZE
410 add_client client mds --path $MOUNT && return $?
411 echo "--add mtpt with neither --lov nor --ost will return error"
415 XMLCONFIG=$OLDXMLCONFIG
417 run_test 11 "use default lov configuration (should return error)"
420 OLDXMLCONFIG=$XMLCONFIG
421 XMLCONFIG="batch.xml"
422 BATCHFILE="batchfile"
425 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
426 [ -f "$BATCHFILE" ] && rm -f $BATCHFILE
427 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
428 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions \"-I 128\"" >> $BATCHFILE
429 # --mkfsoptions "-I 128"
430 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
431 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
432 echo "matched double quote success"
434 echo "matched double quote fail"
439 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
440 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions \"-I 128" >> $BATCHFILE
441 # --mkfsoptions "-I 128
442 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
443 echo "unmatched double quote should return error"
447 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
448 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions '-I 128'" >> $BATCHFILE
449 # --mkfsoptions '-I 128'
450 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
451 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
452 echo "matched single quote success"
454 echo "matched single quote fail"
459 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
460 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions '-I 128" >> $BATCHFILE
461 # --mkfsoptions '-I 128
462 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
463 echo "unmatched single quote should return error"
467 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
468 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions \-\I\ \128" >> $BATCHFILE
469 # --mkfsoptions \-\I\ \128
470 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
471 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
472 echo "backslash followed by a whitespace/letter success"
474 echo "backslash followed by a whitespace/letter fail"
479 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
480 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions -I\ 128\\" >> $BATCHFILE
481 # --mkfsoptions -I\ 128\
482 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
483 echo "backslash followed by nothing should return error"
486 XMLCONFIG=$OLDXMLCONFIG
488 run_test 12 "lmc --batch, with single/double quote, backslash in batchfile"
491 OLDXMLCONFIG=$XMLCONFIG
492 XMLCONFIG="conf13-1.xml"
494 # check long uuid will be truncated properly and uniquely
495 echo "To generate XML configuration file(with long ost name): $XMLCONFIG"
496 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
497 do_lmc --add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp
498 do_lmc --add mds --node $HOSTNAME --mds mds1_name_longer_than_31characters
499 do_lmc --add mds --node $HOSTNAME --mds mds2_name_longer_than_31characters
500 if [ ! -f "$XMLCONFIG" ]; then
501 echo "Error:no file $XMLCONFIG created!"
504 EXPECTEDMDS1UUID="e_longer_than_31characters_UUID"
505 EXPECTEDMDS2UUID="longer_than_31characters_UUID_2"
506 FOUNDMDS1UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '1p' \
507 | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
508 FOUNDMDS2UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '2p' \
509 | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
510 [ -z "$FOUNDMDS1UUID" ] && echo "MDS1 UUID empty" && return 1
511 [ -z "$FOUNDMDS2UUID" ] && echo "MDS2 UUID empty" && return 1
512 if ([ $EXPECTEDMDS1UUID = $FOUNDMDS1UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS2UUID ]) || \
513 ([ $EXPECTEDMDS1UUID = $FOUNDMDS2UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS1UUID ]); then
514 echo "Success:long uuid truncated successfully and being unique."
516 echo "Error:expected uuid for mds1 and mds2: $EXPECTEDMDS1UUID; $EXPECTEDMDS2UUID"
517 echo "but: found uuid for mds1 and mds2: $FOUNDMDS1UUID; $FOUNDMDS2UUID"
521 XMLCONFIG=$OLDXMLCONFIG
523 run_test 13 "check new_uuid of lmc operating correctly"
526 OLDXMLCONFIG=$XMLCONFIG
527 XMLCONFIG="conf13-1.xml"
528 SECONDXMLCONFIG="conf13-2.xml"
529 # check multiple invocations for lmc generate same XML configuration file
531 echo "Generate the first XML configuration file"
533 echo "mv $XMLCONFIG to $SECONDXMLCONFIG"
534 sed -e "s/mtime[^ ]*//" $XMLCONFIG > $SECONDXMLCONFIG || return $?
535 echo "Generate the second XML configuration file"
537 # don't compare .xml mtime, it will always be different
538 if [ `sed -e "s/mtime[^ ]*//" $XMLCONFIG | diff - $SECONDXMLCONFIG | wc -l` -eq 0 ]; then
539 echo "Success:multiple invocations for lmc generate same XML file"
541 echo "Error: multiple invocations for lmc generate different XML file"
545 rm -f $XMLCONFIG $SECONDXMLCONFIG
546 XMLCONFIG=$OLDXMLCONFIG
548 run_test 13b "check lmc generates consistent .xml file"
553 # create xml file with --mkfsoptions for ost
554 echo "create xml file with --mkfsoptions for ost"
555 add_mds mds --dev $MDSDEV --size $MDSSIZE
556 add_lov lov1 mds --stripe_sz $STRIPE_BYTES\
557 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
558 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE \
559 --mkfsoptions "-Llabel_conf_14"
560 add_client client mds --lov lov1 --path $MOUNT
562 FOUNDSTRING=`awk -F"<" '/<mkfsoptions>/{print $2}' $XMLCONFIG`
563 EXPECTEDSTRING="mkfsoptions>-Llabel_conf_14"
564 if [ "$EXPECTEDSTRING" != "$FOUNDSTRING" ]; then
565 echo "Error: expected: $EXPECTEDSTRING; found: $FOUNDSTRING"
568 echo "Success:mkfsoptions for ost written to xml file correctly."
570 # mount lustre to test lconf mkfsoptions-parsing
574 mount_client $MOUNT || return $?
575 if [ -z "`do_facet ost1 dumpe2fs -h $OSTDEV | grep label_conf_14`" ]; then
576 echo "Error: the mkoptions not applied to mke2fs of ost."
580 echo "lconf mkfsoptions for ost success"
584 run_test 14 "test mkfsoptions of ost for lmc and lconf"
588 [ -f $MOUNTLUSTRE ] && echo "remove $MOUNTLUSTRE" && rm -f $MOUNTLUSTRE
589 if [ -f $MOUNTLUSTRE.sav ]; then
590 echo "return original $MOUNTLUSTRE.sav to $MOUNTLUSTRE"
591 mv $MOUNTLUSTRE.sav $MOUNTLUSTRE
595 # this only tests the kernel mount command, not anything about lustre.
597 MOUNTLUSTRE=${MOUNTLUSTRE:-/sbin/mount.lustre}
601 echo "mount lustre on ${MOUNT} without $MOUNTLUSTRE....."
602 if [ -f "$MOUNTLUSTRE" ]; then
603 echo "save $MOUNTLUSTRE to $MOUNTLUSTRE.sav"
604 mv $MOUNTLUSTRE $MOUNTLUSTRE.sav && trap cleanup_15 EXIT INT
605 if [ -f $MOUNTLUSTRE ]; then
606 skip "$MOUNTLUSTRE cannot be moved, skipping test"
611 mount_client $MOUNT && error "mount succeeded" && return 1
612 echo "mount lustre on $MOUNT without $MOUNTLUSTRE failed as expected"
616 run_test 15 "zconf-mount without /sbin/mount.lustre (should return error)"
619 TMPMTPT="${MOUNT%/*}/conf16"
621 if [ ! -e "$MDSDEV" ]; then
622 log "no $MDSDEV existing, so mount Lustre to create one"
624 check_mount || return 41
628 [ -f "$MDSDEV" ] && LOOPOPT="-o loop"
630 log "change the mode of $MDSDEV/OBJECTS,LOGS,PENDING to 555"
631 do_facet mds "mkdir -p $TMPMTPT &&
632 mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
633 chmod 555 $TMPMTPT/{OBJECTS,LOGS,PENDING} &&
634 umount $TMPMTPT" || return $?
636 log "mount Lustre to change the mode of OBJECTS/LOGS/PENDING, then umount Lustre"
638 check_mount || return 41
641 log "read the mode of OBJECTS/LOGS/PENDING and check if they has been changed properly"
642 EXPECTEDOBJECTSMODE=`do_facet mds "debugfs -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
643 EXPECTEDLOGSMODE=`do_facet mds "debugfs -R 'stat LOGS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
644 EXPECTEDPENDINGMODE=`do_facet mds "debugfs -R 'stat PENDING' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
646 if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
647 log "Success:Lustre change the mode of OBJECTS correctly"
649 error "Lustre does not change mode of OBJECTS properly"
652 if [ "$EXPECTEDLOGSMODE" = "0777" ]; then
653 log "Success:Lustre change the mode of LOGS correctly"
655 error "Lustre does not change mode of LOGS properly"
658 if [ "$EXPECTEDPENDINGMODE" = "0777" ]; then
659 log "Success:Lustre change the mode of PENDING correctly"
661 error "Lustre does not change mode of PENDING properly"
664 run_test 16 "verify that lustre will correct the mode of OBJECTS/LOGS/PENDING"
667 if [ ! -e "$MDSDEV" ]; then
668 echo "no $MDSDEV existing, so mount Lustre to create one"
670 check_mount || return 41
674 echo "Remove mds config log"
675 do_facet mds "debugfs -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
678 start_mds && return 42
681 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
684 [ -f $MDSDEV ] && echo "remove $MDSDEV" && rm -f $MDSDEV
685 echo "mount mds with large journal..."
686 local myMDSSIZE=2000000
687 OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
689 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
692 echo "mount lustre system..."
694 check_mount || return 41
696 echo "check journal size..."
697 FOUNDSIZE=`do_facet mds "debugfs -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
698 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
699 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
701 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
706 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
709 run_test 18 "check mkfs creates large journals"
712 start_mds || return 1
713 stop_mds -f || return 2
715 run_test 19a "start/stop MDS without OSTs"
718 start_ost || return 1
719 stop_ost -f || return 2
721 run_test 19b "start/stop OSTs without MDS"
724 # first format the ost/mdt
728 check_mount || return 43
730 remount_client ro $MOUNT || return 44
731 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
732 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
733 remount_client rw $MOUNT || return 47
735 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
736 MCNT=`grep -c $MOUNT /etc/mtab`
737 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
742 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
750 run_test 21a "start mds before ost, stop ost first"
758 run_test 21b "start ost before mds, stop mds first"
768 run_test 21c "start mds between two osts, stop mds last"
771 #reformat to remove all logs
774 echo Client mount before any osts are in the logs
776 check_mount && return 41
779 echo Client mount with ost in logs, but none running
783 # check_mount will block trying to contact ost
787 echo Client mount with a running ost
791 check_mount || return 41
796 run_test 22 "start a client before osts (should return errs)"
802 # force down client so that recovering mds waits for reconnect
803 zconf_umount `hostname` $MOUNT -f
804 # enter recovery on mds
806 # try to start a new client
807 mount_client $MOUNT &
810 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
811 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
813 ps --ppid $MOUNT_LUSTRE_PID
814 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
815 kill -TERM $MOUNT_PID
816 echo "waiting for mount to finish"
823 #this test isn't working yet
824 #run_test 23 "interrupt client during recovery mount delay"
827 local fs2mds_HOST=$mds_HOST
828 local fs2ost_HOST=$ost_HOST
830 [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ] && [ -b "$MDSDEV" ] && \
831 log "mixed loopback and real device not working" && return
833 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
834 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
836 # test 8-char fsname as well
837 local FSNAME2=test1234
838 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
840 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
843 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
844 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
846 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
848 check_mount || return 2
849 # files written on 1 should not show up on 2
850 cp /etc/passwd $DIR/$tfile
852 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
855 cp /etc/passwd $MOUNT2/b || return 3
856 rm $MOUNT2/b || return 4
857 # 2 is actually mounted
858 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
860 facet_failover fs2mds
861 facet_failover fs2ost
864 # the MDS must remain up until last MDT
866 MDS=$(do_facet mds "cat $LPROC/devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
867 [ -z "$MDS" ] && error "No MDT" && return 8
871 cleanup_nocli || return 6
873 run_test 24a "Multiple MDTs on a single node"
876 local fs2mds_HOST=$mds_HOST
877 [ -z "$fs2mds_DEV" ] && [ -b "$MDSDEV" ] && \
878 log "mixed loopback and real device not working" && return
880 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
882 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
884 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
887 run_test 24b "Multiple MGSs on a single node (should return err)"
891 check_mount || return 2
892 local MODULES=$($LCTL modules | awk '{ print $2 }')
893 rmmod $MODULES 2>/dev/null || true
896 run_test 25 "Verify modules are referenced"
900 # we need modules before mount for sysctl, so make sure...
901 do_facet mds "lsmod | grep -q lustre || modprobe lustre"
902 #define OBD_FAIL_MDS_FS_SETUP 0x135
903 do_facet mds "sysctl -w lustre.fail_loc=0x80000135"
904 start_mds && echo MDS started && return 1
906 DEVS=$(cat $LPROC/devices | wc -l)
907 [ $DEVS -gt 0 ] && return 2
908 unload_modules || return 203
910 run_test 26 "MDT startup failure cleans LOV (should return errs)"
916 local ORIG=$(do_facet $myfacet "$TEST")
917 if [ $# -gt 3 ]; then
923 echo "Setting $PARAM from $ORIG to $FINAL"
924 do_facet mds "$LCTL conf_param $PARAM=$FINAL" || error conf_param failed
930 RESULT=$(do_facet $myfacet "$TEST")
931 if [ $RESULT -eq $FINAL ]; then
932 echo "Updated config after $WAIT sec (got $RESULT)"
936 if [ $WAIT -eq $MAX ]; then
937 echo "Config update not seen: wanted $FINAL got $RESULT"
940 echo "Waiting $(($MAX - $WAIT)) secs for config update"
945 start_ost || return 1
946 start_mds || return 2
947 echo "Requeue thread should have started: "
948 ps -e | grep ll_cfg_requeue
949 set_and_check ost1 "cat $LPROC/obdfilter/$FSNAME-OST0000/client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
952 run_test 27a "Reacquire MGS lock if OST started first"
957 set_and_check mds "cat $LPROC/mdt/$FSNAME-MDT0000/identity_acquire_expire" "$FSNAME-MDT0000.mdt.identity_acquire_expire" || return 3
958 set_and_check client "cat $LPROC/mdc/$FSNAME-MDT0000-mdc-*/max_rpcs_in_flight" "$FSNAME-MDT0000.mdc.max_rpcs_in_flight" || return 4
961 run_test 27b "Reacquire MGS lock after failover"
965 TEST="cat $LPROC/llite/$FSNAME-*/max_read_ahead_whole_mb"
968 FINAL=$(($ORIG + 10))
969 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
970 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
971 umount_client $MOUNT || return 200
974 if [ $RESULT -ne $FINAL ]; then
975 echo "New config not seen: wanted $FINAL got $RESULT"
978 echo "New config success: got $RESULT"
982 run_test 28 "permanent parameter setting"
985 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2, skipping" && return
986 setup > /dev/null 2>&1
990 local PARAM="$FSNAME-OST0001.osc.active"
991 local PROC_ACT="$LPROC/osc/$FSNAME-OST0001-osc-[^M]*/active"
992 local PROC_UUID="$LPROC/osc/$FSNAME-OST0001-osc-[^M]*/ost_server_uuid"
993 if [ ! -r $PROC_ACT ]; then
994 echo "Can't read $PROC_ACT"
995 ls $LPROC/osc/$FSNAME-*
998 ACTV=$(cat $PROC_ACT)
1000 set_and_check client "cat $PROC_ACT" "$PARAM" $DEAC || return 2
1001 # also check ost_server_uuid status
1002 RESULT=$(grep DEACTIV $PROC_UUID)
1003 if [ -z "$RESULT" ]; then
1004 echo "Live client not deactivated: $(cat $PROC_UUID)"
1007 echo "Live client success: got $RESULT"
1011 local MPROC="$LPROC/osc/$FSNAME-OST0001-osc-[M]*/active"
1016 RESULT=`do_facet mds " [ -r $MPROC ] && cat $MPROC"`
1017 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1018 if [ $RESULT -eq $DEAC ]; then
1019 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
1023 if [ $WAIT -eq $MAX ]; then
1024 echo "MDT not deactivated: wanted $DEAC got $RESULT"
1027 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
1030 # test new client starts deactivated
1031 umount_client $MOUNT || return 200
1033 RESULT=$(grep DEACTIV $PROC_UUID | grep NEW)
1034 if [ -z "$RESULT" ]; then
1035 echo "New client not deactivated from start: $(cat $PROC_UUID)"
1038 echo "New client success: got $RESULT"
1041 # make sure it reactivates
1042 set_and_check client "cat $PROC_ACT" "$PARAM" $ACTV || return 6
1044 umount_client $MOUNT
1047 #writeconf to remove all ost2 traces for subsequent tests
1050 run_test 29 "permanently remove an OST"
1053 # start mds first after writeconf
1057 TEST="cat $LPROC/llite/$FSNAME-*/max_read_ahead_whole_mb"
1059 for i in $(seq 1 20); do
1060 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1062 # make sure client restart still works
1063 umount_client $MOUNT
1064 mount_client $MOUNT || return 4
1065 [ "$($TEST)" -ne "$i" ] && return 5
1066 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
1069 run_test 30 "Big config llog"
1071 test_31() { # bug 10734
1072 # ipaddr must not exist
1073 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1076 run_test 31 "Connect to non-existent node (shouldn't crash)"
1079 # XXX - make this run on client-only systems with real hardware on
1081 # there appears to be a lot of assumption here about loopback
1083 # or maybe this test is just totally useless on a client-only system
1084 [ -z "$TUNEFS" ] && skip "No tunefs" && return
1085 local DISK1_4=$LUSTRE/tests/disk1_4.zip
1086 [ ! -r $DISK1_4 ] && skip "Cant find $DISK1_4, skipping" && return
1087 unzip -o -j -d $TMP/$tdir $DISK1_4 || { skip "Cant unzip $DISK1_4, skipping" && return ; }
1089 sysctl lnet.debug=$PTLDEBUG
1091 $TUNEFS $TMP/$tdir/mds || error "tunefs failed"
1092 # nids are wrong, so client wont work, but server should start
1093 start mds $TMP/$tdir/mds "-o loop,exclude=lustre-OST0000" || return 3
1094 local UUID=$(cat $LPROC/mds/lustre-MDT0000/uuid)
1096 [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
1098 $TUNEFS --mgsnode=`hostname` $TMP/$tdir/ost1 || error "tunefs failed"
1099 start ost1 $TMP/$tdir/ost1 "-o loop" || return 5
1100 UUID=$(cat $LPROC/obdfilter/lustre-OST0000/uuid)
1102 [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
1104 local NID=$($LCTL list_nids | head -1)
1106 echo "OSC changes should return err:"
1107 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 && return 7
1108 $LCTL conf_param lustre-OST0000.failover.node=$NID && return 8
1110 echo "MDC changes should succeed:"
1111 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1112 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1115 # With a new good MDT failover nid, we should be able to mount a client
1116 # (but it cant talk to OST)
1117 local OLDMOUNTOPT=$MOUNTOPT
1118 MOUNTOPT="exclude=lustre-OST0000"
1120 MOUNTOPT=$OLDMOUNTOPT
1121 set_and_check client "cat $LPROC/mdc/*/max_rpcs_in_flight" "lustre-MDT0000.mdc.max_rpcs_in_flight" || return 11
1123 zconf_umount `hostname` $MOUNT -f
1126 # mount a second time to make sure we didnt leave upgrade flag on
1127 $TUNEFS --dryrun $TMP/$tdir/mds || error "tunefs failed"
1128 start mds $TMP/$tdir/mds "-o loop,exclude=lustre-OST0000" || return 12
1131 [ -d $TMP/$tdir ] && rm -rf $TMP/$tdir
1133 run_test 32a "Upgrade from 1.4 (not live)"
1136 # XXX - make this run on client-only systems with real hardware on
1138 # there appears to be a lot of assumption here about loopback
1140 # or maybe this test is just totally useless on a client-only system
1141 [ -z "$TUNEFS" ] && skip "No tunefs" && return
1142 local DISK1_4=$LUSTRE/tests/disk1_4.zip
1143 [ ! -r $DISK1_4 ] && skip "Cant find $DISK1_4, skipping" && return
1144 unzip -o -j -d $TMP/$tdir $DISK1_4 || { skip "Cant unzip $DISK1_4, skipping" && return ; }
1146 sysctl lnet.debug=$PTLDEBUG
1148 # writeconf will cause servers to register with their current nids
1149 $TUNEFS --writeconf $TMP/$tdir/mds || error "tunefs failed"
1150 start mds $TMP/$tdir/mds "-o loop" || return 3
1151 local UUID=$(cat $LPROC/mds/lustre-MDT0000/uuid)
1153 [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
1155 $TUNEFS --mgsnode=`hostname` $TMP/$tdir/ost1 || error "tunefs failed"
1156 start ost1 $TMP/$tdir/ost1 "-o loop" || return 5
1157 UUID=$(cat $LPROC/obdfilter/lustre-OST0000/uuid)
1159 [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
1161 echo "OSC changes should succeed:"
1162 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1163 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1165 echo "MDC changes should succeed:"
1166 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1169 # MDT and OST should have registered with new nids, so we should have
1170 # a fully-functioning client
1171 echo "Check client and old fs contents"
1173 set_and_check client "cat $LPROC/mdc/*/max_rpcs_in_flight" "${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight" || return 11
1174 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "2479747619 779" ] || return 12
1178 [ -d $TMP/$tdir ] && rm -rf $TMP/$tdir
1180 run_test 32b "Upgrade from 1.4 with writeconf"
1182 test_33() { # bug 12333
1183 local FSNAME2=test1234
1184 local fs2mds_HOST=$mds_HOST
1185 local fs2ost_HOST=$ost_HOST
1187 [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ] && [ -b "$MDSDEV" ] && \
1188 log "mixed loopback and real device not working" && return
1190 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1191 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1192 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1193 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=`hostname`@tcp --reformat $fs2ostdev || exit 10
1195 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1196 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1198 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1204 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1205 cleanup_nocli || return 6
1207 run_test 33 "Mount ost with a large index number"
1212 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1213 # Drop lock cancelation reply during umount
1214 #define OBD_FAIL_LDLM_CANCEL 0x304
1215 do_facet client sysctl -w lustre.fail_loc=0x80000304
1216 #sysctl -w lnet.debug=-1
1217 umount_client $MOUNT
1220 run_test 34 "Drop cancel during umount"
1224 do_facet client multiop $DIR/file O_c &
1226 manual_umount_client
1228 do_facet client killall -USR1 multiop
1229 if [ $rc -eq 0 ]; then
1230 error "umount not fail!"
1235 run_test 34a "umount with opened file should be fail"
1240 touch $DIR/$tfile || return 1
1241 stop_mds --force || return 2
1243 manual_umount_client --force
1245 if [ $rc -ne 0 ]; then
1246 error "mtab after failed umount - rc $rc"
1252 run_test 34b "force umount with failed mds should be normal"
1256 touch $DIR/$tfile || return 1
1257 stop_ost --force || return 2
1259 manual_umount_client --force
1261 if [ $rc -ne 0 ]; then
1262 error "mtab after failed umount - rc $rc"
1268 run_test 34c "force umount with failed mds should be normal"
1270 test_35() { # bug 12459
1273 DBG_SAVE="`sysctl -n lnet.debug`"
1274 sysctl -w lnet.debug="ha"
1276 log "Set up a fake failnode for the MDS"
1278 do_facet mds $LCTL conf_param ${FSNAME}-MDT0000.failover.node=$FAKENID || return 4
1280 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1283 MSG="conf-sanity.sh test_33 `date +%F%kh%Mm%Ss`"
1286 log "Stopping the MDT:"
1287 stop_mds || return 5
1289 df $MOUNT > /dev/null 2>&1 &
1291 log "Restarting the MDT:"
1292 start_mds || return 6
1293 log "Wait for df ($DFPID) ... "
1296 sysctl -w lnet.debug="$DBG_SAVE"
1298 # retrieve from the log the first server that the client tried to
1299 # contact after the connection loss
1300 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1301 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1302 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1304 if (\\\$NF ~ /$FAKENID/)
1310 }" $TMP/lustre-log-$TESTNAME.log`
1311 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1314 run_test 35 "Reconnect to the last active server first"
1318 local FSNAME2=test1234
1319 local fs2mds_HOST=$mds_HOST
1320 local fs2ost_HOST=$ost_HOST
1321 local fs3ost_HOST=$ost_HOST
1324 [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ] && [ -b "$MDSDEV" ] && \
1325 log "mixed loopback and real device not working" && return
1327 [ $OSTCOUNT -lt 2 ] && skip "skipping test for single OST" && return
1329 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1330 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1331 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1332 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1333 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b1024' --fsname=${FSNAME2} --mgsnode=`hostname`@tcp --reformat $fs2ostdev || exit 10
1334 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=`hostname`@tcp --reformat $fs3ostdev || exit 10
1336 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1337 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1338 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1340 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1342 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1343 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
1344 skip "skipping test for remote OST" && return
1345 BKTOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
1346 $LPROC/obdfilter/*/kbytestotal`
1347 BKFREE=`awk 'BEGIN{free=0}; {free+=$1}; END{print free}' \
1348 $LPROC/obdfilter/*/kbytesfree`
1349 BKAVAIL=`awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}' \
1350 $LPROC/obdfilter/*/kbytesavail`
1351 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1352 DFTOTAL=`echo $STRING | cut -d, -f1`
1353 DFUSED=`echo $STRING | cut -d, -f2`
1354 DFAVAIL=`echo $STRING | cut -d, -f3`
1355 DFFREE=$(($DFTOTAL - $DFUSED))
1357 ALLOWANCE=$((64 * $OSTCOUNT))
1359 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1360 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1361 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1364 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1365 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1366 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1369 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1370 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1371 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1376 stop fs3ost -f || return 200
1377 stop fs2ost -f || return 201
1378 stop fs2mds -f || return 202
1379 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1380 unload_modules || return 203
1383 run_test 36 "df report consistency on OSTs with different block size"
1385 umount_client $MOUNT
1389 equals_msg `basename $0`: test complete
1390 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true