3 # FIXME - there is no reason to use all of these different return codes,
4 # espcially when most of them are mapped to something else anyway.
5 # The tests should use error() to describe the failure more clearly,
6 # and reduce the need to look into the tests to see what failed.
12 # bug number for skipped test: LU-2828
13 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 59 64"
14 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18 if [ -r /etc/SuSE-release ]
20 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
21 local patchlev=`grep PATCHLEVEL /etc/SuSE-release \
23 if [ $vers -eq 11 ] && [ $patchlev -eq 2 ]
31 if is_sles11; then # LU-2181
32 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 23a 34b"
35 if [ "$FAILURE_MODE" = "HARD" ]; then
36 CONFIG_EXCEPTIONS="24a " && \
37 echo "Except the tests: $CONFIG_EXCEPTIONS for FAILURE_MODE=$FAILURE_MODE, bug 23573" && \
38 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
41 # bug number for skipped test:
42 # a tool to create lustre filesystem images
43 ALWAYS_EXCEPT="32newtarball $ALWAYS_EXCEPT"
46 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
48 PTLDEBUG=${PTLDEBUG:--1}
50 LUSTRE=${LUSTRE:-`dirname $0`/..}
51 RLUSTRE=${RLUSTRE:-$LUSTRE}
52 export MULTIOP=${MULTIOP:-multiop}
54 . $LUSTRE/tests/test-framework.sh
56 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
58 # use small MDS + OST size to speed formatting time
59 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
60 # STORED_MDSSIZE is used in test_18
61 STORED_MDSSIZE=$MDSSIZE
62 STORED_OSTSIZE=$OSTSIZE
66 if ! combined_mgs_mds; then
67 # bug number for skipped test: 23954
68 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
71 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
72 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
73 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
76 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
77 # bug number for skipped test: LU-2778 LU-4444
78 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 57b 69"
83 require_dsh_mds || exit 0
84 require_dsh_ost || exit 0
86 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45 69"
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
109 writeconf_or_reformat() {
110 # There are at most 2 OSTs for write_conf test
111 # who knows if/where $TUNEFS is installed?
112 # Better reformat if it fails...
113 writeconf_all $MDSCOUNT 2 ||
114 { echo "tunefs failed, reformatting instead" &&
115 reformat_and_config && return 0; }
125 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
131 local dev=$(mdsdevname $num)
134 echo "start mds service on `facet_active_host $facet`"
135 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
141 local dev=$(mdsdevname $num)
144 echo "stop mds service on `facet_active_host $facet`"
145 # These tests all use non-failover stop
146 stop $facet -f || return 97
152 for num in $(seq $MDSCOUNT); do
153 start_mdt $num $@ || return 94
158 if ! combined_mgs_mds ; then
166 for num in $(seq $MDSCOUNT); do
167 stop_mdt $num || return 97
172 echo "stop mgs service on `facet_active_host mgs`"
173 # These tests all use non-failover stop
174 stop mgs -f || return 97
178 echo "start ost1 service on `facet_active_host ost1`"
179 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
183 echo "stop ost1 service on `facet_active_host ost1`"
184 # These tests all use non-failover stop
185 stop ost1 -f || return 98
189 echo "start ost2 service on `facet_active_host ost2`"
190 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
194 echo "stop ost2 service on `facet_active_host ost2`"
195 # These tests all use non-failover stop
196 stop ost2 -f || return 93
201 echo "mount $FSNAME on ${MOUNTPATH}....."
202 zconf_mount `hostname` $MOUNTPATH || return 96
206 local mountopt="remount,$1"
208 echo "remount '$1' lustre on ${MOUNTPATH}....."
209 zconf_mount `hostname` $MOUNTPATH "$mountopt" || return 96
214 echo "umount lustre on ${MOUNTPATH}....."
215 zconf_umount `hostname` $MOUNTPATH || return 97
218 manual_umount_client(){
221 echo "manual umount lustre on ${MOUNT}...."
222 do_facet client "umount -d ${FORCE} $MOUNT"
228 start_mds || error "MDT start failed"
229 start_ost || error "OST start failed"
230 mount_client $MOUNT || error "client start failed"
231 client_up || error "client_up failed"
240 unload_modules_conf () {
241 if combined_mgs_mds || ! local_mode; then
242 unload_modules || return 1
247 stop_ost || return 202
248 stop_mds || return 201
249 unload_modules_conf || return 203
253 umount_client $MOUNT || return 200
254 cleanup_nocli || return $?
258 do_facet client "cp /etc/passwd $DIR/a" || return 71
259 do_facet client "rm $DIR/a" || return 72
260 # make sure lustre is actually mounted (touch will block,
261 # but grep won't, so do it after)
262 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
263 echo "setup single mount lustre success"
267 do_facet client "touch $DIR/a" || return 71
268 do_facet client "rm $DIR/a" || return 72
269 do_facet client "touch $DIR2/a" || return 73
270 do_facet client "rm $DIR2/a" || return 74
271 echo "setup double mount lustre success"
276 if [ "$ONLY" == "setup" ]; then
281 if [ "$ONLY" == "cleanup" ]; then
288 #create single point mountpoint
294 check_mount || return 41
297 run_test 0 "single mount setup"
300 start_mds || error "MDT start failed"
302 echo "start ost second time..."
303 start_ost && error "2nd OST start should fail"
304 mount_client $MOUNT || error "client start failed"
305 check_mount || return 42
308 run_test 1 "start up ost twice (should return errors)"
312 echo "start mds second time.."
313 start_mdt 1 && error "2nd MDT start should fail"
316 check_mount || return 43
319 run_test 2 "start up mds twice (should return err)"
323 #mount.lustre returns an error if already in mtab
324 mount_client $MOUNT && error "2nd client mount should fail"
325 check_mount || return 44
328 run_test 3 "mount client twice (should return err)"
332 touch $DIR/$tfile || return 85
336 # ok for ost to fail shutdown
337 if [ 202 -ne $eno ]; then
342 run_test 4 "force cleanup ost, then cleanup"
344 test_5a() { # was test_5
346 touch $DIR/$tfile || return 1
347 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
349 stop_mds -f || return 2
351 # cleanup may return an error from the failed
352 # disconnects; for now I'll consider this successful
353 # if all the modules have unloaded.
357 echo "killing umount"
358 kill -TERM $UMOUNT_PID
359 echo "waiting for umount to finish"
361 if grep " $MOUNT " /proc/mounts; then
362 echo "test 5: /proc/mounts after failed umount"
366 echo "killing umount"
367 kill -TERM $UMOUNT_PID
368 echo "waiting for umount to finish"
370 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
374 # stop_mds is a no-op here, and should not fail
375 cleanup_nocli || return $?
376 # df may have lingering entry
378 # mtab may have lingering entry
382 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
384 grep -q $MOUNT" " /etc/mtab || break
385 echo "Waiting /etc/mtab updated ... "
386 WAIT=$(( WAIT + sleep))
388 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
389 echo "/etc/mtab updated in $WAIT secs"
391 run_test 5a "force cleanup mds, then cleanup"
399 grep " $MOUNT " /etc/mtab && \
400 error false "unexpected entry in mtab before mount" && return 10
404 if ! combined_mgs_mds ; then
405 trap cleanup_5b EXIT ERR
410 [ -d $MOUNT ] || mkdir -p $MOUNT
411 mount_client $MOUNT && rc=1
412 grep " $MOUNT " /etc/mtab && \
413 error "$MOUNT entry in mtab after failed mount" && rc=11
415 # stop_mds is a no-op here, and should not fail
416 cleanup_nocli || rc=$?
417 if ! combined_mgs_mds ; then
422 run_test 5b "Try to start a client with no MGS (should return errs)"
425 grep " $MOUNT " /etc/mtab && \
426 error false "unexpected entry in mtab before mount" && return 10
431 [ -d $MOUNT ] || mkdir -p $MOUNT
432 local oldfs="${FSNAME}"
433 FSNAME="wrong.${FSNAME}"
434 mount_client $MOUNT || :
436 grep " $MOUNT " /etc/mtab && \
437 error "$MOUNT entry in mtab after failed mount" && rc=11
439 cleanup_nocli || rc=$?
442 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
445 grep " $MOUNT " /etc/mtab && \
446 error false "unexpected entry in mtab before mount" && return 10
452 mount_client $MOUNT || rc=1
454 grep " $MOUNT " /etc/mtab && \
455 error "$MOUNT entry in mtab after unmount" && rc=11
458 run_test 5d "mount with ost down"
461 grep " $MOUNT " /etc/mtab && \
462 error false "unexpected entry in mtab before mount" && return 10
468 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
469 do_facet client "lctl set_param fail_loc=0x80000506"
470 mount_client $MOUNT || echo "mount failed (not fatal)"
472 grep " $MOUNT " /etc/mtab && \
473 error "$MOUNT entry in mtab after unmount" && rc=11
476 run_test 5e "delayed connect, don't crash (bug 10268)"
479 if combined_mgs_mds ; then
480 skip "combined mgs and mds"
484 grep " $MOUNT " /etc/mtab && \
485 error false "unexpected entry in mtab before mount" && return 10
489 [ -d $MOUNT ] || mkdir -p $MOUNT
490 mount_client $MOUNT &
492 echo client_mount pid is $pid
496 if ! ps -f -p $pid >/dev/null; then
499 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
500 error "mount returns $rc, expected to hang"
509 # mount should succeed after start mds
512 [ $rc -eq 0 ] || error "mount returned $rc"
513 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
517 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
522 mount_client ${MOUNT} || return 87
523 touch $DIR/a || return 86
526 run_test 6 "manual umount, then mount again"
531 cleanup_nocli || return $?
533 run_test 7 "manual umount, then cleanup"
538 check_mount2 || return 45
539 umount_client $MOUNT2
542 run_test 8 "double mount setup"
547 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
548 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
550 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
551 if [ "$CHECK_PTLDEBUG" ] && { \
552 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
553 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
554 echo "lnet.debug success"
556 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
559 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
560 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
561 echo "lnet.subsystem_debug success"
563 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
566 stop_ost || return $?
568 run_test 9 "test ptldebug and subsystem for mkfs"
576 do_facet $facet "test -b $dev" || rc=1
577 if [[ "$size" ]]; then
578 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
579 awk '($3 == "in") { print $1 }')
580 [[ $in = "1+0" ]] || rc=1
586 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
587 # But with new MDS stack we don't care about the mode of local objects
588 # anymore, so this test is removed. See bug 22944 for more details.
592 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
593 skip "Only applicable to ldiskfs-based MDTs"
598 check_mount || return 41
601 echo "Remove mds config log"
602 if ! combined_mgs_mds ; then
606 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
607 $(mgsdevname) || return \$?" || return $?
609 if ! combined_mgs_mds ; then
614 start_mds && return 42
617 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
620 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
621 skip "Only applicable to ldiskfs-based MDTs"
625 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
630 # check if current MDSSIZE is large enough
631 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
632 log "use MDSSIZE=$MDSSIZE"
634 # check if the global config has a large enough MDSSIZE
635 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
636 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
637 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
639 # check if the block device is large enough
640 is_blkdev $SINGLEMDS $MDSDEV $MIN
641 local large_enough=$?
642 if [ -n "$OK" ]; then
643 [ $large_enough -ne 0 ] && OK=""
645 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
646 log "use device $MDSDEV with MIN=$MIN"
649 # check if a loopback device has enough space for fs metadata (5%)
651 if [ -z "$OK" ]; then
652 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
653 awk '($1 != "Filesystem") {print $4}')
654 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
655 OK=1 && myMDSSIZE=$MIN && \
656 log "use file $MDSDEV with MIN=$MIN"
659 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
662 echo "mount mds with large journal..."
664 local OLD_MDSSIZE=$MDSSIZE
668 echo "mount lustre system..."
670 check_mount || return 41
672 echo "check journal size..."
673 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
674 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
675 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
677 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
685 run_test 18 "check mkfs creates large journals"
688 start_mds || return 1
689 stop_mds -f || return 2
691 run_test 19a "start/stop MDS without OSTs"
694 start_ost || return 1
695 stop_ost -f || return 2
697 run_test 19b "start/stop OSTs without MDS"
700 # first format the ost/mdt
704 check_mount || return 43
706 remount_client ro $MOUNT || return 44
707 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
708 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
709 remount_client rw $MOUNT || return 47
711 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
712 MCNT=`grep -c $MOUNT /etc/mtab`
713 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
718 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
723 wait_osc_import_state mds ost FULL
727 run_test 21a "start mds before ost, stop ost first"
732 wait_osc_import_state mds ost FULL
736 run_test 21b "start ost before mds, stop mds first"
742 wait_osc_import_state mds ost2 FULL
746 #writeconf to remove all ost2 traces for subsequent tests
747 writeconf_or_reformat
749 run_test 21c "start mds between two osts, stop mds last"
752 if combined_mgs_mds ; then
753 skip "need separate mgs device" && return 0
763 wait_osc_import_state mds ost2 FULL
769 #writeconf to remove all ost2 traces for subsequent tests
770 writeconf_or_reformat
773 run_test 21d "start mgs then ost and then mds"
778 echo Client mount with ost in logs, but none running
780 # wait until mds connected to ost and open client connection
781 wait_osc_import_state mds ost FULL
784 # check_mount will block trying to contact ost
785 mcreate $DIR/$tfile || return 40
786 rm -f $DIR/$tfile || return 42
790 echo Client mount with a running ost
793 # if gss enabled, wait full time to let connection from
794 # mds to ost be established, due to the mismatch between
795 # initial connect timeout and gss context negotiation timeout.
796 # This perhaps could be remove after AT landed.
797 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
798 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
801 wait_osc_import_state mds ost FULL
802 wait_osc_import_state client ost FULL
803 check_mount || return 41
808 run_test 22 "start a client before osts (should return errs)"
810 test_23a() { # was test_23
814 # force down client so that recovering mds waits for reconnect
815 local running=$(grep -c $MOUNT /proc/mounts) || true
816 if [ $running -ne 0 ]; then
817 echo "Stopping client $MOUNT (opts: -f)"
821 # enter recovery on mds
823 # try to start a new client
824 mount_client $MOUNT &
826 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
827 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
828 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
830 ps --ppid $MOUNT_LUSTRE_PID
831 echo "waiting for mount to finish"
833 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
834 # SIGTERM works but it does not spread to offspring processses
835 kill -s TERM $MOUNT_PID
836 kill -s TERM $MOUNT_LUSTRE_PID
837 # we can not wait $MOUNT_PID because it is not a child of this shell
843 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
845 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
846 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
849 [ -z "$PID1" -a -z "$PID2" ] && break
850 echo "waiting for mount to finish ... "
851 WAIT=$(( WAIT + sleep))
853 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
854 error "MOUNT_PID $MOUNT_PID and "\
855 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
858 stop_mds || error "stopping MDSes failed"
859 stop_ost || error "stopping OSSes failed"
861 run_test 23a "interrupt client during recovery mount delay"
866 test_23b() { # was test_23
869 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
870 lctl set_param fail_loc=0x80000313
874 run_test 23b "Simulate -EINTR during mount"
876 fs2mds_HOST=$mds_HOST
877 fs2ost_HOST=$ost_HOST
879 MDSDEV1_2=$fs2mds_DEV
880 OSTDEV1_2=$fs2ost_DEV
881 OSTDEV2_2=$fs3ost_DEV
885 echo "umount $MOUNT2 ..."
886 umount $MOUNT2 || true
887 echo "stopping fs2mds ..."
888 stop fs2mds -f || true
889 echo "stopping fs2ost ..."
890 stop fs2ost -f || true
894 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
896 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
897 is_blkdev $SINGLEMDS $MDSDEV && \
898 skip_env "mixed loopback and real device not working" && return
901 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
903 local fs2mdsdev=$(mdsdevname 1_2)
904 local fs2ostdev=$(ostdevname 1_2)
905 local fs2mdsvdev=$(mdsvdevname 1_2)
906 local fs2ostvdev=$(ostvdevname 1_2)
908 # test 8-char fsname as well
909 local FSNAME2=test1234
911 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
912 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
914 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
915 --reformat $fs2ostdev $fs2ostvdev || exit 10
918 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
919 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
921 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || return 1
923 check_mount || return 2
924 # files written on 1 should not show up on 2
925 cp /etc/passwd $DIR/$tfile
927 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
930 cp /etc/passwd $MOUNT2/b || return 3
931 rm $MOUNT2/b || return 4
932 # 2 is actually mounted
933 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
935 facet_failover fs2mds
936 facet_failover fs2ost
939 # the MDS must remain up until last MDT
941 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
942 [ -z "$MDS" ] && error "No MDT" && return 8
944 cleanup_nocli || return 6
946 run_test 24a "Multiple MDTs on a single node"
949 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
951 if [ -z "$fs2mds_DEV" ]; then
952 local dev=${SINGLEMDS}_dev
954 is_blkdev $SINGLEMDS $MDSDEV && \
955 skip_env "mixed loopback and real device not working" && return
958 local fs2mdsdev=$(mdsdevname 1_2)
959 local fs2mdsvdev=$(mdsvdevname 1_2)
961 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
962 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
964 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
968 run_test 24b "Multiple MGSs on a single node (should return err)"
972 check_mount || return 2
973 local MODULES=$($LCTL modules | awk '{ print $2 }')
974 rmmod $MODULES 2>/dev/null || true
977 run_test 25 "Verify modules are referenced"
981 # we need modules before mount for sysctl, so make sure...
982 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
983 #define OBD_FAIL_MDS_FS_SETUP 0x135
984 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
985 start_mds && echo MDS started && return 1
986 lctl get_param -n devices
987 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
988 [ $DEVS -gt 0 ] && return 2
989 # start mds to drop writeconf setting
990 start_mds || return 3
992 unload_modules_conf || return $?
994 run_test 26 "MDT startup failure cleans LOV (should return errs)"
997 start_ost || return 1
998 start_mds || return 2
999 echo "Requeue thread should have started: "
1000 ps -e | grep ll_cfg_requeue
1001 set_conf_param_and_check ost1 \
1002 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1003 "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
1006 run_test 27a "Reacquire MGS lock if OST started first"
1011 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1012 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1014 facet_failover $SINGLEMDS
1015 set_conf_param_and_check $SINGLEMDS \
1016 "lctl get_param -n mdt.$device.identity_acquire_expire" \
1017 "$device.mdt.identity_acquire_expire" || return 3
1018 set_conf_param_and_check client \
1019 "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight"\
1020 "$device.mdc.max_rpcs_in_flight" || return 4
1024 run_test 27b "Reacquire MGS lock after failover"
1028 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1029 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1031 FINAL=$(($ORIG + 1))
1032 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL || return 3
1033 FINAL=$(($FINAL + 1))
1034 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL || return 4
1035 umount_client $MOUNT || return 200
1038 if [ $RESULT -ne $FINAL ]; then
1039 echo "New config not seen: wanted $FINAL got $RESULT"
1042 echo "New config success: got $RESULT"
1044 set_conf_param_and_check client "$TEST" "$PARAM" $ORIG || return 5
1047 run_test 28 "permanent parameter setting"
1049 test_28a() { # LU-4221
1050 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1051 { skip "Need OST version at least 2.5.52" && return 0; }
1052 [ "$(facet_fstype ost1)" = "zfs" ] &&
1053 skip "LU-4221: no such proc params for ZFS OSTs" && return
1060 local device="$FSNAME-OST0000"
1064 # In this test we will set three kinds of proc parameters with
1066 # 1. the ones moved from the OFD to the OSD, and only their
1067 # symlinks kept in obdfilter
1068 # 2. non-symlink ones in the OFD
1069 # 3. non-symlink ones in the OSD
1072 # prepare a symlink parameter in the OFD
1073 name="writethrough_cache_enable"
1074 param="$device.ost.$name"
1075 cmd="$LCTL get_param -n obdfilter.$device.$name"
1077 # conf_param the symlink parameter in the OFD
1078 old=$(do_facet ost1 $cmd)
1079 new=$(((old + 1) % 2))
1080 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1081 error "lctl conf_param $device.ost.$param=$new failed"
1083 # conf_param the target parameter in the OSD
1084 param="$device.osd.$name"
1085 cmd="$LCTL get_param -n osd-*.$device.$name"
1086 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1087 error "lctl conf_param $device.osd.$param=$old failed"
1090 # prepare a non-symlink parameter in the OFD
1091 name="client_cache_seconds"
1092 param="$device.ost.$name"
1093 cmd="$LCTL get_param -n obdfilter.$device.$name"
1095 # conf_param the parameter in the OFD
1096 old=$(do_facet ost1 $cmd)
1098 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1099 error "lctl conf_param $device.ost.$param=$new failed"
1100 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1101 error "lctl conf_param $device.ost.$param=$old failed"
1104 # prepare a non-symlink parameter in the OSD
1105 name="lma_self_repair"
1106 param="$device.osd.$name"
1107 cmd="$LCTL get_param -n osd-*.$device.$name"
1109 # conf_param the parameter in the OSD
1110 old=$(do_facet ost1 $cmd)
1111 new=$(((old + 1) % 2))
1112 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1113 error "lctl conf_param $device.osd.$param=$new failed"
1114 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1115 error "lctl conf_param $device.osd.$param=$old failed"
1119 run_test 28a "set symlink parameters permanently with conf_param"
1122 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1123 setup > /dev/null 2>&1
1127 local PARAM="$FSNAME-OST0001.osc.active"
1128 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1129 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1131 ACTV=$(lctl get_param -n $PROC_ACT)
1133 set_conf_param_and_check client \
1134 "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1135 # also check ost_server_uuid status
1136 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1137 if [ -z "$RESULT" ]; then
1138 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1141 echo "Live client success: got $RESULT"
1145 for num in $(seq $MDSCOUNT); do
1146 local mdtosc=$(get_mdtosc_proc_path mds${num} $FSNAME-OST0001)
1147 local MPROC="osc.$mdtosc.active"
1152 RESULT=$(do_facet mds${num} " lctl get_param -n $MPROC")
1153 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1154 if [ $RESULT -eq $DEAC ]; then
1155 echo -n "MDT deactivated also after"
1156 echo "$WAIT sec (got $RESULT)"
1160 if [ $WAIT -eq $MAX ]; then
1161 echo -n "MDT not deactivated: wanted $DEAC"
1165 echo "Waiting $(($MAX - $WAIT))secs for MDT deactivated"
1168 # test new client starts deactivated
1169 umount_client $MOUNT || return 200
1171 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1172 if [ -z "$RESULT" ]; then
1173 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1176 echo "New client success: got $RESULT"
1179 # make sure it reactivates
1180 set_conf_param_and_check client \
1181 "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1183 umount_client $MOUNT
1186 #writeconf to remove all ost2 traces for subsequent tests
1187 writeconf_or_reformat
1189 run_test 29 "permanently remove an OST"
1194 echo Big config llog
1195 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1197 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1198 for i in ${LIST[@]}; do
1199 set_conf_param_and_check client "$TEST" \
1200 "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1202 # make sure client restart still works
1203 umount_client $MOUNT
1204 mount_client $MOUNT || return 4
1205 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1208 echo Erase parameter setting
1209 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1210 umount_client $MOUNT
1211 mount_client $MOUNT || return 6
1213 echo "deleted (default) value=$FINAL, orig=$ORIG"
1214 # assumes this parameter started at the default value
1215 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1219 run_test 30a "Big config llog and conf_param deletion"
1224 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1225 # numerical part of it. Hopefully that's not already a failover address for
1227 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1228 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1229 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1230 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1231 echo "Using fake nid $NEW"
1233 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1234 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1235 set_conf_param_and_check client "$TEST" \
1236 "$FSNAME-OST0000.failover.node" $NEW ||
1237 error "didn't add failover nid $NEW"
1238 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1241 # The NIDS value is the failover nid strings and "[" and "]". So
1242 # we need to subtract the space taken by the delimiters. This has
1243 # changed from earlier version of Lustre but this test is run only
1244 # locally so this change will not break interop. See LU-3386
1245 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 3))
1246 echo "should have 2 failover nids: $NIDCOUNT"
1247 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1248 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" ||
1249 error "conf_param delete failed"
1250 umount_client $MOUNT
1251 mount_client $MOUNT || return 3
1253 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1256 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 3))
1257 echo "only 1 final nid should remain: $NIDCOUNT"
1258 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1262 run_test 30b "Remove failover nids"
1264 test_31() { # bug 10734
1265 # ipaddr must not exist
1266 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1269 run_test 31 "Connect to non-existent node (shouldn't crash)"
1273 T32_BLIMIT=20480 # Kbytes
1277 # This is not really a test but a tool to create new disk
1278 # image tarballs for the upgrade tests.
1280 # Disk image tarballs should be created on single-node
1281 # clusters by running this test with default configurations
1282 # plus a few mandatory environment settings that are verified
1283 # at the beginning of the test.
1285 test_32newtarball() {
1289 local tmp=$TMP/t32_image_create
1291 if [ $FSNAME != t32fs -o $MDSCOUNT -ne 1 -o \
1292 \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o $OSTCOUNT -ne 1 -o \
1293 -z "$OSTDEV1" ]; then
1294 error "Needs FSNAME=t32fs MDSCOUNT=1 MDSDEV1=<nonexistent_file>" \
1295 "(or MDSDEV, in the case of b1_8) OSTCOUNT=1" \
1296 "OSTDEV1=<nonexistent_file>"
1300 echo "Found stale $tmp"
1305 tar cf - -C $src . | tar xf - -C $tmp/src
1306 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1307 count=$(($T32_BLIMIT / 1024 / 2))
1308 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1310 # format ost with comma-separated NIDs to verify LU-4460
1311 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
1312 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1316 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1317 $LFS quotacheck -ug /mnt/$FSNAME
1318 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1321 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1328 ls -Rni --time-style=+%s >$tmp/img/list
1329 find . ! -name .lustre -type f -exec sha1sum {} \; |
1330 sort -k 2 >$tmp/img/sha1sums
1332 $LCTL get_param -n version | head -n 1 |
1333 sed -e 's/^lustre: *//' >$tmp/img/commit
1335 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1336 $LFS quotaon -ug /mnt/$FSNAME
1337 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1338 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1339 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1340 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1341 | tr -d "*" > $tmp/img/bspace
1342 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1343 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1344 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1345 | tr -d "*" > $tmp/img/ispace
1350 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1353 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1354 echo "Data verification failed"
1357 uname -r >$tmp/img/kernel
1358 uname -m >$tmp/img/arch
1360 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1361 mv $OSTDEV1 $tmp/img
1363 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1364 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1367 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1372 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1375 # The list of applicable tarballs is returned via the caller's
1376 # variable "tarballs".
1379 local node=$(facet_active_host $SINGLEMDS)
1380 local r="do_node $node"
1382 if [ "$CLIENTONLY" ]; then
1383 skip "Client-only testing"
1387 if ! $r which $TUNEFS; then
1388 skip_env "tunefs.lustre required on $node"
1392 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1394 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 -name \'disk*-$IMGTYPE.tar.bz2\')
1396 if [ -z "$tarballs" ]; then
1397 skip "No applicable tarballs found"
1402 t32_test_cleanup() {
1404 local fstype=$(facet_fstype $SINGLEMDS)
1407 if $shall_cleanup_lustre; then
1408 umount $tmp/mnt/lustre || rc=$?
1410 if $shall_cleanup_mdt; then
1411 $r umount -d $tmp/mnt/mdt || rc=$?
1413 if $shall_cleanup_mdt1; then
1414 $r umount -d $tmp/mnt/mdt1 || rc=$?
1416 if $shall_cleanup_ost; then
1417 $r umount -d $tmp/mnt/ost || rc=$?
1422 if [ $fstype == "zfs" ]; then
1423 $r $ZPOOL destroy t32fs-mdt1 || rc=$?
1424 $r $ZPOOL destroy t32fs-ost1 || rc=$?
1429 t32_bits_per_long() {
1431 # Yes, this is not meant to be perfect.
1441 t32_reload_modules() {
1443 local all_removed=false
1446 while ((i < 20)); do
1447 echo "Unloading modules on $node: Attempt $i"
1448 do_rpc_nodes $node $LUSTRE_RMMOD $(facet_fstype $SINGLEMDS) &&
1450 do_rpc_nodes $node check_mem_leak || return 1
1451 if $all_removed; then
1452 do_rpc_nodes $node load_modules
1458 echo "Unloading modules on $node: Given up"
1462 t32_wait_til_devices_gone() {
1468 echo wait for devices to go
1469 while ((i < 20)); do
1470 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1471 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1472 ((devices == 0 && loops == 0)) && return 0
1476 echo "waiting for dev on $node: dev $devices loop $loops given up"
1477 do_rpc_nodes $node "losetup -a"
1478 do_rpc_nodes $node "$LCTL devices_list"
1482 t32_verify_quota() {
1486 local fstype=$(facet_fstype $SINGLEMDS)
1490 $LFS quota -u $T32_QID -v $mnt
1492 qval=$($LFS quota -v -u $T32_QID $mnt |
1493 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1494 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1496 [ $qval -eq $img_bspace ] || {
1497 echo "bspace, act:$qval, exp:$img_bspace"
1501 qval=$($LFS quota -v -u $T32_QID $mnt |
1502 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1503 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1505 [ $qval -eq $img_ispace ] || {
1506 echo "ispace, act:$qval, exp:$img_ispace"
1510 qval=$($LFS quota -v -u $T32_QID $mnt |
1511 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1512 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1514 [ $qval -eq $T32_BLIMIT ] || {
1515 echo "blimit, act:$qval, exp:$T32_BLIMIT"
1519 qval=$($LFS quota -v -u $T32_QID $mnt |
1520 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1521 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1523 [ $qval -eq $T32_ILIMIT ] || {
1524 echo "ilimit, act:$qval, exp:$T32_ILIMIT"
1528 do_node $node $LCTL conf_param $fsname.quota.mdt=ug
1529 cmd="$LCTL get_param -n osd-$fstype.$fsname-MDT0000"
1530 cmd=$cmd.quota_slave.enabled
1531 wait_update $node "$cmd" "ug" || {
1532 echo "Enable mdt quota failed"
1536 do_node $node $LCTL conf_param $fsname.quota.ost=ug
1537 cmd="$LCTL get_param -n osd-$fstype.$fsname-OST0000"
1538 cmd=$cmd.quota_slave.enabled
1539 wait_update $node "$cmd" "ug" || {
1540 echo "Enable ost quota failed"
1545 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1546 bs=1M count=$(($T32_BLIMIT / 1024)) oflag=sync && {
1547 echo "Write succeed, but expect -EDQUOT"
1550 rm -f $mnt/t32_qf_new
1552 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1554 echo "Create succeed, but expect -EDQUOT"
1557 unlinkmany $mnt/t32_qf_ $T32_ILIMIT
1565 local dne_upgrade=${dne_upgrade:-"no"}
1566 local ff_convert=${ff_convert:-"no"}
1567 local shall_cleanup_mdt=false
1568 local shall_cleanup_mdt1=false
1569 local shall_cleanup_ost=false
1570 local shall_cleanup_lustre=false
1571 local node=$(facet_active_host $SINGLEMDS)
1572 local r="do_node $node"
1573 local node2=$(facet_active_host mds2)
1581 local nid=$($r $LCTL list_nids | head -1)
1587 local fstype=$(facet_fstype $SINGLEMDS)
1588 local mdt_dev=$tmp/mdt
1589 local ost_dev=$tmp/ost
1591 trap 'trap - RETURN; t32_test_cleanup' RETURN
1593 mkdir -p $tmp/mnt/lustre
1594 $r mkdir -p $tmp/mnt/{mdt,ost}
1595 $r tar xjvf $tarball -S -C $tmp || {
1596 error_noexit "Unpacking the disk image tarball"
1599 img_commit=$($r cat $tmp/commit)
1600 img_kernel=$($r cat $tmp/kernel)
1601 img_arch=$($r cat $tmp/arch)
1602 img_bspace=$($r cat $tmp/bspace)
1603 img_ispace=$($r cat $tmp/ispace)
1604 echo "Upgrading from $(basename $tarball), created with:"
1605 echo " Commit: $img_commit"
1606 echo " Kernel: $img_kernel"
1607 echo " Arch: $img_arch"
1609 local version=$(version_code $img_commit)
1610 [[ $version -ge $(version_code 2.5.0) ]] && ff_convert="no"
1612 if [ $fstype == "zfs" ]; then
1614 $r $ZPOOL import -f -d $tmp t32fs-mdt1
1615 $r $ZPOOL import -f -d $tmp t32fs-ost1
1616 mdt_dev=t32fs-mdt1/mdt1
1617 ost_dev=t32fs-ost1/ost1
1618 wait_update_facet $SINGLEMDS "$ZPOOL list |
1619 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1620 error_noexit "import zfs pool failed"
1625 $r $LCTL set_param debug="$PTLDEBUG"
1627 $r $TUNEFS --dryrun $mdt_dev || {
1629 error_noexit "tunefs.lustre before mounting the MDT"
1632 if [ "$writeconf" ]; then
1634 if [ $fstype == "ldiskfs" ]; then
1636 $r $TUNEFS --quota $mdt_dev || {
1638 error_noexit "Enable mdt quota feature"
1643 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1644 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1645 { skip "LU-2200: Cannot run over Inifiniband w/o lctl replace_nids "
1646 "(Need MGS version at least 2.3.59)"; return 0; }
1648 local osthost=$(facet_active_host ost1)
1649 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1652 if [ $fstype == "ldiskfs" ]; then
1655 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1656 $r lctl replace_nids $fsname-OST0000 $ostnid
1657 $r lctl replace_nids $fsname-MDT0000 $nid
1658 $r umount -d $tmp/mnt/mdt
1661 mopts=exclude=$fsname-OST0000
1662 if [ $fstype == "ldiskfs" ]; then
1667 t32_wait_til_devices_gone $node
1669 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1671 error_noexit "Mounting the MDT"
1674 shall_cleanup_mdt=true
1676 if [ "$dne_upgrade" != "no" ]; then
1677 local fs2mdsdev=$(mdsdevname 1_2)
1678 local fs2mdsvdev=$(mdsvdevname 1_2)
1680 echo "mkfs new MDT on ${fs2mdsdev}...."
1681 if [ $(facet_fstype mds1) == ldiskfs ]; then
1682 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1685 add fs2mds $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1686 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1687 error_noexit "Mkfs new MDT failed"
1691 $r $TUNEFS --dryrun $fs2mdsdev || {
1692 error_noexit "tunefs.lustre before mounting the MDT"
1696 echo "mount new MDT....$fs2mdsdev"
1697 $r mkdir -p $tmp/mnt/mdt1
1698 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1699 error_noexit "mount mdt1 failed"
1703 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1704 error_noexit "enable remote dir create failed"
1706 shall_cleanup_mdt1=true
1709 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1710 error_noexit "Getting MDT UUID"
1713 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1714 error_noexit "Unexpected MDT UUID: \"$uuid\""
1718 $r $TUNEFS --dryrun $ost_dev || {
1719 error_noexit "tunefs.lustre before mounting the OST"
1722 if [ "$writeconf" ]; then
1723 mopts=mgsnode=$nid,$writeconf
1724 if [ $fstype == "ldiskfs" ]; then
1726 $r $TUNEFS --quota $ost_dev || {
1728 error_noexit "Enable ost quota feature"
1734 if [ $fstype == "ldiskfs" ]; then
1738 $r $MOUNT_CMD -o $mopts $ost_dev $tmp/mnt/ost || {
1739 error_noexit "Mounting the OST"
1742 shall_cleanup_ost=true
1744 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1745 error_noexit "Getting OST UUID"
1748 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1749 error_noexit "Unexpected OST UUID: \"$uuid\""
1753 $r $LCTL conf_param $fsname-OST0000.osc.max_dirty_mb=15 || {
1754 error_noexit "Setting \"max_dirty_mb\""
1757 $r $LCTL conf_param $fsname-OST0000.failover.node=$nid || {
1758 error_noexit "Setting OST \"failover.node\""
1761 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1762 error_noexit "Setting \"max_rpcs_in_flight\""
1765 $r $LCTL conf_param $fsname-MDT0000.failover.node=$nid || {
1766 error_noexit "Setting MDT \"failover.node\""
1769 $r $LCTL pool_new $fsname.interop || {
1770 error_noexit "Setting \"interop\""
1773 $r $LCTL conf_param $fsname-MDT0000.lov.stripesize=4M || {
1774 error_noexit "Setting \"lov.stripesize\""
1778 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1779 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1780 error_noexit "Start OI scrub on OST0"
1784 # The oi_scrub should be on ost1, but for test_32(),
1785 # all on the SINGLEMDS.
1786 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1787 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1788 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1789 error_noexit "Failed to get the expected 'completed'"
1793 local UPDATED=$($r $LCTL get_param -n \
1794 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1795 awk '/^updated/ { print $2 }')
1796 [ $UPDATED -ge 1 ] || {
1797 error_noexit "Only $UPDATED objects have been converted"
1802 if [ "$dne_upgrade" != "no" ]; then
1803 $r $LCTL conf_param \
1804 $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
1805 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
1808 $r $LCTL conf_param $fsname-MDT0001.failover.node=$nid || {
1809 error_noexit "Setting MDT1 \"failover.node\""
1812 $r $LCTL conf_param $fsname-MDT0001.lov.stripesize=4M || {
1813 error_noexit "Setting MDT1 \"lov.stripesize\""
1819 if [ "$writeconf" ]; then
1820 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
1821 error_noexit "Mounting the client"
1824 shall_cleanup_lustre=true
1825 $LCTL set_param debug="$PTLDEBUG"
1827 t32_verify_quota $node $fsname $tmp/mnt/lustre || {
1828 error_noexit "verify quota failed"
1832 if [ "$dne_upgrade" != "no" ]; then
1833 $LFS mkdir -i 1 $tmp/mnt/lustre/remote_dir || {
1834 error_noexit "set remote dir failed"
1838 pushd $tmp/mnt/lustre
1839 tar -cf - . --exclude=./remote_dir |
1840 tar -xvf - -C remote_dir 1>/dev/null || {
1841 error_noexit "cp to remote dir failed"
1847 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
1848 error_noexit "dd failed"
1851 rm -rf $tmp/mnt/lustre/tmp_file || {
1852 error_noexit "rm failed"
1856 if $r test -f $tmp/sha1sums; then
1857 # LU-2393 - do both sorts on same node to ensure locale
1859 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
1860 if [ "$dne_upgrade" != "no" ]; then
1861 pushd $tmp/mnt/lustre/remote_dir
1863 pushd $tmp/mnt/lustre
1866 find ! -name .lustre -type f -exec sha1sum {} \; |
1867 sort -k 2 >$tmp/sha1sums || {
1868 error_noexit "sha1sum"
1872 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
1873 error_noexit "sha1sum verification failed"
1877 echo "sha1sum verification skipped"
1880 if [ "$dne_upgrade" != "no" ]; then
1881 rm -rf $tmp/mnt/lustre/remote_dir || {
1882 error_noexit "remove remote dir failed"
1887 if $r test -f $tmp/list; then
1889 # There is not a Test Framework API to copy files to or
1890 # from a remote node.
1892 # LU-2393 - do both sorts on same node to ensure locale
1894 $r cat $tmp/list | sort -k 6 >$tmp/list.orig
1895 pushd $tmp/mnt/lustre
1896 ls -Rni --time-style=+%s | sort -k 6 >$tmp/list || {
1902 # 32-bit and 64-bit clients use different algorithms to
1903 # convert FIDs into inode numbers. Hence, remove the inode
1904 # numbers from the lists, if the original list was created
1905 # on an architecture with different number of bits per
1908 if [ $(t32_bits_per_long $(uname -m)) != \
1909 $(t32_bits_per_long $img_arch) ]; then
1910 echo "Different number of bits per \"long\" from the disk image"
1911 for list in list.orig list; do
1912 sed -i -e 's/^[0-9]\+[ \t]\+//' $tmp/$list
1915 if ! diff -ub $tmp/list.orig $tmp/list; then
1916 error_noexit "list verification failed"
1920 echo "list verification skipped"
1924 # When adding new data verification tests, please check for
1925 # the presence of the required reference files first, like
1926 # the "sha1sums" and "list" tests above, to avoid the need to
1927 # regenerate every image for each test addition.
1930 nrpcs_orig=$($LCTL get_param \
1931 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
1932 error_noexit "Getting \"max_rpcs_in_flight\""
1935 nrpcs=$((nrpcs_orig + 5))
1936 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=$nrpcs || {
1937 error_noexit "Changing \"max_rpcs_in_flight\""
1940 wait_update $HOSTNAME "$LCTL get_param \
1941 -n mdc.*MDT0000*.max_rpcs_in_flight" $nrpcs || {
1942 error_noexit "Verifying \"max_rpcs_in_flight\""
1946 umount $tmp/mnt/lustre || {
1947 error_noexit "Unmounting the client"
1950 shall_cleanup_lustre=false
1952 if [ "$dne_upgrade" != "no" ]; then
1953 $r umount -d $tmp/mnt/mdt1 || {
1954 error_noexit "Unmounting the MDT2"
1957 shall_cleanup_mdt1=false
1960 $r umount -d $tmp/mnt/mdt || {
1961 error_noexit "Unmounting the MDT"
1964 shall_cleanup_mdt=false
1966 $r umount -d $tmp/mnt/ost || {
1967 error_noexit "Unmounting the OST"
1970 shall_cleanup_ost=false
1972 t32_reload_modules $node || {
1973 error_noexit "Reloading modules"
1977 # mount a second time to make sure we didnt leave upgrade flag on
1978 $r $TUNEFS --dryrun $mdt_dev || {
1980 error_noexit "tunefs.lustre before remounting the MDT"
1984 mopts=exclude=$fsname-OST0000
1985 if [ $fstype == "ldiskfs" ]; then
1988 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1989 error_noexit "Remounting the MDT"
1992 shall_cleanup_mdt=true
2002 for tarball in $tarballs; do
2003 t32_test $tarball || let "rc += $?"
2007 run_test 32a "Upgrade (not live)"
2015 for tarball in $tarballs; do
2016 t32_test $tarball writeconf || let "rc += $?"
2020 run_test 32b "Upgrade with writeconf"
2027 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2029 for tarball in $tarballs; do
2030 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2034 run_test 32c "dne upgrade test"
2042 for tarball in $tarballs; do
2043 ff_convert=yes t32_test $tarball || rc=$?
2047 run_test 32d "convert ff test"
2049 test_33a() { # bug 12333, was test_33
2051 local FSNAME2=test-123
2052 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2055 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2057 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2058 local dev=${SINGLEMDS}_dev
2059 local MDSDEV=${!dev}
2060 is_blkdev $SINGLEMDS $MDSDEV && \
2061 skip_env "mixed loopback and real device not working" && return
2064 local fs2mdsdev=$(mdsdevname 1_2)
2065 local fs2ostdev=$(ostdevname 1_2)
2066 local fs2mdsvdev=$(mdsvdevname 1_2)
2067 local fs2ostvdev=$(ostvdevname 1_2)
2069 if [ $(facet_fstype mds1) == ldiskfs ]; then
2070 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2073 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2074 --reformat $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
2075 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2076 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2077 $fs2ostvdev || exit 10
2079 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2080 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2081 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
2083 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
2086 cp /etc/hosts $MOUNT2/ || rc=3
2087 $LFS getstripe $MOUNT2/hosts
2092 cleanup_nocli || rc=6
2095 run_test 33a "Mount ost with a large index number"
2097 test_33b() { # was test_34
2100 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2101 # Drop lock cancelation reply during umount
2102 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2103 do_facet client lctl set_param fail_loc=0x80000304
2104 #lctl set_param debug=-1
2105 umount_client $MOUNT
2108 run_test 33b "Drop cancel during umount"
2112 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2113 manual_umount_client
2115 do_facet client killall -USR1 multiop
2116 if [ $rc -eq 0 ]; then
2117 error "umount not fail!"
2122 run_test 34a "umount with opened file should be fail"
2127 touch $DIR/$tfile || return 1
2128 stop_mds --force || return 2
2130 manual_umount_client --force
2132 if [ $rc -ne 0 ]; then
2133 error "mtab after failed umount - rc $rc"
2139 run_test 34b "force umount with failed mds should be normal"
2143 touch $DIR/$tfile || return 1
2144 stop_ost --force || return 2
2146 manual_umount_client --force
2148 if [ $rc -ne 0 ]; then
2149 error "mtab after failed umount - rc $rc"
2155 run_test 34c "force umount with failed ost should be normal"
2157 test_35a() { # bug 12459
2160 DBG_SAVE="`lctl get_param -n debug`"
2161 lctl set_param debug="ha"
2163 log "Set up a fake failnode for the MDS"
2165 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
2166 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2167 do_facet mgs "$LCTL conf_param \
2168 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" || return 4
2170 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2173 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2176 log "Stopping the MDT: $device"
2177 stop_mdt 1 || return 5
2179 df $MOUNT > /dev/null 2>&1 &
2181 log "Restarting the MDT: $device"
2182 start_mdt 1 || return 6
2183 log "Wait for df ($DFPID) ... "
2186 lctl set_param debug="$DBG_SAVE"
2188 # retrieve from the log the first server that the client tried to
2189 # contact after the connection loss
2190 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2191 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2192 /import_select_connection.*$device-mdc.* using connection/ {
2194 if (\\\$NF ~ /$FAKENID/)
2200 }" $TMP/lustre-log-$TESTNAME.log`
2201 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
2203 # remove nid settings
2204 writeconf_or_reformat
2206 run_test 35a "Reconnect to the last active server first"
2208 test_35b() { # bug 18674
2209 remote_mds || { skip "local MDS" && return 0; }
2213 $LCTL set_param debug="ha"
2215 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2218 log "Set up a fake failnode for the MDS"
2220 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2221 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2222 do_facet mgs "$LCTL conf_param \
2223 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" || return 1
2225 local at_max_saved=0
2226 # adaptive timeouts may prevent seeing the issue
2227 if at_is_enabled; then
2228 at_max_saved=$(at_max_get mds)
2229 at_max_set 0 mds client
2232 mkdir -p $MOUNT/$tdir
2234 log "Injecting EBUSY on MDS"
2235 # Setting OBD_FAIL_MDS_RESEND=0x136
2236 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
2238 $LCTL set_param mdc.${FSNAME}*.stats=clear
2240 log "Creating a test file and stat it"
2241 touch $MOUNT/$tdir/$tfile
2242 stat $MOUNT/$tdir/$tfile
2244 log "Stop injecting EBUSY on MDS"
2245 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
2246 rm -f $MOUNT/$tdir/$tfile
2249 # restore adaptive timeout
2250 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2252 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2254 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
2256 # retrieve from the log if the client has ever tried to
2257 # contact the fake server after the loss of connection
2258 FAILCONN=`awk "BEGIN {ret = 0;}
2259 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2261 if (\\\$NF ~ /$FAKENID/) {
2266 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2268 [ "$FAILCONN" == "0" ] && \
2269 log "ERROR: The client reconnection has not been triggered" && \
2271 [ "$FAILCONN" == "2" ] && \
2272 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
2276 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2277 # Reconnects are supposed to be rate limited to one every 5s
2278 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
2279 log "ERROR: Too many reconnects $CONNCNT" && \
2283 # remove nid settings
2284 writeconf_or_reformat
2286 run_test 35b "Continue reconnection retries, if the active server is busy"
2289 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
2291 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
2292 { skip "remote OST" && return 0; }
2295 local FSNAME2=test1234
2296 local fs3ost_HOST=$ost_HOST
2297 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2299 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2301 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2302 is_blkdev $SINGLEMDS $MDSDEV && \
2303 skip_env "mixed loopback and real device not working" && return
2306 local fs2mdsdev=$(mdsdevname 1_2)
2307 local fs2ostdev=$(ostdevname 1_2)
2308 local fs3ostdev=$(ostdevname 2_2)
2309 local fs2mdsvdev=$(mdsvdevname 1_2)
2310 local fs2ostvdev=$(ostvdevname 1_2)
2311 local fs3ostvdev=$(ostvdevname 2_2)
2313 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2314 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2315 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2316 # different one than the default value here.
2317 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2318 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2319 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2320 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2322 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2323 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2324 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2326 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || return 1
2328 sleep 5 # until 11778 fixed
2330 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
2332 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
2333 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
2334 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
2335 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
2336 DFTOTAL=`echo $STRING | cut -d, -f1`
2337 DFUSED=`echo $STRING | cut -d, -f2`
2338 DFAVAIL=`echo $STRING | cut -d, -f3`
2339 DFFREE=$(($DFTOTAL - $DFUSED))
2341 ALLOWANCE=$((64 * $OSTCOUNT))
2343 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2344 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2345 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2348 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2349 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2350 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2353 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2354 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2355 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2360 stop fs3ost -f || return 200
2361 stop fs2ost -f || return 201
2362 stop fs2mds -f || return 202
2363 unload_modules_conf || return 203
2366 run_test 36 "df report consistency on OSTs with different block size"
2369 local mntpt=$(facet_mntpt $SINGLEMDS)
2370 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2371 local mdsdev_sym="$TMP/sym_mdt.img"
2372 local opts=$MDS_MOUNT_OPTS
2375 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2376 skip "Currently only applicable to ldiskfs-based MDTs"
2380 echo "MDS : $mdsdev"
2381 echo "SYMLINK : $mdsdev_sym"
2382 do_facet $SINGLEMDS rm -f $mdsdev_sym
2384 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2386 echo "mount symlink device - $mdsdev_sym"
2388 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2389 opts=$(csa_add "$opts" -o loop)
2391 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2392 $mdsdev_sym $mntpt 2>&1)
2395 echo mount_op=$mount_op
2397 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
2399 if $(echo $mount_op | grep -q "unable to set tunable"); then
2400 error "set tunables failed for symlink device"
2403 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2407 run_test 37 "verify set tunables works for symlink device"
2409 test_38() { # bug 14222
2410 local fstype=$(facet_fstype $SINGLEMDS)
2411 local mntpt=$(facet_mntpt $SINGLEMDS)
2416 local SRC="/etc /bin"
2417 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2418 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2420 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2421 error "copying $SRC to $DIR/$tdir"
2423 umount_client $MOUNT
2424 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2426 log "delete lov_objid file on MDS"
2428 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2430 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2432 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2434 # check create in mds_lov_connect
2438 [ $V ] && log "verifying $DIR/$tdir/$f"
2439 diff -q $f $DIR/$tdir/$f || ERROR=y
2441 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2442 if [ "$ERROR" = "y" ]; then
2443 # check it's updates in sync
2444 umount_client $MOUNT
2446 mount_fstype $SIGNLEMDS
2447 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2448 unmount_fstype $SINGLEMDS
2449 error "old and new files are different after connect" || true
2451 touch $DIR/$tdir/f2 || error "f2 file create failed"
2453 # check it's updates in sync
2454 umount_client $MOUNT
2457 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2459 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2460 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2462 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2467 [ $V ] && log "verifying $DIR/$tdir/$f"
2468 diff -q $f $DIR/$tdir/$f || ERROR=y
2470 touch $DIR/$tdir/f3 || error "f3 file create failed"
2471 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2472 umount_client $MOUNT
2474 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2475 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2476 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2478 [ "$ERROR" = "y" ] &&
2479 error "old and new files are different after sync" || true
2481 log "files compared the same"
2484 run_test 38 "MDS recreates missing lov_objid file from OST data"
2490 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2491 error "memory leak detected" || true
2493 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2495 test_40() { # bug 15759
2497 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2498 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2502 run_test 40 "race during service thread startup"
2504 test_41a() { #bug 14134
2505 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2506 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2507 skip "Loop devices does not work with nosvc option"
2512 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2514 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2515 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
2516 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2518 mount_client $MOUNT || return 1
2521 echo "blah blah" > $MOUNT/$tfile
2524 umount_client $MOUNT
2525 stop ost1 -f || return 201
2526 stop_mds -f || return 202
2527 stop_mds -f || return 203
2528 unload_modules_conf || return 204
2531 run_test 41a "mount mds with --nosvc and --nomgs"
2534 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2535 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2536 skip "Loop devices does not work with nosvc option"
2540 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2544 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2546 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2548 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2550 mount_client $MOUNT || return 1
2553 echo "blah blah" > $MOUNT/$tfile
2554 cat $MOUNT/$tfile || return 200
2556 umount_client $MOUNT
2557 stop_ost || return 201
2558 stop_mds -f || return 202
2559 stop_mds -f || return 203
2562 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2565 local server_version=$(lustre_version_code $SINGLEMDS)
2567 [[ $server_version -ge $(version_code 2.6.52) ]] ||
2568 [[ $server_version -ge $(version_code 2.5.26) &&
2569 $server_version -lt $(version_code 2.5.50) ]] ||
2570 [[ $server_version -ge $(version_code 2.5.4) &&
2571 $server_version -lt $(version_code 2.5.11) ]] ||
2572 { skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"; return; }
2575 # MDT concurent start
2576 #define OBD_FAIL_TGT_DELAY_CONNECT 0x703
2577 do_facet $SINGLEMDS "lctl set_param fail_loc=0x703"
2578 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS &
2581 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
2582 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS &
2588 if [ $rc == 0 ] && [ $rc2 == 114 ]; then
2589 echo "1st MDT start succeed"
2590 echo "2nd MDT start failed with EALREADY"
2591 elif [ $rc2 == 0 ] && [ $rc == 114 ]; then
2592 echo "1st MDT start failed with EALREADY"
2593 echo "2nd MDT start succeed"
2596 error "unexpected concurent MDT mounts result, rc=$rc rc2=$rc2"
2599 # OST concurent start
2600 #define OBD_FAIL_TGT_DELAY_CONNECT 0x703
2601 do_facet ost1 "lctl set_param fail_loc=0x703"
2602 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &
2605 do_facet ost1 "lctl set_param fail_loc=0x0"
2606 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &
2612 if [ $rc == 0 ] && [ $rc2 == 114 ]; then
2613 echo "1st OST start succeed"
2614 echo "2nd OST start failed with EALREADY"
2615 elif [ $rc2 == 0 ] && [ $rc == 114 ]; then
2616 echo "1st OST start failed with EALREADY"
2617 echo "2nd OST start succeed"
2621 error "unexpected concurent OST mounts result, rc=$rc rc2=$rc2"
2627 # verify everything ok
2632 error "MDT(s) start failed"
2640 error "OST(s) start failed"
2648 error "client start failed"
2655 error "client mount failed"
2659 run_test 41c "concurent mounts of MDT/OST should all fail but one"
2661 test_42() { #bug 14693
2663 check_mount || error "client was not mounted"
2665 do_facet mgs $LCTL conf_param $FSNAME.llite.some_wrong_param=10
2666 umount_client $MOUNT ||
2667 error "unmounting client failed with invalid llite param"
2668 mount_client $MOUNT ||
2669 error "mounting client failed with invalid llite param"
2671 do_facet mgs $LCTL conf_param $FSNAME.sys.some_wrong_param=20
2672 cleanup || error "stopping $FSNAME failed with invalid sys param"
2675 check_mount || "client was not mounted with invalid sys param"
2676 cleanup || error "stopping $FSNAME failed with invalid sys param"
2679 run_test 42 "allow client/server mount/unmount with invalid config param"
2682 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.58) ]] ||
2683 { skip "Need MDS version at least 2.5.58" && return 0; }
2684 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
2687 USER1=$(cat /etc/passwd | grep :$ID1:$ID1: | cut -d: -f1)
2688 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
2692 chmod ugo+x $DIR || error "chmod 0 failed"
2693 set_conf_param_and_check mds \
2694 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2695 "$FSNAME.mdt.root_squash" \
2697 wait_update $HOSTNAME \
2698 "lctl get_param -n llite.${FSNAME}*.root_squash" \
2700 error "check llite root_squash failed!"
2701 set_conf_param_and_check mds \
2702 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2703 "$FSNAME.mdt.nosquash_nids" \
2705 wait_update $HOSTNAME \
2706 "lctl get_param -n llite.${FSNAME}*.nosquash_nids" \
2708 error "check llite nosquash_nids failed!"
2711 # create set of test files
2713 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
2714 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
2715 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
2717 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
2718 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
2720 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
2721 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
2722 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
2724 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
2725 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
2726 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
2729 # check root_squash:
2730 # set root squash UID:GID to RUNAS_ID
2731 # root should be able to access only files owned by RUNAS_ID
2733 set_conf_param_and_check mds \
2734 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2735 "$FSNAME.mdt.root_squash" \
2736 "$RUNAS_ID:$RUNAS_ID"
2737 wait_update $HOSTNAME \
2738 "lctl get_param -n llite.${FSNAME}*.root_squash" \
2739 "$RUNAS_ID:$RUNAS_ID" ||
2740 error "check llite root_squash failed!"
2742 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
2743 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
2744 error "$ST: root read permission is denied"
2745 echo "$ST: root read permission is granted - ok"
2748 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
2749 error "$ST: root write permission is denied"
2750 echo "$ST: root write permission is granted - ok"
2752 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2753 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
2754 error "$ST: root read permission is granted"
2755 echo "$ST: root read permission is denied - ok"
2758 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
2759 error "$ST: root write permission is granted"
2760 echo "$ST: root write permission is denied - ok"
2762 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2763 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
2764 error "$ST: root unlink permission is granted"
2765 echo "$ST: root unlink permission is denied - ok"
2767 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
2768 error "$ST: root create permission is granted"
2769 echo "$ST: root create permission is denied - ok"
2773 # check root_squash is enforced independently
2774 # of client cache content
2776 # access file by USER1, keep access open
2777 # root should be denied access to user file
2779 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
2783 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
2784 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
2785 { kill $pid; error "$ST: root read permission is granted"; }
2786 echo "$ST: root read permission is denied - ok"
2789 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
2790 { kill $pid; error "$ST: root write permission is granted"; }
2791 echo "$ST: root write permission is denied - ok"
2797 # check nosquash_nids:
2798 # put client's NID into nosquash_nids list,
2799 # root should be able to access root file after that
2801 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
2802 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
2803 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
2804 set_conf_param_and_check mds \
2805 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2806 "$FSNAME-MDTall.mdt.nosquash_nids" \
2808 wait_update $HOSTNAME \
2809 "lctl get_param -n llite.${FSNAME}*.nosquash_nids" \
2811 error "check llite nosquash_nids failed!"
2813 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2814 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
2815 error "$ST: root read permission is denied"
2816 echo "$ST: root read permission is granted - ok"
2819 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
2820 error "$ST: root write permission is denied"
2821 echo "$ST: root write permission is granted - ok"
2823 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2824 rm $DIR/$tdir-rootdir/tfile-1 || \
2825 error "$ST: root unlink permission is denied"
2826 echo "$ST: root unlink permission is granted - ok"
2827 touch $DIR/$tdir-rootdir/tfile-2 || \
2828 error "$ST: root create permission is denied"
2829 echo "$ST: root create permission is granted - ok"
2833 run_test 43 "check root_squash and nosquash_nids"
2835 umount_client $MOUNT
2840 check_mount || return 2
2841 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
2843 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
2844 for VAL in $UUIDS; do
2845 NID=$(echo $VAL | cut -d= -f1)
2846 CLUUID=$(echo $VAL | cut -d= -f2)
2847 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
2849 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
2853 run_test 44 "mounted client proc entry exists"
2857 check_mount || return 2
2862 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
2863 do_facet client "lctl set_param fail_loc=0x50f"
2866 manual_umount_client --force || return 3
2867 do_facet client "lctl set_param fail_loc=0x0"
2869 mount_client $MOUNT || return 4
2873 run_test 45 "long unlink handling in ptlrpcd"
2880 umount_client $MOUNT2 || rc=$?
2881 umount_client $MOUNT || rc=$?
2882 while [ $count -gt 0 ]; do
2883 stop ost${count} -f || rc=$?
2887 cleanup_nocli || rc=$?
2888 #writeconf to remove all ost2 traces for subsequent tests
2889 writeconf_or_reformat
2894 echo "Testing with $OSTCOUNT OSTs"
2896 start_mds || return 1
2897 #first client should see only one ost
2898 start_ost || return 2
2899 wait_osc_import_state mds ost FULL
2901 mount_client $MOUNT || return 3
2902 trap "cleanup_46a $OSTCOUNT" EXIT ERR
2905 for (( i=2; i<=$OSTCOUNT; i++ )); do
2906 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
2909 # wait until osts in sync
2910 for (( i=2; i<=$OSTCOUNT; i++ )); do
2911 wait_osc_import_state mds ost$i FULL
2912 wait_osc_import_state client ost$i FULL
2915 #second client see all ost's
2917 mount_client $MOUNT2 || return 8
2918 $LFS setstripe -c -1 $MOUNT2 || return 9
2919 $LFS getstripe $MOUNT2 || return 10
2921 echo "ok" > $MOUNT2/widestripe
2922 $LFS getstripe $MOUNT2/widestripe || return 11
2923 # fill acl buffer for avoid expand lsm to them
2924 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
2925 setfacl -m $acl $MOUNT2/widestripe
2929 stat $MOUNT/widestripe || return 12
2931 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
2934 run_test 46a "handle ost additional - wide striped file"
2939 check_mount || return 2
2940 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2944 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2945 if echo $ns | grep "MDT[[:digit:]]*"; then
2948 lrs=$(echo $ns | sed 's/.*lru_size=//')
2949 lru_size[count]=$lrs
2954 facet_failover $SINGLEMDS
2955 client_up || return 3
2958 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2959 if echo $ns | grep "MDT[[:digit:]]*"; then
2962 lrs=$(echo $ns | sed 's/.*lru_size=//')
2963 if ! test "$lrs" -eq "${lru_size[count]}"; then
2964 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2965 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2973 run_test 47 "server restart does not make client loss lru_resize settings"
2978 # reformat after this test is needed - if test will failed
2979 # we will have unkillable file at FS
2983 test_48() { # bug 17636
2986 check_mount || return 2
2988 $LFS setstripe -c -1 $MOUNT || return 9
2989 $LFS getstripe $MOUNT || return 10
2991 echo "ok" > $MOUNT/widestripe
2992 $LFS getstripe $MOUNT/widestripe || return 11
2994 trap cleanup_48 EXIT ERR
2996 # fill acl buffer for avoid expand lsm to them
2997 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2998 setfacl -m $acl $MOUNT/widestripe
3001 stat $MOUNT/widestripe || return 12
3006 run_test 48 "too many acls on file"
3008 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3009 test_49a() { # bug 17710
3010 local timeout_orig=$TIMEOUT
3011 local ldlm_timeout_orig=$LDLM_TIMEOUT
3012 local LOCAL_TIMEOUT=20
3014 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3015 TIMEOUT=$LOCAL_TIMEOUT
3019 check_mount || error "client mount failed"
3021 echo "check ldlm_timout..."
3022 local LDLM_MDS="$(do_facet $SINGLEMDS lctl get_param -n ldlm_timeout)"
3023 local LDLM_OST1="$(do_facet ost1 lctl get_param -n ldlm_timeout)"
3024 local LDLM_CLIENT="$(do_facet client lctl get_param -n ldlm_timeout)"
3026 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3027 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3030 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3031 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3034 umount_client $MOUNT
3035 stop_ost || error "problem stopping OSS"
3036 stop_mds || error "problem stopping MDS"
3038 LDLM_TIMEOUT=$ldlm_timeout_orig
3039 TIMEOUT=$timeout_orig
3041 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3043 test_49b() { # bug 17710
3044 local timeout_orig=$TIMEOUT
3045 local ldlm_timeout_orig=$LDLM_TIMEOUT
3046 local LOCAL_TIMEOUT=20
3048 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3049 TIMEOUT=$LOCAL_TIMEOUT
3053 check_mount || error "client mount failed"
3055 local LDLM_MDS="$(do_facet $SINGLEMDS lctl get_param -n ldlm_timeout)"
3056 local LDLM_OST1="$(do_facet ost1 lctl get_param -n ldlm_timeout)"
3057 local LDLM_CLIENT="$(do_facet client lctl get_param -n ldlm_timeout)"
3059 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3060 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3063 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3064 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3067 cleanup || error "cleanup failed"
3069 LDLM_TIMEOUT=$ldlm_timeout_orig
3070 TIMEOUT=$timeout_orig
3072 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3075 # Test both statfs and lfs df and fail if either one fails
3076 multiop_bg_pause $1 f_
3079 killall -USR1 multiop
3080 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
3081 wait $PID || { RC1=$?; log "multiop return error "; }
3088 if [ $RC2 -eq 0 ]; then
3090 log "lazystatfs df failed"
3094 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
3100 lctl set_param llite.$FSNAME-*.lazystatfs=1
3103 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3105 cleanup || return $?
3107 run_test 50a "lazystatfs all servers available =========================="
3111 lctl set_param llite.$FSNAME-*.lazystatfs=1
3114 # Wait for client to detect down OST
3115 stop_ost || error "Unable to stop OST1"
3116 wait_osc_import_state mds ost DISCONN
3118 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
3120 umount_client $MOUNT || error "Unable to unmount client"
3121 stop_mds || error "Unable to stop MDS"
3123 run_test 50b "lazystatfs all servers down =========================="
3126 start_mds || error "Unable to start MDS"
3127 start_ost || error "Unable to start OST1"
3128 start_ost2 || error "Unable to start OST2"
3129 mount_client $MOUNT || error "Unable to mount client"
3130 lctl set_param llite.$FSNAME-*.lazystatfs=1
3133 # Wait for client to detect down OST
3134 stop_ost || error "Unable to stop OST1"
3135 wait_osc_import_state mds ost DISCONN
3136 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3138 umount_client $MOUNT || error "Unable to unmount client"
3139 stop_ost2 || error "Unable to stop OST2"
3140 stop_mds || error "Unable to stop MDS"
3141 #writeconf to remove all ost2 traces for subsequent tests
3142 writeconf_or_reformat
3144 run_test 50c "lazystatfs one server down =========================="
3147 start_mds || error "Unable to start MDS"
3148 start_ost || error "Unable to start OST1"
3149 start_ost2 || error "Unable to start OST2"
3150 mount_client $MOUNT || error "Unable to mount client"
3151 lctl set_param llite.$FSNAME-*.lazystatfs=1
3154 # Issue the statfs during the window where the client still
3155 # belives the OST to be available but it is in fact down.
3156 # No failure just a statfs which hangs for a timeout interval.
3157 stop_ost || error "Unable to stop OST1"
3158 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3160 umount_client $MOUNT || error "Unable to unmount client"
3161 stop_ost2 || error "Unable to stop OST2"
3162 stop_mds || error "Unable to stop MDS"
3163 #writeconf to remove all ost2 traces for subsequent tests
3164 writeconf_or_reformat
3166 run_test 50d "lazystatfs client/server conn race =========================="
3173 start_mds || return 1
3174 #first client should see only one ost
3175 start_ost || return 2
3176 wait_osc_import_state mds ost FULL
3178 # Wait for client to detect down OST
3179 stop_ost || error "Unable to stop OST1"
3180 wait_osc_import_state mds ost DISCONN
3182 mount_client $MOUNT || error "Unable to mount client"
3183 lctl set_param llite.$FSNAME-*.lazystatfs=0
3185 multiop_bg_pause $MOUNT _f
3189 if [ $RC1 -ne 0 ]; then
3190 log "multiop failed $RC1"
3193 sleep $(( $TIMEOUT+1 ))
3195 [ $? -ne 0 ] && error "process isn't sleep"
3196 start_ost || error "Unable to start OST1"
3197 wait $pid || error "statfs failed"
3200 umount_client $MOUNT || error "Unable to unmount client"
3201 stop_ost || error "Unable to stop OST1"
3202 stop_mds || error "Unable to stop MDS"
3204 run_test 50e "normal statfs all servers down =========================="
3209 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3211 start_mds || error "Unable to start mds"
3212 #first client should see only one ost
3213 start_ost || error "Unable to start OST1"
3214 wait_osc_import_state mds ost FULL
3216 start_ost2 || error "Unable to start OST2"
3217 wait_osc_import_state mds ost2 FULL
3219 # Wait for client to detect down OST
3220 stop_ost2 || error "Unable to stop OST2"
3222 wait_osc_import_state mds ost2 DISCONN
3223 mount_client $MOUNT || error "Unable to mount client"
3224 lctl set_param llite.$FSNAME-*.lazystatfs=0
3226 multiop_bg_pause $MOUNT _f
3230 if [ $RC1 -ne 0 ]; then
3231 log "lazystatfs multiop failed $RC1"
3234 sleep $(( $TIMEOUT+1 ))
3236 [ $? -ne 0 ] && error "process isn't sleep"
3237 start_ost2 || error "Unable to start OST2"
3238 wait $pid || error "statfs failed"
3239 stop_ost2 || error "Unable to stop OST2"
3242 umount_client $MOUNT || error "Unable to unmount client"
3243 stop_ost || error "Unable to stop OST1"
3244 stop_mds || error "Unable to stop MDS"
3245 #writeconf to remove all ost2 traces for subsequent tests
3246 writeconf_or_reformat
3248 run_test 50f "normal statfs one server in down =========================="
3251 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
3253 start_ost2 || error "Unable to start OST2"
3254 wait_osc_import_state mds ost2 FULL
3255 wait_osc_import_state client ost2 FULL
3257 local PARAM="${FSNAME}-OST0001.osc.active"
3259 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
3260 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
3262 umount_client $MOUNT || error "Unable to unmount client"
3263 mount_client $MOUNT || error "Unable to mount client"
3264 # This df should not cause a panic
3267 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
3269 umount_client $MOUNT || error "Unable to unmount client"
3270 stop_ost2 || error "Unable to stop OST2"
3271 stop_ost || error "Unable to stop OST1"
3272 stop_mds || error "Unable to stop MDS"
3273 #writeconf to remove all ost2 traces for subsequent tests
3274 writeconf_or_reformat
3276 run_test 50g "deactivated OST should not cause panic====================="
3280 # prepare MDT/OST, make OSC inactive for OST1
3281 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
3283 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3284 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3285 error "tunefs OST1 failed"
3286 start_mds || error "Unable to start MDT"
3287 start_ost || error "Unable to start OST1"
3288 start_ost2 || error "Unable to start OST2"
3289 mount_client $MOUNT || error "client start failed"
3293 # activatate OSC for OST1
3294 local TEST="$LCTL get_param -n osc.${FSNAME}-OST0000-osc-[!M]*.active"
3295 set_conf_param_and_check client \
3296 "$TEST" "${FSNAME}-OST0000.osc.active" 1 ||
3297 error "Unable to activate OST1"
3299 mkdir -p $DIR/$tdir/2
3300 $LFS setstripe -c -1 -i 0 $DIR/$tdir/2
3301 sleep 1 && echo "create a file after OST1 is activated"
3303 createmany -o $DIR/$tdir/2/$tfile-%d 1
3305 # check OSC import is working
3306 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3307 error "some OSC imports are still not connected"
3310 umount_client $MOUNT || error "Unable to umount client"
3311 stop_ost2 || error "Unable to stop OST2"
3314 run_test 50h "LU-642: activate deactivated OST ==="
3317 local LOCAL_TIMEOUT=20
3321 check_mount || return 1
3324 $LFS setstripe -c -1 $MOUNT/d1
3325 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3326 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
3327 touch $MOUNT/d1/f1 &
3330 start_ost2 || return 2
3332 stop_ost2 || return 3
3334 #writeconf to remove all ost2 traces for subsequent tests
3335 writeconf_or_reformat
3337 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
3346 do_node $node mkdir -p $dest
3347 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3349 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
3350 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3351 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
3353 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
3354 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
3364 local backup2=${TMP}/backup2
3366 do_node $node mkdir -p $backup2
3367 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3369 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
3370 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3371 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
3373 do_node $node "diff -rq $backup $backup2"
3374 [ $? -eq 0 ] || { error "contents differ"; return 3; }
3376 local xattrs2=${TMP}/xattrs2
3377 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
3378 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
3380 do_node $node "diff $xattrs $xattrs2"
3381 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
3383 do_node $node "rm -rf $backup2 $xattrs2"
3384 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
3388 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3389 skip "Only applicable to ldiskfs-based MDTs"
3394 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
3396 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
3398 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
3401 local ost1mnt=$(facet_mntpt ost1)
3402 local ost1node=$(facet_active_host ost1)
3403 local ost1tmp=$TMP/conf52
3407 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
3408 touch $TMP/modified_first
3409 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
3410 local mtime=$(stat -c %Y $TMP/modified_first)
3411 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
3413 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
3416 $LFS setstripe -c -1 -S 1M $DIR/$tdir
3417 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
3419 for (( i=0; i < nrfiles; i++ )); do
3420 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
3421 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
3427 echo backup files to $TMP/files
3428 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
3429 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
3430 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
3432 umount_client $MOUNT
3433 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
3435 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
3437 echo mount ost1 as ldiskfs
3438 do_node $ost1node mkdir -p $ost1mnt
3439 [ $? -eq 0 ] || { error "Unable to create $ost1mnt"; return 23; }
3440 if ! do_node $ost1node test -b $ost1_dev; then
3443 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
3445 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
3448 echo backup objects to $ost1tmp/objects
3449 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
3450 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
3451 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
3453 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
3455 # move objects to lost+found
3456 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
3457 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
3459 # recover objects dry-run
3460 echo "ll_recover_lost_found_objs dry_run"
3461 do_node $ost1node "ll_recover_lost_found_objs -n -d $ost1mnt/O"
3462 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
3465 echo "ll_recover_lost_found_objs fix run"
3466 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
3467 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
3469 # compare restored objects against saved ones
3470 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
3471 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
3473 do_node $ost1node "umount $ost1mnt"
3474 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
3477 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
3479 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
3482 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
3483 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
3485 rm -rf $TMP/files $TMP/file_xattrs
3486 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
3487 do_node $ost1node "rm -rf $ost1tmp"
3488 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
3491 run_test 52 "check recovering objects from lost+found"
3493 # Checks threads_min/max/started for some service
3495 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
3496 # parameter pattern prefix like 'ost.*.ost'.
3509 local msg="Insane $modname thread counts"
3510 local ncpts=$(check_cpt_number $facet)
3514 check_mount || return 41
3516 # We need to expand $parampat, but it may match multiple parameters, so
3517 # we'll pick the first one
3518 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
3519 error "Couldn't expand ${parampat}.threads_min parameter name"
3523 # Remove the .threads_min part
3524 paramp=${paramp%.threads_min}
3526 # Check for sanity in defaults
3527 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3528 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3529 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
3530 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
3531 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
3532 nthrs=$(expr $tmax - $tmin)
3533 if [ $nthrs -lt $ncpts ]; then
3539 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
3540 skip_env "module parameter forced $facet thread count" &&
3541 tmin=3 && tmax=$((3 * tmax))
3543 # Check that we can change min/max
3544 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + nthrs))"
3545 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - nthrs))"
3546 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3547 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3548 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) && $tmax2 == ($tmax - $nthrs)))' || return $?
3550 # Check that we can set min/max to the same value
3551 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3552 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
3553 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3554 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3555 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
3557 # Check that we can't set max < min
3558 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
3559 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3560 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3561 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
3563 # We need to ensure that we get the module options desired; to do this
3564 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
3565 LOAD_MODULES_REMOTE=true
3568 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
3569 setmodopts -a $modname "$newvalue" oldvalue
3573 check_mount || return 41
3575 # Restore previous setting of MODOPTS_*
3576 setmodopts $modname "$oldvalue"
3578 # Check that $opts took
3579 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
3580 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
3581 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
3582 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
3591 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
3594 run_test 53a "check OSS thread count params"
3598 local mds=$(do_facet $SINGLEMDS "lctl get_param -N mds.*.*.threads_max \
3600 if [ -z "$mds" ]; then
3601 #running this on an old MDT
3602 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
3604 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
3608 run_test 53b "check MDS thread count params"
3611 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3612 skip "Only applicable to ldiskfs-based MDTs"
3616 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p
3617 [ $? -eq 0 ] || error "llverdev failed!"
3620 run_test 54a "test llverdev and partial verify of device"
3623 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3624 skip "Only applicable to ldiskfs-based MDTs"
3629 run_llverfs $MOUNT -p
3630 [ $? -eq 0 ] || error "llverfs failed!"
3633 run_test 54b "test llverfs and partial verify of filesystem"
3637 local max_ost_index=$1
3638 echo -n $(((max_ost_index + 1) * 8))
3642 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3643 skip "Only applicable to ldiskfs-based MDTs"
3647 local mdsdev=$(mdsdevname 1)
3648 local mdsvdev=$(mdsvdevname 1)
3652 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
3654 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
3655 --reformat $(ostdevname 1) $(ostvdevname 1)
3661 echo checking size of lov_objid for ost index $i
3662 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
3663 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
3664 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
3666 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
3673 run_test 55 "check lov_objid size"
3676 local mds_journal_size_orig=$MDSJOURNALSIZE
3681 for num in $(seq 1 $MDSCOUNT); do
3682 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3683 --reformat $(mdsdevname $num) $(mdsvdevname $num)
3685 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
3686 $(ostdevname 1) $(ostvdevname 1)
3687 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
3688 $(ostdevname 2) $(ostvdevname 2)
3691 start_ost || error "Unable to start first ost (idx 10000)"
3692 start_ost2 || error "Unable to start second ost (idx 1000)"
3693 mount_client $MOUNT || error "Unable to mount client"
3696 wait_osc_import_state mds ost1 FULL
3697 wait_osc_import_state mds ost2 FULL
3698 $LFS setstripe --stripe-count=-1 $DIR/$tfile || error "Unable to create"
3699 n=$($LFS getstripe --stripe-count $DIR/$tfile)
3700 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
3703 MDSJOURNALSIZE=$mds_journal_size_orig
3706 run_test 56 "check big OST indexes and out-of-index-order start"
3708 test_57a() { # bug 22656
3709 do_rpc_nodes $(facet_active_host ost1) load_modules_local
3710 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
3711 writeconf_or_reformat
3712 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3713 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
3715 start_ost && error "OST registration from failnode should fail"
3718 run_test 57a "initial registration from failnode should fail (should return errs)"
3721 do_rpc_nodes $(facet_active_host ost1) load_modules_local
3722 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
3723 writeconf_or_reformat
3724 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3725 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
3727 start_ost || error "OST registration from servicenode should not fail"
3730 run_test 57b "initial registration from servicenode should not fail"
3733 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
3736 test_58() { # bug 22658
3739 createmany -o $DIR/$tdir/$tfile-%d 100
3740 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
3741 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
3742 do_facet $SINGLEMDS "lctl set_param fail_loc=0x601"
3743 unlinkmany $DIR/$tdir/$tfile-%d 100
3746 local MNTDIR=$(facet_mntpt $SINGLEMDS)
3747 local devname=$(mdsdevname ${SINGLEMDS//mds/})
3749 # remove all files from the OBJECTS dir
3750 mount_fstype $SINGLEMDS
3752 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
3754 unmount_fstype $SINGLEMDS
3755 # restart MDS with missing llog files
3757 do_facet mds "lctl set_param fail_loc=0"
3760 run_test 58 "missing llog files must not prevent MDT from mounting"
3763 start_mgsmds >> /dev/null
3764 local C1=$(count_osts)
3765 if [ $C1 -eq 0 ]; then
3766 start_ost >> /dev/null
3770 echo "original ost count: $C1 (expect > 0)"
3771 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
3772 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
3773 local C2=$(count_osts)
3774 echo "after mdt writeconf count: $C2 (expect 0)"
3775 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
3776 echo "OST start without writeconf should fail:"
3777 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
3778 echo "OST start with writeconf should succeed:"
3779 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
3780 local C3=$(count_osts)
3781 echo "after ost writeconf count: $C3 (expect 1)"
3782 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
3783 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
3784 local C4=$(count_osts)
3785 echo "after ost2 writeconf count: $C4 (expect 2)"
3786 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
3787 stop_ost2 >> /dev/null
3788 cleanup_nocli >> /dev/null
3789 #writeconf to remove all ost2 traces for subsequent tests
3790 writeconf_or_reformat
3792 run_test 59 "writeconf mount option"
3794 test_60() { # LU-471
3797 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3798 skip "Only applicable to ldiskfs-based MDTs"
3802 for num in $(seq $MDSCOUNT); do
3803 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3804 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
3805 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3809 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
3811 [ $rc -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
3813 # MDT default has dirdata feature
3814 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
3815 # we disable uninit_bg feature
3816 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
3817 # we set stride extended options
3818 echo $dump | grep stride > /dev/null || error "stride is not set"
3821 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
3824 local reformat=false
3826 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
3827 { skip "Need MDS version at least 2.1.53"; return 0; }
3829 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
3830 ! large_xattr_enabled; then
3832 LDISKFS_MKFS_OPTS+=" -O large_xattr"
3834 for num in $(seq $MDSCOUNT); do
3835 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
3836 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3837 error "add mds $num failed"
3841 setup_noconfig || error "setting up the filesystem failed"
3842 client_up || error "starting client failed"
3844 local file=$DIR/$tfile
3847 local large_value="$(generate_string $(max_xattr_size))"
3848 local small_value="bar"
3850 local name="trusted.big"
3851 log "save large xattr $name on $file"
3852 setfattr -n $name -v $large_value $file ||
3853 error "saving $name on $file failed"
3855 local new_value=$(get_xattr_value $name $file)
3856 [[ "$new_value" != "$large_value" ]] &&
3857 error "$name different after saving"
3859 log "shrink value of $name on $file"
3860 setfattr -n $name -v $small_value $file ||
3861 error "shrinking value of $name on $file failed"
3863 new_value=$(get_xattr_value $name $file)
3864 [[ "$new_value" != "$small_value" ]] &&
3865 error "$name different after shrinking"
3867 log "grow value of $name on $file"
3868 setfattr -n $name -v $large_value $file ||
3869 error "growing value of $name on $file failed"
3871 new_value=$(get_xattr_value $name $file)
3872 [[ "$new_value" != "$large_value" ]] &&
3873 error "$name different after growing"
3875 log "check value of $name on $file after remounting MDS"
3877 new_value=$(get_xattr_value $name $file)
3878 [[ "$new_value" != "$large_value" ]] &&
3879 error "$name different after remounting MDS"
3881 log "remove large xattr $name from $file"
3882 setfattr -x $name $file || error "removing $name from $file failed"
3887 LDISKFS_MKFS_OPTS=${LDISKFS_MKFS_OPTS% -O large_xattr}
3891 run_test 61 "large xattr"
3894 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3895 skip "Only applicable to ldiskfs-based MDTs"
3900 local mdsdev=$(mdsdevname 1)
3901 local ostdev=$(ostdevname 1)
3903 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
3904 { skip "Need MDS version at least 2.2.51"; return 0; }
3906 echo "disable journal for mds"
3907 do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
3908 start_mds && error "MDT start should fail"
3909 echo "disable journal for ost"
3910 do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
3911 start_ost && error "OST start should fail"
3912 cleanup || return $?
3915 run_test 62 "start with disabled journal"
3918 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3919 skip "Only applicable to ldiskfs-based MDTs"
3923 local inode_slab=$(do_facet $SINGLEMDS \
3924 "awk '/ldiskfs_inode_cache/ { print \\\$5 }' /proc/slabinfo")
3925 if [ -z "$inode_slab" ]; then
3926 skip "ldiskfs module has not been loaded"
3930 echo "$inode_slab ldisk inodes per page"
3931 [ "$inode_slab" -ge "3" ] ||
3932 error "ldisk inode size is too big, $inode_slab objs per page"
3935 run_test 63 "Verify each page can at least hold 3 ldisk inodes"
3940 start_ost2 || error "Unable to start second ost"
3941 mount_client $MOUNT || error "Unable to mount client"
3942 stop_ost2 || error "Unable to stop second ost"
3944 $LFS df --lazy || error "lfs df failed"
3945 cleanup || return $?
3946 #writeconf to remove all ost2 traces for subsequent tests
3947 writeconf_or_reformat
3949 run_test 64 "check lfs df --lazy "
3951 test_65() { # LU-2237
3952 # Currently, the test is only valid for ldiskfs backend
3953 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
3954 skip "non-ldiskfs backend" && return
3956 local devname=$(mdsdevname ${SINGLEMDS//mds/})
3957 local brpt=$(facet_mntpt brpt)
3960 if ! do_facet $SINGLEMDS "test -b $devname"; then
3965 local obj=$(do_facet $SINGLEMDS \
3966 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
3968 if [ -z "$obj" ]; then
3969 # The MDT may be just re-formatted, mount the MDT for the
3970 # first time to guarantee the "last_rcvd" file is there.
3971 start_mds || error "fail to mount the MDS for the first time"
3975 # remove the "last_rcvd" file
3976 do_facet $SINGLEMDS "mkdir -p $brpt"
3977 do_facet $SINGLEMDS \
3978 "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
3979 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
3980 do_facet $SINGLEMDS "umount -d $brpt"
3982 # restart MDS, the "last_rcvd" file should be recreated.
3983 start_mds || error "fail to restart the MDS"
3985 obj=$(do_facet $SINGLEMDS \
3986 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
3987 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
3989 run_test 65 "re-create the lost last_rcvd file when server mount"
3992 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
3993 { skip "Need MGS version at least 2.3.59"; return 0; }
3996 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
3997 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
3999 echo "replace_nids should fail if MDS, OSTs and clients are UP"
4000 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4001 error "replace_nids fail"
4003 umount_client $MOUNT || error "unmounting client failed"
4004 echo "replace_nids should fail if MDS and OSTs are UP"
4005 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4006 error "replace_nids fail"
4009 echo "replace_nids should fail if MDS is UP"
4010 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4011 error "replace_nids fail"
4013 stop_mds || error "stopping mds failed"
4015 if combined_mgs_mds; then
4016 start_mdt 1 "-o nosvc" ||
4017 error "starting mds with nosvc option failed"
4020 echo "command should accept two parameters"
4021 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
4022 error "command should accept two params"
4024 echo "correct device name should be passed"
4025 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
4026 error "wrong devname"
4028 echo "wrong nids list should not destroy the system"
4029 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
4032 echo "replace OST nid"
4033 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
4034 error "replace nids failed"
4036 echo "command should accept two parameters"
4037 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
4038 error "command should accept two params"
4040 echo "wrong nids list should not destroy the system"
4041 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
4044 echo "replace MDS nid"
4045 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
4046 error "replace nids failed"
4048 if ! combined_mgs_mds ; then
4055 check_mount || error "error after nid replace"
4056 cleanup || error "cleanup failed"
4059 run_test 66 "replace nids"
4061 test_67() { #LU-2950
4062 local legacy="$TMP/legacy_lnet_config"
4063 local new="$TMP/new_routes_test"
4064 local out="$TMP/config_out_file"
4065 local verify="$TMP/conv_verify"
4066 local verify_conf="$TMP/conf_verify"
4068 # Create the legacy file that will be run through the
4069 # lustre_routes_conversion script
4070 cat <<- LEGACY_LNET_CONFIG > $legacy
4071 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
4072 tcp2 54 10.1.3.2@tcp;
4073 tcp3 10.3.4.3@tcp:3;
4077 # Create the verification file to verify the output of
4078 # lustre_routes_conversion script against.
4079 cat <<- VERIFY_LNET_CONFIG > $verify
4080 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
4081 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
4082 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
4083 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
4084 tcp4: { gateway: 10.3.3.4@tcp }
4087 # Create the verification file to verify the output of
4088 # lustre_routes_config script against
4089 cat <<- VERIFY_LNET_CONFIG > $verify_conf
4090 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
4091 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
4092 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
4093 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
4094 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
4097 lustre_routes_conversion $legacy $new > /dev/null
4098 if [ -f $new ]; then
4099 # verify the conversion output
4100 cmp -s $new $verify > /dev/null
4101 if [ $? -eq 1 ]; then
4102 error "routes conversion failed"
4105 lustre_routes_config --dry-run --verbose $new > $out
4106 # check that the script succeeded
4107 cmp -s $out $verify_conf > /dev/null
4108 if [ $? -eq 1 ]; then
4109 error "routes config failed"
4112 error "routes conversion test failed"
4114 # remove generated files
4115 rm -f $new $legacy $verify $verify_conf $out
4117 run_test 67 "test routes conversion and configuration"
4125 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.53) ] ||
4126 { skip "Need MDS version at least 2.4.53"; return 0; }
4128 umount_client $MOUNT || error "umount client failed"
4130 start_mdt 1 || error "MDT start failed"
4133 # START-END - the sequences we'll be reserving
4134 START=$(do_facet $SINGLEMDS \
4135 lctl get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4136 END=$((START + (1 << 30)))
4137 do_facet $SINGLEMDS \
4138 lctl set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4140 # reset the sequences MDT0000 has already assigned
4141 do_facet $SINGLEMDS \
4142 lctl set_param seq.srv*MDT0000.space=clear
4144 # remount to let the client allocate new sequence
4145 mount_client $MOUNT || error "mount client failed"
4148 do_facet $SINGLEMDS \
4149 lctl get_param seq.srv*MDT0000.space
4150 $LFS path2fid $DIR/$tfile
4152 local old_ifs="$IFS"
4154 fid=($($LFS path2fid $DIR/$tfile))
4158 if [[ $seq < $END ]]; then
4159 error "used reserved sequence $seq?"
4161 cleanup || return $?
4163 run_test 68 "be able to reserve specific sequences in FLDB"
4166 local server_version=$(lustre_version_code $SINGLEMDS)
4168 [[ $server_version -lt $(version_code 2.4.2) ]] &&
4169 skip "Need MDS version at least 2.4.2" && return
4171 [[ $server_version -ge $(version_code 2.4.50) ]] &&
4172 [[ $server_version -lt $(version_code 2.5.0) ]] &&
4173 skip "Need MDS version at least 2.5.0" && return
4177 # use OST0000 since it probably has the most creations
4178 local OSTNAME=$(ostname_from_index 0)
4179 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4180 local last_id=$(do_facet mds1 lctl get_param -n \
4181 osc.$mdtosc_proc1.prealloc_last_id)
4183 # Want to have OST LAST_ID over 1.5 * OST_MAX_PRECREATE to
4184 # verify that the LAST_ID recovery is working properly. If
4185 # not, then the OST will refuse to allow the MDS connect
4186 # because the LAST_ID value is too different from the MDS
4187 #define OST_MAX_PRECREATE=20000
4188 local num_create=$((20000 * 5))
4191 $LFS setstripe -i 0 $DIR/$tdir
4192 createmany -o $DIR/$tdir/$tfile- $num_create ||
4193 error "createmany: failed to create $num_create files: $?"
4194 # delete all of the files with objects on OST0 so the
4195 # filesystem is not inconsistent later on
4196 $LFS find $MOUNT --ost 0 | xargs rm
4198 stop_ost || error "OST0 stop failure"
4199 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
4200 $(ostdevname 1) $(ostvdevname 1) ||
4201 error "reformat and replace $ostdev failed"
4202 start_ost || error "OST0 restart failure"
4203 wait_osc_import_state mds ost FULL
4205 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
4206 local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
4207 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
4211 run_test 69 "replace an OST with the same index"
4214 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4219 start_mdt 1 || error "MDT0 start fail"
4221 start_ost || error "OST0 start fail"
4223 start_mdt 2 || error "MDT1 start fail"
4225 mount_client $MOUNT || error "mount client fails"
4227 mkdir -p $DIR/$tdir || error "create dir fail"
4229 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4230 error "create remote dir fail"
4232 rm -rf $DIR/$tdir || error "delete dir fail"
4233 cleanup || return $?
4235 run_test 70a "start MDT0, then OST, then MDT1"
4238 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4241 start_ost || error "OST0 start fail"
4243 start_mdt 1 || error "MDT0 start fail"
4244 start_mdt 2 || error "MDT1 start fail"
4246 mount_client $MOUNT || error "mount client fails"
4248 mkdir -p $DIR/$tdir || error "create dir fail"
4250 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4251 error "create remote dir fail"
4253 rm -rf $DIR/$tdir || error "delete dir fail"
4255 cleanup || return $?
4257 run_test 70b "start OST, MDT1, MDT0"
4260 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4263 start_mdt 1 || error "MDT0 start fail"
4264 start_mdt 2 || error "MDT1 start fail"
4265 start_ost || error "OST0 start fail"
4267 mount_client $MOUNT || error "mount client fails"
4268 stop_mdt 1 || error "MDT1 start fail"
4270 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
4271 echo "deactivate $mdc_for_mdt1"
4272 $LCTL --device $mdc_for_mdt1 deactivate || return 1
4274 mkdir -p $DIR/$tdir && error "mkdir succeed"
4276 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4277 error "create remote dir succeed"
4279 cleanup || return $?
4281 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
4284 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4287 start_mdt 1 || error "MDT0 start fail"
4288 start_mdt 2 || error "MDT1 start fail"
4289 start_ost || error "OST0 start fail"
4291 mount_client $MOUNT || error "mount client fails"
4293 stop_mdt 2 || error "MDT1 start fail"
4295 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
4297 echo "deactivate $mdc_for_mdt2"
4298 $LCTL --device $mdc_for_mdt2 deactivate ||
4299 error "set $mdc_for_mdt2 deactivate failed"
4301 mkdir -p $DIR/$tdir || error "mkdir fail"
4302 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4303 error "create remote dir succeed"
4305 rm -rf $DIR/$tdir || error "delete dir fail"
4307 cleanup || return $?
4309 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
4312 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4313 if combined_mgs_mds; then
4314 skip "needs separate MGS/MDT" && return
4318 start_mdt 1 || error "MDT0 start fail"
4319 start_ost || error "OST0 start fail"
4320 start_mdt 2 || error "MDT1 start fail"
4321 start_ost2 || error "OST1 start fail"
4323 mount_client $MOUNT || error "mount client fails"
4325 mkdir -p $DIR/$tdir || error "mkdir fail"
4326 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4327 error "create remote dir succeed"
4329 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4330 rm -rf $DIR/$tdir || error "delete dir fail"
4332 umount_client $MOUNT
4333 stop_mdt 1 || error "MDT0 stop fail"
4334 stop_mdt 2 || error "MDT1 stop fail"
4335 stop_ost || error "OST0 stop fail"
4336 stop_ost2 || error "OST1 stop fail"
4338 run_test 71a "start MDT0 OST0, MDT1, OST1"
4341 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4342 if combined_mgs_mds; then
4343 skip "needs separate MGS/MDT" && return
4347 start_mdt 2 || error "MDT1 start fail"
4348 start_ost || error "OST0 start fail"
4349 start_mdt 1 || error "MDT0 start fail"
4350 start_ost2 || error "OST1 start fail"
4352 mount_client $MOUNT || error "mount client fails"
4354 mkdir -p $DIR/$tdir || error "mkdir fail"
4355 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4356 error "create remote dir succeed"
4358 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4359 rm -rf $DIR/$tdir || error "delete dir fail"
4361 umount_client $MOUNT
4362 stop_mdt 1 || error "MDT0 stop fail"
4363 stop_mdt 2 || error "MDT1 stop fail"
4364 stop_ost || error "OST0 stop fail"
4365 stop_ost2 || error "OST1 stop fail"
4367 run_test 71b "start MDT1, OST0, MDT0, OST1"
4370 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4371 if combined_mgs_mds; then
4372 skip "needs separate MGS/MDT" && return
4376 start_ost || error "OST0 start fail"
4377 start_ost2 || error "OST1 start fail"
4378 start_mdt 2 || error "MDT1 start fail"
4379 start_mdt 1 || error "MDT0 start fail"
4381 mount_client $MOUNT || error "mount client fails"
4383 mkdir -p $DIR/$tdir || error "mkdir fail"
4384 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4385 error "create remote dir succeed"
4387 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4388 rm -rf $DIR/$tdir || error "delete dir fail"
4390 umount_client $MOUNT
4391 stop_mdt 1 || error "MDT0 stop fail"
4392 stop_mdt 2 || error "MDT1 stop fail"
4393 stop_ost || error "OST0 stop fail"
4394 stop_ost2 || error "OST1 stop fail"
4397 run_test 71c "start OST0, OST1, MDT1, MDT0"
4400 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4401 if combined_mgs_mds; then
4402 skip "needs separate MGS/MDT" && return
4406 start_ost || error "OST0 start fail"
4407 start_mdt 2 || error "MDT0 start fail"
4408 start_mdt 1 || error "MDT0 start fail"
4409 start_ost2 || error "OST1 start fail"
4411 mount_client $MOUNT || error "mount client fails"
4413 mkdir -p $DIR/$tdir || error "mkdir fail"
4414 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4415 error "create remote dir succeed"
4417 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4418 rm -rf $DIR/$tdir || error "delete dir fail"
4420 umount_client $MOUNT
4421 stop_mdt 1 || error "MDT0 stop fail"
4422 stop_mdt 2 || error "MDT1 stop fail"
4423 stop_ost || error "OST0 stop fail"
4424 stop_ost2 || error "OST1 stop fail"
4427 run_test 71d "start OST0, MDT1, MDT0, OST1"
4430 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4431 if combined_mgs_mds; then
4432 skip "needs separate MGS/MDT" && return
4436 start_ost || error "OST0 start fail"
4437 start_mdt 2 || error "MDT1 start fail"
4438 start_ost2 || error "OST1 start fail"
4439 start_mdt 1 || error "MDT0 start fail"
4441 mount_client $MOUNT || error "mount client fails"
4443 mkdir -p $DIR/$tdir || error "mkdir fail"
4444 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4445 error "create remote dir succeed"
4447 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4448 rm -rf $DIR/$tdir || error "delete dir fail"
4450 umount_client $MOUNT
4451 stop_mdt 1 || error "MDT0 stop fail"
4452 stop_mdt 2 || error "MDT1 stop fail"
4453 stop_ost || error "OST0 stop fail"
4454 stop_ost2 || error "OST1 stop fail"
4457 run_test 71e "start OST0, MDT1, OST1, MDT0"
4459 test_72() { #LU-2634
4460 local mdsdev=$(mdsdevname 1)
4461 local ostdev=$(ostdevname 1)
4462 local cmd="$E2FSCK -fnvd $mdsdev"
4465 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
4466 skip "ldiskfs only test" && return
4468 #tune MDT with "-O extents"
4470 for num in $(seq $MDSCOUNT); do
4471 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
4472 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4473 error "add mds $num failed"
4474 $TUNE2FS -O extents $(mdsdevname $num)
4477 add ost1 $(mkfs_opts ost1 $ostdev) --reformat $ostdev ||
4478 error "add $ostdev failed"
4479 start_mgsmds || error "start mds failed"
4480 start_ost || error "start ost failed"
4481 mount_client $MOUNT || error "mount client failed"
4483 #create some short symlinks
4485 createmany -o $DIR/$tdir/$tfile-%d $fn
4486 echo "create $fn short symlinks"
4487 for i in $(seq -w 1 $fn); do
4488 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
4493 umount_client $MOUNT || error "umount client failed"
4494 stop_mds || error "stop mds failed"
4495 stop_ost || error "stop ost failed"
4498 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
4500 run_test 72 "test fast symlink with extents flag enabled"
4502 test_73() { #LU-3006
4504 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4505 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
4506 error "1st tunefs failed"
4507 start_mgsmds || error "start mds failed"
4508 start_ost || error "start ost failed"
4509 mount_client $MOUNT || error "mount client failed"
4510 lctl get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
4511 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
4512 umount_client $MOUNT || error "umount client failed"
4516 run_test 73 "failnode to update from mountdata properly"
4518 test_75() { # LU-2374
4519 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
4520 skip "Need MDS version at least 2.4.1" && return
4523 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
4524 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
4525 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
4526 --reformat $(ostdevname 1) $(ostvdevname 1)"
4528 #check with default parameters
4529 add mds1 $opts_mds || error "add mds1 failed for default params"
4530 add ost1 $opts_ost || error "add ost1 failed for default params"
4532 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
4533 opts_mds=$(echo $opts_mds |
4534 sed -e "s/--index=$index/--index=$index --mdt/")
4535 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
4536 opts_ost=$(echo $opts_ost |
4537 sed -e "s/--index=$index/--index=$index --ost/")
4539 add mds1 $opts_mds || error "add mds1 failed for new params"
4540 add ost1 $opts_ost || error "add ost1 failed for new params"
4543 run_test 75 "The order of --index should be irrelevant"
4546 [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] ||
4547 { skip "Need MDS version at least 2.4.52" && return 0; }
4549 local MDMB_PARAM="osc.*.max_dirty_mb"
4550 echo "Change MGS params"
4551 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
4553 echo "max_dirty_mb: $MAX_DIRTY_MB"
4554 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB + MAX_DIRTY_MB))
4555 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
4556 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
4557 wait_update $HOSTNAME "lctl get_param -n $MDMB_PARAM |
4558 head -1" $NEW_MAX_DIRTY_MB
4559 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
4560 echo "$MAX_DIRTY_MB"
4561 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
4562 error "error while apply max_dirty_mb"
4564 echo "Check the value is stored after remount"
4567 wait_update $HOSTNAME "lctl get_param -n $MDMB_PARAM |
4568 head -1" $NEW_MAX_DIRTY_MB
4569 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
4570 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
4571 error "max_dirty_mb is not saved after remount"
4573 echo "Change OST params"
4574 CLIENT_PARAM="obdfilter.*.client_cache_count"
4575 local CLIENT_CACHE_COUNT
4576 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4578 echo "client_cache_count: $CLIENT_CACHE_COUNT"
4579 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
4580 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
4581 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
4582 wait_update $(facet_host ost1) "lctl get_param -n $CLIENT_PARAM |
4583 head -1" $NEW_CLIENT_CACHE_COUNT
4584 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4586 echo "$CLIENT_CACHE_COUNT"
4587 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
4588 error "error while apply client_cache_count"
4590 echo "Check the value is stored after remount"
4593 wait_update $(facet_host ost1) "lctl get_param -n $CLIENT_PARAM |
4594 head -1" $NEW_CLIENT_CACHE_COUNT
4595 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4597 echo "$CLIENT_CACHE_COUNT"
4598 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
4599 error "client_cache_count is not saved after remount"
4602 run_test 76a "set permanent params set_param -P"
4604 test_76b() { # LU-4783
4605 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.57) ]] ||
4606 { skip "Need MGS version at least 2.5.57" && return 0; }
4609 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
4610 error "start params log failed"
4613 run_test 76b "verify params log setup correctly"
4615 test_77() { # LU-3445
4616 local server_version=$(lustre_version_code $SINGLEMDS)
4618 [[ $server_version -ge $(version_code 2.2.60) ]] &&
4619 [[ $server_version -le $(version_code 2.4.0) ]] &&
4620 skip "Need MDS version < 2.2.60 or > 2.4.0" && return
4622 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
4623 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
4624 skip_env "mixed loopback and real device not working" && return
4627 local fs2mdsdev=$(mdsdevname 1_2)
4628 local fs2ostdev=$(ostdevname 1_2)
4629 local fs2mdsvdev=$(mdsvdevname 1_2)
4630 local fs2ostvdev=$(ostvdevname 1_2)
4631 local fsname=test1234
4633 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
4635 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
4636 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
4637 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
4638 error "start fs2mds failed"
4640 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
4641 [[ $mgsnid = *,* ]] || mgsnid+=",$mgsnid"
4643 add fs2ost $(mkfs_opts ost1 $fs2ostdev) --mgsnode=$mgsnid \
4644 --failnode=$failnid --fsname=$fsname \
4645 --reformat $fs2ostdev $fs2ostvdev ||
4646 error "add fs2ost failed"
4647 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
4650 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
4651 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
4654 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
4657 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ||
4658 $(facet_fstype ost1) != ldiskfs ]] &&
4659 skip "only applicable to ldiskfs-based MDTs and OSTs" && return
4661 # reformat the Lustre filesystem with a smaller size
4662 local saved_MDSSIZE=$MDSSIZE
4663 local saved_OSTSIZE=$OSTSIZE
4664 MDSSIZE=$((MDSSIZE - 20000))
4665 OSTSIZE=$((OSTSIZE - 20000))
4666 reformat || error "(1) reformat Lustre filesystem failed"
4667 MDSSIZE=$saved_MDSSIZE
4668 OSTSIZE=$saved_OSTSIZE
4670 # mount the Lustre filesystem
4671 setup_noconfig || error "(2) setup Lustre filesystem failed"
4674 log "create test files"
4678 mkdir -p $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
4679 for i in $(seq $num_files); do
4680 file=$MOUNT/$tdir/$tfile-$i
4681 dd if=/dev/urandom of=$file count=1 bs=1M ||
4682 error "(4) create $file failed"
4685 # unmount the Lustre filesystem
4686 cleanup || error "(5) cleanup Lustre filesystem failed"
4688 # run e2fsck on the MDT and OST devices
4689 local mds_host=$(facet_active_host $SINGLEMDS)
4690 local ost_host=$(facet_active_host ost1)
4691 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
4692 local ost_dev=$(ostdevname 1)
4694 run_e2fsck $mds_host $mds_dev "-y"
4695 run_e2fsck $ost_host $ost_dev "-y"
4697 # get the original block count of the MDT and OST filesystems
4698 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
4699 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
4701 # expand the MDT and OST filesystems to the device size
4702 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
4703 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
4705 # run e2fsck on the MDT and OST devices again
4706 run_e2fsck $mds_host $mds_dev "-y"
4707 run_e2fsck $ost_host $ost_dev "-y"
4709 # mount the Lustre filesystem
4713 log "check files after expanding the MDT and OST filesystems"
4714 for i in $(seq $num_files); do
4715 file=$MOUNT/$tdir/$tfile-$i
4716 $CHECKSTAT -t file -s 1048576 $file ||
4717 error "(6) checkstat $file failed"
4721 log "create more files after expanding the MDT and OST filesystems"
4722 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
4723 file=$MOUNT/$tdir/$tfile-$i
4724 dd if=/dev/urandom of=$file count=1 bs=1M ||
4725 error "(7) create $file failed"
4728 # unmount the Lustre filesystem
4729 cleanup || error "(8) cleanup Lustre filesystem failed"
4731 # run e2fsck on the MDT and OST devices
4732 run_e2fsck $mds_host $mds_dev "-y"
4733 run_e2fsck $ost_host $ost_dev "-y"
4735 # get the maximum block count of the MDT and OST filesystems
4736 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
4737 local ost_max_blks=$(get_block_count ost1 $ost_dev)
4739 # get the minimum block count of the MDT and OST filesystems
4740 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
4741 grep minimum | sed -e 's/^.*filesystem: //g')
4742 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
4743 grep minimum | sed -e 's/^.*filesystem: //g')
4745 # shrink the MDT and OST filesystems to a smaller size
4749 if [[ $mds_max_blks -gt $mds_min_blks &&
4750 $mds_max_blks -gt $mds_orig_blks ]]; then
4751 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
4752 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
4753 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
4754 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
4755 error "shrink $SINGLEMDS to $new_blks failed"
4759 if [[ $ost_max_blks -gt $ost_min_blks &&
4760 $ost_max_blks -gt $ost_orig_blks ]]; then
4761 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
4762 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
4763 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
4764 run_resize2fs ost1 $ost_dev $new_blks ||
4765 error "shrink ost1 to $new_blks failed"
4769 # check whether the MDT or OST filesystem was shrunk or not
4771 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
4772 reformat || error "(10) reformat Lustre filesystem failed"
4776 # run e2fsck on the MDT and OST devices again
4777 run_e2fsck $mds_host $mds_dev "-y"
4778 run_e2fsck $ost_host $ost_dev "-y"
4780 # mount the Lustre filesystem again
4784 log "check files after shrinking the MDT and OST filesystems"
4785 for i in $(seq $((num_files + 10))); do
4786 file=$MOUNT/$tdir/$tfile-$i
4787 $CHECKSTAT -t file -s 1048576 $file ||
4788 error "(11) checkstat $file failed"
4791 # unmount and reformat the Lustre filesystem
4792 cleanup || error "(12) cleanup Lustre filesystem failed"
4793 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
4794 reformat || error "(14) reformat Lustre filesystem failed"
4796 run_test 78 "run resize2fs on MDT and OST filesystems"
4798 test_79() { # LU-4227
4799 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.59) ]] ||
4800 { skip "Need MDS version at least 2.5.59"; return 0; }
4802 local mdsdev1=$(mdsdevname 1)
4803 local mdsvdev1=$(mdsvdevname 1)
4804 local mdsdev2=$(mdsdevname 2)
4805 local mdsvdev2=$(mdsvdevname 2)
4806 local ostdev1=$(ostdevname 1)
4807 local ostvdev1=$(ostvdevname 1)
4808 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
4809 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
4810 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
4813 # remove --mgs/--mgsnode from mkfs.lustre options
4814 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
4816 mgsnode_opt=$(echo $opts_mds2 |
4817 awk '{ for ( i = 1; i < NF; i++ )
4818 if ( $i ~ "--mgsnode" ) { print $i; break } }')
4819 [ -n $mgsnode_opt ] &&
4820 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
4822 mgsnode_opt=$(echo $opts_ost1 |
4823 awk '{ for ( i = 1; i < NF; i++ )
4824 if ( $i ~ "--mgsnode" ) { print $i; break } }')
4825 [ -n $mgsnode_opt ] &&
4826 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
4828 # -MGS, format a mdt without --mgs option
4829 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
4830 error "Must specify --mgs when formatting mdt combined with mgs"
4832 # +MGS, format a mdt/ost without --mgsnode option
4833 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
4834 > /dev/null || error "start mds1 failed"
4835 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
4836 error "Must specify --mgsnode when formatting a mdt"
4837 add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
4838 error "Must specify --mgsnode when formatting an ost"
4842 run_test 79 "format MDT/OST without mgs option (should return errors)"
4847 uuid=$(do_facet ost1 lctl get_param -n mgc.*.uuid)
4848 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
4849 do_facet ost1 "lctl set_param fail_val=10 fail_loc=0x906"
4850 do_facet mgs "lctl set_param fail_val=10 fail_loc=0x906"
4851 do_facet mgs "lctl set_param -n mgs/MGS/evict_client $uuid"
4855 do_facet ost1 "lctl set_param fail_loc=0"
4858 run_test 80 "mgc import reconnect race"
4860 if ! combined_mgs_mds ; then
4866 # restore the values of MDSSIZE and OSTSIZE
4867 MDSSIZE=$STORED_MDSSIZE
4868 OSTSIZE=$STORED_OSTSIZE