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: 13369
15 ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT 34a"
16 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
19 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
22 LUSTRE=${LUSTRE:-`dirname $0`/..}
23 RLUSTRE=${RLUSTRE:-$LUSTRE}
26 . $LUSTRE/tests/test-framework.sh
28 # STORED_MDSSIZE is used in test_18
29 if [ -n "$MDSSIZE" ]; then
30 STORED_MDSSIZE=$MDSSIZE
32 # use small MDS + OST size to speed formatting time
35 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
37 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
38 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
41 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30 31 45"
55 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
56 do_facet ${facet} "$TUNEFS --writeconf $dev" ||
57 { echo "tunefs failed, reformatting instead" && reformat_and_config && return 1; }
62 # if writeconf failed, we reformatted
63 writeconf1 mds $MDSDEV || return 0
64 writeconf1 ost1 `ostdevname 1` || return 0
65 writeconf1 ost2 `ostdevname 2` || return 0
69 # The MGS must be started before the OSTs for a new fs, so start
70 # and stop to generate the startup logs.
73 wait_osc_import_state mds ost FULL
78 reformat_and_config() {
80 if ! combined_mgs_mds ; then
88 start mgs $MGSDEV $mgs_MOUNT_OPTS
92 echo "start mds service on `facet_active_host mds`"
93 start mds $MDSDEV $MDS_MOUNT_OPTS $@ || return 94
97 echo "stop mgs service on `facet_active_host mgs`"
98 # These tests all use non-failover stop
99 stop mgs -f || return 97
103 echo "stop mds service on `facet_active_host mds`"
104 # These tests all use non-failover stop
105 stop mds -f || return 97
109 echo "start ost1 service on `facet_active_host ost1`"
110 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
114 echo "stop ost1 service on `facet_active_host ost1`"
115 # These tests all use non-failover stop
116 stop ost1 -f || return 98
120 echo "start ost2 service on `facet_active_host ost2`"
121 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
125 echo "stop ost2 service on `facet_active_host ost2`"
126 # These tests all use non-failover stop
127 stop ost2 -f || return 93
131 echo "start client on `facet_active_host client`"
132 start client || return 99
136 echo "stop client on `facet_active_host client`"
137 stop client || return 100
142 echo "mount $FSNAME on ${MOUNTPATH}....."
143 zconf_mount `hostname` $MOUNTPATH || return 96
147 local SAVEMOUNTOPT=$MOUNTOPT
148 MOUNTOPT="remount,$1"
150 echo "remount '$1' lustre on ${MOUNTPATH}....."
151 zconf_mount `hostname` $MOUNTPATH || return 96
152 MOUNTOPT=$SAVEMOUNTOPT
157 echo "umount lustre on ${MOUNTPATH}....."
158 zconf_umount `hostname` $MOUNTPATH || return 97
161 manual_umount_client(){
164 echo "manual umount lustre on ${MOUNT}...."
165 do_facet client "umount -d ${FORCE} $MOUNT"
171 start_mds || error "MDT start failed"
172 start_ost || error "OST start failed"
173 mount_client $MOUNT || error "client start failed"
178 if ! combined_mgs_mds ; then
188 stop_mds || return 201
189 stop_ost || return 202
190 unload_modules || return 203
194 umount_client $MOUNT || return 200
195 cleanup_nocli || return $?
199 do_facet client "cp /etc/passwd $DIR/a" || return 71
200 do_facet client "rm $DIR/a" || return 72
201 # make sure lustre is actually mounted (touch will block,
202 # but grep won't, so do it after)
203 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
204 echo "setup single mount lustre success"
208 do_facet client "touch $DIR/a" || return 71
209 do_facet client "rm $DIR/a" || return 72
210 do_facet client "touch $DIR2/a" || return 73
211 do_facet client "rm $DIR2/a" || return 74
212 echo "setup double mount lustre success"
217 if [ "$ONLY" == "setup" ]; then
222 if [ "$ONLY" == "cleanup" ]; then
227 #create single point mountpoint
233 check_mount || return 41
236 run_test 0 "single mount setup"
240 echo "start ost second time..."
241 start_ost && error "2nd OST start should fail"
242 start_mds || error "MDT start failed"
243 mount_client $MOUNT || error "client start failed"
244 check_mount || return 42
247 run_test 1 "start up ost twice (should return errors)"
252 echo "start mds second time.."
253 start_mds && error "2nd MDT start should fail"
255 check_mount || return 43
258 run_test 2 "start up mds twice (should return err)"
262 #mount.lustre returns an error if already in mtab
263 mount_client $MOUNT && error "2nd client mount should fail"
264 check_mount || return 44
267 run_test 3 "mount client twice (should return err)"
271 touch $DIR/$tfile || return 85
275 # ok for ost to fail shutdown
276 if [ 202 -ne $eno ]; then
281 run_test 4 "force cleanup ost, then cleanup"
283 test_5a() { # was test_5
285 touch $DIR/$tfile || return 1
286 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
288 stop_mds -f || return 2
290 # cleanup may return an error from the failed
291 # disconnects; for now I'll consider this successful
292 # if all the modules have unloaded.
296 echo "killing umount"
297 kill -TERM $UMOUNT_PID
298 echo "waiting for umount to finish"
300 if grep " $MOUNT " /proc/mounts; then
301 echo "test 5: /proc/mounts after failed umount"
305 echo "killing umount"
306 kill -TERM $UMOUNT_PID
307 echo "waiting for umount to finish"
309 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
313 # stop_mds is a no-op here, and should not fail
314 cleanup_nocli || return $?
315 # df may have lingering entry
317 # mtab may have lingering entry
321 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
323 grep -q $MOUNT" " /etc/mtab || break
324 echo "Waiting /etc/mtab updated ... "
325 WAIT=$(( WAIT + sleep))
327 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
328 echo "/etc/mtab updated in $WAIT secs"
330 run_test 5a "force cleanup mds, then cleanup"
338 grep " $MOUNT " /etc/mtab && \
339 error false "unexpected entry in mtab before mount" && return 10
343 if ! combined_mgs_mds ; then
344 trap cleanup_5b EXIT ERR
349 [ -d $MOUNT ] || mkdir -p $MOUNT
350 mount_client $MOUNT && rc=1
351 grep " $MOUNT " /etc/mtab && \
352 error "$MOUNT entry in mtab after failed mount" && rc=11
354 # stop_mds is a no-op here, and should not fail
355 cleanup_nocli || rc=$?
356 if ! combined_mgs_mds ; then
361 run_test 5b "Try to start a client with no MGS (should return errs)"
364 grep " $MOUNT " /etc/mtab && \
365 error false "unexpected entry in mtab before mount" && return 10
370 [ -d $MOUNT ] || mkdir -p $MOUNT
371 local oldfs="${FSNAME}"
372 FSNAME="wrong.${FSNAME}"
373 mount_client $MOUNT || :
375 grep " $MOUNT " /etc/mtab && \
376 error "$MOUNT entry in mtab after failed mount" && rc=11
378 cleanup_nocli || rc=$?
381 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
384 grep " $MOUNT " /etc/mtab && \
385 error false "unexpected entry in mtab before mount" && return 10
391 mount_client $MOUNT || rc=1
393 grep " $MOUNT " /etc/mtab && \
394 error "$MOUNT entry in mtab after unmount" && rc=11
397 run_test 5d "mount with ost down"
400 grep " $MOUNT " /etc/mtab && \
401 error false "unexpected entry in mtab before mount" && return 10
407 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
408 do_facet client "lctl set_param fail_loc=0x80000506"
409 mount_client $MOUNT || echo "mount failed (not fatal)"
411 grep " $MOUNT " /etc/mtab && \
412 error "$MOUNT entry in mtab after unmount" && rc=11
415 run_test 5e "delayed connect, don't crash (bug 10268)"
418 if combined_mgs_mds ; then
419 skip "combined mgs and mds"
423 grep " $MOUNT " /etc/mtab && \
424 error false "unexpected entry in mtab before mount" && return 10
428 [ -d $MOUNT ] || mkdir -p $MOUNT
429 mount_client $MOUNT &
431 echo client_mount pid is $pid
435 if ! ps -f -p $pid >/dev/null; then
438 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
439 error "mount returns $rc, expected to hang"
448 # mount should succeed after start mds
451 [ $rc -eq 0 ] || error "mount returned $rc"
452 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
456 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
461 mount_client ${MOUNT} || return 87
462 touch $DIR/a || return 86
465 run_test 6 "manual umount, then mount again"
470 cleanup_nocli || return $?
472 run_test 7 "manual umount, then cleanup"
477 check_mount2 || return 45
478 umount_client $MOUNT2
481 run_test 8 "double mount setup"
486 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
487 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
489 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
490 # interop 1.8 <-> 2.0: "trace inode warning error emerg console"
491 local lustre_version=$(get_lustre_version ost1)
492 echo ost1 running $lustre_version
493 if [ "$CHECK_PTLDEBUG" ] && [ "$CHECK_PTLDEBUG" = "trace inode" ]; then
494 echo "lnet.debug success"
495 elif [[ $lustre_version != 1.8* ]] && \
496 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ]; then
497 echo "lnet.debug success"
499 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
502 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
503 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
504 echo "lnet.subsystem_debug success"
506 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
509 stop_ost || return $?
511 run_test 9 "test ptldebug and subsystem for mkfs"
519 do_facet $facet "test -b $dev" || rc=1
520 if [[ "$size" ]]; then
521 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
522 awk '($3 == "in") { print $1 }')
523 [[ $in = "1+0" ]] || rc=1
530 # interop 1.8 <-> 2.0: 20: no LOGS
531 local files="{OBJECTS,PENDING}"
532 local lustre_version=$(get_lustre_version mds)
533 if [[ $lustre_version = 1.8* ]]; then
534 files="{OBJECTS,PENDING,LOGS}"
537 check_mount || return 41
540 local TMPMTPT="${TMP}/conf16"
542 is_blkdev mds $MDSDEV || LOOPOPT="-o loop"
544 log "change the mode of $MDSDEV/$files to 555"
545 do_facet mds "mkdir -p $TMPMTPT &&
546 mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
547 chmod 555 $TMPMTPT/$files &&
548 umount $TMPMTPT" || return $?
550 log "mount Lustre to change the mode of $files, then umount Lustre"
552 check_mount || return 41
555 log "read the mode of $files and check if they has been changed properly"
557 for file in ${files//[\{\},]/ }; do
558 expected=`do_facet mds "$DEBUGFS -R 'stat $file' $MDSDEV 2> /dev/null" | \
559 grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
561 if [ "$expected" = "0777" ]; then
562 log "Success:Lustre change the mode of $file correctly"
564 error "Lustre does not change mode of $file properly"
568 run_test 16 "verify that lustre will correct the mode of OBJECTS/LOGS/PENDING"
572 check_mount || return 41
575 echo "Remove mds config log"
576 if ! combined_mgs_mds ; then
580 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MGSDEV || return \$?" || return $?
582 if ! combined_mgs_mds ; then
587 start_mds && return 42
590 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
593 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
598 # check if current MDSSIZE is large enough
599 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
600 log "use MDSSIZE=$MDSSIZE"
602 # check if the global config has a large enough MDSSIZE
603 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
604 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
605 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
607 # check if the block device is large enough
608 [ -z "$OK" ] && $(is_blkdev mds $MDSDEV $MIN) && OK=1 &&
609 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
611 # check if a loopback device has enough space for fs metadata (5%)
613 if [ -z "$OK" ]; then
614 local SPACE=$(do_facet mds "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
615 awk '($1 != "Filesystem") {print $4}')
616 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
617 OK=1 && myMDSSIZE=$MIN && \
618 log "use file $MDSDEV with MIN=$MIN"
621 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
624 echo "mount mds with large journal..."
625 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
627 local opts="--mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
629 if combined_mgs_mds ; then
630 MDS_MKFS_OPTS="--mgs $opts"
632 MDS_MKFS_OPTS="--mgsnode=$MGSNID $opts"
636 echo "mount lustre system..."
638 check_mount || return 41
640 echo "check journal size..."
641 local FOUNDSIZE=$(do_facet mds "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
642 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
643 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
645 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
650 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
653 run_test 18 "check mkfs creates large journals"
656 start_mds || return 1
657 stop_mds -f || return 2
659 run_test 19a "start/stop MDS without OSTs"
662 start_ost || return 1
663 stop_ost -f || return 2
665 run_test 19b "start/stop OSTs without MDS"
668 # first format the ost/mdt
672 check_mount || return 43
674 remount_client ro $MOUNT || return 44
675 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
676 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
677 remount_client rw $MOUNT || return 47
679 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
680 MCNT=`grep -c $MOUNT /etc/mtab`
681 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
686 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
691 wait_osc_import_state mds ost FULL
695 run_test 21a "start mds before ost, stop ost first"
700 wait_osc_import_state mds ost FULL
704 run_test 21b "start ost before mds, stop mds first"
710 wait_osc_import_state mds ost2 FULL
715 #writeconf to remove all ost2 traces for subsequent tests
718 run_test 21c "start mds between two osts, stop mds last"
721 if combined_mgs_mds ; then
722 skip "need separate mgs device" && return 0
732 wait_osc_import_state mds ost2 FULL
739 run_test 21d "start mgs then ost and then mds"
745 echo Client mount with ost in logs, but none running
747 wait_osc_import_state mds ost FULL
750 # check_mount will block trying to contact ost
751 mcreate $DIR/$tfile || return 40
752 rm -f $DIR/$tfile || return 42
756 echo Client mount with a running ost
759 check_mount || return 41
764 run_test 22 "start a client before osts (should return errs)"
766 test_23a() { # was test_23
770 # force down client so that recovering mds waits for reconnect
771 local running=$(grep -c $MOUNT /proc/mounts) || true
772 if [ $running -ne 0 ]; then
773 echo "Stopping client $MOUNT (opts: -f)"
777 # enter recovery on mds
779 # try to start a new client
780 mount_client $MOUNT &
782 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
783 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
784 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
786 ps --ppid $MOUNT_LUSTRE_PID
787 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
788 kill -TERM $MOUNT_LUSTRE_PID
789 echo "waiting for mount to finish"
791 # we can not wait $MOUNT_PID because it is not a child of this shell
797 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
799 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
800 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
803 [ -z "$PID1" -a -z "$PID2" ] && break
804 echo "waiting for mount to finish ... "
805 WAIT=$(( WAIT + sleep))
807 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
808 error "MOUNT_PID $MOUNT_PID and \
809 MOUNT__LUSTRE_PID $MOUNT__LUSTRE_PID still not killed in $WAIT secs"
815 run_test 23a "interrupt client during recovery mount delay"
820 test_23b() { # was test_23
823 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
824 lctl set_param fail_loc=0x80000313
828 run_test 23b "Simulate -EINTR during mount"
830 fs2mds_HOST=$mds_HOST
831 fs2ost_HOST=$ost_HOST
835 echo "umount $MOUNT2 ..."
836 umount $MOUNT2 || true
837 echo "stopping fs2mds ..."
838 stop fs2mds -f || true
839 echo "stopping fs2ost ..."
840 stop fs2ost -f || true
844 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
845 is_blkdev mds $MDSDEV && \
846 skip_env "mixed loopback and real device not working" && return
849 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
851 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
852 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
854 # test 8-char fsname as well
855 local FSNAME2=test1234
856 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
858 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
861 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
862 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
864 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
866 check_mount || return 2
867 # files written on 1 should not show up on 2
868 cp /etc/passwd $DIR/$tfile
870 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
872 cp /etc/passwd $MOUNT2/b || return 3
873 rm $MOUNT2/b || return 4
874 # 2 is actually mounted
875 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
877 facet_failover fs2mds
878 facet_failover fs2ost
881 # the MDS must remain up until last MDT
884 local mdt_obdname=$(do_facet mds "lctl get_param -n devices" | \
885 awk '/ mdt / { print $4 }' | head -1)
886 [ -z "$mdt_obdname" ] && error "No MDT" && return 8
889 cleanup_nocli || return 6
891 run_test 24a "Multiple MDTs on a single node"
894 if [ -z "$fs2mds_DEV" ]; then
895 is_blkdev mds $MDSDEV && \
896 skip_env "mixed loopback and real device not working" && return
899 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
901 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
903 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
906 run_test 24b "Multiple MGSs on a single node (should return err)"
910 check_mount || return 2
911 local MODULES=$($LCTL modules | awk '{ print $2 }')
912 rmmod $MODULES 2>/dev/null || true
915 run_test 25 "Verify modules are referenced"
919 # we need modules before mount for sysctl, so make sure...
920 do_facet mds "lsmod | grep -q lustre || modprobe lustre"
921 #define OBD_FAIL_MDS_FS_SETUP 0x135
922 do_facet mds "lctl set_param fail_loc=0x80000135"
923 start_mds && echo MDS started && return 1
924 lctl get_param -n devices
925 DEVS=$(lctl get_param -n devices | wc -l)
926 [ $DEVS -gt 0 ] && return 2
927 unload_modules || return 203
929 run_test 26 "MDT startup failure cleans LOV (should return errs)"
935 local ORIG=$(do_facet $myfacet "$TEST")
936 if [ $# -gt 3 ]; then
942 echo "Setting $PARAM from $ORIG to $FINAL"
943 do_facet mds "$LCTL conf_param $PARAM=$FINAL" || error conf_param failed
945 wait_update $(facet_host $myfacet) "$TEST" $FINAL || error check failed!
949 start_ost || return 1
950 start_mds || return 2
951 echo "Requeue thread should have started: "
952 ps -e | grep ll_cfg_requeue
953 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
956 run_test 27a "Reacquire MGS lock if OST started first"
961 # interop 1.8 <-> 2.0:
962 # 1.8: group_acquire_expire, 2.0: identity_acquire_expire
963 local acquire_expire=$(do_facet mds lctl get_param md*.$FSNAME-MDT0000.*acquire_expire | \
964 cut -d= -f1 | cut -d. -f3)
966 set_and_check mds "lctl get_param -n md*.$FSNAME-MDT0000.$acquire_expire" \
967 "$FSNAME-MDT0000.mdt.$acquire_expire" || return 3
968 set_and_check client "lctl get_param -n mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight" \
969 "$FSNAME-MDT0000.mdc.max_rpcs_in_flight" || return 4
973 run_test 27b "Reacquire MGS lock after failover"
977 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
978 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
981 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
982 FINAL=$(($FINAL + 1))
983 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
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"
993 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
996 run_test 28 "permanent parameter setting"
999 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1000 setup > /dev/null 2>&1
1004 local PARAM="$FSNAME-OST0001.osc.active"
1005 local PROC_ACT="osc.$FSNAME-OST0001-osc-*.active"
1006 local PROC_UUID="osc.$FSNAME-OST0001-osc-*.ost_server_uuid"
1008 ACTV=$(lctl get_param -n $PROC_ACT)
1010 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1011 # also check ost_server_uuid status
1012 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1013 if [ -z "$RESULT" ]; then
1014 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1017 echo "Live client success: got $RESULT"
1021 local MPROC="osc.$(get_mdtosc_proc_path $FSNAME-OST0001).active"
1026 RESULT=`do_facet mds " lctl get_param -n $MPROC"`
1027 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1028 if [ $RESULT -eq $DEAC ]; then
1029 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
1033 if [ $WAIT -eq $MAX ]; then
1034 echo "MDT not deactivated: wanted $DEAC got $RESULT"
1037 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
1040 # test new client starts deactivated
1041 umount_client $MOUNT || return 200
1043 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1044 if [ -z "$RESULT" ]; then
1045 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1048 echo "New client success: got $RESULT"
1051 # make sure it reactivates
1052 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1054 umount_client $MOUNT
1057 #writeconf to remove all ost2 traces for subsequent tests
1060 run_test 29 "permanently remove an OST"
1065 echo Big config llog
1066 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1068 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1069 for i in ${LIST[@]}; do
1070 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1072 # make sure client restart still works
1073 umount_client $MOUNT
1074 mount_client $MOUNT || return 4
1075 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1078 echo Erase parameter setting
1079 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1080 umount_client $MOUNT
1081 mount_client $MOUNT || return 6
1083 echo "deleted (default) value=$FINAL, orig=$ORIG"
1084 # assumes this parameter started at the default value
1085 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1089 run_test 30a "Big config llog and conf_param deletion"
1094 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1095 # numerical part of it. Hopefully that's not already a failover address for
1097 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1098 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1099 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1100 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1101 echo "Using fake nid $NEW"
1103 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1104 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
1105 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1107 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1108 echo "should have 2 failover nids: $NIDCOUNT"
1109 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1110 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1111 umount_client $MOUNT
1112 mount_client $MOUNT || return 3
1114 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1116 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1117 echo "only 1 final nid should remain: $NIDCOUNT"
1118 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1122 run_test 30b "Remove failover nids"
1124 test_31() { # bug 10734
1125 # ipaddr must not exist
1126 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1129 run_test 31 "Connect to non-existent node (returns errors, should not crash)"
1131 # Use these start32/stop32 fn instead of t-f start/stop fn,
1132 # for local devices, to skip global facet vars init
1136 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1137 umount -d $@ ${MOUNT%/*}/${facet}
1146 mkdir -p ${MOUNT%/*}/${facet}
1148 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1149 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1151 if [ $RC -ne 0 ]; then
1152 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1153 echo "Start of ${device} of local ${facet} failed ${RC}"
1159 cleanup_nocli32 () {
1167 echo "Cleanup test_32 umount $MOUNT ..."
1168 umount -f $MOUNT || true
1169 echo "Cleanup local mds ost1 ..."
1175 # this test is totally useless on a client-only system
1176 client_only && skip "client only testing" && return 0
1177 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1178 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1180 local DISK1_6=$LUSTRE/tests/disk1_6.tar.bz2
1181 [ ! -r $DISK1_6 ] && skip_env "Cant find $DISK1_6, skipping" && return
1183 local tmpdir=$TMP/conf32a
1186 tar xjvf $DISK1_6 -C $tmpdir ||
1187 { skip_env "Cant untar $DISK1_6, skipping" && return ; }
1189 lctl set_param debug=$PTLDEBUG
1191 $TUNEFS $tmpdir/mds || error "tunefs failed"
1193 # nids are wrong, so client wont work, but server should start
1194 start32 mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1195 trap cleanup_32 EXIT INT || return 3
1197 local UUID=$(lctl get_param -n mds.lustre-MDT0000.uuid)
1199 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1201 $TUNEFS --mgsnode=`hostname` $tmpdir/ost1 || error "tunefs failed"
1202 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1203 UUID=$(lctl get_param -n obdfilter.lustre-OST0000.uuid)
1205 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1207 local NID=$($LCTL list_nids | head -1)
1209 echo "OSC changes should succeed:"
1210 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1211 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1213 echo "MDC changes should succeed:"
1214 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1215 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1220 # mount a second time to make sure we didnt leave upgrade flag on
1222 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1223 start32 mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1224 trap cleanup_32 EXIT INT || return 12
1228 rm -rf $tmpdir || true # true is only for TMP on NFS
1230 run_test 32a "Upgrade from 1.6 (not live)"
1233 # this test is totally useless on a client-only system
1234 client_only && skip "client only testing" && return 0
1235 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1236 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1238 local DISK1_6=$LUSTRE/tests/disk1_6.tar.bz2
1239 [ ! -r $DISK1_6 ] && skip_env "Cant find $DISK1_6, skipping" && return
1241 local tmpdir=$TMP/conf32b
1244 tar xjvf $DISK1_6 -C $tmpdir ||
1245 { skip_env "Cant untar $DISK1_6, skipping" && return ; }
1248 lctl set_param debug=$PTLDEBUG
1250 # Ugrade process in according to comment 2 bug 20246
1251 # writeconf will cause servers to register with their current nids
1252 $TUNEFS --mdt --writeconf --erase-param \
1253 --param="mdt.group_upcall=/usr/sbin/l_getgroups" $tmpdir/mds || \
1254 error "tunefs mds failed"
1256 start32 mds $tmpdir/mds "-o loop,abort_recov" && \
1257 trap cleanup_32 EXIT INT || return 3
1260 start32 mds "-o loop" $tmpdir/mds || return 4
1261 local UUID=$(lctl get_param -n mds.lustre-MDT0000.uuid)
1263 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1265 $TUNEFS --ost --writeconf --erase-param --mgsnode=`hostname`@$NETTYPE $tmpdir/ost1 || \
1266 error "tunefs ost failed"
1267 start32 ost1 $tmpdir/ost1 "-o loop,abort_recov" || return 5
1269 UUID=$(lctl get_param -n obdfilter.lustre-OST0000.uuid)
1271 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1273 local NID=$($LCTL list_nids | head -1)
1275 echo "OSC changes should succeed:"
1276 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || error "OSC conf_param failed"
1277 $LCTL conf_param lustre-OST0000.failover.node=$NID || error "add failover nid=$NID failed"
1279 echo "MDC changes should succeed:"
1280 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1283 # MDT and OST should have registered with new nids, so we should have
1284 # a fully-functioning client
1285 echo "Check client and old fs contents"
1287 local device=`h2$NETTYPE $HOSTNAME`:/lustre
1288 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1289 mount -t lustre $device $MOUNT || return 1
1291 local old=$(lctl get_param -n mdc.*.max_rpcs_in_flight)
1292 local new=$((old + 5))
1293 lctl conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=$new
1294 wait_update $HOSTNAME "lctl get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1296 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "2940530074 2837" ] || return 12
1301 rm -rf $tmpdir || true # true is only for TMP on NFS
1303 run_test 32b "Upgrade from 1.6 with writeconf"
1305 test_33a() { # bug 12333, was test_33
1307 local FSNAME2=test-123
1308 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1310 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1311 is_blkdev mds $MDSDEV && \
1312 skip_env "mixed loopback and real device not working" && return
1315 # interop 1.8 <-> 2.0
1317 local major=$(get_mds_version_major)
1318 local minor=$(get_mds_version_minor)
1319 if [ $major -le 1 -a $minor -le 8 ]; then
1322 mkfs_opts="--mkfsoptions='-J size=8'" # bug 17931
1325 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1326 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1327 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} $mkfs_opts --reformat $fs2mdsdev || exit 10
1328 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1330 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1331 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1332 do_facet mds "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1334 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1335 cp /etc/hosts $MOUNT2/. || rc=3
1338 cp /etc/hosts $MOUNT2/ || rc=3
1339 $LFS getstripe $MOUNT2/hosts
1344 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1345 cleanup_nocli || rc=6
1348 run_test 33a "Mount ost with a large index number"
1350 test_33b() { # was test_33a
1353 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1354 # Drop lock cancelation reply during umount
1355 #define OBD_FAIL_LDLM_CANCEL 0x304
1356 do_facet client lctl set_param fail_loc=0x80000304
1357 #lctl set_param debug=-1
1358 umount_client $MOUNT
1361 run_test 33b "Drop cancel during umount"
1365 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1366 manual_umount_client
1368 do_facet client killall -USR1 multiop
1369 if [ $rc -eq 0 ]; then
1370 error "umount not fail!"
1375 run_test 34a "umount with opened file should be fail"
1380 touch $DIR/$tfile || return 1
1381 stop_mds --force || return 2
1383 manual_umount_client --force
1385 if [ $rc -ne 0 ]; then
1386 error "mtab after failed umount - rc $rc"
1392 run_test 34b "force umount with failed mds should be normal"
1396 touch $DIR/$tfile || return 1
1397 stop_ost --force || return 2
1399 manual_umount_client --force
1401 if [ $rc -ne 0 ]; then
1402 error "mtab after failed umount - rc $rc"
1408 run_test 34c "force umount with failed ost should be normal"
1410 test_35a() { # bug 12459
1414 lctl set_param debug="ha"
1416 log "Set up a fake failnode for the MDS"
1418 do_facet mds $LCTL conf_param ${FSNAME}-MDT0000.failover.node=$FAKENID || return 4
1420 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1423 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1426 log "Stopping the MDT:"
1427 stop_mds || return 5
1429 df $MOUNT > /dev/null 2>&1 &
1431 log "Restarting the MDT:"
1432 start_mds || return 6
1433 log "Wait for df ($DFPID) ... "
1438 # retrieve from the log the first server that the client tried to
1439 # contact after the connection loss
1440 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1441 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1442 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1444 if (\\\$NF ~ /$FAKENID/)
1450 }" $TMP/lustre-log-$TESTNAME.log`
1451 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1453 # remove nid settings
1456 run_test 35a "Reconnect to the last active server first"
1458 test_35b() { # bug 18674
1459 remote_mds || { skip "local MDS" && return 0; }
1463 $LCTL set_param debug="ha"
1465 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1468 log "Set up a fake failnode for the MDS"
1470 do_facet mds $LCTL conf_param ${FSNAME}-MDT0000.failover.node=$FAKENID || \
1473 local at_max_saved=0
1474 # adaptive timeouts may prevent seeing the issue
1475 if at_is_enabled; then
1476 at_max_saved=$(at_max_get mds)
1477 at_max_set 0 mds client
1480 mkdir -p $MOUNT/$tdir
1482 log "Injecting EBUSY on MDS"
1483 # Setting OBD_FAIL_MDS_RESEND=0x136
1484 do_facet mds "$LCTL set_param fail_loc=0x80000136" || return 2
1486 $LCTL set_param mdc.${FSNAME}*.stats=clear
1488 log "Creating a test file and stat it"
1489 touch $MOUNT/$tdir/$tfile
1490 stat $MOUNT/$tdir/$tfile
1492 log "Stop injecting EBUSY on MDS"
1493 do_facet mds "$LCTL set_param fail_loc=0" || return 3
1494 rm -f $MOUNT/$tdir/$tfile
1497 # restore adaptive timeout
1498 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1500 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1502 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
1504 # retrieve from the log if the client has ever tried to
1505 # contact the fake server after the loss of connection
1506 FAILCONN=`awk "BEGIN {ret = 0;}
1507 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1509 if (\\\$NF ~ /$FAKENID/) {
1514 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1516 [ "$FAILCONN" == "0" ] && \
1517 log "ERROR: The client reconnection has not been triggered" && \
1519 [ "$FAILCONN" == "2" ] && \
1520 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1523 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
1524 # Reconnects are supposed to be rate limited to one every 5s
1525 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
1526 log "ERROR: Too many reconnects $CONNCNT" && \
1530 # remove nid settings
1533 run_test 35b "Continue reconnection retries, if the active server is busy"
1536 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1538 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1539 { skip "remote OST" && return 0; }
1542 local FSNAME2=test1234
1543 local fs3ost_HOST=$ost_HOST
1545 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1547 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1548 is_blkdev mds $MDSDEV && \
1549 skip_env "mixed loopback and real device not working" && return
1552 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1553 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1554 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1555 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1556 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1558 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1559 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1561 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1562 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1563 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1565 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1567 sleep 5 # until 11778 fixed
1569 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1571 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1572 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1573 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1574 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1575 DFTOTAL=`echo $STRING | cut -d, -f1`
1576 DFUSED=`echo $STRING | cut -d, -f2`
1577 DFAVAIL=`echo $STRING | cut -d, -f3`
1578 DFFREE=$(($DFTOTAL - $DFUSED))
1580 ALLOWANCE=$((64 * $OSTCOUNT))
1582 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1583 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1584 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1587 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1588 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1589 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1592 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1593 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1594 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1599 stop fs3ost -f || return 200
1600 stop fs2ost -f || return 201
1601 stop fs2mds -f || return 202
1602 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1603 unload_modules || return 203
1606 run_test 36 "df report consistency on OSTs with different block size"
1609 client_only && skip "client only testing" && return 0
1610 LOCAL_MDSDEV="$TMP/mdt.img"
1611 SYM_MDSDEV="$TMP/sym_mdt.img"
1613 echo "MDS : $LOCAL_MDSDEV"
1614 echo "SYMLINK : $SYM_MDSDEV"
1618 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1619 error "mkfs.lustre $LOCAL_MDSDEV failed"
1620 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1622 echo "mount symlink device - $SYM_MDSDEV"
1624 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1625 umount -d ${MOUNT%/*}/mds
1626 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1628 if [ -n "$mount_op" ]; then
1629 error "**** FAIL: set tunables failed for symlink device"
1633 run_test 37 "verify set tunables works for symlink device"
1635 test_38() { # bug 14222
1640 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1641 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1643 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1644 error "copying $SRC to $DIR/$tdir"
1646 umount_client $MOUNT
1648 log "rename lov_objid file on MDS"
1649 rm -f $TMP/lov_objid.orig
1650 do_facet mds "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1651 do_facet mds "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1653 do_facet mds "od -Ax -td8 $TMP/lov_objid.orig"
1654 # check create in mds_lov_connect
1658 [ $V ] && log "verifying $DIR/$tdir/$f"
1659 diff -q $f $DIR/$tdir/$f || ERROR=y
1661 do_facet mds "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1662 do_facet mds "od -Ax -td8 $TMP/lov_objid.new"
1663 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1666 # check it's updates in sync
1667 umount_client $MOUNT
1670 do_facet mds dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1671 do_facet mds "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1672 do_facet mds "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1677 [ $V ] && log "verifying $DIR/$tdir/$f"
1678 diff -q $f $DIR/$tdir/$f || ERROR=y
1680 do_facet mds "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1681 do_facet mds "od -Ax -td8 $TMP/lov_objid.new1"
1682 umount_client $MOUNT
1684 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1686 log "files compared the same"
1689 run_test 38 "MDS recreates missing lov_objid file from OST data"
1691 test_39() { #bug 14413
1695 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1696 error "memory leak detected" || true
1698 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1700 test_40() { # bug 15759
1702 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1703 do_facet mds "lctl set_param fail_loc=0x80000706"
1707 run_test 40 "race during service thread startup"
1709 test_41() { #bug 14134
1711 start mds $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1712 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1713 start mds $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1715 mount_client $MOUNT || return 1
1718 echo "blah blah" > $MOUNT/$tfile
1721 umount_client $MOUNT
1722 stop ost1 -f || return 201
1723 stop mds -f || return 202
1724 stop mds -f || return 203
1725 unload_modules || return 204
1728 run_test 41 "mount mds with --nosvc and --nomgs"
1730 test_42() { #bug 14693
1732 check_mount || return 2
1733 do_facet client lctl conf_param lustre.llite.some_wrong_param=10
1734 umount_client $MOUNT
1735 mount_client $MOUNT || return 1
1739 run_test 42 "invalid config param should not prevent client from mounting"
1741 test_43() { #bug 15993
1743 VERSION_1_8=$(do_facet mds $LCTL get_param version | grep ^lustre.*1\.[78])
1744 if [ -z "$VERSION_1_8" ]; then
1745 skip "skipping test for non 1.8 MDS"
1750 check_mount || return 2
1751 testfile=$DIR/$tfile
1752 lma="this-should-be-removed-after-remount-and-accessed"
1754 echo "set/get trusted.lma"
1755 #define OBD_FAIL_MDS_ALLOW_COMMON_EA_SETTING 0x13f
1756 do_facet mds "lctl set_param fail_loc=0x13f"
1757 lctl set_param fail_loc=0x13f
1758 setfattr -n trusted.lma -v $lma $testfile || error "create common EA"
1759 do_facet mds "lctl set_param fail_loc=0"
1760 lctl set_param fail_loc=0
1761 ATTR=$(getfattr -n trusted.lma $testfile 2> /dev/null | grep trusted.lma)
1762 [ "$ATTR" = "trusted.lma=\"$lma\"" ] || error "check common EA"
1763 umount_client $MOUNT
1768 check_mount || return 3
1769 #define OBD_FAIL_MDS_REMOVE_COMMON_EA 0x13e
1770 do_facet mds "lctl set_param fail_loc=0x13e"
1772 do_facet mds "lctl set_param fail_loc=0"
1773 getfattr -d -m trusted $testfile 2> /dev/null | \
1774 grep "trusted.lma" && error "common EA not removed" || true
1778 run_test 43 "remove common EA if it exists"
1782 check_mount || return 2
1783 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1785 UUIDS=$(do_facet mds "$LCTL get_param $(get_mds_mdt_device_proc_path).${FSNAME}*.exports.*.uuid")
1786 for VAL in $UUIDS; do
1787 NID=$(echo $VAL | cut -d= -f1)
1788 CLUUID=$(echo $VAL | cut -d= -f2)
1789 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1791 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1795 run_test 44 "mounted client proc entry exists"
1799 check_mount || return 2
1804 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1805 do_facet client "lctl set_param fail_loc=0x50f"
1808 manual_umount_client --force || return 3
1809 do_facet client "lctl set_param fail_loc=0x0"
1811 mount_client $MOUNT || return 4
1815 run_test 45 "long unlink handling in ptlrpcd"
1822 umount_client $MOUNT2 || rc=$?
1823 umount_client $MOUNT || rc=$?
1824 while [ $count -gt 0 ]; do
1825 stop ost${count} -f || rc=$?
1829 cleanup_nocli || rc=$?
1830 #writeconf to remove all ost2 traces for subsequent tests
1836 echo "Testing with $OSTCOUNT OSTs"
1838 start_mds || return 1
1839 #first client should see only one ost
1840 start_ost || return 2
1841 wait_osc_import_state mds ost FULL
1843 mount_client $MOUNT || return 3
1844 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1847 for (( i=2; i<=$OSTCOUNT; i++ )); do
1848 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1851 # wait until osts in sync
1852 for (( i=2; i<=$OSTCOUNT; i++ )); do
1853 wait_osc_import_state mds ost$i FULL
1856 #second client see all ost's
1858 mount_client $MOUNT2 || return 8
1859 $LFS setstripe $MOUNT2 -c -1 || return 9
1860 $LFS getstripe $MOUNT2 || return 10
1862 echo "ok" > $MOUNT2/widestripe
1863 $LFS getstripe $MOUNT2/widestripe || return 11
1864 # fill acl buffer for avoid expand lsm to them
1865 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1866 setfacl -m $acl $MOUNT2/widestripe
1870 stat $MOUNT/widestripe || return 12
1872 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1875 run_test 46a "handle ost additional - wide striped file"
1880 check_mount || return 2
1881 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1885 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1886 lrs=$(echo $ns | sed 's/.*lru_size=//')
1887 lru_size[count]=$lrs
1893 client_up || return 3
1896 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1897 lrs=$(echo $ns | sed 's/.*lru_size=//')
1898 if ! test "$lrs" -eq "${lru_size[count]}"; then
1899 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1900 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1908 run_test 47 "server restart does not make client loss lru_resize settings"
1913 # reformat after this test is needed - if test will failed
1914 # we will have unkillable file at FS
1918 test_48() { # bug 17636
1921 check_mount || return 2
1923 $LFS setstripe $MOUNT -c -1 || return 9
1924 $LFS getstripe $MOUNT || return 10
1926 echo "ok" > $MOUNT/widestripe
1927 $LFS getstripe $MOUNT/widestripe || return 11
1929 trap cleanup_48 EXIT ERR
1931 # fill acl buffer for avoid expand lsm to them
1932 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1933 setfacl -m $acl $MOUNT/widestripe
1936 stat $MOUNT/widestripe || return 12
1941 run_test 48 "too many acls on file"
1943 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1944 test_49() { # bug 17710
1945 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1946 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1947 local LOCAL_TIMEOUT=20
1949 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1953 check_mount || return 1
1955 echo "check ldlm_timout..."
1956 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1957 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1958 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1960 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1961 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1964 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1965 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1968 umount_client $MOUNT
1969 stop_ost || return 2
1970 stop_mds || return 3
1972 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$((LOCAL_TIMEOUT - 1)) $MKFSOPT $OSTOPT"
1976 check_mount || return 7
1978 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1979 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1980 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1982 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1983 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1986 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1987 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1990 cleanup || return $?
1992 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1993 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1995 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1998 # Test both statfs and lfs df and fail if either one fails
1999 multiop_bg_pause $1 f_
2002 killall -USR1 multiop
2003 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2004 wait $PID || { RC1=$?; log "multiop return error "; }
2011 if [ $RC2 -eq 0 ]; then
2013 log "lazystatfs df failed"
2017 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2023 lctl set_param llite.$FSNAME-*.lazystatfs=1
2026 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2028 cleanup || return $?
2030 run_test 50a "lazystatfs all servers available =========================="
2034 lctl set_param llite.$FSNAME-*.lazystatfs=1
2037 # Wait for client to detect down OST
2038 stop_ost || error "Unable to stop OST1"
2039 wait_osc_import_state mds ost DISCONN
2041 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2043 umount_client $MOUNT || error "Unable to unmount client"
2044 stop_mds || error "Unable to stop MDS"
2046 run_test 50b "lazystatfs all servers down =========================="
2049 start_mds || error "Unable to start MDS"
2050 start_ost || error "Unable to start OST1"
2051 start_ost2 || error "Unable to start OST2"
2052 mount_client $MOUNT || error "Unable to mount client"
2053 lctl set_param llite.$FSNAME-*.lazystatfs=1
2056 # Wait for client to detect down OST
2057 stop_ost || error "Unable to stop OST1"
2058 wait_osc_import_state mds ost DISCONN
2059 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2061 umount_client $MOUNT || error "Unable to unmount client"
2062 stop_ost2 || error "Unable to stop OST2"
2063 stop_mds || error "Unable to stop MDS"
2065 run_test 50c "lazystatfs one server down =========================="
2068 start_mds || error "Unable to start MDS"
2069 start_ost || error "Unable to start OST1"
2070 start_ost2 || error "Unable to start OST2"
2071 mount_client $MOUNT || error "Unable to mount client"
2072 lctl set_param llite.$FSNAME-*.lazystatfs=1
2075 # Issue the statfs during the window where the client still
2076 # belives the OST to be available but it is in fact down.
2077 # No failure just a statfs which hangs for a timeout interval.
2078 stop_ost || error "Unable to stop OST1"
2079 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2081 umount_client $MOUNT || error "Unable to unmount client"
2082 stop_ost2 || error "Unable to stop OST2"
2083 stop_mds || error "Unable to stop MDS"
2085 run_test 50d "lazystatfs client/server conn race =========================="
2092 start_mds || return 1
2093 #first client should see only one ost
2094 start_ost || return 2
2095 wait_osc_import_state mds ost FULL
2097 # Wait for client to detect down OST
2098 stop_ost || error "Unable to stop OST1"
2099 wait_osc_import_state mds ost DISCONN
2101 mount_client $MOUNT || error "Unable to mount client"
2102 lctl set_param llite.$FSNAME-*.lazystatfs=0
2104 multiop_bg_pause $MOUNT _f
2108 if [ $RC1 -ne 0 ]; then
2109 log "lazystatfs multiop failed $RC1"
2112 sleep $(( $TIMEOUT+1 ))
2114 [ $? -ne 0 ] && error "process isn't sleep"
2115 start_ost || error "Unable to start OST1"
2116 wait $pid || error "statfs failed"
2119 umount_client $MOUNT || error "Unable to unmount client"
2120 stop_ost || error "Unable to stop OST1"
2121 stop_mds || error "Unable to stop MDS"
2123 run_test 50e "normal statfs all servers down =========================="
2128 CONN_PROC="osc.$FSNAME-OST0001-osc.ost_server_uuid"
2130 start_mds || error "Unable to start mds"
2131 #first client should see only one ost
2132 start_ost || error "Unable to start OST1"
2133 wait_osc_import_state mds ost FULL
2135 start_ost2 || error "Unable to start OST2"
2136 wait_osc_import_state mds ost2 FULL
2138 # Wait for client to detect down OST
2139 stop_ost2 || error "Unable to stop OST2"
2140 wait_osc_import_state mds ost2 DISCONN
2142 mount_client $MOUNT || error "Unable to mount client"
2143 lctl set_param llite.$FSNAME-*.lazystatfs=0
2145 multiop_bg_pause $MOUNT _f
2149 if [ $RC1 -ne 0 ]; then
2150 log "lazystatfs multiop failed $RC1"
2153 sleep $(( $TIMEOUT+1 ))
2155 [ $? -ne 0 ] && error "process isn't sleep"
2156 start_ost2 || error "Unable to start OST2"
2157 wait $pid || error "statfs failed"
2158 stop_ost2 || error "Unable to stop OST2"
2161 umount_client $MOUNT || error "Unable to unmount client"
2162 stop_ost || error "Unable to stop OST1"
2163 stop_mds || error "Unable to stop MDS"
2164 #writeconf to remove all ost2 traces for subsequent tests
2167 run_test 50f "normal statfs one server in down =========================="
2170 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2172 start_ost2 || error "Unable to start OST2"
2174 local PARAM="${FSNAME}-OST0001.osc.active"
2176 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2177 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2179 umount_client $MOUNT || error "Unable to unmount client"
2180 mount_client $MOUNT || error "Unable to mount client"
2181 # This df should not cause a panic
2184 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2186 umount_client $MOUNT || error "Unable to unmount client"
2187 stop_ost2 || error "Unable to stop OST2"
2188 stop_ost || error "Unable to stop OST1"
2189 stop_mds || error "Unable to stop MDS"
2190 #writeconf to remove all ost2 traces for subsequent tests
2193 run_test 50g "deactivated OST should not cause panic====================="
2197 local max_ost_index=$1
2198 echo -n $(($max_ost_index * 8 + 8))
2202 local saved_opts=$OST_MKFS_OPTS
2204 for i in 0 1023 2048
2206 OST_MKFS_OPTS="$saved_opts --index $i"
2210 cp /etc/passwd $DIR/1
2214 cp /etc/passwd $DIR/2
2217 echo checking size of lov_objid for ost index $i
2218 local file_size=`do_facet mds \
2219 "$DEBUGFS -R 'stat lov_objid' $MDSDEV 2>/dev/null" | \
2220 grep ^User | awk '{print $6}'`
2221 if [ "$file_size" != $(lov_objid_size $i) ]; then
2222 error "lov_objid size has to be $(lov_objid_size $i), \
2225 echo ok, lov_objid size is correct: $file_size
2230 OST_MKFS_OPTS=$saved_opts
2233 run_test 55 "check lov_objid size"
2236 add mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $MDSDEV
2237 add ost1 $OST_MKFS_OPTS --index=1000 --reformat `ostdevname 1`
2238 add ost2 $OST_MKFS_OPTS --index=10000 --reformat `ostdevname 2`
2242 start_ost2 || error "Unable to start second ost"
2243 mount_client $MOUNT || error "Unable to mount client"
2248 run_test 56 "check big indexes"
2250 test_57() { # bug 22656
2251 local NID=$($LCTL list_nids | head -1)
2253 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2254 if ! combined_mgs_mds ; then
2259 start_ost && error "OST registration from failnode should fail"
2262 run_test 57 "initial registration from failnode should fail (should return errs)"
2264 test_58() { # bug 22658
2265 [ "$FSTYPE" != "ldiskfs" ] && skip "not supported for $FSTYPE" && return
2268 createmany -o $DIR/$tdir/$tfile-%d 100
2269 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
2270 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
2271 do_facet mds "lctl set_param fail_loc=0x601"
2272 unlinkmany $DIR/$tdir/$tfile-%d 100
2274 local MNTDIR=$(facet_mntpt mds)
2275 # remove all files from the OBJECTS dir
2276 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
2277 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
2278 do_facet mds "umount $MNTDIR"
2279 # restart MDS with missing llog files
2281 do_facet mds "lctl set_param fail_loc=0"
2284 run_test 58 "missing llog files must not prevent MDT from mounting"
2286 if ! combined_mgs_mds ; then
2290 equals_msg `basename $0`: test complete
2291 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true
2293 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2297 start_mds >> /dev/null
2298 local C1=$(count_osts)
2299 echo "original ost count: $C1 (expect > 0)"
2300 stop_mds >> /dev/null
2301 start_mds -o writeconf >> /dev/null || error "MDT start failed"
2302 local C2=$(count_osts)
2303 echo "after mdt writeconf count: $C2 (expect 0)"
2304 [ $C1 -gt 0 ] && [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2305 echo "OST start without writeconf should fail:"
2306 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2307 echo "OST start with writeconf should succeed:"
2308 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2309 local C3=$(count_osts)
2310 echo "after ost writeconf count: $C3 (expect 1)"
2311 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2312 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2313 local C4=$(count_osts)
2314 echo "after ost2 writeconf count: $C4 (expect 2)"
2315 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2316 stop_ost2 >> /dev/null
2317 cleanup_nocli >> /dev/null
2319 run_test 58 "writeconf mount option"