7 # bug number for skipped test:
8 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
9 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
11 # bug number for skipped test:
12 # a tool to create lustre filesystem images
13 ALWAYS_EXCEPT="32newtarball $ALWAYS_EXCEPT"
15 # bug number for skipped tests: LU-9795 (all below)
16 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 0 31 32a 32d 35a"
17 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 53a 53b 54b 76a 76b"
18 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76c 76d 78 103"
22 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
24 PTLDEBUG=${PTLDEBUG:--1}
26 LUSTRE=${LUSTRE:-$(dirname $0)/..}
27 RLUSTRE=${RLUSTRE:-$LUSTRE}
28 export MULTIOP=${MULTIOP:-multiop}
30 . $LUSTRE/tests/test-framework.sh
32 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
34 # use small MDS + OST size to speed formatting time
35 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
36 # STORED_MDSSIZE is used in test_18
37 STORED_MDSSIZE=$MDSSIZE
38 STORED_OSTSIZE=$OSTSIZE
40 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && MDSSIZE=400000
42 [ $(facet_fstype ost1) = "zfs" ] && OSTSIZE=400000
52 # bug number for skipped test: LU-11915
53 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 110"
55 if ! combined_mgs_mds; then
56 # bug number for skipped test: LU-11991 LU-11990
57 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 32a 32b 32c 32d 32e 66"
58 # bug number for skipped test: LU-9897 LU-12032
59 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 84 123F"
62 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
63 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
64 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
70 require_dsh_mds || exit 0
71 require_dsh_ost || exit 0
74 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69 106 111"
79 # The MGS must be started before the OSTs for a new fs, so start
80 # and stop to generate the startup logs.
83 wait_osc_import_state mds ost FULL
88 reformat_and_config() {
90 if ! combined_mgs_mds ; then
96 writeconf_or_reformat() {
97 # There are at most 2 OSTs for write_conf test
98 # who knows if/where $TUNEFS is installed?
99 # Better reformat if it fails...
100 writeconf_all $MDSCOUNT 2 ||
101 { echo "tunefs failed, reformatting instead" &&
102 reformat_and_config && return 0; }
111 echo "start mgs service on $(facet_active_host mgs)"
112 start mgs $(mgsdevname) $MGS_MOUNT_OPTS $@
118 local dev=$(mdsdevname $num)
121 echo "start mds service on `facet_active_host $facet`"
122 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
128 local dev=$(mdsdevname $num)
131 echo "stop mds service on `facet_active_host $facet`"
132 # These tests all use non-failover stop
133 stop $facet -f || return 97
139 for num in $(seq $MDSCOUNT); do
140 start_mdt $num $@ || return 94
145 if ! combined_mgs_mds ; then
153 for num in $(seq $MDSCOUNT); do
154 stop_mdt $num || return 97
159 echo "stop mgs service on `facet_active_host mgs`"
160 # These tests all use non-failover stop
161 stop mgs -f || return 97
165 echo "start ost1 service on `facet_active_host ost1`"
166 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
170 echo "stop ost1 service on `facet_active_host ost1`"
171 # These tests all use non-failover stop
172 stop ost1 -f || return 98
176 echo "start ost2 service on `facet_active_host ost2`"
177 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
181 echo "stop ost2 service on `facet_active_host ost2`"
182 # These tests all use non-failover stop
183 stop ost2 -f || return 93
188 echo "mount $FSNAME on ${MOUNTPATH}....."
189 zconf_mount $(hostname) $MOUNTPATH || return 96
193 local mountopt="remount,$1"
195 echo "remount '$1' lustre on ${MOUNTPATH}....."
196 zconf_mount $(hostname) $MOUNTPATH "$mountopt" || return 96
202 echo "umount lustre on $mountpath....."
203 zconf_umount $HOSTNAME $mountpath $@ || return 97
206 manual_umount_client(){
209 echo "manual umount lustre on ${MOUNT}...."
210 do_facet client "umount ${FORCE} $MOUNT"
216 start_mds || error "MDT start failed"
217 start_ost || error "Unable to start OST1"
218 mount_client $MOUNT || error "client start failed"
219 client_up || error "client_up failed"
228 unload_modules_conf () {
229 if combined_mgs_mds || ! local_mode; then
230 unload_modules || return 1
235 stop_ost || return 202
236 stop_mds || return 201
237 unload_modules_conf || return 203
242 [ "x$1" != "x" ] && force='-f'
243 umount_client $MOUNT $force|| return 200
244 cleanup_nocli || return $?
249 echo "umount $MOUNT2 ..."
250 umount $MOUNT2 || true
251 echo "stopping fs2mds ..."
252 stop fs2mds -f || true
253 echo "stopping fs2ost ..."
254 stop fs2ost -f || true
258 do_facet client "cp /etc/passwd $DIR/a" || return 71
259 do_facet client "rm $DIR/a" || return 72
260 # make sure lustre is actually mounted (touch will block,
261 # but grep won't, so do it after)
262 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
263 echo "setup single mount lustre success"
267 do_facet client "touch $DIR/a" || return 71
268 do_facet client "rm $DIR/a" || return 72
269 do_facet client "touch $DIR2/a" || return 73
270 do_facet client "rm $DIR2/a" || return 74
271 echo "setup double mount lustre success"
275 cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
280 if [ "$ONLY" == "setup" ]; then
285 if [ "$ONLY" == "cleanup" ]; then
292 #create single point mountpoint
298 check_mount || error "check_mount failed"
299 cleanup || error "cleanup failed with $?"
301 run_test 0 "single mount setup"
304 start_mds || error "MDS start failed"
305 start_ost || error "unable to start OST"
306 echo "start ost second time..."
307 start_ost && error "2nd OST start should fail"
308 mount_client $MOUNT || error "client start failed"
309 check_mount || error "check_mount failed"
310 cleanup || error "cleanup failed with $?"
312 run_test 1 "start up ost twice (should return errors)"
315 start_mds || error "MDT start failed"
316 echo "start mds second time.."
317 start_mds && error "2nd MDT start should fail"
318 start_ost || error "OST start failed"
319 mount_client $MOUNT || error "mount_client failed to start client"
320 check_mount || error "check_mount failed"
321 cleanup || error "cleanup failed with $?"
323 run_test 2 "start up mds twice (should return err)"
327 #mount.lustre returns an error if already in mtab
328 mount_client $MOUNT && error "2nd client mount should fail"
329 check_mount || error "check_mount failed"
330 cleanup || error "cleanup failed with $?"
332 run_test 3 "mount client twice (should return err)"
336 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
337 stop_ost || error "Unable to stop OST1"
338 umount_client $MOUNT -f || error “unmount $MOUNT failed”
341 # ok for ost to fail shutdown
342 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
343 error "cleanup failed with $?"
346 run_test 4 "force cleanup ost, then cleanup"
348 test_5a() { # was test_5
350 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
351 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
353 stop_mds || error "Unable to stop MDS"
355 # cleanup may return an error from the failed
356 # disconnects; for now I'll consider this successful
357 # if all the modules have unloaded.
361 echo "killing umount"
362 kill -TERM $UMOUNT_PID
363 echo "waiting for umount to finish"
365 if grep " $MOUNT " /proc/mounts; then
366 echo "test 5: /proc/mounts after failed umount"
370 echo "killing umount"
371 kill -TERM $UMOUNT_PID
372 echo "waiting for umount to finish"
374 grep " $MOUNT " /proc/mounts &&
375 error "/proc/mounts after second umount"
378 # manual_mount_client may fail due to umount succeeding above
380 # stop_mds is a no-op here, and should not fail
381 cleanup_nocli || error "cleanup_nocli failed with $?"
382 # df may have lingering entry
384 # mtab may have lingering entry
388 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
390 grep -q $MOUNT" " /etc/mtab || break
391 echo "Waiting /etc/mtab updated ... "
392 WAIT=$(( WAIT + sleep))
394 [ "$WAIT" -eq "$MAX_WAIT" ] &&
395 error "/etc/mtab is not updated in $WAIT secs"
396 echo "/etc/mtab updated in $WAIT secs"
398 run_test 5a "force cleanup mds, then cleanup"
406 grep " $MOUNT " /etc/mtab &&
407 error false "unexpected entry in mtab before mount" && return 10
409 start_ost || error "OST start failed"
410 if ! combined_mgs_mds ; then
411 trap cleanup_5b EXIT ERR
412 start_mds || error "MDS start failed"
416 mount_client $MOUNT && error "mount_client $MOUNT should fail"
417 grep " $MOUNT " /etc/mtab &&
418 error "$MOUNT entry in mtab after failed mount"
420 # stop_mds is a no-op here, and should not fail
421 cleanup_nocli || error "cleanup_nocli failed with $?"
422 if ! combined_mgs_mds ; then
426 run_test 5b "Try to start a client with no MGS (should return errs)"
429 grep " $MOUNT " /etc/mtab &&
430 error false "unexpected entry in mtab before mount" && return 10
432 start_mds || error "MDS start failed"
433 start_ost || error "OST start failed"
434 local oldfs="${FSNAME}"
435 FSNAME="wrong.${FSNAME}"
436 mount_client $MOUNT || :
438 grep " $MOUNT " /etc/mtab &&
439 error "$MOUNT entry in mtab after failed mount"
441 cleanup_nocli || error "cleanup_nocli failed with $?"
443 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
446 grep " $MOUNT " /etc/mtab &&
447 error "unexpected entry in mtab before mount"
449 start_ost || error "OST start failed"
450 start_mds || error "MDS start failed"
451 stop_ost -f || error "Unable to stop OST1"
452 mount_client $MOUNT || error "mount_client $MOUNT failed"
453 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
454 cleanup_nocli || error "cleanup_nocli failed with $?"
455 ! grep " $MOUNT " /etc/mtab ||
456 error "$MOUNT entry in mtab after unmount"
458 run_test 5d "mount with ost down"
461 grep " $MOUNT " /etc/mtab &&
462 error false "unexpected entry in mtab before mount" && return 10
464 start_mds || error "MDS start failed"
465 start_ost || error "OST start failed"
467 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
468 do_facet client "$LCTL set_param fail_loc=0x80000506"
469 mount_client $MOUNT || echo "mount failed (not fatal)"
470 cleanup || error "cleanup failed with $?"
471 grep " $MOUNT " /etc/mtab &&
472 error "$MOUNT entry in mtab after unmount"
475 run_test 5e "delayed connect, don't crash (bug 10268)"
478 combined_mgs_mds && skip "needs separate mgs and mds"
480 grep " $MOUNT " /etc/mtab &&
481 error false "unexpected entry in mtab before mount" && return 10
484 start_ost || error "OST start failed"
485 mount_client $MOUNT &
487 echo client_mount pid is $pid
491 if ! ps -f -p $pid >/dev/null; then
494 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
495 error "mount returns $rc, expected to hang"
497 cleanup || error "cleanup failed with $?"
502 start_mds || error "start MDS failed"
504 # mount should succeed after start mds
506 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
507 cleanup || error "final call to cleanup failed with rc $?"
509 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
513 [ $(lustre_version_code client) -lt $(version_code 2.9.53) ] &&
514 skip "automount of debugfs missing before 2.9.53"
515 umount /sys/kernel/debug
516 $LCTL get_param -n devices | egrep -v "error" && \
517 error "lctl can't access debugfs data"
518 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
520 run_test 5g "handle missing debugfs"
526 #define OBD_FAIL_MDS_FS_SETUP 0x135
527 do_facet mds1 "$LCTL set_param fail_loc=0x80000135"
528 start_mdt 1 && error "start mdt should fail"
529 start_mdt 1 || error "start mdt failed"
530 client_up || error "client_up failed"
533 run_test 5h "start mdt failure at mdt_fs_setup()"
539 #define OBD_FAIL_QUOTA_INIT 0xA05
540 do_facet mds1 "$LCTL set_param fail_loc=0x80000A05"
541 start_mdt 1 && error "start mdt should fail"
542 start_mdt 1 || error "start mdt failed"
543 client_up || error "client_up failed"
546 run_test 5i "start mdt failure at mdt_quota_init()"
551 mount_client $MOUNT || error "mount_client $MOUNT failed"
552 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
553 cleanup || error "cleanup failed with rc $?"
555 run_test 6 "manual umount, then mount again"
560 cleanup_nocli || error "cleanup_nocli failed with $?"
562 run_test 7 "manual umount, then cleanup"
566 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
567 check_mount2 || error "check_mount2 failed"
568 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
569 cleanup || error "cleanup failed with rc $?"
571 run_test 8 "double mount setup"
574 start_ost || error "OST start failed"
576 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
577 error "do_facet ost1 set_param inode trace failed."
578 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
579 error "do_facet ost1 set_param debug mds ost failed."
581 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
582 if [ "$CHECK_PTLDEBUG" ] && { \
583 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
584 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
585 echo "lnet.debug success"
587 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
589 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
590 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
591 echo "lnet.subsystem_debug success"
593 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
595 stop_ost || error "Unable to stop OST1"
597 run_test 9 "test ptldebug and subsystem for mkfs"
600 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
601 # But with new MDS stack we don't care about the mode of local objects
602 # anymore, so this test is removed. See bug 22944 for more details.
606 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
607 skip "ldiskfs only test"
611 check_mount || error "check_mount failed"
612 cleanup || error "cleanup failed with rc $?"
614 echo "Remove mds config log"
615 if ! combined_mgs_mds ; then
619 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
620 $(mgsdevname) || return \$?" ||
621 error "do_facet mgs failed with $?"
623 if ! combined_mgs_mds ; then
627 start_ost || error "OST start failed"
628 start_mds && error "MDS start succeeded, but should fail"
631 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
634 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
635 skip "ldiskfs only test"
638 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
643 # check if current MDSSIZE is large enough
644 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
645 log "use MDSSIZE=$MDSSIZE"
647 # check if the global config has a large enough MDSSIZE
648 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
649 [ $STORED_MDSSIZE -ge $MIN ] &&
650 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
651 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
653 # check if the block device is large enough
654 is_blkdev $SINGLEMDS $MDSDEV $MIN
655 local large_enough=$?
656 if [ -n "$OK" ]; then
657 [ $large_enough -ne 0 ] && OK=""
659 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
660 log "use device $MDSDEV with MIN=$MIN"
663 # check if a loopback device has enough space for fs metadata (5%)
665 if [ -z "$OK" ]; then
666 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
667 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
668 awk '($1 != "Filesystem") { print $4 }')
669 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
670 OK=1 && myMDSSIZE=$MIN &&
671 log "use file $MDSDEV with MIN=$MIN"
674 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS"
676 echo "mount mds with large journal..."
678 local OLD_MDSSIZE=$MDSSIZE
682 echo "mount lustre system..."
684 check_mount || error "check_mount failed"
686 echo "check journal size..."
687 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
688 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
689 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
691 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
694 cleanup || error "cleanup failed with rc $?"
699 run_test 18 "check mkfs creates large journals"
702 start_mds || error "MDS start failed"
703 stop_mds || error "Unable to stop MDS"
705 run_test 19a "start/stop MDS without OSTs"
708 start_ost || error "Unable to start OST1"
709 stop_ost -f || error "Unable to stop OST1"
711 run_test 19b "start/stop OSTs without MDS"
714 # first format the ost/mdt
715 start_mds || error "MDS start failed"
716 start_ost || error "Unable to start OST1"
717 mount_client $MOUNT || error "mount_client $MOUNT failed"
718 check_mount || error "check_mount failed"
719 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
720 remount_client ro $MOUNT || error "remount_client with ro failed"
721 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
722 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
723 remount_client rw $MOUNT || error "remount_client with rw failed"
724 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
725 MCNT=$(grep -c $MOUNT' ' /etc/mtab)
726 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
728 stop_mds || error "Unable to stop MDS"
729 stop_ost || error "Unable to stop OST1"
731 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
734 start_mds || error "MDS start failed"
735 start_ost || error "unable to start OST1"
736 wait_osc_import_state mds ost FULL
737 stop_ost || error "unable to stop OST1"
738 stop_mds || error "unable to stop MDS"
740 run_test 21a "start mds before ost, stop ost first"
743 start_ost || error "unable to start OST1"
744 start_mds || error "MDS start failed"
745 wait_osc_import_state mds ost FULL
746 stop_mds || error "unable to stop MDS"
747 stop_ost || error "unable to stop OST1"
749 run_test 21b "start ost before mds, stop mds first"
752 start_ost || error "Unable to start OST1"
753 start_mds || error "MDS start failed"
754 start_ost2 || error "Unable to start OST2"
755 wait_osc_import_state mds ost2 FULL
756 stop_ost || error "Unable to stop OST1"
757 stop_ost2 || error "Unable to stop OST2"
758 stop_mds || error "Unable to stop MDS"
759 #writeconf to remove all ost2 traces for subsequent tests
760 writeconf_or_reformat
762 run_test 21c "start mds between two osts, stop mds last"
765 combined_mgs_mds && skip "need separate mgs device"
770 start_mgs || error "unable to start MGS"
771 start_ost || error "unable to start OST1"
772 start_ost2 || error "unable to start OST2"
773 start_mds || error "MDS start failed"
774 wait_osc_import_state mds ost2 FULL
776 stop_ost || error "Unable to stop OST1"
777 stop_ost2 || error "Unable to stop OST2"
778 stop_mds || error "Unable to stop MDS"
780 #writeconf to remove all ost2 traces for subsequent tests
781 writeconf_or_reformat
782 start_mgs || error "unable to start MGS"
784 run_test 21d "start mgs then ost and then mds"
787 MGSNID="$saved_mgsnid"
789 echo "stopping fs2mgs ..."
790 stop $fs2mgs -f || true
793 test_21e() { # LU-5863
794 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
795 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
796 skip_env "mixed loopback and real device not working"
799 local fs2mdsdev=$(mdsdevname 1_2)
800 local fs2ostdev=$(ostdevname 1_2)
801 local fs3ostdev=$(ostdevname 2_2)
803 local fs2mdsvdev=$(mdsvdevname 1_2)
804 local fs2ostvdev=$(ostvdevname 1_2)
805 local fs3ostvdev=$(ostvdevname 2_2)
807 # temporarily use fs3ost as fs2mgs
809 local fs2mgsdev=$fs3ostdev
810 local fs2mgsvdev=$fs3ostvdev
812 local fsname=test1234
814 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
815 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
816 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
817 error "start fs2mgs failed"
819 local saved_mgsnid="$MGSNID"
820 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
822 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
823 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
824 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
825 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
827 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
828 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
830 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
831 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
832 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
836 run_test 21e "separate MGS and MDS"
839 start_mds || error "MDS start failed"
841 echo "Client mount with ost in logs, but none running"
842 start_ost || error "unable to start OST1"
843 # wait until mds connected to ost and open client connection
844 wait_osc_import_state mds ost FULL
845 stop_ost || error "unable to stop OST1"
846 mount_client $MOUNT || error "mount_client $MOUNT failed"
847 # check_mount will block trying to contact ost
848 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
849 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
850 umount_client $MOUNT -f
853 echo "Client mount with a running ost"
854 start_ost || error "unable to start OST1"
856 # if gss enabled, wait full time to let connection from
857 # mds to ost be established, due to the mismatch between
858 # initial connect timeout and gss context negotiation timeout.
859 # This perhaps could be remove after AT landed.
860 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
861 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
863 mount_client $MOUNT || error "mount_client $MOUNT failed"
864 wait_osc_import_state mds ost FULL
865 wait_osc_import_ready client ost
866 check_mount || error "check_mount failed"
869 cleanup || error "cleanup failed with rc $?"
871 run_test 22 "start a client before osts (should return errs)"
873 test_23a() { # was test_23
876 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
877 # force down client so that recovering mds waits for reconnect
878 local running=$(grep -c $MOUNT /proc/mounts) || true
879 if [ $running -ne 0 ]; then
880 echo "Stopping client $MOUNT (opts: -f)"
884 # enter recovery on failed mds
885 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
886 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
887 # try to start a new client
888 mount_client $MOUNT &
890 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
891 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
892 grep -v grep | awk '{print $2}')
893 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
895 ps --ppid $MOUNT_LUSTRE_PID
896 echo "waiting for mount to finish"
898 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
899 # SIGTERM works but it does not spread to offspring processses
900 kill -s TERM $MOUNT_PID
901 kill -s TERM $MOUNT_LUSTRE_PID
902 # we can not wait $MOUNT_PID because it is not a child of this shell
908 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
910 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
911 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
914 [ -z "$PID1" -a -z "$PID2" ] && break
915 echo "waiting for mount to finish ... "
916 WAIT=$(( WAIT + sleep))
918 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
919 error "MOUNT_PID $MOUNT_PID and "\
920 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
923 cleanup || error "cleanup failed with rc $?"
925 run_test 23a "interrupt client during recovery mount delay"
927 test_23b() { # was test_23
928 start_mds || error "MDS start failed"
929 start_ost || error "Unable to start OST1"
930 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
931 $LCTL set_param fail_loc=0x80000313
933 cleanup || error "cleanup failed with rc $?"
935 run_test 23b "Simulate -EINTR during mount"
938 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
940 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
941 is_blkdev $SINGLEMDS $MDSDEV &&
942 skip_env "mixed loopback and real device not working"
945 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
947 local fs2mdsdev=$(mdsdevname 1_2)
948 local fs2ostdev=$(ostdevname 1_2)
949 local fs2mdsvdev=$(mdsvdevname 1_2)
950 local fs2ostvdev=$(ostvdevname 1_2)
953 # LU-9733 test fsname started with numbers as well
954 local FSNAME2=969362ae
956 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
957 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
959 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
960 --reformat $fs2ostdev $fs2ostvdev || exit 10
963 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
964 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
965 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
966 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
968 # LU-9733 test fsname started with numbers
969 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
970 changelog_register -n) ||
971 error "register changelog failed"
973 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
974 changelog_deregister $cl_user ||
975 error "deregister changelog failed"
977 check_mount || error "check_mount failed"
978 # files written on 1 should not show up on 2
979 cp /etc/passwd $DIR/$tfile
981 [ -e $MOUNT2/$tfile ] && error "File bleed"
984 cp /etc/passwd $MOUNT2/$tfile ||
985 error "cp /etc/passwd $MOUNT2/$tfile failed"
986 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
987 # 2 is actually mounted
988 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
990 facet_failover fs2mds
991 facet_failover fs2ost
994 # the MDS must remain up until last MDT
996 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
997 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
998 [ -z "$MDS" ] && error "No MDT"
1000 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1002 run_test 24a "Multiple MDTs on a single node"
1005 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1007 skip "needs combined MGT and MDT device"
1009 if [ -z "$fs2mds_DEV" ]; then
1010 local dev=${SINGLEMDS}_dev
1011 local MDSDEV=${!dev}
1012 is_blkdev $SINGLEMDS $MDSDEV &&
1013 skip_env "mixed loopback and real device not working"
1016 local fs2mdsdev=$(mdsdevname 1_2)
1017 local fs2mdsvdev=$(mdsvdevname 1_2)
1019 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1020 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1022 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && {
1024 error "start MDS should fail"
1027 cleanup || error "cleanup failed with rc $?"
1029 run_test 24b "Multiple MGSs on a single node (should return err)"
1033 check_mount || error "check_mount failed"
1034 local MODULES=$($LCTL modules | awk '{ print $2 }')
1035 rmmod $MODULES 2>/dev/null || true
1036 cleanup || error "cleanup failed with $?"
1038 run_test 25 "Verify modules are referenced"
1042 # we need modules before mount for sysctl, so make sure...
1043 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1044 #define OBD_FAIL_MDS_FS_SETUP 0x135
1045 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1046 start_mds && error "MDS started but should not have started"
1047 $LCTL get_param -n devices
1048 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1049 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1050 # start mds to drop writeconf setting
1051 start_mds || error "Unable to start MDS"
1052 stop_mds || error "Unable to stop MDS"
1053 unload_modules_conf || error "unload_modules_conf failed with $?"
1055 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1059 start_ost || error "Unable to start OST1"
1060 start_mds || error "Unable to start MDS"
1061 echo "Requeue thread should have started: "
1062 ps -e | grep ll_cfg_requeue
1063 set_persistent_param_and_check ost1 \
1064 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1065 "$FSNAME-OST0000.ost.client_cache_seconds"
1066 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1068 run_test 27a "Reacquire MGS lock if OST started first"
1073 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1074 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1076 facet_failover $SINGLEMDS
1077 set_persistent_param_and_check $SINGLEMDS \
1078 "mdt.$device.identity_acquire_expire" \
1079 "$device.mdt.identity_acquire_expire"
1080 set_persistent_param_and_check client \
1081 "mdc.$device-mdc-*.max_rpcs_in_flight" \
1082 "$device.mdc.max_rpcs_in_flight"
1084 cleanup || error "cleanup failed with $?"
1086 run_test 27b "Reacquire MGS lock after failover"
1088 test_28A() { # was test_28
1091 local TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1092 local PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1093 local orig=$($LCTL get_param -n $TEST)
1094 local max=$($LCTL get_param -n \
1095 llite.$FSNAME-*.max_read_ahead_per_file_mb)
1097 orig=${orig%%.[0-9]*}
1099 echo "ORIG:$orig MAX:$max"
1100 [[ $max -le $orig ]] && orig=$((max - 3))
1101 echo "ORIG:$orig MAX:$max"
1103 local final=$((orig + 1))
1105 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1106 final=$((final + 1))
1107 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1108 umount_client $MOUNT || error "umount_client $MOUNT failed"
1109 mount_client $MOUNT || error "mount_client $MOUNT failed"
1111 local result=$($LCTL get_param -n $TEST)
1113 if [ $result -ne $final ]; then
1114 error "New config not seen: wanted $final got $result"
1116 echo "New config success: got $result"
1118 set_persistent_param_and_check client "$TEST" "$PARAM" $orig
1119 cleanup || error "cleanup failed with rc $?"
1121 run_test 28A "permanent parameter setting"
1123 test_28a() { # LU-4221
1124 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1125 skip "Need OST version at least 2.5.52"
1126 [ "$(facet_fstype ost1)" = "zfs" ] &&
1127 skip "LU-4221: no such proc params for ZFS OSTs"
1134 local device="$FSNAME-OST0000"
1138 # In this test we will set three kinds of proc parameters with
1139 # lctl set_param -P or lctl conf_param:
1140 # 1. non-symlink ones in the OFD
1141 # 2. non-symlink ones in the OSD
1144 # prepare a non-symlink parameter in the OFD
1145 name="client_cache_seconds"
1146 param="$device.ost.$name"
1147 cmd="obdfilter.$device.$name"
1149 # permanently setting the parameter in the OFD
1150 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1152 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1153 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1156 # prepare a non-symlink parameter in the OSD
1158 param="$device.osd.$name"
1159 cmd="osd-*.$device.$name"
1161 # conf_param the parameter in the OSD
1162 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1163 new=$(((old + 1) % 2))
1164 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1165 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1167 cleanup || error "cleanup failed with $?"
1169 run_test 28a "set symlink parameters permanently with lctl"
1172 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
1173 setup_noconfig > /dev/null 2>&1
1174 start_ost2 || error "Unable to start OST2"
1177 local PARAM="$FSNAME-OST0001.osc.active"
1178 # With lctl set_param -P the value $PROC_ACT will be sent to
1179 # all nodes. The [!M] filter out the ability to set active
1180 # on the MDS servers which is tested with wait_osp_* below.
1181 # For ost_server_uuid that only exist on client so filtering
1183 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1184 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1186 ACTV=$($LCTL get_param -n $PROC_ACT)
1188 set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
1189 # also check ost_server_uuid status
1190 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1191 if [ -z "$RESULT" ]; then
1192 error "Client not deactivated: $($LCTL get_param \
1195 echo "Live client success: got $RESULT"
1199 wait_osp_active ost ${FSNAME}-OST0001 1 0
1201 # test new client starts deactivated
1202 umount_client $MOUNT || error "umount_client $MOUNT failed"
1203 mount_client $MOUNT || error "mount_client $MOUNT failed"
1205 # the 2nd and 3rd field of ost_server_uuid do not update at the same
1206 # time when using lctl set_param -P
1207 wait_update_facet client \
1208 "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'" \
1210 error "New client start active: $($LCTL get_param -n $PROC_UUID)"
1212 echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
1214 # make sure it reactivates
1215 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1217 umount_client $MOUNT
1218 stop_ost2 || error "Unable to stop OST2"
1219 cleanup_nocli || error "cleanup_nocli failed with $?"
1220 #writeconf to remove all ost2 traces for subsequent tests
1221 writeconf_or_reformat
1223 run_test 29 "permanently remove an OST"
1228 echo Big config llog
1229 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1230 ORIG=$($LCTL get_param -n $TEST)
1231 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1232 for i in ${LIST[@]}; do
1233 set_persistent_param_and_check client "$TEST" \
1234 "$FSNAME.llite.max_read_ahead_whole_mb" $i
1236 # make sure client restart still works
1237 umount_client $MOUNT
1238 mount_client $MOUNT || error "mount_client $MOUNT failed"
1239 [ "$($LCTL get_param -n $TEST)" -ne "$i" ] &&
1240 error "Param didn't stick across restart $($TEST) != $i"
1243 echo Erase parameter setting
1244 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1245 do_facet mgs "$PERM_CMD -d $TEST" ||
1246 error "Erase param $TEST failed"
1248 do_facet mgs "$PERM_CMD \
1249 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1250 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1252 umount_client $MOUNT
1253 mount_client $MOUNT || error "mount_client $MOUNT failed"
1254 FINAL=$($LCTL get_param -n $TEST)
1255 echo "deleted (default) value=$FINAL, orig=$ORIG"
1256 ORIG=${ORIG%%.[0-9]*}
1257 FINAL=${FINAL%%.[0-9]*}
1258 # assumes this parameter started at the default value
1259 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1261 cleanup || error "cleanup failed with rc $?"
1263 run_test 30a "Big config llog and permanent parameter deletion"
1268 local orignids=$($LCTL get_param -n \
1269 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1271 local orignidcount=$(echo "$orignids" | wc -w)
1273 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1274 # numerical part of it. Hopefully that's not already a failover address
1276 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1278 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1279 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1280 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1281 echo "Using fake nid $NEW"
1283 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1284 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1285 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1286 PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
1287 echo "Setting $PARAM from $TEST to $NEW"
1288 do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
1289 error "$PERM_CMD $PARAM failed"
1291 PARAM="$FSNAME-OST0000.failover.node"
1292 echo "Setting $PARAM from $TEST to $NEW"
1293 do_facet mgs "$PERM_CMD $PARAM='$NEW'" ||
1294 error "$PARAM $PARAM failed"
1296 wait_update_facet client "$TEST" "$NEW" ||
1297 error "check $PARAM failed!"
1299 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1301 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1302 echo "should have $((orignidcount + 1)) entries \
1303 in failover nids string, have $NIDCOUNT"
1304 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1305 error "Failover nid not added"
1307 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1308 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1310 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1311 error "$PERM_CMD delete failed"
1313 umount_client $MOUNT
1314 mount_client $MOUNT || error "mount_client $MOUNT failed"
1316 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1318 NIDCOUNT=$(echo "$NIDS" | wc -w)
1319 echo "only $orignidcount final entries should remain \
1320 in failover nids string, have $NIDCOUNT"
1321 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1323 cleanup || error "cleanup failed with rc $?"
1325 run_test 30b "Remove failover nids"
1327 test_31() { # bug 10734
1328 # ipaddr must not exist
1329 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1330 cleanup || error "cleanup failed with rc $?"
1332 run_test 31 "Connect to non-existent node (shouldn't crash)"
1336 T32_BLIMIT=40960 # Kbytes
1340 # This is not really a test but a tool to create new disk
1341 # image tarballs for the upgrade tests.
1343 # Disk image tarballs should be created on single-node
1344 # clusters by running this test with default configurations
1345 # plus a few mandatory environment settings that are verified
1346 # at the beginning of the test.
1348 test_32newtarball() {
1352 local tmp=$TMP/t32_image_create
1353 local server_version=$(lustre_version_code $SINGLEMDS)
1358 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1359 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1360 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1361 "MDSDEV1=<nonexistent_file>" \
1362 "MDSDEV2=<nonexistent_file>" \
1363 "(or MDSDEV, in the case of b1_8)" \
1364 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1368 echo "Found stale $tmp"
1372 mkdir $tmp/src || return 1
1373 tar cf - -C $src . | tar xf - -C $tmp/src
1374 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1375 count=$(($T32_BLIMIT / 1024 / 4))
1376 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1378 # format ost with comma-separated NIDs to verify LU-4460
1379 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1380 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1384 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1385 $LFS quotacheck -ug /mnt/$FSNAME
1386 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1389 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1391 if [[ $MDSCOUNT -ge 2 ]]; then
1392 remote_dir=/mnt/$FSNAME/remote_dir
1393 $LFS mkdir -i 1 $remote_dir
1394 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1396 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1397 striped_dir=/mnt/$FSNAME/striped_dir_old
1398 $LFS mkdir -i 1 -c 2 $striped_dir
1399 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1405 mkdir $tmp/img || return 1
1409 pushd_dir=/mnt/$FSNAME
1410 if [[ $MDSCOUNT -ge 2 ]]; then
1411 pushd_dir=$remote_dir
1412 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1414 ls -Rni --time-style=+%s >$tmp/img/list2
1420 ls -Rni --time-style=+%s >$tmp/img/list
1421 find ! -name .lustre -type f -exec sha1sum {} \; |
1422 sort -k 2 >$tmp/img/sha1sums
1424 $LCTL get_param -n version | head -n 1 |
1425 sed -e 's/^lustre: *//' >$tmp/img/commit
1427 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1428 $LFS quotaon -ug /mnt/$FSNAME
1429 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1430 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1431 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1432 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1433 | tr -d "*" > $tmp/img/bspace
1434 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1435 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1436 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1437 | tr -d "*" > $tmp/img/ispace
1438 echo $T32_BLIMIT > $tmp/img/blimit
1439 echo $T32_ILIMIT > $tmp/img/ilimit
1444 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1447 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1448 echo "Data verification failed"
1451 uname -r >$tmp/img/kernel
1452 uname -m >$tmp/img/arch
1454 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1455 for num in $(seq 2 $MDSCOUNT); do
1456 local devname=$(mdsdevname $num)
1458 [[ $(facet_fstype $facet) != zfs ]] ||
1459 devname=$(mdsvdevname $num)
1460 mv $devname $tmp/img
1462 mv $OSTDEV1 $tmp/img
1464 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1465 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1468 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1473 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1476 # The list of applicable tarballs is returned via the caller's
1477 # variable "tarballs".
1480 [ "$CLIENTONLY" ] && skip "Client-only testing"
1482 local node=$(facet_active_host $SINGLEMDS)
1483 local r="do_node $node"
1485 ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
1487 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1489 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1490 -name \'disk*-$IMGTYPE.tar.bz2\')
1492 [ -z "$tarballs" ] && skip "No applicable tarballs found"
1495 t32_test_cleanup() {
1497 local facet=$SINGLEMDS
1498 local fstype=$(facet_fstype $facet)
1501 if $shall_cleanup_lustre; then
1502 umount $tmp/mnt/lustre || rc=$?
1504 if $shall_cleanup_mdt; then
1505 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1507 if $shall_cleanup_mdt1; then
1508 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1510 if $shall_cleanup_ost; then
1511 $r $UMOUNT $tmp/mnt/ost || rc=$?
1516 if [[ $fstype == zfs ]]; then
1518 local poolname_list="t32fs-mdt1 t32fs-ost1"
1520 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1522 for poolname in $poolname_list; do
1523 destroy_zpool $facet $poolname
1526 combined_mgs_mds || start_mgs || rc=$?
1530 t32_bits_per_long() {
1532 # Yes, this is not meant to be perfect.
1542 t32_reload_modules() {
1544 local all_removed=false
1546 local fstype=$(facet_fstype $SINGLEMDS)
1548 [ $fstype == "zfs" ] && do_rpc_nodes $node "service zed stop"
1550 while ((i < 20)); do
1551 echo "Unloading modules on $node: Attempt $i"
1552 do_rpc_nodes $node $LUSTRE_RMMOD $fstype &&
1554 do_rpc_nodes $node check_mem_leak || return 1
1555 if $all_removed; then
1556 do_rpc_nodes $node load_modules
1559 if [ $fstype == "zfs" ]; then
1560 do_rpc_nodes $node "$ZPOOL status -v"
1565 echo "Unloading modules on $node: Given up"
1569 t32_wait_til_devices_gone() {
1575 echo wait for devices to go
1576 while ((i < 20)); do
1577 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1578 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1579 ((devices == 0 && loops == 0)) && return 0
1583 echo "waiting for dev on $node: dev $devices loop $loops given up"
1584 do_rpc_nodes $node "losetup -a"
1585 do_rpc_nodes $node "$LCTL device_list"
1589 t32_verify_quota() {
1593 local fstype=$(facet_fstype $SINGLEMDS)
1597 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1598 # lustre will estimate the object count usage. This fails quota
1599 # verification in 32b. The object quota usage should be accurate after
1600 # zfs-0.7.0 is released.
1601 [ $fstype == "zfs" ] && {
1602 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1604 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1605 echo "Skip quota verify for zfs: $zfs_version"
1610 $LFS quota -u $T32_QID -v $mnt
1612 qval=$($LFS quota -v -u $T32_QID $mnt |
1613 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1614 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1616 [ $qval -eq $img_bspace ] || {
1617 echo "bspace, act:$qval, exp:$img_bspace"
1621 qval=$($LFS quota -v -u $T32_QID $mnt |
1622 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1623 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1625 [ $qval -eq $img_ispace ] || {
1626 echo "ispace, act:$qval, exp:$img_ispace"
1630 qval=$($LFS quota -v -u $T32_QID $mnt |
1631 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1632 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1634 [ $qval -eq $img_blimit ] || {
1635 echo "blimit, act:$qval, exp:$img_blimit"
1639 qval=$($LFS quota -v -u $T32_QID $mnt |
1640 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1641 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1643 [ $qval -eq $img_ilimit ] || {
1644 echo "ilimit, act:$qval, exp:$img_ilimit"
1648 set_persistent_param_and_check $facet \
1649 "osd-$fstype.$fsname-MDT0000.quota_slave.enabled" \
1650 "$fsname.quota.mdt" ug
1652 set_persistent_param_and_check $facet \
1653 "osd-$fstype.$fsname-OST0000.quota_slave.enabled" \
1654 "$fsname.quota.ost" ug
1657 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1658 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1659 echo "Write succeed, but expect -EDQUOT"
1662 rm -f $mnt/t32_qf_new
1664 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1666 echo "Create succeed, but expect -EDQUOT"
1669 unlinkmany $mnt/t32_qf_ $img_ilimit
1677 local dne_upgrade=${dne_upgrade:-"no"}
1678 local dom_upgrade=${dom_upgrade:-"no"}
1679 local ff_convert=${ff_convert:-"no"}
1680 local shall_cleanup_mdt=false
1681 local shall_cleanup_mdt1=false
1682 local shall_cleanup_ost=false
1683 local shall_cleanup_lustre=false
1684 local mdt2_is_available=false
1685 local node=$(facet_active_host $SINGLEMDS)
1686 local r="do_node $node"
1702 local fstype=$(facet_fstype $SINGLEMDS)
1703 local mdt_dev=$tmp/mdt
1704 local mdt2_dev=$tmp/mdt2
1705 local ost_dev=$tmp/ost
1710 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1711 trap 'trap - RETURN; t32_test_cleanup' RETURN
1714 nid=$($r $LCTL list_nids | head -1)
1716 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1717 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1718 $r tar xjvf $tarball -S -C $tmp || {
1719 error_noexit "Unpacking the disk image tarball"
1722 img_commit=$($r cat $tmp/commit)
1723 img_kernel=$($r cat $tmp/kernel)
1724 img_arch=$($r cat $tmp/arch)
1725 img_bspace=$($r cat $tmp/bspace)
1726 img_ispace=$($r cat $tmp/ispace)
1728 # older images did not have "blimit" and "ilimit" files
1729 # use old values for T32_BLIMIT and T32_ILIMIT
1730 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1732 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1735 echo "Upgrading from $(basename $tarball), created with:"
1736 echo " Commit: $img_commit"
1737 echo " Kernel: $img_kernel"
1738 echo " Arch: $img_arch"
1739 echo "OST version: $(lustre_build_version ost1)"
1741 # The conversion can be made only when both of the following
1742 # conditions are satisfied:
1743 # - ost device img version < 2.3.64
1744 # - ost server version >= 2.5
1745 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1746 $(lustre_version_code ost1) -lt $(version_code 2.5.0) ] &&
1749 ! $r test -f $mdt2_dev || mdt2_is_available=true
1751 if [[ $fstype == zfs ]]; then
1754 local poolname_list="t32fs-mdt1 t32fs-ost1"
1756 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1758 for poolname in $poolname_list; do
1760 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1761 $ZPOOL import -f -d $tmp $poolname"
1764 # upgrade zpool to latest supported features, including
1765 # dnode quota accounting in 0.7.0
1766 $r "$ZPOOL upgrade -a"
1768 mdt_dev=t32fs-mdt1/mdt1
1769 ost_dev=t32fs-ost1/ost1
1770 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1771 wait_update_facet $SINGLEMDS "$ZPOOL list |
1772 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1773 error_noexit "import zfs pool failed"
1778 $r $LCTL set_param debug="$PTLDEBUG"
1780 $r $TUNEFS --dryrun $mdt_dev || {
1782 error_noexit "tunefs.lustre before mounting the MDT"
1786 if $mdt2_is_available; then
1787 $r $TUNEFS --dryrun $mdt2_dev || {
1789 error_noexit "tunefs.lustre before mounting the MDT"
1794 if [ "$writeconf" ]; then
1796 if [ $fstype == "ldiskfs" ]; then
1798 $r $TUNEFS --quota $mdt_dev || {
1800 error_noexit "Enable mdt quota feature"
1803 if $mdt2_is_available; then
1804 $r $TUNEFS --quota $mdt2_dev || {
1806 error_noexit "Enable mdt quota feature"
1812 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1813 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1814 skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
1815 "(Need MGS version at least 2.3.59)"
1817 local osthost=$(facet_active_host ost1)
1818 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1821 if [ $fstype == "ldiskfs" ]; then
1824 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1825 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1826 $r $LCTL replace_nids $fsname-MDT0000 $nid
1827 $r $UMOUNT $tmp/mnt/mdt
1830 mopts=exclude=$fsname-OST0000
1831 if [ $fstype == "ldiskfs" ]; then
1836 t32_wait_til_devices_gone $node
1838 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1840 error_noexit "Mounting the MDT"
1843 shall_cleanup_mdt=true
1845 if $mdt2_is_available; then
1846 mopts=mgsnode=$nid,$mopts
1847 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1849 error_noexit "Mounting the MDT"
1853 echo "mount new MDT....$mdt2_dev"
1854 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1855 error_noexit "enable remote dir create failed"
1857 shall_cleanup_mdt1=true
1858 elif [ "$dne_upgrade" != "no" ]; then
1859 local fs2mdsdev=$(mdsdevname 1_2)
1860 local fs2mdsvdev=$(mdsvdevname 1_2)
1862 echo "mkfs new MDT on ${fs2mdsdev}...."
1863 if [ $(facet_fstype mds1) == ldiskfs ]; then
1864 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1867 add $SINGLEMDS $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1868 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1869 error_noexit "Mkfs new MDT failed"
1873 [[ $(facet_fstype mds1) != zfs ]] || import_zpool mds1
1875 $r $TUNEFS --dryrun $fs2mdsdev || {
1876 error_noexit "tunefs.lustre before mounting the MDT"
1880 echo "mount new MDT....$fs2mdsdev"
1881 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1882 error_noexit "mount mdt1 failed"
1886 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1887 error_noexit "enable remote dir create failed"
1889 shall_cleanup_mdt1=true
1892 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1893 error_noexit "Getting MDT UUID"
1896 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1897 error_noexit "Unexpected MDT UUID: \"$uuid\""
1901 $r $TUNEFS --dryrun $ost_dev || {
1902 error_noexit "tunefs.lustre before mounting the OST"
1905 if [ "$writeconf" ]; then
1906 mopts=mgsnode=$nid,$writeconf
1907 if [ $fstype == "ldiskfs" ]; then
1909 $r $TUNEFS --quota $ost_dev || {
1911 error_noexit "Enable ost quota feature"
1917 if [ $fstype == "ldiskfs" ]; then
1922 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1923 error_noexit "Mounting the OST"
1926 shall_cleanup_ost=true
1928 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1929 error_noexit "Getting OST UUID"
1932 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1933 error_noexit "Unexpected OST UUID: \"$uuid\""
1937 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1938 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
1939 error_noexit "Setting OST \"failover.node\""
1942 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
1943 error_noexit "Setting MDT \"failover.node\""
1946 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
1947 error_noexit "Setting \"max_dirty_mb\""
1950 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
1951 error_noexit "Setting \"max_rpcs_in_flight\""
1954 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
1955 error_noexit "Setting \"lov.stripesize\""
1958 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
1959 error_noexit "Setting \"mdd.atime_diff\""
1963 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
1964 error_noexit "Setting OST \"failover.node\""
1968 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
1969 error_noexit "Setting MDT \"failover.node\""
1973 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
1974 error_noexit "Setting \"max_dirty_mb\""
1977 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1978 error_noexit "Setting \"max_rpcs_in_flight\""
1981 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
1982 error_noexit "Setting \"lov.stripesize\""
1985 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
1986 error_noexit "Setting \"mdd.atime_diff\""
1991 $r $LCTL pool_new $fsname.interop || {
1992 error_noexit "Setting \"interop\""
1996 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1997 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1998 error_noexit "Start OI scrub on OST0"
2002 # The oi_scrub should be on ost1, but for test_32(),
2003 # all on the SINGLEMDS.
2004 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
2005 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2006 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
2007 error_noexit "Failed to get the expected 'completed'"
2011 local UPDATED=$($r $LCTL get_param -n \
2012 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2013 awk '/^updated/ { print $2 }')
2014 [ $UPDATED -ge 1 ] || {
2015 error_noexit "Only $UPDATED objects have been converted"
2020 if [ "$dne_upgrade" != "no" ]; then
2021 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2022 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
2023 error_noexit "Setting MDT1 \"failover.node\""
2027 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
2028 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2031 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
2032 error_noexit "Setting MDT1 \"lov.stripesize\""
2036 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
2037 error_noexit "Setting MDT1 \"failover.node\""
2040 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2041 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2044 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2045 error_noexit "Setting MDT1 \"lov.stripesize\""
2051 if [ "$writeconf" ]; then
2052 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2053 error_noexit "Mounting the client"
2057 shall_cleanup_lustre=true
2058 $r $LCTL set_param debug="$PTLDEBUG"
2060 # Leave re-enabling this to a separate patch for LU-11558
2061 # t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2062 # error_noexit "verify quota failed"
2066 if $r test -f $tmp/list; then
2068 # There is not a Test Framework API to copy files to or
2069 # from a remote node.
2071 # LU-2393 - do both sorts on same node to ensure locale
2073 local list_file=$tmp/list
2075 if $mdt2_is_available; then
2076 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2077 $r test -f $tmp/list2; then
2078 list_file=$tmp/list2
2079 pushd $tmp/mnt/lustre/striped_dir_old
2081 pushd $tmp/mnt/lustre/remote_dir
2084 pushd $tmp/mnt/lustre
2086 $r cat $list_file | sort -k 6 >$tmp/list.orig
2087 ls -Rni --time-style=+%s | sort -k 6 |
2088 sed 's/\. / /' >$tmp/list || {
2094 # 32-bit and 64-bit clients use different algorithms to
2095 # convert FIDs into inode numbers. Hence, remove the
2096 # inode numbers from the lists, if the original list was
2097 # created on an architecture with different number of
2100 if [ $(t32_bits_per_long $(uname -m)) != \
2101 $(t32_bits_per_long $img_arch) ]; then
2102 echo "Different number of bits per \"long\"" \
2103 "from the disk image"
2104 for list in list.orig list; do
2105 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2109 if ! diff -ub $tmp/list.orig $tmp/list; then
2110 error_noexit "list verification failed"
2114 echo "list verification skipped"
2117 if [ "$dom_upgrade" != "no" ]; then
2118 echo "Check DoM file can be created"
2119 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2120 error_noexit "Verify DoM creation"
2123 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2124 error_noexit "Verify a DoM file"
2127 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2128 count=1 conv=fsync || {
2129 error_noexit "Cannot write to DoM file"
2132 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2133 error_noexit "DoM: bad size after write"
2136 rm $tmp/mnt/lustre/dom
2138 set_persistent_param_and_check mds \
2139 "lod.*MDT0000*.dom_stripesize" \
2140 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2141 error_noexit "Changing \"dom_stripesize\""
2146 if [ "$dne_upgrade" != "no" ]; then
2147 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2148 error_noexit "set striped dir failed"
2152 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2154 pushd $tmp/mnt/lustre
2155 tar -cf - . --exclude=./striped_dir \
2156 --exclude=./striped_dir_old \
2157 --exclude=./remote_dir |
2158 tar -xvf - -C striped_dir 1>/dev/null || {
2159 error_noexit "cp to striped dir failed"
2165 # If it is upgrade from DNE (2.5), then rename the remote dir,
2166 # which is created in 2.5 to striped dir.
2167 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2168 stripe_index=$($LFS getdirstripe -i \
2169 $tmp/mnt/lustre/remote_dir)
2171 [[ $stripe_index -eq 1 ]] || {
2172 error_noexit "get index \"$stripe_index\"" \
2173 "from remote dir failed"
2176 mv $tmp/mnt/lustre/remote_dir \
2177 $tmp/mnt/lustre/striped_dir/ || {
2178 error_noexit "mv remote dir failed"
2183 # If it is upgraded from DNE (2.7), then move the striped dir
2184 # which was created in 2.7 to the new striped dir.
2185 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2186 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2187 stripe_count=$($LFS getdirstripe -c \
2188 $tmp/mnt/lustre/striped_dir_old)
2189 [[ $stripe_count -eq 2 ]] || {
2190 error_noexit "get count $stripe_count" \
2191 "from striped dir failed"
2194 mv $tmp/mnt/lustre/striped_dir_old \
2195 $tmp/mnt/lustre/striped_dir/ || {
2196 error_noexit "mv striped dir failed"
2202 $r $LCTL set_param -n osd*.*.force_sync=1
2203 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2204 error_noexit "dd failed"
2207 rm -rf $tmp/mnt/lustre/tmp_file || {
2208 error_noexit "rm failed"
2212 if $r test -f $tmp/sha1sums; then
2213 # LU-2393 - do both sorts on same node to ensure locale
2215 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2216 if [ "$dne_upgrade" != "no" ]; then
2217 pushd $tmp/mnt/lustre/striped_dir
2219 pushd $tmp/mnt/lustre
2222 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2223 ! -name .lustre -type f -exec sha1sum {} \; |
2224 sort -k 2 >$tmp/sha1sums || {
2226 error_noexit "sha1sum"
2230 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2231 error_noexit "sha1sum verification failed"
2235 # if upgrade from DNE(2.5), then check remote directory
2236 # if upgrade from DNE(2.7), then check striped directory
2237 if $mdt2_is_available &&
2238 [[ "$dne_upgrade" != "no" ]]; then
2239 local new_dir="$tmp/mnt/lustre/striped_dir"
2240 local striped_dir_old="$new_dir/striped_dir_old"
2242 local dir_list="$new_dir/remote_dir"
2243 [[ ! -d $triped_dir_old ]] ||
2244 dir_list+=" $striped_dir_old"
2246 for dir in $dir_list; do
2248 find ! -name .lustre -type f \
2249 -exec sha1sum {} \; |
2250 sort -k 2 >$tmp/sha1sums || {
2252 error_noexit "sha1sum"
2256 if ! diff -ub $tmp/sha1sums.orig \
2258 error_noexit "sha1sum $dir" \
2265 echo "sha1sum verification skipped"
2268 if [ "$dne_upgrade" != "no" ]; then
2269 rm -rf $tmp/mnt/lustre/striped_dir || {
2270 error_noexit "remove remote dir failed"
2275 # migrate files/dirs to remote MDT, then move them back
2276 if [ $(lustre_version_code mds1) -ge $(version_code 2.7.50) -a \
2277 $dne_upgrade != "no" ]; then
2278 $r $LCTL set_param -n \
2279 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2281 echo "test migration"
2282 pushd $tmp/mnt/lustre
2283 for dir in $(find ! -name .lustre ! -name . -type d); do
2284 mdt_index=$($LFS getdirstripe -i $dir)
2285 stripe_cnt=$($LFS getdirstripe -c $dir)
2286 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2287 $LFS migrate -m 1 $dir || {
2289 error_noexit "migrate MDT1 failed"
2295 for dir in $(find ! -name . ! -name .lustre -type d); do
2296 mdt_index=$($LFS getdirstripe -i $dir)
2297 stripe_cnt=$($LFS getdirstripe -c $dir)
2298 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2299 $LFS migrate -m 0 $dir || {
2301 error_noexit "migrate MDT0 failed"
2310 # When adding new data verification tests, please check for
2311 # the presence of the required reference files first, like
2312 # the "sha1sums" and "list" tests above, to avoid the need to
2313 # regenerate every image for each test addition.
2316 nrpcs_orig=$($LCTL get_param \
2317 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2318 error_noexit "Getting \"max_rpcs_in_flight\""
2321 nrpcs=$((nrpcs_orig + 5))
2323 set_persistent_param_and_check client \
2324 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
2325 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
2326 error_noexit "Changing \"max_rpcs_in_flight\""
2330 umount $tmp/mnt/lustre || {
2331 error_noexit "Unmounting the client"
2334 shall_cleanup_lustre=false
2336 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2337 $r $UMOUNT $tmp/mnt/mdt1 || {
2338 error_noexit "Unmounting the MDT2"
2341 if [[ $fstype == zfs ]]; then
2342 $r "$ZPOOL export t32fs-mdt2"
2344 shall_cleanup_mdt1=false
2347 $r $UMOUNT $tmp/mnt/mdt || {
2348 error_noexit "Unmounting the MDT"
2351 if [[ $fstype == zfs ]]; then
2352 $r "$ZPOOL export t32fs-mdt1"
2354 shall_cleanup_mdt=false
2356 $r $UMOUNT $tmp/mnt/ost || {
2357 error_noexit "Unmounting the OST"
2360 if [[ $fstype == zfs ]]; then
2361 $r "$ZPOOL export t32fs-ost1"
2363 shall_cleanup_ost=false
2365 t32_reload_modules $node || {
2366 error_noexit "Reloading modules"
2370 if [[ $fstype == zfs ]]; then
2371 local poolname=t32fs-mdt1
2373 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2374 $ZPOOL import -f -d $tmp $poolname"
2376 # upgrade zpool to latest supported features,
2377 # including dnode quota accounting in 0.7.0
2378 $r "$ZPOOL upgrade $poolname"
2381 # mount a second time to make sure we didnt leave upgrade flag on
2382 $r $TUNEFS --dryrun $mdt_dev || {
2384 error_noexit "tunefs.lustre before remounting the MDT"
2388 mopts=exclude=$fsname-OST0000
2389 if [ $fstype == "ldiskfs" ]; then
2392 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2393 error_noexit "Remounting the MDT"
2396 shall_cleanup_mdt=true
2406 for tarball in $tarballs; do
2407 t32_test $tarball || let "rc += $?"
2411 run_test 32a "Upgrade (not live)"
2419 for tarball in $tarballs; do
2420 t32_test $tarball writeconf || let "rc += $?"
2424 run_test 32b "Upgrade with writeconf"
2431 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2433 for tarball in $tarballs; do
2434 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2435 echo $tarball | grep "1_8" && continue
2436 echo $tarball | grep "2_1" && continue
2438 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2442 run_test 32c "dne upgrade test"
2450 for tarball in $tarballs; do
2451 ff_convert=yes t32_test $tarball || rc=$?
2455 run_test 32d "convert ff test"
2458 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
2459 skip "Need MDS version at least 2.10.56"
2466 for tarball in $tarballs; do
2467 echo $tarball | grep "2_9" || continue
2469 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
2473 run_test 32e "dom upgrade test"
2475 test_33a() { # bug 12333, was test_33
2476 local FSNAME2=test-123
2477 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2480 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2482 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2483 local dev=${SINGLEMDS}_dev
2484 local MDSDEV=${!dev}
2485 is_blkdev $SINGLEMDS $MDSDEV &&
2486 skip_env "mixed loopback and real device not working"
2489 local fs2mdsdev=$(mdsdevname 1_2)
2490 local fs2ostdev=$(ostdevname 1_2)
2491 local fs2mdsvdev=$(mdsvdevname 1_2)
2492 local fs2ostvdev=$(ostvdevname 1_2)
2494 if [ $(facet_fstype mds1) == ldiskfs ]; then
2495 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2498 if combined_mgs_mds; then
2499 local mgs_flag="--mgs"
2502 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
2503 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
2505 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2506 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2507 $fs2ostvdev || exit 10
2509 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2510 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2512 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2513 do_facet mgs "$PERM_CMD timeout=200" ||
2514 error "$PERM_CMD timeout=200 failed"
2516 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
2517 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
2519 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2520 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2523 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2524 $LFS getstripe $MOUNT2/hosts ||
2525 error "$LFS getstripe $MOUNT2/hosts failed"
2530 cleanup_nocli || error "cleanup_nocli failed with $?"
2532 run_test 33a "Mount ost with a large index number"
2534 test_33b() { # was test_34
2537 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2538 # Drop lock cancelation reply during umount
2539 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2540 do_facet client $LCTL set_param fail_loc=0x80000304
2541 #lctl set_param debug=-1
2542 umount_client $MOUNT
2543 cleanup || error "cleanup failed with $?"
2545 run_test 33b "Drop cancel during umount"
2549 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2550 manual_umount_client
2552 do_facet client killall -USR1 multiop
2553 if [ $rc -eq 0 ]; then
2554 error "umount not fail!"
2557 cleanup || error "cleanup failed with rc $?"
2559 run_test 34a "umount with opened file should be fail"
2563 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2564 stop_mds || error "Unable to stop MDS"
2566 manual_umount_client --force || error "mtab after failed umount with $?"
2568 cleanup || error "cleanup failed with $?"
2570 run_test 34b "force umount with failed mds should be normal"
2574 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2575 stop_ost || error "Unable to stop OST1"
2577 manual_umount_client --force || error "mtab after failed umount with $?"
2579 cleanup || error "cleanup failed with $?"
2581 run_test 34c "force umount with failed ost should be normal"
2583 test_35a() { # bug 12459
2586 DBG_SAVE="`$LCTL get_param -n debug`"
2587 $LCTL set_param debug="ha"
2589 log "Set up a fake failnode for the MDS"
2591 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2592 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2594 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2595 do_facet mgs "$PERM_CMD \
2596 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2597 error "Setting mdc.*${device}*.import=connection=\
2598 $(h2nettype $FAKENID) failed."
2600 do_facet mgs "$PERM_CMD \
2601 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2602 error "Setting ${device}.failover.node=\
2603 $(h2nettype $FAKENID) failed."
2605 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2608 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2611 log "Stopping the MDT: $device"
2612 stop_mdt 1 || error "MDT0 stop fail"
2614 df $MOUNT > /dev/null 2>&1 &
2616 log "Restarting the MDT: $device"
2617 start_mdt 1 || error "MDT0 start fail"
2618 log "Wait for df ($DFPID) ... "
2621 $LCTL set_param debug="$DBG_SAVE"
2623 # retrieve from the log the first server that the client tried to
2624 # contact after the connection loss
2625 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2626 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2627 /import_select_connection.*$device-mdc.* using connection/ {
2629 if (\\\$NF ~ /$FAKENID/)
2635 }" $TMP/lustre-log-$TESTNAME.log`
2636 [ "$NEXTCONN" != "0" ] &&
2637 error "Tried to connect to ${NEXTCONN} not last active server"
2638 cleanup || error "cleanup failed with $?"
2639 # remove nid settings
2640 writeconf_or_reformat
2642 run_test 35a "Reconnect to the last active server first"
2644 test_35b() { # bug 18674
2645 remote_mds || skip "local MDS"
2649 $LCTL set_param debug="ha"
2651 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2654 log "Set up a fake failnode for the MDS"
2656 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2657 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2659 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2660 do_facet mgs "$PERM_CMD \
2661 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2662 error "Set mdc.*${device}*.import=connection=\
2663 $(h2nettype $FAKENID) failed"
2665 do_facet mgs "$PERM_CMD \
2666 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2667 error "Set ${device}.failover.node=\
2668 $(h2nettype $FAKENID) failed"
2671 local at_max_saved=0
2672 # adaptive timeouts may prevent seeing the issue
2673 if at_is_enabled; then
2674 at_max_saved=$(at_max_get mds)
2675 at_max_set 0 mds client
2678 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2680 log "Injecting EBUSY on MDS"
2681 # Setting OBD_FAIL_MDS_RESEND=0x136
2682 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2683 error "unable to set param fail_loc=0x80000136"
2685 $LCTL set_param mdc.${FSNAME}*.stats=clear
2687 log "Creating a test file and stat it"
2688 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2689 stat $MOUNT/$tdir/$tfile
2691 log "Stop injecting EBUSY on MDS"
2692 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2693 error "unable to set param fail_loc=0"
2694 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2697 # restore adaptive timeout
2698 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2700 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2702 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2703 awk '/mds_connect/{print $2}')
2705 # retrieve from the log if the client has ever tried to
2706 # contact the fake server after the loss of connection
2707 FAILCONN=`awk "BEGIN {ret = 0;}
2708 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2710 if (\\\$NF ~ /$FAKENID/) {
2715 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2717 [ "$FAILCONN" == "0" ] &&
2718 error "The client reconnection has not been triggered"
2719 [ "$FAILCONN" == "2" ] &&
2720 error "Primary server busy, client reconnect to failover failed"
2723 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2724 # Reconnects are supposed to be rate limited to one every 5s
2725 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2726 error "Too many reconnects $CONNCNT"
2728 cleanup || error "cleanup failed with $?"
2729 # remove nid settings
2730 writeconf_or_reformat
2732 run_test 35b "Continue reconnection retries, if the active server is busy"
2735 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2737 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2741 local FSNAME2=test1234
2742 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2744 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2746 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2747 is_blkdev $SINGLEMDS $MDSDEV &&
2748 skip_env "mixed loopback and real device not working"
2751 local fs2mdsdev=$(mdsdevname 1_2)
2752 local fs2ostdev=$(ostdevname 1_2)
2753 local fs3ostdev=$(ostdevname 2_2)
2754 local fs2mdsvdev=$(mdsvdevname 1_2)
2755 local fs2ostvdev=$(ostvdevname 1_2)
2756 local fs3ostvdev=$(ostvdevname 2_2)
2759 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2760 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2761 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2762 # different one than the default value here.
2763 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2764 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2765 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2766 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2768 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2769 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2770 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2771 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2772 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2774 sleep 5 # until 11778 fixed
2776 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2778 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2779 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2780 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2781 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2782 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2783 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2784 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2785 DFTOTAL=$(echo $STRING | cut -d, -f1)
2786 DFUSED=$(echo $STRING | cut -d, -f2)
2787 DFAVAIL=$(echo $STRING | cut -d, -f3)
2788 DFFREE=$(($DFTOTAL - $DFUSED))
2790 ALLOWANCE=$((64 * $OSTCOUNT))
2792 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2793 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2794 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2797 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2798 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2799 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2802 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2803 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2804 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2809 stop fs3ost -f || error "unable to stop OST3"
2810 stop fs2ost -f || error "unable to stop OST2"
2811 stop fs2mds -f || error "unable to stop second MDS"
2812 unload_modules_conf || error "unable unload modules"
2815 run_test 36 "df report consistency on OSTs with different block size"
2818 local mntpt=$(facet_mntpt $SINGLEMDS)
2819 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2820 local mdsdev_sym="$TMP/sym_mdt.img"
2821 local opts=$MDS_MOUNT_OPTS
2824 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2825 skip "ldiskfs only test"
2828 echo "MDS : $mdsdev"
2829 echo "SYMLINK : $mdsdev_sym"
2830 do_facet $SINGLEMDS rm -f $mdsdev_sym
2832 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2834 echo "mount symlink device - $mdsdev_sym"
2836 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2837 opts=$(csa_add "$opts" -o loop)
2841 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2842 $mdsdev_sym $mntpt 2>&1)
2845 echo mount_op=$mount_op
2847 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2849 if $(echo $mount_op | grep -q "unable to set tunable"); then
2850 error "set tunables failed for symlink device"
2853 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2855 run_test 37 "verify set tunables works for symlink device"
2857 test_38() { # bug 14222
2858 local fstype=$(facet_fstype $SINGLEMDS)
2859 local mntpt=$(facet_mntpt $SINGLEMDS)
2864 local SRC="/etc /bin"
2865 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2866 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2867 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2868 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2869 error "copying $SRC to $DIR/$tdir"
2871 umount_client $MOUNT || error "umount_client $MOUNT failed"
2872 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2873 stop_mds || error "Unable to stop MDS"
2874 log "delete lov_objid file on MDS"
2876 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2878 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2880 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2882 # check create in mds_lov_connect
2883 start_mds || error "unable to start MDS"
2884 mount_client $MOUNT || error "mount_client $MOUNT failed"
2886 [ $V ] && log "verifying $DIR/$tdir/$f"
2887 diff -q $f $DIR/$tdir/$f || ERROR=y
2889 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2890 if [ "$ERROR" = "y" ]; then
2891 # check it's updates in sync
2892 umount_client $MOUNT
2894 mount_fstype $SIGNLEMDS
2895 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2896 unmount_fstype $SINGLEMDS
2897 error "old and new files are different after connect" || true
2899 touch $DIR/$tdir/f2 || error "f2 file create failed"
2901 # check it's updates in sync
2902 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2905 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2907 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2908 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2910 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2912 start_mds || error "unable to start MDS"
2913 mount_client $MOUNT || error "mount_client $MOUNT failed"
2915 [ $V ] && log "verifying $DIR/$tdir/$f"
2916 diff -q $f $DIR/$tdir/$f || ERROR=y
2918 touch $DIR/$tdir/f3 || error "f3 file create failed"
2919 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2920 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2922 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2923 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2924 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2926 [ "$ERROR" = "y" ] &&
2927 error "old and new files are different after sync" || true
2929 log "files compared the same"
2930 cleanup || error "cleanup failed with $?"
2932 run_test 38 "MDS recreates missing lov_objid file from OST data"
2937 cleanup || error "cleanup failed with $?"
2938 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2939 error "memory leak detected" || true
2941 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2943 test_40() { # bug 15759
2944 start_ost || error "Unable to start OST1"
2945 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2946 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2948 cleanup || error "cleanup failed with rc $?"
2950 run_test 40 "race during service thread startup"
2952 test_41a() { #bug 14134
2953 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2954 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2955 skip "Loop devices does not work with nosvc option"
2958 combined_mgs_mds || skip "needs combined MGT and MDT device"
2960 start_mdt 1 -o nosvc -n
2961 if [ $MDSCOUNT -ge 2 ]; then
2962 for num in $(seq 2 $MDSCOUNT); do
2963 start_mdt $num || return
2966 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2967 start_mdt 1 -o nomgs,force
2968 mount_client $MOUNT || error "mount_client $MOUNT failed"
2971 echo "blah blah" > $MOUNT/$tfile
2974 umount_client $MOUNT || error "umount_client $MOUNT failed"
2975 stop ost1 -f || error "unable to stop OST1"
2976 stop_mds || error "Unable to stop MDS"
2977 stop_mds || error "Unable to stop MDS on second try"
2979 run_test 41a "mount mds with --nosvc and --nomgs"
2982 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2983 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2984 skip "Loop devices does not work with nosvc option"
2987 ! combined_mgs_mds && skip "needs combined mgs device"
2991 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2993 start_mdt 1 -o nosvc -n
2994 if [ $MDSCOUNT -ge 2 ]; then
2995 for num in $(seq 2 $MDSCOUNT); do
2996 start_mdt $num || return
2999 start_ost || error "Unable to start OST1"
3000 start_mdt 1 -o nomgs,force
3001 mount_client $MOUNT || error "mount_client $MOUNT failed"
3004 echo "blah blah" > $MOUNT/$tfile
3005 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
3007 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
3008 stop_ost || error "Unable to stop OST1"
3009 stop_mds || error "Unable to stop MDS"
3010 stop_mds || error "Unable to stop MDS on second try"
3012 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
3015 local server_version=$(lustre_version_code $SINGLEMDS)
3016 local oss_list=$(comma_list $(osts_nodes))
3018 [[ $server_version -ge $(version_code 2.6.52) ]] ||
3019 [[ $server_version -ge $(version_code 2.5.26) &&
3020 $server_version -lt $(version_code 2.5.50) ]] ||
3021 [[ $server_version -ge $(version_code 2.5.4) &&
3022 $server_version -lt $(version_code 2.5.11) ]] ||
3023 skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"
3025 # ensure mds1 ost1 have been created even if running sub-test standalone
3028 cleanup || error "cleanup failed"
3030 # using directly mount command instead of start() function to avoid
3031 # any side effect of // with others/externals tools/features
3032 # ("zpool import", ...)
3034 # MDT concurrent start
3036 LOAD_MODULES_REMOTE=true load_modules
3037 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
3038 error "MDT concurrent start: libcfs module not loaded"
3040 local mds1dev=$(mdsdevname 1)
3041 local mds1mnt=$(facet_mntpt mds1)
3042 local mds1fstype=$(facet_fstype mds1)
3043 local mds1opts=$MDS_MOUNT_OPTS
3045 if [ $mds1fstype == ldiskfs ] &&
3046 ! do_facet mds1 test -b $mds1dev; then
3047 mds1opts=$(csa_add "$mds1opts" -o loop)
3049 if [[ $mds1fstype == zfs ]]; then
3050 import_zpool mds1 || return ${PIPESTATUS[0]}
3053 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3054 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
3056 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
3059 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
3063 do_facet mds1 "$LCTL set_param fail_loc=0x0"
3064 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3065 echo "1st MDT start succeed"
3066 echo "2nd MDT start failed with $rc2"
3067 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3068 echo "1st MDT start failed with $rc"
3069 echo "2nd MDT start succeed"
3072 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
3075 if [ $MDSCOUNT -ge 2 ]; then
3076 for num in $(seq 2 $MDSCOUNT); do
3077 start_mdt $num || return
3081 # OST concurrent start
3083 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
3084 error "OST concurrent start: libcfs module not loaded"
3086 local ost1dev=$(ostdevname 1)
3087 local ost1mnt=$(facet_mntpt ost1)
3088 local ost1fstype=$(facet_fstype ost1)
3089 local ost1opts=$OST_MOUNT_OPTS
3091 if [ $ost1fstype == ldiskfs ] &&
3092 ! do_facet ost1 test -b $ost1dev; then
3093 ost1opts=$(csa_add "$ost1opts" -o loop)
3095 if [[ $ost1fstype == zfs ]]; then
3096 import_zpool ost1 || return ${PIPESTATUS[0]}
3099 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3100 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
3102 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
3105 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
3109 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3110 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3111 echo "1st OST start succeed"
3112 echo "2nd OST start failed with $rc2"
3113 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3114 echo "1st OST start failed with $rc"
3115 echo "2nd OST start succeed"
3119 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3125 # verify everything ok
3130 error "MDT(s) start failed"
3138 error "OST(s) start failed"
3146 error "client start failed"
3153 error "client mount failed"
3157 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3159 test_42() { #bug 14693
3163 check_mount || error "client was not mounted"
3165 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3166 PARAM="llite.$FSNAME-*.some_wrong_param"
3168 PARAM="$FSNAME.llite.some_wrong_param"
3171 do_facet mgs $PERM_CMD $PARAM=10
3172 umount_client $MOUNT ||
3173 error "unmounting client failed with invalid llite param"
3174 mount_client $MOUNT ||