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 if [[ ${!opts} != *mkfsoptions* ]]; then
58 eval ${facet}_MKFS_OPTS=\"${!opts} --mkfsoptions='\\\"-E lazy_itable_init\\\"'\"
60 val=${!opts//--mkfsoptions=\\\"/--mkfsoptions=\\\"-E lazy_itable_init }
61 eval ${facet}_MKFS_OPTS='${val}'
69 require_dsh_mds || exit 0
70 require_dsh_ost || exit 0
72 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
87 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
88 do_facet ${facet} "$TUNEFS --quiet --writeconf $dev" ||
89 { echo "tunefs failed, reformatting instead" && reformat_and_config && return 1; }
96 # if writeconf fails anywhere, we reformat everything
97 writeconf1 mds `mdsdevname 1` || return 0
98 writeconf1 ost1 `ostdevname 1` || return 0
99 writeconf1 ost2 `ostdevname 2` || return 0
103 # The MGS must be started before the OSTs for a new fs, so start
104 # and stop to generate the startup logs.
107 wait_osc_import_state mds ost FULL
112 reformat_and_config() {
114 if ! combined_mgs_mds ; then
122 start mgs $MGSDEV $MGS_MOUNT_OPTS
126 local facet=$SINGLEMDS
127 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
128 local num=$(echo $facet | tr -d "mds")
129 local dev=$(mdsdevname $num)
130 echo "start mds service on `facet_active_host $facet`"
131 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
135 if ! combined_mgs_mds ; then
142 echo "stop mds service on `facet_active_host $SINGLEMDS`"
143 # These tests all use non-failover stop
144 stop $SINGLEMDS -f || return 97
148 echo "stop mgs service on `facet_active_host mgs`"
149 # These tests all use non-failover stop
150 stop mgs -f || return 97
154 echo "start ost1 service on `facet_active_host ost1`"
155 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
159 echo "stop ost1 service on `facet_active_host ost1`"
160 # These tests all use non-failover stop
161 stop ost1 -f || return 98
165 echo "start ost2 service on `facet_active_host ost2`"
166 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
170 echo "stop ost2 service on `facet_active_host ost2`"
171 # These tests all use non-failover stop
172 stop ost2 -f || return 93
177 echo "mount $FSNAME on ${MOUNTPATH}....."
178 zconf_mount `hostname` $MOUNTPATH || return 96
182 local mountopt="-o remount,$1"
184 echo "remount '$1' lustre on ${MOUNTPATH}....."
185 zconf_mount `hostname` $MOUNTPATH "$mountopt" || return 96
190 echo "umount lustre on ${MOUNTPATH}....."
191 zconf_umount `hostname` $MOUNTPATH || return 97
194 manual_umount_client(){
197 echo "manual umount lustre on ${MOUNT}...."
198 do_facet client "umount -d ${FORCE} $MOUNT"
204 start_mds || error "MDT start failed"
205 start_ost || error "OST start failed"
206 mount_client $MOUNT || error "client start failed"
207 client_up || error "client_up failed"
211 if ! combined_mgs_mds ; then
220 unload_modules_conf () {
221 if combined_mgs_mds || ! local_mode; then
222 unload_modules || return 1
227 stop_ost || return 202
228 stop_mds || return 201
229 unload_modules_conf || return 203
233 umount_client $MOUNT || return 200
234 cleanup_nocli || return $?
238 do_facet client "cp /etc/passwd $DIR/a" || return 71
239 do_facet client "rm $DIR/a" || return 72
240 # make sure lustre is actually mounted (touch will block,
241 # but grep won't, so do it after)
242 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
243 echo "setup single mount lustre success"
247 do_facet client "touch $DIR/a" || return 71
248 do_facet client "rm $DIR/a" || return 72
249 do_facet client "touch $DIR2/a" || return 73
250 do_facet client "rm $DIR2/a" || return 74
251 echo "setup double mount lustre success"
256 if [ "$ONLY" == "setup" ]; then
261 if [ "$ONLY" == "cleanup" ]; then
268 #create single point mountpoint
274 check_mount || return 41
277 run_test 0 "single mount setup"
280 start_mds || error "MDT start failed"
282 echo "start ost second time..."
283 start_ost && error "2nd OST start should fail"
284 mount_client $MOUNT || error "client start failed"
285 check_mount || return 42
288 run_test 1 "start up ost twice (should return errors)"
292 echo "start mds second time.."
293 start_mds && error "2nd MDT start should fail"
296 check_mount || return 43
299 run_test 2 "start up mds twice (should return err)"
303 #mount.lustre returns an error if already in mtab
304 mount_client $MOUNT && error "2nd client mount should fail"
305 check_mount || return 44
308 run_test 3 "mount client twice (should return err)"
312 touch $DIR/$tfile || return 85
316 # ok for ost to fail shutdown
317 if [ 202 -ne $eno ]; then
322 run_test 4 "force cleanup ost, then cleanup"
324 test_5a() { # was test_5
326 touch $DIR/$tfile || return 1
327 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
329 stop_mds -f || return 2
331 # cleanup may return an error from the failed
332 # disconnects; for now I'll consider this successful
333 # if all the modules have unloaded.
337 echo "killing umount"
338 kill -TERM $UMOUNT_PID
339 echo "waiting for umount to finish"
341 if grep " $MOUNT " /proc/mounts; then
342 echo "test 5: /proc/mounts after failed umount"
346 echo "killing umount"
347 kill -TERM $UMOUNT_PID
348 echo "waiting for umount to finish"
350 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
354 # stop_mds is a no-op here, and should not fail
355 cleanup_nocli || return $?
356 # df may have lingering entry
358 # mtab may have lingering entry
362 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
364 grep -q $MOUNT" " /etc/mtab || break
365 echo "Waiting /etc/mtab updated ... "
366 WAIT=$(( WAIT + sleep))
368 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
369 echo "/etc/mtab updated in $WAIT secs"
371 run_test 5a "force cleanup mds, then cleanup"
379 grep " $MOUNT " /etc/mtab && \
380 error false "unexpected entry in mtab before mount" && return 10
384 if ! combined_mgs_mds ; then
385 trap cleanup_5b EXIT ERR
390 [ -d $MOUNT ] || mkdir -p $MOUNT
391 mount_client $MOUNT && rc=1
392 grep " $MOUNT " /etc/mtab && \
393 error "$MOUNT entry in mtab after failed mount" && rc=11
395 # stop_mds is a no-op here, and should not fail
396 cleanup_nocli || rc=$?
397 if ! combined_mgs_mds ; then
402 run_test 5b "Try to start a client with no MGS (should return errs)"
405 grep " $MOUNT " /etc/mtab && \
406 error false "unexpected entry in mtab before mount" && return 10
411 [ -d $MOUNT ] || mkdir -p $MOUNT
412 local oldfs="${FSNAME}"
413 FSNAME="wrong.${FSNAME}"
414 mount_client $MOUNT || :
416 grep " $MOUNT " /etc/mtab && \
417 error "$MOUNT entry in mtab after failed mount" && rc=11
419 cleanup_nocli || rc=$?
422 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
425 grep " $MOUNT " /etc/mtab && \
426 error false "unexpected entry in mtab before mount" && return 10
432 mount_client $MOUNT || rc=1
434 grep " $MOUNT " /etc/mtab && \
435 error "$MOUNT entry in mtab after unmount" && rc=11
438 run_test 5d "mount with ost down"
441 grep " $MOUNT " /etc/mtab && \
442 error false "unexpected entry in mtab before mount" && return 10
448 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
449 do_facet client "lctl set_param fail_loc=0x80000506"
450 mount_client $MOUNT || echo "mount failed (not fatal)"
452 grep " $MOUNT " /etc/mtab && \
453 error "$MOUNT entry in mtab after unmount" && rc=11
456 run_test 5e "delayed connect, don't crash (bug 10268)"
459 if combined_mgs_mds ; then
460 skip "combined mgs and mds"
464 grep " $MOUNT " /etc/mtab && \
465 error false "unexpected entry in mtab before mount" && return 10
469 [ -d $MOUNT ] || mkdir -p $MOUNT
470 mount_client $MOUNT &
472 echo client_mount pid is $pid
476 if ! ps -f -p $pid >/dev/null; then
479 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
480 error "mount returns $rc, expected to hang"
489 # mount should succeed after start mds
492 [ $rc -eq 0 ] || error "mount returned $rc"
493 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
497 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
502 mount_client ${MOUNT} || return 87
503 touch $DIR/a || return 86
506 run_test 6 "manual umount, then mount again"
511 cleanup_nocli || return $?
513 run_test 7 "manual umount, then cleanup"
518 check_mount2 || return 45
519 umount_client $MOUNT2
522 run_test 8 "double mount setup"
527 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
528 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
530 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
531 if [ "$CHECK_PTLDEBUG" ] && { \
532 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
533 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
534 echo "lnet.debug success"
536 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
539 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
540 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
541 echo "lnet.subsystem_debug success"
543 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
546 stop_ost || return $?
548 run_test 9 "test ptldebug and subsystem for mkfs"
556 do_facet $facet "test -b $dev" || rc=1
557 if [[ "$size" ]]; then
558 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
559 awk '($3 == "in") { print $1 }')
560 [[ $in = "1+0" ]] || rc=1
566 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
567 # But with new MDS stack we don't care about the mode of local objects
568 # anymore, so this test is removed. See bug 22944 for more details.
573 check_mount || return 41
576 echo "Remove mds config log"
577 if ! combined_mgs_mds ; then
581 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MGSDEV || return \$?" || return $?
583 if ! combined_mgs_mds ; then
588 start_mds && return 42
591 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
594 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
596 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
601 # check if current MDSSIZE is large enough
602 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
603 log "use MDSSIZE=$MDSSIZE"
605 # check if the global config has a large enough MDSSIZE
606 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
607 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
608 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
610 # check if the block device is large enough
611 [ -z "$OK" ] && $(is_blkdev $SINGLEMDS $MDSDEV $MIN) && OK=1 &&
612 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
614 # check if a loopback device has enough space for fs metadata (5%)
616 if [ -z "$OK" ]; then
617 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
618 awk '($1 != "Filesystem") {print $4}')
619 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
620 OK=1 && myMDSSIZE=$MIN && \
621 log "use file $MDSDEV with MIN=$MIN"
624 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
627 echo "mount mds with large journal..."
628 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
630 local opts="--mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
632 if combined_mgs_mds ; then
633 MDS_MKFS_OPTS="--mgs $opts"
635 MDS_MKFS_OPTS="--mgsnode=$MGSNID $opts"
639 echo "mount lustre system..."
641 check_mount || return 41
643 echo "check journal size..."
644 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
645 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
646 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
648 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
653 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
656 run_test 18 "check mkfs creates large journals"
659 start_mds || return 1
660 stop_mds -f || return 2
662 run_test 19a "start/stop MDS without OSTs"
665 start_ost || return 1
666 stop_ost -f || return 2
668 run_test 19b "start/stop OSTs without MDS"
671 # first format the ost/mdt
675 check_mount || return 43
677 remount_client ro $MOUNT || return 44
678 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
679 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
680 remount_client rw $MOUNT || return 47
682 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
683 MCNT=`grep -c $MOUNT /etc/mtab`
684 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
689 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
694 wait_osc_import_state mds ost FULL
698 run_test 21a "start mds before ost, stop ost first"
703 wait_osc_import_state mds ost FULL
707 run_test 21b "start ost before mds, stop mds first"
713 wait_osc_import_state mds ost2 FULL
717 #writeconf to remove all ost2 traces for subsequent tests
720 run_test 21c "start mds between two osts, stop mds last"
723 if combined_mgs_mds ; then
724 skip "need separate mgs device" && return 0
734 wait_osc_import_state mds ost2 FULL
740 #writeconf to remove all ost2 traces for subsequent tests
744 run_test 21d "start mgs then ost and then mds"
749 echo Client mount with ost in logs, but none running
751 # wait until mds connected to ost and open client connection
752 wait_osc_import_state mds ost FULL
755 # check_mount will block trying to contact ost
756 mcreate $DIR/$tfile || return 40
757 rm -f $DIR/$tfile || return 42
761 echo Client mount with a running ost
764 # if gss enabled, wait full time to let connection from
765 # mds to ost be established, due to the mismatch between
766 # initial connect timeout and gss context negotiation timeout.
767 # This perhaps could be remove after AT landed.
768 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
769 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
772 wait_osc_import_state mds ost FULL
773 wait_osc_import_state client ost FULL
774 check_mount || return 41
779 run_test 22 "start a client before osts (should return errs)"
781 test_23a() { # was test_23
785 # force down client so that recovering mds waits for reconnect
786 local running=$(grep -c $MOUNT /proc/mounts) || true
787 if [ $running -ne 0 ]; then
788 echo "Stopping client $MOUNT (opts: -f)"
792 # enter recovery on mds
794 # try to start a new client
795 mount_client $MOUNT &
797 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
798 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
799 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
801 ps --ppid $MOUNT_LUSTRE_PID
802 echo "waiting for mount to finish"
804 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
805 # SIGTERM works but it does not spread to offspring processses
806 kill -s TERM $MOUNT_PID
807 kill -s TERM $MOUNT_LUSTRE_PID
808 # we can not wait $MOUNT_PID because it is not a child of this shell
814 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
816 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
817 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
820 [ -z "$PID1" -a -z "$PID2" ] && break
821 echo "waiting for mount to finish ... "
822 WAIT=$(( WAIT + sleep))
824 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
825 error "MOUNT_PID $MOUNT_PID and "\
826 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
832 run_test 23a "interrupt client during recovery mount delay"
837 test_23b() { # was test_23
840 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
841 lctl set_param fail_loc=0x80000313
845 run_test 23b "Simulate -EINTR during mount"
847 fs2mds_HOST=$mds_HOST
848 fs2ost_HOST=$ost_HOST
852 echo "umount $MOUNT2 ..."
853 umount $MOUNT2 || true
854 echo "stopping fs2mds ..."
855 stop fs2mds -f || true
856 echo "stopping fs2ost ..."
857 stop fs2ost -f || true
861 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
863 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
864 is_blkdev $SINGLEMDS $MDSDEV && \
865 skip_env "mixed loopback and real device not working" && return
868 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
870 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
871 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
873 # test 8-char fsname as well
874 local FSNAME2=test1234
875 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
877 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
880 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
881 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
883 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
885 check_mount || return 2
886 # files written on 1 should not show up on 2
887 cp /etc/passwd $DIR/$tfile
889 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
892 cp /etc/passwd $MOUNT2/b || return 3
893 rm $MOUNT2/b || return 4
894 # 2 is actually mounted
895 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
897 facet_failover fs2mds
898 facet_failover fs2ost
901 # the MDS must remain up until last MDT
903 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
904 [ -z "$MDS" ] && error "No MDT" && return 8
906 cleanup_nocli || return 6
908 run_test 24a "Multiple MDTs on a single node"
911 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
913 if [ -z "$fs2mds_DEV" ]; then
914 local dev=${SINGLEMDS}_dev
916 is_blkdev $SINGLEMDS $MDSDEV && \
917 skip_env "mixed loopback and real device not working" && return
920 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
922 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
924 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
927 run_test 24b "Multiple MGSs on a single node (should return err)"
931 check_mount || return 2
932 local MODULES=$($LCTL modules | awk '{ print $2 }')
933 rmmod $MODULES 2>/dev/null || true
936 run_test 25 "Verify modules are referenced"
940 # we need modules before mount for sysctl, so make sure...
941 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
942 #define OBD_FAIL_MDS_FS_SETUP 0x135
943 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
944 start_mds && echo MDS started && return 1
945 lctl get_param -n devices
946 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
947 [ $DEVS -gt 0 ] && return 2
948 unload_modules_conf || return $?
950 run_test 26 "MDT startup failure cleans LOV (should return errs)"
956 local ORIG=$(do_facet $myfacet "$TEST")
957 if [ $# -gt 3 ]; then
963 echo "Setting $PARAM from $ORIG to $FINAL"
964 do_facet mgs "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
966 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
970 start_ost || return 1
971 start_mds || return 2
972 echo "Requeue thread should have started: "
973 ps -e | grep ll_cfg_requeue
974 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
977 run_test 27a "Reacquire MGS lock if OST started first"
982 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
984 facet_failover $SINGLEMDS
985 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
986 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
990 run_test 27b "Reacquire MGS lock after failover"
994 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
995 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
998 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
999 FINAL=$(($FINAL + 1))
1000 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
1001 umount_client $MOUNT || return 200
1004 if [ $RESULT -ne $FINAL ]; then
1005 echo "New config not seen: wanted $FINAL got $RESULT"
1008 echo "New config success: got $RESULT"
1010 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
1013 run_test 28 "permanent parameter setting"
1016 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1017 setup > /dev/null 2>&1
1021 local PARAM="$FSNAME-OST0001.osc.active"
1022 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1023 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1025 ACTV=$(lctl get_param -n $PROC_ACT)
1027 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1028 # also check ost_server_uuid status
1029 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1030 if [ -z "$RESULT" ]; then
1031 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1034 echo "Live client success: got $RESULT"
1038 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0001)
1039 mdtosc=${mdtosc/-MDT*/-MDT\*}
1040 local MPROC="osc.$mdtosc.active"
1045 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
1046 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1047 if [ $RESULT -eq $DEAC ]; then
1048 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
1052 if [ $WAIT -eq $MAX ]; then
1053 echo "MDT not deactivated: wanted $DEAC got $RESULT"
1056 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
1059 # quotacheck should not fail immediately after deactivate
1060 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1062 # test new client starts deactivated
1063 umount_client $MOUNT || return 200
1065 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1066 if [ -z "$RESULT" ]; then
1067 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1070 echo "New client success: got $RESULT"
1073 # quotacheck should not fail after umount/mount operation
1074 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1076 # make sure it reactivates
1077 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1079 umount_client $MOUNT
1082 #writeconf to remove all ost2 traces for subsequent tests
1085 run_test 29 "permanently remove an OST"
1090 echo Big config llog
1091 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1093 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1094 for i in ${LIST[@]}; do
1095 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1097 # make sure client restart still works
1098 umount_client $MOUNT
1099 mount_client $MOUNT || return 4
1100 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1103 echo Erase parameter setting
1104 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1105 umount_client $MOUNT
1106 mount_client $MOUNT || return 6
1108 echo "deleted (default) value=$FINAL, orig=$ORIG"
1109 # assumes this parameter started at the default value
1110 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1114 run_test 30a "Big config llog and conf_param deletion"
1119 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1120 # numerical part of it. Hopefully that's not already a failover address for
1122 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1123 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1124 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1125 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1126 echo "Using fake nid $NEW"
1128 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1129 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
1130 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1132 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1133 echo "should have 2 failover nids: $NIDCOUNT"
1134 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1135 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1136 umount_client $MOUNT
1137 mount_client $MOUNT || return 3
1139 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1141 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1142 echo "only 1 final nid should remain: $NIDCOUNT"
1143 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1147 run_test 30b "Remove failover nids"
1149 test_31() { # bug 10734
1150 # ipaddr must not exist
1151 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1154 run_test 31 "Connect to non-existent node (shouldn't crash)"
1156 # Use these start32/stop32 fn instead of t-f start/stop fn,
1157 # for local devices, to skip global facet vars init
1161 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1162 umount -d $@ ${MOUNT%/*}/${facet}
1171 mkdir -p ${MOUNT%/*}/${facet}
1173 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1174 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1176 if [ $RC -ne 0 ]; then
1177 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1178 echo "Start of ${device} of local ${facet} failed ${RC}"
1184 cleanup_nocli32 () {
1192 echo "Cleanup test_32 umount $MOUNT ..."
1193 umount -f $MOUNT || true
1194 echo "Cleanup local mds ost1 ..."
1196 combined_mgs_mds || start_mgs
1201 client_only && skip "client only testing" && return 0
1202 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1203 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1205 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1206 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1207 local tmpdir=$TMP/conf32a
1209 tar xjvf $DISK1_8 -C $tmpdir || \
1210 { skip_env "Cannot untar $DISK1_8" && return 0; }
1213 $LCTL set_param debug="$PTLDEBUG"
1215 $TUNEFS $tmpdir/mds || error "tunefs failed"
1217 combined_mgs_mds || stop mgs
1219 # nids are wrong, so client wont work, but server should start
1220 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1221 trap cleanup_32 EXIT INT || return 3
1223 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1225 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1227 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1228 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1229 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1231 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1233 local NID=$($LCTL list_nids | head -1)
1235 echo "OSC changes should succeed:"
1236 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1237 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1240 echo "MDC changes should succeed:"
1241 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1242 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1245 echo "LOV changes should succeed:"
1246 $LCTL pool_new lustre.interop || return 11
1247 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1252 # mount a second time to make sure we didnt leave upgrade flag on
1254 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1256 combined_mgs_mds || stop mgs
1258 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1259 trap cleanup_32 EXIT INT || return 12
1263 rm -rf $tmpdir || true # true is only for TMP on NFS
1265 run_test 32a "Upgrade from 1.8 (not live)"
1268 client_only && skip "client only testing" && return 0
1269 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1270 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1272 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1273 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1274 local tmpdir=$TMP/conf32b
1276 tar xjvf $DISK1_8 -C $tmpdir || \
1277 { skip_env "Cannot untar $DISK1_8" && return ; }
1280 $LCTL set_param debug="+config"
1281 local NEWNAME=lustre
1283 # writeconf will cause servers to register with their current nids
1284 $TUNEFS --writeconf --erase-params \
1285 --param mdt.identity_upcall=$L_GETIDENTITY \
1286 --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1287 combined_mgs_mds || stop mgs
1289 start32 mds1 $tmpdir/mds "-o loop" && \
1290 trap cleanup_32 EXIT INT || return 3
1292 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1294 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1296 $TUNEFS --writeconf --erase-params \
1297 --mgsnode=$HOSTNAME --fsname=$NEWNAME $tmpdir/ost1 ||\
1298 error "tunefs failed"
1299 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1300 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1302 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1304 local NID=$($LCTL list_nids | head -1)
1306 echo "OSC changes should succeed:"
1307 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1308 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1311 echo "MDC changes should succeed:"
1312 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1313 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1316 echo "LOV changes should succeed:"
1317 $LCTL pool_new ${NEWNAME}.interop || return 11
1318 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1321 # MDT and OST should have registered with new nids, so we should have
1322 # a fully-functioning client
1323 echo "Check client and old fs contents"
1325 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1326 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1327 mount -t lustre $device $MOUNT || return 1
1329 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1330 local new=$((old + 5))
1331 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1332 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1334 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1339 rm -rf $tmpdir || true # true is only for TMP on NFS
1341 run_test 32b "Upgrade from 1.8 with writeconf"
1343 test_33a() { # bug 12333, was test_33
1345 local FSNAME2=test-123
1346 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1348 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1350 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1351 local dev=${SINGLEMDS}_dev
1352 local MDSDEV=${!dev}
1353 is_blkdev $SINGLEMDS $MDSDEV && \
1354 skip_env "mixed loopback and real device not working" && return
1357 combined_mgs_mds || mkfs_opts="$mkfs_opts --nomgs"
1359 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1360 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1361 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1362 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1364 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1365 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1366 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1368 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1371 cp /etc/hosts $MOUNT2/ || rc=3
1372 $LFS getstripe $MOUNT2/hosts
1377 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1378 cleanup_nocli || rc=6
1381 run_test 33a "Mount ost with a large index number"
1383 test_33b() { # was test_34
1386 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1387 # Drop lock cancelation reply during umount
1388 #define OBD_FAIL_LDLM_CANCEL 0x304
1389 do_facet client lctl set_param fail_loc=0x80000304
1390 #lctl set_param debug=-1
1391 umount_client $MOUNT
1394 run_test 33b "Drop cancel during umount"
1398 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1399 manual_umount_client
1401 do_facet client killall -USR1 multiop
1402 if [ $rc -eq 0 ]; then
1403 error "umount not fail!"
1408 run_test 34a "umount with opened file should be fail"
1413 touch $DIR/$tfile || return 1
1414 stop_mds --force || return 2
1416 manual_umount_client --force
1418 if [ $rc -ne 0 ]; then
1419 error "mtab after failed umount - rc $rc"
1425 run_test 34b "force umount with failed mds should be normal"
1429 touch $DIR/$tfile || return 1
1430 stop_ost --force || return 2
1432 manual_umount_client --force
1434 if [ $rc -ne 0 ]; then
1435 error "mtab after failed umount - rc $rc"
1441 run_test 34c "force umount with failed ost should be normal"
1443 test_35a() { # bug 12459
1446 DBG_SAVE="`lctl get_param -n debug`"
1447 lctl set_param debug="ha"
1449 log "Set up a fake failnode for the MDS"
1451 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1452 do_facet mgs $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1454 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1457 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1460 log "Stopping the MDT:"
1461 stop_mds || return 5
1463 df $MOUNT > /dev/null 2>&1 &
1465 log "Restarting the MDT:"
1466 start_mds || return 6
1467 log "Wait for df ($DFPID) ... "
1470 lctl set_param debug="$DBG_SAVE"
1472 # retrieve from the log the first server that the client tried to
1473 # contact after the connection loss
1474 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1475 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1476 /import_select_connection.*$device-mdc.* using connection/ {
1478 if (\\\$NF ~ /$FAKENID/)
1484 }" $TMP/lustre-log-$TESTNAME.log`
1485 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1487 # remove nid settings
1490 run_test 35a "Reconnect to the last active server first"
1492 test_35b() { # bug 18674
1493 remote_mds || { skip "local MDS" && return 0; }
1497 $LCTL set_param debug="ha"
1499 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1502 log "Set up a fake failnode for the MDS"
1504 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | \
1505 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1506 do_facet mgs "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1509 local at_max_saved=0
1510 # adaptive timeouts may prevent seeing the issue
1511 if at_is_enabled; then
1512 at_max_saved=$(at_max_get mds)
1513 at_max_set 0 mds client
1516 mkdir -p $MOUNT/$tdir
1518 log "Injecting EBUSY on MDS"
1519 # Setting OBD_FAIL_MDS_RESEND=0x136
1520 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
1522 $LCTL set_param mdc.${FSNAME}*.stats=clear
1524 log "Creating a test file and stat it"
1525 touch $MOUNT/$tdir/$tfile
1526 stat $MOUNT/$tdir/$tfile
1528 log "Stop injecting EBUSY on MDS"
1529 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
1530 rm -f $MOUNT/$tdir/$tfile
1533 # restore adaptive timeout
1534 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1536 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1538 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
1540 # retrieve from the log if the client has ever tried to
1541 # contact the fake server after the loss of connection
1542 FAILCONN=`awk "BEGIN {ret = 0;}
1543 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1545 if (\\\$NF ~ /$FAKENID/) {
1550 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1552 [ "$FAILCONN" == "0" ] && \
1553 log "ERROR: The client reconnection has not been triggered" && \
1555 [ "$FAILCONN" == "2" ] && \
1556 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1560 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
1561 # Reconnects are supposed to be rate limited to one every 5s
1562 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
1563 log "ERROR: Too many reconnects $CONNCNT" && \
1567 # remove nid settings
1570 run_test 35b "Continue reconnection retries, if the active server is busy"
1573 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1575 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1576 { skip "remote OST" && return 0; }
1579 local FSNAME2=test1234
1580 local fs3ost_HOST=$ost_HOST
1581 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1583 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1585 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1586 is_blkdev $SINGLEMDS $MDSDEV && \
1587 skip_env "mixed loopback and real device not working" && return
1590 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1591 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1592 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1593 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1594 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1596 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1597 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1599 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1600 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1601 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1603 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1605 sleep 5 # until 11778 fixed
1607 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1609 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1610 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1611 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1612 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1613 DFTOTAL=`echo $STRING | cut -d, -f1`
1614 DFUSED=`echo $STRING | cut -d, -f2`
1615 DFAVAIL=`echo $STRING | cut -d, -f3`
1616 DFFREE=$(($DFTOTAL - $DFUSED))
1618 ALLOWANCE=$((64 * $OSTCOUNT))
1620 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1621 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1622 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1625 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1626 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1627 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1630 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1631 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1632 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1637 stop fs3ost -f || return 200
1638 stop fs2ost -f || return 201
1639 stop fs2mds -f || return 202
1640 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1641 unload_modules_conf || return 203
1644 run_test 36 "df report consistency on OSTs with different block size"
1647 local mntpt=$(facet_mntpt $SINGLEMDS)
1648 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
1649 local mdsdev_sym="$TMP/sym_mdt.img"
1651 echo "MDS : $mdsdev"
1652 echo "SYMLINK : $mdsdev_sym"
1653 do_facet $SINGLEMDS rm -f $mdsdev_sym
1655 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
1657 echo "mount symlink device - $mdsdev_sym"
1660 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $MDS_MOUNT_OPTS $mdsdev_sym $mntpt 2>&1 )
1663 echo mount_op=$mount_op
1665 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
1667 if $(echo $mount_op | grep -q "unable to set tunable"); then
1668 error "set tunables failed for symlink device"
1671 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
1675 run_test 37 "verify set tunables works for symlink device"
1677 test_38() { # bug 14222
1682 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1683 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1685 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1686 error "copying $SRC to $DIR/$tdir"
1688 umount_client $MOUNT
1690 log "rename lov_objid file on MDS"
1691 rm -f $TMP/lov_objid.orig
1693 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1694 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1695 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1697 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1698 # check create in mds_lov_connect
1702 [ $V ] && log "verifying $DIR/$tdir/$f"
1703 diff -q $f $DIR/$tdir/$f || ERROR=y
1705 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1706 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1707 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1709 # check it's updates in sync
1710 umount_client $MOUNT
1713 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1714 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1715 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1720 [ $V ] && log "verifying $DIR/$tdir/$f"
1721 diff -q $f $DIR/$tdir/$f || ERROR=y
1723 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1724 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1725 umount_client $MOUNT
1727 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1729 log "files compared the same"
1732 run_test 38 "MDS recreates missing lov_objid file from OST data"
1738 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1739 error "memory leak detected" || true
1741 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1743 test_40() { # bug 15759
1745 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1746 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
1750 run_test 40 "race during service thread startup"
1752 test_41a() { #bug 14134
1753 echo $MDS_MOUNT_OPTS | grep "loop" && skip " loop devices does not work with nosvc option" && return
1756 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1758 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1759 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1760 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1762 mount_client $MOUNT || return 1
1765 echo "blah blah" > $MOUNT/$tfile
1768 umount_client $MOUNT
1769 stop ost1 -f || return 201
1770 stop_mds -f || return 202
1771 stop_mds -f || return 203
1772 unload_modules_conf || return 204
1775 run_test 41a "mount mds with --nosvc and --nomgs"
1778 echo $MDS_MOUNT_OPTS | grep "loop" && skip " loop devices does not work with nosvc option" && return
1780 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
1784 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1786 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1788 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1790 mount_client $MOUNT || return 1
1793 echo "blah blah" > $MOUNT/$tfile
1794 cat $MOUNT/$tfile || return 200
1796 umount_client $MOUNT
1797 stop_ost || return 201
1798 stop_mds -f || return 202
1799 stop_mds -f || return 203
1802 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
1804 test_42() { #bug 14693
1806 check_mount || return 2
1807 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1808 umount_client $MOUNT
1809 mount_client $MOUNT || return 1
1813 run_test 42 "invalid config param should not prevent client from mounting"
1816 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1818 chmod ugo+x $DIR || error "chmod 0 failed"
1820 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1821 "$FSNAME.mdt.root_squash" \
1824 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1825 "$FSNAME.mdt.nosquash_nids" \
1829 # create set of test files
1831 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1832 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1833 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1835 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1836 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1838 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1839 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1840 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1843 # check root_squash:
1844 # set root squash UID:GID to RUNAS_ID
1845 # root should be able to access only files owned by RUNAS_ID
1848 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1849 "$FSNAME.mdt.root_squash" \
1850 "$RUNAS_ID:$RUNAS_ID"
1852 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1853 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1854 error "$ST: root read permission is denied"
1855 echo "$ST: root read permission is granted - ok"
1858 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1859 error "$ST: root write permission is denied"
1860 echo "$ST: root write permission is granted - ok"
1862 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1863 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1864 error "$ST: root read permission is granted"
1865 echo "$ST: root read permission is denied - ok"
1868 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1869 error "$ST: root write permission is granted"
1870 echo "$ST: root write permission is denied - ok"
1872 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1873 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1874 error "$ST: root unlink permission is granted"
1875 echo "$ST: root unlink permission is denied - ok"
1877 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1878 error "$ST: root create permission is granted"
1879 echo "$ST: root create permission is denied - ok"
1882 # check nosquash_nids:
1883 # put client's NID into nosquash_nids list,
1884 # root should be able to access root file after that
1886 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1887 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1888 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1890 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1891 "$FSNAME-MDTall.mdt.nosquash_nids" \
1894 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1895 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1896 error "$ST: root read permission is denied"
1897 echo "$ST: root read permission is granted - ok"
1900 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1901 error "$ST: root write permission is denied"
1902 echo "$ST: root write permission is granted - ok"
1904 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1905 rm $DIR/$tdir-rootdir/tfile-1 || \
1906 error "$ST: root unlink permission is denied"
1907 echo "$ST: root unlink permission is granted - ok"
1908 touch $DIR/$tdir-rootdir/tfile-2 || \
1909 error "$ST: root create permission is denied"
1910 echo "$ST: root create permission is granted - ok"
1914 run_test 43 "check root_squash and nosquash_nids"
1916 umount_client $MOUNT
1921 check_mount || return 2
1922 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1924 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1925 for VAL in $UUIDS; do
1926 NID=$(echo $VAL | cut -d= -f1)
1927 CLUUID=$(echo $VAL | cut -d= -f2)
1928 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1930 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1934 run_test 44 "mounted client proc entry exists"
1938 check_mount || return 2
1943 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1944 do_facet client "lctl set_param fail_loc=0x50f"
1947 manual_umount_client --force || return 3
1948 do_facet client "lctl set_param fail_loc=0x0"
1950 mount_client $MOUNT || return 4
1954 run_test 45 "long unlink handling in ptlrpcd"
1961 umount_client $MOUNT2 || rc=$?
1962 umount_client $MOUNT || rc=$?
1963 while [ $count -gt 0 ]; do
1964 stop ost${count} -f || rc=$?
1968 cleanup_nocli || rc=$?
1969 #writeconf to remove all ost2 traces for subsequent tests
1975 echo "Testing with $OSTCOUNT OSTs"
1977 start_mds || return 1
1978 #first client should see only one ost
1979 start_ost || return 2
1980 wait_osc_import_state mds ost FULL
1982 mount_client $MOUNT || return 3
1983 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1986 for (( i=2; i<=$OSTCOUNT; i++ )); do
1987 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1990 # wait until osts in sync
1991 for (( i=2; i<=$OSTCOUNT; i++ )); do
1992 wait_osc_import_state mds ost$i FULL
1993 wait_osc_import_state client ost$i FULL
1996 #second client see all ost's
1998 mount_client $MOUNT2 || return 8
1999 $LFS setstripe -c -1 $MOUNT2 || return 9
2000 $LFS getstripe $MOUNT2 || return 10
2002 echo "ok" > $MOUNT2/widestripe
2003 $LFS getstripe $MOUNT2/widestripe || return 11
2004 # fill acl buffer for avoid expand lsm to them
2005 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
2006 setfacl -m $acl $MOUNT2/widestripe
2010 stat $MOUNT/widestripe || return 12
2012 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
2015 run_test 46a "handle ost additional - wide striped file"
2020 check_mount || return 2
2021 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2025 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2026 if echo $ns | grep "MDT[[:digit:]]*"; then
2029 lrs=$(echo $ns | sed 's/.*lru_size=//')
2030 lru_size[count]=$lrs
2035 facet_failover $SINGLEMDS
2036 client_up || return 3
2039 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2040 if echo $ns | grep "MDT[[:digit:]]*"; then
2043 lrs=$(echo $ns | sed 's/.*lru_size=//')
2044 if ! test "$lrs" -eq "${lru_size[count]}"; then
2045 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2046 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2054 run_test 47 "server restart does not make client loss lru_resize settings"
2059 # reformat after this test is needed - if test will failed
2060 # we will have unkillable file at FS
2064 test_48() { # bug 17636
2067 check_mount || return 2
2069 $LFS setstripe -c -1 $MOUNT || return 9
2070 $LFS getstripe $MOUNT || return 10
2072 echo "ok" > $MOUNT/widestripe
2073 $LFS getstripe $MOUNT/widestripe || return 11
2075 trap cleanup_48 EXIT ERR
2077 # fill acl buffer for avoid expand lsm to them
2078 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2079 setfacl -m $acl $MOUNT/widestripe
2082 stat $MOUNT/widestripe || return 12
2087 run_test 48 "too many acls on file"
2089 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2090 test_49() { # bug 17710
2091 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
2092 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
2093 local LOCAL_TIMEOUT=20
2096 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
2100 check_mount || return 1
2102 echo "check ldlm_timout..."
2103 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2104 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2105 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2107 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2108 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2111 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2112 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2115 umount_client $MOUNT
2116 stop_ost || return 2
2117 stop_mds || return 3
2119 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"
2123 check_mount || return 7
2125 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2126 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2127 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2129 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2130 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2133 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2134 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2137 cleanup || return $?
2139 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
2140 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
2142 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
2145 # Test both statfs and lfs df and fail if either one fails
2146 multiop_bg_pause $1 f_
2149 killall -USR1 multiop
2150 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2151 wait $PID || { RC1=$?; log "multiop return error "; }
2158 if [ $RC2 -eq 0 ]; then
2160 log "lazystatfs df failed"
2164 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2170 lctl set_param llite.$FSNAME-*.lazystatfs=1
2173 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2175 cleanup || return $?
2177 run_test 50a "lazystatfs all servers available =========================="
2181 lctl set_param llite.$FSNAME-*.lazystatfs=1
2184 # Wait for client to detect down OST
2185 stop_ost || error "Unable to stop OST1"
2186 wait_osc_import_state mds ost DISCONN
2188 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2190 umount_client $MOUNT || error "Unable to unmount client"
2191 stop_mds || error "Unable to stop MDS"
2193 run_test 50b "lazystatfs all servers down =========================="
2196 start_mds || error "Unable to start MDS"
2197 start_ost || error "Unable to start OST1"
2198 start_ost2 || error "Unable to start OST2"
2199 mount_client $MOUNT || error "Unable to mount client"
2200 lctl set_param llite.$FSNAME-*.lazystatfs=1
2203 # Wait for client to detect down OST
2204 stop_ost || error "Unable to stop OST1"
2205 wait_osc_import_state mds ost DISCONN
2206 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2208 umount_client $MOUNT || error "Unable to unmount client"
2209 stop_ost2 || error "Unable to stop OST2"
2210 stop_mds || error "Unable to stop MDS"
2211 #writeconf to remove all ost2 traces for subsequent tests
2214 run_test 50c "lazystatfs one server down =========================="
2217 start_mds || error "Unable to start MDS"
2218 start_ost || error "Unable to start OST1"
2219 start_ost2 || error "Unable to start OST2"
2220 mount_client $MOUNT || error "Unable to mount client"
2221 lctl set_param llite.$FSNAME-*.lazystatfs=1
2224 # Issue the statfs during the window where the client still
2225 # belives the OST to be available but it is in fact down.
2226 # No failure just a statfs which hangs for a timeout interval.
2227 stop_ost || error "Unable to stop OST1"
2228 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2230 umount_client $MOUNT || error "Unable to unmount client"
2231 stop_ost2 || error "Unable to stop OST2"
2232 stop_mds || error "Unable to stop MDS"
2233 #writeconf to remove all ost2 traces for subsequent tests
2236 run_test 50d "lazystatfs client/server conn race =========================="
2243 start_mds || return 1
2244 #first client should see only one ost
2245 start_ost || return 2
2246 wait_osc_import_state mds ost FULL
2248 # Wait for client to detect down OST
2249 stop_ost || error "Unable to stop OST1"
2250 wait_osc_import_state mds ost DISCONN
2252 mount_client $MOUNT || error "Unable to mount client"
2253 lctl set_param llite.$FSNAME-*.lazystatfs=0
2255 multiop_bg_pause $MOUNT _f
2259 if [ $RC1 -ne 0 ]; then
2260 log "multiop failed $RC1"
2263 sleep $(( $TIMEOUT+1 ))
2265 [ $? -ne 0 ] && error "process isn't sleep"
2266 start_ost || error "Unable to start OST1"
2267 wait $pid || error "statfs failed"
2270 umount_client $MOUNT || error "Unable to unmount client"
2271 stop_ost || error "Unable to stop OST1"
2272 stop_mds || error "Unable to stop MDS"
2274 run_test 50e "normal statfs all servers down =========================="
2279 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2281 start_mds || error "Unable to start mds"
2282 #first client should see only one ost
2283 start_ost || error "Unable to start OST1"
2284 wait_osc_import_state mds ost FULL
2286 start_ost2 || error "Unable to start OST2"
2287 wait_osc_import_state mds ost2 FULL
2289 # Wait for client to detect down OST
2290 stop_ost2 || error "Unable to stop OST2"
2292 wait_osc_import_state mds ost2 DISCONN
2293 mount_client $MOUNT || error "Unable to mount client"
2294 lctl set_param llite.$FSNAME-*.lazystatfs=0
2296 multiop_bg_pause $MOUNT _f
2300 if [ $RC1 -ne 0 ]; then
2301 log "lazystatfs multiop failed $RC1"
2304 sleep $(( $TIMEOUT+1 ))
2306 [ $? -ne 0 ] && error "process isn't sleep"
2307 start_ost2 || error "Unable to start OST2"
2308 wait $pid || error "statfs failed"
2309 stop_ost2 || error "Unable to stop OST2"
2312 umount_client $MOUNT || error "Unable to unmount client"
2313 stop_ost || error "Unable to stop OST1"
2314 stop_mds || error "Unable to stop MDS"
2315 #writeconf to remove all ost2 traces for subsequent tests
2318 run_test 50f "normal statfs one server in down =========================="
2321 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2323 start_ost2 || error "Unable to start OST2"
2324 wait_osc_import_state mds ost2 FULL
2325 wait_osc_import_state client ost2 FULL
2327 local PARAM="${FSNAME}-OST0001.osc.active"
2329 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2330 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2332 umount_client $MOUNT || error "Unable to unmount client"
2333 mount_client $MOUNT || error "Unable to mount client"
2334 # This df should not cause a panic
2337 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2339 umount_client $MOUNT || error "Unable to unmount client"
2340 stop_ost2 || error "Unable to stop OST2"
2341 stop_ost || error "Unable to stop OST1"
2342 stop_mds || error "Unable to stop MDS"
2343 #writeconf to remove all ost2 traces for subsequent tests
2346 run_test 50g "deactivated OST should not cause panic====================="
2349 local LOCAL_TIMEOUT=20
2353 check_mount || return 1
2356 $LFS setstripe -c -1 $MOUNT/d1
2357 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2358 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2359 touch $MOUNT/d1/f1 &
2362 start_ost2 || return 2
2364 stop_ost2 || return 3
2366 #writeconf to remove all ost2 traces for subsequent tests
2369 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2378 do_node $node mkdir -p $dest
2379 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2381 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2382 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2383 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2385 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2386 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2396 local backup2=${TMP}/backup2
2398 do_node $node mkdir -p $backup2
2399 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2401 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2402 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2403 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2405 do_node $node "diff -rq $backup $backup2"
2406 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2408 local xattrs2=${TMP}/xattrs2
2409 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2410 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2412 do_node $node "diff $xattrs $xattrs2"
2413 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2415 do_node $node "rm -rf $backup2 $xattrs2"
2416 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2421 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2423 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2425 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2428 local ost1mnt=$(facet_mntpt ost1)
2429 local ost1node=$(facet_active_host ost1)
2430 local ost1tmp=$TMP/conf52
2433 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2434 touch $TMP/modified_first
2435 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2436 local mtime=$(stat -c %Y $TMP/modified_first)
2437 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2439 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2442 $LFS setstripe -c -1 -S 1M $DIR/$tdir
2443 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2445 for (( i=0; i < nrfiles; i++ )); do
2446 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2447 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2453 echo backup files to $TMP/files
2454 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2455 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2456 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2458 umount_client $MOUNT
2459 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2461 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2463 echo mount ost1 as ldiskfs
2464 do_node $ost1node mkdir -p $ost1mnt
2465 [ $? -eq 0 ] || { error "Unable to create $ost1mnt"; return 23; }
2466 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2467 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2470 echo backup objects to $ost1tmp/objects
2471 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2472 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2473 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2474 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2476 # move objects to lost+found
2477 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2478 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2481 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2482 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2484 # compare restored objects against saved ones
2485 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2486 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2488 do_node $ost1node "umount $ost1mnt"
2489 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2492 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2494 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2497 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2498 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2500 rm -rf $TMP/files $TMP/file_xattrs
2501 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2502 do_node $ost1node "rm -rf $ost1tmp"
2503 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2506 run_test 52 "check recovering objects from lost+found"
2508 # Checks threads_min/max/started for some service
2510 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2511 # parameter pattern prefix like 'ost.*.ost'.
2523 local msg="Insane $modname thread counts"
2527 check_mount || return 41
2529 # We need to expand $parampat, but it may match multiple parameters, so
2530 # we'll pick the first one
2531 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2532 error "Couldn't expand ${parampat}.threads_min parameter name"
2536 # Remove the .threads_min part
2537 paramp=${paramp%.threads_min}
2539 # Check for sanity in defaults
2540 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2541 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2542 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2543 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2544 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
2546 # Check that we can change min/max
2547 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + 1))"
2548 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 1))"
2549 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2550 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2551 lassert 25 "$msg" '(($tmin2 == ($tmin + 1) && $tmax2 == ($tmax -1)))' || return $?
2553 # Check that we can set min/max to the same value
2554 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2555 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2556 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2557 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2558 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2560 # Check that we can't set max < min
2561 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2562 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2563 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2564 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
2566 # We need to ensure that we get the module options desired; to do this
2567 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2568 LOAD_MODULES_REMOTE=true
2571 setmodopts -a $modname "$opts" oldvalue
2575 check_mount || return 41
2577 # Restore previous setting of MODOPTS_*
2578 setmodopts $modname "$oldvalue"
2580 # Check that $opts took
2581 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2582 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2583 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2584 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2587 # Workaround a YALA bug where YALA expects that modules will remain
2588 # loaded on the servers
2589 LOAD_MODULES_REMOTE=false
2596 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2598 run_test 53a "check OSS thread count params"
2601 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2603 run_test 53b "check MDT thread count params"
2606 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p
2607 [ $? -eq 0 ] || error "llverdev failed!"
2610 run_test 54a "test llverdev and partial verify of device"
2614 run_llverfs $MOUNT -p
2615 [ $? -eq 0 ] || error "llverfs failed!"
2618 run_test 54b "test llverfs and partial verify of filesystem"
2622 local max_ost_index=$1
2623 echo -n $(((max_ost_index + 1) * 8))
2627 local mdsdev=$(mdsdevname 1)
2628 local ostdev=$(ostdevname 1)
2629 local saved_opts=$OST_MKFS_OPTS
2633 OST_MKFS_OPTS="$saved_opts --index $i"
2641 echo checking size of lov_objid for ost index $i
2642 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2643 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2644 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2646 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2651 OST_MKFS_OPTS=$saved_opts
2654 run_test 55 "check lov_objid size"
2657 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2658 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2659 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2663 start_ost2 || error "Unable to start second ost"
2664 mount_client $MOUNT || error "Unable to mount client"
2667 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
2671 run_test 56 "check big indexes"
2673 test_57a() { # bug 22656
2674 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2676 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2678 start_ost && error "OST registration from failnode should fail"
2681 run_test 57a "initial registration from failnode should fail (should return errs)"
2684 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2686 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
2688 start_ost || error "OST registration from servicenode should not fail"
2691 run_test 57b "initial registration from servicenode should not fail"
2694 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2697 test_58() { # bug 22658
2698 [ "$FSTYPE" != "ldiskfs" ] && skip "not supported for $FSTYPE" && return
2701 createmany -o $DIR/$tdir/$tfile-%d 100
2702 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
2703 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
2704 do_facet mds "lctl set_param fail_loc=0x601"
2705 unlinkmany $DIR/$tdir/$tfile-%d 100
2707 local MNTDIR=$(facet_mntpt mds)
2708 # remove all files from the OBJECTS dir
2709 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
2710 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
2711 do_facet mds "umount $MNTDIR"
2712 # restart MDS with missing llog files
2714 do_facet mds "lctl set_param fail_loc=0"
2717 run_test 58 "missing llog files must not prevent MDT from mounting"
2720 start_mgsmds >> /dev/null
2721 local C1=$(count_osts)
2722 if [ $C1 -eq 0 ]; then
2723 start_ost >> /dev/null
2727 echo "original ost count: $C1 (expect > 0)"
2728 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2729 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2730 local C2=$(count_osts)
2731 echo "after mdt writeconf count: $C2 (expect 0)"
2732 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2733 echo "OST start without writeconf should fail:"
2734 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2735 echo "OST start with writeconf should succeed:"
2736 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2737 local C3=$(count_osts)
2738 echo "after ost writeconf count: $C3 (expect 1)"
2739 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2740 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2741 local C4=$(count_osts)
2742 echo "after ost2 writeconf count: $C4 (expect 2)"
2743 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2744 stop_ost2 >> /dev/null
2745 cleanup_nocli >> /dev/null
2746 #writeconf to remove all ost2 traces for subsequent tests
2749 run_test 59 "writeconf mount option"
2751 test_60() { # LU-471
2752 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' --reformat $(mdsdevname 1)
2754 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
2756 [ $rc -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
2758 # MDT default has dirdata feature
2759 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
2760 # we disable uninit_bg feature
2761 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
2762 # we set stride extended options
2763 echo $dump | grep stride > /dev/null || error "stride is not set"
2766 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
2769 local reformat=false
2771 if ! large_xattr_enabled; then
2773 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
2774 add $SINGLEMDS $MDS_MKFS_OPTS --mkfsoptions='\"-O large_xattr\"' \
2775 --reformat $mds_dev || error "reformatting $mds_dev failed"
2778 setup_noconfig || error "setting up the filesystem failed"
2779 client_up || error "starting client failed"
2781 local file=$DIR/$tfile
2784 local large_value="$(generate_string $(max_xattr_size))"
2785 local small_value="bar"
2787 local name="trusted.big"
2788 log "save large xattr $name on $file"
2789 setfattr -n $name -v $large_value $file ||
2790 error "saving $name on $file failed"
2792 local new_value=$(get_xattr_value $name $file)
2793 [[ "$new_value" != "$large_value" ]] &&
2794 error "$name different after saving"
2796 log "shrink value of $name on $file"
2797 setfattr -n $name -v $small_value $file ||
2798 error "shrinking value of $name on $file failed"
2800 new_value=$(get_xattr_value $name $file)
2801 [[ "$new_value" != "$small_value" ]] &&
2802 error "$name different after shrinking"
2804 log "grow value of $name on $file"
2805 setfattr -n $name -v $large_value $file ||
2806 error "growing value of $name on $file failed"
2808 new_value=$(get_xattr_value $name $file)
2809 [[ "$new_value" != "$large_value" ]] &&
2810 error "$name different after growing"
2812 log "check value of $name on $file after remounting MDS"
2814 new_value=$(get_xattr_value $name $file)
2815 [[ "$new_value" != "$large_value" ]] &&
2816 error "$name different after remounting MDS"
2818 log "remove large xattr $name from $file"
2819 setfattr -x $name $file || error "removing $name from $file failed"
2823 $reformat && reformat
2825 run_test 61 "large xattr"
2829 local mdsdev=$(mdsdevname 1)
2830 local ostdev=$(ostdevname 1)
2832 echo "disable journal for mds"
2833 do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
2834 start_mds && error "MDT start should fail"
2835 echo "disable journal for ost"
2836 do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
2837 start_ost && error "OST start should fail"
2838 cleanup || return $?
2841 run_test 62 "start with disabled journal"
2843 if ! combined_mgs_mds ; then
2849 # restore the ${facet}_MKFS_OPTS variables
2850 for facet in MGS MDS OST; do
2851 opts=SAVED_${facet}_MKFS_OPTS
2852 if [[ -n ${!opts} ]]; then
2853 eval ${facet}_MKFS_OPTS=\"${!opts}\"
2857 complete $(basename $0) $SECONDS