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 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
16 if [ "$FAILURE_MODE" = "HARD" ]; then
17 CONFIG_EXCEPTIONS="24a " && \
18 echo "Except the tests: $CONFIG_EXCEPTIONS for FAILURE_MODE=$FAILURE_MODE, bug 23573" && \
19 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
23 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
25 PTLDEBUG=${PTLDEBUG:--1}
27 LUSTRE=${LUSTRE:-`dirname $0`/..}
28 RLUSTRE=${RLUSTRE:-$LUSTRE}
29 export MULTIOP=${MULTIOP:-multiop}
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 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
52 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
58 require_dsh_mds || exit 0
59 require_dsh_ost || exit 0
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
76 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
77 do_facet ${facet} "$TUNEFS --quiet --writeconf $dev" ||
78 { echo "tunefs failed, reformatting instead" && reformat_and_config && return 1; }
85 # if writeconf fails anywhere, we reformat everything
86 writeconf1 mds `mdsdevname 1` || return 0
87 writeconf1 ost1 `ostdevname 1` || return 0
88 writeconf1 ost2 `ostdevname 2` || return 0
92 # The MGS must be started before the OSTs for a new fs, so start
93 # and stop to generate the startup logs.
96 wait_osc_import_state mds ost FULL
101 reformat_and_config() {
103 if ! combined_mgs_mds ; then
111 start mgs $MGSDEV $MGS_MOUNT_OPTS
115 local facet=$SINGLEMDS
116 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
117 local num=$(echo $facet | tr -d "mds")
118 local dev=$(mdsdevname $num)
119 echo "start mds service on `facet_active_host $facet`"
120 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
124 if ! combined_mgs_mds ; then
131 echo "stop mds service on `facet_active_host $SINGLEMDS`"
132 # These tests all use non-failover stop
133 stop $SINGLEMDS -f || return 97
137 echo "stop mgs service on `facet_active_host mgs`"
138 # These tests all use non-failover stop
139 stop mgs -f || return 97
143 echo "start ost1 service on `facet_active_host ost1`"
144 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
148 echo "stop ost1 service on `facet_active_host ost1`"
149 # These tests all use non-failover stop
150 stop ost1 -f || return 98
154 echo "start ost2 service on `facet_active_host ost2`"
155 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
159 echo "stop ost2 service on `facet_active_host ost2`"
160 # These tests all use non-failover stop
161 stop ost2 -f || return 93
166 echo "mount $FSNAME on ${MOUNTPATH}....."
167 zconf_mount `hostname` $MOUNTPATH || return 96
171 local mountopt="-o remount,$1"
173 echo "remount '$1' lustre on ${MOUNTPATH}....."
174 zconf_mount `hostname` $MOUNTPATH "$mountopt" || return 96
179 echo "umount lustre on ${MOUNTPATH}....."
180 zconf_umount `hostname` $MOUNTPATH || return 97
183 manual_umount_client(){
186 echo "manual umount lustre on ${MOUNT}...."
187 do_facet client "umount -d ${FORCE} $MOUNT"
193 start_mds || error "MDT start failed"
194 start_ost || error "OST start failed"
195 mount_client $MOUNT || error "client start failed"
196 client_up || error "client_up failed"
200 if ! combined_mgs_mds ; then
209 unload_modules_conf () {
210 if combined_mgs_mds || ! local_mode; then
211 unload_modules || return 1
216 stop_ost || return 202
217 stop_mds || return 201
218 unload_modules_conf || return 203
222 umount_client $MOUNT || return 200
223 cleanup_nocli || return $?
227 do_facet client "cp /etc/passwd $DIR/a" || return 71
228 do_facet client "rm $DIR/a" || return 72
229 # make sure lustre is actually mounted (touch will block,
230 # but grep won't, so do it after)
231 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
232 echo "setup single mount lustre success"
236 do_facet client "touch $DIR/a" || return 71
237 do_facet client "rm $DIR/a" || return 72
238 do_facet client "touch $DIR2/a" || return 73
239 do_facet client "rm $DIR2/a" || return 74
240 echo "setup double mount lustre success"
245 if [ "$ONLY" == "setup" ]; then
250 if [ "$ONLY" == "cleanup" ]; then
257 #create single point mountpoint
263 check_mount || return 41
266 run_test 0 "single mount setup"
269 start_mds || error "MDT start failed"
271 echo "start ost second time..."
272 start_ost && error "2nd OST start should fail"
273 mount_client $MOUNT || error "client start failed"
274 check_mount || return 42
277 run_test 1 "start up ost twice (should return errors)"
281 echo "start mds second time.."
282 start_mds && error "2nd MDT start should fail"
285 check_mount || return 43
288 run_test 2 "start up mds twice (should return err)"
292 #mount.lustre returns an error if already in mtab
293 mount_client $MOUNT && error "2nd client mount should fail"
294 check_mount || return 44
297 run_test 3 "mount client twice (should return err)"
301 touch $DIR/$tfile || return 85
305 # ok for ost to fail shutdown
306 if [ 202 -ne $eno ]; then
311 run_test 4 "force cleanup ost, then cleanup"
313 test_5a() { # was test_5
315 touch $DIR/$tfile || return 1
316 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
318 stop_mds -f || return 2
320 # cleanup may return an error from the failed
321 # disconnects; for now I'll consider this successful
322 # if all the modules have unloaded.
326 echo "killing umount"
327 kill -TERM $UMOUNT_PID
328 echo "waiting for umount to finish"
330 if grep " $MOUNT " /proc/mounts; then
331 echo "test 5: /proc/mounts after failed umount"
335 echo "killing umount"
336 kill -TERM $UMOUNT_PID
337 echo "waiting for umount to finish"
339 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
343 # stop_mds is a no-op here, and should not fail
344 cleanup_nocli || return $?
345 # df may have lingering entry
347 # mtab may have lingering entry
351 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
353 grep -q $MOUNT" " /etc/mtab || break
354 echo "Waiting /etc/mtab updated ... "
355 WAIT=$(( WAIT + sleep))
357 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
358 echo "/etc/mtab updated in $WAIT secs"
360 run_test 5a "force cleanup mds, then cleanup"
368 grep " $MOUNT " /etc/mtab && \
369 error false "unexpected entry in mtab before mount" && return 10
373 if ! combined_mgs_mds ; then
374 trap cleanup_5b EXIT ERR
379 [ -d $MOUNT ] || mkdir -p $MOUNT
380 mount_client $MOUNT && rc=1
381 grep " $MOUNT " /etc/mtab && \
382 error "$MOUNT entry in mtab after failed mount" && rc=11
384 # stop_mds is a no-op here, and should not fail
385 cleanup_nocli || rc=$?
386 if ! combined_mgs_mds ; then
391 run_test 5b "Try to start a client with no MGS (should return errs)"
394 grep " $MOUNT " /etc/mtab && \
395 error false "unexpected entry in mtab before mount" && return 10
400 [ -d $MOUNT ] || mkdir -p $MOUNT
401 local oldfs="${FSNAME}"
402 FSNAME="wrong.${FSNAME}"
403 mount_client $MOUNT || :
405 grep " $MOUNT " /etc/mtab && \
406 error "$MOUNT entry in mtab after failed mount" && rc=11
408 cleanup_nocli || rc=$?
411 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
414 grep " $MOUNT " /etc/mtab && \
415 error false "unexpected entry in mtab before mount" && return 10
421 mount_client $MOUNT || rc=1
423 grep " $MOUNT " /etc/mtab && \
424 error "$MOUNT entry in mtab after unmount" && rc=11
427 run_test 5d "mount with ost down"
430 grep " $MOUNT " /etc/mtab && \
431 error false "unexpected entry in mtab before mount" && return 10
437 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
438 do_facet client "lctl set_param fail_loc=0x80000506"
439 mount_client $MOUNT || echo "mount failed (not fatal)"
441 grep " $MOUNT " /etc/mtab && \
442 error "$MOUNT entry in mtab after unmount" && rc=11
445 run_test 5e "delayed connect, don't crash (bug 10268)"
448 if combined_mgs_mds ; then
449 skip "combined mgs and mds"
453 grep " $MOUNT " /etc/mtab && \
454 error false "unexpected entry in mtab before mount" && return 10
458 [ -d $MOUNT ] || mkdir -p $MOUNT
459 mount_client $MOUNT &
461 echo client_mount pid is $pid
465 if ! ps -f -p $pid >/dev/null; then
468 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
469 error "mount returns $rc, expected to hang"
478 # mount should succeed after start mds
481 [ $rc -eq 0 ] || error "mount returned $rc"
482 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
486 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
491 mount_client ${MOUNT} || return 87
492 touch $DIR/a || return 86
495 run_test 6 "manual umount, then mount again"
500 cleanup_nocli || return $?
502 run_test 7 "manual umount, then cleanup"
507 check_mount2 || return 45
508 umount_client $MOUNT2
511 run_test 8 "double mount setup"
516 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
517 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
519 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
520 if [ "$CHECK_PTLDEBUG" ] && { \
521 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
522 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
523 echo "lnet.debug success"
525 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
528 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
529 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
530 echo "lnet.subsystem_debug success"
532 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
535 stop_ost || return $?
537 run_test 9 "test ptldebug and subsystem for mkfs"
545 do_facet $facet "test -b $dev" || rc=1
546 if [[ "$size" ]]; then
547 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
548 awk '($3 == "in") { print $1 }')
549 [[ $in = "1+0" ]] || rc=1
555 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
556 # But with new MDS stack we don't care about the mode of local objects
557 # anymore, so this test is removed. See bug 22944 for more details.
562 check_mount || return 41
565 echo "Remove mds config log"
566 if ! combined_mgs_mds ; then
570 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MGSDEV || return \$?" || return $?
572 if ! combined_mgs_mds ; then
577 start_mds && return 42
580 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
583 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
584 skip "Only applicable to ldiskfs-based MDTs"
588 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
593 # check if current MDSSIZE is large enough
594 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
595 log "use MDSSIZE=$MDSSIZE"
597 # check if the global config has a large enough MDSSIZE
598 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
599 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
600 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
602 # check if the block device is large enough
603 [ -z "$OK" ] && $(is_blkdev $SINGLEMDS $MDSDEV $MIN) && OK=1 &&
604 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
606 # check if a loopback device has enough space for fs metadata (5%)
608 if [ -z "$OK" ]; then
609 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
610 awk '($1 != "Filesystem") {print $4}')
611 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
612 OK=1 && myMDSSIZE=$MIN && \
613 log "use file $MDSDEV with MIN=$MIN"
616 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
619 echo "mount mds with large journal..."
621 local OLD_MDSSIZE=$MDSSIZE
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"
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
730 run_test 21d "start mgs then ost and then mds"
735 echo Client mount with ost in logs, but none running
737 # wait until mds connected to ost and open client connection
738 wait_osc_import_state mds ost FULL
741 # check_mount will block trying to contact ost
742 mcreate $DIR/$tfile || return 40
743 rm -f $DIR/$tfile || return 42
747 echo Client mount with a running ost
750 # if gss enabled, wait full time to let connection from
751 # mds to ost be established, due to the mismatch between
752 # initial connect timeout and gss context negotiation timeout.
753 # This perhaps could be remove after AT landed.
754 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
755 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
758 wait_osc_import_state mds ost FULL
759 wait_osc_import_state client ost FULL
760 check_mount || return 41
765 run_test 22 "start a client before osts (should return errs)"
767 test_23a() { # was test_23
771 # force down client so that recovering mds waits for reconnect
772 local running=$(grep -c $MOUNT /proc/mounts) || true
773 if [ $running -ne 0 ]; then
774 echo "Stopping client $MOUNT (opts: -f)"
778 # enter recovery on mds
780 # try to start a new client
781 mount_client $MOUNT &
783 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
784 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
785 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
787 ps --ppid $MOUNT_LUSTRE_PID
788 echo "waiting for mount to finish"
790 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
791 # SIGTERM works but it does not spread to offspring processses
792 kill -s TERM $MOUNT_PID
793 kill -s TERM $MOUNT_LUSTRE_PID
794 # we can not wait $MOUNT_PID because it is not a child of this shell
800 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
802 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
803 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
806 [ -z "$PID1" -a -z "$PID2" ] && break
807 echo "waiting for mount to finish ... "
808 WAIT=$(( WAIT + sleep))
810 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
811 error "MOUNT_PID $MOUNT_PID and "\
812 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
818 run_test 23a "interrupt client during recovery mount delay"
823 test_23b() { # was test_23
826 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
827 lctl set_param fail_loc=0x80000313
831 run_test 23b "Simulate -EINTR during mount"
833 fs2mds_HOST=$mds_HOST
834 fs2ost_HOST=$ost_HOST
836 MDSDEV1_2=$fs2mds_DEV
837 OSTDEV1_2=$fs2ost_DEV
838 OSTDEV2_2=$fs3ost_DEV
842 echo "umount $MOUNT2 ..."
843 umount $MOUNT2 || true
844 echo "stopping fs2mds ..."
845 stop fs2mds -f || true
846 echo "stopping fs2ost ..."
847 stop fs2ost -f || true
851 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
853 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
854 is_blkdev $SINGLEMDS $MDSDEV && \
855 skip_env "mixed loopback and real device not working" && return
858 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
860 local fs2mdsdev=$(mdsdevname 1_2)
861 local fs2ostdev=$(ostdevname 1_2)
862 local fs2mdsvdev=$(mdsvdevname 1_2)
863 local fs2ostvdev=$(ostvdevname 1_2)
865 # test 8-char fsname as well
866 local FSNAME2=test1234
867 add fs2mds $(mkfs_opts mds1) --nomgs --mgsnode=$MGSNID \
868 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
870 add fs2ost $(mkfs_opts ost1) --fsname=${FSNAME2} --reformat \
871 $fs2ostdev $fs2ostvdev || exit 10
874 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
875 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
877 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
879 check_mount || return 2
880 # files written on 1 should not show up on 2
881 cp /etc/passwd $DIR/$tfile
883 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
886 cp /etc/passwd $MOUNT2/b || return 3
887 rm $MOUNT2/b || return 4
888 # 2 is actually mounted
889 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
891 facet_failover fs2mds
892 facet_failover fs2ost
895 # the MDS must remain up until last MDT
897 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
898 [ -z "$MDS" ] && error "No MDT" && return 8
900 cleanup_nocli || return 6
902 run_test 24a "Multiple MDTs on a single node"
905 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
907 if [ -z "$fs2mds_DEV" ]; then
908 local dev=${SINGLEMDS}_dev
910 is_blkdev $SINGLEMDS $MDSDEV && \
911 skip_env "mixed loopback and real device not working" && return
914 local fs2mdsdev=$(mdsdevname 1_2)
915 local fs2mdsvdev=$(mdsvdevname 1_2)
917 add fs2mds $(mkfs_opts mds1) --mgs --fsname=${FSNAME}2 --reformat \
918 $fs2mdsdev $fs2mdsvdev || exit 10
920 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
923 run_test 24b "Multiple MGSs on a single node (should return err)"
927 check_mount || return 2
928 local MODULES=$($LCTL modules | awk '{ print $2 }')
929 rmmod $MODULES 2>/dev/null || true
932 run_test 25 "Verify modules are referenced"
936 # we need modules before mount for sysctl, so make sure...
937 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
938 #define OBD_FAIL_MDS_FS_SETUP 0x135
939 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
940 start_mds && echo MDS started && return 1
941 lctl get_param -n devices
942 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
943 [ $DEVS -gt 0 ] && return 2
944 # start mds to drop writeconf setting
945 start_mds || return 3
947 unload_modules_conf || return $?
949 run_test 26 "MDT startup failure cleans LOV (should return errs)"
955 local ORIG=$(do_facet $myfacet "$TEST")
956 if [ $# -gt 3 ]; then
962 echo "Setting $PARAM from $ORIG to $FINAL"
963 do_facet mgs "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
965 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
969 start_ost || return 1
970 start_mds || return 2
971 echo "Requeue thread should have started: "
972 ps -e | grep ll_cfg_requeue
973 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
976 run_test 27a "Reacquire MGS lock if OST started first"
981 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
983 facet_failover $SINGLEMDS
984 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
985 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
989 run_test 27b "Reacquire MGS lock after failover"
993 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
994 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
997 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
998 FINAL=$(($FINAL + 1))
999 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
1000 umount_client $MOUNT || return 200
1003 if [ $RESULT -ne $FINAL ]; then
1004 echo "New config not seen: wanted $FINAL got $RESULT"
1007 echo "New config success: got $RESULT"
1009 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
1012 run_test 28 "permanent parameter setting"
1015 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1016 setup > /dev/null 2>&1
1020 local PARAM="$FSNAME-OST0001.osc.active"
1021 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1022 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1024 ACTV=$(lctl get_param -n $PROC_ACT)
1026 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1027 # also check ost_server_uuid status
1028 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1029 if [ -z "$RESULT" ]; then
1030 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1033 echo "Live client success: got $RESULT"
1037 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0001)
1038 mdtosc=${mdtosc/-MDT*/-MDT\*}
1039 local MPROC="osc.$mdtosc.active"
1044 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
1045 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1046 if [ $RESULT -eq $DEAC ]; then
1047 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
1051 if [ $WAIT -eq $MAX ]; then
1052 echo "MDT not deactivated: wanted $DEAC got $RESULT"
1055 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
1058 # quotacheck should not fail immediately after deactivate
1059 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1061 # test new client starts deactivated
1062 umount_client $MOUNT || return 200
1064 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1065 if [ -z "$RESULT" ]; then
1066 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1069 echo "New client success: got $RESULT"
1072 # quotacheck should not fail after umount/mount operation
1073 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1075 # make sure it reactivates
1076 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1078 umount_client $MOUNT
1081 #writeconf to remove all ost2 traces for subsequent tests
1084 run_test 29 "permanently remove an OST"
1089 echo Big config llog
1090 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1092 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1093 for i in ${LIST[@]}; do
1094 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1096 # make sure client restart still works
1097 umount_client $MOUNT
1098 mount_client $MOUNT || return 4
1099 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1102 echo Erase parameter setting
1103 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1104 umount_client $MOUNT
1105 mount_client $MOUNT || return 6
1107 echo "deleted (default) value=$FINAL, orig=$ORIG"
1108 # assumes this parameter started at the default value
1109 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1113 run_test 30a "Big config llog and conf_param deletion"
1118 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1119 # numerical part of it. Hopefully that's not already a failover address for
1121 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1122 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1123 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1124 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1125 echo "Using fake nid $NEW"
1127 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1128 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
1129 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1131 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1132 echo "should have 2 failover nids: $NIDCOUNT"
1133 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1134 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1135 umount_client $MOUNT
1136 mount_client $MOUNT || return 3
1138 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1140 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1141 echo "only 1 final nid should remain: $NIDCOUNT"
1142 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1146 run_test 30b "Remove failover nids"
1148 test_31() { # bug 10734
1149 # ipaddr must not exist
1150 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1153 run_test 31 "Connect to non-existent node (shouldn't crash)"
1155 # Use these start32/stop32 fn instead of t-f start/stop fn,
1156 # for local devices, to skip global facet vars init
1160 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1161 umount -d $@ ${MOUNT%/*}/${facet}
1170 mkdir -p ${MOUNT%/*}/${facet}
1172 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1173 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1175 if [ $RC -ne 0 ]; then
1176 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1177 echo "Start of ${device} of local ${facet} failed ${RC}"
1183 cleanup_nocli32 () {
1191 echo "Cleanup test_32 umount $MOUNT ..."
1192 umount -f $MOUNT || true
1193 echo "Cleanup local mds ost1 ..."
1195 combined_mgs_mds || start_mgs
1200 client_only && skip "client only testing" && return 0
1201 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1202 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1204 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1205 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1206 local tmpdir=$TMP/conf32a
1208 tar xjvf $DISK1_8 -C $tmpdir || \
1209 { skip_env "Cannot untar $DISK1_8" && return 0; }
1212 $LCTL set_param debug="$PTLDEBUG"
1214 $TUNEFS $tmpdir/mds || error "tunefs failed"
1216 combined_mgs_mds || stop mgs
1218 # nids are wrong, so client wont work, but server should start
1219 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1220 trap cleanup_32 EXIT INT || return 3
1222 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1224 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1226 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1227 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1228 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1230 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1232 local NID=$($LCTL list_nids | head -1)
1234 echo "OSC changes should succeed:"
1235 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1236 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1239 echo "MDC changes should succeed:"
1240 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1241 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1244 echo "LOV changes should succeed:"
1245 $LCTL pool_new lustre.interop || return 11
1246 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1251 # mount a second time to make sure we didnt leave upgrade flag on
1253 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1255 combined_mgs_mds || stop mgs
1257 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1258 trap cleanup_32 EXIT INT || return 12
1262 rm -rf $tmpdir || true # true is only for TMP on NFS
1264 run_test 32a "Upgrade from 1.8 (not live)"
1267 client_only && skip "client only testing" && return 0
1268 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1269 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1271 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1272 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1273 local tmpdir=$TMP/conf32b
1275 tar xjvf $DISK1_8 -C $tmpdir || \
1276 { skip_env "Cannot untar $DISK1_8" && return ; }
1279 $LCTL set_param debug="+config"
1280 local NEWNAME=lustre
1282 # writeconf will cause servers to register with their current nids
1283 $TUNEFS --writeconf --erase-params \
1284 --param mdt.identity_upcall=$L_GETIDENTITY \
1285 --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1286 combined_mgs_mds || stop mgs
1288 start32 mds1 $tmpdir/mds "-o loop" && \
1289 trap cleanup_32 EXIT INT || return 3
1291 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1293 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1295 $TUNEFS --writeconf --erase-params \
1296 --mgsnode=$HOSTNAME --fsname=$NEWNAME $tmpdir/ost1 ||\
1297 error "tunefs failed"
1298 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1299 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1301 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1303 local NID=$($LCTL list_nids | head -1)
1305 echo "OSC changes should succeed:"
1306 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1307 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1310 echo "MDC changes should succeed:"
1311 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1312 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1315 echo "LOV changes should succeed:"
1316 $LCTL pool_new ${NEWNAME}.interop || return 11
1317 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1320 # MDT and OST should have registered with new nids, so we should have
1321 # a fully-functioning client
1322 echo "Check client and old fs contents"
1324 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1325 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1326 mount -t lustre $device $MOUNT || return 1
1328 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1329 local new=$((old + 5))
1330 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1331 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1333 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1338 rm -rf $tmpdir || true # true is only for TMP on NFS
1340 run_test 32b "Upgrade from 1.8 with writeconf"
1342 test_33a() { # bug 12333, was test_33
1344 local FSNAME2=test-123
1345 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1348 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1350 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1351 local dev=${SINGLEMDS}_dev
1352 local MDSDEV=${!dev}
1353 is_blkdev $SINGLEMDS $MDSDEV && \
1354 skip_env "mixed loopback and real device not working" && return
1357 local fs2mdsdev=$(mdsdevname 1_2)
1358 local fs2ostdev=$(ostdevname 1_2)
1359 local fs2mdsvdev=$(mdsvdevname 1_2)
1360 local fs2ostvdev=$(ostvdevname 1_2)
1362 if [ $(facet_fstype mds1) == ldiskfs ]; then
1363 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
1366 add fs2mds $(mkfs_opts mds1) --fsname=${FSNAME2} --reformat \
1367 $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
1368 add fs2ost $(mkfs_opts ost1) --mgsnode=$MGSNID --fsname=${FSNAME2} \
1369 --index=8191 --reformat $fs2ostdev $fs2ostvdev || exit 10
1371 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1372 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1373 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1375 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1378 cp /etc/hosts $MOUNT2/ || rc=3
1379 $LFS getstripe $MOUNT2/hosts
1384 cleanup_nocli || rc=6
1387 run_test 33a "Mount ost with a large index number"
1389 test_33b() { # was test_34
1392 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1393 # Drop lock cancelation reply during umount
1394 #define OBD_FAIL_LDLM_CANCEL 0x304
1395 do_facet client lctl set_param fail_loc=0x80000304
1396 #lctl set_param debug=-1
1397 umount_client $MOUNT
1400 run_test 33b "Drop cancel during umount"
1404 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1405 manual_umount_client
1407 do_facet client killall -USR1 multiop
1408 if [ $rc -eq 0 ]; then
1409 error "umount not fail!"
1414 run_test 34a "umount with opened file should be fail"
1419 touch $DIR/$tfile || return 1
1420 stop_mds --force || return 2
1422 manual_umount_client --force
1424 if [ $rc -ne 0 ]; then
1425 error "mtab after failed umount - rc $rc"
1431 run_test 34b "force umount with failed mds should be normal"
1435 touch $DIR/$tfile || return 1
1436 stop_ost --force || return 2
1438 manual_umount_client --force
1440 if [ $rc -ne 0 ]; then
1441 error "mtab after failed umount - rc $rc"
1447 run_test 34c "force umount with failed ost should be normal"
1449 test_35a() { # bug 12459
1452 DBG_SAVE="`lctl get_param -n debug`"
1453 lctl set_param debug="ha"
1455 log "Set up a fake failnode for the MDS"
1457 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1458 do_facet mgs $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1460 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1463 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1466 log "Stopping the MDT:"
1467 stop_mds || return 5
1469 df $MOUNT > /dev/null 2>&1 &
1471 log "Restarting the MDT:"
1472 start_mds || return 6
1473 log "Wait for df ($DFPID) ... "
1476 lctl set_param debug="$DBG_SAVE"
1478 # retrieve from the log the first server that the client tried to
1479 # contact after the connection loss
1480 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1481 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1482 /import_select_connection.*$device-mdc.* using connection/ {
1484 if (\\\$NF ~ /$FAKENID/)
1490 }" $TMP/lustre-log-$TESTNAME.log`
1491 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1493 # remove nid settings
1496 run_test 35a "Reconnect to the last active server first"
1498 test_35b() { # bug 18674
1499 remote_mds || { skip "local MDS" && return 0; }
1503 $LCTL set_param debug="ha"
1505 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1508 log "Set up a fake failnode for the MDS"
1510 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | \
1511 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1512 do_facet mgs "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1515 local at_max_saved=0
1516 # adaptive timeouts may prevent seeing the issue
1517 if at_is_enabled; then
1518 at_max_saved=$(at_max_get mds)
1519 at_max_set 0 mds client
1522 mkdir -p $MOUNT/$tdir
1524 log "Injecting EBUSY on MDS"
1525 # Setting OBD_FAIL_MDS_RESEND=0x136
1526 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
1528 $LCTL set_param mdc.${FSNAME}*.stats=clear
1530 log "Creating a test file and stat it"
1531 touch $MOUNT/$tdir/$tfile
1532 stat $MOUNT/$tdir/$tfile
1534 log "Stop injecting EBUSY on MDS"
1535 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
1536 rm -f $MOUNT/$tdir/$tfile
1539 # restore adaptive timeout
1540 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1542 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1544 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
1546 # retrieve from the log if the client has ever tried to
1547 # contact the fake server after the loss of connection
1548 FAILCONN=`awk "BEGIN {ret = 0;}
1549 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1551 if (\\\$NF ~ /$FAKENID/) {
1556 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1558 [ "$FAILCONN" == "0" ] && \
1559 log "ERROR: The client reconnection has not been triggered" && \
1561 [ "$FAILCONN" == "2" ] && \
1562 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1566 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
1567 # Reconnects are supposed to be rate limited to one every 5s
1568 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
1569 log "ERROR: Too many reconnects $CONNCNT" && \
1573 # remove nid settings
1576 run_test 35b "Continue reconnection retries, if the active server is busy"
1579 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1581 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1582 { skip "remote OST" && return 0; }
1585 local FSNAME2=test1234
1586 local fs3ost_HOST=$ost_HOST
1587 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1589 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1591 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1592 is_blkdev $SINGLEMDS $MDSDEV && \
1593 skip_env "mixed loopback and real device not working" && return
1596 local fs2mdsdev=$(mdsdevname 1_2)
1597 local fs2ostdev=$(ostdevname 1_2)
1598 local fs3ostdev=$(ostdevname 2_2)
1599 local fs2mdsvdev=$(mdsvdevname 1_2)
1600 local fs2ostvdev=$(ostvdevname 1_2)
1601 local fs3ostvdev=$(ostvdevname 2_2)
1603 add fs2mds $(mkfs_opts mds1) --fsname=${FSNAME2} --reformat \
1604 $fs2mdsdev $fs2mdsvdev || exit 10
1605 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
1606 # different one than the default value here.
1607 add fs2ost $(mkfs_opts ost1) --mgsnode=$MGSNID --fsname=${FSNAME2} \
1608 --reformat $fs2ostdev $fs2ostvdev || exit 10
1609 add fs3ost $(mkfs_opts ost1) --mgsnode=$MGSNID --fsname=${FSNAME2} \
1610 --reformat $fs3ostdev $fs3ostvdev || exit 10
1612 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1613 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1614 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1616 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1618 sleep 5 # until 11778 fixed
1620 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1622 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1623 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1624 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1625 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1626 DFTOTAL=`echo $STRING | cut -d, -f1`
1627 DFUSED=`echo $STRING | cut -d, -f2`
1628 DFAVAIL=`echo $STRING | cut -d, -f3`
1629 DFFREE=$(($DFTOTAL - $DFUSED))
1631 ALLOWANCE=$((64 * $OSTCOUNT))
1633 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1634 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1635 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1638 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1639 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1640 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1643 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1644 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1645 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1650 stop fs3ost -f || return 200
1651 stop fs2ost -f || return 201
1652 stop fs2mds -f || return 202
1653 unload_modules_conf || return 203
1656 run_test 36 "df report consistency on OSTs with different block size"
1659 local mntpt=$(facet_mntpt $SINGLEMDS)
1660 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
1661 local mdsdev_sym="$TMP/sym_mdt.img"
1662 local opts=$MDS_MOUNT_OPTS
1665 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
1666 skip "Currently only applicable to ldiskfs-based MDTs"
1670 echo "MDS : $mdsdev"
1671 echo "SYMLINK : $mdsdev_sym"
1672 do_facet $SINGLEMDS rm -f $mdsdev_sym
1674 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
1676 echo "mount symlink device - $mdsdev_sym"
1678 if ! do_facet $SINGLEMDS test -b $mdsdev; then
1679 opts=$(csa_add "$opts" -o loop)
1681 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
1682 $mdsdev_sym $mntpt 2>&1)
1685 echo mount_op=$mount_op
1687 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
1689 if $(echo $mount_op | grep -q "unable to set tunable"); then
1690 error "set tunables failed for symlink device"
1693 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
1697 run_test 37 "verify set tunables works for symlink device"
1699 test_38() { # bug 14222
1704 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1705 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1707 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1708 error "copying $SRC to $DIR/$tdir"
1710 umount_client $MOUNT
1712 log "rename lov_objid file on MDS"
1713 rm -f $TMP/lov_objid.orig
1715 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1716 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1717 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1719 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1720 # check create in mds_lov_connect
1724 [ $V ] && log "verifying $DIR/$tdir/$f"
1725 diff -q $f $DIR/$tdir/$f || ERROR=y
1727 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1728 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1729 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1731 # check it's updates in sync
1732 umount_client $MOUNT
1735 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1736 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1737 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1742 [ $V ] && log "verifying $DIR/$tdir/$f"
1743 diff -q $f $DIR/$tdir/$f || ERROR=y
1745 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1746 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1747 umount_client $MOUNT
1749 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1751 log "files compared the same"
1754 run_test 38 "MDS recreates missing lov_objid file from OST data"
1760 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1761 error "memory leak detected" || true
1763 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1765 test_40() { # bug 15759
1767 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1768 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
1772 run_test 40 "race during service thread startup"
1774 test_41a() { #bug 14134
1775 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
1776 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
1777 skip "Loop devices does not work with nosvc option"
1782 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1784 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1785 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1786 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1788 mount_client $MOUNT || return 1
1791 echo "blah blah" > $MOUNT/$tfile
1794 umount_client $MOUNT
1795 stop ost1 -f || return 201
1796 stop_mds -f || return 202
1797 stop_mds -f || return 203
1798 unload_modules_conf || return 204
1801 run_test 41a "mount mds with --nosvc and --nomgs"
1804 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
1805 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
1806 skip "Loop devices does not work with nosvc option"
1810 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
1814 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1816 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1818 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1820 mount_client $MOUNT || return 1
1823 echo "blah blah" > $MOUNT/$tfile
1824 cat $MOUNT/$tfile || return 200
1826 umount_client $MOUNT
1827 stop_ost || return 201
1828 stop_mds -f || return 202
1829 stop_mds -f || return 203
1832 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
1834 test_42() { #bug 14693
1836 check_mount || return 2
1837 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1838 umount_client $MOUNT
1839 mount_client $MOUNT || return 1
1843 run_test 42 "invalid config param should not prevent client from mounting"
1846 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1848 chmod ugo+x $DIR || error "chmod 0 failed"
1850 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1851 "$FSNAME.mdt.root_squash" \
1854 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1855 "$FSNAME.mdt.nosquash_nids" \
1859 # create set of test files
1861 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1862 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1863 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1865 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1866 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1868 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1869 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1870 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1873 # check root_squash:
1874 # set root squash UID:GID to RUNAS_ID
1875 # root should be able to access only files owned by RUNAS_ID
1878 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1879 "$FSNAME.mdt.root_squash" \
1880 "$RUNAS_ID:$RUNAS_ID"
1882 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1883 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1884 error "$ST: root read permission is denied"
1885 echo "$ST: root read permission is granted - ok"
1888 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1889 error "$ST: root write permission is denied"
1890 echo "$ST: root write permission is granted - ok"
1892 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1893 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1894 error "$ST: root read permission is granted"
1895 echo "$ST: root read permission is denied - ok"
1898 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1899 error "$ST: root write permission is granted"
1900 echo "$ST: root write permission is denied - ok"
1902 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1903 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1904 error "$ST: root unlink permission is granted"
1905 echo "$ST: root unlink permission is denied - ok"
1907 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1908 error "$ST: root create permission is granted"
1909 echo "$ST: root create permission is denied - ok"
1912 # check nosquash_nids:
1913 # put client's NID into nosquash_nids list,
1914 # root should be able to access root file after that
1916 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1917 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1918 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1920 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1921 "$FSNAME-MDTall.mdt.nosquash_nids" \
1924 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1925 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1926 error "$ST: root read permission is denied"
1927 echo "$ST: root read permission is granted - ok"
1930 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1931 error "$ST: root write permission is denied"
1932 echo "$ST: root write permission is granted - ok"
1934 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1935 rm $DIR/$tdir-rootdir/tfile-1 || \
1936 error "$ST: root unlink permission is denied"
1937 echo "$ST: root unlink permission is granted - ok"
1938 touch $DIR/$tdir-rootdir/tfile-2 || \
1939 error "$ST: root create permission is denied"
1940 echo "$ST: root create permission is granted - ok"
1944 run_test 43 "check root_squash and nosquash_nids"
1946 umount_client $MOUNT
1951 check_mount || return 2
1952 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1954 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1955 for VAL in $UUIDS; do
1956 NID=$(echo $VAL | cut -d= -f1)
1957 CLUUID=$(echo $VAL | cut -d= -f2)
1958 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1960 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1964 run_test 44 "mounted client proc entry exists"
1968 check_mount || return 2
1973 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1974 do_facet client "lctl set_param fail_loc=0x50f"
1977 manual_umount_client --force || return 3
1978 do_facet client "lctl set_param fail_loc=0x0"
1980 mount_client $MOUNT || return 4
1984 run_test 45 "long unlink handling in ptlrpcd"
1991 umount_client $MOUNT2 || rc=$?
1992 umount_client $MOUNT || rc=$?
1993 while [ $count -gt 0 ]; do
1994 stop ost${count} -f || rc=$?
1998 cleanup_nocli || rc=$?
1999 #writeconf to remove all ost2 traces for subsequent tests
2005 echo "Testing with $OSTCOUNT OSTs"
2007 start_mds || return 1
2008 #first client should see only one ost
2009 start_ost || return 2
2010 wait_osc_import_state mds ost FULL
2012 mount_client $MOUNT || return 3
2013 trap "cleanup_46a $OSTCOUNT" EXIT ERR
2016 for (( i=2; i<=$OSTCOUNT; i++ )); do
2017 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
2020 # wait until osts in sync
2021 for (( i=2; i<=$OSTCOUNT; i++ )); do
2022 wait_osc_import_state mds ost$i FULL
2023 wait_osc_import_state client ost$i FULL
2026 #second client see all ost's
2028 mount_client $MOUNT2 || return 8
2029 $LFS setstripe -c -1 $MOUNT2 || return 9
2030 $LFS getstripe $MOUNT2 || return 10
2032 echo "ok" > $MOUNT2/widestripe
2033 $LFS getstripe $MOUNT2/widestripe || return 11
2034 # fill acl buffer for avoid expand lsm to them
2035 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
2036 setfacl -m $acl $MOUNT2/widestripe
2040 stat $MOUNT/widestripe || return 12
2042 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
2045 run_test 46a "handle ost additional - wide striped file"
2050 check_mount || return 2
2051 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2055 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2056 if echo $ns | grep "MDT[[:digit:]]*"; then
2059 lrs=$(echo $ns | sed 's/.*lru_size=//')
2060 lru_size[count]=$lrs
2065 facet_failover $SINGLEMDS
2066 client_up || return 3
2069 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2070 if echo $ns | grep "MDT[[:digit:]]*"; then
2073 lrs=$(echo $ns | sed 's/.*lru_size=//')
2074 if ! test "$lrs" -eq "${lru_size[count]}"; then
2075 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2076 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2084 run_test 47 "server restart does not make client loss lru_resize settings"
2089 # reformat after this test is needed - if test will failed
2090 # we will have unkillable file at FS
2094 test_48() { # bug 17636
2097 check_mount || return 2
2099 $LFS setstripe -c -1 $MOUNT || return 9
2100 $LFS getstripe $MOUNT || return 10
2102 echo "ok" > $MOUNT/widestripe
2103 $LFS getstripe $MOUNT/widestripe || return 11
2105 trap cleanup_48 EXIT ERR
2107 # fill acl buffer for avoid expand lsm to them
2108 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2109 setfacl -m $acl $MOUNT/widestripe
2112 stat $MOUNT/widestripe || return 12
2117 run_test 48 "too many acls on file"
2119 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2120 test_49() { # bug 17710
2121 local timeout_orig=$TIMEOUT
2122 local ldlm_timeout_orig=$LDLM_TIMEOUT
2123 local LOCAL_TIMEOUT=20
2125 LDLM_TIMEOUT=$LOCAL_TIMEOUT
2126 TIMEOUT=$LOCAL_TIMEOUT
2130 check_mount || return 1
2132 echo "check ldlm_timout..."
2133 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2134 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2135 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2137 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2138 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2141 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2142 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2145 umount_client $MOUNT
2146 stop_ost || return 2
2147 stop_mds || return 3
2149 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
2153 check_mount || return 7
2155 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2156 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2157 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2159 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2160 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2163 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2164 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2167 cleanup || return $?
2169 LDLM_TIMEOUT=$ldlm_timeout_orig
2170 TIMEOUT=$timeout_orig
2172 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
2175 # Test both statfs and lfs df and fail if either one fails
2176 multiop_bg_pause $1 f_
2179 killall -USR1 multiop
2180 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2181 wait $PID || { RC1=$?; log "multiop return error "; }
2188 if [ $RC2 -eq 0 ]; then
2190 log "lazystatfs df failed"
2194 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2200 lctl set_param llite.$FSNAME-*.lazystatfs=1
2203 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2205 cleanup || return $?
2207 run_test 50a "lazystatfs all servers available =========================="
2211 lctl set_param llite.$FSNAME-*.lazystatfs=1
2214 # Wait for client to detect down OST
2215 stop_ost || error "Unable to stop OST1"
2216 wait_osc_import_state mds ost DISCONN
2218 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2220 umount_client $MOUNT || error "Unable to unmount client"
2221 stop_mds || error "Unable to stop MDS"
2223 run_test 50b "lazystatfs all servers down =========================="
2226 start_mds || error "Unable to start MDS"
2227 start_ost || error "Unable to start OST1"
2228 start_ost2 || error "Unable to start OST2"
2229 mount_client $MOUNT || error "Unable to mount client"
2230 lctl set_param llite.$FSNAME-*.lazystatfs=1
2233 # Wait for client to detect down OST
2234 stop_ost || error "Unable to stop OST1"
2235 wait_osc_import_state mds ost DISCONN
2236 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2238 umount_client $MOUNT || error "Unable to unmount client"
2239 stop_ost2 || error "Unable to stop OST2"
2240 stop_mds || error "Unable to stop MDS"
2241 #writeconf to remove all ost2 traces for subsequent tests
2244 run_test 50c "lazystatfs one server down =========================="
2247 start_mds || error "Unable to start MDS"
2248 start_ost || error "Unable to start OST1"
2249 start_ost2 || error "Unable to start OST2"
2250 mount_client $MOUNT || error "Unable to mount client"
2251 lctl set_param llite.$FSNAME-*.lazystatfs=1
2254 # Issue the statfs during the window where the client still
2255 # belives the OST to be available but it is in fact down.
2256 # No failure just a statfs which hangs for a timeout interval.
2257 stop_ost || error "Unable to stop OST1"
2258 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2260 umount_client $MOUNT || error "Unable to unmount client"
2261 stop_ost2 || error "Unable to stop OST2"
2262 stop_mds || error "Unable to stop MDS"
2263 #writeconf to remove all ost2 traces for subsequent tests
2266 run_test 50d "lazystatfs client/server conn race =========================="
2273 start_mds || return 1
2274 #first client should see only one ost
2275 start_ost || return 2
2276 wait_osc_import_state mds ost FULL
2278 # Wait for client to detect down OST
2279 stop_ost || error "Unable to stop OST1"
2280 wait_osc_import_state mds ost DISCONN
2282 mount_client $MOUNT || error "Unable to mount client"
2283 lctl set_param llite.$FSNAME-*.lazystatfs=0
2285 multiop_bg_pause $MOUNT _f
2289 if [ $RC1 -ne 0 ]; then
2290 log "multiop failed $RC1"
2293 sleep $(( $TIMEOUT+1 ))
2295 [ $? -ne 0 ] && error "process isn't sleep"
2296 start_ost || error "Unable to start OST1"
2297 wait $pid || error "statfs failed"
2300 umount_client $MOUNT || error "Unable to unmount client"
2301 stop_ost || error "Unable to stop OST1"
2302 stop_mds || error "Unable to stop MDS"
2304 run_test 50e "normal statfs all servers down =========================="
2309 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2311 start_mds || error "Unable to start mds"
2312 #first client should see only one ost
2313 start_ost || error "Unable to start OST1"
2314 wait_osc_import_state mds ost FULL
2316 start_ost2 || error "Unable to start OST2"
2317 wait_osc_import_state mds ost2 FULL
2319 # Wait for client to detect down OST
2320 stop_ost2 || error "Unable to stop OST2"
2322 wait_osc_import_state mds ost2 DISCONN
2323 mount_client $MOUNT || error "Unable to mount client"
2324 lctl set_param llite.$FSNAME-*.lazystatfs=0
2326 multiop_bg_pause $MOUNT _f
2330 if [ $RC1 -ne 0 ]; then
2331 log "lazystatfs multiop failed $RC1"
2334 sleep $(( $TIMEOUT+1 ))
2336 [ $? -ne 0 ] && error "process isn't sleep"
2337 start_ost2 || error "Unable to start OST2"
2338 wait $pid || error "statfs failed"
2339 stop_ost2 || error "Unable to stop OST2"
2342 umount_client $MOUNT || error "Unable to unmount client"
2343 stop_ost || error "Unable to stop OST1"
2344 stop_mds || error "Unable to stop MDS"
2345 #writeconf to remove all ost2 traces for subsequent tests
2348 run_test 50f "normal statfs one server in down =========================="
2351 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2353 start_ost2 || error "Unable to start OST2"
2354 wait_osc_import_state mds ost2 FULL
2355 wait_osc_import_state client ost2 FULL
2357 local PARAM="${FSNAME}-OST0001.osc.active"
2359 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2360 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2362 umount_client $MOUNT || error "Unable to unmount client"
2363 mount_client $MOUNT || error "Unable to mount client"
2364 # This df should not cause a panic
2367 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2369 umount_client $MOUNT || error "Unable to unmount client"
2370 stop_ost2 || error "Unable to stop OST2"
2371 stop_ost || error "Unable to stop OST1"
2372 stop_mds || error "Unable to stop MDS"
2373 #writeconf to remove all ost2 traces for subsequent tests
2376 run_test 50g "deactivated OST should not cause panic====================="
2379 local LOCAL_TIMEOUT=20
2383 check_mount || return 1
2386 $LFS setstripe -c -1 $MOUNT/d1
2387 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2388 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2389 touch $MOUNT/d1/f1 &
2392 start_ost2 || return 2
2394 stop_ost2 || return 3
2396 #writeconf to remove all ost2 traces for subsequent tests
2399 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2408 do_node $node mkdir -p $dest
2409 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2411 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2412 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2413 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2415 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2416 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2426 local backup2=${TMP}/backup2
2428 do_node $node mkdir -p $backup2
2429 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2431 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2432 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2433 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2435 do_node $node "diff -rq $backup $backup2"
2436 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2438 local xattrs2=${TMP}/xattrs2
2439 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2440 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2442 do_node $node "diff $xattrs $xattrs2"
2443 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2445 do_node $node "rm -rf $backup2 $xattrs2"
2446 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2451 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2453 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2455 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2458 local ost1mnt=$(facet_mntpt ost1)
2459 local ost1node=$(facet_active_host ost1)
2460 local ost1tmp=$TMP/conf52
2464 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2465 touch $TMP/modified_first
2466 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2467 local mtime=$(stat -c %Y $TMP/modified_first)
2468 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2470 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2473 $LFS setstripe -c -1 -S 1M $DIR/$tdir
2474 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2476 for (( i=0; i < nrfiles; i++ )); do
2477 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2478 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2484 echo backup files to $TMP/files
2485 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2486 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2487 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2489 umount_client $MOUNT
2490 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2492 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2494 echo mount ost1 as ldiskfs
2495 do_node $ost1node mkdir -p $ost1mnt
2496 [ $? -eq 0 ] || { error "Unable to create $ost1mnt"; return 23; }
2497 if ! do_node $ost1node test -b $ost1_dev; then
2500 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
2502 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2505 echo backup objects to $ost1tmp/objects
2506 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2507 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2508 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2509 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2511 # move objects to lost+found
2512 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2513 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2516 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2517 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2519 # compare restored objects against saved ones
2520 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2521 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2523 do_node $ost1node "umount $ost1mnt"
2524 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2527 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2529 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2532 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2533 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2535 rm -rf $TMP/files $TMP/file_xattrs
2536 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2537 do_node $ost1node "rm -rf $ost1tmp"
2538 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2541 run_test 52 "check recovering objects from lost+found"
2543 # Checks threads_min/max/started for some service
2545 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2546 # parameter pattern prefix like 'ost.*.ost'.
2559 local msg="Insane $modname thread counts"
2560 local ncpts=$(check_cpt_number $facet)
2565 check_mount || return 41
2567 # We need to expand $parampat, but it may match multiple parameters, so
2568 # we'll pick the first one
2569 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2570 error "Couldn't expand ${parampat}.threads_min parameter name"
2574 # Remove the .threads_min part
2575 paramp=${paramp%.threads_min}
2577 # Check for sanity in defaults
2578 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2579 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2580 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2581 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2582 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
2583 nthrs=$(expr $tmax - $tmin)
2584 if [ $nthrs -lt $ncpts ]; then
2590 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
2591 skip_env "module parameter forced $facet thread count" &&
2592 tmin=3 && tmax=$((3 * tmax))
2594 # Check that we can change min/max
2595 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + nthrs))"
2596 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - nthrs))"
2597 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2598 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2599 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) && $tmax2 == ($tmax - $nthrs)))' || return $?
2601 # Check that we can set min/max to the same value
2602 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2603 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2604 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2605 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2606 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2608 # Check that we can't set max < min
2609 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2610 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2611 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2612 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
2614 # We need to ensure that we get the module options desired; to do this
2615 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2616 LOAD_MODULES_REMOTE=true
2619 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
2620 setmodopts -a $modname "$newvalue" oldvalue
2624 check_mount || return 41
2626 # Restore previous setting of MODOPTS_*
2627 setmodopts $modname "$oldvalue"
2629 # Check that $opts took
2630 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2631 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2632 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2633 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2636 # Workaround a YALA bug where YALA expects that modules will remain
2637 # loaded on the servers
2638 LOAD_MODULES_REMOTE=false
2645 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
2647 run_test 53a "check OSS thread count params"
2650 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' '16'
2652 run_test 53b "check MDT thread count params"
2655 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p
2656 [ $? -eq 0 ] || error "llverdev failed!"
2659 run_test 54a "test llverdev and partial verify of device"
2663 run_llverfs $MOUNT -p
2664 [ $? -eq 0 ] || error "llverfs failed!"
2667 run_test 54b "test llverfs and partial verify of filesystem"
2671 local max_ost_index=$1
2672 echo -n $(((max_ost_index + 1) * 8))
2676 local mdsdev=$(mdsdevname 1)
2677 local mdsvdev=$(mdsvdevname 1)
2681 add mds1 $(mkfs_opts mds1) --reformat $mdsdev $mdsvdev ||
2683 add ost1 $(mkfs_opts ost1) --index=$i --reformat \
2684 $(ostdevname 1) $(ostvdevname 1)
2690 echo checking size of lov_objid for ost index $i
2691 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2692 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2693 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2695 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2702 run_test 55 "check lov_objid size"
2705 local mds_journal_size_orig=$MDSJOURNALSIZE
2708 add mds1 $(mkfs_opts mds1) --reformat $(mdsdevname 1) $(mdsvdevname 1)
2709 add ost1 $(mkfs_opts ost1) --index=1000 --reformat \
2710 $(ostdevname 1) $(ostvdevname 1)
2711 add ost2 $(mkfs_opts ost2) --index=10000 --reformat \
2712 $(ostdevname 2) $(ostvdevname 2)
2716 start_ost2 || error "Unable to start second ost"
2717 mount_client $MOUNT || error "Unable to mount client"
2720 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
2722 MDSJOURNALSIZE=$mds_journal_size_orig
2725 run_test 56 "check big indexes"
2727 test_57a() { # bug 22656
2728 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2730 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2732 start_ost && error "OST registration from failnode should fail"
2735 run_test 57a "initial registration from failnode should fail (should return errs)"
2738 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2740 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
2742 start_ost || error "OST registration from servicenode should not fail"
2745 run_test 57b "initial registration from servicenode should not fail"
2748 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2751 test_58() { # bug 22658
2752 if [ $(facet_fstype mds) == zfs ]; then
2753 skip "Does not work with ZFS-based MDTs yet"
2758 createmany -o $DIR/$tdir/$tfile-%d 100
2759 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
2760 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
2761 do_facet mds "lctl set_param fail_loc=0x601"
2762 unlinkmany $DIR/$tdir/$tfile-%d 100
2764 local MNTDIR=$(facet_mntpt mds)
2765 # remove all files from the OBJECTS dir
2766 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
2767 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
2768 do_facet mds "umount $MNTDIR"
2769 # restart MDS with missing llog files
2771 do_facet mds "lctl set_param fail_loc=0"
2774 run_test 58 "missing llog files must not prevent MDT from mounting"
2777 start_mgsmds >> /dev/null
2778 local C1=$(count_osts)
2779 if [ $C1 -eq 0 ]; then
2780 start_ost >> /dev/null
2784 echo "original ost count: $C1 (expect > 0)"
2785 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2786 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2787 local C2=$(count_osts)
2788 echo "after mdt writeconf count: $C2 (expect 0)"
2789 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2790 echo "OST start without writeconf should fail:"
2791 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2792 echo "OST start with writeconf should succeed:"
2793 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2794 local C3=$(count_osts)
2795 echo "after ost writeconf count: $C3 (expect 1)"
2796 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2797 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2798 local C4=$(count_osts)
2799 echo "after ost2 writeconf count: $C4 (expect 2)"
2800 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2801 stop_ost2 >> /dev/null
2802 cleanup_nocli >> /dev/null
2803 #writeconf to remove all ost2 traces for subsequent tests
2806 run_test 59 "writeconf mount option"
2808 test_60() { # LU-471
2809 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2810 skip "Only applicable to ldiskfs-based MDTs"
2814 add mds1 $(mkfs_opts mds1) \
2815 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' --reformat \
2816 $(mdsdevname 1) $(mdsvdevname 1) || exit 10
2818 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
2820 [ $rc -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
2822 # MDT default has dirdata feature
2823 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
2824 # we disable uninit_bg feature
2825 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
2826 # we set stride extended options
2827 echo $dump | grep stride > /dev/null || error "stride is not set"
2830 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
2833 local reformat=false
2835 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
2836 { skip "Need MDS version at least 2.1.53"; return 0; }
2838 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2839 ! large_xattr_enabled; then
2841 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
2842 LDISKFS_MKFS_OPTS+=" -O large_xattr"
2843 add $SINGLEMDS $(mkfs_opts $SINGLEMDS) --reformat $mds_dev ||
2844 error "reformatting $mds_dev failed"
2847 setup_noconfig || error "setting up the filesystem failed"
2848 client_up || error "starting client failed"
2850 local file=$DIR/$tfile
2853 local large_value="$(generate_string $(max_xattr_size))"
2854 local small_value="bar"
2856 local name="trusted.big"
2857 log "save large xattr $name on $file"
2858 setfattr -n $name -v $large_value $file ||
2859 error "saving $name on $file failed"
2861 local new_value=$(get_xattr_value $name $file)
2862 [[ "$new_value" != "$large_value" ]] &&
2863 error "$name different after saving"
2865 log "shrink value of $name on $file"
2866 setfattr -n $name -v $small_value $file ||
2867 error "shrinking value of $name on $file failed"
2869 new_value=$(get_xattr_value $name $file)
2870 [[ "$new_value" != "$small_value" ]] &&
2871 error "$name different after shrinking"
2873 log "grow value of $name on $file"
2874 setfattr -n $name -v $large_value $file ||
2875 error "growing value of $name on $file failed"
2877 new_value=$(get_xattr_value $name $file)
2878 [[ "$new_value" != "$large_value" ]] &&
2879 error "$name different after growing"
2881 log "check value of $name on $file after remounting MDS"
2883 new_value=$(get_xattr_value $name $file)
2884 [[ "$new_value" != "$large_value" ]] &&
2885 error "$name different after remounting MDS"
2887 log "remove large xattr $name from $file"
2888 setfattr -x $name $file || error "removing $name from $file failed"
2893 LDISKFS_MKFS_OPTS=${LDISKFS_MKFS_OPTS% -O large_xattr}
2897 run_test 61 "large xattr"
2901 local mdsdev=$(mdsdevname 1)
2902 local ostdev=$(ostdevname 1)
2904 echo "disable journal for mds"
2905 do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
2906 start_mds && error "MDT start should fail"
2907 echo "disable journal for ost"
2908 do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
2909 start_ost && error "OST start should fail"
2910 cleanup || return $?
2913 run_test 62 "start with disabled journal"
2916 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2917 skip "Only applicable to ldiskfs-based MDTs"
2921 local inode_slab=$(do_facet $SINGLEMDS \
2922 "awk '/ldiskfs_inode_cache/ { print \\\$5 }' /proc/slabinfo")
2923 if [ -z "$inode_slab" ]; then
2924 skip "ldiskfs module has not been loaded"
2928 echo "$inode_slab ldisk inodes per page"
2929 [ "$inode_slab" -ge "3" ] ||
2930 error "ldisk inode size is too big, $inode_slab objs per page"
2933 run_test 63 "Verify each page can at least hold 3 ldisk inodes"
2935 if ! combined_mgs_mds ; then
2941 complete $(basename $0) $SECONDS