2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:autoindent:shiftwidth=4:tabstop=4:
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:
16 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
17 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
19 if [ "$FAILURE_MODE" = "HARD" ]; then
20 CONFIG_EXCEPTIONS="24a " && \
21 echo "Except the tests: $CONFIG_EXCEPTIONS for FAILURE_MODE=$FAILURE_MODE, bug 23573" && \
22 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
26 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
28 PTLDEBUG=${PTLDEBUG:--1}
30 LUSTRE=${LUSTRE:-`dirname $0`/..}
31 RLUSTRE=${RLUSTRE:-$LUSTRE}
33 . $LUSTRE/tests/test-framework.sh
36 # use small MDS + OST size to speed formatting time
37 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
40 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
42 if ! combined_mgs_mds; then
43 # bug number for skipped test: 23954
44 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
47 # STORED_MDSSIZE is used in test_18
48 if [ -n "$MDSSIZE" ]; then
49 STORED_MDSSIZE=$MDSSIZE
52 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
53 for facet in MGS MDS OST; do
54 opts=${facet}_MKFS_OPTS
55 if [[ ${!opts} != *lazy_itable_init* ]]; then
56 eval SAVED_${facet}_MKFS_OPTS=\"${!opts}\"
57 eval ${facet}_MKFS_OPTS=\"${!opts} \
58 --mkfsoptions='\\\"-E lazy_itable_init\\\"'\"
65 require_dsh_mds || exit 0
66 require_dsh_ost || exit 0
68 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
83 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
84 do_facet ${facet} "$TUNEFS --quiet --writeconf $dev" ||
85 { echo "tunefs failed, reformatting instead" && reformat_and_config && return 1; }
92 # if writeconf fails anywhere, we reformat everything
93 writeconf1 mds `mdsdevname 1` || return 0
94 writeconf1 ost1 `ostdevname 1` || return 0
95 writeconf1 ost2 `ostdevname 2` || return 0
99 # The MGS must be started before the OSTs for a new fs, so start
100 # and stop to generate the startup logs.
103 wait_osc_import_state mds ost FULL
108 reformat_and_config() {
110 if ! combined_mgs_mds ; then
118 start mgs $MGSDEV $MGS_MOUNT_OPTS
122 local facet=$SINGLEMDS
123 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
124 local num=$(echo $facet | tr -d "mds")
125 local dev=$(mdsdevname $num)
126 echo "start mds service on `facet_active_host $facet`"
127 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
131 if ! combined_mgs_mds ; then
138 echo "stop mds service on `facet_active_host $SINGLEMDS`"
139 # These tests all use non-failover stop
140 stop $SINGLEMDS -f || return 97
144 echo "stop mgs service on `facet_active_host mgs`"
145 # These tests all use non-failover stop
146 stop mgs -f || return 97
150 echo "start ost1 service on `facet_active_host ost1`"
151 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
155 echo "stop ost1 service on `facet_active_host ost1`"
156 # These tests all use non-failover stop
157 stop ost1 -f || return 98
161 echo "start ost2 service on `facet_active_host ost2`"
162 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
166 echo "stop ost2 service on `facet_active_host ost2`"
167 # These tests all use non-failover stop
168 stop ost2 -f || return 93
173 echo "mount $FSNAME on ${MOUNTPATH}....."
174 zconf_mount `hostname` $MOUNTPATH || return 96
178 local mountopt="-o remount,$1"
180 echo "remount '$1' lustre on ${MOUNTPATH}....."
181 zconf_mount `hostname` $MOUNTPATH "$mountopt" || return 96
186 echo "umount lustre on ${MOUNTPATH}....."
187 zconf_umount `hostname` $MOUNTPATH || return 97
190 manual_umount_client(){
193 echo "manual umount lustre on ${MOUNT}...."
194 do_facet client "umount -d ${FORCE} $MOUNT"
200 start_mds || error "MDT start failed"
201 start_ost || error "OST start failed"
202 mount_client $MOUNT || error "client start failed"
203 client_up || error "client_up failed"
207 if ! combined_mgs_mds ; then
216 unload_modules_conf () {
217 if combined_mgs_mds || ! local_mode; then
218 unload_modules || return 1
223 stop_ost || return 202
224 stop_mds || return 201
225 unload_modules_conf || return 203
229 umount_client $MOUNT || return 200
230 cleanup_nocli || return $?
234 do_facet client "cp /etc/passwd $DIR/a" || return 71
235 do_facet client "rm $DIR/a" || return 72
236 # make sure lustre is actually mounted (touch will block,
237 # but grep won't, so do it after)
238 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
239 echo "setup single mount lustre success"
243 do_facet client "touch $DIR/a" || return 71
244 do_facet client "rm $DIR/a" || return 72
245 do_facet client "touch $DIR2/a" || return 73
246 do_facet client "rm $DIR2/a" || return 74
247 echo "setup double mount lustre success"
252 if [ "$ONLY" == "setup" ]; then
257 if [ "$ONLY" == "cleanup" ]; then
264 #create single point mountpoint
270 check_mount || return 41
273 run_test 0 "single mount setup"
276 start_mds || error "MDT start failed"
278 echo "start ost second time..."
279 start_ost && error "2nd OST start should fail"
280 mount_client $MOUNT || error "client start failed"
281 check_mount || return 42
284 run_test 1 "start up ost twice (should return errors)"
288 echo "start mds second time.."
289 start_mds && error "2nd MDT start should fail"
292 check_mount || return 43
295 run_test 2 "start up mds twice (should return err)"
299 #mount.lustre returns an error if already in mtab
300 mount_client $MOUNT && error "2nd client mount should fail"
301 check_mount || return 44
304 run_test 3 "mount client twice (should return err)"
308 touch $DIR/$tfile || return 85
312 # ok for ost to fail shutdown
313 if [ 202 -ne $eno ]; then
318 run_test 4 "force cleanup ost, then cleanup"
320 test_5a() { # was test_5
322 touch $DIR/$tfile || return 1
323 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
325 stop_mds -f || return 2
327 # cleanup may return an error from the failed
328 # disconnects; for now I'll consider this successful
329 # if all the modules have unloaded.
333 echo "killing umount"
334 kill -TERM $UMOUNT_PID
335 echo "waiting for umount to finish"
337 if grep " $MOUNT " /proc/mounts; then
338 echo "test 5: /proc/mounts after failed umount"
342 echo "killing umount"
343 kill -TERM $UMOUNT_PID
344 echo "waiting for umount to finish"
346 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
350 # stop_mds is a no-op here, and should not fail
351 cleanup_nocli || return $?
352 # df may have lingering entry
354 # mtab may have lingering entry
358 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
360 grep -q $MOUNT" " /etc/mtab || break
361 echo "Waiting /etc/mtab updated ... "
362 WAIT=$(( WAIT + sleep))
364 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
365 echo "/etc/mtab updated in $WAIT secs"
367 run_test 5a "force cleanup mds, then cleanup"
375 grep " $MOUNT " /etc/mtab && \
376 error false "unexpected entry in mtab before mount" && return 10
380 if ! combined_mgs_mds ; then
381 trap cleanup_5b EXIT ERR
386 [ -d $MOUNT ] || mkdir -p $MOUNT
387 mount_client $MOUNT && rc=1
388 grep " $MOUNT " /etc/mtab && \
389 error "$MOUNT entry in mtab after failed mount" && rc=11
391 # stop_mds is a no-op here, and should not fail
392 cleanup_nocli || rc=$?
393 if ! combined_mgs_mds ; then
398 run_test 5b "Try to start a client with no MGS (should return errs)"
401 grep " $MOUNT " /etc/mtab && \
402 error false "unexpected entry in mtab before mount" && return 10
407 [ -d $MOUNT ] || mkdir -p $MOUNT
408 local oldfs="${FSNAME}"
409 FSNAME="wrong.${FSNAME}"
410 mount_client $MOUNT || :
412 grep " $MOUNT " /etc/mtab && \
413 error "$MOUNT entry in mtab after failed mount" && rc=11
415 cleanup_nocli || rc=$?
418 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
421 grep " $MOUNT " /etc/mtab && \
422 error false "unexpected entry in mtab before mount" && return 10
428 mount_client $MOUNT || rc=1
430 grep " $MOUNT " /etc/mtab && \
431 error "$MOUNT entry in mtab after unmount" && rc=11
434 run_test 5d "mount with ost down"
437 grep " $MOUNT " /etc/mtab && \
438 error false "unexpected entry in mtab before mount" && return 10
444 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
445 do_facet client "lctl set_param fail_loc=0x80000506"
446 mount_client $MOUNT || echo "mount failed (not fatal)"
448 grep " $MOUNT " /etc/mtab && \
449 error "$MOUNT entry in mtab after unmount" && rc=11
452 run_test 5e "delayed connect, don't crash (bug 10268)"
455 if combined_mgs_mds ; then
456 skip "combined mgs and mds"
460 grep " $MOUNT " /etc/mtab && \
461 error false "unexpected entry in mtab before mount" && return 10
465 [ -d $MOUNT ] || mkdir -p $MOUNT
466 mount_client $MOUNT &
468 echo client_mount pid is $pid
472 if ! ps -f -p $pid >/dev/null; then
475 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
476 error "mount returns $rc, expected to hang"
485 # mount should succeed after start mds
488 [ $rc -eq 0 ] || error "mount returned $rc"
489 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
493 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
498 mount_client ${MOUNT} || return 87
499 touch $DIR/a || return 86
502 run_test 6 "manual umount, then mount again"
507 cleanup_nocli || return $?
509 run_test 7 "manual umount, then cleanup"
514 check_mount2 || return 45
515 umount_client $MOUNT2
518 run_test 8 "double mount setup"
523 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
524 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
526 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
527 if [ "$CHECK_PTLDEBUG" ] && { \
528 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
529 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
530 echo "lnet.debug success"
532 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
535 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
536 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
537 echo "lnet.subsystem_debug success"
539 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
542 stop_ost || return $?
544 run_test 9 "test ptldebug and subsystem for mkfs"
552 do_facet $facet "test -b $dev" || rc=1
553 if [[ "$size" ]]; then
554 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
555 awk '($3 == "in") { print $1 }')
556 [[ $in = "1+0" ]] || rc=1
562 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
563 # But with new MDS stack we don't care about the mode of local objects
564 # anymore, so this test is removed. See bug 22944 for more details.
569 check_mount || return 41
572 echo "Remove mds config log"
573 if ! combined_mgs_mds ; then
577 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MGSDEV || return \$?" || return $?
579 if ! combined_mgs_mds ; then
584 start_mds && return 42
587 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
590 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
592 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
597 # check if current MDSSIZE is large enough
598 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
599 log "use MDSSIZE=$MDSSIZE"
601 # check if the global config has a large enough MDSSIZE
602 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
603 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
604 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
606 # check if the block device is large enough
607 [ -z "$OK" ] && $(is_blkdev $SINGLEMDS $MDSDEV $MIN) && OK=1 &&
608 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
610 # check if a loopback device has enough space for fs metadata (5%)
612 if [ -z "$OK" ]; then
613 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
614 awk '($1 != "Filesystem") {print $4}')
615 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
616 OK=1 && myMDSSIZE=$MIN && \
617 log "use file $MDSDEV with MIN=$MIN"
620 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
623 echo "mount mds with large journal..."
624 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
626 local opts="--mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
628 if combined_mgs_mds ; then
629 MDS_MKFS_OPTS="--mgs $opts"
631 MDS_MKFS_OPTS="--mgsnode=$MGSNID $opts"
635 echo "mount lustre system..."
637 check_mount || return 41
639 echo "check journal size..."
640 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
641 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
642 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
644 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
649 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
652 run_test 18 "check mkfs creates large journals"
655 start_mds || return 1
656 stop_mds -f || return 2
658 run_test 19a "start/stop MDS without OSTs"
661 start_ost || return 1
662 stop_ost -f || return 2
664 run_test 19b "start/stop OSTs without MDS"
667 # first format the ost/mdt
671 check_mount || return 43
673 remount_client ro $MOUNT || return 44
674 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
675 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
676 remount_client rw $MOUNT || return 47
678 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
679 MCNT=`grep -c $MOUNT /etc/mtab`
680 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
685 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
690 wait_osc_import_state mds ost FULL
694 run_test 21a "start mds before ost, stop ost first"
699 wait_osc_import_state mds ost FULL
703 run_test 21b "start ost before mds, stop mds first"
709 wait_osc_import_state mds ost2 FULL
713 #writeconf to remove all ost2 traces for subsequent tests
716 run_test 21c "start mds between two osts, stop mds last"
719 if combined_mgs_mds ; then
720 skip "need separate mgs device" && return 0
730 wait_osc_import_state mds ost2 FULL
736 #writeconf to remove all ost2 traces for subsequent tests
739 run_test 21d "start mgs then ost and then mds"
744 echo Client mount with ost in logs, but none running
746 # wait until mds connected to ost and open client connection
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 # if gss enabled, wait full time to let connection from
760 # mds to ost be established, due to the mismatch between
761 # initial connect timeout and gss context negotiation timeout.
762 # This perhaps could be remove after AT landed.
763 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
764 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
767 check_mount || return 41
772 run_test 22 "start a client before osts (should return errs)"
774 test_23a() { # was test_23
778 # force down client so that recovering mds waits for reconnect
779 local running=$(grep -c $MOUNT /proc/mounts) || true
780 if [ $running -ne 0 ]; then
781 echo "Stopping client $MOUNT (opts: -f)"
785 # enter recovery on mds
787 # try to start a new client
788 mount_client $MOUNT &
790 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
791 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
792 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
794 ps --ppid $MOUNT_LUSTRE_PID
795 echo "waiting for mount to finish"
797 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
798 # SIGTERM works but it does not spread to offspring processses
799 kill -s TERM $MOUNT_PID
800 kill -s TERM $MOUNT_LUSTRE_PID
801 # we can not wait $MOUNT_PID because it is not a child of this shell
807 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
809 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
810 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
813 [ -z "$PID1" -a -z "$PID2" ] && break
814 echo "waiting for mount to finish ... "
815 WAIT=$(( WAIT + sleep))
817 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
818 error "MOUNT_PID $MOUNT_PID and "\
819 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
825 run_test 23a "interrupt client during recovery mount delay"
830 test_23b() { # was test_23
833 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
834 lctl set_param fail_loc=0x80000313
838 run_test 23b "Simulate -EINTR during mount"
840 fs2mds_HOST=$mds_HOST
841 fs2ost_HOST=$ost_HOST
845 echo "umount $MOUNT2 ..."
846 umount $MOUNT2 || true
847 echo "stopping fs2mds ..."
848 stop fs2mds -f || true
849 echo "stopping fs2ost ..."
850 stop fs2ost -f || true
854 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
856 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
857 is_blkdev $SINGLEMDS $MDSDEV && \
858 skip_env "mixed loopback and real device not working" && return
861 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
863 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
864 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
866 # test 8-char fsname as well
867 local FSNAME2=test1234
868 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
870 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
873 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
874 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
876 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
878 check_mount || return 2
879 # files written on 1 should not show up on 2
880 cp /etc/passwd $DIR/$tfile
882 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
885 cp /etc/passwd $MOUNT2/b || return 3
886 rm $MOUNT2/b || return 4
887 # 2 is actually mounted
888 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
890 facet_failover fs2mds
891 facet_failover fs2ost
894 # the MDS must remain up until last MDT
896 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
897 [ -z "$MDS" ] && error "No MDT" && return 8
899 cleanup_nocli || return 6
901 run_test 24a "Multiple MDTs on a single node"
904 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
906 if [ -z "$fs2mds_DEV" ]; then
907 local dev=${SINGLEMDS}_dev
909 is_blkdev $SINGLEMDS $MDSDEV && \
910 skip_env "mixed loopback and real device not working" && return
913 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
915 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
917 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
920 run_test 24b "Multiple MGSs on a single node (should return err)"
924 check_mount || return 2
925 local MODULES=$($LCTL modules | awk '{ print $2 }')
926 rmmod $MODULES 2>/dev/null || true
929 run_test 25 "Verify modules are referenced"
933 # we need modules before mount for sysctl, so make sure...
934 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
935 #define OBD_FAIL_MDS_FS_SETUP 0x135
936 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
937 start_mds && echo MDS started && return 1
938 lctl get_param -n devices
939 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
940 [ $DEVS -gt 0 ] && return 2
941 unload_modules_conf || return $?
943 run_test 26 "MDT startup failure cleans LOV (should return errs)"
949 local ORIG=$(do_facet $myfacet "$TEST")
950 if [ $# -gt 3 ]; then
956 echo "Setting $PARAM from $ORIG to $FINAL"
957 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
959 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
963 start_ost || return 1
964 start_mds || return 2
965 echo "Requeue thread should have started: "
966 ps -e | grep ll_cfg_requeue
967 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
970 run_test 27a "Reacquire MGS lock if OST started first"
975 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
977 facet_failover $SINGLEMDS
978 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
979 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
983 run_test 27b "Reacquire MGS lock after failover"
987 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
988 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
991 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
992 FINAL=$(($FINAL + 1))
993 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
994 umount_client $MOUNT || return 200
997 if [ $RESULT -ne $FINAL ]; then
998 echo "New config not seen: wanted $FINAL got $RESULT"
1001 echo "New config success: got $RESULT"
1003 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
1006 run_test 28 "permanent parameter setting"
1009 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1010 setup > /dev/null 2>&1
1014 local PARAM="$FSNAME-OST0001.osc.active"
1015 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1016 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1018 ACTV=$(lctl get_param -n $PROC_ACT)
1020 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1021 # also check ost_server_uuid status
1022 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1023 if [ -z "$RESULT" ]; then
1024 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1027 echo "Live client success: got $RESULT"
1031 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0001)
1032 mdtosc=${mdtosc/-MDT*/-MDT\*}
1033 local MPROC="osc.$mdtosc.active"
1038 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
1039 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1040 if [ $RESULT -eq $DEAC ]; then
1041 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
1045 if [ $WAIT -eq $MAX ]; then
1046 echo "MDT not deactivated: wanted $DEAC got $RESULT"
1049 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
1052 # quotacheck should not fail immediately after deactivate
1053 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1055 # test new client starts deactivated
1056 umount_client $MOUNT || return 200
1058 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1059 if [ -z "$RESULT" ]; then
1060 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1063 echo "New client success: got $RESULT"
1066 # quotacheck should not fail after umount/mount operation
1067 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1069 # make sure it reactivates
1070 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1072 umount_client $MOUNT
1075 #writeconf to remove all ost2 traces for subsequent tests
1078 run_test 29 "permanently remove an OST"
1083 echo Big config llog
1084 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1086 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1087 for i in ${LIST[@]}; do
1088 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1090 # make sure client restart still works
1091 umount_client $MOUNT
1092 mount_client $MOUNT || return 4
1093 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1096 echo Erase parameter setting
1097 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1098 umount_client $MOUNT
1099 mount_client $MOUNT || return 6
1101 echo "deleted (default) value=$FINAL, orig=$ORIG"
1102 # assumes this parameter started at the default value
1103 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1107 run_test 30a "Big config llog and conf_param deletion"
1112 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1113 # numerical part of it. Hopefully that's not already a failover address for
1115 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1116 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1117 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1118 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1119 echo "Using fake nid $NEW"
1121 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1122 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
1123 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1125 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1126 echo "should have 2 failover nids: $NIDCOUNT"
1127 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1128 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1129 umount_client $MOUNT
1130 mount_client $MOUNT || return 3
1132 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1134 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1135 echo "only 1 final nid should remain: $NIDCOUNT"
1136 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1140 run_test 30b "Remove failover nids"
1142 test_31() { # bug 10734
1143 # ipaddr must not exist
1144 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1147 run_test 31 "Connect to non-existent node (shouldn't crash)"
1149 # Use these start32/stop32 fn instead of t-f start/stop fn,
1150 # for local devices, to skip global facet vars init
1154 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1155 umount -d $@ ${MOUNT%/*}/${facet}
1164 mkdir -p ${MOUNT%/*}/${facet}
1166 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1167 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1169 if [ $RC -ne 0 ]; then
1170 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1171 echo "Start of ${device} of local ${facet} failed ${RC}"
1177 cleanup_nocli32 () {
1185 echo "Cleanup test_32 umount $MOUNT ..."
1186 umount -f $MOUNT || true
1187 echo "Cleanup local mds ost1 ..."
1189 combined_mgs_mds || start_mgs
1194 client_only && skip "client only testing" && return 0
1195 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1196 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1198 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1199 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1200 local tmpdir=$TMP/conf32a
1202 tar xjvf $DISK1_8 -C $tmpdir || \
1203 { skip_env "Cannot untar $DISK1_8" && return 0; }
1206 $LCTL set_param debug=$PTLDEBUG
1208 $TUNEFS $tmpdir/mds || error "tunefs failed"
1210 combined_mgs_mds || stop mgs
1212 # nids are wrong, so client wont work, but server should start
1213 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1214 trap cleanup_32 EXIT INT || return 3
1216 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1218 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1220 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1221 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1222 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1224 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1226 local NID=$($LCTL list_nids | head -1)
1228 echo "OSC changes should succeed:"
1229 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1230 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1233 echo "MDC changes should succeed:"
1234 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1235 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1238 echo "LOV changes should succeed:"
1239 $LCTL pool_new lustre.interop || return 11
1240 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1245 # mount a second time to make sure we didnt leave upgrade flag on
1247 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1249 combined_mgs_mds || stop mgs
1251 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1252 trap cleanup_32 EXIT INT || return 12
1256 rm -rf $tmpdir || true # true is only for TMP on NFS
1258 run_test 32a "Upgrade from 1.8 (not live)"
1261 client_only && skip "client only testing" && return 0
1262 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1263 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1265 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1266 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1267 local tmpdir=$TMP/conf32b
1269 tar xjvf $DISK1_8 -C $tmpdir || \
1270 { skip_env "Cannot untar $DISK1_8" && return ; }
1273 $LCTL set_param debug="config"
1274 local NEWNAME=lustre
1276 # writeconf will cause servers to register with their current nids
1277 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1278 combined_mgs_mds || stop mgs
1280 start32 mds1 $tmpdir/mds "-o loop" && \
1281 trap cleanup_32 EXIT INT || return 3
1283 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1285 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1287 $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 ||\
1288 error "tunefs failed"
1289 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1290 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1292 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1294 local NID=$($LCTL list_nids | head -1)
1296 echo "OSC changes should succeed:"
1297 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1298 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1301 echo "MDC changes should succeed:"
1302 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1303 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1306 echo "LOV changes should succeed:"
1307 $LCTL pool_new ${NEWNAME}.interop || return 11
1308 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1311 # MDT and OST should have registered with new nids, so we should have
1312 # a fully-functioning client
1313 echo "Check client and old fs contents"
1315 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1316 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1317 mount -t lustre $device $MOUNT || return 1
1319 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1320 local new=$((old + 5))
1321 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1322 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1324 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1329 rm -rf $tmpdir || true # true is only for TMP on NFS
1331 run_test 32b "Upgrade from 1.8 with writeconf"
1333 test_33a() { # bug 12333, was test_33
1335 local FSNAME2=test-123
1336 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1338 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1340 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1341 local dev=${SINGLEMDS}_dev
1342 local MDSDEV=${!dev}
1343 is_blkdev $SINGLEMDS $MDSDEV && \
1344 skip_env "mixed loopback and real device not working" && return
1347 combined_mgs_mds || mkfs_opts="$mkfs_opts --nomgs"
1349 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1350 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1351 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1352 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1354 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1355 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1356 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1358 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1361 cp /etc/hosts $MOUNT2/ || rc=3
1362 $LFS getstripe $MOUNT2/hosts
1367 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1368 cleanup_nocli || rc=6
1371 run_test 33a "Mount ost with a large index number"
1373 test_33b() { # was test_34
1376 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1377 # Drop lock cancelation reply during umount
1378 #define OBD_FAIL_LDLM_CANCEL 0x304
1379 do_facet client lctl set_param fail_loc=0x80000304
1380 #lctl set_param debug=-1
1381 umount_client $MOUNT
1384 run_test 33b "Drop cancel during umount"
1388 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1389 manual_umount_client
1391 do_facet client killall -USR1 multiop
1392 if [ $rc -eq 0 ]; then
1393 error "umount not fail!"
1398 run_test 34a "umount with opened file should be fail"
1403 touch $DIR/$tfile || return 1
1404 stop_mds --force || return 2
1406 manual_umount_client --force
1408 if [ $rc -ne 0 ]; then
1409 error "mtab after failed umount - rc $rc"
1415 run_test 34b "force umount with failed mds should be normal"
1419 touch $DIR/$tfile || return 1
1420 stop_ost --force || return 2
1422 manual_umount_client --force
1424 if [ $rc -ne 0 ]; then
1425 error "mtab after failed umount - rc $rc"
1431 run_test 34c "force umount with failed ost should be normal"
1433 test_35a() { # bug 12459
1436 DBG_SAVE="`lctl get_param -n debug`"
1437 lctl set_param debug="ha"
1439 log "Set up a fake failnode for the MDS"
1441 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1442 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1444 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1447 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1450 log "Stopping the MDT:"
1451 stop_mds || return 5
1453 df $MOUNT > /dev/null 2>&1 &
1455 log "Restarting the MDT:"
1456 start_mds || return 6
1457 log "Wait for df ($DFPID) ... "
1460 lctl set_param debug="$DBG_SAVE"
1462 # retrieve from the log the first server that the client tried to
1463 # contact after the connection loss
1464 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1465 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1466 /import_select_connection.*$device-mdc.* using connection/ {
1468 if (\\\$NF ~ /$FAKENID/)
1474 }" $TMP/lustre-log-$TESTNAME.log`
1475 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1477 # remove nid settings
1480 run_test 35a "Reconnect to the last active server first"
1482 test_35b() { # bug 18674
1483 remote_mds || { skip "local MDS" && return 0; }
1487 $LCTL set_param debug="ha"
1489 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1492 log "Set up a fake failnode for the MDS"
1494 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | \
1495 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1496 do_facet $SINGLEMDS "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1499 local at_max_saved=0
1500 # adaptive timeouts may prevent seeing the issue
1501 if at_is_enabled; then
1502 at_max_saved=$(at_max_get mds)
1503 at_max_set 0 mds client
1506 mkdir -p $MOUNT/$tdir
1508 log "Injecting EBUSY on MDS"
1509 # Setting OBD_FAIL_MDS_RESEND=0x136
1510 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
1512 $LCTL set_param mdc.${FSNAME}*.stats=clear
1514 log "Creating a test file and stat it"
1515 touch $MOUNT/$tdir/$tfile
1516 stat $MOUNT/$tdir/$tfile
1518 log "Stop injecting EBUSY on MDS"
1519 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
1520 rm -f $MOUNT/$tdir/$tfile
1523 # restore adaptive timeout
1524 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1526 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1528 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
1530 # retrieve from the log if the client has ever tried to
1531 # contact the fake server after the loss of connection
1532 FAILCONN=`awk "BEGIN {ret = 0;}
1533 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1535 if (\\\$NF ~ /$FAKENID/) {
1540 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1542 [ "$FAILCONN" == "0" ] && \
1543 log "ERROR: The client reconnection has not been triggered" && \
1545 [ "$FAILCONN" == "2" ] && \
1546 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1550 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
1551 # Reconnects are supposed to be rate limited to one every 5s
1552 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
1553 log "ERROR: Too many reconnects $CONNCNT" && \
1557 # remove nid settings
1560 run_test 35b "Continue reconnection retries, if the active server is busy"
1563 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1565 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1566 { skip "remote OST" && return 0; }
1569 local FSNAME2=test1234
1570 local fs3ost_HOST=$ost_HOST
1571 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1573 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1575 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1576 is_blkdev $SINGLEMDS $MDSDEV && \
1577 skip_env "mixed loopback and real device not working" && return
1580 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1581 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1582 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1583 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1584 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1586 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1587 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1589 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1590 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1591 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1593 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1595 sleep 5 # until 11778 fixed
1597 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1599 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1600 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1601 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1602 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1603 DFTOTAL=`echo $STRING | cut -d, -f1`
1604 DFUSED=`echo $STRING | cut -d, -f2`
1605 DFAVAIL=`echo $STRING | cut -d, -f3`
1606 DFFREE=$(($DFTOTAL - $DFUSED))
1608 ALLOWANCE=$((64 * $OSTCOUNT))
1610 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1611 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1612 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1615 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1616 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1617 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1620 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1621 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1622 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1627 stop fs3ost -f || return 200
1628 stop fs2ost -f || return 201
1629 stop fs2mds -f || return 202
1630 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1631 unload_modules_conf || return 203
1634 run_test 36 "df report consistency on OSTs with different block size"
1637 local mntpt=$(facet_mntpt $SINGLEMDS)
1638 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
1639 local mdsdev_sym="$TMP/sym_mdt.img"
1641 echo "MDS : $mdsdev"
1642 echo "SYMLINK : $mdsdev_sym"
1643 do_facet $SINGLEMDS rm -f $mdsdev_sym
1645 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
1647 echo "mount symlink device - $mdsdev_sym"
1650 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $MDS_MOUNT_OPTS $mdsdev_sym $mntpt 2>&1 )
1653 echo mount_op=$mount_op
1655 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
1657 if $(echo $mount_op | grep -q "unable to set tunable"); then
1658 error "set tunables failed for symlink device"
1661 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
1665 run_test 37 "verify set tunables works for symlink device"
1667 test_38() { # bug 14222
1672 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1673 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1675 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1676 error "copying $SRC to $DIR/$tdir"
1678 umount_client $MOUNT
1680 log "rename lov_objid file on MDS"
1681 rm -f $TMP/lov_objid.orig
1683 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1684 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1685 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1687 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1688 # check create in mds_lov_connect
1692 [ $V ] && log "verifying $DIR/$tdir/$f"
1693 diff -q $f $DIR/$tdir/$f || ERROR=y
1695 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1696 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1697 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1699 # check it's updates in sync
1700 umount_client $MOUNT
1703 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1704 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1705 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1710 [ $V ] && log "verifying $DIR/$tdir/$f"
1711 diff -q $f $DIR/$tdir/$f || ERROR=y
1713 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1714 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1715 umount_client $MOUNT
1717 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1719 log "files compared the same"
1722 run_test 38 "MDS recreates missing lov_objid file from OST data"
1728 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1729 error "memory leak detected" || true
1731 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1733 test_40() { # bug 15759
1735 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1736 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
1740 run_test 40 "race during service thread startup"
1742 test_41a() { #bug 14134
1743 echo $MDS_MOUNT_OPTS | grep "loop" && skip " loop devices does not work with nosvc option" && return
1746 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1748 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1749 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1750 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1752 mount_client $MOUNT || return 1
1755 echo "blah blah" > $MOUNT/$tfile
1758 umount_client $MOUNT
1759 stop ost1 -f || return 201
1760 stop_mds -f || return 202
1761 stop_mds -f || return 203
1762 unload_modules_conf || return 204
1765 run_test 41a "mount mds with --nosvc and --nomgs"
1768 echo $MDS_MOUNT_OPTS | grep "loop" && skip " loop devices does not work with nosvc option" && return
1772 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1774 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1776 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1778 mount_client $MOUNT || return 1
1781 echo "blah blah" > $MOUNT/$tfile
1782 cat $MOUNT/$tfile || return 200
1784 umount_client $MOUNT
1785 stop_ost || return 201
1786 stop_mds -f || return 202
1787 stop_mds -f || return 203
1790 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
1792 test_42() { #bug 14693
1794 check_mount || return 2
1795 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1796 umount_client $MOUNT
1797 mount_client $MOUNT || return 1
1801 run_test 42 "invalid config param should not prevent client from mounting"
1804 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1806 chmod ugo+x $DIR || error "chmod 0 failed"
1808 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1809 "$FSNAME.mdt.root_squash" \
1812 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1813 "$FSNAME.mdt.nosquash_nids" \
1817 # create set of test files
1819 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1820 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1821 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1823 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1824 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1826 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1827 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1828 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1831 # check root_squash:
1832 # set root squash UID:GID to RUNAS_ID
1833 # root should be able to access only files owned by RUNAS_ID
1836 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1837 "$FSNAME.mdt.root_squash" \
1838 "$RUNAS_ID:$RUNAS_ID"
1840 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1841 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1842 error "$ST: root read permission is denied"
1843 echo "$ST: root read permission is granted - ok"
1846 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1847 error "$ST: root write permission is denied"
1848 echo "$ST: root write permission is granted - ok"
1850 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1851 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1852 error "$ST: root read permission is granted"
1853 echo "$ST: root read permission is denied - ok"
1856 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1857 error "$ST: root write permission is granted"
1858 echo "$ST: root write permission is denied - ok"
1860 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1861 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1862 error "$ST: root unlink permission is granted"
1863 echo "$ST: root unlink permission is denied - ok"
1865 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1866 error "$ST: root create permission is granted"
1867 echo "$ST: root create permission is denied - ok"
1870 # check nosquash_nids:
1871 # put client's NID into nosquash_nids list,
1872 # root should be able to access root file after that
1874 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1875 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1876 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1878 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1879 "$FSNAME-MDTall.mdt.nosquash_nids" \
1882 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1883 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1884 error "$ST: root read permission is denied"
1885 echo "$ST: root read permission is granted - ok"
1888 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1889 error "$ST: root write permission is denied"
1890 echo "$ST: root write permission is granted - ok"
1892 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1893 rm $DIR/$tdir-rootdir/tfile-1 || \
1894 error "$ST: root unlink permission is denied"
1895 echo "$ST: root unlink permission is granted - ok"
1896 touch $DIR/$tdir-rootdir/tfile-2 || \
1897 error "$ST: root create permission is denied"
1898 echo "$ST: root create permission is granted - ok"
1902 run_test 43 "check root_squash and nosquash_nids"
1904 umount_client $MOUNT
1909 check_mount || return 2
1910 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1912 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1913 for VAL in $UUIDS; do
1914 NID=$(echo $VAL | cut -d= -f1)
1915 CLUUID=$(echo $VAL | cut -d= -f2)
1916 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1918 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1922 run_test 44 "mounted client proc entry exists"
1926 check_mount || return 2
1931 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1932 do_facet client "lctl set_param fail_loc=0x50f"
1935 manual_umount_client --force || return 3
1936 do_facet client "lctl set_param fail_loc=0x0"
1938 mount_client $MOUNT || return 4
1942 run_test 45 "long unlink handling in ptlrpcd"
1949 umount_client $MOUNT2 || rc=$?
1950 umount_client $MOUNT || rc=$?
1951 while [ $count -gt 0 ]; do
1952 stop ost${count} -f || rc=$?
1956 cleanup_nocli || rc=$?
1957 #writeconf to remove all ost2 traces for subsequent tests
1963 echo "Testing with $OSTCOUNT OSTs"
1965 start_mds || return 1
1966 #first client should see only one ost
1967 start_ost || return 2
1968 wait_osc_import_state mds ost FULL
1970 mount_client $MOUNT || return 3
1971 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1974 for (( i=2; i<=$OSTCOUNT; i++ )); do
1975 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1978 # wait until osts in sync
1979 for (( i=2; i<=$OSTCOUNT; i++ )); do
1980 wait_osc_import_state mds ost$i FULL
1984 #second client see all ost's
1986 mount_client $MOUNT2 || return 8
1987 $LFS setstripe $MOUNT2 -c -1 || return 9
1988 $LFS getstripe $MOUNT2 || return 10
1990 echo "ok" > $MOUNT2/widestripe
1991 $LFS getstripe $MOUNT2/widestripe || return 11
1992 # fill acl buffer for avoid expand lsm to them
1993 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1994 setfacl -m $acl $MOUNT2/widestripe
1998 stat $MOUNT/widestripe || return 12
2000 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
2003 run_test 46a "handle ost additional - wide striped file"
2008 check_mount || return 2
2009 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2013 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2014 if echo $ns | grep "MDT[[:digit:]]*"; then
2017 lrs=$(echo $ns | sed 's/.*lru_size=//')
2018 lru_size[count]=$lrs
2023 facet_failover $SINGLEMDS
2024 client_up || return 3
2027 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2028 if echo $ns | grep "MDT[[:digit:]]*"; then
2031 lrs=$(echo $ns | sed 's/.*lru_size=//')
2032 if ! test "$lrs" -eq "${lru_size[count]}"; then
2033 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2034 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2042 run_test 47 "server restart does not make client loss lru_resize settings"
2047 # reformat after this test is needed - if test will failed
2048 # we will have unkillable file at FS
2052 test_48() { # bug 17636
2055 check_mount || return 2
2057 $LFS setstripe $MOUNT -c -1 || return 9
2058 $LFS getstripe $MOUNT || return 10
2060 echo "ok" > $MOUNT/widestripe
2061 $LFS getstripe $MOUNT/widestripe || return 11
2063 trap cleanup_48 EXIT ERR
2065 # fill acl buffer for avoid expand lsm to them
2066 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2067 setfacl -m $acl $MOUNT/widestripe
2070 stat $MOUNT/widestripe || return 12
2075 run_test 48 "too many acls on file"
2077 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2078 test_49() { # bug 17710
2079 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
2080 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
2081 local LOCAL_TIMEOUT=20
2084 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
2088 check_mount || return 1
2090 echo "check ldlm_timout..."
2091 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2092 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2093 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2095 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2096 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2099 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2100 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2103 umount_client $MOUNT
2104 stop_ost || return 2
2105 stop_mds || return 3
2107 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"
2111 check_mount || return 7
2113 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2114 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2115 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2117 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2118 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2121 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2122 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2125 cleanup || return $?
2127 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
2128 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
2130 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
2133 # Test both statfs and lfs df and fail if either one fails
2134 multiop_bg_pause $1 f_
2137 killall -USR1 multiop
2138 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2139 wait $PID || { RC1=$?; log "multiop return error "; }
2146 if [ $RC2 -eq 0 ]; then
2148 log "lazystatfs df failed"
2152 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2158 lctl set_param llite.$FSNAME-*.lazystatfs=1
2161 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2163 cleanup || return $?
2165 run_test 50a "lazystatfs all servers available =========================="
2169 lctl set_param llite.$FSNAME-*.lazystatfs=1
2172 # Wait for client to detect down OST
2173 stop_ost || error "Unable to stop OST1"
2174 wait_osc_import_state mds ost DISCONN
2176 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2178 umount_client $MOUNT || error "Unable to unmount client"
2179 stop_mds || error "Unable to stop MDS"
2181 run_test 50b "lazystatfs all servers down =========================="
2184 start_mds || error "Unable to start MDS"
2185 start_ost || error "Unable to start OST1"
2186 start_ost2 || error "Unable to start OST2"
2187 mount_client $MOUNT || error "Unable to mount client"
2188 lctl set_param llite.$FSNAME-*.lazystatfs=1
2191 # Wait for client to detect down OST
2192 stop_ost || error "Unable to stop OST1"
2193 wait_osc_import_state mds ost DISCONN
2194 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2196 umount_client $MOUNT || error "Unable to unmount client"
2197 stop_ost2 || error "Unable to stop OST2"
2198 stop_mds || error "Unable to stop MDS"
2199 #writeconf to remove all ost2 traces for subsequent tests
2202 run_test 50c "lazystatfs one server down =========================="
2205 start_mds || error "Unable to start MDS"
2206 start_ost || error "Unable to start OST1"
2207 start_ost2 || error "Unable to start OST2"
2208 mount_client $MOUNT || error "Unable to mount client"
2209 lctl set_param llite.$FSNAME-*.lazystatfs=1
2212 # Issue the statfs during the window where the client still
2213 # belives the OST to be available but it is in fact down.
2214 # No failure just a statfs which hangs for a timeout interval.
2215 stop_ost || error "Unable to stop OST1"
2216 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2218 umount_client $MOUNT || error "Unable to unmount client"
2219 stop_ost2 || error "Unable to stop OST2"
2220 stop_mds || error "Unable to stop MDS"
2221 #writeconf to remove all ost2 traces for subsequent tests
2224 run_test 50d "lazystatfs client/server conn race =========================="
2231 start_mds || return 1
2232 #first client should see only one ost
2233 start_ost || return 2
2234 wait_osc_import_state mds ost FULL
2236 # Wait for client to detect down OST
2237 stop_ost || error "Unable to stop OST1"
2238 wait_osc_import_state mds ost DISCONN
2240 mount_client $MOUNT || error "Unable to mount client"
2241 lctl set_param llite.$FSNAME-*.lazystatfs=0
2243 multiop_bg_pause $MOUNT _f
2247 if [ $RC1 -ne 0 ]; then
2248 log "multiop failed $RC1"
2251 sleep $(( $TIMEOUT+1 ))
2253 [ $? -ne 0 ] && error "process isn't sleep"
2254 start_ost || error "Unable to start OST1"
2255 wait $pid || error "statfs failed"
2258 umount_client $MOUNT || error "Unable to unmount client"
2259 stop_ost || error "Unable to stop OST1"
2260 stop_mds || error "Unable to stop MDS"
2262 run_test 50e "normal statfs all servers down =========================="
2267 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2269 start_mds || error "Unable to start mds"
2270 #first client should see only one ost
2271 start_ost || error "Unable to start OST1"
2272 wait_osc_import_state mds ost FULL
2274 start_ost2 || error "Unable to start OST2"
2275 wait_osc_import_state mds ost2 FULL
2277 # Wait for client to detect down OST
2278 stop_ost2 || error "Unable to stop OST2"
2280 wait_osc_import_state mds ost2 DISCONN
2281 mount_client $MOUNT || error "Unable to mount client"
2282 lctl set_param llite.$FSNAME-*.lazystatfs=0
2284 multiop_bg_pause $MOUNT _f
2288 if [ $RC1 -ne 0 ]; then
2289 log "lazystatfs multiop failed $RC1"
2292 sleep $(( $TIMEOUT+1 ))
2294 [ $? -ne 0 ] && error "process isn't sleep"
2295 start_ost2 || error "Unable to start OST2"
2296 wait $pid || error "statfs failed"
2297 stop_ost2 || error "Unable to stop OST2"
2300 umount_client $MOUNT || error "Unable to unmount client"
2301 stop_ost || error "Unable to stop OST1"
2302 stop_mds || error "Unable to stop MDS"
2303 #writeconf to remove all ost2 traces for subsequent tests
2306 run_test 50f "normal statfs one server in down =========================="
2309 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2311 start_ost2 || error "Unable to start OST2"
2312 wait_osc_import_state mds ost2 FULL
2313 wait_osc_import_state client ost2 FULL
2315 local PARAM="${FSNAME}-OST0001.osc.active"
2317 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2318 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2320 umount_client $MOUNT || error "Unable to unmount client"
2321 mount_client $MOUNT || error "Unable to mount client"
2322 # This df should not cause a panic
2325 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2327 umount_client $MOUNT || error "Unable to unmount client"
2328 stop_ost2 || error "Unable to stop OST2"
2329 stop_ost || error "Unable to stop OST1"
2330 stop_mds || error "Unable to stop MDS"
2331 #writeconf to remove all ost2 traces for subsequent tests
2334 run_test 50g "deactivated OST should not cause panic====================="
2337 local LOCAL_TIMEOUT=20
2341 check_mount || return 1
2344 $LFS setstripe -c -1 $MOUNT/d1
2345 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2346 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2347 touch $MOUNT/d1/f1 &
2350 start_ost2 || return 2
2352 stop_ost2 || return 3
2354 #writeconf to remove all ost2 traces for subsequent tests
2357 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2366 do_node $node mkdir -p $dest
2367 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2369 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2370 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2371 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2373 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2374 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2384 local backup2=${TMP}/backup2
2386 do_node $node mkdir -p $backup2
2387 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2389 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2390 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2391 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2393 do_node $node "diff -rq $backup $backup2"
2394 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2396 local xattrs2=${TMP}/xattrs2
2397 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2398 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2400 do_node $node "diff $xattrs $xattrs2"
2401 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2403 do_node $node "rm -rf $backup2 $xattrs2"
2404 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2409 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2411 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2413 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2416 local ost1mnt=${MOUNT%/*}/ost1
2417 local ost1node=$(facet_active_host ost1)
2418 local ost1tmp=$TMP/conf52
2421 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2422 touch $TMP/modified_first
2423 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2424 local mtime=$(stat -c %Y $TMP/modified_first)
2425 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2427 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2430 $LFS setstripe $DIR/$tdir -c -1 -s 1M
2431 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2433 for (( i=0; i < nrfiles; i++ )); do
2434 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2435 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2441 echo backup files to $TMP/files
2442 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2443 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2444 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2446 umount_client $MOUNT
2447 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2449 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2451 echo mount ost1 as ldiskfs
2452 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2453 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2456 echo backup objects to $ost1tmp/objects
2457 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2458 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2459 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2460 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2462 # move objects to lost+found
2463 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2464 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2467 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2468 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2470 # compare restored objects against saved ones
2471 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2472 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2474 do_node $ost1node "umount $ost1_dev"
2475 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2478 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2480 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2483 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2484 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2486 rm -rf $TMP/files $TMP/file_xattrs
2487 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2488 do_node $ost1node "rm -rf $ost1tmp"
2489 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2492 run_test 52 "check recovering objects from lost+found"
2494 # Checks threads_min/max/started for some service
2496 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2497 # parameter pattern prefix like 'ost.*.ost'.
2509 local msg="Insane $modname thread counts"
2513 check_mount || return 41
2515 # We need to expand $parampat, but it may match multiple parameters, so
2516 # we'll pick the first one
2517 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2518 error "Couldn't expand ${parampat}.threads_min parameter name"
2522 # Remove the .threads_min part
2523 paramp=${paramp%.threads_min}
2525 # Check for sanity in defaults
2526 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2527 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2528 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2529 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2530 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
2532 # Check that we can change min/max
2533 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + 1))"
2534 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 1))"
2535 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2536 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2537 lassert 25 "$msg" '(($tmin2 == ($tmin + 1) && $tmax2 == ($tmax -1)))' || return $?
2539 # Check that we can set min/max to the same value
2540 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2541 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2542 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2543 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2544 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2546 # Check that we can't set max < min
2547 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2548 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2549 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2550 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
2552 # We need to ensure that we get the module options desired; to do this
2553 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2554 LOAD_MODULES_REMOTE=true
2557 setmodopts -a $modname "$opts" oldvalue
2561 check_mount || return 41
2563 # Restore previous setting of MODOPTS_*
2564 setmodopts $modname "$oldvalue"
2566 # Check that $opts took
2567 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2568 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2569 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2570 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2573 # Workaround a YALA bug where YALA expects that modules will remain
2574 # loaded on the servers
2575 LOAD_MODULES_REMOTE=false
2582 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2584 run_test 53a "check OSS thread count params"
2587 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2589 run_test 53b "check MDT thread count params"
2594 local partial_arg=""
2595 local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
2597 # Run in partial (fast) mode if the size
2598 # of a partition > 10 GB
2599 [ $size -gt 10 ] && partial_arg="-p"
2601 llverfs $partial_arg $dir
2605 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
2606 [ $? -eq 0 ] || error "llverdev failed!"
2609 run_test 54a "llverdev"
2614 [ $? -eq 0 ] || error "llverfs failed!"
2617 run_test 54b "llverfs"
2621 local max_ost_index=$1
2622 echo -n $(((max_ost_index + 1) * 8))
2626 local mdsdev=$(mdsdevname 1)
2627 local ostdev=$(ostdevname 1)
2628 local saved_opts=$OST_MKFS_OPTS
2630 for i in 0 1023 2048
2632 OST_MKFS_OPTS="$saved_opts --index $i"
2640 echo checking size of lov_objid for ost index $i
2641 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2642 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2643 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2645 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2650 OST_MKFS_OPTS=$saved_opts
2653 run_test 55 "check lov_objid size"
2656 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2657 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2658 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2662 start_ost2 || error "Unable to start second ost"
2663 mount_client $MOUNT || error "Unable to mount client"
2666 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
2670 run_test 56 "check big indexes"
2672 test_57a() { # bug 22656
2673 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2675 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2677 start_ost && error "OST registration from failnode should fail"
2680 run_test 57a "initial registration from failnode should fail (should return errs)"
2683 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2685 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
2687 start_ost || error "OST registration from servicenode should not fail"
2690 run_test 57b "initial registration from servicenode should not fail"
2693 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2696 test_58() { # bug 22658
2697 [ "$FSTYPE" != "ldiskfs" ] && skip "not supported for $FSTYPE" && return
2700 createmany -o $DIR/$tdir/$tfile-%d 100
2701 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
2702 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
2703 do_facet mds "lctl set_param fail_loc=0x601"
2704 unlinkmany $DIR/$tdir/$tfile-%d 100
2706 local MNTDIR=$(facet_mntpt mds)
2707 # remove all files from the OBJECTS dir
2708 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
2709 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
2710 do_facet mds "umount $MNTDIR"
2711 # restart MDS with missing llog files
2713 do_facet mds "lctl set_param fail_loc=0"
2716 run_test 58 "missing llog files must not prevent MDT from mounting"
2719 start_mgsmds >> /dev/null
2720 local C1=$(count_osts)
2721 if [ $C1 -eq 0 ]; then
2722 start_ost >> /dev/null
2726 echo "original ost count: $C1 (expect > 0)"
2727 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2728 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2729 local C2=$(count_osts)
2730 echo "after mdt writeconf count: $C2 (expect 0)"
2731 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2732 echo "OST start without writeconf should fail:"
2733 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2734 echo "OST start with writeconf should succeed:"
2735 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2736 local C3=$(count_osts)
2737 echo "after ost writeconf count: $C3 (expect 1)"
2738 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2739 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2740 local C4=$(count_osts)
2741 echo "after ost2 writeconf count: $C4 (expect 2)"
2742 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2743 stop_ost2 >> /dev/null
2744 cleanup_nocli >> /dev/null
2745 #writeconf to remove all ost2 traces for subsequent tests
2748 run_test 59 "writeconf mount option"
2750 test_60() { # LU-471
2751 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' --reformat $(mdsdevname 1)
2753 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
2755 [ $rc -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
2757 # MDT default has dirdata feature
2758 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
2759 # we disable uninit_bg feature
2760 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
2761 # we set stride extended options
2762 echo $dump | grep stride > /dev/null || error "stride is not set"
2765 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
2767 if ! combined_mgs_mds ; then
2773 # restore the ${facet}_MKFS_OPTS variables
2774 for facet in MGS MDS OST; do
2775 opts=SAVED_${facet}_MKFS_OPTS
2776 if [[ -n ${!opts} ]]; then
2777 eval ${facet}_MKFS_OPTS=\"${!opts}\"
2781 complete $(basename $0) $SECONDS