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 18"
17 # bug number for skipped test:
18 ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT $MOUNTCONFSKIP 16 23"
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
22 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
24 PTLDEBUG=${PTLDEBUG:--1}
25 LUSTRE=${LUSTRE:-`dirname $0`/..}
26 RLUSTRE=${RLUSTRE:-$LUSTRE}
27 MOUNTLUSTRE=${MOUNTLUSTRE:-/sbin/mount.lustre}
28 MKFSLUSTRE=${MKFSLUSTRE:-/usr/sbin/mkfs.lustre}
31 . $LUSTRE/tests/test-framework.sh
33 # use small MDS + OST size to speed formatting time
36 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
47 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
48 do_facet ${facet} "$TUNEFS --writeconf $MDSDEV" || echo "tunefs failed, reformatting instead" && reformat
53 # The MGS must be started before the OSTs for a new fs, so start
54 # and stop to generate the startup logs.
63 echo "start mds service on `facet_active_host mds`"
64 start mds $MDSDEV $MDS_MOUNT_OPTS || return 94
68 echo "stop mds service on `facet_active_host mds`"
69 # These tests all use non-failover stop
70 stop mds -f || return 97
74 echo "start ost1 service on `facet_active_host ost1`"
75 start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95
79 echo "stop ost1 service on `facet_active_host ost1`"
80 # These tests all use non-failover stop
81 stop ost1 -f || return 98
85 echo "start ost2 service on `facet_active_host ost2`"
86 start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92
90 echo "stop ost2 service on `facet_active_host ost2`"
91 # These tests all use non-failover stop
92 stop ost2 -f || return 93
97 echo "mount $FSNAME on ${MOUNTPATH}....."
98 zconf_mount `hostname` $MOUNTPATH || return 96
102 local SAVEMOUNTOPT=$MOUNTOPT
103 MOUNTOPT="remount,$1"
105 echo "remount '$1' lustre on ${MOUNTPATH}....."
106 zconf_mount `hostname` $MOUNTPATH || return 96
107 MOUNTOPT=$SAVEMOUNTOPT
112 echo "umount lustre on ${MOUNTPATH}....."
113 zconf_umount `hostname` $MOUNTPATH || return 97
116 manual_umount_client(){
117 echo "manual umount lustre on ${MOUNT}...."
118 do_facet client "umount -d $MOUNT"
128 stop_mds || return 201
129 stop_ost || return 202
130 unload_modules || return 203
134 umount_client $MOUNT || return 200
135 cleanup_nocli || return $?
139 do_facet client "cp /etc/passwd $DIR/a" || return 71
140 do_facet client "rm $DIR/a" || return 72
141 # make sure lustre is actually mounted (touch will block,
142 # but grep won't, so do it after)
143 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
144 echo "setup single mount lustre success"
148 do_facet client "touch $DIR/a" || return 71
149 do_facet client "rm $DIR/a" || return 72
150 do_facet client "touch $DIR2/a" || return 73
151 do_facet client "rm $DIR2/a" || return 74
152 echo "setup double mount lustre success"
157 if [ "$ONLY" == "setup" ]; then
162 if [ "$ONLY" == "cleanup" ]; then
167 #create single point mountpoint
175 check_mount || return 41
178 run_test 0 "single mount setup"
182 echo "start ost second time..."
184 check_mount || return 42
187 run_test 1 "start up ost twice (should return errors)"
192 echo "start mds second time.."
195 check_mount || return 43
198 run_test 2 "start up mds twice (should return err)"
202 #mount.lustre returns an error if already in mtab
203 mount_client $MOUNT && return $?
204 check_mount || return 44
207 run_test 3 "mount client twice (should return err)"
211 touch $DIR/$tfile || return 85
215 # ok for ost to fail shutdown
216 if [ 202 -ne $eno ]; then
221 run_test 4 "force cleanup ost, then cleanup"
225 touch $DIR/$tfile || return 1
226 stop_mds -f || return 2
228 # cleanup may return an error from the failed
229 # disconnects; for now I'll consider this successful
230 # if all the modules have unloaded.
234 echo "killing umount"
235 kill -TERM $UMOUNT_PID
236 echo "waiting for umount to finish"
238 if grep " $MOUNT " /etc/mtab; then
239 echo "test 5: mtab after failed umount"
243 echo "killing umount"
244 kill -TERM $UMOUNT_PID
245 echo "waiting for umount to finish"
247 grep " $MOUNT " /etc/mtab && echo "test 5: mtab after second umount" && return 11
251 # stop_mds is a no-op here, and should not fail
252 cleanup_nocli || return $?
253 # df may have lingering entry
255 # mtab may have lingering entry
256 grep -v $MOUNT" " /etc/mtab > $TMP/mtabtemp
257 mv $TMP/mtabtemp /etc/mtab
259 run_test 5 "force cleanup mds, then cleanup"
263 [ -d $MOUNT ] || mkdir -p $MOUNT
264 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
265 mount_client $MOUNT && return 1
266 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
268 # stop_mds is a no-op here, and should not fail
269 cleanup_nocli || return $?
272 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
277 [ -d $MOUNT ] || mkdir -p $MOUNT
278 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
279 mount -t lustre $MGSNID:/wrong.$FSNAME $MOUNT || :
280 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
282 cleanup_nocli || return $?
284 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
290 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
291 mount_client $MOUNT || return 1
293 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
296 run_test 5d "mount with ost down"
301 # give MDS a chance to connect to OSTs (bz 10476)
304 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
305 do_facet client "sysctl -w lustre.fail_loc=0x80000506"
306 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
307 mount_client $MOUNT || echo "mount failed (not fatal)"
309 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
312 run_test 5e "delayed connect, don't crash (bug 10268)"
317 mount_client ${MOUNT} || return 87
318 touch $DIR/a || return 86
321 run_test 6 "manual umount, then mount again"
326 cleanup_nocli || return $?
328 run_test 7 "manual umount, then cleanup"
333 check_mount2 || return 45
334 umount_client $MOUNT2
337 run_test 8 "double mount setup"
342 do_facet ost1 sysctl lnet.debug=\'inode trace\' || return 1
343 do_facet ost1 sysctl lnet.subsystem_debug=\'mds ost\' || return 1
345 CHECK_PTLDEBUG="`do_facet ost1 sysctl -n lnet.debug`"
346 if [ "$CHECK_PTLDEBUG" ] && [ "$CHECK_PTLDEBUG" = "trace inode" ];then
347 echo "lnet.debug success"
349 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
352 CHECK_SUBSYS="`do_facet ost1 sysctl -n lnet.subsystem_debug`"
353 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
354 echo "lnet.subsystem_debug success"
356 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
359 stop_ost || return $?
362 run_test 9 "test ptldebug and subsystem for mkfs"
365 echo "generate configuration with the same name for node and mds"
366 OLDXMLCONFIG=$XMLCONFIG
367 XMLCONFIG="broken.xml"
368 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
372 echo "the name for node and mds is the same"
373 do_lmc --add mds --node ${facet}_facet --mds ${facet}_facet \
374 --dev $MDSDEV --size $MDSSIZE || return $?
375 do_lmc --add lov --mds ${facet}_facet --lov lov1 --stripe_sz \
376 $STRIPE_BYTES --stripe_cnt $STRIPES_PER_OBJ \
377 --stripe_pattern 0 || return $?
378 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
380 add_facet $facet --lustre_upcall $UPCALL
381 do_lmc --add mtpt --node ${facet}_facet --mds mds_facet \
382 --lov lov1 --path $MOUNT
388 check_mount || return 41
392 XMLCONFIG=$OLDXMLCONFIG
394 run_test 10 "mount lustre with the same name for node and mds"
397 OLDXMLCONFIG=$XMLCONFIG
398 XMLCONFIG="conf11.xml"
400 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
401 add_mds mds --dev $MDSDEV --size $MDSSIZE
402 add_ost ost --dev $OSTDEV --size $OSTSIZE
403 add_client client mds --path $MOUNT --ost ost_svc || return $?
404 echo "Default lov config success!"
406 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
407 add_mds mds --dev $MDSDEV --size $MDSSIZE
408 add_ost ost --dev $OSTDEV --size $OSTSIZE
409 add_client client mds --path $MOUNT && return $?
410 echo "--add mtpt with neither --lov nor --ost will return error"
414 XMLCONFIG=$OLDXMLCONFIG
416 run_test 11 "use default lov configuration (should return error)"
419 OLDXMLCONFIG=$XMLCONFIG
420 XMLCONFIG="batch.xml"
421 BATCHFILE="batchfile"
424 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
425 [ -f "$BATCHFILE" ] && rm -f $BATCHFILE
426 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
427 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions \"-I 128\"" >> $BATCHFILE
428 # --mkfsoptions "-I 128"
429 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
430 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
431 echo "matched double quote success"
433 echo "matched double quote fail"
438 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
439 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions \"-I 128" >> $BATCHFILE
440 # --mkfsoptions "-I 128
441 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
442 echo "unmatched double quote should return error"
446 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
447 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions '-I 128'" >> $BATCHFILE
448 # --mkfsoptions '-I 128'
449 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
450 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
451 echo "matched single quote success"
453 echo "matched single quote fail"
458 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
459 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions '-I 128" >> $BATCHFILE
460 # --mkfsoptions '-I 128
461 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
462 echo "unmatched single quote should return error"
466 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
467 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions \-\I\ \128" >> $BATCHFILE
468 # --mkfsoptions \-\I\ \128
469 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
470 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
471 echo "backslash followed by a whitespace/letter success"
473 echo "backslash followed by a whitespace/letter fail"
478 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
479 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions -I\ 128\\" >> $BATCHFILE
480 # --mkfsoptions -I\ 128\
481 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
482 echo "backslash followed by nothing should return error"
485 XMLCONFIG=$OLDXMLCONFIG
487 run_test 12 "lmc --batch, with single/double quote, backslash in batchfile"
490 OLDXMLCONFIG=$XMLCONFIG
491 XMLCONFIG="conf13-1.xml"
493 # check long uuid will be truncated properly and uniquely
494 echo "To generate XML configuration file(with long ost name): $XMLCONFIG"
495 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
496 do_lmc --add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp
497 do_lmc --add mds --node $HOSTNAME --mds mds1_name_longer_than_31characters
498 do_lmc --add mds --node $HOSTNAME --mds mds2_name_longer_than_31characters
499 if [ ! -f "$XMLCONFIG" ]; then
500 echo "Error:no file $XMLCONFIG created!"
503 EXPECTEDMDS1UUID="e_longer_than_31characters_UUID"
504 EXPECTEDMDS2UUID="longer_than_31characters_UUID_2"
505 FOUNDMDS1UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '1p' \
506 | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
507 FOUNDMDS2UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '2p' \
508 | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
509 [ -z "$FOUNDMDS1UUID" ] && echo "MDS1 UUID empty" && return 1
510 [ -z "$FOUNDMDS2UUID" ] && echo "MDS2 UUID empty" && return 1
511 if ([ $EXPECTEDMDS1UUID = $FOUNDMDS1UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS2UUID ]) || \
512 ([ $EXPECTEDMDS1UUID = $FOUNDMDS2UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS1UUID ]); then
513 echo "Success:long uuid truncated successfully and being unique."
515 echo "Error:expected uuid for mds1 and mds2: $EXPECTEDMDS1UUID; $EXPECTEDMDS2UUID"
516 echo "but: found uuid for mds1 and mds2: $FOUNDMDS1UUID; $FOUNDMDS2UUID"
520 XMLCONFIG=$OLDXMLCONFIG
522 run_test 13 "check new_uuid of lmc operating correctly"
525 OLDXMLCONFIG=$XMLCONFIG
526 XMLCONFIG="conf13-1.xml"
527 SECONDXMLCONFIG="conf13-2.xml"
528 # check multiple invocations for lmc generate same XML configuration file
530 echo "Generate the first XML configuration file"
532 echo "mv $XMLCONFIG to $SECONDXMLCONFIG"
533 sed -e "s/mtime[^ ]*//" $XMLCONFIG > $SECONDXMLCONFIG || return $?
534 echo "Generate the second XML configuration file"
536 # don't compare .xml mtime, it will always be different
537 if [ `sed -e "s/mtime[^ ]*//" $XMLCONFIG | diff - $SECONDXMLCONFIG | wc -l` -eq 0 ]; then
538 echo "Success:multiple invocations for lmc generate same XML file"
540 echo "Error: multiple invocations for lmc generate different XML file"
544 rm -f $XMLCONFIG $SECONDXMLCONFIG
545 XMLCONFIG=$OLDXMLCONFIG
547 run_test 13b "check lmc generates consistent .xml file"
552 # create xml file with --mkfsoptions for ost
553 echo "create xml file with --mkfsoptions for ost"
554 add_mds mds --dev $MDSDEV --size $MDSSIZE
555 add_lov lov1 mds --stripe_sz $STRIPE_BYTES\
556 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
557 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE \
558 --mkfsoptions "-Llabel_conf_14"
559 add_client client mds --lov lov1 --path $MOUNT
561 FOUNDSTRING=`awk -F"<" '/<mkfsoptions>/{print $2}' $XMLCONFIG`
562 EXPECTEDSTRING="mkfsoptions>-Llabel_conf_14"
563 if [ "$EXPECTEDSTRING" != "$FOUNDSTRING" ]; then
564 echo "Error: expected: $EXPECTEDSTRING; found: $FOUNDSTRING"
567 echo "Success:mkfsoptions for ost written to xml file correctly."
569 # mount lustre to test lconf mkfsoptions-parsing
573 mount_client $MOUNT || return $?
574 if [ -z "`do_facet ost1 dumpe2fs -h $OSTDEV | grep label_conf_14`" ]; then
575 echo "Error: the mkoptions not applied to mke2fs of ost."
579 echo "lconf mkfsoptions for ost success"
583 run_test 14 "test mkfsoptions of ost for lmc and lconf"
587 [ -f $MOUNTLUSTRE ] && echo "remove $MOUNTLUSTRE" && rm -f $MOUNTLUSTRE
588 if [ -f $MOUNTLUSTRE.sav ]; then
589 echo "return original $MOUNTLUSTRE.sav to $MOUNTLUSTRE"
590 mv $MOUNTLUSTRE.sav $MOUNTLUSTRE
594 # this only tests the kernel mount command, not anything about lustre.
596 MOUNTLUSTRE=${MOUNTLUSTRE:-/sbin/mount.lustre}
600 echo "mount lustre on ${MOUNT} without $MOUNTLUSTRE....."
601 if [ -f "$MOUNTLUSTRE" ]; then
602 echo "save $MOUNTLUSTRE to $MOUNTLUSTRE.sav"
603 mv $MOUNTLUSTRE $MOUNTLUSTRE.sav && trap cleanup_15 EXIT INT
604 if [ -f $MOUNTLUSTRE ]; then
605 skip "$MOUNTLUSTRE cannot be moved, skipping test"
610 mount_client $MOUNT && error "mount succeeded" && return 1
611 echo "mount lustre on $MOUNT without $MOUNTLUSTRE failed as expected"
615 run_test 15 "zconf-mount without /sbin/mount.lustre (should return error)"
618 TMPMTPT="${MOUNT%/*}/conf16"
620 if [ ! -e "$MDSDEV" ]; then
621 log "no $MDSDEV existing, so mount Lustre to create one"
623 check_mount || return 41
627 [ -f "$MDSDEV" ] && LOOPOPT="-o loop"
629 log "change the mode of $MDSDEV/OBJECTS,LOGS,PENDING to 555"
630 do_facet mds "mkdir -p $TMPMTPT &&
631 mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
632 chmod 555 $TMPMTPT/{OBJECTS,LOGS,PENDING} &&
633 umount $TMPMTPT" || return $?
635 log "mount Lustre to change the mode of OBJECTS/LOGS/PENDING, then umount Lustre"
637 check_mount || return 41
640 log "read the mode of OBJECTS/LOGS/PENDING and check if they has been changed properly"
641 EXPECTEDOBJECTSMODE=`do_facet mds "debugfs -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
642 EXPECTEDLOGSMODE=`do_facet mds "debugfs -R 'stat LOGS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
643 EXPECTEDPENDINGMODE=`do_facet mds "debugfs -R 'stat PENDING' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
645 if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
646 log "Success:Lustre change the mode of OBJECTS correctly"
648 error "Lustre does not change mode of OBJECTS properly"
651 if [ "$EXPECTEDLOGSMODE" = "0777" ]; then
652 log "Success:Lustre change the mode of LOGS correctly"
654 error "Lustre does not change mode of LOGS properly"
657 if [ "$EXPECTEDPENDINGMODE" = "0777" ]; then
658 log "Success:Lustre change the mode of PENDING correctly"
660 error "Lustre does not change mode of PENDING properly"
663 run_test 16 "verify that lustre will correct the mode of OBJECTS/LOGS/PENDING"
666 if [ ! -e "$MDSDEV" ]; then
667 echo "no $MDSDEV existing, so mount Lustre to create one"
669 check_mount || return 41
673 echo "Remove mds config log"
674 do_facet mds "debugfs -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
677 start_mds && return 42
680 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
683 [ -f $MDSDEV ] && echo "remove $MDSDEV" && rm -f $MDSDEV
684 echo "mount mds with large journal..."
687 #FIXME have to change MDS_MKFS_OPTS
690 echo "mount lustre system..."
692 check_mount || return 41
694 echo "check journal size..."
695 FOUNDSIZE=`do_facet mds "debugfs -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
696 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
697 log "Success: mkfs creates large journals"
699 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
707 run_test 18 "check mkfs creates large journals"
710 start_mds || return 1
711 stop_mds -f || return 2
713 run_test 19a "start/stop MDS without OSTs"
716 start_ost || return 1
717 stop_ost -f || return 2
719 run_test 19b "start/stop OSTs without MDS"
722 # first format the ost/mdt
726 check_mount || return 43
728 remount_client ro $MOUNT || return 44
729 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
730 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
731 remount_client rw $MOUNT || return 47
733 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
734 MCNT=`grep -c $MOUNT /etc/mtab`
735 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
740 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
748 run_test 21a "start mds before ost, stop ost first"
756 run_test 21b "start ost before mds, stop mds first"
766 run_test 21c "start mds between two osts, stop mds last"
769 #reformat to remove all logs
772 echo Client mount before any osts are in the logs
774 check_mount && return 41
777 echo Client mount with ost in logs, but none running
781 # check_mount will block trying to contact ost
785 echo Client mount with a running ost
789 check_mount || return 41
794 run_test 22 "start a client before osts (should return errs)"
800 # force down client so that recovering mds waits for reconnect
801 zconf_umount `hostname` $MOUNT -f
802 # enter recovery on mds
804 # try to start a new client
805 mount_client $MOUNT &
808 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
809 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
811 ps --ppid $MOUNT_LUSTRE_PID
812 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
813 kill -TERM $MOUNT_PID
814 echo "waiting for mount to finish"
821 #this test isn't working yet
822 #run_test 23 "interrupt client during recovery mount delay"
825 local fs2mds_HOST=$mds_HOST
826 local fs2ost_HOST=$ost_HOST
828 [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ] && [ -b "$MDSDEV" ] && \
829 log "mixed loopback and real device not working" && return
831 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
832 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
834 # test 8-char fsname as well
835 local FSNAME2=test1234
836 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
838 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
841 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
842 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
844 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
846 check_mount || return 2
847 # files written on 1 should not show up on 2
848 cp /etc/passwd $DIR/$tfile
850 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
853 cp /etc/passwd $MOUNT2/b || return 3
854 rm $MOUNT2/b || return 4
855 # 2 is actually mounted
856 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
858 facet_failover fs2mds
859 facet_failover fs2ost
862 # the MDS must remain up until last MDT
864 MDS=$(do_facet mds "cat $LPROC/devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
865 [ -z "$MDS" ] && error "No MDT" && return 8
869 cleanup_nocli || return 6
871 run_test 24a "Multiple MDTs on a single node"
874 local fs2mds_HOST=$mds_HOST
875 [ -z "$fs2mds_DEV" ] && [ -b "$MDSDEV" ] && \
876 log "mixed loopback and real device not working" && return
878 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
880 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
882 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
885 run_test 24b "Multiple MGSs on a single node (should return err)"
889 check_mount || return 2
890 local MODULES=$($LCTL modules | awk '{ print $2 }')
891 rmmod $MODULES 2>/dev/null || true
894 run_test 25 "Verify modules are referenced"
898 # we need modules before mount for sysctl, so make sure...
899 do_facet mds "lsmod | grep -q lustre || modprobe lustre"
900 #define OBD_FAIL_MDS_FS_SETUP 0x135
901 do_facet mds "sysctl -w lustre.fail_loc=0x80000135"
902 start_mds && echo MDS started && return 1
904 DEVS=$(cat $LPROC/devices | wc -l)
905 [ $DEVS -gt 0 ] && return 2
906 unload_modules || return 203
908 run_test 26 "MDT startup failure cleans LOV (should return errs)"
914 local ORIG=$(do_facet $myfacet "$TEST")
915 if [ $# -gt 3 ]; then
921 echo "Setting $PARAM from $ORIG to $FINAL"
922 do_facet mds "$LCTL conf_param $PARAM=$FINAL" || error conf_param failed
928 RESULT=$(do_facet $myfacet "$TEST")
929 if [ $RESULT -eq $FINAL ]; then
930 echo "Updated config after $WAIT sec (got $RESULT)"
934 if [ $WAIT -eq $MAX ]; then
935 echo "Config update not seen: wanted $FINAL got $RESULT"
938 echo "Waiting $(($MAX - $WAIT)) secs for config update"
943 start_ost || return 1
944 start_mds || return 2
945 echo "Requeue thread should have started: "
946 ps -e | grep ll_cfg_requeue
947 set_and_check ost1 "cat $LPROC/obdfilter/$FSNAME-OST0000/client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
950 run_test 27a "Reacquire MGS lock if OST started first"
955 set_and_check mds "cat $LPROC/mdt/$FSNAME-MDT0000/identity_acquire_expire" "$FSNAME-MDT0000.mdt.identity_acquire_expire" || return 3
956 set_and_check client "cat $LPROC/mdc/$FSNAME-MDT0000-mdc-*/max_rpcs_in_flight" "$FSNAME-MDT0000.mdc.max_rpcs_in_flight" || return 4
959 run_test 27b "Reacquire MGS lock after failover"
963 TEST="cat $LPROC/llite/$FSNAME-*/max_read_ahead_whole_mb"
966 FINAL=$(($ORIG + 10))
967 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
968 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
969 umount_client $MOUNT || return 200
972 if [ $RESULT -ne $FINAL ]; then
973 echo "New config not seen: wanted $FINAL got $RESULT"
976 echo "New config success: got $RESULT"
980 run_test 28 "permanent parameter setting"
983 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2, skipping" && return
984 setup > /dev/null 2>&1
988 local PARAM="$FSNAME-OST0001.osc.active"
989 local PROC_ACT="$LPROC/osc/$FSNAME-OST0001-osc-[^M]*/active"
990 local PROC_UUID="$LPROC/osc/$FSNAME-OST0001-osc-[^M]*/ost_server_uuid"
991 if [ ! -r $PROC_ACT ]; then
992 echo "Can't read $PROC_ACT"
993 ls $LPROC/osc/$FSNAME-*
996 ACTV=$(cat $PROC_ACT)
998 set_and_check client "cat $PROC_ACT" "$PARAM" $DEAC || return 2
999 # also check ost_server_uuid status
1000 RESULT=$(grep DEACTIV $PROC_UUID)
1001 if [ -z "$RESULT" ]; then
1002 echo "Live client not deactivated: $(cat $PROC_UUID)"
1005 echo "Live client success: got $RESULT"
1009 local MPROC="$LPROC/osc/$FSNAME-OST0001-osc-[M]*/active"
1014 RESULT=`do_facet mds " [ -r $MPROC ] && cat $MPROC"`
1015 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1016 if [ $RESULT -eq $DEAC ]; then
1017 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
1021 if [ $WAIT -eq $MAX ]; then
1022 echo "MDT not deactivated: wanted $DEAC got $RESULT"
1025 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
1028 # test new client starts deactivated
1029 umount_client $MOUNT || return 200
1031 RESULT=$(grep DEACTIV $PROC_UUID | grep NEW)
1032 if [ -z "$RESULT" ]; then
1033 echo "New client not deactivated from start: $(cat $PROC_UUID)"
1036 echo "New client success: got $RESULT"
1039 # make sure it reactivates
1040 set_and_check client "cat $PROC_ACT" "$PARAM" $ACTV || return 6
1042 umount_client $MOUNT
1045 #writeconf to remove all ost2 traces for subsequent tests
1048 run_test 29 "permanently remove an OST"
1051 # start mds first after writeconf
1055 TEST="cat $LPROC/llite/$FSNAME-*/max_read_ahead_whole_mb"
1057 for i in $(seq 1 20); do
1058 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1060 # make sure client restart still works
1061 umount_client $MOUNT
1062 mount_client $MOUNT || return 4
1063 [ "$($TEST)" -ne "$i" ] && return 5
1064 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
1067 run_test 30 "Big config llog"
1069 test_31() { # bug 10734
1070 # ipaddr must not exist
1071 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1074 run_test 31 "Connect to non-existent node (shouldn't crash)"
1077 # XXX - make this run on client-only systems with real hardware on
1079 # there appears to be a lot of assumption here about loopback
1081 # or maybe this test is just totally useless on a client-only system
1082 [ -z "$TUNEFS" ] && skip "No tunefs" && return
1083 [ ! -r disk1_4.zip ] && skip "Cant find disk1_4.zip, skipping" && return
1084 unzip -o -j -d $TMP/$tdir disk1_4.zip || { skip "Cant unzip disk1_4, skipping" && return ; }
1086 sysctl lnet.debug=$PTLDEBUG
1088 $TUNEFS $TMP/$tdir/mds || error "tunefs failed"
1089 # nids are wrong, so client wont work, but server should start
1090 start mds $TMP/$tdir/mds "-o loop,exclude=lustre-OST0000" || return 3
1091 local UUID=$(cat $LPROC/mds/lustre-MDT0000/uuid)
1093 [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
1095 $TUNEFS --mgsnode=`hostname` $TMP/$tdir/ost1 || error "tunefs failed"
1096 start ost1 $TMP/$tdir/ost1 "-o loop" || return 5
1097 UUID=$(cat $LPROC/obdfilter/lustre-OST0000/uuid)
1099 [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
1101 local NID=$($LCTL list_nids | head -1)
1103 echo "OSC changes should return err:"
1104 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 && return 7
1105 $LCTL conf_param lustre-OST0000.failover.node=$NID && return 8
1107 echo "MDC changes should succeed:"
1108 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1109 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1112 # With a new good MDT failover nid, we should be able to mount a client
1113 # (but it cant talk to OST)
1114 local OLDMOUNTOPT=$MOUNTOPT
1115 MOUNTOPT="exclude=lustre-OST0000"
1117 MOUNTOPT=$OLDMOUNTOPT
1118 set_and_check client "cat $LPROC/mdc/*/max_rpcs_in_flight" "lustre-MDT0000.mdc.max_rpcs_in_flight" || return 11
1120 zconf_umount `hostname` $MOUNT -f
1123 # mount a second time to make sure we didnt leave upgrade flag on
1124 $TUNEFS --dryrun $TMP/$tdir/mds || error "tunefs failed"
1125 start mds $TMP/$tdir/mds "-o loop,exclude=lustre-OST0000" || return 12
1128 [ -d $TMP/$tdir ] && rm -rf $TMP/$tdir
1130 run_test 32a "Upgrade from 1.4 (not live)"
1133 # XXX - make this run on client-only systems with real hardware on
1135 # there appears to be a lot of assumption here about loopback
1137 # or maybe this test is just totally useless on a client-only system
1138 [ -z "$TUNEFS" ] && skip "No tunefs" && return
1139 [ ! -r disk1_4.zip ] && skip "Cant find disk1_4.zip, skipping" && return
1140 unzip -o -j -d $TMP/$tdir disk1_4.zip || { skip "Cant unzip disk1_4, skipping" && return ; }
1142 sysctl lnet.debug=$PTLDEBUG
1144 # writeconf will cause servers to register with their current nids
1145 $TUNEFS --writeconf $TMP/$tdir/mds || error "tunefs failed"
1146 start mds $TMP/$tdir/mds "-o loop" || return 3
1147 local UUID=$(cat $LPROC/mds/lustre-MDT0000/uuid)
1149 [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
1151 $TUNEFS --mgsnode=`hostname` $TMP/$tdir/ost1 || error "tunefs failed"
1152 start ost1 $TMP/$tdir/ost1 "-o loop" || return 5
1153 UUID=$(cat $LPROC/obdfilter/lustre-OST0000/uuid)
1155 [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
1157 echo "OSC changes should succeed:"
1158 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1159 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1161 echo "MDC changes should succeed:"
1162 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1165 # MDT and OST should have registered with new nids, so we should have
1166 # a fully-functioning client
1167 echo "Check client and old fs contents"
1169 set_and_check client "cat $LPROC/mdc/*/max_rpcs_in_flight" "lustre-MDT0000.mdc.max_rpcs_in_flight" || return 11
1170 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "2479747619 779" ] || return 12
1174 [ -d $TMP/$tdir ] && rm -rf $TMP/$tdir
1176 run_test 32b "Upgrade from 1.4 with writeconf"
1178 test_33() { # bug 12333
1179 local FSNAME2=test1234
1180 local fs2mds_HOST=$mds_HOST
1181 local fs2ost_HOST=$ost_HOST
1183 [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ] && [ -b "$MDSDEV" ] && \
1184 log "mixed loopback and real device not working" && return
1186 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1187 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1188 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1189 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=`hostname`@tcp --reformat $fs2ostdev || exit 10
1191 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1192 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1194 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1200 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1201 cleanup_nocli || return 6
1203 run_test 33 "Mount ost with a large index number"
1205 test_35() { # bug 12459
1208 DBG_SAVE="`sysctl -n lnet.debug`"
1209 sysctl -w lnet.debug="ha"
1211 log "Set up a fake failnode for the MDS"
1213 $LCTL conf_param ${FSNAME}-MDT0000.failover.node=$FAKENID || return 4
1215 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1218 MSG="conf-sanity.sh test_33 `date +%F%kh%Mm%Ss`"
1221 log "Stopping the MDT:"
1222 stop_mds || return 5
1224 df $MOUNT > /dev/null 2>&1 &
1226 log "Restarting the MDT:"
1227 start_mds || return 6
1228 log "Wait for df ($DFPID) ... "
1231 sysctl -w lnet.debug="$DBG_SAVE"
1233 # retrieve from the log the first server that the client tried to
1234 # contact after the connection loss
1235 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1236 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1237 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1239 if (\\\$NF ~ /$FAKENID/)
1245 }" $TMP/lustre-log-$TESTNAME.log`
1246 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1249 run_test 35 "Reconnect to the last active server first"
1253 local FSNAME2=test1234
1254 local fs2mds_HOST=$mds_HOST
1255 local fs2ost_HOST=$ost_HOST
1256 local fs3ost_HOST=$ost_HOST
1259 [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ] && [ -b "$MDSDEV" ] && \
1260 log "mixed loopback and real device not working" && return
1262 [ $OSTCOUNT -lt 2 ] && skip "skipping test for single OST" && return
1264 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1265 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1266 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1267 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1268 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b1024' --fsname=${FSNAME2} --mgsnode=`hostname`@tcp --reformat $fs2ostdev || exit 10
1269 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=`hostname`@tcp --reformat $fs3ostdev || exit 10
1271 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1272 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1273 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1275 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1277 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1278 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
1279 skip "skipping test for remote OST" && return
1280 BKTOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
1281 $LPROC/obdfilter/*/kbytestotal`
1282 BKFREE=`awk 'BEGIN{free=0}; {free+=$1}; END{print free}' \
1283 $LPROC/obdfilter/*/kbytesfree`
1284 BKAVAIL=`awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}' \
1285 $LPROC/obdfilter/*/kbytesavail`
1286 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1287 DFTOTAL=`echo $STRING | cut -d, -f1`
1288 DFUSED=`echo $STRING | cut -d, -f2`
1289 DFAVAIL=`echo $STRING | cut -d, -f3`
1290 DFFREE=$(($DFTOTAL - $DFUSED))
1292 ALLOWANCE=$((64 * $OSTCOUNT))
1294 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1295 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1296 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1299 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1300 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1301 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1304 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1305 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1306 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1311 stop fs3ost -f || return 200
1312 stop fs2ost -f || return 201
1313 stop fs2mds -f || return 202
1314 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1315 unload_modules || return 203
1318 run_test 36 "df report consistency on OSTs with different block size"
1320 umount_client $MOUNT
1324 equals_msg `basename $0`: test complete
1325 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true