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
55 require_dsh_mds || exit 0
56 require_dsh_ost || exit 0
58 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
73 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
74 do_facet ${facet} "$TUNEFS --quiet --writeconf $dev" ||
75 { echo "tunefs failed, reformatting instead" && reformat_and_config && return 1; }
82 # if writeconf fails anywhere, we reformat everything
83 writeconf1 mds `mdsdevname 1` || return 0
84 writeconf1 ost1 `ostdevname 1` || return 0
85 writeconf1 ost2 `ostdevname 2` || return 0
89 # The MGS must be started before the OSTs for a new fs, so start
90 # and stop to generate the startup logs.
93 wait_osc_import_state mds ost FULL
98 reformat_and_config() {
100 if ! combined_mgs_mds ; then
108 start mgs $MGSDEV $MGS_MOUNT_OPTS
112 local facet=$SINGLEMDS
113 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
114 local num=$(echo $facet | tr -d "mds")
115 local dev=$(mdsdevname $num)
116 echo "start mds service on `facet_active_host $facet`"
117 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
121 if ! combined_mgs_mds ; then
128 echo "stop mds service on `facet_active_host $SINGLEMDS`"
129 # These tests all use non-failover stop
130 stop $SINGLEMDS -f || return 97
134 echo "stop mgs service on `facet_active_host mgs`"
135 # These tests all use non-failover stop
136 stop mgs -f || return 97
140 echo "start ost1 service on `facet_active_host ost1`"
141 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
145 echo "stop ost1 service on `facet_active_host ost1`"
146 # These tests all use non-failover stop
147 stop ost1 -f || return 98
151 echo "start ost2 service on `facet_active_host ost2`"
152 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
156 echo "stop ost2 service on `facet_active_host ost2`"
157 # These tests all use non-failover stop
158 stop ost2 -f || return 93
163 echo "mount $FSNAME on ${MOUNTPATH}....."
164 zconf_mount `hostname` $MOUNTPATH || return 96
168 local mountopt="-o remount,$1"
170 echo "remount '$1' lustre on ${MOUNTPATH}....."
171 zconf_mount `hostname` $MOUNTPATH "$mountopt" || return 96
176 echo "umount lustre on ${MOUNTPATH}....."
177 zconf_umount `hostname` $MOUNTPATH || return 97
180 manual_umount_client(){
183 echo "manual umount lustre on ${MOUNT}...."
184 do_facet client "umount -d ${FORCE} $MOUNT"
190 start_mds || error "MDT start failed"
191 start_ost || error "OST start failed"
192 mount_client $MOUNT || error "client start failed"
193 client_up || error "client_up failed"
197 if ! combined_mgs_mds ; then
206 unload_modules_conf () {
207 if combined_mgs_mds || ! local_mode; then
208 unload_modules || return 1
213 stop_ost || return 202
214 stop_mds || return 201
215 unload_modules_conf || return 203
219 umount_client $MOUNT || return 200
220 cleanup_nocli || return $?
224 do_facet client "cp /etc/passwd $DIR/a" || return 71
225 do_facet client "rm $DIR/a" || return 72
226 # make sure lustre is actually mounted (touch will block,
227 # but grep won't, so do it after)
228 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
229 echo "setup single mount lustre success"
233 do_facet client "touch $DIR/a" || return 71
234 do_facet client "rm $DIR/a" || return 72
235 do_facet client "touch $DIR2/a" || return 73
236 do_facet client "rm $DIR2/a" || return 74
237 echo "setup double mount lustre success"
242 if [ "$ONLY" == "setup" ]; then
247 if [ "$ONLY" == "cleanup" ]; then
254 #create single point mountpoint
260 check_mount || return 41
263 run_test 0 "single mount setup"
266 start_mds || error "MDT start failed"
268 echo "start ost second time..."
269 start_ost && error "2nd OST start should fail"
270 mount_client $MOUNT || error "client start failed"
271 check_mount || return 42
274 run_test 1 "start up ost twice (should return errors)"
278 echo "start mds second time.."
279 start_mds && error "2nd MDT start should fail"
282 check_mount || return 43
285 run_test 2 "start up mds twice (should return err)"
289 #mount.lustre returns an error if already in mtab
290 mount_client $MOUNT && error "2nd client mount should fail"
291 check_mount || return 44
294 run_test 3 "mount client twice (should return err)"
298 touch $DIR/$tfile || return 85
302 # ok for ost to fail shutdown
303 if [ 202 -ne $eno ]; then
308 run_test 4 "force cleanup ost, then cleanup"
310 test_5a() { # was test_5
312 touch $DIR/$tfile || return 1
313 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
315 stop_mds -f || return 2
317 # cleanup may return an error from the failed
318 # disconnects; for now I'll consider this successful
319 # if all the modules have unloaded.
323 echo "killing umount"
324 kill -TERM $UMOUNT_PID
325 echo "waiting for umount to finish"
327 if grep " $MOUNT " /proc/mounts; then
328 echo "test 5: /proc/mounts after failed umount"
332 echo "killing umount"
333 kill -TERM $UMOUNT_PID
334 echo "waiting for umount to finish"
336 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
340 # stop_mds is a no-op here, and should not fail
341 cleanup_nocli || return $?
342 # df may have lingering entry
344 # mtab may have lingering entry
348 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
350 grep -q $MOUNT" " /etc/mtab || break
351 echo "Waiting /etc/mtab updated ... "
352 WAIT=$(( WAIT + sleep))
354 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
355 echo "/etc/mtab updated in $WAIT secs"
357 run_test 5a "force cleanup mds, then cleanup"
365 grep " $MOUNT " /etc/mtab && \
366 error false "unexpected entry in mtab before mount" && return 10
370 if ! combined_mgs_mds ; then
371 trap cleanup_5b EXIT ERR
376 [ -d $MOUNT ] || mkdir -p $MOUNT
377 mount_client $MOUNT && rc=1
378 grep " $MOUNT " /etc/mtab && \
379 error "$MOUNT entry in mtab after failed mount" && rc=11
381 # stop_mds is a no-op here, and should not fail
382 cleanup_nocli || rc=$?
383 if ! combined_mgs_mds ; then
388 run_test 5b "Try to start a client with no MGS (should return errs)"
391 grep " $MOUNT " /etc/mtab && \
392 error false "unexpected entry in mtab before mount" && return 10
397 [ -d $MOUNT ] || mkdir -p $MOUNT
398 local oldfs="${FSNAME}"
399 FSNAME="wrong.${FSNAME}"
400 mount_client $MOUNT || :
402 grep " $MOUNT " /etc/mtab && \
403 error "$MOUNT entry in mtab after failed mount" && rc=11
405 cleanup_nocli || rc=$?
408 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
411 grep " $MOUNT " /etc/mtab && \
412 error false "unexpected entry in mtab before mount" && return 10
418 mount_client $MOUNT || rc=1
420 grep " $MOUNT " /etc/mtab && \
421 error "$MOUNT entry in mtab after unmount" && rc=11
424 run_test 5d "mount with ost down"
427 grep " $MOUNT " /etc/mtab && \
428 error false "unexpected entry in mtab before mount" && return 10
434 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
435 do_facet client "lctl set_param fail_loc=0x80000506"
436 mount_client $MOUNT || echo "mount failed (not fatal)"
438 grep " $MOUNT " /etc/mtab && \
439 error "$MOUNT entry in mtab after unmount" && rc=11
442 run_test 5e "delayed connect, don't crash (bug 10268)"
445 if combined_mgs_mds ; then
446 skip "combined mgs and mds"
450 grep " $MOUNT " /etc/mtab && \
451 error false "unexpected entry in mtab before mount" && return 10
455 [ -d $MOUNT ] || mkdir -p $MOUNT
456 mount_client $MOUNT &
458 echo client_mount pid is $pid
462 if ! ps -f -p $pid >/dev/null; then
465 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
466 error "mount returns $rc, expected to hang"
475 # mount should succeed after start mds
478 [ $rc -eq 0 ] || error "mount returned $rc"
479 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
483 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
488 mount_client ${MOUNT} || return 87
489 touch $DIR/a || return 86
492 run_test 6 "manual umount, then mount again"
497 cleanup_nocli || return $?
499 run_test 7 "manual umount, then cleanup"
504 check_mount2 || return 45
505 umount_client $MOUNT2
508 run_test 8 "double mount setup"
513 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
514 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
516 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
517 if [ "$CHECK_PTLDEBUG" ] && { \
518 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
519 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
520 echo "lnet.debug success"
522 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
525 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
526 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
527 echo "lnet.subsystem_debug success"
529 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
532 stop_ost || return $?
534 run_test 9 "test ptldebug and subsystem for mkfs"
542 do_facet $facet "test -b $dev" || rc=1
543 if [[ "$size" ]]; then
544 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
545 awk '($3 == "in") { print $1 }')
546 [[ $in = "1+0" ]] || rc=1
552 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
553 # But with new MDS stack we don't care about the mode of local objects
554 # anymore, so this test is removed. See bug 22944 for more details.
559 check_mount || return 41
562 echo "Remove mds config log"
563 if ! combined_mgs_mds ; then
567 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MGSDEV || return \$?" || return $?
569 if ! combined_mgs_mds ; then
574 start_mds && return 42
577 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
580 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
582 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
587 # check if current MDSSIZE is large enough
588 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
589 log "use MDSSIZE=$MDSSIZE"
591 # check if the global config has a large enough MDSSIZE
592 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
593 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
594 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
596 # check if the block device is large enough
597 [ -z "$OK" ] && $(is_blkdev $SINGLEMDS $MDSDEV $MIN) && OK=1 &&
598 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
600 # check if a loopback device has enough space for fs metadata (5%)
602 if [ -z "$OK" ]; then
603 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
604 awk '($1 != "Filesystem") {print $4}')
605 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
606 OK=1 && myMDSSIZE=$MIN && \
607 log "use file $MDSDEV with MIN=$MIN"
610 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
613 echo "mount mds with large journal..."
614 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
616 local opts="--mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
618 if combined_mgs_mds ; then
619 MDS_MKFS_OPTS="--mgs $opts"
621 MDS_MKFS_OPTS="--mgsnode=$MGSNID $opts"
625 echo "mount lustre system..."
627 check_mount || return 41
629 echo "check journal size..."
630 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
631 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
632 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
634 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
639 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
642 run_test 18 "check mkfs creates large journals"
645 start_mds || return 1
646 stop_mds -f || return 2
648 run_test 19a "start/stop MDS without OSTs"
651 start_ost || return 1
652 stop_ost -f || return 2
654 run_test 19b "start/stop OSTs without MDS"
657 # first format the ost/mdt
661 check_mount || return 43
663 remount_client ro $MOUNT || return 44
664 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
665 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
666 remount_client rw $MOUNT || return 47
668 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
669 MCNT=`grep -c $MOUNT /etc/mtab`
670 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
675 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
680 wait_osc_import_state mds ost FULL
684 run_test 21a "start mds before ost, stop ost first"
689 wait_osc_import_state mds ost FULL
693 run_test 21b "start ost before mds, stop mds first"
699 wait_osc_import_state mds ost2 FULL
703 #writeconf to remove all ost2 traces for subsequent tests
706 run_test 21c "start mds between two osts, stop mds last"
709 if combined_mgs_mds ; then
710 skip "need separate mgs device" && return 0
720 wait_osc_import_state mds ost2 FULL
726 #writeconf to remove all ost2 traces for subsequent tests
729 run_test 21d "start mgs then ost and then mds"
734 echo Client mount with ost in logs, but none running
736 # wait until mds connected to ost and open client connection
737 wait_osc_import_state mds ost FULL
740 # check_mount will block trying to contact ost
741 mcreate $DIR/$tfile || return 40
742 rm -f $DIR/$tfile || return 42
746 echo Client mount with a running ost
749 # if gss enabled, wait full time to let connection from
750 # mds to ost be established, due to the mismatch between
751 # initial connect timeout and gss context negotiation timeout.
752 # This perhaps could be remove after AT landed.
753 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
754 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
757 check_mount || return 41
762 run_test 22 "start a client before osts (should return errs)"
764 test_23a() { # was test_23
768 # force down client so that recovering mds waits for reconnect
769 local running=$(grep -c $MOUNT /proc/mounts) || true
770 if [ $running -ne 0 ]; then
771 echo "Stopping client $MOUNT (opts: -f)"
775 # enter recovery on mds
777 # try to start a new client
778 mount_client $MOUNT &
780 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
781 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
782 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
784 ps --ppid $MOUNT_LUSTRE_PID
785 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
786 kill -TERM $MOUNT_LUSTRE_PID
787 echo "waiting for mount to finish"
789 # we can not wait $MOUNT_PID because it is not a child of this shell
795 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
797 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
798 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
801 [ -z "$PID1" -a -z "$PID2" ] && break
802 echo "waiting for mount to finish ... "
803 WAIT=$(( WAIT + sleep))
805 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
806 error "MOUNT_PID $MOUNT_PID and "\
807 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
813 run_test 23a "interrupt client during recovery mount delay"
818 test_23b() { # was test_23
821 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
822 lctl set_param fail_loc=0x80000313
826 run_test 23b "Simulate -EINTR during mount"
828 fs2mds_HOST=$mds_HOST
829 fs2ost_HOST=$ost_HOST
833 echo "umount $MOUNT2 ..."
834 umount $MOUNT2 || true
835 echo "stopping fs2mds ..."
836 stop fs2mds -f || true
837 echo "stopping fs2ost ..."
838 stop fs2ost -f || true
842 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
844 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
845 is_blkdev $SINGLEMDS $MDSDEV && \
846 skip_env "mixed loopback and real device not working" && return
849 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
851 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
852 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
854 # test 8-char fsname as well
855 local FSNAME2=test1234
856 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
858 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
861 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
862 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
864 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
866 check_mount || return 2
867 # files written on 1 should not show up on 2
868 cp /etc/passwd $DIR/$tfile
870 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
873 cp /etc/passwd $MOUNT2/b || return 3
874 rm $MOUNT2/b || return 4
875 # 2 is actually mounted
876 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
878 facet_failover fs2mds
879 facet_failover fs2ost
882 # the MDS must remain up until last MDT
884 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
885 [ -z "$MDS" ] && error "No MDT" && return 8
887 cleanup_nocli || return 6
889 run_test 24a "Multiple MDTs on a single node"
892 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
894 if [ -z "$fs2mds_DEV" ]; then
895 local dev=${SINGLEMDS}_dev
897 is_blkdev $SINGLEMDS $MDSDEV && \
898 skip_env "mixed loopback and real device not working" && return
901 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
903 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
905 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
908 run_test 24b "Multiple MGSs on a single node (should return err)"
912 check_mount || return 2
913 local MODULES=$($LCTL modules | awk '{ print $2 }')
914 rmmod $MODULES 2>/dev/null || true
917 run_test 25 "Verify modules are referenced"
921 # we need modules before mount for sysctl, so make sure...
922 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
923 #define OBD_FAIL_MDS_FS_SETUP 0x135
924 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
925 start_mds && echo MDS started && return 1
926 lctl get_param -n devices
927 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
928 [ $DEVS -gt 0 ] && return 2
929 unload_modules_conf || return $?
931 run_test 26 "MDT startup failure cleans LOV (should return errs)"
937 local ORIG=$(do_facet $myfacet "$TEST")
938 if [ $# -gt 3 ]; then
944 echo "Setting $PARAM from $ORIG to $FINAL"
945 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
947 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
951 start_ost || return 1
952 start_mds || return 2
953 echo "Requeue thread should have started: "
954 ps -e | grep ll_cfg_requeue
955 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
958 run_test 27a "Reacquire MGS lock if OST started first"
963 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
965 facet_failover $SINGLEMDS
966 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
967 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
971 run_test 27b "Reacquire MGS lock after failover"
975 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
976 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
979 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
980 FINAL=$(($FINAL + 1))
981 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
982 umount_client $MOUNT || return 200
985 if [ $RESULT -ne $FINAL ]; then
986 echo "New config not seen: wanted $FINAL got $RESULT"
989 echo "New config success: got $RESULT"
991 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
994 run_test 28 "permanent parameter setting"
997 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
998 setup > /dev/null 2>&1
1002 local PARAM="$FSNAME-OST0001.osc.active"
1003 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1004 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1006 ACTV=$(lctl get_param -n $PROC_ACT)
1008 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1009 # also check ost_server_uuid status
1010 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1011 if [ -z "$RESULT" ]; then
1012 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1015 echo "Live client success: got $RESULT"
1019 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0001)
1020 mdtosc=${mdtosc/-MDT*/-MDT\*}
1021 local MPROC="osc.$mdtosc.active"
1026 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
1027 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1028 if [ $RESULT -eq $DEAC ]; then
1029 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
1033 if [ $WAIT -eq $MAX ]; then
1034 echo "MDT not deactivated: wanted $DEAC got $RESULT"
1037 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
1040 # quotacheck should not fail immediately after deactivate
1041 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1043 # test new client starts deactivated
1044 umount_client $MOUNT || return 200
1046 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1047 if [ -z "$RESULT" ]; then
1048 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1051 echo "New client success: got $RESULT"
1054 # quotacheck should not fail after umount/mount operation
1055 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1057 # make sure it reactivates
1058 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1060 umount_client $MOUNT
1063 #writeconf to remove all ost2 traces for subsequent tests
1066 run_test 29 "permanently remove an OST"
1071 echo Big config llog
1072 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1074 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1075 for i in ${LIST[@]}; do
1076 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1078 # make sure client restart still works
1079 umount_client $MOUNT
1080 mount_client $MOUNT || return 4
1081 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1084 echo Erase parameter setting
1085 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1086 umount_client $MOUNT
1087 mount_client $MOUNT || return 6
1089 echo "deleted (default) value=$FINAL, orig=$ORIG"
1090 # assumes this parameter started at the default value
1091 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1095 run_test 30a "Big config llog and conf_param deletion"
1100 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1101 # numerical part of it. Hopefully that's not already a failover address for
1103 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1104 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1105 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1106 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1107 echo "Using fake nid $NEW"
1109 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1110 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
1111 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1113 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1114 echo "should have 2 failover nids: $NIDCOUNT"
1115 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1116 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1117 umount_client $MOUNT
1118 mount_client $MOUNT || return 3
1120 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1122 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1123 echo "only 1 final nid should remain: $NIDCOUNT"
1124 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1128 run_test 30b "Remove failover nids"
1130 test_31() { # bug 10734
1131 # ipaddr must not exist
1132 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1135 run_test 31 "Connect to non-existent node (shouldn't crash)"
1137 # Use these start32/stop32 fn instead of t-f start/stop fn,
1138 # for local devices, to skip global facet vars init
1142 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1143 umount -d $@ ${MOUNT%/*}/${facet}
1152 mkdir -p ${MOUNT%/*}/${facet}
1154 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1155 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1157 if [ $RC -ne 0 ]; then
1158 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1159 echo "Start of ${device} of local ${facet} failed ${RC}"
1165 cleanup_nocli32 () {
1173 echo "Cleanup test_32 umount $MOUNT ..."
1174 umount -f $MOUNT || true
1175 echo "Cleanup local mds ost1 ..."
1177 combined_mgs_mds || start_mgs
1182 client_only && skip "client only testing" && return 0
1183 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1184 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1186 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1187 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1188 local tmpdir=$TMP/conf32a
1190 tar xjvf $DISK1_8 -C $tmpdir || \
1191 { skip_env "Cannot untar $DISK1_8" && return 0; }
1194 $LCTL set_param debug=$PTLDEBUG
1196 $TUNEFS $tmpdir/mds || error "tunefs failed"
1198 combined_mgs_mds || stop mgs
1200 # nids are wrong, so client wont work, but server should start
1201 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1202 trap cleanup_32 EXIT INT || return 3
1204 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1206 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1208 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1209 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1210 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1212 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1214 local NID=$($LCTL list_nids | head -1)
1216 echo "OSC changes should succeed:"
1217 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1218 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1221 echo "MDC changes should succeed:"
1222 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1223 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1226 echo "LOV changes should succeed:"
1227 $LCTL pool_new lustre.interop || return 11
1228 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1233 # mount a second time to make sure we didnt leave upgrade flag on
1235 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1237 combined_mgs_mds || stop mgs
1239 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1240 trap cleanup_32 EXIT INT || return 12
1244 rm -rf $tmpdir || true # true is only for TMP on NFS
1246 run_test 32a "Upgrade from 1.8 (not live)"
1249 client_only && skip "client only testing" && return 0
1250 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1251 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1253 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1254 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1255 local tmpdir=$TMP/conf32b
1257 tar xjvf $DISK1_8 -C $tmpdir || \
1258 { skip_env "Cannot untar $DISK1_8" && return ; }
1261 $LCTL set_param debug="config"
1262 local NEWNAME=lustre
1264 # writeconf will cause servers to register with their current nids
1265 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1266 combined_mgs_mds || stop mgs
1268 start32 mds1 $tmpdir/mds "-o loop" && \
1269 trap cleanup_32 EXIT INT || return 3
1271 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1273 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1275 $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 ||\
1276 error "tunefs failed"
1277 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1278 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1280 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1282 local NID=$($LCTL list_nids | head -1)
1284 echo "OSC changes should succeed:"
1285 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1286 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1289 echo "MDC changes should succeed:"
1290 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1291 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1294 echo "LOV changes should succeed:"
1295 $LCTL pool_new ${NEWNAME}.interop || return 11
1296 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1299 # MDT and OST should have registered with new nids, so we should have
1300 # a fully-functioning client
1301 echo "Check client and old fs contents"
1303 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1304 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1305 mount -t lustre $device $MOUNT || return 1
1307 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1308 local new=$((old + 5))
1309 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1310 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1312 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1317 rm -rf $tmpdir || true # true is only for TMP on NFS
1319 run_test 32b "Upgrade from 1.8 with writeconf"
1321 test_33a() { # bug 12333, was test_33
1323 local FSNAME2=test-123
1324 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1326 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1328 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1329 local dev=${SINGLEMDS}_dev
1330 local MDSDEV=${!dev}
1331 is_blkdev $SINGLEMDS $MDSDEV && \
1332 skip_env "mixed loopback and real device not working" && return
1335 combined_mgs_mds || mkfs_opts="$mkfs_opts --nomgs"
1337 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1338 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1339 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1340 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1342 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1343 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1344 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1346 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1349 cp /etc/hosts $MOUNT2/ || rc=3
1350 $LFS getstripe $MOUNT2/hosts
1355 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1356 cleanup_nocli || rc=6
1359 run_test 33a "Mount ost with a large index number"
1361 test_33b() { # was test_34
1364 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1365 # Drop lock cancelation reply during umount
1366 #define OBD_FAIL_LDLM_CANCEL 0x304
1367 do_facet client lctl set_param fail_loc=0x80000304
1368 #lctl set_param debug=-1
1369 umount_client $MOUNT
1372 run_test 33b "Drop cancel during umount"
1376 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1377 manual_umount_client
1379 do_facet client killall -USR1 multiop
1380 if [ $rc -eq 0 ]; then
1381 error "umount not fail!"
1386 run_test 34a "umount with opened file should be fail"
1391 touch $DIR/$tfile || return 1
1392 stop_mds --force || return 2
1394 manual_umount_client --force
1396 if [ $rc -ne 0 ]; then
1397 error "mtab after failed umount - rc $rc"
1403 run_test 34b "force umount with failed mds should be normal"
1407 touch $DIR/$tfile || return 1
1408 stop_ost --force || return 2
1410 manual_umount_client --force
1412 if [ $rc -ne 0 ]; then
1413 error "mtab after failed umount - rc $rc"
1419 run_test 34c "force umount with failed ost should be normal"
1421 test_35a() { # bug 12459
1424 DBG_SAVE="`lctl get_param -n debug`"
1425 lctl set_param debug="ha"
1427 log "Set up a fake failnode for the MDS"
1429 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1430 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1432 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1435 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1438 log "Stopping the MDT:"
1439 stop_mds || return 5
1441 df $MOUNT > /dev/null 2>&1 &
1443 log "Restarting the MDT:"
1444 start_mds || return 6
1445 log "Wait for df ($DFPID) ... "
1448 lctl set_param debug="$DBG_SAVE"
1450 # retrieve from the log the first server that the client tried to
1451 # contact after the connection loss
1452 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1453 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1454 /import_select_connection.*$device-mdc.* using connection/ {
1456 if (\\\$NF ~ /$FAKENID/)
1462 }" $TMP/lustre-log-$TESTNAME.log`
1463 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1465 # remove nid settings
1468 run_test 35a "Reconnect to the last active server first"
1470 test_35b() { # bug 18674
1471 remote_mds || { skip "local MDS" && return 0; }
1475 $LCTL set_param debug="ha"
1477 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1480 log "Set up a fake failnode for the MDS"
1482 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | \
1483 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1484 do_facet $SINGLEMDS "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1487 local at_max_saved=0
1488 # adaptive timeouts may prevent seeing the issue
1489 if at_is_enabled; then
1490 at_max_saved=$(at_max_get mds)
1491 at_max_set 0 mds client
1494 mkdir -p $MOUNT/testdir
1495 touch $MOUNT/testdir/test
1497 log "Injecting EBUSY on MDS"
1498 # Setting OBD_FAIL_MDS_RESEND=0x136
1499 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
1501 log "Stat on a test file"
1502 stat $MOUNT/testdir/test
1504 log "Stop injecting EBUSY on MDS"
1505 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
1506 rm -f $MOUNT/testdir/test
1509 # restore adaptive timeout
1510 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1512 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1514 # retrieve from the log if the client has ever tried to
1515 # contact the fake server after the loss of connection
1516 FAILCONN=`awk "BEGIN {ret = 0;}
1517 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1519 if (\\\$NF ~ /$FAKENID/) {
1524 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1526 [ "$FAILCONN" == "0" ] && \
1527 log "ERROR: The client reconnection has not been triggered" && \
1529 [ "$FAILCONN" == "2" ] && \
1530 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1534 # remove nid settings
1537 run_test 35b "Continue reconnection retries, if the active server is busy"
1540 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1542 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1543 { skip "remote OST" && return 0; }
1546 local FSNAME2=test1234
1547 local fs3ost_HOST=$ost_HOST
1548 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1550 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1552 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1553 is_blkdev $SINGLEMDS $MDSDEV && \
1554 skip_env "mixed loopback and real device not working" && return
1557 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1558 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1559 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1560 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1561 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1563 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1564 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1566 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1567 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1568 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1570 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1572 sleep 5 # until 11778 fixed
1574 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1576 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1577 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1578 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1579 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1580 DFTOTAL=`echo $STRING | cut -d, -f1`
1581 DFUSED=`echo $STRING | cut -d, -f2`
1582 DFAVAIL=`echo $STRING | cut -d, -f3`
1583 DFFREE=$(($DFTOTAL - $DFUSED))
1585 ALLOWANCE=$((64 * $OSTCOUNT))
1587 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1588 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1589 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1592 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1593 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1594 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1597 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1598 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1599 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1604 stop fs3ost -f || return 200
1605 stop fs2ost -f || return 201
1606 stop fs2mds -f || return 202
1607 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1608 unload_modules_conf || return 203
1611 run_test 36 "df report consistency on OSTs with different block size"
1614 local mntpt=$(facet_mntpt $SINGLEMDS)
1615 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
1616 local mdsdev_sym="$TMP/sym_mdt.img"
1618 echo "MDS : $mdsdev"
1619 echo "SYMLINK : $mdsdev_sym"
1620 do_facet $SINGLEMDS rm -f $mdsdev_sym
1622 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
1624 echo "mount symlink device - $mdsdev_sym"
1627 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $MDS_MOUNT_OPTS $mdsdev_sym $mntpt 2>&1 )
1630 echo mount_op=$mount_op
1632 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
1634 if $(echo $mount_op | grep -q "unable to set tunable"); then
1635 error "set tunables failed for symlink device"
1638 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
1642 run_test 37 "verify set tunables works for symlink device"
1644 test_38() { # bug 14222
1649 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1650 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1652 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1653 error "copying $SRC to $DIR/$tdir"
1655 umount_client $MOUNT
1657 log "rename lov_objid file on MDS"
1658 rm -f $TMP/lov_objid.orig
1660 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1661 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1662 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1664 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1665 # check create in mds_lov_connect
1669 [ $V ] && log "verifying $DIR/$tdir/$f"
1670 diff -q $f $DIR/$tdir/$f || ERROR=y
1672 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1673 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1674 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1676 # check it's updates in sync
1677 umount_client $MOUNT
1680 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1681 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1682 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1687 [ $V ] && log "verifying $DIR/$tdir/$f"
1688 diff -q $f $DIR/$tdir/$f || ERROR=y
1690 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1691 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1692 umount_client $MOUNT
1694 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1696 log "files compared the same"
1699 run_test 38 "MDS recreates missing lov_objid file from OST data"
1705 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1706 error "memory leak detected" || true
1708 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1710 test_40() { # bug 15759
1712 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1713 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
1717 run_test 40 "race during service thread startup"
1719 test_41a() { #bug 14134
1720 echo $MDS_MOUNT_OPTS | grep "loop" && skip " loop devices does not work with nosvc option" && return
1723 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1725 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1726 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1727 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1729 mount_client $MOUNT || return 1
1732 echo "blah blah" > $MOUNT/$tfile
1735 umount_client $MOUNT
1736 stop ost1 -f || return 201
1737 stop_mds -f || return 202
1738 stop_mds -f || return 203
1739 unload_modules_conf || return 204
1742 run_test 41a "mount mds with --nosvc and --nomgs"
1745 echo $MDS_MOUNT_OPTS | grep "loop" && skip " loop devices does not work with nosvc option" && return
1749 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1751 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1753 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1755 mount_client $MOUNT || return 1
1758 echo "blah blah" > $MOUNT/$tfile
1759 cat $MOUNT/$tfile || return 200
1761 umount_client $MOUNT
1762 stop_ost || return 201
1763 stop_mds -f || return 202
1764 stop_mds -f || return 203
1768 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
1769 test_42() { #bug 14693
1771 check_mount || return 2
1772 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1773 umount_client $MOUNT
1774 mount_client $MOUNT || return 1
1778 run_test 42 "invalid config param should not prevent client from mounting"
1781 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1783 chmod ugo+x $DIR || error "chmod 0 failed"
1785 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1786 "$FSNAME.mdt.root_squash" \
1789 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1790 "$FSNAME.mdt.nosquash_nids" \
1794 # create set of test files
1796 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1797 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1798 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1800 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1801 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1803 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1804 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1805 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1808 # check root_squash:
1809 # set root squash UID:GID to RUNAS_ID
1810 # root should be able to access only files owned by RUNAS_ID
1813 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1814 "$FSNAME.mdt.root_squash" \
1815 "$RUNAS_ID:$RUNAS_ID"
1817 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1818 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1819 error "$ST: root read permission is denied"
1820 echo "$ST: root read permission is granted - ok"
1823 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1824 error "$ST: root write permission is denied"
1825 echo "$ST: root write permission is granted - ok"
1827 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1828 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1829 error "$ST: root read permission is granted"
1830 echo "$ST: root read permission is denied - ok"
1833 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1834 error "$ST: root write permission is granted"
1835 echo "$ST: root write permission is denied - ok"
1837 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1838 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1839 error "$ST: root unlink permission is granted"
1840 echo "$ST: root unlink permission is denied - ok"
1842 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1843 error "$ST: root create permission is granted"
1844 echo "$ST: root create permission is denied - ok"
1847 # check nosquash_nids:
1848 # put client's NID into nosquash_nids list,
1849 # root should be able to access root file after that
1851 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1852 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1853 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1855 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1856 "$FSNAME-MDTall.mdt.nosquash_nids" \
1859 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1860 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1861 error "$ST: root read permission is denied"
1862 echo "$ST: root read permission is granted - ok"
1865 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1866 error "$ST: root write permission is denied"
1867 echo "$ST: root write permission is granted - ok"
1869 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1870 rm $DIR/$tdir-rootdir/tfile-1 || \
1871 error "$ST: root unlink permission is denied"
1872 echo "$ST: root unlink permission is granted - ok"
1873 touch $DIR/$tdir-rootdir/tfile-2 || \
1874 error "$ST: root create permission is denied"
1875 echo "$ST: root create permission is granted - ok"
1879 run_test 43 "check root_squash and nosquash_nids"
1881 umount_client $MOUNT
1886 check_mount || return 2
1887 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1889 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1890 for VAL in $UUIDS; do
1891 NID=$(echo $VAL | cut -d= -f1)
1892 CLUUID=$(echo $VAL | cut -d= -f2)
1893 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1895 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1899 run_test 44 "mounted client proc entry exists"
1903 check_mount || return 2
1908 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1909 do_facet client "lctl set_param fail_loc=0x50f"
1912 manual_umount_client --force || return 3
1913 do_facet client "lctl set_param fail_loc=0x0"
1915 mount_client $MOUNT || return 4
1919 run_test 45 "long unlink handling in ptlrpcd"
1926 umount_client $MOUNT2 || rc=$?
1927 umount_client $MOUNT || rc=$?
1928 while [ $count -gt 0 ]; do
1929 stop ost${count} -f || rc=$?
1933 cleanup_nocli || rc=$?
1934 #writeconf to remove all ost2 traces for subsequent tests
1940 echo "Testing with $OSTCOUNT OSTs"
1942 start_mds || return 1
1943 #first client should see only one ost
1944 start_ost || return 2
1945 wait_osc_import_state mds ost FULL
1947 mount_client $MOUNT || return 3
1948 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1951 for (( i=2; i<=$OSTCOUNT; i++ )); do
1952 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1955 # wait until osts in sync
1956 for (( i=2; i<=$OSTCOUNT; i++ )); do
1957 wait_osc_import_state mds ost$i FULL
1961 #second client see all ost's
1963 mount_client $MOUNT2 || return 8
1964 $LFS setstripe $MOUNT2 -c -1 || return 9
1965 $LFS getstripe $MOUNT2 || return 10
1967 echo "ok" > $MOUNT2/widestripe
1968 $LFS getstripe $MOUNT2/widestripe || return 11
1969 # fill acl buffer for avoid expand lsm to them
1970 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1971 setfacl -m $acl $MOUNT2/widestripe
1975 stat $MOUNT/widestripe || return 12
1977 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1980 run_test 46a "handle ost additional - wide striped file"
1985 check_mount || return 2
1986 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1990 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1991 if echo $ns | grep "MDT[[:digit:]]*"; then
1994 lrs=$(echo $ns | sed 's/.*lru_size=//')
1995 lru_size[count]=$lrs
2000 facet_failover $SINGLEMDS
2001 client_up || return 3
2004 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2005 if echo $ns | grep "MDT[[:digit:]]*"; then
2008 lrs=$(echo $ns | sed 's/.*lru_size=//')
2009 if ! test "$lrs" -eq "${lru_size[count]}"; then
2010 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2011 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2019 run_test 47 "server restart does not make client loss lru_resize settings"
2024 # reformat after this test is needed - if test will failed
2025 # we will have unkillable file at FS
2029 test_48() { # bug 17636
2032 check_mount || return 2
2034 $LFS setstripe $MOUNT -c -1 || return 9
2035 $LFS getstripe $MOUNT || return 10
2037 echo "ok" > $MOUNT/widestripe
2038 $LFS getstripe $MOUNT/widestripe || return 11
2040 trap cleanup_48 EXIT ERR
2042 # fill acl buffer for avoid expand lsm to them
2043 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2044 setfacl -m $acl $MOUNT/widestripe
2047 stat $MOUNT/widestripe || return 12
2052 run_test 48 "too many acls on file"
2054 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2055 test_49() { # bug 17710
2056 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
2057 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
2058 local LOCAL_TIMEOUT=20
2061 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
2065 check_mount || return 1
2067 echo "check ldlm_timout..."
2068 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2069 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2070 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2072 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2073 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2076 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2077 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2080 umount_client $MOUNT
2081 stop_ost || return 2
2082 stop_mds || return 3
2084 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"
2088 check_mount || return 7
2090 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2091 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2092 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2094 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2095 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2098 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2099 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2102 cleanup || return $?
2104 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
2105 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
2107 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
2110 # Test both statfs and lfs df and fail if either one fails
2111 multiop_bg_pause $1 f_
2114 killall -USR1 multiop
2115 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2116 wait $PID || { RC1=$?; log "multiop return error "; }
2123 if [ $RC2 -eq 0 ]; then
2125 log "lazystatfs df failed"
2129 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2135 lctl set_param llite.$FSNAME-*.lazystatfs=1
2138 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2140 cleanup || return $?
2142 run_test 50a "lazystatfs all servers available =========================="
2146 lctl set_param llite.$FSNAME-*.lazystatfs=1
2149 # Wait for client to detect down OST
2150 stop_ost || error "Unable to stop OST1"
2151 wait_osc_import_state mds ost DISCONN
2153 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2155 umount_client $MOUNT || error "Unable to unmount client"
2156 stop_mds || error "Unable to stop MDS"
2158 run_test 50b "lazystatfs all servers down =========================="
2161 start_mds || error "Unable to start MDS"
2162 start_ost || error "Unable to start OST1"
2163 start_ost2 || error "Unable to start OST2"
2164 mount_client $MOUNT || error "Unable to mount client"
2165 lctl set_param llite.$FSNAME-*.lazystatfs=1
2168 # Wait for client to detect down OST
2169 stop_ost || error "Unable to stop OST1"
2170 wait_osc_import_state mds ost DISCONN
2171 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2173 umount_client $MOUNT || error "Unable to unmount client"
2174 stop_ost2 || error "Unable to stop OST2"
2175 stop_mds || error "Unable to stop MDS"
2176 #writeconf to remove all ost2 traces for subsequent tests
2179 run_test 50c "lazystatfs one server down =========================="
2182 start_mds || error "Unable to start MDS"
2183 start_ost || error "Unable to start OST1"
2184 start_ost2 || error "Unable to start OST2"
2185 mount_client $MOUNT || error "Unable to mount client"
2186 lctl set_param llite.$FSNAME-*.lazystatfs=1
2189 # Issue the statfs during the window where the client still
2190 # belives the OST to be available but it is in fact down.
2191 # No failure just a statfs which hangs for a timeout interval.
2192 stop_ost || error "Unable to stop OST1"
2193 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2195 umount_client $MOUNT || error "Unable to unmount client"
2196 stop_ost2 || error "Unable to stop OST2"
2197 stop_mds || error "Unable to stop MDS"
2198 #writeconf to remove all ost2 traces for subsequent tests
2201 run_test 50d "lazystatfs client/server conn race =========================="
2208 start_mds || return 1
2209 #first client should see only one ost
2210 start_ost || return 2
2211 wait_osc_import_state mds ost FULL
2213 # Wait for client to detect down OST
2214 stop_ost || error "Unable to stop OST1"
2215 wait_osc_import_state mds ost DISCONN
2217 mount_client $MOUNT || error "Unable to mount client"
2218 lctl set_param llite.$FSNAME-*.lazystatfs=0
2220 multiop_bg_pause $MOUNT _f
2224 if [ $RC1 -ne 0 ]; then
2225 log "multiop failed $RC1"
2228 sleep $(( $TIMEOUT+1 ))
2230 [ $? -ne 0 ] && error "process isn't sleep"
2231 start_ost || error "Unable to start OST1"
2232 wait $pid || error "statfs failed"
2235 umount_client $MOUNT || error "Unable to unmount client"
2236 stop_ost || error "Unable to stop OST1"
2237 stop_mds || error "Unable to stop MDS"
2239 run_test 50e "normal statfs all servers down =========================="
2244 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2246 start_mds || error "Unable to start mds"
2247 #first client should see only one ost
2248 start_ost || error "Unable to start OST1"
2249 wait_osc_import_state mds ost FULL
2251 start_ost2 || error "Unable to start OST2"
2252 wait_osc_import_state mds ost2 FULL
2254 # Wait for client to detect down OST
2255 stop_ost2 || error "Unable to stop OST2"
2257 wait_osc_import_state mds ost2 DISCONN
2258 mount_client $MOUNT || error "Unable to mount client"
2259 lctl set_param llite.$FSNAME-*.lazystatfs=0
2261 multiop_bg_pause $MOUNT _f
2265 if [ $RC1 -ne 0 ]; then
2266 log "lazystatfs multiop failed $RC1"
2269 sleep $(( $TIMEOUT+1 ))
2271 [ $? -ne 0 ] && error "process isn't sleep"
2272 start_ost2 || error "Unable to start OST2"
2273 wait $pid || error "statfs failed"
2274 stop_ost2 || error "Unable to stop OST2"
2277 umount_client $MOUNT || error "Unable to unmount client"
2278 stop_ost || error "Unable to stop OST1"
2279 stop_mds || error "Unable to stop MDS"
2280 #writeconf to remove all ost2 traces for subsequent tests
2283 run_test 50f "normal statfs one server in down =========================="
2286 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2288 start_ost2 || error "Unable to start OST2"
2289 wait_osc_import_state mds ost2 FULL
2290 wait_osc_import_state client ost2 FULL
2292 local PARAM="${FSNAME}-OST0001.osc.active"
2294 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2295 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2297 umount_client $MOUNT || error "Unable to unmount client"
2298 mount_client $MOUNT || error "Unable to mount client"
2299 # This df should not cause a panic
2302 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2304 umount_client $MOUNT || error "Unable to unmount client"
2305 stop_ost2 || error "Unable to stop OST2"
2306 stop_ost || error "Unable to stop OST1"
2307 stop_mds || error "Unable to stop MDS"
2308 #writeconf to remove all ost2 traces for subsequent tests
2311 run_test 50g "deactivated OST should not cause panic====================="
2314 local LOCAL_TIMEOUT=20
2318 check_mount || return 1
2321 $LFS setstripe -c -1 $MOUNT/d1
2322 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2323 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2324 touch $MOUNT/d1/f1 &
2327 start_ost2 || return 2
2329 stop_ost2 || return 3
2331 #writeconf to remove all ost2 traces for subsequent tests
2334 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2343 do_node $node mkdir -p $dest
2344 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2346 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2347 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2348 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2350 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2351 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2361 local backup2=${TMP}/backup2
2363 do_node $node mkdir -p $backup2
2364 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2366 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2367 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2368 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2370 do_node $node "diff -rq $backup $backup2"
2371 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2373 local xattrs2=${TMP}/xattrs2
2374 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2375 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2377 do_node $node "diff $xattrs $xattrs2"
2378 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2380 do_node $node "rm -rf $backup2 $xattrs2"
2381 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2386 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2388 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2390 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2393 local ost1mnt=${MOUNT%/*}/ost1
2394 local ost1node=$(facet_active_host ost1)
2395 local ost1tmp=$TMP/conf52
2398 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2399 touch $TMP/modified_first
2400 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2401 local mtime=$(stat -c %Y $TMP/modified_first)
2402 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2404 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2407 $LFS setstripe $DIR/$tdir -c -1 -s 1M
2408 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2410 for (( i=0; i < nrfiles; i++ )); do
2411 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2412 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2418 echo backup files to $TMP/files
2419 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2420 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2421 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2423 umount_client $MOUNT
2424 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2426 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2428 echo mount ost1 as ldiskfs
2429 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2430 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2433 echo backup objects to $ost1tmp/objects
2434 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2435 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2436 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2437 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2439 # move objects to lost+found
2440 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2441 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2444 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2445 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2447 # compare restored objects against saved ones
2448 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2449 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2451 do_node $ost1node "umount $ost1_dev"
2452 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2455 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2457 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2460 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2461 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2463 rm -rf $TMP/files $TMP/file_xattrs
2464 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2465 do_node $ost1node "rm -rf $ost1tmp"
2466 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2469 run_test 52 "check recovering objects from lost+found"
2471 # Checks threads_min/max/started for some service
2473 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2474 # parameter pattern prefix like 'ost.*.ost'.
2486 local msg="Insane $modname thread counts"
2490 check_mount || return 41
2492 # We need to expand $parampat, but it may match multiple parameters, so
2493 # we'll pick the first one
2494 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2495 error "Couldn't expand ${parampat}.threads_min parameter name"
2499 # Remove the .threads_min part
2500 paramp=${paramp%.threads_min}
2502 # Check for sanity in defaults
2503 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2504 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2505 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2506 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2507 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
2509 # Check that we can change min/max
2510 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + 1))"
2511 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 1))"
2512 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2513 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2514 lassert 25 "$msg" '(($tmin2 == ($tmin + 1) && $tmax2 == ($tmax -1)))' || return $?
2516 # Check that we can set min/max to the same value
2517 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2518 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2519 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2520 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2521 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2523 # Check that we can't set max < min
2524 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2525 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2526 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2527 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
2529 # We need to ensure that we get the module options desired; to do this
2530 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2531 LOAD_MODULES_REMOTE=true
2534 setmodopts -a $modname "$opts" oldvalue
2538 check_mount || return 41
2540 # Restore previous setting of MODOPTS_*
2541 setmodopts $modname "$oldvalue"
2543 # Check that $opts took
2544 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2545 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2546 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2547 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2550 # Workaround a YALA bug where YALA expects that modules will remain
2551 # loaded on the servers
2552 LOAD_MODULES_REMOTE=false
2559 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2561 run_test 53a "check OSS thread count params"
2564 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2566 run_test 53b "check MDT thread count params"
2571 local partial_arg=""
2572 local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
2574 # Run in partial (fast) mode if the size
2575 # of a partition > 10 GB
2576 [ $size -gt 10 ] && partial_arg="-p"
2578 llverfs $partial_arg $dir
2582 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
2583 [ $? -eq 0 ] || error "llverdev failed!"
2586 run_test 54a "llverdev"
2591 [ $? -eq 0 ] || error "llverfs failed!"
2594 run_test 54b "llverfs"
2598 local max_ost_index=$1
2599 echo -n $(((max_ost_index + 1) * 8))
2603 local mdsdev=$(mdsdevname 1)
2604 local ostdev=$(ostdevname 1)
2605 local saved_opts=$OST_MKFS_OPTS
2607 for i in 0 1023 2048
2609 OST_MKFS_OPTS="$saved_opts --index $i"
2617 echo checking size of lov_objid for ost index $i
2618 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2619 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2620 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2622 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2627 OST_MKFS_OPTS=$saved_opts
2630 run_test 55 "check lov_objid size"
2633 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2634 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2635 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2639 start_ost2 || error "Unable to start second ost"
2640 mount_client $MOUNT || error "Unable to mount client"
2643 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
2647 run_test 56 "check big indexes"
2649 test_57a() { # bug 22656
2650 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2652 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2654 start_ost && error "OST registration from failnode should fail"
2657 run_test 57a "initial registration from failnode should fail (should return errs)"
2660 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2662 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
2664 start_ost || error "OST registration from servicenode should not fail"
2667 run_test 57b "initial registration from servicenode should not fail"
2670 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2673 test_58() { # bug 22658
2674 [ "$FSTYPE" != "ldiskfs" ] && skip "not supported for $FSTYPE" && return
2677 createmany -o $DIR/$tdir/$tfile-%d 100
2678 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
2679 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
2680 do_facet mds "lctl set_param fail_loc=0x601"
2681 unlinkmany $DIR/$tdir/$tfile-%d 100
2683 local MNTDIR=$(facet_mntpt mds)
2684 # remove all files from the OBJECTS dir
2685 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
2686 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
2687 do_facet mds "umount $MNTDIR"
2688 # restart MDS with missing llog files
2690 do_facet mds "lctl set_param fail_loc=0"
2693 run_test 58 "missing llog files must not prevent MDT from mounting"
2696 start_mgsmds >> /dev/null
2697 local C1=$(count_osts)
2698 if [ $C1 -eq 0 ]; then
2699 start_ost >> /dev/null
2703 echo "original ost count: $C1 (expect > 0)"
2704 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2705 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2706 local C2=$(count_osts)
2707 echo "after mdt writeconf count: $C2 (expect 0)"
2708 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2709 echo "OST start without writeconf should fail:"
2710 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2711 echo "OST start with writeconf should succeed:"
2712 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2713 local C3=$(count_osts)
2714 echo "after ost writeconf count: $C3 (expect 1)"
2715 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2716 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2717 local C4=$(count_osts)
2718 echo "after ost2 writeconf count: $C4 (expect 2)"
2719 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2720 stop_ost2 >> /dev/null
2721 cleanup_nocli >> /dev/null
2722 #writeconf to remove all ost2 traces for subsequent tests
2725 run_test 59 "writeconf mount option"
2727 if ! combined_mgs_mds ; then
2733 complete $(basename $0) $SECONDS