3 # FIXME - there is no reason to use all of these different
4 # return codes, espcially when most of them are mapped to something
5 # else anyway. The combination of test number and return code
6 # figure out what failed.
12 # bug number for skipped test:
14 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
15 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
17 if [ "$FAILURE_MODE" = "HARD" ]; then
18 CONFIG_EXCEPTIONS="24a " && \
19 echo "Except the tests: $CONFIG_EXCEPTIONS for FAILURE_MODE=$FAILURE_MODE, bug 23573" && \
20 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
24 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
26 PTLDEBUG=${PTLDEBUG:--1}
28 LUSTRE=${LUSTRE:-`dirname $0`/..}
29 RLUSTRE=${RLUSTRE:-$LUSTRE}
30 export MULTIOP=${MULTIOP:-multiop}
32 . $LUSTRE/tests/test-framework.sh
35 # use small MDS + OST size to speed formatting time
36 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
39 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
41 if ! combined_mgs_mds; then
42 # bug number for skipped test: 23954
43 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
46 # STORED_MDSSIZE is used in test_18
47 if [ -n "$MDSSIZE" ]; then
48 STORED_MDSSIZE=$MDSSIZE
51 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
52 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
53 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
59 require_dsh_mds || exit 0
60 require_dsh_ost || exit 0
62 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
77 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
78 do_facet ${facet} "$TUNEFS --quiet --writeconf $dev" ||
79 { echo "tunefs failed, reformatting instead" && reformat_and_config && return 1; }
86 # if writeconf fails anywhere, we reformat everything
87 writeconf1 mds `mdsdevname 1` || return 0
88 writeconf1 ost1 `ostdevname 1` || return 0
89 writeconf1 ost2 `ostdevname 2` || return 0
93 # The MGS must be started before the OSTs for a new fs, so start
94 # and stop to generate the startup logs.
97 wait_osc_import_state mds ost FULL
102 reformat_and_config() {
104 if ! combined_mgs_mds ; then
112 start mgs $MGSDEV $MGS_MOUNT_OPTS
116 local facet=$SINGLEMDS
117 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
118 local num=$(echo $facet | tr -d "mds")
119 local dev=$(mdsdevname $num)
120 echo "start mds service on `facet_active_host $facet`"
121 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
125 if ! combined_mgs_mds ; then
132 echo "stop mds service on `facet_active_host $SINGLEMDS`"
133 # These tests all use non-failover stop
134 stop $SINGLEMDS -f || return 97
138 echo "stop mgs service on `facet_active_host mgs`"
139 # These tests all use non-failover stop
140 stop mgs -f || return 97
144 echo "start ost1 service on `facet_active_host ost1`"
145 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
149 echo "stop ost1 service on `facet_active_host ost1`"
150 # These tests all use non-failover stop
151 stop ost1 -f || return 98
155 echo "start ost2 service on `facet_active_host ost2`"
156 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
160 echo "stop ost2 service on `facet_active_host ost2`"
161 # These tests all use non-failover stop
162 stop ost2 -f || return 93
167 echo "mount $FSNAME on ${MOUNTPATH}....."
168 zconf_mount `hostname` $MOUNTPATH || return 96
172 local mountopt="-o remount,$1"
174 echo "remount '$1' lustre on ${MOUNTPATH}....."
175 zconf_mount `hostname` $MOUNTPATH "$mountopt" || return 96
180 echo "umount lustre on ${MOUNTPATH}....."
181 zconf_umount `hostname` $MOUNTPATH || return 97
184 manual_umount_client(){
187 echo "manual umount lustre on ${MOUNT}...."
188 do_facet client "umount -d ${FORCE} $MOUNT"
194 start_mds || error "MDT start failed"
195 start_ost || error "OST start failed"
196 mount_client $MOUNT || error "client start failed"
197 client_up || error "client_up failed"
201 if ! combined_mgs_mds ; then
210 unload_modules_conf () {
211 if combined_mgs_mds || ! local_mode; then
212 unload_modules || return 1
217 stop_ost || return 202
218 stop_mds || return 201
219 unload_modules_conf || return 203
223 umount_client $MOUNT || return 200
224 cleanup_nocli || return $?
228 do_facet client "cp /etc/passwd $DIR/a" || return 71
229 do_facet client "rm $DIR/a" || return 72
230 # make sure lustre is actually mounted (touch will block,
231 # but grep won't, so do it after)
232 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
233 echo "setup single mount lustre success"
237 do_facet client "touch $DIR/a" || return 71
238 do_facet client "rm $DIR/a" || return 72
239 do_facet client "touch $DIR2/a" || return 73
240 do_facet client "rm $DIR2/a" || return 74
241 echo "setup double mount lustre success"
246 if [ "$ONLY" == "setup" ]; then
251 if [ "$ONLY" == "cleanup" ]; then
258 #create single point mountpoint
264 check_mount || return 41
267 run_test 0 "single mount setup"
270 start_mds || error "MDT start failed"
272 echo "start ost second time..."
273 start_ost && error "2nd OST start should fail"
274 mount_client $MOUNT || error "client start failed"
275 check_mount || return 42
278 run_test 1 "start up ost twice (should return errors)"
282 echo "start mds second time.."
283 start_mds && error "2nd MDT start should fail"
286 check_mount || return 43
289 run_test 2 "start up mds twice (should return err)"
293 #mount.lustre returns an error if already in mtab
294 mount_client $MOUNT && error "2nd client mount should fail"
295 check_mount || return 44
298 run_test 3 "mount client twice (should return err)"
302 touch $DIR/$tfile || return 85
306 # ok for ost to fail shutdown
307 if [ 202 -ne $eno ]; then
312 run_test 4 "force cleanup ost, then cleanup"
314 test_5a() { # was test_5
316 touch $DIR/$tfile || return 1
317 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
319 stop_mds -f || return 2
321 # cleanup may return an error from the failed
322 # disconnects; for now I'll consider this successful
323 # if all the modules have unloaded.
327 echo "killing umount"
328 kill -TERM $UMOUNT_PID
329 echo "waiting for umount to finish"
331 if grep " $MOUNT " /proc/mounts; then
332 echo "test 5: /proc/mounts after failed umount"
336 echo "killing umount"
337 kill -TERM $UMOUNT_PID
338 echo "waiting for umount to finish"
340 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
344 # stop_mds is a no-op here, and should not fail
345 cleanup_nocli || return $?
346 # df may have lingering entry
348 # mtab may have lingering entry
352 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
354 grep -q $MOUNT" " /etc/mtab || break
355 echo "Waiting /etc/mtab updated ... "
356 WAIT=$(( WAIT + sleep))
358 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
359 echo "/etc/mtab updated in $WAIT secs"
361 run_test 5a "force cleanup mds, then cleanup"
369 grep " $MOUNT " /etc/mtab && \
370 error false "unexpected entry in mtab before mount" && return 10
374 if ! combined_mgs_mds ; then
375 trap cleanup_5b EXIT ERR
380 [ -d $MOUNT ] || mkdir -p $MOUNT
381 mount_client $MOUNT && rc=1
382 grep " $MOUNT " /etc/mtab && \
383 error "$MOUNT entry in mtab after failed mount" && rc=11
385 # stop_mds is a no-op here, and should not fail
386 cleanup_nocli || rc=$?
387 if ! combined_mgs_mds ; then
392 run_test 5b "Try to start a client with no MGS (should return errs)"
395 grep " $MOUNT " /etc/mtab && \
396 error false "unexpected entry in mtab before mount" && return 10
401 [ -d $MOUNT ] || mkdir -p $MOUNT
402 local oldfs="${FSNAME}"
403 FSNAME="wrong.${FSNAME}"
404 mount_client $MOUNT || :
406 grep " $MOUNT " /etc/mtab && \
407 error "$MOUNT entry in mtab after failed mount" && rc=11
409 cleanup_nocli || rc=$?
412 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
415 grep " $MOUNT " /etc/mtab && \
416 error false "unexpected entry in mtab before mount" && return 10
422 mount_client $MOUNT || rc=1
424 grep " $MOUNT " /etc/mtab && \
425 error "$MOUNT entry in mtab after unmount" && rc=11
428 run_test 5d "mount with ost down"
431 grep " $MOUNT " /etc/mtab && \
432 error false "unexpected entry in mtab before mount" && return 10
438 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
439 do_facet client "lctl set_param fail_loc=0x80000506"
440 mount_client $MOUNT || echo "mount failed (not fatal)"
442 grep " $MOUNT " /etc/mtab && \
443 error "$MOUNT entry in mtab after unmount" && rc=11
446 run_test 5e "delayed connect, don't crash (bug 10268)"
449 if combined_mgs_mds ; then
450 skip "combined mgs and mds"
454 grep " $MOUNT " /etc/mtab && \
455 error false "unexpected entry in mtab before mount" && return 10
459 [ -d $MOUNT ] || mkdir -p $MOUNT
460 mount_client $MOUNT &
462 echo client_mount pid is $pid
466 if ! ps -f -p $pid >/dev/null; then
469 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
470 error "mount returns $rc, expected to hang"
479 # mount should succeed after start mds
482 [ $rc -eq 0 ] || error "mount returned $rc"
483 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
487 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
492 mount_client ${MOUNT} || return 87
493 touch $DIR/a || return 86
496 run_test 6 "manual umount, then mount again"
501 cleanup_nocli || return $?
503 run_test 7 "manual umount, then cleanup"
508 check_mount2 || return 45
509 umount_client $MOUNT2
512 run_test 8 "double mount setup"
517 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
518 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
520 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
521 if [ "$CHECK_PTLDEBUG" ] && { \
522 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
523 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
524 echo "lnet.debug success"
526 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
529 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
530 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
531 echo "lnet.subsystem_debug success"
533 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
536 stop_ost || return $?
538 run_test 9 "test ptldebug and subsystem for mkfs"
546 do_facet $facet "test -b $dev" || rc=1
547 if [[ "$size" ]]; then
548 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
549 awk '($3 == "in") { print $1 }')
550 [[ $in = "1+0" ]] || rc=1
556 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
557 # But with new MDS stack we don't care about the mode of local objects
558 # anymore, so this test is removed. See bug 22944 for more details.
563 check_mount || return 41
566 echo "Remove mds config log"
567 if ! combined_mgs_mds ; then
571 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MGSDEV || return \$?" || return $?
573 if ! combined_mgs_mds ; then
578 start_mds && return 42
581 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
584 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
585 skip "Only applicable to ldiskfs-based MDTs"
589 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
594 # check if current MDSSIZE is large enough
595 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
596 log "use MDSSIZE=$MDSSIZE"
598 # check if the global config has a large enough MDSSIZE
599 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
600 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
601 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
603 # check if the block device is large enough
604 [ -z "$OK" ] && $(is_blkdev $SINGLEMDS $MDSDEV $MIN) && OK=1 &&
605 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
607 # check if a loopback device has enough space for fs metadata (5%)
609 if [ -z "$OK" ]; then
610 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
611 awk '($1 != "Filesystem") {print $4}')
612 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
613 OK=1 && myMDSSIZE=$MIN && \
614 log "use file $MDSDEV with MIN=$MIN"
617 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
620 echo "mount mds with large journal..."
622 local OLD_MDSSIZE=$MDSSIZE
626 echo "mount lustre system..."
628 check_mount || return 41
630 echo "check journal size..."
631 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
632 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
633 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
635 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
643 run_test 18 "check mkfs creates large journals"
646 start_mds || return 1
647 stop_mds -f || return 2
649 run_test 19a "start/stop MDS without OSTs"
652 start_ost || return 1
653 stop_ost -f || return 2
655 run_test 19b "start/stop OSTs without MDS"
658 # first format the ost/mdt
662 check_mount || return 43
664 remount_client ro $MOUNT || return 44
665 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
666 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
667 remount_client rw $MOUNT || return 47
669 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
670 MCNT=`grep -c $MOUNT /etc/mtab`
671 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
676 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
681 wait_osc_import_state mds ost FULL
685 run_test 21a "start mds before ost, stop ost first"
690 wait_osc_import_state mds ost FULL
694 run_test 21b "start ost before mds, stop mds first"
700 wait_osc_import_state mds ost2 FULL
704 #writeconf to remove all ost2 traces for subsequent tests
707 run_test 21c "start mds between two osts, stop mds last"
710 if combined_mgs_mds ; then
711 skip "need separate mgs device" && return 0
721 wait_osc_import_state mds ost2 FULL
727 #writeconf to remove all ost2 traces for subsequent tests
731 run_test 21d "start mgs then ost and then mds"
736 echo Client mount with ost in logs, but none running
738 # wait until mds connected to ost and open client connection
739 wait_osc_import_state mds ost FULL
742 # check_mount will block trying to contact ost
743 mcreate $DIR/$tfile || return 40
744 rm -f $DIR/$tfile || return 42
748 echo Client mount with a running ost
751 # if gss enabled, wait full time to let connection from
752 # mds to ost be established, due to the mismatch between
753 # initial connect timeout and gss context negotiation timeout.
754 # This perhaps could be remove after AT landed.
755 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
756 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
759 wait_osc_import_state mds ost FULL
760 wait_osc_import_state client ost FULL
761 check_mount || return 41
766 run_test 22 "start a client before osts (should return errs)"
768 test_23a() { # was test_23
772 # force down client so that recovering mds waits for reconnect
773 local running=$(grep -c $MOUNT /proc/mounts) || true
774 if [ $running -ne 0 ]; then
775 echo "Stopping client $MOUNT (opts: -f)"
779 # enter recovery on mds
781 # try to start a new client
782 mount_client $MOUNT &
784 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
785 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
786 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
788 ps --ppid $MOUNT_LUSTRE_PID
789 echo "waiting for mount to finish"
791 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
792 # SIGTERM works but it does not spread to offspring processses
793 kill -s TERM $MOUNT_PID
794 kill -s TERM $MOUNT_LUSTRE_PID
795 # we can not wait $MOUNT_PID because it is not a child of this shell
801 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
803 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
804 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
807 [ -z "$PID1" -a -z "$PID2" ] && break
808 echo "waiting for mount to finish ... "
809 WAIT=$(( WAIT + sleep))
811 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
812 error "MOUNT_PID $MOUNT_PID and "\
813 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
819 run_test 23a "interrupt client during recovery mount delay"
824 test_23b() { # was test_23
827 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
828 lctl set_param fail_loc=0x80000313
832 run_test 23b "Simulate -EINTR during mount"
834 fs2mds_HOST=$mds_HOST
835 fs2ost_HOST=$ost_HOST
837 MDSDEV1_2=$fs2mds_DEV
838 OSTDEV1_2=$fs2ost_DEV
839 OSTDEV2_2=$fs3ost_DEV
843 echo "umount $MOUNT2 ..."
844 umount $MOUNT2 || true
845 echo "stopping fs2mds ..."
846 stop fs2mds -f || true
847 echo "stopping fs2ost ..."
848 stop fs2ost -f || true
852 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
854 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
855 is_blkdev $SINGLEMDS $MDSDEV && \
856 skip_env "mixed loopback and real device not working" && return
859 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
861 local fs2mdsdev=$(mdsdevname 1_2)
862 local fs2ostdev=$(ostdevname 1_2)
863 local fs2mdsvdev=$(mdsvdevname 1_2)
864 local fs2ostvdev=$(ostvdevname 1_2)
866 # test 8-char fsname as well
867 local FSNAME2=test1234
868 add fs2mds $(mkfs_opts mds1) --nomgs --mgsnode=$MGSNID \
869 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
871 add fs2ost $(mkfs_opts ost1) --fsname=${FSNAME2} --reformat \
872 $fs2ostdev $fs2ostvdev || exit 10
875 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
876 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
878 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
880 check_mount || return 2
881 # files written on 1 should not show up on 2
882 cp /etc/passwd $DIR/$tfile
884 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
887 cp /etc/passwd $MOUNT2/b || return 3
888 rm $MOUNT2/b || return 4
889 # 2 is actually mounted
890 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
892 facet_failover fs2mds
893 facet_failover fs2ost
896 # the MDS must remain up until last MDT
898 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
899 [ -z "$MDS" ] && error "No MDT" && return 8
901 cleanup_nocli || return 6
903 run_test 24a "Multiple MDTs on a single node"
906 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
908 if [ -z "$fs2mds_DEV" ]; then
909 local dev=${SINGLEMDS}_dev
911 is_blkdev $SINGLEMDS $MDSDEV && \
912 skip_env "mixed loopback and real device not working" && return
915 local fs2mdsdev=$(mdsdevname 1_2)
916 local fs2mdsvdev=$(mdsvdevname 1_2)
918 add fs2mds $(mkfs_opts mds1) --mgs --fsname=${FSNAME}2 --reformat \
919 $fs2mdsdev $fs2mdsvdev || exit 10
921 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
924 run_test 24b "Multiple MGSs on a single node (should return err)"
928 check_mount || return 2
929 local MODULES=$($LCTL modules | awk '{ print $2 }')
930 rmmod $MODULES 2>/dev/null || true
933 run_test 25 "Verify modules are referenced"
937 # we need modules before mount for sysctl, so make sure...
938 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
939 #define OBD_FAIL_MDS_FS_SETUP 0x135
940 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
941 start_mds && echo MDS started && return 1
942 lctl get_param -n devices
943 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
944 [ $DEVS -gt 0 ] && return 2
945 unload_modules_conf || return $?
947 run_test 26 "MDT startup failure cleans LOV (should return errs)"
953 local ORIG=$(do_facet $myfacet "$TEST")
954 if [ $# -gt 3 ]; then
960 echo "Setting $PARAM from $ORIG to $FINAL"
961 do_facet mgs "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
963 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
967 start_ost || return 1
968 start_mds || return 2
969 echo "Requeue thread should have started: "
970 ps -e | grep ll_cfg_requeue
971 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
974 run_test 27a "Reacquire MGS lock if OST started first"
979 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
981 facet_failover $SINGLEMDS
982 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
983 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
987 run_test 27b "Reacquire MGS lock after failover"
991 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
992 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
995 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
996 FINAL=$(($FINAL + 1))
997 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
998 umount_client $MOUNT || return 200
1001 if [ $RESULT -ne $FINAL ]; then
1002 echo "New config not seen: wanted $FINAL got $RESULT"
1005 echo "New config success: got $RESULT"
1007 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
1010 run_test 28 "permanent parameter setting"
1013 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1014 setup > /dev/null 2>&1
1018 local PARAM="$FSNAME-OST0001.osc.active"
1019 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1020 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1022 ACTV=$(lctl get_param -n $PROC_ACT)
1024 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1025 # also check ost_server_uuid status
1026 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1027 if [ -z "$RESULT" ]; then
1028 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1031 echo "Live client success: got $RESULT"
1035 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0001)
1036 mdtosc=${mdtosc/-MDT*/-MDT\*}
1037 local MPROC="osc.$mdtosc.active"
1042 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
1043 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1044 if [ $RESULT -eq $DEAC ]; then
1045 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
1049 if [ $WAIT -eq $MAX ]; then
1050 echo "MDT not deactivated: wanted $DEAC got $RESULT"
1053 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
1056 # quotacheck should not fail immediately after deactivate
1057 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1059 # test new client starts deactivated
1060 umount_client $MOUNT || return 200
1062 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1063 if [ -z "$RESULT" ]; then
1064 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1067 echo "New client success: got $RESULT"
1070 # quotacheck should not fail after umount/mount operation
1071 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
1073 # make sure it reactivates
1074 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1076 umount_client $MOUNT
1079 #writeconf to remove all ost2 traces for subsequent tests
1082 run_test 29 "permanently remove an OST"
1087 echo Big config llog
1088 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1090 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1091 for i in ${LIST[@]}; do
1092 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1094 # make sure client restart still works
1095 umount_client $MOUNT
1096 mount_client $MOUNT || return 4
1097 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1100 echo Erase parameter setting
1101 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1102 umount_client $MOUNT
1103 mount_client $MOUNT || return 6
1105 echo "deleted (default) value=$FINAL, orig=$ORIG"
1106 # assumes this parameter started at the default value
1107 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1111 run_test 30a "Big config llog and conf_param deletion"
1116 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1117 # numerical part of it. Hopefully that's not already a failover address for
1119 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1120 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1121 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1122 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1123 echo "Using fake nid $NEW"
1125 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1126 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
1127 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1129 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1130 echo "should have 2 failover nids: $NIDCOUNT"
1131 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1132 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1133 umount_client $MOUNT
1134 mount_client $MOUNT || return 3
1136 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1138 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1139 echo "only 1 final nid should remain: $NIDCOUNT"
1140 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1144 run_test 30b "Remove failover nids"
1146 test_31() { # bug 10734
1147 # ipaddr must not exist
1148 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1151 run_test 31 "Connect to non-existent node (shouldn't crash)"
1153 # Use these start32/stop32 fn instead of t-f start/stop fn,
1154 # for local devices, to skip global facet vars init
1158 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1159 umount -d $@ ${MOUNT%/*}/${facet}
1168 mkdir -p ${MOUNT%/*}/${facet}
1170 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1171 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1173 if [ $RC -ne 0 ]; then
1174 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1175 echo "Start of ${device} of local ${facet} failed ${RC}"
1181 cleanup_nocli32 () {
1189 echo "Cleanup test_32 umount $MOUNT ..."
1190 umount -f $MOUNT || true
1191 echo "Cleanup local mds ost1 ..."
1193 combined_mgs_mds || start_mgs
1198 client_only && skip "client only testing" && return 0
1199 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1200 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1202 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1203 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1204 local tmpdir=$TMP/conf32a
1206 tar xjvf $DISK1_8 -C $tmpdir || \
1207 { skip_env "Cannot untar $DISK1_8" && return 0; }
1210 $LCTL set_param debug="$PTLDEBUG"
1212 $TUNEFS $tmpdir/mds || error "tunefs failed"
1214 combined_mgs_mds || stop mgs
1216 # nids are wrong, so client wont work, but server should start
1217 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1218 trap cleanup_32 EXIT INT || return 3
1220 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1222 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1224 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1225 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1226 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1228 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1230 local NID=$($LCTL list_nids | head -1)
1232 echo "OSC changes should succeed:"
1233 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1234 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1237 echo "MDC changes should succeed:"
1238 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1239 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1242 echo "LOV changes should succeed:"
1243 $LCTL pool_new lustre.interop || return 11
1244 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1249 # mount a second time to make sure we didnt leave upgrade flag on
1251 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1253 combined_mgs_mds || stop mgs
1255 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1256 trap cleanup_32 EXIT INT || return 12
1260 rm -rf $tmpdir || true # true is only for TMP on NFS
1262 run_test 32a "Upgrade from 1.8 (not live)"
1265 client_only && skip "client only testing" && return 0
1266 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1267 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1269 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1270 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1271 local tmpdir=$TMP/conf32b
1273 tar xjvf $DISK1_8 -C $tmpdir || \
1274 { skip_env "Cannot untar $DISK1_8" && return ; }
1277 $LCTL set_param debug="+config"
1278 local NEWNAME=lustre
1280 # writeconf will cause servers to register with their current nids
1281 $TUNEFS --writeconf --erase-params \
1282 --param mdt.identity_upcall=$L_GETIDENTITY \
1283 --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1284 combined_mgs_mds || stop mgs
1286 start32 mds1 $tmpdir/mds "-o loop" && \
1287 trap cleanup_32 EXIT INT || return 3
1289 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1291 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1293 $TUNEFS --writeconf --erase-params \
1294 --mgsnode=$HOSTNAME --fsname=$NEWNAME $tmpdir/ost1 ||\
1295 error "tunefs failed"
1296 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1297 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1299 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1301 local NID=$($LCTL list_nids | head -1)
1303 echo "OSC changes should succeed:"
1304 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1305 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1308 echo "MDC changes should succeed:"
1309 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1310 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1313 echo "LOV changes should succeed:"
1314 $LCTL pool_new ${NEWNAME}.interop || return 11
1315 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1318 # MDT and OST should have registered with new nids, so we should have
1319 # a fully-functioning client
1320 echo "Check client and old fs contents"
1322 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1323 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1324 mount -t lustre $device $MOUNT || return 1
1326 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1327 local new=$((old + 5))
1328 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1329 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1331 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1336 rm -rf $tmpdir || true # true is only for TMP on NFS
1338 run_test 32b "Upgrade from 1.8 with writeconf"
1340 test_33a() { # bug 12333, was test_33
1342 local FSNAME2=test-123
1343 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1346 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1348 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1349 local dev=${SINGLEMDS}_dev
1350 local MDSDEV=${!dev}
1351 is_blkdev $SINGLEMDS $MDSDEV && \
1352 skip_env "mixed loopback and real device not working" && return
1355 local fs2mdsdev=$(mdsdevname 1_2)
1356 local fs2ostdev=$(ostdevname 1_2)
1357 local fs2mdsvdev=$(mdsvdevname 1_2)
1358 local fs2ostvdev=$(ostvdevname 1_2)
1360 if [ $(facet_fstype mds1) == ldiskfs ]; then
1361 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
1364 add fs2mds $(mkfs_opts mds1) --fsname=${FSNAME2} --reformat \
1365 $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
1366 add fs2ost $(mkfs_opts ost1) --mgsnode=$MGSNID --fsname=${FSNAME2} \
1367 --index=8191 --reformat $fs2ostdev $fs2ostvdev || exit 10
1369 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1370 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1371 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1373 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1376 cp /etc/hosts $MOUNT2/ || rc=3
1377 $LFS getstripe $MOUNT2/hosts
1382 cleanup_nocli || rc=6
1385 run_test 33a "Mount ost with a large index number"
1387 test_33b() { # was test_34
1390 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1391 # Drop lock cancelation reply during umount
1392 #define OBD_FAIL_LDLM_CANCEL 0x304
1393 do_facet client lctl set_param fail_loc=0x80000304
1394 #lctl set_param debug=-1
1395 umount_client $MOUNT
1398 run_test 33b "Drop cancel during umount"
1402 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1403 manual_umount_client
1405 do_facet client killall -USR1 multiop
1406 if [ $rc -eq 0 ]; then
1407 error "umount not fail!"
1412 run_test 34a "umount with opened file should be fail"
1417 touch $DIR/$tfile || return 1
1418 stop_mds --force || return 2
1420 manual_umount_client --force
1422 if [ $rc -ne 0 ]; then
1423 error "mtab after failed umount - rc $rc"
1429 run_test 34b "force umount with failed mds should be normal"
1433 touch $DIR/$tfile || return 1
1434 stop_ost --force || return 2
1436 manual_umount_client --force
1438 if [ $rc -ne 0 ]; then
1439 error "mtab after failed umount - rc $rc"
1445 run_test 34c "force umount with failed ost should be normal"
1447 test_35a() { # bug 12459
1450 DBG_SAVE="`lctl get_param -n debug`"
1451 lctl set_param debug="ha"
1453 log "Set up a fake failnode for the MDS"
1455 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1456 do_facet mgs $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1458 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1461 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1464 log "Stopping the MDT:"
1465 stop_mds || return 5
1467 df $MOUNT > /dev/null 2>&1 &
1469 log "Restarting the MDT:"
1470 start_mds || return 6
1471 log "Wait for df ($DFPID) ... "
1474 lctl set_param debug="$DBG_SAVE"
1476 # retrieve from the log the first server that the client tried to
1477 # contact after the connection loss
1478 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1479 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1480 /import_select_connection.*$device-mdc.* using connection/ {
1482 if (\\\$NF ~ /$FAKENID/)
1488 }" $TMP/lustre-log-$TESTNAME.log`
1489 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1491 # remove nid settings
1494 run_test 35a "Reconnect to the last active server first"
1496 test_35b() { # bug 18674
1497 remote_mds || { skip "local MDS" && return 0; }
1501 $LCTL set_param debug="ha"
1503 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1506 log "Set up a fake failnode for the MDS"
1508 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | \
1509 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1510 do_facet mgs "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1513 local at_max_saved=0
1514 # adaptive timeouts may prevent seeing the issue
1515 if at_is_enabled; then
1516 at_max_saved=$(at_max_get mds)
1517 at_max_set 0 mds client
1520 mkdir -p $MOUNT/$tdir
1522 log "Injecting EBUSY on MDS"
1523 # Setting OBD_FAIL_MDS_RESEND=0x136
1524 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
1526 $LCTL set_param mdc.${FSNAME}*.stats=clear
1528 log "Creating a test file and stat it"
1529 touch $MOUNT/$tdir/$tfile
1530 stat $MOUNT/$tdir/$tfile
1532 log "Stop injecting EBUSY on MDS"
1533 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
1534 rm -f $MOUNT/$tdir/$tfile
1537 # restore adaptive timeout
1538 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1540 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1542 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
1544 # retrieve from the log if the client has ever tried to
1545 # contact the fake server after the loss of connection
1546 FAILCONN=`awk "BEGIN {ret = 0;}
1547 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1549 if (\\\$NF ~ /$FAKENID/) {
1554 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1556 [ "$FAILCONN" == "0" ] && \
1557 log "ERROR: The client reconnection has not been triggered" && \
1559 [ "$FAILCONN" == "2" ] && \
1560 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1564 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
1565 # Reconnects are supposed to be rate limited to one every 5s
1566 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
1567 log "ERROR: Too many reconnects $CONNCNT" && \
1571 # remove nid settings
1574 run_test 35b "Continue reconnection retries, if the active server is busy"
1577 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1579 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1580 { skip "remote OST" && return 0; }
1583 local FSNAME2=test1234
1584 local fs3ost_HOST=$ost_HOST
1585 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1587 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1589 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1590 is_blkdev $SINGLEMDS $MDSDEV && \
1591 skip_env "mixed loopback and real device not working" && return
1594 local fs2mdsdev=$(mdsdevname 1_2)
1595 local fs2ostdev=$(ostdevname 1_2)
1596 local fs3ostdev=$(ostdevname 2_2)
1597 local fs2mdsvdev=$(mdsvdevname 1_2)
1598 local fs2ostvdev=$(ostvdevname 1_2)
1599 local fs3ostvdev=$(ostvdevname 2_2)
1601 add fs2mds $(mkfs_opts mds1) --fsname=${FSNAME2} --reformat \
1602 $fs2mdsdev $fs2mdsvdev || exit 10
1603 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
1604 # different one than the default value here.
1605 add fs2ost $(mkfs_opts ost1) --mgsnode=$MGSNID --fsname=${FSNAME2} \
1606 --reformat $fs2ostdev $fs2ostvdev || exit 10
1607 add fs3ost $(mkfs_opts ost1) --mgsnode=$MGSNID --fsname=${FSNAME2} \
1608 --reformat $fs3ostdev $fs3ostvdev || exit 10
1610 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1611 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1612 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1614 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1616 sleep 5 # until 11778 fixed
1618 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1620 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1621 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1622 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1623 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1624 DFTOTAL=`echo $STRING | cut -d, -f1`
1625 DFUSED=`echo $STRING | cut -d, -f2`
1626 DFAVAIL=`echo $STRING | cut -d, -f3`
1627 DFFREE=$(($DFTOTAL - $DFUSED))
1629 ALLOWANCE=$((64 * $OSTCOUNT))
1631 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1632 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1633 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1636 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1637 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1638 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1641 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1642 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1643 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1648 stop fs3ost -f || return 200
1649 stop fs2ost -f || return 201
1650 stop fs2mds -f || return 202
1651 unload_modules_conf || return 203
1654 run_test 36 "df report consistency on OSTs with different block size"
1657 local mntpt=$(facet_mntpt $SINGLEMDS)
1658 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
1659 local mdsdev_sym="$TMP/sym_mdt.img"
1660 local opts=$MDS_MOUNT_OPTS
1663 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
1664 skip "Currently only applicable to ldiskfs-based MDTs"
1668 echo "MDS : $mdsdev"
1669 echo "SYMLINK : $mdsdev_sym"
1670 do_facet $SINGLEMDS rm -f $mdsdev_sym
1672 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
1674 echo "mount symlink device - $mdsdev_sym"
1676 if ! do_facet $SINGLEMDS test -b $mdsdev; then
1677 opts=$(csa_add "$opts" -o loop)
1679 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
1680 $mdsdev_sym $mntpt 2>&1)
1683 echo mount_op=$mount_op
1685 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
1687 if $(echo $mount_op | grep -q "unable to set tunable"); then
1688 error "set tunables failed for symlink device"
1691 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
1695 run_test 37 "verify set tunables works for symlink device"
1697 test_38() { # bug 14222
1702 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1703 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1705 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1706 error "copying $SRC to $DIR/$tdir"
1708 umount_client $MOUNT
1710 log "rename lov_objid file on MDS"
1711 rm -f $TMP/lov_objid.orig
1713 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1714 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1715 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1717 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1718 # check create in mds_lov_connect
1722 [ $V ] && log "verifying $DIR/$tdir/$f"
1723 diff -q $f $DIR/$tdir/$f || ERROR=y
1725 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1726 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1727 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1729 # check it's updates in sync
1730 umount_client $MOUNT
1733 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1734 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1735 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1740 [ $V ] && log "verifying $DIR/$tdir/$f"
1741 diff -q $f $DIR/$tdir/$f || ERROR=y
1743 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1744 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1745 umount_client $MOUNT
1747 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1749 log "files compared the same"
1752 run_test 38 "MDS recreates missing lov_objid file from OST data"
1758 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1759 error "memory leak detected" || true
1761 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1763 test_40() { # bug 15759
1765 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1766 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
1770 run_test 40 "race during service thread startup"
1772 test_41a() { #bug 14134
1773 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
1774 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
1775 skip "Loop devices does not work with nosvc option"
1780 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1782 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1783 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1784 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1786 mount_client $MOUNT || return 1
1789 echo "blah blah" > $MOUNT/$tfile
1792 umount_client $MOUNT
1793 stop ost1 -f || return 201
1794 stop_mds -f || return 202
1795 stop_mds -f || return 203
1796 unload_modules_conf || return 204
1799 run_test 41a "mount mds with --nosvc and --nomgs"
1802 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
1803 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
1804 skip "Loop devices does not work with nosvc option"
1808 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
1812 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1814 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1816 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1818 mount_client $MOUNT || return 1
1821 echo "blah blah" > $MOUNT/$tfile
1822 cat $MOUNT/$tfile || return 200
1824 umount_client $MOUNT
1825 stop_ost || return 201
1826 stop_mds -f || return 202
1827 stop_mds -f || return 203
1830 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
1832 test_42() { #bug 14693
1834 check_mount || return 2
1835 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1836 umount_client $MOUNT
1837 mount_client $MOUNT || return 1
1841 run_test 42 "invalid config param should not prevent client from mounting"
1844 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1846 chmod ugo+x $DIR || error "chmod 0 failed"
1848 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1849 "$FSNAME.mdt.root_squash" \
1852 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1853 "$FSNAME.mdt.nosquash_nids" \
1857 # create set of test files
1859 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1860 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1861 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1863 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1864 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1866 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1867 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1868 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1871 # check root_squash:
1872 # set root squash UID:GID to RUNAS_ID
1873 # root should be able to access only files owned by RUNAS_ID
1876 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1877 "$FSNAME.mdt.root_squash" \
1878 "$RUNAS_ID:$RUNAS_ID"
1880 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1881 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1882 error "$ST: root read permission is denied"
1883 echo "$ST: root read permission is granted - ok"
1886 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1887 error "$ST: root write permission is denied"
1888 echo "$ST: root write permission is granted - ok"
1890 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1891 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1892 error "$ST: root read permission is granted"
1893 echo "$ST: root read permission is denied - ok"
1896 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1897 error "$ST: root write permission is granted"
1898 echo "$ST: root write permission is denied - ok"
1900 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1901 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1902 error "$ST: root unlink permission is granted"
1903 echo "$ST: root unlink permission is denied - ok"
1905 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1906 error "$ST: root create permission is granted"
1907 echo "$ST: root create permission is denied - ok"
1910 # check nosquash_nids:
1911 # put client's NID into nosquash_nids list,
1912 # root should be able to access root file after that
1914 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1915 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1916 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1918 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1919 "$FSNAME-MDTall.mdt.nosquash_nids" \
1922 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1923 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1924 error "$ST: root read permission is denied"
1925 echo "$ST: root read permission is granted - ok"
1928 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1929 error "$ST: root write permission is denied"
1930 echo "$ST: root write permission is granted - ok"
1932 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1933 rm $DIR/$tdir-rootdir/tfile-1 || \
1934 error "$ST: root unlink permission is denied"
1935 echo "$ST: root unlink permission is granted - ok"
1936 touch $DIR/$tdir-rootdir/tfile-2 || \
1937 error "$ST: root create permission is denied"
1938 echo "$ST: root create permission is granted - ok"
1942 run_test 43 "check root_squash and nosquash_nids"
1944 umount_client $MOUNT
1949 check_mount || return 2
1950 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1952 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1953 for VAL in $UUIDS; do
1954 NID=$(echo $VAL | cut -d= -f1)
1955 CLUUID=$(echo $VAL | cut -d= -f2)
1956 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1958 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1962 run_test 44 "mounted client proc entry exists"
1966 check_mount || return 2
1971 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1972 do_facet client "lctl set_param fail_loc=0x50f"
1975 manual_umount_client --force || return 3
1976 do_facet client "lctl set_param fail_loc=0x0"
1978 mount_client $MOUNT || return 4
1982 run_test 45 "long unlink handling in ptlrpcd"
1989 umount_client $MOUNT2 || rc=$?
1990 umount_client $MOUNT || rc=$?
1991 while [ $count -gt 0 ]; do
1992 stop ost${count} -f || rc=$?
1996 cleanup_nocli || rc=$?
1997 #writeconf to remove all ost2 traces for subsequent tests
2003 echo "Testing with $OSTCOUNT OSTs"
2005 start_mds || return 1
2006 #first client should see only one ost
2007 start_ost || return 2
2008 wait_osc_import_state mds ost FULL
2010 mount_client $MOUNT || return 3
2011 trap "cleanup_46a $OSTCOUNT" EXIT ERR
2014 for (( i=2; i<=$OSTCOUNT; i++ )); do
2015 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
2018 # wait until osts in sync
2019 for (( i=2; i<=$OSTCOUNT; i++ )); do
2020 wait_osc_import_state mds ost$i FULL
2021 wait_osc_import_state client ost$i FULL
2024 #second client see all ost's
2026 mount_client $MOUNT2 || return 8
2027 $LFS setstripe -c -1 $MOUNT2 || return 9
2028 $LFS getstripe $MOUNT2 || return 10
2030 echo "ok" > $MOUNT2/widestripe
2031 $LFS getstripe $MOUNT2/widestripe || return 11
2032 # fill acl buffer for avoid expand lsm to them
2033 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
2034 setfacl -m $acl $MOUNT2/widestripe
2038 stat $MOUNT/widestripe || return 12
2040 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
2043 run_test 46a "handle ost additional - wide striped file"
2048 check_mount || return 2
2049 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2053 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2054 if echo $ns | grep "MDT[[:digit:]]*"; then
2057 lrs=$(echo $ns | sed 's/.*lru_size=//')
2058 lru_size[count]=$lrs
2063 facet_failover $SINGLEMDS
2064 client_up || return 3
2067 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2068 if echo $ns | grep "MDT[[:digit:]]*"; then
2071 lrs=$(echo $ns | sed 's/.*lru_size=//')
2072 if ! test "$lrs" -eq "${lru_size[count]}"; then
2073 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2074 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2082 run_test 47 "server restart does not make client loss lru_resize settings"
2087 # reformat after this test is needed - if test will failed
2088 # we will have unkillable file at FS
2092 test_48() { # bug 17636
2095 check_mount || return 2
2097 $LFS setstripe -c -1 $MOUNT || return 9
2098 $LFS getstripe $MOUNT || return 10
2100 echo "ok" > $MOUNT/widestripe
2101 $LFS getstripe $MOUNT/widestripe || return 11
2103 trap cleanup_48 EXIT ERR
2105 # fill acl buffer for avoid expand lsm to them
2106 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2107 setfacl -m $acl $MOUNT/widestripe
2110 stat $MOUNT/widestripe || return 12
2115 run_test 48 "too many acls on file"
2117 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2118 test_49() { # bug 17710
2119 local timeout_orig=$TIMEOUT
2120 local ldlm_timeout_orig=$LDLM_TIMEOUT
2121 local LOCAL_TIMEOUT=20
2123 LDLM_TIMEOUT=$LOCAL_TIMEOUT
2124 TIMEOUT=$LOCAL_TIMEOUT
2128 check_mount || return 1
2130 echo "check ldlm_timout..."
2131 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2132 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2133 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2135 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2136 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2139 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2140 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2143 umount_client $MOUNT
2144 stop_ost || return 2
2145 stop_mds || return 3
2147 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
2151 check_mount || return 7
2153 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2154 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2155 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2157 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2158 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2161 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2162 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2165 cleanup || return $?
2167 LDLM_TIMEOUT=$ldlm_timeout_orig
2168 TIMEOUT=$timeout_orig
2170 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
2173 # Test both statfs and lfs df and fail if either one fails
2174 multiop_bg_pause $1 f_
2177 killall -USR1 multiop
2178 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2179 wait $PID || { RC1=$?; log "multiop return error "; }
2186 if [ $RC2 -eq 0 ]; then
2188 log "lazystatfs df failed"
2192 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2198 lctl set_param llite.$FSNAME-*.lazystatfs=1
2201 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2203 cleanup || return $?
2205 run_test 50a "lazystatfs all servers available =========================="
2209 lctl set_param llite.$FSNAME-*.lazystatfs=1
2212 # Wait for client to detect down OST
2213 stop_ost || error "Unable to stop OST1"
2214 wait_osc_import_state mds ost DISCONN
2216 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2218 umount_client $MOUNT || error "Unable to unmount client"
2219 stop_mds || error "Unable to stop MDS"
2221 run_test 50b "lazystatfs all servers down =========================="
2224 start_mds || error "Unable to start MDS"
2225 start_ost || error "Unable to start OST1"
2226 start_ost2 || error "Unable to start OST2"
2227 mount_client $MOUNT || error "Unable to mount client"
2228 lctl set_param llite.$FSNAME-*.lazystatfs=1
2231 # Wait for client to detect down OST
2232 stop_ost || error "Unable to stop OST1"
2233 wait_osc_import_state mds ost DISCONN
2234 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2236 umount_client $MOUNT || error "Unable to unmount client"
2237 stop_ost2 || error "Unable to stop OST2"
2238 stop_mds || error "Unable to stop MDS"
2239 #writeconf to remove all ost2 traces for subsequent tests
2242 run_test 50c "lazystatfs one server down =========================="
2245 start_mds || error "Unable to start MDS"
2246 start_ost || error "Unable to start OST1"
2247 start_ost2 || error "Unable to start OST2"
2248 mount_client $MOUNT || error "Unable to mount client"
2249 lctl set_param llite.$FSNAME-*.lazystatfs=1
2252 # Issue the statfs during the window where the client still
2253 # belives the OST to be available but it is in fact down.
2254 # No failure just a statfs which hangs for a timeout interval.
2255 stop_ost || error "Unable to stop OST1"
2256 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2258 umount_client $MOUNT || error "Unable to unmount client"
2259 stop_ost2 || error "Unable to stop OST2"
2260 stop_mds || error "Unable to stop MDS"
2261 #writeconf to remove all ost2 traces for subsequent tests
2264 run_test 50d "lazystatfs client/server conn race =========================="
2271 start_mds || return 1
2272 #first client should see only one ost
2273 start_ost || return 2
2274 wait_osc_import_state mds ost FULL
2276 # Wait for client to detect down OST
2277 stop_ost || error "Unable to stop OST1"
2278 wait_osc_import_state mds ost DISCONN
2280 mount_client $MOUNT || error "Unable to mount client"
2281 lctl set_param llite.$FSNAME-*.lazystatfs=0
2283 multiop_bg_pause $MOUNT _f
2287 if [ $RC1 -ne 0 ]; then
2288 log "multiop failed $RC1"
2291 sleep $(( $TIMEOUT+1 ))
2293 [ $? -ne 0 ] && error "process isn't sleep"
2294 start_ost || error "Unable to start OST1"
2295 wait $pid || error "statfs failed"
2298 umount_client $MOUNT || error "Unable to unmount client"
2299 stop_ost || error "Unable to stop OST1"
2300 stop_mds || error "Unable to stop MDS"
2302 run_test 50e "normal statfs all servers down =========================="
2307 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2309 start_mds || error "Unable to start mds"
2310 #first client should see only one ost
2311 start_ost || error "Unable to start OST1"
2312 wait_osc_import_state mds ost FULL
2314 start_ost2 || error "Unable to start OST2"
2315 wait_osc_import_state mds ost2 FULL
2317 # Wait for client to detect down OST
2318 stop_ost2 || error "Unable to stop OST2"
2320 wait_osc_import_state mds ost2 DISCONN
2321 mount_client $MOUNT || error "Unable to mount client"
2322 lctl set_param llite.$FSNAME-*.lazystatfs=0
2324 multiop_bg_pause $MOUNT _f
2328 if [ $RC1 -ne 0 ]; then
2329 log "lazystatfs multiop failed $RC1"
2332 sleep $(( $TIMEOUT+1 ))
2334 [ $? -ne 0 ] && error "process isn't sleep"
2335 start_ost2 || error "Unable to start OST2"
2336 wait $pid || error "statfs failed"
2337 stop_ost2 || error "Unable to stop OST2"
2340 umount_client $MOUNT || error "Unable to unmount client"
2341 stop_ost || error "Unable to stop OST1"
2342 stop_mds || error "Unable to stop MDS"
2343 #writeconf to remove all ost2 traces for subsequent tests
2346 run_test 50f "normal statfs one server in down =========================="
2349 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2351 start_ost2 || error "Unable to start OST2"
2352 wait_osc_import_state mds ost2 FULL
2353 wait_osc_import_state client ost2 FULL
2355 local PARAM="${FSNAME}-OST0001.osc.active"
2357 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2358 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2360 umount_client $MOUNT || error "Unable to unmount client"
2361 mount_client $MOUNT || error "Unable to mount client"
2362 # This df should not cause a panic
2365 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2367 umount_client $MOUNT || error "Unable to unmount client"
2368 stop_ost2 || error "Unable to stop OST2"
2369 stop_ost || error "Unable to stop OST1"
2370 stop_mds || error "Unable to stop MDS"
2371 #writeconf to remove all ost2 traces for subsequent tests
2374 run_test 50g "deactivated OST should not cause panic====================="
2377 local LOCAL_TIMEOUT=20
2381 check_mount || return 1
2384 $LFS setstripe -c -1 $MOUNT/d1
2385 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2386 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2387 touch $MOUNT/d1/f1 &
2390 start_ost2 || return 2
2392 stop_ost2 || return 3
2394 #writeconf to remove all ost2 traces for subsequent tests
2397 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2406 do_node $node mkdir -p $dest
2407 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2409 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2410 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2411 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2413 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2414 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2424 local backup2=${TMP}/backup2
2426 do_node $node mkdir -p $backup2
2427 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2429 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2430 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2431 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2433 do_node $node "diff -rq $backup $backup2"
2434 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2436 local xattrs2=${TMP}/xattrs2
2437 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2438 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2440 do_node $node "diff $xattrs $xattrs2"
2441 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2443 do_node $node "rm -rf $backup2 $xattrs2"
2444 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2449 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2451 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2453 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2456 local ost1mnt=$(facet_mntpt ost1)
2457 local ost1node=$(facet_active_host ost1)
2458 local ost1tmp=$TMP/conf52
2462 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2463 touch $TMP/modified_first
2464 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2465 local mtime=$(stat -c %Y $TMP/modified_first)
2466 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2468 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2471 $LFS setstripe -c -1 -S 1M $DIR/$tdir
2472 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2474 for (( i=0; i < nrfiles; i++ )); do
2475 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2476 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2482 echo backup files to $TMP/files
2483 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2484 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2485 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2487 umount_client $MOUNT
2488 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2490 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2492 echo mount ost1 as ldiskfs
2493 do_node $ost1node mkdir -p $ost1mnt
2494 [ $? -eq 0 ] || { error "Unable to create $ost1mnt"; return 23; }
2495 if ! do_node $ost1node test -b $ost1_dev; then
2498 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
2500 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2503 echo backup objects to $ost1tmp/objects
2504 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2505 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2506 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2507 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2509 # move objects to lost+found
2510 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2511 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2514 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2515 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2517 # compare restored objects against saved ones
2518 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2519 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2521 do_node $ost1node "umount $ost1mnt"
2522 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2525 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2527 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2530 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2531 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2533 rm -rf $TMP/files $TMP/file_xattrs
2534 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2535 do_node $ost1node "rm -rf $ost1tmp"
2536 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2539 run_test 52 "check recovering objects from lost+found"
2541 # Checks threads_min/max/started for some service
2543 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2544 # parameter pattern prefix like 'ost.*.ost'.
2556 local msg="Insane $modname thread counts"
2560 check_mount || return 41
2562 # We need to expand $parampat, but it may match multiple parameters, so
2563 # we'll pick the first one
2564 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2565 error "Couldn't expand ${parampat}.threads_min parameter name"
2569 # Remove the .threads_min part
2570 paramp=${paramp%.threads_min}
2572 # Check for sanity in defaults
2573 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2574 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2575 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2576 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2577 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
2579 # Check that we can change min/max
2580 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + 1))"
2581 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 1))"
2582 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2583 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2584 lassert 25 "$msg" '(($tmin2 == ($tmin + 1) && $tmax2 == ($tmax -1)))' || return $?
2586 # Check that we can set min/max to the same value
2587 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2588 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2589 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2590 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2591 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2593 # Check that we can't set max < min
2594 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2595 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2596 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2597 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
2599 # We need to ensure that we get the module options desired; to do this
2600 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2601 LOAD_MODULES_REMOTE=true
2604 setmodopts -a $modname "$opts" oldvalue
2608 check_mount || return 41
2610 # Restore previous setting of MODOPTS_*
2611 setmodopts $modname "$oldvalue"
2613 # Check that $opts took
2614 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2615 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2616 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2617 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2620 # Workaround a YALA bug where YALA expects that modules will remain
2621 # loaded on the servers
2622 LOAD_MODULES_REMOTE=false
2629 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2631 run_test 53a "check OSS thread count params"
2634 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2636 run_test 53b "check MDT thread count params"
2639 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p
2640 [ $? -eq 0 ] || error "llverdev failed!"
2643 run_test 54a "test llverdev and partial verify of device"
2647 run_llverfs $MOUNT -p
2648 [ $? -eq 0 ] || error "llverfs failed!"
2651 run_test 54b "test llverfs and partial verify of filesystem"
2655 local max_ost_index=$1
2656 echo -n $(((max_ost_index + 1) * 8))
2660 local mdsdev=$(mdsdevname 1)
2661 local mdsvdev=$(mdsvdevname 1)
2665 add mds1 $(mkfs_opts mds1) --reformat $mdsdev $mdsvdev ||
2667 add ost1 $(mkfs_opts ost1) --index=$i --reformat \
2668 $(ostdevname 1) $(ostvdevname 1)
2674 echo checking size of lov_objid for ost index $i
2675 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2676 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2677 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2679 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2686 run_test 55 "check lov_objid size"
2689 local mds_journal_size_orig=$MDSJOURNALSIZE
2692 add mds1 $(mkfs_opts mds1) --reformat $(mdsdevname 1) $(mdsvdevname 1)
2693 add ost1 $(mkfs_opts ost1) --index=1000 --reformat \
2694 $(ostdevname 1) $(ostvdevname 1)
2695 add ost2 $(mkfs_opts ost2) --index=10000 --reformat \
2696 $(ostdevname 2) $(ostvdevname 2)
2700 start_ost2 || error "Unable to start second ost"
2701 mount_client $MOUNT || error "Unable to mount client"
2704 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
2706 MDSJOURNALSIZE=$mds_journal_size_orig
2709 run_test 56 "check big indexes"
2711 test_57a() { # bug 22656
2712 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2714 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2716 start_ost && error "OST registration from failnode should fail"
2719 run_test 57a "initial registration from failnode should fail (should return errs)"
2722 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2724 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
2726 start_ost || error "OST registration from servicenode should not fail"
2729 run_test 57b "initial registration from servicenode should not fail"
2732 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2735 test_58() { # bug 22658
2736 if [ $(facet_fstype mds) == zfs ]; then
2737 skip "Does not work with ZFS-based MDTs yet"
2742 createmany -o $DIR/$tdir/$tfile-%d 100
2743 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
2744 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
2745 do_facet mds "lctl set_param fail_loc=0x601"
2746 unlinkmany $DIR/$tdir/$tfile-%d 100
2748 local MNTDIR=$(facet_mntpt mds)
2749 # remove all files from the OBJECTS dir
2750 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
2751 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
2752 do_facet mds "umount $MNTDIR"
2753 # restart MDS with missing llog files
2755 do_facet mds "lctl set_param fail_loc=0"
2758 run_test 58 "missing llog files must not prevent MDT from mounting"
2761 start_mgsmds >> /dev/null
2762 local C1=$(count_osts)
2763 if [ $C1 -eq 0 ]; then
2764 start_ost >> /dev/null
2768 echo "original ost count: $C1 (expect > 0)"
2769 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2770 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2771 local C2=$(count_osts)
2772 echo "after mdt writeconf count: $C2 (expect 0)"
2773 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2774 echo "OST start without writeconf should fail:"
2775 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2776 echo "OST start with writeconf should succeed:"
2777 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2778 local C3=$(count_osts)
2779 echo "after ost writeconf count: $C3 (expect 1)"
2780 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2781 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2782 local C4=$(count_osts)
2783 echo "after ost2 writeconf count: $C4 (expect 2)"
2784 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2785 stop_ost2 >> /dev/null
2786 cleanup_nocli >> /dev/null
2787 #writeconf to remove all ost2 traces for subsequent tests
2790 run_test 59 "writeconf mount option"
2792 test_60() { # LU-471
2793 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2794 skip "Only applicable to ldiskfs-based MDTs"
2798 add mds1 $(mkfs_opts mds1) \
2799 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' --reformat \
2800 $(mdsdevname 1) $(mdsvdevname 1) || exit 10
2802 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
2804 [ $rc -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
2806 # MDT default has dirdata feature
2807 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
2808 # we disable uninit_bg feature
2809 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
2810 # we set stride extended options
2811 echo $dump | grep stride > /dev/null || error "stride is not set"
2814 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
2817 local reformat=false
2819 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
2820 { skip "Need MDS version at least 2.1.53"; return 0; }
2822 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2823 ! large_xattr_enabled; then
2825 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
2826 LDISKFS_MKFS_OPTS+=" -O large_xattr"
2827 add $SINGLEMDS $(mkfs_opts $SINGLEMDS) --reformat $mds_dev ||
2828 error "reformatting $mds_dev failed"
2831 setup_noconfig || error "setting up the filesystem failed"
2832 client_up || error "starting client failed"
2834 local file=$DIR/$tfile
2837 local large_value="$(generate_string $(max_xattr_size))"
2838 local small_value="bar"
2840 local name="trusted.big"
2841 log "save large xattr $name on $file"
2842 setfattr -n $name -v $large_value $file ||
2843 error "saving $name on $file failed"
2845 local new_value=$(get_xattr_value $name $file)
2846 [[ "$new_value" != "$large_value" ]] &&
2847 error "$name different after saving"
2849 log "shrink value of $name on $file"
2850 setfattr -n $name -v $small_value $file ||
2851 error "shrinking value of $name on $file failed"
2853 new_value=$(get_xattr_value $name $file)
2854 [[ "$new_value" != "$small_value" ]] &&
2855 error "$name different after shrinking"
2857 log "grow value of $name on $file"
2858 setfattr -n $name -v $large_value $file ||
2859 error "growing value of $name on $file failed"
2861 new_value=$(get_xattr_value $name $file)
2862 [[ "$new_value" != "$large_value" ]] &&
2863 error "$name different after growing"
2865 log "check value of $name on $file after remounting MDS"
2867 new_value=$(get_xattr_value $name $file)
2868 [[ "$new_value" != "$large_value" ]] &&
2869 error "$name different after remounting MDS"
2871 log "remove large xattr $name from $file"
2872 setfattr -x $name $file || error "removing $name from $file failed"
2877 LDISKFS_MKFS_OPTS=${LDISKFS_MKFS_OPTS% -O large_xattr}
2881 run_test 61 "large xattr"
2885 local mdsdev=$(mdsdevname 1)
2886 local ostdev=$(ostdevname 1)
2888 echo "disable journal for mds"
2889 do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
2890 start_mds && error "MDT start should fail"
2891 echo "disable journal for ost"
2892 do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
2893 start_ost && error "OST start should fail"
2894 cleanup || return $?
2897 run_test 62 "start with disabled journal"
2899 if ! combined_mgs_mds ; then
2905 complete $(basename $0) $SECONDS