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"
1095 TEST="lctl get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1096 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
1097 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1099 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1100 echo "should have 2 failover nids: $NIDCOUNT"
1101 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1102 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1103 umount_client $MOUNT
1104 mount_client $MOUNT || return 3
1106 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1108 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1109 echo "only 1 final nid should remain: $NIDCOUNT"
1110 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1114 run_test 30b "Remove failover nids"
1116 test_31() { # bug 10734
1117 # ipaddr must not exist
1118 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1121 run_test 31 "Connect to non-existent node (returns errors, should not crash)"
1123 # Use these start32/stop32 fn instead of t-f start/stop fn,
1124 # for local devices, to skip global facet vars init
1128 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1129 umount -d $@ ${MOUNT%/*}/${facet}
1138 mkdir -p ${MOUNT%/*}/${facet}
1140 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1141 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1143 if [ $RC -ne 0 ]; then
1144 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1145 echo "Start of ${device} of local ${facet} failed ${RC}"
1151 cleanup_nocli32 () {
1159 echo "Cleanup test_32 umount $MOUNT ..."
1160 umount -f $MOUNT || true
1161 echo "Cleanup local mds ost1 ..."
1167 # this test is totally useless on a client-only system
1168 client_only && skip "client only testing" && return 0
1169 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1170 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1172 local DISK1_6=$LUSTRE/tests/disk1_6.tar.bz2
1173 [ ! -r $DISK1_6 ] && skip_env "Cant find $DISK1_6, skipping" && return
1175 local tmpdir=$TMP/conf32a
1178 tar xjvf $DISK1_6 -C $tmpdir ||
1179 { skip_env "Cant untar $DISK1_6, skipping" && return ; }
1181 lctl set_param debug=$PTLDEBUG
1183 $TUNEFS $tmpdir/mds || error "tunefs failed"
1185 # nids are wrong, so client wont work, but server should start
1186 start32 mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1187 trap cleanup_32 EXIT INT || return 3
1189 local UUID=$(lctl get_param -n mds.lustre-MDT0000.uuid)
1191 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1193 $TUNEFS --mgsnode=`hostname` $tmpdir/ost1 || error "tunefs failed"
1194 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1195 UUID=$(lctl get_param -n obdfilter.lustre-OST0000.uuid)
1197 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1199 local NID=$($LCTL list_nids | head -1)
1201 echo "OSC changes should succeed:"
1202 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1203 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1205 echo "MDC changes should succeed:"
1206 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1207 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1212 # mount a second time to make sure we didnt leave upgrade flag on
1214 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1215 start32 mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1216 trap cleanup_32 EXIT INT || return 12
1220 rm -rf $tmpdir || true # true is only for TMP on NFS
1222 run_test 32a "Upgrade from 1.6 (not live)"
1225 # this test is totally useless on a client-only system
1226 client_only && skip "client only testing" && return 0
1227 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1228 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1230 local DISK1_6=$LUSTRE/tests/disk1_6.tar.bz2
1231 [ ! -r $DISK1_6 ] && skip_env "Cant find $DISK1_6, skipping" && return
1233 local tmpdir=$TMP/conf32b
1236 tar xjvf $DISK1_6 -C $tmpdir ||
1237 { skip_env "Cant untar $DISK1_6, skipping" && return ; }
1240 lctl set_param debug=$PTLDEBUG
1242 # Ugrade process in according to comment 2 bug 20246
1243 # writeconf will cause servers to register with their current nids
1244 $TUNEFS --mdt --writeconf --erase-param \
1245 --param="mdt.group_upcall=/usr/sbin/l_getgroups" $tmpdir/mds || \
1246 error "tunefs mds failed"
1248 start32 mds $tmpdir/mds "-o loop,abort_recov" && \
1249 trap cleanup_32 EXIT INT || return 3
1252 start32 mds "-o loop" $tmpdir/mds || return 4
1253 local UUID=$(lctl get_param -n mds.lustre-MDT0000.uuid)
1255 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1257 $TUNEFS --ost --writeconf --erase-param --mgsnode=`hostname`@$NETTYPE $tmpdir/ost1 || \
1258 error "tunefs ost failed"
1259 start32 ost1 $tmpdir/ost1 "-o loop,abort_recov" || return 5
1261 UUID=$(lctl get_param -n obdfilter.lustre-OST0000.uuid)
1263 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1265 local NID=$($LCTL list_nids | head -1)
1267 echo "OSC changes should succeed:"
1268 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || error "OSC conf_param failed"
1269 $LCTL conf_param lustre-OST0000.failover.node=$NID || error "add failover nid=$NID failed"
1271 echo "MDC changes should succeed:"
1272 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1275 # MDT and OST should have registered with new nids, so we should have
1276 # a fully-functioning client
1277 echo "Check client and old fs contents"
1279 local device=`h2$NETTYPE $HOSTNAME`:/lustre
1280 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1281 mount -t lustre $device $MOUNT || return 1
1283 local old=$(lctl get_param -n mdc.*.max_rpcs_in_flight)
1284 local new=$((old + 5))
1285 lctl conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=$new
1286 wait_update $HOSTNAME "lctl get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1288 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "2940530074 2837" ] || return 12
1293 rm -rf $tmpdir || true # true is only for TMP on NFS
1295 run_test 32b "Upgrade from 1.6 with writeconf"
1297 test_33a() { # bug 12333, was test_33
1299 local FSNAME2=test-123
1300 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1302 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1303 is_blkdev mds $MDSDEV && \
1304 skip_env "mixed loopback and real device not working" && return
1307 # interop 1.8 <-> 2.0
1309 local major=$(get_mds_version_major)
1310 local minor=$(get_mds_version_minor)
1311 if [ $major -le 1 -a $minor -le 8 ]; then
1314 mkfs_opts="--mkfsoptions='-J size=8'" # bug 17931
1317 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1318 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1319 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} $mkfs_opts --reformat $fs2mdsdev || exit 10
1320 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1322 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1323 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1324 do_facet mds "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1326 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1327 cp /etc/hosts $MOUNT2/. || rc=3
1330 cp /etc/hosts $MOUNT2/ || rc=3
1331 $LFS getstripe $MOUNT2/hosts
1336 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1337 cleanup_nocli || rc=6
1340 run_test 33a "Mount ost with a large index number"
1342 test_33b() { # was test_33a
1345 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1346 # Drop lock cancelation reply during umount
1347 #define OBD_FAIL_LDLM_CANCEL 0x304
1348 do_facet client lctl set_param fail_loc=0x80000304
1349 #lctl set_param debug=-1
1350 umount_client $MOUNT
1353 run_test 33b "Drop cancel during umount"
1357 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1358 manual_umount_client
1360 do_facet client killall -USR1 multiop
1361 if [ $rc -eq 0 ]; then
1362 error "umount not fail!"
1367 run_test 34a "umount with opened file should be fail"
1372 touch $DIR/$tfile || return 1
1373 stop_mds --force || return 2
1375 manual_umount_client --force
1377 if [ $rc -ne 0 ]; then
1378 error "mtab after failed umount - rc $rc"
1384 run_test 34b "force umount with failed mds should be normal"
1388 touch $DIR/$tfile || return 1
1389 stop_ost --force || return 2
1391 manual_umount_client --force
1393 if [ $rc -ne 0 ]; then
1394 error "mtab after failed umount - rc $rc"
1400 run_test 34c "force umount with failed ost should be normal"
1402 test_35a() { # bug 12459
1406 lctl set_param debug="ha"
1408 log "Set up a fake failnode for the MDS"
1410 do_facet mds $LCTL conf_param ${FSNAME}-MDT0000.failover.node=$FAKENID || return 4
1412 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1415 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1418 log "Stopping the MDT:"
1419 stop_mds || return 5
1421 df $MOUNT > /dev/null 2>&1 &
1423 log "Restarting the MDT:"
1424 start_mds || return 6
1425 log "Wait for df ($DFPID) ... "
1430 # retrieve from the log the first server that the client tried to
1431 # contact after the connection loss
1432 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1433 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1434 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1436 if (\\\$NF ~ /$FAKENID/)
1442 }" $TMP/lustre-log-$TESTNAME.log`
1443 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1445 # remove nid settings
1448 run_test 35a "Reconnect to the last active server first"
1450 test_35b() { # bug 18674
1451 remote_mds || { skip "local MDS" && return 0; }
1455 $LCTL set_param debug="ha"
1457 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1460 log "Set up a fake failnode for the MDS"
1462 do_facet mds $LCTL conf_param ${FSNAME}-MDT0000.failover.node=$FAKENID || \
1465 local at_max_saved=0
1466 # adaptive timeouts may prevent seeing the issue
1467 if at_is_enabled; then
1468 at_max_saved=$(at_max_get mds)
1469 at_max_set 0 mds client
1472 mkdir -p $MOUNT/$tdir
1474 log "Injecting EBUSY on MDS"
1475 # Setting OBD_FAIL_MDS_RESEND=0x136
1476 do_facet mds "$LCTL set_param fail_loc=0x80000136" || return 2
1478 $LCTL set_param mdc.${FSNAME}*.stats=clear
1480 log "Creating a test file and stat it"
1481 touch $MOUNT/$tdir/$tfile
1482 stat $MOUNT/$tdir/$tfile
1484 log "Stop injecting EBUSY on MDS"
1485 do_facet mds "$LCTL set_param fail_loc=0" || return 3
1486 rm -f $MOUNT/$tdir/$tfile
1489 # restore adaptive timeout
1490 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1492 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1494 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
1496 # retrieve from the log if the client has ever tried to
1497 # contact the fake server after the loss of connection
1498 FAILCONN=`awk "BEGIN {ret = 0;}
1499 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1501 if (\\\$NF ~ /$FAKENID/) {
1506 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1508 [ "$FAILCONN" == "0" ] && \
1509 log "ERROR: The client reconnection has not been triggered" && \
1511 [ "$FAILCONN" == "2" ] && \
1512 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1515 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
1516 # Reconnects are supposed to be rate limited to one every 5s
1517 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
1518 log "ERROR: Too many reconnects $CONNCNT" && \
1522 # remove nid settings
1525 run_test 35b "Continue reconnection retries, if the active server is busy"
1528 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1530 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1531 { skip "remote OST" && return 0; }
1534 local FSNAME2=test1234
1535 local fs3ost_HOST=$ost_HOST
1537 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1539 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1540 is_blkdev mds $MDSDEV && \
1541 skip_env "mixed loopback and real device not working" && return
1544 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1545 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1546 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1547 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1548 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1550 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1551 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1553 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1554 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1555 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1557 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1559 sleep 5 # until 11778 fixed
1561 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1563 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1564 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1565 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1566 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1567 DFTOTAL=`echo $STRING | cut -d, -f1`
1568 DFUSED=`echo $STRING | cut -d, -f2`
1569 DFAVAIL=`echo $STRING | cut -d, -f3`
1570 DFFREE=$(($DFTOTAL - $DFUSED))
1572 ALLOWANCE=$((64 * $OSTCOUNT))
1574 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1575 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1576 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1579 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1580 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1581 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1584 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1585 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1586 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1591 stop fs3ost -f || return 200
1592 stop fs2ost -f || return 201
1593 stop fs2mds -f || return 202
1594 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1595 unload_modules || return 203
1598 run_test 36 "df report consistency on OSTs with different block size"
1601 client_only && skip "client only testing" && return 0
1602 LOCAL_MDSDEV="$TMP/mdt.img"
1603 SYM_MDSDEV="$TMP/sym_mdt.img"
1605 echo "MDS : $LOCAL_MDSDEV"
1606 echo "SYMLINK : $SYM_MDSDEV"
1610 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1611 error "mkfs.lustre $LOCAL_MDSDEV failed"
1612 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1614 echo "mount symlink device - $SYM_MDSDEV"
1616 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1617 umount -d ${MOUNT%/*}/mds
1618 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1620 if [ -n "$mount_op" ]; then
1621 error "**** FAIL: set tunables failed for symlink device"
1625 run_test 37 "verify set tunables works for symlink device"
1627 test_38() { # bug 14222
1632 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1633 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1635 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1636 error "copying $SRC to $DIR/$tdir"
1638 umount_client $MOUNT
1640 log "rename lov_objid file on MDS"
1641 rm -f $TMP/lov_objid.orig
1642 do_facet mds "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1643 do_facet mds "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1645 do_facet mds "od -Ax -td8 $TMP/lov_objid.orig"
1646 # check create in mds_lov_connect
1650 [ $V ] && log "verifying $DIR/$tdir/$f"
1651 diff -q $f $DIR/$tdir/$f || ERROR=y
1653 do_facet mds "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1654 do_facet mds "od -Ax -td8 $TMP/lov_objid.new"
1655 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1658 # check it's updates in sync
1659 umount_client $MOUNT
1662 do_facet mds dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1663 do_facet mds "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1664 do_facet mds "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1669 [ $V ] && log "verifying $DIR/$tdir/$f"
1670 diff -q $f $DIR/$tdir/$f || ERROR=y
1672 do_facet mds "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1673 do_facet mds "od -Ax -td8 $TMP/lov_objid.new1"
1674 umount_client $MOUNT
1676 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1678 log "files compared the same"
1681 run_test 38 "MDS recreates missing lov_objid file from OST data"
1683 test_39() { #bug 14413
1687 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1688 error "memory leak detected" || true
1690 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1692 test_40() { # bug 15759
1694 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1695 do_facet mds "lctl set_param fail_loc=0x80000706"
1699 run_test 40 "race during service thread startup"
1701 test_41() { #bug 14134
1703 start mds $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1704 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1705 start mds $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1707 mount_client $MOUNT || return 1
1710 echo "blah blah" > $MOUNT/$tfile
1713 umount_client $MOUNT
1714 stop ost1 -f || return 201
1715 stop mds -f || return 202
1716 stop mds -f || return 203
1717 unload_modules || return 204
1720 run_test 41 "mount mds with --nosvc and --nomgs"
1722 test_42() { #bug 14693
1724 check_mount || return 2
1725 do_facet client lctl conf_param lustre.llite.some_wrong_param=10
1726 umount_client $MOUNT
1727 mount_client $MOUNT || return 1
1731 run_test 42 "invalid config param should not prevent client from mounting"
1733 test_43() { #bug 15993
1735 VERSION_1_8=$(do_facet mds $LCTL get_param version | grep ^lustre.*1\.[78])
1736 if [ -z "$VERSION_1_8" ]; then
1737 skip "skipping test for non 1.8 MDS"
1742 check_mount || return 2
1743 testfile=$DIR/$tfile
1744 lma="this-should-be-removed-after-remount-and-accessed"
1746 echo "set/get trusted.lma"
1747 #define OBD_FAIL_MDS_ALLOW_COMMON_EA_SETTING 0x13f
1748 do_facet mds "lctl set_param fail_loc=0x13f"
1749 lctl set_param fail_loc=0x13f
1750 setfattr -n trusted.lma -v $lma $testfile || error "create common EA"
1751 do_facet mds "lctl set_param fail_loc=0"
1752 lctl set_param fail_loc=0
1753 ATTR=$(getfattr -n trusted.lma $testfile 2> /dev/null | grep trusted.lma)
1754 [ "$ATTR" = "trusted.lma=\"$lma\"" ] || error "check common EA"
1755 umount_client $MOUNT
1760 check_mount || return 3
1761 #define OBD_FAIL_MDS_REMOVE_COMMON_EA 0x13e
1762 do_facet mds "lctl set_param fail_loc=0x13e"
1764 do_facet mds "lctl set_param fail_loc=0"
1765 getfattr -d -m trusted $testfile 2> /dev/null | \
1766 grep "trusted.lma" && error "common EA not removed" || true
1770 run_test 43 "remove common EA if it exists"
1774 check_mount || return 2
1775 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1777 UUIDS=$(do_facet mds "$LCTL get_param $(get_mds_mdt_device_proc_path).${FSNAME}*.exports.*.uuid")
1778 for VAL in $UUIDS; do
1779 NID=$(echo $VAL | cut -d= -f1)
1780 CLUUID=$(echo $VAL | cut -d= -f2)
1781 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1783 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1787 run_test 44 "mounted client proc entry exists"
1791 check_mount || return 2
1796 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1797 do_facet client "lctl set_param fail_loc=0x50f"
1800 manual_umount_client --force || return 3
1801 do_facet client "lctl set_param fail_loc=0x0"
1803 mount_client $MOUNT || return 4
1807 run_test 45 "long unlink handling in ptlrpcd"
1814 umount_client $MOUNT2 || rc=$?
1815 umount_client $MOUNT || rc=$?
1816 while [ $count -gt 0 ]; do
1817 stop ost${count} -f || rc=$?
1821 cleanup_nocli || rc=$?
1822 #writeconf to remove all ost2 traces for subsequent tests
1828 echo "Testing with $OSTCOUNT OSTs"
1830 start_mds || return 1
1831 #first client should see only one ost
1832 start_ost || return 2
1833 wait_osc_import_state mds ost FULL
1835 mount_client $MOUNT || return 3
1836 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1839 for (( i=2; i<=$OSTCOUNT; i++ )); do
1840 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1843 # wait until osts in sync
1844 for (( i=2; i<=$OSTCOUNT; i++ )); do
1845 wait_osc_import_state mds ost$i FULL
1848 #second client see all ost's
1850 mount_client $MOUNT2 || return 8
1851 $LFS setstripe $MOUNT2 -c -1 || return 9
1852 $LFS getstripe $MOUNT2 || return 10
1854 echo "ok" > $MOUNT2/widestripe
1855 $LFS getstripe $MOUNT2/widestripe || return 11
1856 # fill acl buffer for avoid expand lsm to them
1857 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1858 setfacl -m $acl $MOUNT2/widestripe
1862 stat $MOUNT/widestripe || return 12
1864 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1867 run_test 46a "handle ost additional - wide striped file"
1872 check_mount || return 2
1873 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1877 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1878 lrs=$(echo $ns | sed 's/.*lru_size=//')
1879 lru_size[count]=$lrs
1885 client_up || return 3
1888 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1889 lrs=$(echo $ns | sed 's/.*lru_size=//')
1890 if ! test "$lrs" -eq "${lru_size[count]}"; then
1891 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1892 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1900 run_test 47 "server restart does not make client loss lru_resize settings"
1905 # reformat after this test is needed - if test will failed
1906 # we will have unkillable file at FS
1910 test_48() { # bug 17636
1913 check_mount || return 2
1915 $LFS setstripe $MOUNT -c -1 || return 9
1916 $LFS getstripe $MOUNT || return 10
1918 echo "ok" > $MOUNT/widestripe
1919 $LFS getstripe $MOUNT/widestripe || return 11
1921 trap cleanup_48 EXIT ERR
1923 # fill acl buffer for avoid expand lsm to them
1924 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1925 setfacl -m $acl $MOUNT/widestripe
1928 stat $MOUNT/widestripe || return 12
1933 run_test 48 "too many acls on file"
1935 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1936 test_49() { # bug 17710
1937 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1938 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1939 local LOCAL_TIMEOUT=20
1941 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1945 check_mount || return 1
1947 echo "check ldlm_timout..."
1948 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1949 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1950 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1952 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1953 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1956 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1957 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1960 umount_client $MOUNT
1961 stop_ost || return 2
1962 stop_mds || return 3
1964 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"
1968 check_mount || return 7
1970 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1971 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1972 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1974 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1975 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1978 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1979 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1982 cleanup || return $?
1984 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1985 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1987 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1990 # Test both statfs and lfs df and fail if either one fails
1991 multiop_bg_pause $1 f_
1994 killall -USR1 multiop
1995 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
1996 wait $PID || { RC1=$?; log "multiop return error "; }
2003 if [ $RC2 -eq 0 ]; then
2005 log "lazystatfs df failed"
2009 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2015 lctl set_param llite.$FSNAME-*.lazystatfs=1
2018 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2020 cleanup || return $?
2022 run_test 50a "lazystatfs all servers available =========================="
2026 lctl set_param llite.$FSNAME-*.lazystatfs=1
2029 # Wait for client to detect down OST
2030 stop_ost || error "Unable to stop OST1"
2031 wait_osc_import_state mds ost DISCONN
2033 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2035 umount_client $MOUNT || error "Unable to unmount client"
2036 stop_mds || error "Unable to stop MDS"
2038 run_test 50b "lazystatfs all servers down =========================="
2041 start_mds || error "Unable to start MDS"
2042 start_ost || error "Unable to start OST1"
2043 start_ost2 || error "Unable to start OST2"
2044 mount_client $MOUNT || error "Unable to mount client"
2045 lctl set_param llite.$FSNAME-*.lazystatfs=1
2048 # Wait for client to detect down OST
2049 stop_ost || error "Unable to stop OST1"
2050 wait_osc_import_state mds ost DISCONN
2051 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2053 umount_client $MOUNT || error "Unable to unmount client"
2054 stop_ost2 || error "Unable to stop OST2"
2055 stop_mds || error "Unable to stop MDS"
2057 run_test 50c "lazystatfs one server down =========================="
2060 start_mds || error "Unable to start MDS"
2061 start_ost || error "Unable to start OST1"
2062 start_ost2 || error "Unable to start OST2"
2063 mount_client $MOUNT || error "Unable to mount client"
2064 lctl set_param llite.$FSNAME-*.lazystatfs=1
2067 # Issue the statfs during the window where the client still
2068 # belives the OST to be available but it is in fact down.
2069 # No failure just a statfs which hangs for a timeout interval.
2070 stop_ost || error "Unable to stop OST1"
2071 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2073 umount_client $MOUNT || error "Unable to unmount client"
2074 stop_ost2 || error "Unable to stop OST2"
2075 stop_mds || error "Unable to stop MDS"
2077 run_test 50d "lazystatfs client/server conn race =========================="
2084 start_mds || return 1
2085 #first client should see only one ost
2086 start_ost || return 2
2087 wait_osc_import_state mds ost FULL
2089 # Wait for client to detect down OST
2090 stop_ost || error "Unable to stop OST1"
2091 wait_osc_import_state mds ost DISCONN
2093 mount_client $MOUNT || error "Unable to mount client"
2094 lctl set_param llite.$FSNAME-*.lazystatfs=0
2096 multiop_bg_pause $MOUNT _f
2100 if [ $RC1 -ne 0 ]; then
2101 log "lazystatfs multiop failed $RC1"
2104 sleep $(( $TIMEOUT+1 ))
2106 [ $? -ne 0 ] && error "process isn't sleep"
2107 start_ost || error "Unable to start OST1"
2108 wait $pid || error "statfs failed"
2111 umount_client $MOUNT || error "Unable to unmount client"
2112 stop_ost || error "Unable to stop OST1"
2113 stop_mds || error "Unable to stop MDS"
2115 run_test 50e "normal statfs all servers down =========================="
2120 CONN_PROC="osc.$FSNAME-OST0001-osc.ost_server_uuid"
2122 start_mds || error "Unable to start mds"
2123 #first client should see only one ost
2124 start_ost || error "Unable to start OST1"
2125 wait_osc_import_state mds ost FULL
2127 start_ost2 || error "Unable to start OST2"
2128 wait_osc_import_state mds ost2 FULL
2130 # Wait for client to detect down OST
2131 stop_ost2 || error "Unable to stop OST2"
2132 wait_osc_import_state mds ost2 DISCONN
2134 mount_client $MOUNT || error "Unable to mount client"
2135 lctl set_param llite.$FSNAME-*.lazystatfs=0
2137 multiop_bg_pause $MOUNT _f
2141 if [ $RC1 -ne 0 ]; then
2142 log "lazystatfs multiop failed $RC1"
2145 sleep $(( $TIMEOUT+1 ))
2147 [ $? -ne 0 ] && error "process isn't sleep"
2148 start_ost2 || error "Unable to start OST2"
2149 wait $pid || error "statfs failed"
2150 stop_ost2 || error "Unable to stop OST2"
2153 umount_client $MOUNT || error "Unable to unmount client"
2154 stop_ost || error "Unable to stop OST1"
2155 stop_mds || error "Unable to stop MDS"
2156 #writeconf to remove all ost2 traces for subsequent tests
2159 run_test 50f "normal statfs one server in down =========================="
2162 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2164 start_ost2 || error "Unable to start OST2"
2166 local PARAM="${FSNAME}-OST0001.osc.active"
2168 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2169 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2171 umount_client $MOUNT || error "Unable to unmount client"
2172 mount_client $MOUNT || error "Unable to mount client"
2173 # This df should not cause a panic
2176 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2178 umount_client $MOUNT || error "Unable to unmount client"
2179 stop_ost2 || error "Unable to stop OST2"
2180 stop_ost || error "Unable to stop OST1"
2181 stop_mds || error "Unable to stop MDS"
2182 #writeconf to remove all ost2 traces for subsequent tests
2185 run_test 50g "deactivated OST should not cause panic====================="
2187 if ! combined_mgs_mds ; then
2191 equals_msg `basename $0`: test complete
2192 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true