3 # FIXME - there is no reason to use all of these different
4 # return codes, espcially when most of them are mapped to something
5 # else anyway. The combination of test number and return code
6 # figure out what failed.
12 # bug number for skipped test:
14 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
15 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
17 if [ "$FAILURE_MODE" = "HARD" ]; then
18 CONFIG_EXCEPTIONS="24a " && \
19 echo "Except the tests: $CONFIG_EXCEPTIONS for FAILURE_MODE=$FAILURE_MODE, bug 23573" && \
20 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
24 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
26 PTLDEBUG=${PTLDEBUG:--1}
28 LUSTRE=${LUSTRE:-`dirname $0`/..}
29 RLUSTRE=${RLUSTRE:-$LUSTRE}
31 . $LUSTRE/tests/test-framework.sh
34 # use small MDS + OST size to speed formatting time
35 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
38 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
40 if ! combined_mgs_mds; then
41 # bug number for skipped test: 23954
42 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
45 # STORED_MDSSIZE is used in test_18
46 if [ -n "$MDSSIZE" ]; then
47 STORED_MDSSIZE=$MDSSIZE
50 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
51 for facet in MGS MDS OST; do
52 opts=${facet}_MKFS_OPTS
53 if [[ ${!opts} != *lazy_itable_init* ]]; then
54 eval SAVED_${facet}_MKFS_OPTS=\"${!opts}\"
55 if [[ ${!opts} != *mkfsoptions* ]]; then
56 eval ${facet}_MKFS_OPTS=\"${!opts} --mkfsoptions='\\\"-E lazy_itable_init\\\"'\"
58 val=${!opts//--mkfsoptions=\\\"/--mkfsoptions=\\\"-E lazy_itable_init }
59 eval ${facet}_MKFS_OPTS='${val}'
67 require_dsh_mds || exit 0
68 require_dsh_ost || exit 0
70 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
85 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
86 do_facet ${facet} "$TUNEFS --quiet --writeconf $dev" ||
87 { echo "tunefs failed, reformatting instead" && reformat_and_config && return 1; }
94 # if writeconf fails anywhere, we reformat everything
95 writeconf1 mds `mdsdevname 1` || return 0
96 writeconf1 ost1 `ostdevname 1` || return 0
97 writeconf1 ost2 `ostdevname 2` || return 0
101 # The MGS must be started before the OSTs for a new fs, so start
102 # and stop to generate the startup logs.
105 wait_osc_import_state mds ost FULL
110 reformat_and_config() {
112 if ! combined_mgs_mds ; then
120 start mgs $MGSDEV $MGS_MOUNT_OPTS
124 local facet=$SINGLEMDS
125 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
126 local num=$(echo $facet | tr -d "mds")
127 local dev=$(mdsdevname $num)
128 echo "start mds service on `facet_active_host $facet`"
129 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
133 if ! combined_mgs_mds ; then
140 echo "stop mds service on `facet_active_host $SINGLEMDS`"
141 # These tests all use non-failover stop
142 stop $SINGLEMDS -f || return 97
146 echo "stop mgs service on `facet_active_host mgs`"
147 # These tests all use non-failover stop
148 stop mgs -f || return 97
152 echo "start ost1 service on `facet_active_host ost1`"
153 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
157 echo "stop ost1 service on `facet_active_host ost1`"
158 # These tests all use non-failover stop
159 stop ost1 -f || return 98
163 echo "start ost2 service on `facet_active_host ost2`"
164 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
168 echo "stop ost2 service on `facet_active_host ost2`"
169 # These tests all use non-failover stop
170 stop ost2 -f || return 93
175 echo "mount $FSNAME on ${MOUNTPATH}....."
176 zconf_mount `hostname` $MOUNTPATH || return 96
180 local mountopt="-o remount,$1"
182 echo "remount '$1' lustre on ${MOUNTPATH}....."
183 zconf_mount `hostname` $MOUNTPATH "$mountopt" || return 96
188 echo "umount lustre on ${MOUNTPATH}....."
189 zconf_umount `hostname` $MOUNTPATH || return 97
192 manual_umount_client(){
195 echo "manual umount lustre on ${MOUNT}...."
196 do_facet client "umount -d ${FORCE} $MOUNT"
202 start_mds || error "MDT start failed"
203 start_ost || error "OST start failed"
204 mount_client $MOUNT || error "client start failed"
205 client_up || error "client_up failed"
209 if ! combined_mgs_mds ; then
218 unload_modules_conf () {
219 if combined_mgs_mds || ! local_mode; then
220 unload_modules || return 1
225 stop_ost || return 202
226 stop_mds || return 201
227 unload_modules_conf || return 203
231 umount_client $MOUNT || return 200
232 cleanup_nocli || return $?
236 do_facet client "cp /etc/passwd $DIR/a" || return 71
237 do_facet client "rm $DIR/a" || return 72
238 # make sure lustre is actually mounted (touch will block,
239 # but grep won't, so do it after)
240 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
241 echo "setup single mount lustre success"
245 do_facet client "touch $DIR/a" || return 71
246 do_facet client "rm $DIR/a" || return 72
247 do_facet client "touch $DIR2/a" || return 73
248 do_facet client "rm $DIR2/a" || return 74
249 echo "setup double mount lustre success"
254 if [ "$ONLY" == "setup" ]; then
259 if [ "$ONLY" == "cleanup" ]; then
266 #create single point mountpoint
272 check_mount || return 41
275 run_test 0 "single mount setup"
278 start_mds || error "MDT start failed"
280 echo "start ost second time..."
281 start_ost && error "2nd OST start should fail"
282 mount_client $MOUNT || error "client start failed"
283 check_mount || return 42
286 run_test 1 "start up ost twice (should return errors)"
290 echo "start mds second time.."
291 start_mds && error "2nd MDT start should fail"
294 check_mount || return 43
297 run_test 2 "start up mds twice (should return err)"
301 #mount.lustre returns an error if already in mtab
302 mount_client $MOUNT && error "2nd client mount should fail"
303 check_mount || return 44
306 run_test 3 "mount client twice (should return err)"
310 touch $DIR/$tfile || return 85
314 # ok for ost to fail shutdown
315 if [ 202 -ne $eno ]; then
320 run_test 4 "force cleanup ost, then cleanup"
322 test_5a() { # was test_5
324 touch $DIR/$tfile || return 1
325 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
327 stop_mds -f || return 2
329 # cleanup may return an error from the failed
330 # disconnects; for now I'll consider this successful
331 # if all the modules have unloaded.
335 echo "killing umount"
336 kill -TERM $UMOUNT_PID
337 echo "waiting for umount to finish"
339 if grep " $MOUNT " /proc/mounts; then
340 echo "test 5: /proc/mounts after failed umount"
344 echo "killing umount"
345 kill -TERM $UMOUNT_PID
346 echo "waiting for umount to finish"
348 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
352 # stop_mds is a no-op here, and should not fail
353 cleanup_nocli || return $?
354 # df may have lingering entry
356 # mtab may have lingering entry
360 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
362 grep -q $MOUNT" " /etc/mtab || break
363 echo "Waiting /etc/mtab updated ... "
364 WAIT=$(( WAIT + sleep))
366 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
367 echo "/etc/mtab updated in $WAIT secs"
369 run_test 5a "force cleanup mds, then cleanup"
377 grep " $MOUNT " /etc/mtab && \
378 error false "unexpected entry in mtab before mount" && return 10
382 if ! combined_mgs_mds ; then
383 trap cleanup_5b EXIT ERR
388 [ -d $MOUNT ] || mkdir -p $MOUNT
389 mount_client $MOUNT && rc=1
390 grep " $MOUNT " /etc/mtab && \
391 error "$MOUNT entry in mtab after failed mount" && rc=11
393 # stop_mds is a no-op here, and should not fail
394 cleanup_nocli || rc=$?
395 if ! combined_mgs_mds ; then
400 run_test 5b "Try to start a client with no MGS (should return errs)"
403 grep " $MOUNT " /etc/mtab && \
404 error false "unexpected entry in mtab before mount" && return 10
409 [ -d $MOUNT ] || mkdir -p $MOUNT
410 local oldfs="${FSNAME}"
411 FSNAME="wrong.${FSNAME}"
412 mount_client $MOUNT || :
414 grep " $MOUNT " /etc/mtab && \
415 error "$MOUNT entry in mtab after failed mount" && rc=11
417 cleanup_nocli || rc=$?
420 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
423 grep " $MOUNT " /etc/mtab && \
424 error false "unexpected entry in mtab before mount" && return 10
430 mount_client $MOUNT || rc=1
432 grep " $MOUNT " /etc/mtab && \
433 error "$MOUNT entry in mtab after unmount" && rc=11
436 run_test 5d "mount with ost down"
439 grep " $MOUNT " /etc/mtab && \
440 error false "unexpected entry in mtab before mount" && return 10
446 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
447 do_facet client "lctl set_param fail_loc=0x80000506"
448 mount_client $MOUNT || echo "mount failed (not fatal)"
450 grep " $MOUNT " /etc/mtab && \
451 error "$MOUNT entry in mtab after unmount" && rc=11
454 run_test 5e "delayed connect, don't crash (bug 10268)"
457 if combined_mgs_mds ; then
458 skip "combined mgs and mds"
462 grep " $MOUNT " /etc/mtab && \
463 error false "unexpected entry in mtab before mount" && return 10
467 [ -d $MOUNT ] || mkdir -p $MOUNT
468 mount_client $MOUNT &
470 echo client_mount pid is $pid
474 if ! ps -f -p $pid >/dev/null; then
477 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
478 error "mount returns $rc, expected to hang"
487 # mount should succeed after start mds
490 [ $rc -eq 0 ] || error "mount returned $rc"
491 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
495 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
500 mount_client ${MOUNT} || return 87
501 touch $DIR/a || return 86
504 run_test 6 "manual umount, then mount again"
509 cleanup_nocli || return $?
511 run_test 7 "manual umount, then cleanup"
516 check_mount2 || return 45
517 umount_client $MOUNT2
520 run_test 8 "double mount setup"
525 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
526 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
528 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
529 if [ "$CHECK_PTLDEBUG" ] && { \
530 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
531 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
532 echo "lnet.debug success"
534 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
537 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
538 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
539 echo "lnet.subsystem_debug success"
541 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
544 stop_ost || return $?
546 run_test 9 "test ptldebug and subsystem for mkfs"
554 do_facet $facet "test -b $dev" || rc=1
555 if [[ "$size" ]]; then
556 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
557 awk '($3 == "in") { print $1 }')
558 [[ $in = "1+0" ]] || rc=1
564 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
565 # But with new MDS stack we don't care about the mode of local objects
566 # anymore, so this test is removed. See bug 22944 for more details.
571 check_mount || return 41
574 echo "Remove mds config log"
575 if ! combined_mgs_mds ; then
579 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MGSDEV || return \$?" || return $?
581 if ! combined_mgs_mds ; then
586 start_mds && return 42
589 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
592 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
594 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
599 # check if current MDSSIZE is large enough
600 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
601 log "use MDSSIZE=$MDSSIZE"
603 # check if the global config has a large enough MDSSIZE
604 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
605 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
606 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
608 # check if the block device is large enough
609 [ -z "$OK" ] && $(is_blkdev $SINGLEMDS $MDSDEV $MIN) && OK=1 &&
610 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
612 # check if a loopback device has enough space for fs metadata (5%)
614 if [ -z "$OK" ]; then
615 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
616 awk '($1 != "Filesystem") {print $4}')
617 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
618 OK=1 && myMDSSIZE=$MIN && \
619 log "use file $MDSDEV with MIN=$MIN"
622 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
625 echo "mount mds with large journal..."
626 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
628 local opts="--mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
630 if combined_mgs_mds ; then
631 MDS_MKFS_OPTS="--mgs $opts"
633 MDS_MKFS_OPTS="--mgsnode=$MGSNID $opts"
637 echo "mount lustre system..."
639 check_mount || return 41
641 echo "check journal size..."
642 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
643 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
644 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
646 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
651 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
654 run_test 18 "check mkfs creates large journals"
657 start_mds || return 1
658 stop_mds -f || return 2
660 run_test 19a "start/stop MDS without OSTs"
663 start_ost || return 1
664 stop_ost -f || return 2
666 run_test 19b "start/stop OSTs without MDS"
669 # first format the ost/mdt
673 check_mount || return 43
675 remount_client ro $MOUNT || return 44
676 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
677 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
678 remount_client rw $MOUNT || return 47
680 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
681 MCNT=`grep -c $MOUNT /etc/mtab`
682 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
687 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
692 wait_osc_import_state mds ost FULL
696 run_test 21a "start mds before ost, stop ost first"
701 wait_osc_import_state mds ost FULL
705 run_test 21b "start ost before mds, stop mds first"
711 wait_osc_import_state mds ost2 FULL
715 #writeconf to remove all ost2 traces for subsequent tests
718 run_test 21c "start mds between two osts, stop mds last"
721 if combined_mgs_mds ; then
722 skip "need separate mgs device" && return 0
732 wait_osc_import_state mds ost2 FULL
738 #writeconf to remove all ost2 traces for subsequent tests
742 run_test 21d "start mgs then ost and then mds"
747 echo Client mount with ost in logs, but none running
749 # wait until mds connected to ost and open client connection
750 wait_osc_import_state mds ost FULL
753 # check_mount will block trying to contact ost
754 mcreate $DIR/$tfile || return 40
755 rm -f $DIR/$tfile || return 42
759 echo Client mount with a running ost
762 # if gss enabled, wait full time to let connection from
763 # mds to ost be established, due to the mismatch between
764 # initial connect timeout and gss context negotiation timeout.
765 # This perhaps could be remove after AT landed.
766 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
767 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
770 wait_osc_import_state mds ost FULL
771 wait_osc_import_state client ost FULL
772 check_mount || return 41
777 run_test 22 "start a client before osts (should return errs)"
779 test_23a() { # was test_23
783 # force down client so that recovering mds waits for reconnect
784 local running=$(grep -c $MOUNT /proc/mounts) || true
785 if [ $running -ne 0 ]; then
786 echo "Stopping client $MOUNT (opts: -f)"
790 # enter recovery on mds
792 # try to start a new client
793 mount_client $MOUNT &
795 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
796 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
797 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
799 ps --ppid $MOUNT_LUSTRE_PID
800 echo "waiting for mount to finish"
802 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
803 # SIGTERM works but it does not spread to offspring processses
804 kill -s TERM $MOUNT_PID
805 kill -s TERM $MOUNT_LUSTRE_PID
806 # we can not wait $MOUNT_PID because it is not a child of this shell
812 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
814 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
815 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
818 [ -z "$PID1" -a -z "$PID2" ] && break
819 echo "waiting for mount to finish ... "
820 WAIT=$(( WAIT + sleep))
822 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
823 error "MOUNT_PID $MOUNT_PID and "\
824 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
830 run_test 23a "interrupt client during recovery mount delay"
835 test_23b() { # was test_23
838 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
839 lctl set_param fail_loc=0x80000313
843 run_test 23b "Simulate -EINTR during mount"
845 fs2mds_HOST=$mds_HOST
846 fs2ost_HOST=$ost_HOST
850 echo "umount $MOUNT2 ..."
851 umount $MOUNT2 || true
852 echo "stopping fs2mds ..."
853 stop fs2mds -f || true
854 echo "stopping fs2ost ..."
855 stop fs2ost -f || true
859 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
861 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
862 is_blkdev $SINGLEMDS $MDSDEV && \
863 skip_env "mixed loopback and real device not working" && return
866 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
868 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
869 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
871 # test 8-char fsname as well
872 local FSNAME2=test1234
873 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
875 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
878 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
879 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
881 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
883 check_mount || return 2
884 # files written on 1 should not show up on 2
885 cp /etc/passwd $DIR/$tfile
887 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
890 cp /etc/passwd $MOUNT2/b || return 3
891 rm $MOUNT2/b || return 4
892 # 2 is actually mounted
893 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
895 facet_failover fs2mds
896 facet_failover fs2ost
899 # the MDS must remain up until last MDT
901 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
902 [ -z "$MDS" ] && error "No MDT" && return 8
904 cleanup_nocli || return 6
906 run_test 24a "Multiple MDTs on a single node"
909 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
911 if [ -z "$fs2mds_DEV" ]; then
912 local dev=${SINGLEMDS}_dev
914 is_blkdev $SINGLEMDS $MDSDEV && \
915 skip_env "mixed loopback and real device not working" && return
918 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
920 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
922 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
925 run_test 24b "Multiple MGSs on a single node (should return err)"
929 check_mount || return 2
930 local MODULES=$($LCTL modules | awk '{ print $2 }')
931 rmmod $MODULES 2>/dev/null || true
934 run_test 25 "Verify modules are referenced"
938 # we need modules before mount for sysctl, so make sure...
939 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
940 #define OBD_FAIL_MDS_FS_SETUP 0x135
941 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
942 start_mds && echo MDS started && return 1
943 lctl get_param -n devices
944 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
945 [ $DEVS -gt 0 ] && return 2
946 unload_modules_conf || return $?
948 run_test 26 "MDT startup failure cleans LOV (should return errs)"
954 local ORIG=$(do_facet $myfacet "$TEST")
955 if [ $# -gt 3 ]; then
961 echo "Setting $PARAM from $ORIG to $FINAL"
962 do_facet mgs "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
964 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
968 start_ost || return 1
969 start_mds || return 2
970 echo "Requeue thread should have started: "
971 ps -e | grep ll_cfg_requeue
972 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
975 run_test 27a "Reacquire MGS lock if OST started first"
980 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
982 facet_failover $SINGLEMDS
983 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
984 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
988 run_test 27b "Reacquire MGS lock after failover"
992 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
993 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
996 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
997 FINAL=$(($FINAL + 1))
998 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
999 umount_client $MOUNT || return 200
1002 if [ $RESULT -ne $FINAL ]; then
1003 echo "New config not seen: wanted $FINAL got $RESULT"
1006 echo "New config success: got $RESULT"
1008 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
1011 run_test 28 "permanent parameter setting"
1014 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1015 setup > /dev/null 2>&1
1019 local PARAM="$FSNAME-OST0001.osc.active"
1020 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1021 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1023 ACTV=$(lctl get_param -n $PROC_ACT)
1025 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1026 # also check ost_server_uuid status
1027 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1028 if [ -z "$RESULT" ]; then
1029 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1032 echo "Live client success: got $RESULT"
1036 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0001)
1037 mdtosc=${mdtosc/-MDT*/-MDT\*}
1038 local MPROC="osc.$mdtosc.active"
1043 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
1044 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1045 if [ $RESULT -eq $DEAC ]; then
1046 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
1050 if [ $WAIT -eq $MAX ]; then
1051 echo "MDT not deactivated: wanted $DEAC got $RESULT"
1054 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
1057 # quotacheck should not fail immediately after deactivate
1058 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1060 # test new client starts deactivated
1061 umount_client $MOUNT || return 200
1063 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1064 if [ -z "$RESULT" ]; then
1065 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1068 echo "New client success: got $RESULT"
1071 # quotacheck should not fail after umount/mount operation
1072 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1074 # make sure it reactivates
1075 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1077 umount_client $MOUNT
1080 #writeconf to remove all ost2 traces for subsequent tests
1083 run_test 29 "permanently remove an OST"
1088 echo Big config llog
1089 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1091 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1092 for i in ${LIST[@]}; do
1093 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1095 # make sure client restart still works
1096 umount_client $MOUNT
1097 mount_client $MOUNT || return 4
1098 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1101 echo Erase parameter setting
1102 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1103 umount_client $MOUNT
1104 mount_client $MOUNT || return 6
1106 echo "deleted (default) value=$FINAL, orig=$ORIG"
1107 # assumes this parameter started at the default value
1108 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1112 run_test 30a "Big config llog and conf_param deletion"
1117 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1118 # numerical part of it. Hopefully that's not already a failover address for
1120 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1121 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1122 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1123 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1124 echo "Using fake nid $NEW"
1126 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1127 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
1128 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1130 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1131 echo "should have 2 failover nids: $NIDCOUNT"
1132 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1133 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1134 umount_client $MOUNT
1135 mount_client $MOUNT || return 3
1137 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1139 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1140 echo "only 1 final nid should remain: $NIDCOUNT"
1141 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1145 run_test 30b "Remove failover nids"
1147 test_31() { # bug 10734
1148 # ipaddr must not exist
1149 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1152 run_test 31 "Connect to non-existent node (shouldn't crash)"
1154 # Use these start32/stop32 fn instead of t-f start/stop fn,
1155 # for local devices, to skip global facet vars init
1159 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1160 umount -d $@ ${MOUNT%/*}/${facet}
1169 mkdir -p ${MOUNT%/*}/${facet}
1171 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1172 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1174 if [ $RC -ne 0 ]; then
1175 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1176 echo "Start of ${device} of local ${facet} failed ${RC}"
1182 cleanup_nocli32 () {
1190 echo "Cleanup test_32 umount $MOUNT ..."
1191 umount -f $MOUNT || true
1192 echo "Cleanup local mds ost1 ..."
1194 combined_mgs_mds || start_mgs
1199 client_only && skip "client only testing" && return 0
1200 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1201 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1203 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1204 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1205 local tmpdir=$TMP/conf32a
1207 tar xjvf $DISK1_8 -C $tmpdir || \
1208 { skip_env "Cannot untar $DISK1_8" && return 0; }
1211 $LCTL set_param debug="$PTLDEBUG"
1213 $TUNEFS $tmpdir/mds || error "tunefs failed"
1215 combined_mgs_mds || stop mgs
1217 # nids are wrong, so client wont work, but server should start
1218 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1219 trap cleanup_32 EXIT INT || return 3
1221 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1223 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1225 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1226 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1227 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1229 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1231 local NID=$($LCTL list_nids | head -1)
1233 echo "OSC changes should succeed:"
1234 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1235 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1238 echo "MDC changes should succeed:"
1239 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1240 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1243 echo "LOV changes should succeed:"
1244 $LCTL pool_new lustre.interop || return 11
1245 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1250 # mount a second time to make sure we didnt leave upgrade flag on
1252 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1254 combined_mgs_mds || stop mgs
1256 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1257 trap cleanup_32 EXIT INT || return 12
1261 rm -rf $tmpdir || true # true is only for TMP on NFS
1263 run_test 32a "Upgrade from 1.8 (not live)"
1266 client_only && skip "client only testing" && return 0
1267 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1268 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1270 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1271 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1272 local tmpdir=$TMP/conf32b
1274 tar xjvf $DISK1_8 -C $tmpdir || \
1275 { skip_env "Cannot untar $DISK1_8" && return ; }
1278 $LCTL set_param debug="+config"
1279 local NEWNAME=lustre
1281 # writeconf will cause servers to register with their current nids
1282 $TUNEFS --writeconf --erase-params \
1283 --param mdt.identity_upcall=$L_GETIDENTITY \
1284 --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1285 combined_mgs_mds || stop mgs
1287 start32 mds1 $tmpdir/mds "-o loop" && \
1288 trap cleanup_32 EXIT INT || return 3
1290 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1292 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1294 $TUNEFS --writeconf --erase-params \
1295 --mgsnode=$HOSTNAME --fsname=$NEWNAME $tmpdir/ost1 ||\
1296 error "tunefs failed"
1297 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1298 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1300 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1302 local NID=$($LCTL list_nids | head -1)
1304 echo "OSC changes should succeed:"
1305 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1306 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1309 echo "MDC changes should succeed:"
1310 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1311 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1314 echo "LOV changes should succeed:"
1315 $LCTL pool_new ${NEWNAME}.interop || return 11
1316 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1319 # MDT and OST should have registered with new nids, so we should have
1320 # a fully-functioning client
1321 echo "Check client and old fs contents"
1323 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1324 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1325 mount -t lustre $device $MOUNT || return 1
1327 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1328 local new=$((old + 5))
1329 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1330 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1332 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1337 rm -rf $tmpdir || true # true is only for TMP on NFS
1339 run_test 32b "Upgrade from 1.8 with writeconf"
1341 test_33a() { # bug 12333, was test_33
1343 local FSNAME2=test-123
1344 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1346 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1348 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1349 local dev=${SINGLEMDS}_dev
1350 local MDSDEV=${!dev}
1351 is_blkdev $SINGLEMDS $MDSDEV && \
1352 skip_env "mixed loopback and real device not working" && return
1355 combined_mgs_mds || mkfs_opts="$mkfs_opts --nomgs"
1357 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1358 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1359 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1360 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1362 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1363 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1364 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1366 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1369 cp /etc/hosts $MOUNT2/ || rc=3
1370 $LFS getstripe $MOUNT2/hosts
1375 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1376 cleanup_nocli || rc=6
1379 run_test 33a "Mount ost with a large index number"
1381 test_33b() { # was test_34
1384 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1385 # Drop lock cancelation reply during umount
1386 #define OBD_FAIL_LDLM_CANCEL 0x304
1387 do_facet client lctl set_param fail_loc=0x80000304
1388 #lctl set_param debug=-1
1389 umount_client $MOUNT
1392 run_test 33b "Drop cancel during umount"
1396 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1397 manual_umount_client
1399 do_facet client killall -USR1 multiop
1400 if [ $rc -eq 0 ]; then
1401 error "umount not fail!"
1406 run_test 34a "umount with opened file should be fail"
1411 touch $DIR/$tfile || return 1
1412 stop_mds --force || return 2
1414 manual_umount_client --force
1416 if [ $rc -ne 0 ]; then
1417 error "mtab after failed umount - rc $rc"
1423 run_test 34b "force umount with failed mds should be normal"
1427 touch $DIR/$tfile || return 1
1428 stop_ost --force || return 2
1430 manual_umount_client --force
1432 if [ $rc -ne 0 ]; then
1433 error "mtab after failed umount - rc $rc"
1439 run_test 34c "force umount with failed ost should be normal"
1441 test_35a() { # bug 12459
1444 DBG_SAVE="`lctl get_param -n debug`"
1445 lctl set_param debug="ha"
1447 log "Set up a fake failnode for the MDS"
1449 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1450 do_facet mgs $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1452 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1455 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1458 log "Stopping the MDT:"
1459 stop_mds || return 5
1461 df $MOUNT > /dev/null 2>&1 &
1463 log "Restarting the MDT:"
1464 start_mds || return 6
1465 log "Wait for df ($DFPID) ... "
1468 lctl set_param debug="$DBG_SAVE"
1470 # retrieve from the log the first server that the client tried to
1471 # contact after the connection loss
1472 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1473 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1474 /import_select_connection.*$device-mdc.* using connection/ {
1476 if (\\\$NF ~ /$FAKENID/)
1482 }" $TMP/lustre-log-$TESTNAME.log`
1483 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1485 # remove nid settings
1488 run_test 35a "Reconnect to the last active server first"
1490 test_35b() { # bug 18674
1491 remote_mds || { skip "local MDS" && return 0; }
1495 $LCTL set_param debug="ha"
1497 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1500 log "Set up a fake failnode for the MDS"
1502 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | \
1503 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1504 do_facet mgs "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1507 local at_max_saved=0
1508 # adaptive timeouts may prevent seeing the issue
1509 if at_is_enabled; then
1510 at_max_saved=$(at_max_get mds)
1511 at_max_set 0 mds client
1514 mkdir -p $MOUNT/$tdir
1516 log "Injecting EBUSY on MDS"
1517 # Setting OBD_FAIL_MDS_RESEND=0x136
1518 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
1520 $LCTL set_param mdc.${FSNAME}*.stats=clear
1522 log "Creating a test file and stat it"
1523 touch $MOUNT/$tdir/$tfile
1524 stat $MOUNT/$tdir/$tfile
1526 log "Stop injecting EBUSY on MDS"
1527 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
1528 rm -f $MOUNT/$tdir/$tfile
1531 # restore adaptive timeout
1532 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1534 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1536 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
1538 # retrieve from the log if the client has ever tried to
1539 # contact the fake server after the loss of connection
1540 FAILCONN=`awk "BEGIN {ret = 0;}
1541 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1543 if (\\\$NF ~ /$FAKENID/) {
1548 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1550 [ "$FAILCONN" == "0" ] && \
1551 log "ERROR: The client reconnection has not been triggered" && \
1553 [ "$FAILCONN" == "2" ] && \
1554 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1558 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
1559 # Reconnects are supposed to be rate limited to one every 5s
1560 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
1561 log "ERROR: Too many reconnects $CONNCNT" && \
1565 # remove nid settings
1568 run_test 35b "Continue reconnection retries, if the active server is busy"
1571 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1573 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1574 { skip "remote OST" && return 0; }
1577 local FSNAME2=test1234
1578 local fs3ost_HOST=$ost_HOST
1579 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1581 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1583 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1584 is_blkdev $SINGLEMDS $MDSDEV && \
1585 skip_env "mixed loopback and real device not working" && return
1588 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1589 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1590 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1591 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1592 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1594 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1595 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1597 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1598 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1599 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1601 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1603 sleep 5 # until 11778 fixed
1605 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1607 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1608 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1609 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1610 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1611 DFTOTAL=`echo $STRING | cut -d, -f1`
1612 DFUSED=`echo $STRING | cut -d, -f2`
1613 DFAVAIL=`echo $STRING | cut -d, -f3`
1614 DFFREE=$(($DFTOTAL - $DFUSED))
1616 ALLOWANCE=$((64 * $OSTCOUNT))
1618 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1619 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1620 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1623 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1624 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1625 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1628 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1629 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1630 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1635 stop fs3ost -f || return 200
1636 stop fs2ost -f || return 201
1637 stop fs2mds -f || return 202
1638 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1639 unload_modules_conf || return 203
1642 run_test 36 "df report consistency on OSTs with different block size"
1645 local mntpt=$(facet_mntpt $SINGLEMDS)
1646 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
1647 local mdsdev_sym="$TMP/sym_mdt.img"
1649 echo "MDS : $mdsdev"
1650 echo "SYMLINK : $mdsdev_sym"
1651 do_facet $SINGLEMDS rm -f $mdsdev_sym
1653 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
1655 echo "mount symlink device - $mdsdev_sym"
1658 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $MDS_MOUNT_OPTS $mdsdev_sym $mntpt 2>&1 )
1661 echo mount_op=$mount_op
1663 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
1665 if $(echo $mount_op | grep -q "unable to set tunable"); then
1666 error "set tunables failed for symlink device"
1669 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
1673 run_test 37 "verify set tunables works for symlink device"
1675 test_38() { # bug 14222
1680 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1681 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1683 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1684 error "copying $SRC to $DIR/$tdir"
1686 umount_client $MOUNT
1688 log "rename lov_objid file on MDS"
1689 rm -f $TMP/lov_objid.orig
1691 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1692 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1693 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1695 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1696 # check create in mds_lov_connect
1700 [ $V ] && log "verifying $DIR/$tdir/$f"
1701 diff -q $f $DIR/$tdir/$f || ERROR=y
1703 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1704 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1705 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1707 # check it's updates in sync
1708 umount_client $MOUNT
1711 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1712 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1713 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1718 [ $V ] && log "verifying $DIR/$tdir/$f"
1719 diff -q $f $DIR/$tdir/$f || ERROR=y
1721 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1722 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1723 umount_client $MOUNT
1725 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1727 log "files compared the same"
1730 run_test 38 "MDS recreates missing lov_objid file from OST data"
1736 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1737 error "memory leak detected" || true
1739 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1741 test_40() { # bug 15759
1743 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1744 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
1748 run_test 40 "race during service thread startup"
1750 test_41a() { #bug 14134
1751 echo $MDS_MOUNT_OPTS | grep "loop" && skip " loop devices does not work with nosvc option" && return
1754 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1756 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1757 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1758 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1760 mount_client $MOUNT || return 1
1763 echo "blah blah" > $MOUNT/$tfile
1766 umount_client $MOUNT
1767 stop ost1 -f || return 201
1768 stop_mds -f || return 202
1769 stop_mds -f || return 203
1770 unload_modules_conf || return 204
1773 run_test 41a "mount mds with --nosvc and --nomgs"
1776 echo $MDS_MOUNT_OPTS | grep "loop" && skip " loop devices does not work with nosvc option" && return
1778 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
1782 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1784 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1786 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1788 mount_client $MOUNT || return 1
1791 echo "blah blah" > $MOUNT/$tfile
1792 cat $MOUNT/$tfile || return 200
1794 umount_client $MOUNT
1795 stop_ost || return 201
1796 stop_mds -f || return 202
1797 stop_mds -f || return 203
1800 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
1802 test_42() { #bug 14693
1804 check_mount || return 2
1805 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1806 umount_client $MOUNT
1807 mount_client $MOUNT || return 1
1811 run_test 42 "invalid config param should not prevent client from mounting"
1814 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1816 chmod ugo+x $DIR || error "chmod 0 failed"
1818 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1819 "$FSNAME.mdt.root_squash" \
1822 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1823 "$FSNAME.mdt.nosquash_nids" \
1827 # create set of test files
1829 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1830 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1831 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1833 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1834 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1836 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1837 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1838 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1841 # check root_squash:
1842 # set root squash UID:GID to RUNAS_ID
1843 # root should be able to access only files owned by RUNAS_ID
1846 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1847 "$FSNAME.mdt.root_squash" \
1848 "$RUNAS_ID:$RUNAS_ID"
1850 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1851 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1852 error "$ST: root read permission is denied"
1853 echo "$ST: root read permission is granted - ok"
1856 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1857 error "$ST: root write permission is denied"
1858 echo "$ST: root write permission is granted - ok"
1860 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1861 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1862 error "$ST: root read permission is granted"
1863 echo "$ST: root read permission is denied - ok"
1866 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1867 error "$ST: root write permission is granted"
1868 echo "$ST: root write permission is denied - ok"
1870 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1871 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1872 error "$ST: root unlink permission is granted"
1873 echo "$ST: root unlink permission is denied - ok"
1875 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1876 error "$ST: root create permission is granted"
1877 echo "$ST: root create permission is denied - ok"
1880 # check nosquash_nids:
1881 # put client's NID into nosquash_nids list,
1882 # root should be able to access root file after that
1884 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1885 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1886 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1888 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1889 "$FSNAME-MDTall.mdt.nosquash_nids" \
1892 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1893 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1894 error "$ST: root read permission is denied"
1895 echo "$ST: root read permission is granted - ok"
1898 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1899 error "$ST: root write permission is denied"
1900 echo "$ST: root write permission is granted - ok"
1902 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1903 rm $DIR/$tdir-rootdir/tfile-1 || \
1904 error "$ST: root unlink permission is denied"
1905 echo "$ST: root unlink permission is granted - ok"
1906 touch $DIR/$tdir-rootdir/tfile-2 || \
1907 error "$ST: root create permission is denied"
1908 echo "$ST: root create permission is granted - ok"
1912 run_test 43 "check root_squash and nosquash_nids"
1914 umount_client $MOUNT
1919 check_mount || return 2
1920 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1922 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1923 for VAL in $UUIDS; do
1924 NID=$(echo $VAL | cut -d= -f1)
1925 CLUUID=$(echo $VAL | cut -d= -f2)
1926 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1928 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1932 run_test 44 "mounted client proc entry exists"
1936 check_mount || return 2
1941 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1942 do_facet client "lctl set_param fail_loc=0x50f"
1945 manual_umount_client --force || return 3
1946 do_facet client "lctl set_param fail_loc=0x0"
1948 mount_client $MOUNT || return 4
1952 run_test 45 "long unlink handling in ptlrpcd"
1959 umount_client $MOUNT2 || rc=$?
1960 umount_client $MOUNT || rc=$?
1961 while [ $count -gt 0 ]; do
1962 stop ost${count} -f || rc=$?
1966 cleanup_nocli || rc=$?
1967 #writeconf to remove all ost2 traces for subsequent tests
1973 echo "Testing with $OSTCOUNT OSTs"
1975 start_mds || return 1
1976 #first client should see only one ost
1977 start_ost || return 2
1978 wait_osc_import_state mds ost FULL
1980 mount_client $MOUNT || return 3
1981 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1984 for (( i=2; i<=$OSTCOUNT; i++ )); do
1985 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1988 # wait until osts in sync
1989 for (( i=2; i<=$OSTCOUNT; i++ )); do
1990 wait_osc_import_state mds ost$i FULL
1991 wait_osc_import_state client ost$i FULL
1994 #second client see all ost's
1996 mount_client $MOUNT2 || return 8
1997 $LFS setstripe -c -1 $MOUNT2 || return 9
1998 $LFS getstripe $MOUNT2 || return 10
2000 echo "ok" > $MOUNT2/widestripe
2001 $LFS getstripe $MOUNT2/widestripe || return 11
2002 # fill acl buffer for avoid expand lsm to them
2003 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
2004 setfacl -m $acl $MOUNT2/widestripe
2008 stat $MOUNT/widestripe || return 12
2010 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
2013 run_test 46a "handle ost additional - wide striped file"
2018 check_mount || return 2
2019 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2023 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2024 if echo $ns | grep "MDT[[:digit:]]*"; then
2027 lrs=$(echo $ns | sed 's/.*lru_size=//')
2028 lru_size[count]=$lrs
2033 facet_failover $SINGLEMDS
2034 client_up || return 3
2037 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2038 if echo $ns | grep "MDT[[:digit:]]*"; then
2041 lrs=$(echo $ns | sed 's/.*lru_size=//')
2042 if ! test "$lrs" -eq "${lru_size[count]}"; then
2043 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2044 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2052 run_test 47 "server restart does not make client loss lru_resize settings"
2057 # reformat after this test is needed - if test will failed
2058 # we will have unkillable file at FS
2062 test_48() { # bug 17636
2065 check_mount || return 2
2067 $LFS setstripe -c -1 $MOUNT || return 9
2068 $LFS getstripe $MOUNT || return 10
2070 echo "ok" > $MOUNT/widestripe
2071 $LFS getstripe $MOUNT/widestripe || return 11
2073 trap cleanup_48 EXIT ERR
2075 # fill acl buffer for avoid expand lsm to them
2076 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2077 setfacl -m $acl $MOUNT/widestripe
2080 stat $MOUNT/widestripe || return 12
2085 run_test 48 "too many acls on file"
2087 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2088 test_49() { # bug 17710
2089 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
2090 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
2091 local LOCAL_TIMEOUT=20
2094 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
2098 check_mount || return 1
2100 echo "check ldlm_timout..."
2101 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2102 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2103 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2105 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2106 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2109 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2110 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2113 umount_client $MOUNT
2114 stop_ost || return 2
2115 stop_mds || return 3
2117 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"
2121 check_mount || return 7
2123 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2124 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2125 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2127 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2128 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2131 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2132 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2135 cleanup || return $?
2137 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
2138 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
2140 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
2143 # Test both statfs and lfs df and fail if either one fails
2144 multiop_bg_pause $1 f_
2147 killall -USR1 multiop
2148 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2149 wait $PID || { RC1=$?; log "multiop return error "; }
2156 if [ $RC2 -eq 0 ]; then
2158 log "lazystatfs df failed"
2162 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2168 lctl set_param llite.$FSNAME-*.lazystatfs=1
2171 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2173 cleanup || return $?
2175 run_test 50a "lazystatfs all servers available =========================="
2179 lctl set_param llite.$FSNAME-*.lazystatfs=1
2182 # Wait for client to detect down OST
2183 stop_ost || error "Unable to stop OST1"
2184 wait_osc_import_state mds ost DISCONN
2186 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2188 umount_client $MOUNT || error "Unable to unmount client"
2189 stop_mds || error "Unable to stop MDS"
2191 run_test 50b "lazystatfs all servers down =========================="
2194 start_mds || error "Unable to start MDS"
2195 start_ost || error "Unable to start OST1"
2196 start_ost2 || error "Unable to start OST2"
2197 mount_client $MOUNT || error "Unable to mount client"
2198 lctl set_param llite.$FSNAME-*.lazystatfs=1
2201 # Wait for client to detect down OST
2202 stop_ost || error "Unable to stop OST1"
2203 wait_osc_import_state mds ost DISCONN
2204 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2206 umount_client $MOUNT || error "Unable to unmount client"
2207 stop_ost2 || error "Unable to stop OST2"
2208 stop_mds || error "Unable to stop MDS"
2209 #writeconf to remove all ost2 traces for subsequent tests
2212 run_test 50c "lazystatfs one server down =========================="
2215 start_mds || error "Unable to start MDS"
2216 start_ost || error "Unable to start OST1"
2217 start_ost2 || error "Unable to start OST2"
2218 mount_client $MOUNT || error "Unable to mount client"
2219 lctl set_param llite.$FSNAME-*.lazystatfs=1
2222 # Issue the statfs during the window where the client still
2223 # belives the OST to be available but it is in fact down.
2224 # No failure just a statfs which hangs for a timeout interval.
2225 stop_ost || error "Unable to stop OST1"
2226 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2228 umount_client $MOUNT || error "Unable to unmount client"
2229 stop_ost2 || error "Unable to stop OST2"
2230 stop_mds || error "Unable to stop MDS"
2231 #writeconf to remove all ost2 traces for subsequent tests
2234 run_test 50d "lazystatfs client/server conn race =========================="
2241 start_mds || return 1
2242 #first client should see only one ost
2243 start_ost || return 2
2244 wait_osc_import_state mds ost FULL
2246 # Wait for client to detect down OST
2247 stop_ost || error "Unable to stop OST1"
2248 wait_osc_import_state mds ost DISCONN
2250 mount_client $MOUNT || error "Unable to mount client"
2251 lctl set_param llite.$FSNAME-*.lazystatfs=0
2253 multiop_bg_pause $MOUNT _f
2257 if [ $RC1 -ne 0 ]; then
2258 log "multiop failed $RC1"
2261 sleep $(( $TIMEOUT+1 ))
2263 [ $? -ne 0 ] && error "process isn't sleep"
2264 start_ost || error "Unable to start OST1"
2265 wait $pid || error "statfs failed"
2268 umount_client $MOUNT || error "Unable to unmount client"
2269 stop_ost || error "Unable to stop OST1"
2270 stop_mds || error "Unable to stop MDS"
2272 run_test 50e "normal statfs all servers down =========================="
2277 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2279 start_mds || error "Unable to start mds"
2280 #first client should see only one ost
2281 start_ost || error "Unable to start OST1"
2282 wait_osc_import_state mds ost FULL
2284 start_ost2 || error "Unable to start OST2"
2285 wait_osc_import_state mds ost2 FULL
2287 # Wait for client to detect down OST
2288 stop_ost2 || error "Unable to stop OST2"
2290 wait_osc_import_state mds ost2 DISCONN
2291 mount_client $MOUNT || error "Unable to mount client"
2292 lctl set_param llite.$FSNAME-*.lazystatfs=0
2294 multiop_bg_pause $MOUNT _f
2298 if [ $RC1 -ne 0 ]; then
2299 log "lazystatfs multiop failed $RC1"
2302 sleep $(( $TIMEOUT+1 ))
2304 [ $? -ne 0 ] && error "process isn't sleep"
2305 start_ost2 || error "Unable to start OST2"
2306 wait $pid || error "statfs failed"
2307 stop_ost2 || error "Unable to stop OST2"
2310 umount_client $MOUNT || error "Unable to unmount client"
2311 stop_ost || error "Unable to stop OST1"
2312 stop_mds || error "Unable to stop MDS"
2313 #writeconf to remove all ost2 traces for subsequent tests
2316 run_test 50f "normal statfs one server in down =========================="
2319 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2321 start_ost2 || error "Unable to start OST2"
2322 wait_osc_import_state mds ost2 FULL
2323 wait_osc_import_state client ost2 FULL
2325 local PARAM="${FSNAME}-OST0001.osc.active"
2327 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2328 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2330 umount_client $MOUNT || error "Unable to unmount client"
2331 mount_client $MOUNT || error "Unable to mount client"
2332 # This df should not cause a panic
2335 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2337 umount_client $MOUNT || error "Unable to unmount client"
2338 stop_ost2 || error "Unable to stop OST2"
2339 stop_ost || error "Unable to stop OST1"
2340 stop_mds || error "Unable to stop MDS"
2341 #writeconf to remove all ost2 traces for subsequent tests
2344 run_test 50g "deactivated OST should not cause panic====================="
2347 local LOCAL_TIMEOUT=20
2351 check_mount || return 1
2354 $LFS setstripe -c -1 $MOUNT/d1
2355 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2356 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2357 touch $MOUNT/d1/f1 &
2360 start_ost2 || return 2
2362 stop_ost2 || return 3
2364 #writeconf to remove all ost2 traces for subsequent tests
2367 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2376 do_node $node mkdir -p $dest
2377 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2379 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2380 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2381 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2383 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2384 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2394 local backup2=${TMP}/backup2
2396 do_node $node mkdir -p $backup2
2397 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2399 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2400 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2401 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2403 do_node $node "diff -rq $backup $backup2"
2404 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2406 local xattrs2=${TMP}/xattrs2
2407 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2408 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2410 do_node $node "diff $xattrs $xattrs2"
2411 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2413 do_node $node "rm -rf $backup2 $xattrs2"
2414 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2419 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2421 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2423 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2426 local ost1mnt=$(facet_mntpt ost1)
2427 local ost1node=$(facet_active_host ost1)
2428 local ost1tmp=$TMP/conf52
2431 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2432 touch $TMP/modified_first
2433 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2434 local mtime=$(stat -c %Y $TMP/modified_first)
2435 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2437 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2440 $LFS setstripe -c -1 -S 1M $DIR/$tdir
2441 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2443 for (( i=0; i < nrfiles; i++ )); do
2444 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2445 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2451 echo backup files to $TMP/files
2452 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2453 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2454 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2456 umount_client $MOUNT
2457 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2459 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2461 echo mount ost1 as ldiskfs
2462 do_node $ost1node mkdir -p $ost1mnt
2463 [ $? -eq 0 ] || { error "Unable to create $ost1mnt"; return 23; }
2464 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2465 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2468 echo backup objects to $ost1tmp/objects
2469 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2470 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2471 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2472 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2474 # move objects to lost+found
2475 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2476 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2479 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2480 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2482 # compare restored objects against saved ones
2483 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2484 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2486 do_node $ost1node "umount $ost1mnt"
2487 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2490 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2492 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2495 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2496 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2498 rm -rf $TMP/files $TMP/file_xattrs
2499 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2500 do_node $ost1node "rm -rf $ost1tmp"
2501 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2504 run_test 52 "check recovering objects from lost+found"
2506 # Checks threads_min/max/started for some service
2508 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2509 # parameter pattern prefix like 'ost.*.ost'.
2521 local msg="Insane $modname thread counts"
2525 check_mount || return 41
2527 # We need to expand $parampat, but it may match multiple parameters, so
2528 # we'll pick the first one
2529 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2530 error "Couldn't expand ${parampat}.threads_min parameter name"
2534 # Remove the .threads_min part
2535 paramp=${paramp%.threads_min}
2537 # Check for sanity in defaults
2538 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2539 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2540 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2541 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2542 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
2544 # Check that we can change min/max
2545 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + 1))"
2546 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 1))"
2547 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2548 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2549 lassert 25 "$msg" '(($tmin2 == ($tmin + 1) && $tmax2 == ($tmax -1)))' || return $?
2551 # Check that we can set min/max to the same value
2552 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2553 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2554 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2555 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2556 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2558 # Check that we can't set max < min
2559 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2560 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2561 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2562 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
2564 # We need to ensure that we get the module options desired; to do this
2565 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2566 LOAD_MODULES_REMOTE=true
2569 setmodopts -a $modname "$opts" oldvalue
2573 check_mount || return 41
2575 # Restore previous setting of MODOPTS_*
2576 setmodopts $modname "$oldvalue"
2578 # Check that $opts took
2579 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2580 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2581 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2582 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2585 # Workaround a YALA bug where YALA expects that modules will remain
2586 # loaded on the servers
2587 LOAD_MODULES_REMOTE=false
2594 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2596 run_test 53a "check OSS thread count params"
2599 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2601 run_test 53b "check MDT thread count params"
2604 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p
2605 [ $? -eq 0 ] || error "llverdev failed!"
2608 run_test 54a "test llverdev and partial verify of device"
2612 run_llverfs $MOUNT -p
2613 [ $? -eq 0 ] || error "llverfs failed!"
2616 run_test 54b "test llverfs and partial verify of filesystem"
2620 local max_ost_index=$1
2621 echo -n $(((max_ost_index + 1) * 8))
2625 local mdsdev=$(mdsdevname 1)
2626 local ostdev=$(ostdevname 1)
2627 local saved_opts=$OST_MKFS_OPTS
2631 OST_MKFS_OPTS="$saved_opts --index $i"
2639 echo checking size of lov_objid for ost index $i
2640 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2641 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2642 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2644 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2649 OST_MKFS_OPTS=$saved_opts
2652 run_test 55 "check lov_objid size"
2655 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2656 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2657 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2661 start_ost2 || error "Unable to start second ost"
2662 mount_client $MOUNT || error "Unable to mount client"
2665 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
2669 run_test 56 "check big indexes"
2671 test_57a() { # bug 22656
2672 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2674 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2676 start_ost && error "OST registration from failnode should fail"
2679 run_test 57a "initial registration from failnode should fail (should return errs)"
2682 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2684 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
2686 start_ost || error "OST registration from servicenode should not fail"
2689 run_test 57b "initial registration from servicenode should not fail"
2692 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2695 test_58() { # bug 22658
2696 [ "$FSTYPE" != "ldiskfs" ] && skip "not supported for $FSTYPE" && return
2699 createmany -o $DIR/$tdir/$tfile-%d 100
2700 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
2701 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
2702 do_facet mds "lctl set_param fail_loc=0x601"
2703 unlinkmany $DIR/$tdir/$tfile-%d 100
2705 local MNTDIR=$(facet_mntpt mds)
2706 # remove all files from the OBJECTS dir
2707 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
2708 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
2709 do_facet mds "umount $MNTDIR"
2710 # restart MDS with missing llog files
2712 do_facet mds "lctl set_param fail_loc=0"
2715 run_test 58 "missing llog files must not prevent MDT from mounting"
2718 start_mgsmds >> /dev/null
2719 local C1=$(count_osts)
2720 if [ $C1 -eq 0 ]; then
2721 start_ost >> /dev/null
2725 echo "original ost count: $C1 (expect > 0)"
2726 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2727 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2728 local C2=$(count_osts)
2729 echo "after mdt writeconf count: $C2 (expect 0)"
2730 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2731 echo "OST start without writeconf should fail:"
2732 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2733 echo "OST start with writeconf should succeed:"
2734 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2735 local C3=$(count_osts)
2736 echo "after ost writeconf count: $C3 (expect 1)"
2737 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2738 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2739 local C4=$(count_osts)
2740 echo "after ost2 writeconf count: $C4 (expect 2)"
2741 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2742 stop_ost2 >> /dev/null
2743 cleanup_nocli >> /dev/null
2744 #writeconf to remove all ost2 traces for subsequent tests
2747 run_test 59 "writeconf mount option"
2749 test_60() { # LU-471
2750 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' --reformat $(mdsdevname 1)
2752 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
2754 [ $rc -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
2756 # MDT default has dirdata feature
2757 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
2758 # we disable uninit_bg feature
2759 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
2760 # we set stride extended options
2761 echo $dump | grep stride > /dev/null || error "stride is not set"
2764 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
2767 local reformat=false
2769 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
2770 { skip "Need MDS version at least 2.1.53"; return 0; }
2772 if ! large_xattr_enabled; then
2774 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
2775 add $SINGLEMDS $MDS_MKFS_OPTS --mkfsoptions='\"-O large_xattr\"' \
2776 --reformat $mds_dev || error "reformatting $mds_dev failed"
2779 setup_noconfig || error "setting up the filesystem failed"
2780 client_up || error "starting client failed"
2782 local file=$DIR/$tfile
2785 local large_value="$(generate_string $(max_xattr_size))"
2786 local small_value="bar"
2788 local name="trusted.big"
2789 log "save large xattr $name on $file"
2790 setfattr -n $name -v $large_value $file ||
2791 error "saving $name on $file failed"
2793 local new_value=$(get_xattr_value $name $file)
2794 [[ "$new_value" != "$large_value" ]] &&
2795 error "$name different after saving"
2797 log "shrink value of $name on $file"
2798 setfattr -n $name -v $small_value $file ||
2799 error "shrinking value of $name on $file failed"
2801 new_value=$(get_xattr_value $name $file)
2802 [[ "$new_value" != "$small_value" ]] &&
2803 error "$name different after shrinking"
2805 log "grow value of $name on $file"
2806 setfattr -n $name -v $large_value $file ||
2807 error "growing value of $name on $file failed"
2809 new_value=$(get_xattr_value $name $file)
2810 [[ "$new_value" != "$large_value" ]] &&
2811 error "$name different after growing"
2813 log "check value of $name on $file after remounting MDS"
2815 new_value=$(get_xattr_value $name $file)
2816 [[ "$new_value" != "$large_value" ]] &&
2817 error "$name different after remounting MDS"
2819 log "remove large xattr $name from $file"
2820 setfattr -x $name $file || error "removing $name from $file failed"
2824 $reformat && reformat
2826 run_test 61 "large xattr"
2830 local mdsdev=$(mdsdevname 1)
2831 local ostdev=$(ostdevname 1)
2833 echo "disable journal for mds"
2834 do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
2835 start_mds && error "MDT start should fail"
2836 echo "disable journal for ost"
2837 do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
2838 start_ost && error "OST start should fail"
2839 cleanup || return $?
2842 run_test 62 "start with disabled journal"
2844 if ! combined_mgs_mds ; then
2850 # restore the ${facet}_MKFS_OPTS variables
2851 for facet in MGS MDS OST; do
2852 opts=SAVED_${facet}_MKFS_OPTS
2853 if [[ -n ${!opts} ]]; then
2854 eval ${facet}_MKFS_OPTS=\"${!opts}\"
2858 complete $(basename $0) $SECONDS