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 # xml xml xml xml xml xml dumb
16 MOUNTCONFSKIP="10 11 12 13 13b 14 15 "
18 # bug number for skipped test: 13369 12743
19 ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT $MOUNTCONFSKIP 34a 36"
20 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
23 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
26 LUSTRE=${LUSTRE:-`dirname $0`/..}
27 RLUSTRE=${RLUSTRE:-$LUSTRE}
30 . $LUSTRE/tests/test-framework.sh
32 # use small MDS + OST size to speed formatting time
35 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
46 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
47 do_facet ${facet} "$TUNEFS --writeconf $MDSDEV" || echo "tunefs failed, reformatting instead" && reformat
52 # The MGS must be started before the OSTs for a new fs, so start
53 # and stop to generate the startup logs.
62 echo "start mds service on `facet_active_host mds`"
63 start mds $MDSDEV $MDS_MOUNT_OPTS || return 94
67 echo "stop mds service on `facet_active_host mds`"
68 # These tests all use non-failover stop
69 stop mds -f || return 97
73 echo "start ost1 service on `facet_active_host ost1`"
74 start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95
78 echo "stop ost1 service on `facet_active_host ost1`"
79 # These tests all use non-failover stop
80 stop ost1 -f || return 98
84 echo "start ost2 service on `facet_active_host ost2`"
85 start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92
89 echo "stop ost2 service on `facet_active_host ost2`"
90 # These tests all use non-failover stop
91 stop ost2 -f || return 93
95 echo "start client on `facet_active_host client`"
96 start client || return 99
100 echo "stop client on `facet_active_host client`"
101 stop client || return 100
106 echo "mount $FSNAME on ${MOUNTPATH}....."
107 zconf_mount `hostname` $MOUNTPATH || return 96
111 local SAVEMOUNTOPT=$MOUNTOPT
112 MOUNTOPT="remount,$1"
114 echo "remount '$1' lustre on ${MOUNTPATH}....."
115 zconf_mount `hostname` $MOUNTPATH || return 96
116 MOUNTOPT=$SAVEMOUNTOPT
121 echo "umount lustre on ${MOUNTPATH}....."
122 zconf_umount `hostname` $MOUNTPATH || return 97
125 manual_umount_client(){
128 echo "manual umount lustre on ${MOUNT}...."
129 do_facet client "umount -d ${FORCE} $MOUNT"
141 stop_mds || return 201
142 stop_ost || return 202
143 unload_modules || return 203
147 umount_client $MOUNT || return 200
148 cleanup_nocli || return $?
152 do_facet client "cp /etc/passwd $DIR/a" || return 71
153 do_facet client "rm $DIR/a" || return 72
154 # make sure lustre is actually mounted (touch will block,
155 # but grep won't, so do it after)
156 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
157 echo "setup single mount lustre success"
161 do_facet client "touch $DIR/a" || return 71
162 do_facet client "rm $DIR/a" || return 72
163 do_facet client "touch $DIR2/a" || return 73
164 do_facet client "rm $DIR2/a" || return 74
165 echo "setup double mount lustre success"
170 if [ "$ONLY" == "setup" ]; then
175 if [ "$ONLY" == "cleanup" ]; then
180 #create single point mountpoint
187 check_mount || return 41
190 run_test 0 "single mount setup"
194 echo "start ost second time..."
196 check_mount || return 42
199 run_test 1 "start up ost twice (should return errors)"
204 echo "start mds second time.."
207 check_mount || return 43
210 run_test 2 "start up mds twice (should return err)"
214 #mount.lustre returns an error if already in mtab
215 mount_client $MOUNT && return $?
216 check_mount || return 44
219 run_test 3 "mount client twice (should return err)"
223 touch $DIR/$tfile || return 85
227 # ok for ost to fail shutdown
228 if [ 202 -ne $eno ]; then
233 run_test 4 "force cleanup ost, then cleanup"
237 touch $DIR/$tfile || return 1
238 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
240 stop_mds -f || return 2
242 # cleanup may return an error from the failed
243 # disconnects; for now I'll consider this successful
244 # if all the modules have unloaded.
248 echo "killing umount"
249 kill -TERM $UMOUNT_PID
250 echo "waiting for umount to finish"
252 if grep " $MOUNT " /proc/mounts; then
253 echo "test 5: /proc/mounts after failed umount"
257 echo "killing umount"
258 kill -TERM $UMOUNT_PID
259 echo "waiting for umount to finish"
261 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
265 # stop_mds is a no-op here, and should not fail
266 cleanup_nocli || return $?
267 # df may have lingering entry
269 # mtab may have lingering entry
270 grep -v $MOUNT" " /etc/mtab > $TMP/mtabtemp
271 mv $TMP/mtabtemp /etc/mtab
273 run_test 5 "force cleanup mds, then cleanup"
277 [ -d $MOUNT ] || mkdir -p $MOUNT
278 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
279 mount_client $MOUNT && return 1
280 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
282 # stop_mds is a no-op here, and should not fail
283 cleanup_nocli || return $?
286 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
291 [ -d $MOUNT ] || mkdir -p $MOUNT
292 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
293 mount -t lustre $MGSNID:/wrong.$FSNAME $MOUNT || :
294 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
296 cleanup_nocli || return $?
298 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
304 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
305 mount_client $MOUNT || return 1
307 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
310 run_test 5d "mount with ost down"
316 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
317 do_facet client "sysctl -w lustre.fail_loc=0x80000506"
318 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
319 mount_client $MOUNT || echo "mount failed (not fatal)"
321 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
324 run_test 5e "delayed connect, don't crash (bug 10268)"
329 mount_client ${MOUNT} || return 87
330 touch $DIR/a || return 86
333 run_test 6 "manual umount, then mount again"
338 cleanup_nocli || return $?
340 run_test 7 "manual umount, then cleanup"
345 check_mount2 || return 45
346 umount_client $MOUNT2
349 run_test 8 "double mount setup"
354 do_facet ost1 sysctl lnet.debug=\'inode trace\' || return 1
355 do_facet ost1 sysctl lnet.subsystem_debug=\'mds ost\' || return 1
357 CHECK_PTLDEBUG="`do_facet ost1 sysctl -n lnet.debug`"
358 if [ "$CHECK_PTLDEBUG" ] && [ "$CHECK_PTLDEBUG" = "trace inode" ];then
359 echo "lnet.debug success"
361 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
364 CHECK_SUBSYS="`do_facet ost1 sysctl -n lnet.subsystem_debug`"
365 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
366 echo "lnet.subsystem_debug success"
368 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
371 stop_ost || return $?
374 run_test 9 "test ptldebug and subsystem for mkfs"
377 echo "generate configuration with the same name for node and mds"
378 OLDXMLCONFIG=$XMLCONFIG
379 XMLCONFIG="broken.xml"
380 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
384 echo "the name for node and mds is the same"
385 do_lmc --add mds --node ${facet}_facet --mds ${facet}_facet \
386 --dev $MDSDEV --size $MDSSIZE || return $?
387 do_lmc --add lov --mds ${facet}_facet --lov lov1 --stripe_sz \
388 $STRIPE_BYTES --stripe_cnt $STRIPES_PER_OBJ \
389 --stripe_pattern 0 || return $?
390 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
392 add_facet $facet --lustre_upcall $UPCALL
393 do_lmc --add mtpt --node ${facet}_facet --mds mds_facet \
394 --lov lov1 --path $MOUNT
400 check_mount || return 41
404 XMLCONFIG=$OLDXMLCONFIG
406 run_test 10 "mount lustre with the same name for node and mds"
409 OLDXMLCONFIG=$XMLCONFIG
410 XMLCONFIG="conf11.xml"
412 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
413 add_mds mds --dev $MDSDEV --size $MDSSIZE
414 add_ost ost --dev $OSTDEV --size $OSTSIZE
415 add_client client mds --path $MOUNT --ost ost_svc || return $?
416 echo "Default lov config success!"
418 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
419 add_mds mds --dev $MDSDEV --size $MDSSIZE
420 add_ost ost --dev $OSTDEV --size $OSTSIZE
421 add_client client mds --path $MOUNT && return $?
422 echo "--add mtpt with neither --lov nor --ost will return error"
426 XMLCONFIG=$OLDXMLCONFIG
428 run_test 11 "use default lov configuration (should return error)"
431 OLDXMLCONFIG=$XMLCONFIG
432 XMLCONFIG="batch.xml"
433 BATCHFILE="batchfile"
436 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
437 [ -f "$BATCHFILE" ] && rm -f $BATCHFILE
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 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
443 echo "matched double quote success"
445 echo "matched double quote fail"
450 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
451 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions \"-I 128" >> $BATCHFILE
452 # --mkfsoptions "-I 128
453 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
454 echo "unmatched double quote should return error"
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 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
463 echo "matched single quote success"
465 echo "matched single quote fail"
470 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
471 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions '-I 128" >> $BATCHFILE
472 # --mkfsoptions '-I 128
473 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
474 echo "unmatched single quote should return error"
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 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
483 echo "backslash followed by a whitespace/letter success"
485 echo "backslash followed by a whitespace/letter fail"
490 echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE
491 echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions -I\ 128\\" >> $BATCHFILE
492 # --mkfsoptions -I\ 128\
493 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
494 echo "backslash followed by nothing should return error"
497 XMLCONFIG=$OLDXMLCONFIG
499 run_test 12 "lmc --batch, with single/double quote, backslash in batchfile"
502 OLDXMLCONFIG=$XMLCONFIG
503 XMLCONFIG="conf13-1.xml"
505 # check long uuid will be truncated properly and uniquely
506 echo "To generate XML configuration file(with long ost name): $XMLCONFIG"
507 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
508 do_lmc --add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp
509 do_lmc --add mds --node $HOSTNAME --mds mds1_name_longer_than_31characters
510 do_lmc --add mds --node $HOSTNAME --mds mds2_name_longer_than_31characters
511 if [ ! -f "$XMLCONFIG" ]; then
512 echo "Error:no file $XMLCONFIG created!"
515 EXPECTEDMDS1UUID="e_longer_than_31characters_UUID"
516 EXPECTEDMDS2UUID="longer_than_31characters_UUID_2"
517 FOUNDMDS1UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '1p' \
518 | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
519 FOUNDMDS2UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '2p' \
520 | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
521 [ -z "$FOUNDMDS1UUID" ] && echo "MDS1 UUID empty" && return 1
522 [ -z "$FOUNDMDS2UUID" ] && echo "MDS2 UUID empty" && return 1
523 if ([ $EXPECTEDMDS1UUID = $FOUNDMDS1UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS2UUID ]) || \
524 ([ $EXPECTEDMDS1UUID = $FOUNDMDS2UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS1UUID ]); then
525 echo "Success:long uuid truncated successfully and being unique."
527 echo "Error:expected uuid for mds1 and mds2: $EXPECTEDMDS1UUID; $EXPECTEDMDS2UUID"
528 echo "but: found uuid for mds1 and mds2: $FOUNDMDS1UUID; $FOUNDMDS2UUID"
532 XMLCONFIG=$OLDXMLCONFIG
534 run_test 13 "check new_uuid of lmc operating correctly"
537 OLDXMLCONFIG=$XMLCONFIG
538 XMLCONFIG="conf13-1.xml"
539 SECONDXMLCONFIG="conf13-2.xml"
540 # check multiple invocations for lmc generate same XML configuration file
542 echo "Generate the first XML configuration file"
544 echo "mv $XMLCONFIG to $SECONDXMLCONFIG"
545 sed -e "s/mtime[^ ]*//" $XMLCONFIG > $SECONDXMLCONFIG || return $?
546 echo "Generate the second XML configuration file"
548 # don't compare .xml mtime, it will always be different
549 if [ `sed -e "s/mtime[^ ]*//" $XMLCONFIG | diff - $SECONDXMLCONFIG | wc -l` -eq 0 ]; then
550 echo "Success:multiple invocations for lmc generate same XML file"
552 echo "Error: multiple invocations for lmc generate different XML file"
556 rm -f $XMLCONFIG $SECONDXMLCONFIG
557 XMLCONFIG=$OLDXMLCONFIG
559 run_test 13b "check lmc generates consistent .xml file"
564 # create xml file with --mkfsoptions for ost
565 echo "create xml file with --mkfsoptions for ost"
566 add_mds mds --dev $MDSDEV --size $MDSSIZE
567 add_lov lov1 mds --stripe_sz $STRIPE_BYTES\
568 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
569 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE \
570 --mkfsoptions "-Llabel_conf_14"
571 add_client client mds --lov lov1 --path $MOUNT
573 FOUNDSTRING=`awk -F"<" '/<mkfsoptions>/{print $2}' $XMLCONFIG`
574 EXPECTEDSTRING="mkfsoptions>-Llabel_conf_14"
575 if [ "$EXPECTEDSTRING" != "$FOUNDSTRING" ]; then
576 echo "Error: expected: $EXPECTEDSTRING; found: $FOUNDSTRING"
579 echo "Success:mkfsoptions for ost written to xml file correctly."
581 # mount lustre to test lconf mkfsoptions-parsing
585 mount_client $MOUNT || return $?
586 if [ -z "`do_facet ost1 dumpe2fs -h $OSTDEV | grep label_conf_14`" ]; then
587 echo "Error: the mkoptions not applied to mke2fs of ost."
591 echo "lconf mkfsoptions for ost success"
595 run_test 14 "test mkfsoptions of ost for lmc and lconf"
599 [ -f $MOUNTLUSTRE ] && echo "remove $MOUNTLUSTRE" && rm -f $MOUNTLUSTRE
600 if [ -f $MOUNTLUSTRE.sav ]; then
601 echo "return original $MOUNTLUSTRE.sav to $MOUNTLUSTRE"
602 mv $MOUNTLUSTRE.sav $MOUNTLUSTRE
606 # this only tests the kernel mount command, not anything about lustre.
608 MOUNTLUSTRE=${MOUNTLUSTRE:-/sbin/mount.lustre}
612 echo "mount lustre on ${MOUNT} without $MOUNTLUSTRE....."
613 if [ -f "$MOUNTLUSTRE" ]; then
614 echo "save $MOUNTLUSTRE to $MOUNTLUSTRE.sav"
615 mv $MOUNTLUSTRE $MOUNTLUSTRE.sav && trap cleanup_15 EXIT INT
616 if [ -f $MOUNTLUSTRE ]; then
617 skip "$MOUNTLUSTRE cannot be moved, skipping test"
622 mount_client $MOUNT && error "mount succeeded" && return 1
623 echo "mount lustre on $MOUNT without $MOUNTLUSTRE failed as expected"
627 run_test 15 "zconf-mount without /sbin/mount.lustre (should return error)"
630 TMPMTPT="${MOUNT%/*}/conf16"
632 if [ ! -e "$MDSDEV" ]; then
633 log "no $MDSDEV existing, so mount Lustre to create one"
635 check_mount || return 41
639 [ -f "$MDSDEV" ] && LOOPOPT="-o loop"
641 log "change the mode of $MDSDEV/OBJECTS,LOGS,PENDING to 555"
642 do_facet mds "mkdir -p $TMPMTPT &&
643 mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
644 chmod 555 $TMPMTPT/{OBJECTS,LOGS,PENDING} &&
645 umount $TMPMTPT" || return $?
647 log "mount Lustre to change the mode of OBJECTS/LOGS/PENDING, then umount Lustre"
649 check_mount || return 41
652 log "read the mode of OBJECTS/LOGS/PENDING and check if they has been changed properly"
653 EXPECTEDOBJECTSMODE=`do_facet mds "debugfs -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
654 EXPECTEDLOGSMODE=`do_facet mds "debugfs -R 'stat LOGS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
655 EXPECTEDPENDINGMODE=`do_facet mds "debugfs -R 'stat PENDING' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
657 if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
658 log "Success:Lustre change the mode of OBJECTS correctly"
660 error "Lustre does not change mode of OBJECTS properly"
663 if [ "$EXPECTEDLOGSMODE" = "0777" ]; then
664 log "Success:Lustre change the mode of LOGS correctly"
666 error "Lustre does not change mode of LOGS properly"
669 if [ "$EXPECTEDPENDINGMODE" = "0777" ]; then
670 log "Success:Lustre change the mode of PENDING correctly"
672 error "Lustre does not change mode of PENDING properly"
675 run_test 16 "verify that lustre will correct the mode of OBJECTS/LOGS/PENDING"
678 if [ ! -e "$MDSDEV" ]; then
679 echo "no $MDSDEV existing, so mount Lustre to create one"
681 check_mount || return 41
685 echo "Remove mds config log"
686 do_facet mds "debugfs -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
689 start_mds && return 42
692 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
695 [ -f $MDSDEV ] && echo "remove $MDSDEV" && rm -f $MDSDEV
696 echo "mount mds with large journal..."
697 local myMDSSIZE=2000000
698 OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
700 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
703 echo "mount lustre system..."
705 check_mount || return 41
707 echo "check journal size..."
708 FOUNDSIZE=`do_facet mds "debugfs -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
709 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
710 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
712 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
717 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
720 run_test 18 "check mkfs creates large journals"
723 start_mds || return 1
724 stop_mds -f || return 2
726 run_test 19a "start/stop MDS without OSTs"
729 start_ost || return 1
730 stop_ost -f || return 2
732 run_test 19b "start/stop OSTs without MDS"
735 # first format the ost/mdt
739 check_mount || return 43
741 remount_client ro $MOUNT || return 44
742 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
743 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
744 remount_client rw $MOUNT || return 47
746 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
747 MCNT=`grep -c $MOUNT /etc/mtab`
748 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
753 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
761 run_test 21a "start mds before ost, stop ost first"
769 run_test 21b "start ost before mds, stop mds first"
779 run_test 21c "start mds between two osts, stop mds last"
782 #reformat to remove all logs
785 echo Client mount before any osts are in the logs
787 check_mount && return 41
790 echo Client mount with ost in logs, but none running
794 # check_mount will block trying to contact ost
798 echo Client mount with a running ost
801 check_mount || return 41
806 run_test 22 "start a client before osts (should return errs)"
812 # force down client so that recovering mds waits for reconnect
813 zconf_umount `hostname` $MOUNT -f
814 # enter recovery on mds
816 # try to start a new client
817 mount_client $MOUNT &
820 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
821 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
823 ps --ppid $MOUNT_LUSTRE_PID
824 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
825 kill -TERM $MOUNT_PID
826 echo "waiting for mount to finish"
833 #this test isn't working yet
834 #run_test 23 "interrupt client during recovery mount delay"
837 local fs2mds_HOST=$mds_HOST
838 local fs2ost_HOST=$ost_HOST
839 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
840 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
841 do_facet mds [ -b "$MDSDEV" ] && \
842 skip "mixed loopback and real device not working" && return
845 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
846 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
848 # test 8-char fsname as well
849 local FSNAME2=test1234
850 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
852 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
855 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
856 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
858 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
860 check_mount || return 2
861 # files written on 1 should not show up on 2
862 cp /etc/passwd $DIR/$tfile
864 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
866 cp /etc/passwd $MOUNT2/b || return 3
867 rm $MOUNT2/b || return 4
868 # 2 is actually mounted
869 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
871 facet_failover fs2mds
872 facet_failover fs2ost
875 # the MDS must remain up until last MDT
877 MDS=$(do_facet mds "cat $LPROC/devices" | awk '($3 ~ "mdt" && $4 ~ "MDS") { print $4 }')
878 [ -z "$MDS" ] && error "No MDS" && return 8
882 cleanup_nocli || return 6
884 run_test 24a "Multiple MDTs on a single node"
887 local fs2mds_HOST=$mds_HOST
888 if [ -z "$fs2mds_DEV" ]; then
889 do_facet mds [ -b "$MDSDEV" ] && \
890 skip "mixed loopback and real device not working" && return
893 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
895 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
897 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
900 run_test 24b "Multiple MGSs on a single node (should return err)"
904 check_mount || return 2
905 local MODULES=$($LCTL modules | awk '{ print $2 }')
906 rmmod $MODULES 2>/dev/null || true
909 run_test 25 "Verify modules are referenced"
913 # we need modules before mount for sysctl, so make sure...
914 do_facet mds "lsmod | grep -q lustre || modprobe lustre"
915 #define OBD_FAIL_MDS_FS_SETUP 0x135
916 do_facet mds "sysctl -w lustre.fail_loc=0x80000135"
917 start_mds && echo MDS started && return 1
919 DEVS=$(cat $LPROC/devices | wc -l)
920 [ $DEVS -gt 0 ] && return 2
921 unload_modules || return 203
923 run_test 26 "MDT startup failure cleans LOV (should return errs)"
929 local ORIG=$(do_facet $myfacet "$TEST")
930 if [ $# -gt 3 ]; then
936 echo "Setting $PARAM from $ORIG to $FINAL"
937 do_facet mds "$LCTL conf_param $PARAM=$FINAL" || error conf_param failed
943 RESULT=$(do_facet $myfacet "$TEST")
944 if [ $RESULT -eq $FINAL ]; then
945 echo "Updated config after $WAIT sec (got $RESULT)"
949 if [ $WAIT -eq $MAX ]; then
950 echo "Config update not seen: wanted $FINAL got $RESULT"
953 echo "Waiting $(($MAX - $WAIT)) secs for config update"
958 start_ost || return 1
959 start_mds || return 2
960 echo "Requeue thread should have started: "
961 ps -e | grep ll_cfg_requeue
962 set_and_check ost1 "cat $LPROC/obdfilter/$FSNAME-OST0000/client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
965 run_test 27a "Reacquire MGS lock if OST started first"
970 set_and_check mds "cat $LPROC/mds/$FSNAME-MDT0000/group_acquire_expire" "$FSNAME-MDT0000.mdt.group_acquire_expire" || return 3
971 set_and_check client "cat $LPROC/mdc/$FSNAME-MDT0000-mdc-*/max_rpcs_in_flight" "$FSNAME-MDT0000.mdc.max_rpcs_in_flight" || return 4
974 run_test 27b "Reacquire MGS lock after failover"
978 TEST="cat $LPROC/llite/$FSNAME-*/max_read_ahead_whole_mb"
981 FINAL=$(($ORIG + 10))
982 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
983 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
984 umount_client $MOUNT || return 200
987 if [ $RESULT -ne $FINAL ]; then
988 echo "New config not seen: wanted $FINAL got $RESULT"
991 echo "New config success: got $RESULT"
995 run_test 28 "permanent parameter setting"
998 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2, skipping" && return
999 setup > /dev/null 2>&1
1003 local PARAM="$FSNAME-OST0001.osc.active"
1004 local PROC_ACT="$LPROC/osc/$FSNAME-OST0001-osc-*/active"
1005 local PROC_UUID="$LPROC/osc/$FSNAME-OST0001-osc-*/ost_server_uuid"
1006 if [ ! -r $PROC_ACT ]; then
1007 echo "Can't read $PROC_ACT"
1008 ls $LPROC/osc/$FSNAME-*
1011 ACTV=$(cat $PROC_ACT)
1013 set_and_check client "cat $PROC_ACT" "$PARAM" $DEAC || return 2
1014 # also check ost_server_uuid status
1015 RESULT=$(grep DEACTIV $PROC_UUID)
1016 if [ -z "$RESULT" ]; then
1017 echo "Live client not deactivated: $(cat $PROC_UUID)"
1020 echo "Live client success: got $RESULT"
1024 local MPROC="$LPROC/osc/$FSNAME-OST0001-osc/active"
1029 RESULT=`do_facet mds " [ -r $MPROC ] && cat $MPROC"`
1030 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1031 if [ $RESULT -eq $DEAC ]; then
1032 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
1036 if [ $WAIT -eq $MAX ]; then
1037 echo "MDT not deactivated: wanted $DEAC got $RESULT"
1040 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
1043 # test new client starts deactivated
1044 umount_client $MOUNT || return 200
1046 RESULT=$(grep DEACTIV $PROC_UUID | grep NEW)
1047 if [ -z "$RESULT" ]; then
1048 echo "New client not deactivated from start: $(cat $PROC_UUID)"
1051 echo "New client success: got $RESULT"
1054 # make sure it reactivates
1055 set_and_check client "cat $PROC_ACT" "$PARAM" $ACTV || return 6
1057 umount_client $MOUNT
1060 #writeconf to remove all ost2 traces for subsequent tests
1063 run_test 29 "permanently remove an OST"
1066 # start mds first after writeconf
1070 TEST="cat $LPROC/llite/$FSNAME-*/max_read_ahead_whole_mb"
1072 for i in $(seq 1 20); do
1073 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1075 # make sure client restart still works
1076 umount_client $MOUNT
1077 mount_client $MOUNT || return 4
1078 [ "$($TEST)" -ne "$i" ] && return 5
1079 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
1082 run_test 30 "Big config llog"
1084 test_31() { # bug 10734
1085 # ipaddr must not exist
1086 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1089 run_test 31 "Connect to non-existent node (returns errors, should not crash)"
1092 # XXX - make this run on client-only systems with real hardware on
1094 # there appears to be a lot of assumption here about loopback
1096 # or maybe this test is just totally useless on a client-only system
1097 [ "$mds_HOST" = "`hostname`" ] || { skip "remote MDS" && return 0; }
1098 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1099 { skip "remote OST" && return 0; }
1101 [ -z "$TUNEFS" ] && skip "No tunefs" && return
1102 local DISK1_4=$LUSTRE/tests/disk1_4.zip
1103 [ ! -r $DISK1_4 ] && skip "Cant find $DISK1_4, skipping" && return
1104 unzip -o -j -d $TMP/$tdir $DISK1_4 || { skip "Cant unzip $DISK1_4, skipping" && return ; }
1106 sysctl lnet.debug=$PTLDEBUG
1108 $TUNEFS $TMP/$tdir/mds || error "tunefs failed"
1109 # nids are wrong, so client wont work, but server should start
1110 start mds $TMP/$tdir/mds "-o loop,exclude=lustre-OST0000" || return 3
1111 local UUID=$(cat $LPROC/mds/lustre-MDT0000/uuid)
1113 [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
1115 $TUNEFS --mgsnode=`hostname` $TMP/$tdir/ost1 || error "tunefs failed"
1116 start ost1 $TMP/$tdir/ost1 "-o loop" || return 5
1117 UUID=$(cat $LPROC/obdfilter/lustre-OST0000/uuid)
1119 [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
1121 local NID=$($LCTL list_nids | head -1)
1123 echo "OSC changes should return err:"
1124 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 && return 7
1125 $LCTL conf_param lustre-OST0000.failover.node=$NID && return 8
1127 echo "MDC changes should succeed:"
1128 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1129 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1132 # With a new good MDT failover nid, we should be able to mount a client
1133 # (but it cant talk to OST)
1134 local OLDMOUNTOPT=$MOUNTOPT
1135 MOUNTOPT="exclude=lustre-OST0000"
1137 MOUNTOPT=$OLDMOUNTOPT
1138 set_and_check client "cat $LPROC/mdc/*/max_rpcs_in_flight" "lustre-MDT0000.mdc.max_rpcs_in_flight" || return 11
1140 zconf_umount `hostname` $MOUNT -f
1144 # mount a second time to make sure we didnt leave upgrade flag on
1146 $TUNEFS --dryrun $TMP/$tdir/mds || error "tunefs failed"
1148 start mds $TMP/$tdir/mds "-o loop,exclude=lustre-OST0000" || return 12
1151 [ -d $TMP/$tdir ] && rm -rf $TMP/$tdir
1153 run_test 32a "Upgrade from 1.4 (not live)"
1156 # XXX - make this run on client-only systems with real hardware on
1158 # there appears to be a lot of assumption here about loopback
1160 # or maybe this test is just totally useless on a client-only system
1161 [ "$mds_HOST" = "`hostname`" ] || { skip "remote MDS" && return 0; }
1162 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1163 { skip "remote OST" && return 0; }
1165 [ -z "$TUNEFS" ] && skip "No tunefs" && return
1166 local DISK1_4=$LUSTRE/tests/disk1_4.zip
1167 [ ! -r $DISK1_4 ] && skip "Cant find $DISK1_4, skipping" && return
1168 unzip -o -j -d $TMP/$tdir $DISK1_4 || { skip "Cant unzip $DISK1_4, skipping" && return ; }
1170 sysctl lnet.debug=$PTLDEBUG
1173 # writeconf will cause servers to register with their current nids
1174 $TUNEFS --writeconf --fsname=$NEWNAME $TMP/$tdir/mds || error "tunefs failed"
1175 start mds $TMP/$tdir/mds "-o loop" || return 3
1176 local UUID=$(cat $LPROC/mds/${NEWNAME}-MDT0000/uuid)
1178 [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
1180 $TUNEFS --mgsnode=`hostname` --fsname=$NEWNAME --writeconf $TMP/$tdir/ost1 || error "tunefs failed"
1181 start ost1 $TMP/$tdir/ost1 "-o loop" || return 5
1182 UUID=$(cat $LPROC/obdfilter/${NEWNAME}-OST0000/uuid)
1184 [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
1186 echo "OSC changes should succeed:"
1187 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1188 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1190 echo "MDC changes should succeed:"
1191 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1194 # MDT and OST should have registered with new nids, so we should have
1195 # a fully-functioning client
1196 echo "Check client and old fs contents"
1201 set_and_check client "cat $LPROC/mdc/*/max_rpcs_in_flight" "${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight" || return 11
1202 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "2479747619 779" ] || return 12
1206 [ -d $TMP/$tdir ] && rm -rf $TMP/$tdir
1208 run_test 32b "Upgrade from 1.4 with writeconf"
1210 test_33() { # bug 12333
1211 local FSNAME2=test1234
1212 local fs2mds_HOST=$mds_HOST
1213 local fs2ost_HOST=$ost_HOST
1214 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1216 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1217 do_facet mds [ -b "$MDSDEV" ] && \
1218 skip "mixed loopback and real device not working" && return
1221 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1222 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1223 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1224 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1226 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1227 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1229 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1235 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1236 cleanup_nocli || return 6
1238 run_test 33 "Mount ost with a large index number"
1240 umount_client $MOUNT
1246 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1247 # Drop lock cancelation reply during umount
1248 #define OBD_FAIL_LDLM_CANCEL 0x304
1249 do_facet client sysctl -w lustre.fail_loc=0x80000304
1250 #sysctl -w lnet.debug=-1
1251 umount_client $MOUNT
1254 run_test 33a "Drop cancel during umount"
1258 do_facet client multiop $DIR/file O_c &
1260 manual_umount_client
1262 do_facet client killall -USR1 multiop
1263 if [ $rc -eq 0 ]; then
1264 error "umount not fail!"
1269 run_test 34a "umount with opened file should be fail"
1274 touch $DIR/$tfile || return 1
1275 stop_mds --force || return 2
1277 manual_umount_client --force
1279 if [ $rc -ne 0 ]; then
1280 error "mtab after failed umount - rc $rc"
1286 run_test 34b "force umount with failed mds should be normal"
1290 touch $DIR/$tfile || return 1
1291 stop_ost --force || return 2
1293 manual_umount_client --force
1295 if [ $rc -ne 0 ]; then
1296 error "mtab after failed umount - rc $rc"
1302 run_test 34c "force umount with failed mds should be normal"
1304 test_35() { # bug 12459
1308 sysctl -w lnet.debug="ha"
1310 log "Set up a fake failnode for the MDS"
1312 do_facet mds $LCTL conf_param ${FSNAME}-MDT0000.failover.node=$FAKENID || return 4
1314 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1317 MSG="conf-sanity.sh test_33 `date +%F%kh%Mm%Ss`"
1320 log "Stopping the MDT:"
1321 stop_mds || return 5
1323 df $MOUNT > /dev/null 2>&1 &
1325 log "Restarting the MDT:"
1326 start_mds || return 6
1327 log "Wait for df ($DFPID) ... "
1332 # retrieve from the log the first server that the client tried to
1333 # contact after the connection loss
1334 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1335 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1336 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1338 if (\\\$NF ~ /$FAKENID/)
1344 }" $TMP/lustre-log-$TESTNAME.log`
1345 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1348 run_test 35 "Reconnect to the last active server first"
1352 local FSNAME2=test1234
1353 local fs2mds_HOST=$mds_HOST
1354 local fs2ost_HOST=$ost_HOST
1355 local fs3ost_HOST=$ost_HOST
1357 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1360 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1361 do_facet mds [ -b "$MDSDEV" ] && \
1362 skip "mixed loopback and real device not working" && return
1364 [ $OSTCOUNT -lt 2 ] && skip "skipping test for single OST" && return
1366 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
1367 skip "skipping test for remote OST" && return
1369 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1370 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1371 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1372 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1373 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b1024' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1374 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1376 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1377 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1378 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1380 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1382 sleep 5 # until 11778 fixed
1384 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1386 BKTOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
1387 $LPROC/obdfilter/*/kbytestotal`
1388 BKFREE=`awk 'BEGIN{free=0}; {free+=$1}; END{print free}' \
1389 $LPROC/obdfilter/*/kbytesfree`
1390 BKAVAIL=`awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}' \
1391 $LPROC/obdfilter/*/kbytesavail`
1392 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1393 DFTOTAL=`echo $STRING | cut -d, -f1`
1394 DFUSED=`echo $STRING | cut -d, -f2`
1395 DFAVAIL=`echo $STRING | cut -d, -f3`
1396 DFFREE=$(($DFTOTAL - $DFUSED))
1398 ALLOWANCE=$((64 * $OSTCOUNT))
1400 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1401 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1402 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1405 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1406 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1407 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1410 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1411 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1412 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1417 stop fs3ost -f || return 200
1418 stop fs2ost -f || return 201
1419 stop fs2mds -f || return 202
1420 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1421 unload_modules || return 203
1424 run_test 36 "df report consistency on OSTs with different block size"
1426 equals_msg `basename $0`: test complete
1427 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true