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 # test new client starts deactivated
1059 umount_client $MOUNT || return 200
1061 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1062 if [ -z "$RESULT" ]; then
1063 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1066 echo "New client success: got $RESULT"
1069 # make sure it reactivates
1070 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1072 umount_client $MOUNT
1075 #writeconf to remove all ost2 traces for subsequent tests
1078 run_test 29 "permanently remove an OST"
1083 echo Big config llog
1084 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1086 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1087 for i in ${LIST[@]}; do
1088 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1090 # make sure client restart still works
1091 umount_client $MOUNT
1092 mount_client $MOUNT || return 4
1093 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1096 echo Erase parameter setting
1097 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1098 umount_client $MOUNT
1099 mount_client $MOUNT || return 6
1101 echo "deleted (default) value=$FINAL, orig=$ORIG"
1102 # assumes this parameter started at the default value
1103 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1107 run_test 30a "Big config llog and conf_param deletion"
1112 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1113 # numerical part of it. Hopefully that's not already a failover address for
1115 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1116 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1117 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1118 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1119 echo "Using fake nid $NEW"
1121 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1122 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
1123 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1125 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1126 echo "should have 2 failover nids: $NIDCOUNT"
1127 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1128 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1129 umount_client $MOUNT
1130 mount_client $MOUNT || return 3
1132 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1134 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1135 echo "only 1 final nid should remain: $NIDCOUNT"
1136 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1140 run_test 30b "Remove failover nids"
1142 test_31() { # bug 10734
1143 # ipaddr must not exist
1144 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1147 run_test 31 "Connect to non-existent node (shouldn't crash)"
1149 # Use these start32/stop32 fn instead of t-f start/stop fn,
1150 # for local devices, to skip global facet vars init
1154 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1155 umount -d $@ ${MOUNT%/*}/${facet}
1164 mkdir -p ${MOUNT%/*}/${facet}
1166 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1167 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1169 if [ $RC -ne 0 ]; then
1170 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1171 echo "Start of ${device} of local ${facet} failed ${RC}"
1177 cleanup_nocli32 () {
1185 echo "Cleanup test_32 umount $MOUNT ..."
1186 umount -f $MOUNT || true
1187 echo "Cleanup local mds ost1 ..."
1189 combined_mgs_mds || start_mgs
1194 client_only && skip "client only testing" && return 0
1195 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1196 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1198 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1199 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1200 local tmpdir=$TMP/conf32a
1202 tar xjvf $DISK1_8 -C $tmpdir || \
1203 { skip_env "Cannot untar $DISK1_8" && return 0; }
1206 $LCTL set_param debug="$PTLDEBUG"
1208 $TUNEFS $tmpdir/mds || error "tunefs failed"
1210 combined_mgs_mds || stop mgs
1212 # nids are wrong, so client wont work, but server should start
1213 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1214 trap cleanup_32 EXIT INT || return 3
1216 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1218 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1220 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1221 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1222 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1224 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1226 local NID=$($LCTL list_nids | head -1)
1228 echo "OSC changes should succeed:"
1229 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1230 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1233 echo "MDC changes should succeed:"
1234 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1235 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1238 echo "LOV changes should succeed:"
1239 $LCTL pool_new lustre.interop || return 11
1240 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1245 # mount a second time to make sure we didnt leave upgrade flag on
1247 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1249 combined_mgs_mds || stop mgs
1251 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1252 trap cleanup_32 EXIT INT || return 12
1256 rm -rf $tmpdir || true # true is only for TMP on NFS
1258 run_test 32a "Upgrade from 1.8 (not live)"
1261 client_only && skip "client only testing" && return 0
1262 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1263 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1265 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1266 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1267 local tmpdir=$TMP/conf32b
1269 tar xjvf $DISK1_8 -C $tmpdir || \
1270 { skip_env "Cannot untar $DISK1_8" && return ; }
1273 $LCTL set_param debug="+config"
1274 local NEWNAME=lustre
1276 # writeconf will cause servers to register with their current nids
1277 $TUNEFS --writeconf --erase-params \
1278 --param mdt.identity_upcall=$L_GETIDENTITY \
1279 --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1280 combined_mgs_mds || stop mgs
1282 start32 mds1 $tmpdir/mds "-o loop" && \
1283 trap cleanup_32 EXIT INT || return 3
1285 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1287 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1289 $TUNEFS --writeconf --erase-params \
1290 --mgsnode=$HOSTNAME --fsname=$NEWNAME $tmpdir/ost1 ||\
1291 error "tunefs failed"
1292 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1293 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1295 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1297 local NID=$($LCTL list_nids | head -1)
1299 echo "OSC changes should succeed:"
1300 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1301 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1304 echo "MDC changes should succeed:"
1305 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1306 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1309 echo "LOV changes should succeed:"
1310 $LCTL pool_new ${NEWNAME}.interop || return 11
1311 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1314 # MDT and OST should have registered with new nids, so we should have
1315 # a fully-functioning client
1316 echo "Check client and old fs contents"
1318 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1319 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1320 mount -t lustre $device $MOUNT || return 1
1322 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1323 local new=$((old + 5))
1324 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1325 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1327 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1332 rm -rf $tmpdir || true # true is only for TMP on NFS
1334 run_test 32b "Upgrade from 1.8 with writeconf"
1336 test_33a() { # bug 12333, was test_33
1338 local FSNAME2=test-123
1339 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1342 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1344 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1345 local dev=${SINGLEMDS}_dev
1346 local MDSDEV=${!dev}
1347 is_blkdev $SINGLEMDS $MDSDEV && \
1348 skip_env "mixed loopback and real device not working" && return
1351 local fs2mdsdev=$(mdsdevname 1_2)
1352 local fs2ostdev=$(ostdevname 1_2)
1353 local fs2mdsvdev=$(mdsvdevname 1_2)
1354 local fs2ostvdev=$(ostvdevname 1_2)
1356 if [ $(facet_fstype mds1) == ldiskfs ]; then
1357 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
1360 add fs2mds $(mkfs_opts mds1) --fsname=${FSNAME2} --reformat \
1361 $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
1362 add fs2ost $(mkfs_opts ost1) --mgsnode=$MGSNID --fsname=${FSNAME2} \
1363 --index=8191 --reformat $fs2ostdev $fs2ostvdev || exit 10
1365 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1366 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1367 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1369 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1372 cp /etc/hosts $MOUNT2/ || rc=3
1373 $LFS getstripe $MOUNT2/hosts
1378 cleanup_nocli || rc=6
1381 run_test 33a "Mount ost with a large index number"
1383 test_33b() { # was test_34
1386 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1387 # Drop lock cancelation reply during umount
1388 #define OBD_FAIL_LDLM_CANCEL 0x304
1389 do_facet client lctl set_param fail_loc=0x80000304
1390 #lctl set_param debug=-1
1391 umount_client $MOUNT
1394 run_test 33b "Drop cancel during umount"
1398 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1399 manual_umount_client
1401 do_facet client killall -USR1 multiop
1402 if [ $rc -eq 0 ]; then
1403 error "umount not fail!"
1408 run_test 34a "umount with opened file should be fail"
1413 touch $DIR/$tfile || return 1
1414 stop_mds --force || return 2
1416 manual_umount_client --force
1418 if [ $rc -ne 0 ]; then
1419 error "mtab after failed umount - rc $rc"
1425 run_test 34b "force umount with failed mds should be normal"
1429 touch $DIR/$tfile || return 1
1430 stop_ost --force || return 2
1432 manual_umount_client --force
1434 if [ $rc -ne 0 ]; then
1435 error "mtab after failed umount - rc $rc"
1441 run_test 34c "force umount with failed ost should be normal"
1443 test_35a() { # bug 12459
1446 DBG_SAVE="`lctl get_param -n debug`"
1447 lctl set_param debug="ha"
1449 log "Set up a fake failnode for the MDS"
1451 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1452 do_facet mgs $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1454 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1457 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1460 log "Stopping the MDT:"
1461 stop_mds || return 5
1463 df $MOUNT > /dev/null 2>&1 &
1465 log "Restarting the MDT:"
1466 start_mds || return 6
1467 log "Wait for df ($DFPID) ... "
1470 lctl set_param debug="$DBG_SAVE"
1472 # retrieve from the log the first server that the client tried to
1473 # contact after the connection loss
1474 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1475 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1476 /import_select_connection.*$device-mdc.* using connection/ {
1478 if (\\\$NF ~ /$FAKENID/)
1484 }" $TMP/lustre-log-$TESTNAME.log`
1485 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1487 # remove nid settings
1490 run_test 35a "Reconnect to the last active server first"
1492 test_35b() { # bug 18674
1493 remote_mds || { skip "local MDS" && return 0; }
1497 $LCTL set_param debug="ha"
1499 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1502 log "Set up a fake failnode for the MDS"
1504 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | \
1505 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1506 do_facet mgs "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1509 local at_max_saved=0
1510 # adaptive timeouts may prevent seeing the issue
1511 if at_is_enabled; then
1512 at_max_saved=$(at_max_get mds)
1513 at_max_set 0 mds client
1516 mkdir -p $MOUNT/$tdir
1518 log "Injecting EBUSY on MDS"
1519 # Setting OBD_FAIL_MDS_RESEND=0x136
1520 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
1522 $LCTL set_param mdc.${FSNAME}*.stats=clear
1524 log "Creating a test file and stat it"
1525 touch $MOUNT/$tdir/$tfile
1526 stat $MOUNT/$tdir/$tfile
1528 log "Stop injecting EBUSY on MDS"
1529 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
1530 rm -f $MOUNT/$tdir/$tfile
1533 # restore adaptive timeout
1534 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1536 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1538 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
1540 # retrieve from the log if the client has ever tried to
1541 # contact the fake server after the loss of connection
1542 FAILCONN=`awk "BEGIN {ret = 0;}
1543 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1545 if (\\\$NF ~ /$FAKENID/) {
1550 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1552 [ "$FAILCONN" == "0" ] && \
1553 log "ERROR: The client reconnection has not been triggered" && \
1555 [ "$FAILCONN" == "2" ] && \
1556 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1560 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
1561 # Reconnects are supposed to be rate limited to one every 5s
1562 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
1563 log "ERROR: Too many reconnects $CONNCNT" && \
1567 # remove nid settings
1570 run_test 35b "Continue reconnection retries, if the active server is busy"
1573 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1575 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1576 { skip "remote OST" && return 0; }
1579 local FSNAME2=test1234
1580 local fs3ost_HOST=$ost_HOST
1581 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1583 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1585 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1586 is_blkdev $SINGLEMDS $MDSDEV && \
1587 skip_env "mixed loopback and real device not working" && return
1590 local fs2mdsdev=$(mdsdevname 1_2)
1591 local fs2ostdev=$(ostdevname 1_2)
1592 local fs3ostdev=$(ostdevname 2_2)
1593 local fs2mdsvdev=$(mdsvdevname 1_2)
1594 local fs2ostvdev=$(ostvdevname 1_2)
1595 local fs3ostvdev=$(ostvdevname 2_2)
1597 add fs2mds $(mkfs_opts mds1) --fsname=${FSNAME2} --reformat \
1598 $fs2mdsdev $fs2mdsvdev || exit 10
1599 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
1600 # different one than the default value here.
1601 add fs2ost $(mkfs_opts ost1) --mgsnode=$MGSNID --fsname=${FSNAME2} \
1602 --reformat $fs2ostdev $fs2ostvdev || exit 10
1603 add fs3ost $(mkfs_opts ost1) --mgsnode=$MGSNID --fsname=${FSNAME2} \
1604 --reformat $fs3ostdev $fs3ostvdev || exit 10
1606 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1607 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1608 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1610 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1612 sleep 5 # until 11778 fixed
1614 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1616 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1617 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1618 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1619 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1620 DFTOTAL=`echo $STRING | cut -d, -f1`
1621 DFUSED=`echo $STRING | cut -d, -f2`
1622 DFAVAIL=`echo $STRING | cut -d, -f3`
1623 DFFREE=$(($DFTOTAL - $DFUSED))
1625 ALLOWANCE=$((64 * $OSTCOUNT))
1627 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1628 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1629 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1632 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1633 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1634 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1637 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1638 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1639 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1644 stop fs3ost -f || return 200
1645 stop fs2ost -f || return 201
1646 stop fs2mds -f || return 202
1647 unload_modules_conf || return 203
1650 run_test 36 "df report consistency on OSTs with different block size"
1653 local mntpt=$(facet_mntpt $SINGLEMDS)
1654 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
1655 local mdsdev_sym="$TMP/sym_mdt.img"
1656 local opts=$MDS_MOUNT_OPTS
1659 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
1660 skip "Currently only applicable to ldiskfs-based MDTs"
1664 echo "MDS : $mdsdev"
1665 echo "SYMLINK : $mdsdev_sym"
1666 do_facet $SINGLEMDS rm -f $mdsdev_sym
1668 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
1670 echo "mount symlink device - $mdsdev_sym"
1672 if ! do_facet $SINGLEMDS test -b $mdsdev; then
1673 opts=$(csa_add "$opts" -o loop)
1675 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
1676 $mdsdev_sym $mntpt 2>&1)
1679 echo mount_op=$mount_op
1681 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
1683 if $(echo $mount_op | grep -q "unable to set tunable"); then
1684 error "set tunables failed for symlink device"
1687 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
1691 run_test 37 "verify set tunables works for symlink device"
1693 test_38() { # bug 14222
1698 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1699 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1701 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1702 error "copying $SRC to $DIR/$tdir"
1704 umount_client $MOUNT
1706 log "rename lov_objid file on MDS"
1707 rm -f $TMP/lov_objid.orig
1709 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1710 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1711 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1713 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1714 # check create in mds_lov_connect
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.new\\\" $MDSDEV"
1722 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1723 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1725 # check it's updates in sync
1726 umount_client $MOUNT
1729 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1730 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1731 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1736 [ $V ] && log "verifying $DIR/$tdir/$f"
1737 diff -q $f $DIR/$tdir/$f || ERROR=y
1739 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1740 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1741 umount_client $MOUNT
1743 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1745 log "files compared the same"
1748 run_test 38 "MDS recreates missing lov_objid file from OST data"
1754 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1755 error "memory leak detected" || true
1757 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1759 test_40() { # bug 15759
1761 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1762 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
1766 run_test 40 "race during service thread startup"
1768 test_41a() { #bug 14134
1769 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
1770 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
1771 skip "Loop devices does not work with nosvc option"
1776 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1778 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1779 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1780 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1782 mount_client $MOUNT || return 1
1785 echo "blah blah" > $MOUNT/$tfile
1788 umount_client $MOUNT
1789 stop ost1 -f || return 201
1790 stop_mds -f || return 202
1791 stop_mds -f || return 203
1792 unload_modules_conf || return 204
1795 run_test 41a "mount mds with --nosvc and --nomgs"
1798 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
1799 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
1800 skip "Loop devices does not work with nosvc option"
1804 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
1808 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1810 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1812 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1814 mount_client $MOUNT || return 1
1817 echo "blah blah" > $MOUNT/$tfile
1818 cat $MOUNT/$tfile || return 200
1820 umount_client $MOUNT
1821 stop_ost || return 201
1822 stop_mds -f || return 202
1823 stop_mds -f || return 203
1826 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
1828 test_42() { #bug 14693
1830 check_mount || return 2
1831 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1832 umount_client $MOUNT
1833 mount_client $MOUNT || return 1
1837 run_test 42 "invalid config param should not prevent client from mounting"
1840 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1842 chmod ugo+x $DIR || error "chmod 0 failed"
1844 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1845 "$FSNAME.mdt.root_squash" \
1848 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1849 "$FSNAME.mdt.nosquash_nids" \
1853 # create set of test files
1855 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1856 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1857 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1859 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1860 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1862 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1863 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1864 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1867 # check root_squash:
1868 # set root squash UID:GID to RUNAS_ID
1869 # root should be able to access only files owned by RUNAS_ID
1872 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1873 "$FSNAME.mdt.root_squash" \
1874 "$RUNAS_ID:$RUNAS_ID"
1876 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1877 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1878 error "$ST: root read permission is denied"
1879 echo "$ST: root read permission is granted - ok"
1882 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1883 error "$ST: root write permission is denied"
1884 echo "$ST: root write permission is granted - ok"
1886 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1887 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1888 error "$ST: root read permission is granted"
1889 echo "$ST: root read permission is denied - ok"
1892 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1893 error "$ST: root write permission is granted"
1894 echo "$ST: root write permission is denied - ok"
1896 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1897 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1898 error "$ST: root unlink permission is granted"
1899 echo "$ST: root unlink permission is denied - ok"
1901 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1902 error "$ST: root create permission is granted"
1903 echo "$ST: root create permission is denied - ok"
1906 # check nosquash_nids:
1907 # put client's NID into nosquash_nids list,
1908 # root should be able to access root file after that
1910 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1911 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1912 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1914 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1915 "$FSNAME-MDTall.mdt.nosquash_nids" \
1918 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1919 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1920 error "$ST: root read permission is denied"
1921 echo "$ST: root read permission is granted - ok"
1924 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1925 error "$ST: root write permission is denied"
1926 echo "$ST: root write permission is granted - ok"
1928 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1929 rm $DIR/$tdir-rootdir/tfile-1 || \
1930 error "$ST: root unlink permission is denied"
1931 echo "$ST: root unlink permission is granted - ok"
1932 touch $DIR/$tdir-rootdir/tfile-2 || \
1933 error "$ST: root create permission is denied"
1934 echo "$ST: root create permission is granted - ok"
1938 run_test 43 "check root_squash and nosquash_nids"
1940 umount_client $MOUNT
1945 check_mount || return 2
1946 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1948 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1949 for VAL in $UUIDS; do
1950 NID=$(echo $VAL | cut -d= -f1)
1951 CLUUID=$(echo $VAL | cut -d= -f2)
1952 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1954 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1958 run_test 44 "mounted client proc entry exists"
1962 check_mount || return 2
1967 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1968 do_facet client "lctl set_param fail_loc=0x50f"
1971 manual_umount_client --force || return 3
1972 do_facet client "lctl set_param fail_loc=0x0"
1974 mount_client $MOUNT || return 4
1978 run_test 45 "long unlink handling in ptlrpcd"
1985 umount_client $MOUNT2 || rc=$?
1986 umount_client $MOUNT || rc=$?
1987 while [ $count -gt 0 ]; do
1988 stop ost${count} -f || rc=$?
1992 cleanup_nocli || rc=$?
1993 #writeconf to remove all ost2 traces for subsequent tests
1999 echo "Testing with $OSTCOUNT OSTs"
2001 start_mds || return 1
2002 #first client should see only one ost
2003 start_ost || return 2
2004 wait_osc_import_state mds ost FULL
2006 mount_client $MOUNT || return 3
2007 trap "cleanup_46a $OSTCOUNT" EXIT ERR
2010 for (( i=2; i<=$OSTCOUNT; i++ )); do
2011 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
2014 # wait until osts in sync
2015 for (( i=2; i<=$OSTCOUNT; i++ )); do
2016 wait_osc_import_state mds ost$i FULL
2017 wait_osc_import_state client ost$i FULL
2020 #second client see all ost's
2022 mount_client $MOUNT2 || return 8
2023 $LFS setstripe -c -1 $MOUNT2 || return 9
2024 $LFS getstripe $MOUNT2 || return 10
2026 echo "ok" > $MOUNT2/widestripe
2027 $LFS getstripe $MOUNT2/widestripe || return 11
2028 # fill acl buffer for avoid expand lsm to them
2029 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
2030 setfacl -m $acl $MOUNT2/widestripe
2034 stat $MOUNT/widestripe || return 12
2036 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
2039 run_test 46a "handle ost additional - wide striped file"
2044 check_mount || return 2
2045 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2049 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2050 if echo $ns | grep "MDT[[:digit:]]*"; then
2053 lrs=$(echo $ns | sed 's/.*lru_size=//')
2054 lru_size[count]=$lrs
2059 facet_failover $SINGLEMDS
2060 client_up || return 3
2063 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2064 if echo $ns | grep "MDT[[:digit:]]*"; then
2067 lrs=$(echo $ns | sed 's/.*lru_size=//')
2068 if ! test "$lrs" -eq "${lru_size[count]}"; then
2069 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2070 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2078 run_test 47 "server restart does not make client loss lru_resize settings"
2083 # reformat after this test is needed - if test will failed
2084 # we will have unkillable file at FS
2088 test_48() { # bug 17636
2091 check_mount || return 2
2093 $LFS setstripe -c -1 $MOUNT || return 9
2094 $LFS getstripe $MOUNT || return 10
2096 echo "ok" > $MOUNT/widestripe
2097 $LFS getstripe $MOUNT/widestripe || return 11
2099 trap cleanup_48 EXIT ERR
2101 # fill acl buffer for avoid expand lsm to them
2102 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2103 setfacl -m $acl $MOUNT/widestripe
2106 stat $MOUNT/widestripe || return 12
2111 run_test 48 "too many acls on file"
2113 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2114 test_49() { # bug 17710
2115 local timeout_orig=$TIMEOUT
2116 local ldlm_timeout_orig=$LDLM_TIMEOUT
2117 local LOCAL_TIMEOUT=20
2119 LDLM_TIMEOUT=$LOCAL_TIMEOUT
2120 TIMEOUT=$LOCAL_TIMEOUT
2124 check_mount || return 1
2126 echo "check ldlm_timout..."
2127 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2128 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2129 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2131 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2132 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2135 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2136 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2139 umount_client $MOUNT
2140 stop_ost || return 2
2141 stop_mds || return 3
2143 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
2147 check_mount || return 7
2149 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2150 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2151 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2153 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2154 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2157 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2158 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2161 cleanup || return $?
2163 LDLM_TIMEOUT=$ldlm_timeout_orig
2164 TIMEOUT=$timeout_orig
2166 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
2169 # Test both statfs and lfs df and fail if either one fails
2170 multiop_bg_pause $1 f_
2173 killall -USR1 multiop
2174 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2175 wait $PID || { RC1=$?; log "multiop return error "; }
2182 if [ $RC2 -eq 0 ]; then
2184 log "lazystatfs df failed"
2188 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2194 lctl set_param llite.$FSNAME-*.lazystatfs=1
2197 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2199 cleanup || return $?
2201 run_test 50a "lazystatfs all servers available =========================="
2205 lctl set_param llite.$FSNAME-*.lazystatfs=1
2208 # Wait for client to detect down OST
2209 stop_ost || error "Unable to stop OST1"
2210 wait_osc_import_state mds ost DISCONN
2212 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2214 umount_client $MOUNT || error "Unable to unmount client"
2215 stop_mds || error "Unable to stop MDS"
2217 run_test 50b "lazystatfs all servers down =========================="
2220 start_mds || error "Unable to start MDS"
2221 start_ost || error "Unable to start OST1"
2222 start_ost2 || error "Unable to start OST2"
2223 mount_client $MOUNT || error "Unable to mount client"
2224 lctl set_param llite.$FSNAME-*.lazystatfs=1
2227 # Wait for client to detect down OST
2228 stop_ost || error "Unable to stop OST1"
2229 wait_osc_import_state mds ost DISCONN
2230 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2232 umount_client $MOUNT || error "Unable to unmount client"
2233 stop_ost2 || error "Unable to stop OST2"
2234 stop_mds || error "Unable to stop MDS"
2235 #writeconf to remove all ost2 traces for subsequent tests
2238 run_test 50c "lazystatfs one server down =========================="
2241 start_mds || error "Unable to start MDS"
2242 start_ost || error "Unable to start OST1"
2243 start_ost2 || error "Unable to start OST2"
2244 mount_client $MOUNT || error "Unable to mount client"
2245 lctl set_param llite.$FSNAME-*.lazystatfs=1
2248 # Issue the statfs during the window where the client still
2249 # belives the OST to be available but it is in fact down.
2250 # No failure just a statfs which hangs for a timeout interval.
2251 stop_ost || error "Unable to stop OST1"
2252 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2254 umount_client $MOUNT || error "Unable to unmount client"
2255 stop_ost2 || error "Unable to stop OST2"
2256 stop_mds || error "Unable to stop MDS"
2257 #writeconf to remove all ost2 traces for subsequent tests
2260 run_test 50d "lazystatfs client/server conn race =========================="
2267 start_mds || return 1
2268 #first client should see only one ost
2269 start_ost || return 2
2270 wait_osc_import_state mds ost FULL
2272 # Wait for client to detect down OST
2273 stop_ost || error "Unable to stop OST1"
2274 wait_osc_import_state mds ost DISCONN
2276 mount_client $MOUNT || error "Unable to mount client"
2277 lctl set_param llite.$FSNAME-*.lazystatfs=0
2279 multiop_bg_pause $MOUNT _f
2283 if [ $RC1 -ne 0 ]; then
2284 log "multiop failed $RC1"
2287 sleep $(( $TIMEOUT+1 ))
2289 [ $? -ne 0 ] && error "process isn't sleep"
2290 start_ost || error "Unable to start OST1"
2291 wait $pid || error "statfs failed"
2294 umount_client $MOUNT || error "Unable to unmount client"
2295 stop_ost || error "Unable to stop OST1"
2296 stop_mds || error "Unable to stop MDS"
2298 run_test 50e "normal statfs all servers down =========================="
2303 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2305 start_mds || error "Unable to start mds"
2306 #first client should see only one ost
2307 start_ost || error "Unable to start OST1"
2308 wait_osc_import_state mds ost FULL
2310 start_ost2 || error "Unable to start OST2"
2311 wait_osc_import_state mds ost2 FULL
2313 # Wait for client to detect down OST
2314 stop_ost2 || error "Unable to stop OST2"
2316 wait_osc_import_state mds ost2 DISCONN
2317 mount_client $MOUNT || error "Unable to mount client"
2318 lctl set_param llite.$FSNAME-*.lazystatfs=0
2320 multiop_bg_pause $MOUNT _f
2324 if [ $RC1 -ne 0 ]; then
2325 log "lazystatfs multiop failed $RC1"
2328 sleep $(( $TIMEOUT+1 ))
2330 [ $? -ne 0 ] && error "process isn't sleep"
2331 start_ost2 || error "Unable to start OST2"
2332 wait $pid || error "statfs failed"
2333 stop_ost2 || error "Unable to stop OST2"
2336 umount_client $MOUNT || error "Unable to unmount client"
2337 stop_ost || error "Unable to stop OST1"
2338 stop_mds || error "Unable to stop MDS"
2339 #writeconf to remove all ost2 traces for subsequent tests
2342 run_test 50f "normal statfs one server in down =========================="
2345 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2347 start_ost2 || error "Unable to start OST2"
2348 wait_osc_import_state mds ost2 FULL
2349 wait_osc_import_state client ost2 FULL
2351 local PARAM="${FSNAME}-OST0001.osc.active"
2353 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2354 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2356 umount_client $MOUNT || error "Unable to unmount client"
2357 mount_client $MOUNT || error "Unable to mount client"
2358 # This df should not cause a panic
2361 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2363 umount_client $MOUNT || error "Unable to unmount client"
2364 stop_ost2 || error "Unable to stop OST2"
2365 stop_ost || error "Unable to stop OST1"
2366 stop_mds || error "Unable to stop MDS"
2367 #writeconf to remove all ost2 traces for subsequent tests
2370 run_test 50g "deactivated OST should not cause panic====================="
2373 local LOCAL_TIMEOUT=20
2377 check_mount || return 1
2380 $LFS setstripe -c -1 $MOUNT/d1
2381 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2382 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2383 touch $MOUNT/d1/f1 &
2386 start_ost2 || return 2
2388 stop_ost2 || return 3
2390 #writeconf to remove all ost2 traces for subsequent tests
2393 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2402 do_node $node mkdir -p $dest
2403 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2405 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2406 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2407 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2409 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2410 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2420 local backup2=${TMP}/backup2
2422 do_node $node mkdir -p $backup2
2423 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2425 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2426 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2427 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2429 do_node $node "diff -rq $backup $backup2"
2430 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2432 local xattrs2=${TMP}/xattrs2
2433 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2434 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2436 do_node $node "diff $xattrs $xattrs2"
2437 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2439 do_node $node "rm -rf $backup2 $xattrs2"
2440 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2445 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2447 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2449 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2452 local ost1mnt=$(facet_mntpt ost1)
2453 local ost1node=$(facet_active_host ost1)
2454 local ost1tmp=$TMP/conf52
2458 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2459 touch $TMP/modified_first
2460 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2461 local mtime=$(stat -c %Y $TMP/modified_first)
2462 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2464 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2467 $LFS setstripe -c -1 -S 1M $DIR/$tdir
2468 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2470 for (( i=0; i < nrfiles; i++ )); do
2471 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2472 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2478 echo backup files to $TMP/files
2479 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2480 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2481 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2483 umount_client $MOUNT
2484 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2486 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2488 echo mount ost1 as ldiskfs
2489 do_node $ost1node mkdir -p $ost1mnt
2490 [ $? -eq 0 ] || { error "Unable to create $ost1mnt"; return 23; }
2491 if ! do_node $ost1node test -b $ost1_dev; then
2494 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
2496 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2499 echo backup objects to $ost1tmp/objects
2500 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2501 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2502 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2503 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2505 # move objects to lost+found
2506 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2507 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2510 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2511 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2513 # compare restored objects against saved ones
2514 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2515 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2517 do_node $ost1node "umount $ost1mnt"
2518 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2521 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2523 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2526 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2527 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2529 rm -rf $TMP/files $TMP/file_xattrs
2530 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2531 do_node $ost1node "rm -rf $ost1tmp"
2532 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2535 run_test 52 "check recovering objects from lost+found"
2537 # Checks threads_min/max/started for some service
2539 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2540 # parameter pattern prefix like 'ost.*.ost'.
2553 local msg="Insane $modname thread counts"
2554 local ncpts=$(check_cpt_number $facet)
2559 check_mount || return 41
2561 # We need to expand $parampat, but it may match multiple parameters, so
2562 # we'll pick the first one
2563 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2564 error "Couldn't expand ${parampat}.threads_min parameter name"
2568 # Remove the .threads_min part
2569 paramp=${paramp%.threads_min}
2571 # Check for sanity in defaults
2572 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2573 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2574 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2575 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2576 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
2577 nthrs=$(expr $tmax - $tmin)
2578 if [ $nthrs -lt $ncpts ]; then
2584 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
2585 skip_env "module parameter forced $facet thread count" &&
2586 tmin=3 && tmax=$((3 * tmax))
2588 # Check that we can change min/max
2589 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + nthrs))"
2590 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - nthrs))"
2591 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2592 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2593 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) && $tmax2 == ($tmax - $nthrs)))' || return $?
2595 # Check that we can set min/max to the same value
2596 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2597 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2598 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2599 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2600 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2602 # Check that we can't set max < min
2603 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
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 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
2608 # We need to ensure that we get the module options desired; to do this
2609 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2610 LOAD_MODULES_REMOTE=true
2613 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
2614 setmodopts -a $modname "$newvalue" oldvalue
2618 check_mount || return 41
2620 # Restore previous setting of MODOPTS_*
2621 setmodopts $modname "$oldvalue"
2623 # Check that $opts took
2624 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2625 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2626 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2627 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2630 # Workaround a YALA bug where YALA expects that modules will remain
2631 # loaded on the servers
2632 LOAD_MODULES_REMOTE=false
2639 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
2641 run_test 53a "check OSS thread count params"
2644 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' '16'
2646 run_test 53b "check MDT thread count params"
2649 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p
2650 [ $? -eq 0 ] || error "llverdev failed!"
2653 run_test 54a "test llverdev and partial verify of device"
2657 run_llverfs $MOUNT -p
2658 [ $? -eq 0 ] || error "llverfs failed!"
2661 run_test 54b "test llverfs and partial verify of filesystem"
2665 local max_ost_index=$1
2666 echo -n $(((max_ost_index + 1) * 8))
2670 local mdsdev=$(mdsdevname 1)
2671 local mdsvdev=$(mdsvdevname 1)
2675 add mds1 $(mkfs_opts mds1) --reformat $mdsdev $mdsvdev ||
2677 add ost1 $(mkfs_opts ost1) --index=$i --reformat \
2678 $(ostdevname 1) $(ostvdevname 1)
2684 echo checking size of lov_objid for ost index $i
2685 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2686 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2687 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2689 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2696 run_test 55 "check lov_objid size"
2699 local mds_journal_size_orig=$MDSJOURNALSIZE
2702 add mds1 $(mkfs_opts mds1) --reformat $(mdsdevname 1) $(mdsvdevname 1)
2703 add ost1 $(mkfs_opts ost1) --index=1000 --reformat \
2704 $(ostdevname 1) $(ostvdevname 1)
2705 add ost2 $(mkfs_opts ost2) --index=10000 --reformat \
2706 $(ostdevname 2) $(ostvdevname 2)
2710 start_ost2 || error "Unable to start second ost"
2711 mount_client $MOUNT || error "Unable to mount client"
2715 MDSJOURNALSIZE=$mds_journal_size_orig
2718 run_test 56 "check big indexes"
2720 test_57a() { # bug 22656
2721 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2723 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2725 start_ost && error "OST registration from failnode should fail"
2728 run_test 57a "initial registration from failnode should fail (should return errs)"
2731 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2733 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
2735 start_ost || error "OST registration from servicenode should not fail"
2738 run_test 57b "initial registration from servicenode should not fail"
2741 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2744 test_58() { # bug 22658
2745 if [ $(facet_fstype mds) == zfs ]; then
2746 skip "Does not work with ZFS-based MDTs yet"
2751 createmany -o $DIR/$tdir/$tfile-%d 100
2752 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
2753 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
2754 do_facet mds "lctl set_param fail_loc=0x601"
2755 unlinkmany $DIR/$tdir/$tfile-%d 100
2757 local MNTDIR=$(facet_mntpt mds)
2758 # remove all files from the OBJECTS dir
2759 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
2760 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
2761 do_facet mds "umount $MNTDIR"
2762 # restart MDS with missing llog files
2764 do_facet mds "lctl set_param fail_loc=0"
2767 run_test 58 "missing llog files must not prevent MDT from mounting"
2770 start_mgsmds >> /dev/null
2771 local C1=$(count_osts)
2772 if [ $C1 -eq 0 ]; then
2773 start_ost >> /dev/null
2777 echo "original ost count: $C1 (expect > 0)"
2778 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2779 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2780 local C2=$(count_osts)
2781 echo "after mdt writeconf count: $C2 (expect 0)"
2782 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2783 echo "OST start without writeconf should fail:"
2784 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2785 echo "OST start with writeconf should succeed:"
2786 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2787 local C3=$(count_osts)
2788 echo "after ost writeconf count: $C3 (expect 1)"
2789 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2790 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2791 local C4=$(count_osts)
2792 echo "after ost2 writeconf count: $C4 (expect 2)"
2793 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2794 stop_ost2 >> /dev/null
2795 cleanup_nocli >> /dev/null
2796 #writeconf to remove all ost2 traces for subsequent tests
2799 run_test 59 "writeconf mount option"
2801 test_60() { # LU-471
2802 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2803 skip "Only applicable to ldiskfs-based MDTs"
2807 add mds1 $(mkfs_opts mds1) \
2808 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' --reformat \
2809 $(mdsdevname 1) $(mdsvdevname 1) || exit 10
2811 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
2813 [ $rc -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
2815 # MDT default has dirdata feature
2816 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
2817 # we disable uninit_bg feature
2818 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
2819 # we set stride extended options
2820 echo $dump | grep stride > /dev/null || error "stride is not set"
2823 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
2826 local reformat=false
2828 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
2829 { skip "Need MDS version at least 2.1.53"; return 0; }
2831 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2832 ! large_xattr_enabled; then
2834 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
2835 LDISKFS_MKFS_OPTS+=" -O large_xattr"
2836 add $SINGLEMDS $(mkfs_opts $SINGLEMDS) --reformat $mds_dev ||
2837 error "reformatting $mds_dev failed"
2840 setup_noconfig || error "setting up the filesystem failed"
2841 client_up || error "starting client failed"
2843 local file=$DIR/$tfile
2846 local large_value="$(generate_string $(max_xattr_size))"
2847 local small_value="bar"
2849 local name="trusted.big"
2850 log "save large xattr $name on $file"
2851 setfattr -n $name -v $large_value $file ||
2852 error "saving $name on $file failed"
2854 local new_value=$(get_xattr_value $name $file)
2855 [[ "$new_value" != "$large_value" ]] &&
2856 error "$name different after saving"
2858 log "shrink value of $name on $file"
2859 setfattr -n $name -v $small_value $file ||
2860 error "shrinking value of $name on $file failed"
2862 new_value=$(get_xattr_value $name $file)
2863 [[ "$new_value" != "$small_value" ]] &&
2864 error "$name different after shrinking"
2866 log "grow value of $name on $file"
2867 setfattr -n $name -v $large_value $file ||
2868 error "growing value of $name on $file failed"
2870 new_value=$(get_xattr_value $name $file)
2871 [[ "$new_value" != "$large_value" ]] &&
2872 error "$name different after growing"
2874 log "check value of $name on $file after remounting MDS"
2876 new_value=$(get_xattr_value $name $file)
2877 [[ "$new_value" != "$large_value" ]] &&
2878 error "$name different after remounting MDS"
2880 log "remove large xattr $name from $file"
2881 setfattr -x $name $file || error "removing $name from $file failed"
2886 LDISKFS_MKFS_OPTS=${LDISKFS_MKFS_OPTS% -O large_xattr}
2890 run_test 61 "large xattr"
2894 local mdsdev=$(mdsdevname 1)
2895 local ostdev=$(ostdevname 1)
2897 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
2898 { skip "Need MDS version at least 2.2.51"; return 0; }
2900 echo "disable journal for mds"
2901 do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
2902 start_mds && error "MDT start should fail"
2903 echo "disable journal for ost"
2904 do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
2905 start_ost && error "OST start should fail"
2906 cleanup || return $?
2909 run_test 62 "start with disabled journal"
2912 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2913 skip "Only applicable to ldiskfs-based MDTs"
2917 local inode_slab=$(do_facet $SINGLEMDS \
2918 "awk '/ldiskfs_inode_cache/ { print \\\$5 }' /proc/slabinfo")
2919 if [ -z "$inode_slab" ]; then
2920 skip "ldiskfs module has not been loaded"
2924 echo "$inode_slab ldisk inodes per page"
2925 [ "$inode_slab" -ge "3" ] ||
2926 error "ldisk inode size is too big, $inode_slab objs per page"
2929 run_test 63 "Verify each page can at least hold 3 ldisk inodes"
2931 if ! combined_mgs_mds ; then
2937 complete $(basename $0) $SECONDS