7 # bug number for skipped test: LU-8972
8 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 101"
9 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
13 if [ -r /etc/SuSE-release ]
15 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
16 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
18 if [ $vers -eq 11 ] && [ $patchlev -eq 2 ]
26 if [ "$FAILURE_MODE" = "HARD" ]; then
27 CONFIG_EXCEPTIONS="24a " &&
28 echo "Except the tests: $CONFIG_EXCEPTIONS for " \
29 "FAILURE_MODE=$FAILURE_MODE, b=23573" &&
30 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
33 # bug number for skipped test:
34 # a tool to create lustre filesystem images
35 ALWAYS_EXCEPT="32newtarball $ALWAYS_EXCEPT"
38 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
40 PTLDEBUG=${PTLDEBUG:--1}
42 LUSTRE=${LUSTRE:-$(dirname $0)/..}
43 RLUSTRE=${RLUSTRE:-$LUSTRE}
44 export MULTIOP=${MULTIOP:-multiop}
46 . $LUSTRE/tests/test-framework.sh
48 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
50 # use small MDS + OST size to speed formatting time
51 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
52 # STORED_MDSSIZE is used in test_18
53 STORED_MDSSIZE=$MDSSIZE
54 STORED_OSTSIZE=$OSTSIZE
66 if ! combined_mgs_mds; then
67 # bug number for skipped test: LU-9860 LU-9860 LU-9860
68 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 43b 53b 54b"
69 # bug number for skipped test: LU-9875 LU-9879 LU-9879 LU-9879 LU-9879
70 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 70e 80 84 87 100"
71 # bug number for skipped test: LU-8110 LU-9400 LU-9879 LU-9879 LU-9879
72 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 102 103 104 105 107"
75 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
76 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
77 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
80 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
81 # bug number for skipped test:
82 ALWAYS_EXCEPT="$ALWAYS_EXCEPT"
87 require_dsh_mds || exit 0
88 require_dsh_ost || exit 0
91 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69"
96 # The MGS must be started before the OSTs for a new fs, so start
97 # and stop to generate the startup logs.
100 wait_osc_import_state mds ost FULL
105 reformat_and_config() {
107 if ! combined_mgs_mds ; then
113 writeconf_or_reformat() {
114 # There are at most 2 OSTs for write_conf test
115 # who knows if/where $TUNEFS is installed?
116 # Better reformat if it fails...
117 writeconf_all $MDSCOUNT 2 ||
118 { echo "tunefs failed, reformatting instead" &&
119 reformat_and_config && return 0; }
129 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
135 local dev=$(mdsdevname $num)
138 echo "start mds service on `facet_active_host $facet`"
139 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
145 local dev=$(mdsdevname $num)
148 echo "stop mds service on `facet_active_host $facet`"
149 # These tests all use non-failover stop
150 stop $facet -f || return 97
156 for num in $(seq $MDSCOUNT); do
157 start_mdt $num $@ || return 94
162 if ! combined_mgs_mds ; then
170 for num in $(seq $MDSCOUNT); do
171 stop_mdt $num || return 97
176 echo "stop mgs service on `facet_active_host mgs`"
177 # These tests all use non-failover stop
178 stop mgs -f || return 97
182 echo "start ost1 service on `facet_active_host ost1`"
183 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
187 echo "stop ost1 service on `facet_active_host ost1`"
188 # These tests all use non-failover stop
189 stop ost1 -f || return 98
193 echo "start ost2 service on `facet_active_host ost2`"
194 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
198 echo "stop ost2 service on `facet_active_host ost2`"
199 # These tests all use non-failover stop
200 stop ost2 -f || return 93
205 echo "mount $FSNAME on ${MOUNTPATH}....."
206 zconf_mount $(hostname) $MOUNTPATH || return 96
210 local mountopt="remount,$1"
212 echo "remount '$1' lustre on ${MOUNTPATH}....."
213 zconf_mount $(hostname) $MOUNTPATH "$mountopt" || return 96
219 echo "umount lustre on $mountpath....."
220 zconf_umount $HOSTNAME $mountpath $@ || return 97
223 manual_umount_client(){
226 echo "manual umount lustre on ${MOUNT}...."
227 do_facet client "umount ${FORCE} $MOUNT"
233 start_mds || error "MDT start failed"
234 start_ost || error "Unable to start OST1"
235 mount_client $MOUNT || error "client start failed"
236 client_up || error "client_up failed"
245 unload_modules_conf () {
246 if combined_mgs_mds || ! local_mode; then
247 unload_modules || return 1
252 stop_ost || return 202
253 stop_mds || return 201
254 unload_modules_conf || return 203
259 [ "x$1" != "x" ] && force='-f'
260 umount_client $MOUNT $force|| return 200
261 cleanup_nocli || return $?
266 echo "umount $MOUNT2 ..."
267 umount $MOUNT2 || true
268 echo "stopping fs2mds ..."
269 stop fs2mds -f || true
270 echo "stopping fs2ost ..."
271 stop fs2ost -f || true
275 do_facet client "cp /etc/passwd $DIR/a" || return 71
276 do_facet client "rm $DIR/a" || return 72
277 # make sure lustre is actually mounted (touch will block,
278 # but grep won't, so do it after)
279 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
280 echo "setup single mount lustre success"
284 do_facet client "touch $DIR/a" || return 71
285 do_facet client "rm $DIR/a" || return 72
286 do_facet client "touch $DIR2/a" || return 73
287 do_facet client "rm $DIR2/a" || return 74
288 echo "setup double mount lustre success"
293 if [ "$ONLY" == "setup" ]; then
298 if [ "$ONLY" == "cleanup" ]; then
305 #create single point mountpoint
311 check_mount || error "check_mount failed"
312 cleanup || error "cleanup failed with $?"
314 run_test 0 "single mount setup"
317 start_mds || error "MDS start failed"
318 start_ost || error "unable to start OST"
319 echo "start ost second time..."
320 start_ost && error "2nd OST start should fail"
321 mount_client $MOUNT || error "client start failed"
322 check_mount || error "check_mount failed"
323 cleanup || error "cleanup failed with $?"
325 run_test 1 "start up ost twice (should return errors)"
328 start_mds || error "MDT start failed"
329 echo "start mds second time.."
330 start_mds && error "2nd MDT start should fail"
331 start_ost || error "OST start failed"
332 mount_client $MOUNT || error "mount_client failed to start client"
333 check_mount || error "check_mount failed"
334 cleanup || error "cleanup failed with $?"
336 run_test 2 "start up mds twice (should return err)"
340 #mount.lustre returns an error if already in mtab
341 mount_client $MOUNT && error "2nd client mount should fail"
342 check_mount || error "check_mount failed"
343 cleanup || error "cleanup failed with $?"
345 run_test 3 "mount client twice (should return err)"
349 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
350 stop_ost || error "Unable to stop OST1"
351 umount_client $MOUNT -f || error “unmount $MOUNT failed”
354 # ok for ost to fail shutdown
355 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
356 error "cleanup failed with $?"
359 run_test 4 "force cleanup ost, then cleanup"
361 test_5a() { # was test_5
363 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
364 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
366 stop_mds || error "Unable to stop MDS"
368 # cleanup may return an error from the failed
369 # disconnects; for now I'll consider this successful
370 # if all the modules have unloaded.
374 echo "killing umount"
375 kill -TERM $UMOUNT_PID
376 echo "waiting for umount to finish"
378 if grep " $MOUNT " /proc/mounts; then
379 echo "test 5: /proc/mounts after failed umount"
383 echo "killing umount"
384 kill -TERM $UMOUNT_PID
385 echo "waiting for umount to finish"
387 grep " $MOUNT " /proc/mounts &&
388 error "/proc/mounts after second umount"
391 # manual_mount_client may fail due to umount succeeding above
393 # stop_mds is a no-op here, and should not fail
394 cleanup_nocli || error "cleanup_nocli failed with $?"
395 # df may have lingering entry
397 # mtab may have lingering entry
401 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
403 grep -q $MOUNT" " /etc/mtab || break
404 echo "Waiting /etc/mtab updated ... "
405 WAIT=$(( WAIT + sleep))
407 [ "$WAIT" -eq "$MAX_WAIT" ] &&
408 error "/etc/mtab is not updated in $WAIT secs"
409 echo "/etc/mtab updated in $WAIT secs"
411 run_test 5a "force cleanup mds, then cleanup"
419 grep " $MOUNT " /etc/mtab &&
420 error false "unexpected entry in mtab before mount" && return 10
422 start_ost || error "OST start failed"
423 if ! combined_mgs_mds ; then
424 trap cleanup_5b EXIT ERR
425 start_mds || error "MDS start failed"
429 mount_client $MOUNT && error "mount_client $MOUNT should fail"
430 grep " $MOUNT " /etc/mtab &&
431 error "$MOUNT entry in mtab after failed mount"
433 # stop_mds is a no-op here, and should not fail
434 cleanup_nocli || error "cleanup_nocli failed with $?"
435 if ! combined_mgs_mds ; then
439 run_test 5b "Try to start a client with no MGS (should return errs)"
442 grep " $MOUNT " /etc/mtab &&
443 error false "unexpected entry in mtab before mount" && return 10
445 start_mds || error "MDS start failed"
446 start_ost || error "OST start failed"
447 local oldfs="${FSNAME}"
448 FSNAME="wrong.${FSNAME}"
449 mount_client $MOUNT || :
451 grep " $MOUNT " /etc/mtab &&
452 error "$MOUNT entry in mtab after failed mount"
454 cleanup_nocli || error "cleanup_nocli failed with $?"
456 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
459 grep " $MOUNT " /etc/mtab &&
460 error "unexpected entry in mtab before mount"
462 start_ost || error "OST start failed"
463 start_mds || error "MDS start failed"
464 stop_ost -f || error "Unable to stop OST1"
465 mount_client $MOUNT || error "mount_client $MOUNT failed"
466 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
467 cleanup_nocli || error "cleanup_nocli failed with $?"
468 ! grep " $MOUNT " /etc/mtab ||
469 error "$MOUNT entry in mtab after unmount"
471 run_test 5d "mount with ost down"
474 grep " $MOUNT " /etc/mtab &&
475 error false "unexpected entry in mtab before mount" && return 10
477 start_mds || error "MDS start failed"
478 start_ost || error "OST start failed"
480 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
481 do_facet client "$LCTL set_param fail_loc=0x80000506"
482 mount_client $MOUNT || echo "mount failed (not fatal)"
483 cleanup || error "cleanup failed with $?"
484 grep " $MOUNT " /etc/mtab &&
485 error "$MOUNT entry in mtab after unmount"
488 run_test 5e "delayed connect, don't crash (bug 10268)"
491 if combined_mgs_mds ; then
492 skip "needs separate mgs and mds"
496 grep " $MOUNT " /etc/mtab &&
497 error false "unexpected entry in mtab before mount" && return 10
500 start_ost || error "OST start failed"
501 mount_client $MOUNT &
503 echo client_mount pid is $pid
507 if ! ps -f -p $pid >/dev/null; then
510 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
511 error "mount returns $rc, expected to hang"
513 cleanup || error "cleanup failed with $?"
518 start_mds || error "start MDS failed"
520 # mount should succeed after start mds
522 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
523 cleanup || error "final call to cleanup failed with rc $?"
525 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
529 [ $(lustre_version_code client) -lt $(version_code 2.9.53) ] &&
530 { skip "automount of debugfs missing before 2.9.53" && return 0; }
531 umount /sys/kernel/debug
532 $LCTL get_param -n devices | egrep -v "error" && \
533 error "lctl can't access debugfs data"
534 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
536 run_test 5g "handle missing debugfs"
541 mount_client $MOUNT || error "mount_client $MOUNT failed"
542 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
543 cleanup || error "cleanup failed with rc $?"
545 run_test 6 "manual umount, then mount again"
550 cleanup_nocli || error "cleanup_nocli failed with $?"
552 run_test 7 "manual umount, then cleanup"
556 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
557 check_mount2 || error "check_mount2 failed"
558 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
559 cleanup || error "cleanup failed with rc $?"
561 run_test 8 "double mount setup"
564 start_ost || error "OST start failed"
566 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
567 error "do_facet ost1 set_param inode trace failed."
568 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
569 error "do_facet ost1 set_param debug mds ost failed."
571 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
572 if [ "$CHECK_PTLDEBUG" ] && { \
573 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
574 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
575 echo "lnet.debug success"
577 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
579 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
580 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
581 echo "lnet.subsystem_debug success"
583 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
585 stop_ost || error "Unable to stop OST1"
587 run_test 9 "test ptldebug and subsystem for mkfs"
595 do_facet $facet "test -b $dev" || rc=1
596 if [[ "$size" ]]; then
597 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k \
598 count=1 skip=$size 2>&1" |
599 awk '($3 == "in") { print $1 }')
600 [[ $in = "1+0" ]] || rc=1
606 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
607 # But with new MDS stack we don't care about the mode of local objects
608 # anymore, so this test is removed. See bug 22944 for more details.
612 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
613 skip "ldiskfs only test"
618 check_mount || error "check_mount failed"
619 cleanup || error "cleanup failed with rc $?"
621 echo "Remove mds config log"
622 if ! combined_mgs_mds ; then
626 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
627 $(mgsdevname) || return \$?" ||
628 error "do_facet mgs failed with $?"
630 if ! combined_mgs_mds ; then
634 start_ost || error "OST start failed"
635 start_mds && error "MDS start succeeded, but should fail"
638 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
641 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
642 skip "ldiskfs only test"
646 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
651 # check if current MDSSIZE is large enough
652 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
653 log "use MDSSIZE=$MDSSIZE"
655 # check if the global config has a large enough MDSSIZE
656 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
657 [ $STORED_MDSSIZE -ge $MIN ] &&
658 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
659 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
661 # check if the block device is large enough
662 is_blkdev $SINGLEMDS $MDSDEV $MIN
663 local large_enough=$?
664 if [ -n "$OK" ]; then
665 [ $large_enough -ne 0 ] && OK=""
667 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
668 log "use device $MDSDEV with MIN=$MIN"
671 # check if a loopback device has enough space for fs metadata (5%)
673 if [ -z "$OK" ]; then
674 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
675 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
676 awk '($1 != "Filesystem") { print $4 }')
677 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
678 OK=1 && myMDSSIZE=$MIN &&
679 log "use file $MDSDEV with MIN=$MIN"
682 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
684 echo "mount mds with large journal..."
686 local OLD_MDSSIZE=$MDSSIZE
690 echo "mount lustre system..."
692 check_mount || error "check_mount failed"
694 echo "check journal size..."
695 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
696 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
697 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
699 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
702 cleanup || error "cleanup failed with rc $?"
707 run_test 18 "check mkfs creates large journals"
710 start_mds || error "MDS start failed"
711 stop_mds || error "Unable to stop MDS"
713 run_test 19a "start/stop MDS without OSTs"
716 start_ost || error "Unable to start OST1"
717 stop_ost -f || error "Unable to stop OST1"
719 run_test 19b "start/stop OSTs without MDS"
722 # first format the ost/mdt
723 start_mds || error "MDS start failed"
724 start_ost || error "Unable to start OST1"
725 mount_client $MOUNT || error "mount_client $MOUNT failed"
726 check_mount || error "check_mount failed"
727 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
728 remount_client ro $MOUNT || error "remount_client with ro failed"
729 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
730 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
731 remount_client rw $MOUNT || error "remount_client with rw failed"
732 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
733 MCNT=$(grep -c $MOUNT /etc/mtab)
734 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
736 stop_mds || error "Unable to stop MDS"
737 stop_ost || error "Unable to stop OST1"
739 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
742 start_mds || error "MDS start failed"
743 start_ost || error "unable to start OST1"
744 wait_osc_import_state mds ost FULL
745 stop_ost || error "unable to stop OST1"
746 stop_mds || error "unable to stop MDS"
748 run_test 21a "start mds before ost, stop ost first"
751 start_ost || error "unable to start OST1"
752 start_mds || error "MDS start failed"
753 wait_osc_import_state mds ost FULL
754 stop_mds || error "unable to stop MDS"
755 stop_ost || error "unable to stop OST1"
757 run_test 21b "start ost before mds, stop mds first"
760 start_ost || error "Unable to start OST1"
761 start_mds || error "MDS start failed"
762 start_ost2 || error "Unable to start OST2"
763 wait_osc_import_state mds ost2 FULL
764 stop_ost || error "Unable to stop OST1"
765 stop_ost2 || error "Unable to stop OST2"
766 stop_mds || error "Unable to stop MDS"
767 #writeconf to remove all ost2 traces for subsequent tests
768 writeconf_or_reformat
770 run_test 21c "start mds between two osts, stop mds last"
773 if combined_mgs_mds ; then
774 skip "need separate mgs device" && return 0
780 start_mgs || error "unable to start MGS"
781 start_ost || error "unable to start OST1"
782 start_ost2 || error "unable to start OST2"
783 start_mds || error "MDS start failed"
784 wait_osc_import_state mds ost2 FULL
786 stop_ost || error "Unable to stop OST1"
787 stop_ost2 || error "Unable to stop OST2"
788 stop_mds || error "Unable to stop MDS"
790 #writeconf to remove all ost2 traces for subsequent tests
791 writeconf_or_reformat
792 start_mgs || error "unable to start MGS"
794 run_test 21d "start mgs then ost and then mds"
797 MGSNID="$saved_mgsnid"
799 echo "stopping fs2mgs ..."
800 stop $fs2mgs -f || true
803 test_21e() { # LU-5863
804 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
805 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
806 skip_env "mixed loopback and real device not working" && return
809 local fs2mdsdev=$(mdsdevname 1_2)
810 local fs2ostdev=$(ostdevname 1_2)
811 local fs3ostdev=$(ostdevname 2_2)
813 local fs2mdsvdev=$(mdsvdevname 1_2)
814 local fs2ostvdev=$(ostvdevname 1_2)
815 local fs3ostvdev=$(ostvdevname 2_2)
817 # temporarily use fs3ost as fs2mgs
819 local fs2mgsdev=$fs3ostdev
820 local fs2mgsvdev=$fs3ostvdev
822 local fsname=test1234
824 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
825 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
826 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
827 error "start fs2mgs failed"
829 local saved_mgsnid="$MGSNID"
830 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
832 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
833 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
834 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
835 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
837 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
838 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
840 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
841 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
842 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
846 run_test 21e "separate MGS and MDS"
849 start_mds || error "MDS start failed"
851 echo "Client mount with ost in logs, but none running"
852 start_ost || error "unable to start OST1"
853 # wait until mds connected to ost and open client connection
854 wait_osc_import_state mds ost FULL
855 stop_ost || error "unable to stop OST1"
856 mount_client $MOUNT || error "mount_client $MOUNT failed"
857 # check_mount will block trying to contact ost
858 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
859 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
860 umount_client $MOUNT -f
863 echo "Client mount with a running ost"
864 start_ost || error "unable to start OST1"
866 # if gss enabled, wait full time to let connection from
867 # mds to ost be established, due to the mismatch between
868 # initial connect timeout and gss context negotiation timeout.
869 # This perhaps could be remove after AT landed.
870 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
871 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
873 mount_client $MOUNT || error "mount_client $MOUNT failed"
874 wait_osc_import_state mds ost FULL
875 wait_osc_import_state client ost FULL
876 check_mount || error "check_mount failed"
879 cleanup || error "cleanup failed with rc $?"
881 run_test 22 "start a client before osts (should return errs)"
883 test_23a() { # was test_23
886 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
887 # force down client so that recovering mds waits for reconnect
888 local running=$(grep -c $MOUNT /proc/mounts) || true
889 if [ $running -ne 0 ]; then
890 echo "Stopping client $MOUNT (opts: -f)"
894 # enter recovery on failed mds
895 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
896 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
897 # try to start a new client
898 mount_client $MOUNT &
900 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
901 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
902 grep -v grep | awk '{print $2}')
903 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
905 ps --ppid $MOUNT_LUSTRE_PID
906 echo "waiting for mount to finish"
908 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
909 # SIGTERM works but it does not spread to offspring processses
910 kill -s TERM $MOUNT_PID
911 kill -s TERM $MOUNT_LUSTRE_PID
912 # we can not wait $MOUNT_PID because it is not a child of this shell
918 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
920 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
921 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
924 [ -z "$PID1" -a -z "$PID2" ] && break
925 echo "waiting for mount to finish ... "
926 WAIT=$(( WAIT + sleep))
928 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
929 error "MOUNT_PID $MOUNT_PID and "\
930 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
933 stop_mds || error "stopping MDSes failed"
934 stop_ost || error "stopping OSSes failed"
936 run_test 23a "interrupt client during recovery mount delay"
941 test_23b() { # was test_23
942 start_mds || error "MDS start failed"
943 start_ost || error "Unable to start OST1"
944 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
945 $LCTL set_param fail_loc=0x80000313
947 cleanup || error "cleanup failed with rc $?"
949 run_test 23b "Simulate -EINTR during mount"
952 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
954 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
955 is_blkdev $SINGLEMDS $MDSDEV &&
956 skip_env "mixed loopback and real device not working" && return
959 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
961 local fs2mdsdev=$(mdsdevname 1_2)
962 local fs2ostdev=$(ostdevname 1_2)
963 local fs2mdsvdev=$(mdsvdevname 1_2)
964 local fs2ostvdev=$(ostvdevname 1_2)
967 # LU-9733 test fsname started with numbers as well
968 local FSNAME2=969362ae
970 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
971 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
973 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
974 --reformat $fs2ostdev $fs2ostvdev || exit 10
977 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
978 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
979 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
980 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
982 # LU-9733 test fsname started with numbers
983 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
984 changelog_register -n) ||
985 error "register changelog failed"
987 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
988 changelog_deregister $cl_user ||
989 error "deregister changelog failed"
991 check_mount || error "check_mount failed"
992 # files written on 1 should not show up on 2
993 cp /etc/passwd $DIR/$tfile
995 [ -e $MOUNT2/$tfile ] && error "File bleed"
998 cp /etc/passwd $MOUNT2/$tfile ||
999 error "cp /etc/passwd $MOUNT2/$tfile failed"
1000 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
1001 # 2 is actually mounted
1002 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
1004 facet_failover fs2mds
1005 facet_failover fs2ost
1007 umount_client $MOUNT
1008 # the MDS must remain up until last MDT
1010 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1011 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1012 [ -z "$MDS" ] && error "No MDT"
1014 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1016 run_test 24a "Multiple MDTs on a single node"
1019 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1021 if [ -z "$fs2mds_DEV" ]; then
1022 local dev=${SINGLEMDS}_dev
1023 local MDSDEV=${!dev}
1024 is_blkdev $SINGLEMDS $MDSDEV &&
1025 skip_env "mixed loopback and real device not working" && return
1028 local fs2mdsdev=$(mdsdevname 1_2)
1029 local fs2mdsvdev=$(mdsvdevname 1_2)
1031 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1032 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1034 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS &&
1035 error "start MDS should fail"
1037 cleanup || error "cleanup failed with rc $?"
1039 run_test 24b "Multiple MGSs on a single node (should return err)"
1043 check_mount || error "check_mount failed"
1044 local MODULES=$($LCTL modules | awk '{ print $2 }')
1045 rmmod $MODULES 2>/dev/null || true
1046 cleanup || error "cleanup failed with $?"
1048 run_test 25 "Verify modules are referenced"
1052 # we need modules before mount for sysctl, so make sure...
1053 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1054 #define OBD_FAIL_MDS_FS_SETUP 0x135
1055 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1056 start_mds && error "MDS started but should not have started"
1057 $LCTL get_param -n devices
1058 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1059 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1060 # start mds to drop writeconf setting
1061 start_mds || error "Unable to start MDS"
1062 stop_mds || error "Unable to stop MDS"
1063 unload_modules_conf || error "unload_modules_conf failed with $?"
1065 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1068 start_ost || error "Unable to start OST1"
1069 start_mds || error "Unable to start MDS"
1070 echo "Requeue thread should have started: "
1071 ps -e | grep ll_cfg_requeue
1072 set_conf_param_and_check ost1 \
1073 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1074 "$FSNAME-OST0000.ost.client_cache_seconds" ||
1075 error "set_conf_param_and_check ost1 failed"
1076 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1078 run_test 27a "Reacquire MGS lock if OST started first"
1083 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1084 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1086 facet_failover $SINGLEMDS
1087 set_conf_param_and_check $SINGLEMDS \
1088 "$LCTL get_param -n mdt.$device.identity_acquire_expire" \
1089 "$device.mdt.identity_acquire_expire" ||
1090 error "set_conf_param_and_check $SINGLEMDS failed"
1091 set_conf_param_and_check client \
1092 "$LCTL get_param -n mdc.$device-mdc-*.max_rpcs_in_flight"\
1093 "$device.mdc.max_rpcs_in_flight" ||
1094 error "set_conf_param_and_check client failed"
1096 cleanup || error "cleanup failed with $?"
1098 run_test 27b "Reacquire MGS lock after failover"
1102 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1103 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1105 FINAL=$(($ORIG + 1))
1106 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1107 error "first set_conf_param_and_check client failed"
1108 FINAL=$(($FINAL + 1))
1109 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1110 error "second set_conf_param_and_check client failed"
1111 umount_client $MOUNT || error "umount_client $MOUNT failed"
1112 mount_client $MOUNT || error "mount_client $MOUNT failed"
1114 if [ $RESULT -ne $FINAL ]; then
1115 error "New config not seen: wanted $FINAL got $RESULT"
1117 echo "New config success: got $RESULT"
1119 set_conf_param_and_check client "$TEST" "$PARAM" $ORIG ||
1120 error "third set_conf_param_and_check client failed"
1121 cleanup || error "cleanup failed with rc $?"
1123 run_test 28 "permanent parameter setting"
1125 test_28a() { # LU-4221
1126 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1127 { skip "Need OST version at least 2.5.52" && return 0; }
1128 [ "$(facet_fstype ost1)" = "zfs" ] &&
1129 skip "LU-4221: no such proc params for ZFS OSTs" && return
1136 local device="$FSNAME-OST0000"
1140 # In this test we will set three kinds of proc parameters with
1142 # 1. the ones moved from the OFD to the OSD, and only their
1143 # symlinks kept in obdfilter
1144 # 2. non-symlink ones in the OFD
1145 # 3. non-symlink ones in the OSD
1148 # prepare a symlink parameter in the OFD
1149 name="writethrough_cache_enable"
1150 param="$device.ost.$name"
1151 cmd="$LCTL get_param -n obdfilter.$device.$name"
1153 # conf_param the symlink parameter in the OFD
1154 old=$(do_facet ost1 $cmd)
1155 new=$(((old + 1) % 2))
1156 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1157 error "lctl conf_param $device.ost.$param=$new failed"
1159 # conf_param the target parameter in the OSD
1160 param="$device.osd.$name"
1161 cmd="$LCTL get_param -n osd-*.$device.$name"
1162 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1163 error "lctl conf_param $device.osd.$param=$old failed"
1166 # prepare a non-symlink parameter in the OFD
1167 name="client_cache_seconds"
1168 param="$device.ost.$name"
1169 cmd="$LCTL get_param -n obdfilter.$device.$name"
1171 # conf_param the parameter in the OFD
1172 old=$(do_facet ost1 $cmd)
1174 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1175 error "lctl conf_param $device.ost.$param=$new failed"
1176 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1177 error "lctl conf_param $device.ost.$param=$old failed"
1180 # prepare a non-symlink parameter in the OSD
1182 param="$device.osd.$name"
1183 cmd="$LCTL get_param -n osd-*.$device.$name"
1185 # conf_param the parameter in the OSD
1186 old=$(do_facet ost1 $cmd)
1187 new=$(((old + 1) % 2))
1188 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1189 error "lctl conf_param $device.osd.$param=$new failed"
1190 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1191 error "lctl conf_param $device.osd.$param=$old failed"
1193 cleanup || error "cleanup failed with $?"
1195 run_test 28a "set symlink parameters permanently with conf_param"
1198 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1199 setup > /dev/null 2>&1
1200 start_ost2 || error "Unable to start OST2"
1203 local PARAM="$FSNAME-OST0001.osc.active"
1204 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1205 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1207 ACTV=$($LCTL get_param -n $PROC_ACT)
1209 set_conf_param_and_check client \
1210 "$LCTL get_param -n $PROC_ACT" "$PARAM" $DEAC ||
1211 error "set_conf_param_and_check client failed"
1212 # also check ost_server_uuid status
1213 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1214 if [ -z "$RESULT" ]; then
1215 error "Client not deactivated: $($LCTL get_param \
1218 echo "Live client success: got $RESULT"
1222 wait_osp_active ost ${FSNAME}-OST0001 1 0
1224 # test new client starts deactivated
1225 umount_client $MOUNT || error "umount_client $MOUNT failed"
1226 mount_client $MOUNT || error "mount_client $MOUNT failed"
1227 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1228 if [ -z "$RESULT" ]; then
1229 error "New client start active: $(lctl get_param -n $PROC_UUID)"
1231 echo "New client success: got $RESULT"
1234 # make sure it reactivates
1235 set_conf_param_and_check client \
1236 "$LCTL get_param -n $PROC_ACT" "$PARAM" $ACTV ||
1237 error "lctl get_param $PROC_ACT $PARAM $ACTV failed"
1239 umount_client $MOUNT
1240 stop_ost2 || error "Unable to stop OST2"
1241 cleanup_nocli || error "cleanup_nocli failed with $?"
1242 #writeconf to remove all ost2 traces for subsequent tests
1243 writeconf_or_reformat
1245 run_test 29 "permanently remove an OST"
1250 echo Big config llog
1251 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1253 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1254 for i in ${LIST[@]}; do
1255 set_conf_param_and_check client "$TEST" \
1256 "$FSNAME.llite.max_read_ahead_whole_mb" $i ||
1257 error "Set $FSNAME.llite.max_read_ahead_whole_mb failed"
1259 # make sure client restart still works
1260 umount_client $MOUNT
1261 mount_client $MOUNT || error "mount_client $MOUNT failed"
1262 [ "$($TEST)" -ne "$i" ] &&
1263 error "Param didn't stick across restart $($TEST) != $i"
1266 echo Erase parameter setting
1267 do_facet mgs "$LCTL conf_param \
1268 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1269 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1270 umount_client $MOUNT
1271 mount_client $MOUNT || error "mount_client $MOUNT failed"
1273 echo "deleted (default) value=$FINAL, orig=$ORIG"
1274 # assumes this parameter started at the default value
1275 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1277 cleanup || error "cleanup failed with rc $?"
1279 run_test 30a "Big config llog and conf_param deletion"
1284 local orignids=$($LCTL get_param -n \
1285 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1287 local orignidcount=$(echo "$orignids" | wc -w)
1289 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1290 # numerical part of it. Hopefully that's not already a failover address
1292 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1294 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1295 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1296 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1297 echo "Using fake nid $NEW"
1299 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1300 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1301 set_conf_param_and_check client "$TEST" \
1302 "$FSNAME-OST0000.failover.node" $NEW ||
1303 error "didn't add failover nid $NEW"
1304 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1307 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1308 echo "should have $((orignidcount + 1)) entries \
1309 in failover nids string, have $NIDCOUNT"
1310 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1311 error "Failover nid not added"
1313 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" ||
1314 error "conf_param delete failed"
1315 umount_client $MOUNT
1316 mount_client $MOUNT || error "mount_client $MOUNT failed"
1318 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1321 NIDCOUNT=$(echo "$NIDS" | wc -w)
1322 echo "only $orignidcount final entries should remain \
1323 in failover nids string, have $NIDCOUNT"
1324 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1326 cleanup || error "cleanup failed with rc $?"
1328 run_test 30b "Remove failover nids"
1330 test_31() { # bug 10734
1331 # ipaddr must not exist
1332 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1333 cleanup || error "cleanup failed with rc $?"
1335 run_test 31 "Connect to non-existent node (shouldn't crash)"
1339 T32_BLIMIT=40960 # Kbytes
1343 # This is not really a test but a tool to create new disk
1344 # image tarballs for the upgrade tests.
1346 # Disk image tarballs should be created on single-node
1347 # clusters by running this test with default configurations
1348 # plus a few mandatory environment settings that are verified
1349 # at the beginning of the test.
1351 test_32newtarball() {
1355 local tmp=$TMP/t32_image_create
1356 local server_version=$(lustre_version_code $SINGLEMDS)
1361 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1362 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1363 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1364 "MDSDEV1=<nonexistent_file>" \
1365 "MDSDEV2=<nonexistent_file>" \
1366 "(or MDSDEV, in the case of b1_8)" \
1367 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1371 echo "Found stale $tmp"
1375 mkdir $tmp/src || return 1
1376 tar cf - -C $src . | tar xf - -C $tmp/src
1377 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1378 count=$(($T32_BLIMIT / 1024 / 4))
1379 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1381 # format ost with comma-separated NIDs to verify LU-4460
1382 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1383 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1387 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1388 $LFS quotacheck -ug /mnt/$FSNAME
1389 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1392 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1394 if [[ $MDSCOUNT -ge 2 ]]; then
1395 remote_dir=/mnt/$FSNAME/remote_dir
1396 $LFS mkdir -i 1 $remote_dir
1397 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1399 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1400 striped_dir=/mnt/$FSNAME/striped_dir_old
1401 $LFS mkdir -i 1 -c 2 $striped_dir
1402 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1408 mkdir $tmp/img || return 1
1412 pushd_dir=/mnt/$FSNAME
1413 if [[ $MDSCOUNT -ge 2 ]]; then
1414 pushd_dir=$remote_dir
1415 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1417 ls -Rni --time-style=+%s >$tmp/img/list2
1423 ls -Rni --time-style=+%s >$tmp/img/list
1424 find ! -name .lustre -type f -exec sha1sum {} \; |
1425 sort -k 2 >$tmp/img/sha1sums
1427 $LCTL get_param -n version | head -n 1 |
1428 sed -e 's/^lustre: *//' >$tmp/img/commit
1430 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1431 $LFS quotaon -ug /mnt/$FSNAME
1432 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1433 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1434 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1435 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1436 | tr -d "*" > $tmp/img/bspace
1437 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1438 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1439 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1440 | tr -d "*" > $tmp/img/ispace
1441 echo $T32_BLIMIT > $tmp/img/blimit
1442 echo $T32_ILIMIT > $tmp/img/ilimit
1447 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1450 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1451 echo "Data verification failed"
1454 uname -r >$tmp/img/kernel
1455 uname -m >$tmp/img/arch
1457 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1458 for num in $(seq 2 $MDSCOUNT); do
1459 local devname=$(mdsdevname $num)
1461 [[ $(facet_fstype $facet) != zfs ]] ||
1462 devname=$(mdsvdevname $num)
1463 mv $devname $tmp/img
1465 mv $OSTDEV1 $tmp/img
1467 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1468 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1471 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1476 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1479 # The list of applicable tarballs is returned via the caller's
1480 # variable "tarballs".
1483 local node=$(facet_active_host $SINGLEMDS)
1484 local r="do_node $node"
1486 if [ "$CLIENTONLY" ]; then
1487 skip "Client-only testing"
1491 if ! $r which $TUNEFS; then
1492 skip_env "tunefs.lustre required on $node"
1496 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1498 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1499 -name \'disk*-$IMGTYPE.tar.bz2\')
1501 if [ -z "$tarballs" ]; then
1502 skip "No applicable tarballs found"
1507 t32_test_cleanup() {
1509 local facet=$SINGLEMDS
1510 local fstype=$(facet_fstype $facet)
1513 if $shall_cleanup_lustre; then
1514 umount $tmp/mnt/lustre || rc=$?
1516 if $shall_cleanup_mdt; then
1517 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1519 if $shall_cleanup_mdt1; then
1520 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1522 if $shall_cleanup_ost; then
1523 $r $UMOUNT $tmp/mnt/ost || rc=$?
1528 if [[ $fstype == zfs ]]; then
1530 local poolname_list="t32fs-mdt1 t32fs-ost1"
1532 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1534 for poolname in $poolname_list; do
1535 destroy_zpool $facet $poolname
1538 combined_mgs_mds || start_mgs || rc=$?
1542 t32_bits_per_long() {
1544 # Yes, this is not meant to be perfect.
1554 t32_reload_modules() {
1556 local all_removed=false
1559 while ((i < 20)); do
1560 echo "Unloading modules on $node: Attempt $i"
1561 do_rpc_nodes $node $LUSTRE_RMMOD $(facet_fstype $SINGLEMDS) &&
1563 do_rpc_nodes $node check_mem_leak || return 1
1564 if $all_removed; then
1565 do_rpc_nodes $node load_modules
1571 echo "Unloading modules on $node: Given up"
1575 t32_wait_til_devices_gone() {
1581 echo wait for devices to go
1582 while ((i < 20)); do
1583 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1584 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1585 ((devices == 0 && loops == 0)) && return 0
1589 echo "waiting for dev on $node: dev $devices loop $loops given up"
1590 do_rpc_nodes $node "losetup -a"
1591 do_rpc_nodes $node "$LCTL device_list"
1595 t32_verify_quota() {
1599 local fstype=$(facet_fstype $SINGLEMDS)
1603 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1604 # lustre will estimate the object count usage. This fails quota
1605 # verification in 32b. The object quota usage should be accurate after
1606 # zfs-0.7.0 is released.
1607 [ $fstype == "zfs" ] && {
1608 local zfs_version=$(do_node $node cat /sys/module/zfs/version)
1610 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1611 echo "Skip quota verify for zfs: $zfs_version"
1616 $LFS quota -u $T32_QID -v $mnt
1618 qval=$($LFS quota -v -u $T32_QID $mnt |
1619 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1620 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1622 [ $qval -eq $img_bspace ] || {
1623 echo "bspace, act:$qval, exp:$img_bspace"
1627 qval=$($LFS quota -v -u $T32_QID $mnt |
1628 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1629 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1631 [ $qval -eq $img_ispace ] || {
1632 echo "ispace, act:$qval, exp:$img_ispace"
1636 qval=$($LFS quota -v -u $T32_QID $mnt |
1637 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1638 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1640 [ $qval -eq $img_blimit ] || {
1641 echo "blimit, act:$qval, exp:$img_blimit"
1645 qval=$($LFS quota -v -u $T32_QID $mnt |
1646 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1647 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1649 [ $qval -eq $img_ilimit ] || {
1650 echo "ilimit, act:$qval, exp:$img_ilimit"
1654 do_node $node $LCTL conf_param $fsname.quota.mdt=ug
1655 cmd="$LCTL get_param -n osd-$fstype.$fsname-MDT0000"
1656 cmd=$cmd.quota_slave.enabled
1657 wait_update $node "$cmd" "ug" || {
1658 echo "Enable mdt quota failed"
1662 do_node $node $LCTL conf_param $fsname.quota.ost=ug
1663 cmd="$LCTL get_param -n osd-$fstype.$fsname-OST0000"
1664 cmd=$cmd.quota_slave.enabled
1665 wait_update $node "$cmd" "ug" || {
1666 echo "Enable ost quota failed"
1671 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1672 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1673 echo "Write succeed, but expect -EDQUOT"
1676 rm -f $mnt/t32_qf_new
1678 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1680 echo "Create succeed, but expect -EDQUOT"
1683 unlinkmany $mnt/t32_qf_ $img_ilimit
1691 local dne_upgrade=${dne_upgrade:-"no"}
1692 local ff_convert=${ff_convert:-"no"}
1693 local shall_cleanup_mdt=false
1694 local shall_cleanup_mdt1=false
1695 local shall_cleanup_ost=false
1696 local shall_cleanup_lustre=false
1697 local mdt2_is_available=false
1698 local node=$(facet_active_host $SINGLEMDS)
1699 local r="do_node $node"
1715 local fstype=$(facet_fstype $SINGLEMDS)
1716 local mdt_dev=$tmp/mdt
1717 local mdt2_dev=$tmp/mdt2
1718 local ost_dev=$tmp/ost
1723 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1724 trap 'trap - RETURN; t32_test_cleanup' RETURN
1727 nid=$($r $LCTL list_nids | head -1)
1729 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1730 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1731 $r tar xjvf $tarball -S -C $tmp || {
1732 error_noexit "Unpacking the disk image tarball"
1735 img_commit=$($r cat $tmp/commit)
1736 img_kernel=$($r cat $tmp/kernel)
1737 img_arch=$($r cat $tmp/arch)
1738 img_bspace=$($r cat $tmp/bspace)
1739 img_ispace=$($r cat $tmp/ispace)
1741 # older images did not have "blimit" and "ilimit" files
1742 # use old values for T32_BLIMIT and T32_ILIMIT
1743 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1745 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1748 echo "Upgrading from $(basename $tarball), created with:"
1749 echo " Commit: $img_commit"
1750 echo " Kernel: $img_kernel"
1751 echo " Arch: $img_arch"
1752 echo "OST version: $(lustre_build_version ost1)"
1754 # The conversion can be made only when both of the following
1755 # conditions are satisfied:
1756 # - ost device img version < 2.3.64
1757 # - ost server version >= 2.5
1758 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1759 $(lustre_version_code ost1) -lt $(version_code 2.5.0) ] &&
1762 ! $r test -f $mdt2_dev || mdt2_is_available=true
1764 if [[ $fstype == zfs ]]; then
1767 local poolname_list="t32fs-mdt1 t32fs-ost1"
1769 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1771 for poolname in $poolname_list; do
1773 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1774 $ZPOOL import -f -d $tmp $poolname"
1777 # upgrade zpool to latest supported features, including
1778 # dnode quota accounting in 0.7.0
1779 $r "$ZPOOL upgrade -a"
1781 mdt_dev=t32fs-mdt1/mdt1
1782 ost_dev=t32fs-ost1/ost1
1783 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1784 wait_update_facet $SINGLEMDS "$ZPOOL list |
1785 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1786 error_noexit "import zfs pool failed"
1791 $r $LCTL set_param debug="$PTLDEBUG"
1793 $r $TUNEFS --dryrun $mdt_dev || {
1795 error_noexit "tunefs.lustre before mounting the MDT"
1799 if $mdt2_is_available; then
1800 $r $TUNEFS --dryrun $mdt2_dev || {
1802 error_noexit "tunefs.lustre before mounting the MDT"
1807 if [ "$writeconf" ]; then
1809 if [ $fstype == "ldiskfs" ]; then
1811 $r $TUNEFS --quota $mdt_dev || {
1813 error_noexit "Enable mdt quota feature"
1816 if $mdt2_is_available; then
1817 $r $TUNEFS --quota $mdt2_dev || {
1819 error_noexit "Enable mdt quota feature"
1825 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1826 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1827 { skip "LU-2200: Cannot run over Inifiniband w/o lctl replace_nids "
1828 "(Need MGS version at least 2.3.59)"; return 0; }
1830 local osthost=$(facet_active_host ost1)
1831 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1834 if [ $fstype == "ldiskfs" ]; then
1837 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1838 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1839 $r $LCTL replace_nids $fsname-MDT0000 $nid
1840 $r $UMOUNT $tmp/mnt/mdt
1843 mopts=exclude=$fsname-OST0000
1844 if [ $fstype == "ldiskfs" ]; then
1849 t32_wait_til_devices_gone $node
1851 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1853 error_noexit "Mounting the MDT"
1856 shall_cleanup_mdt=true
1858 if $mdt2_is_available; then
1859 mopts=mgsnode=$nid,$mopts
1860 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1862 error_noexit "Mounting the MDT"
1866 echo "mount new MDT....$mdt2_dev"
1867 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1868 error_noexit "enable remote dir create failed"
1870 shall_cleanup_mdt1=true
1871 elif [ "$dne_upgrade" != "no" ]; then
1872 local fs2mdsdev=$(mdsdevname 1_2)
1873 local fs2mdsvdev=$(mdsvdevname 1_2)
1875 echo "mkfs new MDT on ${fs2mdsdev}...."
1876 if [ $(facet_fstype mds1) == ldiskfs ]; then
1877 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1880 add $SINGLEMDS $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1881 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1882 error_noexit "Mkfs new MDT failed"
1886 [[ $(facet_fstype mds1) != zfs ]] || import_zpool mds1
1888 $r $TUNEFS --dryrun $fs2mdsdev || {
1889 error_noexit "tunefs.lustre before mounting the MDT"
1893 echo "mount new MDT....$fs2mdsdev"
1894 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1895 error_noexit "mount mdt1 failed"
1899 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1900 error_noexit "enable remote dir create failed"
1902 shall_cleanup_mdt1=true
1905 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1906 error_noexit "Getting MDT UUID"
1909 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1910 error_noexit "Unexpected MDT UUID: \"$uuid\""
1914 $r $TUNEFS --dryrun $ost_dev || {
1915 error_noexit "tunefs.lustre before mounting the OST"
1918 if [ "$writeconf" ]; then
1919 mopts=mgsnode=$nid,$writeconf
1920 if [ $fstype == "ldiskfs" ]; then
1922 $r $TUNEFS --quota $ost_dev || {
1924 error_noexit "Enable ost quota feature"
1930 if [ $fstype == "ldiskfs" ]; then
1935 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1936 error_noexit "Mounting the OST"
1939 shall_cleanup_ost=true
1941 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1942 error_noexit "Getting OST UUID"
1945 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1946 error_noexit "Unexpected OST UUID: \"$uuid\""
1950 $r $LCTL conf_param $fsname-OST0000.osc.max_dirty_mb=15 || {
1951 error_noexit "Setting \"max_dirty_mb\""
1954 $r $LCTL conf_param $fsname-OST0000.failover.node=$nid || {
1955 error_noexit "Setting OST \"failover.node\""
1958 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1959 error_noexit "Setting \"max_rpcs_in_flight\""
1962 $r $LCTL conf_param $fsname-MDT0000.failover.node=$nid || {
1963 error_noexit "Setting MDT \"failover.node\""
1966 $r $LCTL pool_new $fsname.interop || {
1967 error_noexit "Setting \"interop\""
1970 $r $LCTL conf_param $fsname-MDT0000.lov.stripesize=4M || {
1971 error_noexit "Setting \"lov.stripesize\""
1974 $r $LCTL conf_param $fsname-MDT0000.mdd.atime_diff=70 || {
1975 error_noexit "Setting \"mdd.atime_diff\""
1979 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1980 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1981 error_noexit "Start OI scrub on OST0"
1985 # The oi_scrub should be on ost1, but for test_32(),
1986 # all on the SINGLEMDS.
1987 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1988 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1989 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1990 error_noexit "Failed to get the expected 'completed'"
1994 local UPDATED=$($r $LCTL get_param -n \
1995 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1996 awk '/^updated/ { print $2 }')
1997 [ $UPDATED -ge 1 ] || {
1998 error_noexit "Only $UPDATED objects have been converted"
2003 if [ "$dne_upgrade" != "no" ]; then
2004 $r $LCTL conf_param \
2005 $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2006 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2009 $r $LCTL conf_param $fsname-MDT0001.failover.node=$nid || {
2010 error_noexit "Setting MDT1 \"failover.node\""
2013 $r $LCTL conf_param $fsname-MDT0001.lov.stripesize=4M || {
2014 error_noexit "Setting MDT1 \"lov.stripesize\""
2019 if [ "$writeconf" ]; then
2020 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2021 error_noexit "Mounting the client"
2025 shall_cleanup_lustre=true
2026 $r $LCTL set_param debug="$PTLDEBUG"
2028 t32_verify_quota $node $fsname $tmp/mnt/lustre || {
2029 error_noexit "verify quota failed"
2033 if $r test -f $tmp/list; then
2035 # There is not a Test Framework API to copy files to or
2036 # from a remote node.
2038 # LU-2393 - do both sorts on same node to ensure locale
2040 local list_file=$tmp/list
2042 if $mdt2_is_available; then
2043 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2044 $r test -f $tmp/list2; then
2045 list_file=$tmp/list2
2046 pushd $tmp/mnt/lustre/striped_dir_old
2048 pushd $tmp/mnt/lustre/remote_dir
2051 pushd $tmp/mnt/lustre
2053 $r cat $list_file | sort -k 6 >$tmp/list.orig
2054 ls -Rni --time-style=+%s | sort -k 6 |
2055 sed 's/\. / /' >$tmp/list || {
2061 # 32-bit and 64-bit clients use different algorithms to
2062 # convert FIDs into inode numbers. Hence, remove the
2063 # inode numbers from the lists, if the original list was
2064 # created on an architecture with different number of
2067 if [ $(t32_bits_per_long $(uname -m)) != \
2068 $(t32_bits_per_long $img_arch) ]; then
2069 echo "Different number of bits per \"long\"" \
2070 "from the disk image"
2071 for list in list.orig list; do
2072 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2076 if ! diff -ub $tmp/list.orig $tmp/list; then
2077 error_noexit "list verification failed"
2081 echo "list verification skipped"
2084 if [ "$dne_upgrade" != "no" ]; then
2085 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2086 error_noexit "set striped dir failed"
2090 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2092 pushd $tmp/mnt/lustre
2093 tar -cf - . --exclude=./striped_dir \
2094 --exclude=./striped_dir_old \
2095 --exclude=./remote_dir |
2096 tar -xvf - -C striped_dir 1>/dev/null || {
2097 error_noexit "cp to striped dir failed"
2103 # If it is upgrade from DNE (2.5), then rename the remote dir,
2104 # which is created in 2.5 to striped dir.
2105 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2106 stripe_index=$($LFS getdirstripe -i \
2107 $tmp/mnt/lustre/remote_dir)
2109 [[ $stripe_index -eq 1 ]] || {
2110 error_noexit "get index \"$stripe_index\"" \
2111 "from remote dir failed"
2114 mv $tmp/mnt/lustre/remote_dir \
2115 $tmp/mnt/lustre/striped_dir/ || {
2116 error_noexit "mv remote dir failed"
2121 # If it is upgraded from DNE (2.7), then move the striped dir
2122 # which was created in 2.7 to the new striped dir.
2123 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2124 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2125 stripe_count=$($LFS getdirstripe -c \
2126 $tmp/mnt/lustre/striped_dir_old)
2127 [[ $stripe_count -eq 2 ]] || {
2128 error_noexit "get count $stripe_count" \
2129 "from striped dir failed"
2132 mv $tmp/mnt/lustre/striped_dir_old \
2133 $tmp/mnt/lustre/striped_dir/ || {
2134 error_noexit "mv striped dir failed"
2140 $r $LCTL set_param -n osd*.*.force_sync=1
2141 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2142 error_noexit "dd failed"
2145 rm -rf $tmp/mnt/lustre/tmp_file || {
2146 error_noexit "rm failed"
2150 if $r test -f $tmp/sha1sums; then
2151 # LU-2393 - do both sorts on same node to ensure locale
2153 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2154 if [ "$dne_upgrade" != "no" ]; then
2155 pushd $tmp/mnt/lustre/striped_dir
2157 pushd $tmp/mnt/lustre
2160 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2161 ! -name .lustre -type f -exec sha1sum {} \; |
2162 sort -k 2 >$tmp/sha1sums || {
2164 error_noexit "sha1sum"
2168 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2169 error_noexit "sha1sum verification failed"
2173 # if upgrade from DNE(2.5), then check remote directory
2174 # if upgrade from DNE(2.7), then check striped directory
2175 if $mdt2_is_available &&
2176 [[ "$dne_upgrade" != "no" ]]; then
2177 local new_dir="$tmp/mnt/lustre/striped_dir"
2178 local striped_dir_old="$new_dir/striped_dir_old"
2180 local dir_list="$new_dir/remote_dir"
2181 [[ ! -d $triped_dir_old ]] ||
2182 dir_list+=" $striped_dir_old"
2184 for dir in $dir_list; do
2186 find ! -name .lustre -type f \
2187 -exec sha1sum {} \; |
2188 sort -k 2 >$tmp/sha1sums || {
2190 error_noexit "sha1sum"
2194 if ! diff -ub $tmp/sha1sums.orig \
2196 error_noexit "sha1sum $dir" \
2203 echo "sha1sum verification skipped"
2206 if [ "$dne_upgrade" != "no" ]; then
2207 rm -rf $tmp/mnt/lustre/striped_dir || {
2208 error_noexit "remove remote dir failed"
2213 # migrate files/dirs to remote MDT, then move them back
2214 if [ $(lustre_version_code mds1) -ge $(version_code 2.7.50) -a \
2215 $dne_upgrade != "no" ]; then
2216 $r $LCTL set_param -n \
2217 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2219 echo "test migration"
2220 pushd $tmp/mnt/lustre
2221 for dir in $(find ! -name .lustre ! -name . -type d); do
2222 mdt_index=$($LFS getdirstripe -i $dir)
2223 stripe_cnt=$($LFS getdirstripe -c $dir)
2224 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2225 $LFS mv -M 1 $dir || {
2227 error_noexit "migrate MDT1 failed"
2233 for dir in $(find ! -name . ! -name .lustre -type d); do
2234 mdt_index=$($LFS getdirstripe -i $dir)
2235 stripe_cnt=$($LFS getdirstripe -c $dir)
2236 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2237 $LFS mv -M 0 $dir || {
2239 error_noexit "migrate MDT0 failed"
2248 # When adding new data verification tests, please check for
2249 # the presence of the required reference files first, like
2250 # the "sha1sums" and "list" tests above, to avoid the need to
2251 # regenerate every image for each test addition.
2254 nrpcs_orig=$($LCTL get_param \
2255 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2256 error_noexit "Getting \"max_rpcs_in_flight\""
2259 nrpcs=$((nrpcs_orig + 5))
2260 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=$nrpcs || {
2261 error_noexit "Changing \"max_rpcs_in_flight\""
2264 wait_update $HOSTNAME "$LCTL get_param \
2265 -n mdc.*MDT0000*.max_rpcs_in_flight" $nrpcs || {
2266 error_noexit "Verifying \"max_rpcs_in_flight\""
2270 umount $tmp/mnt/lustre || {
2271 error_noexit "Unmounting the client"
2274 shall_cleanup_lustre=false
2276 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2277 $r $UMOUNT $tmp/mnt/mdt1 || {
2278 error_noexit "Unmounting the MDT2"
2281 shall_cleanup_mdt1=false
2284 $r $UMOUNT $tmp/mnt/mdt || {
2285 error_noexit "Unmounting the MDT"
2288 shall_cleanup_mdt=false
2290 $r $UMOUNT $tmp/mnt/ost || {
2291 error_noexit "Unmounting the OST"
2294 shall_cleanup_ost=false
2296 t32_reload_modules $node || {
2297 error_noexit "Reloading modules"
2301 if [[ $fstype == zfs ]]; then
2302 local poolname=t32fs-mdt1
2304 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2305 $ZPOOL import -f -d $tmp $poolname"
2307 # upgrade zpool to latest supported features,
2308 # including dnode quota accounting in 0.7.0
2309 $r "$ZPOOL upgrade $poolname"
2312 # mount a second time to make sure we didnt leave upgrade flag on
2313 $r $TUNEFS --dryrun $mdt_dev || {
2315 error_noexit "tunefs.lustre before remounting the MDT"
2319 mopts=exclude=$fsname-OST0000
2320 if [ $fstype == "ldiskfs" ]; then
2323 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2324 error_noexit "Remounting the MDT"
2327 shall_cleanup_mdt=true
2337 for tarball in $tarballs; do
2338 t32_test $tarball || let "rc += $?"
2342 run_test 32a "Upgrade (not live)"
2350 for tarball in $tarballs; do
2351 t32_test $tarball writeconf || let "rc += $?"
2355 run_test 32b "Upgrade with writeconf"
2362 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2364 for tarball in $tarballs; do
2365 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2366 echo $tarball | grep "1_8" && continue
2367 echo $tarball | grep "2_1" && continue
2369 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2373 run_test 32c "dne upgrade test"
2381 for tarball in $tarballs; do
2382 ff_convert=yes t32_test $tarball || rc=$?
2386 run_test 32d "convert ff test"
2388 test_33a() { # bug 12333, was test_33
2389 local FSNAME2=test-123
2390 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2393 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2395 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2396 local dev=${SINGLEMDS}_dev
2397 local MDSDEV=${!dev}
2398 is_blkdev $SINGLEMDS $MDSDEV &&
2399 skip_env "mixed loopback and real device not working" &&
2403 local fs2mdsdev=$(mdsdevname 1_2)
2404 local fs2ostdev=$(ostdevname 1_2)
2405 local fs2mdsvdev=$(mdsvdevname 1_2)
2406 local fs2ostvdev=$(ostvdevname 1_2)
2408 if [ $(facet_fstype mds1) == ldiskfs ]; then
2409 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2412 if combined_mgs_mds; then
2413 local mgs_flag="--mgs"
2416 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
2417 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
2419 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2420 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2421 $fs2ostvdev || exit 10
2423 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2424 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2425 do_facet mgs "$LCTL conf_param $FSNAME2.sys.timeout=200" ||
2426 error "$LCTL conf_param $FSNAME2.sys.timeout=200 failed"
2427 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2428 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2431 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2432 $GETSTRIPE $MOUNT2/hosts || error "$GETSTRIPE $MOUNT2/hosts failed"
2437 cleanup_nocli || error "cleanup_nocli failed with $?"
2439 run_test 33a "Mount ost with a large index number"
2441 test_33b() { # was test_34
2444 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2445 # Drop lock cancelation reply during umount
2446 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2447 do_facet client $LCTL set_param fail_loc=0x80000304
2448 #lctl set_param debug=-1
2449 umount_client $MOUNT
2450 cleanup || error "cleanup failed with $?"
2452 run_test 33b "Drop cancel during umount"
2456 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2457 manual_umount_client
2459 do_facet client killall -USR1 multiop
2460 if [ $rc -eq 0 ]; then
2461 error "umount not fail!"
2464 cleanup || error "cleanup failed with rc $?"
2466 run_test 34a "umount with opened file should be fail"
2470 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2471 stop_mds || error "Unable to stop MDS"
2473 manual_umount_client --force || error "mtab after failed umount with $?"
2475 cleanup || error "cleanup failed with $?"
2477 run_test 34b "force umount with failed mds should be normal"
2481 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2482 stop_ost || error "Unable to stop OST1"
2484 manual_umount_client --force || error "mtab after failed umount with $?"
2486 cleanup || error "cleanup failed with $?"
2488 run_test 34c "force umount with failed ost should be normal"
2490 test_35a() { # bug 12459
2493 DBG_SAVE="`$LCTL get_param -n debug`"
2494 $LCTL set_param debug="ha"
2496 log "Set up a fake failnode for the MDS"
2498 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2499 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2500 do_facet mgs "$LCTL conf_param \
2501 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2502 error "Setting ${device}.failover.node=\
2503 $(h2nettype $FAKENID) failed."
2505 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2508 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2511 log "Stopping the MDT: $device"
2512 stop_mdt 1 || error "MDT0 stop fail"
2514 df $MOUNT > /dev/null 2>&1 &
2516 log "Restarting the MDT: $device"
2517 start_mdt 1 || error "MDT0 start fail"
2518 log "Wait for df ($DFPID) ... "
2521 $LCTL set_param debug="$DBG_SAVE"
2523 # retrieve from the log the first server that the client tried to
2524 # contact after the connection loss
2525 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2526 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2527 /import_select_connection.*$device-mdc.* using connection/ {
2529 if (\\\$NF ~ /$FAKENID/)
2535 }" $TMP/lustre-log-$TESTNAME.log`
2536 [ "$NEXTCONN" != "0" ] &&
2537 error "Tried to connect to ${NEXTCONN} not last active server"
2538 cleanup || error "cleanup failed with $?"
2539 # remove nid settings
2540 writeconf_or_reformat
2542 run_test 35a "Reconnect to the last active server first"
2544 test_35b() { # bug 18674
2545 remote_mds || { skip "local MDS" && return 0; }
2549 $LCTL set_param debug="ha"
2551 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2554 log "Set up a fake failnode for the MDS"
2556 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2557 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2558 do_facet mgs "$LCTL conf_param \
2559 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2560 error "Set ${device}.failover.node=\
2561 $(h2nettype $FAKENID) failed"
2563 local at_max_saved=0
2564 # adaptive timeouts may prevent seeing the issue
2565 if at_is_enabled; then
2566 at_max_saved=$(at_max_get mds)
2567 at_max_set 0 mds client
2570 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2572 log "Injecting EBUSY on MDS"
2573 # Setting OBD_FAIL_MDS_RESEND=0x136
2574 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2575 error "unable to set param fail_loc=0x80000136"
2577 $LCTL set_param mdc.${FSNAME}*.stats=clear
2579 log "Creating a test file and stat it"
2580 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2581 stat $MOUNT/$tdir/$tfile
2583 log "Stop injecting EBUSY on MDS"
2584 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2585 error "unable to set param fail_loc=0"
2586 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2589 # restore adaptive timeout
2590 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2592 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2594 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2595 awk '/mds_connect/{print $2}')
2597 # retrieve from the log if the client has ever tried to
2598 # contact the fake server after the loss of connection
2599 FAILCONN=`awk "BEGIN {ret = 0;}
2600 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2602 if (\\\$NF ~ /$FAKENID/) {
2607 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2609 [ "$FAILCONN" == "0" ] &&
2610 error "The client reconnection has not been triggered"
2611 [ "$FAILCONN" == "2" ] &&
2612 error "Primary server busy, client reconnect to failover failed"
2615 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2616 # Reconnects are supposed to be rate limited to one every 5s
2617 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2618 error "Too many reconnects $CONNCNT"
2620 cleanup || error "cleanup failed with $?"
2621 # remove nid settings
2622 writeconf_or_reformat
2624 run_test 35b "Continue reconnection retries, if the active server is busy"
2627 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
2629 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2630 { skip "remote OST" && return 0; }
2633 local FSNAME2=test1234
2634 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2636 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2638 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2639 is_blkdev $SINGLEMDS $MDSDEV &&
2640 skip_env "mixed loopback and real device not working" && return
2643 local fs2mdsdev=$(mdsdevname 1_2)
2644 local fs2ostdev=$(ostdevname 1_2)
2645 local fs3ostdev=$(ostdevname 2_2)
2646 local fs2mdsvdev=$(mdsvdevname 1_2)
2647 local fs2ostvdev=$(ostvdevname 1_2)
2648 local fs3ostvdev=$(ostvdevname 2_2)
2650 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2651 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2652 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2653 # different one than the default value here.
2654 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2655 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2656 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2657 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2659 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2660 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2661 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2662 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2663 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2665 sleep 5 # until 11778 fixed
2667 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2669 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2670 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2671 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2672 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2673 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2674 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2675 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2676 DFTOTAL=$(echo $STRING | cut -d, -f1)
2677 DFUSED=$(echo $STRING | cut -d, -f2)
2678 DFAVAIL=$(echo $STRING | cut -d, -f3)
2679 DFFREE=$(($DFTOTAL - $DFUSED))
2681 ALLOWANCE=$((64 * $OSTCOUNT))
2683 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2684 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2685 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2688 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2689 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2690 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2693 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2694 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2695 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2700 stop fs3ost -f || error "unable to stop OST3"
2701 stop fs2ost -f || error "unable to stop OST2"
2702 stop fs2mds -f || error "unable to stop second MDS"
2703 unload_modules_conf || error "unable unload modules"
2706 run_test 36 "df report consistency on OSTs with different block size"
2709 local mntpt=$(facet_mntpt $SINGLEMDS)
2710 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2711 local mdsdev_sym="$TMP/sym_mdt.img"
2712 local opts=$MDS_MOUNT_OPTS
2715 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2716 skip "ldiskfs only test"
2720 echo "MDS : $mdsdev"
2721 echo "SYMLINK : $mdsdev_sym"
2722 do_facet $SINGLEMDS rm -f $mdsdev_sym
2724 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2726 echo "mount symlink device - $mdsdev_sym"
2728 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2729 opts=$(csa_add "$opts" -o loop)
2731 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2732 $mdsdev_sym $mntpt 2>&1)
2735 echo mount_op=$mount_op
2737 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2739 if $(echo $mount_op | grep -q "unable to set tunable"); then
2740 error "set tunables failed for symlink device"
2743 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2745 run_test 37 "verify set tunables works for symlink device"
2747 test_38() { # bug 14222
2748 local fstype=$(facet_fstype $SINGLEMDS)
2749 local mntpt=$(facet_mntpt $SINGLEMDS)
2754 local SRC="/etc /bin"
2755 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2756 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2757 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2758 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2759 error "copying $SRC to $DIR/$tdir"
2761 umount_client $MOUNT || error "umount_client $MOUNT failed"
2762 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2763 stop_mds || error "Unable to stop MDS"
2764 log "delete lov_objid file on MDS"
2766 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2768 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2770 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2772 # check create in mds_lov_connect
2773 start_mds || error "unable to start MDS"
2774 mount_client $MOUNT || error "mount_client $MOUNT failed"
2776 [ $V ] && log "verifying $DIR/$tdir/$f"
2777 diff -q $f $DIR/$tdir/$f || ERROR=y
2779 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2780 if [ "$ERROR" = "y" ]; then
2781 # check it's updates in sync
2782 umount_client $MOUNT
2784 mount_fstype $SIGNLEMDS
2785 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2786 unmount_fstype $SINGLEMDS
2787 error "old and new files are different after connect" || true
2789 touch $DIR/$tdir/f2 || error "f2 file create failed"
2791 # check it's updates in sync
2792 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2795 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2797 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2798 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2800 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2802 start_mds || error "unable to start MDS"
2803 mount_client $MOUNT || error "mount_client $MOUNT failed"
2805 [ $V ] && log "verifying $DIR/$tdir/$f"
2806 diff -q $f $DIR/$tdir/$f || ERROR=y
2808 touch $DIR/$tdir/f3 || error "f3 file create failed"
2809 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2810 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2812 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2813 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2814 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2816 [ "$ERROR" = "y" ] &&
2817 error "old and new files are different after sync" || true
2819 log "files compared the same"
2820 cleanup || error "cleanup failed with $?"
2822 run_test 38 "MDS recreates missing lov_objid file from OST data"
2827 cleanup || error "cleanup failed with $?"
2828 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2829 error "memory leak detected" || true
2831 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2833 test_40() { # bug 15759
2834 start_ost || error "Unable to start OST1"
2835 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2836 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2838 cleanup || error "cleanup failed with rc $?"
2840 run_test 40 "race during service thread startup"
2842 test_41a() { #bug 14134
2843 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2844 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2845 skip "Loop devices does not work with nosvc option"
2850 { skip "needs combined MGT and MDT device" && return 0; }
2852 start_mdt 1 -o nosvc -n
2853 if [ $MDSCOUNT -ge 2 ]; then
2854 for num in $(seq 2 $MDSCOUNT); do
2855 start_mdt $num || return
2858 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2859 start_mdt 1 -o nomgs,force
2860 mount_client $MOUNT || error "mount_client $MOUNT failed"
2863 echo "blah blah" > $MOUNT/$tfile
2866 umount_client $MOUNT || error "umount_client $MOUNT failed"
2867 stop ost1 -f || error "unable to stop OST1"
2868 stop_mds || error "Unable to stop MDS"
2869 stop_mds || error "Unable to stop MDS on second try"
2871 run_test 41a "mount mds with --nosvc and --nomgs"
2874 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2875 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2876 skip "Loop devices does not work with nosvc option"
2880 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2884 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2886 start_mdt 1 -o nosvc -n
2887 if [ $MDSCOUNT -ge 2 ]; then
2888 for num in $(seq 2 $MDSCOUNT); do
2889 start_mdt $num || return
2892 start_ost || error "Unable to start OST1"
2893 start_mdt 1 -o nomgs,force
2894 mount_client $MOUNT || error "mount_client $MOUNT failed"
2897 echo "blah blah" > $MOUNT/$tfile
2898 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
2900 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
2901 stop_ost || error "Unable to stop OST1"
2902 stop_mds || error "Unable to stop MDS"
2903 stop_mds || error "Unable to stop MDS on second try"
2905 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2908 local server_version=$(lustre_version_code $SINGLEMDS)
2909 local oss_list=$(comma_list $(osts_nodes))
2911 [[ $server_version -ge $(version_code 2.6.52) ]] ||
2912 [[ $server_version -ge $(version_code 2.5.26) &&
2913 $server_version -lt $(version_code 2.5.50) ]] ||
2914 [[ $server_version -ge $(version_code 2.5.4) &&
2915 $server_version -lt $(version_code 2.5.11) ]] ||
2916 { skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"; return; }
2918 # ensure mds1 ost1 have been created even if running sub-test standalone
2921 cleanup || error "cleanup failed"
2923 # using directly mount command instead of start() function to avoid
2924 # any side effect of // with others/externals tools/features
2925 # ("zpool import", ...)
2927 # MDT concurrent start
2929 LOAD_MODULES_REMOTE=true load_modules
2930 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
2931 error "MDT concurrent start: libcfs module not loaded"
2933 local mds1dev=$(mdsdevname 1)
2934 local mds1mnt=$(facet_mntpt mds1)
2935 local mds1fstype=$(facet_fstype mds1)
2936 local mds1opts=$MDS_MOUNT_OPTS
2938 if [ $mds1fstype == ldiskfs ] &&
2939 ! do_facet mds1 test -b $mds1dev; then
2940 mds1opts=$(csa_add "$mds1opts" -o loop)
2942 if [[ $mds1fstype == zfs ]]; then
2943 import_zpool mds1 || return ${PIPESTATUS[0]}
2946 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
2947 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
2949 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
2952 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
2956 do_facet mds1 "$LCTL set_param fail_loc=0x0"
2957 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
2958 echo "1st MDT start succeed"
2959 echo "2nd MDT start failed with $rc2"
2960 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
2961 echo "1st MDT start failed with $rc"
2962 echo "2nd MDT start succeed"
2965 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
2968 if [ $MDSCOUNT -ge 2 ]; then
2969 for num in $(seq 2 $MDSCOUNT); do
2970 start_mdt $num || return
2974 # OST concurrent start
2976 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
2977 error "OST concurrent start: libcfs module not loaded"
2979 local ost1dev=$(ostdevname 1)
2980 local ost1mnt=$(facet_mntpt ost1)
2981 local ost1fstype=$(facet_fstype ost1)
2982 local ost1opts=$OST_MOUNT_OPTS
2984 if [ $ost1fstype == ldiskfs ] &&
2985 ! do_facet ost1 test -b $ost1dev; then
2986 ost1opts=$(csa_add "$ost1opts" -o loop)
2988 if [[ $ost1fstype == zfs ]]; then
2989 import_zpool ost1 || return ${PIPESTATUS[0]}
2992 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
2993 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
2995 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
2998 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
3002 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3003 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3004 echo "1st OST start succeed"
3005 echo "2nd OST start failed with $rc2"
3006 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3007 echo "1st OST start failed with $rc"
3008 echo "2nd OST start succeed"
3012 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3018 # verify everything ok
3023 error "MDT(s) start failed"
3031 error "OST(s) start failed"
3039 error "client start failed"
3046 error "client mount failed"
3050 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3052 test_42() { #bug 14693
3054 check_mount || error "client was not mounted"
3056 do_facet mgs $LCTL conf_param $FSNAME.llite.some_wrong_param=10
3057 umount_client $MOUNT ||
3058 error "unmounting client failed with invalid llite param"
3059 mount_client $MOUNT ||
3060 error "mounting client failed with invalid llite param"
3062 do_facet mgs $LCTL conf_param $FSNAME.sys.some_wrong_param=20
3063 cleanup || error "stopping $FSNAME failed with invalid sys param"
3065 check_mount || error "client was not mounted with invalid sys param"
3066 cleanup || error "stopping $FSNAME failed with invalid sys param"
3068 run_test 42 "allow client/server mount/unmount with invalid config param"
3071 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.58) ]] ||
3072 { skip "Need MDS version at least 2.5.58" && return 0; }
3073 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
3076 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
3077 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
3081 chmod ugo+x $DIR || error "chmod 0 failed"
3082 set_conf_param_and_check mds1 \
3083 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
3084 "$FSNAME.mdt.root_squash" \
3086 wait_update $HOSTNAME \
3087 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3089 error "check llite root_squash failed!"
3090 set_conf_param_and_check mds1 \
3091 "$LCTL get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
3092 "$FSNAME.mdt.nosquash_nids" \
3094 wait_update $HOSTNAME \
3095 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3097 error "check llite nosquash_nids failed!"
3100 # create set of test files
3102 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
3103 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
3104 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
3106 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
3107 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
3109 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
3110 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
3111 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
3113 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
3114 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
3115 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
3118 # check root_squash:
3119 # set root squash UID:GID to RUNAS_ID
3120 # root should be able to access only files owned by RUNAS_ID
3122 set_conf_param_and_check mds1 \
3123 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
3124 "$FSNAME.mdt.root_squash" \
3125 "$RUNAS_ID:$RUNAS_ID"
3126 wait_update $HOSTNAME \
3127 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3128 "$RUNAS_ID:$RUNAS_ID" ||
3129 error "check llite root_squash failed!"
3131 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
3132 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3133 error "$ST: root read permission is denied"
3134 echo "$ST: root read permission is granted - ok"
3137 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3138 error "$ST: root write permission is denied"
3139 echo "$ST: root write permission is granted - ok"
3141 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3142 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3143 error "$ST: root read permission is granted"
3144 echo "$ST: root read permission is denied - ok"
3147 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3148 error "$ST: root write permission is granted"
3149 echo "$ST: root write permission is denied - ok"
3151 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3152 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
3153 error "$ST: root unlink permission is granted"
3154 echo "$ST: root unlink permission is denied - ok"
3156 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
3157 error "$ST: root create permission is granted"
3158 echo "$ST: root create permission is denied - ok"
3161 # check root_squash is enforced independently
3162 # of client cache content
3164 # access file by USER1, keep access open
3165 # root should be denied access to user file
3167 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
3171 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
3172 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3173 { kill $pid; error "$ST: root read permission is granted"; }
3174 echo "$ST: root read permission is denied - ok"
3177 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3178 { kill $pid; error "$ST: root write permission is granted"; }
3179 echo "$ST: root write permission is denied - ok"