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 # bug number for skipped test: 13739
15 HEAD_EXCEPT=" 32a 32b "
17 # bug number for skipped test:
18 ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT $HEAD_EXCEPT"
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
22 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
24 PTLDEBUG=${PTLDEBUG:--1}
26 LUSTRE=${LUSTRE:-`dirname $0`/..}
27 RLUSTRE=${RLUSTRE:-$LUSTRE}
29 . $LUSTRE/tests/test-framework.sh
31 # STORED_MDSSIZE is used in test_18
32 if [ -n "$MDSSIZE" ]; then
33 STORED_MDSSIZE=$MDSSIZE
35 # use small MDS + OST size to speed formatting time
38 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
41 [ "$SLOW" = "no" ] && EXCEPT_SLOW="0 1 2 3 6 7 15 18 24b 25 30 31 32 33 34a "
50 local facet=$SINGLEMDS
51 local dev=${facet}_dev
55 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
56 do_facet ${facet} "$TUNEFS --writeconf ${!dev}" || echo "tunefs failed, reformatting instead" && reformat
61 # The MGS must be started before the OSTs for a new fs, so start
62 # and stop to generate the startup logs.
71 local facet=$SINGLEMDS
72 local dev=${facet}_dev
73 echo "start mds service on `facet_active_host $facet`"
74 start $facet ${!dev} $MDS_MOUNT_OPTS || return 94
78 echo "stop mds service on `facet_active_host $SINGLEMDS`"
79 # These tests all use non-failover stop
80 stop $SINGLEMDS -f || return 97
84 echo "start ost1 service on `facet_active_host ost1`"
85 start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95
89 echo "stop ost1 service on `facet_active_host ost1`"
90 # These tests all use non-failover stop
91 stop ost1 -f || return 98
95 echo "start ost2 service on `facet_active_host ost2`"
96 start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92
100 echo "stop ost2 service on `facet_active_host ost2`"
101 # These tests all use non-failover stop
102 stop ost2 -f || return 93
107 echo "mount $FSNAME on ${MOUNTPATH}....."
108 zconf_mount `hostname` $MOUNTPATH || return 96
112 local SAVEMOUNTOPT=$MOUNTOPT
113 MOUNTOPT="remount,$1"
115 echo "remount '$1' lustre on ${MOUNTPATH}....."
116 zconf_mount `hostname` $MOUNTPATH || return 96
117 MOUNTOPT=$SAVEMOUNTOPT
122 echo "umount lustre on ${MOUNTPATH}....."
123 zconf_umount `hostname` $MOUNTPATH || return 97
126 manual_umount_client(){
127 echo "manual umount lustre on ${MOUNT}...."
128 do_facet client "umount -d $MOUNT"
138 stop_mds || return 201
139 stop_ost || return 202
140 unload_modules || return 203
144 umount_client $MOUNT || return 200
145 cleanup_nocli || return $?
149 do_facet client "cp /etc/passwd $DIR/a" || return 71
150 do_facet client "rm $DIR/a" || return 72
151 # make sure lustre is actually mounted (touch will block,
152 # but grep won't, so do it after)
153 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
154 echo "setup single mount lustre success"
158 do_facet client "touch $DIR/a" || return 71
159 do_facet client "rm $DIR/a" || return 72
160 do_facet client "touch $DIR2/a" || return 73
161 do_facet client "rm $DIR2/a" || return 74
162 echo "setup double mount lustre success"
167 if [ "$ONLY" == "setup" ]; then
172 if [ "$ONLY" == "cleanup" ]; then
177 #create single point mountpoint
185 check_mount || return 41
188 run_test 0 "single mount setup"
192 echo "start ost second time..."
194 check_mount || return 42
197 run_test 1 "start up ost twice (should return errors)"
202 echo "start mds second time.."
205 check_mount || return 43
208 run_test 2 "start up mds twice (should return err)"
212 #mount.lustre returns an error if already in mtab
213 mount_client $MOUNT && return $?
214 check_mount || return 44
217 run_test 3 "mount client twice (should return err)"
221 touch $DIR/$tfile || return 85
225 # ok for ost to fail shutdown
226 if [ 202 -ne $eno ]; then
231 run_test 4 "force cleanup ost, then cleanup"
233 test_5a() { # was test_5
235 touch $DIR/$tfile || return 1
236 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
238 stop_mds -f || return 2
240 # cleanup may return an error from the failed
241 # disconnects; for now I'll consider this successful
242 # if all the modules have unloaded.
246 echo "killing umount"
247 kill -TERM $UMOUNT_PID
248 echo "waiting for umount to finish"
250 if grep " $MOUNT " /proc/mounts; then
251 echo "test 5: /proc/mounts after failed umount"
255 echo "killing umount"
256 kill -TERM $UMOUNT_PID
257 echo "waiting for umount to finish"
259 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
263 # stop_mds is a no-op here, and should not fail
264 cleanup_nocli || return $?
265 # df may have lingering entry
267 # mtab may have lingering entry
271 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
273 grep -q $MOUNT" " /etc/mtab || break
274 echo "Waiting /etc/mtab updated ... "
275 WAIT=$(( WAIT + sleep))
277 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
278 echo "/etc/mtab updated in $WAIT secs"
280 run_test 5a "force cleanup mds, then cleanup"
284 [ -d $MOUNT ] || mkdir -p $MOUNT
285 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
286 mount_client $MOUNT && return 1
287 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
289 # stop_mds is a no-op here, and should not fail
290 cleanup_nocli || return $?
293 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
298 [ -d $MOUNT ] || mkdir -p $MOUNT
299 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
300 local oldfs="${FSNAME}"
301 FSNAME="wrong.${FSNAME}"
302 mount_client $MOUNT || :
304 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
306 cleanup_nocli || return $?
308 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
314 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
315 mount_client $MOUNT || return 1
317 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
320 run_test 5d "mount with ost down"
326 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
327 do_facet client "lctl set_param fail_loc=0x80000506"
328 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
329 mount_client $MOUNT || echo "mount failed (not fatal)"
331 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
334 run_test 5e "delayed connect, don't crash (bug 10268)"
339 mount_client ${MOUNT} || return 87
340 touch $DIR/a || return 86
343 run_test 6 "manual umount, then mount again"
348 cleanup_nocli || return $?
350 run_test 7 "manual umount, then cleanup"
355 check_mount2 || return 45
356 umount_client $MOUNT2
359 run_test 8 "double mount setup"
364 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
365 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
367 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
368 if [ "$CHECK_PTLDEBUG" ] && [ "$CHECK_PTLDEBUG" = "trace inode" ];then
369 echo "lnet.debug success"
371 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
374 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
375 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
376 echo "lnet.subsystem_debug success"
378 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
381 stop_ost || return $?
384 run_test 9 "test ptldebug and subsystem for mkfs"
386 # LOGS/PENDING do not exist anymore since CMD3
388 local TMPMTPT="${TMP}/conf16"
389 local dev=${SINGLEMDS}_dev
391 if [ ! -e "$MDSDEV" ]; then
392 log "no $MDSDEV existing, so mount Lustre to create one"
394 check_mount || return 41
398 [ -f "$MDSDEV" ] && LOOPOPT="-o loop"
400 log "change the mode of $MDSDEV/OBJECTS to 555"
401 do_facet $SINGLEMDS "mkdir -p $TMPMTPT &&
402 mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
403 chmod 555 $TMPMTPT/OBJECTS &&
404 umount $TMPMTPT" || return $?
406 log "mount Lustre to change the mode of OBJECTS, then umount Lustre"
408 check_mount || return 41
411 log "read the mode of OBJECTS and check if they has been changed properly"
412 EXPECTEDOBJECTSMODE=`do_facet $SINGLEMDS "debugfs -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
414 if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
415 log "Success:Lustre change the mode of OBJECTS correctly"
417 error "Lustre does not change mode of OBJECTS properly"
420 run_test 16 "verify that lustre will correct the mode of OBJECTS"
423 local dev=${SINGLEMDS}_dev
426 if [ ! -e "$MDSDEV" ]; then
427 echo "no $MDSDEV existing, so mount Lustre to create one"
429 check_mount || return 41
433 echo "Remove mds config log"
434 do_facet $SINGLEMDS "debugfs -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
437 start_mds && return 42
440 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
443 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
445 local dev=${SINGLEMDS}_dev
451 # check if current MDSSIZE is large enough
452 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
453 log "use MDSSIZE=$MDSSIZE"
455 # check if the global config has a large enough MDSSIZE
456 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
457 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
458 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
460 # check if the block device is large enough
461 [ -z "$OK" -a -b $MDSDEV ] && \
462 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
463 awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
464 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
466 # check if a loopback device has enough space for fs metadata (5%)
467 [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
468 SPACE=$(df -P $(dirname $MDSDEV) |
469 awk '($1 != "Filesystem") {print $4}') &&
470 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
471 log "use file $MDSDEV with MIN=$MIN"
473 [ -z "$OK" ] && skip "$MDSDEV too small for ${MIN}kB MDS" && return
476 echo "mount mds with large journal..."
477 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
479 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
482 echo "mount lustre system..."
484 check_mount || return 41
486 echo "check journal size..."
487 local FOUNDSIZE=`do_facet mds "debugfs -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
488 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
489 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
491 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
496 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
499 run_test 18 "check mkfs creates large journals"
502 start_mds || return 1
503 stop_mds -f || return 2
505 run_test 19a "start/stop MDS without OSTs"
508 start_ost || return 1
509 stop_ost -f || return 2
511 run_test 19b "start/stop OSTs without MDS"
514 # first format the ost/mdt
518 check_mount || return 43
520 remount_client ro $MOUNT || return 44
521 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
522 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
523 remount_client rw $MOUNT || return 47
525 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
526 MCNT=`grep -c $MOUNT /etc/mtab`
527 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
532 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
540 run_test 21a "start mds before ost, stop ost first"
548 run_test 21b "start ost before mds, stop mds first"
558 run_test 21c "start mds between two osts, stop mds last"
561 #reformat to remove all logs
564 echo Client mount before any osts are in the logs
566 check_mount && return 41
569 echo Client mount with ost in logs, but none running
573 # check_mount will block trying to contact ost
577 echo Client mount with a running ost
580 # if gss enabled, wait full time to let connection from
581 # mds to ost be established, due to the mismatch between
582 # initial connect timeout and gss context negotiation timeout.
583 # This perhaps could be remove after AT landed.
584 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
585 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
588 check_mount || return 41
593 run_test 22 "start a client before osts (should return errs)"
595 test_23a() { # was test_23
599 # force down client so that recovering mds waits for reconnect
600 local running=$(grep -c $MOUNT /proc/mounts) || true
601 if [ $running -ne 0 ]; then
602 echo "Stopping client $MOUNT (opts: -f)"
606 # enter recovery on mds
608 # try to start a new client
609 mount_client $MOUNT &
611 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
612 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
613 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
615 ps --ppid $MOUNT_LUSTRE_PID
616 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
617 kill -TERM $MOUNT_LUSTRE_PID
618 echo "waiting for mount to finish"
620 # we can not wait $MOUNT_PID because it is not a child of this shell
626 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
628 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
629 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
632 [ -z "$PID1" -a -z "$PID2" ] && break
633 echo "waiting for mount to finish ... "
634 WAIT=$(( WAIT + sleep))
636 [ "$WAIT" -eq "$MAX_WAIT" ] && error "MOUNT_PID $MOUNT_PID and \
637 MOUNT__LUSTRE_PID $MOUNT__LUSTRE_PID still not killed in $WAIT secs"
642 run_test 23a "interrupt client during recovery mount delay"
647 test_23b() { # was test_23
650 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
651 lctl set_param fail_loc=0x80000313
655 run_test 23b "Simulate -EINTR during mount"
657 fs2mds_HOST=$mds_HOST
658 fs2ost_HOST=$ost_HOST
662 echo "umount $MOUNT2 ..."
663 umount $MOUNT2 || true
664 echo "stopping fs2mds ..."
665 stop fs2mds -f || true
666 echo "stopping fs2ost ..."
667 stop fs2ost -f || true
674 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
675 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
676 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
677 skip "mixed loopback and real device not working" && return
680 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
681 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
683 # test 8-char fsname as well
684 local FSNAME2=test1234
685 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
687 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
690 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
691 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
693 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
695 check_mount || return 2
696 # files written on 1 should not show up on 2
697 cp /etc/passwd $DIR/$tfile
699 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
702 cp /etc/passwd $MOUNT2/b || return 3
703 rm $MOUNT2/b || return 4
704 # 2 is actually mounted
705 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
707 facet_failover fs2mds
708 facet_failover fs2ost
711 # the MDS must remain up until last MDT
713 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
714 [ -z "$MDS" ] && error "No MDT" && return 8
716 cleanup_nocli || return 6
718 run_test 24a "Multiple MDTs on a single node"
721 if [ -z "$fs2mds_DEV" ]; then
722 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
723 skip "mixed loopback and real device not working" && return
726 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
728 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
730 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
733 run_test 24b "Multiple MGSs on a single node (should return err)"
737 check_mount || return 2
738 local MODULES=$($LCTL modules | awk '{ print $2 }')
739 rmmod $MODULES 2>/dev/null || true
742 run_test 25 "Verify modules are referenced"
746 # we need modules before mount for sysctl, so make sure...
747 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
748 #define OBD_FAIL_MDS_FS_SETUP 0x135
749 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
750 start_mds && echo MDS started && return 1
751 lctl get_param -n devices
752 DEVS=$(lctl get_param -n devices | wc -l)
753 [ $DEVS -gt 0 ] && return 2
754 unload_modules || return 203
756 run_test 26 "MDT startup failure cleans LOV (should return errs)"
762 local ORIG=$(do_facet $myfacet "$TEST")
763 if [ $# -gt 3 ]; then
769 echo "Setting $PARAM from $ORIG to $FINAL"
770 do_facet $SINGLEMDS "$LCTL conf_param $PARAM=$FINAL" || error conf_param failed
776 RESULT=$(do_facet $myfacet "$TEST")
777 if [ $RESULT -eq $FINAL ]; then
778 echo "Updated config after $WAIT sec (got $RESULT)"
782 if [ $WAIT -eq $MAX ]; then
783 echo "Config update not seen: wanted $FINAL got $RESULT"
786 echo "Waiting $(($MAX - $WAIT)) secs for config update"
791 start_ost || return 1
792 start_mds || return 2
793 echo "Requeue thread should have started: "
794 ps -e | grep ll_cfg_requeue
795 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
798 run_test 27a "Reacquire MGS lock if OST started first"
803 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
805 facet_failover $SINGLEMDS
806 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
807 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
811 run_test 27b "Reacquire MGS lock after failover"
815 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
816 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
819 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
820 FINAL=$(($FINAL + 1))
821 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
822 umount_client $MOUNT || return 200
825 if [ $RESULT -ne $FINAL ]; then
826 echo "New config not seen: wanted $FINAL got $RESULT"
829 echo "New config success: got $RESULT"
831 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
834 run_test 28 "permanent parameter setting"
837 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2, skipping" && return
838 setup > /dev/null 2>&1
842 local PARAM="$FSNAME-OST0001.osc.active"
843 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
844 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
846 ACTV=$(lctl get_param -n $PROC_ACT)
848 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
849 # also check ost_server_uuid status
850 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
851 if [ -z "$RESULT" ]; then
852 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
855 echo "Live client success: got $RESULT"
859 local MPROC="osc.$FSNAME-OST0001-osc-[M]*.active"
864 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
865 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
866 if [ $RESULT -eq $DEAC ]; then
867 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
871 if [ $WAIT -eq $MAX ]; then
872 echo "MDT not deactivated: wanted $DEAC got $RESULT"
875 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
878 # test new client starts deactivated
879 umount_client $MOUNT || return 200
881 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
882 if [ -z "$RESULT" ]; then
883 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
886 echo "New client success: got $RESULT"
889 # make sure it reactivates
890 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
895 #writeconf to remove all ost2 traces for subsequent tests
901 run_test 29 "permanently remove an OST"
906 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
908 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
909 for i in ${LIST[@]}; do
910 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
912 # make sure client restart still works
914 mount_client $MOUNT || return 4
915 [ "$($TEST)" -ne "$i" ] && return 5
916 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
919 run_test 30 "Big config llog"
921 test_31() { # bug 10734
922 # ipaddr must not exist
923 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
926 run_test 31 "Connect to non-existent node (shouldn't crash)"
929 # XXX - make this run on client-only systems with real hardware on
931 # there appears to be a lot of assumption here about loopback
933 # or maybe this test is just totally useless on a client-only system
934 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
935 [ "$mds_HOST" = "`hostname`" ] || { skip "remote MDS" && return 0; }
936 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
937 { skip "remote OST" && return 0; }
939 [ -z "$TUNEFS" ] && skip "No tunefs" && return
940 local DISK1_4=$LUSTRE/tests/disk1_4.zip
941 [ ! -r $DISK1_4 ] && skip "Cant find $DISK1_4, skipping" && return
943 local tmpdir=$TMP/conf32a
944 unzip -o -j -d $tmpdir $DISK1_4 || { skip "Cant unzip $DISK1_4, skipping" && return ; }
946 lctl set_param debug=$PTLDEBUG
948 $TUNEFS $tmpdir/mds || error "tunefs failed"
949 # nids are wrong, so client wont work, but server should start
950 start mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" || return 3
951 local UUID=$(lctl get_param -n mdt.lustre-MDT0000.uuid)
953 [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
955 $TUNEFS --mgsnode=`hostname` $tmpdir/ost1 || error "tunefs failed"
956 start ost1 $tmpdir/ost1 "-o loop" || return 5
957 UUID=$(lctl get_param -n obdfilter.lustre-OST0000.uuid)
959 [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
961 local NID=$($LCTL list_nids | head -1)
963 echo "OSC changes should return err:"
964 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 && return 7
965 $LCTL conf_param lustre-OST0000.failover.node=$NID && return 8
967 echo "MDC changes should succeed:"
968 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
969 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
972 # With a new good MDT failover nid, we should be able to mount a client
973 # (but it cant talk to OST)
974 local OLDMOUNTOPT=$MOUNTOPT
975 MOUNTOPT="exclude=lustre-OST0000"
977 MOUNTOPT=$OLDMOUNTOPT
978 set_and_check client "lctl get_param -n mdc.*.max_rpcs_in_flight" "lustre-MDT0000.mdc.max_rpcs_in_flight" ||
981 zconf_umount `hostname` $MOUNT -f
985 # mount a second time to make sure we didnt leave upgrade flag on
987 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
989 start mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" || return 12
992 rm -rf $tmpdir || true # true is only for TMP on NFS
994 run_test 32a "Upgrade from 1.4 (not live)"
997 # XXX - make this run on client-only systems with real hardware on
999 # there appears to be a lot of assumption here about loopback
1001 # or maybe this test is just totally useless on a client-only system
1002 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1003 [ "$mds_HOST" = "`hostname`" ] || { skip "remote MDS" && return 0; }
1004 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1005 { skip "remote OST" && return 0; }
1007 [ -z "$TUNEFS" ] && skip "No tunefs" && return
1008 local DISK1_4=$LUSTRE/tests/disk1_4.zip
1009 [ ! -r $DISK1_4 ] && skip "Cant find $DISK1_4, skipping" && return
1011 local tmpdir=$TMP/conf32b
1012 unzip -o -j -d $tmpdir $DISK1_4 || { skip "Cant unzip $DISK1_4, skipping" && return ; }
1014 lctl set_param debug=$PTLDEBUG
1017 # writeconf will cause servers to register with their current nids
1018 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1019 start mds $tmpdir/mds "-o loop" || return 3
1020 local UUID=$(lctl get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1022 [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
1024 $TUNEFS --mgsnode=`hostname` --fsname=$NEWNAME --writeconf $tmpdir/ost1 || error "tunefs failed"
1025 start ost1 $tmpdir/ost1 "-o loop" || return 5
1026 UUID=$(lctl get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1028 [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
1030 echo "OSC changes should succeed:"
1031 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1032 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1034 echo "MDC changes should succeed:"
1035 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1038 # MDT and OST should have registered with new nids, so we should have
1039 # a fully-functioning client
1040 echo "Check client and old fs contents"
1045 set_and_check client "lctl get_param -n mdc.*.max_rpcs_in_flight" "${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight" || return 11
1046 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "2479747619 779" ] || return 12
1050 rm -rf $tmpdir || true # true is only for TMP on NFS
1052 run_test 32b "Upgrade from 1.4 with writeconf"
1054 test_33a() { # bug 12333, was test_33
1056 local FSNAME2=test-123
1057 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1059 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1060 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1061 skip "mixed loopback and real device not working" && return
1064 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1065 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1066 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1067 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1069 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1070 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1071 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1073 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1076 cp /etc/hosts $MOUNT2/ || rc=3
1077 $LFS getstripe $MOUNT2/hosts
1082 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1083 cleanup_nocli || rc=6
1086 run_test 33a "Mount ost with a large index number"
1088 test_33b() { # was test_34
1091 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1092 # Drop lock cancelation reply during umount
1093 #define OBD_FAIL_LDLM_CANCEL 0x304
1094 do_facet client lctl set_param fail_loc=0x80000304
1095 #lctl set_param debug=-1
1096 umount_client $MOUNT
1099 run_test 33b "Drop cancel during umount"
1103 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1104 manual_umount_client
1106 do_facet client killall -USR1 multiop
1107 if [ $rc -eq 0 ]; then
1108 error "umount not fail!"
1113 run_test 34a "umount with opened file should be fail"
1118 touch $DIR/$tfile || return 1
1119 stop_mds --force || return 2
1121 manual_umount_client --force
1123 if [ $rc -ne 0 ]; then
1124 error "mtab after failed umount - rc $rc"
1130 run_test 34b "force umount with failed mds should be normal"
1134 touch $DIR/$tfile || return 1
1135 stop_ost --force || return 2
1137 manual_umount_client --force
1139 if [ $rc -ne 0 ]; then
1140 error "mtab after failed umount - rc $rc"
1146 run_test 34c "force umount with failed ost should be normal"
1148 test_35() { # bug 12459
1151 DBG_SAVE="`lctl get_param -n debug`"
1152 lctl set_param debug="ha"
1154 log "Set up a fake failnode for the MDS"
1156 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1157 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1159 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1162 MSG="conf-sanity.sh test_35 `date +%F%kh%Mm%Ss`"
1165 log "Stopping the MDT:"
1166 stop_mds || return 5
1168 df $MOUNT > /dev/null 2>&1 &
1170 log "Restarting the MDT:"
1171 start_mds || return 6
1172 log "Wait for df ($DFPID) ... "
1175 lctl set_param debug="$DBG_SAVE"
1177 # retrieve from the log the first server that the client tried to
1178 # contact after the connection loss
1179 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1180 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1181 /import_select_connection.$device-mdc.* using connection/ {
1183 if (\\\$NF ~ /$FAKENID/)
1189 }" $TMP/lustre-log-$TESTNAME.log`
1190 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1193 run_test 35 "Reconnect to the last active server first"
1197 local FSNAME2=test1234
1198 local fs3ost_HOST=$ost_HOST
1200 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1203 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1204 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1205 skip "mixed loopback and real device not working" && return
1207 [ $OSTCOUNT -lt 2 ] && skip "skipping test for single OST" && return
1209 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1210 { skip "remote OST" && return 0; }
1212 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1213 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1214 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1215 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1216 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1218 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1219 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1221 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1222 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1223 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1225 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1227 sleep 5 # until 11778 fixed
1229 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1231 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1232 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1233 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1234 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1235 DFTOTAL=`echo $STRING | cut -d, -f1`
1236 DFUSED=`echo $STRING | cut -d, -f2`
1237 DFAVAIL=`echo $STRING | cut -d, -f3`
1238 DFFREE=$(($DFTOTAL - $DFUSED))
1240 ALLOWANCE=$((64 * $OSTCOUNT))
1242 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1243 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1244 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1247 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1248 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1249 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1252 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1253 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1254 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1259 stop fs3ost -f || return 200
1260 stop fs2ost -f || return 201
1261 stop fs2mds -f || return 202
1262 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1263 unload_modules || return 203
1266 run_test 36 "df report consistency on OSTs with different block size"
1269 [ -n "$CLIENTONLY" -o -n "$CLIENTMODSONLY" ] && skip "client only testing" && return 0
1270 LOCAL_MDSDEV="$TMP/mdt.img"
1271 SYM_MDSDEV="$TMP/sym_mdt.img"
1273 echo "MDS : $LOCAL_MDSDEV"
1274 echo "SYMLINK : $SYM_MDSDEV"
1278 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1279 error "mkfs.lustre $LOCAL_MDSDEV failed"
1280 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1282 echo "mount symlink device - $SYM_MDSDEV"
1284 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1285 umount -d ${MOUNT%/*}/mds
1286 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1288 if [ -n "$mount_op" ]; then
1289 error "**** FAIL: set tunables failed for symlink device"
1293 run_test 37 "verify set tunables works for symlink device"
1295 test_38() { # bug 14222
1300 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1301 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1303 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1304 error "copying $SRC to $DIR/$tdir"
1306 umount_client $MOUNT
1308 log "rename lov_objid file on MDS"
1309 rm -f $TMP/lov_objid.orig
1311 local dev=${SINGLEMDS}_dev
1312 local MDSDEV=${!dev}
1313 do_facet $SINGLEMDS "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1314 do_facet $SINGLEMDS "debugfs -w -R \\\"rm lov_objid\\\" $MDSDEV"
1316 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1317 # check create in mds_lov_connect
1321 [ $V ] && log "verifying $DIR/$tdir/$f"
1322 diff -q $f $DIR/$tdir/$f || ERROR=y
1324 do_facet $SINGLEMDS "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1325 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1326 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1328 # check it's updates in sync
1329 umount_client $MOUNT
1332 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1333 do_facet $SINGLEMDS "debugfs -w -R \\\"rm lov_objid\\\" $MDSDEV"
1334 do_facet $SINGLEMDS "debugfs -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1339 [ $V ] && log "verifying $DIR/$tdir/$f"
1340 diff -q $f $DIR/$tdir/$f || ERROR=y
1342 do_facet $SINGLEMDS "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1343 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1344 umount_client $MOUNT
1346 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1348 log "files compared the same"
1351 run_test 38 "MDS recreates missing lov_objid file from OST data"
1357 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1358 error "memory leak detected" || true
1360 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1362 test_40() { # bug 15759
1364 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1365 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1369 run_test 40 "race during service thread startup"
1371 test_41() { #bug 14134
1373 local dev=${SINGLEMDS}_dev
1374 local MDSDEV=${!dev}
1376 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1377 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1378 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs
1380 mount_client $MOUNT || return 1
1383 echo "blah blah" > $MOUNT/$tfile
1386 umount_client $MOUNT
1387 stop ost1 -f || return 201
1388 stop_mds -f || return 202
1389 stop_mds -f || return 203
1390 unload_modules || return 204
1393 run_test 41 "mount mds with --nosvc and --nomgs"
1395 test_42() { #bug 14693
1397 check_mount || return 2
1398 do_facet client lctl conf_param lustre.llite.some_wrong_param=10
1399 umount_client $MOUNT
1400 mount_client $MOUNT || return 1
1404 run_test 42 "invalid config param should not prevent client from mounting"
1406 umount_client $MOUNT
1410 equals_msg `basename $0`: test complete
1411 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true