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 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 journal 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 LU-9860 LU-9860 LU-9860 LU-9860
72 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b 33a 43b 53b 54b"
73 # bug number for skipped test: LU-9875 LU-9879 LU-9879 LU-9879 LU-9879
74 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 70e 80 84 87 100"
75 # bug number for skipped test: LU-8110 LU-9400 LU-9879 LU-9879 LU-9879
76 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 102 103 104 105 107"
79 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
80 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
81 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
84 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
85 # bug number for skipped test: LU-9888
86 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 32b"
91 require_dsh_mds || exit 0
92 require_dsh_ost || exit 0
95 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69"
100 # The MGS must be started before the OSTs for a new fs, so start
101 # and stop to generate the startup logs.
104 wait_osc_import_state mds ost FULL
109 reformat_and_config() {
111 if ! combined_mgs_mds ; then
117 writeconf_or_reformat() {
118 # There are at most 2 OSTs for write_conf test
119 # who knows if/where $TUNEFS is installed?
120 # Better reformat if it fails...
121 writeconf_all $MDSCOUNT 2 ||
122 { echo "tunefs failed, reformatting instead" &&
123 reformat_and_config && return 0; }
133 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
139 local dev=$(mdsdevname $num)
142 echo "start mds service on `facet_active_host $facet`"
143 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
149 local dev=$(mdsdevname $num)
152 echo "stop mds service on `facet_active_host $facet`"
153 # These tests all use non-failover stop
154 stop $facet -f || return 97
160 for num in $(seq $MDSCOUNT); do
161 start_mdt $num $@ || return 94
166 if ! combined_mgs_mds ; then
174 for num in $(seq $MDSCOUNT); do
175 stop_mdt $num || return 97
180 echo "stop mgs service on `facet_active_host mgs`"
181 # These tests all use non-failover stop
182 stop mgs -f || return 97
186 echo "start ost1 service on `facet_active_host ost1`"
187 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
191 echo "stop ost1 service on `facet_active_host ost1`"
192 # These tests all use non-failover stop
193 stop ost1 -f || return 98
197 echo "start ost2 service on `facet_active_host ost2`"
198 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
202 echo "stop ost2 service on `facet_active_host ost2`"
203 # These tests all use non-failover stop
204 stop ost2 -f || return 93
209 echo "mount $FSNAME on ${MOUNTPATH}....."
210 zconf_mount $(hostname) $MOUNTPATH || return 96
214 local mountopt="remount,$1"
216 echo "remount '$1' lustre on ${MOUNTPATH}....."
217 zconf_mount $(hostname) $MOUNTPATH "$mountopt" || return 96
223 echo "umount lustre on $mountpath....."
224 zconf_umount $HOSTNAME $mountpath $@ || return 97
227 manual_umount_client(){
230 echo "manual umount lustre on ${MOUNT}...."
231 do_facet client "umount ${FORCE} $MOUNT"
237 start_mds || error "MDT start failed"
238 start_ost || error "Unable to start OST1"
239 mount_client $MOUNT || error "client start failed"
240 client_up || error "client_up failed"
249 unload_modules_conf () {
250 if combined_mgs_mds || ! local_mode; then
251 unload_modules || return 1
256 stop_ost || return 202
257 stop_mds || return 201
258 unload_modules_conf || return 203
262 umount_client $MOUNT || return 200
263 cleanup_nocli || return $?
268 echo "umount $MOUNT2 ..."
269 umount $MOUNT2 || true
270 echo "stopping fs2mds ..."
271 stop fs2mds -f || true
272 echo "stopping fs2ost ..."
273 stop fs2ost -f || true
277 do_facet client "cp /etc/passwd $DIR/a" || return 71
278 do_facet client "rm $DIR/a" || return 72
279 # make sure lustre is actually mounted (touch will block,
280 # but grep won't, so do it after)
281 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
282 echo "setup single mount lustre success"
286 do_facet client "touch $DIR/a" || return 71
287 do_facet client "rm $DIR/a" || return 72
288 do_facet client "touch $DIR2/a" || return 73
289 do_facet client "rm $DIR2/a" || return 74
290 echo "setup double mount lustre success"
295 if [ "$ONLY" == "setup" ]; then
300 if [ "$ONLY" == "cleanup" ]; then
307 #create single point mountpoint
313 check_mount || error "check_mount failed"
314 cleanup || error "cleanup failed with $?"
316 run_test 0 "single mount setup"
319 start_mds || error "MDS start failed"
320 start_ost || error "unable to start OST"
321 echo "start ost second time..."
322 start_ost && error "2nd OST start should fail"
323 mount_client $MOUNT || error "client start failed"
324 check_mount || error "check_mount failed"
325 cleanup || error "cleanup failed with $?"
327 run_test 1 "start up ost twice (should return errors)"
330 start_mds || error "MDT start failed"
331 echo "start mds second time.."
332 start_mds && error "2nd MDT start should fail"
333 start_ost || error "OST start failed"
334 mount_client $MOUNT || error "mount_client failed to start client"
335 check_mount || error "check_mount failed"
336 cleanup || error "cleanup failed with $?"
338 run_test 2 "start up mds twice (should return err)"
342 #mount.lustre returns an error if already in mtab
343 mount_client $MOUNT && error "2nd client mount should fail"
344 check_mount || error "check_mount failed"
345 cleanup || error "cleanup failed with $?"
347 run_test 3 "mount client twice (should return err)"
351 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
352 stop_ost || error "Unable to stop OST1"
353 umount_client $MOUNT -f || error “unmount $MOUNT failed”
356 # ok for ost to fail shutdown
357 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
358 error "cleanup failed with $?"
361 run_test 4 "force cleanup ost, then cleanup"
363 test_5a() { # was test_5
365 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
366 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
368 stop_mds || error "Unable to stop MDS"
370 # cleanup may return an error from the failed
371 # disconnects; for now I'll consider this successful
372 # if all the modules have unloaded.
376 echo "killing umount"
377 kill -TERM $UMOUNT_PID
378 echo "waiting for umount to finish"
380 if grep " $MOUNT " /proc/mounts; then
381 echo "test 5: /proc/mounts after failed umount"
385 echo "killing umount"
386 kill -TERM $UMOUNT_PID
387 echo "waiting for umount to finish"
389 grep " $MOUNT " /proc/mounts &&
390 error "/proc/mounts after second umount"
393 # manual_mount_client may fail due to umount succeeding above
395 # stop_mds is a no-op here, and should not fail
396 cleanup_nocli || error "cleanup_nocli failed with $?"
397 # df may have lingering entry
399 # mtab may have lingering entry
403 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
405 grep -q $MOUNT" " /etc/mtab || break
406 echo "Waiting /etc/mtab updated ... "
407 WAIT=$(( WAIT + sleep))
409 [ "$WAIT" -eq "$MAX_WAIT" ] &&
410 error "/etc/mtab is not updated in $WAIT secs"
411 echo "/etc/mtab updated in $WAIT secs"
413 run_test 5a "force cleanup mds, then cleanup"
421 grep " $MOUNT " /etc/mtab &&
422 error false "unexpected entry in mtab before mount" && return 10
424 start_ost || error "OST start failed"
425 if ! combined_mgs_mds ; then
426 trap cleanup_5b EXIT ERR
427 start_mds || error "MDS start failed"
431 mount_client $MOUNT && error "mount_client $MOUNT should fail"
432 grep " $MOUNT " /etc/mtab &&
433 error "$MOUNT entry in mtab after failed mount"
435 # stop_mds is a no-op here, and should not fail
436 cleanup_nocli || error "cleanup_nocli failed with $?"
437 if ! combined_mgs_mds ; then
441 run_test 5b "Try to start a client with no MGS (should return errs)"
444 grep " $MOUNT " /etc/mtab &&
445 error false "unexpected entry in mtab before mount" && return 10
447 start_mds || error "MDS start failed"
448 start_ost || error "OST start failed"
449 local oldfs="${FSNAME}"
450 FSNAME="wrong.${FSNAME}"
451 mount_client $MOUNT || :
453 grep " $MOUNT " /etc/mtab &&
454 error "$MOUNT entry in mtab after failed mount"
456 cleanup_nocli || error "cleanup_nocli failed with $?"
458 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
461 grep " $MOUNT " /etc/mtab &&
462 error "unexpected entry in mtab before mount"
464 start_ost || error "OST start failed"
465 start_mds || error "MDS start failed"
466 stop_ost -f || error "Unable to stop OST1"
467 mount_client $MOUNT || error "mount_client $MOUNT failed"
468 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
469 cleanup_nocli || error "cleanup_nocli failed with $?"
470 ! grep " $MOUNT " /etc/mtab ||
471 error "$MOUNT entry in mtab after unmount"
473 run_test 5d "mount with ost down"
476 grep " $MOUNT " /etc/mtab &&
477 error false "unexpected entry in mtab before mount" && return 10
479 start_mds || error "MDS start failed"
480 start_ost || error "OST start failed"
482 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
483 do_facet client "$LCTL set_param fail_loc=0x80000506"
484 mount_client $MOUNT || echo "mount failed (not fatal)"
485 cleanup || error "cleanup failed with $?"
486 grep " $MOUNT " /etc/mtab &&
487 error "$MOUNT entry in mtab after unmount"
490 run_test 5e "delayed connect, don't crash (bug 10268)"
493 if combined_mgs_mds ; then
494 skip "needs separate mgs and mds"
498 grep " $MOUNT " /etc/mtab &&
499 error false "unexpected entry in mtab before mount" && return 10
502 start_ost || error "OST start failed"
503 mount_client $MOUNT &
505 echo client_mount pid is $pid
509 if ! ps -f -p $pid >/dev/null; then
512 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
513 error "mount returns $rc, expected to hang"
515 cleanup || error "cleanup failed with $?"
520 start_mds || error "start MDS failed"
522 # mount should succeed after start mds
524 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
525 cleanup || error "final call to cleanup failed with rc $?"
527 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
531 [ $(lustre_version_code client) -lt $(version_code 2.9.53) ] &&
532 { skip "automount of debugfs missing before 2.9.53" && return 0; }
533 umount /sys/kernel/debug
534 $LCTL get_param -n devices | egrep -v "error" && \
535 error "lctl can't access debugfs data"
536 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
538 run_test 5g "handle missing debugfs"
543 mount_client $MOUNT || error "mount_client $MOUNT failed"
544 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
545 cleanup || error "cleanup failed with rc $?"
547 run_test 6 "manual umount, then mount again"
552 cleanup_nocli || error "cleanup_nocli failed with $?"
554 run_test 7 "manual umount, then cleanup"
558 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
559 check_mount2 || error "check_mount2 failed"
560 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
561 cleanup || error "cleanup failed with rc $?"
563 run_test 8 "double mount setup"
566 start_ost || error "OST start failed"
568 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
569 error "do_facet ost1 set_param inode trace failed."
570 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
571 error "do_facet ost1 set_param debug mds ost failed."
573 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
574 if [ "$CHECK_PTLDEBUG" ] && { \
575 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
576 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
577 echo "lnet.debug success"
579 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
581 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
582 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
583 echo "lnet.subsystem_debug success"
585 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
587 stop_ost || error "Unable to stop OST1"
589 run_test 9 "test ptldebug and subsystem for mkfs"
597 do_facet $facet "test -b $dev" || rc=1
598 if [[ "$size" ]]; then
599 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k \
600 count=1 skip=$size 2>&1" |
601 awk '($3 == "in") { print $1 }')
602 [[ $in = "1+0" ]] || rc=1
608 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
609 # But with new MDS stack we don't care about the mode of local objects
610 # anymore, so this test is removed. See bug 22944 for more details.
614 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
615 skip "ldiskfs only test"
620 check_mount || error "check_mount failed"
621 cleanup || error "cleanup failed with rc $?"
623 echo "Remove mds config log"
624 if ! combined_mgs_mds ; then
628 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
629 $(mgsdevname) || return \$?" ||
630 error "do_facet mgs failed with $?"
632 if ! combined_mgs_mds ; then
636 start_ost || error "OST start failed"
637 start_mds && error "MDS start succeeded, but should fail"
640 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
643 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
644 skip "ldiskfs only test"
648 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
653 # check if current MDSSIZE is large enough
654 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
655 log "use MDSSIZE=$MDSSIZE"
657 # check if the global config has a large enough MDSSIZE
658 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
659 [ $STORED_MDSSIZE -ge $MIN ] &&
660 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
661 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
663 # check if the block device is large enough
664 is_blkdev $SINGLEMDS $MDSDEV $MIN
665 local large_enough=$?
666 if [ -n "$OK" ]; then
667 [ $large_enough -ne 0 ] && OK=""
669 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
670 log "use device $MDSDEV with MIN=$MIN"
673 # check if a loopback device has enough space for fs metadata (5%)
675 if [ -z "$OK" ]; then
676 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
677 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
678 awk '($1 != "Filesystem") { print $4 }')
679 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
680 OK=1 && myMDSSIZE=$MIN &&
681 log "use file $MDSDEV with MIN=$MIN"
684 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
686 echo "mount mds with large journal..."
688 local OLD_MDSSIZE=$MDSSIZE
692 echo "mount lustre system..."
694 check_mount || error "check_mount failed"
696 echo "check journal size..."
697 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
698 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
699 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
701 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
704 cleanup || error "cleanup failed with rc $?"
709 run_test 18 "check mkfs creates large journals"
712 start_mds || error "MDS start failed"
713 stop_mds || error "Unable to stop MDS"
715 run_test 19a "start/stop MDS without OSTs"
718 start_ost || error "Unable to start OST1"
719 stop_ost -f || error "Unable to stop OST1"
721 run_test 19b "start/stop OSTs without MDS"
724 # first format the ost/mdt
725 start_mds || error "MDS start failed"
726 start_ost || error "Unable to start OST1"
727 mount_client $MOUNT || error "mount_client $MOUNT failed"
728 check_mount || error "check_mount failed"
729 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
730 remount_client ro $MOUNT || error "remount_client with ro failed"
731 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
732 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
733 remount_client rw $MOUNT || error "remount_client with rw failed"
734 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
735 MCNT=$(grep -c $MOUNT /etc/mtab)
736 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
738 stop_mds || error "Unable to stop MDS"
739 stop_ost || error "Unable to stop OST1"
741 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
744 start_mds || error "MDS start failed"
745 start_ost || error "unable to start OST1"
746 wait_osc_import_state mds ost FULL
747 stop_ost || error "unable to stop OST1"
748 stop_mds || error "unable to stop MDS"
750 run_test 21a "start mds before ost, stop ost first"
753 start_ost || error "unable to start OST1"
754 start_mds || error "MDS start failed"
755 wait_osc_import_state mds ost FULL
756 stop_mds || error "unable to stop MDS"
757 stop_ost || error "unable to stop OST1"
759 run_test 21b "start ost before mds, stop mds first"
762 start_ost || error "Unable to start OST1"
763 start_mds || error "MDS start failed"
764 start_ost2 || error "Unable to start OST2"
765 wait_osc_import_state mds ost2 FULL
766 stop_ost || error "Unable to stop OST1"
767 stop_ost2 || error "Unable to stop OST2"
768 stop_mds || error "Unable to stop MDS"
769 #writeconf to remove all ost2 traces for subsequent tests
770 writeconf_or_reformat
772 run_test 21c "start mds between two osts, stop mds last"
775 if combined_mgs_mds ; then
776 skip "need separate mgs device" && return 0
782 start_mgs || error "unable to start MGS"
783 start_ost || error "unable to start OST1"
784 start_ost2 || error "unable to start OST2"
785 start_mds || error "MDS start failed"
786 wait_osc_import_state mds ost2 FULL
788 stop_ost || error "Unable to stop OST1"
789 stop_ost2 || error "Unable to stop OST2"
790 stop_mds || error "Unable to stop MDS"
792 #writeconf to remove all ost2 traces for subsequent tests
793 writeconf_or_reformat
794 start_mgs || error "unable to start MGS"
796 run_test 21d "start mgs then ost and then mds"
799 MGSNID="$saved_mgsnid"
801 echo "stopping fs2mgs ..."
802 stop $fs2mgs -f || true
805 test_21e() { # LU-5863
806 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
807 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
808 skip_env "mixed loopback and real device not working" && return
811 local fs2mdsdev=$(mdsdevname 1_2)
812 local fs2ostdev=$(ostdevname 1_2)
813 local fs3ostdev=$(ostdevname 2_2)
815 local fs2mdsvdev=$(mdsvdevname 1_2)
816 local fs2ostvdev=$(ostvdevname 1_2)
817 local fs3ostvdev=$(ostvdevname 2_2)
819 # temporarily use fs3ost as fs2mgs
821 local fs2mgsdev=$fs3ostdev
822 local fs2mgsvdev=$fs3ostvdev
824 local fsname=test1234
826 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
827 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
828 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
829 error "start fs2mgs failed"
831 local saved_mgsnid="$MGSNID"
832 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
834 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
835 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
836 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
837 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
839 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
840 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
842 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
843 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
844 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
848 run_test 21e "separate MGS and MDS"
851 start_mds || error "MDS start failed"
853 echo "Client mount with ost in logs, but none running"
854 start_ost || error "unable to start OST1"
855 # wait until mds connected to ost and open client connection
856 wait_osc_import_state mds ost FULL
857 stop_ost || error "unable to stop OST1"
858 mount_client $MOUNT || error "mount_client $MOUNT failed"
859 # check_mount will block trying to contact ost
860 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
861 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
862 umount_client $MOUNT -f
865 echo "Client mount with a running ost"
866 start_ost || error "unable to start OST1"
868 # if gss enabled, wait full time to let connection from
869 # mds to ost be established, due to the mismatch between
870 # initial connect timeout and gss context negotiation timeout.
871 # This perhaps could be remove after AT landed.
872 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
873 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
875 mount_client $MOUNT || error "mount_client $MOUNT failed"
876 wait_osc_import_state mds ost FULL
877 wait_osc_import_state client ost FULL
878 check_mount || error "check_mount failed"
881 cleanup || error "cleanup failed with rc $?"
883 run_test 22 "start a client before osts (should return errs)"
885 test_23a() { # was test_23
888 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
889 # force down client so that recovering mds waits for reconnect
890 local running=$(grep -c $MOUNT /proc/mounts) || true
891 if [ $running -ne 0 ]; then
892 echo "Stopping client $MOUNT (opts: -f)"
896 # enter recovery on failed mds
897 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
898 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
899 # try to start a new client
900 mount_client $MOUNT &
902 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
903 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
904 grep -v grep | awk '{print $2}')
905 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
907 ps --ppid $MOUNT_LUSTRE_PID
908 echo "waiting for mount to finish"
910 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
911 # SIGTERM works but it does not spread to offspring processses
912 kill -s TERM $MOUNT_PID
913 kill -s TERM $MOUNT_LUSTRE_PID
914 # we can not wait $MOUNT_PID because it is not a child of this shell
920 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
922 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
923 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
926 [ -z "$PID1" -a -z "$PID2" ] && break
927 echo "waiting for mount to finish ... "
928 WAIT=$(( WAIT + sleep))
930 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
931 error "MOUNT_PID $MOUNT_PID and "\
932 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
935 stop_mds || error "stopping MDSes failed"
936 stop_ost || error "stopping OSSes failed"
938 run_test 23a "interrupt client during recovery mount delay"
943 test_23b() { # was test_23
944 start_mds || error "MDS start failed"
945 start_ost || error "Unable to start OST1"
946 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
947 $LCTL set_param fail_loc=0x80000313
949 cleanup || error "cleanup failed with rc $?"
951 run_test 23b "Simulate -EINTR during mount"
954 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
956 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
957 is_blkdev $SINGLEMDS $MDSDEV &&
958 skip_env "mixed loopback and real device not working" && return
961 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
963 local fs2mdsdev=$(mdsdevname 1_2)
964 local fs2ostdev=$(ostdevname 1_2)
965 local fs2mdsvdev=$(mdsvdevname 1_2)
966 local fs2ostvdev=$(ostvdevname 1_2)
969 # LU-9733 test fsname started with numbers as well
970 local FSNAME2=969362ae
972 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
973 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
975 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
976 --reformat $fs2ostdev $fs2ostvdev || exit 10
979 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
980 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
981 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
982 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
984 # LU-9733 test fsname started with numbers
985 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
986 changelog_register -n) ||
987 error "register changelog failed"
989 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
990 changelog_deregister $cl_user ||
991 error "deregister changelog failed"
993 check_mount || error "check_mount failed"
994 # files written on 1 should not show up on 2
995 cp /etc/passwd $DIR/$tfile
997 [ -e $MOUNT2/$tfile ] && error "File bleed"
1000 cp /etc/passwd $MOUNT2/$tfile ||
1001 error "cp /etc/passwd $MOUNT2/$tfile failed"
1002 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
1003 # 2 is actually mounted
1004 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
1006 facet_failover fs2mds
1007 facet_failover fs2ost
1009 umount_client $MOUNT
1010 # the MDS must remain up until last MDT
1012 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1013 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1014 [ -z "$MDS" ] && error "No MDT"
1016 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1018 run_test 24a "Multiple MDTs on a single node"
1021 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1023 if [ -z "$fs2mds_DEV" ]; then
1024 local dev=${SINGLEMDS}_dev
1025 local MDSDEV=${!dev}
1026 is_blkdev $SINGLEMDS $MDSDEV &&
1027 skip_env "mixed loopback and real device not working" && return
1030 local fs2mdsdev=$(mdsdevname 1_2)
1031 local fs2mdsvdev=$(mdsvdevname 1_2)
1033 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1034 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1036 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS &&
1037 error "start MDS should fail"
1039 cleanup || error "cleanup failed with rc $?"
1041 run_test 24b "Multiple MGSs on a single node (should return err)"
1045 check_mount || error "check_mount failed"
1046 local MODULES=$($LCTL modules | awk '{ print $2 }')
1047 rmmod $MODULES 2>/dev/null || true
1048 cleanup || error "cleanup failed with $?"
1050 run_test 25 "Verify modules are referenced"
1054 # we need modules before mount for sysctl, so make sure...
1055 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1056 #define OBD_FAIL_MDS_FS_SETUP 0x135
1057 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1058 start_mds && error "MDS started but should not have started"
1059 $LCTL get_param -n devices
1060 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1061 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1062 # start mds to drop writeconf setting
1063 start_mds || error "Unable to start MDS"
1064 stop_mds || error "Unable to stop MDS"
1065 unload_modules_conf || error "unload_modules_conf failed with $?"
1067 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1070 start_ost || error "Unable to start OST1"
1071 start_mds || error "Unable to start MDS"
1072 echo "Requeue thread should have started: "
1073 ps -e | grep ll_cfg_requeue
1074 set_conf_param_and_check ost1 \
1075 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1076 "$FSNAME-OST0000.ost.client_cache_seconds" ||
1077 error "set_conf_param_and_check ost1 failed"
1078 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1080 run_test 27a "Reacquire MGS lock if OST started first"
1085 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1086 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1088 facet_failover $SINGLEMDS
1089 set_conf_param_and_check $SINGLEMDS \
1090 "$LCTL get_param -n mdt.$device.identity_acquire_expire" \
1091 "$device.mdt.identity_acquire_expire" ||
1092 error "set_conf_param_and_check $SINGLEMDS failed"
1093 set_conf_param_and_check client \
1094 "$LCTL get_param -n mdc.$device-mdc-*.max_rpcs_in_flight"\
1095 "$device.mdc.max_rpcs_in_flight" ||
1096 error "set_conf_param_and_check client failed"
1098 cleanup || error "cleanup failed with $?"
1100 run_test 27b "Reacquire MGS lock after failover"
1104 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1105 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1107 FINAL=$(($ORIG + 1))
1108 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1109 error "first set_conf_param_and_check client failed"
1110 FINAL=$(($FINAL + 1))
1111 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1112 error "second set_conf_param_and_check client failed"
1113 umount_client $MOUNT || error "umount_client $MOUNT failed"
1114 mount_client $MOUNT || error "mount_client $MOUNT failed"
1116 if [ $RESULT -ne $FINAL ]; then
1117 error "New config not seen: wanted $FINAL got $RESULT"
1119 echo "New config success: got $RESULT"
1121 set_conf_param_and_check client "$TEST" "$PARAM" $ORIG ||
1122 error "third set_conf_param_and_check client failed"
1123 cleanup || error "cleanup failed with rc $?"
1125 run_test 28 "permanent parameter setting"
1127 test_28a() { # LU-4221
1128 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1129 { skip "Need OST version at least 2.5.52" && return 0; }
1130 [ "$(facet_fstype ost1)" = "zfs" ] &&
1131 skip "LU-4221: no such proc params for ZFS OSTs" && return
1138 local device="$FSNAME-OST0000"
1142 # In this test we will set three kinds of proc parameters with
1144 # 1. the ones moved from the OFD to the OSD, and only their
1145 # symlinks kept in obdfilter
1146 # 2. non-symlink ones in the OFD
1147 # 3. non-symlink ones in the OSD
1150 # prepare a symlink parameter in the OFD
1151 name="writethrough_cache_enable"
1152 param="$device.ost.$name"
1153 cmd="$LCTL get_param -n obdfilter.$device.$name"
1155 # conf_param the symlink parameter in the OFD
1156 old=$(do_facet ost1 $cmd)
1157 new=$(((old + 1) % 2))
1158 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1159 error "lctl conf_param $device.ost.$param=$new failed"
1161 # conf_param the target parameter in the OSD
1162 param="$device.osd.$name"
1163 cmd="$LCTL get_param -n osd-*.$device.$name"
1164 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1165 error "lctl conf_param $device.osd.$param=$old failed"
1168 # prepare a non-symlink parameter in the OFD
1169 name="client_cache_seconds"
1170 param="$device.ost.$name"
1171 cmd="$LCTL get_param -n obdfilter.$device.$name"
1173 # conf_param the parameter in the OFD
1174 old=$(do_facet ost1 $cmd)
1176 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1177 error "lctl conf_param $device.ost.$param=$new failed"
1178 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1179 error "lctl conf_param $device.ost.$param=$old failed"
1182 # prepare a non-symlink parameter in the OSD
1184 param="$device.osd.$name"
1185 cmd="$LCTL get_param -n osd-*.$device.$name"
1187 # conf_param the parameter in the OSD
1188 old=$(do_facet ost1 $cmd)
1189 new=$(((old + 1) % 2))
1190 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1191 error "lctl conf_param $device.osd.$param=$new failed"
1192 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1193 error "lctl conf_param $device.osd.$param=$old failed"
1195 cleanup || error "cleanup failed with $?"
1197 run_test 28a "set symlink parameters permanently with conf_param"
1200 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1201 setup > /dev/null 2>&1
1202 start_ost2 || error "Unable to start OST2"
1205 local PARAM="$FSNAME-OST0001.osc.active"
1206 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1207 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1209 ACTV=$($LCTL get_param -n $PROC_ACT)
1211 set_conf_param_and_check client \
1212 "$LCTL get_param -n $PROC_ACT" "$PARAM" $DEAC ||
1213 error "set_conf_param_and_check client failed"
1214 # also check ost_server_uuid status
1215 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1216 if [ -z "$RESULT" ]; then
1217 error "Client not deactivated: $($LCTL get_param \
1220 echo "Live client success: got $RESULT"
1224 wait_osp_active ost ${FSNAME}-OST0001 1 0
1226 # test new client starts deactivated
1227 umount_client $MOUNT || error "umount_client $MOUNT failed"
1228 mount_client $MOUNT || error "mount_client $MOUNT failed"
1229 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1230 if [ -z "$RESULT" ]; then
1231 error "New client start active: $(lctl get_param -n $PROC_UUID)"
1233 echo "New client success: got $RESULT"
1236 # make sure it reactivates
1237 set_conf_param_and_check client \
1238 "$LCTL get_param -n $PROC_ACT" "$PARAM" $ACTV ||
1239 error "lctl get_param $PROC_ACT $PARAM $ACTV failed"
1241 umount_client $MOUNT
1242 stop_ost2 || error "Unable to stop OST2"
1243 cleanup_nocli || error "cleanup_nocli failed with $?"
1244 #writeconf to remove all ost2 traces for subsequent tests
1245 writeconf_or_reformat
1247 run_test 29 "permanently remove an OST"
1252 echo Big config llog
1253 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1255 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1256 for i in ${LIST[@]}; do
1257 set_conf_param_and_check client "$TEST" \
1258 "$FSNAME.llite.max_read_ahead_whole_mb" $i ||
1259 error "Set $FSNAME.llite.max_read_ahead_whole_mb failed"
1261 # make sure client restart still works
1262 umount_client $MOUNT
1263 mount_client $MOUNT || error "mount_client $MOUNT failed"
1264 [ "$($TEST)" -ne "$i" ] &&
1265 error "Param didn't stick across restart $($TEST) != $i"
1268 echo Erase parameter setting
1269 do_facet mgs "$LCTL conf_param \
1270 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1271 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1272 umount_client $MOUNT
1273 mount_client $MOUNT || error "mount_client $MOUNT failed"
1275 echo "deleted (default) value=$FINAL, orig=$ORIG"
1276 # assumes this parameter started at the default value
1277 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1279 cleanup || error "cleanup failed with rc $?"
1281 run_test 30a "Big config llog and conf_param deletion"
1286 local orignids=$($LCTL get_param -n \
1287 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1289 local orignidcount=$(echo "$orignids" | wc -w)
1291 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1292 # numerical part of it. Hopefully that's not already a failover address
1294 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1296 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1297 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1298 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1299 echo "Using fake nid $NEW"
1301 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1302 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1303 set_conf_param_and_check client "$TEST" \
1304 "$FSNAME-OST0000.failover.node" $NEW ||
1305 error "didn't add failover nid $NEW"
1306 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1309 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1310 echo "should have $((orignidcount + 1)) entries \
1311 in failover nids string, have $NIDCOUNT"
1312 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1313 error "Failover nid not added"
1315 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" ||
1316 error "conf_param delete failed"
1317 umount_client $MOUNT
1318 mount_client $MOUNT || error "mount_client $MOUNT failed"
1320 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1323 NIDCOUNT=$(echo "$NIDS" | wc -w)
1324 echo "only $orignidcount final entries should remain \
1325 in failover nids string, have $NIDCOUNT"
1326 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1328 cleanup || error "cleanup failed with rc $?"
1330 run_test 30b "Remove failover nids"
1332 test_31() { # bug 10734
1333 # ipaddr must not exist
1334 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1335 cleanup || error "cleanup failed with rc $?"
1337 run_test 31 "Connect to non-existent node (shouldn't crash)"
1341 T32_BLIMIT=40960 # Kbytes
1345 # This is not really a test but a tool to create new disk
1346 # image tarballs for the upgrade tests.
1348 # Disk image tarballs should be created on single-node
1349 # clusters by running this test with default configurations
1350 # plus a few mandatory environment settings that are verified
1351 # at the beginning of the test.
1353 test_32newtarball() {
1357 local tmp=$TMP/t32_image_create
1358 local server_version=$(lustre_version_code $SINGLEMDS)
1363 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1364 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1365 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1366 "MDSDEV1=<nonexistent_file>" \
1367 "MDSDEV2=<nonexistent_file>" \
1368 "(or MDSDEV, in the case of b1_8)" \
1369 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1373 echo "Found stale $tmp"
1377 mkdir $tmp/src || return 1
1378 tar cf - -C $src . | tar xf - -C $tmp/src
1379 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1380 count=$(($T32_BLIMIT / 1024 / 4))
1381 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1383 # format ost with comma-separated NIDs to verify LU-4460
1384 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1385 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1389 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1390 $LFS quotacheck -ug /mnt/$FSNAME
1391 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1394 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1396 if [[ $MDSCOUNT -ge 2 ]]; then
1397 remote_dir=/mnt/$FSNAME/remote_dir
1398 $LFS mkdir -i 1 $remote_dir
1399 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1401 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1402 striped_dir=/mnt/$FSNAME/striped_dir_old
1403 $LFS mkdir -i 1 -c 2 $striped_dir
1404 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1410 mkdir $tmp/img || return 1
1414 pushd_dir=/mnt/$FSNAME
1415 if [[ $MDSCOUNT -ge 2 ]]; then
1416 pushd_dir=$remote_dir
1417 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1419 ls -Rni --time-style=+%s >$tmp/img/list2
1425 ls -Rni --time-style=+%s >$tmp/img/list
1426 find ! -name .lustre -type f -exec sha1sum {} \; |
1427 sort -k 2 >$tmp/img/sha1sums
1429 $LCTL get_param -n version | head -n 1 |
1430 sed -e 's/^lustre: *//' >$tmp/img/commit
1432 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1433 $LFS quotaon -ug /mnt/$FSNAME
1434 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1435 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1436 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1437 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1438 | tr -d "*" > $tmp/img/bspace
1439 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1440 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1441 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1442 | tr -d "*" > $tmp/img/ispace
1443 echo $T32_BLIMIT > $tmp/img/blimit
1444 echo $T32_ILIMIT > $tmp/img/ilimit
1449 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1452 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1453 echo "Data verification failed"
1456 uname -r >$tmp/img/kernel
1457 uname -m >$tmp/img/arch
1459 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1460 for num in $(seq 2 $MDSCOUNT); do
1461 local devname=$(mdsdevname $num)
1463 [[ $(facet_fstype $facet) != zfs ]] ||
1464 devname=$(mdsvdevname $num)
1465 mv $devname $tmp/img
1467 mv $OSTDEV1 $tmp/img
1469 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1470 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1473 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1478 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1481 # The list of applicable tarballs is returned via the caller's
1482 # variable "tarballs".
1485 local node=$(facet_active_host $SINGLEMDS)
1486 local r="do_node $node"
1488 if [ "$CLIENTONLY" ]; then
1489 skip "Client-only testing"
1493 if ! $r which $TUNEFS; then
1494 skip_env "tunefs.lustre required on $node"
1498 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1500 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1501 -name \'disk*-$IMGTYPE.tar.bz2\')
1503 if [ -z "$tarballs" ]; then
1504 skip "No applicable tarballs found"
1509 t32_test_cleanup() {
1511 local facet=$SINGLEMDS
1512 local fstype=$(facet_fstype $facet)
1515 if $shall_cleanup_lustre; then
1516 umount $tmp/mnt/lustre || rc=$?
1518 if $shall_cleanup_mdt; then
1519 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1521 if $shall_cleanup_mdt1; then
1522 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1524 if $shall_cleanup_ost; then
1525 $r $UMOUNT $tmp/mnt/ost || rc=$?
1530 if [[ $fstype == zfs ]]; then
1532 local poolname_list="t32fs-mdt1 t32fs-ost1"
1534 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1536 for poolname in $poolname_list; do
1537 destroy_zpool $facet $poolname
1540 combined_mgs_mds || start_mgs || rc=$?
1544 t32_bits_per_long() {
1546 # Yes, this is not meant to be perfect.
1556 t32_reload_modules() {
1558 local all_removed=false
1561 while ((i < 20)); do
1562 echo "Unloading modules on $node: Attempt $i"
1563 do_rpc_nodes $node $LUSTRE_RMMOD $(facet_fstype $SINGLEMDS) &&
1565 do_rpc_nodes $node check_mem_leak || return 1
1566 if $all_removed; then
1567 do_rpc_nodes $node load_modules
1573 echo "Unloading modules on $node: Given up"
1577 t32_wait_til_devices_gone() {
1583 echo wait for devices to go
1584 while ((i < 20)); do
1585 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1586 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1587 ((devices == 0 && loops == 0)) && return 0
1591 echo "waiting for dev on $node: dev $devices loop $loops given up"
1592 do_rpc_nodes $node "losetup -a"
1593 do_rpc_nodes $node "$LCTL device_list"
1597 t32_verify_quota() {
1601 local fstype=$(facet_fstype $SINGLEMDS)
1605 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1606 # lustre will estimate the object count usage. This fails quota
1607 # verification in 32b. The object quota usage should be accurate after
1608 # zfs-0.7.0 is released.
1609 [ $fstype == "zfs" ] && {
1610 local zfs_version=$(do_node $node cat /sys/module/zfs/version)
1612 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1613 echo "Skip quota verify for zfs: $zfs_version"
1618 $LFS quota -u $T32_QID -v $mnt
1620 qval=$($LFS quota -v -u $T32_QID $mnt |
1621 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1622 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1624 [ $qval -eq $img_bspace ] || {
1625 echo "bspace, act:$qval, exp:$img_bspace"
1629 qval=$($LFS quota -v -u $T32_QID $mnt |
1630 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1631 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1633 [ $qval -eq $img_ispace ] || {
1634 echo "ispace, act:$qval, exp:$img_ispace"
1638 qval=$($LFS quota -v -u $T32_QID $mnt |
1639 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1640 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1642 [ $qval -eq $img_blimit ] || {
1643 echo "blimit, act:$qval, exp:$img_blimit"
1647 qval=$($LFS quota -v -u $T32_QID $mnt |
1648 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1649 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1651 [ $qval -eq $img_ilimit ] || {
1652 echo "ilimit, act:$qval, exp:$img_ilimit"
1656 do_node $node $LCTL conf_param $fsname.quota.mdt=ug
1657 cmd="$LCTL get_param -n osd-$fstype.$fsname-MDT0000"
1658 cmd=$cmd.quota_slave.enabled
1659 wait_update $node "$cmd" "ug" || {
1660 echo "Enable mdt quota failed"
1664 do_node $node $LCTL conf_param $fsname.quota.ost=ug
1665 cmd="$LCTL get_param -n osd-$fstype.$fsname-OST0000"
1666 cmd=$cmd.quota_slave.enabled
1667 wait_update $node "$cmd" "ug" || {
1668 echo "Enable ost quota failed"
1673 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1674 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1675 echo "Write succeed, but expect -EDQUOT"
1678 rm -f $mnt/t32_qf_new
1680 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1682 echo "Create succeed, but expect -EDQUOT"
1685 unlinkmany $mnt/t32_qf_ $img_ilimit
1693 local dne_upgrade=${dne_upgrade:-"no"}
1694 local ff_convert=${ff_convert:-"no"}
1695 local shall_cleanup_mdt=false
1696 local shall_cleanup_mdt1=false
1697 local shall_cleanup_ost=false
1698 local shall_cleanup_lustre=false
1699 local mdt2_is_available=false
1700 local node=$(facet_active_host $SINGLEMDS)
1701 local r="do_node $node"
1717 local fstype=$(facet_fstype $SINGLEMDS)
1718 local mdt_dev=$tmp/mdt
1719 local mdt2_dev=$tmp/mdt2
1720 local ost_dev=$tmp/ost
1725 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1726 trap 'trap - RETURN; t32_test_cleanup' RETURN
1729 nid=$($r $LCTL list_nids | head -1)
1731 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1732 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1733 $r tar xjvf $tarball -S -C $tmp || {
1734 error_noexit "Unpacking the disk image tarball"
1737 img_commit=$($r cat $tmp/commit)
1738 img_kernel=$($r cat $tmp/kernel)
1739 img_arch=$($r cat $tmp/arch)
1740 img_bspace=$($r cat $tmp/bspace)
1741 img_ispace=$($r cat $tmp/ispace)
1743 # older images did not have "blimit" and "ilimit" files
1744 # use old values for T32_BLIMIT and T32_ILIMIT
1745 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1747 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1750 echo "Upgrading from $(basename $tarball), created with:"
1751 echo " Commit: $img_commit"
1752 echo " Kernel: $img_kernel"
1753 echo " Arch: $img_arch"
1754 echo "OST version: $(lustre_build_version ost1)"
1756 # The conversion can be made only when both of the following
1757 # conditions are satisfied:
1758 # - ost device img version < 2.3.64
1759 # - ost server version >= 2.5
1760 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1761 $(lustre_version_code ost1) -lt $(version_code 2.5.0) ] &&
1764 ! $r test -f $mdt2_dev || mdt2_is_available=true
1766 if [[ $fstype == zfs ]]; then
1769 local poolname_list="t32fs-mdt1 t32fs-ost1"
1771 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1773 for poolname in $poolname_list; do
1775 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1776 $ZPOOL import -f -d $tmp $poolname"
1779 # upgrade zpool to latest supported features, including
1780 # dnode quota accounting in 0.7.0
1781 $r "$ZPOOL upgrade -a"
1783 mdt_dev=t32fs-mdt1/mdt1
1784 ost_dev=t32fs-ost1/ost1
1785 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1786 wait_update_facet $SINGLEMDS "$ZPOOL list |
1787 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1788 error_noexit "import zfs pool failed"
1793 $r $LCTL set_param debug="$PTLDEBUG"
1795 $r $TUNEFS --dryrun $mdt_dev || {
1797 error_noexit "tunefs.lustre before mounting the MDT"
1801 if $mdt2_is_available; then
1802 $r $TUNEFS --dryrun $mdt2_dev || {
1804 error_noexit "tunefs.lustre before mounting the MDT"
1809 if [ "$writeconf" ]; then
1811 if [ $fstype == "ldiskfs" ]; then
1813 $r $TUNEFS --quota $mdt_dev || {
1815 error_noexit "Enable mdt quota feature"
1818 if $mdt2_is_available; then
1819 $r $TUNEFS --quota $mdt2_dev || {
1821 error_noexit "Enable mdt quota feature"
1827 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1828 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1829 { skip "LU-2200: Cannot run over Inifiniband w/o lctl replace_nids "
1830 "(Need MGS version at least 2.3.59)"; return 0; }
1832 local osthost=$(facet_active_host ost1)
1833 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1836 if [ $fstype == "ldiskfs" ]; then
1839 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1840 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1841 $r $LCTL replace_nids $fsname-MDT0000 $nid
1842 $r $UMOUNT $tmp/mnt/mdt
1845 mopts=exclude=$fsname-OST0000
1846 if [ $fstype == "ldiskfs" ]; then
1851 t32_wait_til_devices_gone $node
1853 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1855 error_noexit "Mounting the MDT"
1858 shall_cleanup_mdt=true
1860 if $mdt2_is_available; then
1861 mopts=mgsnode=$nid,$mopts
1862 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1864 error_noexit "Mounting the MDT"
1868 echo "mount new MDT....$mdt2_dev"
1869 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1870 error_noexit "enable remote dir create failed"
1872 shall_cleanup_mdt1=true
1873 elif [ "$dne_upgrade" != "no" ]; then
1874 local fs2mdsdev=$(mdsdevname 1_2)
1875 local fs2mdsvdev=$(mdsvdevname 1_2)
1877 echo "mkfs new MDT on ${fs2mdsdev}...."
1878 if [ $(facet_fstype mds1) == ldiskfs ]; then
1879 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1882 add $SINGLEMDS $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1883 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1884 error_noexit "Mkfs new MDT failed"
1888 [[ $(facet_fstype mds1) != zfs ]] || import_zpool mds1
1890 $r $TUNEFS --dryrun $fs2mdsdev || {
1891 error_noexit "tunefs.lustre before mounting the MDT"
1895 echo "mount new MDT....$fs2mdsdev"
1896 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1897 error_noexit "mount mdt1 failed"
1901 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1902 error_noexit "enable remote dir create failed"
1904 shall_cleanup_mdt1=true
1907 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1908 error_noexit "Getting MDT UUID"
1911 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1912 error_noexit "Unexpected MDT UUID: \"$uuid\""
1916 $r $TUNEFS --dryrun $ost_dev || {
1917 error_noexit "tunefs.lustre before mounting the OST"
1920 if [ "$writeconf" ]; then
1921 mopts=mgsnode=$nid,$writeconf
1922 if [ $fstype == "ldiskfs" ]; then
1924 $r $TUNEFS --quota $ost_dev || {
1926 error_noexit "Enable ost quota feature"
1932 if [ $fstype == "ldiskfs" ]; then
1937 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1938 error_noexit "Mounting the OST"
1941 shall_cleanup_ost=true
1943 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1944 error_noexit "Getting OST UUID"
1947 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1948 error_noexit "Unexpected OST UUID: \"$uuid\""
1952 $r $LCTL conf_param $fsname-OST0000.osc.max_dirty_mb=15 || {
1953 error_noexit "Setting \"max_dirty_mb\""
1956 $r $LCTL conf_param $fsname-OST0000.failover.node=$nid || {
1957 error_noexit "Setting OST \"failover.node\""
1960 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1961 error_noexit "Setting \"max_rpcs_in_flight\""
1964 $r $LCTL conf_param $fsname-MDT0000.failover.node=$nid || {
1965 error_noexit "Setting MDT \"failover.node\""
1968 $r $LCTL pool_new $fsname.interop || {
1969 error_noexit "Setting \"interop\""
1972 $r $LCTL conf_param $fsname-MDT0000.lov.stripesize=4M || {
1973 error_noexit "Setting \"lov.stripesize\""
1976 $r $LCTL conf_param $fsname-MDT0000.mdd.atime_diff=70 || {
1977 error_noexit "Setting \"mdd.atime_diff\""
1981 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1982 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1983 error_noexit "Start OI scrub on OST0"
1987 # The oi_scrub should be on ost1, but for test_32(),
1988 # all on the SINGLEMDS.
1989 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1990 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1991 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1992 error_noexit "Failed to get the expected 'completed'"
1996 local UPDATED=$($r $LCTL get_param -n \
1997 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1998 awk '/^updated/ { print $2 }')
1999 [ $UPDATED -ge 1 ] || {
2000 error_noexit "Only $UPDATED objects have been converted"
2005 if [ "$dne_upgrade" != "no" ]; then
2006 $r $LCTL conf_param \
2007 $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2008 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2011 $r $LCTL conf_param $fsname-MDT0001.failover.node=$nid || {
2012 error_noexit "Setting MDT1 \"failover.node\""
2015 $r $LCTL conf_param $fsname-MDT0001.lov.stripesize=4M || {
2016 error_noexit "Setting MDT1 \"lov.stripesize\""
2021 if [ "$writeconf" ]; then
2022 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2023 error_noexit "Mounting the client"
2027 shall_cleanup_lustre=true
2028 $r $LCTL set_param debug="$PTLDEBUG"
2030 t32_verify_quota $node $fsname $tmp/mnt/lustre || {
2031 error_noexit "verify quota failed"
2035 if $r test -f $tmp/list; then
2037 # There is not a Test Framework API to copy files to or
2038 # from a remote node.
2040 # LU-2393 - do both sorts on same node to ensure locale
2042 local list_file=$tmp/list
2044 if $mdt2_is_available; then
2045 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2046 $r test -f $tmp/list2; then
2047 list_file=$tmp/list2
2048 pushd $tmp/mnt/lustre/striped_dir_old
2050 pushd $tmp/mnt/lustre/remote_dir
2053 pushd $tmp/mnt/lustre
2055 $r cat $list_file | sort -k 6 >$tmp/list.orig
2056 ls -Rni --time-style=+%s | sort -k 6 |
2057 sed 's/\. / /' >$tmp/list || {
2063 # 32-bit and 64-bit clients use different algorithms to
2064 # convert FIDs into inode numbers. Hence, remove the
2065 # inode numbers from the lists, if the original list was
2066 # created on an architecture with different number of
2069 if [ $(t32_bits_per_long $(uname -m)) != \
2070 $(t32_bits_per_long $img_arch) ]; then
2071 echo "Different number of bits per \"long\"" \
2072 "from the disk image"
2073 for list in list.orig list; do
2074 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2078 if ! diff -ub $tmp/list.orig $tmp/list; then
2079 error_noexit "list verification failed"
2083 echo "list verification skipped"
2086 if [ "$dne_upgrade" != "no" ]; then
2087 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2088 error_noexit "set striped dir failed"
2092 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2094 pushd $tmp/mnt/lustre
2095 tar -cf - . --exclude=./striped_dir \
2096 --exclude=./striped_dir_old \
2097 --exclude=./remote_dir |
2098 tar -xvf - -C striped_dir 1>/dev/null || {
2099 error_noexit "cp to striped dir failed"
2105 # If it is upgrade from DNE (2.5), then rename the remote dir,
2106 # which is created in 2.5 to striped dir.
2107 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2108 stripe_index=$($LFS getdirstripe -i \
2109 $tmp/mnt/lustre/remote_dir)
2111 [[ $stripe_index -eq 1 ]] || {
2112 error_noexit "get index \"$stripe_index\"" \
2113 "from remote dir failed"
2116 mv $tmp/mnt/lustre/remote_dir \
2117 $tmp/mnt/lustre/striped_dir/ || {
2118 error_noexit "mv remote dir failed"
2123 # If it is upgraded from DNE (2.7), then move the striped dir
2124 # which was created in 2.7 to the new striped dir.
2125 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2126 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2127 stripe_count=$($LFS getdirstripe -c \
2128 $tmp/mnt/lustre/striped_dir_old)
2129 [[ $stripe_count -eq 2 ]] || {
2130 error_noexit "get count $stripe_count" \
2131 "from striped dir failed"
2134 mv $tmp/mnt/lustre/striped_dir_old \
2135 $tmp/mnt/lustre/striped_dir/ || {
2136 error_noexit "mv striped dir failed"
2142 $r $LCTL set_param -n osd*.*.force_sync=1
2143 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2144 error_noexit "dd failed"
2147 rm -rf $tmp/mnt/lustre/tmp_file || {
2148 error_noexit "rm failed"
2152 if $r test -f $tmp/sha1sums; then
2153 # LU-2393 - do both sorts on same node to ensure locale
2155 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2156 if [ "$dne_upgrade" != "no" ]; then
2157 pushd $tmp/mnt/lustre/striped_dir
2159 pushd $tmp/mnt/lustre
2162 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2163 ! -name .lustre -type f -exec sha1sum {} \; |
2164 sort -k 2 >$tmp/sha1sums || {
2166 error_noexit "sha1sum"
2170 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2171 error_noexit "sha1sum verification failed"
2175 # if upgrade from DNE(2.5), then check remote directory
2176 # if upgrade from DNE(2.7), then check striped directory
2177 if $mdt2_is_available &&
2178 [[ "$dne_upgrade" != "no" ]]; then
2179 local new_dir="$tmp/mnt/lustre/striped_dir"
2180 local striped_dir_old="$new_dir/striped_dir_old"
2182 local dir_list="$new_dir/remote_dir"
2183 [[ ! -d $triped_dir_old ]] ||
2184 dir_list+=" $striped_dir_old"
2186 for dir in $dir_list; do
2188 find ! -name .lustre -type f \
2189 -exec sha1sum {} \; |
2190 sort -k 2 >$tmp/sha1sums || {
2192 error_noexit "sha1sum"
2196 if ! diff -ub $tmp/sha1sums.orig \
2198 error_noexit "sha1sum $dir" \
2205 echo "sha1sum verification skipped"
2208 if [ "$dne_upgrade" != "no" ]; then
2209 rm -rf $tmp/mnt/lustre/striped_dir || {
2210 error_noexit "remove remote dir failed"
2215 # migrate files/dirs to remote MDT, then move them back
2216 if [ $(lustre_version_code mds1) -ge $(version_code 2.7.50) -a \
2217 $dne_upgrade != "no" ]; then
2218 $r $LCTL set_param -n \
2219 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2221 echo "test migration"
2222 pushd $tmp/mnt/lustre
2223 for dir in $(find ! -name .lustre ! -name . -type d); do
2224 mdt_index=$($LFS getdirstripe -i $dir)
2225 stripe_cnt=$($LFS getdirstripe -c $dir)
2226 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2227 $LFS mv -M 1 $dir || {
2229 error_noexit "migrate MDT1 failed"
2235 for dir in $(find ! -name . ! -name .lustre -type d); do
2236 mdt_index=$($LFS getdirstripe -i $dir)
2237 stripe_cnt=$($LFS getdirstripe -c $dir)
2238 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2239 $LFS mv -M 0 $dir || {
2241 error_noexit "migrate MDT0 failed"
2250 # When adding new data verification tests, please check for
2251 # the presence of the required reference files first, like
2252 # the "sha1sums" and "list" tests above, to avoid the need to
2253 # regenerate every image for each test addition.
2256 nrpcs_orig=$($LCTL get_param \
2257 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2258 error_noexit "Getting \"max_rpcs_in_flight\""
2261 nrpcs=$((nrpcs_orig + 5))
2262 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=$nrpcs || {
2263 error_noexit "Changing \"max_rpcs_in_flight\""
2266 wait_update $HOSTNAME "$LCTL get_param \
2267 -n mdc.*MDT0000*.max_rpcs_in_flight" $nrpcs || {
2268 error_noexit "Verifying \"max_rpcs_in_flight\""
2272 umount $tmp/mnt/lustre || {
2273 error_noexit "Unmounting the client"
2276 shall_cleanup_lustre=false
2278 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2279 $r $UMOUNT $tmp/mnt/mdt1 || {
2280 error_noexit "Unmounting the MDT2"
2283 shall_cleanup_mdt1=false
2286 $r $UMOUNT $tmp/mnt/mdt || {
2287 error_noexit "Unmounting the MDT"
2290 shall_cleanup_mdt=false
2292 $r $UMOUNT $tmp/mnt/ost || {
2293 error_noexit "Unmounting the OST"
2296 shall_cleanup_ost=false
2298 t32_reload_modules $node || {
2299 error_noexit "Reloading modules"
2303 if [[ $fstype == zfs ]]; then
2304 local poolname=t32fs-mdt1
2306 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2307 $ZPOOL import -f -d $tmp $poolname"
2309 # upgrade zpool to latest supported features,
2310 # including dnode quota accounting in 0.7.0
2311 $r "$ZPOOL upgrade $poolname"
2314 # mount a second time to make sure we didnt leave upgrade flag on
2315 $r $TUNEFS --dryrun $mdt_dev || {
2317 error_noexit "tunefs.lustre before remounting the MDT"
2321 mopts=exclude=$fsname-OST0000
2322 if [ $fstype == "ldiskfs" ]; then
2325 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2326 error_noexit "Remounting the MDT"
2329 shall_cleanup_mdt=true
2339 for tarball in $tarballs; do
2340 t32_test $tarball || let "rc += $?"
2344 run_test 32a "Upgrade (not live)"
2352 for tarball in $tarballs; do
2353 t32_test $tarball writeconf || let "rc += $?"
2357 run_test 32b "Upgrade with writeconf"
2364 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2366 for tarball in $tarballs; do
2367 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2368 echo $tarball | grep "1_8" && continue
2369 echo $tarball | grep "2_1" && continue
2371 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2375 run_test 32c "dne upgrade test"
2383 for tarball in $tarballs; do
2384 ff_convert=yes t32_test $tarball || rc=$?
2388 run_test 32d "convert ff test"
2390 test_33a() { # bug 12333, was test_33
2391 local FSNAME2=test-123
2392 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2395 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2397 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2398 local dev=${SINGLEMDS}_dev
2399 local MDSDEV=${!dev}
2400 is_blkdev $SINGLEMDS $MDSDEV &&
2401 skip_env "mixed loopback and real device not working" &&
2405 local fs2mdsdev=$(mdsdevname 1_2)
2406 local fs2ostdev=$(ostdevname 1_2)
2407 local fs2mdsvdev=$(mdsvdevname 1_2)
2408 local fs2ostvdev=$(ostvdevname 1_2)
2410 if [ $(facet_fstype mds1) == ldiskfs ]; then
2411 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2414 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2415 --reformat $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
2416 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2417 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2418 $fs2ostvdev || exit 10
2420 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2421 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2422 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" ||
2423 error "$LCTL conf_param $FSNAME2.sys.timeout=200 failed"
2424 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2425 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2428 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2429 $GETSTRIPE $MOUNT2/hosts || error "$GETSTRIPE $MOUNT2/hosts failed"
2434 cleanup_nocli || error "cleanup_nocli failed with $?"
2436 run_test 33a "Mount ost with a large index number"
2438 test_33b() { # was test_34
2441 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2442 # Drop lock cancelation reply during umount
2443 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2444 do_facet client $LCTL set_param fail_loc=0x80000304
2445 #lctl set_param debug=-1
2446 umount_client $MOUNT
2447 cleanup || error "cleanup failed with $?"
2449 run_test 33b "Drop cancel during umount"
2453 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2454 manual_umount_client
2456 do_facet client killall -USR1 multiop
2457 if [ $rc -eq 0 ]; then
2458 error "umount not fail!"
2461 cleanup || error "cleanup failed with rc $?"
2463 run_test 34a "umount with opened file should be fail"
2467 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2468 stop_mds || error "Unable to stop MDS"
2470 manual_umount_client --force || error "mtab after failed umount with $?"
2472 cleanup || error "cleanup failed with $?"
2474 run_test 34b "force umount with failed mds should be normal"
2478 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2479 stop_ost || error "Unable to stop OST1"
2481 manual_umount_client --force || error "mtab after failed umount with $?"
2483 cleanup || error "cleanup failed with $?"
2485 run_test 34c "force umount with failed ost should be normal"
2487 test_35a() { # bug 12459
2490 DBG_SAVE="`$LCTL get_param -n debug`"
2491 $LCTL set_param debug="ha"
2493 log "Set up a fake failnode for the MDS"
2495 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2496 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2497 do_facet mgs "$LCTL conf_param \
2498 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2499 error "Setting ${device}.failover.node=\
2500 $(h2nettype $FAKENID) failed."
2502 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2505 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2508 log "Stopping the MDT: $device"
2509 stop_mdt 1 || error "MDT0 stop fail"
2511 df $MOUNT > /dev/null 2>&1 &
2513 log "Restarting the MDT: $device"
2514 start_mdt 1 || error "MDT0 start fail"
2515 log "Wait for df ($DFPID) ... "
2518 $LCTL set_param debug="$DBG_SAVE"
2520 # retrieve from the log the first server that the client tried to
2521 # contact after the connection loss
2522 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2523 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2524 /import_select_connection.*$device-mdc.* using connection/ {
2526 if (\\\$NF ~ /$FAKENID/)
2532 }" $TMP/lustre-log-$TESTNAME.log`
2533 [ "$NEXTCONN" != "0" ] &&
2534 error "Tried to connect to ${NEXTCONN} not last active server"
2535 cleanup || error "cleanup failed with $?"
2536 # remove nid settings
2537 writeconf_or_reformat
2539 run_test 35a "Reconnect to the last active server first"
2541 test_35b() { # bug 18674
2542 remote_mds || { skip "local MDS" && return 0; }
2546 $LCTL set_param debug="ha"
2548 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2551 log "Set up a fake failnode for the MDS"
2553 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2554 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2555 do_facet mgs "$LCTL conf_param \
2556 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2557 error "Set ${device}.failover.node=\
2558 $(h2nettype $FAKENID) failed"
2560 local at_max_saved=0
2561 # adaptive timeouts may prevent seeing the issue
2562 if at_is_enabled; then
2563 at_max_saved=$(at_max_get mds)
2564 at_max_set 0 mds client
2567 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2569 log "Injecting EBUSY on MDS"
2570 # Setting OBD_FAIL_MDS_RESEND=0x136
2571 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2572 error "unable to set param fail_loc=0x80000136"
2574 $LCTL set_param mdc.${FSNAME}*.stats=clear
2576 log "Creating a test file and stat it"
2577 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2578 stat $MOUNT/$tdir/$tfile
2580 log "Stop injecting EBUSY on MDS"
2581 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2582 error "unable to set param fail_loc=0"
2583 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2586 # restore adaptive timeout
2587 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2589 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2591 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2592 awk '/mds_connect/{print $2}')
2594 # retrieve from the log if the client has ever tried to
2595 # contact the fake server after the loss of connection
2596 FAILCONN=`awk "BEGIN {ret = 0;}
2597 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2599 if (\\\$NF ~ /$FAKENID/) {
2604 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2606 [ "$FAILCONN" == "0" ] &&
2607 error "The client reconnection has not been triggered"
2608 [ "$FAILCONN" == "2" ] &&
2609 error "Primary server busy, client reconnect to failover failed"
2612 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2613 # Reconnects are supposed to be rate limited to one every 5s
2614 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2615 error "Too many reconnects $CONNCNT"
2617 cleanup || error "cleanup failed with $?"
2618 # remove nid settings
2619 writeconf_or_reformat
2621 run_test 35b "Continue reconnection retries, if the active server is busy"
2624 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
2626 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2627 { skip "remote OST" && return 0; }
2630 local FSNAME2=test1234
2631 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2633 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2635 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2636 is_blkdev $SINGLEMDS $MDSDEV &&
2637 skip_env "mixed loopback and real device not working" && return
2640 local fs2mdsdev=$(mdsdevname 1_2)
2641 local fs2ostdev=$(ostdevname 1_2)
2642 local fs3ostdev=$(ostdevname 2_2)
2643 local fs2mdsvdev=$(mdsvdevname 1_2)
2644 local fs2ostvdev=$(ostvdevname 1_2)
2645 local fs3ostvdev=$(ostvdevname 2_2)
2647 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2648 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2649 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2650 # different one than the default value here.
2651 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2652 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2653 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2654 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2656 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2657 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2658 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2659 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2660 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2662 sleep 5 # until 11778 fixed
2664 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2666 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2667 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2668 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2669 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2670 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2671 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2672 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2673 DFTOTAL=$(echo $STRING | cut -d, -f1)
2674 DFUSED=$(echo $STRING | cut -d, -f2)
2675 DFAVAIL=$(echo $STRING | cut -d, -f3)
2676 DFFREE=$(($DFTOTAL - $DFUSED))
2678 ALLOWANCE=$((64 * $OSTCOUNT))
2680 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2681 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2682 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2685 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2686 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2687 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2690 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2691 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2692 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2697 stop fs3ost -f || error "unable to stop OST3"
2698 stop fs2ost -f || error "unable to stop OST2"
2699 stop fs2mds -f || error "unable to stop second MDS"
2700 unload_modules_conf || error "unable unload modules"
2703 run_test 36 "df report consistency on OSTs with different block size"
2706 local mntpt=$(facet_mntpt $SINGLEMDS)
2707 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2708 local mdsdev_sym="$TMP/sym_mdt.img"
2709 local opts=$MDS_MOUNT_OPTS
2712 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2713 skip "ldiskfs only test"
2717 echo "MDS : $mdsdev"
2718 echo "SYMLINK : $mdsdev_sym"
2719 do_facet $SINGLEMDS rm -f $mdsdev_sym
2721 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2723 echo "mount symlink device - $mdsdev_sym"
2725 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2726 opts=$(csa_add "$opts" -o loop)
2728 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2729 $mdsdev_sym $mntpt 2>&1)
2732 echo mount_op=$mount_op
2734 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2736 if $(echo $mount_op | grep -q "unable to set tunable"); then
2737 error "set tunables failed for symlink device"
2740 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2742 run_test 37 "verify set tunables works for symlink device"
2744 test_38() { # bug 14222
2745 local fstype=$(facet_fstype $SINGLEMDS)
2746 local mntpt=$(facet_mntpt $SINGLEMDS)
2751 local SRC="/etc /bin"
2752 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2753 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2754 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2755 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2756 error "copying $SRC to $DIR/$tdir"
2758 umount_client $MOUNT || error "umount_client $MOUNT failed"
2759 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2760 stop_mds || error "Unable to stop MDS"
2761 log "delete lov_objid file on MDS"
2763 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2765 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2767 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2769 # check create in mds_lov_connect
2770 start_mds || error "unable to start MDS"
2771 mount_client $MOUNT || error "mount_client $MOUNT failed"
2773 [ $V ] && log "verifying $DIR/$tdir/$f"
2774 diff -q $f $DIR/$tdir/$f || ERROR=y
2776 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2777 if [ "$ERROR" = "y" ]; then
2778 # check it's updates in sync
2779 umount_client $MOUNT
2781 mount_fstype $SIGNLEMDS
2782 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2783 unmount_fstype $SINGLEMDS
2784 error "old and new files are different after connect" || true
2786 touch $DIR/$tdir/f2 || error "f2 file create failed"
2788 # check it's updates in sync
2789 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2792 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2794 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2795 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2797 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2799 start_mds || error "unable to start MDS"
2800 mount_client $MOUNT || error "mount_client $MOUNT failed"
2802 [ $V ] && log "verifying $DIR/$tdir/$f"
2803 diff -q $f $DIR/$tdir/$f || ERROR=y
2805 touch $DIR/$tdir/f3 || error "f3 file create failed"
2806 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2807 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2809 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2810 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2811 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2813 [ "$ERROR" = "y" ] &&
2814 error "old and new files are different after sync" || true
2816 log "files compared the same"
2817 cleanup || error "cleanup failed with $?"
2819 run_test 38 "MDS recreates missing lov_objid file from OST data"
2824 cleanup || error "cleanup failed with $?"
2825 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2826 error "memory leak detected" || true
2828 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2830 test_40() { # bug 15759
2831 start_ost || error "Unable to start OST1"
2832 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2833 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2835 cleanup || error "cleanup failed with rc $?"
2837 run_test 40 "race during service thread startup"
2839 test_41a() { #bug 14134
2840 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2841 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2842 skip "Loop devices does not work with nosvc option"
2847 { skip "needs combined MGT and MDT device" && return 0; }
2849 start_mdt 1 -o nosvc -n
2850 if [ $MDSCOUNT -ge 2 ]; then
2851 for num in $(seq 2 $MDSCOUNT); do
2852 start_mdt $num || return
2855 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2856 start_mdt 1 -o nomgs,force
2857 mount_client $MOUNT || error "mount_client $MOUNT failed"
2860 echo "blah blah" > $MOUNT/$tfile
2863 umount_client $MOUNT || error "umount_client $MOUNT failed"
2864 stop ost1 -f || error "unable to stop OST1"
2865 stop_mds || error "Unable to stop MDS"
2866 stop_mds || error "Unable to stop MDS on second try"
2868 run_test 41a "mount mds with --nosvc and --nomgs"
2871 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2872 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2873 skip "Loop devices does not work with nosvc option"
2877 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2881 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2883 start_mdt 1 -o nosvc -n
2884 if [ $MDSCOUNT -ge 2 ]; then
2885 for num in $(seq 2 $MDSCOUNT); do
2886 start_mdt $num || return
2889 start_ost || error "Unable to start OST1"
2890 start_mdt 1 -o nomgs,force
2891 mount_client $MOUNT || error "mount_client $MOUNT failed"
2894 echo "blah blah" > $MOUNT/$tfile
2895 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
2897 umount_client $MOUNT || error "umount_client $MOUNT failed"
2898 stop_ost || error "Unable to stop OST1"
2899 stop_mds || error "Unable to stop MDS"
2900 stop_mds || error "Unable to stop MDS on second try"
2902 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2905 local server_version=$(lustre_version_code $SINGLEMDS)
2906 local oss_list=$(comma_list $(osts_nodes))
2908 [[ $server_version -ge $(version_code 2.6.52) ]] ||
2909 [[ $server_version -ge $(version_code 2.5.26) &&
2910 $server_version -lt $(version_code 2.5.50) ]] ||
2911 [[ $server_version -ge $(version_code 2.5.4) &&
2912 $server_version -lt $(version_code 2.5.11) ]] ||
2913 { skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"; return; }
2915 # ensure mds1 ost1 have been created even if running sub-test standalone
2918 cleanup || error "cleanup failed"
2920 # using directly mount command instead of start() function to avoid
2921 # any side effect of // with others/externals tools/features
2922 # ("zpool import", ...)
2924 # MDT concurrent start
2926 LOAD_MODULES_REMOTE=true load_modules
2927 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
2928 error "MDT concurrent start: libcfs module not loaded"
2930 local mds1dev=$(mdsdevname 1)
2931 local mds1mnt=$(facet_mntpt mds1)
2932 local mds1fstype=$(facet_fstype mds1)
2933 local mds1opts=$MDS_MOUNT_OPTS
2935 if [ $mds1fstype == ldiskfs ] &&
2936 ! do_facet mds1 test -b $mds1dev; then
2937 mds1opts=$(csa_add "$mds1opts" -o loop)
2939 if [[ $mds1fstype == zfs ]]; then
2940 import_zpool mds1 || return ${PIPESTATUS[0]}
2943 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
2944 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
2946 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
2949 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
2953 do_facet mds1 "$LCTL set_param fail_loc=0x0"
2954 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
2955 echo "1st MDT start succeed"
2956 echo "2nd MDT start failed with $rc2"
2957 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
2958 echo "1st MDT start failed with $rc"
2959 echo "2nd MDT start succeed"
2962 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
2965 if [ $MDSCOUNT -ge 2 ]; then
2966 for num in $(seq 2 $MDSCOUNT); do
2967 start_mdt $num || return
2971 # OST concurrent start
2973 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
2974 error "OST concurrent start: libcfs module not loaded"
2976 local ost1dev=$(ostdevname 1)
2977 local ost1mnt=$(facet_mntpt ost1)
2978 local ost1fstype=$(facet_fstype ost1)
2979 local ost1opts=$OST_MOUNT_OPTS
2981 if [ $ost1fstype == ldiskfs ] &&
2982 ! do_facet ost1 test -b $ost1dev; then
2983 ost1opts=$(csa_add "$ost1opts" -o loop)
2985 if [[ $ost1fstype == zfs ]]; then
2986 import_zpool ost1 || return ${PIPESTATUS[0]}
2989 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
2990 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
2992 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
2995 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
2999 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3000 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3001 echo "1st OST start succeed"
3002 echo "2nd OST start failed with $rc2"
3003 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3004 echo "1st OST start failed with $rc"
3005 echo "2nd OST start succeed"
3009 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3015 # verify everything ok
3020 error "MDT(s) start failed"
3028 error "OST(s) start failed"
3036 error "client start failed"
3043 error "client mount failed"
3047 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3049 test_42() { #bug 14693
3051 check_mount || error "client was not mounted"
3053 do_facet mgs $LCTL conf_param $FSNAME.llite.some_wrong_param=10
3054 umount_client $MOUNT ||
3055 error "unmounting client failed with invalid llite param"
3056 mount_client $MOUNT ||
3057 error "mounting client failed with invalid llite param"
3059 do_facet mgs $LCTL conf_param $FSNAME.sys.some_wrong_param=20
3060 cleanup || error "stopping $FSNAME failed with invalid sys param"
3062 check_mount || error "client was not mounted with invalid sys param"
3063 cleanup || error "stopping $FSNAME failed with invalid sys param"
3065 run_test 42 "allow client/server mount/unmount with invalid config param"
3068 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.58) ]] ||
3069 { skip "Need MDS version at least 2.5.58" && return 0; }
3070 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
3073 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
3074 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
3078 chmod ugo+x $DIR || error "chmod 0 failed"
3079 set_conf_param_and_check mds1 \
3080 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
3081 "$FSNAME.mdt.root_squash" \
3083 wait_update $HOSTNAME \
3084 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3086 error "check llite root_squash failed!"
3087 set_conf_param_and_check mds1 \
3088 "$LCTL get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
3089 "$FSNAME.mdt.nosquash_nids" \
3091 wait_update $HOSTNAME \
3092 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3094 error "check llite nosquash_nids failed!"
3097 # create set of test files
3099 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
3100 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
3101 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
3103 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
3104 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
3106 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
3107 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
3108 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
3110 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
3111 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
3112 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
3115 # check root_squash:
3116 # set root squash UID:GID to RUNAS_ID
3117 # root should be able to access only files owned by RUNAS_ID
3119 set_conf_param_and_check mds1 \
3120 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
3121 "$FSNAME.mdt.root_squash" \
3122 "$RUNAS_ID:$RUNAS_ID"
3123 wait_update $HOSTNAME \
3124 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3125 "$RUNAS_ID:$RUNAS_ID" ||
3126 error "check llite root_squash failed!"
3128 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
3129 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3130 error "$ST: root read permission is denied"
3131 echo "$ST: root read permission is granted - ok"
3134 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3135 error "$ST: root write permission is denied"
3136 echo "$ST: root write permission is granted - ok"
3138 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3139 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3140 error "$ST: root read permission is granted"
3141 echo "$ST: root read permission is denied - ok"
3144 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3145 error "$ST: root write permission is granted"
3146 echo "$ST: root write permission is denied - ok"
3148 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3149 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
3150 error "$ST: root unlink permission is granted"
3151 echo "$ST: root unlink permission is denied - ok"
3153 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
3154 error "$ST: root create permission is granted"
3155 echo "$ST: root create permission is denied - ok"
3158 # check root_squash is enforced independently
3159 # of client cache content
3161 # access file by USER1, keep access open
3162 # root should be denied access to user file
3164 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
3168 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
3169 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3170 { kill $pid; error "$ST: root read permission is granted"; }
3171 echo "$ST: root read permission is denied - ok"
3174 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3175 { kill $pid; error "$ST: root write permission is granted"; }
3176 echo "$ST: root write permission is denied - ok"
3182 # check nosquash_nids:
3183 # put client's NID into nosquash_nids list,
3184 # root should be able to access root file after that
3186 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
3187 NIDLIST="2@gni $NIDLIST 192.168.0.[2,10]@tcp"
3188 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
3189 set_conf_param_and_check mds1 \
3190 "$LCTL get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
3191 "$FSNAME-MDTall.mdt.nosquash_nids" \
3193 wait_update $HOSTNAME \
3194 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3196 error "check llite nosquash_nids failed!"
3198 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3199 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3200 error "$ST: root read permission is denied"
3201 echo "$ST: root read permission is granted - ok"
3204 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3205 error "$ST: root write permission is denied"
3206 echo "$ST: root write permission is granted - ok"
3208 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3209 rm $DIR/$tdir-rootdir/tfile-1 ||
3210 error "$ST: root unlink permission is denied"
3211 echo "$ST: root unlink permission is granted - ok"
3212 touch $DIR/$tdir-rootdir/tfile-2 ||
3213 error "$ST: root create permission is denied"
3214 echo "$ST: root create permission is granted - ok"
3215 cleanup || error "cleanup failed with $?"
3217 run_test 43a "check root_squash and nosquash_nids"
3219 test_43b() { # LU-5690
3220 [[ $(lustre_version_code mgs) -ge $(version_code 2.7.62) ]] ||
3221 { skip "Need MGS version 2.7.62+"; return; }
3223 if [[ -z "$fs2mds_DEV" ]]; then
3224 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
3225 skip_env "mixed loopback and real device not working" && return
3228 local fs2mdsdev=$(mdsdevname 1_2)
3229 local fs2mdsvdev=$(mdsvdevname 1_2)
3231 # temporarily use fs2mds as fs2mgs
3233 local fs2mgsdev=$fs2mdsdev
3234 local fs2mgsvdev=$fs2mdsvdev
3236 local fsname=test1234
3238 load_module llite/lustre
3239 local client_ip=$(host_nids_address $HOSTNAME $NETTYPE)
3240 local host=${client_ip//*./}
3241 local net=${client_ip/%$host/}
3242 local nosquash_nids=$(h2nettype $net[$host,$host,$host])
3244 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
3245 --param mdt.root_squash=$RUNAS_ID:$RUNAS_ID \
3246 --param mdt.nosquash_nids=$nosquash_nids \
3247 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
3248 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS || error "start fs2mgs failed"
3249 stop $fs2mgs -f || error "stop fs2mgs failed"
3251 run_test 43b "parse nosquash_nids with commas in expr_list"
3253 umount_client $MOUNT
3258 check_mount || error "check_mount"
3259 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
3261 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
3262 for VAL in $UUIDS; do
3263 NID=$(echo $VAL | cut -d= -f1)
3264 CLUUID=$(echo $VAL | cut -d= -f2)
3265 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
3267 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
3268 cleanup || error "cleanup failed with $?"
3270 run_test 44 "mounted client proc entry exists"
3274 check_mount || error "check_mount"
3275 stop_mds || error "Unable to stop MDS"
3279 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
3280 do_facet client "$LCTL set_param fail_loc=0x8000050f"
3283 manual_umount_client --force || error "manual_umount_client failed"
3284 do_facet client "$LCTL set_param fail_loc=0x0"
3285 start_mds || error "unable to start MDS"
3286 mount_client $MOUNT || error "mount_client $MOUNT failed"
3287 cleanup || error "cleanup failed with $?"
3289 run_test 45 "long unlink handling in ptlrpcd"
3296 umount_client $MOUNT2 || rc=$?
3297 umount_client $MOUNT || rc=$?
3298 while [ $count -gt 0 ]; do
3299 stop ost${count} -f || rc=$?
3303 cleanup_nocli || rc=$?
3304 #writeconf to remove all ost2 traces for subsequent tests
3305 writeconf_or_reformat
3310 echo "Testing with $OSTCOUNT OSTs"
3312 start_mds || error "unable to start MDS"
3313 #first client should see only one ost
3314 start_ost || error "Unable to start OST1"
3315 wait_osc_import_state mds ost FULL
3317 mount_client $MOUNT || error "mount_client $MOUNT failed"
3318 trap "cleanup_46a $OSTCOUNT" EXIT ERR
3321 for (( i=2; i<=$OSTCOUNT; i++ )); do
3322 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
3323 error "start_ost$i $(ostdevname $i) failed"
3326 # wait until osts in sync
3327 for (( i=2; i<=$OSTCOUNT; i++ )); do
3328 wait_osc_import_state mds ost$i FULL
3329 wait_osc_import_state client ost$i FULL
3332 #second client see all ost's
3334 mount_client $MOUNT2 || error "mount_client failed"
3335 $SETSTRIPE -c -1 $MOUNT2 || error "$SETSTRIPE -c -1 $MOUNT2 failed"
3336 $GETSTRIPE $MOUNT2 || error "$GETSTRIPE $MOUNT2 failed"
3338 echo "ok" > $MOUNT2/widestripe
3339 $GETSTRIPE $MOUNT2/widestripe ||
3340 error "$GETSTRIPE $MOUNT2/widestripe failed"
3341 # fill acl buffer for avoid expand lsm to them
3342 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
3344 setfacl -m $acl $MOUNT2/widestripe
3348 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3350 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
3352 run_test 46a "handle ost additional - wide striped file"
3357 check_mount || error "check_mount failed"
3358 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
3362 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3363 if echo $ns | grep "MDT[[:digit:]]*"; then
3366 lrs=$(echo $ns | sed 's/.*lru_size=//')
3367 lru_size[count]=$lrs
3372 facet_failover $SINGLEMDS
3373 client_up || error "client_up failed"
3376 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3377 if echo $ns | grep "MDT[[:digit:]]*"; then
3380 lrs=$(echo $ns | sed 's/.*lru_size=//')
3381 if ! test "$lrs" -eq "${lru_size[count]}"; then
3382 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
3383 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
3388 cleanup || error "cleanup failed with $?"
3390 run_test 47 "server restart does not make client loss lru_resize settings"
3395 # reformat after this test is needed - if the test fails,
3396 # we will have unkillable file at FS
3400 test_48() { # bz-17636 LU-7473
3404 check_mount || error "check_mount failed"
3406 $SETSTRIPE -c -1 $MOUNT || error "$SETSTRIPE -c -1 $MOUNT failed"
3407 $GETSTRIPE $MOUNT || error "$GETSTRIPE $MOUNT failed"
3409 echo "ok" > $MOUNT/widestripe
3410 $GETSTRIPE $MOUNT/widestripe ||
3411 error "$GETSTRIPE $MOUNT/widestripe failed"
3413 # In the future, we may introduce more EAs, such as selinux, enlarged
3414 # LOV EA, and so on. These EA will use some EA space that is shared by
3415 # ACL entries. So here we only check some reasonable ACL entries count,
3416 # instead of the max number that is calculated from the max_ea_size.
3417 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.57) ];
3419 count=28 # hard coded of RPC protocol
3420 elif [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3421 count=4000 # max_num 4091 max_ea_size = 32768
3422 elif ! large_xattr_enabled; then
3423 count=450 # max_num 497 max_ea_size = 4012
3425 count=4500 # max_num 8187 max_ea_size = 1048492
3426 # not create too much (>5000) to save test time
3429 echo "It is expected to hold at least $count ACL entries"
3430 trap cleanup_48 EXIT ERR
3431 for ((i = 0; i < $count; i++)) do
3432 setfacl -m u:$((i + 100)):rw $MOUNT/widestripe ||
3433 error "Fail to setfacl for $MOUNT/widestripe at $i"
3436 cancel_lru_locks mdc
3437 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3438 local r_count=$(getfacl $MOUNT/widestripe | grep "user:" | wc -l)
3439 count=$((count + 1)) # for the entry "user::rw-"
3441 [ $count -eq $r_count ] ||
3442 error "Expected ACL entries $count, but got $r_count"
3446 run_test 48 "too many acls on file"
3448 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3449 test_49a() { # bug 17710
3450 local timeout_orig=$TIMEOUT
3451 local ldlm_timeout_orig=$LDLM_TIMEOUT
3452 local LOCAL_TIMEOUT=20
3454 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3455 TIMEOUT=$LOCAL_TIMEOUT
3459 check_mount || error "client mount failed"
3461 echo "check ldlm_timout..."
3462 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3463 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3464 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3466 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3467 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3470 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3471 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3474 umount_client $MOUNT || error "umount_client $MOUNT failed"
3475 stop_ost || error "problem stopping OSS"
3476 stop_mds || error "problem stopping MDS"
3478 LDLM_TIMEOUT=$ldlm_timeout_orig
3479 TIMEOUT=$timeout_orig
3481 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3483 test_49b() { # bug 17710
3484 local timeout_orig=$TIMEOUT
3485 local ldlm_timeout_orig=$LDLM_TIMEOUT
3486 local LOCAL_TIMEOUT=20
3488 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3489 TIMEOUT=$LOCAL_TIMEOUT
3493 check_mount || error "client mount failed"
3495 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3496 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3497 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3499 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3500 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3503 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3504 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3507 cleanup || error "cleanup failed"
3509 LDLM_TIMEOUT=$ldlm_timeout_orig
3510 TIMEOUT=$timeout_orig
3512 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3515 # Test both statfs and lfs df and fail if either one fails
3516 multiop_bg_pause $1 f_
3519 killall -USR1 multiop
3520 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
3521 wait $PID || { RC1=$?; log "multiop return error "; }
3528 if [ $RC2 -eq 0 ]; then
3530 log "lazystatfs df failed"
3534 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
3540 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3541 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3543 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3545 cleanup || error "cleanup failed with rc $?"
3547 run_test 50a "lazystatfs all servers available"
3551 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3552 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3554 # Wait for client to detect down OST
3555 stop_ost || error "Unable to stop OST1"
3556 wait_osc_import_state mds ost DISCONN
3558 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
3560 umount_client $MOUNT || error "Unable to unmount client"
3561 stop_mds || error "Unable to stop MDS"
3563 run_test 50b "lazystatfs all servers down"
3566 start_mds || error "Unable to start MDS"
3567 start_ost || error "Unable to start OST1"
3568 start_ost2 || error "Unable to start OST2"
3569 mount_client $MOUNT || error "Unable to mount client"
3570 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3571 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3573 # Wait for client to detect down OST
3574 stop_ost || error "Unable to stop OST1"
3575 wait_osc_import_state mds ost DISCONN
3576 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3578 umount_client $MOUNT || error "Unable to unmount client"
3579 stop_ost2 || error "Unable to stop OST2"
3580 stop_mds || error "Unable to stop MDS"
3581 #writeconf to remove all ost2 traces for subsequent tests
3582 writeconf_or_reformat
3584 run_test 50c "lazystatfs one server down"
3587 start_mds || error "Unable to start MDS"
3588 start_ost || error "Unable to start OST1"
3589 start_ost2 || error "Unable to start OST2"
3590 mount_client $MOUNT || error "Unable to mount client"
3591 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3592 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3594 # Issue the statfs during the window where the client still
3595 # belives the OST to be available but it is in fact down.
3596 # No failure just a statfs which hangs for a timeout interval.
3597 stop_ost || error "Unable to stop OST1"
3598 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3600 umount_client $MOUNT || error "Unable to unmount client"
3601 stop_ost2 || error "Unable to stop OST2"
3602 stop_mds || error "Unable to stop MDS"
3603 #writeconf to remove all ost2 traces for subsequent tests
3604 writeconf_or_reformat
3606 run_test 50d "lazystatfs client/server conn race"
3613 start_mds || error "Unable to start MDS"
3614 #first client should see only one ost
3615 start_ost || error "Unable to start OST1"
3616 wait_osc_import_state mds ost FULL
3618 # Wait for client to detect down OST
3619 stop_ost || error "Unable to stop OST1"
3620 wait_osc_import_state mds ost DISCONN
3622 mount_client $MOUNT || error "Unable to mount client"
3623 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3625 multiop_bg_pause $MOUNT _f
3629 if [ $RC1 -ne 0 ]; then
3630 log "multiop failed $RC1"
3633 sleep $(( $TIMEOUT+1 ))
3635 [ $? -ne 0 ] && error "process isn't sleep"
3636 start_ost || error "Unable to start OST1"
3637 wait $pid || error "statfs failed"
3640 umount_client $MOUNT || error "Unable to unmount client"
3641 stop_ost || error "Unable to stop OST1"
3642 stop_mds || error "Unable to stop MDS"
3644 run_test 50e "normal statfs all servers down"
3649 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3651 start_mds || error "Unable to start mds"
3652 #first client should see only one ost
3653 start_ost || error "Unable to start OST1"
3654 wait_osc_import_state mds ost FULL
3656 start_ost2 || error "Unable to start OST2"
3657 wait_osc_import_state mds ost2 FULL
3659 # Wait for client to detect down OST
3660 stop_ost2 || error "Unable to stop OST2"
3662 wait_osc_import_state mds ost2 DISCONN
3663 mount_client $MOUNT || error "Unable to mount client"
3664 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3666 multiop_bg_pause $MOUNT _f
3670 if [ $RC1 -ne 0 ]; then
3671 log "lazystatfs multiop failed $RC1"
3674 sleep $(( $TIMEOUT+1 ))
3676 [ $? -ne 0 ] && error "process isn't sleep"
3677 start_ost2 || error "Unable to start OST2"
3678 wait $pid || error "statfs failed"
3679 stop_ost2 || error "Unable to stop OST2"
3682 umount_client $MOUNT -f || error "Unable to unmount client"
3683 stop_ost || error "Unable to stop OST1"
3684 stop_mds || error "Unable to stop MDS"
3685 #writeconf to remove all ost2 traces for subsequent tests
3686 writeconf_or_reformat
3688 run_test 50f "normal statfs one server in down"
3691 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs" && return
3693 start_ost2 || error "Unable to start OST2"
3694 wait_osc_import_state mds ost2 FULL
3695 wait_osc_import_state client ost2 FULL
3697 local PARAM="${FSNAME}-OST0001.osc.active"
3699 $SETSTRIPE -c -1 $DIR/$tfile || error "$SETSTRIPE failed"
3700 do_facet mgs $LCTL conf_param $PARAM=0 ||
3701 error "Unable to deactivate OST"
3703 umount_client $MOUNT || error "Unable to unmount client"
3704 mount_client $MOUNT || error "Unable to mount client"
3705 # This df should not cause a panic
3708 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
3709 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
3710 umount_client $MOUNT || error "Unable to unmount client"
3711 stop_ost2 || error "Unable to stop OST2"
3712 stop_ost || error "Unable to stop OST1"
3713 stop_mds || error "Unable to stop MDS"
3714 #writeconf to remove all ost2 traces for subsequent tests
3715 writeconf_or_reformat
3717 run_test 50g "deactivated OST should not cause panic"
3721 # prepare MDT/OST, make OSC inactive for OST1
3722 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs" && return
3724 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3725 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3726 error "tunefs OST1 failed"
3727 start_mds || error "Unable to start MDT"
3728 start_ost || error "Unable to start OST1"
3729 start_ost2 || error "Unable to start OST2"
3730 mount_client $MOUNT || error "client start failed"
3732 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3734 # activatate OSC for OST1
3735 local TEST="$LCTL get_param -n osc.${FSNAME}-OST0000-osc-[!M]*.active"
3736 set_conf_param_and_check client \
3737 "$TEST" "${FSNAME}-OST0000.osc.active" 1 ||
3738 error "Unable to activate OST1"
3740 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3741 $SETSTRIPE -c -1 -i 0 $DIR/$tdir/2 ||
3742 error "$SETSTRIPE $DIR/$tdir/2 failed"
3743 sleep 1 && echo "create a file after OST1 is activated"
3745 createmany -o $DIR/$tdir/2/$tfile-%d 1
3747 # check OSC import is working
3748 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3749 error "some OSC imports are still not connected"
3752 umount_client $MOUNT || error "Unable to umount client"
3753 stop_ost2 || error "Unable to stop OST2"
3754 cleanup_nocli || error "cleanup_nocli failed with $?"
3756 run_test 50h "LU-642: activate deactivated OST"
3759 # prepare MDT/OST, make OSC inactive for OST1
3760 [ "$MDSCOUNT" -lt "2" ] && skip_env "needs >= 2 MDTs" && return
3763 [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
3764 do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
3765 error "tunefs MDT2 failed"
3766 start_mds || error "Unable to start MDT"
3767 start_ost || error "Unable to start OST1"
3768 start_ost2 || error "Unable to start OST2"
3769 mount_client $MOUNT || error "client start failed"
3771 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3773 $LCTL conf_param ${FSNAME}-MDT0000.mdc.active=0 &&
3774 error "deactive MDC0 succeeds"
3775 # activate MDC for MDT2
3776 local TEST="$LCTL get_param -n mdc.${FSNAME}-MDT0001-mdc-[!M]*.active"
3777 set_conf_param_and_check client \
3778 "$TEST" "${FSNAME}-MDT0001.mdc.active" 1 ||
3779 error "Unable to activate MDT2"
3781 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
3782 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.60) ]
3784 wait_dne_interconnect
3786 $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3788 createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
3790 rm -rf $DIR/$tdir/2 || error "unlink dir failed"
3792 # deactivate MDC for MDT2
3793 local TEST="$LCTL get_param -n mdc.${FSNAME}-MDT0001-mdc-[!M]*.active"
3794 set_conf_param_and_check client \
3795 "$TEST" "${FSNAME}-MDT0001.mdc.active" 0 ||
3796 error "Unable to deactivate MDT2"
3798 wait_osp_active mds ${FSNAME}-MDT0001 1 0
3800 $LFS mkdir -i1 $DIR/$tdir/2 &&
3801 error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
3803 $LFS mkdir -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3804 error "mkdir $DIR/$tdir/striped_dir fails after deactive MDT2"
3806 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3807 [ $stripe_count -eq $((MDSCOUNT - 1)) ] ||
3808 error "wrong $stripe_count != $((MDSCOUNT -1)) for striped_dir"
3811 umount_client $MOUNT || error "Unable to umount client"
3816 run_test 50i "activate deactivated MDT"
3819 local LOCAL_TIMEOUT=20
3823 check_mount || error "check_mount failed"
3825 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3826 $SETSTRIPE -c -1 $MOUNT/$tdir ||
3827 error "$SETSTRIPE -c -1 $MOUNT/$tdir failed"
3828 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3829 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
3830 touch $MOUNT/$tdir/$tfile &
3833 start_ost2 || error "Unable to start OST1"
3835 stop_ost2 || error "Unable to stop OST1"
3836 umount_client $MOUNT -f || error “unmount $MOUNT failed”
3837 cleanup_nocli || error “stop server failed”
3838 #writeconf to remove all ost2 traces for subsequent tests
3839 writeconf_or_reformat
3841 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
3850 do_node $node mkdir -p $dest
3851 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3853 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
3854 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3855 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
3857 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
3858 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
3868 local backup2=${TMP}/backup2
3870 do_node $node mkdir -p $backup2
3871 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3873 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
3874 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3875 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
3877 do_node $node "diff -rq $backup $backup2"
3878 [ $? -eq 0 ] || { error "contents differ"; return 3; }
3880 local xattrs2=${TMP}/xattrs2
3881 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
3882 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
3884 do_node $node "diff $xattrs $xattrs2"
3885 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
3887 do_node $node "rm -rf $backup2 $xattrs2"
3888 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
3892 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3893 skip "ldiskfs only test"
3897 start_mds || error "Unable to start MDS"
3898 start_ost || error "Unable to start OST1"
3899 mount_client $MOUNT || error "Unable to mount client"
3902 local ost1mnt=$(facet_mntpt ost1)
3903 local ost1node=$(facet_active_host ost1)
3904 local ost1tmp=$TMP/conf52
3907 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
3908 touch $TMP/modified_first || error "Unable to create temporary file"
3909 local mtime=$(stat -c %Y $TMP/modified_first)
3910 do_node $ost1node "mkdir -p $ost1tmp &&
3911 touch -m -d @$mtime $ost1tmp/modified_first" ||
3912 error "Unable to create temporary file"
3915 $SETSTRIPE -c -1 -S 1M $DIR/$tdir || error "$SETSTRIPE failed"
3917 for (( i=0; i < nrfiles; i++ )); do
3918 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
3919 error "multiop failed"
3925 echo backup files to $TMP/$tdir
3926 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
3927 copy_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
3928 error "Unable to copy files"
3930 umount_client $MOUNT || error "Unable to umount client"
3931 stop_ost || error "Unable to stop ost1"
3933 echo mount ost1 as ldiskfs
3934 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
3935 if ! do_node $ost1node test -b $ost1_dev; then
3938 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
3940 error "Unable to mount ost1 as ldiskfs"
3943 echo backup objects to $ost1tmp/objects
3944 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
3945 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
3946 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
3948 error "Unable to copy objects"
3950 # move objects to lost+found
3951 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
3952 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
3954 do_node $ost1node "umount $ost1mnt" ||
3955 error "Unable to umount ost1 as ldiskfs"
3957 start_ost || error "Unable to start OST1"
3958 mount_client $MOUNT || error "Unable to mount client"
3960 local REPAIRED=$(do_node $ost1node "$LCTL get_param \
3961 -n osd-ldiskfs.$FSNAME-OST0000.oi_scrub" |
3962 awk '/^lf_repa[ri]*ed/ { print $2 }')
3963 [ $REPAIRED -gt 0 ] ||
3964 error "Some entry under /lost+found should be repaired"
3967 diff_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
3968 error "Unable to diff files"
3970 rm -rf $TMP/$tdir $TMP/file_xattrs ||
3971 error "Unable to delete temporary files"
3972 do_node $ost1node "rm -rf $ost1tmp" ||
3973 error "Unable to delete temporary files"
3974 cleanup || error "cleanup failed with $?"
3976 run_test 52 "check recovering objects from lost+found"
3978 # Checks threads_min/max/started for some service
3980 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
3981 # parameter pattern prefix like 'ost.*.ost'.
3994 local msg="Insane $modname thread counts"
3995 local ncpts=$(check_cpt_number $facet)
3999 check_mount || return 41
4001 # We need to expand $parampat, but it may match multiple parameters, so
4002 # we'll pick the first one
4003 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
4004 error "Couldn't expand ${parampat}.threads_min parameter name"
4008 # Remove the .threads_min part
4009 paramp=${paramp%.threads_min}
4011 # Check for sanity in defaults
4012 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4014 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4016 tstarted=$(do_facet $facet "$LCTL get_param \
4017 -n ${paramp}.threads_started" || echo 0)
4018 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
4020 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4022 nthrs=$(expr $tmax - $tmin)
4023 if [ $nthrs -lt $ncpts ]; then
4029 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
4030 skip_env "module parameter forced $facet thread count" &&
4031 tmin=3 && tmax=$((3 * tmax))
4033 # Check that we can change min/max
4034 do_facet $facet "$LCTL set_param \
4035 ${paramp}.threads_min=$((tmin + nthrs))"
4036 do_facet $facet "$LCTL set_param \
4037 ${paramp}.threads_max=$((tmax - nthrs))"
4038 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4040 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4042 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
4043 $tmax2 == ($tmax - $nthrs)))' || return $?
4045 # Check that we can set min/max to the same value
4046 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4048 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
4049 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4051 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4053 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
4055 # Check that we can't set max < min
4056 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
4057 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4059 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4061 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
4063 # We need to ensure that we get the module options desired; to do this
4064 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
4065 LOAD_MODULES_REMOTE=true
4068 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
4069 setmodopts -a $modname "$newvalue" oldvalue
4072 check_mount || return 41
4074 # Restore previous setting of MODOPTS_*
4075 setmodopts $modname "$oldvalue"
4077 # Check that $opts took
4078 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min")
4079 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max")
4080 tstarted=$(do_facet $facet \
4081 "$LCTL get_param -n ${paramp}.threads_started")
4082 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4091 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
4092 cleanup || error "cleanup failed with rc $?"
4094 run_test 53a "check OSS thread count params"
4098 local mds=$(do_facet $SINGLEMDS "$LCTL get_param \
4099 -N mds.*.*.threads_max 2>/dev/null")
4100 if [ -z "$mds" ]; then
4101 #running this on an old MDT
4102 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
4104 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
4106 cleanup || error "cleanup failed with $?"
4108 run_test 53b "check MDS thread count params"
4111 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4112 skip "ldiskfs only test"
4116 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
4117 error "llverdev failed with rc=$?"
4120 run_test 54a "test llverdev and partial verify of device"
4123 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4124 skip "ldiskfs only test"
4129 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
4130 cleanup || error "cleanup failed with rc=$?"
4132 run_test 54b "test llverfs and partial verify of filesystem"
4136 local max_ost_index=$1
4137 echo -n $(((max_ost_index + 1) * 8))
4141 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4142 skip "ldiskfs only test"
4146 local mdsdev=$(mdsdevname 1)
4147 local mdsvdev=$(mdsvdevname 1)
4151 if ! combined_mgs_mds; then
4152 stop_mgs || error "stopping MGS service failed"
4153 format_mgs || error "formatting MGT failed"
4155 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
4157 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
4158 --reformat $(ostdevname 1) $(ostvdevname 1)
4164 echo checking size of lov_objid for ost index $i
4165 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" |
4166 grep ^User | awk -F 'Size: ' '{print $2}')
4167 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
4168 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
4170 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
4177 run_test 55 "check lov_objid size"
4180 local server_version=$(lustre_version_code $SINGLEMDS)
4181 local mds_journal_size_orig=$MDSJOURNALSIZE
4187 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
4188 $(ostdevname 1) $(ostvdevname 1)
4189 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
4190 $(ostdevname 2) $(ostvdevname 2)
4193 start_ost || error "Unable to start first ost (idx 10000)"
4194 start_ost2 || error "Unable to start second ost (idx 1000)"
4195 mount_client $MOUNT || error "Unable to mount client"
4199 if [[ $server_version -ge $(version_code 2.6.54) ]] ||
4200 [[ $server_version -ge $(version_code 2.5.4) &&
4201 $server_version -lt $(version_code 2.5.11) ]]; then
4202 wait_osc_import_state mds ost1 FULL
4203 wait_osc_import_state mds ost2 FULL
4204 $SETSTRIPE --stripe-count=-1 $DIR/$tfile ||
4205 error "Unable to setstripe $DIR/$tfile"
4206 n=$($LFS getstripe --stripe-count $DIR/$tfile)
4207 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
4212 MDSJOURNALSIZE=$mds_journal_size_orig
4215 run_test 56a "check big OST indexes and out-of-index-order start"
4220 umount_client $MOUNT -f || error "unmount client failed"
4229 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs" && return
4231 trap cleanup_56b EXIT RETURN ERR
4234 if ! combined_mgs_mds ; then
4239 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) --index=0 --reformat \
4240 $(mdsdevname 1) $(mdsvdevname 1)
4241 add mds2 $(mkfs_opts mds2 $(mdsdevname 2)) --index=1 --reformat \
4242 $(mdsdevname 2) $(mdsvdevname 2)
4243 add mds3 $(mkfs_opts mds3 $(mdsdevname 3)) --index=1000 --reformat \
4244 $(mdsdevname 3) $(mdsvdevname 3)
4248 start_mdt 1 || error "MDT 1 (idx 0) start failed"
4249 start_mdt 2 || error "MDT 2 (idx 1) start failed"
4250 start_mdt 3 || error "MDT 3 (idx 1000) start failed"
4251 start_ost || error "Unable to start first ost"
4252 start_ost2 || error "Unable to start second ost"
4254 do_nodes $(comma_list $(mdts_nodes)) \
4255 "$LCTL set_param mdt.*.enable_remote_dir=1 \
4256 mdt.*.enable_remote_dir_gid=-1"
4258 mount_client $MOUNT || error "Unable to mount client"
4260 $LFS mkdir -c3 $MOUNT/$tdir || error "failed to make testdir"
4262 echo "This is test file 1!" > $MOUNT/$tdir/$tfile.1 ||
4263 error "failed to make test file 1"
4264 echo "This is test file 2!" > $MOUNT/$tdir/$tfile.2 ||
4265 error "failed to make test file 2"
4266 echo "This is test file 1000!" > $MOUNT/$tdir/$tfile.1000 ||
4267 error "failed to make test file 1000"
4269 rm -rf $MOUNT/$tdir || error "failed to remove testdir"
4271 $LFS mkdir -i1000 $MOUNT/$tdir.1000 ||
4272 error "create remote dir at idx 1000 failed"
4275 echo "=== START lfs df OUTPUT ==="
4277 echo "==== END lfs df OUTPUT ===="
4279 mdtcnt=$(echo -e "$output" | grep $FSNAME-MDT | wc -l)
4280 ostcnt=$(echo -e "$output" | grep $FSNAME-OST | wc -l)
4282 echo "lfs df returned mdt count $mdtcnt and ost count $ostcnt"
4283 [ $mdtcnt -eq 3 ] || error "lfs df returned wrong mdt count"
4284 [ $ostcnt -eq 2 ] || error "lfs df returned wrong ost count"
4286 echo "This is test file 1!" > $MOUNT/$tdir.1000/$tfile.1 ||
4287 error "failed to make test file 1"
4288 echo "This is test file 2!" > $MOUNT/$tdir.1000/$tfile.2 ||
4289 error "failed to make test file 2"
4290 echo "This is test file 1000!" > $MOUNT/$tdir.1000/$tfile.1000 ||
4291 error "failed to make test file 1000"
4292 rm -rf $MOUNT/$tdir.1000 || error "failed to remove remote_dir"
4295 echo "=== START lfs mdts OUTPUT ==="
4297 echo "==== END lfs mdts OUTPUT ===="
4299 echo -e "$output" | grep -v "MDTS:" | awk '{print $1}' |
4300 sed 's/://g' > $TMP/mdts-actual.txt
4301 sort $TMP/mdts-actual.txt -o $TMP/mdts-actual.txt
4303 echo -e "0\n1\n1000" > $TMP/mdts-expected.txt
4305 diff $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4308 rm $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4310 [ $result -eq 0 ] || error "target_obd proc file is incorrect!"
4312 run_test 56b "test target_obd correctness with nonconsecutive MDTs"
4314 test_57a() { # bug 22656
4315 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4316 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4317 tail -1 | awk '{print $1}')
4318 writeconf_or_reformat
4319 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4320 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
4321 error "tunefs failed"
4323 start_ost && error "OST registration from failnode should fail"
4326 run_test 57a "initial registration from failnode should fail (should return errs)"
4329 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4330 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4331 tail -1 | awk '{print $1}')
4332 writeconf_or_reformat
4333 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4334 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
4335 error "tunefs failed"
4337 start_ost || error "OST registration from servicenode should not fail"
4340 run_test 57b "initial registration from servicenode should not fail"
4343 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
4346 test_58() { # bug 22658
4347 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
4349 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4350 createmany -o $DIR/$tdir/$tfile-%d 100
4351 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
4352 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
4353 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x601"
4354 unlinkmany $DIR/$tdir/$tfile-%d 100
4355 stop_mds || error "Unable to stop MDS"
4357 local MNTDIR=$(facet_mntpt $SINGLEMDS)
4358 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4360 # remove all files from the OBJECTS dir
4361 mount_fstype $SINGLEMDS
4363 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
4365 unmount_fstype $SINGLEMDS
4366 # restart MDS with missing llog files
4367 start_mds || error "unable to start MDS"
4368 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
4371 run_test 58 "missing llog files must not prevent MDT from mounting"
4374 start_mgsmds >> /dev/null
4375 local C1=$(count_osts)
4376 if [ $C1 -eq 0 ]; then
4377 start_ost >> /dev/null
4381 echo "original ost count: $C1 (expect > 0)"
4382 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
4383 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
4384 local C2=$(count_osts)
4385 echo "after mdt writeconf count: $C2 (expect 0)"
4386 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
4387 echo "OST start without writeconf should fail:"
4388 start_ost >> /dev/null &&
4389 error "OST start without writeconf didn't fail"
4390 echo "OST start with writeconf should succeed:"
4391 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
4392 local C3=$(count_osts)
4393 echo "after ost writeconf count: $C3 (expect 1)"
4394 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
4395 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
4396 local C4=$(count_osts)
4397 echo "after ost2 writeconf count: $C4 (expect 2)"
4398 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
4399 stop_ost2 >> /dev/null
4400 cleanup_nocli >> /dev/null
4401 #writeconf to remove all ost2 traces for subsequent tests
4402 writeconf_or_reformat
4404 run_test 59 "writeconf mount option"
4406 test_60() { # LU-471
4409 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4410 skip "ldiskfs only test"
4414 for num in $(seq $MDSCOUNT); do
4415 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
4416 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
4417 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4421 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
4422 [ ${PIPESTATUS[0]} -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
4424 # MDT default has dirdata feature
4425 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
4426 # we disable uninit_bg feature
4427 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
4428 # we set stride extended options
4429 echo $dump | grep stride > /dev/null || error "stride is not set"
4432 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
4437 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
4438 { skip "Need MDS version at least 2.1.53"; return 0; }
4440 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
4441 ! large_xattr_enabled; then
4444 for num in $(seq $MDSCOUNT); do
4445 do_facet mds${num} $TUNE2FS -O large_xattr \
4446 $(mdsdevname $num) ||
4447 error "tune2fs on mds $num failed"
4451 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
4452 setup_noconfig || error "setting up the filesystem failed"
4453 client_up || error "starting client failed"
4455 local file=$DIR/$tfile
4456 touch $file || error "touch $file failed"
4458 local large_value="$(generate_string $(max_xattr_size))"
4459 local small_value="bar"
4461 local name="trusted.big"
4462 log "save large xattr $name on $file"
4463 setfattr -n $name -v $large_value $file ||
4464 error "saving $name on $file failed"
4466 local new_value=$(get_xattr_value $name $file)
4467 [[ "$new_value" != "$large_value" ]] &&
4468 error "$name different after saving"
4470 log "shrink value of $name on $file"
4471 setfattr -n $name -v $small_value $file ||
4472 error "shrinking value of $name on $file failed"
4474 new_value=$(get_xattr_value $name $file)
4475 [[ "$new_value" != "$small_value" ]] &&
4476 error "$name different after shrinking"
4478 log "grow value of $name on $file"
4479 setfattr -n $name -v $large_value $file ||
4480 error "growing value of $name on $file failed"
4482 new_value=$(get_xattr_value $name $file)
4483 [[ "$new_value" != "$large_value" ]] &&
4484 error "$name different after growing"
4486 log "check value of $name on $file after remounting MDS"
4488 new_value=$(get_xattr_value $name $file)
4489 [[ "$new_value" != "$large_value" ]] &&
4490 error "$name different after remounting MDS"
4492 log "remove large xattr $name from $file"
4493 setfattr -x $name $file || error "removing $name from $file failed"
4496 stopall || error "stopping for e2fsck run"
4497 for num in $(seq $MDSCOUNT); do
4498 run_e2fsck $(facet_active_host mds$num) \
4499 $(mdsdevname $num) "-y" ||
4500 error "e2fsck MDT$num failed"
4502 setup_noconfig || error "remounting the filesystem failed"
4505 # need to delete this file to avoid problems in other tests
4507 stopall || error "stopping systems to turn off large_xattr"
4509 for num in $(seq $MDSCOUNT); do
4510 do_facet mds${num} $TUNE2FS -O ^large_xattr \
4511 $(mdsdevname $num) ||
4512 error "tune2fs on mds $num failed"
4516 run_test 61 "large xattr"
4519 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4520 skip "ldiskfs only test"
4525 local mdsdev=$(mdsdevname 1)
4526 local ostdev=$(ostdevname 1)
4528 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
4529 { skip "Need MDS version at least 2.2.51"; return 0; }
4531 echo "disable journal for mds"
4532 do_facet mds1 $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
4533 start_mds && error "MDT start should fail"
4534 echo "disable journal for ost"
4535 do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
4536 start_ost && error "OST start should fail"
4537 cleanup || error "cleanup failed with rc $?"
4540 run_test 62 "start with disabled journal"
4543 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4544 skip "ldiskfs only test"
4548 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ldiskfs
4549 local inode_slab=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4550 awk '/ldiskfs_inode_cache/ { print $5 / $6 }')
4551 if [ -z "$inode_slab" ]; then
4552 skip "ldiskfs module has not been loaded"
4556 echo "$inode_slab ldiskfs inodes per page"
4557 [ "${inode_slab%.*}" -ge "3" ] && return 0
4559 # If kmalloc-128 is also 1 per page - this is a debug kernel
4560 # and so this is not an error.
4561 local kmalloc128=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4562 awk '/^(kmalloc|size)-128 / { print $5 / $6 }')
4563 # 32 128-byte chunks in 4k
4564 [ "${kmalloc128%.*}" -lt "32" ] ||
4565 error "ldiskfs inode too big, only $inode_slab objs/page, " \
4566 "kmalloc128 = $kmalloc128 objs/page"
4568 run_test 63 "Verify each page can at least hold 3 ldiskfs inodes"
4571 start_mds || error "unable to start MDS"
4572 start_ost || error "Unable to start OST1"
4573 start_ost2 || error "Unable to start second ost"
4574 mount_client $MOUNT || error "Unable to mount client"
4575 stop_ost2 || error "Unable to stop second ost"
4578 umount_client $MOUNT -f || error “unmount $MOUNT failed”
4579 cleanup_nocli || error "cleanup_nocli failed with $?"
4580 #writeconf to remove all ost2 traces for subsequent tests
4581 writeconf_or_reformat
4583 run_test 64 "check lfs df --lazy "
4585 test_65() { # LU-2237
4586 # Currently, the test is only valid for ldiskfs backend
4587 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
4588 skip "ldiskfs only test" && return
4590 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4591 local brpt=$(facet_mntpt brpt)
4594 if ! do_facet $SINGLEMDS "test -b $devname"; then
4598 stop_mds || error "Unable to stop MDS"
4599 local obj=$(do_facet $SINGLEMDS \
4600 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
4602 if [ -z "$obj" ]; then
4603 # The MDT may be just re-formatted, mount the MDT for the
4604 # first time to guarantee the "last_rcvd" file is there.
4605 start_mds || error "fail to mount the MDS for the first time"
4606 stop_mds || error "Unable to stop MDS"
4609 # remove the "last_rcvd" file
4610 do_facet $SINGLEMDS "mkdir -p $brpt"
4611 do_facet $SINGLEMDS \
4612 "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
4613 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
4614 do_facet $SINGLEMDS "$UMOUNT $brpt"
4616 # restart MDS, the "last_rcvd" file should be recreated.
4617 start_mds || error "fail to restart the MDS"
4618 stop_mds || error "Unable to stop MDS"
4619 obj=$(do_facet $SINGLEMDS \
4620 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
4621 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
4623 run_test 65 "re-create the lost last_rcvd file when server mount"
4626 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
4627 { skip "Need MGS version at least 2.3.59"; return 0; }
4630 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
4631 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
4633 echo "replace_nids should fail if MDS, OSTs and clients are UP"
4634 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4635 error "replace_nids fail"
4637 umount_client $MOUNT || error "unmounting client failed"
4638 echo "replace_nids should fail if MDS and OSTs are UP"
4639 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4640 error "replace_nids fail"
4642 stop_ost || error "Unable to stop OST1"
4643 echo "replace_nids should fail if MDS is UP"
4644 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4645 error "replace_nids fail"
4647 stop_mds || error "stopping mds failed"
4649 if combined_mgs_mds; then
4650 start_mdt 1 "-o nosvc" ||
4651 error "starting mds with nosvc option failed"
4654 echo "command should accept two parameters"
4655 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
4656 error "command should accept two params"
4658 echo "correct device name should be passed"
4659 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
4660 error "wrong devname"
4662 echo "wrong nids list should not destroy the system"
4663 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
4666 echo "replace OST nid"
4667 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
4668 error "replace nids failed"
4670 echo "command should accept two parameters"
4671 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
4672 error "command should accept two params"
4674 echo "wrong nids list should not destroy the system"
4675 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
4678 echo "replace MDS nid"
4679 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
4680 error "replace nids failed"
4682 if ! combined_mgs_mds ; then
4685 stop_mds || error "Unable to stop MDS"
4689 check_mount || error "error after nid replace"
4690 cleanup || error "cleanup failed"
4693 run_test 66 "replace nids"
4695 test_67() { #LU-2950
4696 local legacy="$TMP/legacy_lnet_config"
4697 local new="$TMP/new_routes_test"
4698 local out="$TMP/config_out_file"
4699 local verify="$TMP/conv_verify"
4700 local verify_conf="$TMP/conf_verify"
4702 # Create the legacy file that will be run through the
4703 # lustre_routes_conversion script
4704 cat <<- LEGACY_LNET_CONFIG > $legacy
4705 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
4706 tcp2 54 10.1.3.2@tcp;
4707 tcp3 10.3.4.3@tcp:3;
4711 # Create the verification file to verify the output of
4712 # lustre_routes_conversion script against.
4713 cat <<- VERIFY_LNET_CONFIG > $verify
4714 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
4715 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
4716 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
4717 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
4718 tcp4: { gateway: 10.3.3.4@tcp }
4721 # Create the verification file to verify the output of
4722 # lustre_routes_config script against
4723 cat <<- VERIFY_LNET_CONFIG > $verify_conf
4724 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
4725 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
4726 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
4727 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
4728 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
4731 lustre_routes_conversion $legacy $new > /dev/null
4732 if [ -f $new ]; then
4733 # verify the conversion output
4734 cmp -s $new $verify > /dev/null
4735 if [ $? -eq 1 ]; then
4736 error "routes conversion failed"
4739 lustre_routes_config --dry-run --verbose $new > $out
4740 # check that the script succeeded
4741 cmp -s $out $verify_conf > /dev/null
4742 if [ $? -eq 1 ]; then
4743 error "routes config failed"
4746 error "routes conversion test failed"
4748 # remove generated files
4749 rm -f $new $legacy $verify $verify_conf $out
4751 run_test 67 "test routes conversion and configuration"
4759 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.53) ] ||
4760 { skip "Need MDS version at least 2.4.53"; return 0; }
4762 umount_client $MOUNT || error "umount client failed"
4764 if ! combined_mgs_mds; then
4765 start_mgs || error "start mgs failed"
4768 start_mdt 1 || error "MDT start failed"
4769 start_ost || error "Unable to start OST1"
4771 # START-END - the sequences we'll be reserving
4772 START=$(do_facet $SINGLEMDS \
4773 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4774 END=$((START + (1 << 30)))
4775 do_facet $SINGLEMDS \
4776 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4778 # reset the sequences MDT0000 has already assigned
4779 do_facet $SINGLEMDS \
4780 $LCTL set_param seq.srv*MDT0000.space=clear
4782 # remount to let the client allocate new sequence
4783 mount_client $MOUNT || error "mount client failed"
4785 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4786 do_facet $SINGLEMDS \
4787 $LCTL get_param seq.srv*MDT0000.space
4788 $LFS path2fid $DIR/$tfile
4790 local old_ifs="$IFS"
4792 fid=($($LFS path2fid $DIR/$tfile))
4796 if [[ $seq < $END ]]; then
4797 error "used reserved sequence $seq?"
4799 cleanup || error "cleanup failed with $?"
4801 run_test 68 "be able to reserve specific sequences in FLDB"
4803 # Test 69: is about the total number of objects ever created on an OST.
4804 # so that when it is reformatted the normal MDS->OST orphan recovery won't
4805 # just "precreate" the missing objects. In the past it might try to recreate
4806 # millions of objects after an OST was reformatted
4808 local server_version=$(lustre_version_code $SINGLEMDS)
4810 [[ $server_version -lt $(version_code 2.4.2) ]] &&
4811 skip "Need MDS version at least 2.4.2" && return
4813 [[ $server_version -ge $(version_code 2.4.50) ]] &&
4814 [[ $server_version -lt $(version_code 2.5.0) ]] &&
4815 skip "Need MDS version at least 2.5.0" && return
4818 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4820 # use OST0000 since it probably has the most creations
4821 local OSTNAME=$(ostname_from_index 0)
4822 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4823 local last_id=$(do_facet mds1 $LCTL get_param -n \
4824 osc.$mdtosc_proc1.prealloc_last_id)
4826 # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
4827 # verify that the LAST_ID recovery is working properly. If
4828 # not, then the OST will refuse to allow the MDS connect
4829 # because the LAST_ID value is too different from the MDS
4830 #define OST_MAX_PRECREATE=20000
4831 local ost_max_pre=20000
4832 local num_create=$(( ost_max_pre * 5 + 1 - last_id))
4834 # If the LAST_ID is already over 5 * OST_MAX_PRECREATE, we don't
4835 # need to create any files. So, skip this section.
4836 if [ $num_create -gt 0 ]; then
4837 # Check the number of inodes available on OST0
4839 local ifree=$($LFS df -i $MOUNT | awk '/OST0000/ { print $4 }')
4840 log "On OST0, $ifree inodes available. Want $num_create."
4842 $SETSTRIPE -i 0 $DIR/$tdir ||
4843 error "$SETSTRIPE -i 0 $DIR/$tdir failed"
4844 if [ $ifree -lt 10000 ]; then
4845 files=$(( ifree - 50 ))
4850 local j=$((num_create / files + 1))
4851 for i in $(seq 1 $j); do
4852 createmany -o $DIR/$tdir/$tfile-$i- $files ||
4853 error "createmany fail create $files files: $?"
4854 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
4855 error "unlinkmany failed unlink $files files"
4859 # delete all of the files with objects on OST0 so the
4860 # filesystem is not inconsistent later on
4861 $LFS find $MOUNT --ost 0 -print0 | xargs -0 rm
4863 umount_client $MOUNT || error "umount client failed"
4864 stop_ost || error "OST0 stop failure"
4865 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
4866 $(ostdevname 1) $(ostvdevname 1) ||
4867 error "reformat and replace $ostdev failed"
4868 start_ost || error "OST0 restart failure"
4869 wait_osc_import_state mds ost FULL
4871 mount_client $MOUNT || error "mount client failed"
4872 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
4873 local idx=$($GETSTRIPE -i $DIR/$tdir/$tfile-last)
4874 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
4876 local iused=$($LFS df -i $MOUNT | awk '/OST0000/ { print $3 }')
4877 log "On OST0, $iused used inodes"
4878 [ $iused -ge $((ost_max_pre/2 + 1000)) ] &&
4879 error "OST replacement created too many inodes; $iused"
4880 cleanup || error "cleanup failed with $?"
4882 run_test 69 "replace an OST with the same index"
4885 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4888 cleanup || error "cleanup failed with $?"
4890 start_mdt 1 || error "MDT0 start fail"
4892 start_ost || error "OST0 start fail"
4893 for num in $(seq 2 $MDSCOUNT); do
4894 start_mdt $num || return
4897 mount_client $MOUNT || error "mount client fails"
4899 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
4901 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4902 error "create remote dir fail"
4904 rm -rf $DIR/$tdir || error "delete dir fail"
4905 cleanup || error "cleanup failed with $?"
4907 run_test 70a "start MDT0, then OST, then MDT1"
4910 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4913 start_ost || error "OST0 start fail"
4915 start_mds || error "MDS start fail"
4917 mount_client $MOUNT || error "mount client fails"
4919 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
4921 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4922 error "create remote dir fail"
4924 rm -rf $DIR/$tdir || error "delete dir fail"
4926 cleanup || error "cleanup failed with $?"
4928 run_test 70b "start OST, MDT1, MDT0"
4931 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4934 start_mds || error "MDS start fail"
4935 start_ost || error "OST0 start fail"
4937 mount_client $MOUNT || error "mount client fails"
4938 stop_mdt 1 || error "MDT1 start fail"
4940 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
4941 echo "deactivate $mdc_for_mdt1"
4942 $LCTL --device $mdc_for_mdt1 deactivate ||
4943 error "set $mdc_for_mdt1 deactivate failed"
4945 mkdir $DIR/$tdir && error "mkdir succeed"
4947 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4948 error "create remote dir succeed"
4950 cleanup || error "cleanup failed with $?"
4952 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
4955 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4958 start_mds || error "MDS start fail"
4959 start_ost || error "OST0 start fail"
4961 mount_client $MOUNT || error "mount client fails"
4963 stop_mdt 2 || error "MDT1 start fail"
4965 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
4967 echo "deactivate $mdc_for_mdt2"
4968 $LCTL --device $mdc_for_mdt2 deactivate ||
4969 error "set $mdc_for_mdt2 deactivate failed"
4971 mkdir $DIR/$tdir || error "mkdir fail"
4972 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4973 error "create remote dir succeed"
4975 rm -rf $DIR/$tdir || error "delete dir fail"
4977 cleanup || error "cleanup failed with $?"
4979 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
4982 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4984 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.62) ] ||
4985 { skip "Need MDS version at least 2.7.62"; return 0; }
4987 cleanup || error "cleanup failed with $?"
4989 local mdsdev=$(mdsdevname 1)
4990 local ostdev=$(ostdevname 1)
4991 local mdsvdev=$(mdsvdevname 1)
4992 local ostvdev=$(ostvdevname 1)
4993 local opts_mds="$(mkfs_opts mds1 $mdsdev) --reformat $mdsdev $mdsvdev"
4994 local opts_ost="$(mkfs_opts ost1 $ostdev) --reformat $ostdev $ostvdev"
4996 add mds1 $opts_mds || error "add mds1 failed"
4997 start_mdt 1 || error "start mdt1 failed"
4998 add ost1 $opts_ost || error "add ost1 failed"
4999 start_ost || error "start ost failed"
5000 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
5002 local soc=$(do_facet mds1 "$LCTL get_param -n \
5003 mdt.*MDT0000.sync_lock_cancel")
5004 [ $soc == "never" ] || error "SoC enabled on single MDS"
5006 for i in $(seq 2 $MDSCOUNT); do
5007 mdsdev=$(mdsdevname $i)
5008 mdsvdev=$(mdsvdevname $i)
5009 opts_mds="$(mkfs_opts mds$i $mdsdev) --reformat $mdsdev \
5011 add mds$i $opts_mds || error "add mds$i failed"
5012 start_mdt $i || error "start mdt$i fail"
5015 wait_dne_interconnect
5017 for i in $(seq $MDSCOUNT); do
5018 soc=$(do_facet mds$i "$LCTL get_param -n \
5019 mdt.*MDT000$((i - 1)).sync_lock_cancel")
5020 [ $soc == "blocking" ] || error "SoC not enabled on DNE"
5023 for i in $(seq 2 $MDSCOUNT); do
5024 stop_mdt $i || error "stop mdt$i fail"
5026 soc=$(do_facet mds1 "$LCTL get_param -n \
5027 mdt.*MDT0000.sync_lock_cancel")
5028 [ $soc == "never" ] || error "SoC enabled on single MDS"
5030 cleanup || error "cleanup failed with $?"
5032 run_test 70e "Sync-on-Cancel will be enabled by default on DNE"
5035 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5036 if combined_mgs_mds; then
5037 skip "needs separate MGS/MDT" && return
5041 start_mdt 1 || error "MDT0 start fail"
5042 start_ost || error "OST0 start fail"
5043 for num in $(seq 2 $MDSCOUNT); do
5044 start_mdt $num || return
5047 start_ost2 || error "OST1 start fail"
5049 mount_client $MOUNT || error "mount client fails"
5051 mkdir $DIR/$tdir || error "mkdir fail"
5052 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5053 error "create remote dir succeed"
5055 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5056 rm -rf $DIR/$tdir || error "delete dir fail"
5058 umount_client $MOUNT || error "umount_client failed"
5059 stop_mds || error "MDS stop fail"
5060 stop_ost || error "OST0 stop fail"
5061 stop_ost2 || error "OST1 stop fail"
5063 run_test 71a "start MDT0 OST0, MDT1, OST1"
5066 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5067 if combined_mgs_mds; then
5068 skip "needs separate MGS/MDT" && return
5072 for num in $(seq 2 $MDSCOUNT); do
5073 start_mdt $num || return
5075 start_ost || error "OST0 start fail"
5076 start_mdt 1 || error "MDT0 start fail"
5077 start_ost2 || error "OST1 start fail"
5079 mount_client $MOUNT || error "mount client fails"
5081 mkdir $DIR/$tdir || error "mkdir fail"
5082 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5083 error "create remote dir succeed"
5085 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5086 rm -rf $DIR/$tdir || error "delete dir fail"
5088 umount_client $MOUNT || error "umount_client failed"
5089 stop_mds || error "MDT0 stop fail"
5090 stop_ost || error "OST0 stop fail"
5091 stop_ost2 || error "OST1 stop fail"
5093 run_test 71b "start MDT1, OST0, MDT0, OST1"
5096 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5097 if combined_mgs_mds; then
5098 skip "needs separate MGS/MDT" && return
5102 start_ost || error "OST0 start fail"
5103 start_ost2 || error "OST1 start fail"
5104 for num in $(seq 2 $MDSCOUNT); do
5105 start_mdt $num || return
5107 start_mdt 1 || error "MDT0 start fail"
5109 mount_client $MOUNT || error "mount client fails"
5111 mkdir $DIR/$tdir || error "mkdir fail"
5112 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5113 error "create remote dir succeed"
5115 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5116 rm -rf $DIR/$tdir || error "delete dir fail"
5118 umount_client $MOUNT || error "umount_client failed"
5119 stop_mds || error "MDS stop fail"
5120 stop_ost || error "OST0 stop fail"
5121 stop_ost2 || error "OST1 stop fail"
5124 run_test 71c "start OST0, OST1, MDT1, MDT0"
5127 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5128 if combined_mgs_mds; then
5129 skip "needs separate MGS/MDT" && return
5133 start_ost || error "OST0 start fail"
5134 for num in $(seq 2 $MDSCOUNT); do
5135 start_mdt $num || return
5137 start_mdt 1 || error "MDT0 start fail"
5138 start_ost2 || error "OST1 start fail"
5140 mount_client $MOUNT || error "mount client fails"
5142 mkdir $DIR/$tdir || error "mkdir fail"
5143 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5144 error "create remote dir succeed"
5146 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5147 rm -rf $DIR/$tdir || error "delete dir fail"
5149 umount_client $MOUNT || error "umount_client failed"
5150 stop_mds || error "MDS stop fail"
5151 stop_ost || error "OST0 stop fail"
5152 stop_ost2 || error "OST1 stop fail"
5155 run_test 71d "start OST0, MDT1, MDT0, OST1"
5158 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5159 if combined_mgs_mds; then
5160 skip "needs separate MGS/MDT" && return
5164 start_ost || error "OST0 start fail"
5165 for num in $(seq 2 $MDSCOUNT); do
5166 start_mdt $num || return
5168 start_ost2 || error "OST1 start fail"
5169 start_mdt 1 || error "MDT0 start fail"
5171 mount_client $MOUNT || error "mount client fails"
5173 mkdir $DIR/$tdir || error "mkdir fail"
5174 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5175 error "create remote dir succeed"
5177 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5178 rm -rf $DIR/$tdir || error "delete dir fail"
5180 umount_client $MOUNT || error "umount_client failed"
5181 stop_mds || error "MDS stop fail"
5182 stop_ost || error "OST0 stop fail"
5183 stop_ost2 || error "OST1 stop fail"
5186 run_test 71e "start OST0, MDT1, OST1, MDT0"
5188 test_72() { #LU-2634
5189 local mdsdev=$(mdsdevname 1)
5190 local ostdev=$(ostdevname 1)
5191 local cmd="$E2FSCK -fnvd $mdsdev"
5195 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
5196 skip "ldiskfs only test" && return
5198 if combined_mgs_mds; then
5199 add_options='--reformat'
5201 add_options='--reformat --replace'
5204 #tune MDT with "-O extents"
5206 for num in $(seq $MDSCOUNT); do
5207 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
5208 $add_options $(mdsdevname $num) $(mdsvdevname $num) ||
5209 error "add mds $num failed"
5210 do_facet mds${num} "$TUNE2FS -O extents $(mdsdevname $num)" ||
5211 error "$TUNE2FS failed on mds${num}"
5214 add ost1 $(mkfs_opts ost1 $ostdev) $add_options $ostdev ||
5215 error "add $ostdev failed"
5216 start_mds || error "start mds failed"
5217 start_ost || error "start ost failed"
5218 mount_client $MOUNT || error "mount client failed"
5220 #create some short symlinks
5221 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5222 createmany -o $DIR/$tdir/$tfile-%d $fn
5223 echo "create $fn short symlinks"
5224 for i in $(seq -w 1 $fn); do
5225 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
5230 umount_client $MOUNT || error "umount client failed"
5231 stop_mds || error "stop mds failed"
5232 stop_ost || error "stop ost failed"
5235 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
5237 run_test 72 "test fast symlink with extents flag enabled"
5239 test_73() { #LU-3006
5240 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
5241 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
5242 error "1st tunefs failed"
5243 start_mgsmds || error "start mds failed"
5244 start_ost || error "start ost failed"
5245 mount_client $MOUNT || error "mount client failed"
5246 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
5247 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
5248 umount_client $MOUNT || error "umount client failed"
5252 run_test 73 "failnode to update from mountdata properly"
5254 test_75() { # LU-2374
5255 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
5256 skip "Need MDS version at least 2.4.1" && return
5259 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
5260 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
5261 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
5262 --reformat $(ostdevname 1) $(ostvdevname 1)"
5264 #check with default parameters
5265 add mds1 $opts_mds || error "add mds1 failed for default params"
5266 add ost1 $opts_ost || error "add ost1 failed for default params"
5268 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
5269 opts_mds=$(echo $opts_mds |
5270 sed -e "s/--index=$index/--index=$index --mdt/")
5271 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
5272 opts_ost=$(echo $opts_ost |
5273 sed -e "s/--index=$index/--index=$index --ost/")
5275 add mds1 $opts_mds || error "add mds1 failed for new params"
5276 add ost1 $opts_ost || error "add ost1 failed for new params"
5277 if ! combined_mgs_mds; then
5278 stop_mgs || error "stop mgs failed"
5283 run_test 75 "The order of --index should be irrelevant"
5286 [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] ||
5287 { skip "Need MDS version at least 2.4.52" && return 0; }
5289 if ! combined_mgs_mds; then
5290 start_mgs || error "start mgs failed"
5293 local MDMB_PARAM="osc.*.max_dirty_mb"
5294 echo "Change MGS params"
5295 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
5297 echo "max_dirty_mb: $MAX_DIRTY_MB"
5298 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB + MAX_DIRTY_MB))
5299 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
5300 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
5301 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5302 head -1" $NEW_MAX_DIRTY_MB
5303 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5304 echo "$MAX_DIRTY_MB"
5305 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5306 error "error while apply max_dirty_mb"
5308 echo "Check the value is stored after remount"
5311 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5312 head -1" $NEW_MAX_DIRTY_MB
5313 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5314 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5315 error "max_dirty_mb is not saved after remount"
5317 echo "Change OST params"
5318 CLIENT_PARAM="obdfilter.*.client_cache_count"
5319 local CLIENT_CACHE_COUNT
5320 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5322 echo "client_cache_count: $CLIENT_CACHE_COUNT"
5323 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
5324 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
5325 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
5326 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5327 head -1" $NEW_CLIENT_CACHE_COUNT
5328 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5330 echo "$CLIENT_CACHE_COUNT"
5331 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5332 error "error while apply client_cache_count"
5334 echo "Check the value is stored after remount"
5337 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5338 head -1" $NEW_CLIENT_CACHE_COUNT
5339 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5341 echo "$CLIENT_CACHE_COUNT"
5342 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5343 error "client_cache_count is not saved after remount"
5346 run_test 76a "set permanent params set_param -P"
5348 test_76b() { # LU-4783
5349 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.57) ]] ||
5350 { skip "Need MGS version at least 2.5.57" && return 0; }
5353 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
5354 error "start params log failed"
5357 run_test 76b "verify params log setup correctly"
5360 [[ $(lustre_version_code mgs) -ge $(version_code 2.8.54) ]] ||
5361 { skip "Need MDS version at least 2.4.52" && return 0; }
5363 local MASK_PARAM="mdd.*.changelog_mask"
5364 echo "Change changelog_mask"
5365 do_facet mgs $LCTL set_param -P $MASK_PARAM=-CLOSE ||
5366 error "Can't change changlog_mask"
5367 wait_update $(facet_host mds) "$LCTL get_param -n $MASK_PARAM |
5370 echo "Check the value is stored after mds remount"
5371 stop_mds || error "Failed to stop MDS"
5372 start_mds || error "Failed to start MDS"
5373 local CHANGELOG_MASK=$(do_facet mgs $LCTL get_param -n $MASK_PARAM)
5374 echo $CHANGELOG_MASK | grep CLOSE > /dev/null &&
5375 error "changelog_mask is not changed"
5379 run_test 76c "verify changelog_mask is applied with set_param -P"
5381 test_76d() { #LU-9399
5384 local xattr_cache="llite.*.xattr_cache"
5385 local cmd="$LCTL get_param -n $xattr_cache | head -1"
5386 local new=$((($(eval $cmd) + 1) % 2))
5388 echo "lctl set_param -P llite.*.xattr_cache=$new"
5389 do_facet mgs $LCTL set_param -P $xattr_cache=$new ||
5390 error "Can't change xattr_cache"
5391 wait_update $HOSTNAME "$cmd" "$new"
5393 echo "Check $xattr_cache on client $MOUNT"
5394 umount_client $MOUNT || error "umount $MOUNT failed"
5395 mount_client $MOUNT || error "mount $MOUNT failed"
5396 [ $(eval $cmd) -eq $new ] ||
5397 error "$xattr_cache != $new on client $MOUNT"
5399 echo "Check $xattr_cache on the new client $MOUNT2"
5400 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
5401 [ $(eval $cmd) -eq $new ] ||
5402 error "$xattr_cache != $new on client $MOUNT2"
5403 umount_client $MOUNT2 || error "umount $MOUNT2 failed"
5407 run_test 76d "verify llite.*.xattr_cache can be set by 'set_param -P' correctly"
5409 test_77() { # LU-3445
5410 local server_version=$(lustre_version_code $SINGLEMDS)
5411 [[ $server_version -ge $(version_code 2.8.55) ]] ||
5412 { skip "Need MDS version 2.8.55+ "; return; }
5414 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
5415 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
5416 skip_env "mixed loopback and real device not working" && return
5419 local fs2mdsdev=$(mdsdevname 1_2)
5420 local fs2ostdev=$(ostdevname 1_2)
5421 local fs2mdsvdev=$(mdsvdevname 1_2)
5422 local fs2ostvdev=$(ostvdevname 1_2)
5423 local fsname=test1234
5425 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
5427 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
5429 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
5430 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
5431 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
5432 error "start fs2mds failed"
5434 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
5435 mgsnid="0.0.0.0@tcp,$mgsnid,$mgsnid:$mgsnid"
5437 add fs2ost --mgsnode=$mgsnid $(mkfs_opts ost1 $fs2ostdev) \
5438 --failnode=$failnid --fsname=$fsname \
5439 --reformat $fs2ostdev $fs2ostvdev ||
5440 error "add fs2ost failed"
5441 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
5443 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
5444 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
5445 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
5448 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
5451 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ||
5452 $(facet_fstype ost1) != ldiskfs ]] &&
5453 skip "ldiskfs only test" && return
5455 # reformat the Lustre filesystem with a smaller size
5456 local saved_MDSCOUNT=$MDSCOUNT
5457 local saved_MDSSIZE=$MDSSIZE
5458 local saved_OSTCOUNT=$OSTCOUNT
5459 local saved_OSTSIZE=$OSTSIZE
5462 MDSSIZE=$((MDSSIZE - 20000))
5463 OSTSIZE=$((OSTSIZE - 20000))
5464 reformat || error "(1) reformat Lustre filesystem failed"
5465 MDSSIZE=$saved_MDSSIZE
5466 OSTSIZE=$saved_OSTSIZE
5468 # mount the Lustre filesystem
5469 setup_noconfig || error "(2) setup Lustre filesystem failed"
5472 log "create test files"
5477 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
5479 for i in $(seq $num_files); do
5480 file=$MOUNT/$tdir/$tfile-$i
5481 dd if=/dev/urandom of=$file count=1 bs=1M || {
5482 $LCTL get_param osc.*.cur*grant*
5483 $LFS df; $LFS df -i;
5484 # stop creating files if there is no more space
5485 if [ ! -e $file ]; then
5486 num_files=$((i - 1))
5490 $LFS getstripe -v $file
5491 local ost_idx=$(LFS getstripe -i $file)
5492 do_facet ost$((ost_idx + 1)) \
5493 $LCTL get_param obdfilter.*.*grant*
5494 error "(4) create $file failed"
5498 # unmount the Lustre filesystem
5499 cleanup || error "(5) cleanup Lustre filesystem failed"
5501 # run e2fsck on the MDT and OST devices
5502 local mds_host=$(facet_active_host $SINGLEMDS)
5503 local ost_host=$(facet_active_host ost1)
5504 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
5505 local ost_dev=$(ostdevname 1)
5507 run_e2fsck $mds_host $mds_dev "-y"
5508 run_e2fsck $ost_host $ost_dev "-y"
5510 # get the original block count of the MDT and OST filesystems
5511 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
5512 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
5514 # expand the MDT and OST filesystems to the device size
5515 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
5516 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
5518 # run e2fsck on the MDT and OST devices again
5519 run_e2fsck $mds_host $mds_dev "-y"
5520 run_e2fsck $ost_host $ost_dev "-y"
5522 # mount the Lustre filesystem
5526 log "check files after expanding the MDT and OST filesystems"
5527 for i in $(seq $num_files); do
5528 file=$MOUNT/$tdir/$tfile-$i
5529 $CHECKSTAT -t file -s 1048576 $file ||
5530 error "(6) checkstat $file failed"
5534 log "create more files after expanding the MDT and OST filesystems"
5535 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
5536 file=$MOUNT/$tdir/$tfile-$i
5537 dd if=/dev/urandom of=$file count=1 bs=1M ||
5538 error "(7) create $file failed"
5541 # unmount the Lustre filesystem
5542 cleanup || error "(8) cleanup Lustre filesystem failed"
5544 # run e2fsck on the MDT and OST devices
5545 run_e2fsck $mds_host $mds_dev "-y"
5546 run_e2fsck $ost_host $ost_dev "-y"
5548 # get the maximum block count of the MDT and OST filesystems
5549 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
5550 local ost_max_blks=$(get_block_count ost1 $ost_dev)
5552 # get the minimum block count of the MDT and OST filesystems
5553 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
5554 grep minimum | sed -e 's/^.*filesystem: //g')
5555 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
5556 grep minimum | sed -e 's/^.*filesystem: //g')
5558 # shrink the MDT and OST filesystems to a smaller size
5562 if [[ $mds_max_blks -gt $mds_min_blks &&
5563 $mds_max_blks -gt $mds_orig_blks ]]; then
5564 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
5565 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
5566 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
5567 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
5568 error "shrink $SINGLEMDS to $new_blks failed"
5572 if [[ $ost_max_blks -gt $ost_min_blks &&
5573 $ost_max_blks -gt $ost_orig_blks ]]; then
5574 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
5575 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
5576 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
5577 run_resize2fs ost1 $ost_dev $new_blks ||
5578 error "shrink ost1 to $new_blks failed"
5582 # check whether the MDT or OST filesystem was shrunk or not
5584 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
5585 reformat || error "(10) reformat Lustre filesystem failed"
5589 # run e2fsck on the MDT and OST devices again
5590 run_e2fsck $mds_host $mds_dev "-y"
5591 run_e2fsck $ost_host $ost_dev "-y"
5593 # mount the Lustre filesystem again
5597 log "check files after shrinking the MDT and OST filesystems"
5598 for i in $(seq $((num_files + 10))); do
5599 file=$MOUNT/$tdir/$tfile-$i
5600 $CHECKSTAT -t file -s 1048576 $file ||
5601 error "(11) checkstat $file failed"
5604 # unmount and reformat the Lustre filesystem
5605 cleanup || error "(12) cleanup Lustre filesystem failed"
5606 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
5608 MDSCOUNT=$saved_MDSCOUNT
5609 OSTCOUNT=$saved_OSTCOUNT
5610 reformat || error "(14) reformat Lustre filesystem failed"
5612 run_test 78 "run resize2fs on MDT and OST filesystems"
5614 test_79() { # LU-4227
5615 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.59) ]] ||
5616 { skip "Need MDS version at least 2.5.59"; return 0; }
5618 local mdsdev1=$(mdsdevname 1)
5619 local mdsvdev1=$(mdsvdevname 1)
5620 local mdsdev2=$(mdsdevname 2)
5621 local mdsvdev2=$(mdsvdevname 2)
5622 local ostdev1=$(ostdevname 1)
5623 local ostvdev1=$(ostvdevname 1)
5624 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
5625 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
5626 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
5629 # remove --mgs/--mgsnode from mkfs.lustre options
5630 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
5632 mgsnode_opt=$(echo $opts_mds2 |
5633 awk '{ for ( i = 1; i < NF; i++ )
5634 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5635 [ -n $mgsnode_opt ] &&
5636 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
5638 mgsnode_opt=$(echo $opts_ost1 |
5639 awk '{ for ( i = 1; i < NF; i++ )
5640 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5641 [ -n $mgsnode_opt ] &&
5642 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
5644 # -MGS, format a mdt without --mgs option
5645 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
5646 error "Must specify --mgs when formatting mdt combined with mgs"
5648 # +MGS, format a mdt/ost without --mgsnode option
5649 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
5650 > /dev/null || error "start mds1 failed"
5651 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
5652 error "Must specify --mgsnode when formatting a mdt"
5653 add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
5654 error "Must specify --mgsnode when formatting an ost"
5658 run_test 79 "format MDT/OST without mgs option (should return errors)"
5661 start_mds || error "Failed to start MDT"
5662 start_ost || error "Failed to start OST1"
5663 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
5664 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
5665 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
5666 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
5667 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
5669 start_ost2 || error "Failed to start OST2"
5671 do_facet ost1 "$LCTL set_param fail_loc=0"
5674 run_test 80 "mgc import reconnect race"
5676 #Save the original values of $OSTCOUNT and $OSTINDEX$i.
5678 local new_ostcount=$1
5679 saved_ostcount=$OSTCOUNT
5680 OSTCOUNT=$new_ostcount
5684 for i in $(seq $OSTCOUNT); do
5686 eval saved_ostindex$i=${!index}
5691 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
5692 restore_ostindex() {
5697 for i in $(seq $OSTCOUNT); do
5698 index=saved_ostindex$i
5699 eval OSTINDEX$i=${!index}
5701 OSTCOUNT=$saved_ostcount
5706 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
5707 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
5708 # assigned index and ensures we can mount such a formatted file system
5709 test_81() { # LU-4665
5710 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5711 { skip "Need MDS version at least 2.6.54" && return; }
5712 [[ $OSTCOUNT -ge 3 ]] || { skip_env "needs >= 3 OSTs" && return; }
5716 # Each time RANDOM is referenced, a random integer between 0 and 32767
5719 local saved_ostindex1=$OSTINDEX1
5720 for i in 65535 $((RANDOM + 65536)); do
5721 echo -e "\nFormat ost1 with --index=$i, should fail"
5723 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
5724 $(ostdevname 1) $(ostvdevname 1); then
5725 OSTINDEX1=$saved_ostindex1
5726 error "format ost1 with --index=$i should fail"
5729 OSTINDEX1=$saved_ostindex1
5733 # Format OSTs with random sparse indices.
5734 trap "restore_ostindex" EXIT
5735 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices"
5736 OST_INDEX_LIST=[0,$((RANDOM * 2 % 65533 + 1)),65534] formatall
5738 # Setup and check Lustre filesystem.
5739 start_mgsmds || error "start_mgsmds failed"
5740 for i in $(seq $OSTCOUNT); do
5741 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5742 error "start ost$i failed"
5745 mount_client $MOUNT || error "mount client $MOUNT failed"
5746 check_mount || error "check client $MOUNT failed"
5749 local max_easize=$($LCTL get_param -n llite.*.max_easize)
5750 [[ $max_easize -eq 128 ]] ||
5751 error "max_easize is $max_easize, should be 128 bytes"
5755 run_test 81 "sparse OST indexing"
5757 # Here we exercise the stripe placement functionality on a file system that
5758 # has formatted the OST with a random index. With the file system the following
5759 # functionality is tested:
5761 # 1. Creating a new file with a specific stripe layout.
5763 # 2. Modifiy a existing empty file with a specific stripe layout.
5765 # 3. Ensure we fail to set the stripe layout of a file that already has one.
5767 # 4. If ost-index is defined we need to ensure it is the first entry in the
5768 # ost index list returned by lfs getstripe.
5770 # 5. Lastly ensure this functionality fails with directories.
5771 test_82a() { # LU-4665
5772 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5773 { skip "Need MDS version at least 2.6.54" && return; }
5774 [[ $OSTCOUNT -ge 3 ]] || { skip_env "needs >= 3 OSTs" && return; }
5780 # Format OSTs with random sparse indices.
5784 local LOV_V1_INSANE_STRIPE_COUNT=65532
5785 for i in $(seq $OSTCOUNT); do
5786 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
5787 ost_indices+=" $index"
5789 ost_indices=$(comma_list $ost_indices)
5791 trap "restore_ostindex" EXIT
5792 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5793 OST_INDEX_LIST=[$ost_indices] formatall
5795 # Setup Lustre filesystem.
5796 start_mgsmds || error "start_mgsmds failed"
5797 for i in $(seq $OSTCOUNT); do
5798 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5799 error "start ost$i failed"
5802 mount_client $MOUNT || error "mount client $MOUNT failed"
5805 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
5806 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5808 # 1. If the file does not exist, new file will be created
5809 # with specified OSTs.
5810 local file=$DIR/$tdir/$tfile-1
5811 local cmd="$SETSTRIPE -o $ost_indices $file"
5813 eval $cmd || error "$cmd failed"
5814 check_stripe_count $file $OSTCOUNT
5815 check_obdidx $file $ost_indices
5816 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5817 error "write $file failed"
5819 # 2. If the file already exists and is an empty file, the file
5820 # will be attached with specified layout.
5821 file=$DIR/$tdir/$tfile-2
5822 mcreate $file || error "mcreate $file failed"
5823 cmd="$SETSTRIPE -o $ost_indices $file"
5825 eval $cmd || error "$cmd failed"
5826 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5827 error "write $file failed"
5828 check_stripe_count $file $OSTCOUNT
5829 check_obdidx $file $ost_indices
5831 # 3. If the file already has a valid layout attached, the command
5832 # should fail with EBUSY.
5834 eval $cmd && error "stripe is already set on $file, $cmd should fail"
5836 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
5837 # be in the OST indices list.
5838 local start_ost_idx=${ost_indices##*,}
5839 file=$DIR/$tdir/$tfile-3
5840 cmd="$SETSTRIPE -o $ost_indices -i $start_ost_idx $file"
5842 eval $cmd || error "$cmd failed"
5843 check_stripe_count $file $OSTCOUNT
5844 check_obdidx $file $ost_indices
5845 check_start_ost_idx $file $start_ost_idx
5847 file=$DIR/$tdir/$tfile-4
5849 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
5850 cmd+=" -i $start_ost_idx $file"
5852 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
5854 # 5. Specifying OST indices for directory should fail with ENOSUPP.
5855 local dir=$DIR/$tdir/$tdir
5856 mkdir $dir || error "mkdir $dir failed"
5857 cmd="$SETSTRIPE -o $ost_indices $dir"
5859 eval $cmd && error "$cmd should fail, specifying OST indices" \
5860 "for directory is not supported"
5864 run_test 82a "specify OSTs for file (succeed) or directory (fail)"
5869 # Remove OSTs from a pool and destroy the pool.
5870 destroy_pool $ost_pool || true
5875 # Test 82b is run to ensure that if the user supplies a pool with a specific
5876 # stripe layout that it behaves proprerly. It should fail in the case that
5877 # the supplied OST index list points to OSTs not contained in the user
5879 test_82b() { # LU-4665
5880 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5881 { skip "Need MDS version at least 2.6.54" && return; }
5882 [[ $OSTCOUNT -ge 4 ]] || { skip_env "needs >= 4 OSTs" && return; }
5888 # Format OSTs with random sparse indices.
5892 local LOV_V1_INSANE_STRIPE_COUNT=65532
5893 for i in $(seq $OSTCOUNT); do
5894 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
5895 ost_indices+=" $index"
5897 ost_indices=$(comma_list $ost_indices)
5899 trap "restore_ostindex" EXIT
5900 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5901 OST_INDEX_LIST=[$ost_indices] formatall
5903 # Setup Lustre filesystem.
5904 start_mgsmds || error "start_mgsmds failed"
5905 for i in $(seq $OSTCOUNT); do
5906 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5907 error "start ost$i failed"
5910 mount_client $MOUNT || error "mount client $MOUNT failed"
5912 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
5913 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5915 # Create a new pool and add OSTs into it.
5916 local ost_pool=$FSNAME.$TESTNAME
5917 create_pool $ost_pool || error "create OST pool $ost_pool failed"
5920 trap "cleanup_82b" EXIT
5922 local ost_idx_in_list=${ost_indices##*,}
5923 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
5926 local ost_targets="$FSNAME-OST["
5927 for i in ${ost_idx_in_pool//,/ }; do
5928 ost_targets=$ost_targets$(printf "%04x," $i)
5930 ost_targets="${ost_targets%,}]"
5932 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
5933 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
5934 sort -u | tr '\n' ' ')
5936 local cmd="$LCTL pool_add $ost_pool $ost_targets"
5937 do_facet mgs $cmd || error "$cmd failed"
5938 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
5939 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
5940 error "wait_update $ost_pool failed"
5941 wait_update_facet $SINGLEMDS "$LCTL pool_list $ost_pool | wc -l" 4 ||
5942 error "wait_update pool_list $ost_pool failed"
5944 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
5945 # then the OSTs must be the members of the pool.
5946 local file=$DIR/$tdir/$tfile
5947 cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
5949 eval $cmd && error "OST with index $ost_idx_in_list should be" \
5950 "in OST pool $ost_pool"
5952 # Only select OST $ost_idx_in_list from $ost_pool for file.
5953 ost_idx_in_list=${ost_idx_in_pool#*,}
5954 cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
5956 eval $cmd || error "$cmd failed"
5957 cmd="$GETSTRIPE $file"
5959 eval $cmd || error "$cmd failed"
5960 check_stripe_count $file 2
5961 check_obdidx $file $ost_idx_in_list
5962 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5963 error "write $file failed"
5967 run_test 82b "specify OSTs for file with --pool and --ost-list options"
5970 [[ $(lustre_version_code ost1) -ge $(version_code 2.6.91) ]] ||
5971 { skip "Need OST version at least 2.6.91" && return 0; }
5972 if [ $(facet_fstype ost1) != ldiskfs ]; then
5973 skip "ldiskfs only test"
5983 ostmnt=$(facet_mntpt ost1)
5984 fstype=$(facet_fstype ost1)
5986 # Mount the OST as an ldiskfs filesystem.
5987 log "mount the OST $dev as a $fstype filesystem"
5988 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
5989 --reformat $dev > /dev/null ||
5990 error "format ost1 error"
5992 if ! test -b $dev; then
5993 mnt_opts=$(csa_add "$OST_MOUNT_OPTS" -o loop)
5995 echo "mnt_opts $mnt_opts"
5996 do_facet ost1 mount -t $fstype $dev \
5998 # Run llverfs on the mounted ldiskfs filesystem.
5999 # It is needed to get ENOSPACE.
6000 log "run llverfs in partial mode on the OST $fstype $ostmnt"
6001 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
6002 "no" || error "run_llverfs error on $fstype"
6005 log "unmount the OST $dev"
6008 # Delete file IO_scrub. Later osd_scrub_setup will try to
6009 # create "IO_scrub" but will get ENOSPACE.
6011 echo "start ost1 service on `facet_active_host ost1`"
6012 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
6015 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
6016 echo "string err $err"
6017 [ -z "$err" ] || error $err
6020 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
6021 Busy inodes after unmount ..."
6024 local facet=$SINGLEMDS
6025 local num=$(echo $facet | tr -d "mds")
6026 local dev=$(mdsdevname $num)
6027 local time_min=$(recovery_time_min)
6028 local recovery_duration
6029 local completed_clients
6030 local correct_clients
6033 echo "start mds service on $(facet_active_host $facet)"
6035 "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" $@ ||
6036 error "start MDS failed"
6038 start_ost || error "start OST0000 failed"
6039 start_ost2 || error "start OST0001 failed"
6041 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
6043 mount_client $MOUNT1 || error "mount $MOUNT1 failed"
6044 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
6045 # make sure new superblock labels are sync'd before disabling writes
6049 replay_barrier $SINGLEMDS
6050 createmany -o $DIR1/$tfile-%d 1000
6052 # We need to catch the end of recovery window to extend it.
6053 # Skip 5 requests and add delay to request handling.
6054 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
6055 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
6057 facet_failover --fsck $SINGLEMDS || error "failover: $?"
6060 echo "recovery status"
6061 do_facet $SINGLEMDS \
6062 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
6064 recovery_duration=$(do_facet $SINGLEMDS \
6065 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6066 awk '/recovery_duration/ { print $2 }')
6067 (( $recovery_duration > $time_min + $wrap_up )) &&
6068 error "recovery_duration > recovery_time_hard + wrap up"
6069 completed_clients=$(do_facet $SINGLEMDS \
6070 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6071 awk '/completed_clients/ { print $2 }')
6073 correct_clients="$MDSCOUNT/$((MDSCOUNT+1))"
6074 [ "$completed_clients" = "${correct_clients}" ] ||
6075 error "$completed_clients != $correct_clients"
6077 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
6078 umount_client $MOUNT1
6079 umount_client $MOUNT2
6085 run_test 84 "check recovery_hard_time"
6088 [[ $(lustre_version_code ost1) -ge $(version_code 2.7.55) ]] ||
6089 { skip "Need OST version at least 2.7.55" && return 0; }
6090 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
6091 do_facet ost1 "lctl set_param fail_loc=0x197"
6095 run_test 85 "osd_ost init: fail ea_fid_set"
6100 # ost1 has already registered to the MGS before the reformat.
6101 # So after reformatting it with option "-G", it could not be
6102 # mounted to the MGS. Cleanup the system for subsequent tests.
6107 local server_version=$(lustre_version_code $SINGLEMDS)
6108 [ "$(facet_fstype ost1)" = "zfs" ] &&
6109 skip "LU-6442: no such mkfs params for ZFS OSTs" && return
6110 [[ $server_version -ge $(version_code 2.7.56) ]] ||
6111 { skip "Need server version newer than 2.7.55"; return 0; }
6113 local OST_OPTS="$(mkfs_opts ost1 $(ostdevname 1)) \
6114 --reformat $(ostdevname 1) $(ostvdevname 1)"
6117 local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6118 awk '/Flex block group size: / { print $NF; exit; }')
6121 if [[ ${!opts} != *mkfsoptions* ]]; then
6122 eval opts=\"${!opts} \
6123 --mkfsoptions='\\\"-O flex_bg -G $NEWSIZE\\\"'\"
6125 val=${!opts//--mkfsoptions=\\\"/ \
6126 --mkfsoptions=\\\"-O flex_bg -G $NEWSIZE }
6130 echo "params: $opts"
6132 trap cleanup_86 EXIT ERR
6135 add ost1 $opts || error "add ost1 failed with new params"
6137 local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6138 awk '/Flex block group size: / { print $NF; exit; }')
6140 [[ $FOUNDSIZE == $NEWSIZE ]] ||
6141 error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
6145 run_test 86 "Replacing mkfs.lustre -G option"
6147 test_87() { #LU-6544
6148 [[ $(lustre_version_code $SINGLEMDS1) -ge $(version_code 2.9.51) ]] ||
6149 { skip "Need MDS version at least 2.9.51" && return; }
6150 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
6151 { skip "ldiskfs only test" && return; }
6152 [[ $OSTCOUNT -gt 59 ]] &&
6153 { skip "Ignore wide striping situation" && return; }
6155 local mdsdev=$(mdsdevname 1)
6156 local mdsvdev=$(mdsvdevname 1)
6157 local file=$DIR/$tfile
6158 local mntpt=$(facet_mntpt $SINGLEMDS)
6159 local used_xattr_blk=0
6160 local inode_size=${1:-1024}
6162 local xtest="trusted.test"
6166 local stripe_cnt=$(($OSTCOUNT + 2))
6168 #Please see ldiskfs_make_lustre() for MDT inode size calculation
6169 if [ $stripe_cnt -gt 16 ]; then
6172 left_size=$(expr $inode_size - \
6175 32 - 40 \* 3 - 32 \* 3 - $stripe_cnt \* 24 - 16 - 3 - \
6177 24 - 18 - $(expr length $tfile) - 16 - 4)
6178 if [ $left_size -le 0 ]; then
6179 echo "No space($left_size) is expected in inode."
6180 echo "Try 1-byte xattr instead to verify this."
6183 echo "Estimate: at most $left_size-byte space left in inode."
6189 add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$stripe_cnt \
6190 --reformat $mdsdev $mdsvdev || error "add mds1 failed"
6191 start_mdt 1 > /dev/null || error "start mdt1 failed"
6192 for i in $(seq $OSTCOUNT); do
6193 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
6194 error "start ost$i failed"
6196 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
6197 check_mount || error "check client $MOUNT failed"
6200 $SETSTRIPE -E 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
6201 error "Create file with 3 components failed"
6202 $TRUNCATE $file $((1024*1024*64+1)) || error "truncate file failed"
6203 i=$($GETSTRIPE -I3 -c $file) || error "get 3rd stripe count failed"
6204 if [ $i -ne $OSTCOUNT ]; then
6205 left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
6206 echo -n "Since only $i out $OSTCOUNT OSTs are used, "
6207 echo -n "the expected left space is changed to "
6208 echo "$left_size bytes at most."
6210 value=$(generate_string $left_size)
6211 setfattr -n $xtest -v $value $file
6212 orig=$(get_xattr_value $xtest $file)
6213 [[ "$orig" != "$value" ]] && error "$xtest changed"
6215 #Verify if inode has some expected space left
6216 umount $MOUNT > /dev/null || error "umount $MOUNT failed"
6217 stop_mdt 1 > /dev/null || error "stop mdt1 failed"
6218 mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
6220 do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
6221 used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
6223 [[ $used_xattr_blk -eq 0 ]] &&
6224 error "Please check MDS inode size calculation: \
6225 more than $left_size-byte space left in inode."
6226 echo "Verified: at most $left_size-byte space left in inode."
6230 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
6233 [ "$(facet_fstype mds1)" == "zfs" ] &&
6234 skip "LU-6662: no implementation for ZFS" && return
6238 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6239 --reformat $(mdsdevname 1) || error "add mds1 failed"
6241 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6242 grep -e \".*opts:.*errors=remount-ro.*\"" ||
6243 error "default mount options is missing"
6245 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6246 --mountfsoptions="user_xattr,errors=panic" \
6247 --reformat $(mdsdevname 1) || error "add mds1 failed"
6249 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6250 grep -e \".*opts:.*errors=panic.*\"" ||
6251 error "user can't override default mount options"
6253 run_test 88 "check the default mount options can be overridden"
6255 test_89() { # LU-7131
6256 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.9.54) ]] ||
6257 { skip "Need MDT version at least 2.9.54" && return 0; }
6259 local key=failover.node
6260 local val1=192.0.2.254@tcp0 # Reserved IPs, see RFC 5735
6261 local val2=192.0.2.255@tcp0
6262 local mdsdev=$(mdsdevname 1)
6267 [ $(facet_fstype mds1) == zfs ] && import_zpool mds1
6268 # Check that parameters are added correctly
6269 echo "tunefs --param $key=$val1"
6270 do_facet mds "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
6271 error "tunefs --param $key=$val1 failed"
6272 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6273 error "tunefs --dryrun failed"
6274 params=${params##*Parameters:}
6275 params=${params%%exiting*}
6276 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val1) = "1" ] ||
6277 error "on-disk parameter not added correctly via tunefs"
6279 # Check that parameters replace existing instances when added
6280 echo "tunefs --param $key=$val2"
6281 do_facet mds "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
6282 error "tunefs --param $key=$val2 failed"
6283 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6284 error "tunefs --dryrun failed"
6285 params=${params##*Parameters:}
6286 params=${params%%exiting*}
6287 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "1" ] ||
6288 error "on-disk parameter not replaced via tunefs"
6289 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val2) = "1" ] ||
6290 error "on-disk parameter not replaced correctly via tunefs"
6292 # Check that a parameter is erased properly
6293 echo "tunefs --erase-param $key"
6294 do_facet mds "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
6295 error "tunefs --erase-param $key failed"
6296 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6297 error "tunefs --dryrun failed"
6298 params=${params##*Parameters:}
6299 params=${params%%exiting*}
6300 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "0" ] ||
6301 error "on-disk parameter not erased correctly via tunefs"
6303 # Check that all the parameters are erased
6304 echo "tunefs --erase-params"
6305 do_facet mds "$TUNEFS --erase-params $mdsdev >/dev/null" ||
6306 error "tunefs --erase-params failed"
6307 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6308 error "tunefs --dryrun failed"
6309 params=${params##*Parameters:}
6310 params=${params%%exiting*}
6312 error "all on-disk parameters not erased correctly via tunefs"
6314 # Check the order of options --erase-params and --param
6315 echo "tunefs --param $key=$val1 --erase-params"
6317 "$TUNEFS --param $key=$val1 --erase-params $mdsdev >/dev/null"||
6318 error "tunefs --param $key=$val1 --erase-params failed"
6319 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6320 error "tunefs --dryrun failed"
6321 params=${params##*Parameters:}
6322 params=${params%%exiting*}
6323 [ $(echo $params | tr ' ' '\n') == "$key=$val1" ] ||
6324 error "on-disk param not added correctly with --erase-params"
6328 run_test 89 "check tunefs --param and --erase-param{s} options"
6331 # $2 (optional) value of max_mod_rpcs_in_flight to set
6332 check_max_mod_rpcs_in_flight() {
6340 idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
6341 facet="mds$((0x$idx + 1))"
6343 if [ -z "$mmr" ]; then
6344 # get value of max_mod_rcps_in_flight
6345 mmr=$($LCTL get_param -n \
6346 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
6347 error "Unable to get max_mod_rpcs_in_flight"
6348 echo "max_mod_rcps_in_flight is $mmr"
6350 # set value of max_mod_rpcs_in_flight
6352 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
6353 error "Unable to set max_mod_rpcs_in_flight to $mmr"
6354 echo "max_mod_rpcs_in_flight set to $mmr"
6357 # create mmr+1 files
6358 echo "creating $((mmr + 1)) files ..."
6360 for i in $(seq $((mmr + 1))); do
6366 # consumes mmr-1 modify RPC slots
6367 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6368 # drop requests on MDT so that RPC slots are consumed
6369 # during all the request resend interval
6370 do_facet $facet "$LCTL set_param fail_loc=0x159"
6371 echo "launch $((mmr - 1)) chmod in parallel ..."
6372 for i in $(seq $((mmr - 1))); do
6373 chmod 0600 $dir/file-$i &
6377 # send one additional modify RPC
6378 do_facet $facet "$LCTL set_param fail_loc=0"
6379 echo "launch 1 additional chmod in parallel ..."
6380 chmod 0600 $dir/file-$mmr &
6383 # check this additional modify RPC get a modify RPC slot
6384 # and succeed its operation
6385 checkstat -vp 0600 $dir/file-$mmr ||
6386 error "Unable to send $mmr modify RPCs in parallel"
6391 # consumes mmr modify RPC slots
6392 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6393 # drop requests on MDT so that RPC slots are consumed
6394 # during all the request resend interval
6395 do_facet $facet "$LCTL set_param fail_loc=0x159"
6396 echo "launch $mmr chmod in parallel ..."
6397 for i in $(seq $mmr); do
6398 chmod 0666 $dir/file-$i &
6402 # send one additional modify RPC
6403 do_facet $facet "$LCTL set_param fail_loc=0"
6404 echo "launch 1 additional chmod in parallel ..."
6405 chmod 0666 $dir/file-$((mmr + 1)) &
6408 # check this additional modify RPC blocked getting a modify RPC slot
6409 checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
6410 error "Unexpectedly send $(($mmr + 1)) modify RPCs in parallel"
6416 if ! combined_mgs_mds ; then
6421 [[ $($LCTL get_param mdc.*.import |
6422 grep "connect_flags:.*multi_mod_rpc") ]] ||
6423 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
6425 # check default value
6426 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6427 check_max_mod_rpcs_in_flight $DIR/$tdir
6431 run_test 90a "check max_mod_rpcs_in_flight is enforced"
6441 [[ $($LCTL get_param mdc.*.import |
6442 grep "connect_flags:.*multi_mod_rpc") ]] ||
6443 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
6446 # update max_mod_rpcs_in_flight
6447 $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
6448 check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
6451 # check client is able to send multiple modify RPCs in paralell
6452 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6453 grep -c "multi_mod_rpcs")
6454 if [ "$tmp" -ne $MDSCOUNT ]; then
6455 echo "Client not able to send multiple modify RPCs in parallel"
6460 # update max_mod_rpcs_in_flight
6461 $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
6462 check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
6465 $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
6466 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
6467 facet="mds$((0x$idx + 1))"
6469 # save MDT max_mod_rpcs_per_client
6470 mmrpc=$(do_facet $facet \
6471 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6473 # update max_mod_rpcs_in_flight
6474 umount_client $MOUNT
6476 "echo 16 > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6478 $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
6479 check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
6481 # restore MDT max_mod_rpcs_per_client initial value
6483 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6485 rm -rf $DIR/${tdir}?
6488 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
6497 [[ $($LCTL get_param mdc.*.import |
6498 grep "connect_flags:.*multi_mod_rpc") ]] ||
6499 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
6501 # check client is able to send multiple modify RPCs in paralell
6502 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6503 grep -c "multi_mod_rpcs")
6504 if [ "$tmp" -ne $MDSCOUNT ]; then
6505 skip "Client not able to send multiple modify RPCs in parallel"
6510 # get max_rpcs_in_flight value
6511 mrif=$($LCTL get_param -n mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6512 echo "max_rpcs_in_flight is $mrif"
6514 # get MDT max_mod_rpcs_per_client
6515 mmrpc=$(do_facet mds1 \
6516 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6517 echo "max_mod_rpcs_per_client is $mmrpc"
6520 # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
6521 # prerequisite: set max_mod_rpcs_per_client to max_rpcs_in_flight value
6522 umount_client $MOUNT
6524 "echo $mrif > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6528 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif &&
6529 error "set max_mod_rpcs_in_flight to $mrif should fail"
6531 umount_client $MOUNT
6533 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6537 # attempt to set max_mod_rpcs_in_flight to max_mod_rpcs_per_client+1
6538 # prerequisite: set max_rpcs_in_flight to max_mod_rpcs_per_client+2
6540 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc + 2))
6543 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc + 1)) &&
6544 error "set max_mod_rpcs_in_flight to $((mmrpc + 1)) should fail"
6548 run_test 90c "check max_mod_rpcs_in_flight update limits"
6559 [[ $($LCTL get_param mdc.*.import |
6560 grep "connect_flags:.*multi_mod_rpc") ]] ||
6561 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
6563 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6564 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
6565 facet="mds$((0x$idx + 1))"
6567 # check client version supports multislots
6568 tmp=$($LCTL get_param -N \
6569 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6570 if [ -z "$tmp" ]; then
6571 skip "Client does not support multiple modify RPCs in flight"
6576 # get current value of max_mod_rcps_in_flight
6577 mmr=$($LCTL get_param -n \
6578 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6579 echo "max_mod_rcps_in_flight is $mmr"
6582 echo "creating $mmr files ..."
6584 for i in $(seq $mmr); do
6585 touch $DIR/$tdir/file-$i
6588 # prepare for close RPC
6589 multiop_bg_pause $DIR/$tdir/file-close O_c
6592 # consumes mmr modify RPC slots
6593 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6594 # drop requests on MDT so that RPC slots are consumed
6595 # during all the request resend interval
6596 do_facet $facet "$LCTL set_param fail_loc=0x159"
6597 echo "launch $mmr chmod in parallel ..."
6598 for i in $(seq $mmr); do
6599 chmod 0600 $DIR/$tdir/file-$i &
6602 # send one additional close RPC
6603 do_facet $facet "$LCTL set_param fail_loc=0"
6604 echo "launch 1 additional close in parallel ..."
6606 cancel_lru_locks mdc
6609 # check this additional close RPC get a modify RPC slot
6610 # and multiop process completed
6611 [ -d /proc/$pid ] &&
6612 error "Unable to send the additional close RPC in parallel"
6617 run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
6619 check_uuid_on_ost() {
6621 do_facet ost1 "$LCTL get_param obdfilter.${FSNAME}*.exports.'$nid'.uuid"
6624 check_uuid_on_mdt() {
6626 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6634 [[ $(lustre_version_code ost1) -ge $(version_code 2.7.63) ]] ||
6635 { skip "Need OST version at least 2.7.63" && return 0; }
6636 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.63) ]] ||
6637 { skip "Need MDT version at least 2.7.63" && return 0; }
6639 start_mds || error "MDS start failed"
6640 start_ost || error "unable to start OST"
6641 mount_client $MOUNT || error "client start failed"
6642 check_mount || error "check_mount failed"
6645 nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
6649 uuid=$(get_client_uuid $MOUNT)
6651 echo "list nids on mdt:"
6652 do_facet $SINGLEMDS "$LCTL list_param mdt.${FSNAME}*.exports.*"
6653 echo "uuid from $nid:"
6654 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6656 found=$(check_uuid_on_mdt $nid | grep $uuid)
6657 [ -z "$found" ] && error "can't find $uuid $nid on MDT"
6658 found=$(check_uuid_on_ost $nid | grep $uuid)
6659 [ -z "$found" ] && error "can't find $uuid $nid on OST"
6661 # umount the client so it won't reconnect
6662 manual_umount_client --force || error "failed to umount $?"
6663 # shouldn't disappear on MDS after forced umount
6664 found=$(check_uuid_on_mdt $nid | grep $uuid)
6665 [ -z "$found" ] && error "can't find $uuid $nid"
6668 do_facet $SINGLEMDS \
6669 "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
6671 found=$(check_uuid_on_mdt $nid | grep $uuid)
6672 [ -n "$found" ] && error "found $uuid $nid on MDT"
6673 found=$(check_uuid_on_ost $nid | grep $uuid)
6674 [ -n "$found" ] && error "found $uuid $nid on OST"
6676 # check it didn't reconnect (being umounted)
6677 sleep $((TIMEOUT+1))
6678 found=$(check_uuid_on_mdt $nid | grep $uuid)
6679 [ -n "$found" ] && error "found $uuid $nid on MDT"
6680 found=$(check_uuid_on_ost $nid | grep $uuid)
6681 [ -n "$found" ] && error "found $uuid $nid on OST"
6685 run_test 91 "evict-by-nid support"
6687 generate_ldev_conf() {
6688 # generate an ldev.conf file
6689 local ldevconfpath=$1
6691 local fsldevformat=""
6694 fstype=$(facet_fstype mgs)
6695 if [ "$fstype" == "zfs" ]; then
6696 fsldevformat="$fstype:"
6701 printf "%s\t-\t%s-MGS0000\t%s%s\n" \
6705 $(mgsdevname) > $ldevconfpath
6707 local mdsfo_host=$mdsfailover_HOST;
6708 if [ -z "$mdsfo_host" ]; then
6712 for num in $(seq $MDSCOUNT); do
6713 fstype=$(facet_fstype mds$num)
6714 if [ "$fstype" == "zfs" ]; then
6715 fsldevformat="$fstype:"
6720 printf "%s\t%s\t%s-MDT%04d\t%s%s\n" \
6726 $(mdsdevname $num) >> $ldevconfpath
6729 local ostfo_host=$ostfailover_HOST;
6730 if [ -z "$ostfo_host" ]; then
6734 for num in $(seq $OSTCOUNT); do
6735 fstype=$(facet_fstype ost$num)
6736 if [ "$fstype" == "zfs" ]; then
6737 fsldevformat="$fstype:"
6742 printf "%s\t%s\t%s-OST%04d\t%s%s\n" \
6748 $(ostdevname $num) >> $ldevconfpath
6751 echo "----- $ldevconfpath -----"
6753 echo "--- END $ldevconfpath ---"
6758 # generate a nids file (mapping between hostname to nid)
6759 # looks like we only have the MGS nid available to us
6760 # so just echo that to a file
6762 echo -e "${mgs_HOST}\t${MGSNID}" > $nidspath
6764 echo "----- $nidspath -----"
6766 echo "--- END $nidspath ---"
6769 compare_ldev_output() {
6773 sort $expected_output -o $expected_output
6774 sort $ldev_output -o $ldev_output
6776 echo "-- START OF LDEV OUTPUT --"
6778 echo "--- END OF LDEV OUTPUT ---"
6780 echo "-- START OF EXPECTED OUTPUT --"
6781 cat $expected_output
6782 echo "--- END OF EXPECTED OUTPUT ---"
6784 diff $expected_output $ldev_output
6789 if [ -z "$LDEV" ]; then
6790 error "ldev is missing!"
6793 local LDEVCONFPATH=$TMP/ldev.conf
6794 local NIDSPATH=$TMP/nids
6796 echo "Host is $(hostname)"
6798 generate_ldev_conf $LDEVCONFPATH
6799 generate_nids $NIDSPATH
6801 # echo the mgs nid and compare it to environment variable MGSNID
6802 # also, ldev.conf and nids is a server side thing, use the OSS
6805 output=$($LDEV -c $LDEVCONFPATH -H $ost_HOST -n $NIDSPATH echo %m)
6807 echo "-- START OF LDEV OUTPUT --"
6809 echo "--- END OF LDEV OUTPUT ---"
6811 # ldev failed, error
6812 if [ $? -ne 0 ]; then
6813 rm $LDEVCONFPATH $NIDSPATH
6814 error "ldev failed to execute!"
6817 # need to process multiple lines because of combined MGS and MDS
6818 echo -e $output | awk '{ print $2 }' | while read -r line ; do
6819 if [ "$line" != "$MGSNID" ]; then
6820 rm $LDEVCONFPATH $NIDSPATH
6821 error "ldev failed mgs nid '$line', expected '$MGSNID'"
6825 rm $LDEVCONFPATH $NIDSPATH
6827 run_test 92 "ldev returns MGS NID correctly in command substitution"
6830 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs" && return
6833 #start mgs or mgs/mdt0
6834 if ! combined_mgs_mds ; then
6841 start_ost || error "OST0 start fail"
6843 #define OBD_FAIL_MGS_WRITE_TARGET_DELAY 0x90e
6844 do_facet mgs "$LCTL set_param fail_val = 10 fail_loc=0x8000090e"
6845 for num in $(seq 2 $MDSCOUNT); do
6849 mount_client $MOUNT || error "mount client fails"
6850 wait_osc_import_state mds ost FULL
6851 wait_osc_import_state client ost FULL
6852 check_mount || error "check_mount failed"
6854 cleanup || error "cleanup failed with $?"
6856 run_test 93 "register mulitple MDT at the same time"
6859 if [ -z "$LDEV" ]; then
6860 error "ldev is missing!"
6863 local LDEVCONFPATH=$TMP/ldev.conf
6864 local NIDSPATH=$TMP/nids
6866 generate_ldev_conf $LDEVCONFPATH
6867 generate_nids $NIDSPATH
6869 local LDEV_OUTPUT=$TMP/ldev-output.txt
6870 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME > $LDEV_OUTPUT
6872 # ldev failed, error
6873 if [ $? -ne 0 ]; then
6874 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
6875 error "ldev failed to execute!"
6879 local EXPECTED_OUTPUT=$TMP/ldev-expected.txt
6881 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
6883 for num in $(seq $MDSCOUNT); do
6884 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
6887 for num in $(seq $OSTCOUNT); do
6888 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
6891 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
6893 if [ $? -ne 0 ]; then
6894 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
6895 error "ldev failed to produce the correct hostlist!"
6898 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
6900 run_test 94 "ldev outputs correct labels for file system name query"
6903 if [ -z "$LDEV" ]; then
6904 error "ldev is missing!"
6907 local LDEVCONFPATH=$TMP/ldev.conf
6908 local NIDSPATH=$TMP/nids
6910 generate_ldev_conf $LDEVCONFPATH
6911 generate_nids $NIDSPATH
6915 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME &>/dev/null
6916 if [ $? -ne 0 ]; then
6917 rm $LDEVCONFPATH $NIDSPATH
6918 error "ldev label filtering w/ -F failed!"
6922 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -l &>/dev/null
6923 if [ $? -ne 0 ]; then
6924 rm $LDEVCONFPATH $NIDSPATH
6925 error "ldev label filtering w/ -l failed!"
6929 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f &>/dev/null
6930 if [ $? -ne 0 ]; then
6931 rm $LDEVCONFPATH $NIDSPATH
6932 error "ldev label filtering w/ -f failed!"
6936 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a &>/dev/null
6937 if [ $? -ne 0 ]; then
6938 rm $LDEVCONFPATH $NIDSPATH
6939 error "ldev label filtering w/ -a failed!"
6944 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -F $FSNAME &>/dev/null
6945 if [ $? -eq 0 ]; then
6946 rm $LDEVCONFPATH $NIDSPATH
6947 error "ldev label filtering w/ -a and -F incorrectly succeeded"
6951 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -f &>/dev/null
6952 if [ $? -eq 0 ]; then
6953 rm $LDEVCONFPATH $NIDSPATH
6954 error "ldev label filtering w/ -a and -f incorrectly succeeded"
6958 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -l &>/dev/null
6959 if [ $? -eq 0 ]; then
6960 rm $LDEVCONFPATH $NIDSPATH
6961 error "ldev label filtering w/ -a and -l incorrectly succeeded"
6965 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f -l &>/dev/null
6966 if [ $? -eq 0 ]; then
6967 rm $LDEVCONFPATH $NIDSPATH
6968 error "ldev label filtering w/ -f and -l incorrectly succeeded"
6972 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -l &>/dev/null
6973 if [ $? -eq 0 ]; then
6974 rm $LDEVCONFPATH $NIDSPATH
6975 error "ldev label filtering w/ -F and -l incorrectly succeeded"
6978 # file sys & foreign
6979 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -f &>/dev/null
6980 if [ $? -eq 0 ]; then
6981 rm $LDEVCONFPATH $NIDSPATH
6982 error "ldev label filtering w/ -F and -f incorrectly succeeded"
6985 rm $LDEVCONFPATH $NIDSPATH
6987 run_test 95 "ldev should only allow one label filter"
6990 if [ -z "$LDEV" ]; then
6991 error "ldev is missing!"
6994 local LDEVCONFPATH=$TMP/ldev.conf
6995 local NIDSPATH=$TMP/nids
6997 generate_ldev_conf $LDEVCONFPATH
6998 generate_nids $NIDSPATH
7000 local LDEV_OUTPUT=$TMP/ldev-output.txt
7001 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -H $mgs_HOST \
7003 awk '{print $2}' > $LDEV_OUTPUT
7005 # ldev failed, error
7006 if [ $? -ne 0 ]; then
7007 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7008 error "ldev failed to execute!"
7012 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7014 echo "$mgs_HOST-$(facet_fstype mgs)" > $EXPECTED_OUTPUT
7016 if [ "$mgs_HOST" == "$mds_HOST" ]; then
7017 for num in $(seq $MDSCOUNT); do
7018 echo "$mds_HOST-$(facet_fstype mds$num)" \
7023 if [ "$mgs_HOST" == "$ost_HOST" ]; then
7024 for num in $(seq $OSTCOUNT); do
7025 echo "$ost_HOST-$(facet_fstype ost$num)" \
7030 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7032 if [ $? -ne 0 ]; then
7033 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7034 error "ldev failed to produce the correct output!"
7037 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7039 run_test 96 "ldev returns hostname and backend fs correctly in command sub"
7042 if [ -z "$LDEV" ]; then
7043 error "ldev is missing!"
7046 local LDEVCONFPATH=$TMP/ldev.conf
7047 local NIDSPATH=$TMP/nids
7049 generate_ldev_conf $LDEVCONFPATH
7050 generate_nids $NIDSPATH
7052 local LDEV_OUTPUT=$TMP/ldev-output.txt
7053 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7055 echo -e "\nMDT role"
7056 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mdt > $LDEV_OUTPUT
7058 if [ $? -ne 0 ]; then
7059 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7060 error "ldev failed to execute for mdt role!"
7063 for num in $(seq $MDSCOUNT); do
7064 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7067 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7069 if [ $? -ne 0 ]; then
7070 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7071 error "ldev failed to produce the correct output for mdt role!"
7074 echo -e "\nOST role"
7075 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R ost > $LDEV_OUTPUT
7077 if [ $? -ne 0 ]; then
7078 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7079 error "ldev failed to execute for ost role!"
7083 for num in $(seq $OSTCOUNT); do
7084 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7087 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7089 if [ $? -ne 0 ]; then
7090 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7091 error "ldev failed to produce the correct output for ost role!"
7094 echo -e "\nMGS role"
7095 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mgs > $LDEV_OUTPUT
7097 if [ $? -ne 0 ]; then
7098 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7099 error "ldev failed to execute for mgs role!"
7102 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7104 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7106 if [ $? -ne 0 ]; then
7107 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7108 error "ldev failed to produce the correct output for mgs role!"
7111 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7113 run_test 97 "ldev returns correct ouput when querying based on role"
7118 local temp=$MDS_MOUNT_OPTS
7121 check_mount || error "mount failed"
7122 mountopt="user_xattr"
7123 for ((x = 1; x <= 400; x++)); do
7124 mountopt="$mountopt,user_xattr"
7126 remount_client $mountopt $MOUNT 2>&1 | grep "too long" ||
7127 error "Buffer overflow check failed"
7128 cleanup || error "cleanup failed"
7130 run_test 98 "Buffer-overflow check while parsing mount_opts"
7134 [[ $(facet_fstype ost1) != ldiskfs ]] &&
7135 { skip "ldiskfs only test" && return; }
7136 [[ $(lustre_version_code ost1) -ge $(version_code 2.8.57) ]] ||
7137 { skip "Need OST version at least 2.8.57" && return 0; }
7139 local ost_opts="$(mkfs_opts ost1 $(ostdevname 1)) \
7140 --reformat $(ostdevname 1) $(ostvdevname 1)"
7141 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" &&
7142 skip "meta_bg already set" && return
7145 if [[ ${!opts} != *mkfsoptions* ]]; then
7146 eval opts=\"${!opts} \
7147 --mkfsoptions='\\\"-O ^resize_inode,meta_bg\\\"'\"
7149 local val=${!opts//--mkfsoptions=\\\"/ \
7150 --mkfsoptions=\\\"-O ^resize_inode,meta_bg }
7154 echo "params: $opts"
7156 add ost1 $opts || error "add ost1 failed with new params"
7158 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" ||
7159 error "meta_bg is not set"
7163 run_test 99 "Adding meta_bg option"
7167 start_mds || error "MDS start failed"
7168 start_ost || error "unable to start OST"
7169 mount_client $MOUNT || error "client start failed"
7170 check_mount || error "check_mount failed"
7179 do_facet mgs 'lshowmount -v' | awk 'BEGIN {NR == 0; rc=1} /MGS:/ {rc=0}
7180 END {exit rc}' || error "lshowmount have no output MGS"
7182 do_facet mds1 'lshowmount -v' | awk 'BEGIN {NR == 2; rc=1} /-MDT0000:/
7183 {rc=0} END {exit rc}' || error "lshowmount have no output MDT0"
7185 do_facet ost1 'lshowmount -v' | awk 'BEGIN {NR == 4; rc=1} /-OST0000:/
7186 {rc=0} END {exit rc}' || error "lshowmount have no output OST0"
7188 cleanup || error "cleanup failed with $?"
7190 run_test 100 "check lshowmount lists MGS, MDT, OST and 0@lo"
7193 local createmany_oid
7194 local dev=$FSNAME-OST0000-osc-MDT0000
7197 createmany -o $DIR1/$tfile-%d 50000 &
7199 # MDT->OST reconnection causes MDT<->OST last_id synchornisation
7200 # via osp_precreate_cleanup_orphans.
7201 for ((i = 0; i < 100; i++)); do
7202 for ((k = 0; k < 10; k++)); do
7203 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;" \
7204 "$LCTL --device $dev activate"
7207 ls -asl $MOUNT | grep '???' &&
7208 (kill -9 $createmany_oid &>/dev/null; \
7209 error "File hasn't object on OST")
7211 kill -s 0 $createmany_oid || break
7213 wait $createmany_oid
7216 run_test 101 "Race MDT->OST reconnection with create"
7219 cleanup || error "cleanup failed with $?"
7221 local mds1dev=$(mdsdevname 1)
7222 local mds1mnt=$(facet_mntpt mds1)
7223 local mds1fstype=$(facet_fstype mds1)
7224 local mds1opts=$MDS_MOUNT_OPTS
7226 if [ $mds1fstype == ldiskfs ] &&
7227 ! do_facet mds1 test -b $mds1dev; then
7228 mds1opts=$(csa_add "$mds1opts" -o loop)
7230 if [[ $mds1fstype == zfs ]]; then
7231 import_zpool mds1 || return ${PIPESTATUS[0]}
7234 # unload all and only load libcfs to allow fail_loc setting
7235 do_facet mds1 lustre_rmmod || error "unable to unload modules"
7236 do_facet mds1 modprobe libcfs || error "libcfs not loaded"
7237 do_facet mds1 lsmod \| grep libcfs || error "libcfs not loaded"
7239 #define OBD_FAIL_OBDCLASS_MODULE_LOAD 0x60a
7240 do_facet mds1 "$LCTL set_param fail_loc=0x8000060a"
7242 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
7243 error "mdt start must fail"
7244 do_facet mds1 lsmod \| grep obdclass && error "obdclass must not load"
7246 do_facet mds1 "$LCTL set_param fail_loc=0x0"
7248 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts ||
7249 error "mdt start must not fail"
7251 cleanup || error "cleanup failed with $?"
7253 run_test 102 "obdclass module cleanup upon error"
7258 echo "rename $FSNAME to $newname"
7260 if [ ! combined_mgs_mds ]; then
7261 local facet=$(mgsdevname)
7264 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7265 error "(7) Fail to rename MGS"
7266 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7267 reimport_zpool mgs $newname-mgs
7271 for num in $(seq $MDSCOUNT); do
7272 local facet=$(mdsdevname $num)
7274 do_facet mds${num} \
7275 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7276 error "(8) Fail to rename MDT $num"
7277 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7278 reimport_zpool mds${num} $newname-mdt${num}
7282 for num in $(seq $OSTCOUNT); do
7283 local facet=$(ostdevname $num)
7285 do_facet ost${num} \
7286 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7287 error "(9) Fail to rename OST $num"
7288 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7289 reimport_zpool ost${num} $newname-ost${num}
7294 test_103_set_pool() {
7298 do_facet mgs $LCTL pool_add $FSNAME.$pname ${FSNAME}-$ost_x ||
7299 error "Fail to add $ost_x to $FSNAME.$pname"
7300 wait_update $HOSTNAME \
7301 "lctl get_param -n lov.$FSNAME-clilov-*.pools.$pname |
7302 grep $ost_x" "$FSNAME-${ost_x}_UUID" ||
7303 error "$ost_x is NOT in pool $FSNAME.$pname"
7306 test_103_check_pool() {
7307 local save_fsname=$1
7310 stat $DIR/$tdir/test-framework.sh ||
7311 error "($errno) Fail to stat"
7312 do_facet mgs $LCTL pool_list $FSNAME.pool1 ||
7313 error "($errno) Fail to list $FSNAME.pool1"
7314 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname ||
7315 error "($errno) Fail to list $FSNAME.$save_fsname"
7316 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname |
7317 grep ${FSNAME}-OST0000 ||
7318 error "($errno) List $FSNAME.$save_fsname is invalid"
7320 local pname=$($LFS getstripe --pool $DIR/$tdir/d0)
7321 [ "$pname" = "$save_fsname" ] ||
7322 error "($errno) Unexpected pool name $pname"
7326 check_mount_and_prep
7328 mkdir $DIR/$tdir || error "(1) Fail to mkdir $DIR/$tdir"
7329 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir ||
7330 error "(2) Fail to copy test-framework.sh"
7332 do_facet mgs $LCTL pool_new $FSNAME.pool1 ||
7333 error "(3) Fail to create $FSNAME.pool1"
7334 # name the pool name as the fsname
7335 do_facet mgs $LCTL pool_new $FSNAME.$FSNAME ||
7336 error "(4) Fail to create $FSNAME.$FSNAME"
7338 test_103_set_pool $FSNAME OST0000
7340 $SETSTRIPE -p $FSNAME $DIR/$tdir/d0 ||
7341 error "(6) Fail to setstripe on $DIR/$tdir/d0"
7346 test_renamefs mylustre
7348 local save_fsname=$FSNAME
7352 test_103_check_pool $save_fsname 7
7354 if [ $OSTCOUNT -ge 2 ]; then
7355 test_103_set_pool $save_fsname OST0001
7358 $SETSTRIPE -p $save_fsname $DIR/$tdir/f0 ||
7359 error "(16) Fail to setstripe on $DIR/$tdir/f0"
7368 test_103_check_pool $save_fsname 17
7372 test_renamefs $save_fsname
7378 run_test 103 "rename filesystem name"
7380 test_104() { # LU-6952
7381 local mds_mountopts=$MDS_MOUNT_OPTS
7382 local ost_mountopts=$OST_MOUNT_OPTS
7383 local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
7384 local lctl_ver=$(do_facet $SINGLEMDS $LCTL --version |
7387 [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
7388 { skip "this test needs utils above 2.9.55" && return 0; }
7390 # specify "acl" in mount options used by mkfs.lustre
7391 if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
7392 MDS_MOUNT_FS_OPTS="acl,user_xattr"
7395 MDS_MOUNT_FS_OPTS="${MDS_MOUNT_FS_OPTS},acl,user_xattr"
7398 echo "mountfsopt: $MDS_MOUNT_FS_OPTS"
7400 #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
7402 if [ -z "$MDS_MOUNT_OPTS" ]; then
7403 MDS_MOUNT_OPTS="-o noacl"
7405 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7408 for num in $(seq $MDSCOUNT); do
7409 start mds$num $(mdsdevname $num) $MDS_MOUNT_OPTS ||
7410 error "Failed to start MDS"
7413 for num in $(seq $OSTCOUNT); do
7414 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
7415 error "Failed to start OST"
7419 setfacl -m "d:$RUNAS_ID:rwx" $MOUNT &&
7420 error "ACL is applied when FS is mounted with noacl."
7422 MDS_MOUNT_OPTS=$mds_mountopts
7423 OST_MOUNT_OPTS=$ost_mountopts
7424 MDS_MOUNT_FS_OPTS=$mds_mountfsopts
7429 run_test 104 "Make sure user defined options are reflected in mount"
7431 error_and_umount() {
7442 mount --bind $DIR $TMP/$tdir || error "mount bind mnt pt failed"
7443 rm -f $TMP/$tdir/$tfile
7444 rm -f $TMP/$tdir/${tfile}1
7446 # Files should not be created in ro bind mount point
7447 # remounting from rw to ro
7448 mount -o remount,ro $TMP/$tdir ||
7449 error_and_umount "readonly remount of bind mnt pt failed"
7450 touch $TMP/$tdir/$tfile &&
7451 error_and_umount "touch succeeds on ro bind mnt pt"
7452 [ -e $TMP/$tdir/$tfile ] &&
7453 error_and_umount "file created on ro bind mnt pt"
7455 # Files should be created in rw bind mount point
7456 # remounting from ro to rw
7457 mount -o remount,rw $TMP/$tdir ||
7458 error_and_umount "read-write remount of bind mnt pt failed"
7459 touch $TMP/$tdir/${tfile}1 ||
7460 error_and_umount "touch fails on rw bind mnt pt"
7461 [ -e $TMP/$tdir/${tfile}1 ] ||
7462 error_and_umount "file not created on rw bind mnt pt"
7463 umount $TMP/$tdir || error "umount of bind mnt pt failed"
7465 cleanup || error "cleanup failed with $?"
7467 run_test 105 "check file creation for ro and rw bind mnt pt"
7470 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.50) ]] ||
7471 { skip "Need MDS version > 2.10.50"; return; }
7473 start_mgsmds || error "start_mgsmds failed"
7474 start_ost || error "unable to start OST"
7476 # add unknown configuration parameter.
7477 local PARAM="$FSNAME-OST0000.ost.unknown_param=50"
7478 do_facet mgs "$LCTL conf_param $PARAM"
7479 cleanup_nocli || error "cleanup_nocli failed with $?"
7482 # unknown param should be ignored while mounting.
7483 start_ost || error "unable to start OST after unknown param set"
7485 cleanup || error "cleanup failed with $?"
7487 run_test 107 "Unknown config param should not fail target mounting"
7489 if ! combined_mgs_mds ; then
7495 # restore the values of MDSSIZE and OSTSIZE
7496 MDSSIZE=$STORED_MDSSIZE
7497 OSTSIZE=$STORED_OSTSIZE