7 # bug number for skipped test:
8 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
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 is_sles11; then # LU-2181
27 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 23a 34b"
30 if [ "$FAILURE_MODE" = "HARD" ]; then
31 CONFIG_EXCEPTIONS="24a " &&
32 echo "Except the tests: $CONFIG_EXCEPTIONS for " \
33 "FAILURE_MODE=$FAILURE_MODE, b=23573" &&
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
37 # bug number for skipped test:
38 # a tool to create lustre filesystem images
39 ALWAYS_EXCEPT="32newtarball $ALWAYS_EXCEPT"
42 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
44 PTLDEBUG=${PTLDEBUG:--1}
46 LUSTRE=${LUSTRE:-$(dirname $0)/..}
47 RLUSTRE=${RLUSTRE:-$LUSTRE}
48 export MULTIOP=${MULTIOP:-multiop}
50 . $LUSTRE/tests/test-framework.sh
52 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
54 # use small MDS + OST size to speed formatting time
55 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
56 # STORED_MDSSIZE is used in test_18
57 STORED_MDSSIZE=$MDSSIZE
58 STORED_OSTSIZE=$OSTSIZE
70 if ! combined_mgs_mds; then
71 # bug number for skipped test: 23954
72 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
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: LU-2778 LU-4444
82 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 57b 69"
87 require_dsh_mds || exit 0
88 require_dsh_ost || exit 0
90 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45 69"
95 # The MGS must be started before the OSTs for a new fs, so start
96 # and stop to generate the startup logs.
99 wait_osc_import_state mds ost FULL
104 reformat_and_config() {
106 if ! combined_mgs_mds ; then
112 writeconf_or_reformat() {
113 # There are at most 2 OSTs for write_conf test
114 # who knows if/where $TUNEFS is installed?
115 # Better reformat if it fails...
116 writeconf_all $MDSCOUNT 2 ||
117 { echo "tunefs failed, reformatting instead" &&
118 reformat_and_config && return 0; }
128 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
134 local dev=$(mdsdevname $num)
137 echo "start mds service on `facet_active_host $facet`"
138 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
144 local dev=$(mdsdevname $num)
147 echo "stop mds service on `facet_active_host $facet`"
148 # These tests all use non-failover stop
149 stop $facet -f || return 97
155 for num in $(seq $MDSCOUNT); do
156 start_mdt $num $@ || return 94
161 if ! combined_mgs_mds ; then
169 for num in $(seq $MDSCOUNT); do
170 stop_mdt $num || return 97
175 echo "stop mgs service on `facet_active_host mgs`"
176 # These tests all use non-failover stop
177 stop mgs -f || return 97
181 echo "start ost1 service on `facet_active_host ost1`"
182 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
186 echo "stop ost1 service on `facet_active_host ost1`"
187 # These tests all use non-failover stop
188 stop ost1 -f || return 98
192 echo "start ost2 service on `facet_active_host ost2`"
193 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
197 echo "stop ost2 service on `facet_active_host ost2`"
198 # These tests all use non-failover stop
199 stop ost2 -f || return 93
204 echo "mount $FSNAME on ${MOUNTPATH}....."
205 zconf_mount $(hostname) $MOUNTPATH || return 96
209 local mountopt="remount,$1"
211 echo "remount '$1' lustre on ${MOUNTPATH}....."
212 zconf_mount $(hostname) $MOUNTPATH "$mountopt" || return 96
217 echo "umount lustre on ${MOUNTPATH}....."
218 zconf_umount $(hostname) $MOUNTPATH || return 97
221 manual_umount_client(){
224 echo "manual umount lustre on ${MOUNT}...."
225 do_facet client "umount -d ${FORCE} $MOUNT"
231 start_mds || error "MDT start failed"
232 start_ost || error "Unable to start OST1"
233 mount_client $MOUNT || error "client start failed"
234 client_up || error "client_up failed"
243 unload_modules_conf () {
244 if combined_mgs_mds || ! local_mode; then
245 unload_modules || return 1
250 stop_ost || return 202
251 stop_mds || return 201
252 unload_modules_conf || return 203
256 umount_client $MOUNT || return 200
257 cleanup_nocli || return $?
262 echo "umount $MOUNT2 ..."
263 umount $MOUNT2 || true
264 echo "stopping fs2mds ..."
265 stop fs2mds -f || true
266 echo "stopping fs2ost ..."
267 stop fs2ost -f || true
271 do_facet client "cp /etc/passwd $DIR/a" || return 71
272 do_facet client "rm $DIR/a" || return 72
273 # make sure lustre is actually mounted (touch will block,
274 # but grep won't, so do it after)
275 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
276 echo "setup single mount lustre success"
280 do_facet client "touch $DIR/a" || return 71
281 do_facet client "rm $DIR/a" || return 72
282 do_facet client "touch $DIR2/a" || return 73
283 do_facet client "rm $DIR2/a" || return 74
284 echo "setup double mount lustre success"
289 if [ "$ONLY" == "setup" ]; then
294 if [ "$ONLY" == "cleanup" ]; then
301 #create single point mountpoint
307 check_mount || error "check_mount failed"
308 cleanup || error "cleanup failed with $?"
310 run_test 0 "single mount setup"
313 start_mds || error "MDS start failed"
314 start_ost || error "unable to start OST"
315 echo "start ost second time..."
316 start_ost && error "2nd OST start should fail"
317 mount_client $MOUNT || error "client start failed"
318 check_mount || error "check_mount failed"
319 cleanup || error "cleanup failed with $?"
321 run_test 1 "start up ost twice (should return errors)"
324 start_mds || error "MDT start failed"
325 echo "start mds second time.."
326 start_mds && error "2nd MDT start should fail"
327 start_ost || error "OST start failed"
328 mount_client $MOUNT || error "mount_client failed to start client"
329 check_mount || error "check_mount failed"
330 cleanup || error "cleanup failed with $?"
332 run_test 2 "start up mds twice (should return err)"
336 #mount.lustre returns an error if already in mtab
337 mount_client $MOUNT && error "2nd client mount should fail"
338 check_mount || error "check_mount failed"
339 cleanup || error "cleanup failed with $?"
341 run_test 3 "mount client twice (should return err)"
345 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
346 stop_ost || error "Unable to stop OST1"
349 # ok for ost to fail shutdown
350 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
351 error "cleanup failed with $?"
354 run_test 4 "force cleanup ost, then cleanup"
356 test_5a() { # was test_5
358 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
359 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
361 stop_mds || error "Unable to stop MDS"
363 # cleanup may return an error from the failed
364 # disconnects; for now I'll consider this successful
365 # if all the modules have unloaded.
369 echo "killing umount"
370 kill -TERM $UMOUNT_PID
371 echo "waiting for umount to finish"
373 if grep " $MOUNT " /proc/mounts; then
374 echo "test 5: /proc/mounts after failed umount"
378 echo "killing umount"
379 kill -TERM $UMOUNT_PID
380 echo "waiting for umount to finish"
382 grep " $MOUNT " /proc/mounts &&
383 error "/proc/mounts after second umount"
386 # manual_mount_client may fail due to umount succeeding above
388 # stop_mds is a no-op here, and should not fail
389 cleanup_nocli || error "cleanup_nocli failed with $?"
390 # df may have lingering entry
392 # mtab may have lingering entry
396 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
398 grep -q $MOUNT" " /etc/mtab || break
399 echo "Waiting /etc/mtab updated ... "
400 WAIT=$(( WAIT + sleep))
402 [ "$WAIT" -eq "$MAX_WAIT" ] &&
403 error "/etc/mtab is not updated in $WAIT secs"
404 echo "/etc/mtab updated in $WAIT secs"
406 run_test 5a "force cleanup mds, then cleanup"
414 grep " $MOUNT " /etc/mtab &&
415 error false "unexpected entry in mtab before mount" && return 10
417 start_ost || error "OST start failed"
418 if ! combined_mgs_mds ; then
419 trap cleanup_5b EXIT ERR
420 start_mds || error "MDS start failed"
424 mount_client $MOUNT && error "mount_client $MOUNT should fail"
425 grep " $MOUNT " /etc/mtab &&
426 error "$MOUNT entry in mtab after failed mount"
428 # stop_mds is a no-op here, and should not fail
429 cleanup_nocli || error "cleanup_nocli failed with $?"
430 if ! combined_mgs_mds ; then
434 run_test 5b "Try to start a client with no MGS (should return errs)"
437 grep " $MOUNT " /etc/mtab &&
438 error false "unexpected entry in mtab before mount" && return 10
440 start_mds || error "MDS start failed"
441 start_ost || error "OST start failed"
442 local oldfs="${FSNAME}"
443 FSNAME="wrong.${FSNAME}"
444 mount_client $MOUNT || :
446 grep " $MOUNT " /etc/mtab &&
447 error "$MOUNT entry in mtab after failed mount"
449 cleanup_nocli || error "cleanup_nocli failed with $?"
451 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
454 grep " $MOUNT " /etc/mtab &&
455 error false "unexpected entry in mtab before mount" && return 10
457 start_ost || error "OST start failed"
458 start_mds || error "MDS start failed"
459 stop_ost || error "Unable to stop OST1"
460 mount_client $MOUNT || error "mount_client $MOUNT failed"
461 cleanup || error "cleanup_nocli failed with $?"
462 grep " $MOUNT " /etc/mtab &&
463 error "$MOUNT entry in mtab after unmount"
466 run_test 5d "mount with ost down"
469 grep " $MOUNT " /etc/mtab &&
470 error false "unexpected entry in mtab before mount" && return 10
472 start_mds || error "MDS start failed"
473 start_ost || error "OST start failed"
475 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
476 do_facet client "$LCTL set_param fail_loc=0x80000506"
477 mount_client $MOUNT || echo "mount failed (not fatal)"
478 cleanup || error "cleanup failed with $?"
479 grep " $MOUNT " /etc/mtab &&
480 error "$MOUNT entry in mtab after unmount"
483 run_test 5e "delayed connect, don't crash (bug 10268)"
486 if combined_mgs_mds ; then
487 skip "combined mgs and mds"
491 grep " $MOUNT " /etc/mtab &&
492 error false "unexpected entry in mtab before mount" && return 10
495 start_ost || error "OST start failed"
496 mount_client $MOUNT &
498 echo client_mount pid is $pid
502 if ! ps -f -p $pid >/dev/null; then
505 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
506 error "mount returns $rc, expected to hang"
508 cleanup || error "cleanup failed with $?"
513 start_mds || error "start MDS failed"
515 # mount should succeed after start mds
517 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
518 cleanup || error "final call to cleanup failed with rc $?"
520 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
525 mount_client $MOUNT || error "mount_client $MOUNT failed"
526 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
527 cleanup || error "cleanup failed with rc $?"
529 run_test 6 "manual umount, then mount again"
534 cleanup_nocli || error "cleanup_nocli failed with $?"
536 run_test 7 "manual umount, then cleanup"
540 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
541 check_mount2 || error "check_mount2 failed"
542 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
543 cleanup || error "cleanup failed with rc $?"
545 run_test 8 "double mount setup"
548 start_ost || error "OST start failed"
550 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
551 error "do_facet ost1 set_param inode trace failed."
552 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
553 error "do_facet ost1 set_param debug mds ost failed."
555 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
556 if [ "$CHECK_PTLDEBUG" ] && { \
557 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
558 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
559 echo "lnet.debug success"
561 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
563 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
564 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
565 echo "lnet.subsystem_debug success"
567 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
569 stop_ost || error "Unable to stop OST1"
571 run_test 9 "test ptldebug and subsystem for mkfs"
579 do_facet $facet "test -b $dev" || rc=1
580 if [[ "$size" ]]; then
581 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k \
582 count=1 skip=$size 2>&1" |
583 awk '($3 == "in") { print $1 }')
584 [[ $in = "1+0" ]] || rc=1
590 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
591 # But with new MDS stack we don't care about the mode of local objects
592 # anymore, so this test is removed. See bug 22944 for more details.
596 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
597 skip "Only applicable to ldiskfs-based MDTs"
602 check_mount || error "check_mount failed"
603 cleanup || error "cleanup failed with rc $?"
605 echo "Remove mds config log"
606 if ! combined_mgs_mds ; then
610 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
611 $(mgsdevname) || return \$?" ||
612 error "do_facet mgs failed with $?"
614 if ! combined_mgs_mds ; then
618 start_ost || error "OST start failed"
619 start_mds && error "MDS start succeeded, but should fail"
622 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
625 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
626 skip "Only applicable to ldiskfs-based MDTs"
630 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
635 # check if current MDSSIZE is large enough
636 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
637 log "use MDSSIZE=$MDSSIZE"
639 # check if the global config has a large enough MDSSIZE
640 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
641 [ $STORED_MDSSIZE -ge $MIN ] &&
642 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
643 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
645 # check if the block device is large enough
646 is_blkdev $SINGLEMDS $MDSDEV $MIN
647 local large_enough=$?
648 if [ -n "$OK" ]; then
649 [ $large_enough -ne 0 ] && OK=""
651 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
652 log "use device $MDSDEV with MIN=$MIN"
655 # check if a loopback device has enough space for fs metadata (5%)
657 if [ -z "$OK" ]; then
658 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
659 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
660 awk '($1 != "Filesystem") { print $4 }')
661 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
662 OK=1 && myMDSSIZE=$MIN &&
663 log "use file $MDSDEV with MIN=$MIN"
666 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
668 echo "mount mds with large journal..."
670 local OLD_MDSSIZE=$MDSSIZE
674 echo "mount lustre system..."
676 check_mount || error "check_mount failed"
678 echo "check journal size..."
679 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
680 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
681 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
683 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
686 cleanup || error "cleanup failed with rc $?"
691 run_test 18 "check mkfs creates large journals"
694 start_mds || error "MDS start failed"
695 stop_mds || error "Unable to stop MDS"
697 run_test 19a "start/stop MDS without OSTs"
700 start_ost || error "Unable to start OST1"
701 stop_ost || error "Unable to stop OST1"
703 run_test 19b "start/stop OSTs without MDS"
706 # first format the ost/mdt
707 start_mds || error "MDS start failed"
708 start_ost || error "Unable to start OST1"
709 mount_client $MOUNT || error "mount_client $MOUNT failed"
710 check_mount || error "check_mount failed"
711 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
712 remount_client ro $MOUNT || error "remount_client with ro failed"
713 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
714 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
715 remount_client rw $MOUNT || error "remount_client with rw failed"
716 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
717 MCNT=$(grep -c $MOUNT /etc/mtab)
718 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
720 stop_mds || error "Unable to stop MDS"
721 stop_ost || error "Unable to stop OST1"
723 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
726 start_mds || error "MDS start failed"
727 start_ost || error "unable to start OST1"
728 wait_osc_import_state mds ost FULL
729 stop_ost || error "unable to stop OST1"
730 stop_mds || error "unable to stop MDS"
732 run_test 21a "start mds before ost, stop ost first"
735 start_ost || error "unable to start OST1"
736 start_mds || error "MDS start failed"
737 wait_osc_import_state mds ost FULL
738 stop_mds || error "unable to stop MDS"
739 stop_ost || error "unable to stop OST1"
741 run_test 21b "start ost before mds, stop mds first"
744 start_ost || error "Unable to start OST1"
745 start_mds || error "MDS start failed"
746 start_ost2 || error "Unable to start OST2"
747 wait_osc_import_state mds ost2 FULL
748 stop_ost || error "Unable to stop OST1"
749 stop_ost2 || error "Unable to stop OST2"
750 stop_mds || error "Unable to stop MDS"
751 #writeconf to remove all ost2 traces for subsequent tests
752 writeconf_or_reformat
754 run_test 21c "start mds between two osts, stop mds last"
757 if combined_mgs_mds ; then
758 skip "need separate mgs device" && return 0
764 start_mgs || error "unable to start MGS"
765 start_ost || error "unable to start OST1"
766 start_ost2 || error "unable to start OST2"
767 start_mds || error "MDS start failed"
768 wait_osc_import_state mds ost2 FULL
770 stop_ost || error "Unable to stop OST1"
771 stop_ost2 || error "Unable to stop OST2"
772 stop_mds || error "Unable to stop MDS"
774 #writeconf to remove all ost2 traces for subsequent tests
775 writeconf_or_reformat
776 start_mgs || error "unable to start MGS"
778 run_test 21d "start mgs then ost and then mds"
781 MGSNID="$saved_mgsnid"
783 echo "stopping fs2mgs ..."
784 stop $fs2mgs -f || true
787 test_21e() { # LU-5863
788 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
789 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
790 skip_env "mixed loopback and real device not working" && return
793 local fs2mdsdev=$(mdsdevname 1_2)
794 local fs2ostdev=$(ostdevname 1_2)
795 local fs3ostdev=$(ostdevname 2_2)
797 local fs2mdsvdev=$(mdsvdevname 1_2)
798 local fs2ostvdev=$(ostvdevname 1_2)
799 local fs3ostvdev=$(ostvdevname 2_2)
801 # temporarily use fs3ost as fs2mgs
803 local fs2mgsdev=$fs3ostdev
804 local fs2mgsvdev=$fs3ostvdev
806 local fsname=test1234
808 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
809 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
810 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
811 error "start fs2mgs failed"
813 local saved_mgsnid="$MGSNID"
814 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
816 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
817 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
818 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
819 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
821 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
822 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
824 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
825 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
826 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
830 run_test 21e "separate MGS and MDS"
833 start_mds || error "MDS start failed"
835 echo "Client mount with ost in logs, but none running"
836 start_ost || error "unable to start OST1"
837 # wait until mds connected to ost and open client connection
838 wait_osc_import_state mds ost FULL
839 stop_ost || error "unable to stop OST1"
840 mount_client $MOUNT || error "mount_client $MOUNT failed"
841 # check_mount will block trying to contact ost
842 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
843 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
847 echo "Client mount with a running ost"
848 start_ost || error "unable to start OST1"
850 # if gss enabled, wait full time to let connection from
851 # mds to ost be established, due to the mismatch between
852 # initial connect timeout and gss context negotiation timeout.
853 # This perhaps could be remove after AT landed.
854 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
855 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
857 mount_client $MOUNT || error "mount_client $MOUNT failed"
858 wait_osc_import_state mds ost FULL
859 wait_osc_import_state client ost FULL
860 check_mount || error "check_mount failed"
863 cleanup || error "cleanup failed with rc $?"
865 run_test 22 "start a client before osts (should return errs)"
867 test_23a() { # was test_23
870 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
871 # force down client so that recovering mds waits for reconnect
872 local running=$(grep -c $MOUNT /proc/mounts) || true
873 if [ $running -ne 0 ]; then
874 echo "Stopping client $MOUNT (opts: -f)"
878 # enter recovery on failed mds
879 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
880 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
881 # try to start a new client
882 mount_client $MOUNT &
884 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
885 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
886 grep -v grep | awk '{print $2}')
887 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
889 ps --ppid $MOUNT_LUSTRE_PID
890 echo "waiting for mount to finish"
892 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
893 # SIGTERM works but it does not spread to offspring processses
894 kill -s TERM $MOUNT_PID
895 kill -s TERM $MOUNT_LUSTRE_PID
896 # we can not wait $MOUNT_PID because it is not a child of this shell
902 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
904 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
905 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
908 [ -z "$PID1" -a -z "$PID2" ] && break
909 echo "waiting for mount to finish ... "
910 WAIT=$(( WAIT + sleep))
912 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
913 error "MOUNT_PID $MOUNT_PID and "\
914 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
917 stop_mds || error "stopping MDSes failed"
918 stop_ost || error "stopping OSSes failed"
920 run_test 23a "interrupt client during recovery mount delay"
925 test_23b() { # was test_23
926 start_mds || error "MDS start failed"
927 start_ost || error "Unable to start OST1"
928 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
929 $LCTL set_param fail_loc=0x80000313
931 cleanup || error "cleanup failed with rc $?"
933 run_test 23b "Simulate -EINTR during mount"
936 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
938 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
939 is_blkdev $SINGLEMDS $MDSDEV &&
940 skip_env "mixed loopback and real device not working" && return
943 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
945 local fs2mdsdev=$(mdsdevname 1_2)
946 local fs2ostdev=$(ostdevname 1_2)
947 local fs2mdsvdev=$(mdsvdevname 1_2)
948 local fs2ostvdev=$(ostvdevname 1_2)
950 # test 8-char fsname as well
951 local FSNAME2=test1234
953 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
954 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
956 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
957 --reformat $fs2ostdev $fs2ostvdev || exit 10
960 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
961 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
962 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
963 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
965 check_mount || error "check_mount failed"
966 # files written on 1 should not show up on 2
967 cp /etc/passwd $DIR/$tfile
969 [ -e $MOUNT2/$tfile ] && error "File bleed"
972 cp /etc/passwd $MOUNT2/$tfile ||
973 error "cp /etc/passwd $MOUNT2/$tfile failed"
974 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
975 # 2 is actually mounted
976 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
978 facet_failover fs2mds
979 facet_failover fs2ost
982 # the MDS must remain up until last MDT
984 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
985 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
986 [ -z "$MDS" ] && error "No MDT"
988 cleanup_nocli || error "cleanup_nocli failed with rc $?"
990 run_test 24a "Multiple MDTs on a single node"
993 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
995 if [ -z "$fs2mds_DEV" ]; then
996 local dev=${SINGLEMDS}_dev
998 is_blkdev $SINGLEMDS $MDSDEV &&
999 skip_env "mixed loopback and real device not working" && return
1002 local fs2mdsdev=$(mdsdevname 1_2)
1003 local fs2mdsvdev=$(mdsvdevname 1_2)
1005 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1006 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1008 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS &&
1009 error "start MDS should fail"
1011 cleanup || error "cleanup failed with rc $?"
1013 run_test 24b "Multiple MGSs on a single node (should return err)"
1017 check_mount || error "check_mount failed"
1018 local MODULES=$($LCTL modules | awk '{ print $2 }')
1019 rmmod $MODULES 2>/dev/null || true
1020 cleanup || error "cleanup failed with $?"
1022 run_test 25 "Verify modules are referenced"
1026 # we need modules before mount for sysctl, so make sure...
1027 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1028 #define OBD_FAIL_MDS_FS_SETUP 0x135
1029 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1030 start_mds && error "MDS started but should not have started"
1031 $LCTL get_param -n devices
1032 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1033 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1034 # start mds to drop writeconf setting
1035 start_mds || error "Unable to start MDS"
1036 stop_mds || error "Unable to stop MDS"
1037 unload_modules_conf || error "unload_modules_conf failed with $?"
1039 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1042 start_ost || error "Unable to start OST1"
1043 start_mds || error "Unable to start MDS"
1044 echo "Requeue thread should have started: "
1045 ps -e | grep ll_cfg_requeue
1046 set_conf_param_and_check ost1 \
1047 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1048 "$FSNAME-OST0000.ost.client_cache_seconds" ||
1049 error "set_conf_param_and_check ost1 failed"
1050 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1052 run_test 27a "Reacquire MGS lock if OST started first"
1057 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1058 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1060 facet_failover $SINGLEMDS
1061 set_conf_param_and_check $SINGLEMDS \
1062 "$LCTL get_param -n mdt.$device.identity_acquire_expire" \
1063 "$device.mdt.identity_acquire_expire" ||
1064 error "set_conf_param_and_check $SINGLEMDS failed"
1065 set_conf_param_and_check client \
1066 "$LCTL get_param -n mdc.$device-mdc-*.max_rpcs_in_flight"\
1067 "$device.mdc.max_rpcs_in_flight" ||
1068 error "set_conf_param_and_check client failed"
1070 cleanup || error "cleanup failed with $?"
1072 run_test 27b "Reacquire MGS lock after failover"
1076 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1077 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1079 FINAL=$(($ORIG + 1))
1080 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1081 error "first set_conf_param_and_check client failed"
1082 FINAL=$(($FINAL + 1))
1083 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1084 error "second set_conf_param_and_check client failed"
1085 umount_client $MOUNT || error "umount_client $MOUNT failed"
1086 mount_client $MOUNT || error "mount_client $MOUNT failed"
1088 if [ $RESULT -ne $FINAL ]; then
1089 error "New config not seen: wanted $FINAL got $RESULT"
1091 echo "New config success: got $RESULT"
1093 set_conf_param_and_check client "$TEST" "$PARAM" $ORIG ||
1094 error "third set_conf_param_and_check client failed"
1095 cleanup || error "cleanup failed with rc $?"
1097 run_test 28 "permanent parameter setting"
1099 test_28a() { # LU-4221
1100 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1101 { skip "Need OST version at least 2.5.52" && return 0; }
1102 [ "$(facet_fstype ost1)" = "zfs" ] &&
1103 skip "LU-4221: no such proc params for ZFS OSTs" && return
1110 local device="$FSNAME-OST0000"
1114 # In this test we will set three kinds of proc parameters with
1116 # 1. the ones moved from the OFD to the OSD, and only their
1117 # symlinks kept in obdfilter
1118 # 2. non-symlink ones in the OFD
1119 # 3. non-symlink ones in the OSD
1122 # prepare a symlink parameter in the OFD
1123 name="writethrough_cache_enable"
1124 param="$device.ost.$name"
1125 cmd="$LCTL get_param -n obdfilter.$device.$name"
1127 # conf_param the symlink parameter in the OFD
1128 old=$(do_facet ost1 $cmd)
1129 new=$(((old + 1) % 2))
1130 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1131 error "lctl conf_param $device.ost.$param=$new failed"
1133 # conf_param the target parameter in the OSD
1134 param="$device.osd.$name"
1135 cmd="$LCTL get_param -n osd-*.$device.$name"
1136 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1137 error "lctl conf_param $device.osd.$param=$old failed"
1140 # prepare a non-symlink parameter in the OFD
1141 name="client_cache_seconds"
1142 param="$device.ost.$name"
1143 cmd="$LCTL get_param -n obdfilter.$device.$name"
1145 # conf_param the parameter in the OFD
1146 old=$(do_facet ost1 $cmd)
1148 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1149 error "lctl conf_param $device.ost.$param=$new failed"
1150 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1151 error "lctl conf_param $device.ost.$param=$old failed"
1154 # prepare a non-symlink parameter in the OSD
1156 param="$device.osd.$name"
1157 cmd="$LCTL get_param -n osd-*.$device.$name"
1159 # conf_param the parameter in the OSD
1160 old=$(do_facet ost1 $cmd)
1161 new=$(((old + 1) % 2))
1162 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1163 error "lctl conf_param $device.osd.$param=$new failed"
1164 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1165 error "lctl conf_param $device.osd.$param=$old failed"
1167 cleanup || error "cleanup failed with $?"
1169 run_test 28a "set symlink parameters permanently with conf_param"
1172 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1173 setup > /dev/null 2>&1
1174 start_ost2 || error "Unable to start OST2"
1177 local PARAM="$FSNAME-OST0001.osc.active"
1178 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1179 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1181 ACTV=$($LCTL get_param -n $PROC_ACT)
1183 set_conf_param_and_check client \
1184 "$LCTL get_param -n $PROC_ACT" "$PARAM" $DEAC ||
1185 error "set_conf_param_and_check client failed"
1186 # also check ost_server_uuid status
1187 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1188 if [ -z "$RESULT" ]; then
1189 error "Client not deactivated: $($LCTL get_param \
1192 echo "Live client success: got $RESULT"
1196 for num in $(seq $MDSCOUNT); do
1197 local mdtosc=$(get_mdtosc_proc_path mds${num} $FSNAME-OST0001)
1198 local MPROC="osc.$mdtosc.active"
1203 RESULT=$(do_facet mds${num} "$LCTL get_param -n $MPROC")
1204 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1205 if [ $RESULT -eq $DEAC ]; then
1206 echo -n "MDT deactivated also after"
1207 echo "$WAIT sec (got $RESULT)"
1211 if [ $WAIT -eq $MAX ]; then
1212 error "MDT active: wanted $DEAC got $RESULT"
1214 echo "Waiting $(($MAX - $WAIT))secs for MDT deactivated"
1217 # test new client starts deactivated
1218 umount_client $MOUNT || error "umount_client $MOUNT failed"
1219 mount_client $MOUNT || error "mount_client $MOUNT failed"
1220 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1221 if [ -z "$RESULT" ]; then
1222 error "New client start active: $(lctl get_param -n $PROC_UUID)"
1224 echo "New client success: got $RESULT"
1227 # make sure it reactivates
1228 set_conf_param_and_check client \
1229 "$LCTL get_param -n $PROC_ACT" "$PARAM" $ACTV ||
1230 error "lctl get_param $PROC_ACT $PARAM $ACTV failed"
1232 umount_client $MOUNT
1233 stop_ost2 || error "Unable to stop OST2"
1234 cleanup_nocli || error "cleanup_nocli failed with $?"
1235 #writeconf to remove all ost2 traces for subsequent tests
1236 writeconf_or_reformat
1238 run_test 29 "permanently remove an OST"
1243 echo Big config llog
1244 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1246 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1247 for i in ${LIST[@]}; do
1248 set_conf_param_and_check client "$TEST" \
1249 "$FSNAME.llite.max_read_ahead_whole_mb" $i ||
1250 error "Set $FSNAME.llite.max_read_ahead_whole_mb failed"
1252 # make sure client restart still works
1253 umount_client $MOUNT
1254 mount_client $MOUNT || error "mount_client $MOUNT failed"
1255 [ "$($TEST)" -ne "$i" ] &&
1256 error "Param didn't stick across restart $($TEST) != $i"
1259 echo Erase parameter setting
1260 do_facet mgs "$LCTL conf_param \
1261 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1262 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1263 umount_client $MOUNT
1264 mount_client $MOUNT || error "mount_client $MOUNT failed"
1266 echo "deleted (default) value=$FINAL, orig=$ORIG"
1267 # assumes this parameter started at the default value
1268 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1270 cleanup || error "cleanup failed with rc $?"
1272 run_test 30a "Big config llog and conf_param deletion"
1277 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1278 # numerical part of it. Hopefully that's not already a failover address
1280 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1281 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1282 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1283 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1284 echo "Using fake nid $NEW"
1286 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1287 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1288 set_conf_param_and_check client "$TEST" \
1289 "$FSNAME-OST0000.failover.node" $NEW ||
1290 error "didn't add failover nid $NEW"
1291 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1294 # The NIDS value is the failover nid strings and "[" and "]". So
1295 # we need to subtract the space taken by the delimiters. This has
1296 # changed from earlier version of Lustre but this test is run only
1297 # locally so this change will not break interop. See LU-3386
1298 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 3))
1299 echo "should have 2 failover nids: $NIDCOUNT"
1300 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1301 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" ||
1302 error "conf_param 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 |
1309 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 3))
1310 echo "only 1 final nid should remain: $NIDCOUNT"
1311 [ $NIDCOUNT -eq 1 ] || 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=20480 # 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
1344 if [ $FSNAME != t32fs -o $MDSCOUNT -ne 1 -o \
1345 \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o $OSTCOUNT -ne 1 -o \
1346 -z "$OSTDEV1" ]; then
1347 error "Needs FSNAME=t32fs MDSCOUNT=1 MDSDEV1=<nonexistent_file>" \
1348 "(or MDSDEV, in the case of b1_8) OSTCOUNT=1" \
1349 "OSTDEV1=<nonexistent_file>"
1353 echo "Found stale $tmp"
1357 mkdir $tmp/src || return 1
1358 tar cf - -C $src . | tar xf - -C $tmp/src
1359 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1360 count=$(($T32_BLIMIT / 1024 / 2))
1361 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1363 # format ost with comma-separated NIDs to verify LU-4460
1364 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
1365 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1369 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1370 $LFS quotacheck -ug /mnt/$FSNAME
1371 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1374 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1377 mkdir $tmp/img || return 1
1381 ls -Rni --time-style=+%s >$tmp/img/list
1382 find . ! -name .lustre -type f -exec sha1sum {} \; |
1383 sort -k 2 >$tmp/img/sha1sums
1385 $LCTL get_param -n version | head -n 1 |
1386 sed -e 's/^lustre: *//' >$tmp/img/commit
1388 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1389 $LFS quotaon -ug /mnt/$FSNAME
1390 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1391 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1392 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1393 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1394 | tr -d "*" > $tmp/img/bspace
1395 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1396 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1397 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1398 | tr -d "*" > $tmp/img/ispace
1403 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1406 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1407 echo "Data verification failed"
1410 uname -r >$tmp/img/kernel
1411 uname -m >$tmp/img/arch
1413 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1414 mv $OSTDEV1 $tmp/img
1416 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1417 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1420 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1425 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1428 # The list of applicable tarballs is returned via the caller's
1429 # variable "tarballs".
1432 local node=$(facet_active_host $SINGLEMDS)
1433 local r="do_node $node"
1435 if [ "$CLIENTONLY" ]; then
1436 skip "Client-only testing"
1440 if ! $r which $TUNEFS; then
1441 skip_env "tunefs.lustre required on $node"
1445 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1447 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 -name \'disk*-$IMGTYPE.tar.bz2\')
1449 if [ -z "$tarballs" ]; then
1450 skip "No applicable tarballs found"
1455 t32_test_cleanup() {
1457 local fstype=$(facet_fstype $SINGLEMDS)
1460 if $shall_cleanup_lustre; then
1461 umount $tmp/mnt/lustre || rc=$?
1463 if $shall_cleanup_mdt; then
1464 $r umount -d $tmp/mnt/mdt || rc=$?
1466 if $shall_cleanup_mdt1; then
1467 $r umount -d $tmp/mnt/mdt1 || rc=$?
1469 if $shall_cleanup_ost; then
1470 $r umount -d $tmp/mnt/ost || rc=$?
1475 if [ $fstype == "zfs" ]; then
1476 $r $ZPOOL destroy t32fs-mdt1 || rc=$?
1477 $r $ZPOOL destroy t32fs-ost1 || rc=$?
1482 t32_bits_per_long() {
1484 # Yes, this is not meant to be perfect.
1494 t32_reload_modules() {
1496 local all_removed=false
1499 while ((i < 20)); do
1500 echo "Unloading modules on $node: Attempt $i"
1501 do_rpc_nodes $node $LUSTRE_RMMOD $(facet_fstype $SINGLEMDS) &&
1503 do_rpc_nodes $node check_mem_leak || return 1
1504 if $all_removed; then
1505 do_rpc_nodes $node load_modules
1511 echo "Unloading modules on $node: Given up"
1515 t32_wait_til_devices_gone() {
1521 echo wait for devices to go
1522 while ((i < 20)); do
1523 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1524 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1525 ((devices == 0 && loops == 0)) && return 0
1529 echo "waiting for dev on $node: dev $devices loop $loops given up"
1530 do_rpc_nodes $node "losetup -a"
1531 do_rpc_nodes $node "$LCTL device_list"
1535 t32_verify_quota() {
1539 local fstype=$(facet_fstype $SINGLEMDS)
1543 $LFS quota -u $T32_QID -v $mnt
1545 qval=$($LFS quota -v -u $T32_QID $mnt |
1546 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1547 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1549 [ $qval -eq $img_bspace ] || {
1550 echo "bspace, act:$qval, exp:$img_bspace"
1554 qval=$($LFS quota -v -u $T32_QID $mnt |
1555 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1556 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1558 [ $qval -eq $img_ispace ] || {
1559 echo "ispace, act:$qval, exp:$img_ispace"
1563 qval=$($LFS quota -v -u $T32_QID $mnt |
1564 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1565 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1567 [ $qval -eq $T32_BLIMIT ] || {
1568 echo "blimit, act:$qval, exp:$T32_BLIMIT"
1572 qval=$($LFS quota -v -u $T32_QID $mnt |
1573 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1574 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1576 [ $qval -eq $T32_ILIMIT ] || {
1577 echo "ilimit, act:$qval, exp:$T32_ILIMIT"
1581 do_node $node $LCTL conf_param $fsname.quota.mdt=ug
1582 cmd="$LCTL get_param -n osd-$fstype.$fsname-MDT0000"
1583 cmd=$cmd.quota_slave.enabled
1584 wait_update $node "$cmd" "ug" || {
1585 echo "Enable mdt quota failed"
1589 do_node $node $LCTL conf_param $fsname.quota.ost=ug
1590 cmd="$LCTL get_param -n osd-$fstype.$fsname-OST0000"
1591 cmd=$cmd.quota_slave.enabled
1592 wait_update $node "$cmd" "ug" || {
1593 echo "Enable ost quota failed"
1598 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1599 bs=1M count=$(($T32_BLIMIT / 1024)) oflag=sync && {
1600 echo "Write succeed, but expect -EDQUOT"
1603 rm -f $mnt/t32_qf_new
1605 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1607 echo "Create succeed, but expect -EDQUOT"
1610 unlinkmany $mnt/t32_qf_ $T32_ILIMIT
1618 local dne_upgrade=${dne_upgrade:-"no"}
1619 local ff_convert=${ff_convert:-"no"}
1620 local shall_cleanup_mdt=false
1621 local shall_cleanup_mdt1=false
1622 local shall_cleanup_ost=false
1623 local shall_cleanup_lustre=false
1624 local node=$(facet_active_host $SINGLEMDS)
1625 local r="do_node $node"
1626 local node2=$(facet_active_host mds2)
1634 local nid=$($r $LCTL list_nids | head -1)
1640 local fstype=$(facet_fstype $SINGLEMDS)
1641 local mdt_dev=$tmp/mdt
1642 local ost_dev=$tmp/ost
1644 trap 'trap - RETURN; t32_test_cleanup' RETURN
1647 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1648 $r mkdir -p $tmp/mnt/{mdt,ost}
1649 $r tar xjvf $tarball -S -C $tmp || {
1650 error_noexit "Unpacking the disk image tarball"
1653 img_commit=$($r cat $tmp/commit)
1654 img_kernel=$($r cat $tmp/kernel)
1655 img_arch=$($r cat $tmp/arch)
1656 img_bspace=$($r cat $tmp/bspace)
1657 img_ispace=$($r cat $tmp/ispace)
1658 echo "Upgrading from $(basename $tarball), created with:"
1659 echo " Commit: $img_commit"
1660 echo " Kernel: $img_kernel"
1661 echo " Arch: $img_arch"
1662 echo "OST version: $(lustre_build_version ost1)"
1664 # The conversion can be made only when both of the following
1665 # conditions are satisfied:
1666 # - ost device img version < 2.3.64
1667 # - ost server version >= 2.5
1668 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1669 $(lustre_version_code ost1) -lt $(version_code 2.5.0) ] &&
1672 if [ $fstype == "zfs" ]; then
1674 $r $ZPOOL import -f -d $tmp t32fs-mdt1
1675 $r $ZPOOL import -f -d $tmp t32fs-ost1
1676 mdt_dev=t32fs-mdt1/mdt1
1677 ost_dev=t32fs-ost1/ost1
1678 wait_update_facet $SINGLEMDS "$ZPOOL list |
1679 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1680 error_noexit "import zfs pool failed"
1685 $r $LCTL set_param debug="$PTLDEBUG"
1687 $r $TUNEFS --dryrun $mdt_dev || {
1689 error_noexit "tunefs.lustre before mounting the MDT"
1692 if [ "$writeconf" ]; then
1694 if [ $fstype == "ldiskfs" ]; then
1696 $r $TUNEFS --quota $mdt_dev || {
1698 error_noexit "Enable mdt quota feature"
1703 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1704 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1705 { skip "LU-2200: Cannot run over Inifiniband w/o lctl replace_nids "
1706 "(Need MGS version at least 2.3.59)"; return 0; }
1708 local osthost=$(facet_active_host ost1)
1709 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1712 if [ $fstype == "ldiskfs" ]; then
1715 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1716 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1717 $r $LCTL replace_nids $fsname-MDT0000 $nid
1718 $r umount -d $tmp/mnt/mdt
1721 mopts=exclude=$fsname-OST0000
1722 if [ $fstype == "ldiskfs" ]; then
1727 t32_wait_til_devices_gone $node
1729 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1731 error_noexit "Mounting the MDT"
1734 shall_cleanup_mdt=true
1736 if [ "$dne_upgrade" != "no" ]; then
1737 local fs2mdsdev=$(mdsdevname 1_2)
1738 local fs2mdsvdev=$(mdsvdevname 1_2)
1740 echo "mkfs new MDT on ${fs2mdsdev}...."
1741 if [ $(facet_fstype mds1) == ldiskfs ]; then
1742 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1745 add fs2mds $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1746 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1747 error_noexit "Mkfs new MDT failed"
1751 $r $TUNEFS --dryrun $fs2mdsdev || {
1752 error_noexit "tunefs.lustre before mounting the MDT"
1756 echo "mount new MDT....$fs2mdsdev"
1757 $r mkdir -p $tmp/mnt/mdt1
1758 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1759 error_noexit "mount mdt1 failed"
1763 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1764 error_noexit "enable remote dir create failed"
1766 shall_cleanup_mdt1=true
1769 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1770 error_noexit "Getting MDT UUID"
1773 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1774 error_noexit "Unexpected MDT UUID: \"$uuid\""
1778 $r $TUNEFS --dryrun $ost_dev || {
1779 error_noexit "tunefs.lustre before mounting the OST"
1782 if [ "$writeconf" ]; then
1783 mopts=mgsnode=$nid,$writeconf
1784 if [ $fstype == "ldiskfs" ]; then
1786 $r $TUNEFS --quota $ost_dev || {
1788 error_noexit "Enable ost quota feature"
1794 if [ $fstype == "ldiskfs" ]; then
1798 $r $MOUNT_CMD -o $mopts $ost_dev $tmp/mnt/ost || {
1799 error_noexit "Mounting the OST"
1802 shall_cleanup_ost=true
1804 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1805 error_noexit "Getting OST UUID"
1808 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1809 error_noexit "Unexpected OST UUID: \"$uuid\""
1813 $r $LCTL conf_param $fsname-OST0000.osc.max_dirty_mb=15 || {
1814 error_noexit "Setting \"max_dirty_mb\""
1817 $r $LCTL conf_param $fsname-OST0000.failover.node=$nid || {
1818 error_noexit "Setting OST \"failover.node\""
1821 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1822 error_noexit "Setting \"max_rpcs_in_flight\""
1825 $r $LCTL conf_param $fsname-MDT0000.failover.node=$nid || {
1826 error_noexit "Setting MDT \"failover.node\""
1829 $r $LCTL pool_new $fsname.interop || {
1830 error_noexit "Setting \"interop\""
1833 $r $LCTL conf_param $fsname-MDT0000.lov.stripesize=4M || {
1834 error_noexit "Setting \"lov.stripesize\""
1837 $r $LCTL conf_param $fsname-MDT0000.mdd.atime_diff=70 || {
1838 error_noexit "Setting \"mdd.atime_diff\""
1842 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1843 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1844 error_noexit "Start OI scrub on OST0"
1848 # The oi_scrub should be on ost1, but for test_32(),
1849 # all on the SINGLEMDS.
1850 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1851 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1852 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1853 error_noexit "Failed to get the expected 'completed'"
1857 local UPDATED=$($r $LCTL get_param -n \
1858 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1859 awk '/^updated/ { print $2 }')
1860 [ $UPDATED -ge 1 ] || {
1861 error_noexit "Only $UPDATED objects have been converted"
1866 if [ "$dne_upgrade" != "no" ]; then
1867 $r $LCTL conf_param \
1868 $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
1869 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
1872 $r $LCTL conf_param $fsname-MDT0001.failover.node=$nid || {
1873 error_noexit "Setting MDT1 \"failover.node\""
1876 $r $LCTL conf_param $fsname-MDT0001.lov.stripesize=4M || {
1877 error_noexit "Setting MDT1 \"lov.stripesize\""
1883 if [ "$writeconf" ]; then
1884 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
1885 error_noexit "Mounting the client"
1888 shall_cleanup_lustre=true
1889 $LCTL set_param debug="$PTLDEBUG"
1891 t32_verify_quota $node $fsname $tmp/mnt/lustre || {
1892 error_noexit "verify quota failed"
1896 if [ "$dne_upgrade" != "no" ]; then
1897 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/remote_dir || {
1898 error_noexit "set remote dir failed"
1902 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/remote_dir
1904 pushd $tmp/mnt/lustre
1905 tar -cf - . --exclude=./remote_dir |
1906 tar -xvf - -C remote_dir 1>/dev/null || {
1907 error_noexit "cp to remote dir failed"
1913 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
1914 error_noexit "dd failed"
1917 rm -rf $tmp/mnt/lustre/tmp_file || {
1918 error_noexit "rm failed"
1922 if $r test -f $tmp/sha1sums; then
1923 # LU-2393 - do both sorts on same node to ensure locale
1925 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
1926 if [ "$dne_upgrade" != "no" ]; then
1927 pushd $tmp/mnt/lustre/remote_dir
1929 pushd $tmp/mnt/lustre
1932 find ! -name .lustre -type f -exec sha1sum {} \; |
1933 sort -k 2 >$tmp/sha1sums || {
1934 error_noexit "sha1sum"
1938 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
1939 error_noexit "sha1sum verification failed"
1943 echo "sha1sum verification skipped"
1946 if [ "$dne_upgrade" != "no" ]; then
1947 rm -rf $tmp/mnt/lustre/remote_dir || {
1948 error_noexit "remove remote dir failed"
1953 if $r test -f $tmp/list; then
1955 # There is not a Test Framework API to copy files to or
1956 # from a remote node.
1958 # LU-2393 - do both sorts on same node to ensure locale
1960 $r cat $tmp/list | sort -k 6 >$tmp/list.orig
1961 pushd $tmp/mnt/lustre
1962 ls -Rni --time-style=+%s | sort -k 6 >$tmp/list || {
1968 # 32-bit and 64-bit clients use different algorithms to
1969 # convert FIDs into inode numbers. Hence, remove the inode
1970 # numbers from the lists, if the original list was created
1971 # on an architecture with different number of bits per
1974 if [ $(t32_bits_per_long $(uname -m)) != \
1975 $(t32_bits_per_long $img_arch) ]; then
1976 echo "Different number of bits per \"long\" from the disk image"
1977 for list in list.orig list; do
1978 sed -i -e 's/^[0-9]\+[ \t]\+//' $tmp/$list
1981 if ! diff -ub $tmp/list.orig $tmp/list; then
1982 error_noexit "list verification failed"
1986 echo "list verification skipped"
1990 # When adding new data verification tests, please check for
1991 # the presence of the required reference files first, like
1992 # the "sha1sums" and "list" tests above, to avoid the need to
1993 # regenerate every image for each test addition.
1996 nrpcs_orig=$($LCTL get_param \
1997 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
1998 error_noexit "Getting \"max_rpcs_in_flight\""
2001 nrpcs=$((nrpcs_orig + 5))
2002 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=$nrpcs || {
2003 error_noexit "Changing \"max_rpcs_in_flight\""
2006 wait_update $HOSTNAME "$LCTL get_param \
2007 -n mdc.*MDT0000*.max_rpcs_in_flight" $nrpcs || {
2008 error_noexit "Verifying \"max_rpcs_in_flight\""
2012 umount $tmp/mnt/lustre || {
2013 error_noexit "Unmounting the client"
2016 shall_cleanup_lustre=false
2018 if [ "$dne_upgrade" != "no" ]; then
2019 $r umount -d $tmp/mnt/mdt1 || {
2020 error_noexit "Unmounting the MDT2"
2023 shall_cleanup_mdt1=false
2026 $r umount -d $tmp/mnt/mdt || {
2027 error_noexit "Unmounting the MDT"
2030 shall_cleanup_mdt=false
2032 $r umount -d $tmp/mnt/ost || {
2033 error_noexit "Unmounting the OST"
2036 shall_cleanup_ost=false
2038 t32_reload_modules $node || {
2039 error_noexit "Reloading modules"
2043 # mount a second time to make sure we didnt leave upgrade flag on
2044 $r $TUNEFS --dryrun $mdt_dev || {
2046 error_noexit "tunefs.lustre before remounting the MDT"
2050 mopts=exclude=$fsname-OST0000
2051 if [ $fstype == "ldiskfs" ]; then
2054 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2055 error_noexit "Remounting the MDT"
2058 shall_cleanup_mdt=true
2068 for tarball in $tarballs; do
2069 t32_test $tarball || let "rc += $?"
2073 run_test 32a "Upgrade (not live)"
2081 for tarball in $tarballs; do
2082 t32_test $tarball writeconf || let "rc += $?"
2086 run_test 32b "Upgrade with writeconf"
2093 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2095 for tarball in $tarballs; do
2096 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2097 echo $tarball | grep "1_8" && continue
2098 echo $tarball | grep "2_1" && continue
2099 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2103 run_test 32c "dne upgrade test"
2111 for tarball in $tarballs; do
2112 ff_convert=yes t32_test $tarball || rc=$?
2116 run_test 32d "convert ff test"
2118 test_33a() { # bug 12333, was test_33
2119 local FSNAME2=test-123
2120 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2123 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2125 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2126 local dev=${SINGLEMDS}_dev
2127 local MDSDEV=${!dev}
2128 is_blkdev $SINGLEMDS $MDSDEV &&
2129 skip_env "mixed loopback and real device not working" &&
2133 local fs2mdsdev=$(mdsdevname 1_2)
2134 local fs2ostdev=$(ostdevname 1_2)
2135 local fs2mdsvdev=$(mdsvdevname 1_2)
2136 local fs2ostvdev=$(ostvdevname 1_2)
2138 if [ $(facet_fstype mds1) == ldiskfs ]; then
2139 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2142 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2143 --reformat $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
2144 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2145 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2146 $fs2ostvdev || exit 10
2148 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2149 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2150 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" ||
2151 error "$LCTL conf_param $FSNAME2.sys.timeout=200 failed"
2152 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2153 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2156 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2157 $GETSTRIPE $MOUNT2/hosts || error "$GETSTRIPE $MOUNT2/hosts failed"
2162 cleanup_nocli || error "cleanup_nocli failed with $?"
2164 run_test 33a "Mount ost with a large index number"
2166 test_33b() { # was test_34
2169 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2170 # Drop lock cancelation reply during umount
2171 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2172 do_facet client $LCTL set_param fail_loc=0x80000304
2173 #lctl set_param debug=-1
2174 umount_client $MOUNT
2175 cleanup || error "cleanup failed with $?"
2177 run_test 33b "Drop cancel during umount"
2181 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2182 manual_umount_client
2184 do_facet client killall -USR1 multiop
2185 if [ $rc -eq 0 ]; then
2186 error "umount not fail!"
2189 cleanup || error "cleanup failed with rc $?"
2191 run_test 34a "umount with opened file should be fail"
2195 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2196 stop_mds || error "Unable to stop MDS"
2198 manual_umount_client --force || error "mtab after failed umount with $?"
2200 cleanup || error "cleanup failed with $?"
2202 run_test 34b "force umount with failed mds should be normal"
2206 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2207 stop_ost || error "Unable to stop OST1"
2209 manual_umount_client --force || error "mtab after failed umount with $?"
2211 cleanup || error "cleanup failed with $?"
2213 run_test 34c "force umount with failed ost should be normal"
2215 test_35a() { # bug 12459
2218 DBG_SAVE="`$LCTL get_param -n debug`"
2219 $LCTL set_param debug="ha"
2221 log "Set up a fake failnode for the MDS"
2223 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2224 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2225 do_facet mgs "$LCTL conf_param \
2226 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" ||
2227 error "Setting ${device}.failover.node=\
2228 $(h2$NETTYPE $FAKENID) failed."
2230 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2233 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2236 log "Stopping the MDT: $device"
2237 stop_mdt 1 || error "MDT0 stop fail"
2239 df $MOUNT > /dev/null 2>&1 &
2241 log "Restarting the MDT: $device"
2242 start_mdt 1 || error "MDT0 start fail"
2243 log "Wait for df ($DFPID) ... "
2246 $LCTL set_param debug="$DBG_SAVE"
2248 # retrieve from the log the first server that the client tried to
2249 # contact after the connection loss
2250 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2251 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2252 /import_select_connection.*$device-mdc.* using connection/ {
2254 if (\\\$NF ~ /$FAKENID/)
2260 }" $TMP/lustre-log-$TESTNAME.log`
2261 [ "$NEXTCONN" != "0" ] &&
2262 error "Tried to connect to ${NEXTCONN} not last active server"
2263 cleanup || error "cleanup failed with $?"
2264 # remove nid settings
2265 writeconf_or_reformat
2267 run_test 35a "Reconnect to the last active server first"
2269 test_35b() { # bug 18674
2270 remote_mds || { skip "local MDS" && return 0; }
2274 $LCTL set_param debug="ha"
2276 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2279 log "Set up a fake failnode for the MDS"
2281 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2282 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2283 do_facet mgs "$LCTL conf_param \
2284 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" ||
2285 error "Set ${device}.failover.node=\
2286 $(h2$NETTYPE $FAKENID) failed"
2288 local at_max_saved=0
2289 # adaptive timeouts may prevent seeing the issue
2290 if at_is_enabled; then
2291 at_max_saved=$(at_max_get mds)
2292 at_max_set 0 mds client
2295 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2297 log "Injecting EBUSY on MDS"
2298 # Setting OBD_FAIL_MDS_RESEND=0x136
2299 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2300 error "unable to set param fail_loc=0x80000136"
2302 $LCTL set_param mdc.${FSNAME}*.stats=clear
2304 log "Creating a test file and stat it"
2305 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2306 stat $MOUNT/$tdir/$tfile
2308 log "Stop injecting EBUSY on MDS"
2309 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2310 error "unable to set param fail_loc=0"
2311 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2314 # restore adaptive timeout
2315 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2317 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2319 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2320 awk '/mds_connect/{print $2}')
2322 # retrieve from the log if the client has ever tried to
2323 # contact the fake server after the loss of connection
2324 FAILCONN=`awk "BEGIN {ret = 0;}
2325 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2327 if (\\\$NF ~ /$FAKENID/) {
2332 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2334 [ "$FAILCONN" == "0" ] &&
2335 error "The client reconnection has not been triggered"
2336 [ "$FAILCONN" == "2" ] &&
2337 error "Primary server busy, client reconnect to failover failed"
2340 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2341 # Reconnects are supposed to be rate limited to one every 5s
2342 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2343 error "Too many reconnects $CONNCNT"
2345 cleanup || error "cleanup failed with $?"
2346 # remove nid settings
2347 writeconf_or_reformat
2349 run_test 35b "Continue reconnection retries, if the active server is busy"
2352 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
2354 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2355 { skip "remote OST" && return 0; }
2358 local FSNAME2=test1234
2359 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2361 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2363 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2364 is_blkdev $SINGLEMDS $MDSDEV &&
2365 skip_env "mixed loopback and real device not working" && return
2368 local fs2mdsdev=$(mdsdevname 1_2)
2369 local fs2ostdev=$(ostdevname 1_2)
2370 local fs3ostdev=$(ostdevname 2_2)
2371 local fs2mdsvdev=$(mdsvdevname 1_2)
2372 local fs2ostvdev=$(ostvdevname 1_2)
2373 local fs3ostvdev=$(ostvdevname 2_2)
2375 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2376 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2377 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2378 # different one than the default value here.
2379 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2380 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2381 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2382 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2384 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2385 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2386 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2387 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2388 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2390 sleep 5 # until 11778 fixed
2392 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2394 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2395 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2396 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2397 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2398 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2399 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2400 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2401 DFTOTAL=$(echo $STRING | cut -d, -f1)
2402 DFUSED=$(echo $STRING | cut -d, -f2)
2403 DFAVAIL=$(echo $STRING | cut -d, -f3)
2404 DFFREE=$(($DFTOTAL - $DFUSED))
2406 ALLOWANCE=$((64 * $OSTCOUNT))
2408 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2409 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2410 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2413 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2414 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2415 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2418 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2419 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2420 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2425 stop fs3ost -f || error "unable to stop OST3"
2426 stop fs2ost -f || error "unable to stop OST2"
2427 stop fs2mds -f || error "unable to stop second MDS"
2428 unload_modules_conf || error "unable unload modules"
2431 run_test 36 "df report consistency on OSTs with different block size"
2434 local mntpt=$(facet_mntpt $SINGLEMDS)
2435 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2436 local mdsdev_sym="$TMP/sym_mdt.img"
2437 local opts=$MDS_MOUNT_OPTS
2440 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2441 skip "Currently only applicable to ldiskfs-based MDTs"
2445 echo "MDS : $mdsdev"
2446 echo "SYMLINK : $mdsdev_sym"
2447 do_facet $SINGLEMDS rm -f $mdsdev_sym
2449 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2451 echo "mount symlink device - $mdsdev_sym"
2453 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2454 opts=$(csa_add "$opts" -o loop)
2456 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2457 $mdsdev_sym $mntpt 2>&1)
2460 echo mount_op=$mount_op
2462 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
2464 if $(echo $mount_op | grep -q "unable to set tunable"); then
2465 error "set tunables failed for symlink device"
2468 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2470 run_test 37 "verify set tunables works for symlink device"
2472 test_38() { # bug 14222
2473 local fstype=$(facet_fstype $SINGLEMDS)
2474 local mntpt=$(facet_mntpt $SINGLEMDS)
2479 local SRC="/etc /bin"
2480 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2481 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2482 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2483 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2484 error "copying $SRC to $DIR/$tdir"
2486 umount_client $MOUNT || error "umount_client $MOUNT failed"
2487 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2488 stop_mds || error "Unable to stop MDS"
2489 log "delete lov_objid file on MDS"
2491 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2493 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2495 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2497 # check create in mds_lov_connect
2498 start_mds || error "unable to start MDS"
2499 mount_client $MOUNT || error "mount_client $MOUNT failed"
2501 [ $V ] && log "verifying $DIR/$tdir/$f"
2502 diff -q $f $DIR/$tdir/$f || ERROR=y
2504 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2505 if [ "$ERROR" = "y" ]; then
2506 # check it's updates in sync
2507 umount_client $MOUNT
2509 mount_fstype $SIGNLEMDS
2510 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2511 unmount_fstype $SINGLEMDS
2512 error "old and new files are different after connect" || true
2514 touch $DIR/$tdir/f2 || error "f2 file create failed"
2516 # check it's updates in sync
2517 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2520 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2522 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2523 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2525 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2527 start_mds || error "unable to start MDS"
2528 mount_client $MOUNT || error "mount_client $MOUNT failed"
2530 [ $V ] && log "verifying $DIR/$tdir/$f"
2531 diff -q $f $DIR/$tdir/$f || ERROR=y
2533 touch $DIR/$tdir/f3 || error "f3 file create failed"
2534 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2535 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2537 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2538 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2539 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2541 [ "$ERROR" = "y" ] &&
2542 error "old and new files are different after sync" || true
2544 log "files compared the same"
2545 cleanup || error "cleanup failed with $?"
2547 run_test 38 "MDS recreates missing lov_objid file from OST data"
2552 cleanup || error "cleanup failed with $?"
2553 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2554 error "memory leak detected" || true
2556 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2558 test_40() { # bug 15759
2559 start_ost || error "Unable to start OST1"
2560 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2561 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2563 cleanup || error "cleanup failed with rc $?"
2565 run_test 40 "race during service thread startup"
2567 test_41a() { #bug 14134
2568 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2569 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2570 skip "Loop devices does not work with nosvc option"
2574 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2576 start_mdt 1 -o nosvc -n
2577 if [ $MDSCOUNT -ge 2 ]; then
2578 for num in $(seq 2 $MDSCOUNT); do
2579 start_mdt $num || return
2582 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2583 start_mdt 1 -o nomgs,force
2584 mount_client $MOUNT || error "mount_client $MOUNT failed"
2587 echo "blah blah" > $MOUNT/$tfile
2590 umount_client $MOUNT || error "umount_client $MOUNT failed"
2591 stop ost1 -f || error "unable to stop OST1"
2592 stop_mds || error "Unable to stop MDS"
2593 stop_mds || error "Unable to stop MDS on second try"
2594 unload_modules_conf || error "unload_modules_conf failed"
2596 run_test 41a "mount mds with --nosvc and --nomgs"
2599 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2600 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2601 skip "Loop devices does not work with nosvc option"
2605 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2609 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2611 start_mdt 1 -o nosvc -n
2612 if [ $MDSCOUNT -ge 2 ]; then
2613 for num in $(seq 2 $MDSCOUNT); do
2614 start_mdt $num || return
2617 start_ost || error "Unable to start OST1"
2618 start_mdt 1 -o nomgs,force
2619 mount_client $MOUNT || error "mount_client $MOUNT failed"
2622 echo "blah blah" > $MOUNT/$tfile
2623 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
2625 umount_client $MOUNT || error "umount_client $MOUNT failed"
2626 stop_ost || error "Unable to stop OST1"
2627 stop_mds || error "Unable to stop MDS"
2628 stop_mds || error "Unable to stop MDS on second try"
2630 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2633 local server_version=$(lustre_version_code $SINGLEMDS)
2635 [[ $server_version -ge $(version_code 2.6.52) ]] ||
2636 [[ $server_version -ge $(version_code 2.5.26) &&
2637 $server_version -lt $(version_code 2.5.50) ]] ||
2638 [[ $server_version -ge $(version_code 2.5.4) &&
2639 $server_version -lt $(version_code 2.5.11) ]] ||
2640 { skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"; return; }
2643 # MDT concurrent start
2644 #define OBD_FAIL_TGT_DELAY_CONNECT 0x703
2645 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x703"
2646 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS &
2649 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
2650 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS &
2656 if [ $rc == 0 ] && [ $rc2 == 114 ]; then
2657 echo "1st MDT start succeed"
2658 echo "2nd MDT start failed with EALREADY"
2659 elif [ $rc2 == 0 ] && [ $rc == 114 ]; then
2660 echo "1st MDT start failed with EALREADY"
2661 echo "2nd MDT start succeed"
2664 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
2667 if [ $MDSCOUNT -ge 2 ]; then
2668 for num in $(seq 2 $MDSCOUNT); do
2669 start_mdt $num || return
2673 # OST concurrent start
2675 #define OBD_FAIL_TGT_DELAY_CONNECT 0x703
2676 do_facet ost1 "$LCTL set_param fail_loc=0x703"
2677 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &
2680 do_facet ost1 "$LCTL set_param fail_loc=0x0"
2681 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &
2687 if [ $rc == 0 ] && [ $rc2 == 114 ]; then
2688 echo "1st OST start succeed"
2689 echo "2nd OST start failed with EALREADY"
2690 elif [ $rc2 == 0 ] && [ $rc == 114 ]; then
2691 echo "1st OST start failed with EALREADY"
2692 echo "2nd OST start succeed"
2696 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
2702 # verify everything ok
2707 error "MDT(s) start failed"
2715 error "OST(s) start failed"
2723 error "client start failed"
2730 error "client mount failed"
2734 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
2736 test_42() { #bug 14693
2738 check_mount || error "client was not mounted"
2740 do_facet mgs $LCTL conf_param $FSNAME.llite.some_wrong_param=10
2741 umount_client $MOUNT ||
2742 error "unmounting client failed with invalid llite param"
2743 mount_client $MOUNT ||
2744 error "mounting client failed with invalid llite param"
2746 do_facet mgs $LCTL conf_param $FSNAME.sys.some_wrong_param=20
2747 cleanup || error "stopping $FSNAME failed with invalid sys param"
2750 check_mount || error "client was not mounted with invalid sys param"
2751 cleanup || error "stopping $FSNAME failed with invalid sys param"
2753 run_test 42 "allow client/server mount/unmount with invalid config param"
2756 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.58) ]] ||
2757 { skip "Need MDS version at least 2.5.58" && return 0; }
2758 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
2761 USER1=$(cat /etc/passwd | grep :$ID1:$ID1: | cut -d: -f1)
2762 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
2766 chmod ugo+x $DIR || error "chmod 0 failed"
2767 set_conf_param_and_check mds \
2768 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2769 "$FSNAME.mdt.root_squash" \
2771 wait_update $HOSTNAME \
2772 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
2774 error "check llite root_squash failed!"
2775 set_conf_param_and_check mds \
2776 "$LCTL get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2777 "$FSNAME.mdt.nosquash_nids" \
2779 wait_update $HOSTNAME \
2780 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
2782 error "check llite nosquash_nids failed!"
2785 # create set of test files
2787 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
2788 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
2789 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
2791 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
2792 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
2794 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
2795 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
2796 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
2798 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
2799 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
2800 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
2803 # check root_squash:
2804 # set root squash UID:GID to RUNAS_ID
2805 # root should be able to access only files owned by RUNAS_ID
2807 set_conf_param_and_check mds \
2808 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2809 "$FSNAME.mdt.root_squash" \
2810 "$RUNAS_ID:$RUNAS_ID"
2811 wait_update $HOSTNAME \
2812 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
2813 "$RUNAS_ID:$RUNAS_ID" ||
2814 error "check llite root_squash failed!"
2816 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
2817 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
2818 error "$ST: root read permission is denied"
2819 echo "$ST: root read permission is granted - ok"
2822 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
2823 error "$ST: root write permission is denied"
2824 echo "$ST: root write permission is granted - ok"
2826 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2827 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
2828 error "$ST: root read permission is granted"
2829 echo "$ST: root read permission is denied - ok"
2832 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
2833 error "$ST: root write permission is granted"
2834 echo "$ST: root write permission is denied - ok"
2836 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2837 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
2838 error "$ST: root unlink permission is granted"
2839 echo "$ST: root unlink permission is denied - ok"
2841 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
2842 error "$ST: root create permission is granted"
2843 echo "$ST: root create permission is denied - ok"
2846 # check root_squash is enforced independently
2847 # of client cache content
2849 # access file by USER1, keep access open
2850 # root should be denied access to user file
2852 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
2856 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
2857 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
2858 { kill $pid; error "$ST: root read permission is granted"; }
2859 echo "$ST: root read permission is denied - ok"
2862 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
2863 { kill $pid; error "$ST: root write permission is granted"; }
2864 echo "$ST: root write permission is denied - ok"
2870 # check nosquash_nids:
2871 # put client's NID into nosquash_nids list,
2872 # root should be able to access root file after that
2874 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
2875 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
2876 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
2877 set_conf_param_and_check mds \
2878 "$LCTL get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2879 "$FSNAME-MDTall.mdt.nosquash_nids" \
2881 wait_update $HOSTNAME \
2882 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
2884 error "check llite nosquash_nids failed!"
2886 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2887 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
2888 error "$ST: root read permission is denied"
2889 echo "$ST: root read permission is granted - ok"
2892 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
2893 error "$ST: root write permission is denied"
2894 echo "$ST: root write permission is granted - ok"
2896 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2897 rm $DIR/$tdir-rootdir/tfile-1 ||
2898 error "$ST: root unlink permission is denied"
2899 echo "$ST: root unlink permission is granted - ok"
2900 touch $DIR/$tdir-rootdir/tfile-2 ||
2901 error "$ST: root create permission is denied"
2902 echo "$ST: root create permission is granted - ok"
2904 run_test 43 "check root_squash and nosquash_nids"
2906 umount_client $MOUNT
2911 check_mount || error "check_mount"
2912 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
2914 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
2915 for VAL in $UUIDS; do
2916 NID=$(echo $VAL | cut -d= -f1)
2917 CLUUID=$(echo $VAL | cut -d= -f2)
2918 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
2920 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
2921 cleanup || error "cleanup failed with $?"
2923 run_test 44 "mounted client proc entry exists"
2927 check_mount || error "check_mount"
2928 stop_mds || error "Unable to stop MDS"
2932 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
2933 do_facet client "$LCTL set_param fail_loc=0x50f"
2936 manual_umount_client --force || error "manual_umount_client failed"
2937 do_facet client "$LCTL set_param fail_loc=0x0"
2938 start_mds || error "unable to start MDS"
2939 mount_client $MOUNT || error "mount_client $MOUNT failed"
2940 cleanup || error "cleanup failed with $?"
2942 run_test 45 "long unlink handling in ptlrpcd"
2949 umount_client $MOUNT2 || rc=$?
2950 umount_client $MOUNT || rc=$?
2951 while [ $count -gt 0 ]; do
2952 stop ost${count} -f || rc=$?
2956 cleanup_nocli || rc=$?
2957 #writeconf to remove all ost2 traces for subsequent tests
2958 writeconf_or_reformat
2963 echo "Testing with $OSTCOUNT OSTs"
2965 start_mds || error "unable to start MDS"
2966 #first client should see only one ost
2967 start_ost || error "Unable to start OST1"
2968 wait_osc_import_state mds ost FULL
2970 mount_client $MOUNT || error "mount_client $MOUNT failed"
2971 trap "cleanup_46a $OSTCOUNT" EXIT ERR
2974 for (( i=2; i<=$OSTCOUNT; i++ )); do
2975 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
2976 error "start_ost$i $(ostdevname $i) failed"
2979 # wait until osts in sync
2980 for (( i=2; i<=$OSTCOUNT; i++ )); do
2981 wait_osc_import_state mds ost$i FULL
2982 wait_osc_import_state client ost$i FULL
2985 #second client see all ost's
2987 mount_client $MOUNT2 || error "mount_client failed"
2988 $SETSTRIPE -c -1 $MOUNT2 || error "$SETSTRIPE -c -1 $MOUNT2 failed"
2989 $GETSTRIPE $MOUNT2 || error "$GETSTRIPE $MOUNT2 failed"
2991 echo "ok" > $MOUNT2/widestripe
2992 $GETSTRIPE $MOUNT2/widestripe ||
2993 error "$GETSTRIPE $MOUNT2/widestripe failed"
2994 # fill acl buffer for avoid expand lsm to them
2995 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
2997 setfacl -m $acl $MOUNT2/widestripe
3001 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3003 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
3005 run_test 46a "handle ost additional - wide striped file"
3010 check_mount || error "check_mount failed"
3011 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
3015 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3016 if echo $ns | grep "MDT[[:digit:]]*"; then
3019 lrs=$(echo $ns | sed 's/.*lru_size=//')
3020 lru_size[count]=$lrs
3025 facet_failover $SINGLEMDS
3026 client_up || error "client_up failed"
3029 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3030 if echo $ns | grep "MDT[[:digit:]]*"; then
3033 lrs=$(echo $ns | sed 's/.*lru_size=//')
3034 if ! test "$lrs" -eq "${lru_size[count]}"; then
3035 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
3036 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
3041 cleanup || error "cleanup failed with $?"
3043 run_test 47 "server restart does not make client loss lru_resize settings"
3048 # reformat after this test is needed - if the test fails,
3049 # we will have unkillable file at FS
3053 test_48() { # bug 17636
3056 check_mount || error "check_mount failed"
3058 $SETSTRIPE -c -1 $MOUNT || error "$SETSTRIPE -c -1 $MOUNT failed"
3059 $GETSTRIPE $MOUNT || error "$GETSTRIPE $MOUNT failed"
3061 echo "ok" > $MOUNT/widestripe
3062 $GETSTRIPE $MOUNT/widestripe ||
3063 error "$GETSTRIPE $MOUNT/widestripe failed"
3065 trap cleanup_48 EXIT ERR
3067 # fill acl buffer for avoid expand lsm to them
3068 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
3069 setfacl -m $acl $MOUNT/widestripe
3072 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3076 run_test 48 "too many acls on file"
3078 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3079 test_49a() { # bug 17710
3080 local timeout_orig=$TIMEOUT
3081 local ldlm_timeout_orig=$LDLM_TIMEOUT
3082 local LOCAL_TIMEOUT=20
3084 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3085 TIMEOUT=$LOCAL_TIMEOUT
3089 check_mount || error "client mount failed"
3091 echo "check ldlm_timout..."
3092 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3093 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3094 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3096 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3097 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3100 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3101 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3104 umount_client $MOUNT || error "umount_client $MOUNT failed"
3105 stop_ost || error "problem stopping OSS"
3106 stop_mds || error "problem stopping MDS"
3108 LDLM_TIMEOUT=$ldlm_timeout_orig
3109 TIMEOUT=$timeout_orig
3111 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3113 test_49b() { # bug 17710
3114 local timeout_orig=$TIMEOUT
3115 local ldlm_timeout_orig=$LDLM_TIMEOUT
3116 local LOCAL_TIMEOUT=20
3118 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3119 TIMEOUT=$LOCAL_TIMEOUT
3123 check_mount || error "client mount failed"
3125 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3126 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3127 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3129 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3130 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3133 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3134 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3137 cleanup || error "cleanup failed"
3139 LDLM_TIMEOUT=$ldlm_timeout_orig
3140 TIMEOUT=$timeout_orig
3142 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3145 # Test both statfs and lfs df and fail if either one fails
3146 multiop_bg_pause $1 f_
3149 killall -USR1 multiop
3150 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
3151 wait $PID || { RC1=$?; log "multiop return error "; }
3158 if [ $RC2 -eq 0 ]; then
3160 log "lazystatfs df failed"
3164 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
3170 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3171 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3173 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3175 cleanup || error "cleanup failed with rc $?"
3177 run_test 50a "lazystatfs all servers available"
3181 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3182 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3184 # Wait for client to detect down OST
3185 stop_ost || error "Unable to stop OST1"
3186 wait_osc_import_state mds ost DISCONN
3188 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
3190 umount_client $MOUNT || error "Unable to unmount client"
3191 stop_mds || error "Unable to stop MDS"
3193 run_test 50b "lazystatfs all servers down"
3196 start_mds || error "Unable to start MDS"
3197 start_ost || error "Unable to start OST1"
3198 start_ost2 || error "Unable to start OST2"
3199 mount_client $MOUNT || error "Unable to mount client"
3200 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3201 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3203 # Wait for client to detect down OST
3204 stop_ost || error "Unable to stop OST1"
3205 wait_osc_import_state mds ost DISCONN
3206 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3208 umount_client $MOUNT || error "Unable to unmount client"
3209 stop_ost2 || error "Unable to stop OST2"
3210 stop_mds || error "Unable to stop MDS"
3211 #writeconf to remove all ost2 traces for subsequent tests
3212 writeconf_or_reformat
3214 run_test 50c "lazystatfs one server down"
3217 start_mds || error "Unable to start MDS"
3218 start_ost || error "Unable to start OST1"
3219 start_ost2 || error "Unable to start OST2"
3220 mount_client $MOUNT || error "Unable to mount client"
3221 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3222 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3224 # Issue the statfs during the window where the client still
3225 # belives the OST to be available but it is in fact down.
3226 # No failure just a statfs which hangs for a timeout interval.
3227 stop_ost || error "Unable to stop OST1"
3228 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3230 umount_client $MOUNT || error "Unable to unmount client"
3231 stop_ost2 || error "Unable to stop OST2"
3232 stop_mds || error "Unable to stop MDS"
3233 #writeconf to remove all ost2 traces for subsequent tests
3234 writeconf_or_reformat
3236 run_test 50d "lazystatfs client/server conn race"