3 # FIXME - there is no reason to use all of these different return codes,
4 # espcially when most of them are mapped to something else anyway.
5 # The tests should use error() to describe the failure more clearly,
6 # and reduce the need to look into the tests to see what failed.
12 # bug number for skipped test: LU-2828
13 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 59 64"
14 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18 if [ -r /etc/SuSE-release ]
20 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
21 local patchlev=`grep PATCHLEVEL /etc/SuSE-release \
23 if [ $vers -eq 11 ] && [ $patchlev -eq 2 ]
31 if is_sles11; then # LU-2181
32 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 23a 34b"
35 if [ "$FAILURE_MODE" = "HARD" ]; then
36 CONFIG_EXCEPTIONS="24a " && \
37 echo "Except the tests: $CONFIG_EXCEPTIONS for FAILURE_MODE=$FAILURE_MODE, bug 23573" && \
38 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
41 # bug number for skipped test:
42 # a tool to create lustre filesystem images
43 ALWAYS_EXCEPT="32newtarball $ALWAYS_EXCEPT"
46 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
48 PTLDEBUG=${PTLDEBUG:--1}
50 LUSTRE=${LUSTRE:-`dirname $0`/..}
51 RLUSTRE=${RLUSTRE:-$LUSTRE}
52 export MULTIOP=${MULTIOP:-multiop}
54 . $LUSTRE/tests/test-framework.sh
56 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
58 # use small MDS + OST size to speed formatting time
59 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
60 # STORED_MDSSIZE is used in test_18
61 STORED_MDSSIZE=$MDSSIZE
62 STORED_OSTSIZE=$OSTSIZE
66 if ! combined_mgs_mds; then
67 # bug number for skipped test: 23954
68 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
71 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
72 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
73 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
76 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
77 # bug number for skipped test: LU-2778 LU-4444
78 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 57b 69"
83 require_dsh_mds || exit 0
84 require_dsh_ost || exit 0
86 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45 69"
92 # The MGS must be started before the OSTs for a new fs, so start
93 # and stop to generate the startup logs.
96 wait_osc_import_state mds ost FULL
101 reformat_and_config() {
103 if ! combined_mgs_mds ; then
109 writeconf_or_reformat() {
110 # There are at most 2 OSTs for write_conf test
111 # who knows if/where $TUNEFS is installed?
112 # Better reformat if it fails...
113 writeconf_all $MDSCOUNT 2 ||
114 { echo "tunefs failed, reformatting instead" &&
115 reformat_and_config && return 0; }
125 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
131 local dev=$(mdsdevname $num)
134 echo "start mds service on `facet_active_host $facet`"
135 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
141 local dev=$(mdsdevname $num)
144 echo "stop mds service on `facet_active_host $facet`"
145 # These tests all use non-failover stop
146 stop $facet -f || return 97
152 for num in $(seq $MDSCOUNT); do
153 start_mdt $num $@ || return 94
158 if ! combined_mgs_mds ; then
166 for num in $(seq $MDSCOUNT); do
167 stop_mdt $num || return 97
172 echo "stop mgs service on `facet_active_host mgs`"
173 # These tests all use non-failover stop
174 stop mgs -f || return 97
178 echo "start ost1 service on `facet_active_host ost1`"
179 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
183 echo "stop ost1 service on `facet_active_host ost1`"
184 # These tests all use non-failover stop
185 stop ost1 -f || return 98
189 echo "start ost2 service on `facet_active_host ost2`"
190 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
194 echo "stop ost2 service on `facet_active_host ost2`"
195 # These tests all use non-failover stop
196 stop ost2 -f || return 93
201 echo "mount $FSNAME on ${MOUNTPATH}....."
202 zconf_mount `hostname` $MOUNTPATH || return 96
206 local mountopt="-o remount,$1"
208 echo "remount '$1' lustre on ${MOUNTPATH}....."
209 zconf_mount `hostname` $MOUNTPATH "$mountopt" || return 96
214 echo "umount lustre on ${MOUNTPATH}....."
215 zconf_umount `hostname` $MOUNTPATH || return 97
218 manual_umount_client(){
221 echo "manual umount lustre on ${MOUNT}...."
222 do_facet client "umount -d ${FORCE} $MOUNT"
228 start_mds || error "MDT start failed"
229 start_ost || error "OST start failed"
230 mount_client $MOUNT || error "client start failed"
231 client_up || error "client_up failed"
235 if ! combined_mgs_mds ; then
244 unload_modules_conf () {
245 if combined_mgs_mds || ! local_mode; then
246 unload_modules || return 1
251 stop_ost || return 202
252 stop_mds || return 201
253 unload_modules_conf || return 203
257 umount_client $MOUNT || return 200
258 cleanup_nocli || return $?
262 do_facet client "cp /etc/passwd $DIR/a" || return 71
263 do_facet client "rm $DIR/a" || return 72
264 # make sure lustre is actually mounted (touch will block,
265 # but grep won't, so do it after)
266 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
267 echo "setup single mount lustre success"
271 do_facet client "touch $DIR/a" || return 71
272 do_facet client "rm $DIR/a" || return 72
273 do_facet client "touch $DIR2/a" || return 73
274 do_facet client "rm $DIR2/a" || return 74
275 echo "setup double mount lustre success"
280 if [ "$ONLY" == "setup" ]; then
285 if [ "$ONLY" == "cleanup" ]; then
292 #create single point mountpoint
298 check_mount || return 41
301 run_test 0 "single mount setup"
304 start_mds || error "MDT start failed"
306 echo "start ost second time..."
307 start_ost && error "2nd OST start should fail"
308 mount_client $MOUNT || error "client start failed"
309 check_mount || return 42
312 run_test 1 "start up ost twice (should return errors)"
316 echo "start mds second time.."
317 start_mdt 1 && error "2nd MDT start should fail"
320 check_mount || return 43
323 run_test 2 "start up mds twice (should return err)"
327 #mount.lustre returns an error if already in mtab
328 mount_client $MOUNT && error "2nd client mount should fail"
329 check_mount || return 44
332 run_test 3 "mount client twice (should return err)"
336 touch $DIR/$tfile || return 85
340 # ok for ost to fail shutdown
341 if [ 202 -ne $eno ]; then
346 run_test 4 "force cleanup ost, then cleanup"
348 test_5a() { # was test_5
350 touch $DIR/$tfile || return 1
351 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
353 stop_mds -f || return 2
355 # cleanup may return an error from the failed
356 # disconnects; for now I'll consider this successful
357 # if all the modules have unloaded.
361 echo "killing umount"
362 kill -TERM $UMOUNT_PID
363 echo "waiting for umount to finish"
365 if grep " $MOUNT " /proc/mounts; then
366 echo "test 5: /proc/mounts after failed umount"
370 echo "killing umount"
371 kill -TERM $UMOUNT_PID
372 echo "waiting for umount to finish"
374 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
378 # stop_mds is a no-op here, and should not fail
379 cleanup_nocli || return $?
380 # df may have lingering entry
382 # mtab may have lingering entry
386 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
388 grep -q $MOUNT" " /etc/mtab || break
389 echo "Waiting /etc/mtab updated ... "
390 WAIT=$(( WAIT + sleep))
392 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
393 echo "/etc/mtab updated in $WAIT secs"
395 run_test 5a "force cleanup mds, then cleanup"
403 grep " $MOUNT " /etc/mtab && \
404 error false "unexpected entry in mtab before mount" && return 10
408 if ! combined_mgs_mds ; then
409 trap cleanup_5b EXIT ERR
414 [ -d $MOUNT ] || mkdir -p $MOUNT
415 mount_client $MOUNT && rc=1
416 grep " $MOUNT " /etc/mtab && \
417 error "$MOUNT entry in mtab after failed mount" && rc=11
419 # stop_mds is a no-op here, and should not fail
420 cleanup_nocli || rc=$?
421 if ! combined_mgs_mds ; then
426 run_test 5b "Try to start a client with no MGS (should return errs)"
429 grep " $MOUNT " /etc/mtab && \
430 error false "unexpected entry in mtab before mount" && return 10
435 [ -d $MOUNT ] || mkdir -p $MOUNT
436 local oldfs="${FSNAME}"
437 FSNAME="wrong.${FSNAME}"
438 mount_client $MOUNT || :
440 grep " $MOUNT " /etc/mtab && \
441 error "$MOUNT entry in mtab after failed mount" && rc=11
443 cleanup_nocli || rc=$?
446 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
449 grep " $MOUNT " /etc/mtab && \
450 error false "unexpected entry in mtab before mount" && return 10
456 mount_client $MOUNT || rc=1
458 grep " $MOUNT " /etc/mtab && \
459 error "$MOUNT entry in mtab after unmount" && rc=11
462 run_test 5d "mount with ost down"
465 grep " $MOUNT " /etc/mtab && \
466 error false "unexpected entry in mtab before mount" && return 10
472 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
473 do_facet client "lctl set_param fail_loc=0x80000506"
474 mount_client $MOUNT || echo "mount failed (not fatal)"
476 grep " $MOUNT " /etc/mtab && \
477 error "$MOUNT entry in mtab after unmount" && rc=11
480 run_test 5e "delayed connect, don't crash (bug 10268)"
483 if combined_mgs_mds ; then
484 skip "combined mgs and mds"
488 grep " $MOUNT " /etc/mtab && \
489 error false "unexpected entry in mtab before mount" && return 10
493 [ -d $MOUNT ] || mkdir -p $MOUNT
494 mount_client $MOUNT &
496 echo client_mount pid is $pid
500 if ! ps -f -p $pid >/dev/null; then
503 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
504 error "mount returns $rc, expected to hang"
513 # mount should succeed after start mds
516 [ $rc -eq 0 ] || error "mount returned $rc"
517 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
521 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
526 mount_client ${MOUNT} || return 87
527 touch $DIR/a || return 86
530 run_test 6 "manual umount, then mount again"
535 cleanup_nocli || return $?
537 run_test 7 "manual umount, then cleanup"
542 check_mount2 || return 45
543 umount_client $MOUNT2
546 run_test 8 "double mount setup"
551 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
552 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
554 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
555 if [ "$CHECK_PTLDEBUG" ] && { \
556 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
557 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
558 echo "lnet.debug success"
560 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
563 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
564 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
565 echo "lnet.subsystem_debug success"
567 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
570 stop_ost || return $?
572 run_test 9 "test ptldebug and subsystem for mkfs"
580 do_facet $facet "test -b $dev" || rc=1
581 if [[ "$size" ]]; then
582 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
583 awk '($3 == "in") { print $1 }')
584 [[ $in = "1+0" ]] || rc=1
590 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
591 # But with new MDS stack we don't care about the mode of local objects
592 # anymore, so this test is removed. See bug 22944 for more details.
596 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
597 skip "Only applicable to ldiskfs-based MDTs"
602 check_mount || return 41
605 echo "Remove mds config log"
606 if ! combined_mgs_mds ; then
610 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
611 $(mgsdevname) || 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 start_ost || return 1
699 stop_ost -f || return 2
701 run_test 19b "start/stop OSTs without MDS"
704 # first format the ost/mdt
708 check_mount || return 43
710 remount_client ro $MOUNT || return 44
711 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
712 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
713 remount_client rw $MOUNT || return 47
715 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
716 MCNT=`grep -c $MOUNT /etc/mtab`
717 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
722 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
727 wait_osc_import_state mds ost FULL
731 run_test 21a "start mds before ost, stop ost first"
736 wait_osc_import_state mds ost FULL
740 run_test 21b "start ost before mds, stop mds first"
746 wait_osc_import_state mds ost2 FULL
750 #writeconf to remove all ost2 traces for subsequent tests
751 writeconf_or_reformat
753 run_test 21c "start mds between two osts, stop mds last"
756 if combined_mgs_mds ; then
757 skip "need separate mgs device" && return 0
767 wait_osc_import_state mds ost2 FULL
773 #writeconf to remove all ost2 traces for subsequent tests
774 writeconf_or_reformat
777 run_test 21d "start mgs then ost and then mds"
782 echo Client mount with ost in logs, but none running
784 # wait until mds connected to ost and open client connection
785 wait_osc_import_state mds ost FULL
788 # check_mount will block trying to contact ost
789 mcreate $DIR/$tfile || return 40
790 rm -f $DIR/$tfile || return 42
794 echo Client mount with a running ost
797 # if gss enabled, wait full time to let connection from
798 # mds to ost be established, due to the mismatch between
799 # initial connect timeout and gss context negotiation timeout.
800 # This perhaps could be remove after AT landed.
801 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
802 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
805 wait_osc_import_state mds ost FULL
806 wait_osc_import_state client ost FULL
807 check_mount || return 41
812 run_test 22 "start a client before osts (should return errs)"
814 test_23a() { # was test_23
818 # force down client so that recovering mds waits for reconnect
819 local running=$(grep -c $MOUNT /proc/mounts) || true
820 if [ $running -ne 0 ]; then
821 echo "Stopping client $MOUNT (opts: -f)"
825 # enter recovery on mds
827 # try to start a new client
828 mount_client $MOUNT &
830 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
831 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
832 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
834 ps --ppid $MOUNT_LUSTRE_PID
835 echo "waiting for mount to finish"
837 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
838 # SIGTERM works but it does not spread to offspring processses
839 kill -s TERM $MOUNT_PID
840 kill -s TERM $MOUNT_LUSTRE_PID
841 # we can not wait $MOUNT_PID because it is not a child of this shell
847 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
849 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
850 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
853 [ -z "$PID1" -a -z "$PID2" ] && break
854 echo "waiting for mount to finish ... "
855 WAIT=$(( WAIT + sleep))
857 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
858 error "MOUNT_PID $MOUNT_PID and "\
859 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
862 stop_mds || error "stopping MDSes failed"
863 stop_ost || error "stopping OSSes failed"
865 run_test 23a "interrupt client during recovery mount delay"
870 test_23b() { # was test_23
873 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
874 lctl set_param fail_loc=0x80000313
878 run_test 23b "Simulate -EINTR during mount"
880 fs2mds_HOST=$mds_HOST
881 fs2ost_HOST=$ost_HOST
883 MDSDEV1_2=$fs2mds_DEV
884 OSTDEV1_2=$fs2ost_DEV
885 OSTDEV2_2=$fs3ost_DEV
889 echo "umount $MOUNT2 ..."
890 umount $MOUNT2 || true
891 echo "stopping fs2mds ..."
892 stop fs2mds -f || true
893 echo "stopping fs2ost ..."
894 stop fs2ost -f || true
898 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
900 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
901 is_blkdev $SINGLEMDS $MDSDEV && \
902 skip_env "mixed loopback and real device not working" && return
905 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
907 local fs2mdsdev=$(mdsdevname 1_2)
908 local fs2ostdev=$(ostdevname 1_2)
909 local fs2mdsvdev=$(mdsvdevname 1_2)
910 local fs2ostvdev=$(ostvdevname 1_2)
912 # test 8-char fsname as well
913 local FSNAME2=test1234
915 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
916 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
918 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
919 --reformat $fs2ostdev $fs2ostvdev || exit 10
922 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
923 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
925 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || return 1
927 check_mount || return 2
928 # files written on 1 should not show up on 2
929 cp /etc/passwd $DIR/$tfile
931 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
934 cp /etc/passwd $MOUNT2/b || return 3
935 rm $MOUNT2/b || return 4
936 # 2 is actually mounted
937 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
939 facet_failover fs2mds
940 facet_failover fs2ost
943 # the MDS must remain up until last MDT
945 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
946 [ -z "$MDS" ] && error "No MDT" && return 8
948 cleanup_nocli || return 6
950 run_test 24a "Multiple MDTs on a single node"
953 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
955 if [ -z "$fs2mds_DEV" ]; then
956 local dev=${SINGLEMDS}_dev
958 is_blkdev $SINGLEMDS $MDSDEV && \
959 skip_env "mixed loopback and real device not working" && return
962 local fs2mdsdev=$(mdsdevname 1_2)
963 local fs2mdsvdev=$(mdsvdevname 1_2)
965 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
966 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
968 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
971 run_test 24b "Multiple MGSs on a single node (should return err)"
975 check_mount || return 2
976 local MODULES=$($LCTL modules | awk '{ print $2 }')
977 rmmod $MODULES 2>/dev/null || true
980 run_test 25 "Verify modules are referenced"
984 # we need modules before mount for sysctl, so make sure...
985 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
986 #define OBD_FAIL_MDS_FS_SETUP 0x135
987 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
988 start_mds && echo MDS started && return 1
989 lctl get_param -n devices
990 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
991 [ $DEVS -gt 0 ] && return 2
992 # start mds to drop writeconf setting
993 start_mds || return 3
995 unload_modules_conf || return $?
997 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1000 start_ost || return 1
1001 start_mds || return 2
1002 echo "Requeue thread should have started: "
1003 ps -e | grep ll_cfg_requeue
1004 set_conf_param_and_check ost1 \
1005 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1006 "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
1009 run_test 27a "Reacquire MGS lock if OST started first"
1014 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1015 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1017 facet_failover $SINGLEMDS
1018 set_conf_param_and_check $SINGLEMDS \
1019 "lctl get_param -n mdt.$device.identity_acquire_expire" \
1020 "$device.mdt.identity_acquire_expire" || return 3
1021 set_conf_param_and_check client \
1022 "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight"\
1023 "$device.mdc.max_rpcs_in_flight" || return 4
1027 run_test 27b "Reacquire MGS lock after failover"
1031 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1032 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1034 FINAL=$(($ORIG + 1))
1035 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL || return 3
1036 FINAL=$(($FINAL + 1))
1037 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL || return 4
1038 umount_client $MOUNT || return 200
1041 if [ $RESULT -ne $FINAL ]; then
1042 echo "New config not seen: wanted $FINAL got $RESULT"
1045 echo "New config success: got $RESULT"
1047 set_conf_param_and_check client "$TEST" "$PARAM" $ORIG || return 5
1050 run_test 28 "permanent parameter setting"
1052 test_28a() { # LU-4221
1053 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1054 { skip "Need OST version at least 2.5.52" && return 0; }
1055 [ "$(facet_fstype ost1)" = "zfs" ] &&
1056 skip "LU-4221: no such proc params for ZFS OSTs" && return
1063 local device="$FSNAME-OST0000"
1067 # In this test we will set three kinds of proc parameters with
1069 # 1. the ones moved from the OFD to the OSD, and only their
1070 # symlinks kept in obdfilter
1071 # 2. non-symlink ones in the OFD
1072 # 3. non-symlink ones in the OSD
1075 # prepare a symlink parameter in the OFD
1076 name="writethrough_cache_enable"
1077 param="$device.ost.$name"
1078 cmd="$LCTL get_param -n obdfilter.$device.$name"
1080 # conf_param the symlink parameter in the OFD
1081 old=$(do_facet ost1 $cmd)
1082 new=$(((old + 1) % 2))
1083 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1084 error "lctl conf_param $device.ost.$param=$new failed"
1086 # conf_param the target parameter in the OSD
1087 param="$device.osd.$name"
1088 cmd="$LCTL get_param -n osd-*.$device.$name"
1089 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1090 error "lctl conf_param $device.osd.$param=$old failed"
1093 # prepare a non-symlink parameter in the OFD
1094 name="client_cache_seconds"
1095 param="$device.ost.$name"
1096 cmd="$LCTL get_param -n obdfilter.$device.$name"
1098 # conf_param the parameter in the OFD
1099 old=$(do_facet ost1 $cmd)
1101 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1102 error "lctl conf_param $device.ost.$param=$new failed"
1103 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1104 error "lctl conf_param $device.ost.$param=$old failed"
1107 # prepare a non-symlink parameter in the OSD
1108 name="lma_self_repair"
1109 param="$device.osd.$name"
1110 cmd="$LCTL get_param -n osd-*.$device.$name"
1112 # conf_param the parameter in the OSD
1113 old=$(do_facet ost1 $cmd)
1114 new=$(((old + 1) % 2))
1115 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1116 error "lctl conf_param $device.osd.$param=$new failed"
1117 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1118 error "lctl conf_param $device.osd.$param=$old failed"
1122 run_test 28a "set symlink parameters permanently with conf_param"
1125 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1126 setup > /dev/null 2>&1
1130 local PARAM="$FSNAME-OST0001.osc.active"
1131 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1132 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1134 ACTV=$(lctl get_param -n $PROC_ACT)
1136 set_conf_param_and_check client \
1137 "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1138 # also check ost_server_uuid status
1139 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1140 if [ -z "$RESULT" ]; then
1141 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1144 echo "Live client success: got $RESULT"
1148 for num in $(seq $MDSCOUNT); do
1149 local mdtosc=$(get_mdtosc_proc_path mds${num} $FSNAME-OST0001)
1150 local MPROC="osc.$mdtosc.active"
1155 RESULT=$(do_facet mds${num} " lctl get_param -n $MPROC")
1156 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1157 if [ $RESULT -eq $DEAC ]; then
1158 echo -n "MDT deactivated also after"
1159 echo "$WAIT sec (got $RESULT)"
1163 if [ $WAIT -eq $MAX ]; then
1164 echo -n "MDT not deactivated: wanted $DEAC"
1168 echo "Waiting $(($MAX - $WAIT))secs for MDT deactivated"
1171 # test new client starts deactivated
1172 umount_client $MOUNT || return 200
1174 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1175 if [ -z "$RESULT" ]; then
1176 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1179 echo "New client success: got $RESULT"
1182 # make sure it reactivates
1183 set_conf_param_and_check client \
1184 "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1186 umount_client $MOUNT
1189 #writeconf to remove all ost2 traces for subsequent tests
1190 writeconf_or_reformat
1192 run_test 29 "permanently remove an OST"
1197 echo Big config llog
1198 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1200 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1201 for i in ${LIST[@]}; do
1202 set_conf_param_and_check client "$TEST" \
1203 "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1205 # make sure client restart still works
1206 umount_client $MOUNT
1207 mount_client $MOUNT || return 4
1208 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1211 echo Erase parameter setting
1212 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1213 umount_client $MOUNT
1214 mount_client $MOUNT || return 6
1216 echo "deleted (default) value=$FINAL, orig=$ORIG"
1217 # assumes this parameter started at the default value
1218 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1222 run_test 30a "Big config llog and conf_param deletion"
1227 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1228 # numerical part of it. Hopefully that's not already a failover address for
1230 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1231 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1232 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1233 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1234 echo "Using fake nid $NEW"
1236 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1237 set_conf_param_and_check client "$TEST" \
1238 "$FSNAME-OST0000.failover.node" $NEW ||
1239 error "didn't add failover nid $NEW"
1240 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1242 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1243 echo "should have 2 failover nids: $NIDCOUNT"
1244 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1245 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1246 umount_client $MOUNT
1247 mount_client $MOUNT || return 3
1249 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1251 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1252 echo "only 1 final nid should remain: $NIDCOUNT"
1253 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1257 run_test 30b "Remove failover nids"
1259 test_31() { # bug 10734
1260 # ipaddr must not exist
1261 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1264 run_test 31 "Connect to non-existent node (shouldn't crash)"
1268 T32_BLIMIT=20480 # Kbytes
1272 # This is not really a test but a tool to create new disk
1273 # image tarballs for the upgrade tests.
1275 # Disk image tarballs should be created on single-node
1276 # clusters by running this test with default configurations
1277 # plus a few mandatory environment settings that are verified
1278 # at the beginning of the test.
1280 test_32newtarball() {
1284 local tmp=$TMP/t32_image_create
1286 if [ $FSNAME != t32fs -o $MDSCOUNT -ne 1 -o \
1287 \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o $OSTCOUNT -ne 1 -o \
1288 -z "$OSTDEV1" ]; then
1289 error "Needs FSNAME=t32fs MDSCOUNT=1 MDSDEV1=<nonexistent_file>" \
1290 "(or MDSDEV, in the case of b1_8) OSTCOUNT=1" \
1291 "OSTDEV1=<nonexistent_file>"
1295 echo "Found stale $tmp"
1300 tar cf - -C $src . | tar xf - -C $tmp/src
1301 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1302 count=$(($T32_BLIMIT / 1024 / 2))
1303 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1305 # format ost with comma-separated NIDs to verify LU-4460
1306 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
1307 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1311 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1312 $LFS quotacheck -ug /mnt/$FSNAME
1313 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1316 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1323 ls -Rni --time-style=+%s >$tmp/img/list
1324 find . ! -name .lustre -type f -exec sha1sum {} \; |
1325 sort -k 2 >$tmp/img/sha1sums
1327 $LCTL get_param -n version | head -n 1 |
1328 sed -e 's/^lustre: *//' >$tmp/img/commit
1330 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1331 $LFS quotaon -ug /mnt/$FSNAME
1332 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1333 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1334 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1335 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1336 | tr -d "*" > $tmp/img/bspace
1337 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1338 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1339 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1340 | tr -d "*" > $tmp/img/ispace
1345 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1348 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1349 echo "Data verification failed"
1352 uname -r >$tmp/img/kernel
1353 uname -m >$tmp/img/arch
1355 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1356 mv $OSTDEV1 $tmp/img
1358 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1359 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1362 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1367 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1370 # The list of applicable tarballs is returned via the caller's
1371 # variable "tarballs".
1374 local node=$(facet_active_host $SINGLEMDS)
1375 local r="do_node $node"
1377 if [ "$CLIENTONLY" ]; then
1378 skip "Client-only testing"
1382 if ! $r which $TUNEFS; then
1383 skip_env "tunefs.lustre required on $node"
1387 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1389 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 -name \'disk*-$IMGTYPE.tar.bz2\')
1391 if [ -z "$tarballs" ]; then
1392 skip "No applicable tarballs found"
1397 t32_test_cleanup() {
1399 local fstype=$(facet_fstype $SINGLEMDS)
1402 if $shall_cleanup_lustre; then
1403 umount $tmp/mnt/lustre || rc=$?
1405 if $shall_cleanup_mdt; then
1406 $r umount -d $tmp/mnt/mdt || rc=$?
1408 if $shall_cleanup_mdt1; then
1409 $r umount -d $tmp/mnt/mdt1 || rc=$?
1411 if $shall_cleanup_ost; then
1412 $r umount -d $tmp/mnt/ost || rc=$?
1417 if [ $fstype == "zfs" ]; then
1418 $r $ZPOOL destroy t32fs-mdt1 || rc=$?
1419 $r $ZPOOL destroy t32fs-ost1 || rc=$?
1424 t32_bits_per_long() {
1426 # Yes, this is not meant to be perfect.
1436 t32_reload_modules() {
1438 local all_removed=false
1441 while ((i < 20)); do
1442 echo "Unloading modules on $node: Attempt $i"
1443 do_rpc_nodes $node $LUSTRE_RMMOD $(facet_fstype $SINGLEMDS) &&
1445 do_rpc_nodes $node check_mem_leak || return 1
1446 if $all_removed; then
1447 do_rpc_nodes $node load_modules
1453 echo "Unloading modules on $node: Given up"
1457 t32_wait_til_devices_gone() {
1463 echo wait for devices to go
1464 while ((i < 20)); do
1465 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1466 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1467 ((devices == 0 && loops == 0)) && return 0
1471 echo "waiting for dev on $node: dev $devices loop $loops given up"
1472 do_rpc_nodes $node "losetup -a"
1473 do_rpc_nodes $node "$LCTL devices_list"
1477 t32_verify_quota() {
1481 local fstype=$(facet_fstype $SINGLEMDS)
1485 $LFS quota -u $T32_QID -v $mnt
1487 qval=$($LFS quota -v -u $T32_QID $mnt |
1488 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1489 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1491 [ $qval -eq $img_bspace ] || {
1492 echo "bspace, act:$qval, exp:$img_bspace"
1496 qval=$($LFS quota -v -u $T32_QID $mnt |
1497 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1498 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1500 [ $qval -eq $img_ispace ] || {
1501 echo "ispace, act:$qval, exp:$img_ispace"
1505 qval=$($LFS quota -v -u $T32_QID $mnt |
1506 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1507 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1509 [ $qval -eq $T32_BLIMIT ] || {
1510 echo "blimit, act:$qval, exp:$T32_BLIMIT"
1514 qval=$($LFS quota -v -u $T32_QID $mnt |
1515 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1516 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1518 [ $qval -eq $T32_ILIMIT ] || {
1519 echo "ilimit, act:$qval, exp:$T32_ILIMIT"
1523 do_node $node $LCTL conf_param $fsname.quota.mdt=ug
1524 cmd="$LCTL get_param -n osd-$fstype.$fsname-MDT0000"
1525 cmd=$cmd.quota_slave.enabled
1526 wait_update $node "$cmd" "ug" || {
1527 echo "Enable mdt quota failed"
1531 do_node $node $LCTL conf_param $fsname.quota.ost=ug
1532 cmd="$LCTL get_param -n osd-$fstype.$fsname-OST0000"
1533 cmd=$cmd.quota_slave.enabled
1534 wait_update $node "$cmd" "ug" || {
1535 echo "Enable ost quota failed"
1540 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1541 bs=1M count=$(($T32_BLIMIT / 1024)) oflag=sync && {
1542 echo "Write succeed, but expect -EDQUOT"
1545 rm -f $mnt/t32_qf_new
1547 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1549 echo "Create succeed, but expect -EDQUOT"
1552 unlinkmany $mnt/t32_qf_ $T32_ILIMIT
1560 local dne_upgrade=${dne_upgrade:-"no"}
1561 local ff_convert=${ff_convert:-"no"}
1562 local shall_cleanup_mdt=false
1563 local shall_cleanup_mdt1=false
1564 local shall_cleanup_ost=false
1565 local shall_cleanup_lustre=false
1566 local node=$(facet_active_host $SINGLEMDS)
1567 local r="do_node $node"
1568 local node2=$(facet_active_host mds2)
1576 local nid=$($r $LCTL list_nids | head -1)
1582 local fstype=$(facet_fstype $SINGLEMDS)
1583 local mdt_dev=$tmp/mdt
1584 local ost_dev=$tmp/ost
1586 trap 'trap - RETURN; t32_test_cleanup' RETURN
1588 mkdir -p $tmp/mnt/lustre
1589 $r mkdir -p $tmp/mnt/{mdt,ost}
1590 $r tar xjvf $tarball -S -C $tmp || {
1591 error_noexit "Unpacking the disk image tarball"
1594 img_commit=$($r cat $tmp/commit)
1595 img_kernel=$($r cat $tmp/kernel)
1596 img_arch=$($r cat $tmp/arch)
1597 img_bspace=$($r cat $tmp/bspace)
1598 img_ispace=$($r cat $tmp/ispace)
1599 echo "Upgrading from $(basename $tarball), created with:"
1600 echo " Commit: $img_commit"
1601 echo " Kernel: $img_kernel"
1602 echo " Arch: $img_arch"
1604 local version=$(version_code $img_commit)
1605 [[ $version -ge $(version_code 2.5.0) ]] && ff_convert="no"
1607 if [ $fstype == "zfs" ]; then
1609 $r $ZPOOL import -f -d $tmp t32fs-mdt1
1610 $r $ZPOOL import -f -d $tmp t32fs-ost1
1611 mdt_dev=t32fs-mdt1/mdt1
1612 ost_dev=t32fs-ost1/ost1
1613 wait_update_facet $SINGLEMDS "$ZPOOL list |
1614 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1615 error_noexit "import zfs pool failed"
1620 $r $LCTL set_param debug="$PTLDEBUG"
1622 $r $TUNEFS --dryrun $mdt_dev || {
1624 error_noexit "tunefs.lustre before mounting the MDT"
1627 if [ "$writeconf" ]; then
1629 if [ $fstype == "ldiskfs" ]; then
1631 $r $TUNEFS --quota $mdt_dev || {
1633 error_noexit "Enable mdt quota feature"
1638 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1639 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1640 { skip "LU-2200: Cannot run over Inifiniband w/o lctl replace_nids "
1641 "(Need MGS version at least 2.3.59)"; return 0; }
1643 local osthost=$(facet_active_host ost1)
1644 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1647 if [ $fstype == "ldiskfs" ]; then
1650 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1651 $r lctl replace_nids $fsname-OST0000 $ostnid
1652 $r lctl replace_nids $fsname-MDT0000 $nid
1653 $r umount -d $tmp/mnt/mdt
1656 mopts=exclude=$fsname-OST0000
1657 if [ $fstype == "ldiskfs" ]; then
1662 t32_wait_til_devices_gone $node
1664 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1666 error_noexit "Mounting the MDT"
1669 shall_cleanup_mdt=true
1671 if [ "$dne_upgrade" != "no" ]; then
1672 local fs2mdsdev=$(mdsdevname 1_2)
1673 local fs2mdsvdev=$(mdsvdevname 1_2)
1675 echo "mkfs new MDT on ${fs2mdsdev}...."
1676 if [ $(facet_fstype mds1) == ldiskfs ]; then
1677 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1680 add fs2mds $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1681 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1682 error_noexit "Mkfs new MDT failed"
1686 $r $TUNEFS --dryrun $fs2mdsdev || {
1687 error_noexit "tunefs.lustre before mounting the MDT"
1691 echo "mount new MDT....$fs2mdsdev"
1692 $r mkdir -p $tmp/mnt/mdt1
1693 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1694 error_noexit "mount mdt1 failed"
1697 shall_cleanup_mdt1=true
1700 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1701 error_noexit "Getting MDT UUID"
1704 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1705 error_noexit "Unexpected MDT UUID: \"$uuid\""
1709 $r $TUNEFS --dryrun $ost_dev || {
1710 error_noexit "tunefs.lustre before mounting the OST"
1713 if [ "$writeconf" ]; then
1714 mopts=mgsnode=$nid,$writeconf
1715 if [ $fstype == "ldiskfs" ]; then
1717 $r $TUNEFS --quota $ost_dev || {
1719 error_noexit "Enable ost quota feature"
1725 if [ $fstype == "ldiskfs" ]; then
1729 $r $MOUNT_CMD -o $mopts $ost_dev $tmp/mnt/ost || {
1730 error_noexit "Mounting the OST"
1733 shall_cleanup_ost=true
1735 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1736 error_noexit "Getting OST UUID"
1739 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1740 error_noexit "Unexpected OST UUID: \"$uuid\""
1744 $r $LCTL conf_param $fsname-OST0000.osc.max_dirty_mb=15 || {
1745 error_noexit "Setting \"max_dirty_mb\""
1748 $r $LCTL conf_param $fsname-OST0000.failover.node=$nid || {
1749 error_noexit "Setting OST \"failover.node\""
1752 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1753 error_noexit "Setting \"max_rpcs_in_flight\""
1756 $r $LCTL conf_param $fsname-MDT0000.failover.node=$nid || {
1757 error_noexit "Setting MDT \"failover.node\""
1760 $r $LCTL pool_new $fsname.interop || {
1761 error_noexit "Setting \"interop\""
1764 $r $LCTL conf_param $fsname-MDT0000.lov.stripesize=4M || {
1765 error_noexit "Setting \"lov.stripesize\""
1769 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1770 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1771 error_noexit "Start OI scrub on OST0"
1775 # The oi_scrub should be on ost1, but for test_32(),
1776 # all on the SINGLEMDS.
1777 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1778 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1779 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1780 error_noexit "Failed to get the expected 'completed'"
1784 local UPDATED=$($r $LCTL get_param -n \
1785 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1786 awk '/^updated/ { print $2 }')
1787 [ $UPDATED -ge 1 ] || {
1788 error_noexit "Only $UPDATED objects have been converted"
1793 if [ "$dne_upgrade" != "no" ]; then
1794 $r $LCTL conf_param \
1795 $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
1796 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
1799 $r $LCTL conf_param $fsname-MDT0001.failover.node=$nid || {
1800 error_noexit "Setting MDT1 \"failover.node\""
1803 $r $LCTL conf_param $fsname-MDT0001.lov.stripesize=4M || {
1804 error_noexit "Setting MDT1 \"lov.stripesize\""
1810 if [ "$writeconf" ]; then
1811 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
1812 error_noexit "Mounting the client"
1815 shall_cleanup_lustre=true
1816 $LCTL set_param debug="$PTLDEBUG"
1818 t32_verify_quota $node $fsname $tmp/mnt/lustre || {
1819 error_noexit "verify quota failed"
1823 if [ "$dne_upgrade" != "no" ]; then
1824 $LFS mkdir -i 1 $tmp/mnt/lustre/remote_dir || {
1825 error_noexit "set remote dir failed"
1829 pushd $tmp/mnt/lustre
1830 tar -cf - . --exclude=./remote_dir |
1831 tar -xvf - -C remote_dir 1>/dev/null || {
1832 error_noexit "cp to remote dir failed"
1838 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
1839 error_noexit "dd failed"
1842 rm -rf $tmp/mnt/lustre/tmp_file || {
1843 error_noexit "rm failed"
1847 if $r test -f $tmp/sha1sums; then
1848 # LU-2393 - do both sorts on same node to ensure locale
1850 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
1851 if [ "$dne_upgrade" != "no" ]; then
1852 pushd $tmp/mnt/lustre/remote_dir
1854 pushd $tmp/mnt/lustre
1857 find ! -name .lustre -type f -exec sha1sum {} \; |
1858 sort -k 2 >$tmp/sha1sums || {
1859 error_noexit "sha1sum"
1863 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
1864 error_noexit "sha1sum verification failed"
1868 echo "sha1sum verification skipped"
1871 if [ "$dne_upgrade" != "no" ]; then
1872 rm -rf $tmp/mnt/lustre/remote_dir || {
1873 error_noexit "remove remote dir failed"
1878 if $r test -f $tmp/list; then
1880 # There is not a Test Framework API to copy files to or
1881 # from a remote node.
1883 # LU-2393 - do both sorts on same node to ensure locale
1885 $r cat $tmp/list | sort -k 6 >$tmp/list.orig
1886 pushd $tmp/mnt/lustre
1887 ls -Rni --time-style=+%s | sort -k 6 >$tmp/list || {
1893 # 32-bit and 64-bit clients use different algorithms to
1894 # convert FIDs into inode numbers. Hence, remove the inode
1895 # numbers from the lists, if the original list was created
1896 # on an architecture with different number of bits per
1899 if [ $(t32_bits_per_long $(uname -m)) != \
1900 $(t32_bits_per_long $img_arch) ]; then
1901 echo "Different number of bits per \"long\" from the disk image"
1902 for list in list.orig list; do
1903 sed -i -e 's/^[0-9]\+[ \t]\+//' $tmp/$list
1906 if ! diff -ub $tmp/list.orig $tmp/list; then
1907 error_noexit "list verification failed"
1911 echo "list verification skipped"
1915 # When adding new data verification tests, please check for
1916 # the presence of the required reference files first, like
1917 # the "sha1sums" and "list" tests above, to avoid the need to
1918 # regenerate every image for each test addition.
1921 nrpcs_orig=$($LCTL get_param \
1922 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
1923 error_noexit "Getting \"max_rpcs_in_flight\""
1926 nrpcs=$((nrpcs_orig + 5))
1927 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=$nrpcs || {
1928 error_noexit "Changing \"max_rpcs_in_flight\""
1931 wait_update $HOSTNAME "$LCTL get_param \
1932 -n mdc.*MDT0000*.max_rpcs_in_flight" $nrpcs || {
1933 error_noexit "Verifying \"max_rpcs_in_flight\""
1937 umount $tmp/mnt/lustre || {
1938 error_noexit "Unmounting the client"
1941 shall_cleanup_lustre=false
1943 if [ "$dne_upgrade" != "no" ]; then
1944 $r umount -d $tmp/mnt/mdt1 || {
1945 error_noexit "Unmounting the MDT2"
1948 shall_cleanup_mdt1=false
1951 $r umount -d $tmp/mnt/mdt || {
1952 error_noexit "Unmounting the MDT"
1955 shall_cleanup_mdt=false
1957 $r umount -d $tmp/mnt/ost || {
1958 error_noexit "Unmounting the OST"
1961 shall_cleanup_ost=false
1963 t32_reload_modules $node || {
1964 error_noexit "Reloading modules"
1968 # mount a second time to make sure we didnt leave upgrade flag on
1969 $r $TUNEFS --dryrun $mdt_dev || {
1971 error_noexit "tunefs.lustre before remounting the MDT"
1975 mopts=exclude=$fsname-OST0000
1976 if [ $fstype == "ldiskfs" ]; then
1979 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1980 error_noexit "Remounting the MDT"
1983 shall_cleanup_mdt=true
1993 for tarball in $tarballs; do
1994 t32_test $tarball || let "rc += $?"
1998 run_test 32a "Upgrade (not live)"
2006 for tarball in $tarballs; do
2007 t32_test $tarball writeconf || let "rc += $?"
2011 run_test 32b "Upgrade with writeconf"
2018 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2020 for tarball in $tarballs; do
2021 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2025 run_test 32c "dne upgrade test"
2033 for tarball in $tarballs; do
2034 ff_convert=yes t32_test $tarball || rc=$?
2038 run_test 32d "convert ff test"
2040 test_33a() { # bug 12333, was test_33
2042 local FSNAME2=test-123
2043 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2046 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2048 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2049 local dev=${SINGLEMDS}_dev
2050 local MDSDEV=${!dev}
2051 is_blkdev $SINGLEMDS $MDSDEV && \
2052 skip_env "mixed loopback and real device not working" && return
2055 local fs2mdsdev=$(mdsdevname 1_2)
2056 local fs2ostdev=$(ostdevname 1_2)
2057 local fs2mdsvdev=$(mdsvdevname 1_2)
2058 local fs2ostvdev=$(ostvdevname 1_2)
2060 if [ $(facet_fstype mds1) == ldiskfs ]; then
2061 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2064 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2065 --reformat $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
2066 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2067 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2068 $fs2ostvdev || exit 10
2070 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2071 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2072 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
2074 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
2077 cp /etc/hosts $MOUNT2/ || rc=3
2078 $LFS getstripe $MOUNT2/hosts
2083 cleanup_nocli || rc=6
2086 run_test 33a "Mount ost with a large index number"
2088 test_33b() { # was test_34
2091 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2092 # Drop lock cancelation reply during umount
2093 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2094 do_facet client lctl set_param fail_loc=0x80000304
2095 #lctl set_param debug=-1
2096 umount_client $MOUNT
2099 run_test 33b "Drop cancel during umount"
2103 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2104 manual_umount_client
2106 do_facet client killall -USR1 multiop
2107 if [ $rc -eq 0 ]; then
2108 error "umount not fail!"
2113 run_test 34a "umount with opened file should be fail"
2118 touch $DIR/$tfile || return 1
2119 stop_mds --force || return 2
2121 manual_umount_client --force
2123 if [ $rc -ne 0 ]; then
2124 error "mtab after failed umount - rc $rc"
2130 run_test 34b "force umount with failed mds should be normal"
2134 touch $DIR/$tfile || return 1
2135 stop_ost --force || return 2
2137 manual_umount_client --force
2139 if [ $rc -ne 0 ]; then
2140 error "mtab after failed umount - rc $rc"
2146 run_test 34c "force umount with failed ost should be normal"
2148 test_35a() { # bug 12459
2151 DBG_SAVE="`lctl get_param -n debug`"
2152 lctl set_param debug="ha"
2154 log "Set up a fake failnode for the MDS"
2156 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
2157 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2158 do_facet mgs "$LCTL conf_param \
2159 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" || return 4
2161 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2164 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2167 log "Stopping the MDT: $device"
2168 stop_mdt 1 || return 5
2170 df $MOUNT > /dev/null 2>&1 &
2172 log "Restarting the MDT: $device"
2173 start_mdt 1 || return 6
2174 log "Wait for df ($DFPID) ... "
2177 lctl set_param debug="$DBG_SAVE"
2179 # retrieve from the log the first server that the client tried to
2180 # contact after the connection loss
2181 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2182 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2183 /import_select_connection.*$device-mdc.* using connection/ {
2185 if (\\\$NF ~ /$FAKENID/)
2191 }" $TMP/lustre-log-$TESTNAME.log`
2192 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
2194 # remove nid settings
2195 writeconf_or_reformat
2197 run_test 35a "Reconnect to the last active server first"
2199 test_35b() { # bug 18674
2200 remote_mds || { skip "local MDS" && return 0; }
2204 $LCTL set_param debug="ha"
2206 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2209 log "Set up a fake failnode for the MDS"
2211 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2212 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2213 do_facet mgs "$LCTL conf_param \
2214 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" || return 1
2216 local at_max_saved=0
2217 # adaptive timeouts may prevent seeing the issue
2218 if at_is_enabled; then
2219 at_max_saved=$(at_max_get mds)
2220 at_max_set 0 mds client
2223 mkdir -p $MOUNT/$tdir
2225 log "Injecting EBUSY on MDS"
2226 # Setting OBD_FAIL_MDS_RESEND=0x136
2227 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
2229 $LCTL set_param mdc.${FSNAME}*.stats=clear
2231 log "Creating a test file and stat it"
2232 touch $MOUNT/$tdir/$tfile
2233 stat $MOUNT/$tdir/$tfile
2235 log "Stop injecting EBUSY on MDS"
2236 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
2237 rm -f $MOUNT/$tdir/$tfile
2240 # restore adaptive timeout
2241 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2243 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2245 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
2247 # retrieve from the log if the client has ever tried to
2248 # contact the fake server after the loss of connection
2249 FAILCONN=`awk "BEGIN {ret = 0;}
2250 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2252 if (\\\$NF ~ /$FAKENID/) {
2257 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2259 [ "$FAILCONN" == "0" ] && \
2260 log "ERROR: The client reconnection has not been triggered" && \
2262 [ "$FAILCONN" == "2" ] && \
2263 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
2267 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2268 # Reconnects are supposed to be rate limited to one every 5s
2269 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
2270 log "ERROR: Too many reconnects $CONNCNT" && \
2274 # remove nid settings
2275 writeconf_or_reformat
2277 run_test 35b "Continue reconnection retries, if the active server is busy"
2280 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
2282 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
2283 { skip "remote OST" && return 0; }
2286 local FSNAME2=test1234
2287 local fs3ost_HOST=$ost_HOST
2288 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2290 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2292 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2293 is_blkdev $SINGLEMDS $MDSDEV && \
2294 skip_env "mixed loopback and real device not working" && return
2297 local fs2mdsdev=$(mdsdevname 1_2)
2298 local fs2ostdev=$(ostdevname 1_2)
2299 local fs3ostdev=$(ostdevname 2_2)
2300 local fs2mdsvdev=$(mdsvdevname 1_2)
2301 local fs2ostvdev=$(ostvdevname 1_2)
2302 local fs3ostvdev=$(ostvdevname 2_2)
2304 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2305 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2306 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2307 # different one than the default value here.
2308 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2309 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2310 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2311 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2313 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2314 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2315 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2317 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || return 1
2319 sleep 5 # until 11778 fixed
2321 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
2323 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
2324 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
2325 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
2326 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
2327 DFTOTAL=`echo $STRING | cut -d, -f1`
2328 DFUSED=`echo $STRING | cut -d, -f2`
2329 DFAVAIL=`echo $STRING | cut -d, -f3`
2330 DFFREE=$(($DFTOTAL - $DFUSED))
2332 ALLOWANCE=$((64 * $OSTCOUNT))
2334 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2335 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2336 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2339 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2340 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2341 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2344 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2345 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2346 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2351 stop fs3ost -f || return 200
2352 stop fs2ost -f || return 201
2353 stop fs2mds -f || return 202
2354 unload_modules_conf || return 203
2357 run_test 36 "df report consistency on OSTs with different block size"
2360 local mntpt=$(facet_mntpt $SINGLEMDS)
2361 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2362 local mdsdev_sym="$TMP/sym_mdt.img"
2363 local opts=$MDS_MOUNT_OPTS
2366 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2367 skip "Currently only applicable to ldiskfs-based MDTs"
2371 echo "MDS : $mdsdev"
2372 echo "SYMLINK : $mdsdev_sym"
2373 do_facet $SINGLEMDS rm -f $mdsdev_sym
2375 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2377 echo "mount symlink device - $mdsdev_sym"
2379 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2380 opts=$(csa_add "$opts" -o loop)
2382 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2383 $mdsdev_sym $mntpt 2>&1)
2386 echo mount_op=$mount_op
2388 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
2390 if $(echo $mount_op | grep -q "unable to set tunable"); then
2391 error "set tunables failed for symlink device"
2394 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2398 run_test 37 "verify set tunables works for symlink device"
2400 test_38() { # bug 14222
2401 local fstype=$(facet_fstype $SINGLEMDS)
2402 local mntpt=$(facet_mntpt $SINGLEMDS)
2407 local SRC="/etc /bin"
2408 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2409 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2411 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2412 error "copying $SRC to $DIR/$tdir"
2414 umount_client $MOUNT
2415 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2417 log "delete lov_objid file on MDS"
2419 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2421 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2423 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2425 # check create in mds_lov_connect
2429 [ $V ] && log "verifying $DIR/$tdir/$f"
2430 diff -q $f $DIR/$tdir/$f || ERROR=y
2432 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2433 if [ "$ERROR" = "y" ]; then
2434 # check it's updates in sync
2435 umount_client $MOUNT
2437 mount_fstype $SIGNLEMDS
2438 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2439 unmount_fstype $SINGLEMDS
2440 error "old and new files are different after connect" || true
2442 touch $DIR/$tdir/f2 || error "f2 file create failed"
2444 # check it's updates in sync
2445 umount_client $MOUNT
2448 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2450 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2451 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2453 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2458 [ $V ] && log "verifying $DIR/$tdir/$f"
2459 diff -q $f $DIR/$tdir/$f || ERROR=y
2461 touch $DIR/$tdir/f3 || error "f3 file create failed"
2462 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2463 umount_client $MOUNT
2465 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2466 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2467 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2469 [ "$ERROR" = "y" ] &&
2470 error "old and new files are different after sync" || true
2472 log "files compared the same"
2475 run_test 38 "MDS recreates missing lov_objid file from OST data"
2481 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2482 error "memory leak detected" || true
2484 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2486 test_40() { # bug 15759
2488 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2489 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2493 run_test 40 "race during service thread startup"
2495 test_41a() { #bug 14134
2496 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2497 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2498 skip "Loop devices does not work with nosvc option"
2503 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2505 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2506 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
2507 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2509 mount_client $MOUNT || return 1
2512 echo "blah blah" > $MOUNT/$tfile
2515 umount_client $MOUNT
2516 stop ost1 -f || return 201
2517 stop_mds -f || return 202
2518 stop_mds -f || return 203
2519 unload_modules_conf || return 204
2522 run_test 41a "mount mds with --nosvc and --nomgs"
2525 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2526 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2527 skip "Loop devices does not work with nosvc option"
2531 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2535 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2537 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2539 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2541 mount_client $MOUNT || return 1
2544 echo "blah blah" > $MOUNT/$tfile
2545 cat $MOUNT/$tfile || return 200
2547 umount_client $MOUNT
2548 stop_ost || return 201
2549 stop_mds -f || return 202
2550 stop_mds -f || return 203
2553 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2555 test_42() { #bug 14693
2557 check_mount || error "client was not mounted"
2559 do_facet mgs $LCTL conf_param $FSNAME.llite.some_wrong_param=10
2560 umount_client $MOUNT ||
2561 error "unmounting client failed with invalid llite param"
2562 mount_client $MOUNT ||
2563 error "mounting client failed with invalid llite param"
2565 do_facet mgs $LCTL conf_param $FSNAME.sys.some_wrong_param=20
2566 cleanup || error "stopping $FSNAME failed with invalid sys param"
2569 check_mount || "client was not mounted with invalid sys param"
2570 cleanup || error "stopping $FSNAME failed with invalid sys param"
2573 run_test 42 "allow client/server mount/unmount with invalid config param"
2576 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
2579 USER1=$(cat /etc/passwd | grep :$ID1:$ID1: | cut -d: -f1)
2580 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
2584 chmod ugo+x $DIR || error "chmod 0 failed"
2585 set_conf_param_and_check mds \
2586 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2587 "$FSNAME.mdt.root_squash" \
2589 wait_update $HOSTNAME \
2590 "lctl get_param -n llite.${FSNAME}*.root_squash" \
2592 error "check llite root_squash failed!"
2593 set_conf_param_and_check mds \
2594 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2595 "$FSNAME.mdt.nosquash_nids" \
2597 wait_update $HOSTNAME \
2598 "lctl get_param -n llite.${FSNAME}*.nosquash_nids" \
2600 error "check llite nosquash_nids failed!"
2603 # create set of test files
2605 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
2606 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
2607 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
2609 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
2610 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
2612 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
2613 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
2614 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
2616 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
2617 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
2618 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
2621 # check root_squash:
2622 # set root squash UID:GID to RUNAS_ID
2623 # root should be able to access only files owned by RUNAS_ID
2625 set_conf_param_and_check mds \
2626 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2627 "$FSNAME.mdt.root_squash" \
2628 "$RUNAS_ID:$RUNAS_ID"
2629 wait_update $HOSTNAME \
2630 "lctl get_param -n llite.${FSNAME}*.root_squash" \
2631 "$RUNAS_ID:$RUNAS_ID" ||
2632 error "check llite root_squash failed!"
2634 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
2635 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
2636 error "$ST: root read permission is denied"
2637 echo "$ST: root read permission is granted - ok"
2640 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
2641 error "$ST: root write permission is denied"
2642 echo "$ST: root write permission is granted - ok"
2644 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2645 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
2646 error "$ST: root read permission is granted"
2647 echo "$ST: root read permission is denied - ok"
2650 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
2651 error "$ST: root write permission is granted"
2652 echo "$ST: root write permission is denied - ok"
2654 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2655 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
2656 error "$ST: root unlink permission is granted"
2657 echo "$ST: root unlink permission is denied - ok"
2659 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
2660 error "$ST: root create permission is granted"
2661 echo "$ST: root create permission is denied - ok"
2665 # check root_squash is enforced independently
2666 # of client cache content
2668 # access file by USER1, keep access open
2669 # root should be denied access to user file
2671 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
2675 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
2676 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
2677 { kill $pid; error "$ST: root read permission is granted"; }
2678 echo "$ST: root read permission is denied - ok"
2681 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
2682 { kill $pid; error "$ST: root write permission is granted"; }
2683 echo "$ST: root write permission is denied - ok"
2689 # check nosquash_nids:
2690 # put client's NID into nosquash_nids list,
2691 # root should be able to access root file after that
2693 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
2694 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
2695 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
2696 set_conf_param_and_check mds \
2697 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2698 "$FSNAME-MDTall.mdt.nosquash_nids" \
2700 wait_update $HOSTNAME \
2701 "lctl get_param -n llite.${FSNAME}*.nosquash_nids" \
2703 error "check llite nosquash_nids failed!"
2705 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2706 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
2707 error "$ST: root read permission is denied"
2708 echo "$ST: root read permission is granted - ok"
2711 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
2712 error "$ST: root write permission is denied"
2713 echo "$ST: root write permission is granted - ok"
2715 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2716 rm $DIR/$tdir-rootdir/tfile-1 || \
2717 error "$ST: root unlink permission is denied"
2718 echo "$ST: root unlink permission is granted - ok"
2719 touch $DIR/$tdir-rootdir/tfile-2 || \
2720 error "$ST: root create permission is denied"
2721 echo "$ST: root create permission is granted - ok"
2725 run_test 43 "check root_squash and nosquash_nids"
2727 umount_client $MOUNT
2732 check_mount || return 2
2733 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
2735 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
2736 for VAL in $UUIDS; do
2737 NID=$(echo $VAL | cut -d= -f1)
2738 CLUUID=$(echo $VAL | cut -d= -f2)
2739 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
2741 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
2745 run_test 44 "mounted client proc entry exists"
2749 check_mount || return 2
2754 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
2755 do_facet client "lctl set_param fail_loc=0x50f"
2758 manual_umount_client --force || return 3
2759 do_facet client "lctl set_param fail_loc=0x0"
2761 mount_client $MOUNT || return 4
2765 run_test 45 "long unlink handling in ptlrpcd"
2772 umount_client $MOUNT2 || rc=$?
2773 umount_client $MOUNT || rc=$?
2774 while [ $count -gt 0 ]; do
2775 stop ost${count} -f || rc=$?
2779 cleanup_nocli || rc=$?
2780 #writeconf to remove all ost2 traces for subsequent tests
2781 writeconf_or_reformat
2786 echo "Testing with $OSTCOUNT OSTs"
2788 start_mds || return 1
2789 #first client should see only one ost
2790 start_ost || return 2
2791 wait_osc_import_state mds ost FULL
2793 mount_client $MOUNT || return 3
2794 trap "cleanup_46a $OSTCOUNT" EXIT ERR
2797 for (( i=2; i<=$OSTCOUNT; i++ )); do
2798 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
2801 # wait until osts in sync
2802 for (( i=2; i<=$OSTCOUNT; i++ )); do
2803 wait_osc_import_state mds ost$i FULL
2804 wait_osc_import_state client ost$i FULL
2807 #second client see all ost's
2809 mount_client $MOUNT2 || return 8
2810 $LFS setstripe -c -1 $MOUNT2 || return 9
2811 $LFS getstripe $MOUNT2 || return 10
2813 echo "ok" > $MOUNT2/widestripe
2814 $LFS getstripe $MOUNT2/widestripe || return 11
2815 # fill acl buffer for avoid expand lsm to them
2816 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
2817 setfacl -m $acl $MOUNT2/widestripe
2821 stat $MOUNT/widestripe || return 12
2823 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
2826 run_test 46a "handle ost additional - wide striped file"
2831 check_mount || return 2
2832 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2836 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2837 if echo $ns | grep "MDT[[:digit:]]*"; then
2840 lrs=$(echo $ns | sed 's/.*lru_size=//')
2841 lru_size[count]=$lrs
2846 facet_failover $SINGLEMDS
2847 client_up || return 3
2850 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2851 if echo $ns | grep "MDT[[:digit:]]*"; then
2854 lrs=$(echo $ns | sed 's/.*lru_size=//')
2855 if ! test "$lrs" -eq "${lru_size[count]}"; then
2856 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2857 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2865 run_test 47 "server restart does not make client loss lru_resize settings"
2870 # reformat after this test is needed - if test will failed
2871 # we will have unkillable file at FS
2875 test_48() { # bug 17636
2878 check_mount || return 2
2880 $LFS setstripe -c -1 $MOUNT || return 9
2881 $LFS getstripe $MOUNT || return 10
2883 echo "ok" > $MOUNT/widestripe
2884 $LFS getstripe $MOUNT/widestripe || return 11
2886 trap cleanup_48 EXIT ERR
2888 # fill acl buffer for avoid expand lsm to them
2889 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2890 setfacl -m $acl $MOUNT/widestripe
2893 stat $MOUNT/widestripe || return 12
2898 run_test 48 "too many acls on file"
2900 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2901 test_49a() { # bug 17710
2902 local timeout_orig=$TIMEOUT
2903 local ldlm_timeout_orig=$LDLM_TIMEOUT
2904 local LOCAL_TIMEOUT=20
2906 LDLM_TIMEOUT=$LOCAL_TIMEOUT
2907 TIMEOUT=$LOCAL_TIMEOUT
2911 check_mount || error "client mount failed"
2913 echo "check ldlm_timout..."
2914 local LDLM_MDS="$(do_facet $SINGLEMDS lctl get_param -n ldlm_timeout)"
2915 local LDLM_OST1="$(do_facet ost1 lctl get_param -n ldlm_timeout)"
2916 local LDLM_CLIENT="$(do_facet client lctl get_param -n ldlm_timeout)"
2918 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
2919 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2922 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2923 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
2926 umount_client $MOUNT
2927 stop_ost || error "problem stopping OSS"
2928 stop_mds || error "problem stopping MDS"
2930 LDLM_TIMEOUT=$ldlm_timeout_orig
2931 TIMEOUT=$timeout_orig
2933 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
2935 test_49b() { # bug 17710
2936 local timeout_orig=$TIMEOUT
2937 local ldlm_timeout_orig=$LDLM_TIMEOUT
2938 local LOCAL_TIMEOUT=20
2940 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
2941 TIMEOUT=$LOCAL_TIMEOUT
2945 check_mount || error "client mount failed"
2947 local LDLM_MDS="$(do_facet $SINGLEMDS lctl get_param -n ldlm_timeout)"
2948 local LDLM_OST1="$(do_facet ost1 lctl get_param -n ldlm_timeout)"
2949 local LDLM_CLIENT="$(do_facet client lctl get_param -n ldlm_timeout)"
2951 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
2952 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2955 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2956 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
2959 cleanup || error "cleanup failed"
2961 LDLM_TIMEOUT=$ldlm_timeout_orig
2962 TIMEOUT=$timeout_orig
2964 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
2967 # Test both statfs and lfs df and fail if either one fails
2968 multiop_bg_pause $1 f_
2971 killall -USR1 multiop
2972 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2973 wait $PID || { RC1=$?; log "multiop return error "; }
2980 if [ $RC2 -eq 0 ]; then
2982 log "lazystatfs df failed"
2986 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2992 lctl set_param llite.$FSNAME-*.lazystatfs=1
2995 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2997 cleanup || return $?
2999 run_test 50a "lazystatfs all servers available =========================="
3003 lctl set_param llite.$FSNAME-*.lazystatfs=1
3006 # Wait for client to detect down OST
3007 stop_ost || error "Unable to stop OST1"
3008 wait_osc_import_state mds ost DISCONN
3010 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
3012 umount_client $MOUNT || error "Unable to unmount client"
3013 stop_mds || error "Unable to stop MDS"
3015 run_test 50b "lazystatfs all servers down =========================="
3018 start_mds || error "Unable to start MDS"
3019 start_ost || error "Unable to start OST1"
3020 start_ost2 || error "Unable to start OST2"
3021 mount_client $MOUNT || error "Unable to mount client"
3022 lctl set_param llite.$FSNAME-*.lazystatfs=1
3025 # Wait for client to detect down OST
3026 stop_ost || error "Unable to stop OST1"
3027 wait_osc_import_state mds ost DISCONN
3028 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3030 umount_client $MOUNT || error "Unable to unmount client"
3031 stop_ost2 || error "Unable to stop OST2"
3032 stop_mds || error "Unable to stop MDS"
3033 #writeconf to remove all ost2 traces for subsequent tests
3034 writeconf_or_reformat
3036 run_test 50c "lazystatfs one server down =========================="
3039 start_mds || error "Unable to start MDS"
3040 start_ost || error "Unable to start OST1"
3041 start_ost2 || error "Unable to start OST2"
3042 mount_client $MOUNT || error "Unable to mount client"
3043 lctl set_param llite.$FSNAME-*.lazystatfs=1
3046 # Issue the statfs during the window where the client still
3047 # belives the OST to be available but it is in fact down.
3048 # No failure just a statfs which hangs for a timeout interval.
3049 stop_ost || error "Unable to stop OST1"
3050 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3052 umount_client $MOUNT || error "Unable to unmount client"
3053 stop_ost2 || error "Unable to stop OST2"
3054 stop_mds || error "Unable to stop MDS"
3055 #writeconf to remove all ost2 traces for subsequent tests
3056 writeconf_or_reformat
3058 run_test 50d "lazystatfs client/server conn race =========================="
3065 start_mds || return 1
3066 #first client should see only one ost
3067 start_ost || return 2
3068 wait_osc_import_state mds ost FULL
3070 # Wait for client to detect down OST
3071 stop_ost || error "Unable to stop OST1"
3072 wait_osc_import_state mds ost DISCONN
3074 mount_client $MOUNT || error "Unable to mount client"
3075 lctl set_param llite.$FSNAME-*.lazystatfs=0
3077 multiop_bg_pause $MOUNT _f
3081 if [ $RC1 -ne 0 ]; then
3082 log "multiop failed $RC1"
3085 sleep $(( $TIMEOUT+1 ))
3087 [ $? -ne 0 ] && error "process isn't sleep"
3088 start_ost || error "Unable to start OST1"
3089 wait $pid || error "statfs failed"
3092 umount_client $MOUNT || error "Unable to unmount client"
3093 stop_ost || error "Unable to stop OST1"
3094 stop_mds || error "Unable to stop MDS"
3096 run_test 50e "normal statfs all servers down =========================="
3101 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3103 start_mds || error "Unable to start mds"
3104 #first client should see only one ost
3105 start_ost || error "Unable to start OST1"
3106 wait_osc_import_state mds ost FULL
3108 start_ost2 || error "Unable to start OST2"
3109 wait_osc_import_state mds ost2 FULL
3111 # Wait for client to detect down OST
3112 stop_ost2 || error "Unable to stop OST2"
3114 wait_osc_import_state mds ost2 DISCONN
3115 mount_client $MOUNT || error "Unable to mount client"
3116 lctl set_param llite.$FSNAME-*.lazystatfs=0
3118 multiop_bg_pause $MOUNT _f
3122 if [ $RC1 -ne 0 ]; then
3123 log "lazystatfs multiop failed $RC1"
3126 sleep $(( $TIMEOUT+1 ))
3128 [ $? -ne 0 ] && error "process isn't sleep"
3129 start_ost2 || error "Unable to start OST2"
3130 wait $pid || error "statfs failed"
3131 stop_ost2 || error "Unable to stop OST2"
3134 umount_client $MOUNT || error "Unable to unmount client"
3135 stop_ost || error "Unable to stop OST1"
3136 stop_mds || error "Unable to stop MDS"
3137 #writeconf to remove all ost2 traces for subsequent tests
3138 writeconf_or_reformat
3140 run_test 50f "normal statfs one server in down =========================="
3143 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
3145 start_ost2 || error "Unable to start OST2"
3146 wait_osc_import_state mds ost2 FULL
3147 wait_osc_import_state client ost2 FULL
3149 local PARAM="${FSNAME}-OST0001.osc.active"
3151 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
3152 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
3154 umount_client $MOUNT || error "Unable to unmount client"
3155 mount_client $MOUNT || error "Unable to mount client"
3156 # This df should not cause a panic
3159 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
3161 umount_client $MOUNT || error "Unable to unmount client"
3162 stop_ost2 || error "Unable to stop OST2"
3163 stop_ost || error "Unable to stop OST1"
3164 stop_mds || error "Unable to stop MDS"
3165 #writeconf to remove all ost2 traces for subsequent tests
3166 writeconf_or_reformat
3168 run_test 50g "deactivated OST should not cause panic====================="
3172 # prepare MDT/OST, make OSC inactive for OST1
3173 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
3175 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3176 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3177 error "tunefs OST1 failed"
3178 start_mds || error "Unable to start MDT"
3179 start_ost || error "Unable to start OST1"
3180 start_ost2 || error "Unable to start OST2"
3181 mount_client $MOUNT || error "client start failed"
3185 # activatate OSC for OST1
3186 local TEST="$LCTL get_param -n osc.${FSNAME}-OST0000-osc-[!M]*.active"
3187 set_conf_param_and_check client \
3188 "$TEST" "${FSNAME}-OST0000.osc.active" 1 ||
3189 error "Unable to activate OST1"
3191 mkdir -p $DIR/$tdir/2
3192 $LFS setstripe -c -1 -i 0 $DIR/$tdir/2
3193 sleep 1 && echo "create a file after OST1 is activated"
3195 createmany -o $DIR/$tdir/2/$tfile-%d 1
3197 # check OSC import is working
3198 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3199 error "some OSC imports are still not connected"
3202 umount_client $MOUNT || error "Unable to umount client"
3203 stop_ost2 || error "Unable to stop OST2"
3206 run_test 50h "LU-642: activate deactivated OST ==="
3209 local LOCAL_TIMEOUT=20
3213 check_mount || return 1
3216 $LFS setstripe -c -1 $MOUNT/d1
3217 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3218 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
3219 touch $MOUNT/d1/f1 &
3222 start_ost2 || return 2
3224 stop_ost2 || return 3
3226 #writeconf to remove all ost2 traces for subsequent tests
3227 writeconf_or_reformat
3229 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
3238 do_node $node mkdir -p $dest
3239 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3241 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
3242 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3243 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
3245 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
3246 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
3256 local backup2=${TMP}/backup2
3258 do_node $node mkdir -p $backup2
3259 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3261 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
3262 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3263 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
3265 do_node $node "diff -rq $backup $backup2"
3266 [ $? -eq 0 ] || { error "contents differ"; return 3; }
3268 local xattrs2=${TMP}/xattrs2
3269 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
3270 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
3272 do_node $node "diff $xattrs $xattrs2"
3273 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
3275 do_node $node "rm -rf $backup2 $xattrs2"
3276 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
3280 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3281 skip "Only applicable to ldiskfs-based MDTs"
3286 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
3288 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
3290 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
3293 local ost1mnt=$(facet_mntpt ost1)
3294 local ost1node=$(facet_active_host ost1)
3295 local ost1tmp=$TMP/conf52
3299 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
3300 touch $TMP/modified_first
3301 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
3302 local mtime=$(stat -c %Y $TMP/modified_first)
3303 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
3305 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
3308 $LFS setstripe -c -1 -S 1M $DIR/$tdir
3309 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
3311 for (( i=0; i < nrfiles; i++ )); do
3312 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
3313 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
3319 echo backup files to $TMP/files
3320 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
3321 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
3322 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
3324 umount_client $MOUNT
3325 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
3327 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
3329 echo mount ost1 as ldiskfs
3330 do_node $ost1node mkdir -p $ost1mnt
3331 [ $? -eq 0 ] || { error "Unable to create $ost1mnt"; return 23; }
3332 if ! do_node $ost1node test -b $ost1_dev; then
3335 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
3337 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
3340 echo backup objects to $ost1tmp/objects
3341 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
3342 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
3343 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
3345 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
3347 # move objects to lost+found
3348 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
3349 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
3351 # recover objects dry-run
3352 echo "ll_recover_lost_found_objs dry_run"
3353 do_node $ost1node "ll_recover_lost_found_objs -n -d $ost1mnt/O"
3354 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
3357 echo "ll_recover_lost_found_objs fix run"
3358 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
3359 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
3361 # compare restored objects against saved ones
3362 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
3363 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
3365 do_node $ost1node "umount $ost1mnt"
3366 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
3369 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
3371 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
3374 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
3375 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
3377 rm -rf $TMP/files $TMP/file_xattrs
3378 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
3379 do_node $ost1node "rm -rf $ost1tmp"
3380 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
3383 run_test 52 "check recovering objects from lost+found"
3385 # Checks threads_min/max/started for some service
3387 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
3388 # parameter pattern prefix like 'ost.*.ost'.
3401 local msg="Insane $modname thread counts"
3402 local ncpts=$(check_cpt_number $facet)
3406 check_mount || return 41
3408 # We need to expand $parampat, but it may match multiple parameters, so
3409 # we'll pick the first one
3410 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
3411 error "Couldn't expand ${parampat}.threads_min parameter name"
3415 # Remove the .threads_min part
3416 paramp=${paramp%.threads_min}
3418 # Check for sanity in defaults
3419 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3420 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3421 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
3422 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
3423 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
3424 nthrs=$(expr $tmax - $tmin)
3425 if [ $nthrs -lt $ncpts ]; then
3431 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
3432 skip_env "module parameter forced $facet thread count" &&
3433 tmin=3 && tmax=$((3 * tmax))
3435 # Check that we can change min/max
3436 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + nthrs))"
3437 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - nthrs))"
3438 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3439 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3440 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) && $tmax2 == ($tmax - $nthrs)))' || return $?
3442 # Check that we can set min/max to the same value
3443 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3444 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
3445 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3446 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3447 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
3449 # Check that we can't set max < min
3450 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
3451 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3452 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3453 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
3455 # We need to ensure that we get the module options desired; to do this
3456 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
3457 LOAD_MODULES_REMOTE=true
3460 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
3461 setmodopts -a $modname "$newvalue" oldvalue
3465 check_mount || return 41
3467 # Restore previous setting of MODOPTS_*
3468 setmodopts $modname "$oldvalue"
3470 # Check that $opts took
3471 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
3472 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
3473 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
3474 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
3483 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
3486 run_test 53a "check OSS thread count params"
3490 local mds=$(do_facet $SINGLEMDS "lctl get_param -N mds.*.*.threads_max \
3492 if [ -z "$mds" ]; then
3493 #running this on an old MDT
3494 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
3496 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
3500 run_test 53b "check MDS thread count params"
3503 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3504 skip "Only applicable to ldiskfs-based MDTs"
3508 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p
3509 [ $? -eq 0 ] || error "llverdev failed!"
3512 run_test 54a "test llverdev and partial verify of device"
3515 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3516 skip "Only applicable to ldiskfs-based MDTs"
3521 run_llverfs $MOUNT -p
3522 [ $? -eq 0 ] || error "llverfs failed!"
3525 run_test 54b "test llverfs and partial verify of filesystem"
3529 local max_ost_index=$1
3530 echo -n $(((max_ost_index + 1) * 8))
3534 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3535 skip "Only applicable to ldiskfs-based MDTs"
3539 local mdsdev=$(mdsdevname 1)
3540 local mdsvdev=$(mdsvdevname 1)
3544 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
3546 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
3547 --reformat $(ostdevname 1) $(ostvdevname 1)
3553 echo checking size of lov_objid for ost index $i
3554 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
3555 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
3556 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
3558 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
3565 run_test 55 "check lov_objid size"
3568 local mds_journal_size_orig=$MDSJOURNALSIZE
3572 for num in $(seq 1 $MDSCOUNT); do
3573 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3574 --reformat $(mdsdevname $num) $(mdsvdevname $num)
3576 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=1000 --reformat \
3577 $(ostdevname 1) $(ostvdevname 1)
3578 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=10000 --reformat \
3579 $(ostdevname 2) $(ostvdevname 2)
3583 start_ost2 || error "Unable to start second ost"
3584 mount_client $MOUNT || error "Unable to mount client"
3588 MDSJOURNALSIZE=$mds_journal_size_orig
3591 run_test 56 "check big indexes"
3593 test_57a() { # bug 22656
3594 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
3595 writeconf_or_reformat
3596 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3597 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
3599 start_ost && error "OST registration from failnode should fail"
3602 run_test 57a "initial registration from failnode should fail (should return errs)"
3605 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
3606 writeconf_or_reformat
3607 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3608 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
3610 start_ost || error "OST registration from servicenode should not fail"
3613 run_test 57b "initial registration from servicenode should not fail"
3616 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
3619 test_58() { # bug 22658
3622 createmany -o $DIR/$tdir/$tfile-%d 100
3623 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
3624 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
3625 do_facet $SINGLEMDS "lctl set_param fail_loc=0x601"
3626 unlinkmany $DIR/$tdir/$tfile-%d 100
3629 local MNTDIR=$(facet_mntpt $SINGLEMDS)
3630 local devname=$(mdsdevname ${SINGLEMDS//mds/})
3632 # remove all files from the OBJECTS dir
3633 mount_fstype $SINGLEMDS
3635 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
3637 unmount_fstype $SINGLEMDS
3638 # restart MDS with missing llog files
3640 do_facet mds "lctl set_param fail_loc=0"
3643 run_test 58 "missing llog files must not prevent MDT from mounting"
3646 start_mgsmds >> /dev/null
3647 local C1=$(count_osts)
3648 if [ $C1 -eq 0 ]; then
3649 start_ost >> /dev/null
3653 echo "original ost count: $C1 (expect > 0)"
3654 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
3655 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
3656 local C2=$(count_osts)
3657 echo "after mdt writeconf count: $C2 (expect 0)"
3658 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
3659 echo "OST start without writeconf should fail:"
3660 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
3661 echo "OST start with writeconf should succeed:"
3662 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
3663 local C3=$(count_osts)
3664 echo "after ost writeconf count: $C3 (expect 1)"
3665 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
3666 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
3667 local C4=$(count_osts)
3668 echo "after ost2 writeconf count: $C4 (expect 2)"
3669 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
3670 stop_ost2 >> /dev/null
3671 cleanup_nocli >> /dev/null
3672 #writeconf to remove all ost2 traces for subsequent tests
3673 writeconf_or_reformat
3675 run_test 59 "writeconf mount option"
3677 test_60() { # LU-471
3680 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3681 skip "Only applicable to ldiskfs-based MDTs"
3685 for num in $(seq $MDSCOUNT); do
3686 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3687 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
3688 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3692 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
3694 [ $rc -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
3696 # MDT default has dirdata feature
3697 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
3698 # we disable uninit_bg feature
3699 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
3700 # we set stride extended options
3701 echo $dump | grep stride > /dev/null || error "stride is not set"
3704 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
3707 local reformat=false
3709 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
3710 { skip "Need MDS version at least 2.1.53"; return 0; }
3712 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
3713 ! large_xattr_enabled; then
3715 LDISKFS_MKFS_OPTS+=" -O large_xattr"
3717 for num in $(seq $MDSCOUNT); do
3718 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
3719 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3720 error "add mds $num failed"
3724 setup_noconfig || error "setting up the filesystem failed"
3725 client_up || error "starting client failed"
3727 local file=$DIR/$tfile
3730 local large_value="$(generate_string $(max_xattr_size))"
3731 local small_value="bar"
3733 local name="trusted.big"
3734 log "save large xattr $name on $file"
3735 setfattr -n $name -v $large_value $file ||
3736 error "saving $name on $file failed"
3738 local new_value=$(get_xattr_value $name $file)
3739 [[ "$new_value" != "$large_value" ]] &&
3740 error "$name different after saving"
3742 log "shrink value of $name on $file"
3743 setfattr -n $name -v $small_value $file ||
3744 error "shrinking value of $name on $file failed"
3746 new_value=$(get_xattr_value $name $file)
3747 [[ "$new_value" != "$small_value" ]] &&
3748 error "$name different after shrinking"
3750 log "grow value of $name on $file"
3751 setfattr -n $name -v $large_value $file ||
3752 error "growing value of $name on $file failed"
3754 new_value=$(get_xattr_value $name $file)
3755 [[ "$new_value" != "$large_value" ]] &&
3756 error "$name different after growing"
3758 log "check value of $name on $file after remounting MDS"
3760 new_value=$(get_xattr_value $name $file)
3761 [[ "$new_value" != "$large_value" ]] &&
3762 error "$name different after remounting MDS"
3764 log "remove large xattr $name from $file"
3765 setfattr -x $name $file || error "removing $name from $file failed"
3770 LDISKFS_MKFS_OPTS=${LDISKFS_MKFS_OPTS% -O large_xattr}
3774 run_test 61 "large xattr"
3777 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3778 skip "Only applicable to ldiskfs-based MDTs"
3783 local mdsdev=$(mdsdevname 1)
3784 local ostdev=$(ostdevname 1)
3786 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
3787 { skip "Need MDS version at least 2.2.51"; return 0; }
3789 echo "disable journal for mds"
3790 do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
3791 start_mds && error "MDT start should fail"
3792 echo "disable journal for ost"
3793 do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
3794 start_ost && error "OST start should fail"
3795 cleanup || return $?
3798 run_test 62 "start with disabled journal"
3801 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3802 skip "Only applicable to ldiskfs-based MDTs"
3806 local inode_slab=$(do_facet $SINGLEMDS \
3807 "awk '/ldiskfs_inode_cache/ { print \\\$5 }' /proc/slabinfo")
3808 if [ -z "$inode_slab" ]; then
3809 skip "ldiskfs module has not been loaded"
3813 echo "$inode_slab ldisk inodes per page"
3814 [ "$inode_slab" -ge "3" ] ||
3815 error "ldisk inode size is too big, $inode_slab objs per page"
3818 run_test 63 "Verify each page can at least hold 3 ldisk inodes"
3823 start_ost2 || error "Unable to start second ost"
3824 mount_client $MOUNT || error "Unable to mount client"
3825 stop_ost2 || error "Unable to stop second ost"
3827 $LFS df --lazy || error "lfs df failed"
3828 cleanup || return $?
3829 #writeconf to remove all ost2 traces for subsequent tests
3830 writeconf_or_reformat
3832 run_test 64 "check lfs df --lazy "
3834 test_65() { # LU-2237
3835 # Currently, the test is only valid for ldiskfs backend
3836 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
3837 skip "non-ldiskfs backend" && return
3839 local devname=$(mdsdevname ${SINGLEMDS//mds/})
3840 local brpt=$(facet_mntpt brpt)
3843 if ! do_facet $SINGLEMDS "test -b $devname"; then
3848 local obj=$(do_facet $SINGLEMDS \
3849 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
3851 if [ -z "$obj" ]; then
3852 # The MDT may be just re-formatted, mount the MDT for the
3853 # first time to guarantee the "last_rcvd" file is there.
3854 start_mds || error "fail to mount the MDS for the first time"
3858 # remove the "last_rcvd" file
3859 do_facet $SINGLEMDS "mkdir -p $brpt"
3860 do_facet $SINGLEMDS \
3861 "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
3862 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
3863 do_facet $SINGLEMDS "umount -d $brpt"
3865 # restart MDS, the "last_rcvd" file should be recreated.
3866 start_mds || error "fail to restart the MDS"
3868 obj=$(do_facet $SINGLEMDS \
3869 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
3870 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
3872 run_test 65 "re-create the lost last_rcvd file when server mount"
3875 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
3876 { skip "Need MGS version at least 2.3.59"; return 0; }
3879 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
3880 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
3882 echo "replace_nids should fail if MDS, OSTs and clients are UP"
3883 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
3884 error "replace_nids fail"
3886 umount_client $MOUNT || error "unmounting client failed"
3887 echo "replace_nids should fail if MDS and OSTs are UP"
3888 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
3889 error "replace_nids fail"
3892 echo "replace_nids should fail if MDS is UP"
3893 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
3894 error "replace_nids fail"
3896 stop_mds || error "stopping mds failed"
3898 if combined_mgs_mds; then
3899 start_mdt 1 "-o nosvc" ||
3900 error "starting mds with nosvc option failed"
3903 echo "command should accept two parameters"
3904 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
3905 error "command should accept two params"
3907 echo "correct device name should be passed"
3908 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
3909 error "wrong devname"
3911 echo "wrong nids list should not destroy the system"
3912 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
3915 echo "replace OST nid"
3916 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
3917 error "replace nids failed"
3919 echo "command should accept two parameters"
3920 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
3921 error "command should accept two params"
3923 echo "wrong nids list should not destroy the system"
3924 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
3927 echo "replace MDS nid"
3928 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
3929 error "replace nids failed"
3931 if ! combined_mgs_mds ; then
3938 check_mount || error "error after nid replace"
3939 cleanup || error "cleanup failed"
3942 run_test 66 "replace nids"
3944 test_67() { #LU-2950
3945 local legacy="$TMP/legacy_lnet_config"
3946 local new="$TMP/new_routes_test"
3947 local out="$TMP/config_out_file"
3948 local verify="$TMP/conv_verify"
3949 local verify_conf="$TMP/conf_verify"
3951 # Create the legacy file that will be run through the
3952 # lustre_routes_conversion script
3953 cat <<- LEGACY_LNET_CONFIG > $legacy
3954 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
3955 tcp2 54 10.1.3.2@tcp;
3956 tcp3 10.3.4.3@tcp:3;
3960 # Create the verification file to verify the output of
3961 # lustre_routes_conversion script against.
3962 cat <<- VERIFY_LNET_CONFIG > $verify
3963 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
3964 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
3965 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
3966 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
3967 tcp4: { gateway: 10.3.3.4@tcp }
3970 # Create the verification file to verify the output of
3971 # lustre_routes_config script against
3972 cat <<- VERIFY_LNET_CONFIG > $verify_conf
3973 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
3974 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
3975 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
3976 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
3977 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
3980 lustre_routes_conversion $legacy $new > /dev/null
3981 if [ -f $new ]; then
3982 # verify the conversion output
3983 cmp -s $new $verify > /dev/null
3984 if [ $? -eq 1 ]; then
3985 error "routes conversion failed"
3988 lustre_routes_config --dry-run --verbose $new > $out
3989 # check that the script succeeded
3990 cmp -s $out $verify_conf > /dev/null
3991 if [ $? -eq 1 ]; then
3992 error "routes config failed"
3995 error "routes conversion test failed"
3997 # remove generated files
3998 rm -f $new $legacy $verify $verify_conf $out
4000 run_test 67 "test routes conversion and configuration"
4008 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.53) ] ||
4009 { skip "Need MDS version at least 2.4.53"; return 0; }
4011 umount_client $MOUNT || error "umount client failed"
4013 start_mdt 1 || error "MDT start failed"
4016 # START-END - the sequences we'll be reserving
4017 START=$(do_facet $SINGLEMDS \
4018 lctl get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4019 END=$((START + (1 << 30)))
4020 do_facet $SINGLEMDS \
4021 lctl set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4023 # reset the sequences MDT0000 has already assigned
4024 do_facet $SINGLEMDS \
4025 lctl set_param seq.srv*MDT0000.space=clear
4027 # remount to let the client allocate new sequence
4028 mount_client $MOUNT || error "mount client failed"
4031 do_facet $SINGLEMDS \
4032 lctl get_param seq.srv*MDT0000.space
4033 $LFS path2fid $DIR/$tfile
4035 local old_ifs="$IFS"
4037 fid=($($LFS path2fid $DIR/$tfile))
4041 if [[ $seq < $END ]]; then
4042 error "used reserved sequence $seq?"
4044 cleanup || return $?
4046 run_test 68 "be able to reserve specific sequences in FLDB"
4049 local server_version=$(lustre_version_code $SINGLEMDS)
4051 [[ $server_version -lt $(version_code 2.4.2) ]] &&
4052 skip "Need MDS version at least 2.4.2" && return
4054 [[ $server_version -ge $(version_code 2.4.50) ]] &&
4055 [[ $server_version -lt $(version_code 2.5.0) ]] &&
4056 skip "Need MDS version at least 2.5.0" && return
4060 # use OST0000 since it probably has the most creations
4061 local OSTNAME=$(ostname_from_index 0)
4062 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4063 local last_id=$(do_facet mds1 lctl get_param -n \
4064 osc.$mdtosc_proc1.prealloc_last_id)
4066 # Want to have OST LAST_ID over 1.5 * OST_MAX_PRECREATE to
4067 # verify that the LAST_ID recovery is working properly. If
4068 # not, then the OST will refuse to allow the MDS connect
4069 # because the LAST_ID value is too different from the MDS
4070 #define OST_MAX_PRECREATE=20000
4071 local num_create=$((20000 * 5))
4074 $LFS setstripe -i 0 $DIR/$tdir
4075 createmany -o $DIR/$tdir/$tfile- $num_create ||
4076 error "createmany: failed to create $num_create files: $?"
4077 # delete all of the files with objects on OST0 so the
4078 # filesystem is not inconsistent later on
4079 $LFS find $MOUNT --ost 0 | xargs rm
4081 stop_ost || error "OST0 stop failure"
4082 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
4083 $(ostdevname 1) $(ostvdevname 1) ||
4084 error "reformat and replace $ostdev failed"
4085 start_ost || error "OST0 restart failure"
4086 wait_osc_import_state mds ost FULL
4088 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
4089 local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
4090 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
4094 run_test 69 "replace an OST with the same index"
4097 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4102 start_mdt 1 || error "MDT0 start fail"
4104 start_ost || error "OST0 start fail"
4106 start_mdt 2 || error "MDT1 start fail"
4108 mount_client $MOUNT || error "mount client fails"
4110 mkdir -p $DIR/$tdir || error "create dir fail"
4112 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4113 error "create remote dir fail"
4115 rm -rf $DIR/$tdir || error "delete dir fail"
4116 cleanup || return $?
4118 run_test 70a "start MDT0, then OST, then MDT1"
4121 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4124 start_ost || error "OST0 start fail"
4126 start_mdt 1 || error "MDT0 start fail"
4127 start_mdt 2 || error "MDT1 start fail"
4129 mount_client $MOUNT || error "mount client fails"
4131 mkdir -p $DIR/$tdir || error "create dir fail"
4133 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4134 error "create remote dir fail"
4136 rm -rf $DIR/$tdir || error "delete dir fail"
4138 cleanup || return $?
4140 run_test 70b "start OST, MDT1, MDT0"
4143 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4146 start_mdt 1 || error "MDT0 start fail"
4147 start_mdt 2 || error "MDT1 start fail"
4148 start_ost || error "OST0 start fail"
4150 mount_client $MOUNT || error "mount client fails"
4151 stop_mdt 1 || error "MDT1 start fail"
4153 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
4154 echo "deactivate $mdc_for_mdt1"
4155 $LCTL --device $mdc_for_mdt1 deactivate || return 1
4157 mkdir -p $DIR/$tdir && error "mkdir succeed"
4159 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4160 error "create remote dir succeed"
4162 cleanup || return $?
4164 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
4167 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4170 start_mdt 1 || error "MDT0 start fail"
4171 start_mdt 2 || error "MDT1 start fail"
4172 start_ost || error "OST0 start fail"
4174 mount_client $MOUNT || error "mount client fails"
4176 stop_mdt 2 || error "MDT1 start fail"
4178 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
4180 echo "deactivate $mdc_for_mdt2"
4181 $LCTL --device $mdc_for_mdt2 deactivate ||
4182 error "set $mdc_for_mdt2 deactivate failed"
4184 mkdir -p $DIR/$tdir || error "mkdir fail"
4185 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4186 error "create remote dir succeed"
4188 rm -rf $DIR/$tdir || error "delete dir fail"
4190 cleanup || return $?
4192 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
4195 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4196 if combined_mgs_mds; then
4197 skip "needs separate MGS/MDT" && return
4201 start_mdt 1 || error "MDT0 start fail"
4202 start_ost || error "OST0 start fail"
4203 start_mdt 2 || error "MDT1 start fail"
4204 start_ost2 || error "OST1 start fail"
4206 mount_client $MOUNT || error "mount client fails"
4208 mkdir -p $DIR/$tdir || error "mkdir fail"
4209 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4210 error "create remote dir succeed"
4212 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4213 rm -rf $DIR/$tdir || error "delete dir fail"
4215 umount_client $MOUNT
4216 stop_mdt 1 || error "MDT0 stop fail"
4217 stop_mdt 2 || error "MDT1 stop fail"
4218 stop_ost || error "OST0 stop fail"
4219 stop_ost2 || error "OST1 stop fail"
4221 run_test 71a "start MDT0 OST0, MDT1, OST1"
4224 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4225 if combined_mgs_mds; then
4226 skip "needs separate MGS/MDT" && return
4230 start_mdt 2 || error "MDT1 start fail"
4231 start_ost || error "OST0 start fail"
4232 start_mdt 1 || error "MDT0 start fail"
4233 start_ost2 || error "OST1 start fail"
4235 mount_client $MOUNT || error "mount client fails"
4237 mkdir -p $DIR/$tdir || error "mkdir fail"
4238 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4239 error "create remote dir succeed"
4241 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4242 rm -rf $DIR/$tdir || error "delete dir fail"
4244 umount_client $MOUNT
4245 stop_mdt 1 || error "MDT0 stop fail"
4246 stop_mdt 2 || error "MDT1 stop fail"
4247 stop_ost || error "OST0 stop fail"
4248 stop_ost2 || error "OST1 stop fail"
4250 run_test 71b "start MDT1, OST0, MDT0, OST1"
4253 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4254 if combined_mgs_mds; then
4255 skip "needs separate MGS/MDT" && return
4259 start_ost || error "OST0 start fail"
4260 start_ost2 || error "OST1 start fail"
4261 start_mdt 2 || error "MDT1 start fail"
4262 start_mdt 1 || error "MDT0 start fail"
4264 mount_client $MOUNT || error "mount client fails"
4266 mkdir -p $DIR/$tdir || error "mkdir fail"
4267 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4268 error "create remote dir succeed"
4270 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4271 rm -rf $DIR/$tdir || error "delete dir fail"
4273 umount_client $MOUNT
4274 stop_mdt 1 || error "MDT0 stop fail"
4275 stop_mdt 2 || error "MDT1 stop fail"
4276 stop_ost || error "OST0 stop fail"
4277 stop_ost2 || error "OST1 stop fail"
4280 run_test 71c "start OST0, OST1, MDT1, MDT0"
4283 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4284 if combined_mgs_mds; then
4285 skip "needs separate MGS/MDT" && return
4289 start_ost || error "OST0 start fail"
4290 start_mdt 2 || error "MDT0 start fail"
4291 start_mdt 1 || error "MDT0 start fail"
4292 start_ost2 || error "OST1 start fail"
4294 mount_client $MOUNT || error "mount client fails"
4296 mkdir -p $DIR/$tdir || error "mkdir fail"
4297 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4298 error "create remote dir succeed"
4300 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4301 rm -rf $DIR/$tdir || error "delete dir fail"
4303 umount_client $MOUNT
4304 stop_mdt 1 || error "MDT0 stop fail"
4305 stop_mdt 2 || error "MDT1 stop fail"
4306 stop_ost || error "OST0 stop fail"
4307 stop_ost2 || error "OST1 stop fail"
4310 run_test 71d "start OST0, MDT1, MDT0, OST1"
4313 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4314 if combined_mgs_mds; then
4315 skip "needs separate MGS/MDT" && return
4319 start_ost || error "OST0 start fail"
4320 start_mdt 2 || error "MDT1 start fail"
4321 start_ost2 || error "OST1 start fail"
4322 start_mdt 1 || error "MDT0 start fail"
4324 mount_client $MOUNT || error "mount client fails"
4326 mkdir -p $DIR/$tdir || error "mkdir fail"
4327 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4328 error "create remote dir succeed"
4330 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4331 rm -rf $DIR/$tdir || error "delete dir fail"
4333 umount_client $MOUNT
4334 stop_mdt 1 || error "MDT0 stop fail"
4335 stop_mdt 2 || error "MDT1 stop fail"
4336 stop_ost || error "OST0 stop fail"
4337 stop_ost2 || error "OST1 stop fail"
4340 run_test 71e "start OST0, MDT1, OST1, MDT0"
4342 test_72() { #LU-2634
4343 local mdsdev=$(mdsdevname 1)
4344 local ostdev=$(ostdevname 1)
4345 local cmd="$E2FSCK -fnvd $mdsdev"
4348 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
4349 skip "ldiskfs only test" && return
4351 #tune MDT with "-O extents"
4353 for num in $(seq $MDSCOUNT); do
4354 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
4355 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4356 error "add mds $num failed"
4357 $TUNE2FS -O extents $(mdsdevname $num)
4360 add ost1 $(mkfs_opts ost1 $ostdev) --reformat $ostdev ||
4361 error "add $ostdev failed"
4362 start_mgsmds || error "start mds failed"
4363 start_ost || error "start ost failed"
4364 mount_client $MOUNT || error "mount client failed"
4366 #create some short symlinks
4368 createmany -o $DIR/$tdir/$tfile-%d $fn
4369 echo "create $fn short symlinks"
4370 for i in $(seq -w 1 $fn); do
4371 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
4376 umount_client $MOUNT || error "umount client failed"
4377 stop_mds || error "stop mds failed"
4378 stop_ost || error "stop ost failed"
4381 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
4383 run_test 72 "test fast symlink with extents flag enabled"
4385 test_73() { #LU-3006
4387 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4388 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
4389 error "1st tunefs failed"
4390 start_mgsmds || error "start mds failed"
4391 start_ost || error "start ost failed"
4392 mount_client $MOUNT || error "mount client failed"
4393 lctl get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
4394 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
4395 umount_client $MOUNT || error "umount client failed"
4399 run_test 73 "failnode to update from mountdata properly"
4401 test_75() { # LU-2374
4402 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
4403 skip "Need MDS version at least 2.4.1" && return
4406 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
4407 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
4408 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
4409 --reformat $(ostdevname 1) $(ostvdevname 1)"
4411 #check with default parameters
4412 add mds1 $opts_mds || error "add mds1 failed for default params"
4413 add ost1 $opts_ost || error "add ost1 failed for default params"
4415 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
4416 opts_mds=$(echo $opts_mds |
4417 sed -e "s/--index=$index/--index=$index --mdt/")
4418 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
4419 opts_ost=$(echo $opts_ost |
4420 sed -e "s/--index=$index/--index=$index --ost/")
4422 add mds1 $opts_mds || error "add mds1 failed for new params"
4423 add ost1 $opts_ost || error "add ost1 failed for new params"
4426 run_test 75 "The order of --index should be irrelevant"
4429 [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] ||
4430 { skip "Need MDS version at least 2.4.52" && return 0; }
4432 local MDMB_PARAM="osc.*.max_dirty_mb"
4433 echo "Change MGS params"
4434 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
4436 echo "max_dirty_mb: $MAX_DIRTY_MB"
4437 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB + MAX_DIRTY_MB))
4438 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
4439 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
4440 wait_update $HOSTNAME "lctl get_param -n $MDMB_PARAM |
4441 head -1" $NEW_MAX_DIRTY_MB
4442 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
4443 echo "$MAX_DIRTY_MB"
4444 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
4445 error "error while apply max_dirty_mb"
4447 echo "Check the value is stored after remount"
4450 wait_update $HOSTNAME "lctl get_param -n $MDMB_PARAM |
4451 head -1" $NEW_MAX_DIRTY_MB
4452 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
4453 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
4454 error "max_dirty_mb is not saved after remount"
4456 echo "Change OST params"
4457 CLIENT_PARAM="obdfilter.*.client_cache_count"
4458 local CLIENT_CACHE_COUNT
4459 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4461 echo "client_cache_count: $CLIENT_CACHE_COUNT"
4462 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
4463 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
4464 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
4465 wait_update $(facet_host ost1) "lctl get_param -n $CLIENT_PARAM |
4466 head -1" $NEW_CLIENT_CACHE_COUNT
4467 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4469 echo "$CLIENT_CACHE_COUNT"
4470 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
4471 error "error while apply client_cache_count"
4473 echo "Check the value is stored after remount"
4476 wait_update $(facet_host ost1) "lctl get_param -n $CLIENT_PARAM |
4477 head -1" $NEW_CLIENT_CACHE_COUNT
4478 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4480 echo "$CLIENT_CACHE_COUNT"
4481 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
4482 error "client_cache_count is not saved after remount"
4485 run_test 76a "set permanent params set_param -P"
4487 test_76b() { # LU-4783
4488 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.57) ]] ||
4489 { skip "Need MGS version at least 2.5.57" && return 0; }
4492 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
4493 error "start params log failed"
4496 run_test 76b "verify params log setup correctly"
4498 test_77() { # LU-3445
4499 local server_version=$(lustre_version_code $SINGLEMDS)
4501 [[ $server_version -ge $(version_code 2.2.60) ]] &&
4502 [[ $server_version -le $(version_code 2.4.0) ]] &&
4503 skip "Need MDS version < 2.2.60 or > 2.4.0" && return
4505 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
4506 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
4507 skip_env "mixed loopback and real device not working" && return
4510 local fs2mdsdev=$(mdsdevname 1_2)
4511 local fs2ostdev=$(ostdevname 1_2)
4512 local fs2mdsvdev=$(mdsvdevname 1_2)
4513 local fs2ostvdev=$(ostvdevname 1_2)
4514 local fsname=test1234
4516 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
4518 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
4519 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
4520 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
4521 error "start fs2mds failed"
4523 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
4524 [[ $mgsnid = *,* ]] || mgsnid+=",$mgsnid"
4526 add fs2ost $(mkfs_opts ost1 $fs2ostdev) --mgsnode=$mgsnid \
4527 --failnode=$failnid --fsname=$fsname \
4528 --reformat $fs2ostdev $fs2ostvdev ||
4529 error "add fs2ost failed"
4530 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
4533 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
4534 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
4537 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
4540 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ||
4541 $(facet_fstype ost1) != ldiskfs ]] &&
4542 skip "only applicable to ldiskfs-based MDTs and OSTs" && return
4544 # reformat the Lustre filesystem with a smaller size
4545 local saved_MDSSIZE=$MDSSIZE
4546 local saved_OSTSIZE=$OSTSIZE
4547 MDSSIZE=$((MDSSIZE - 20000))
4548 OSTSIZE=$((OSTSIZE - 20000))
4549 reformat || error "(1) reformat Lustre filesystem failed"
4550 MDSSIZE=$saved_MDSSIZE
4551 OSTSIZE=$saved_OSTSIZE
4553 # mount the Lustre filesystem
4554 setup_noconfig || error "(2) setup Lustre filesystem failed"
4557 log "create test files"
4561 mkdir -p $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
4562 for i in $(seq $num_files); do
4563 file=$MOUNT/$tdir/$tfile-$i
4564 dd if=/dev/urandom of=$file count=1 bs=1M ||
4565 error "(4) create $file failed"
4568 # unmount the Lustre filesystem
4569 cleanup || error "(5) cleanup Lustre filesystem failed"
4571 # run e2fsck on the MDT and OST devices
4572 local mds_host=$(facet_active_host $SINGLEMDS)
4573 local ost_host=$(facet_active_host ost1)
4574 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
4575 local ost_dev=$(ostdevname 1)
4577 run_e2fsck $mds_host $mds_dev "-y"
4578 run_e2fsck $ost_host $ost_dev "-y"
4580 # get the original block count of the MDT and OST filesystems
4581 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
4582 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
4584 # expand the MDT and OST filesystems to the device size
4585 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
4586 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
4588 # run e2fsck on the MDT and OST devices again
4589 run_e2fsck $mds_host $mds_dev "-y"
4590 run_e2fsck $ost_host $ost_dev "-y"
4592 # mount the Lustre filesystem
4596 log "check files after expanding the MDT and OST filesystems"
4597 for i in $(seq $num_files); do
4598 file=$MOUNT/$tdir/$tfile-$i
4599 $CHECKSTAT -t file -s 1048576 $file ||
4600 error "(6) checkstat $file failed"
4604 log "create more files after expanding the MDT and OST filesystems"
4605 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
4606 file=$MOUNT/$tdir/$tfile-$i
4607 dd if=/dev/urandom of=$file count=1 bs=1M ||
4608 error "(7) create $file failed"
4611 # unmount the Lustre filesystem
4612 cleanup || error "(8) cleanup Lustre filesystem failed"
4614 # run e2fsck on the MDT and OST devices
4615 run_e2fsck $mds_host $mds_dev "-y"
4616 run_e2fsck $ost_host $ost_dev "-y"
4618 # get the maximum block count of the MDT and OST filesystems
4619 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
4620 local ost_max_blks=$(get_block_count ost1 $ost_dev)
4622 # get the minimum block count of the MDT and OST filesystems
4623 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
4624 grep minimum | sed -e 's/^.*filesystem: //g')
4625 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
4626 grep minimum | sed -e 's/^.*filesystem: //g')
4628 # shrink the MDT and OST filesystems to a smaller size
4632 if [[ $mds_max_blks -gt $mds_min_blks &&
4633 $mds_max_blks -gt $mds_orig_blks ]]; then
4634 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
4635 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
4636 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
4637 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
4638 error "shrink $SINGLEMDS to $new_blks failed"
4642 if [[ $ost_max_blks -gt $ost_min_blks &&
4643 $ost_max_blks -gt $ost_orig_blks ]]; then
4644 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
4645 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
4646 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
4647 run_resize2fs ost1 $ost_dev $new_blks ||
4648 error "shrink ost1 to $new_blks failed"
4652 # check whether the MDT or OST filesystem was shrunk or not
4654 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
4655 reformat || error "(10) reformat Lustre filesystem failed"
4659 # run e2fsck on the MDT and OST devices again
4660 run_e2fsck $mds_host $mds_dev "-y"
4661 run_e2fsck $ost_host $ost_dev "-y"
4663 # mount the Lustre filesystem again
4667 log "check files after shrinking the MDT and OST filesystems"
4668 for i in $(seq $((num_files + 10))); do
4669 file=$MOUNT/$tdir/$tfile-$i
4670 $CHECKSTAT -t file -s 1048576 $file ||
4671 error "(11) checkstat $file failed"
4674 # unmount and reformat the Lustre filesystem
4675 cleanup || error "(12) cleanup Lustre filesystem failed"
4676 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
4677 reformat || error "(14) reformat Lustre filesystem failed"
4679 run_test 78 "run resize2fs on MDT and OST filesystems"
4681 if ! combined_mgs_mds ; then
4687 # restore the values of MDSSIZE and OSTSIZE
4688 MDSSIZE=$STORED_MDSSIZE
4689 OSTSIZE=$STORED_OSTSIZE