8 PTLDEBUG=${PTLDEBUG:--1}
9 LUSTRE=${LUSTRE:-$(dirname $0)/..}
10 . $LUSTRE/tests/test-framework.sh
14 # tool to create lustre filesystem images
15 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 32newtarball"
17 # bug number for skipped test: LU-11915
18 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 110 115"
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
22 # bug number for skipped tests: LU-9795 (all below)
23 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 0 31 32a 32d 35a"
24 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 53a 53b 54b 76a 76b"
25 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76c 76d 78 103"
28 if ! combined_mgs_mds; then
29 # bug number for skipped test: LU-11991 LU-11990
30 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 32a 32b 32c 32d 32e 66"
31 # bug number for skipped test: LU-9897 LU-12032
32 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 84 123F"
36 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69 106 111"
40 # use small MDS + OST size to speed formatting time
41 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
42 # STORED_MDSSIZE is used in test_18
43 STORED_MDSSIZE=$MDSSIZE
44 STORED_OSTSIZE=$OSTSIZE
46 [ "$mds1_FSTYPE" = zfs ] && MDSSIZE=400000
48 [ "$ost1_FSTYPE" = zfs ] && OSTSIZE=400000
58 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
59 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
60 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
64 require_dsh_mds || exit 0
65 require_dsh_ost || exit 0
70 # The MGS must be started before the OSTs for a new fs, so start
71 # and stop to generate the startup logs.
74 wait_osc_import_state mds ost FULL
79 reformat_and_config() {
81 if ! combined_mgs_mds ; then
87 writeconf_or_reformat() {
88 # There are at most 2 OSTs for write_conf test
89 # who knows if/where $TUNEFS is installed?
90 # Better reformat if it fails...
91 writeconf_all $MDSCOUNT 2 ||
92 { echo "tunefs failed, reformatting instead" &&
93 reformat_and_config && return 0; }
102 echo "start mgs service on $(facet_active_host mgs)"
103 start mgs $(mgsdevname) $MGS_MOUNT_OPTS $@
109 local dev=$(mdsdevname $num)
112 echo "start mds service on `facet_active_host $facet`"
113 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
119 local dev=$(mdsdevname $num)
122 echo "stop mds service on `facet_active_host $facet`"
123 # These tests all use non-failover stop
124 stop $facet -f || return 97
130 for num in $(seq $MDSCOUNT); do
131 start_mdt $num $@ || return 94
136 if ! combined_mgs_mds ; then
144 for num in $(seq $MDSCOUNT); do
145 stop_mdt $num || return 97
150 echo "stop mgs service on `facet_active_host mgs`"
151 # These tests all use non-failover stop
152 stop mgs -f || return 97
156 echo "start ost1 service on `facet_active_host ost1`"
157 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
161 echo "stop ost1 service on `facet_active_host ost1`"
162 # These tests all use non-failover stop
163 stop ost1 -f || return 98
167 echo "start ost2 service on `facet_active_host ost2`"
168 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
172 echo "stop ost2 service on `facet_active_host ost2`"
173 # These tests all use non-failover stop
174 stop ost2 -f || return 93
181 echo "mount $FSNAME ${mountopt:+with opts $mountopt} on $mountpath....."
182 zconf_mount $HOSTNAME $mountpath $mountopt || return 96
188 echo "umount lustre on $mountpath....."
189 zconf_umount $HOSTNAME $mountpath $@ || return 97
192 manual_umount_client(){
195 echo "manual umount lustre on ${MOUNT}...."
196 do_facet client "umount ${FORCE} $MOUNT"
202 start_mds || error "MDT start failed"
203 start_ost || error "Unable to start OST1"
204 mount_client $MOUNT || error "client start failed"
205 client_up || error "client_up failed"
214 unload_modules_conf () {
215 if combined_mgs_mds || ! local_mode; then
216 unload_modules || return 1
221 stop_ost || return 202
222 stop_mds || return 201
223 unload_modules_conf || return 203
228 [ "x$1" != "x" ] && force='-f'
229 umount_client $MOUNT $force|| return 200
230 cleanup_nocli || return $?
235 echo "umount $MOUNT2 ..."
236 umount $MOUNT2 || true
237 echo "stopping fs2mds ..."
238 stop fs2mds -f || true
239 echo "stopping fs2ost ..."
240 stop fs2ost -f || true
244 do_facet client "cp /etc/passwd $DIR/a" || return 71
245 do_facet client "rm $DIR/a" || return 72
246 # make sure lustre is actually mounted (touch will block,
247 # but grep won't, so do it after)
248 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
249 echo "setup single mount lustre success"
253 do_facet client "touch $DIR/a" || return 71
254 do_facet client "rm $DIR/a" || return 72
255 do_facet client "touch $DIR2/a" || return 73
256 do_facet client "rm $DIR2/a" || return 74
257 echo "setup double mount lustre success"
261 cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
264 if [ "$ONLY" == "setup" ]; then
269 if [ "$ONLY" == "cleanup" ]; then
276 #create single point mountpoint
282 check_mount || error "check_mount failed"
283 cleanup || error "cleanup failed with $?"
285 run_test 0 "single mount setup"
288 start_mds || error "MDS start failed"
289 start_ost || error "unable to start OST"
290 echo "start ost second time..."
291 start_ost && error "2nd OST start should fail"
292 mount_client $MOUNT || error "client start failed"
293 check_mount || error "check_mount failed"
294 cleanup || error "cleanup failed with $?"
296 run_test 1 "start up ost twice (should return errors)"
299 start_mds || error "MDT start failed"
300 echo "start mds second time.."
301 start_mds && error "2nd MDT start should fail"
302 start_ost || error "OST start failed"
303 mount_client $MOUNT || error "mount_client failed to start client"
304 check_mount || error "check_mount failed"
305 cleanup || error "cleanup failed with $?"
307 run_test 2 "start up mds twice (should return err)"
311 #mount.lustre returns an error if already in mtab
312 mount_client $MOUNT && error "2nd client mount should fail"
313 check_mount || error "check_mount failed"
314 cleanup || error "cleanup failed with $?"
316 run_test 3 "mount client twice (should return err)"
320 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
321 stop_ost || error "Unable to stop OST1"
322 umount_client $MOUNT -f || error “unmount $MOUNT failed”
325 # ok for ost to fail shutdown
326 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
327 error "cleanup failed with $?"
330 run_test 4 "force cleanup ost, then cleanup"
332 test_5a() { # was test_5
334 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
335 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
337 stop_mds || error "Unable to stop MDS"
339 # cleanup may return an error from the failed
340 # disconnects; for now I'll consider this successful
341 # if all the modules have unloaded.
345 echo "killing umount"
346 kill -TERM $UMOUNT_PID
347 echo "waiting for umount to finish"
349 if grep " $MOUNT " /proc/mounts; then
350 echo "test 5: /proc/mounts after failed umount"
354 echo "killing umount"
355 kill -TERM $UMOUNT_PID
356 echo "waiting for umount to finish"
358 grep " $MOUNT " /proc/mounts &&
359 error "/proc/mounts after second umount"
362 # manual_mount_client may fail due to umount succeeding above
364 # stop_mds is a no-op here, and should not fail
365 cleanup_nocli || error "cleanup_nocli failed with $?"
366 # df may have lingering entry
368 # mtab may have lingering entry
372 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
374 grep -q $MOUNT" " /etc/mtab || break
375 echo "Waiting /etc/mtab updated ... "
376 WAIT=$(( WAIT + sleep))
378 [ "$WAIT" -eq "$MAX_WAIT" ] &&
379 error "/etc/mtab is not updated in $WAIT secs"
380 echo "/etc/mtab updated in $WAIT secs"
382 run_test 5a "force cleanup mds, then cleanup"
390 grep " $MOUNT " /etc/mtab &&
391 error false "unexpected entry in mtab before mount" && return 10
393 start_ost || error "OST start failed"
394 if ! combined_mgs_mds ; then
395 trap cleanup_5b EXIT ERR
396 start_mds || error "MDS start failed"
400 mount_client $MOUNT && error "mount_client $MOUNT should fail"
401 grep " $MOUNT " /etc/mtab &&
402 error "$MOUNT entry in mtab after failed mount"
404 # stop_mds is a no-op here, and should not fail
405 cleanup_nocli || error "cleanup_nocli failed with $?"
406 if ! combined_mgs_mds ; then
410 run_test 5b "Try to start a client with no MGS (should return errs)"
413 grep " $MOUNT " /etc/mtab &&
414 error false "unexpected entry in mtab before mount" && return 10
416 start_mds || error "MDS start failed"
417 start_ost || error "OST start failed"
418 local oldfs="${FSNAME}"
419 FSNAME="wrong.${FSNAME}"
420 mount_client $MOUNT || :
422 grep " $MOUNT " /etc/mtab &&
423 error "$MOUNT entry in mtab after failed mount"
425 cleanup_nocli || error "cleanup_nocli failed with $?"
427 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
430 grep " $MOUNT " /etc/mtab &&
431 error "unexpected entry in mtab before mount"
433 start_ost || error "OST start failed"
434 start_mds || error "MDS start failed"
435 stop_ost -f || error "Unable to stop OST1"
436 mount_client $MOUNT || error "mount_client $MOUNT failed"
437 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
438 cleanup_nocli || error "cleanup_nocli failed with $?"
439 ! grep " $MOUNT " /etc/mtab ||
440 error "$MOUNT entry in mtab after unmount"
442 run_test 5d "mount with ost down"
445 grep " $MOUNT " /etc/mtab &&
446 error false "unexpected entry in mtab before mount" && return 10
448 start_mds || error "MDS start failed"
449 start_ost || error "OST start failed"
451 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
452 do_facet client "$LCTL set_param fail_loc=0x80000506"
453 mount_client $MOUNT || echo "mount failed (not fatal)"
454 cleanup || error "cleanup failed with $?"
455 grep " $MOUNT " /etc/mtab &&
456 error "$MOUNT entry in mtab after unmount"
459 run_test 5e "delayed connect, don't crash (bug 10268)"
462 combined_mgs_mds && skip "needs separate mgs and mds"
464 grep " $MOUNT " /etc/mtab &&
465 error false "unexpected entry in mtab before mount" && return 10
468 start_ost || error "OST start failed"
469 mount_client $MOUNT &
471 echo client_mount pid is $pid
475 if ! ps -f -p $pid >/dev/null; then
478 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
479 error "mount returns $rc, expected to hang"
481 cleanup || error "cleanup failed with $?"
486 start_mds || error "start MDS failed"
488 # mount should succeed after start mds
490 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
491 cleanup || error "final call to cleanup failed with rc $?"
493 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
497 [ "$CLIENT_VERSION" -lt $(version_code 2.9.53) ] &&
498 skip "automount of debugfs missing before 2.9.53"
499 umount /sys/kernel/debug
500 $LCTL get_param -n devices | egrep -v "error" && \
501 error "lctl can't access debugfs data"
502 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
504 run_test 5g "handle missing debugfs"
510 #define OBD_FAIL_MDS_FS_SETUP 0x135
511 do_facet mds1 "$LCTL set_param fail_loc=0x80000135"
512 start_mdt 1 && error "start mdt should fail"
513 start_mdt 1 || error "start mdt failed"
514 client_up || error "client_up failed"
517 run_test 5h "start mdt failure at mdt_fs_setup()"
523 #define OBD_FAIL_QUOTA_INIT 0xA05
524 do_facet mds1 "$LCTL set_param fail_loc=0x80000A05"
525 start_mdt 1 && error "start mdt should fail"
526 start_mdt 1 || error "start mdt failed"
527 client_up || error "client_up failed"
530 run_test 5i "start mdt failure at mdt_quota_init()"
535 mount_client $MOUNT || error "mount_client $MOUNT failed"
536 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
537 cleanup || error "cleanup failed with rc $?"
539 run_test 6 "manual umount, then mount again"
544 cleanup_nocli || error "cleanup_nocli failed with $?"
546 run_test 7 "manual umount, then cleanup"
550 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
551 check_mount2 || error "check_mount2 failed"
552 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
553 cleanup || error "cleanup failed with rc $?"
555 run_test 8 "double mount setup"
558 start_ost || error "OST start failed"
560 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
561 error "do_facet ost1 set_param inode trace failed."
562 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
563 error "do_facet ost1 set_param debug mds ost failed."
565 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
566 if [ "$CHECK_PTLDEBUG" ] && { \
567 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
568 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
569 echo "lnet.debug success"
571 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
573 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
574 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
575 echo "lnet.subsystem_debug success"
577 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
579 stop_ost || error "Unable to stop OST1"
581 run_test 9 "test ptldebug and subsystem for mkfs"
584 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
585 # But with new MDS stack we don't care about the mode of local objects
586 # anymore, so this test is removed. See bug 22944 for more details.
590 if [ "$mds1_FSTYPE" != ldiskfs ]; then
591 skip "ldiskfs only test"
595 check_mount || error "check_mount failed"
596 cleanup || error "cleanup failed with rc $?"
598 echo "Remove mds config log"
599 if ! combined_mgs_mds ; then
603 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
604 $(mgsdevname) || return \$?" ||
605 error "do_facet mgs failed with $?"
607 if ! combined_mgs_mds ; then
611 start_ost || error "OST start failed"
612 start_mds && error "MDS start succeeded, but should fail"
615 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
618 if [ "$mds1_FSTYPE" != ldiskfs ]; then
619 skip "ldiskfs only test"
622 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
627 # check if current MDSSIZE is large enough
628 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
629 log "use MDSSIZE=$MDSSIZE"
631 # check if the global config has a large enough MDSSIZE
632 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
633 [ $STORED_MDSSIZE -ge $MIN ] &&
634 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
635 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
637 # check if the block device is large enough
638 is_blkdev $SINGLEMDS $MDSDEV $MIN
639 local large_enough=$?
640 if [ -n "$OK" ]; then
641 [ $large_enough -ne 0 ] && OK=""
643 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
644 log "use device $MDSDEV with MIN=$MIN"
647 # check if a loopback device has enough space for fs metadata (5%)
649 if [ -z "$OK" ]; then
650 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
651 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
652 awk '($1 != "Filesystem") { print $4 }')
653 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
654 OK=1 && myMDSSIZE=$MIN &&
655 log "use file $MDSDEV with MIN=$MIN"
658 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS"
660 echo "mount mds with large journal..."
662 local OLD_MDSSIZE=$MDSSIZE
666 echo "mount lustre system..."
668 check_mount || error "check_mount failed"
670 echo "check journal size..."
671 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
672 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
673 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
675 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
678 cleanup || error "cleanup failed with rc $?"
683 run_test 18 "check mkfs creates large journals"
686 start_mds || error "MDS start failed"
687 stop_mds || error "Unable to stop MDS"
689 run_test 19a "start/stop MDS without OSTs"
692 start_ost || error "Unable to start OST1"
693 stop_ost -f || error "Unable to stop OST1"
695 run_test 19b "start/stop OSTs without MDS"
698 # first format the ost/mdt
699 start_mds || error "MDS start failed"
700 start_ost || error "Unable to start OST1"
701 mount_client $MOUNT || error "mount_client $MOUNT failed"
702 check_mount || error "check_mount failed"
703 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
704 mount_client $MOUNT remount,ro || error "remount client with ro failed"
705 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
706 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
707 mount_client $MOUNT remount,rw || error "remount client with rw failed"
708 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
709 MCNT=$(grep -c $MOUNT' ' /etc/mtab)
710 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
712 stop_mds || error "Unable to stop MDS"
713 stop_ost || error "Unable to stop OST1"
715 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
718 start_mds || error "MDS start failed"
719 start_ost || error "unable to start OST1"
720 wait_osc_import_state mds ost FULL
721 stop_ost || error "unable to stop OST1"
722 stop_mds || error "unable to stop MDS"
724 run_test 21a "start mds before ost, stop ost first"
727 start_ost || error "unable to start OST1"
728 start_mds || error "MDS start failed"
729 wait_osc_import_state mds ost FULL
730 stop_mds || error "unable to stop MDS"
731 stop_ost || error "unable to stop OST1"
733 run_test 21b "start ost before mds, stop mds first"
736 start_ost || error "Unable to start OST1"
737 start_mds || error "MDS start failed"
738 start_ost2 || error "Unable to start OST2"
739 wait_osc_import_state mds ost2 FULL
740 stop_ost || error "Unable to stop OST1"
741 stop_ost2 || error "Unable to stop OST2"
742 stop_mds || error "Unable to stop MDS"
743 #writeconf to remove all ost2 traces for subsequent tests
744 writeconf_or_reformat
746 run_test 21c "start mds between two osts, stop mds last"
749 combined_mgs_mds && skip "need separate mgs device"
754 start_mgs || error "unable to start MGS"
755 start_ost || error "unable to start OST1"
756 start_ost2 || error "unable to start OST2"
757 start_mds || error "MDS start failed"
758 wait_osc_import_state mds ost2 FULL
760 local zkeeper=${KEEP_ZPOOL}
761 stack_trap "KEEP_ZPOOL=$zkeeper" EXIT
764 stop_ost || error "Unable to stop OST1"
765 stop_ost2 || error "Unable to stop OST2"
766 stop_mds || error "Unable to stop MDS"
768 #writeconf to remove all ost2 traces for subsequent tests
769 writeconf_or_reformat
770 KEEP_ZPOOL="${zkeeper}"
772 start_mgs || error "unable to start MGS"
774 run_test 21d "start mgs then ost and then mds"
777 MGSNID="$saved_mgsnid"
779 echo "stopping fs2mgs ..."
780 stop $fs2mgs -f || true
783 test_21e() { # LU-5863
784 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
785 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
786 skip_env "mixed loopback and real device not working"
789 local fs2mdsdev=$(mdsdevname 1_2)
790 local fs2ostdev=$(ostdevname 1_2)
791 local fs3ostdev=$(ostdevname 2_2)
793 local fs2mdsvdev=$(mdsvdevname 1_2)
794 local fs2ostvdev=$(ostvdevname 1_2)
795 local fs3ostvdev=$(ostvdevname 2_2)
797 # temporarily use fs3ost as fs2mgs
799 local fs2mgsdev=$fs3ostdev
800 local fs2mgsvdev=$fs3ostvdev
802 local fsname=test1234
804 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
805 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
806 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
807 error "start fs2mgs failed"
809 local saved_mgsnid="$MGSNID"
810 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
812 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
813 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
814 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
815 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
817 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
818 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
820 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
821 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
822 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
826 run_test 21e "separate MGS and MDS"
829 start_mds || error "MDS start failed"
831 echo "Client mount with ost in logs, but none running"
832 start_ost || error "unable to start OST1"
833 # wait until mds connected to ost and open client connection
834 wait_osc_import_state mds ost FULL
835 stop_ost || error "unable to stop OST1"
836 mount_client $MOUNT || error "mount_client $MOUNT failed"
837 # check_mount will block trying to contact ost
838 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
839 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
840 umount_client $MOUNT -f
843 echo "Client mount with a running ost"
844 start_ost || error "unable to start OST1"
846 # if gss enabled, wait full time to let connection from
847 # mds to ost be established, due to the mismatch between
848 # initial connect timeout and gss context negotiation timeout.
849 # This perhaps could be remove after AT landed.
850 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
851 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
853 mount_client $MOUNT || error "mount_client $MOUNT failed"
854 wait_osc_import_state mds ost FULL
855 wait_osc_import_ready client ost
856 check_mount || error "check_mount failed"
859 cleanup || error "cleanup failed with rc $?"
861 run_test 22 "start a client before osts (should return errs)"
863 test_23a() { # was test_23
866 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
867 # force down client so that recovering mds waits for reconnect
868 local running=$(grep -c $MOUNT /proc/mounts) || true
869 if [ $running -ne 0 ]; then
870 echo "Stopping client $MOUNT (opts: -f)"
874 # enter recovery on failed mds
875 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
876 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
877 # try to start a new client
878 mount_client $MOUNT &
880 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
881 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
882 grep -v grep | awk '{print $2}')
883 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
885 ps --ppid $MOUNT_LUSTRE_PID
886 echo "waiting for mount to finish"
888 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
889 # SIGTERM works but it does not spread to offspring processses
890 kill -s TERM $MOUNT_PID
891 kill -s TERM $MOUNT_LUSTRE_PID
892 # we can not wait $MOUNT_PID because it is not a child of this shell
898 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
900 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
901 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
904 [ -z "$PID1" -a -z "$PID2" ] && break
905 echo "waiting for mount to finish ... "
906 WAIT=$(( WAIT + sleep))
908 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
909 error "MOUNT_PID $MOUNT_PID and "\
910 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
913 cleanup || error "cleanup failed with rc $?"
915 run_test 23a "interrupt client during recovery mount delay"
917 test_23b() { # was test_23
918 start_mds || error "MDS start failed"
919 start_ost || error "Unable to start OST1"
920 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
921 $LCTL set_param fail_loc=0x80000313
923 cleanup || error "cleanup failed with rc $?"
925 run_test 23b "Simulate -EINTR during mount"
928 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
930 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
931 is_blkdev $SINGLEMDS $MDSDEV &&
932 skip_env "mixed loopback and real device not working"
935 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
937 local fs2mdsdev=$(mdsdevname 1_2)
938 local fs2ostdev=$(ostdevname 1_2)
939 local fs2mdsvdev=$(mdsvdevname 1_2)
940 local fs2ostvdev=$(ostvdevname 1_2)
943 # LU-9733 test fsname started with numbers as well
944 local FSNAME2=969362ae
946 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
947 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
949 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
950 --reformat $fs2ostdev $fs2ostvdev || exit 10
953 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
954 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
955 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
956 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
958 # LU-9733 test fsname started with numbers
959 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
960 changelog_register -n) ||
961 error "register changelog failed"
963 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
964 changelog_deregister $cl_user ||
965 error "deregister changelog failed"
967 check_mount || error "check_mount failed"
968 # files written on 1 should not show up on 2
969 cp /etc/passwd $DIR/$tfile
971 [ -e $MOUNT2/$tfile ] && error "File bleed"
974 cp /etc/passwd $MOUNT2/$tfile ||
975 error "cp /etc/passwd $MOUNT2/$tfile failed"
976 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
977 # 2 is actually mounted
978 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
980 facet_failover fs2mds
981 facet_failover fs2ost
984 # the MDS must remain up until last MDT
986 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
987 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
988 [ -z "$MDS" ] && error "No MDT"
990 cleanup_nocli || error "cleanup_nocli failed with rc $?"
992 run_test 24a "Multiple MDTs on a single node"
995 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
997 skip "needs combined MGT and MDT device"
999 if [ -z "$fs2mds_DEV" ]; then
1000 local dev=${SINGLEMDS}_dev
1001 local MDSDEV=${!dev}
1002 is_blkdev $SINGLEMDS $MDSDEV &&
1003 skip_env "mixed loopback and real device not working"
1006 local fs2mdsdev=$(mdsdevname 1_2)
1007 local fs2mdsvdev=$(mdsvdevname 1_2)
1009 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1010 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1012 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && {
1014 error "start MDS should fail"
1017 cleanup || error "cleanup failed with rc $?"
1019 run_test 24b "Multiple MGSs on a single node (should return err)"
1023 check_mount || error "check_mount failed"
1024 local MODULES=$($LCTL modules | awk '{ print $2 }')
1025 rmmod $MODULES 2>/dev/null || true
1026 cleanup || error "cleanup failed with $?"
1028 run_test 25 "Verify modules are referenced"
1032 # we need modules before mount for sysctl, so make sure...
1033 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1034 #define OBD_FAIL_MDS_FS_SETUP 0x135
1035 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1036 start_mds && error "MDS started but should not have started"
1037 $LCTL get_param -n devices
1038 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1039 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1040 # start mds to drop writeconf setting
1041 start_mds || error "Unable to start MDS"
1042 stop_mds || error "Unable to stop MDS"
1043 unload_modules_conf || error "unload_modules_conf failed with $?"
1045 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1049 start_ost || error "Unable to start OST1"
1050 start_mds || error "Unable to start MDS"
1051 echo "Requeue thread should have started: "
1052 ps -e | grep ll_cfg_requeue
1053 set_persistent_param_and_check ost1 \
1054 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1055 "$FSNAME-OST0000.ost.client_cache_seconds"
1056 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1058 run_test 27a "Reacquire MGS lock if OST started first"
1063 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1064 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1066 facet_failover $SINGLEMDS
1067 set_persistent_param_and_check $SINGLEMDS \
1068 "mdt.$device.identity_acquire_expire" \
1069 "$device.mdt.identity_acquire_expire"
1070 set_persistent_param_and_check client \
1071 "mdc.$device-mdc-*.max_rpcs_in_flight" \
1072 "$device.mdc.max_rpcs_in_flight"
1074 cleanup || error "cleanup failed with $?"
1076 run_test 27b "Reacquire MGS lock after failover"
1078 test_28A() { # was test_28
1081 local TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1082 local PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1083 local orig=$($LCTL get_param -n $TEST)
1084 local max=$($LCTL get_param -n \
1085 llite.$FSNAME-*.max_read_ahead_per_file_mb)
1087 orig=${orig%%.[0-9]*}
1089 echo "ORIG:$orig MAX:$max"
1090 [[ $max -le $orig ]] && orig=$((max - 3))
1091 echo "ORIG:$orig MAX:$max"
1093 local final=$((orig + 1))
1095 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1096 final=$((final + 1))
1097 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1098 umount_client $MOUNT || error "umount_client $MOUNT failed"
1099 mount_client $MOUNT || error "mount_client $MOUNT failed"
1101 local result=$($LCTL get_param -n $TEST)
1103 if [ $result -ne $final ]; then
1104 error "New config not seen: wanted $final got $result"
1106 echo "New config success: got $result"
1108 set_persistent_param_and_check client "$TEST" "$PARAM" $orig
1109 cleanup || error "cleanup failed with rc $?"
1111 run_test 28A "permanent parameter setting"
1113 test_28a() { # LU-4221
1114 [[ "$OST1_VERSION" -ge $(version_code 2.5.52) ]] ||
1115 skip "Need OST version at least 2.5.52"
1116 [ "$ost1_FSTYPE" = zfs ] &&
1117 skip "LU-4221: no such proc params for ZFS OSTs"
1124 local device="$FSNAME-OST0000"
1128 # In this test we will set three kinds of proc parameters with
1129 # lctl set_param -P or lctl conf_param:
1130 # 1. non-symlink ones in the OFD
1131 # 2. non-symlink ones in the OSD
1134 # prepare a non-symlink parameter in the OFD
1135 name="client_cache_seconds"
1136 param="$device.ost.$name"
1137 cmd="obdfilter.$device.$name"
1139 # permanently setting the parameter in the OFD
1140 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1142 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1143 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1146 # prepare a non-symlink parameter in the OSD
1148 param="$device.osd.$name"
1149 cmd="osd-*.$device.$name"
1151 # conf_param the parameter in the OSD
1152 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1153 new=$(((old + 1) % 2))
1154 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1155 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1157 cleanup || error "cleanup failed with $?"
1159 run_test 28a "set symlink parameters permanently with lctl"
1162 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
1163 setup_noconfig > /dev/null 2>&1
1164 start_ost2 || error "Unable to start OST2"
1167 local PARAM="$FSNAME-OST0001.osc.active"
1168 # With lctl set_param -P the value $PROC_ACT will be sent to
1169 # all nodes. The [!M] filter out the ability to set active
1170 # on the MDS servers which is tested with wait_osp_* below.
1171 # For ost_server_uuid that only exist on client so filtering
1173 local PROC_ACT="os[cp].$FSNAME-OST0001-osc-[^M]*.active"
1174 local PROC_UUID="os[cp].$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1176 ACTV=$($LCTL get_param -n $PROC_ACT)
1178 set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
1179 # also check ost_server_uuid status
1180 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1181 if [ -z "$RESULT" ]; then
1182 error "Client not deactivated: $($LCTL get_param \
1185 echo "Live client success: got $RESULT"
1189 wait_osp_active ost ${FSNAME}-OST0001 1 0
1191 # test new client starts deactivated
1192 umount_client $MOUNT || error "umount_client $MOUNT failed"
1193 mount_client $MOUNT || error "mount_client $MOUNT failed"
1195 # the 2nd and 3rd field of ost_server_uuid do not update at the same
1196 # time when using lctl set_param -P
1197 wait_update_facet client \
1198 "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'" \
1200 error "New client start active: $($LCTL get_param -n $PROC_UUID)"
1202 echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
1204 # make sure it reactivates
1205 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1207 umount_client $MOUNT
1208 stop_ost2 || error "Unable to stop OST2"
1209 cleanup_nocli || error "cleanup_nocli failed with $?"
1210 #writeconf to remove all ost2 traces for subsequent tests
1211 writeconf_or_reformat
1213 run_test 29 "permanently remove an OST"
1218 echo Big config llog
1219 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1220 ORIG=$($LCTL get_param -n $TEST)
1221 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1222 for i in ${LIST[@]}; do
1223 set_persistent_param_and_check client "$TEST" \
1224 "$FSNAME.llite.max_read_ahead_whole_mb" $i
1226 # make sure client restart still works
1227 umount_client $MOUNT
1228 mount_client $MOUNT || error "mount_client $MOUNT failed"
1229 [ "$($LCTL get_param -n $TEST)" -ne "$i" ] &&
1230 error "Param didn't stick across restart $($TEST) != $i"
1233 echo Erase parameter setting
1234 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1235 do_facet mgs "$PERM_CMD -d $TEST" ||
1236 error "Erase param $TEST failed"
1238 do_facet mgs "$PERM_CMD \
1239 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1240 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1242 umount_client $MOUNT
1243 mount_client $MOUNT || error "mount_client $MOUNT failed"
1244 FINAL=$($LCTL get_param -n $TEST)
1245 echo "deleted (default) value=$FINAL, orig=$ORIG"
1246 ORIG=${ORIG%%.[0-9]*}
1247 FINAL=${FINAL%%.[0-9]*}
1248 # assumes this parameter started at the default value
1249 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1251 cleanup || error "cleanup failed with rc $?"
1253 run_test 30a "Big config llog and permanent parameter deletion"
1258 local orignids=$($LCTL get_param -n \
1259 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1261 local orignidcount=$(echo "$orignids" | wc -w)
1263 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1264 # numerical part of it. Hopefully that's not already a failover address
1266 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1268 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1269 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1270 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1271 echo "Using fake nid $NEW"
1273 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1274 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1275 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1276 PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
1277 echo "Setting $PARAM from $TEST to $NEW"
1278 do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
1279 error "$PERM_CMD $PARAM failed"
1281 PARAM="$FSNAME-OST0000.failover.node"
1282 echo "Setting $PARAM from $TEST to $NEW"
1283 do_facet mgs "$PERM_CMD $PARAM='$NEW'" ||
1284 error "$PARAM $PARAM failed"
1286 wait_update_facet client "$TEST" "$NEW" ||
1287 error "check $PARAM failed!"
1289 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1291 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1292 echo "should have $((orignidcount + 1)) entries \
1293 in failover nids string, have $NIDCOUNT"
1294 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1295 error "Failover nid not added"
1297 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1298 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1300 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1301 error "$PERM_CMD delete failed"
1303 umount_client $MOUNT
1304 mount_client $MOUNT || error "mount_client $MOUNT failed"
1306 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1308 NIDCOUNT=$(echo "$NIDS" | wc -w)
1309 echo "only $orignidcount final entries should remain \
1310 in failover nids string, have $NIDCOUNT"
1311 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1313 cleanup || error "cleanup failed with rc $?"
1315 run_test 30b "Remove failover nids"
1317 test_31() { # bug 10734
1318 # ipaddr must not exist
1319 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1320 cleanup || error "cleanup failed with rc $?"
1322 run_test 31 "Connect to non-existent node (shouldn't crash)"
1326 T32_BLIMIT=40960 # Kbytes
1330 # This is not really a test but a tool to create new disk
1331 # image tarballs for the upgrade tests.
1333 # Disk image tarballs should be created on single-node
1334 # clusters by running this test with default configurations
1335 # plus a few mandatory environment settings that are verified
1336 # at the beginning of the test.
1338 test_32newtarball() {
1342 local tmp=$TMP/t32_image_create
1347 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1348 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1349 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1350 "MDSDEV1=<nonexistent_file>" \
1351 "MDSDEV2=<nonexistent_file>" \
1352 "(or MDSDEV, in the case of b1_8)" \
1353 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1357 echo "Found stale $tmp"
1361 mkdir $tmp/src || return 1
1362 tar cf - -C $src . | tar xf - -C $tmp/src
1363 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1364 count=$(($T32_BLIMIT / 1024 / 4))
1365 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1367 # format ost with comma-separated NIDs to verify LU-4460
1368 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1369 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1373 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1374 $LFS quotacheck -ug /mnt/$FSNAME
1375 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1378 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1380 if [[ $MDSCOUNT -ge 2 ]]; then
1381 remote_dir=/mnt/$FSNAME/remote_dir
1382 $LFS mkdir -i 1 $remote_dir
1383 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1385 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1386 striped_dir=/mnt/$FSNAME/striped_dir_old
1387 $LFS mkdir -i 1 -c 2 $striped_dir
1388 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1394 mkdir $tmp/img || return 1
1398 pushd_dir=/mnt/$FSNAME
1399 if [[ $MDSCOUNT -ge 2 ]]; then
1400 pushd_dir=$remote_dir
1401 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1403 ls -Rni --time-style=+%s >$tmp/img/list2
1409 ls -Rni --time-style=+%s >$tmp/img/list
1410 find ! -name .lustre -type f -exec sha1sum {} \; |
1411 sort -k 2 >$tmp/img/sha1sums
1413 $LCTL get_param -n version | head -n 1 |
1414 sed -e 's/^lustre: *//' >$tmp/img/commit
1416 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1417 $LFS quotaon -ug /mnt/$FSNAME
1418 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1419 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1420 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1421 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1422 | tr -d "*" > $tmp/img/bspace
1423 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1424 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1425 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1426 | tr -d "*" > $tmp/img/ispace
1427 echo $T32_BLIMIT > $tmp/img/blimit
1428 echo $T32_ILIMIT > $tmp/img/ilimit
1433 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1436 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1437 echo "Data verification failed"
1440 uname -r >$tmp/img/kernel
1441 uname -m >$tmp/img/arch
1443 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1444 for num in $(seq 2 $MDSCOUNT); do
1445 local devname=$(mdsdevname $num)
1447 [[ $(facet_fstype $facet) != zfs ]] ||
1448 devname=$(mdsvdevname $num)
1449 mv $devname $tmp/img
1451 mv $OSTDEV1 $tmp/img
1453 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1454 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1457 tar cjvf $dst/disk$version-"$mds1_FSTYPE".tar.bz2 -S *
1462 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1465 # The list of applicable tarballs is returned via the caller's
1466 # variable "tarballs".
1469 [ "$CLIENTONLY" ] && skip "Client-only testing"
1471 local node=$(facet_active_host $SINGLEMDS)
1472 local r="do_node $node"
1474 ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
1476 local IMGTYPE="$mds1_FSTYPE"
1478 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1479 -name \'disk*-$IMGTYPE.tar.bz2\')
1481 [ -z "$tarballs" ] && skip "No applicable tarballs found"
1484 t32_test_cleanup() {
1486 local facet=$SINGLEMDS
1489 if $shall_cleanup_lustre; then
1490 umount $tmp/mnt/lustre || rc=$?
1492 if $shall_cleanup_mdt; then
1493 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1495 if $shall_cleanup_mdt1; then
1496 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1498 if $shall_cleanup_ost; then
1499 $r $UMOUNT $tmp/mnt/ost || rc=$?
1504 if [[ "$mds1_FSTYPE" == zfs ]]; then
1506 local poolname_list="t32fs-mdt1 t32fs-ost1"
1508 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1510 for poolname in $poolname_list; do
1511 destroy_zpool $facet $poolname
1514 combined_mgs_mds || start_mgs || rc=$?
1518 t32_bits_per_long() {
1520 # Yes, this is not meant to be perfect.
1530 t32_reload_modules() {
1532 local all_removed=false
1535 [ "$mds1_FSTYPE" == zfs ] && do_rpc_nodes $node "service zed stop"
1537 while ((i < 20)); do
1538 echo "Unloading modules on $node: Attempt $i"
1539 do_rpc_nodes $node $LUSTRE_RMMOD "$mds1_FSTYPE" &&
1541 do_rpc_nodes $node check_mem_leak || return 1
1542 if $all_removed; then
1543 do_rpc_nodes $node load_modules
1546 if [ "$mds1_FSTYPE" == zfs ]; then
1547 do_rpc_nodes $node "$ZPOOL status -v"
1552 echo "Unloading modules on $node: Given up"
1556 t32_wait_til_devices_gone() {
1562 echo wait for devices to go
1563 while ((i < 20)); do
1564 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1565 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1566 ((devices == 0 && loops == 0)) && return 0
1570 echo "waiting for dev on $node: dev $devices loop $loops given up"
1571 do_rpc_nodes $node "losetup -a"
1572 do_rpc_nodes $node "$LCTL device_list"
1576 t32_verify_quota() {
1583 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1584 # lustre will estimate the object count usage. This fails quota
1585 # verification in 32b. The object quota usage should be accurate after
1586 # zfs-0.7.0 is released.
1587 [ "$mds1_FSTYPE" == zfs ] && {
1588 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1590 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1591 echo "Skip quota verify for zfs: $zfs_version"
1596 $LFS quota -u $T32_QID -v $mnt
1598 qval=$($LFS quota -v -u $T32_QID $mnt |
1599 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1600 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1602 [ $qval -eq $img_bspace ] || {
1603 echo "bspace, act:$qval, exp:$img_bspace"
1607 qval=$($LFS quota -v -u $T32_QID $mnt |
1608 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1609 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1611 [ $qval -eq $img_ispace ] || {
1612 echo "ispace, act:$qval, exp:$img_ispace"
1616 qval=$($LFS quota -v -u $T32_QID $mnt |
1617 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1618 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1620 [ $qval -eq $img_blimit ] || {
1621 echo "blimit, act:$qval, exp:$img_blimit"
1625 qval=$($LFS quota -v -u $T32_QID $mnt |
1626 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1627 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1629 [ $qval -eq $img_ilimit ] || {
1630 echo "ilimit, act:$qval, exp:$img_ilimit"
1634 set_persistent_param_and_check $facet \
1635 "osd-$mds1_FSTYPE.$fsname-MDT0000.quota_slave.enabled" \
1636 "$fsname.quota.mdt" ug
1638 set_persistent_param_and_check $facet \
1639 "osd-$mds1_FSTYPE.$fsname-OST0000.quota_slave.enabled" \
1640 "$fsname.quota.ost" ug
1643 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1644 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1645 echo "Write succeed, but expect -EDQUOT"
1648 rm -f $mnt/t32_qf_new
1650 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1652 echo "Create succeed, but expect -EDQUOT"
1655 unlinkmany $mnt/t32_qf_ $img_ilimit
1663 local dne_upgrade=${dne_upgrade:-"no"}
1664 local dom_upgrade=${dom_upgrade:-"no"}
1665 local ff_convert=${ff_convert:-"no"}
1666 local shall_cleanup_mdt=false
1667 local shall_cleanup_mdt1=false
1668 local shall_cleanup_ost=false
1669 local shall_cleanup_lustre=false
1670 local mdt2_is_available=false
1671 local node=$(facet_active_host $SINGLEMDS)
1672 local r="do_node $node"
1688 local mdt_dev=$tmp/mdt
1689 local mdt2_dev=$tmp/mdt2
1690 local ost_dev=$tmp/ost
1695 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1696 trap 'trap - RETURN; t32_test_cleanup' RETURN
1699 nid=$($r $LCTL list_nids | head -1)
1701 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1702 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1703 $r tar xjvf $tarball -S -C $tmp || {
1704 error_noexit "Unpacking the disk image tarball"
1707 img_commit=$($r cat $tmp/commit)
1708 img_kernel=$($r cat $tmp/kernel)
1709 img_arch=$($r cat $tmp/arch)
1710 img_bspace=$($r cat $tmp/bspace)
1711 img_ispace=$($r cat $tmp/ispace)
1713 # older images did not have "blimit" and "ilimit" files
1714 # use old values for T32_BLIMIT and T32_ILIMIT
1715 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1717 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1720 echo "Upgrading from $(basename $tarball), created with:"
1721 echo " Commit: $img_commit"
1722 echo " Kernel: $img_kernel"
1723 echo " Arch: $img_arch"
1724 echo "OST version: $(lustre_build_version ost1)"
1726 # The conversion can be made only when both of the following
1727 # conditions are satisfied:
1728 # - ost device img version < 2.3.64
1729 # - ost server version >= 2.5
1730 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1731 "$OST1_VERSION" -lt $(version_code 2.5.0) ] &&
1734 ! $r test -f $mdt2_dev || mdt2_is_available=true
1736 if [[ "$mds1_FSTYPE" == zfs ]]; then
1739 local poolname_list="t32fs-mdt1 t32fs-ost1"
1741 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1743 for poolname in $poolname_list; do
1745 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1746 $ZPOOL import -f -d $tmp $poolname"
1749 # upgrade zpool to latest supported features, including
1750 # dnode quota accounting in 0.7.0
1751 $r "$ZPOOL upgrade -a"
1753 mdt_dev=t32fs-mdt1/mdt1
1754 ost_dev=t32fs-ost1/ost1
1755 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1756 wait_update_facet $SINGLEMDS "$ZPOOL list |
1757 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1758 error_noexit "import zfs pool failed"
1763 $r $LCTL set_param debug="$PTLDEBUG"
1765 $r $TUNEFS --dryrun $mdt_dev || {
1767 error_noexit "tunefs.lustre before mounting the MDT"
1771 if $mdt2_is_available; then
1772 $r $TUNEFS --dryrun $mdt2_dev || {
1774 error_noexit "tunefs.lustre before mounting the MDT"
1779 if [ "$writeconf" ]; then
1781 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1783 $r $TUNEFS --quota $mdt_dev || {
1785 error_noexit "Enable mdt quota feature"
1788 if $mdt2_is_available; then
1789 $r $TUNEFS --quota $mdt2_dev || {
1791 error_noexit "Enable mdt quota feature"
1797 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1798 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
1799 skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
1800 "(Need MGS version at least 2.3.59)"
1802 local osthost=$(facet_active_host ost1)
1803 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1806 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1809 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1810 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1811 $r $LCTL replace_nids $fsname-MDT0000 $nid
1812 $r $UMOUNT $tmp/mnt/mdt
1815 mopts=exclude=$fsname-OST0000
1816 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1821 t32_wait_til_devices_gone $node
1823 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1825 error_noexit "Mounting the MDT"
1828 shall_cleanup_mdt=true
1830 if $mdt2_is_available; then
1831 mopts=mgsnode=$nid,$mopts
1832 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1834 error_noexit "Mounting the MDT"
1838 echo "mount new MDT....$mdt2_dev"
1839 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1840 error_noexit "enable remote dir create failed"
1842 shall_cleanup_mdt1=true
1843 elif [ "$dne_upgrade" != "no" ]; then
1844 local fs2mdsdev=$(mdsdevname 1_2)
1845 local fs2mdsvdev=$(mdsvdevname 1_2)
1847 echo "mkfs new MDT on ${fs2mdsdev}...."
1848 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1849 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1852 add $SINGLEMDS $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1853 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1854 error_noexit "Mkfs new MDT failed"
1858 [[ "$mds1_FSTYPE" != zfs ]] || import_zpool mds1
1860 $r $TUNEFS --dryrun $fs2mdsdev || {
1861 error_noexit "tunefs.lustre before mounting the MDT"
1865 echo "mount new MDT....$fs2mdsdev"
1866 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1867 error_noexit "mount mdt1 failed"
1871 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1872 error_noexit "enable remote dir create failed"
1874 shall_cleanup_mdt1=true
1877 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1878 error_noexit "Getting MDT UUID"
1881 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1882 error_noexit "Unexpected MDT UUID: \"$uuid\""
1886 $r $TUNEFS --dryrun $ost_dev || {
1887 error_noexit "tunefs.lustre before mounting the OST"
1890 if [ "$writeconf" ]; then
1891 mopts=mgsnode=$nid,$writeconf
1892 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1894 $r $TUNEFS --quota $ost_dev || {
1896 error_noexit "Enable ost quota feature"
1902 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1907 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1908 error_noexit "Mounting the OST"
1911 shall_cleanup_ost=true
1913 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1914 error_noexit "Getting OST UUID"
1917 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1918 error_noexit "Unexpected OST UUID: \"$uuid\""
1922 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1923 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
1924 error_noexit "Setting OST \"failover.node\""
1927 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
1928 error_noexit "Setting MDT \"failover.node\""
1931 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
1932 error_noexit "Setting \"max_dirty_mb\""
1935 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
1936 error_noexit "Setting \"max_rpcs_in_flight\""
1939 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
1940 error_noexit "Setting \"lov.stripesize\""
1943 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
1944 error_noexit "Setting \"mdd.atime_diff\""
1948 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
1949 error_noexit "Setting OST \"failover.node\""
1953 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
1954 error_noexit "Setting MDT \"failover.node\""
1958 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
1959 error_noexit "Setting \"max_dirty_mb\""
1962 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1963 error_noexit "Setting \"max_rpcs_in_flight\""
1966 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
1967 error_noexit "Setting \"lov.stripesize\""
1970 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
1971 error_noexit "Setting \"mdd.atime_diff\""
1976 $r $LCTL pool_new $fsname.interop || {
1977 error_noexit "Setting \"interop\""
1981 if [ "$ff_convert" != "no" -a "$ost1_FSTYPE" == ldiskfs ]; then
1982 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1983 error_noexit "Start OI scrub on OST0"
1987 # The oi_scrub should be on ost1, but for test_32(),
1988 # all on the SINGLEMDS.
1989 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1990 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1991 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1992 error_noexit "Failed to get the expected 'completed'"
1996 local UPDATED=$($r $LCTL get_param -n \
1997 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1998 awk '/^updated/ { print $2 }')
1999 [ $UPDATED -ge 1 ] || {
2000 error_noexit "Only $UPDATED objects have been converted"
2005 if [ "$dne_upgrade" != "no" ]; then
2006 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2007 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
2008 error_noexit "Setting MDT1 \"failover.node\""
2012 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
2013 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2016 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
2017 error_noexit "Setting MDT1 \"lov.stripesize\""
2021 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
2022 error_noexit "Setting MDT1 \"failover.node\""
2025 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2026 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2029 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2030 error_noexit "Setting MDT1 \"lov.stripesize\""
2036 if [ "$writeconf" ]; then
2037 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2038 error_noexit "Mounting the client"
2042 shall_cleanup_lustre=true
2043 $r $LCTL set_param debug="$PTLDEBUG"
2045 # Leave re-enabling this to a separate patch for LU-11558
2046 # t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2047 # error_noexit "verify quota failed"
2051 if $r test -f $tmp/list; then
2053 # There is not a Test Framework API to copy files to or
2054 # from a remote node.
2056 # LU-2393 - do both sorts on same node to ensure locale
2058 local list_file=$tmp/list
2060 if $mdt2_is_available; then
2061 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2062 $r test -f $tmp/list2; then
2063 list_file=$tmp/list2
2064 pushd $tmp/mnt/lustre/striped_dir_old
2066 pushd $tmp/mnt/lustre/remote_dir
2069 pushd $tmp/mnt/lustre
2071 $r cat $list_file | sort -k 6 >$tmp/list.orig
2072 ls -Rni --time-style=+%s | sort -k 6 |
2073 sed 's/\. / /' >$tmp/list || {
2079 # 32-bit and 64-bit clients use different algorithms to
2080 # convert FIDs into inode numbers. Hence, remove the
2081 # inode numbers from the lists, if the original list was
2082 # created on an architecture with different number of
2085 if [ $(t32_bits_per_long $(uname -m)) != \
2086 $(t32_bits_per_long $img_arch) ]; then
2087 echo "Different number of bits per \"long\"" \
2088 "from the disk image"
2089 for list in list.orig list; do
2090 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2094 if ! diff -ub $tmp/list.orig $tmp/list; then
2095 error_noexit "list verification failed"
2099 echo "list verification skipped"
2102 if [ "$dom_upgrade" != "no" ]; then
2103 echo "Check DoM file can be created"
2104 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2105 error_noexit "Verify DoM creation"
2108 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2109 error_noexit "Verify a DoM file"
2112 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2113 count=1 conv=fsync || {
2114 error_noexit "Cannot write to DoM file"
2117 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2118 error_noexit "DoM: bad size after write"
2121 rm $tmp/mnt/lustre/dom
2123 set_persistent_param_and_check mds \
2124 "lod.*MDT0000*.dom_stripesize" \
2125 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2126 error_noexit "Changing \"dom_stripesize\""
2131 if [ "$dne_upgrade" != "no" ]; then
2132 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2133 error_noexit "set striped dir failed"
2137 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2139 pushd $tmp/mnt/lustre
2140 tar -cf - . --exclude=./striped_dir \
2141 --exclude=./striped_dir_old \
2142 --exclude=./remote_dir |
2143 tar -xvf - -C striped_dir 1>/dev/null || {
2144 error_noexit "cp to striped dir failed"
2150 # If it is upgrade from DNE (2.5), then rename the remote dir,
2151 # which is created in 2.5 to striped dir.
2152 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2153 stripe_index=$($LFS getdirstripe -i \
2154 $tmp/mnt/lustre/remote_dir)
2156 [[ $stripe_index -eq 1 ]] || {
2157 error_noexit "get index \"$stripe_index\"" \
2158 "from remote dir failed"
2161 mv $tmp/mnt/lustre/remote_dir \
2162 $tmp/mnt/lustre/striped_dir/ || {
2163 error_noexit "mv remote dir failed"
2168 # If it is upgraded from DNE (2.7), then move the striped dir
2169 # which was created in 2.7 to the new striped dir.
2170 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2171 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2172 stripe_count=$($LFS getdirstripe -c \
2173 $tmp/mnt/lustre/striped_dir_old)
2174 [[ $stripe_count -eq 2 ]] || {
2175 error_noexit "get count $stripe_count" \
2176 "from striped dir failed"
2179 mv $tmp/mnt/lustre/striped_dir_old \
2180 $tmp/mnt/lustre/striped_dir/ || {
2181 error_noexit "mv striped dir failed"
2187 $r $LCTL set_param -n osd*.*.force_sync=1
2188 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2189 error_noexit "dd failed"
2192 rm -rf $tmp/mnt/lustre/tmp_file || {
2193 error_noexit "rm failed"
2197 if $r test -f $tmp/sha1sums; then
2198 # LU-2393 - do both sorts on same node to ensure locale
2200 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2201 if [ "$dne_upgrade" != "no" ]; then
2202 pushd $tmp/mnt/lustre/striped_dir
2204 pushd $tmp/mnt/lustre
2207 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2208 ! -name .lustre -type f -exec sha1sum {} \; |
2209 sort -k 2 >$tmp/sha1sums || {
2211 error_noexit "sha1sum"
2215 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2216 error_noexit "sha1sum verification failed"
2220 # if upgrade from DNE(2.5), then check remote directory
2221 # if upgrade from DNE(2.7), then check striped directory
2222 if $mdt2_is_available &&
2223 [[ "$dne_upgrade" != "no" ]]; then
2224 local new_dir="$tmp/mnt/lustre/striped_dir"
2225 local striped_dir_old="$new_dir/striped_dir_old"
2227 local dir_list="$new_dir/remote_dir"
2228 [[ ! -d $triped_dir_old ]] ||
2229 dir_list+=" $striped_dir_old"
2231 for dir in $dir_list; do
2233 find ! -name .lustre -type f \
2234 -exec sha1sum {} \; |
2235 sort -k 2 >$tmp/sha1sums || {
2237 error_noexit "sha1sum"
2241 if ! diff -ub $tmp/sha1sums.orig \
2243 error_noexit "sha1sum $dir" \
2250 echo "sha1sum verification skipped"
2253 if [ "$dne_upgrade" != "no" ]; then
2254 rm -rf $tmp/mnt/lustre/striped_dir || {
2255 error_noexit "remove remote dir failed"
2260 # migrate files/dirs to remote MDT, then move them back
2261 if [ "$MDS1_VERSION" -ge $(version_code 2.7.50) -a \
2262 $dne_upgrade != "no" ]; then
2263 $r $LCTL set_param -n \
2264 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2266 echo "test migration"
2267 pushd $tmp/mnt/lustre
2268 for dir in $(find ! -name .lustre ! -name . -type d); do
2269 mdt_index=$($LFS getdirstripe -i $dir)
2270 stripe_cnt=$($LFS getdirstripe -c $dir)
2271 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2272 $LFS migrate -m 1 $dir || {
2274 error_noexit "migrate MDT1 failed"
2280 for dir in $(find ! -name . ! -name .lustre -type d); do
2281 mdt_index=$($LFS getdirstripe -i $dir)
2282 stripe_cnt=$($LFS getdirstripe -c $dir)
2283 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2284 $LFS migrate -m 0 $dir || {
2286 error_noexit "migrate MDT0 failed"
2295 # When adding new data verification tests, please check for
2296 # the presence of the required reference files first, like
2297 # the "sha1sums" and "list" tests above, to avoid the need to
2298 # regenerate every image for each test addition.
2301 nrpcs_orig=$($LCTL get_param \
2302 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2303 error_noexit "Getting \"max_rpcs_in_flight\""
2306 nrpcs=$((nrpcs_orig + 5))
2308 set_persistent_param_and_check client \
2309 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
2310 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
2311 error_noexit "Changing \"max_rpcs_in_flight\""
2315 umount $tmp/mnt/lustre || {
2316 error_noexit "Unmounting the client"
2319 shall_cleanup_lustre=false
2321 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2322 $r $UMOUNT $tmp/mnt/mdt1 || {
2323 error_noexit "Unmounting the MDT2"
2326 if [[ "$mds1_FSTYPE" == zfs ]]; then
2327 $r "$ZPOOL export t32fs-mdt2"
2329 shall_cleanup_mdt1=false
2332 $r $UMOUNT $tmp/mnt/mdt || {
2333 error_noexit "Unmounting the MDT"
2336 if [[ "$mds1_FSTYPE" == zfs ]]; then
2337 $r "$ZPOOL export t32fs-mdt1"
2339 shall_cleanup_mdt=false
2341 $r $UMOUNT $tmp/mnt/ost || {
2342 error_noexit "Unmounting the OST"
2345 if [[ "$mds1_FSTYPE" == zfs ]]; then
2346 $r "$ZPOOL export t32fs-ost1"
2348 shall_cleanup_ost=false
2350 t32_reload_modules $node || {
2351 error_noexit "Reloading modules"
2355 if [[ "$mds1_FSTYPE" == zfs ]]; then
2356 local poolname=t32fs-mdt1
2358 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2359 $ZPOOL import -f -d $tmp $poolname"
2361 # upgrade zpool to latest supported features,
2362 # including dnode quota accounting in 0.7.0
2363 $r "$ZPOOL upgrade $poolname"
2366 # mount a second time to make sure we didnt leave upgrade flag on
2367 $r $TUNEFS --dryrun $mdt_dev || {
2369 error_noexit "tunefs.lustre before remounting the MDT"
2373 mopts=exclude=$fsname-OST0000
2374 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2377 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2378 error_noexit "Remounting the MDT"
2381 shall_cleanup_mdt=true
2391 for tarball in $tarballs; do
2392 t32_test $tarball || let "rc += $?"
2396 run_test 32a "Upgrade (not live)"
2404 for tarball in $tarballs; do
2405 t32_test $tarball writeconf || let "rc += $?"
2409 run_test 32b "Upgrade with writeconf"
2416 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2418 for tarball in $tarballs; do
2419 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2420 echo $tarball | grep "1_8" && continue
2421 echo $tarball | grep "2_1" && continue
2423 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2427 run_test 32c "dne upgrade test"
2435 for tarball in $tarballs; do
2436 ff_convert=yes t32_test $tarball || rc=$?
2440 run_test 32d "convert ff test"
2443 [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
2444 skip "Need MDS version at least 2.10.56"
2451 for tarball in $tarballs; do
2452 echo $tarball | grep "2_9" || continue
2454 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
2458 run_test 32e "dom upgrade test"
2460 test_33a() { # bug 12333, was test_33
2461 local FSNAME2=test-123
2462 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2465 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2467 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2468 local dev=${SINGLEMDS}_dev
2469 local MDSDEV=${!dev}
2470 is_blkdev $SINGLEMDS $MDSDEV &&
2471 skip_env "mixed loopback and real device not working"
2474 local fs2mdsdev=$(mdsdevname 1_2)
2475 local fs2ostdev=$(ostdevname 1_2)
2476 local fs2mdsvdev=$(mdsvdevname 1_2)
2477 local fs2ostvdev=$(ostvdevname 1_2)
2479 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2480 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2483 if combined_mgs_mds; then
2484 local mgs_flag="--mgs"
2487 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
2488 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
2490 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2491 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2492 $fs2ostvdev || exit 10
2494 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2495 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2497 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2498 do_facet mgs "$PERM_CMD timeout=200" ||
2499 error "$PERM_CMD timeout=200 failed"
2501 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
2502 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
2504 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2505 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2508 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2509 $LFS getstripe $MOUNT2/hosts ||
2510 error "$LFS getstripe $MOUNT2/hosts failed"
2515 cleanup_nocli || error "cleanup_nocli failed with $?"
2517 run_test 33a "Mount ost with a large index number"
2519 test_33b() { # was test_34
2522 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2523 # Drop lock cancelation reply during umount
2524 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2525 do_facet client $LCTL set_param fail_loc=0x80000304
2526 #lctl set_param debug=-1
2527 umount_client $MOUNT
2528 cleanup || error "cleanup failed with $?"
2530 run_test 33b "Drop cancel during umount"
2534 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2535 manual_umount_client
2537 do_facet client killall -USR1 multiop
2538 if [ $rc -eq 0 ]; then
2539 error "umount not fail!"
2542 cleanup || error "cleanup failed with rc $?"
2544 run_test 34a "umount with opened file should be fail"
2548 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2549 stop_mds || error "Unable to stop MDS"
2551 manual_umount_client --force || error "mtab after failed umount with $?"
2553 cleanup || error "cleanup failed with $?"
2555 run_test 34b "force umount with failed mds should be normal"
2559 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2560 stop_ost || error "Unable to stop OST1"
2562 manual_umount_client --force || error "mtab after failed umount with $?"
2564 cleanup || error "cleanup failed with $?"
2566 run_test 34c "force umount with failed ost should be normal"
2568 test_35a() { # bug 12459
2571 DBG_SAVE="`$LCTL get_param -n debug`"
2572 $LCTL set_param debug="ha"
2574 log "Set up a fake failnode for the MDS"
2576 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2577 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2579 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2580 do_facet mgs "$PERM_CMD \
2581 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2582 error "Setting mdc.*${device}*.import=connection=\
2583 $(h2nettype $FAKENID) failed."
2585 do_facet mgs "$PERM_CMD \
2586 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2587 error "Setting ${device}.failover.node=\
2588 $(h2nettype $FAKENID) failed."
2590 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2593 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2596 log "Stopping the MDT: $device"
2597 stop_mdt 1 || error "MDT0 stop fail"
2599 df $MOUNT > /dev/null 2>&1 &
2601 log "Restarting the MDT: $device"
2602 start_mdt 1 || error "MDT0 start fail"
2603 log "Wait for df ($DFPID) ... "
2606 $LCTL set_param debug="$DBG_SAVE"
2608 # retrieve from the log the first server that the client tried to
2609 # contact after the connection loss
2610 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2611 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2612 /import_select_connection.*$device-mdc.* using connection/ {
2614 if (\\\$NF ~ /$FAKENID/)
2620 }" $TMP/lustre-log-$TESTNAME.log`
2621 [ "$NEXTCONN" != "0" ] &&
2622 error "Tried to connect to ${NEXTCONN} not last active server"
2623 cleanup || error "cleanup failed with $?"
2624 # remove nid settings
2625 writeconf_or_reformat
2627 run_test 35a "Reconnect to the last active server first"
2629 test_35b() { # bug 18674
2630 remote_mds || skip "local MDS"
2634 $LCTL set_param debug="ha"
2636 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2639 log "Set up a fake failnode for the MDS"
2641 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2642 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2644 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2645 do_facet mgs "$PERM_CMD \
2646 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2647 error "Set mdc.*${device}*.import=connection=\
2648 $(h2nettype $FAKENID) failed"
2650 do_facet mgs "$PERM_CMD \
2651 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2652 error "Set ${device}.failover.node=\
2653 $(h2nettype $FAKENID) failed"
2656 local at_max_saved=0
2657 # adaptive timeouts may prevent seeing the issue
2658 if at_is_enabled; then
2659 at_max_saved=$(at_max_get mds)
2660 at_max_set 0 mds client
2663 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2665 log "Injecting EBUSY on MDS"
2666 # Setting OBD_FAIL_MDS_RESEND=0x136
2667 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2668 error "unable to set param fail_loc=0x80000136"
2670 $LCTL set_param mdc.${FSNAME}*.stats=clear
2672 log "Creating a test file and stat it"
2673 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2674 stat $MOUNT/$tdir/$tfile
2676 log "Stop injecting EBUSY on MDS"
2677 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2678 error "unable to set param fail_loc=0"
2679 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2682 # restore adaptive timeout
2683 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2685 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2687 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2688 awk '/mds_connect/{print $2}')
2690 # retrieve from the log if the client has ever tried to
2691 # contact the fake server after the loss of connection
2692 FAILCONN=`awk "BEGIN {ret = 0;}
2693 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2695 if (\\\$NF ~ /$FAKENID/) {
2700 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2702 [ "$FAILCONN" == "0" ] &&
2703 error "The client reconnection has not been triggered"
2704 [ "$FAILCONN" == "2" ] &&
2705 error "Primary server busy, client reconnect to failover failed"
2708 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2709 # Reconnects are supposed to be rate limited to one every 5s
2710 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2711 error "Too many reconnects $CONNCNT"
2713 cleanup || error "cleanup failed with $?"
2714 # remove nid settings
2715 writeconf_or_reformat
2717 run_test 35b "Continue reconnection retries, if the active server is busy"
2720 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2722 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2726 local FSNAME2=test1234
2727 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2729 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2731 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2732 is_blkdev $SINGLEMDS $MDSDEV &&
2733 skip_env "mixed loopback and real device not working"
2736 local fs2mdsdev=$(mdsdevname 1_2)
2737 local fs2ostdev=$(ostdevname 1_2)
2738 local fs3ostdev=$(ostdevname 2_2)
2739 local fs2mdsvdev=$(mdsvdevname 1_2)
2740 local fs2ostvdev=$(ostvdevname 1_2)
2741 local fs3ostvdev=$(ostvdevname 2_2)
2744 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2745 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2746 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2747 # different one than the default value here.
2748 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2749 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2750 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2751 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2753 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2754 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2755 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2756 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2757 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2759 sleep 5 # until 11778 fixed
2761 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2763 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2764 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2765 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2766 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2767 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2768 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2769 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2770 DFTOTAL=$(echo $STRING | cut -d, -f1)
2771 DFUSED=$(echo $STRING | cut -d, -f2)
2772 DFAVAIL=$(echo $STRING | cut -d, -f3)
2773 DFFREE=$(($DFTOTAL - $DFUSED))
2775 ALLOWANCE=$((64 * $OSTCOUNT))
2777 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2778 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2779 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2782 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2783 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2784 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2787 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2788 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2789 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2794 stop fs3ost -f || error "unable to stop OST3"
2795 stop fs2ost -f || error "unable to stop OST2"
2796 stop fs2mds -f || error "unable to stop second MDS"
2797 unload_modules_conf || error "unable unload modules"
2800 run_test 36 "df report consistency on OSTs with different block size"
2803 local mntpt=$(facet_mntpt $SINGLEMDS)
2804 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2805 local mdsdev_sym="$TMP/sym_mdt.img"
2806 local opts=$MDS_MOUNT_OPTS
2809 if [ "$mds1_FSTYPE" != ldiskfs ]; then
2810 skip "ldiskfs only test"
2813 echo "MDS : $mdsdev"
2814 echo "SYMLINK : $mdsdev_sym"
2815 do_facet $SINGLEMDS rm -f $mdsdev_sym
2817 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2819 echo "mount symlink device - $mdsdev_sym"
2821 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2822 opts=$(csa_add "$opts" -o loop)
2826 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2827 $mdsdev_sym $mntpt 2>&1)
2830 echo mount_op=$mount_op
2832 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2834 if $(echo $mount_op | grep -q "unable to set tunable"); then
2835 error "set tunables failed for symlink device"
2838 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2840 run_test 37 "verify set tunables works for symlink device"
2842 test_38() { # bug 14222
2843 local mntpt=$(facet_mntpt $SINGLEMDS)
2848 local SRC="/etc /bin"
2849 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2850 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2851 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2852 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2853 error "copying $SRC to $DIR/$tdir"
2855 umount_client $MOUNT || error "umount_client $MOUNT failed"
2856 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2857 stop_mds || error "Unable to stop MDS"
2858 log "delete lov_objid file on MDS"
2860 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2862 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2864 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2866 # check create in mds_lov_connect
2867 start_mds || error "unable to start MDS"
2868 mount_client $MOUNT || error "mount_client $MOUNT failed"
2870 [ $V ] && log "verifying $DIR/$tdir/$f"
2871 diff -q $f $DIR/$tdir/$f || ERROR=y
2873 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2874 if [ "$ERROR" = "y" ]; then
2875 # check it's updates in sync
2876 umount_client $MOUNT
2878 mount_fstype $SIGNLEMDS
2879 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2880 unmount_fstype $SINGLEMDS
2881 error "old and new files are different after connect" || true
2883 touch $DIR/$tdir/f2 || error "f2 file create failed"
2885 # check it's updates in sync
2886 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2889 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2891 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2892 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2894 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2896 start_mds || error "unable to start MDS"
2897 mount_client $MOUNT || error "mount_client $MOUNT failed"
2899 [ $V ] && log "verifying $DIR/$tdir/$f"
2900 diff -q $f $DIR/$tdir/$f || ERROR=y
2902 touch $DIR/$tdir/f3 || error "f3 file create failed"
2903 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2904 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2906 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2907 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2908 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2910 [ "$ERROR" = "y" ] &&
2911 error "old and new files are different after sync" || true
2913 log "files compared the same"
2914 cleanup || error "cleanup failed with $?"
2916 run_test 38 "MDS recreates missing lov_objid file from OST data"
2921 cleanup || error "cleanup failed with $?"
2922 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2923 error "memory leak detected" || true
2925 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2927 test_40() { # bug 15759
2928 start_ost || error "Unable to start OST1"
2929 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2930 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2932 cleanup || error "cleanup failed with rc $?"
2934 run_test 40 "race during service thread startup"
2936 test_41a() { #bug 14134
2937 if [ "$mds1_FSTYPE" == ldiskfs ] &&
2938 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2939 skip "Loop devices does not work with nosvc option"
2942 combined_mgs_mds || skip "needs combined MGT and MDT device"
2944 start_mdt 1 -o nosvc -n
2945 if [ $MDSCOUNT -ge 2 ]; then
2946 for num in $(seq 2 $MDSCOUNT); do
2947 start_mdt $num || return
2950 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2951 start_mdt 1 -o nomgs,force
2952 mount_client $MOUNT || error "mount_client $MOUNT failed"
2955 echo "blah blah" > $MOUNT/$tfile
2958 umount_client $MOUNT || error "umount_client $MOUNT failed"
2959 stop ost1 -f || error "unable to stop OST1"
2960 stop_mds || error "Unable to stop MDS"
2961 stop_mds || error "Unable to stop MDS on second try"
2963 run_test 41a "mount mds with --nosvc and --nomgs"
2966 if [ "$mds1_FSTYPE" == ldiskfs ] &&
2967 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2968 skip "Loop devices does not work with nosvc option"
2971 ! combined_mgs_mds && skip "needs combined mgs device"
2975 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2977 start_mdt 1 -o nosvc -n
2978 if [ $MDSCOUNT -ge 2 ]; then
2979 for num in $(seq 2 $MDSCOUNT); do
2980 start_mdt $num || return
2983 start_ost || error "Unable to start OST1"
2984 start_mdt 1 -o nomgs,force
2985 mount_client $MOUNT || error "mount_client $MOUNT failed"
2988 echo "blah blah" > $MOUNT/$tfile
2989 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
2991 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
2992 stop_ost || error "Unable to stop OST1"
2993 stop_mds || error "Unable to stop MDS"
2994 stop_mds || error "Unable to stop MDS on second try"
2996 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2999 local oss_list=$(comma_list $(osts_nodes))
3001 [[ "$MDS1_VERSION" -ge $(version_code 2.6.52) ]] ||
3002 [[ "$MDS1_VERSION" -ge $(version_code 2.5.26) &&
3003 "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
3004 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
3005 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]] ||
3006 skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"
3008 # ensure mds1 ost1 have been created even if running sub-test standalone
3011 cleanup || error "cleanup failed"
3013 # using directly mount command instead of start() function to avoid
3014 # any side effect of // with others/externals tools/features
3015 # ("zpool import", ...)
3017 # MDT concurrent start
3019 LOAD_MODULES_REMOTE=true load_modules
3020 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
3021 error "MDT concurrent start: libcfs module not loaded"
3023 local mds1dev=$(mdsdevname 1)
3024 local mds1mnt=$(facet_mntpt mds1)
3025 local mds1opts=$MDS_MOUNT_OPTS
3027 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3028 ! do_facet mds1 test -b $mds1dev; then
3029 mds1opts=$(csa_add "$mds1opts" -o loop)
3031 if [[ "$mds1_FSTYPE" == zfs ]]; then
3032 import_zpool mds1 || return ${PIPESTATUS[0]}
3035 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3036 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
3038 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
3041 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
3045 do_facet mds1 "$LCTL set_param fail_loc=0x0"
3046 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3047 echo "1st MDT start succeed"
3048 echo "2nd MDT start failed with $rc2"
3049 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3050 echo "1st MDT start failed with $rc"
3051 echo "2nd MDT start succeed"
3054 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
3057 if [ $MDSCOUNT -ge 2 ]; then
3058 for num in $(seq 2 $MDSCOUNT); do
3059 start_mdt $num || return
3063 # OST concurrent start
3065 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
3066 error "OST concurrent start: libcfs module not loaded"
3068 local ost1dev=$(ostdevname 1)
3069 local ost1mnt=$(facet_mntpt ost1)
3070 local ost1opts=$OST_MOUNT_OPTS
3072 if [ "$ost1_FSTYPE" == ldiskfs ] &&
3073 ! do_facet ost1 test -b $ost1dev; then
3074 ost1opts=$(csa_add "$ost1opts" -o loop)
3076 if [[ "$ost1_FSTYPE" == zfs ]]; then
3077 import_zpool ost1 || return ${PIPESTATUS[0]}
3080 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3081 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
3083 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
3086 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
3090 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3091 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3092 echo "1st OST start succeed"
3093 echo "2nd OST start failed with $rc2"
3094 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3095 echo "1st OST start failed with $rc"
3096 echo "2nd OST start succeed"
3100 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3106 # verify everything ok
3111 error "MDT(s) start failed"
3119 error "OST(s) start failed"
3127 error "client start failed"
3134 error "client mount failed"
3138 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3140 test_42() { #bug 14693
3144 check_mount || error "client was not mounted"
3146 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3147 PARAM="llite.$FSNAME-*.some_wrong_param"
3149 PARAM="$FSNAME.llite.some_wrong_param"
3152 do_facet mgs $PERM_CMD $PARAM=10
3153 umount_client $MOUNT ||
3154 error "unmounting client failed with invalid llite param"
3155 mount_client $MOUNT ||
3156 error "mounting client failed with invalid llite param"
3158 do_facet mgs $PERM_CMD $PARAM=20
3159 cleanup || error "stopping $FSNAME failed with invalid sys param"
3161 check_mount || error "client was not mounted with invalid sys param"
3162 cleanup || error "stopping $FSNAME failed with invalid sys param"
3164 run_test 42 "allow client/server mount/unmount with invalid config param"
3167 [[ "$MGS_VERSION" -ge $(version_code 2.5.58) ]] ||
3168 skip "Need MDS version at least 2.5.58"
3169 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"