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 is_blkdev $SINGLEMDS $MDSDEV $MIN
645 local large_enough=$?
646 if [ -n "$OK" ]; then
647 [ $large_enough -ne 0 ] && OK=""
649 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
650 log "use device $MDSDEV with MIN=$MIN"
653 # check if a loopback device has enough space for fs metadata (5%)
655 if [ -z "$OK" ]; then
656 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
657 awk '($1 != "Filesystem") {print $4}')
658 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
659 OK=1 && myMDSSIZE=$MIN && \
660 log "use file $MDSDEV with MIN=$MIN"
663 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
666 echo "mount mds with large journal..."
668 local OLD_MDSSIZE=$MDSSIZE
672 echo "mount lustre system..."
674 check_mount || return 41
676 echo "check journal size..."
677 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
678 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
679 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
681 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
689 run_test 18 "check mkfs creates large journals"
692 start_mds || return 1
693 stop_mds -f || return 2
695 run_test 19a "start/stop MDS without OSTs"
698 [ "$(facet_fstype ost1)" = "zfs" ] &&
699 skip "LU-2059: no local config for ZFS OSTs" && return
701 start_ost || return 1
702 stop_ost -f || return 2
704 run_test 19b "start/stop OSTs without MDS"
707 # first format the ost/mdt
711 check_mount || return 43
713 remount_client ro $MOUNT || return 44
714 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
715 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
716 remount_client rw $MOUNT || return 47
718 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
719 MCNT=`grep -c $MOUNT /etc/mtab`
720 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
725 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
730 wait_osc_import_state mds ost FULL
734 run_test 21a "start mds before ost, stop ost first"
737 [ "$(facet_fstype ost1)" = "zfs" ] &&
738 skip "LU-2059: no local config for ZFS OSTs" && return
742 wait_osc_import_state mds ost FULL
746 run_test 21b "start ost before mds, stop mds first"
752 wait_osc_import_state mds ost2 FULL
756 #writeconf to remove all ost2 traces for subsequent tests
757 writeconf_or_reformat
759 run_test 21c "start mds between two osts, stop mds last"
762 if combined_mgs_mds ; then
763 skip "need separate mgs device" && return 0
773 wait_osc_import_state mds ost2 FULL
779 #writeconf to remove all ost2 traces for subsequent tests
780 writeconf_or_reformat
783 run_test 21d "start mgs then ost and then mds"
790 echo Client mount with ost in logs, but none running
792 # wait until mds connected to ost and open client connection
793 for num in $(seq 1 $MDSCOUNT); do
794 wait_osc_import_state mds${num} ost FULL
798 # check_mount will block trying to contact ost
799 mcreate $DIR/$tfile || return 40
800 rm -f $DIR/$tfile || return 42
804 echo Client mount with a running ost
807 # if gss enabled, wait full time to let connection from
808 # mds to ost be established, due to the mismatch between
809 # initial connect timeout and gss context negotiation timeout.
810 # This perhaps could be remove after AT landed.
811 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
812 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
815 for num in $(seq 1 $MDSCOUNT); do
816 wait_osc_import_state mds${num} ost FULL
818 wait_osc_import_state client ost FULL
819 check_mount || return 41
824 run_test 22 "start a client before osts (should return errs)"
826 test_23a() { # was test_23
830 # force down client so that recovering mds waits for reconnect
831 local running=$(grep -c $MOUNT /proc/mounts) || true
832 if [ $running -ne 0 ]; then
833 echo "Stopping client $MOUNT (opts: -f)"
837 # enter recovery on mds
839 # try to start a new client
840 mount_client $MOUNT &
842 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
843 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
844 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
846 ps --ppid $MOUNT_LUSTRE_PID
847 echo "waiting for mount to finish"
849 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
850 # SIGTERM works but it does not spread to offspring processses
851 kill -s TERM $MOUNT_PID
852 kill -s TERM $MOUNT_LUSTRE_PID
853 # we can not wait $MOUNT_PID because it is not a child of this shell
859 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
861 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
862 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
865 [ -z "$PID1" -a -z "$PID2" ] && break
866 echo "waiting for mount to finish ... "
867 WAIT=$(( WAIT + sleep))
869 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
870 error "MOUNT_PID $MOUNT_PID and "\
871 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
877 run_test 23a "interrupt client during recovery mount delay"
882 test_23b() { # was test_23
885 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
886 lctl set_param fail_loc=0x80000313
890 run_test 23b "Simulate -EINTR during mount"
892 fs2mds_HOST=$mds_HOST
893 fs2ost_HOST=$ost_HOST
895 MDSDEV1_2=$fs2mds_DEV
896 OSTDEV1_2=$fs2ost_DEV
897 OSTDEV2_2=$fs3ost_DEV
901 echo "umount $MOUNT2 ..."
902 umount $MOUNT2 || true
903 echo "stopping fs2mds ..."
904 stop fs2mds -f || true
905 echo "stopping fs2ost ..."
906 stop fs2ost -f || true
910 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
912 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
913 is_blkdev $SINGLEMDS $MDSDEV && \
914 skip_env "mixed loopback and real device not working" && return
917 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
919 local fs2mdsdev=$(mdsdevname 1_2)
920 local fs2ostdev=$(ostdevname 1_2)
921 local fs2mdsvdev=$(mdsvdevname 1_2)
922 local fs2ostvdev=$(ostvdevname 1_2)
924 # test 8-char fsname as well
925 local FSNAME2=test1234
927 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
928 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
930 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
931 --reformat $fs2ostdev $fs2ostvdev || exit 10
934 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
935 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
937 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
939 check_mount || return 2
940 # files written on 1 should not show up on 2
941 cp /etc/passwd $DIR/$tfile
943 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
946 cp /etc/passwd $MOUNT2/b || return 3
947 rm $MOUNT2/b || return 4
948 # 2 is actually mounted
949 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
951 facet_failover fs2mds
952 facet_failover fs2ost
955 # the MDS must remain up until last MDT
957 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
958 [ -z "$MDS" ] && error "No MDT" && return 8
960 cleanup_nocli || return 6
962 run_test 24a "Multiple MDTs on a single node"
965 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
967 if [ -z "$fs2mds_DEV" ]; then
968 local dev=${SINGLEMDS}_dev
970 is_blkdev $SINGLEMDS $MDSDEV && \
971 skip_env "mixed loopback and real device not working" && return
974 local fs2mdsdev=$(mdsdevname 1_2)
975 local fs2mdsvdev=$(mdsvdevname 1_2)
977 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
978 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
980 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
983 run_test 24b "Multiple MGSs on a single node (should return err)"
987 check_mount || return 2
988 local MODULES=$($LCTL modules | awk '{ print $2 }')
989 rmmod $MODULES 2>/dev/null || true
992 run_test 25 "Verify modules are referenced"
996 # we need modules before mount for sysctl, so make sure...
997 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
998 #define OBD_FAIL_MDS_FS_SETUP 0x135
999 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
1000 start_mds && echo MDS started && return 1
1001 lctl get_param -n devices
1002 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
1003 [ $DEVS -gt 0 ] && return 2
1004 # start mds to drop writeconf setting
1005 start_mds || return 3
1006 stop_mds || return 4
1007 unload_modules_conf || return $?
1009 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1012 [ "$(facet_fstype ost1)" = "zfs" ] &&
1013 skip "LU-2059: no local config for ZFS OSTs" && return
1015 start_ost || return 1
1016 start_mds || return 2
1017 echo "Requeue thread should have started: "
1018 ps -e | grep ll_cfg_requeue
1019 set_conf_param_and_check ost1 \
1020 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1021 "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
1024 run_test 27a "Reacquire MGS lock if OST started first"
1029 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1030 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1032 facet_failover $SINGLEMDS
1033 set_conf_param_and_check $SINGLEMDS \
1034 "lctl get_param -n mdt.$device.identity_acquire_expire" \
1035 "$device.mdt.identity_acquire_expire" || return 3
1036 set_conf_param_and_check client \
1037 "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight"\
1038 "$device.mdc.max_rpcs_in_flight" || return 4
1042 run_test 27b "Reacquire MGS lock after failover"
1046 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1047 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1049 FINAL=$(($ORIG + 1))
1050 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL || return 3
1051 FINAL=$(($FINAL + 1))
1052 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL || return 4
1053 umount_client $MOUNT || return 200
1056 if [ $RESULT -ne $FINAL ]; then
1057 echo "New config not seen: wanted $FINAL got $RESULT"
1060 echo "New config success: got $RESULT"
1062 set_conf_param_and_check client "$TEST" "$PARAM" $ORIG || return 5
1065 run_test 28 "permanent parameter setting"
1068 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1069 setup > /dev/null 2>&1
1073 local PARAM="$FSNAME-OST0001.osc.active"
1074 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1075 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1077 ACTV=$(lctl get_param -n $PROC_ACT)
1079 set_conf_param_and_check client \
1080 "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1081 # also check ost_server_uuid status
1082 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1083 if [ -z "$RESULT" ]; then
1084 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1087 echo "Live client success: got $RESULT"
1091 for num in $(seq $MDSCOUNT); do
1092 local mdtosc=$(get_mdtosc_proc_path mds${num} $FSNAME-OST0001)
1093 local MPROC="osc.$mdtosc.active"
1098 RESULT=$(do_facet mds${num} " lctl get_param -n $MPROC")
1099 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1100 if [ $RESULT -eq $DEAC ]; then
1101 echo -n "MDT deactivated also after"
1102 echo "$WAIT sec (got $RESULT)"
1106 if [ $WAIT -eq $MAX ]; then
1107 echo -n "MDT not deactivated: wanted $DEAC"
1111 echo "Waiting $(($MAX - $WAIT))secs for MDT deactivated"
1114 # test new client starts deactivated
1115 umount_client $MOUNT || return 200
1117 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1118 if [ -z "$RESULT" ]; then
1119 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1122 echo "New client success: got $RESULT"
1125 # make sure it reactivates
1126 set_conf_param_and_check client \
1127 "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1129 umount_client $MOUNT
1132 #writeconf to remove all ost2 traces for subsequent tests
1133 writeconf_or_reformat
1135 run_test 29 "permanently remove an OST"
1140 echo Big config llog
1141 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1143 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1144 for i in ${LIST[@]}; do
1145 set_conf_param_and_check client "$TEST" \
1146 "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1148 # make sure client restart still works
1149 umount_client $MOUNT
1150 mount_client $MOUNT || return 4
1151 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1154 echo Erase parameter setting
1155 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1156 umount_client $MOUNT
1157 mount_client $MOUNT || return 6
1159 echo "deleted (default) value=$FINAL, orig=$ORIG"
1160 # assumes this parameter started at the default value
1161 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1165 run_test 30a "Big config llog and conf_param deletion"
1170 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1171 # numerical part of it. Hopefully that's not already a failover address for
1173 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1174 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1175 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1176 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1177 echo "Using fake nid $NEW"
1179 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1180 set_conf_param_and_check client "$TEST" \
1181 "$FSNAME-OST0000.failover.node" $NEW ||
1182 error "didn't add failover nid $NEW"
1183 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1185 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1186 echo "should have 2 failover nids: $NIDCOUNT"
1187 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1188 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1189 umount_client $MOUNT
1190 mount_client $MOUNT || return 3
1192 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1194 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1195 echo "only 1 final nid should remain: $NIDCOUNT"
1196 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1200 run_test 30b "Remove failover nids"
1202 test_31() { # bug 10734
1203 # ipaddr must not exist
1204 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1207 run_test 31 "Connect to non-existent node (shouldn't crash)"
1210 # This is not really a test but a tool to create new disk
1211 # image tarballs for the upgrade tests.
1213 # Disk image tarballs should be created on single-node
1214 # clusters by running this test with default configurations
1215 # plus a few mandatory environment settings that are verified
1216 # at the beginning of the test.
1218 test_32newtarball() {
1222 local tmp=$TMP/t32_image_create
1224 if [ $FSNAME != t32fs -o $MDSCOUNT -ne 1 -o \
1225 \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o $OSTCOUNT -ne 1 -o \
1226 -z "$OSTDEV1" ]; then
1227 error "Needs FSNAME=t32fs MDSCOUNT=1 MDSDEV1=<nonexistent_file>" \
1228 "(or MDSDEV, in the case of b1_8) OSTCOUNT=1" \
1229 "OSTDEV1=<nonexistent_file>"
1233 echo "Found stale $tmp"
1238 tar cf - -C $src . | tar xf - -C $tmp/src
1243 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1250 ls -Rni --time-style=+%s >$tmp/img/list
1251 find . ! -name .lustre -type f -exec sha1sum {} \; |
1252 sort -k 2 >$tmp/img/sha1sums
1254 $LCTL get_param -n version | head -n 1 |
1255 sed -e 's/^lustre: *//' >$tmp/img/commit
1259 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1262 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1263 echo "Data verification failed"
1266 uname -r >$tmp/img/kernel
1267 uname -m >$tmp/img/arch
1269 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1270 mv $OSTDEV1 $tmp/img
1272 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1273 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1276 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1281 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1284 # The list of applicable tarballs is returned via the caller's
1285 # variable "tarballs".
1288 local node=$(facet_active_host $SINGLEMDS)
1289 local r="do_node $node"
1291 if [ "$CLIENTONLY" ]; then
1292 skip "Client-only testing"
1296 if ! $r which $TUNEFS; then
1297 skip_env "tunefs.lustre required on $node"
1301 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1302 skip "LU-2200: Test cannot run over Infiniband"
1306 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1308 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 -name \'disk*-$IMGTYPE.tar.bz2\')
1310 if [ -z "$tarballs" ]; then
1311 skip "No applicable tarballs found"
1316 t32_test_cleanup() {
1317 local node=$(facet_active_host $SINGLEMDS)
1318 local r="do_node $node"
1322 if $shall_cleanup_lustre; then
1323 umount $tmp/mnt/lustre || rc=$?
1325 if $shall_cleanup_mdt; then
1326 $r umount -d $tmp/mnt/mdt || rc=$?
1328 if $shall_cleanup_mdt1; then
1329 $r umount -d $tmp/mnt/mdt1 || rc=$?
1331 if $shall_cleanup_ost; then
1332 $r umount -d $tmp/mnt/ost || rc=$?
1334 $r rm -rf $tmp || rc=$?
1335 rm -rf $tmp || rc=$?
1339 t32_bits_per_long() {
1341 # Yes, this is not meant to be perfect.
1351 t32_reload_modules() {
1353 local all_removed=false
1356 while ((i < 20)); do
1357 echo "Unloading modules on $node: Attempt $i"
1358 do_rpc_nodes $node $LUSTRE_RMMOD $(facet_fstype $SINGLEMDS) &&
1360 do_rpc_nodes $node check_mem_leak || return 1
1361 if $all_removed; then
1368 echo "Unloading modules on $node: Given up"
1372 t32_wait_til_devices_gone() {
1377 echo wait for devices to go
1378 while ((i < 20)); do
1379 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1381 ((devices == 0)) && return 1
1385 echo "waiting for devices on $node: Given up"
1392 local dne_upgrade=${dne_upgrade:-"no"}
1393 local shall_cleanup_mdt=false
1394 local shall_cleanup_mdt1=false
1395 local shall_cleanup_ost=false
1396 local shall_cleanup_lustre=false
1397 local node=$(facet_active_host $SINGLEMDS)
1398 local r="do_node $node"
1399 local node2=$(facet_active_host mds2)
1400 local r2="do_node $node2"
1406 local nid=$($r $LCTL list_nids | head -1)
1413 trap 'trap - RETURN; t32_test_cleanup' RETURN
1415 mkdir -p $tmp/mnt/lustre
1416 $r mkdir -p $tmp/mnt/{mdt,ost}
1417 $r tar xjvf $tarball -S -C $tmp || {
1418 error_noexit "Unpacking the disk image tarball"
1421 img_commit=$($r cat $tmp/commit)
1422 img_kernel=$($r cat $tmp/kernel)
1423 img_arch=$($r cat $tmp/arch)
1424 echo "Upgrading from $(basename $tarball), created with:"
1425 echo " Commit: $img_commit"
1426 echo " Kernel: $img_kernel"
1427 echo " Arch: $img_arch"
1429 $r $LCTL set_param debug="$PTLDEBUG"
1431 $r $TUNEFS --dryrun $tmp/mdt || {
1432 error_noexit "tunefs.lustre before mounting the MDT"
1435 if [ "$writeconf" ]; then
1436 mopts=loop,writeconf
1438 mopts=loop,exclude=$fsname-OST0000
1441 t32_wait_til_devices_gone $node
1443 $r mount -t lustre -o $mopts $tmp/mdt $tmp/mnt/mdt || {
1444 error_noexit "Mounting the MDT"
1447 shall_cleanup_mdt=true
1449 if [ "$dne_upgrade" != "no" ]; then
1450 echo "mkfs new MDT...."
1451 add mds2 $(mkfs_opts mds2 $(mdsdevname 2) $fsname) --reformat \
1452 $(mdsdevname 2) $(mdsvdevname 2) > /dev/null || {
1453 error_noexit "Mkfs new MDT failed"
1457 $r2 $TUNEFS --dryrun $(mdsdevname 2) || {
1458 error_noexit "tunefs.lustre before mounting the MDT"
1462 echo "mount new MDT...."
1463 $r2 mkdir -p $tmp/mnt/mdt1
1464 $r2 mount -t lustre -o $mopts $(mdsdevname 2) $tmp/mnt/mdt1 || {
1465 error_noexit "mount mdt1 failed"
1468 shall_cleanup_mdt1=true
1471 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1472 error_noexit "Getting MDT UUID"
1475 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1476 error_noexit "Unexpected MDT UUID: \"$uuid\""
1480 $r $TUNEFS --dryrun $tmp/ost || {
1481 error_noexit "tunefs.lustre before mounting the OST"
1484 if [ "$writeconf" ]; then
1485 mopts=loop,mgsnode=$nid,$writeconf
1487 mopts=loop,mgsnode=$nid
1489 $r mount -t lustre -o $mopts $tmp/ost $tmp/mnt/ost || {
1490 error_noexit "Mounting the OST"
1493 shall_cleanup_ost=true
1495 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1496 error_noexit "Getting OST UUID"
1499 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1500 error_noexit "Unexpected OST UUID: \"$uuid\""
1504 $r $LCTL conf_param $fsname-OST0000.osc.max_dirty_mb=15 || {
1505 error_noexit "Setting \"max_dirty_mb\""
1508 $r $LCTL conf_param $fsname-OST0000.failover.node=$nid || {
1509 error_noexit "Setting OST \"failover.node\""
1512 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1513 error_noexit "Setting \"max_rpcs_in_flight\""
1516 $r $LCTL conf_param $fsname-MDT0000.failover.node=$nid || {
1517 error_noexit "Setting MDT \"failover.node\""
1520 $r $LCTL pool_new $fsname.interop || {
1521 error_noexit "Setting \"interop\""
1524 $r $LCTL conf_param $fsname-MDT0000.lov.stripesize=4M || {
1525 error_noexit "Setting \"lov.stripesize\""
1529 if [ "$dne_upgrade" != "no" ]; then
1530 $r2 $LCTL conf_param \
1531 $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
1532 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
1535 $r2 $LCTL conf_param $fsname-MDT0001.failover.node=$nid || {
1536 error_noexit "Setting MDT1 \"failover.node\""
1539 $r2 $LCTL conf_param $fsname-MDT0001.lov.stripesize=4M || {
1540 error_noexit "Setting MDT1 \"lov.stripesize\""
1546 if [ "$writeconf" ]; then
1547 mount -t lustre $nid:/$fsname $tmp/mnt/lustre || {
1548 error_noexit "Mounting the client"
1551 shall_cleanup_lustre=true
1552 $LCTL set_param debug="$PTLDEBUG"
1553 if [ "$dne_upgrade" != "no" ]; then
1554 $LFS mkdir -i 1 $tmp/mnt/lustre/remote_dir || {
1555 error_noexit "set remote dir failed"
1559 pushd $tmp/mnt/lustre
1560 tar -cf - . --exclude=./remote_dir |
1561 tar -xvf - -C remote_dir 1>/dev/null || {
1562 error_noexit "cp to remote dir failed"
1568 if $r test -f $tmp/sha1sums; then
1569 # LU-2393 - do both sorts on same node to ensure locale
1571 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
1572 if [ "$dne_upgrade" != "no" ]; then
1573 pushd $tmp/mnt/lustre/remote_dir
1575 pushd $tmp/mnt/lustre
1578 find ! -name .lustre -type f -exec sha1sum {} \; |
1579 sort -k 2 >$tmp/sha1sums || {
1580 error_noexit "sha1sum"
1584 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
1585 error_noexit "sha1sum verification failed"
1589 echo "sha1sum verification skipped"
1592 if [ "$dne_upgrade" != "no" ]; then
1593 rm -rf $tmp/mnt/lustre/remote_dir || {
1594 error_noexit "remove remote dir failed"
1599 if $r test -f $tmp/list; then
1601 # There is not a Test Framework API to copy files to or
1602 # from a remote node.
1604 # LU-2393 - do both sorts on same node to ensure locale
1606 $r cat $tmp/list | sort -k 6 >$tmp/list.orig
1607 pushd $tmp/mnt/lustre
1608 ls -Rni --time-style=+%s | sort -k 6 >$tmp/list || {
1614 # 32-bit and 64-bit clients use different algorithms to
1615 # convert FIDs into inode numbers. Hence, remove the inode
1616 # numbers from the lists, if the original list was created
1617 # on an architecture with different number of bits per
1620 if [ $(t32_bits_per_long $(uname -m)) != \
1621 $(t32_bits_per_long $img_arch) ]; then
1622 echo "Different number of bits per \"long\" from the disk image"
1623 for list in list.orig list; do
1624 sed -i -e 's/^[0-9]\+[ \t]\+//' $tmp/$list
1627 if ! diff -ub $tmp/list.orig $tmp/list; then
1628 error_noexit "list verification failed"
1632 echo "list verification skipped"
1636 # When adding new data verification tests, please check for
1637 # the presence of the required reference files first, like
1638 # the "sha1sums" and "list" tests above, to avoid the need to
1639 # regenerate every image for each test addition.
1642 nrpcs_orig=$($LCTL get_param \
1643 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
1644 error_noexit "Getting \"max_rpcs_in_flight\""
1647 nrpcs=$((nrpcs_orig + 5))
1648 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=$nrpcs || {
1649 error_noexit "Changing \"max_rpcs_in_flight\""
1652 wait_update $HOSTNAME "$LCTL get_param \
1653 -n mdc.*MDT0000*.max_rpcs_in_flight" $nrpcs || {
1654 error_noexit "Verifying \"max_rpcs_in_flight\""
1658 umount $tmp/mnt/lustre || {
1659 error_noexit "Unmounting the client"
1662 shall_cleanup_lustre=false
1664 $r umount -d $tmp/mnt/mdt || {
1665 error_noexit "Unmounting the MDT"
1668 shall_cleanup_mdt=false
1669 $r umount -d $tmp/mnt/ost || {
1670 error_noexit "Unmounting the OST"
1673 shall_cleanup_ost=false
1675 t32_reload_modules $node || {
1676 error_noexit "Reloading modules"
1680 # mount a second time to make sure we didnt leave upgrade flag on
1681 $r $TUNEFS --dryrun $tmp/mdt || {
1682 error_noexit "tunefs.lustre before remounting the MDT"
1685 $r mount -t lustre -o loop,exclude=$fsname-OST0000 $tmp/mdt \
1687 error_noexit "Remounting the MDT"
1690 shall_cleanup_mdt=true
1700 for tarball in $tarballs; do
1701 t32_test $tarball || rc=$?
1705 run_test 32a "Upgrade (not live)"
1713 for tarball in $tarballs; do
1714 t32_test $tarball writeconf || rc=$?
1718 run_test 32b "Upgrade with writeconf"
1725 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1727 for tarball in $tarballs; do
1728 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
1732 run_test 32c "dne upgrade test"
1734 test_33a() { # bug 12333, was test_33
1736 local FSNAME2=test-123
1737 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1740 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1742 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1743 local dev=${SINGLEMDS}_dev
1744 local MDSDEV=${!dev}
1745 is_blkdev $SINGLEMDS $MDSDEV && \
1746 skip_env "mixed loopback and real device not working" && return
1749 local fs2mdsdev=$(mdsdevname 1_2)
1750 local fs2ostdev=$(ostdevname 1_2)
1751 local fs2mdsvdev=$(mdsvdevname 1_2)
1752 local fs2ostvdev=$(ostvdevname 1_2)
1754 if [ $(facet_fstype mds1) == ldiskfs ]; then
1755 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
1758 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
1759 --reformat $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
1760 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
1761 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
1762 $fs2ostvdev || exit 10
1764 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1765 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1766 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1768 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1771 cp /etc/hosts $MOUNT2/ || rc=3
1772 $LFS getstripe $MOUNT2/hosts
1777 cleanup_nocli || rc=6
1780 run_test 33a "Mount ost with a large index number"
1782 test_33b() { # was test_34
1785 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1786 # Drop lock cancelation reply during umount
1787 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
1788 do_facet client lctl set_param fail_loc=0x80000304
1789 #lctl set_param debug=-1
1790 umount_client $MOUNT
1793 run_test 33b "Drop cancel during umount"
1797 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1798 manual_umount_client
1800 do_facet client killall -USR1 multiop
1801 if [ $rc -eq 0 ]; then
1802 error "umount not fail!"
1807 run_test 34a "umount with opened file should be fail"
1812 touch $DIR/$tfile || return 1
1813 stop_mds --force || return 2
1815 manual_umount_client --force
1817 if [ $rc -ne 0 ]; then
1818 error "mtab after failed umount - rc $rc"
1824 run_test 34b "force umount with failed mds should be normal"
1828 touch $DIR/$tfile || return 1
1829 stop_ost --force || return 2
1831 manual_umount_client --force
1833 if [ $rc -ne 0 ]; then
1834 error "mtab after failed umount - rc $rc"
1840 run_test 34c "force umount with failed ost should be normal"
1842 test_35a() { # bug 12459
1845 DBG_SAVE="`lctl get_param -n debug`"
1846 lctl set_param debug="ha"
1848 log "Set up a fake failnode for the MDS"
1850 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1851 do_facet mgs "$LCTL conf_param ${device}.failover.node=" \
1852 "$(h2$NETTYPE $FAKENID)" || return 4
1854 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1857 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1860 log "Stopping the MDT: $device"
1861 stop_mdt 1 || return 5
1863 df $MOUNT > /dev/null 2>&1 &
1865 log "Restarting the MDT: $device"
1866 start_mdt 1 || return 6
1867 log "Wait for df ($DFPID) ... "
1870 lctl set_param debug="$DBG_SAVE"
1872 # retrieve from the log the first server that the client tried to
1873 # contact after the connection loss
1874 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1875 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1876 /import_select_connection.*$device-mdc.* using connection/ {
1878 if (\\\$NF ~ /$FAKENID/)
1884 }" $TMP/lustre-log-$TESTNAME.log`
1885 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1887 # remove nid settings
1888 writeconf_or_reformat
1890 run_test 35a "Reconnect to the last active server first"
1892 test_35b() { # bug 18674
1893 remote_mds || { skip "local MDS" && return 0; }
1897 $LCTL set_param debug="ha"
1899 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1902 log "Set up a fake failnode for the MDS"
1904 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | \
1905 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1906 do_facet mgs "$LCTL conf_param ${device}.failover.node=" \
1907 "$(h2$NETTYPE $FAKENID)" || return 1
1909 local at_max_saved=0
1910 # adaptive timeouts may prevent seeing the issue
1911 if at_is_enabled; then
1912 at_max_saved=$(at_max_get mds)
1913 at_max_set 0 mds client
1916 mkdir -p $MOUNT/$tdir
1918 log "Injecting EBUSY on MDS"
1919 # Setting OBD_FAIL_MDS_RESEND=0x136
1920 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
1922 $LCTL set_param mdc.${FSNAME}*.stats=clear
1924 log "Creating a test file and stat it"
1925 touch $MOUNT/$tdir/$tfile
1926 stat $MOUNT/$tdir/$tfile
1928 log "Stop injecting EBUSY on MDS"
1929 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
1930 rm -f $MOUNT/$tdir/$tfile
1933 # restore adaptive timeout
1934 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1936 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1938 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
1940 # retrieve from the log if the client has ever tried to
1941 # contact the fake server after the loss of connection
1942 FAILCONN=`awk "BEGIN {ret = 0;}
1943 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1945 if (\\\$NF ~ /$FAKENID/) {
1950 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1952 [ "$FAILCONN" == "0" ] && \
1953 log "ERROR: The client reconnection has not been triggered" && \
1955 [ "$FAILCONN" == "2" ] && \
1956 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1960 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
1961 # Reconnects are supposed to be rate limited to one every 5s
1962 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
1963 log "ERROR: Too many reconnects $CONNCNT" && \
1967 # remove nid settings
1968 writeconf_or_reformat
1970 run_test 35b "Continue reconnection retries, if the active server is busy"
1973 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1975 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1976 { skip "remote OST" && return 0; }
1979 local FSNAME2=test1234
1980 local fs3ost_HOST=$ost_HOST
1981 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1983 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1985 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1986 is_blkdev $SINGLEMDS $MDSDEV && \
1987 skip_env "mixed loopback and real device not working" && return
1990 local fs2mdsdev=$(mdsdevname 1_2)
1991 local fs2ostdev=$(ostdevname 1_2)
1992 local fs3ostdev=$(ostdevname 2_2)
1993 local fs2mdsvdev=$(mdsvdevname 1_2)
1994 local fs2ostvdev=$(ostvdevname 1_2)
1995 local fs3ostvdev=$(ostvdevname 2_2)
1997 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
1998 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1999 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2000 # different one than the default value here.
2001 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2002 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2003 add fs3ost $(mkfs_opts ost1 ${fs3ostdev}) --mgsnode=$MGSNID \
2004 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2006 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2007 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2008 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2010 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
2012 sleep 5 # until 11778 fixed
2014 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
2016 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
2017 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
2018 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
2019 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
2020 DFTOTAL=`echo $STRING | cut -d, -f1`
2021 DFUSED=`echo $STRING | cut -d, -f2`
2022 DFAVAIL=`echo $STRING | cut -d, -f3`
2023 DFFREE=$(($DFTOTAL - $DFUSED))
2025 ALLOWANCE=$((64 * $OSTCOUNT))
2027 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2028 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2029 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2032 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2033 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2034 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2037 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2038 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2039 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2044 stop fs3ost -f || return 200
2045 stop fs2ost -f || return 201
2046 stop fs2mds -f || return 202
2047 unload_modules_conf || return 203
2050 run_test 36 "df report consistency on OSTs with different block size"
2053 local mntpt=$(facet_mntpt $SINGLEMDS)
2054 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2055 local mdsdev_sym="$TMP/sym_mdt.img"
2056 local opts=$MDS_MOUNT_OPTS
2059 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2060 skip "Currently only applicable to ldiskfs-based MDTs"
2064 echo "MDS : $mdsdev"
2065 echo "SYMLINK : $mdsdev_sym"
2066 do_facet $SINGLEMDS rm -f $mdsdev_sym
2068 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2070 echo "mount symlink device - $mdsdev_sym"
2072 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2073 opts=$(csa_add "$opts" -o loop)
2075 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2076 $mdsdev_sym $mntpt 2>&1)
2079 echo mount_op=$mount_op
2081 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
2083 if $(echo $mount_op | grep -q "unable to set tunable"); then
2084 error "set tunables failed for symlink device"
2087 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2091 run_test 37 "verify set tunables works for symlink device"
2093 test_38() { # bug 14222
2094 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2095 skip "Only applicable to ldiskfs-based MDTs"
2103 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
2104 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2106 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
2107 error "copying $SRC to $DIR/$tdir"
2109 umount_client $MOUNT
2111 log "rename lov_objid file on MDS"
2112 rm -f $TMP/lov_objid.orig
2114 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2115 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
2116 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
2118 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
2119 # check create in mds_lov_connect
2123 [ $V ] && log "verifying $DIR/$tdir/$f"
2124 diff -q $f $DIR/$tdir/$f || ERROR=y
2126 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
2127 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
2128 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
2130 # check it's updates in sync
2131 umount_client $MOUNT
2134 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
2135 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
2136 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
2141 [ $V ] && log "verifying $DIR/$tdir/$f"
2142 diff -q $f $DIR/$tdir/$f || ERROR=y
2144 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
2145 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
2146 umount_client $MOUNT
2148 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
2150 log "files compared the same"
2153 run_test 38 "MDS recreates missing lov_objid file from OST data"
2159 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2160 error "memory leak detected" || true
2162 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2164 test_40() { # bug 15759
2166 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2167 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2171 run_test 40 "race during service thread startup"
2173 test_41a() { #bug 14134
2174 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2175 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2176 skip "Loop devices does not work with nosvc option"
2181 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2183 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2184 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
2185 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2187 mount_client $MOUNT || return 1
2190 echo "blah blah" > $MOUNT/$tfile
2193 umount_client $MOUNT
2194 stop ost1 -f || return 201
2195 stop_mds -f || return 202
2196 stop_mds -f || return 203
2197 unload_modules_conf || return 204
2200 run_test 41a "mount mds with --nosvc and --nomgs"
2203 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2204 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2205 skip "Loop devices does not work with nosvc option"
2209 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2213 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2215 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2217 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2219 mount_client $MOUNT || return 1
2222 echo "blah blah" > $MOUNT/$tfile
2223 cat $MOUNT/$tfile || return 200
2225 umount_client $MOUNT
2226 stop_ost || return 201
2227 stop_mds -f || return 202
2228 stop_mds -f || return 203
2231 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2233 test_42() { #bug 14693
2235 check_mount || return 2
2236 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
2237 umount_client $MOUNT
2238 mount_client $MOUNT || return 1
2242 run_test 42 "invalid config param should not prevent client from mounting"
2245 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
2247 chmod ugo+x $DIR || error "chmod 0 failed"
2248 set_conf_param_and_check mds \
2249 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2250 "$FSNAME.mdt.root_squash" \
2252 set_conf_param_and_check mds \
2253 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2254 "$FSNAME.mdt.nosquash_nids" \
2258 # create set of test files
2260 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
2261 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
2262 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
2264 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
2265 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
2267 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
2268 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
2269 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
2272 # check root_squash:
2273 # set root squash UID:GID to RUNAS_ID
2274 # root should be able to access only files owned by RUNAS_ID
2276 set_conf_param_and_check mds \
2277 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2278 "$FSNAME.mdt.root_squash" \
2279 "$RUNAS_ID:$RUNAS_ID"
2281 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
2282 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
2283 error "$ST: root read permission is denied"
2284 echo "$ST: root read permission is granted - ok"
2287 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
2288 error "$ST: root write permission is denied"
2289 echo "$ST: root write permission is granted - ok"
2291 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2292 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
2293 error "$ST: root read permission is granted"
2294 echo "$ST: root read permission is denied - ok"
2297 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
2298 error "$ST: root write permission is granted"
2299 echo "$ST: root write permission is denied - ok"
2301 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2302 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
2303 error "$ST: root unlink permission is granted"
2304 echo "$ST: root unlink permission is denied - ok"
2306 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
2307 error "$ST: root create permission is granted"
2308 echo "$ST: root create permission is denied - ok"
2311 # check nosquash_nids:
2312 # put client's NID into nosquash_nids list,
2313 # root should be able to access root file after that
2315 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
2316 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
2317 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
2318 set_conf_param_and_check mds \
2319 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2320 "$FSNAME-MDTall.mdt.nosquash_nids" \
2323 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2324 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
2325 error "$ST: root read permission is denied"
2326 echo "$ST: root read permission is granted - ok"
2329 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
2330 error "$ST: root write permission is denied"
2331 echo "$ST: root write permission is granted - ok"
2333 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2334 rm $DIR/$tdir-rootdir/tfile-1 || \
2335 error "$ST: root unlink permission is denied"
2336 echo "$ST: root unlink permission is granted - ok"
2337 touch $DIR/$tdir-rootdir/tfile-2 || \
2338 error "$ST: root create permission is denied"
2339 echo "$ST: root create permission is granted - ok"
2343 run_test 43 "check root_squash and nosquash_nids"
2345 umount_client $MOUNT
2350 check_mount || return 2
2351 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
2353 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
2354 for VAL in $UUIDS; do
2355 NID=$(echo $VAL | cut -d= -f1)
2356 CLUUID=$(echo $VAL | cut -d= -f2)
2357 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
2359 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
2363 run_test 44 "mounted client proc entry exists"
2367 check_mount || return 2
2372 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
2373 do_facet client "lctl set_param fail_loc=0x50f"
2376 manual_umount_client --force || return 3
2377 do_facet client "lctl set_param fail_loc=0x0"
2379 mount_client $MOUNT || return 4
2383 run_test 45 "long unlink handling in ptlrpcd"
2390 umount_client $MOUNT2 || rc=$?
2391 umount_client $MOUNT || rc=$?
2392 while [ $count -gt 0 ]; do
2393 stop ost${count} -f || rc=$?
2397 cleanup_nocli || rc=$?
2398 #writeconf to remove all ost2 traces for subsequent tests
2399 writeconf_or_reformat
2404 echo "Testing with $OSTCOUNT OSTs"
2406 start_mds || return 1
2407 #first client should see only one ost
2408 start_ost || return 2
2409 wait_osc_import_state mds ost FULL
2411 mount_client $MOUNT || return 3
2412 trap "cleanup_46a $OSTCOUNT" EXIT ERR
2415 for (( i=2; i<=$OSTCOUNT; i++ )); do
2416 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
2419 # wait until osts in sync
2420 for (( i=2; i<=$OSTCOUNT; i++ )); do
2421 wait_osc_import_state mds ost$i FULL
2422 wait_osc_import_state client ost$i FULL
2425 #second client see all ost's
2427 mount_client $MOUNT2 || return 8
2428 $LFS setstripe -c -1 $MOUNT2 || return 9
2429 $LFS getstripe $MOUNT2 || return 10
2431 echo "ok" > $MOUNT2/widestripe
2432 $LFS getstripe $MOUNT2/widestripe || return 11
2433 # fill acl buffer for avoid expand lsm to them
2434 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
2435 setfacl -m $acl $MOUNT2/widestripe
2439 stat $MOUNT/widestripe || return 12
2441 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
2444 run_test 46a "handle ost additional - wide striped file"
2449 check_mount || return 2
2450 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2454 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2455 if echo $ns | grep "MDT[[:digit:]]*"; then
2458 lrs=$(echo $ns | sed 's/.*lru_size=//')
2459 lru_size[count]=$lrs
2464 facet_failover $SINGLEMDS
2465 client_up || return 3
2468 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2469 if echo $ns | grep "MDT[[:digit:]]*"; then
2472 lrs=$(echo $ns | sed 's/.*lru_size=//')
2473 if ! test "$lrs" -eq "${lru_size[count]}"; then
2474 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2475 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2483 run_test 47 "server restart does not make client loss lru_resize settings"
2488 # reformat after this test is needed - if test will failed
2489 # we will have unkillable file at FS
2493 test_48() { # bug 17636
2496 check_mount || return 2
2498 $LFS setstripe -c -1 $MOUNT || return 9
2499 $LFS getstripe $MOUNT || return 10
2501 echo "ok" > $MOUNT/widestripe
2502 $LFS getstripe $MOUNT/widestripe || return 11
2504 trap cleanup_48 EXIT ERR
2506 # fill acl buffer for avoid expand lsm to them
2507 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2508 setfacl -m $acl $MOUNT/widestripe
2511 stat $MOUNT/widestripe || return 12
2516 run_test 48 "too many acls on file"
2518 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2519 test_49() { # bug 17710
2520 local timeout_orig=$TIMEOUT
2521 local ldlm_timeout_orig=$LDLM_TIMEOUT
2522 local LOCAL_TIMEOUT=20
2524 LDLM_TIMEOUT=$LOCAL_TIMEOUT
2525 TIMEOUT=$LOCAL_TIMEOUT
2529 check_mount || return 1
2531 echo "check ldlm_timout..."
2532 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2533 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2534 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2536 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2537 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2540 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2541 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2544 umount_client $MOUNT
2545 stop_ost || return 2
2546 stop_mds || return 3
2548 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
2552 check_mount || return 7
2554 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2555 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2556 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2558 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2559 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2562 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2563 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2566 cleanup || return $?
2568 LDLM_TIMEOUT=$ldlm_timeout_orig
2569 TIMEOUT=$timeout_orig
2571 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
2574 # Test both statfs and lfs df and fail if either one fails
2575 multiop_bg_pause $1 f_
2578 killall -USR1 multiop
2579 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2580 wait $PID || { RC1=$?; log "multiop return error "; }
2587 if [ $RC2 -eq 0 ]; then
2589 log "lazystatfs df failed"
2593 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2599 lctl set_param llite.$FSNAME-*.lazystatfs=1
2602 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2604 cleanup || return $?
2606 run_test 50a "lazystatfs all servers available =========================="
2610 lctl set_param llite.$FSNAME-*.lazystatfs=1
2613 # Wait for client to detect down OST
2614 stop_ost || error "Unable to stop OST1"
2615 wait_osc_import_state mds ost DISCONN
2617 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2619 umount_client $MOUNT || error "Unable to unmount client"
2620 stop_mds || error "Unable to stop MDS"
2622 run_test 50b "lazystatfs all servers down =========================="
2625 start_mds || error "Unable to start MDS"
2626 start_ost || error "Unable to start OST1"
2627 start_ost2 || error "Unable to start OST2"
2628 mount_client $MOUNT || error "Unable to mount client"
2629 lctl set_param llite.$FSNAME-*.lazystatfs=1
2632 # Wait for client to detect down OST
2633 stop_ost || error "Unable to stop OST1"
2634 wait_osc_import_state mds ost DISCONN
2635 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2637 umount_client $MOUNT || error "Unable to unmount client"
2638 stop_ost2 || error "Unable to stop OST2"
2639 stop_mds || error "Unable to stop MDS"
2640 #writeconf to remove all ost2 traces for subsequent tests
2641 writeconf_or_reformat
2643 run_test 50c "lazystatfs one server down =========================="
2646 start_mds || error "Unable to start MDS"
2647 start_ost || error "Unable to start OST1"
2648 start_ost2 || error "Unable to start OST2"
2649 mount_client $MOUNT || error "Unable to mount client"
2650 lctl set_param llite.$FSNAME-*.lazystatfs=1
2653 # Issue the statfs during the window where the client still
2654 # belives the OST to be available but it is in fact down.
2655 # No failure just a statfs which hangs for a timeout interval.
2656 stop_ost || error "Unable to stop OST1"
2657 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2659 umount_client $MOUNT || error "Unable to unmount client"
2660 stop_ost2 || error "Unable to stop OST2"
2661 stop_mds || error "Unable to stop MDS"
2662 #writeconf to remove all ost2 traces for subsequent tests
2663 writeconf_or_reformat
2665 run_test 50d "lazystatfs client/server conn race =========================="
2672 start_mds || return 1
2673 #first client should see only one ost
2674 start_ost || return 2
2675 wait_osc_import_state mds ost FULL
2677 # Wait for client to detect down OST
2678 stop_ost || error "Unable to stop OST1"
2679 wait_osc_import_state mds ost DISCONN
2681 mount_client $MOUNT || error "Unable to mount client"
2682 lctl set_param llite.$FSNAME-*.lazystatfs=0
2684 multiop_bg_pause $MOUNT _f
2688 if [ $RC1 -ne 0 ]; then
2689 log "multiop failed $RC1"
2692 sleep $(( $TIMEOUT+1 ))
2694 [ $? -ne 0 ] && error "process isn't sleep"
2695 start_ost || error "Unable to start OST1"
2696 wait $pid || error "statfs failed"
2699 umount_client $MOUNT || error "Unable to unmount client"
2700 stop_ost || error "Unable to stop OST1"
2701 stop_mds || error "Unable to stop MDS"
2703 run_test 50e "normal statfs all servers down =========================="
2708 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2710 start_mds || error "Unable to start mds"
2711 #first client should see only one ost
2712 start_ost || error "Unable to start OST1"
2713 wait_osc_import_state mds ost FULL
2715 start_ost2 || error "Unable to start OST2"
2716 wait_osc_import_state mds ost2 FULL
2718 # Wait for client to detect down OST
2719 stop_ost2 || error "Unable to stop OST2"
2721 wait_osc_import_state mds ost2 DISCONN
2722 mount_client $MOUNT || error "Unable to mount client"
2723 lctl set_param llite.$FSNAME-*.lazystatfs=0
2725 multiop_bg_pause $MOUNT _f
2729 if [ $RC1 -ne 0 ]; then
2730 log "lazystatfs multiop failed $RC1"
2733 sleep $(( $TIMEOUT+1 ))
2735 [ $? -ne 0 ] && error "process isn't sleep"
2736 start_ost2 || error "Unable to start OST2"
2737 wait $pid || error "statfs failed"
2738 stop_ost2 || error "Unable to stop OST2"
2741 umount_client $MOUNT || error "Unable to unmount client"
2742 stop_ost || error "Unable to stop OST1"
2743 stop_mds || error "Unable to stop MDS"
2744 #writeconf to remove all ost2 traces for subsequent tests
2745 writeconf_or_reformat
2747 run_test 50f "normal statfs one server in down =========================="
2750 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2752 start_ost2 || error "Unable to start OST2"
2753 wait_osc_import_state mds ost2 FULL
2754 wait_osc_import_state client ost2 FULL
2756 local PARAM="${FSNAME}-OST0001.osc.active"
2758 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2759 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2761 umount_client $MOUNT || error "Unable to unmount client"
2762 mount_client $MOUNT || error "Unable to mount client"
2763 # This df should not cause a panic
2766 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2768 umount_client $MOUNT || error "Unable to unmount client"
2769 stop_ost2 || error "Unable to stop OST2"
2770 stop_ost || error "Unable to stop OST1"
2771 stop_mds || error "Unable to stop MDS"
2772 #writeconf to remove all ost2 traces for subsequent tests
2773 writeconf_or_reformat
2775 run_test 50g "deactivated OST should not cause panic====================="
2778 local LOCAL_TIMEOUT=20
2782 check_mount || return 1
2785 $LFS setstripe -c -1 $MOUNT/d1
2786 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2787 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2788 touch $MOUNT/d1/f1 &
2791 start_ost2 || return 2
2793 stop_ost2 || return 3
2795 #writeconf to remove all ost2 traces for subsequent tests
2796 writeconf_or_reformat
2798 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2807 do_node $node mkdir -p $dest
2808 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2810 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2811 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2812 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2814 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2815 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2825 local backup2=${TMP}/backup2
2827 do_node $node mkdir -p $backup2
2828 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2830 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2831 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2832 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2834 do_node $node "diff -rq $backup $backup2"
2835 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2837 local xattrs2=${TMP}/xattrs2
2838 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2839 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2841 do_node $node "diff $xattrs $xattrs2"
2842 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2844 do_node $node "rm -rf $backup2 $xattrs2"
2845 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2849 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2850 skip "Only applicable to ldiskfs-based MDTs"
2855 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2857 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2859 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2862 local ost1mnt=$(facet_mntpt ost1)
2863 local ost1node=$(facet_active_host ost1)
2864 local ost1tmp=$TMP/conf52
2868 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2869 touch $TMP/modified_first
2870 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2871 local mtime=$(stat -c %Y $TMP/modified_first)
2872 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2874 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2877 $LFS setstripe -c -1 -S 1M $DIR/$tdir
2878 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2880 for (( i=0; i < nrfiles; i++ )); do
2881 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2882 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2888 echo backup files to $TMP/files
2889 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2890 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2891 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2893 umount_client $MOUNT
2894 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2896 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2898 echo mount ost1 as ldiskfs
2899 do_node $ost1node mkdir -p $ost1mnt
2900 [ $? -eq 0 ] || { error "Unable to create $ost1mnt"; return 23; }
2901 if ! do_node $ost1node test -b $ost1_dev; then
2904 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
2906 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2909 echo backup objects to $ost1tmp/objects
2910 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
2911 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2912 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
2914 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2916 # move objects to lost+found
2917 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2918 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2921 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2922 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2924 # compare restored objects against saved ones
2925 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2926 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2928 do_node $ost1node "umount $ost1mnt"
2929 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2932 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2934 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2937 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2938 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2940 rm -rf $TMP/files $TMP/file_xattrs
2941 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2942 do_node $ost1node "rm -rf $ost1tmp"
2943 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2946 run_test 52 "check recovering objects from lost+found"
2948 # Checks threads_min/max/started for some service
2950 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2951 # parameter pattern prefix like 'ost.*.ost'.
2964 local msg="Insane $modname thread counts"
2965 local ncpts=$(check_cpt_number $facet)
2969 check_mount || return 41
2971 # We need to expand $parampat, but it may match multiple parameters, so
2972 # we'll pick the first one
2973 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2974 error "Couldn't expand ${parampat}.threads_min parameter name"
2978 # Remove the .threads_min part
2979 paramp=${paramp%.threads_min}
2981 # Check for sanity in defaults
2982 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2983 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2984 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2985 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2986 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
2987 nthrs=$(expr $tmax - $tmin)
2988 if [ $nthrs -lt $ncpts ]; then
2994 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
2995 skip_env "module parameter forced $facet thread count" &&
2996 tmin=3 && tmax=$((3 * tmax))
2998 # Check that we can change min/max
2999 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + nthrs))"
3000 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - nthrs))"
3001 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3002 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3003 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) && $tmax2 == ($tmax - $nthrs)))' || return $?
3005 # Check that we can set min/max to the same value
3006 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3007 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
3008 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3009 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3010 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
3012 # Check that we can't set max < min
3013 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
3014 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3015 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3016 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
3018 # We need to ensure that we get the module options desired; to do this
3019 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
3020 LOAD_MODULES_REMOTE=true
3023 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
3024 setmodopts -a $modname "$newvalue" oldvalue
3028 check_mount || return 41
3030 # Restore previous setting of MODOPTS_*
3031 setmodopts $modname "$oldvalue"
3033 # Check that $opts took
3034 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
3035 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
3036 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
3037 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
3046 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
3049 run_test 53a "check OSS thread count params"
3053 local mds=$(do_facet $SINGLEMDS "lctl get_param -N mds.*.*.threads_max \
3055 if [ -z "$mds" ]; then
3056 #running this on an old MDT
3057 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
3059 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
3063 run_test 53b "check MDS thread count params"
3066 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3067 skip "Only applicable to ldiskfs-based MDTs"
3071 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p
3072 [ $? -eq 0 ] || error "llverdev failed!"
3075 run_test 54a "test llverdev and partial verify of device"
3078 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3079 skip "Only applicable to ldiskfs-based MDTs"
3084 run_llverfs $MOUNT -p
3085 [ $? -eq 0 ] || error "llverfs failed!"
3088 run_test 54b "test llverfs and partial verify of filesystem"
3092 local max_ost_index=$1
3093 echo -n $(((max_ost_index + 1) * 8))
3097 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3098 skip "Only applicable to ldiskfs-based MDTs"
3102 local mdsdev=$(mdsdevname 1)
3103 local mdsvdev=$(mdsvdevname 1)
3107 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
3109 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
3110 --reformat $(ostdevname 1) $(ostvdevname 1)
3116 echo checking size of lov_objid for ost index $i
3117 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
3118 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
3119 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
3121 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
3128 run_test 55 "check lov_objid size"
3131 local mds_journal_size_orig=$MDSJOURNALSIZE
3135 for num in $(seq 1 $MDSCOUNT); do
3136 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3137 --reformat $(mdsdevname $num) $(mdsvdevname $num)
3139 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=1000 --reformat \
3140 $(ostdevname 1) $(ostvdevname 1)
3141 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=10000 --reformat \
3142 $(ostdevname 2) $(ostvdevname 2)
3146 start_ost2 || error "Unable to start second ost"
3147 mount_client $MOUNT || error "Unable to mount client"
3151 MDSJOURNALSIZE=$mds_journal_size_orig
3154 run_test 56 "check big indexes"
3156 test_57a() { # bug 22656
3157 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
3158 writeconf_or_reformat
3159 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
3161 start_ost && error "OST registration from failnode should fail"
3164 run_test 57a "initial registration from failnode should fail (should return errs)"
3167 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
3168 writeconf_or_reformat
3169 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
3171 start_ost || error "OST registration from servicenode should not fail"
3174 run_test 57b "initial registration from servicenode should not fail"
3177 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
3180 test_58() { # bug 22658
3181 if [ $(facet_fstype mds) != ldiskfs ]; then
3182 skip "Only applicable to ldiskfs-based MDTs"
3187 createmany -o $DIR/$tdir/$tfile-%d 100
3188 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
3189 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
3190 do_facet mds "lctl set_param fail_loc=0x601"
3191 unlinkmany $DIR/$tdir/$tfile-%d 100
3193 local MNTDIR=$(facet_mntpt mds)
3194 # remove all files from the OBJECTS dir
3195 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
3196 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
3197 do_facet mds "umount $MNTDIR"
3198 # restart MDS with missing llog files
3200 do_facet mds "lctl set_param fail_loc=0"
3203 run_test 58 "missing llog files must not prevent MDT from mounting"
3206 start_mgsmds >> /dev/null
3207 local C1=$(count_osts)
3208 if [ $C1 -eq 0 ]; then
3209 start_ost >> /dev/null
3213 echo "original ost count: $C1 (expect > 0)"
3214 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
3215 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
3216 local C2=$(count_osts)
3217 echo "after mdt writeconf count: $C2 (expect 0)"
3218 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
3219 echo "OST start without writeconf should fail:"
3220 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
3221 echo "OST start with writeconf should succeed:"
3222 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
3223 local C3=$(count_osts)
3224 echo "after ost writeconf count: $C3 (expect 1)"
3225 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
3226 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
3227 local C4=$(count_osts)
3228 echo "after ost2 writeconf count: $C4 (expect 2)"
3229 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
3230 stop_ost2 >> /dev/null
3231 cleanup_nocli >> /dev/null
3232 #writeconf to remove all ost2 traces for subsequent tests
3233 writeconf_or_reformat
3235 run_test 59 "writeconf mount option"
3237 test_60() { # LU-471
3240 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3241 skip "Only applicable to ldiskfs-based MDTs"
3245 for num in $(seq $MDSCOUNT); do
3246 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3247 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
3248 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3252 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
3254 [ $rc -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
3256 # MDT default has dirdata feature
3257 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
3258 # we disable uninit_bg feature
3259 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
3260 # we set stride extended options
3261 echo $dump | grep stride > /dev/null || error "stride is not set"
3264 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
3267 local reformat=false
3269 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
3270 { skip "Need MDS version at least 2.1.53"; return 0; }
3272 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
3273 ! large_xattr_enabled; then
3275 LDISKFS_MKFS_OPTS+=" -O large_xattr"
3277 for num in $(seq $MDSCOUNT); do
3278 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
3279 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3280 error "add mds $num failed"
3284 setup_noconfig || error "setting up the filesystem failed"
3285 client_up || error "starting client failed"
3287 local file=$DIR/$tfile
3290 local large_value="$(generate_string $(max_xattr_size))"
3291 local small_value="bar"
3293 local name="trusted.big"
3294 log "save large xattr $name on $file"
3295 setfattr -n $name -v $large_value $file ||
3296 error "saving $name on $file failed"
3298 local new_value=$(get_xattr_value $name $file)
3299 [[ "$new_value" != "$large_value" ]] &&
3300 error "$name different after saving"
3302 log "shrink value of $name on $file"
3303 setfattr -n $name -v $small_value $file ||
3304 error "shrinking value of $name on $file failed"
3306 new_value=$(get_xattr_value $name $file)
3307 [[ "$new_value" != "$small_value" ]] &&
3308 error "$name different after shrinking"
3310 log "grow value of $name on $file"
3311 setfattr -n $name -v $large_value $file ||
3312 error "growing value of $name on $file failed"
3314 new_value=$(get_xattr_value $name $file)
3315 [[ "$new_value" != "$large_value" ]] &&
3316 error "$name different after growing"
3318 log "check value of $name on $file after remounting MDS"
3320 new_value=$(get_xattr_value $name $file)
3321 [[ "$new_value" != "$large_value" ]] &&
3322 error "$name different after remounting MDS"
3324 log "remove large xattr $name from $file"
3325 setfattr -x $name $file || error "removing $name from $file failed"
3330 LDISKFS_MKFS_OPTS=${LDISKFS_MKFS_OPTS% -O large_xattr}
3334 run_test 61 "large xattr"
3337 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3338 skip "Only applicable to ldiskfs-based MDTs"
3343 local mdsdev=$(mdsdevname 1)
3344 local ostdev=$(ostdevname 1)
3346 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
3347 { skip "Need MDS version at least 2.2.51"; return 0; }
3349 echo "disable journal for mds"
3350 do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
3351 start_mds && error "MDT start should fail"
3352 echo "disable journal for ost"
3353 do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
3354 start_ost && error "OST start should fail"
3355 cleanup || return $?
3358 run_test 62 "start with disabled journal"
3361 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3362 skip "Only applicable to ldiskfs-based MDTs"
3366 local inode_slab=$(do_facet $SINGLEMDS \
3367 "awk '/ldiskfs_inode_cache/ { print \\\$5 }' /proc/slabinfo")
3368 if [ -z "$inode_slab" ]; then
3369 skip "ldiskfs module has not been loaded"
3373 echo "$inode_slab ldisk inodes per page"
3374 [ "$inode_slab" -ge "3" ] ||
3375 error "ldisk inode size is too big, $inode_slab objs per page"
3378 run_test 63 "Verify each page can at least hold 3 ldisk inodes"
3383 start_ost2 || error "Unable to start second ost"
3384 mount_client $MOUNT || error "Unable to mount client"
3385 stop_ost2 || error "Unable to stop second ost"
3387 $LFS df --lazy || error "lfs df failed"
3388 cleanup || return $?
3389 #writeconf to remove all ost2 traces for subsequent tests
3390 writeconf_or_reformat
3392 run_test 64 "check lfs df --lazy "
3394 test_65() { # LU-2237
3395 # Currently, the test is only valid for ldiskfs backend
3396 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
3397 skip "non-ldiskfs backend" && return
3399 local devname=$(mdsdevname ${SINGLEMDS//mds/})
3400 local brpt=$(facet_mntpt brpt)
3403 if ! do_facet $SINGLEMDS "test -b $devname"; then
3408 local obj=$(do_facet $SINGLEMDS \
3409 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
3411 if [ -z "$obj" ]; then
3412 # The MDT may be just re-formatted, mount the MDT for the
3413 # first time to guarantee the "last_rcvd" file is there.
3414 start_mds || error "fail to mount the MDS for the first time"
3418 # remove the "last_rcvd" file
3419 do_facet $SINGLEMDS "mkdir -p $brpt"
3420 do_facet $SINGLEMDS \
3421 "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
3422 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
3423 do_facet $SINGLEMDS "umount $brpt"
3425 # restart MDS, the "last_rcvd" file should be recreated.
3426 start_mds || error "fail to restart the MDS"
3428 obj=$(do_facet $SINGLEMDS \
3429 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
3430 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
3432 run_test 65 "re-create the lost last_rcvd file when server mount"
3436 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
3437 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
3439 echo "replace_nids should fail if MDS, OSTs and clients are UP"
3440 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
3441 error "replace_nids fail"
3443 umount_client $MOUNT || error "unmounting client failed"
3444 echo "replace_nids should fail if MDS and OSTs are UP"
3445 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
3446 error "replace_nids fail"
3449 echo "replace_nids should fail if MDS is UP"
3450 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
3451 error "replace_nids fail"
3453 stop_mds || error "stopping mds failed"
3455 if combined_mgs_mds; then
3456 start_mds "-o nosvc" ||
3457 error "starting mds with nosvc option failed"
3460 echo "command should accept two parameters"
3461 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
3462 error "command should accept two params"
3464 echo "correct device name should be passed"
3465 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
3466 error "wrong devname"
3468 echo "wrong nids list should not destroy the system"
3469 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
3472 echo "replace OST nid"
3473 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
3474 error "replace nids failed"
3476 echo "command should accept two parameters"
3477 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
3478 error "command should accept two params"
3480 echo "wrong nids list should not destroy the system"
3481 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
3484 echo "replace MDS nid"
3485 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
3486 error "replace nids failed"
3488 if ! combined_mgs_mds ; then
3495 check_mount || error "error after nid replace"
3499 run_test 66 "replace nids"
3502 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3505 start_mdt 1 || error "MDT0 start fail"
3507 start_ost || error "OST0 start fail"
3509 start_mdt 2 || error "MDT1 start fail"
3511 mount_client $MOUNT || error "mount client fails"
3513 mkdir -p $DIR/$tdir || error "create dir fail"
3515 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3516 error "create remote dir fail"
3518 rm -rf $DIR/$tdir || error "delete dir fail"
3519 cleanup || return $?
3521 run_test 70a "start MDT0, then OST, then MDT1"
3524 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3527 start_ost || error "OST0 start fail"
3529 start_mdt 1 || error "MDT0 start fail"
3530 start_mdt 2 || error "MDT1 start fail"
3532 mount_client $MOUNT || error "mount client fails"
3534 mkdir -p $DIR/$tdir || error "create dir fail"
3536 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3537 error "create remote dir fail"
3539 rm -rf $DIR/$tdir || error "delete dir fail"
3541 cleanup || return $?
3543 run_test 70b "start OST, MDT1, MDT0"
3546 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3549 start_mdt 1 || error "MDT0 start fail"
3550 start_mdt 2 || error "MDT1 start fail"
3551 start_ost || error "OST0 start fail"
3553 mount_client $MOUNT || error "mount client fails"
3554 stop_mdt 1 || error "MDT1 start fail"
3556 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
3557 echo "deactivate $mdc_for_mdt1"
3558 $LCTL --device $mdc_for_mdt1 deactivate || return 1
3560 mkdir -p $DIR/$tdir && error "mkdir succeed"
3562 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
3563 error "create remote dir succeed"
3565 cleanup || return $?
3567 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
3570 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3573 start_mdt 1 || error "MDT0 start fail"
3574 start_mdt 2 || error "MDT1 start fail"
3575 start_ost || error "OST0 start fail"
3577 mount_client $MOUNT || error "mount client fails"
3579 stop_mdt 2 || error "MDT1 start fail"
3581 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
3583 echo "deactivate $mdc_for_mdt2"
3584 $LCTL --device $mdc_for_mdt2 deactivate ||
3585 error "set $mdc_for_mdt2 deactivate failed"
3587 mkdir -p $DIR/$tdir || error "mkdir fail"
3588 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
3589 error "create remote dir succeed"
3591 rm -rf $DIR/$tdir || error "delete dir fail"
3593 cleanup || return $?
3595 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
3598 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3599 if combined_mgs_mds; then
3600 skip "needs separate MGS/MDT" && return
3604 start_mdt 1 || error "MDT0 start fail"
3605 start_ost || error "OST0 start fail"
3606 start_mdt 2 || error "MDT1 start fail"
3607 start_ost2 || error "OST1 start fail"
3609 mount_client $MOUNT || error "mount client fails"
3611 mkdir -p $DIR/$tdir || error "mkdir fail"
3612 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3613 error "create remote dir succeed"
3615 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
3616 rm -rf $DIR/$tdir || error "delete dir fail"
3618 umount_client $MOUNT
3619 stop_mdt 1 || error "MDT0 stop fail"
3620 stop_mdt 2 || error "MDT1 stop fail"
3621 stop_ost || error "OST0 stop fail"
3622 stop_ost2 || error "OST1 stop fail"
3624 run_test 71a "start MDT0 OST0, MDT1, OST1"
3627 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3628 if combined_mgs_mds; then
3629 skip "needs separate MGS/MDT" && return
3633 start_mdt 2 || error "MDT1 start fail"
3634 start_ost || error "OST0 start fail"
3635 start_mdt 1 || error "MDT0 start fail"
3636 start_ost2 || error "OST1 start fail"
3638 mount_client $MOUNT || error "mount client fails"
3640 mkdir -p $DIR/$tdir || error "mkdir fail"
3641 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3642 error "create remote dir succeed"
3644 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
3645 rm -rf $DIR/$tdir || error "delete dir fail"
3647 umount_client $MOUNT
3648 stop_mdt 1 || error "MDT0 stop fail"
3649 stop_mdt 2 || error "MDT1 stop fail"
3650 stop_ost || error "OST0 stop fail"
3651 stop_ost2 || error "OST1 stop fail"
3653 run_test 71b "start MDT1, OST0, MDT0, OST1"
3656 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3657 if combined_mgs_mds; then
3658 skip "needs separate MGS/MDT" && return
3662 start_ost || error "OST0 start fail"
3663 start_ost2 || error "OST1 start fail"
3664 start_mdt 2 || error "MDT1 start fail"
3665 start_mdt 1 || error "MDT0 start fail"
3667 mount_client $MOUNT || error "mount client fails"
3669 mkdir -p $DIR/$tdir || error "mkdir fail"
3670 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3671 error "create remote dir succeed"
3673 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
3674 rm -rf $DIR/$tdir || error "delete dir fail"
3676 umount_client $MOUNT
3677 stop_mdt 1 || error "MDT0 stop fail"
3678 stop_mdt 2 || error "MDT1 stop fail"
3679 stop_ost || error "OST0 stop fail"
3680 stop_ost2 || error "OST1 stop fail"
3683 run_test 71c "start OST0, OST1, MDT1, MDT0"
3686 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3687 if combined_mgs_mds; then
3688 skip "needs separate MGS/MDT" && return
3692 start_ost || error "OST0 start fail"
3693 start_mdt 2 || error "MDT0 start fail"
3694 start_mdt 1 || error "MDT0 start fail"
3695 start_ost2 || error "OST1 start fail"
3697 mount_client $MOUNT || error "mount client fails"
3699 mkdir -p $DIR/$tdir || error "mkdir fail"
3700 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3701 error "create remote dir succeed"
3703 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
3704 rm -rf $DIR/$tdir || error "delete dir fail"
3706 umount_client $MOUNT
3707 stop_mdt 1 || error "MDT0 stop fail"
3708 stop_mdt 2 || error "MDT1 stop fail"
3709 stop_ost || error "OST0 stop fail"
3710 stop_ost2 || error "OST1 stop fail"
3713 run_test 71d "start OST0, MDT1, MDT0, OST1"
3716 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3717 if combined_mgs_mds; then
3718 skip "needs separate MGS/MDT" && return
3722 start_ost || error "OST0 start fail"
3723 start_mdt 2 || error "MDT1 start fail"
3724 start_ost2 || error "OST1 start fail"
3725 start_mdt 1 || error "MDT0 start fail"
3727 mount_client $MOUNT || error "mount client fails"
3729 mkdir -p $DIR/$tdir || error "mkdir fail"
3730 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
3731 error "create remote dir succeed"
3733 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
3734 rm -rf $DIR/$tdir || error "delete dir fail"
3736 umount_client $MOUNT
3737 stop_mdt 1 || error "MDT0 stop fail"
3738 stop_mdt 2 || error "MDT1 stop fail"
3739 stop_ost || error "OST0 stop fail"
3740 stop_ost2 || error "OST1 stop fail"
3743 run_test 71e "start OST0, MDT1, OST1, MDT0"
3745 if ! combined_mgs_mds ; then