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 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
53 export MULTIOP=${MULTIOP:-multiop}
55 . $LUSTRE/tests/test-framework.sh
57 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
59 # use small MDS + OST size to speed formatting time
60 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
61 # STORED_MDSSIZE is used in test_18
62 STORED_MDSSIZE=$MDSSIZE
63 STORED_OSTSIZE=$OSTSIZE
67 if ! combined_mgs_mds; then
68 # bug number for skipped test: 23954
69 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
72 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
73 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
74 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
77 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
78 # bug number for skipped test: LU-2778 LU-2059 LU-4444
79 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 57b 50h 69"
84 require_dsh_mds || exit 0
85 require_dsh_ost || exit 0
87 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45 69"
93 # The MGS must be started before the OSTs for a new fs, so start
94 # and stop to generate the startup logs.
97 wait_osc_import_state mds ost FULL
102 reformat_and_config() {
104 if ! combined_mgs_mds ; then
110 writeconf_or_reformat() {
111 # There are at most 2 OSTs for write_conf test
112 # who knows if/where $TUNEFS is installed?
113 # Better reformat if it fails...
114 writeconf_all $MDSCOUNT 2 ||
115 { echo "tunefs failed, reformatting instead" &&
116 reformat_and_config && return 0; }
126 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
132 local dev=$(mdsdevname $num)
135 echo "start mds service on `facet_active_host $facet`"
136 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
142 local dev=$(mdsdevname $num)
145 echo "stop mds service on `facet_active_host $facet`"
146 # These tests all use non-failover stop
147 stop $facet -f || return 97
153 for num in $(seq $MDSCOUNT); do
154 start_mdt $num $@ || return 94
159 if ! combined_mgs_mds ; then
167 for num in $(seq $MDSCOUNT); do
168 stop_mdt $num || return 97
173 echo "stop mgs service on `facet_active_host mgs`"
174 # These tests all use non-failover stop
175 stop mgs -f || return 97
179 echo "start ost1 service on `facet_active_host ost1`"
180 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
184 echo "stop ost1 service on `facet_active_host ost1`"
185 # These tests all use non-failover stop
186 stop ost1 -f || return 98
190 echo "start ost2 service on `facet_active_host ost2`"
191 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
195 echo "stop ost2 service on `facet_active_host ost2`"
196 # These tests all use non-failover stop
197 stop ost2 -f || return 93
202 echo "mount $FSNAME on ${MOUNTPATH}....."
203 zconf_mount `hostname` $MOUNTPATH || return 96
207 local mountopt="-o remount,$1"
209 echo "remount '$1' lustre on ${MOUNTPATH}....."
210 zconf_mount `hostname` $MOUNTPATH "$mountopt" || return 96
215 echo "umount lustre on ${MOUNTPATH}....."
216 zconf_umount `hostname` $MOUNTPATH || return 97
219 manual_umount_client(){
222 echo "manual umount lustre on ${MOUNT}...."
223 do_facet client "umount -d ${FORCE} $MOUNT"
229 start_mds || error "MDT start failed"
230 start_ost || error "OST start failed"
231 mount_client $MOUNT || error "client start failed"
232 client_up || error "client_up failed"
236 if ! combined_mgs_mds ; then
245 unload_modules_conf () {
246 if combined_mgs_mds || ! local_mode; then
247 unload_modules || return 1
252 stop_ost || return 202
253 stop_mds || return 201
254 unload_modules_conf || return 203
258 umount_client $MOUNT || return 200
259 cleanup_nocli || return $?
263 do_facet client "cp /etc/passwd $DIR/a" || return 71
264 do_facet client "rm $DIR/a" || return 72
265 # make sure lustre is actually mounted (touch will block,
266 # but grep won't, so do it after)
267 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
268 echo "setup single mount lustre success"
272 do_facet client "touch $DIR/a" || return 71
273 do_facet client "rm $DIR/a" || return 72
274 do_facet client "touch $DIR2/a" || return 73
275 do_facet client "rm $DIR2/a" || return 74
276 echo "setup double mount lustre success"
281 if [ "$ONLY" == "setup" ]; then
286 if [ "$ONLY" == "cleanup" ]; then
293 #create single point mountpoint
299 check_mount || return 41
302 run_test 0 "single mount setup"
305 start_mds || error "MDT start failed"
307 echo "start ost second time..."
308 start_ost && error "2nd OST start should fail"
309 mount_client $MOUNT || error "client start failed"
310 check_mount || return 42
313 run_test 1 "start up ost twice (should return errors)"
317 echo "start mds second time.."
318 start_mdt 1 && error "2nd MDT start should fail"
321 check_mount || return 43
324 run_test 2 "start up mds twice (should return err)"
328 #mount.lustre returns an error if already in mtab
329 mount_client $MOUNT && error "2nd client mount should fail"
330 check_mount || return 44
333 run_test 3 "mount client twice (should return err)"
337 touch $DIR/$tfile || return 85
341 # ok for ost to fail shutdown
342 if [ 202 -ne $eno ]; then
347 run_test 4 "force cleanup ost, then cleanup"
349 test_5a() { # was test_5
351 touch $DIR/$tfile || return 1
352 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
354 stop_mds -f || return 2
356 # cleanup may return an error from the failed
357 # disconnects; for now I'll consider this successful
358 # if all the modules have unloaded.
362 echo "killing umount"
363 kill -TERM $UMOUNT_PID
364 echo "waiting for umount to finish"
366 if grep " $MOUNT " /proc/mounts; then
367 echo "test 5: /proc/mounts after failed umount"
371 echo "killing umount"
372 kill -TERM $UMOUNT_PID
373 echo "waiting for umount to finish"
375 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
379 # stop_mds is a no-op here, and should not fail
380 cleanup_nocli || return $?
381 # df may have lingering entry
383 # mtab may have lingering entry
387 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
389 grep -q $MOUNT" " /etc/mtab || break
390 echo "Waiting /etc/mtab updated ... "
391 WAIT=$(( WAIT + sleep))
393 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
394 echo "/etc/mtab updated in $WAIT secs"
396 run_test 5a "force cleanup mds, then cleanup"
404 grep " $MOUNT " /etc/mtab && \
405 error false "unexpected entry in mtab before mount" && return 10
409 if ! combined_mgs_mds ; then
410 trap cleanup_5b EXIT ERR
415 [ -d $MOUNT ] || mkdir -p $MOUNT
416 mount_client $MOUNT && rc=1
417 grep " $MOUNT " /etc/mtab && \
418 error "$MOUNT entry in mtab after failed mount" && rc=11
420 # stop_mds is a no-op here, and should not fail
421 cleanup_nocli || rc=$?
422 if ! combined_mgs_mds ; then
427 run_test 5b "Try to start a client with no MGS (should return errs)"
430 grep " $MOUNT " /etc/mtab && \
431 error false "unexpected entry in mtab before mount" && return 10
436 [ -d $MOUNT ] || mkdir -p $MOUNT
437 local oldfs="${FSNAME}"
438 FSNAME="wrong.${FSNAME}"
439 mount_client $MOUNT || :
441 grep " $MOUNT " /etc/mtab && \
442 error "$MOUNT entry in mtab after failed mount" && rc=11
444 cleanup_nocli || rc=$?
447 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
450 grep " $MOUNT " /etc/mtab && \
451 error false "unexpected entry in mtab before mount" && return 10
453 [ "$(facet_fstype ost1)" = "zfs" ] &&
454 skip "LU-2059: no local config for ZFS OSTs" && return
460 mount_client $MOUNT || rc=1
462 grep " $MOUNT " /etc/mtab && \
463 error "$MOUNT entry in mtab after unmount" && rc=11
466 run_test 5d "mount with ost down"
469 grep " $MOUNT " /etc/mtab && \
470 error false "unexpected entry in mtab before mount" && return 10
476 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
477 do_facet client "lctl set_param fail_loc=0x80000506"
478 mount_client $MOUNT || echo "mount failed (not fatal)"
480 grep " $MOUNT " /etc/mtab && \
481 error "$MOUNT entry in mtab after unmount" && rc=11
484 run_test 5e "delayed connect, don't crash (bug 10268)"
487 if combined_mgs_mds ; then
488 skip "combined mgs and mds"
492 grep " $MOUNT " /etc/mtab && \
493 error false "unexpected entry in mtab before mount" && return 10
497 [ -d $MOUNT ] || mkdir -p $MOUNT
498 mount_client $MOUNT &
500 echo client_mount pid is $pid
504 if ! ps -f -p $pid >/dev/null; then
507 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
508 error "mount returns $rc, expected to hang"
517 # mount should succeed after start mds
520 [ $rc -eq 0 ] || error "mount returned $rc"
521 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
525 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
530 mount_client ${MOUNT} || return 87
531 touch $DIR/a || return 86
534 run_test 6 "manual umount, then mount again"
539 cleanup_nocli || return $?
541 run_test 7 "manual umount, then cleanup"
546 check_mount2 || return 45
547 umount_client $MOUNT2
550 run_test 8 "double mount setup"
555 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
556 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
558 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
559 if [ "$CHECK_PTLDEBUG" ] && { \
560 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
561 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
562 echo "lnet.debug success"
564 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
567 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
568 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
569 echo "lnet.subsystem_debug success"
571 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
574 stop_ost || return $?
576 run_test 9 "test ptldebug and subsystem for mkfs"
584 do_facet $facet "test -b $dev" || rc=1
585 if [[ "$size" ]]; then
586 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
587 awk '($3 == "in") { print $1 }')
588 [[ $in = "1+0" ]] || rc=1
594 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
595 # But with new MDS stack we don't care about the mode of local objects
596 # anymore, so this test is removed. See bug 22944 for more details.
600 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
601 skip "Only applicable to ldiskfs-based MDTs"
606 check_mount || return 41
609 echo "Remove mds config log"
610 if ! combined_mgs_mds ; then
614 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
615 $(mgsdevname) || return \$?" || return $?
617 if ! combined_mgs_mds ; then
622 start_mds && return 42
625 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
628 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
629 skip "Only applicable to ldiskfs-based MDTs"
633 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
638 # check if current MDSSIZE is large enough
639 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
640 log "use MDSSIZE=$MDSSIZE"
642 # check if the global config has a large enough MDSSIZE
643 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
644 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
645 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
647 # check if the block device is large enough
648 is_blkdev $SINGLEMDS $MDSDEV $MIN
649 local large_enough=$?
650 if [ -n "$OK" ]; then
651 [ $large_enough -ne 0 ] && OK=""
653 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
654 log "use device $MDSDEV with MIN=$MIN"
657 # check if a loopback device has enough space for fs metadata (5%)
659 if [ -z "$OK" ]; then
660 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
661 awk '($1 != "Filesystem") {print $4}')
662 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
663 OK=1 && myMDSSIZE=$MIN && \
664 log "use file $MDSDEV with MIN=$MIN"
667 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
670 echo "mount mds with large journal..."
672 local OLD_MDSSIZE=$MDSSIZE
676 echo "mount lustre system..."
678 check_mount || return 41
680 echo "check journal size..."
681 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
682 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
683 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
685 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
693 run_test 18 "check mkfs creates large journals"
696 start_mds || return 1
697 stop_mds -f || return 2
699 run_test 19a "start/stop MDS without OSTs"
702 [ "$(facet_fstype ost1)" = "zfs" ] &&
703 skip "LU-2059: no local config for ZFS OSTs" && return
705 start_ost || return 1
706 stop_ost -f || return 2
708 run_test 19b "start/stop OSTs without MDS"
711 # first format the ost/mdt
715 check_mount || return 43
717 remount_client ro $MOUNT || return 44
718 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
719 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
720 remount_client rw $MOUNT || return 47
722 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
723 MCNT=`grep -c $MOUNT /etc/mtab`
724 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
729 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
734 wait_osc_import_state mds ost FULL
738 run_test 21a "start mds before ost, stop ost first"
741 [ "$(facet_fstype ost1)" = "zfs" ] &&
742 skip "LU-2059: no local config for ZFS OSTs" && return
746 wait_osc_import_state mds ost FULL
750 run_test 21b "start ost before mds, stop mds first"
756 wait_osc_import_state mds ost2 FULL
760 #writeconf to remove all ost2 traces for subsequent tests
761 writeconf_or_reformat
763 run_test 21c "start mds between two osts, stop mds last"
766 if combined_mgs_mds ; then
767 skip "need separate mgs device" && return 0
777 wait_osc_import_state mds ost2 FULL
783 #writeconf to remove all ost2 traces for subsequent tests
784 writeconf_or_reformat
787 run_test 21d "start mgs then ost and then mds"
792 echo Client mount with ost in logs, but none running
794 # wait until mds connected to ost and open client connection
795 wait_osc_import_state mds ost FULL
798 # check_mount will block trying to contact ost
799 mcreate $DIR/$tfile || return 40
800 rm -f $DIR/$tfile || return 42
804 echo Client mount with a running ost
807 # if gss enabled, wait full time to let connection from
808 # mds to ost be established, due to the mismatch between
809 # initial connect timeout and gss context negotiation timeout.
810 # This perhaps could be remove after AT landed.
811 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
812 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
815 wait_osc_import_state mds ost FULL
816 wait_osc_import_state client ost FULL
817 check_mount || return 41
822 run_test 22 "start a client before osts (should return errs)"
824 test_23a() { # was test_23
828 # force down client so that recovering mds waits for reconnect
829 local running=$(grep -c $MOUNT /proc/mounts) || true
830 if [ $running -ne 0 ]; then
831 echo "Stopping client $MOUNT (opts: -f)"
835 # enter recovery on mds
837 # try to start a new client
838 mount_client $MOUNT &
840 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
841 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
842 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
844 ps --ppid $MOUNT_LUSTRE_PID
845 echo "waiting for mount to finish"
847 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
848 # SIGTERM works but it does not spread to offspring processses
849 kill -s TERM $MOUNT_PID
850 kill -s TERM $MOUNT_LUSTRE_PID
851 # we can not wait $MOUNT_PID because it is not a child of this shell
857 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
859 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
860 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
863 [ -z "$PID1" -a -z "$PID2" ] && break
864 echo "waiting for mount to finish ... "
865 WAIT=$(( WAIT + sleep))
867 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
868 error "MOUNT_PID $MOUNT_PID and "\
869 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
872 stop_mds || error "stopping MDSes failed"
873 stop_ost || error "stopping OSSes failed"
875 run_test 23a "interrupt client during recovery mount delay"
880 test_23b() { # was test_23
883 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
884 lctl set_param fail_loc=0x80000313
888 run_test 23b "Simulate -EINTR during mount"
890 fs2mds_HOST=$mds_HOST
891 fs2ost_HOST=$ost_HOST
893 MDSDEV1_2=$fs2mds_DEV
894 OSTDEV1_2=$fs2ost_DEV
895 OSTDEV2_2=$fs3ost_DEV
899 echo "umount $MOUNT2 ..."
900 umount $MOUNT2 || true
901 echo "stopping fs2mds ..."
902 stop fs2mds -f || true
903 echo "stopping fs2ost ..."
904 stop fs2ost -f || true
908 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
910 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
911 is_blkdev $SINGLEMDS $MDSDEV && \
912 skip_env "mixed loopback and real device not working" && return
915 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
917 local fs2mdsdev=$(mdsdevname 1_2)
918 local fs2ostdev=$(ostdevname 1_2)
919 local fs2mdsvdev=$(mdsvdevname 1_2)
920 local fs2ostvdev=$(ostvdevname 1_2)
922 # test 8-char fsname as well
923 local FSNAME2=test1234
925 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
926 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
928 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
929 --reformat $fs2ostdev $fs2ostvdev || exit 10
932 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
933 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
935 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || return 1
937 check_mount || return 2
938 # files written on 1 should not show up on 2
939 cp /etc/passwd $DIR/$tfile
941 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
944 cp /etc/passwd $MOUNT2/b || return 3
945 rm $MOUNT2/b || return 4
946 # 2 is actually mounted
947 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
949 facet_failover fs2mds
950 facet_failover fs2ost
953 # the MDS must remain up until last MDT
955 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
956 [ -z "$MDS" ] && error "No MDT" && return 8
958 cleanup_nocli || return 6
960 run_test 24a "Multiple MDTs on a single node"
963 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
965 if [ -z "$fs2mds_DEV" ]; then
966 local dev=${SINGLEMDS}_dev
968 is_blkdev $SINGLEMDS $MDSDEV && \
969 skip_env "mixed loopback and real device not working" && return
972 local fs2mdsdev=$(mdsdevname 1_2)
973 local fs2mdsvdev=$(mdsvdevname 1_2)
975 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
976 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
978 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
981 run_test 24b "Multiple MGSs on a single node (should return err)"
985 check_mount || return 2
986 local MODULES=$($LCTL modules | awk '{ print $2 }')
987 rmmod $MODULES 2>/dev/null || true
990 run_test 25 "Verify modules are referenced"
994 # we need modules before mount for sysctl, so make sure...
995 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
996 #define OBD_FAIL_MDS_FS_SETUP 0x135
997 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
998 start_mds && echo MDS started && return 1
999 lctl get_param -n devices
1000 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
1001 [ $DEVS -gt 0 ] && return 2
1002 # start mds to drop writeconf setting
1003 start_mds || return 3
1004 stop_mds || return 4
1005 unload_modules_conf || return $?
1007 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1010 [ "$(facet_fstype ost1)" = "zfs" ] &&
1011 skip "LU-2059: no local config for ZFS OSTs" && return
1013 start_ost || return 1
1014 start_mds || return 2
1015 echo "Requeue thread should have started: "
1016 ps -e | grep ll_cfg_requeue
1017 set_conf_param_and_check ost1 \
1018 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1019 "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
1022 run_test 27a "Reacquire MGS lock if OST started first"
1027 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1028 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1030 facet_failover $SINGLEMDS
1031 set_conf_param_and_check $SINGLEMDS \
1032 "lctl get_param -n mdt.$device.identity_acquire_expire" \
1033 "$device.mdt.identity_acquire_expire" || return 3
1034 set_conf_param_and_check client \
1035 "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight"\
1036 "$device.mdc.max_rpcs_in_flight" || return 4
1040 run_test 27b "Reacquire MGS lock after failover"
1044 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1045 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1047 FINAL=$(($ORIG + 1))
1048 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL || return 3
1049 FINAL=$(($FINAL + 1))
1050 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL || return 4
1051 umount_client $MOUNT || return 200
1054 if [ $RESULT -ne $FINAL ]; then
1055 echo "New config not seen: wanted $FINAL got $RESULT"
1058 echo "New config success: got $RESULT"
1060 set_conf_param_and_check client "$TEST" "$PARAM" $ORIG || return 5
1063 run_test 28 "permanent parameter setting"
1065 test_28a() { # LU-4221
1066 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1067 { skip "Need OST version at least 2.5.52" && return 0; }
1068 [ "$(facet_fstype ost1)" = "zfs" ] &&
1069 skip "LU-4221: no such proc params for ZFS OSTs" && return
1076 local device="$FSNAME-OST0000"
1080 # In this test we will set three kinds of proc parameters with
1082 # 1. the ones moved from the OFD to the OSD, and only their
1083 # symlinks kept in obdfilter
1084 # 2. non-symlink ones in the OFD
1085 # 3. non-symlink ones in the OSD
1088 # prepare a symlink parameter in the OFD
1089 name="writethrough_cache_enable"
1090 param="$device.ost.$name"
1091 cmd="$LCTL get_param -n obdfilter.$device.$name"
1093 # conf_param the symlink parameter in the OFD
1094 old=$(do_facet ost1 $cmd)
1095 new=$(((old + 1) % 2))
1096 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1097 error "lctl conf_param $device.ost.$param=$new failed"
1099 # conf_param the target parameter in the OSD
1100 param="$device.osd.$name"
1101 cmd="$LCTL get_param -n osd-*.$device.$name"
1102 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1103 error "lctl conf_param $device.osd.$param=$old failed"
1106 # prepare a non-symlink parameter in the OFD
1107 name="client_cache_seconds"
1108 param="$device.ost.$name"
1109 cmd="$LCTL get_param -n obdfilter.$device.$name"
1111 # conf_param the parameter in the OFD
1112 old=$(do_facet ost1 $cmd)
1114 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1115 error "lctl conf_param $device.ost.$param=$new failed"
1116 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1117 error "lctl conf_param $device.ost.$param=$old failed"
1120 # prepare a non-symlink parameter in the OSD
1121 name="lma_self_repair"
1122 param="$device.osd.$name"
1123 cmd="$LCTL get_param -n osd-*.$device.$name"
1125 # conf_param the parameter in the OSD
1126 old=$(do_facet ost1 $cmd)
1127 new=$(((old + 1) % 2))
1128 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1129 error "lctl conf_param $device.osd.$param=$new failed"
1130 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1131 error "lctl conf_param $device.osd.$param=$old failed"
1135 run_test 28a "set symlink parameters permanently with conf_param"
1138 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1139 setup > /dev/null 2>&1
1143 local PARAM="$FSNAME-OST0001.osc.active"
1144 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1145 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1147 ACTV=$(lctl get_param -n $PROC_ACT)
1149 set_conf_param_and_check client \
1150 "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1151 # also check ost_server_uuid status
1152 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1153 if [ -z "$RESULT" ]; then
1154 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1157 echo "Live client success: got $RESULT"
1161 for num in $(seq $MDSCOUNT); do
1162 local mdtosc=$(get_mdtosc_proc_path mds${num} $FSNAME-OST0001)
1163 local MPROC="osc.$mdtosc.active"
1168 RESULT=$(do_facet mds${num} " lctl get_param -n $MPROC")
1169 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1170 if [ $RESULT -eq $DEAC ]; then
1171 echo -n "MDT deactivated also after"
1172 echo "$WAIT sec (got $RESULT)"
1176 if [ $WAIT -eq $MAX ]; then
1177 echo -n "MDT not deactivated: wanted $DEAC"
1181 echo "Waiting $(($MAX - $WAIT))secs for MDT deactivated"
1184 # test new client starts deactivated
1185 umount_client $MOUNT || return 200
1187 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1188 if [ -z "$RESULT" ]; then
1189 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1192 echo "New client success: got $RESULT"
1195 # make sure it reactivates
1196 set_conf_param_and_check client \
1197 "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1199 umount_client $MOUNT
1202 #writeconf to remove all ost2 traces for subsequent tests
1203 writeconf_or_reformat
1205 run_test 29 "permanently remove an OST"
1210 echo Big config llog
1211 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1213 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1214 for i in ${LIST[@]}; do
1215 set_conf_param_and_check client "$TEST" \
1216 "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1218 # make sure client restart still works
1219 umount_client $MOUNT
1220 mount_client $MOUNT || return 4
1221 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1224 echo Erase parameter setting
1225 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1226 umount_client $MOUNT
1227 mount_client $MOUNT || return 6
1229 echo "deleted (default) value=$FINAL, orig=$ORIG"
1230 # assumes this parameter started at the default value
1231 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1235 run_test 30a "Big config llog and conf_param deletion"
1240 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1241 # numerical part of it. Hopefully that's not already a failover address for
1243 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1244 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1245 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1246 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1247 echo "Using fake nid $NEW"
1249 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1250 set_conf_param_and_check client "$TEST" \
1251 "$FSNAME-OST0000.failover.node" $NEW ||
1252 error "didn't add failover nid $NEW"
1253 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1255 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1256 echo "should have 2 failover nids: $NIDCOUNT"
1257 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1258 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1259 umount_client $MOUNT
1260 mount_client $MOUNT || return 3
1262 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1264 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1265 echo "only 1 final nid should remain: $NIDCOUNT"
1266 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1270 run_test 30b "Remove failover nids"
1272 test_31() { # bug 10734
1273 # ipaddr must not exist
1274 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1277 run_test 31 "Connect to non-existent node (shouldn't crash)"
1281 T32_BLIMIT=20480 # Kbytes
1285 # This is not really a test but a tool to create new disk
1286 # image tarballs for the upgrade tests.
1288 # Disk image tarballs should be created on single-node
1289 # clusters by running this test with default configurations
1290 # plus a few mandatory environment settings that are verified
1291 # at the beginning of the test.
1293 test_32newtarball() {
1297 local tmp=$TMP/t32_image_create
1299 if [ $FSNAME != t32fs -o $MDSCOUNT -ne 1 -o \
1300 \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o $OSTCOUNT -ne 1 -o \
1301 -z "$OSTDEV1" ]; then
1302 error "Needs FSNAME=t32fs MDSCOUNT=1 MDSDEV1=<nonexistent_file>" \
1303 "(or MDSDEV, in the case of b1_8) OSTCOUNT=1" \
1304 "OSTDEV1=<nonexistent_file>"
1308 echo "Found stale $tmp"
1313 tar cf - -C $src . | tar xf - -C $tmp/src
1314 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1315 count=$(($T32_BLIMIT / 1024 / 2))
1316 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1318 # format ost with comma-separated NIDs to verify LU-4460
1319 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
1320 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1324 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1325 $LFS quotacheck -ug /mnt/$FSNAME
1326 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1329 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1336 ls -Rni --time-style=+%s >$tmp/img/list
1337 find . ! -name .lustre -type f -exec sha1sum {} \; |
1338 sort -k 2 >$tmp/img/sha1sums
1340 $LCTL get_param -n version | head -n 1 |
1341 sed -e 's/^lustre: *//' >$tmp/img/commit
1343 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1344 $LFS quotaon -ug /mnt/$FSNAME
1345 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1346 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1347 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1348 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1349 | tr -d "*" > $tmp/img/bspace
1350 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1351 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1352 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1353 | tr -d "*" > $tmp/img/ispace
1358 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1361 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1362 echo "Data verification failed"
1365 uname -r >$tmp/img/kernel
1366 uname -m >$tmp/img/arch
1368 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1369 mv $OSTDEV1 $tmp/img
1371 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1372 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1375 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1380 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1383 # The list of applicable tarballs is returned via the caller's
1384 # variable "tarballs".
1387 local node=$(facet_active_host $SINGLEMDS)
1388 local r="do_node $node"
1390 if [ "$CLIENTONLY" ]; then
1391 skip "Client-only testing"
1395 if ! $r which $TUNEFS; then
1396 skip_env "tunefs.lustre required on $node"
1400 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1402 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 -name \'disk*-$IMGTYPE.tar.bz2\')
1404 if [ -z "$tarballs" ]; then
1405 skip "No applicable tarballs found"
1410 t32_test_cleanup() {
1412 local fstype=$(facet_fstype $SINGLEMDS)
1415 if $shall_cleanup_lustre; then
1416 umount $tmp/mnt/lustre || rc=$?
1418 if $shall_cleanup_mdt; then
1419 $r umount -d $tmp/mnt/mdt || rc=$?
1421 if $shall_cleanup_mdt1; then
1422 $r umount -d $tmp/mnt/mdt1 || rc=$?
1424 if $shall_cleanup_ost; then
1425 $r umount -d $tmp/mnt/ost || rc=$?
1430 if [ $fstype == "zfs" ]; then
1431 $r $ZPOOL destroy t32fs-mdt1 || rc=$?
1432 $r $ZPOOL destroy t32fs-ost1 || rc=$?
1437 t32_bits_per_long() {
1439 # Yes, this is not meant to be perfect.
1449 t32_reload_modules() {
1451 local all_removed=false
1454 while ((i < 20)); do
1455 echo "Unloading modules on $node: Attempt $i"
1456 do_rpc_nodes $node $LUSTRE_RMMOD $(facet_fstype $SINGLEMDS) &&
1458 do_rpc_nodes $node check_mem_leak || return 1
1459 if $all_removed; then
1460 do_rpc_nodes $node load_modules
1466 echo "Unloading modules on $node: Given up"
1470 t32_wait_til_devices_gone() {
1476 echo wait for devices to go
1477 while ((i < 20)); do
1478 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1479 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1480 ((devices == 0 && loops == 0)) && return 0
1484 echo "waiting for dev on $node: dev $devices loop $loops given up"
1485 do_rpc_nodes $node "losetup -a"
1486 do_rpc_nodes $node "$LCTL devices_list"
1490 t32_verify_quota() {
1494 local fstype=$(facet_fstype $SINGLEMDS)
1498 $LFS quota -u $T32_QID -v $mnt
1500 qval=$($LFS quota -v -u $T32_QID $mnt |
1501 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1502 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1504 [ $qval -eq $img_bspace ] || {
1505 echo "bspace, act:$qval, exp:$img_bspace"
1509 qval=$($LFS quota -v -u $T32_QID $mnt |
1510 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1511 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1513 [ $qval -eq $img_ispace ] || {
1514 echo "ispace, act:$qval, exp:$img_ispace"
1518 qval=$($LFS quota -v -u $T32_QID $mnt |
1519 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1520 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1522 [ $qval -eq $T32_BLIMIT ] || {
1523 echo "blimit, act:$qval, exp:$T32_BLIMIT"
1527 qval=$($LFS quota -v -u $T32_QID $mnt |
1528 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1529 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1531 [ $qval -eq $T32_ILIMIT ] || {
1532 echo "ilimit, act:$qval, exp:$T32_ILIMIT"
1536 do_node $node $LCTL conf_param $fsname.quota.mdt=ug
1537 cmd="$LCTL get_param -n osd-$fstype.$fsname-MDT0000"
1538 cmd=$cmd.quota_slave.enabled
1539 wait_update $node "$cmd" "ug" || {
1540 echo "Enable mdt quota failed"
1544 do_node $node $LCTL conf_param $fsname.quota.ost=ug
1545 cmd="$LCTL get_param -n osd-$fstype.$fsname-OST0000"
1546 cmd=$cmd.quota_slave.enabled
1547 wait_update $node "$cmd" "ug" || {
1548 echo "Enable ost quota failed"
1553 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1554 bs=1M count=$(($T32_BLIMIT / 1024)) oflag=sync && {
1555 echo "Write succeed, but expect -EDQUOT"
1558 rm -f $mnt/t32_qf_new
1560 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1562 echo "Create succeed, but expect -EDQUOT"
1565 unlinkmany $mnt/t32_qf_ $T32_ILIMIT
1573 local dne_upgrade=${dne_upgrade:-"no"}
1574 local ff_convert=${ff_convert:-"no"}
1575 local shall_cleanup_mdt=false
1576 local shall_cleanup_mdt1=false
1577 local shall_cleanup_ost=false
1578 local shall_cleanup_lustre=false
1579 local node=$(facet_active_host $SINGLEMDS)
1580 local r="do_node $node"
1581 local node2=$(facet_active_host mds2)
1589 local nid=$($r $LCTL list_nids | head -1)
1595 local fstype=$(facet_fstype $SINGLEMDS)
1596 local mdt_dev=$tmp/mdt
1597 local ost_dev=$tmp/ost
1599 trap 'trap - RETURN; t32_test_cleanup' RETURN
1601 mkdir -p $tmp/mnt/lustre
1602 $r mkdir -p $tmp/mnt/{mdt,ost}
1603 $r tar xjvf $tarball -S -C $tmp || {
1604 error_noexit "Unpacking the disk image tarball"
1607 img_commit=$($r cat $tmp/commit)
1608 img_kernel=$($r cat $tmp/kernel)
1609 img_arch=$($r cat $tmp/arch)
1610 img_bspace=$($r cat $tmp/bspace)
1611 img_ispace=$($r cat $tmp/ispace)
1612 echo "Upgrading from $(basename $tarball), created with:"
1613 echo " Commit: $img_commit"
1614 echo " Kernel: $img_kernel"
1615 echo " Arch: $img_arch"
1617 local version=$(version_code $img_commit)
1618 [[ $version -ge $(version_code 2.5.0) ]] && ff_convert="no"
1620 if [ $fstype == "zfs" ]; then
1622 $r $ZPOOL import -f -d $tmp t32fs-mdt1
1623 $r $ZPOOL import -f -d $tmp t32fs-ost1
1624 mdt_dev=t32fs-mdt1/mdt1
1625 ost_dev=t32fs-ost1/ost1
1626 wait_update_facet $SINGLEMDS "$ZPOOL list |
1627 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1628 error_noexit "import zfs pool failed"
1633 $r $LCTL set_param debug="$PTLDEBUG"
1635 $r $TUNEFS --dryrun $mdt_dev || {
1637 error_noexit "tunefs.lustre before mounting the MDT"
1640 if [ "$writeconf" ]; then
1642 if [ $fstype == "ldiskfs" ]; then
1644 $r $TUNEFS --quota $mdt_dev || {
1646 error_noexit "Enable mdt quota feature"
1651 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1652 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1653 { skip "LU-2200: Cannot run over Inifiniband w/o lctl replace_nids "
1654 "(Need MGS version at least 2.3.59)"; return 0; }
1656 local osthost=$(facet_active_host ost1)
1657 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1660 if [ $fstype == "ldiskfs" ]; then
1663 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1664 $r lctl replace_nids $fsname-OST0000 $ostnid
1665 $r lctl replace_nids $fsname-MDT0000 $nid
1666 $r umount -d $tmp/mnt/mdt
1669 mopts=exclude=$fsname-OST0000
1670 if [ $fstype == "ldiskfs" ]; then
1675 t32_wait_til_devices_gone $node
1677 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1679 error_noexit "Mounting the MDT"
1682 shall_cleanup_mdt=true
1684 if [ "$dne_upgrade" != "no" ]; then
1685 local fs2mdsdev=$(mdsdevname 1_2)
1686 local fs2mdsvdev=$(mdsvdevname 1_2)
1688 echo "mkfs new MDT on ${fs2mdsdev}...."
1689 if [ $(facet_fstype mds1) == ldiskfs ]; then
1690 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1693 add fs2mds $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1694 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1695 error_noexit "Mkfs new MDT failed"
1699 $r $TUNEFS --dryrun $fs2mdsdev || {
1700 error_noexit "tunefs.lustre before mounting the MDT"
1704 echo "mount new MDT....$fs2mdsdev"
1705 $r mkdir -p $tmp/mnt/mdt1
1706 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1707 error_noexit "mount mdt1 failed"
1710 shall_cleanup_mdt1=true
1713 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1714 error_noexit "Getting MDT UUID"
1717 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1718 error_noexit "Unexpected MDT UUID: \"$uuid\""
1722 $r $TUNEFS --dryrun $ost_dev || {
1723 error_noexit "tunefs.lustre before mounting the OST"
1726 if [ "$writeconf" ]; then
1727 mopts=mgsnode=$nid,$writeconf
1728 if [ $fstype == "ldiskfs" ]; then
1730 $r $TUNEFS --quota $ost_dev || {
1732 error_noexit "Enable ost quota feature"
1738 if [ $fstype == "ldiskfs" ]; then
1742 $r $MOUNT_CMD -o $mopts $ost_dev $tmp/mnt/ost || {
1743 error_noexit "Mounting the OST"
1746 shall_cleanup_ost=true
1748 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1749 error_noexit "Getting OST UUID"
1752 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1753 error_noexit "Unexpected OST UUID: \"$uuid\""
1757 $r $LCTL conf_param $fsname-OST0000.osc.max_dirty_mb=15 || {
1758 error_noexit "Setting \"max_dirty_mb\""
1761 $r $LCTL conf_param $fsname-OST0000.failover.node=$nid || {
1762 error_noexit "Setting OST \"failover.node\""
1765 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1766 error_noexit "Setting \"max_rpcs_in_flight\""
1769 $r $LCTL conf_param $fsname-MDT0000.failover.node=$nid || {
1770 error_noexit "Setting MDT \"failover.node\""
1773 $r $LCTL pool_new $fsname.interop || {
1774 error_noexit "Setting \"interop\""
1777 $r $LCTL conf_param $fsname-MDT0000.lov.stripesize=4M || {
1778 error_noexit "Setting \"lov.stripesize\""
1782 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1783 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1784 error_noexit "Start OI scrub on OST0"
1788 # The oi_scrub should be on ost1, but for test_32(),
1789 # all on the SINGLEMDS.
1790 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1791 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1792 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1793 error_noexit "Failed to get the expected 'completed'"
1797 local UPDATED=$($r $LCTL get_param -n \
1798 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1799 awk '/^updated/ { print $2 }')
1800 [ $UPDATED -ge 1 ] || {
1801 error_noexit "Only $UPDATED objects have been converted"
1806 if [ "$dne_upgrade" != "no" ]; then
1807 $r $LCTL conf_param \
1808 $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
1809 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
1812 $r $LCTL conf_param $fsname-MDT0001.failover.node=$nid || {
1813 error_noexit "Setting MDT1 \"failover.node\""
1816 $r $LCTL conf_param $fsname-MDT0001.lov.stripesize=4M || {
1817 error_noexit "Setting MDT1 \"lov.stripesize\""
1823 if [ "$writeconf" ]; then
1824 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
1825 error_noexit "Mounting the client"
1828 shall_cleanup_lustre=true
1829 $LCTL set_param debug="$PTLDEBUG"
1831 t32_verify_quota $node $fsname $tmp/mnt/lustre || {
1832 error_noexit "verify quota failed"
1836 if [ "$dne_upgrade" != "no" ]; then
1837 $LFS mkdir -i 1 $tmp/mnt/lustre/remote_dir || {
1838 error_noexit "set remote dir failed"
1842 pushd $tmp/mnt/lustre
1843 tar -cf - . --exclude=./remote_dir |
1844 tar -xvf - -C remote_dir 1>/dev/null || {
1845 error_noexit "cp to remote dir failed"
1851 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
1852 error_noexit "dd failed"
1855 rm -rf $tmp/mnt/lustre/tmp_file || {
1856 error_noexit "rm failed"
1860 if $r test -f $tmp/sha1sums; then
1861 # LU-2393 - do both sorts on same node to ensure locale
1863 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
1864 if [ "$dne_upgrade" != "no" ]; then
1865 pushd $tmp/mnt/lustre/remote_dir
1867 pushd $tmp/mnt/lustre
1870 find ! -name .lustre -type f -exec sha1sum {} \; |
1871 sort -k 2 >$tmp/sha1sums || {
1872 error_noexit "sha1sum"
1876 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
1877 error_noexit "sha1sum verification failed"
1881 echo "sha1sum verification skipped"
1884 if [ "$dne_upgrade" != "no" ]; then
1885 rm -rf $tmp/mnt/lustre/remote_dir || {
1886 error_noexit "remove remote dir failed"
1891 if $r test -f $tmp/list; then
1893 # There is not a Test Framework API to copy files to or
1894 # from a remote node.
1896 # LU-2393 - do both sorts on same node to ensure locale
1898 $r cat $tmp/list | sort -k 6 >$tmp/list.orig
1899 pushd $tmp/mnt/lustre
1900 ls -Rni --time-style=+%s | sort -k 6 >$tmp/list || {
1906 # 32-bit and 64-bit clients use different algorithms to
1907 # convert FIDs into inode numbers. Hence, remove the inode
1908 # numbers from the lists, if the original list was created
1909 # on an architecture with different number of bits per
1912 if [ $(t32_bits_per_long $(uname -m)) != \
1913 $(t32_bits_per_long $img_arch) ]; then
1914 echo "Different number of bits per \"long\" from the disk image"
1915 for list in list.orig list; do
1916 sed -i -e 's/^[0-9]\+[ \t]\+//' $tmp/$list
1919 if ! diff -ub $tmp/list.orig $tmp/list; then
1920 error_noexit "list verification failed"
1924 echo "list verification skipped"
1928 # When adding new data verification tests, please check for
1929 # the presence of the required reference files first, like
1930 # the "sha1sums" and "list" tests above, to avoid the need to
1931 # regenerate every image for each test addition.
1934 nrpcs_orig=$($LCTL get_param \
1935 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
1936 error_noexit "Getting \"max_rpcs_in_flight\""
1939 nrpcs=$((nrpcs_orig + 5))
1940 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=$nrpcs || {
1941 error_noexit "Changing \"max_rpcs_in_flight\""
1944 wait_update $HOSTNAME "$LCTL get_param \
1945 -n mdc.*MDT0000*.max_rpcs_in_flight" $nrpcs || {
1946 error_noexit "Verifying \"max_rpcs_in_flight\""
1950 umount $tmp/mnt/lustre || {
1951 error_noexit "Unmounting the client"
1954 shall_cleanup_lustre=false
1956 if [ "$dne_upgrade" != "no" ]; then
1957 $r umount -d $tmp/mnt/mdt1 || {
1958 error_noexit "Unmounting the MDT2"
1961 shall_cleanup_mdt1=false
1964 $r umount -d $tmp/mnt/mdt || {
1965 error_noexit "Unmounting the MDT"
1968 shall_cleanup_mdt=false
1970 $r umount -d $tmp/mnt/ost || {
1971 error_noexit "Unmounting the OST"
1974 shall_cleanup_ost=false
1976 t32_reload_modules $node || {
1977 error_noexit "Reloading modules"
1981 # mount a second time to make sure we didnt leave upgrade flag on
1982 $r $TUNEFS --dryrun $mdt_dev || {
1984 error_noexit "tunefs.lustre before remounting the MDT"
1988 mopts=exclude=$fsname-OST0000
1989 if [ $fstype == "ldiskfs" ]; then
1992 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1993 error_noexit "Remounting the MDT"
1996 shall_cleanup_mdt=true
2006 for tarball in $tarballs; do
2007 t32_test $tarball || let "rc += $?"
2011 run_test 32a "Upgrade (not live)"
2019 for tarball in $tarballs; do
2020 t32_test $tarball writeconf || let "rc += $?"
2024 run_test 32b "Upgrade with writeconf"
2031 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2033 for tarball in $tarballs; do
2034 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2038 run_test 32c "dne upgrade test"
2046 for tarball in $tarballs; do
2047 ff_convert=yes t32_test $tarball || rc=$?
2051 run_test 32d "convert ff test"
2053 test_33a() { # bug 12333, was test_33
2055 local FSNAME2=test-123
2056 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2059 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2061 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2062 local dev=${SINGLEMDS}_dev
2063 local MDSDEV=${!dev}
2064 is_blkdev $SINGLEMDS $MDSDEV && \
2065 skip_env "mixed loopback and real device not working" && return
2068 local fs2mdsdev=$(mdsdevname 1_2)
2069 local fs2ostdev=$(ostdevname 1_2)
2070 local fs2mdsvdev=$(mdsvdevname 1_2)
2071 local fs2ostvdev=$(ostvdevname 1_2)
2073 if [ $(facet_fstype mds1) == ldiskfs ]; then
2074 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2077 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2078 --reformat $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
2079 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2080 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2081 $fs2ostvdev || exit 10
2083 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2084 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2085 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
2087 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
2090 cp /etc/hosts $MOUNT2/ || rc=3
2091 $LFS getstripe $MOUNT2/hosts
2096 cleanup_nocli || rc=6
2099 run_test 33a "Mount ost with a large index number"
2101 test_33b() { # was test_34
2104 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2105 # Drop lock cancelation reply during umount
2106 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2107 do_facet client lctl set_param fail_loc=0x80000304
2108 #lctl set_param debug=-1
2109 umount_client $MOUNT
2112 run_test 33b "Drop cancel during umount"
2116 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2117 manual_umount_client
2119 do_facet client killall -USR1 multiop
2120 if [ $rc -eq 0 ]; then
2121 error "umount not fail!"
2126 run_test 34a "umount with opened file should be fail"
2131 touch $DIR/$tfile || return 1
2132 stop_mds --force || return 2
2134 manual_umount_client --force
2136 if [ $rc -ne 0 ]; then
2137 error "mtab after failed umount - rc $rc"
2143 run_test 34b "force umount with failed mds should be normal"
2147 touch $DIR/$tfile || return 1
2148 stop_ost --force || return 2
2150 manual_umount_client --force
2152 if [ $rc -ne 0 ]; then
2153 error "mtab after failed umount - rc $rc"
2159 run_test 34c "force umount with failed ost should be normal"
2161 test_35a() { # bug 12459
2164 DBG_SAVE="`lctl get_param -n debug`"
2165 lctl set_param debug="ha"
2167 log "Set up a fake failnode for the MDS"
2169 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
2170 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2171 do_facet mgs "$LCTL conf_param \
2172 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" || return 4
2174 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2177 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2180 log "Stopping the MDT: $device"
2181 stop_mdt 1 || return 5
2183 df $MOUNT > /dev/null 2>&1 &
2185 log "Restarting the MDT: $device"
2186 start_mdt 1 || return 6
2187 log "Wait for df ($DFPID) ... "
2190 lctl set_param debug="$DBG_SAVE"
2192 # retrieve from the log the first server that the client tried to
2193 # contact after the connection loss
2194 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2195 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2196 /import_select_connection.*$device-mdc.* using connection/ {
2198 if (\\\$NF ~ /$FAKENID/)
2204 }" $TMP/lustre-log-$TESTNAME.log`
2205 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
2207 # remove nid settings
2208 writeconf_or_reformat
2210 run_test 35a "Reconnect to the last active server first"
2212 test_35b() { # bug 18674
2213 remote_mds || { skip "local MDS" && return 0; }
2217 $LCTL set_param debug="ha"
2219 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2222 log "Set up a fake failnode for the MDS"
2224 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2225 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2226 do_facet mgs "$LCTL conf_param \
2227 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" || return 1
2229 local at_max_saved=0
2230 # adaptive timeouts may prevent seeing the issue
2231 if at_is_enabled; then
2232 at_max_saved=$(at_max_get mds)
2233 at_max_set 0 mds client
2236 mkdir -p $MOUNT/$tdir
2238 log "Injecting EBUSY on MDS"
2239 # Setting OBD_FAIL_MDS_RESEND=0x136
2240 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
2242 $LCTL set_param mdc.${FSNAME}*.stats=clear
2244 log "Creating a test file and stat it"
2245 touch $MOUNT/$tdir/$tfile
2246 stat $MOUNT/$tdir/$tfile
2248 log "Stop injecting EBUSY on MDS"
2249 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
2250 rm -f $MOUNT/$tdir/$tfile
2253 # restore adaptive timeout
2254 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2256 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2258 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
2260 # retrieve from the log if the client has ever tried to
2261 # contact the fake server after the loss of connection
2262 FAILCONN=`awk "BEGIN {ret = 0;}
2263 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2265 if (\\\$NF ~ /$FAKENID/) {
2270 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2272 [ "$FAILCONN" == "0" ] && \
2273 log "ERROR: The client reconnection has not been triggered" && \
2275 [ "$FAILCONN" == "2" ] && \
2276 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
2280 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2281 # Reconnects are supposed to be rate limited to one every 5s
2282 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
2283 log "ERROR: Too many reconnects $CONNCNT" && \
2287 # remove nid settings
2288 writeconf_or_reformat
2290 run_test 35b "Continue reconnection retries, if the active server is busy"
2293 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
2295 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
2296 { skip "remote OST" && return 0; }
2299 local FSNAME2=test1234
2300 local fs3ost_HOST=$ost_HOST
2301 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2303 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2305 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2306 is_blkdev $SINGLEMDS $MDSDEV && \
2307 skip_env "mixed loopback and real device not working" && return
2310 local fs2mdsdev=$(mdsdevname 1_2)
2311 local fs2ostdev=$(ostdevname 1_2)
2312 local fs3ostdev=$(ostdevname 2_2)
2313 local fs2mdsvdev=$(mdsvdevname 1_2)
2314 local fs2ostvdev=$(ostvdevname 1_2)
2315 local fs3ostvdev=$(ostvdevname 2_2)
2317 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2318 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2319 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2320 # different one than the default value here.
2321 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2322 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2323 add fs3ost $(mkfs_opts ost1 ${fs3ostdev}) --mgsnode=$MGSNID \
2324 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2326 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2327 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2328 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2330 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || return 1
2332 sleep 5 # until 11778 fixed
2334 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
2336 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
2337 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
2338 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
2339 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
2340 DFTOTAL=`echo $STRING | cut -d, -f1`
2341 DFUSED=`echo $STRING | cut -d, -f2`
2342 DFAVAIL=`echo $STRING | cut -d, -f3`
2343 DFFREE=$(($DFTOTAL - $DFUSED))
2345 ALLOWANCE=$((64 * $OSTCOUNT))
2347 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2348 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2349 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2352 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2353 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2354 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2357 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2358 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2359 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2364 stop fs3ost -f || return 200
2365 stop fs2ost -f || return 201
2366 stop fs2mds -f || return 202
2367 unload_modules_conf || return 203
2370 run_test 36 "df report consistency on OSTs with different block size"
2373 local mntpt=$(facet_mntpt $SINGLEMDS)
2374 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2375 local mdsdev_sym="$TMP/sym_mdt.img"
2376 local opts=$MDS_MOUNT_OPTS
2379 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2380 skip "Currently only applicable to ldiskfs-based MDTs"
2384 echo "MDS : $mdsdev"
2385 echo "SYMLINK : $mdsdev_sym"
2386 do_facet $SINGLEMDS rm -f $mdsdev_sym
2388 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2390 echo "mount symlink device - $mdsdev_sym"
2392 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2393 opts=$(csa_add "$opts" -o loop)
2395 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2396 $mdsdev_sym $mntpt 2>&1)
2399 echo mount_op=$mount_op
2401 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
2403 if $(echo $mount_op | grep -q "unable to set tunable"); then
2404 error "set tunables failed for symlink device"
2407 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2411 run_test 37 "verify set tunables works for symlink device"
2413 test_38() { # bug 14222
2414 local fstype=$(facet_fstype $SINGLEMDS)
2415 local mntpt=$(facet_mntpt $SINGLEMDS)
2420 local SRC="/etc /bin"
2421 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2422 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2424 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2425 error "copying $SRC to $DIR/$tdir"
2427 umount_client $MOUNT
2428 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2430 log "delete lov_objid file on MDS"
2432 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2434 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2436 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2438 # check create in mds_lov_connect
2442 [ $V ] && log "verifying $DIR/$tdir/$f"
2443 diff -q $f $DIR/$tdir/$f || ERROR=y
2445 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2446 if [ "$ERROR" = "y" ]; then
2447 # check it's updates in sync
2448 umount_client $MOUNT
2450 mount_fstype $SIGNLEMDS
2451 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2452 unmount_fstype $SINGLEMDS
2453 error "old and new files are different after connect" || true
2455 touch $DIR/$tdir/f2 || error "f2 file create failed"
2457 # check it's updates in sync
2458 umount_client $MOUNT
2461 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2463 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2464 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2466 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2471 [ $V ] && log "verifying $DIR/$tdir/$f"
2472 diff -q $f $DIR/$tdir/$f || ERROR=y
2474 touch $DIR/$tdir/f3 || error "f3 file create failed"
2475 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2476 umount_client $MOUNT
2478 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2479 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2480 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2482 [ "$ERROR" = "y" ] &&
2483 error "old and new files are different after sync" || true
2485 log "files compared the same"
2488 run_test 38 "MDS recreates missing lov_objid file from OST data"
2494 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2495 error "memory leak detected" || true
2497 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2499 test_40() { # bug 15759
2501 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2502 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2506 run_test 40 "race during service thread startup"
2508 test_41a() { #bug 14134
2509 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2510 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2511 skip "Loop devices does not work with nosvc option"
2516 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2518 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2519 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
2520 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2522 mount_client $MOUNT || return 1
2525 echo "blah blah" > $MOUNT/$tfile
2528 umount_client $MOUNT
2529 stop ost1 -f || return 201
2530 stop_mds -f || return 202
2531 stop_mds -f || return 203
2532 unload_modules_conf || return 204
2535 run_test 41a "mount mds with --nosvc and --nomgs"
2538 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2539 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2540 skip "Loop devices does not work with nosvc option"
2544 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2548 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2550 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2552 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2554 mount_client $MOUNT || return 1
2557 echo "blah blah" > $MOUNT/$tfile
2558 cat $MOUNT/$tfile || return 200
2560 umount_client $MOUNT
2561 stop_ost || return 201
2562 stop_mds -f || return 202
2563 stop_mds -f || return 203
2566 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2568 test_42() { #bug 14693
2570 check_mount || error "client was not mounted"
2572 do_facet mgs $LCTL conf_param $FSNAME.llite.some_wrong_param=10
2573 umount_client $MOUNT ||
2574 error "unmounting client failed with invalid llite param"
2575 mount_client $MOUNT ||
2576 error "mounting client failed with invalid llite param"
2578 do_facet mgs $LCTL conf_param $FSNAME.sys.some_wrong_param=20
2579 cleanup || error "stopping $FSNAME failed with invalid sys param"
2582 check_mount || "client was not mounted with invalid sys param"
2583 cleanup || error "stopping $FSNAME failed with invalid sys param"
2586 run_test 42 "allow client/server mount/unmount with invalid config param"
2589 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
2591 chmod ugo+x $DIR || error "chmod 0 failed"
2592 set_conf_param_and_check mds \
2593 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2594 "$FSNAME.mdt.root_squash" \
2596 set_conf_param_and_check mds \
2597 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2598 "$FSNAME.mdt.nosquash_nids" \
2602 # create set of test files
2604 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
2605 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
2606 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
2608 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
2609 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
2611 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
2612 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
2613 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
2616 # check root_squash:
2617 # set root squash UID:GID to RUNAS_ID
2618 # root should be able to access only files owned by RUNAS_ID
2620 set_conf_param_and_check mds \
2621 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2622 "$FSNAME.mdt.root_squash" \
2623 "$RUNAS_ID:$RUNAS_ID"
2625 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
2626 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
2627 error "$ST: root read permission is denied"
2628 echo "$ST: root read permission is granted - ok"
2631 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
2632 error "$ST: root write permission is denied"
2633 echo "$ST: root write permission is granted - ok"
2635 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2636 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
2637 error "$ST: root read permission is granted"
2638 echo "$ST: root read permission is denied - ok"
2641 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
2642 error "$ST: root write permission is granted"
2643 echo "$ST: root write permission is denied - ok"
2645 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2646 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
2647 error "$ST: root unlink permission is granted"
2648 echo "$ST: root unlink permission is denied - ok"
2650 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
2651 error "$ST: root create permission is granted"
2652 echo "$ST: root create permission is denied - ok"
2655 # check nosquash_nids:
2656 # put client's NID into nosquash_nids list,
2657 # root should be able to access root file after that
2659 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
2660 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
2661 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
2662 set_conf_param_and_check mds \
2663 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2664 "$FSNAME-MDTall.mdt.nosquash_nids" \
2667 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2668 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
2669 error "$ST: root read permission is denied"
2670 echo "$ST: root read permission is granted - ok"
2673 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
2674 error "$ST: root write permission is denied"
2675 echo "$ST: root write permission is granted - ok"
2677 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2678 rm $DIR/$tdir-rootdir/tfile-1 || \
2679 error "$ST: root unlink permission is denied"
2680 echo "$ST: root unlink permission is granted - ok"
2681 touch $DIR/$tdir-rootdir/tfile-2 || \
2682 error "$ST: root create permission is denied"
2683 echo "$ST: root create permission is granted - ok"
2687 run_test 43 "check root_squash and nosquash_nids"
2689 umount_client $MOUNT
2694 check_mount || return 2
2695 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
2697 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
2698 for VAL in $UUIDS; do
2699 NID=$(echo $VAL | cut -d= -f1)
2700 CLUUID=$(echo $VAL | cut -d= -f2)
2701 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
2703 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
2707 run_test 44 "mounted client proc entry exists"
2711 check_mount || return 2
2716 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
2717 do_facet client "lctl set_param fail_loc=0x50f"
2720 manual_umount_client --force || return 3
2721 do_facet client "lctl set_param fail_loc=0x0"
2723 mount_client $MOUNT || return 4
2727 run_test 45 "long unlink handling in ptlrpcd"
2734 umount_client $MOUNT2 || rc=$?
2735 umount_client $MOUNT || rc=$?
2736 while [ $count -gt 0 ]; do
2737 stop ost${count} -f || rc=$?
2741 cleanup_nocli || rc=$?
2742 #writeconf to remove all ost2 traces for subsequent tests
2743 writeconf_or_reformat
2748 echo "Testing with $OSTCOUNT OSTs"
2750 start_mds || return 1
2751 #first client should see only one ost
2752 start_ost || return 2
2753 wait_osc_import_state mds ost FULL
2755 mount_client $MOUNT || return 3
2756 trap "cleanup_46a $OSTCOUNT" EXIT ERR
2759 for (( i=2; i<=$OSTCOUNT; i++ )); do
2760 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
2763 # wait until osts in sync
2764 for (( i=2; i<=$OSTCOUNT; i++ )); do
2765 wait_osc_import_state mds ost$i FULL
2766 wait_osc_import_state client ost$i FULL
2769 #second client see all ost's
2771 mount_client $MOUNT2 || return 8
2772 $LFS setstripe -c -1 $MOUNT2 || return 9
2773 $LFS getstripe $MOUNT2 || return 10
2775 echo "ok" > $MOUNT2/widestripe
2776 $LFS getstripe $MOUNT2/widestripe || return 11
2777 # fill acl buffer for avoid expand lsm to them
2778 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
2779 setfacl -m $acl $MOUNT2/widestripe
2783 stat $MOUNT/widestripe || return 12
2785 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
2788 run_test 46a "handle ost additional - wide striped file"
2793 check_mount || return 2
2794 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2798 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2799 if echo $ns | grep "MDT[[:digit:]]*"; then
2802 lrs=$(echo $ns | sed 's/.*lru_size=//')
2803 lru_size[count]=$lrs
2808 facet_failover $SINGLEMDS
2809 client_up || return 3
2812 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2813 if echo $ns | grep "MDT[[:digit:]]*"; then
2816 lrs=$(echo $ns | sed 's/.*lru_size=//')
2817 if ! test "$lrs" -eq "${lru_size[count]}"; then
2818 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2819 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2827 run_test 47 "server restart does not make client loss lru_resize settings"
2832 # reformat after this test is needed - if test will failed
2833 # we will have unkillable file at FS
2837 test_48() { # bug 17636
2840 check_mount || return 2
2842 $LFS setstripe -c -1 $MOUNT || return 9
2843 $LFS getstripe $MOUNT || return 10
2845 echo "ok" > $MOUNT/widestripe
2846 $LFS getstripe $MOUNT/widestripe || return 11
2848 trap cleanup_48 EXIT ERR
2850 # fill acl buffer for avoid expand lsm to them
2851 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2852 setfacl -m $acl $MOUNT/widestripe
2855 stat $MOUNT/widestripe || return 12
2860 run_test 48 "too many acls on file"
2862 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2863 test_49a() { # bug 17710
2864 local timeout_orig=$TIMEOUT
2865 local ldlm_timeout_orig=$LDLM_TIMEOUT
2866 local LOCAL_TIMEOUT=20
2868 LDLM_TIMEOUT=$LOCAL_TIMEOUT
2869 TIMEOUT=$LOCAL_TIMEOUT
2873 check_mount || error "client mount failed"
2875 echo "check ldlm_timout..."
2876 local LDLM_MDS="$(do_facet $SINGLEMDS lctl get_param -n ldlm_timeout)"
2877 local LDLM_OST1="$(do_facet ost1 lctl get_param -n ldlm_timeout)"
2878 local LDLM_CLIENT="$(do_facet client lctl get_param -n ldlm_timeout)"
2880 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
2881 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2884 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2885 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
2888 umount_client $MOUNT
2889 stop_ost || error "problem stopping OSS"
2890 stop_mds || error "problem stopping MDS"
2892 LDLM_TIMEOUT=$ldlm_timeout_orig
2893 TIMEOUT=$timeout_orig
2895 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
2897 test_49b() { # bug 17710
2898 local timeout_orig=$TIMEOUT
2899 local ldlm_timeout_orig=$LDLM_TIMEOUT
2900 local LOCAL_TIMEOUT=20
2902 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
2903 TIMEOUT=$LOCAL_TIMEOUT
2907 check_mount || error "client mount failed"
2909 local LDLM_MDS="$(do_facet $SINGLEMDS lctl get_param -n ldlm_timeout)"
2910 local LDLM_OST1="$(do_facet ost1 lctl get_param -n ldlm_timeout)"
2911 local LDLM_CLIENT="$(do_facet client lctl get_param -n ldlm_timeout)"
2913 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
2914 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2917 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2918 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
2921 cleanup || error "cleanup failed"
2923 LDLM_TIMEOUT=$ldlm_timeout_orig
2924 TIMEOUT=$timeout_orig
2926 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
2929 # Test both statfs and lfs df and fail if either one fails
2930 multiop_bg_pause $1 f_
2933 killall -USR1 multiop
2934 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2935 wait $PID || { RC1=$?; log "multiop return error "; }
2942 if [ $RC2 -eq 0 ]; then
2944 log "lazystatfs df failed"
2948 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2954 lctl set_param llite.$FSNAME-*.lazystatfs=1
2957 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2959 cleanup || return $?
2961 run_test 50a "lazystatfs all servers available =========================="
2965 lctl set_param llite.$FSNAME-*.lazystatfs=1
2968 # Wait for client to detect down OST
2969 stop_ost || error "Unable to stop OST1"
2970 wait_osc_import_state mds ost DISCONN
2972 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2974 umount_client $MOUNT || error "Unable to unmount client"
2975 stop_mds || error "Unable to stop MDS"
2977 run_test 50b "lazystatfs all servers down =========================="
2980 start_mds || error "Unable to start MDS"
2981 start_ost || error "Unable to start OST1"
2982 start_ost2 || error "Unable to start OST2"
2983 mount_client $MOUNT || error "Unable to mount client"
2984 lctl set_param llite.$FSNAME-*.lazystatfs=1
2987 # Wait for client to detect down OST
2988 stop_ost || error "Unable to stop OST1"
2989 wait_osc_import_state mds ost DISCONN
2990 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2992 umount_client $MOUNT || error "Unable to unmount client"
2993 stop_ost2 || error "Unable to stop OST2"
2994 stop_mds || error "Unable to stop MDS"
2995 #writeconf to remove all ost2 traces for subsequent tests
2996 writeconf_or_reformat
2998 run_test 50c "lazystatfs one server down =========================="
3001 start_mds || error "Unable to start MDS"
3002 start_ost || error "Unable to start OST1"
3003 start_ost2 || error "Unable to start OST2"
3004 mount_client $MOUNT || error "Unable to mount client"
3005 lctl set_param llite.$FSNAME-*.lazystatfs=1
3008 # Issue the statfs during the window where the client still
3009 # belives the OST to be available but it is in fact down.
3010 # No failure just a statfs which hangs for a timeout interval.
3011 stop_ost || error "Unable to stop OST1"
3012 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3014 umount_client $MOUNT || error "Unable to unmount client"
3015 stop_ost2 || error "Unable to stop OST2"
3016 stop_mds || error "Unable to stop MDS"
3017 #writeconf to remove all ost2 traces for subsequent tests
3018 writeconf_or_reformat
3020 run_test 50d "lazystatfs client/server conn race =========================="
3027 start_mds || return 1
3028 #first client should see only one ost
3029 start_ost || return 2
3030 wait_osc_import_state mds ost FULL
3032 # Wait for client to detect down OST
3033 stop_ost || error "Unable to stop OST1"
3034 wait_osc_import_state mds ost DISCONN
3036 mount_client $MOUNT || error "Unable to mount client"
3037 lctl set_param llite.$FSNAME-*.lazystatfs=0
3039 multiop_bg_pause $MOUNT _f
3043 if [ $RC1 -ne 0 ]; then
3044 log "multiop failed $RC1"
3047 sleep $(( $TIMEOUT+1 ))
3049 [ $? -ne 0 ] && error "process isn't sleep"
3050 start_ost || error "Unable to start OST1"
3051 wait $pid || error "statfs failed"
3054 umount_client $MOUNT || error "Unable to unmount client"
3055 stop_ost || error "Unable to stop OST1"
3056 stop_mds || error "Unable to stop MDS"
3058 run_test 50e "normal statfs all servers down =========================="
3063 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3065 start_mds || error "Unable to start mds"
3066 #first client should see only one ost
3067 start_ost || error "Unable to start OST1"
3068 wait_osc_import_state mds ost FULL
3070 start_ost2 || error "Unable to start OST2"
3071 wait_osc_import_state mds ost2 FULL
3073 # Wait for client to detect down OST
3074 stop_ost2 || error "Unable to stop OST2"
3076 wait_osc_import_state mds ost2 DISCONN
3077 mount_client $MOUNT || error "Unable to mount client"
3078 lctl set_param llite.$FSNAME-*.lazystatfs=0
3080 multiop_bg_pause $MOUNT _f
3084 if [ $RC1 -ne 0 ]; then
3085 log "lazystatfs multiop failed $RC1"
3088 sleep $(( $TIMEOUT+1 ))
3090 [ $? -ne 0 ] && error "process isn't sleep"
3091 start_ost2 || error "Unable to start OST2"
3092 wait $pid || error "statfs failed"
3093 stop_ost2 || error "Unable to stop OST2"
3096 umount_client $MOUNT || error "Unable to unmount client"
3097 stop_ost || error "Unable to stop OST1"
3098 stop_mds || error "Unable to stop MDS"
3099 #writeconf to remove all ost2 traces for subsequent tests
3100 writeconf_or_reformat
3102 run_test 50f "normal statfs one server in down =========================="
3105 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
3107 start_ost2 || error "Unable to start OST2"
3108 wait_osc_import_state mds ost2 FULL
3109 wait_osc_import_state client ost2 FULL
3111 local PARAM="${FSNAME}-OST0001.osc.active"
3113 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
3114 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
3116 umount_client $MOUNT || error "Unable to unmount client"
3117 mount_client $MOUNT || error "Unable to mount client"
3118 # This df should not cause a panic
3121 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
3123 umount_client $MOUNT || error "Unable to unmount client"
3124 stop_ost2 || error "Unable to stop OST2"
3125 stop_ost || error "Unable to stop OST1"
3126 stop_mds || error "Unable to stop MDS"
3127 #writeconf to remove all ost2 traces for subsequent tests
3128 writeconf_or_reformat
3130 run_test 50g "deactivated OST should not cause panic====================="
3134 # prepare MDT/OST, make OSC inactive for OST1
3135 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
3136 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3137 error "tunefs OST1 failed"
3138 start_mds || error "Unable to start MDT"
3139 start_ost || error "Unable to start OST1"
3140 start_ost2 || error "Unable to start OST2"
3141 mount_client $MOUNT || error "client start failed"
3145 # activatate OSC for OST1
3146 local TEST="$LCTL get_param -n osc.${FSNAME}-OST0000-osc-[!M]*.active"
3147 set_conf_param_and_check client \
3148 "$TEST" "${FSNAME}-OST0000.osc.active" 1 ||
3149 error "Unable to activate OST1"
3151 mkdir -p $DIR/$tdir/2
3152 $LFS setstripe -c -1 -i 0 $DIR/$tdir/2
3153 sleep 1 && echo "create a file after OST1 is activated"
3155 createmany -o $DIR/$tdir/2/$tfile-%d 1
3157 # check OSC import is working
3158 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3159 error "some OSC imports are still not connected"
3162 umount_client $MOUNT || error "Unable to umount client"
3163 stop_ost2 || error "Unable to stop OST2"
3166 run_test 50h "LU-642: activate deactivated OST ==="
3169 local LOCAL_TIMEOUT=20
3173 check_mount || return 1
3176 $LFS setstripe -c -1 $MOUNT/d1
3177 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3178 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
3179 touch $MOUNT/d1/f1 &
3182 start_ost2 || return 2
3184 stop_ost2 || return 3
3186 #writeconf to remove all ost2 traces for subsequent tests
3187 writeconf_or_reformat
3189 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
3198 do_node $node mkdir -p $dest
3199 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3201 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
3202 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3203 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
3205 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
3206 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
3216 local backup2=${TMP}/backup2
3218 do_node $node mkdir -p $backup2
3219 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3221 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
3222 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3223 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
3225 do_node $node "diff -rq $backup $backup2"
3226 [ $? -eq 0 ] || { error "contents differ"; return 3; }
3228 local xattrs2=${TMP}/xattrs2
3229 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
3230 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
3232 do_node $node "diff $xattrs $xattrs2"
3233 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
3235 do_node $node "rm -rf $backup2 $xattrs2"
3236 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
3240 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3241 skip "Only applicable to ldiskfs-based MDTs"
3246 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
3248 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
3250 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
3253 local ost1mnt=$(facet_mntpt ost1)
3254 local ost1node=$(facet_active_host ost1)
3255 local ost1tmp=$TMP/conf52
3259 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
3260 touch $TMP/modified_first
3261 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
3262 local mtime=$(stat -c %Y $TMP/modified_first)
3263 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
3265 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
3268 $LFS setstripe -c -1 -S 1M $DIR/$tdir
3269 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
3271 for (( i=0; i < nrfiles; i++ )); do
3272 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
3273 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
3279 echo backup files to $TMP/files
3280 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
3281 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
3282 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
3284 umount_client $MOUNT
3285 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
3287 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
3289 echo mount ost1 as ldiskfs
3290 do_node $ost1node mkdir -p $ost1mnt
3291 [ $? -eq 0 ] || { error "Unable to create $ost1mnt"; return 23; }
3292 if ! do_node $ost1node test -b $ost1_dev; then
3295 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
3297 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
3300 echo backup objects to $ost1tmp/objects
3301 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
3302 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
3303 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
3305 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
3307 # move objects to lost+found
3308 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
3309 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
3311 # recover objects dry-run
3312 echo "ll_recover_lost_found_objs dry_run"
3313 do_node $ost1node "ll_recover_lost_found_objs -n -d $ost1mnt/O"
3314 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
3317 echo "ll_recover_lost_found_objs fix run"
3318 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
3319 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
3321 # compare restored objects against saved ones
3322 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
3323 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
3325 do_node $ost1node "umount $ost1mnt"
3326 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
3329 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
3331 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
3334 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
3335 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
3337 rm -rf $TMP/files $TMP/file_xattrs
3338 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
3339 do_node $ost1node "rm -rf $ost1tmp"
3340 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
3343 run_test 52 "check recovering objects from lost+found"
3345 # Checks threads_min/max/started for some service
3347 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
3348 # parameter pattern prefix like 'ost.*.ost'.
3361 local msg="Insane $modname thread counts"
3362 local ncpts=$(check_cpt_number $facet)
3366 check_mount || return 41
3368 # We need to expand $parampat, but it may match multiple parameters, so
3369 # we'll pick the first one
3370 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
3371 error "Couldn't expand ${parampat}.threads_min parameter name"
3375 # Remove the .threads_min part
3376 paramp=${paramp%.threads_min}
3378 # Check for sanity in defaults
3379 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3380 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3381 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
3382 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
3383 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
3384 nthrs=$(expr $tmax - $tmin)
3385 if [ $nthrs -lt $ncpts ]; then
3391 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
3392 skip_env "module parameter forced $facet thread count" &&
3393 tmin=3 && tmax=$((3 * tmax))
3395 # Check that we can change min/max
3396 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + nthrs))"
3397 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - nthrs))"
3398 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3399 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3400 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) && $tmax2 == ($tmax - $nthrs)))' || return $?
3402 # Check that we can set min/max to the same value
3403 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3404 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
3405 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3406 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3407 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
3409 # Check that we can't set max < min
3410 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
3411 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
3412 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
3413 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
3415 # We need to ensure that we get the module options desired; to do this
3416 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
3417 LOAD_MODULES_REMOTE=true
3420 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
3421 setmodopts -a $modname "$newvalue" oldvalue
3425 check_mount || return 41
3427 # Restore previous setting of MODOPTS_*
3428 setmodopts $modname "$oldvalue"
3430 # Check that $opts took
3431 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
3432 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
3433 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
3434 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
3443 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
3446 run_test 53a "check OSS thread count params"
3450 local mds=$(do_facet $SINGLEMDS "lctl get_param -N mds.*.*.threads_max \
3452 if [ -z "$mds" ]; then
3453 #running this on an old MDT
3454 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
3456 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
3460 run_test 53b "check MDS thread count params"
3463 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3464 skip "Only applicable to ldiskfs-based MDTs"
3468 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p
3469 [ $? -eq 0 ] || error "llverdev failed!"
3472 run_test 54a "test llverdev and partial verify of device"
3475 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3476 skip "Only applicable to ldiskfs-based MDTs"
3481 run_llverfs $MOUNT -p
3482 [ $? -eq 0 ] || error "llverfs failed!"
3485 run_test 54b "test llverfs and partial verify of filesystem"
3489 local max_ost_index=$1
3490 echo -n $(((max_ost_index + 1) * 8))
3494 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3495 skip "Only applicable to ldiskfs-based MDTs"
3499 local mdsdev=$(mdsdevname 1)
3500 local mdsvdev=$(mdsvdevname 1)
3504 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
3506 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
3507 --reformat $(ostdevname 1) $(ostvdevname 1)
3513 echo checking size of lov_objid for ost index $i
3514 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
3515 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
3516 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
3518 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
3525 run_test 55 "check lov_objid size"
3528 local mds_journal_size_orig=$MDSJOURNALSIZE
3532 for num in $(seq 1 $MDSCOUNT); do
3533 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3534 --reformat $(mdsdevname $num) $(mdsvdevname $num)
3536 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=1000 --reformat \
3537 $(ostdevname 1) $(ostvdevname 1)
3538 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=10000 --reformat \
3539 $(ostdevname 2) $(ostvdevname 2)
3543 start_ost2 || error "Unable to start second ost"
3544 mount_client $MOUNT || error "Unable to mount client"
3548 MDSJOURNALSIZE=$mds_journal_size_orig
3551 run_test 56 "check big indexes"
3553 test_57a() { # bug 22656
3554 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
3555 writeconf_or_reformat
3556 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3557 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
3559 start_ost && error "OST registration from failnode should fail"
3562 run_test 57a "initial registration from failnode should fail (should return errs)"
3565 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
3566 writeconf_or_reformat
3567 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3568 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" || error "tunefs failed"
3570 start_ost || error "OST registration from servicenode should not fail"
3573 run_test 57b "initial registration from servicenode should not fail"
3576 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
3579 test_58() { # bug 22658
3582 createmany -o $DIR/$tdir/$tfile-%d 100
3583 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
3584 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
3585 do_facet $SINGLEMDS "lctl set_param fail_loc=0x601"
3586 unlinkmany $DIR/$tdir/$tfile-%d 100
3589 local MNTDIR=$(facet_mntpt $SINGLEMDS)
3590 local devname=$(mdsdevname ${SINGLEMDS//mds/})
3592 # remove all files from the OBJECTS dir
3593 mount_fstype $SINGLEMDS
3595 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
3597 unmount_fstype $SINGLEMDS
3598 # restart MDS with missing llog files
3600 do_facet mds "lctl set_param fail_loc=0"
3603 run_test 58 "missing llog files must not prevent MDT from mounting"
3606 start_mgsmds >> /dev/null
3607 local C1=$(count_osts)
3608 if [ $C1 -eq 0 ]; then
3609 start_ost >> /dev/null
3613 echo "original ost count: $C1 (expect > 0)"
3614 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
3615 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
3616 local C2=$(count_osts)
3617 echo "after mdt writeconf count: $C2 (expect 0)"
3618 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
3619 echo "OST start without writeconf should fail:"
3620 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
3621 echo "OST start with writeconf should succeed:"
3622 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
3623 local C3=$(count_osts)
3624 echo "after ost writeconf count: $C3 (expect 1)"
3625 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
3626 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
3627 local C4=$(count_osts)
3628 echo "after ost2 writeconf count: $C4 (expect 2)"
3629 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
3630 stop_ost2 >> /dev/null
3631 cleanup_nocli >> /dev/null
3632 #writeconf to remove all ost2 traces for subsequent tests
3633 writeconf_or_reformat
3635 run_test 59 "writeconf mount option"
3637 test_60() { # LU-471
3640 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3641 skip "Only applicable to ldiskfs-based MDTs"
3645 for num in $(seq $MDSCOUNT); do
3646 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3647 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
3648 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3652 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
3654 [ $rc -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
3656 # MDT default has dirdata feature
3657 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
3658 # we disable uninit_bg feature
3659 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
3660 # we set stride extended options
3661 echo $dump | grep stride > /dev/null || error "stride is not set"
3664 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
3667 local reformat=false
3669 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
3670 { skip "Need MDS version at least 2.1.53"; return 0; }
3672 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
3673 ! large_xattr_enabled; then
3675 LDISKFS_MKFS_OPTS+=" -O large_xattr"
3677 for num in $(seq $MDSCOUNT); do
3678 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
3679 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3680 error "add mds $num failed"
3684 setup_noconfig || error "setting up the filesystem failed"
3685 client_up || error "starting client failed"
3687 local file=$DIR/$tfile
3690 local large_value="$(generate_string $(max_xattr_size))"
3691 local small_value="bar"
3693 local name="trusted.big"
3694 log "save large xattr $name on $file"
3695 setfattr -n $name -v $large_value $file ||
3696 error "saving $name on $file failed"
3698 local new_value=$(get_xattr_value $name $file)
3699 [[ "$new_value" != "$large_value" ]] &&
3700 error "$name different after saving"
3702 log "shrink value of $name on $file"
3703 setfattr -n $name -v $small_value $file ||
3704 error "shrinking value of $name on $file failed"
3706 new_value=$(get_xattr_value $name $file)
3707 [[ "$new_value" != "$small_value" ]] &&
3708 error "$name different after shrinking"
3710 log "grow value of $name on $file"
3711 setfattr -n $name -v $large_value $file ||
3712 error "growing value of $name on $file failed"
3714 new_value=$(get_xattr_value $name $file)
3715 [[ "$new_value" != "$large_value" ]] &&
3716 error "$name different after growing"
3718 log "check value of $name on $file after remounting MDS"
3720 new_value=$(get_xattr_value $name $file)
3721 [[ "$new_value" != "$large_value" ]] &&
3722 error "$name different after remounting MDS"
3724 log "remove large xattr $name from $file"
3725 setfattr -x $name $file || error "removing $name from $file failed"
3730 LDISKFS_MKFS_OPTS=${LDISKFS_MKFS_OPTS% -O large_xattr}
3734 run_test 61 "large xattr"
3737 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3738 skip "Only applicable to ldiskfs-based MDTs"
3743 local mdsdev=$(mdsdevname 1)
3744 local ostdev=$(ostdevname 1)
3746 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
3747 { skip "Need MDS version at least 2.2.51"; return 0; }
3749 echo "disable journal for mds"
3750 do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
3751 start_mds && error "MDT start should fail"
3752 echo "disable journal for ost"
3753 do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
3754 start_ost && error "OST start should fail"
3755 cleanup || return $?
3758 run_test 62 "start with disabled journal"
3761 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3762 skip "Only applicable to ldiskfs-based MDTs"
3766 local inode_slab=$(do_facet $SINGLEMDS \
3767 "awk '/ldiskfs_inode_cache/ { print \\\$5 }' /proc/slabinfo")
3768 if [ -z "$inode_slab" ]; then
3769 skip "ldiskfs module has not been loaded"
3773 echo "$inode_slab ldisk inodes per page"
3774 [ "$inode_slab" -ge "3" ] ||
3775 error "ldisk inode size is too big, $inode_slab objs per page"
3778 run_test 63 "Verify each page can at least hold 3 ldisk inodes"
3783 start_ost2 || error "Unable to start second ost"
3784 mount_client $MOUNT || error "Unable to mount client"
3785 stop_ost2 || error "Unable to stop second ost"
3787 $LFS df --lazy || error "lfs df failed"
3788 cleanup || return $?
3789 #writeconf to remove all ost2 traces for subsequent tests
3790 writeconf_or_reformat
3792 run_test 64 "check lfs df --lazy "
3794 test_65() { # LU-2237
3795 # Currently, the test is only valid for ldiskfs backend
3796 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
3797 skip "non-ldiskfs backend" && return
3799 local devname=$(mdsdevname ${SINGLEMDS//mds/})
3800 local brpt=$(facet_mntpt brpt)
3803 if ! do_facet $SINGLEMDS "test -b $devname"; then
3808 local obj=$(do_facet $SINGLEMDS \
3809 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
3811 if [ -z "$obj" ]; then
3812 # The MDT may be just re-formatted, mount the MDT for the
3813 # first time to guarantee the "last_rcvd" file is there.
3814 start_mds || error "fail to mount the MDS for the first time"
3818 # remove the "last_rcvd" file
3819 do_facet $SINGLEMDS "mkdir -p $brpt"
3820 do_facet $SINGLEMDS \
3821 "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
3822 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
3823 do_facet $SINGLEMDS "umount -d $brpt"
3825 # restart MDS, the "last_rcvd" file should be recreated.
3826 start_mds || error "fail to restart the MDS"
3828 obj=$(do_facet $SINGLEMDS \
3829 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
3830 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
3832 run_test 65 "re-create the lost last_rcvd file when server mount"
3835 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
3836 { skip "Need MGS version at least 2.3.59"; return 0; }
3839 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
3840 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
3842 echo "replace_nids should fail if MDS, OSTs and clients are UP"
3843 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
3844 error "replace_nids fail"
3846 umount_client $MOUNT || error "unmounting client failed"
3847 echo "replace_nids should fail if MDS and OSTs are UP"
3848 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
3849 error "replace_nids fail"
3852 echo "replace_nids should fail if MDS is UP"
3853 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
3854 error "replace_nids fail"
3856 stop_mds || error "stopping mds failed"
3858 if combined_mgs_mds; then
3859 start_mdt 1 "-o nosvc" ||
3860 error "starting mds with nosvc option failed"
3863 echo "command should accept two parameters"
3864 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
3865 error "command should accept two params"
3867 echo "correct device name should be passed"
3868 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
3869 error "wrong devname"
3871 echo "wrong nids list should not destroy the system"
3872 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
3875 echo "replace OST nid"
3876 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
3877 error "replace nids failed"
3879 echo "command should accept two parameters"
3880 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
3881 error "command should accept two params"
3883 echo "wrong nids list should not destroy the system"
3884 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
3887 echo "replace MDS nid"
3888 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
3889 error "replace nids failed"
3891 if ! combined_mgs_mds ; then
3898 check_mount || error "error after nid replace"
3899 cleanup || error "cleanup failed"
3902 run_test 66 "replace nids"
3904 test_67() { #LU-2950
3905 local legacy="$TMP/legacy_lnet_config"
3906 local new="$TMP/new_routes_test"
3907 local out="$TMP/config_out_file"
3908 local verify="$TMP/conv_verify"
3909 local verify_conf="$TMP/conf_verify"
3911 # Create the legacy file that will be run through the
3912 # lustre_routes_conversion script
3913 cat <<- LEGACY_LNET_CONFIG > $legacy
3914 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
3915 tcp2 54 10.1.3.2@tcp;
3916 tcp3 10.3.4.3@tcp:3;
3920 # Create the verification file to verify the output of
3921 # lustre_routes_conversion script against.
3922 cat <<- VERIFY_LNET_CONFIG > $verify
3923 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
3924 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
3925 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
3926 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
3927 tcp4: { gateway: 10.3.3.4@tcp }
3930 # Create the verification file to verify the output of
3931 # lustre_routes_config script against
3932 cat <<- VERIFY_LNET_CONFIG > $verify_conf
3933 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
3934 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
3935 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
3936 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
3937 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
3940 lustre_routes_conversion $legacy $new > /dev/null
3941 if [ -f $new ]; then
3942 # verify the conversion output
3943 cmp -s $new $verify > /dev/null
3944 if [ $? -eq 1 ]; then
3945 error "routes conversion failed"
3948 lustre_routes_config --dry-run --verbose $new > $out
3949 # check that the script succeeded
3950 cmp -s $out $verify_conf > /dev/null
3951 if [ $? -eq 1 ]; then
3952 error "routes config failed"
3955 error "routes conversion test failed"
3957 # remove generated files
3958 rm -f $new $legacy $verify $verify_conf $out
3960 run_test 67 "test routes conversion and configuration"
3968 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.53) ] ||
3969 { skip "Need MDS version at least 2.4.53"; return 0; }
3971 umount_client $MOUNT || error "umount client failed"
3973 start_mdt 1 || error "MDT start failed"
3976 # START-END - the sequences we'll be reserving
3977 START=$(do_facet $SINGLEMDS \
3978 lctl get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
3979 END=$((START + (1 << 30)))
3980 do_facet $SINGLEMDS \
3981 lctl set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
3983 # reset the sequences MDT0000 has already assigned
3984 do_facet $SINGLEMDS \
3985 lctl set_param seq.srv*MDT0000.space=clear
3987 # remount to let the client allocate new sequence
3988 mount_client $MOUNT || error "mount client failed"
3991 do_facet $SINGLEMDS \
3992 lctl get_param seq.srv*MDT0000.space
3993 $LFS path2fid $DIR/$tfile
3995 local old_ifs="$IFS"
3997 fid=($($LFS path2fid $DIR/$tfile))
4001 if [[ $seq < $END ]]; then
4002 error "used reserved sequence $seq?"
4004 cleanup || return $?
4006 run_test 68 "be able to reserve specific sequences in FLDB"
4009 local server_version=$(lustre_version_code $SINGLEMDS)
4011 [[ $server_version -lt $(version_code 2.4.2) ]] &&
4012 skip "Need MDS version at least 2.4.2" && return
4014 [[ $server_version -ge $(version_code 2.4.50) ]] &&
4015 [[ $server_version -lt $(version_code 2.5.0) ]] &&
4016 skip "Need MDS version at least 2.5.0" && return
4020 # use OST0000 since it probably has the most creations
4021 local OSTNAME=$(ostname_from_index 0)
4022 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4023 local last_id=$(do_facet mds1 lctl get_param -n \
4024 osc.$mdtosc_proc1.prealloc_last_id)
4026 # Want to have OST LAST_ID over 1.5 * OST_MAX_PRECREATE to
4027 # verify that the LAST_ID recovery is working properly. If
4028 # not, then the OST will refuse to allow the MDS connect
4029 # because the LAST_ID value is too different from the MDS
4030 #define OST_MAX_PRECREATE=20000
4031 local num_create=$((20000 * 5))
4034 $LFS setstripe -i 0 $DIR/$tdir
4035 createmany -o $DIR/$tdir/$tfile- $num_create ||
4036 error "createmany: failed to create $num_create files: $?"
4037 # delete all of the files with objects on OST0 so the
4038 # filesystem is not inconsistent later on
4039 $LFS find $MOUNT --ost 0 | xargs rm
4041 stop_ost || error "OST0 stop failure"
4042 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
4043 $(ostdevname 1) $(ostvdevname 1) ||
4044 error "reformat and replace $ostdev failed"
4045 start_ost || error "OST0 restart failure"
4046 wait_osc_import_state mds ost FULL
4048 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
4049 local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
4050 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
4054 run_test 69 "replace an OST with the same index"
4057 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4062 start_mdt 1 || error "MDT0 start fail"
4064 start_ost || error "OST0 start fail"
4066 start_mdt 2 || error "MDT1 start fail"
4068 mount_client $MOUNT || error "mount client fails"
4070 mkdir -p $DIR/$tdir || error "create dir fail"
4072 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4073 error "create remote dir fail"
4075 rm -rf $DIR/$tdir || error "delete dir fail"
4076 cleanup || return $?
4078 run_test 70a "start MDT0, then OST, then MDT1"
4081 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4084 start_ost || error "OST0 start fail"
4086 start_mdt 1 || error "MDT0 start fail"
4087 start_mdt 2 || error "MDT1 start fail"
4089 mount_client $MOUNT || error "mount client fails"
4091 mkdir -p $DIR/$tdir || error "create dir fail"
4093 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4094 error "create remote dir fail"
4096 rm -rf $DIR/$tdir || error "delete dir fail"
4098 cleanup || return $?
4100 run_test 70b "start OST, MDT1, MDT0"
4103 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4106 start_mdt 1 || error "MDT0 start fail"
4107 start_mdt 2 || error "MDT1 start fail"
4108 start_ost || error "OST0 start fail"
4110 mount_client $MOUNT || error "mount client fails"
4111 stop_mdt 1 || error "MDT1 start fail"
4113 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
4114 echo "deactivate $mdc_for_mdt1"
4115 $LCTL --device $mdc_for_mdt1 deactivate || return 1
4117 mkdir -p $DIR/$tdir && error "mkdir succeed"
4119 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4120 error "create remote dir succeed"
4122 cleanup || return $?
4124 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
4127 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4130 start_mdt 1 || error "MDT0 start fail"
4131 start_mdt 2 || error "MDT1 start fail"
4132 start_ost || error "OST0 start fail"
4134 mount_client $MOUNT || error "mount client fails"
4136 stop_mdt 2 || error "MDT1 start fail"
4138 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
4140 echo "deactivate $mdc_for_mdt2"
4141 $LCTL --device $mdc_for_mdt2 deactivate ||
4142 error "set $mdc_for_mdt2 deactivate failed"
4144 mkdir -p $DIR/$tdir || error "mkdir fail"
4145 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4146 error "create remote dir succeed"
4148 rm -rf $DIR/$tdir || error "delete dir fail"
4150 cleanup || return $?
4152 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
4155 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4156 if combined_mgs_mds; then
4157 skip "needs separate MGS/MDT" && return
4161 start_mdt 1 || error "MDT0 start fail"
4162 start_ost || error "OST0 start fail"
4163 start_mdt 2 || error "MDT1 start fail"
4164 start_ost2 || error "OST1 start fail"
4166 mount_client $MOUNT || error "mount client fails"
4168 mkdir -p $DIR/$tdir || error "mkdir fail"
4169 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4170 error "create remote dir succeed"
4172 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4173 rm -rf $DIR/$tdir || error "delete dir fail"
4175 umount_client $MOUNT
4176 stop_mdt 1 || error "MDT0 stop fail"
4177 stop_mdt 2 || error "MDT1 stop fail"
4178 stop_ost || error "OST0 stop fail"
4179 stop_ost2 || error "OST1 stop fail"
4181 run_test 71a "start MDT0 OST0, MDT1, OST1"
4184 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4185 if combined_mgs_mds; then
4186 skip "needs separate MGS/MDT" && return
4190 start_mdt 2 || error "MDT1 start fail"
4191 start_ost || error "OST0 start fail"
4192 start_mdt 1 || error "MDT0 start fail"
4193 start_ost2 || error "OST1 start fail"
4195 mount_client $MOUNT || error "mount client fails"
4197 mkdir -p $DIR/$tdir || error "mkdir fail"
4198 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4199 error "create remote dir succeed"
4201 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4202 rm -rf $DIR/$tdir || error "delete dir fail"
4204 umount_client $MOUNT
4205 stop_mdt 1 || error "MDT0 stop fail"
4206 stop_mdt 2 || error "MDT1 stop fail"
4207 stop_ost || error "OST0 stop fail"
4208 stop_ost2 || error "OST1 stop fail"
4210 run_test 71b "start MDT1, OST0, MDT0, OST1"
4213 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4214 if combined_mgs_mds; then
4215 skip "needs separate MGS/MDT" && return
4219 start_ost || error "OST0 start fail"
4220 start_ost2 || error "OST1 start fail"
4221 start_mdt 2 || error "MDT1 start fail"
4222 start_mdt 1 || error "MDT0 start fail"
4224 mount_client $MOUNT || error "mount client fails"
4226 mkdir -p $DIR/$tdir || error "mkdir fail"
4227 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4228 error "create remote dir succeed"
4230 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4231 rm -rf $DIR/$tdir || error "delete dir fail"
4233 umount_client $MOUNT
4234 stop_mdt 1 || error "MDT0 stop fail"
4235 stop_mdt 2 || error "MDT1 stop fail"
4236 stop_ost || error "OST0 stop fail"
4237 stop_ost2 || error "OST1 stop fail"
4240 run_test 71c "start OST0, OST1, MDT1, MDT0"
4243 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4244 if combined_mgs_mds; then
4245 skip "needs separate MGS/MDT" && return
4249 start_ost || error "OST0 start fail"
4250 start_mdt 2 || error "MDT0 start fail"
4251 start_mdt 1 || error "MDT0 start fail"
4252 start_ost2 || error "OST1 start fail"
4254 mount_client $MOUNT || error "mount client fails"
4256 mkdir -p $DIR/$tdir || error "mkdir fail"
4257 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4258 error "create remote dir succeed"
4260 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4261 rm -rf $DIR/$tdir || error "delete dir fail"
4263 umount_client $MOUNT
4264 stop_mdt 1 || error "MDT0 stop fail"
4265 stop_mdt 2 || error "MDT1 stop fail"
4266 stop_ost || error "OST0 stop fail"
4267 stop_ost2 || error "OST1 stop fail"
4270 run_test 71d "start OST0, MDT1, MDT0, OST1"
4273 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4274 if combined_mgs_mds; then
4275 skip "needs separate MGS/MDT" && return
4279 start_ost || error "OST0 start fail"
4280 start_mdt 2 || error "MDT1 start fail"
4281 start_ost2 || error "OST1 start fail"
4282 start_mdt 1 || error "MDT0 start fail"
4284 mount_client $MOUNT || error "mount client fails"
4286 mkdir -p $DIR/$tdir || error "mkdir fail"
4287 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4288 error "create remote dir succeed"
4290 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4291 rm -rf $DIR/$tdir || error "delete dir fail"
4293 umount_client $MOUNT
4294 stop_mdt 1 || error "MDT0 stop fail"
4295 stop_mdt 2 || error "MDT1 stop fail"
4296 stop_ost || error "OST0 stop fail"
4297 stop_ost2 || error "OST1 stop fail"
4300 run_test 71e "start OST0, MDT1, OST1, MDT0"
4302 test_72() { #LU-2634
4303 local mdsdev=$(mdsdevname 1)
4304 local ostdev=$(ostdevname 1)
4305 local cmd="$E2FSCK -fnvd $mdsdev"
4308 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
4309 skip "ldiskfs only test" && return
4311 #tune MDT with "-O extents"
4313 for num in $(seq $MDSCOUNT); do
4314 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
4315 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4316 error "add mds $num failed"
4317 $TUNE2FS -O extents $(mdsdevname $num)
4320 add ost1 $(mkfs_opts ost1 $ostdev) --reformat $ostdev ||
4321 error "add $ostdev failed"
4322 start_mgsmds || error "start mds failed"
4323 start_ost || error "start ost failed"
4324 mount_client $MOUNT || error "mount client failed"
4326 #create some short symlinks
4328 createmany -o $DIR/$tdir/$tfile-%d $fn
4329 echo "create $fn short symlinks"
4330 for i in $(seq -w 1 $fn); do
4331 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
4336 umount_client $MOUNT || error "umount client failed"
4337 stop_mds || error "stop mds failed"
4338 stop_ost || error "stop ost failed"
4341 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
4343 run_test 72 "test fast symlink with extents flag enabled"
4345 test_73() { #LU-3006
4347 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4348 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
4349 error "1st tunefs failed"
4350 start_mgsmds || error "start mds failed"
4351 start_ost || error "start ost failed"
4352 mount_client $MOUNT || error "mount client failed"
4353 lctl get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
4354 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
4355 umount_client $MOUNT || error "umount client failed"
4359 run_test 73 "failnode to update from mountdata properly"
4361 test_74() { # LU-1606
4362 for TESTPROG in $LUSTRE_TESTS_API_DIR/*.c; do
4363 gcc -Wall -Werror $LUSTRE_TESTS_API_DIR/simple_test.c \
4365 -L$LUSTRE/utils -llustreapi ||
4366 error "client api broken"
4368 cleanup || return $?
4370 run_test 74 "Lustre client api program can compile and link"
4372 test_75() { # LU-2374
4373 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
4374 skip "Need MDS version at least 2.4.1" && return
4377 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
4378 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
4379 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
4380 --reformat $(ostdevname 1) $(ostvdevname 1)"
4382 #check with default parameters
4383 add mds1 $opts_mds || error "add mds1 failed for default params"
4384 add ost1 $opts_ost || error "add ost1 failed for default params"
4386 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
4387 opts_mds=$(echo $opts_mds |
4388 sed -e "s/--index=$index/--index=$index --mdt/")
4389 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
4390 opts_ost=$(echo $opts_ost |
4391 sed -e "s/--index=$index/--index=$index --ost/")
4393 add mds1 $opts_mds || error "add mds1 failed for new params"
4394 add ost1 $opts_ost || error "add ost1 failed for new params"
4397 run_test 75 "The order of --index should be irrelevant"
4400 [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] ||
4401 { skip "Need MDS version at least 2.4.52" && return 0; }
4403 local MDMB_PARAM="osc.*.max_dirty_mb"
4404 echo "Change MGS params"
4405 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
4407 echo "max_dirty_mb: $MAX_DIRTY_MB"
4408 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB + MAX_DIRTY_MB))
4409 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
4410 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
4411 wait_update $HOSTNAME "lctl get_param -n $MDMB_PARAM |
4412 head -1" $NEW_MAX_DIRTY_MB
4413 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
4414 echo "$MAX_DIRTY_MB"
4415 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
4416 error "error while apply max_dirty_mb"
4418 echo "Check the value is stored after remount"
4421 wait_update $HOSTNAME "lctl get_param -n $MDMB_PARAM |
4422 head -1" $NEW_MAX_DIRTY_MB
4423 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
4424 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
4425 error "max_dirty_mb is not saved after remount"
4427 echo "Change OST params"
4428 CLIENT_PARAM="obdfilter.*.client_cache_count"
4429 local CLIENT_CACHE_COUNT
4430 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4432 echo "client_cache_count: $CLIENT_CACHE_COUNT"
4433 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
4434 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
4435 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
4436 wait_update $(facet_host ost1) "lctl get_param -n $CLIENT_PARAM |
4437 head -1" $NEW_CLIENT_CACHE_COUNT
4438 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4440 echo "$CLIENT_CACHE_COUNT"
4441 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
4442 error "error while apply client_cache_count"
4444 echo "Check the value is stored after remount"
4447 wait_update $(facet_host ost1) "lctl get_param -n $CLIENT_PARAM |
4448 head -1" $NEW_CLIENT_CACHE_COUNT
4449 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4451 echo "$CLIENT_CACHE_COUNT"
4452 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
4453 error "client_cache_count is not saved after remount"
4456 run_test 76 "set permanent params set_param -P"
4458 test_77() { # LU-3445
4459 local server_version=$(lustre_version_code $SINGLEMDS)
4461 [[ $server_version -ge $(version_code 2.2.60) ]] &&
4462 [[ $server_version -le $(version_code 2.4.0) ]] &&
4463 skip "Need MDS version < 2.2.60 or > 2.4.0" && return
4465 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
4466 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
4467 skip_env "mixed loopback and real device not working" && return
4470 local fs2mdsdev=$(mdsdevname 1_2)
4471 local fs2ostdev=$(ostdevname 1_2)
4472 local fs2mdsvdev=$(mdsvdevname 1_2)
4473 local fs2ostvdev=$(ostvdevname 1_2)
4474 local fsname=test1234
4476 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
4478 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
4479 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
4480 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
4481 error "start fs2mds failed"
4483 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
4484 [[ $mgsnid = *,* ]] || mgsnid+=",$mgsnid"
4486 add fs2ost $(mkfs_opts ost1 $fs2ostdev) --mgsnode=$mgsnid \
4487 --failnode=$failnid --fsname=$fsname \
4488 --reformat $fs2ostdev $fs2ostvdev ||
4489 error "add fs2ost failed"
4490 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
4493 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
4494 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
4497 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
4500 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ||
4501 $(facet_fstype ost1) != ldiskfs ]] &&
4502 skip "only applicable to ldiskfs-based MDTs and OSTs" && return
4504 # reformat the Lustre filesystem with a smaller size
4505 local saved_MDSSIZE=$MDSSIZE
4506 local saved_OSTSIZE=$OSTSIZE
4507 MDSSIZE=$((MDSSIZE - 20000))
4508 OSTSIZE=$((OSTSIZE - 20000))
4509 reformat || error "(1) reformat Lustre filesystem failed"
4510 MDSSIZE=$saved_MDSSIZE
4511 OSTSIZE=$saved_OSTSIZE
4513 # mount the Lustre filesystem
4514 setup_noconfig || error "(2) setup Lustre filesystem failed"
4517 log "create test files"
4521 mkdir -p $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
4522 for i in $(seq $num_files); do
4523 file=$MOUNT/$tdir/$tfile-$i
4524 dd if=/dev/urandom of=$file count=1 bs=1M ||
4525 error "(4) create $file failed"
4528 # unmount the Lustre filesystem
4529 cleanup || error "(5) cleanup Lustre filesystem failed"
4531 # run e2fsck on the MDT and OST devices
4532 local mds_host=$(facet_active_host $SINGLEMDS)
4533 local ost_host=$(facet_active_host ost1)
4534 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
4535 local ost_dev=$(ostdevname 1)
4537 run_e2fsck $mds_host $mds_dev "-y"
4538 run_e2fsck $ost_host $ost_dev "-y"
4540 # get the original block count of the MDT and OST filesystems
4541 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
4542 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
4544 # expand the MDT and OST filesystems to the device size
4545 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
4546 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
4548 # run e2fsck on the MDT and OST devices again
4549 run_e2fsck $mds_host $mds_dev "-y"
4550 run_e2fsck $ost_host $ost_dev "-y"
4552 # mount the Lustre filesystem
4556 log "check files after expanding the MDT and OST filesystems"
4557 for i in $(seq $num_files); do
4558 file=$MOUNT/$tdir/$tfile-$i
4559 $CHECKSTAT -t file -s 1048576 $file ||
4560 error "(6) checkstat $file failed"
4564 log "create more files after expanding the MDT and OST filesystems"
4565 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
4566 file=$MOUNT/$tdir/$tfile-$i
4567 dd if=/dev/urandom of=$file count=1 bs=1M ||
4568 error "(7) create $file failed"
4571 # unmount the Lustre filesystem
4572 cleanup || error "(8) cleanup Lustre filesystem failed"
4574 # run e2fsck on the MDT and OST devices
4575 run_e2fsck $mds_host $mds_dev "-y"
4576 run_e2fsck $ost_host $ost_dev "-y"
4578 # get the maximum block count of the MDT and OST filesystems
4579 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
4580 local ost_max_blks=$(get_block_count ost1 $ost_dev)
4582 # get the minimum block count of the MDT and OST filesystems
4583 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
4584 grep minimum | sed -e 's/^.*filesystem: //g')
4585 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
4586 grep minimum | sed -e 's/^.*filesystem: //g')
4588 # shrink the MDT and OST filesystems to a smaller size
4592 if [[ $mds_max_blks -gt $mds_min_blks &&
4593 $mds_max_blks -gt $mds_orig_blks ]]; then
4594 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
4595 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
4596 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
4597 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
4598 error "shrink $SINGLEMDS to $new_blks failed"
4602 if [[ $ost_max_blks -gt $ost_min_blks &&
4603 $ost_max_blks -gt $ost_orig_blks ]]; then
4604 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
4605 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
4606 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
4607 run_resize2fs ost1 $ost_dev $new_blks ||
4608 error "shrink ost1 to $new_blks failed"
4612 # check whether the MDT or OST filesystem was shrunk or not
4614 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
4615 reformat || error "(10) reformat Lustre filesystem failed"
4619 # run e2fsck on the MDT and OST devices again
4620 run_e2fsck $mds_host $mds_dev "-y"
4621 run_e2fsck $ost_host $ost_dev "-y"
4623 # mount the Lustre filesystem again
4627 log "check files after shrinking the MDT and OST filesystems"
4628 for i in $(seq $((num_files + 10))); do
4629 file=$MOUNT/$tdir/$tfile-$i
4630 $CHECKSTAT -t file -s 1048576 $file ||
4631 error "(11) checkstat $file failed"
4634 # unmount and reformat the Lustre filesystem
4635 cleanup || error "(12) cleanup Lustre filesystem failed"
4636 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
4637 reformat || error "(14) reformat Lustre filesystem failed"
4639 run_test 78 "run resize2fs on MDT and OST filesystems"
4641 if ! combined_mgs_mds ; then
4647 # restore the values of MDSSIZE and OSTSIZE
4648 MDSSIZE=$STORED_MDSSIZE
4649 OSTSIZE=$STORED_OSTSIZE