3 # FIXME - there is no reason to use all of these different
4 # return codes, espcially when most of them are mapped to something
5 # else anyway. The combination of test number and return code
6 # figure out what failed.
12 # bug number for skipped test:
13 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
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
57 # use small MDS + OST size to speed formatting time
58 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
61 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
63 if ! combined_mgs_mds; then
64 # bug number for skipped test: 23954
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
68 # STORED_MDSSIZE is used in test_18
69 if [ -n "$MDSSIZE" ]; then
70 STORED_MDSSIZE=$MDSSIZE
73 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
74 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
75 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
81 require_dsh_mds || exit 0
82 require_dsh_ost || exit 0
84 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
90 # The MGS must be started before the OSTs for a new fs, so start
91 # and stop to generate the startup logs.
94 wait_osc_import_state mds ost FULL
99 reformat_and_config() {
101 if ! combined_mgs_mds ; then
107 writeconf_or_reformat() {
108 # There are at most 2 OSTs for write_conf test
109 # who knows if/where $TUNEFS is installed?
110 # Better reformat if it fails...
111 writeconf_all $MDSCOUNT 2 ||
112 { echo "tunefs failed, reformatting instead" &&
113 reformat_and_config && return 1; }
123 start mgs $MGSDEV $MGS_MOUNT_OPTS
129 local dev=$(mdsdevname $num)
132 echo "start mds service on `facet_active_host $facet`"
133 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
139 local dev=$(mdsdevname $num)
142 echo "stop mds service on `facet_active_host $facet`"
143 # These tests all use non-failover stop
144 stop $facet -f || return 97
150 for num in $(seq $MDSCOUNT); do
151 start_mdt $num $@ || return 94
156 if ! combined_mgs_mds ; then
164 for num in $(seq $MDSCOUNT); do
165 stop_mdt $num || return 97
170 echo "stop mgs service on `facet_active_host mgs`"
171 # These tests all use non-failover stop
172 stop mgs -f || return 97
176 echo "start ost1 service on `facet_active_host ost1`"
177 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
181 echo "stop ost1 service on `facet_active_host ost1`"
182 # These tests all use non-failover stop
183 stop ost1 -f || return 98
187 echo "start ost2 service on `facet_active_host ost2`"
188 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
192 echo "stop ost2 service on `facet_active_host ost2`"
193 # These tests all use non-failover stop
194 stop ost2 -f || return 93
199 echo "mount $FSNAME on ${MOUNTPATH}....."
200 zconf_mount `hostname` $MOUNTPATH || return 96
204 local mountopt="-o remount,$1"
206 echo "remount '$1' lustre on ${MOUNTPATH}....."
207 zconf_mount `hostname` $MOUNTPATH "$mountopt" || return 96
212 echo "umount lustre on ${MOUNTPATH}....."
213 zconf_umount `hostname` $MOUNTPATH || return 97
216 manual_umount_client(){
219 echo "manual umount lustre on ${MOUNT}...."
220 do_facet client "umount -d ${FORCE} $MOUNT"
226 start_mds || error "MDT start failed"
227 start_ost || error "OST start failed"
228 mount_client $MOUNT || error "client start failed"
229 client_up || error "client_up failed"
233 if ! combined_mgs_mds ; then
242 unload_modules_conf () {
243 if combined_mgs_mds || ! local_mode; then
244 unload_modules || return 1
249 stop_ost || return 202
250 stop_mds || return 201
251 unload_modules_conf || return 203
255 umount_client $MOUNT || return 200
256 cleanup_nocli || return $?
260 do_facet client "cp /etc/passwd $DIR/a" || return 71
261 do_facet client "rm $DIR/a" || return 72
262 # make sure lustre is actually mounted (touch will block,
263 # but grep won't, so do it after)
264 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
265 echo "setup single mount lustre success"
269 do_facet client "touch $DIR/a" || return 71
270 do_facet client "rm $DIR/a" || return 72
271 do_facet client "touch $DIR2/a" || return 73
272 do_facet client "rm $DIR2/a" || return 74
273 echo "setup double mount lustre success"
278 if [ "$ONLY" == "setup" ]; then
283 if [ "$ONLY" == "cleanup" ]; then
290 #create single point mountpoint
296 check_mount || return 41
299 run_test 0 "single mount setup"
302 start_mds || error "MDT start failed"
304 echo "start ost second time..."
305 start_ost && error "2nd OST start should fail"
306 mount_client $MOUNT || error "client start failed"
307 check_mount || return 42
310 run_test 1 "start up ost twice (should return errors)"
314 echo "start mds second time.."
315 start_mdt 1 && error "2nd MDT start should fail"
318 check_mount || return 43
321 run_test 2 "start up mds twice (should return err)"
325 #mount.lustre returns an error if already in mtab
326 mount_client $MOUNT && error "2nd client mount should fail"
327 check_mount || return 44
330 run_test 3 "mount client twice (should return err)"
334 touch $DIR/$tfile || return 85
338 # ok for ost to fail shutdown
339 if [ 202 -ne $eno ]; then
344 run_test 4 "force cleanup ost, then cleanup"
346 test_5a() { # was test_5
348 touch $DIR/$tfile || return 1
349 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
351 stop_mds -f || return 2
353 # cleanup may return an error from the failed
354 # disconnects; for now I'll consider this successful
355 # if all the modules have unloaded.
359 echo "killing umount"
360 kill -TERM $UMOUNT_PID
361 echo "waiting for umount to finish"
363 if grep " $MOUNT " /proc/mounts; then
364 echo "test 5: /proc/mounts after failed umount"
368 echo "killing umount"
369 kill -TERM $UMOUNT_PID
370 echo "waiting for umount to finish"
372 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
376 # stop_mds is a no-op here, and should not fail
377 cleanup_nocli || return $?
378 # df may have lingering entry
380 # mtab may have lingering entry
384 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
386 grep -q $MOUNT" " /etc/mtab || break
387 echo "Waiting /etc/mtab updated ... "
388 WAIT=$(( WAIT + sleep))
390 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
391 echo "/etc/mtab updated in $WAIT secs"
393 run_test 5a "force cleanup mds, then cleanup"
401 grep " $MOUNT " /etc/mtab && \
402 error false "unexpected entry in mtab before mount" && return 10
406 if ! combined_mgs_mds ; then
407 trap cleanup_5b EXIT ERR
412 [ -d $MOUNT ] || mkdir -p $MOUNT
413 mount_client $MOUNT && rc=1
414 grep " $MOUNT " /etc/mtab && \
415 error "$MOUNT entry in mtab after failed mount" && rc=11
417 # stop_mds is a no-op here, and should not fail
418 cleanup_nocli || rc=$?
419 if ! combined_mgs_mds ; then
424 run_test 5b "Try to start a client with no MGS (should return errs)"
427 grep " $MOUNT " /etc/mtab && \
428 error false "unexpected entry in mtab before mount" && return 10
433 [ -d $MOUNT ] || mkdir -p $MOUNT
434 local oldfs="${FSNAME}"
435 FSNAME="wrong.${FSNAME}"
436 mount_client $MOUNT || :
438 grep " $MOUNT " /etc/mtab && \
439 error "$MOUNT entry in mtab after failed mount" && rc=11
441 cleanup_nocli || rc=$?
444 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
447 grep " $MOUNT " /etc/mtab && \
448 error false "unexpected entry in mtab before mount" && return 10
450 [ "$(facet_fstype ost1)" = "zfs" ] &&
451 skip "LU-2059: no local config for ZFS OSTs" && return
457 mount_client $MOUNT || rc=1
459 grep " $MOUNT " /etc/mtab && \
460 error "$MOUNT entry in mtab after unmount" && rc=11
463 run_test 5d "mount with ost down"
466 grep " $MOUNT " /etc/mtab && \
467 error false "unexpected entry in mtab before mount" && return 10
473 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
474 do_facet client "lctl set_param fail_loc=0x80000506"
475 mount_client $MOUNT || echo "mount failed (not fatal)"
477 grep " $MOUNT " /etc/mtab && \
478 error "$MOUNT entry in mtab after unmount" && rc=11
481 run_test 5e "delayed connect, don't crash (bug 10268)"
484 if combined_mgs_mds ; then
485 skip "combined mgs and mds"
489 grep " $MOUNT " /etc/mtab && \
490 error false "unexpected entry in mtab before mount" && return 10
494 [ -d $MOUNT ] || mkdir -p $MOUNT
495 mount_client $MOUNT &
497 echo client_mount pid is $pid
501 if ! ps -f -p $pid >/dev/null; then
504 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
505 error "mount returns $rc, expected to hang"
514 # mount should succeed after start mds
517 [ $rc -eq 0 ] || error "mount returned $rc"
518 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
522 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
527 mount_client ${MOUNT} || return 87
528 touch $DIR/a || return 86
531 run_test 6 "manual umount, then mount again"
536 cleanup_nocli || return $?
538 run_test 7 "manual umount, then cleanup"
543 check_mount2 || return 45
544 umount_client $MOUNT2
547 run_test 8 "double mount setup"
552 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
553 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
555 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
556 if [ "$CHECK_PTLDEBUG" ] && { \
557 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
558 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
559 echo "lnet.debug success"
561 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
564 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
565 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
566 echo "lnet.subsystem_debug success"
568 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
571 stop_ost || return $?
573 run_test 9 "test ptldebug and subsystem for mkfs"
581 do_facet $facet "test -b $dev" || rc=1
582 if [[ "$size" ]]; then
583 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
584 awk '($3 == "in") { print $1 }')
585 [[ $in = "1+0" ]] || rc=1
591 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
592 # But with new MDS stack we don't care about the mode of local objects
593 # anymore, so this test is removed. See bug 22944 for more details.
597 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
598 skip "Only applicable to ldiskfs-based MDTs"
603 check_mount || return 41
606 echo "Remove mds config log"
607 if ! combined_mgs_mds ; then
611 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MGSDEV || return \$?" || return $?
613 if ! combined_mgs_mds ; then
618 start_mds && return 42
621 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
624 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
625 skip "Only applicable to ldiskfs-based MDTs"
629 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
634 # check if current MDSSIZE is large enough
635 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
636 log "use MDSSIZE=$MDSSIZE"
638 # check if the global config has a large enough MDSSIZE
639 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
640 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
641 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
643 # check if the block device is large enough
644 [ -z "$OK" ] && $(is_blkdev $SINGLEMDS $MDSDEV $MIN) && OK=1 &&
645 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
647 # check if a loopback device has enough space for fs metadata (5%)
649 if [ -z "$OK" ]; then
650 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
651 awk '($1 != "Filesystem") {print $4}')
652 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
653 OK=1 && myMDSSIZE=$MIN && \
654 log "use file $MDSDEV with MIN=$MIN"
657 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
660 echo "mount mds with large journal..."
662 local OLD_MDSSIZE=$MDSSIZE
666 echo "mount lustre system..."
668 check_mount || return 41
670 echo "check journal size..."
671 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
672 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
673 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
675 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
683 run_test 18 "check mkfs creates large journals"
686 start_mds || return 1
687 stop_mds -f || return 2
689 run_test 19a "start/stop MDS without OSTs"
692 [ "$(facet_fstype ost1)" = "zfs" ] &&
693 skip "LU-2059: no local config for ZFS OSTs" && return
695 start_ost || return 1
696 stop_ost -f || return 2
698 run_test 19b "start/stop OSTs without MDS"
701 # first format the ost/mdt
705 check_mount || return 43
707 remount_client ro $MOUNT || return 44
708 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
709 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
710 remount_client rw $MOUNT || return 47
712 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
713 MCNT=`grep -c $MOUNT /etc/mtab`
714 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
719 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
724 wait_osc_import_state mds ost FULL
728 run_test 21a "start mds before ost, stop ost first"
731 [ "$(facet_fstype ost1)" = "zfs" ] &&
732 skip "LU-2059: no local config for ZFS OSTs" && return
736 wait_osc_import_state mds ost FULL
740 run_test 21b "start ost before mds, stop mds first"
746 wait_osc_import_state mds ost2 FULL
750 #writeconf to remove all ost2 traces for subsequent tests
751 writeconf_or_reformat
753 run_test 21c "start mds between two osts, stop mds last"
756 if combined_mgs_mds ; then
757 skip "need separate mgs device" && return 0
767 wait_osc_import_state mds ost2 FULL
773 #writeconf to remove all ost2 traces for subsequent tests
774 writeconf_or_reformat
777 run_test 21d "start mgs then ost and then mds"
784 echo Client mount with ost in logs, but none running
786 # wait until mds connected to ost and open client connection
787 for num in $(seq 1 $MDSCOUNT); do
788 wait_osc_import_state mds${num} ost FULL
792 # check_mount will block trying to contact ost
793 mcreate $DIR/$tfile || return 40
794 rm -f $DIR/$tfile || return 42
798 echo Client mount with a running ost
801 # if gss enabled, wait full time to let connection from
802 # mds to ost be established, due to the mismatch between
803 # initial connect timeout and gss context negotiation timeout.
804 # This perhaps could be remove after AT landed.
805 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
806 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
809 for num in $(seq 1 $MDSCOUNT); do
810 wait_osc_import_state mds${num} ost FULL
812 wait_osc_import_state client ost FULL
813 check_mount || return 41
818 run_test 22 "start a client before osts (should return errs)"
820 test_23a() { # was test_23
824 # force down client so that recovering mds waits for reconnect
825 local running=$(grep -c $MOUNT /proc/mounts) || true
826 if [ $running -ne 0 ]; then
827 echo "Stopping client $MOUNT (opts: -f)"
831 # enter recovery on mds
833 # try to start a new client
834 mount_client $MOUNT &
836 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
837 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
838 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
840 ps --ppid $MOUNT_LUSTRE_PID
841 echo "waiting for mount to finish"
843 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
844 # SIGTERM works but it does not spread to offspring processses
845 kill -s TERM $MOUNT_PID
846 kill -s TERM $MOUNT_LUSTRE_PID
847 # we can not wait $MOUNT_PID because it is not a child of this shell
853 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
855 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
856 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
859 [ -z "$PID1" -a -z "$PID2" ] && break
860 echo "waiting for mount to finish ... "
861 WAIT=$(( WAIT + sleep))
863 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
864 error "MOUNT_PID $MOUNT_PID and "\
865 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
871 run_test 23a "interrupt client during recovery mount delay"
876 test_23b() { # was test_23
879 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
880 lctl set_param fail_loc=0x80000313
884 run_test 23b "Simulate -EINTR during mount"
886 fs2mds_HOST=$mds_HOST
887 fs2ost_HOST=$ost_HOST
889 MDSDEV1_2=$fs2mds_DEV
890 OSTDEV1_2=$fs2ost_DEV
891 OSTDEV2_2=$fs3ost_DEV
895 echo "umount $MOUNT2 ..."
896 umount $MOUNT2 || true
897 echo "stopping fs2mds ..."
898 stop fs2mds -f || true
899 echo "stopping fs2ost ..."
900 stop fs2ost -f || true
904 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
906 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
907 is_blkdev $SINGLEMDS $MDSDEV && \
908 skip_env "mixed loopback and real device not working" && return
911 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
913 local fs2mdsdev=$(mdsdevname 1_2)
914 local fs2ostdev=$(ostdevname 1_2)
915 local fs2mdsvdev=$(mdsvdevname 1_2)
916 local fs2ostvdev=$(ostvdevname 1_2)
918 # test 8-char fsname as well
919 local FSNAME2=test1234
921 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
922 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
924 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
925 --reformat $fs2ostdev $fs2ostvdev || exit 10
928 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
929 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
931 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
933 check_mount || return 2
934 # files written on 1 should not show up on 2
935 cp /etc/passwd $DIR/$tfile
937 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
940 cp /etc/passwd $MOUNT2/b || return 3
941 rm $MOUNT2/b || return 4
942 # 2 is actually mounted
943 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
945 facet_failover fs2mds
946 facet_failover fs2ost
949 # the MDS must remain up until last MDT
951 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
952 [ -z "$MDS" ] && error "No MDT" && return 8
954 cleanup_nocli || return 6
956 run_test 24a "Multiple MDTs on a single node"
959 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
961 if [ -z "$fs2mds_DEV" ]; then
962 local dev=${SINGLEMDS}_dev
964 is_blkdev $SINGLEMDS $MDSDEV && \
965 skip_env "mixed loopback and real device not working" && return
968 local fs2mdsdev=$(mdsdevname 1_2)
969 local fs2mdsvdev=$(mdsvdevname 1_2)
971 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
972 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
974 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
977 run_test 24b "Multiple MGSs on a single node (should return err)"
981 check_mount || return 2
982 local MODULES=$($LCTL modules | awk '{ print $2 }')
983 rmmod $MODULES 2>/dev/null || true
986 run_test 25 "Verify modules are referenced"
990 # we need modules before mount for sysctl, so make sure...
991 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
992 #define OBD_FAIL_MDS_FS_SETUP 0x135
993 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
994 start_mds && echo MDS started && return 1
995 lctl get_param -n devices
996 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
997 [ $DEVS -gt 0 ] && return 2
998 # start mds to drop writeconf setting
999 start_mds || return 3
1000 stop_mds || return 4
1001 unload_modules_conf || return $?
1003 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1006 [ "$(facet_fstype ost1)" = "zfs" ] &&
1007 skip "LU-2059: no local config for ZFS OSTs" && return
1009 start_ost || return 1
1010 start_mds || return 2
1011 echo "Requeue thread should have started: "
1012 ps -e | grep ll_cfg_requeue
1013 set_conf_param_and_check ost1 \
1014 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1015 "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
1018 run_test 27a "Reacquire MGS lock if OST started first"
1023 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1024 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1026 facet_failover $SINGLEMDS
1027 set_conf_param_and_check $SINGLEMDS \
1028 "lctl get_param -n mdt.$device.identity_acquire_expire" \
1029 "$device.mdt.identity_acquire_expire" || return 3
1030 set_conf_param_and_check client \
1031 "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight"\
1032 "$device.mdc.max_rpcs_in_flight" || return 4
1036 run_test 27b "Reacquire MGS lock after failover"
1040 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1041 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1043 FINAL=$(($ORIG + 1))
1044 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL || return 3
1045 FINAL=$(($FINAL + 1))
1046 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL || return 4
1047 umount_client $MOUNT || return 200
1050 if [ $RESULT -ne $FINAL ]; then
1051 echo "New config not seen: wanted $FINAL got $RESULT"
1054 echo "New config success: got $RESULT"
1056 set_conf_param_and_check client "$TEST" "$PARAM" $ORIG || return 5
1059 run_test 28 "permanent parameter setting"
1062 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1063 setup > /dev/null 2>&1
1067 local PARAM="$FSNAME-OST0001.osc.active"
1068 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1069 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1071 ACTV=$(lctl get_param -n $PROC_ACT)
1073 set_conf_param_and_check client \
1074 "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1075 # also check ost_server_uuid status
1076 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1077 if [ -z "$RESULT" ]; then
1078 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1081 echo "Live client success: got $RESULT"
1085 for num in $(seq $MDSCOUNT); do
1086 local mdtosc=$(get_mdtosc_proc_path mds${num} $FSNAME-OST0001)
1087 local MPROC="osc.$mdtosc.active"
1092 RESULT=$(do_facet mds${num} " lctl get_param -n $MPROC")
1093 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1094 if [ $RESULT -eq $DEAC ]; then
1095 echo -n "MDT deactivated also after"
1096 echo "$WAIT sec (got $RESULT)"
1100 if [ $WAIT -eq $MAX ]; then
1101 echo -n "MDT not deactivated: wanted $DEAC"
1105 echo "Waiting $(($MAX - $WAIT))secs for MDT deactivated"
1108 # test new client starts deactivated
1109 umount_client $MOUNT || return 200
1111 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1112 if [ -z "$RESULT" ]; then
1113 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1116 echo "New client success: got $RESULT"
1119 # make sure it reactivates
1120 set_conf_param_and_check client \
1121 "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1123 umount_client $MOUNT
1126 #writeconf to remove all ost2 traces for subsequent tests
1127 writeconf_or_reformat
1129 run_test 29 "permanently remove an OST"
1134 echo Big config llog
1135 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1137 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1138 for i in ${LIST[@]}; do
1139 set_conf_param_and_check client "$TEST" \
1140 "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1142 # make sure client restart still works
1143 umount_client $MOUNT
1144 mount_client $MOUNT || return 4
1145 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1148 echo Erase parameter setting
1149 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1150 umount_client $MOUNT
1151 mount_client $MOUNT || return 6
1153 echo "deleted (default) value=$FINAL, orig=$ORIG"
1154 # assumes this parameter started at the default value
1155 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1159 run_test 30a "Big config llog and conf_param deletion"
1164 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1165 # numerical part of it. Hopefully that's not already a failover address for
1167 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1168 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1169 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1170 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1171 echo "Using fake nid $NEW"
1173 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1174 set_conf_param_and_check client "$TEST" \
1175 "$FSNAME-OST0000.failover.node" $NEW ||
1176 error "didn't add failover nid $NEW"
1177 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1179 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1180 echo "should have 2 failover nids: $NIDCOUNT"
1181 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1182 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1183 umount_client $MOUNT
1184 mount_client $MOUNT || return 3
1186 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1188 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1189 echo "only 1 final nid should remain: $NIDCOUNT"
1190 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1194 run_test 30b "Remove failover nids"
1196 test_31() { # bug 10734
1197 # ipaddr must not exist
1198 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1201 run_test 31 "Connect to non-existent node (shouldn't crash)"
1204 # This is not really a test but a tool to create new disk
1205 # image tarballs for the upgrade tests.
1207 # Disk image tarballs should be created on single-node
1208 # clusters by running this test with default configurations
1209 # plus a few mandatory environment settings that are verified
1210 # at the beginning of the test.
1212 test_32newtarball() {
1216 local tmp=$TMP/t32_image_create
1218 if [ $FSNAME != t32fs -o $MDSCOUNT -ne 1 -o \
1219 \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o $OSTCOUNT -ne 1 -o \
1220 -z "$OSTDEV1" ]; then
1221 error "Needs FSNAME=t32fs MDSCOUNT=1 MDSDEV1=<nonexistent_file>" \
1222 "(or MDSDEV, in the case of b1_8) OSTCOUNT=1" \
1223 "OSTDEV1=<nonexistent_file>"
1227 echo "Found stale $tmp"
1232 tar cf - -C $src . | tar xf - -C $tmp/src
1237 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1244 ls -Rni --time-style=+%s >$tmp/img/list
1245 find . ! -name .lustre -type f -exec sha1sum {} \; |
1246 sort -k 2 >$tmp/img/sha1sums
1248 $LCTL get_param -n version | head -n 1 |
1249 sed -e 's/^lustre: *//' >$tmp/img/commit
1253 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1256 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1257 echo "Data verification failed"
1260 uname -r >$tmp/img/kernel
1261 uname -m >$tmp/img/arch
1263 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1264 mv $OSTDEV1 $tmp/img
1266 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1267 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1270 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1275 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1278 # The list of applicable tarballs is returned via the caller's
1279 # variable "tarballs".
1282 local node=$(facet_active_host $SINGLEMDS)
1283 local r="do_node $node"
1285 if [ "$CLIENTONLY" ]; then
1286 skip "Client-only testing"
1290 if ! $r which $TUNEFS; then
1291 skip_env "tunefs.lustre required on $node"
1295 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1296 skip "LU-2200: Test cannot run over Infiniband"
1300 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1302 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 -name \'disk*-$IMGTYPE.tar.bz2\')
1304 if [ -z "$tarballs" ]; then
1305 skip "No applicable tarballs found"
1310 t32_test_cleanup() {
1311 local node=$(facet_active_host $SINGLEMDS)
1312 local r="do_node $node"
1316 if $shall_cleanup_lustre; then
1317 umount $tmp/mnt/lustre || rc=$?
1319 if $shall_cleanup_mdt; then
1320 $r umount -d $tmp/mnt/mdt || rc=$?
1322 if $shall_cleanup_mdt1; then
1323 $r umount -d $tmp/mnt/mdt1 || rc=$?
1325 if $shall_cleanup_ost; then
1326 $r umount -d $tmp/mnt/ost || rc=$?
1328 $r rm -rf $tmp || rc=$?
1329 rm -rf $tmp || rc=$?
1333 t32_bits_per_long() {
1335 # Yes, this is not meant to be perfect.
1345 t32_reload_modules() {
1347 local all_removed=false
1350 while ((i < 20)); do
1351 echo "Unloading modules on $node: Attempt $i"
1352 do_rpc_nodes $node $LUSTRE_RMMOD $(facet_fstype $SINGLEMDS) &&
1354 do_rpc_nodes $node check_mem_leak || return 1
1355 if $all_removed; then
1362 echo "Unloading modules on $node: Given up"
1366 t32_wait_til_devices_gone() {
1371 echo wait for devices to go
1372 while ((i < 20)); do
1373 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1375 ((devices == 0)) && return 1
1379 echo "waiting for devices on $node: Given up"
1386 local dne_upgrade=${dne_upgrade:-"no"}
1387 local shall_cleanup_mdt=false
1388 local shall_cleanup_mdt1=false
1389 local shall_cleanup_ost=false
1390 local shall_cleanup_lustre=false
1391 local node=$(facet_active_host $SINGLEMDS)
1392 local r="do_node $node"
1393 local node2=$(facet_active_host mds2)
1394 local r2="do_node $node2"
1400 local nid=$($r $LCTL list_nids | head -1)
1407 trap 'trap - RETURN; t32_test_cleanup' RETURN
1409 mkdir -p $tmp/mnt/lustre
1410 $r mkdir -p $tmp/mnt/{mdt,ost}
1411 $r tar xjvf $tarball -S -C $tmp || {
1412 error_noexit "Unpacking the disk image tarball"
1415 img_commit=$($r cat $tmp/commit)
1416 img_kernel=$($r cat $tmp/kernel)
1417 img_arch=$($r cat $tmp/arch)
1418 echo "Upgrading from $(basename $tarball), created with:"
1419 echo " Commit: $img_commit"
1420 echo " Kernel: $img_kernel"
1421 echo " Arch: $img_arch"
1423 $r $LCTL set_param debug="$PTLDEBUG"
1425 $r $TUNEFS --dryrun $tmp/mdt || {
1426 error_noexit "tunefs.lustre before mounting the MDT"
1429 if [ "$writeconf" ]; then
1430 mopts=loop,writeconf
1432 mopts=loop,exclude=$fsname-OST0000
1435 t32_wait_til_devices_gone $node
1437 $r mount -t lustre -o $mopts $tmp/mdt $tmp/mnt/mdt || {
1438 error_noexit "Mounting the MDT"
1441 shall_cleanup_mdt=true
1443 if [ "$dne_upgrade" != "no" ]; then
1444 echo "mkfs new MDT...."
1445 add mds2 $(mkfs_opts mds2 $(mdsdevname 2) $fsname) --reformat \
1446 $(mdsdevname 2) $(mdsvdevname 2) > /dev/null || {
1447 error_noexit "Mkfs new MDT failed"
1451 $r2 $TUNEFS --dryrun $(mdsdevname 2) || {
1452 error_noexit "tunefs.lustre before mounting the MDT"
1456 echo "mount new MDT...."
1457 $r2 mkdir -p $tmp/mnt/mdt1
1458 $r2 mount -t lustre -o $mopts $(mdsdevname 2) $tmp/mnt/mdt1 || {
1459 error_noexit "mount mdt1 failed"
1462 shall_cleanup_mdt1=true
1465 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1466 error_noexit "Getting MDT UUID"
1469 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1470 error_noexit "Unexpected MDT UUID: \"$uuid\""
1474 $r $TUNEFS --dryrun $tmp/ost || {
1475 error_noexit "tunefs.lustre before mounting the OST"
1478 if [ "$writeconf" ]; then
1479 mopts=loop,mgsnode=$nid,$writeconf
1481 mopts=loop,mgsnode=$nid
1483 $r mount -t lustre -o $mopts $tmp/ost $tmp/mnt/ost || {
1484 error_noexit "Mounting the OST"
1487 shall_cleanup_ost=true
1489 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1490 error_noexit "Getting OST UUID"
1493 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1494 error_noexit "Unexpected OST UUID: \"$uuid\""
1498 $r $LCTL conf_param $fsname-OST0000.osc.max_dirty_mb=15 || {
1499 error_noexit "Setting \"max_dirty_mb\""
1502 $r $LCTL conf_param $fsname-OST0000.failover.node=$nid || {
1503 error_noexit "Setting OST \"failover.node\""
1506 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1507 error_noexit "Setting \"max_rpcs_in_flight\""
1510 $r $LCTL conf_param $fsname-MDT0000.failover.node=$nid || {
1511 error_noexit "Setting MDT \"failover.node\""
1514 $r $LCTL pool_new $fsname.interop || {
1515 error_noexit "Setting \"interop\""
1518 $r $LCTL conf_param $fsname-MDT0000.lov.stripesize=4M || {
1519 error_noexit "Setting \"lov.stripesize\""
1523 if [ "$dne_upgrade" != "no" ]; then
1524 $r2 $LCTL conf_param \
1525 $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
1526 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
1529 $r2 $LCTL conf_param $fsname-MDT0001.failover.node=$nid || {
1530 error_noexit "Setting MDT1 \"failover.node\""
1533 $r2 $LCTL conf_param $fsname-MDT0001.lov.stripesize=4M || {
1534 error_noexit "Setting MDT1 \"lov.stripesize\""
1540 if [ "$writeconf" ]; then
1541 mount -t lustre $nid:/$fsname $tmp/mnt/lustre || {
1542 error_noexit "Mounting the client"
1545 shall_cleanup_lustre=true
1546 $LCTL set_param debug="$PTLDEBUG"
1547 if [ "$dne_upgrade" != "no" ]; then
1548 $LFS mkdir -i 1 $tmp/mnt/lustre/remote_dir || {
1549 error_noexit "set remote dir failed"
1553 pushd $tmp/mnt/lustre
1554 tar -cf - . --exclude=./remote_dir |
1555 tar -xvf - -C remote_dir 1>/dev/null || {
1556 error_noexit "cp to remote dir failed"
1562 if $r test -f $tmp/sha1sums; then
1563 # LU-2393 - do both sorts on same node to ensure locale
1565 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
1566 if [ "$dne_upgrade" != "no" ]; then
1567 pushd $tmp/mnt/lustre/remote_dir
1569 pushd $tmp/mnt/lustre
1572 find ! -name .lustre -type f -exec sha1sum {} \; |
1573 sort -k 2 >$tmp/sha1sums || {
1574 error_noexit "sha1sum"
1578 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
1579 error_noexit "sha1sum verification failed"
1583 echo "sha1sum verification skipped"
1586 if [ "$dne_upgrade" != "no" ]; then
1587 rm -rf $tmp/mnt/lustre/remote_dir || {
1588 error_noexit "remove remote dir failed"
1593 if $r test -f $tmp/list; then
1595 # There is not a Test Framework API to copy files to or
1596 # from a remote node.
1598 # LU-2393 - do both sorts on same node to ensure locale
1600 $r cat $tmp/list | sort -k 6 >$tmp/list.orig
1601 pushd $tmp/mnt/lustre
1602 ls -Rni --time-style=+%s | sort -k 6 >$tmp/list || {
1608 # 32-bit and 64-bit clients use different algorithms to
1609 # convert FIDs into inode numbers. Hence, remove the inode
1610 # numbers from the lists, if the original list was created
1611 # on an architecture with different number of bits per
1614 if [ $(t32_bits_per_long $(uname -m)) != \
1615 $(t32_bits_per_long $img_arch) ]; then
1616 echo "Different number of bits per \"long\" from the disk image"
1617 for list in list.orig list; do
1618 sed -i -e 's/^[0-9]\+[ \t]\+//' $tmp/$list
1621 if ! diff -ub $tmp/list.orig $tmp/list; then
1622 error_noexit "list verification failed"
1626 echo "list verification skipped"
1630 # When adding new data verification tests, please check for
1631 # the presence of the required reference files first, like
1632 # the "sha1sums" and "list" tests above, to avoid the need to
1633 # regenerate every image for each test addition.
1636 nrpcs_orig=$($LCTL get_param \
1637 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
1638 error_noexit "Getting \"max_rpcs_in_flight\""
1641 nrpcs=$((nrpcs_orig + 5))
1642 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=$nrpcs || {
1643 error_noexit "Changing \"max_rpcs_in_flight\""
1646 wait_update $HOSTNAME "$LCTL get_param \
1647 -n mdc.*MDT0000*.max_rpcs_in_flight" $nrpcs || {
1648 error_noexit "Verifying \"max_rpcs_in_flight\""
1652 umount $tmp/mnt/lustre || {
1653 error_noexit "Unmounting the client"
1656 shall_cleanup_lustre=false
1658 $r umount -d $tmp/mnt/mdt || {
1659 error_noexit "Unmounting the MDT"
1662 shall_cleanup_mdt=false
1663 $r umount -d $tmp/mnt/ost || {
1664 error_noexit "Unmounting the OST"
1667 shall_cleanup_ost=false
1669 t32_reload_modules $node || {
1670 error_noexit "Reloading modules"
1674 # mount a second time to make sure we didnt leave upgrade flag on
1675 $r $TUNEFS --dryrun $tmp/mdt || {
1676 error_noexit "tunefs.lustre before remounting the MDT"
1679 $r mount -t lustre -o loop,exclude=$fsname-OST0000 $tmp/mdt \
1681 error_noexit "Remounting the MDT"
1684 shall_cleanup_mdt=true
1694 for tarball in $tarballs; do
1695 t32_test $tarball || rc=$?
1699 run_test 32a "Upgrade (not live)"
1707 for tarball in $tarballs; do
1708 t32_test $tarball writeconf || rc=$?
1712 run_test 32b "Upgrade with writeconf"
1719 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1721 for tarball in $tarballs; do
1722 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
1726 run_test 32c "dne upgrade test"
1728 test_33a() { # bug 12333, was test_33
1730 local FSNAME2=test-123
1731 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1734 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1736 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1737 local dev=${SINGLEMDS}_dev
1738 local MDSDEV=${!dev}
1739 is_blkdev $SINGLEMDS $MDSDEV && \
1740 skip_env "mixed loopback and real device not working" && return
1743 local fs2mdsdev=$(mdsdevname 1_2)
1744 local fs2ostdev=$(ostdevname 1_2)
1745 local fs2mdsvdev=$(mdsvdevname 1_2)
1746 local fs2ostvdev=$(ostvdevname 1_2)
1748 if [ $(facet_fstype mds1) == ldiskfs ]; then
1749 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
1752 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
1753 --reformat $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
1754 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
1755 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
1756 $fs2ostvdev || exit 10
1758 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1759 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1760 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1762 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1765 cp /etc/hosts $MOUNT2/ || rc=3
1766 $LFS getstripe $MOUNT2/hosts
1771 cleanup_nocli || rc=6
1774 run_test 33a "Mount ost with a large index number"
1776 test_33b() { # was test_34
1779 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1780 # Drop lock cancelation reply during umount
1781 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
1782 do_facet client lctl set_param fail_loc=0x80000304
1783 #lctl set_param debug=-1
1784 umount_client $MOUNT
1787 run_test 33b "Drop cancel during umount"
1791 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1792 manual_umount_client
1794 do_facet client killall -USR1 multiop
1795 if [ $rc -eq 0 ]; then
1796 error "umount not fail!"
1801 run_test 34a "umount with opened file should be fail"
1806 touch $DIR/$tfile || return 1
1807 stop_mds --force || return 2
1809 manual_umount_client --force
1811 if [ $rc -ne 0 ]; then
1812 error "mtab after failed umount - rc $rc"
1818 run_test 34b "force umount with failed mds should be normal"
1822 touch $DIR/$tfile || return 1
1823 stop_ost --force || return 2
1825 manual_umount_client --force
1827 if [ $rc -ne 0 ]; then
1828 error "mtab after failed umount - rc $rc"
1834 run_test 34c "force umount with failed ost should be normal"
1836 test_35a() { # bug 12459
1839 DBG_SAVE="`lctl get_param -n debug`"
1840 lctl set_param debug="ha"
1842 log "Set up a fake failnode for the MDS"
1844 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1845 do_facet mgs "$LCTL conf_param ${device}.failover.node=" \
1846 "$(h2$NETTYPE $FAKENID)" || return 4
1848 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1851 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1854 log "Stopping the MDT: $device"
1855 stop_mdt 1 || return 5
1857 df $MOUNT > /dev/null 2>&1 &
1859 log "Restarting the MDT: $device"
1860 start_mdt 1 || return 6
1861 log "Wait for df ($DFPID) ... "
1864 lctl set_param debug="$DBG_SAVE"
1866 # retrieve from the log the first server that the client tried to
1867 # contact after the connection loss
1868 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1869 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1870 /import_select_connection.*$device-mdc.* using connection/ {
1872 if (\\\$NF ~ /$FAKENID/)
1878 }" $TMP/lustre-log-$TESTNAME.log`
1879 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1881 # remove nid settings
1882 writeconf_or_reformat
1884 run_test 35a "Reconnect to the last active server first"
1886 test_35b() { # bug 18674
1887 remote_mds || { skip "local MDS" && return 0; }
1891 $LCTL set_param debug="ha"
1893 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1896 log "Set up a fake failnode for the MDS"
1898 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | \
1899 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1900 do_facet mgs "$LCTL conf_param ${device}.failover.node=" \
1901 "$(h2$NETTYPE $FAKENID)" || return 1
1903 local at_max_saved=0
1904 # adaptive timeouts may prevent seeing the issue
1905 if at_is_enabled; then
1906 at_max_saved=$(at_max_get mds)
1907 at_max_set 0 mds client
1910 mkdir -p $MOUNT/$tdir
1912 log "Injecting EBUSY on MDS"
1913 # Setting OBD_FAIL_MDS_RESEND=0x136
1914 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
1916 $LCTL set_param mdc.${FSNAME}*.stats=clear
1918 log "Creating a test file and stat it"
1919 touch $MOUNT/$tdir/$tfile
1920 stat $MOUNT/$tdir/$tfile
1922 log "Stop injecting EBUSY on MDS"
1923 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
1924 rm -f $MOUNT/$tdir/$tfile
1927 # restore adaptive timeout
1928 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1930 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1932 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
1934 # retrieve from the log if the client has ever tried to
1935 # contact the fake server after the loss of connection
1936 FAILCONN=`awk "BEGIN {ret = 0;}
1937 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1939 if (\\\$NF ~ /$FAKENID/) {
1944 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1946 [ "$FAILCONN" == "0" ] && \
1947 log "ERROR: The client reconnection has not been triggered" && \
1949 [ "$FAILCONN" == "2" ] && \
1950 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1954 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
1955 # Reconnects are supposed to be rate limited to one every 5s
1956 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
1957 log "ERROR: Too many reconnects $CONNCNT" && \
1961 # remove nid settings
1962 writeconf_or_reformat
1964 run_test 35b "Continue reconnection retries, if the active server is busy"
1967 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1969 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1970 { skip "remote OST" && return 0; }
1973 local FSNAME2=test1234
1974 local fs3ost_HOST=$ost_HOST
1975 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1977 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1979 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1980 is_blkdev $SINGLEMDS $MDSDEV && \
1981 skip_env "mixed loopback and real device not working" && return
1984 local fs2mdsdev=$(mdsdevname 1_2)
1985 local fs2ostdev=$(ostdevname 1_2)
1986 local fs3ostdev=$(ostdevname 2_2)
1987 local fs2mdsvdev=$(mdsvdevname 1_2)
1988 local fs2ostvdev=$(ostvdevname 1_2)
1989 local fs3ostvdev=$(ostvdevname 2_2)
1991 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
1992 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1993 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
1994 # different one than the default value here.
1995 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
1996 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
1997 add fs3ost $(mkfs_opts ost1 ${fs3ostdev}) --mgsnode=$MGSNID \
1998 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2000 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2001 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2002 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2004 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
2006 sleep 5 # until 11778 fixed
2008 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
2010 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
2011 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
2012 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
2013 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
2014 DFTOTAL=`echo $STRING | cut -d, -f1`
2015 DFUSED=`echo $STRING | cut -d, -f2`
2016 DFAVAIL=`echo $STRING | cut -d, -f3`
2017 DFFREE=$(($DFTOTAL - $DFUSED))
2019 ALLOWANCE=$((64 * $OSTCOUNT))
2021 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2022 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2023 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2026 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2027 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2028 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2031 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2032 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2033 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2038 stop fs3ost -f || return 200
2039 stop fs2ost -f || return 201
2040 stop fs2mds -f || return 202
2041 unload_modules_conf || return 203
2044 run_test 36 "df report consistency on OSTs with different block size"
2047 local mntpt=$(facet_mntpt $SINGLEMDS)
2048 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2049 local mdsdev_sym="$TMP/sym_mdt.img"
2050 local opts=$MDS_MOUNT_OPTS
2053 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2054 skip "Currently only applicable to ldiskfs-based MDTs"
2058 echo "MDS : $mdsdev"
2059 echo "SYMLINK : $mdsdev_sym"
2060 do_facet $SINGLEMDS rm -f $mdsdev_sym
2062 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2064 echo "mount symlink device - $mdsdev_sym"
2066 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2067 opts=$(csa_add "$opts" -o loop)
2069 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2070 $mdsdev_sym $mntpt 2>&1)
2073 echo mount_op=$mount_op
2075 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
2077 if $(echo $mount_op | grep -q "unable to set tunable"); then
2078 error "set tunables failed for symlink device"
2081 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2085 run_test 37 "verify set tunables works for symlink device"
2087 test_38() { # bug 14222
2088 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2089 skip "Only applicable to ldiskfs-based MDTs"
2097 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
2098 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2100 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
2101 error "copying $SRC to $DIR/$tdir"
2103 umount_client $MOUNT
2105 log "rename lov_objid file on MDS"
2106 rm -f $TMP/lov_objid.orig
2108 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2109 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
2110 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
2112 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
2113 # check create in mds_lov_connect
2117 [ $V ] && log "verifying $DIR/$tdir/$f"
2118 diff -q $f $DIR/$tdir/$f || ERROR=y
2120 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
2121 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
2122 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
2124 # check it's updates in sync
2125 umount_client $MOUNT
2128 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
2129 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
2130 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
2135 [ $V ] && log "verifying $DIR/$tdir/$f"
2136 diff -q $f $DIR/$tdir/$f || ERROR=y
2138 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
2139 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
2140 umount_client $MOUNT
2142 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
2144 log "files compared the same"
2147 run_test 38 "MDS recreates missing lov_objid file from OST data"
2153 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2154 error "memory leak detected" || true
2156 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2158 test_40() { # bug 15759
2160 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2161 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2165 run_test 40 "race during service thread startup"
2167 test_41a() { #bug 14134
2168 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2169 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2170 skip "Loop devices does not work with nosvc option"
2175 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2177 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2178 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
2179 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2181 mount_client $MOUNT || return 1
2184 echo "blah blah" > $MOUNT/$tfile
2187 umount_client $MOUNT
2188 stop ost1 -f || return 201
2189 stop_mds -f || return 202
2190 stop_mds -f || return 203
2191 unload_modules_conf || return 204
2194 run_test 41a "mount mds with --nosvc and --nomgs"
2197 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2198 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2199 skip "Loop devices does not work with nosvc option"
2203 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2207 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2209 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2211 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2213 mount_client $MOUNT || return 1
2216 echo "blah blah" > $MOUNT/$tfile
2217 cat $MOUNT/$tfile || return 200
2219 umount_client $MOUNT
2220 stop_ost || return 201
2221 stop_mds -f || return 202
2222 stop_mds -f || return 203
2225 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2227 test_42() { #bug 14693
2229 check_mount || return 2
2230 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
2231 umount_client $MOUNT
2232 mount_client $MOUNT || return 1
2236 run_test 42 "invalid config param should not prevent client from mounting"
2239 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
2241 chmod ugo+x $DIR || error "chmod 0 failed"
2242 set_conf_param_and_check mds \
2243 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2244 "$FSNAME.mdt.root_squash" \
2246 set_conf_param_and_check mds \
2247 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2248 "$FSNAME.mdt.nosquash_nids" \
2252 # create set of test files
2254 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
2255 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
2256 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
2258 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
2259 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
2261 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
2262 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
2263 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
2266 # check root_squash:
2267 # set root squash UID:GID to RUNAS_ID
2268 # root should be able to access only files owned by RUNAS_ID
2270 set_conf_param_and_check mds \
2271 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2272 "$FSNAME.mdt.root_squash" \
2273 "$RUNAS_ID:$RUNAS_ID"
2275 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
2276 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
2277 error "$ST: root read permission is denied"
2278 echo "$ST: root read permission is granted - ok"
2281 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
2282 error "$ST: root write permission is denied"
2283 echo "$ST: root write permission is granted - ok"
2285 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2286 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
2287 error "$ST: root read permission is granted"
2288 echo "$ST: root read permission is denied - ok"
2291 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
2292 error "$ST: root write permission is granted"
2293 echo "$ST: root write permission is denied - ok"
2295 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2296 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
2297 error "$ST: root unlink permission is granted"
2298 echo "$ST: root unlink permission is denied - ok"
2300 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
2301 error "$ST: root create permission is granted"
2302 echo "$ST: root create permission is denied - ok"
2305 # check nosquash_nids:
2306 # put client's NID into nosquash_nids list,
2307 # root should be able to access root file after that
2309 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
2310 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
2311 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
2312 set_conf_param_and_check mds \
2313 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2314 "$FSNAME-MDTall.mdt.nosquash_nids" \
2317 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2318 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
2319 error "$ST: root read permission is denied"
2320 echo "$ST: root read permission is granted - ok"
2323 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
2324 error "$ST: root write permission is denied"
2325 echo "$ST: root write permission is granted - ok"
2327 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2328 rm $DIR/$tdir-rootdir/tfile-1 || \
2329 error "$ST: root unlink permission is denied"
2330 echo "$ST: root unlink permission is granted - ok"
2331 touch $DIR/$tdir-rootdir/tfile-2 || \
2332 error "$ST: root create permission is denied"
2333 echo "$ST: root create permission is granted - ok"
2337 run_test 43 "check root_squash and nosquash_nids"
2339 umount_client $MOUNT
2344 check_mount || return 2
2345 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
2347 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
2348 for VAL in $UUIDS; do
2349 NID=$(echo $VAL | cut -d= -f1)
2350 CLUUID=$(echo $VAL | cut -d= -f2)
2351 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
2353 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
2357 run_test 44 "mounted client proc entry exists"
2361 check_mount || return 2
2366 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
2367 do_facet client "lctl set_param fail_loc=0x50f"
2370 manual_umount_client --force || return 3
2371 do_facet client "lctl set_param fail_loc=0x0"
2373 mount_client $MOUNT || return 4
2377 run_test 45 "long unlink handling in ptlrpcd"
2384 umount_client $MOUNT2 || rc=$?
2385 umount_client $MOUNT || rc=$?
2386 while [ $count -gt 0 ]; do
2387 stop ost${count} -f || rc=$?
2391 cleanup_nocli || rc=$?
2392 #writeconf to remove all ost2 traces for subsequent tests
2393 writeconf_or_reformat
2398 echo "Testing with $OSTCOUNT OSTs"
2400 start_mds || return 1
2401 #first client should see only one ost
2402 start_ost || return 2
2403 wait_osc_import_state mds ost FULL
2405 mount_client $MOUNT || return 3
2406 trap "cleanup_46a $OSTCOUNT" EXIT ERR
2409 for (( i=2; i<=$OSTCOUNT; i++ )); do
2410 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
2413 # wait until osts in sync
2414 for (( i=2; i<=$OSTCOUNT; i++ )); do
2415 wait_osc_import_state mds ost$i FULL
2416 wait_osc_import_state client ost$i FULL
2419 #second client see all ost's
2421 mount_client $MOUNT2 || return 8
2422 $LFS setstripe -c -1 $MOUNT2 || return 9
2423 $LFS getstripe $MOUNT2 || return 10
2425 echo "ok" > $MOUNT2/widestripe
2426 $LFS getstripe $MOUNT2/widestripe || return 11
2427 # fill acl buffer for avoid expand lsm to them
2428 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
2429 setfacl -m $acl $MOUNT2/widestripe
2433 stat $MOUNT/widestripe || return 12
2435 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
2438 run_test 46a "handle ost additional - wide striped file"
2443 check_mount || return 2
2444 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2448 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2449 if echo $ns | grep "MDT[[:digit:]]*"; then
2452 lrs=$(echo $ns | sed 's/.*lru_size=//')
2453 lru_size[count]=$lrs
2458 facet_failover $SINGLEMDS
2459 client_up || return 3
2462 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2463 if echo $ns | grep "MDT[[:digit:]]*"; then
2466 lrs=$(echo $ns | sed 's/.*lru_size=//')
2467 if ! test "$lrs" -eq "${lru_size[count]}"; then
2468 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2469 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2477 run_test 47 "server restart does not make client loss lru_resize settings"
2482 # reformat after this test is needed - if test will failed
2483 # we will have unkillable file at FS
2487 test_48() { # bug 17636
2490 check_mount || return 2
2492 $LFS setstripe -c -1 $MOUNT || return 9
2493 $LFS getstripe $MOUNT || return 10
2495 echo "ok" > $MOUNT/widestripe
2496 $LFS getstripe $MOUNT/widestripe || return 11
2498 trap cleanup_48 EXIT ERR
2500 # fill acl buffer for avoid expand lsm to them
2501 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2502 setfacl -m $acl $MOUNT/widestripe
2505 stat $MOUNT/widestripe || return 12
2510 run_test 48 "too many acls on file"
2512 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2513 test_49() { # bug 17710
2514 local timeout_orig=$TIMEOUT
2515 local ldlm_timeout_orig=$LDLM_TIMEOUT
2516 local LOCAL_TIMEOUT=20
2518 LDLM_TIMEOUT=$LOCAL_TIMEOUT
2519 TIMEOUT=$LOCAL_TIMEOUT
2523 check_mount || return 1
2525 echo "check ldlm_timout..."
2526 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2527 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2528 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2530 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2531 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2534 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2535 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2538 umount_client $MOUNT
2539 stop_ost || return 2
2540 stop_mds || return 3
2542 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
2546 check_mount || return 7
2548 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2549 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2550 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2552 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2553 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2556 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2557 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2560 cleanup || return $?
2562 LDLM_TIMEOUT=$ldlm_timeout_orig
2563 TIMEOUT=$timeout_orig
2565 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
2568 # Test both statfs and lfs df and fail if either one fails
2569 multiop_bg_pause $1 f_
2572 killall -USR1 multiop
2573 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2574 wait $PID || { RC1=$?; log "multiop return error "; }
2581 if [ $RC2 -eq 0 ]; then
2583 log "lazystatfs df failed"
2587 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2593 lctl set_param llite.$FSNAME-*.lazystatfs=1
2596 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2598 cleanup || return $?
2600 run_test 50a "lazystatfs all servers available =========================="
2604 lctl set_param llite.$FSNAME-*.lazystatfs=1
2607 # Wait for client to detect down OST
2608 stop_ost || error "Unable to stop OST1"
2609 wait_osc_import_state mds ost DISCONN
2611 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2613 umount_client $MOUNT || error "Unable to unmount client"
2614 stop_mds || error "Unable to stop MDS"
2616 run_test 50b "lazystatfs all servers down =========================="
2619 start_mds || error "Unable to start MDS"
2620 start_ost || error "Unable to start OST1"
2621 start_ost2 || error "Unable to start OST2"
2622 mount_client $MOUNT || error "Unable to mount client"
2623 lctl set_param llite.$FSNAME-*.lazystatfs=1
2626 # Wait for client to detect down OST
2627 stop_ost || error "Unable to stop OST1"
2628 wait_osc_import_state mds ost DISCONN
2629 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2631 umount_client $MOUNT || error "Unable to unmount client"
2632 stop_ost2 || error "Unable to stop OST2"
2633 stop_mds || error "Unable to stop MDS"
2634 #writeconf to remove all ost2 traces for subsequent tests
2635 writeconf_or_reformat
2637 run_test 50c "lazystatfs one server down =========================="
2640 start_mds || error "Unable to start MDS"
2641 start_ost || error "Unable to start OST1"
2642 start_ost2 || error "Unable to start OST2"
2643 mount_client $MOUNT || error "Unable to mount client"
2644 lctl set_param llite.$FSNAME-*.lazystatfs=1
2647 # Issue the statfs during the window where the client still
2648 # belives the OST to be available but it is in fact down.
2649 # No failure just a statfs which hangs for a timeout interval.
2650 stop_ost || error "Unable to stop OST1"
2651 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2653 umount_client $MOUNT || error "Unable to unmount client"
2654 stop_ost2 || error "Unable to stop OST2"
2655 stop_mds || error "Unable to stop MDS"
2656 #writeconf to remove all ost2 traces for subsequent tests
2657 writeconf_or_reformat
2659 run_test 50d "lazystatfs client/server conn race =========================="
2666 start_mds || return 1
2667 #first client should see only one ost
2668 start_ost || return 2
2669 wait_osc_import_state mds ost FULL
2671 # Wait for client to detect down OST
2672 stop_ost || error "Unable to stop OST1"
2673 wait_osc_import_state mds ost DISCONN
2675 mount_client $MOUNT || error "Unable to mount client"
2676 lctl set_param llite.$FSNAME-*.lazystatfs=0
2678 multiop_bg_pause $MOUNT _f
2682 if [ $RC1 -ne 0 ]; then
2683 log "multiop failed $RC1"
2686 sleep $(( $TIMEOUT+1 ))
2688 [ $? -ne 0 ] && error "process isn't sleep"
2689 start_ost || error "Unable to start OST1"
2690 wait $pid || error "statfs failed"
2693 umount_client $MOUNT || error "Unable to unmount client"
2694 stop_ost || error "Unable to stop OST1"
2695 stop_mds || error "Unable to stop MDS"
2697 run_test 50e "normal statfs all servers down =========================="
2702 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2704 start_mds || error "Unable to start mds"
2705 #first client should see only one ost
2706 start_ost || error "Unable to start OST1"
2707 wait_osc_import_state mds ost FULL
2709 start_ost2 || error "Unable to start OST2"
2710 wait_osc_import_state mds ost2 FULL
2712 # Wait for client to detect down OST
2713 stop_ost2 || error "Unable to stop OST2"
2715 wait_osc_import_state mds ost2 DISCONN
2716 mount_client $MOUNT || error "Unable to mount client"
2717 lctl set_param llite.$FSNAME-*.lazystatfs=0
2719 multiop_bg_pause $MOUNT _f
2723 if [ $RC1 -ne 0 ]; then
2724 log "lazystatfs multiop failed $RC1"
2727 sleep $(( $TIMEOUT+1 ))
2729 [ $? -ne 0 ] && error "process isn't sleep"
2730 start_ost2 || error "Unable to start OST2"
2731 wait $pid || error "statfs failed"
2732 stop_ost2 || error "Unable to stop OST2"
2735 umount_client $MOUNT || error "Unable to unmount client"
2736 stop_ost || error "Unable to stop OST1"
2737 stop_mds || error "Unable to stop MDS"
2738 #writeconf to remove all ost2 traces for subsequent tests
2739 writeconf_or_reformat
2741 run_test 50f "normal statfs one server in down =========================="
2744 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2746 start_ost2 || error "Unable to start OST2"
2747 wait_osc_import_state mds ost2 FULL
2748 wait_osc_import_state client ost2 FULL
2750 local PARAM="${FSNAME}-OST0001.osc.active"
2752 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2753 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2755 umount_client $MOUNT || error "Unable to unmount client"
2756 mount_client $MOUNT || error "Unable to mount client"
2757 # This df should not cause a panic
2760 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2762 umount_client $MOUNT || error "Unable to unmount client"
2763 stop_ost2 || error "Unable to stop OST2"
2764 stop_ost || error "Unable to stop OST1"
2765 stop_mds || error "Unable to stop MDS"
2766 #writeconf to remove all ost2 traces for subsequent tests
2767 writeconf_or_reformat
2769 run_test 50g "deactivated OST should not cause panic====================="
2772 local LOCAL_TIMEOUT=20
2776 check_mount || return 1
2779 $LFS setstripe -c -1 $MOUNT/d1
2780 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2781 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2782 touch $MOUNT/d1/f1 &
2785 start_ost2 || return 2
2787 stop_ost2 || return 3
2789 #writeconf to remove all ost2 traces for subsequent tests
2790 writeconf_or_reformat
2792 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2801 do_node $node mkdir -p $dest
2802 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2804 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2805 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2806 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2808 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2809 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2819 local backup2=${TMP}/backup2
2821 do_node $node mkdir -p $backup2
2822 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2824 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2825 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2826 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2828 do_node $node "diff -rq $backup $backup2"
2829 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2831 local xattrs2=${TMP}/xattrs2
2832 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2833 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2835 do_node $node "diff $xattrs $xattrs2"
2836 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2838 do_node $node "rm -rf $backup2 $xattrs2"
2839 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2843 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2844 skip "Only applicable to ldiskfs-based MDTs"
2849 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2851 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2853 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2856 local ost1mnt=$(facet_mntpt ost1)
2857 local ost1node=$(facet_active_host ost1)
2858 local ost1tmp=$TMP/conf52
2862 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2863 touch $TMP/modified_first
2864 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2865 local mtime=$(stat -c %Y $TMP/modified_first)
2866 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2868 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2871 $LFS setstripe -c -1 -S 1M $DIR/$tdir
2872 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2874 for (( i=0; i < nrfiles; i++ )); do
2875 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2876 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2882 echo backup files to $TMP/files
2883 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2884 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2885 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2887 umount_client $MOUNT
2888 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2890 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2892 echo mount ost1 as ldiskfs
2893 do_node $ost1node mkdir -p $ost1mnt
2894 [ $? -eq 0 ] || { error "Unable to create $ost1mnt"; return 23; }
2895 if ! do_node $ost1node test -b $ost1_dev; then
2898 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
2900 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2903 echo backup objects to $ost1tmp/objects
2904 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
2905 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2906 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
2908 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2910 # move objects to lost+found
2911 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2912 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2915 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2916 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2918 # compare restored objects against saved ones
2919 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2920 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2922 do_node $ost1node "umount $ost1mnt"
2923 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2926 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2928 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2931 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2932 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2934 rm -rf $TMP/files $TMP/file_xattrs
2935 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2936 do_node $ost1node "rm -rf $ost1tmp"
2937 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2940 run_test 52 "check recovering objects from lost+found"
2942 # Checks threads_min/max/started for some service
2944 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2945 # parameter pattern prefix like 'ost.*.ost'.
2958 local msg="Insane $modname thread counts"
2959 local ncpts=$(check_cpt_number $facet)
2964 check_mount || return 41
2966 # We need to expand $parampat, but it may match multiple parameters, so
2967 # we'll pick the first one
2968 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2969 error "Couldn't expand ${parampat}.threads_min parameter name"
2973 # Remove the .threads_min part
2974 paramp=${paramp%.threads_min}
2976 # Check for sanity in defaults
2977 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2978 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2979 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2980 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2981 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
2982 nthrs=$(expr $tmax - $tmin)
2983 if [ $nthrs -lt $ncpts ]; then
2989 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
2990 skip_env "module parameter forced $facet thread count" &&
2991 tmin=3 && tmax=$((3 * tmax))
2993 # Check that we can change min/max
2994 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + nthrs))"
2995 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - nthrs))"
2996 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2997 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2998 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) && $tmax2 == ($tmax - $nthrs)))' || return $?
3000 # Check that we can set min/max to the same value
3001 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3002 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
3003 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3004 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3005 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
3007 # Check that we can't set max < min
3008 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
3009 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3010 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3011 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
3013 # We need to ensure that we get the module options desired; to do this
3014 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
3015 LOAD_MODULES_REMOTE=true
3018 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
3019 setmodopts -a $modname "$newvalue" oldvalue
3023 check_mount || return 41
3025 # Restore previous setting of MODOPTS_*
3026 setmodopts $modname "$oldvalue"
3028 # Check that $opts took
3029 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
3030 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
3031 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
3032 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
3041 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
3043 run_test 53a "check OSS thread count params"
3046 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' '16'
3048 run_test 53b "check MDT thread count params"
3051 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3052 skip "Only applicable to ldiskfs-based MDTs"
3056 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p
3057 [ $? -eq 0 ] || error "llverdev failed!"
3060 run_test 54a "test llverdev and partial verify of device"
3063 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3064 skip "Only applicable to ldiskfs-based MDTs"
3069 run_llverfs $MOUNT -p
3070 [ $? -eq 0 ] || error "llverfs failed!"
3073 run_test 54b "test llverfs and partial verify of filesystem"
3077 local max_ost_index=$1
3078 echo -n $(((max_ost_index + 1) * 8))
3082 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3083 skip "Only applicable to ldiskfs-based MDTs"
3087 local mdsdev=$(mdsdevname 1)
3088 local mdsvdev=$(mdsvdevname 1)
3092 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
3094 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
3095 --reformat $(ostdevname 1) $(ostvdevname 1)
3101 echo checking size of lov_objid for ost index $i
3102 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
3103 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
3104 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
3106 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
3113 run_test 55 "check lov_objid size"
3116 local mds_journal_size_orig=$MDSJOURNALSIZE
3120 for num in $(seq 1 $MDSCOUNT); do
3121 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3122 --reformat $(mdsdevname $num) $(mdsvdevname $num)
3124 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=1000 --reformat \
3125 $(ostdevname 1) $(ostvdevname 1)
3126 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=10000 --reformat \
3127 $(ostdevname 2) $(ostvdevname 2)
3131 start_ost2 || error "Unable to start second ost"
3132 mount_client $MOUNT || error "Unable to mount client"
3136 MDSJOURNALSIZE=$mds_journal_size_orig
3139 run_test 56 "check big indexes"
3141 test_57a() { # bug 22656
3142 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
3143 writeconf_or_reformat
3144 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
3146 start_ost && error "OST registration from failnode should fail"
3149 run_test 57a "initial registration from failnode should fail (should return errs)"
3152 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
3153 writeconf_or_reformat
3154 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
3156 start_ost || error "OST registration from servicenode should not fail"
3159 run_test 57b "initial registration from servicenode should not fail"
3162 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
3165 test_58() { # bug 22658
3166 if [ $(facet_fstype mds) != ldiskfs ]; then
3167 skip "Only applicable to ldiskfs-based MDTs"
3172 createmany -o $DIR/$tdir/$tfile-%d 100
3173 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
3174 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
3175 do_facet mds "lctl set_param fail_loc=0x601"
3176 unlinkmany $DIR/$tdir/$tfile-%d 100
3178 local MNTDIR=$(facet_mntpt mds)
3179 # remove all files from the OBJECTS dir
3180 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
3181 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
3182 do_facet mds "umount $MNTDIR"
3183 # restart MDS with missing llog files
3185 do_facet mds "lctl set_param fail_loc=0"
3188 run_test 58 "missing llog files must not prevent MDT from mounting"
3191 start_mgsmds >> /dev/null
3192 local C1=$(count_osts)
3193 if [ $C1 -eq 0 ]; then
3194 start_ost >> /dev/null
3198 echo "original ost count: $C1 (expect > 0)"
3199 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
3200 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
3201 local C2=$(count_osts)
3202 echo "after mdt writeconf count: $C2 (expect 0)"
3203 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
3204 echo "OST start without writeconf should fail:"
3205 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
3206 echo "OST start with writeconf should succeed:"
3207 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
3208 local C3=$(count_osts)
3209 echo "after ost writeconf count: $C3 (expect 1)"
3210 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
3211 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
3212 local C4=$(count_osts)
3213 echo "after ost2 writeconf count: $C4 (expect 2)"
3214 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
3215 stop_ost2 >> /dev/null
3216 cleanup_nocli >> /dev/null
3217 #writeconf to remove all ost2 traces for subsequent tests
3218 writeconf_or_reformat
3220 run_test 59 "writeconf mount option"
3222 test_60() { # LU-471
3225 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3226 skip "Only applicable to ldiskfs-based MDTs"
3230 for num in $(seq $MDSCOUNT); do
3231 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3232 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
3233 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3237 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
3239 [ $rc -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
3241 # MDT default has dirdata feature
3242 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
3243 # we disable uninit_bg feature
3244 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
3245 # we set stride extended options
3246 echo $dump | grep stride > /dev/null || error "stride is not set"
3249 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
3252 local reformat=false
3254 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
3255 { skip "Need MDS version at least 2.1.53"; return 0; }
3257 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
3258 ! large_xattr_enabled; then
3260 LDISKFS_MKFS_OPTS+=" -O large_xattr"
3262 for num in $(seq $MDSCOUNT); do
3263 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
3264 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3265 error "add mds $num failed"
3269 setup_noconfig || error "setting up the filesystem failed"
3270 client_up || error "starting client failed"
3272 local file=$DIR/$tfile
3275 local large_value="$(generate_string $(max_xattr_size))"
3276 local small_value="bar"
3278 local name="trusted.big"
3279 log "save large xattr $name on $file"
3280 setfattr -n $name -v $large_value $file ||
3281 error "saving $name on $file failed"
3283 local new_value=$(get_xattr_value $name $file)
3284 [[ "$new_value" != "$large_value" ]] &&
3285 error "$name different after saving"
3287 log "shrink value of $name on $file"
3288 setfattr -n $name -v $small_value $file ||
3289 error "shrinking value of $name on $file failed"
3291 new_value=$(get_xattr_value $name $file)
3292 [[ "$new_value" != "$small_value" ]] &&
3293 error "$name different after shrinking"
3295 log "grow value of $name on $file"
3296 setfattr -n $name -v $large_value $file ||
3297 error "growing value of $name on $file failed"
3299 new_value=$(get_xattr_value $name $file)
3300 [[ "$new_value" != "$large_value" ]] &&
3301 error "$name different after growing"
3303 log "check value of $name on $file after remounting MDS"
3305 new_value=$(get_xattr_value $name $file)
3306 [[ "$new_value" != "$large_value" ]] &&
3307 error "$name different after remounting MDS"
3309 log "remove large xattr $name from $file"
3310 setfattr -x $name $file || error "removing $name from $file failed"
3315 LDISKFS_MKFS_OPTS=${LDISKFS_MKFS_OPTS% -O large_xattr}
3319 run_test 61 "large xattr"
3322 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3323 skip "Only applicable to ldiskfs-based MDTs"
3328 local mdsdev=$(mdsdevname 1)
3329 local ostdev=$(ostdevname 1)
3331 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
3332 { skip "Need MDS version at least 2.2.51"; return 0; }
3334 echo "disable journal for mds"
3335 do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
3336 start_mds && error "MDT start should fail"
3337 echo "disable journal for ost"
3338 do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
3339 start_ost && error "OST start should fail"
3340 cleanup || return $?
3343 run_test 62 "start with disabled journal"
3346 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3347 skip "Only applicable to ldiskfs-based MDTs"
3351 local inode_slab=$(do_facet $SINGLEMDS \
3352 "awk '/ldiskfs_inode_cache/ { print \\\$5 }' /proc/slabinfo")
3353 if [ -z "$inode_slab" ]; then
3354 skip "ldiskfs module has not been loaded"
3358 echo "$inode_slab ldisk inodes per page"
3359 [ "$inode_slab" -ge "3" ] ||
3360 error "ldisk inode size is too big, $inode_slab objs per page"
3363 run_test 63 "Verify each page can at least hold 3 ldisk inodes"
3368 start_ost2 || error "Unable to start second ost"
3369 mount_client $MOUNT || error "Unable to mount client"
3370 stop_ost2 || error "Unable to stop second ost"
3372 $LFS df --lazy || error "lfs df failed"
3373 cleanup || return $?
3375 run_test 64 "check lfs df --lazy "
3378 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3381 start_mdt 1 || error "MDT0 start fail"
3383 start_ost || error "OST0 start fail"
3385 start_mdt 2 || error "MDT1 start fail"
3387 mount_client $MOUNT || error "mount client fails"
3389 mkdir -p $DIR/$tdir || error "create dir fail"
3391 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3392 error "create remote dir fail"
3394 rm -rf $DIR/$tdir || error "delete dir fail"
3395 cleanup || return $?
3397 run_test 70a "start MDT0, then OST, then MDT1"
3400 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3403 start_ost || error "OST0 start fail"
3405 start_mdt 1 || error "MDT0 start fail"
3406 start_mdt 2 || error "MDT1 start fail"
3408 mount_client $MOUNT || error "mount client fails"
3410 mkdir -p $DIR/$tdir || error "create dir fail"
3412 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3413 error "create remote dir fail"
3415 rm -rf $DIR/$tdir || error "delete dir fail"
3417 cleanup || return $?
3419 run_test 70b "start OST, MDT1, MDT0"
3422 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3425 start_mdt 1 || error "MDT0 start fail"
3426 start_mdt 2 || error "MDT1 start fail"
3427 start_ost || error "OST0 start fail"
3429 mount_client $MOUNT || error "mount client fails"
3430 stop_mdt 1 || error "MDT1 start fail"
3432 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
3433 echo "deactivate $mdc_for_mdt1"
3434 $LCTL --device $mdc_for_mdt1 deactivate || return 1
3436 mkdir -p $DIR/$tdir && error "mkdir succeed"
3438 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
3439 error "create remote dir succeed"
3441 cleanup || return $?
3443 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
3446 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3449 start_mdt 1 || error "MDT0 start fail"
3450 start_mdt 2 || error "MDT1 start fail"
3451 start_ost || error "OST0 start fail"
3453 mount_client $MOUNT || error "mount client fails"
3455 stop_mdt 2 || error "MDT1 start fail"
3457 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
3459 echo "deactivate $mdc_for_mdt2"
3460 $LCTL --device $mdc_for_mdt2 deactivate ||
3461 error "set $mdc_for_mdt2 deactivate failed"
3463 mkdir -p $DIR/$tdir || error "mkdir fail"
3464 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
3465 error "create remote dir succeed"
3467 rm -rf $DIR/$tdir || error "delete dir fail"
3469 cleanup || return $?
3471 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
3474 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3475 if combined_mgs_mds; then
3476 skip "needs separate MGS/MDT" && return
3480 start_mdt 1 || error "MDT0 start fail"
3481 start_ost || error "OST0 start fail"
3482 start_mdt 2 || error "MDT1 start fail"
3483 start_ost2 || error "OST1 start fail"
3485 mount_client $MOUNT || error "mount client fails"
3487 mkdir -p $DIR/$tdir || error "mkdir fail"
3488 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3489 error "create remote dir succeed"
3491 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
3492 rm -rf $DIR/$tdir || error "delete dir fail"
3494 umount_client $MOUNT
3495 stop_mdt 1 || error "MDT0 stop fail"
3496 stop_mdt 2 || error "MDT1 stop fail"
3497 stop_ost || error "OST0 stop fail"
3498 stop_ost2 || error "OST1 stop fail"
3500 run_test 71a "start MDT0 OST0, MDT1, OST1"
3503 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3504 if combined_mgs_mds; then
3505 skip "needs separate MGS/MDT" && return
3509 start_mdt 2 || error "MDT1 start fail"
3510 start_ost || error "OST0 start fail"
3511 start_mdt 1 || error "MDT0 start fail"
3512 start_ost2 || error "OST1 start fail"
3514 mount_client $MOUNT || error "mount client fails"
3516 mkdir -p $DIR/$tdir || error "mkdir fail"
3517 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3518 error "create remote dir succeed"
3520 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
3521 rm -rf $DIR/$tdir || error "delete dir fail"
3523 umount_client $MOUNT
3524 stop_mdt 1 || error "MDT0 stop fail"
3525 stop_mdt 2 || error "MDT1 stop fail"
3526 stop_ost || error "OST0 stop fail"
3527 stop_ost2 || error "OST1 stop fail"
3529 run_test 71b "start MDT1, OST0, MDT0, OST1"
3532 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3533 if combined_mgs_mds; then
3534 skip "needs separate MGS/MDT" && return
3538 start_ost || error "OST0 start fail"
3539 start_ost2 || error "OST1 start fail"
3540 start_mdt 2 || error "MDT1 start fail"
3541 start_mdt 1 || error "MDT0 start fail"
3543 mount_client $MOUNT || error "mount client fails"
3545 mkdir -p $DIR/$tdir || error "mkdir fail"
3546 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3547 error "create remote dir succeed"
3549 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
3550 rm -rf $DIR/$tdir || error "delete dir fail"
3552 umount_client $MOUNT
3553 stop_mdt 1 || error "MDT0 stop fail"
3554 stop_mdt 2 || error "MDT1 stop fail"
3555 stop_ost || error "OST0 stop fail"
3556 stop_ost2 || error "OST1 stop fail"
3559 run_test 71c "start OST0, OST1, MDT1, MDT0"
3562 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3563 if combined_mgs_mds; then
3564 skip "needs separate MGS/MDT" && return
3568 start_ost || error "OST0 start fail"
3569 start_mdt 2 || error "MDT0 start fail"
3570 start_mdt 1 || error "MDT0 start fail"
3571 start_ost2 || error "OST1 start fail"
3573 mount_client $MOUNT || error "mount client fails"
3575 mkdir -p $DIR/$tdir || error "mkdir fail"
3576 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3577 error "create remote dir succeed"
3579 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
3580 rm -rf $DIR/$tdir || error "delete dir fail"
3582 umount_client $MOUNT
3583 stop_mdt 1 || error "MDT0 stop fail"
3584 stop_mdt 2 || error "MDT1 stop fail"
3585 stop_ost || error "OST0 stop fail"
3586 stop_ost2 || error "OST1 stop fail"
3589 run_test 71d "start OST0, MDT1, MDT0, OST1"
3592 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3593 if combined_mgs_mds; then
3594 skip "needs separate MGS/MDT" && return
3598 start_ost || error "OST0 start fail"
3599 start_mdt 2 || error "MDT1 start fail"
3600 start_ost2 || error "OST1 start fail"
3601 start_mdt 1 || error "MDT0 start fail"
3603 mount_client $MOUNT || error "mount client fails"
3605 mkdir -p $DIR/$tdir || error "mkdir fail"
3606 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3607 error "create remote dir succeed"
3609 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
3610 rm -rf $DIR/$tdir || error "delete dir fail"
3612 umount_client $MOUNT
3613 stop_mdt 1 || error "MDT0 stop fail"
3614 stop_mdt 2 || error "MDT1 stop fail"
3615 stop_ost || error "OST0 stop fail"
3616 stop_ost2 || error "OST1 stop fail"
3619 run_test 71e "start OST0, MDT1, OST1, MDT0"
3621 if ! combined_mgs_mds ; then