7 # bug number for skipped test: LU-7005
8 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 50i"
9 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
13 if [ -r /etc/SuSE-release ]
15 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
16 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
18 if [ $vers -eq 11 ] && [ $patchlev -eq 2 ]
26 if is_sles11; then # LU-2181
27 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 23a 34b"
30 if [ "$FAILURE_MODE" = "HARD" ]; then
31 CONFIG_EXCEPTIONS="24a " &&
32 echo "Except the tests: $CONFIG_EXCEPTIONS for " \
33 "FAILURE_MODE=$FAILURE_MODE, b=23573" &&
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
37 # bug number for skipped test:
38 # a tool to create lustre filesystem images
39 ALWAYS_EXCEPT="32newtarball $ALWAYS_EXCEPT"
42 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
44 PTLDEBUG=${PTLDEBUG:--1}
46 LUSTRE=${LUSTRE:-$(dirname $0)/..}
47 RLUSTRE=${RLUSTRE:-$LUSTRE}
48 export MULTIOP=${MULTIOP:-multiop}
50 . $LUSTRE/tests/test-framework.sh
52 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
54 # use small MDS + OST size to speed formatting time
55 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
56 # STORED_MDSSIZE is used in test_18
57 STORED_MDSSIZE=$MDSSIZE
58 STORED_OSTSIZE=$OSTSIZE
70 if ! combined_mgs_mds; then
71 # bug number for skipped test: 23954
72 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
75 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
76 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
77 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
80 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
81 # bug number for skipped test: LU-4444
82 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 69"
87 require_dsh_mds || exit 0
88 require_dsh_ost || exit 0
90 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45 69"
95 # The MGS must be started before the OSTs for a new fs, so start
96 # and stop to generate the startup logs.
99 wait_osc_import_state mds ost FULL
104 reformat_and_config() {
106 if ! combined_mgs_mds ; then
112 writeconf_or_reformat() {
113 # There are at most 2 OSTs for write_conf test
114 # who knows if/where $TUNEFS is installed?
115 # Better reformat if it fails...
116 writeconf_all $MDSCOUNT 2 ||
117 { echo "tunefs failed, reformatting instead" &&
118 reformat_and_config && return 0; }
128 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
134 local dev=$(mdsdevname $num)
137 echo "start mds service on `facet_active_host $facet`"
138 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
144 local dev=$(mdsdevname $num)
147 echo "stop mds service on `facet_active_host $facet`"
148 # These tests all use non-failover stop
149 stop $facet -f || return 97
155 for num in $(seq $MDSCOUNT); do
156 start_mdt $num $@ || return 94
161 if ! combined_mgs_mds ; then
169 for num in $(seq $MDSCOUNT); do
170 stop_mdt $num || return 97
175 echo "stop mgs service on `facet_active_host mgs`"
176 # These tests all use non-failover stop
177 stop mgs -f || return 97
181 echo "start ost1 service on `facet_active_host ost1`"
182 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
186 echo "stop ost1 service on `facet_active_host ost1`"
187 # These tests all use non-failover stop
188 stop ost1 -f || return 98
192 echo "start ost2 service on `facet_active_host ost2`"
193 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
197 echo "stop ost2 service on `facet_active_host ost2`"
198 # These tests all use non-failover stop
199 stop ost2 -f || return 93
204 echo "mount $FSNAME on ${MOUNTPATH}....."
205 zconf_mount $(hostname) $MOUNTPATH || return 96
209 local mountopt="remount,$1"
211 echo "remount '$1' lustre on ${MOUNTPATH}....."
212 zconf_mount $(hostname) $MOUNTPATH "$mountopt" || return 96
217 echo "umount lustre on ${MOUNTPATH}....."
218 zconf_umount $(hostname) $MOUNTPATH || return 97
221 manual_umount_client(){
224 echo "manual umount lustre on ${MOUNT}...."
225 do_facet client "umount -d ${FORCE} $MOUNT"
231 start_mds || error "MDT start failed"
232 start_ost || error "Unable to start OST1"
233 mount_client $MOUNT || error "client start failed"
234 client_up || error "client_up failed"
243 unload_modules_conf () {
244 if combined_mgs_mds || ! local_mode; then
245 unload_modules || return 1
250 stop_ost || return 202
251 stop_mds || return 201
252 unload_modules_conf || return 203
256 umount_client $MOUNT || return 200
257 cleanup_nocli || return $?
262 echo "umount $MOUNT2 ..."
263 umount $MOUNT2 || true
264 echo "stopping fs2mds ..."
265 stop fs2mds -f || true
266 echo "stopping fs2ost ..."
267 stop fs2ost -f || true
271 do_facet client "cp /etc/passwd $DIR/a" || return 71
272 do_facet client "rm $DIR/a" || return 72
273 # make sure lustre is actually mounted (touch will block,
274 # but grep won't, so do it after)
275 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
276 echo "setup single mount lustre success"
280 do_facet client "touch $DIR/a" || return 71
281 do_facet client "rm $DIR/a" || return 72
282 do_facet client "touch $DIR2/a" || return 73
283 do_facet client "rm $DIR2/a" || return 74
284 echo "setup double mount lustre success"
289 if [ "$ONLY" == "setup" ]; then
294 if [ "$ONLY" == "cleanup" ]; then
301 #create single point mountpoint
307 check_mount || error "check_mount failed"
308 cleanup || error "cleanup failed with $?"
310 run_test 0 "single mount setup"
313 start_mds || error "MDS start failed"
314 start_ost || error "unable to start OST"
315 echo "start ost second time..."
316 start_ost && error "2nd OST start should fail"
317 mount_client $MOUNT || error "client start failed"
318 check_mount || error "check_mount failed"
319 cleanup || error "cleanup failed with $?"
321 run_test 1 "start up ost twice (should return errors)"
324 start_mds || error "MDT start failed"
325 echo "start mds second time.."
326 start_mds && error "2nd MDT start should fail"
327 start_ost || error "OST start failed"
328 mount_client $MOUNT || error "mount_client failed to start client"
329 check_mount || error "check_mount failed"
330 cleanup || error "cleanup failed with $?"
332 run_test 2 "start up mds twice (should return err)"
336 #mount.lustre returns an error if already in mtab
337 mount_client $MOUNT && error "2nd client mount should fail"
338 check_mount || error "check_mount failed"
339 cleanup || error "cleanup failed with $?"
341 run_test 3 "mount client twice (should return err)"
345 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
346 stop_ost || error "Unable to stop OST1"
349 # ok for ost to fail shutdown
350 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
351 error "cleanup failed with $?"
354 run_test 4 "force cleanup ost, then cleanup"
356 test_5a() { # was test_5
358 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
359 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
361 stop_mds || error "Unable to stop MDS"
363 # cleanup may return an error from the failed
364 # disconnects; for now I'll consider this successful
365 # if all the modules have unloaded.
369 echo "killing umount"
370 kill -TERM $UMOUNT_PID
371 echo "waiting for umount to finish"
373 if grep " $MOUNT " /proc/mounts; then
374 echo "test 5: /proc/mounts after failed umount"
378 echo "killing umount"
379 kill -TERM $UMOUNT_PID
380 echo "waiting for umount to finish"
382 grep " $MOUNT " /proc/mounts &&
383 error "/proc/mounts after second umount"
386 # manual_mount_client may fail due to umount succeeding above
388 # stop_mds is a no-op here, and should not fail
389 cleanup_nocli || error "cleanup_nocli failed with $?"
390 # df may have lingering entry
392 # mtab may have lingering entry
396 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
398 grep -q $MOUNT" " /etc/mtab || break
399 echo "Waiting /etc/mtab updated ... "
400 WAIT=$(( WAIT + sleep))
402 [ "$WAIT" -eq "$MAX_WAIT" ] &&
403 error "/etc/mtab is not updated in $WAIT secs"
404 echo "/etc/mtab updated in $WAIT secs"
406 run_test 5a "force cleanup mds, then cleanup"
414 grep " $MOUNT " /etc/mtab &&
415 error false "unexpected entry in mtab before mount" && return 10
417 start_ost || error "OST start failed"
418 if ! combined_mgs_mds ; then
419 trap cleanup_5b EXIT ERR
420 start_mds || error "MDS start failed"
424 mount_client $MOUNT && error "mount_client $MOUNT should fail"
425 grep " $MOUNT " /etc/mtab &&
426 error "$MOUNT entry in mtab after failed mount"
428 # stop_mds is a no-op here, and should not fail
429 cleanup_nocli || error "cleanup_nocli failed with $?"
430 if ! combined_mgs_mds ; then
434 run_test 5b "Try to start a client with no MGS (should return errs)"
437 grep " $MOUNT " /etc/mtab &&
438 error false "unexpected entry in mtab before mount" && return 10
440 start_mds || error "MDS start failed"
441 start_ost || error "OST start failed"
442 local oldfs="${FSNAME}"
443 FSNAME="wrong.${FSNAME}"
444 mount_client $MOUNT || :
446 grep " $MOUNT " /etc/mtab &&
447 error "$MOUNT entry in mtab after failed mount"
449 cleanup_nocli || error "cleanup_nocli failed with $?"
451 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
454 grep " $MOUNT " /etc/mtab &&
455 error false "unexpected entry in mtab before mount" && return 10
457 start_ost || error "OST start failed"
458 start_mds || error "MDS start failed"
459 stop_ost || error "Unable to stop OST1"
460 mount_client $MOUNT || error "mount_client $MOUNT failed"
461 cleanup || error "cleanup_nocli failed with $?"
462 grep " $MOUNT " /etc/mtab &&
463 error "$MOUNT entry in mtab after unmount"
466 run_test 5d "mount with ost down"
469 grep " $MOUNT " /etc/mtab &&
470 error false "unexpected entry in mtab before mount" && return 10
472 start_mds || error "MDS start failed"
473 start_ost || error "OST start failed"
475 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
476 do_facet client "$LCTL set_param fail_loc=0x80000506"
477 mount_client $MOUNT || echo "mount failed (not fatal)"
478 cleanup || error "cleanup failed with $?"
479 grep " $MOUNT " /etc/mtab &&
480 error "$MOUNT entry in mtab after unmount"
483 run_test 5e "delayed connect, don't crash (bug 10268)"
486 if combined_mgs_mds ; then
487 skip "combined mgs and mds"
491 grep " $MOUNT " /etc/mtab &&
492 error false "unexpected entry in mtab before mount" && return 10
495 start_ost || error "OST start failed"
496 mount_client $MOUNT &
498 echo client_mount pid is $pid
502 if ! ps -f -p $pid >/dev/null; then
505 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
506 error "mount returns $rc, expected to hang"
508 cleanup || error "cleanup failed with $?"
513 start_mds || error "start MDS failed"
515 # mount should succeed after start mds
517 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
518 cleanup || error "final call to cleanup failed with rc $?"
520 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
525 mount_client $MOUNT || error "mount_client $MOUNT failed"
526 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
527 cleanup || error "cleanup failed with rc $?"
529 run_test 6 "manual umount, then mount again"
534 cleanup_nocli || error "cleanup_nocli failed with $?"
536 run_test 7 "manual umount, then cleanup"
540 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
541 check_mount2 || error "check_mount2 failed"
542 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
543 cleanup || error "cleanup failed with rc $?"
545 run_test 8 "double mount setup"
548 start_ost || error "OST start failed"
550 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
551 error "do_facet ost1 set_param inode trace failed."
552 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
553 error "do_facet ost1 set_param debug mds ost failed."
555 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
556 if [ "$CHECK_PTLDEBUG" ] && { \
557 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
558 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
559 echo "lnet.debug success"
561 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
563 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
564 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
565 echo "lnet.subsystem_debug success"
567 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
569 stop_ost || error "Unable to stop OST1"
571 run_test 9 "test ptldebug and subsystem for mkfs"
579 do_facet $facet "test -b $dev" || rc=1
580 if [[ "$size" ]]; then
581 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k \
582 count=1 skip=$size 2>&1" |
583 awk '($3 == "in") { print $1 }')
584 [[ $in = "1+0" ]] || rc=1
590 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
591 # But with new MDS stack we don't care about the mode of local objects
592 # anymore, so this test is removed. See bug 22944 for more details.
596 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
597 skip "Only applicable to ldiskfs-based MDTs"
602 check_mount || error "check_mount failed"
603 cleanup || error "cleanup failed with rc $?"
605 echo "Remove mds config log"
606 if ! combined_mgs_mds ; then
610 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
611 $(mgsdevname) || return \$?" ||
612 error "do_facet mgs failed with $?"
614 if ! combined_mgs_mds ; then
618 start_ost || error "OST start failed"
619 start_mds && error "MDS start succeeded, but should fail"
622 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
625 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
626 skip "Only applicable to ldiskfs-based MDTs"
630 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
635 # check if current MDSSIZE is large enough
636 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
637 log "use MDSSIZE=$MDSSIZE"
639 # check if the global config has a large enough MDSSIZE
640 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
641 [ $STORED_MDSSIZE -ge $MIN ] &&
642 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
643 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
645 # check if the block device is large enough
646 is_blkdev $SINGLEMDS $MDSDEV $MIN
647 local large_enough=$?
648 if [ -n "$OK" ]; then
649 [ $large_enough -ne 0 ] && OK=""
651 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
652 log "use device $MDSDEV with MIN=$MIN"
655 # check if a loopback device has enough space for fs metadata (5%)
657 if [ -z "$OK" ]; then
658 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
659 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
660 awk '($1 != "Filesystem") { print $4 }')
661 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
662 OK=1 && myMDSSIZE=$MIN &&
663 log "use file $MDSDEV with MIN=$MIN"
666 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
668 echo "mount mds with large journal..."
670 local OLD_MDSSIZE=$MDSSIZE
674 echo "mount lustre system..."
676 check_mount || error "check_mount failed"
678 echo "check journal size..."
679 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
680 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
681 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
683 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
686 cleanup || error "cleanup failed with rc $?"
691 run_test 18 "check mkfs creates large journals"
694 start_mds || error "MDS start failed"
695 stop_mds || error "Unable to stop MDS"
697 run_test 19a "start/stop MDS without OSTs"
700 start_ost || error "Unable to start OST1"
701 stop_ost || error "Unable to stop OST1"
703 run_test 19b "start/stop OSTs without MDS"
706 # first format the ost/mdt
707 start_mds || error "MDS start failed"
708 start_ost || error "Unable to start OST1"
709 mount_client $MOUNT || error "mount_client $MOUNT failed"
710 check_mount || error "check_mount failed"
711 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
712 remount_client ro $MOUNT || error "remount_client with ro failed"
713 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
714 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
715 remount_client rw $MOUNT || error "remount_client with rw failed"
716 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
717 MCNT=$(grep -c $MOUNT /etc/mtab)
718 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
720 stop_mds || error "Unable to stop MDS"
721 stop_ost || error "Unable to stop OST1"
723 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
726 start_mds || error "MDS start failed"
727 start_ost || error "unable to start OST1"
728 wait_osc_import_state mds ost FULL
729 stop_ost || error "unable to stop OST1"
730 stop_mds || error "unable to stop MDS"
732 run_test 21a "start mds before ost, stop ost first"
735 start_ost || error "unable to start OST1"
736 start_mds || error "MDS start failed"
737 wait_osc_import_state mds ost FULL
738 stop_mds || error "unable to stop MDS"
739 stop_ost || error "unable to stop OST1"
741 run_test 21b "start ost before mds, stop mds first"
744 start_ost || error "Unable to start OST1"
745 start_mds || error "MDS start failed"
746 start_ost2 || error "Unable to start OST2"
747 wait_osc_import_state mds ost2 FULL
748 stop_ost || error "Unable to stop OST1"
749 stop_ost2 || error "Unable to stop OST2"
750 stop_mds || error "Unable to stop MDS"
751 #writeconf to remove all ost2 traces for subsequent tests
752 writeconf_or_reformat
754 run_test 21c "start mds between two osts, stop mds last"
757 if combined_mgs_mds ; then
758 skip "need separate mgs device" && return 0
764 start_mgs || error "unable to start MGS"
765 start_ost || error "unable to start OST1"
766 start_ost2 || error "unable to start OST2"
767 start_mds || error "MDS start failed"
768 wait_osc_import_state mds ost2 FULL
770 stop_ost || error "Unable to stop OST1"
771 stop_ost2 || error "Unable to stop OST2"
772 stop_mds || error "Unable to stop MDS"
774 #writeconf to remove all ost2 traces for subsequent tests
775 writeconf_or_reformat
776 start_mgs || error "unable to start MGS"
778 run_test 21d "start mgs then ost and then mds"
781 MGSNID="$saved_mgsnid"
783 echo "stopping fs2mgs ..."
784 stop $fs2mgs -f || true
787 test_21e() { # LU-5863
788 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
789 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
790 skip_env "mixed loopback and real device not working" && return
793 local fs2mdsdev=$(mdsdevname 1_2)
794 local fs2ostdev=$(ostdevname 1_2)
795 local fs3ostdev=$(ostdevname 2_2)
797 local fs2mdsvdev=$(mdsvdevname 1_2)
798 local fs2ostvdev=$(ostvdevname 1_2)
799 local fs3ostvdev=$(ostvdevname 2_2)
801 # temporarily use fs3ost as fs2mgs
803 local fs2mgsdev=$fs3ostdev
804 local fs2mgsvdev=$fs3ostvdev
806 local fsname=test1234
808 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
809 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
810 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
811 error "start fs2mgs failed"
813 local saved_mgsnid="$MGSNID"
814 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
816 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
817 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
818 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
819 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
821 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
822 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
824 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
825 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
826 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
830 run_test 21e "separate MGS and MDS"
833 start_mds || error "MDS start failed"
835 echo "Client mount with ost in logs, but none running"
836 start_ost || error "unable to start OST1"
837 # wait until mds connected to ost and open client connection
838 wait_osc_import_state mds ost FULL
839 stop_ost || error "unable to stop OST1"
840 mount_client $MOUNT || error "mount_client $MOUNT failed"
841 # check_mount will block trying to contact ost
842 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
843 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
847 echo "Client mount with a running ost"
848 start_ost || error "unable to start OST1"
850 # if gss enabled, wait full time to let connection from
851 # mds to ost be established, due to the mismatch between
852 # initial connect timeout and gss context negotiation timeout.
853 # This perhaps could be remove after AT landed.
854 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
855 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
857 mount_client $MOUNT || error "mount_client $MOUNT failed"
858 wait_osc_import_state mds ost FULL
859 wait_osc_import_state client ost FULL
860 check_mount || error "check_mount failed"
863 cleanup || error "cleanup failed with rc $?"
865 run_test 22 "start a client before osts (should return errs)"
867 test_23a() { # was test_23
870 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
871 # force down client so that recovering mds waits for reconnect
872 local running=$(grep -c $MOUNT /proc/mounts) || true
873 if [ $running -ne 0 ]; then
874 echo "Stopping client $MOUNT (opts: -f)"
878 # enter recovery on failed mds
879 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
880 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
881 # try to start a new client
882 mount_client $MOUNT &
884 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
885 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
886 grep -v grep | awk '{print $2}')
887 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
889 ps --ppid $MOUNT_LUSTRE_PID
890 echo "waiting for mount to finish"
892 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
893 # SIGTERM works but it does not spread to offspring processses
894 kill -s TERM $MOUNT_PID
895 kill -s TERM $MOUNT_LUSTRE_PID
896 # we can not wait $MOUNT_PID because it is not a child of this shell
902 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
904 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
905 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
908 [ -z "$PID1" -a -z "$PID2" ] && break
909 echo "waiting for mount to finish ... "
910 WAIT=$(( WAIT + sleep))
912 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
913 error "MOUNT_PID $MOUNT_PID and "\
914 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
917 stop_mds || error "stopping MDSes failed"
918 stop_ost || error "stopping OSSes failed"
920 run_test 23a "interrupt client during recovery mount delay"
925 test_23b() { # was test_23
926 start_mds || error "MDS start failed"
927 start_ost || error "Unable to start OST1"
928 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
929 $LCTL set_param fail_loc=0x80000313
931 cleanup || error "cleanup failed with rc $?"
933 run_test 23b "Simulate -EINTR during mount"
936 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
938 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
939 is_blkdev $SINGLEMDS $MDSDEV &&
940 skip_env "mixed loopback and real device not working" && return
943 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
945 local fs2mdsdev=$(mdsdevname 1_2)
946 local fs2ostdev=$(ostdevname 1_2)
947 local fs2mdsvdev=$(mdsvdevname 1_2)
948 local fs2ostvdev=$(ostvdevname 1_2)
950 # test 8-char fsname as well
951 local FSNAME2=test1234
953 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
954 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
956 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
957 --reformat $fs2ostdev $fs2ostvdev || exit 10
960 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
961 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
962 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
963 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
965 check_mount || error "check_mount failed"
966 # files written on 1 should not show up on 2
967 cp /etc/passwd $DIR/$tfile
969 [ -e $MOUNT2/$tfile ] && error "File bleed"
972 cp /etc/passwd $MOUNT2/$tfile ||
973 error "cp /etc/passwd $MOUNT2/$tfile failed"
974 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
975 # 2 is actually mounted
976 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
978 facet_failover fs2mds
979 facet_failover fs2ost
982 # the MDS must remain up until last MDT
984 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
985 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
986 [ -z "$MDS" ] && error "No MDT"
988 cleanup_nocli || error "cleanup_nocli failed with rc $?"
990 run_test 24a "Multiple MDTs on a single node"
993 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
995 if [ -z "$fs2mds_DEV" ]; then
996 local dev=${SINGLEMDS}_dev
998 is_blkdev $SINGLEMDS $MDSDEV &&
999 skip_env "mixed loopback and real device not working" && return
1002 local fs2mdsdev=$(mdsdevname 1_2)
1003 local fs2mdsvdev=$(mdsvdevname 1_2)
1005 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1006 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1008 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS &&
1009 error "start MDS should fail"
1011 cleanup || error "cleanup failed with rc $?"
1013 run_test 24b "Multiple MGSs on a single node (should return err)"
1017 check_mount || error "check_mount failed"
1018 local MODULES=$($LCTL modules | awk '{ print $2 }')
1019 rmmod $MODULES 2>/dev/null || true
1020 cleanup || error "cleanup failed with $?"
1022 run_test 25 "Verify modules are referenced"
1026 # we need modules before mount for sysctl, so make sure...
1027 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1028 #define OBD_FAIL_MDS_FS_SETUP 0x135
1029 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1030 start_mds && error "MDS started but should not have started"
1031 $LCTL get_param -n devices
1032 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1033 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1034 # start mds to drop writeconf setting
1035 start_mds || error "Unable to start MDS"
1036 stop_mds || error "Unable to stop MDS"
1037 unload_modules_conf || error "unload_modules_conf failed with $?"
1039 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1042 start_ost || error "Unable to start OST1"
1043 start_mds || error "Unable to start MDS"
1044 echo "Requeue thread should have started: "
1045 ps -e | grep ll_cfg_requeue
1046 set_conf_param_and_check ost1 \
1047 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1048 "$FSNAME-OST0000.ost.client_cache_seconds" ||
1049 error "set_conf_param_and_check ost1 failed"
1050 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1052 run_test 27a "Reacquire MGS lock if OST started first"
1057 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1058 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1060 facet_failover $SINGLEMDS
1061 set_conf_param_and_check $SINGLEMDS \
1062 "$LCTL get_param -n mdt.$device.identity_acquire_expire" \
1063 "$device.mdt.identity_acquire_expire" ||
1064 error "set_conf_param_and_check $SINGLEMDS failed"
1065 set_conf_param_and_check client \
1066 "$LCTL get_param -n mdc.$device-mdc-*.max_rpcs_in_flight"\
1067 "$device.mdc.max_rpcs_in_flight" ||
1068 error "set_conf_param_and_check client failed"
1070 cleanup || error "cleanup failed with $?"
1072 run_test 27b "Reacquire MGS lock after failover"
1076 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1077 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1079 FINAL=$(($ORIG + 1))
1080 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1081 error "first set_conf_param_and_check client failed"
1082 FINAL=$(($FINAL + 1))
1083 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1084 error "second set_conf_param_and_check client failed"
1085 umount_client $MOUNT || error "umount_client $MOUNT failed"
1086 mount_client $MOUNT || error "mount_client $MOUNT failed"
1088 if [ $RESULT -ne $FINAL ]; then
1089 error "New config not seen: wanted $FINAL got $RESULT"
1091 echo "New config success: got $RESULT"
1093 set_conf_param_and_check client "$TEST" "$PARAM" $ORIG ||
1094 error "third set_conf_param_and_check client failed"
1095 cleanup || error "cleanup failed with rc $?"
1097 run_test 28 "permanent parameter setting"
1099 test_28a() { # LU-4221
1100 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1101 { skip "Need OST version at least 2.5.52" && return 0; }
1102 [ "$(facet_fstype ost1)" = "zfs" ] &&
1103 skip "LU-4221: no such proc params for ZFS OSTs" && return
1110 local device="$FSNAME-OST0000"
1114 # In this test we will set three kinds of proc parameters with
1116 # 1. the ones moved from the OFD to the OSD, and only their
1117 # symlinks kept in obdfilter
1118 # 2. non-symlink ones in the OFD
1119 # 3. non-symlink ones in the OSD
1122 # prepare a symlink parameter in the OFD
1123 name="writethrough_cache_enable"
1124 param="$device.ost.$name"
1125 cmd="$LCTL get_param -n obdfilter.$device.$name"
1127 # conf_param the symlink parameter in the OFD
1128 old=$(do_facet ost1 $cmd)
1129 new=$(((old + 1) % 2))
1130 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1131 error "lctl conf_param $device.ost.$param=$new failed"
1133 # conf_param the target parameter in the OSD
1134 param="$device.osd.$name"
1135 cmd="$LCTL get_param -n osd-*.$device.$name"
1136 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1137 error "lctl conf_param $device.osd.$param=$old failed"
1140 # prepare a non-symlink parameter in the OFD
1141 name="client_cache_seconds"
1142 param="$device.ost.$name"
1143 cmd="$LCTL get_param -n obdfilter.$device.$name"
1145 # conf_param the parameter in the OFD
1146 old=$(do_facet ost1 $cmd)
1148 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1149 error "lctl conf_param $device.ost.$param=$new failed"
1150 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1151 error "lctl conf_param $device.ost.$param=$old failed"
1154 # prepare a non-symlink parameter in the OSD
1156 param="$device.osd.$name"
1157 cmd="$LCTL get_param -n osd-*.$device.$name"
1159 # conf_param the parameter in the OSD
1160 old=$(do_facet ost1 $cmd)
1161 new=$(((old + 1) % 2))
1162 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1163 error "lctl conf_param $device.osd.$param=$new failed"
1164 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1165 error "lctl conf_param $device.osd.$param=$old failed"
1167 cleanup || error "cleanup failed with $?"
1169 run_test 28a "set symlink parameters permanently with conf_param"
1172 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1173 setup > /dev/null 2>&1
1174 start_ost2 || error "Unable to start OST2"
1177 local PARAM="$FSNAME-OST0001.osc.active"
1178 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1179 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1181 ACTV=$($LCTL get_param -n $PROC_ACT)
1183 set_conf_param_and_check client \
1184 "$LCTL get_param -n $PROC_ACT" "$PARAM" $DEAC ||
1185 error "set_conf_param_and_check client failed"
1186 # also check ost_server_uuid status
1187 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1188 if [ -z "$RESULT" ]; then
1189 error "Client not deactivated: $($LCTL get_param \
1192 echo "Live client success: got $RESULT"
1196 for num in $(seq $MDSCOUNT); do
1197 local mdtosc=$(get_mdtosc_proc_path mds${num} $FSNAME-OST0001)
1198 local MPROC="osc.$mdtosc.active"
1203 RESULT=$(do_facet mds${num} "$LCTL get_param -n $MPROC")
1204 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1205 if [ $RESULT -eq $DEAC ]; then
1206 echo -n "MDT deactivated also after"
1207 echo "$WAIT sec (got $RESULT)"
1211 if [ $WAIT -eq $MAX ]; then
1212 error "MDT active: wanted $DEAC got $RESULT"
1214 echo "Waiting $(($MAX - $WAIT))secs for MDT deactivated"
1217 # test new client starts deactivated
1218 umount_client $MOUNT || error "umount_client $MOUNT failed"
1219 mount_client $MOUNT || error "mount_client $MOUNT failed"
1220 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1221 if [ -z "$RESULT" ]; then
1222 error "New client start active: $(lctl get_param -n $PROC_UUID)"
1224 echo "New client success: got $RESULT"
1227 # make sure it reactivates
1228 set_conf_param_and_check client \
1229 "$LCTL get_param -n $PROC_ACT" "$PARAM" $ACTV ||
1230 error "lctl get_param $PROC_ACT $PARAM $ACTV failed"
1232 umount_client $MOUNT
1233 stop_ost2 || error "Unable to stop OST2"
1234 cleanup_nocli || error "cleanup_nocli failed with $?"
1235 #writeconf to remove all ost2 traces for subsequent tests
1236 writeconf_or_reformat
1238 run_test 29 "permanently remove an OST"
1243 echo Big config llog
1244 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1246 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1247 for i in ${LIST[@]}; do
1248 set_conf_param_and_check client "$TEST" \
1249 "$FSNAME.llite.max_read_ahead_whole_mb" $i ||
1250 error "Set $FSNAME.llite.max_read_ahead_whole_mb failed"
1252 # make sure client restart still works
1253 umount_client $MOUNT
1254 mount_client $MOUNT || error "mount_client $MOUNT failed"
1255 [ "$($TEST)" -ne "$i" ] &&
1256 error "Param didn't stick across restart $($TEST) != $i"
1259 echo Erase parameter setting
1260 do_facet mgs "$LCTL conf_param \
1261 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1262 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1263 umount_client $MOUNT
1264 mount_client $MOUNT || error "mount_client $MOUNT failed"
1266 echo "deleted (default) value=$FINAL, orig=$ORIG"
1267 # assumes this parameter started at the default value
1268 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1270 cleanup || error "cleanup failed with rc $?"
1272 run_test 30a "Big config llog and conf_param deletion"
1277 local orignids=$($LCTL get_param -n \
1278 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1280 local orignidcount=$(echo "$orignids" | wc -w)
1282 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1283 # numerical part of it. Hopefully that's not already a failover address
1285 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1287 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1288 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1289 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1290 echo "Using fake nid $NEW"
1292 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1293 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1294 set_conf_param_and_check client "$TEST" \
1295 "$FSNAME-OST0000.failover.node" $NEW ||
1296 error "didn't add failover nid $NEW"
1297 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1300 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1301 echo "should have $((orignidcount + 1)) entries \
1302 in failover nids string, have $NIDCOUNT"
1303 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1304 error "Failover nid not added"
1306 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" ||
1307 error "conf_param delete failed"
1308 umount_client $MOUNT
1309 mount_client $MOUNT || error "mount_client $MOUNT failed"
1311 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1314 NIDCOUNT=$(echo "$NIDS" | wc -w)
1315 echo "only $orignidcount final entries should remain \
1316 in failover nids string, have $NIDCOUNT"
1317 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1319 cleanup || error "cleanup failed with rc $?"
1321 run_test 30b "Remove failover nids"
1323 test_31() { # bug 10734
1324 # ipaddr must not exist
1325 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1326 cleanup || error "cleanup failed with rc $?"
1328 run_test 31 "Connect to non-existent node (shouldn't crash)"
1332 T32_BLIMIT=20480 # Kbytes
1336 # This is not really a test but a tool to create new disk
1337 # image tarballs for the upgrade tests.
1339 # Disk image tarballs should be created on single-node
1340 # clusters by running this test with default configurations
1341 # plus a few mandatory environment settings that are verified
1342 # at the beginning of the test.
1344 test_32newtarball() {
1348 local tmp=$TMP/t32_image_create
1350 if [ $FSNAME != t32fs -o $MDSCOUNT -ne 1 -o \
1351 \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o $OSTCOUNT -ne 1 -o \
1352 -z "$OSTDEV1" ]; then
1353 error "Needs FSNAME=t32fs MDSCOUNT=1 MDSDEV1=<nonexistent_file>" \
1354 "(or MDSDEV, in the case of b1_8) OSTCOUNT=1" \
1355 "OSTDEV1=<nonexistent_file>"
1359 echo "Found stale $tmp"
1363 mkdir $tmp/src || return 1
1364 tar cf - -C $src . | tar xf - -C $tmp/src
1365 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1366 count=$(($T32_BLIMIT / 1024 / 2))
1367 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1369 # format ost with comma-separated NIDs to verify LU-4460
1370 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
1371 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1375 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1376 $LFS quotacheck -ug /mnt/$FSNAME
1377 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1380 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1383 mkdir $tmp/img || return 1
1387 ls -Rni --time-style=+%s >$tmp/img/list
1388 find . ! -name .lustre -type f -exec sha1sum {} \; |
1389 sort -k 2 >$tmp/img/sha1sums
1391 $LCTL get_param -n version | head -n 1 |
1392 sed -e 's/^lustre: *//' >$tmp/img/commit
1394 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1395 $LFS quotaon -ug /mnt/$FSNAME
1396 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1397 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1398 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1399 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1400 | tr -d "*" > $tmp/img/bspace
1401 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1402 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1403 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1404 | tr -d "*" > $tmp/img/ispace
1409 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1412 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1413 echo "Data verification failed"
1416 uname -r >$tmp/img/kernel
1417 uname -m >$tmp/img/arch
1419 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1420 mv $OSTDEV1 $tmp/img
1422 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1423 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1426 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1431 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1434 # The list of applicable tarballs is returned via the caller's
1435 # variable "tarballs".
1438 local node=$(facet_active_host $SINGLEMDS)
1439 local r="do_node $node"
1441 if [ "$CLIENTONLY" ]; then
1442 skip "Client-only testing"
1446 if ! $r which $TUNEFS; then
1447 skip_env "tunefs.lustre required on $node"
1451 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1453 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 -name \'disk*-$IMGTYPE.tar.bz2\')
1455 if [ -z "$tarballs" ]; then
1456 skip "No applicable tarballs found"
1461 t32_test_cleanup() {
1463 local fstype=$(facet_fstype $SINGLEMDS)
1466 if $shall_cleanup_lustre; then
1467 umount $tmp/mnt/lustre || rc=$?
1469 if $shall_cleanup_mdt; then
1470 $r umount -d $tmp/mnt/mdt || rc=$?
1472 if $shall_cleanup_mdt1; then
1473 $r umount -d $tmp/mnt/mdt1 || rc=$?
1475 if $shall_cleanup_ost; then
1476 $r umount -d $tmp/mnt/ost || rc=$?
1481 if [ $fstype == "zfs" ]; then
1482 $r $ZPOOL destroy t32fs-mdt1 || rc=$?
1483 $r $ZPOOL destroy t32fs-ost1 || rc=$?
1488 t32_bits_per_long() {
1490 # Yes, this is not meant to be perfect.
1500 t32_reload_modules() {
1502 local all_removed=false
1505 while ((i < 20)); do
1506 echo "Unloading modules on $node: Attempt $i"
1507 do_rpc_nodes $node $LUSTRE_RMMOD $(facet_fstype $SINGLEMDS) &&
1509 do_rpc_nodes $node check_mem_leak || return 1
1510 if $all_removed; then
1511 do_rpc_nodes $node load_modules
1517 echo "Unloading modules on $node: Given up"
1521 t32_wait_til_devices_gone() {
1527 echo wait for devices to go
1528 while ((i < 20)); do
1529 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1530 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1531 ((devices == 0 && loops == 0)) && return 0
1535 echo "waiting for dev on $node: dev $devices loop $loops given up"
1536 do_rpc_nodes $node "losetup -a"
1537 do_rpc_nodes $node "$LCTL device_list"
1541 t32_verify_quota() {
1545 local fstype=$(facet_fstype $SINGLEMDS)
1549 $LFS quota -u $T32_QID -v $mnt
1551 qval=$($LFS quota -v -u $T32_QID $mnt |
1552 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1553 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1555 [ $qval -eq $img_bspace ] || {
1556 echo "bspace, act:$qval, exp:$img_bspace"
1560 qval=$($LFS quota -v -u $T32_QID $mnt |
1561 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1562 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1564 [ $qval -eq $img_ispace ] || {
1565 echo "ispace, act:$qval, exp:$img_ispace"
1569 qval=$($LFS quota -v -u $T32_QID $mnt |
1570 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1571 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1573 [ $qval -eq $T32_BLIMIT ] || {
1574 echo "blimit, act:$qval, exp:$T32_BLIMIT"
1578 qval=$($LFS quota -v -u $T32_QID $mnt |
1579 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1580 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1582 [ $qval -eq $T32_ILIMIT ] || {
1583 echo "ilimit, act:$qval, exp:$T32_ILIMIT"
1587 do_node $node $LCTL conf_param $fsname.quota.mdt=ug
1588 cmd="$LCTL get_param -n osd-$fstype.$fsname-MDT0000"
1589 cmd=$cmd.quota_slave.enabled
1590 wait_update $node "$cmd" "ug" || {
1591 echo "Enable mdt quota failed"
1595 do_node $node $LCTL conf_param $fsname.quota.ost=ug
1596 cmd="$LCTL get_param -n osd-$fstype.$fsname-OST0000"
1597 cmd=$cmd.quota_slave.enabled
1598 wait_update $node "$cmd" "ug" || {
1599 echo "Enable ost quota failed"
1604 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1605 bs=1M count=$(($T32_BLIMIT / 1024)) oflag=sync && {
1606 echo "Write succeed, but expect -EDQUOT"
1609 rm -f $mnt/t32_qf_new
1611 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1613 echo "Create succeed, but expect -EDQUOT"
1616 unlinkmany $mnt/t32_qf_ $T32_ILIMIT
1624 local dne_upgrade=${dne_upgrade:-"no"}
1625 local ff_convert=${ff_convert:-"no"}
1626 local shall_cleanup_mdt=false
1627 local shall_cleanup_mdt1=false
1628 local shall_cleanup_ost=false
1629 local shall_cleanup_lustre=false
1630 local node=$(facet_active_host $SINGLEMDS)
1631 local r="do_node $node"
1632 local node2=$(facet_active_host mds2)
1640 local nid=$($r $LCTL list_nids | head -1)
1646 local fstype=$(facet_fstype $SINGLEMDS)
1647 local mdt_dev=$tmp/mdt
1648 local ost_dev=$tmp/ost
1651 trap 'trap - RETURN; t32_test_cleanup' RETURN
1654 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1655 $r mkdir -p $tmp/mnt/{mdt,ost}
1656 $r tar xjvf $tarball -S -C $tmp || {
1657 error_noexit "Unpacking the disk image tarball"
1660 img_commit=$($r cat $tmp/commit)
1661 img_kernel=$($r cat $tmp/kernel)
1662 img_arch=$($r cat $tmp/arch)
1663 img_bspace=$($r cat $tmp/bspace)
1664 img_ispace=$($r cat $tmp/ispace)
1665 echo "Upgrading from $(basename $tarball), created with:"
1666 echo " Commit: $img_commit"
1667 echo " Kernel: $img_kernel"
1668 echo " Arch: $img_arch"
1669 echo "OST version: $(lustre_build_version ost1)"
1671 # The conversion can be made only when both of the following
1672 # conditions are satisfied:
1673 # - ost device img version < 2.3.64
1674 # - ost server version >= 2.5
1675 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1676 $(lustre_version_code ost1) -lt $(version_code 2.5.0) ] &&
1679 if [ $fstype == "zfs" ]; then
1681 $r $ZPOOL import -f -d $tmp t32fs-mdt1
1682 $r $ZPOOL import -f -d $tmp t32fs-ost1
1683 mdt_dev=t32fs-mdt1/mdt1
1684 ost_dev=t32fs-ost1/ost1
1685 wait_update_facet $SINGLEMDS "$ZPOOL list |
1686 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1687 error_noexit "import zfs pool failed"
1692 $r $LCTL set_param debug="$PTLDEBUG"
1694 $r $TUNEFS --dryrun $mdt_dev || {
1696 error_noexit "tunefs.lustre before mounting the MDT"
1699 if [ "$writeconf" ]; then
1701 if [ $fstype == "ldiskfs" ]; then
1703 $r $TUNEFS --quota $mdt_dev || {
1705 error_noexit "Enable mdt quota feature"
1710 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1711 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1712 { skip "LU-2200: Cannot run over Inifiniband w/o lctl replace_nids "
1713 "(Need MGS version at least 2.3.59)"; return 0; }
1715 local osthost=$(facet_active_host ost1)
1716 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1719 if [ $fstype == "ldiskfs" ]; then
1722 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1723 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1724 $r $LCTL replace_nids $fsname-MDT0000 $nid
1725 $r umount -d $tmp/mnt/mdt
1728 mopts=exclude=$fsname-OST0000
1729 if [ $fstype == "ldiskfs" ]; then
1734 t32_wait_til_devices_gone $node
1736 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1738 error_noexit "Mounting the MDT"
1741 shall_cleanup_mdt=true
1743 if [ "$dne_upgrade" != "no" ]; then
1744 local fs2mdsdev=$(mdsdevname 1_2)
1745 local fs2mdsvdev=$(mdsvdevname 1_2)
1747 echo "mkfs new MDT on ${fs2mdsdev}...."
1748 if [ $(facet_fstype mds1) == ldiskfs ]; then
1749 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1752 add fs2mds $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1753 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1754 error_noexit "Mkfs new MDT failed"
1758 $r $TUNEFS --dryrun $fs2mdsdev || {
1759 error_noexit "tunefs.lustre before mounting the MDT"
1763 echo "mount new MDT....$fs2mdsdev"
1764 $r mkdir -p $tmp/mnt/mdt1
1765 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1766 error_noexit "mount mdt1 failed"
1770 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1771 error_noexit "enable remote dir create failed"
1773 shall_cleanup_mdt1=true
1776 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1777 error_noexit "Getting MDT UUID"
1780 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1781 error_noexit "Unexpected MDT UUID: \"$uuid\""
1785 $r $TUNEFS --dryrun $ost_dev || {
1786 error_noexit "tunefs.lustre before mounting the OST"
1789 if [ "$writeconf" ]; then
1790 mopts=mgsnode=$nid,$writeconf
1791 if [ $fstype == "ldiskfs" ]; then
1793 $r $TUNEFS --quota $ost_dev || {
1795 error_noexit "Enable ost quota feature"
1801 if [ $fstype == "ldiskfs" ]; then
1805 $r $MOUNT_CMD -o $mopts $ost_dev $tmp/mnt/ost || {
1806 error_noexit "Mounting the OST"
1809 shall_cleanup_ost=true
1811 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1812 error_noexit "Getting OST UUID"
1815 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1816 error_noexit "Unexpected OST UUID: \"$uuid\""
1820 $r $LCTL conf_param $fsname-OST0000.osc.max_dirty_mb=15 || {
1821 error_noexit "Setting \"max_dirty_mb\""
1824 $r $LCTL conf_param $fsname-OST0000.failover.node=$nid || {
1825 error_noexit "Setting OST \"failover.node\""
1828 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1829 error_noexit "Setting \"max_rpcs_in_flight\""
1832 $r $LCTL conf_param $fsname-MDT0000.failover.node=$nid || {
1833 error_noexit "Setting MDT \"failover.node\""
1836 $r $LCTL pool_new $fsname.interop || {
1837 error_noexit "Setting \"interop\""
1840 $r $LCTL conf_param $fsname-MDT0000.lov.stripesize=4M || {
1841 error_noexit "Setting \"lov.stripesize\""
1844 $r $LCTL conf_param $fsname-MDT0000.mdd.atime_diff=70 || {
1845 error_noexit "Setting \"mdd.atime_diff\""
1849 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1850 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1851 error_noexit "Start OI scrub on OST0"
1855 # The oi_scrub should be on ost1, but for test_32(),
1856 # all on the SINGLEMDS.
1857 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1858 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1859 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1860 error_noexit "Failed to get the expected 'completed'"
1864 local UPDATED=$($r $LCTL get_param -n \
1865 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1866 awk '/^updated/ { print $2 }')
1867 [ $UPDATED -ge 1 ] || {
1868 error_noexit "Only $UPDATED objects have been converted"
1873 if [ "$dne_upgrade" != "no" ]; then
1874 $r $LCTL conf_param \
1875 $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
1876 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
1879 $r $LCTL conf_param $fsname-MDT0001.failover.node=$nid || {
1880 error_noexit "Setting MDT1 \"failover.node\""
1883 $r $LCTL conf_param $fsname-MDT0001.lov.stripesize=4M || {
1884 error_noexit "Setting MDT1 \"lov.stripesize\""
1890 if [ "$writeconf" ]; then
1891 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
1892 error_noexit "Mounting the client"
1895 shall_cleanup_lustre=true
1896 $LCTL set_param debug="$PTLDEBUG"
1898 t32_verify_quota $node $fsname $tmp/mnt/lustre || {
1899 error_noexit "verify quota failed"
1903 if [ "$dne_upgrade" != "no" ]; then
1904 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/remote_dir || {
1905 error_noexit "set remote dir failed"
1909 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/remote_dir
1911 $r $LCTL set_param -n \
1912 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
1914 pushd $tmp/mnt/lustre
1915 tar -cf - . --exclude=./remote_dir |
1916 tar -xvf - -C remote_dir 1>/dev/null || {
1917 error_noexit "cp to remote dir failed"
1923 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
1924 error_noexit "dd failed"
1927 rm -rf $tmp/mnt/lustre/tmp_file || {
1928 error_noexit "rm failed"
1932 if $r test -f $tmp/sha1sums; then
1933 # LU-2393 - do both sorts on same node to ensure locale
1935 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
1936 if [ "$dne_upgrade" != "no" ]; then
1937 pushd $tmp/mnt/lustre/remote_dir
1939 pushd $tmp/mnt/lustre
1942 find ! -name .lustre -type f -exec sha1sum {} \; |
1943 sort -k 2 >$tmp/sha1sums || {
1944 error_noexit "sha1sum"
1948 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
1949 error_noexit "sha1sum verification failed"
1953 echo "sha1sum verification skipped"
1956 if [ "$dne_upgrade" != "no" ]; then
1957 rm -rf $tmp/mnt/lustre/remote_dir || {
1958 error_noexit "remove remote dir failed"
1963 if $r test -f $tmp/list; then
1965 # There is not a Test Framework API to copy files to or
1966 # from a remote node.
1968 # LU-2393 - do both sorts on same node to ensure locale
1970 $r cat $tmp/list | sort -k 6 >$tmp/list.orig
1971 pushd $tmp/mnt/lustre
1972 ls -Rni --time-style=+%s | sort -k 6 >$tmp/list || {
1978 # 32-bit and 64-bit clients use different algorithms to
1979 # convert FIDs into inode numbers. Hence, remove the inode
1980 # numbers from the lists, if the original list was created
1981 # on an architecture with different number of bits per
1984 if [ $(t32_bits_per_long $(uname -m)) != \
1985 $(t32_bits_per_long $img_arch) ]; then
1986 echo "Different number of bits per \"long\" from the disk image"
1987 for list in list.orig list; do
1988 sed -i -e 's/^[0-9]\+[ \t]\+//' $tmp/$list
1991 if ! diff -ub $tmp/list.orig $tmp/list; then
1992 error_noexit "list verification failed"
1996 echo "list verification skipped"
1999 if [ $(lustre_version_code mds1) -ge $(version_code 2.7.50) -a \
2000 $dne_upgrade != "no" ]; then
2001 $r $LCTL set_param -n \
2002 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2004 echo "test migration"
2005 pushd $tmp/mnt/lustre
2006 # migrate the files/directories to the remote MDT, then
2008 for dir in $(find ! -name .lustre ! -name . -type d); do
2009 mdt_index=$($LFS getdirstripe -i $dir)
2010 stripe_cnt=$($LFS getdirstripe -c $dir)
2011 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2012 $LFS mv -M 1 $dir || {
2014 error_noexit "migrate MDT1 failed"
2020 for dir in $(find ! -name . ! -name .lustre -type d); do
2021 mdt_index=$($LFS getdirstripe -i $dir)
2022 stripe_cnt=$($LFS getdirstripe -c $dir)
2023 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2024 $LFS mv -M 0 $dir || {
2026 error_noexit "migrate MDT0 failed"
2035 # When adding new data verification tests, please check for
2036 # the presence of the required reference files first, like
2037 # the "sha1sums" and "list" tests above, to avoid the need to
2038 # regenerate every image for each test addition.
2041 nrpcs_orig=$($LCTL get_param \
2042 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2043 error_noexit "Getting \"max_rpcs_in_flight\""
2046 nrpcs=$((nrpcs_orig + 5))
2047 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=$nrpcs || {
2048 error_noexit "Changing \"max_rpcs_in_flight\""
2051 wait_update $HOSTNAME "$LCTL get_param \
2052 -n mdc.*MDT0000*.max_rpcs_in_flight" $nrpcs || {
2053 error_noexit "Verifying \"max_rpcs_in_flight\""
2057 umount $tmp/mnt/lustre || {
2058 error_noexit "Unmounting the client"
2061 shall_cleanup_lustre=false
2063 if [ "$dne_upgrade" != "no" ]; then
2064 $r umount -d $tmp/mnt/mdt1 || {
2065 error_noexit "Unmounting the MDT2"
2068 shall_cleanup_mdt1=false
2071 $r umount -d $tmp/mnt/mdt || {
2072 error_noexit "Unmounting the MDT"
2075 shall_cleanup_mdt=false
2077 $r umount -d $tmp/mnt/ost || {
2078 error_noexit "Unmounting the OST"
2081 shall_cleanup_ost=false
2083 t32_reload_modules $node || {
2084 error_noexit "Reloading modules"
2088 # mount a second time to make sure we didnt leave upgrade flag on
2089 $r $TUNEFS --dryrun $mdt_dev || {
2091 error_noexit "tunefs.lustre before remounting the MDT"
2095 mopts=exclude=$fsname-OST0000
2096 if [ $fstype == "ldiskfs" ]; then
2099 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2100 error_noexit "Remounting the MDT"
2103 shall_cleanup_mdt=true
2113 for tarball in $tarballs; do
2114 t32_test $tarball || let "rc += $?"
2118 run_test 32a "Upgrade (not live)"
2126 for tarball in $tarballs; do
2127 t32_test $tarball writeconf || let "rc += $?"
2131 run_test 32b "Upgrade with writeconf"
2138 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2140 for tarball in $tarballs; do
2141 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2142 echo $tarball | grep "1_8" && continue
2143 echo $tarball | grep "2_1" && continue
2145 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2149 run_test 32c "dne upgrade test"
2157 for tarball in $tarballs; do
2158 ff_convert=yes t32_test $tarball || rc=$?
2162 run_test 32d "convert ff test"
2164 test_33a() { # bug 12333, was test_33
2165 local FSNAME2=test-123
2166 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2169 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2171 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2172 local dev=${SINGLEMDS}_dev
2173 local MDSDEV=${!dev}
2174 is_blkdev $SINGLEMDS $MDSDEV &&
2175 skip_env "mixed loopback and real device not working" &&
2179 local fs2mdsdev=$(mdsdevname 1_2)
2180 local fs2ostdev=$(ostdevname 1_2)
2181 local fs2mdsvdev=$(mdsvdevname 1_2)
2182 local fs2ostvdev=$(ostvdevname 1_2)
2184 if [ $(facet_fstype mds1) == ldiskfs ]; then
2185 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2188 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2189 --reformat $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
2190 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2191 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2192 $fs2ostvdev || exit 10
2194 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2195 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2196 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" ||
2197 error "$LCTL conf_param $FSNAME2.sys.timeout=200 failed"
2198 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2199 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2202 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2203 $GETSTRIPE $MOUNT2/hosts || error "$GETSTRIPE $MOUNT2/hosts failed"
2208 cleanup_nocli || error "cleanup_nocli failed with $?"
2210 run_test 33a "Mount ost with a large index number"
2212 test_33b() { # was test_34
2215 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2216 # Drop lock cancelation reply during umount
2217 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2218 do_facet client $LCTL set_param fail_loc=0x80000304
2219 #lctl set_param debug=-1
2220 umount_client $MOUNT
2221 cleanup || error "cleanup failed with $?"
2223 run_test 33b "Drop cancel during umount"
2227 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2228 manual_umount_client
2230 do_facet client killall -USR1 multiop
2231 if [ $rc -eq 0 ]; then
2232 error "umount not fail!"
2235 cleanup || error "cleanup failed with rc $?"
2237 run_test 34a "umount with opened file should be fail"
2241 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2242 stop_mds || error "Unable to stop MDS"
2244 manual_umount_client --force || error "mtab after failed umount with $?"
2246 cleanup || error "cleanup failed with $?"
2248 run_test 34b "force umount with failed mds should be normal"
2252 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2253 stop_ost || error "Unable to stop OST1"
2255 manual_umount_client --force || error "mtab after failed umount with $?"
2257 cleanup || error "cleanup failed with $?"
2259 run_test 34c "force umount with failed ost should be normal"
2261 test_35a() { # bug 12459
2264 DBG_SAVE="`$LCTL get_param -n debug`"
2265 $LCTL set_param debug="ha"
2267 log "Set up a fake failnode for the MDS"
2269 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2270 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2271 do_facet mgs "$LCTL conf_param \
2272 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" ||
2273 error "Setting ${device}.failover.node=\
2274 $(h2$NETTYPE $FAKENID) failed."
2276 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2279 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2282 log "Stopping the MDT: $device"
2283 stop_mdt 1 || error "MDT0 stop fail"
2285 df $MOUNT > /dev/null 2>&1 &
2287 log "Restarting the MDT: $device"
2288 start_mdt 1 || error "MDT0 start fail"
2289 log "Wait for df ($DFPID) ... "
2292 $LCTL set_param debug="$DBG_SAVE"
2294 # retrieve from the log the first server that the client tried to
2295 # contact after the connection loss
2296 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2297 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2298 /import_select_connection.*$device-mdc.* using connection/ {
2300 if (\\\$NF ~ /$FAKENID/)
2306 }" $TMP/lustre-log-$TESTNAME.log`
2307 [ "$NEXTCONN" != "0" ] &&
2308 error "Tried to connect to ${NEXTCONN} not last active server"
2309 cleanup || error "cleanup failed with $?"
2310 # remove nid settings
2311 writeconf_or_reformat
2313 run_test 35a "Reconnect to the last active server first"
2315 test_35b() { # bug 18674
2316 remote_mds || { skip "local MDS" && return 0; }
2320 $LCTL set_param debug="ha"
2322 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2325 log "Set up a fake failnode for the MDS"
2327 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2328 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2329 do_facet mgs "$LCTL conf_param \
2330 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" ||
2331 error "Set ${device}.failover.node=\
2332 $(h2$NETTYPE $FAKENID) failed"
2334 local at_max_saved=0
2335 # adaptive timeouts may prevent seeing the issue
2336 if at_is_enabled; then
2337 at_max_saved=$(at_max_get mds)
2338 at_max_set 0 mds client
2341 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2343 log "Injecting EBUSY on MDS"
2344 # Setting OBD_FAIL_MDS_RESEND=0x136
2345 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2346 error "unable to set param fail_loc=0x80000136"
2348 $LCTL set_param mdc.${FSNAME}*.stats=clear
2350 log "Creating a test file and stat it"
2351 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2352 stat $MOUNT/$tdir/$tfile
2354 log "Stop injecting EBUSY on MDS"
2355 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2356 error "unable to set param fail_loc=0"
2357 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2360 # restore adaptive timeout
2361 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2363 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2365 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2366 awk '/mds_connect/{print $2}')
2368 # retrieve from the log if the client has ever tried to
2369 # contact the fake server after the loss of connection
2370 FAILCONN=`awk "BEGIN {ret = 0;}
2371 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2373 if (\\\$NF ~ /$FAKENID/) {
2378 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2380 [ "$FAILCONN" == "0" ] &&
2381 error "The client reconnection has not been triggered"
2382 [ "$FAILCONN" == "2" ] &&
2383 error "Primary server busy, client reconnect to failover failed"
2386 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2387 # Reconnects are supposed to be rate limited to one every 5s
2388 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2389 error "Too many reconnects $CONNCNT"
2391 cleanup || error "cleanup failed with $?"
2392 # remove nid settings
2393 writeconf_or_reformat
2395 run_test 35b "Continue reconnection retries, if the active server is busy"
2398 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
2400 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2401 { skip "remote OST" && return 0; }
2404 local FSNAME2=test1234
2405 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2407 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2409 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2410 is_blkdev $SINGLEMDS $MDSDEV &&
2411 skip_env "mixed loopback and real device not working" && return
2414 local fs2mdsdev=$(mdsdevname 1_2)
2415 local fs2ostdev=$(ostdevname 1_2)
2416 local fs3ostdev=$(ostdevname 2_2)
2417 local fs2mdsvdev=$(mdsvdevname 1_2)
2418 local fs2ostvdev=$(ostvdevname 1_2)
2419 local fs3ostvdev=$(ostvdevname 2_2)
2421 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2422 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2423 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2424 # different one than the default value here.
2425 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2426 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2427 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2428 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2430 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2431 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2432 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2433 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2434 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2436 sleep 5 # until 11778 fixed
2438 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2440 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2441 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2442 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2443 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2444 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2445 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2446 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2447 DFTOTAL=$(echo $STRING | cut -d, -f1)
2448 DFUSED=$(echo $STRING | cut -d, -f2)
2449 DFAVAIL=$(echo $STRING | cut -d, -f3)
2450 DFFREE=$(($DFTOTAL - $DFUSED))
2452 ALLOWANCE=$((64 * $OSTCOUNT))
2454 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2455 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2456 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2459 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2460 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2461 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2464 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2465 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2466 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2471 stop fs3ost -f || error "unable to stop OST3"
2472 stop fs2ost -f || error "unable to stop OST2"
2473 stop fs2mds -f || error "unable to stop second MDS"
2474 unload_modules_conf || error "unable unload modules"
2477 run_test 36 "df report consistency on OSTs with different block size"
2480 local mntpt=$(facet_mntpt $SINGLEMDS)
2481 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2482 local mdsdev_sym="$TMP/sym_mdt.img"
2483 local opts=$MDS_MOUNT_OPTS
2486 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2487 skip "Currently only applicable to ldiskfs-based MDTs"
2491 echo "MDS : $mdsdev"
2492 echo "SYMLINK : $mdsdev_sym"
2493 do_facet $SINGLEMDS rm -f $mdsdev_sym
2495 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2497 echo "mount symlink device - $mdsdev_sym"
2499 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2500 opts=$(csa_add "$opts" -o loop)
2502 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2503 $mdsdev_sym $mntpt 2>&1)
2506 echo mount_op=$mount_op
2508 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
2510 if $(echo $mount_op | grep -q "unable to set tunable"); then
2511 error "set tunables failed for symlink device"
2514 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2516 run_test 37 "verify set tunables works for symlink device"
2518 test_38() { # bug 14222
2519 local fstype=$(facet_fstype $SINGLEMDS)
2520 local mntpt=$(facet_mntpt $SINGLEMDS)
2525 local SRC="/etc /bin"
2526 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2527 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2528 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2529 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2530 error "copying $SRC to $DIR/$tdir"
2532 umount_client $MOUNT || error "umount_client $MOUNT failed"
2533 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2534 stop_mds || error "Unable to stop MDS"
2535 log "delete lov_objid file on MDS"
2537 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2539 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2541 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2543 # check create in mds_lov_connect
2544 start_mds || error "unable to start MDS"
2545 mount_client $MOUNT || error "mount_client $MOUNT failed"
2547 [ $V ] && log "verifying $DIR/$tdir/$f"
2548 diff -q $f $DIR/$tdir/$f || ERROR=y
2550 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2551 if [ "$ERROR" = "y" ]; then
2552 # check it's updates in sync
2553 umount_client $MOUNT
2555 mount_fstype $SIGNLEMDS
2556 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2557 unmount_fstype $SINGLEMDS
2558 error "old and new files are different after connect" || true
2560 touch $DIR/$tdir/f2 || error "f2 file create failed"
2562 # check it's updates in sync
2563 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2566 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2568 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2569 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2571 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2573 start_mds || error "unable to start MDS"
2574 mount_client $MOUNT || error "mount_client $MOUNT failed"
2576 [ $V ] && log "verifying $DIR/$tdir/$f"
2577 diff -q $f $DIR/$tdir/$f || ERROR=y
2579 touch $DIR/$tdir/f3 || error "f3 file create failed"
2580 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2581 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2583 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2584 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2585 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2587 [ "$ERROR" = "y" ] &&
2588 error "old and new files are different after sync" || true
2590 log "files compared the same"
2591 cleanup || error "cleanup failed with $?"
2593 run_test 38 "MDS recreates missing lov_objid file from OST data"
2598 cleanup || error "cleanup failed with $?"
2599 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2600 error "memory leak detected" || true
2602 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2604 test_40() { # bug 15759
2605 start_ost || error "Unable to start OST1"
2606 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2607 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2609 cleanup || error "cleanup failed with rc $?"
2611 run_test 40 "race during service thread startup"
2613 test_41a() { #bug 14134
2614 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2615 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2616 skip "Loop devices does not work with nosvc option"
2620 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2622 start_mdt 1 -o nosvc -n
2623 if [ $MDSCOUNT -ge 2 ]; then
2624 for num in $(seq 2 $MDSCOUNT); do
2625 start_mdt $num || return
2628 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2629 start_mdt 1 -o nomgs,force
2630 mount_client $MOUNT || error "mount_client $MOUNT failed"
2633 echo "blah blah" > $MOUNT/$tfile
2636 umount_client $MOUNT || error "umount_client $MOUNT failed"
2637 stop ost1 -f || error "unable to stop OST1"
2638 stop_mds || error "Unable to stop MDS"
2639 stop_mds || error "Unable to stop MDS on second try"
2640 unload_modules_conf || error "unload_modules_conf failed"
2642 run_test 41a "mount mds with --nosvc and --nomgs"
2645 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2646 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2647 skip "Loop devices does not work with nosvc option"
2651 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2655 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2657 start_mdt 1 -o nosvc -n
2658 if [ $MDSCOUNT -ge 2 ]; then
2659 for num in $(seq 2 $MDSCOUNT); do
2660 start_mdt $num || return
2663 start_ost || error "Unable to start OST1"
2664 start_mdt 1 -o nomgs,force
2665 mount_client $MOUNT || error "mount_client $MOUNT failed"
2668 echo "blah blah" > $MOUNT/$tfile
2669 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
2671 umount_client $MOUNT || error "umount_client $MOUNT failed"
2672 stop_ost || error "Unable to stop OST1"
2673 stop_mds || error "Unable to stop MDS"
2674 stop_mds || error "Unable to stop MDS on second try"
2676 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2679 local server_version=$(lustre_version_code $SINGLEMDS)
2681 [[ $server_version -ge $(version_code 2.6.52) ]] ||
2682 [[ $server_version -ge $(version_code 2.5.26) &&
2683 $server_version -lt $(version_code 2.5.50) ]] ||
2684 [[ $server_version -ge $(version_code 2.5.4) &&
2685 $server_version -lt $(version_code 2.5.11) ]] ||
2686 { skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"; return; }
2689 # MDT concurrent start
2690 #define OBD_FAIL_TGT_DELAY_CONNECT 0x703
2691 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x703"
2692 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS &
2695 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
2696 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS &
2702 if [ $rc == 0 ] && [ $rc2 == 114 ]; then
2703 echo "1st MDT start succeed"
2704 echo "2nd MDT start failed with EALREADY"
2705 elif [ $rc2 == 0 ] && [ $rc == 114 ]; then
2706 echo "1st MDT start failed with EALREADY"
2707 echo "2nd MDT start succeed"
2710 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
2713 if [ $MDSCOUNT -ge 2 ]; then
2714 for num in $(seq 2 $MDSCOUNT); do
2715 start_mdt $num || return
2719 # OST concurrent start
2721 #define OBD_FAIL_TGT_DELAY_CONNECT 0x703
2722 do_facet ost1 "$LCTL set_param fail_loc=0x703"
2723 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &
2726 do_facet ost1 "$LCTL set_param fail_loc=0x0"
2727 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &
2733 if [ $rc == 0 ] && [ $rc2 == 114 ]; then
2734 echo "1st OST start succeed"
2735 echo "2nd OST start failed with EALREADY"
2736 elif [ $rc2 == 0 ] && [ $rc == 114 ]; then
2737 echo "1st OST start failed with EALREADY"
2738 echo "2nd OST start succeed"
2742 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
2748 # verify everything ok
2753 error "MDT(s) start failed"
2761 error "OST(s) start failed"
2769 error "client start failed"
2776 error "client mount failed"
2780 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
2782 test_42() { #bug 14693
2784 check_mount || error "client was not mounted"
2786 do_facet mgs $LCTL conf_param $FSNAME.llite.some_wrong_param=10
2787 umount_client $MOUNT ||
2788 error "unmounting client failed with invalid llite param"
2789 mount_client $MOUNT ||
2790 error "mounting client failed with invalid llite param"
2792 do_facet mgs $LCTL conf_param $FSNAME.sys.some_wrong_param=20
2793 cleanup || error "stopping $FSNAME failed with invalid sys param"
2796 check_mount || error "client was not mounted with invalid sys param"
2797 cleanup || error "stopping $FSNAME failed with invalid sys param"
2799 run_test 42 "allow client/server mount/unmount with invalid config param"
2802 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.58) ]] ||
2803 { skip "Need MDS version at least 2.5.58" && return 0; }
2804 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
2807 USER1=$(cat /etc/passwd | grep :$ID1:$ID1: | cut -d: -f1)
2808 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
2812 chmod ugo+x $DIR || error "chmod 0 failed"
2813 set_conf_param_and_check mds \
2814 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2815 "$FSNAME.mdt.root_squash" \
2817 wait_update $HOSTNAME \
2818 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
2820 error "check llite root_squash failed!"
2821 set_conf_param_and_check mds \
2822 "$LCTL get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2823 "$FSNAME.mdt.nosquash_nids" \
2825 wait_update $HOSTNAME \
2826 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
2828 error "check llite nosquash_nids failed!"
2831 # create set of test files
2833 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
2834 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
2835 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
2837 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
2838 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
2840 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
2841 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
2842 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
2844 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
2845 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
2846 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
2849 # check root_squash:
2850 # set root squash UID:GID to RUNAS_ID
2851 # root should be able to access only files owned by RUNAS_ID
2853 set_conf_param_and_check mds \
2854 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2855 "$FSNAME.mdt.root_squash" \
2856 "$RUNAS_ID:$RUNAS_ID"
2857 wait_update $HOSTNAME \
2858 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
2859 "$RUNAS_ID:$RUNAS_ID" ||
2860 error "check llite root_squash failed!"
2862 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
2863 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
2864 error "$ST: root read permission is denied"
2865 echo "$ST: root read permission is granted - ok"
2868 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
2869 error "$ST: root write permission is denied"
2870 echo "$ST: root write permission is granted - ok"
2872 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2873 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
2874 error "$ST: root read permission is granted"
2875 echo "$ST: root read permission is denied - ok"
2878 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
2879 error "$ST: root write permission is granted"
2880 echo "$ST: root write permission is denied - ok"
2882 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2883 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
2884 error "$ST: root unlink permission is granted"
2885 echo "$ST: root unlink permission is denied - ok"
2887 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
2888 error "$ST: root create permission is granted"
2889 echo "$ST: root create permission is denied - ok"
2892 # check root_squash is enforced independently
2893 # of client cache content
2895 # access file by USER1, keep access open
2896 # root should be denied access to user file
2898 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
2902 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
2903 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
2904 { kill $pid; error "$ST: root read permission is granted"; }
2905 echo "$ST: root read permission is denied - ok"
2908 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
2909 { kill $pid; error "$ST: root write permission is granted"; }
2910 echo "$ST: root write permission is denied - ok"
2916 # check nosquash_nids:
2917 # put client's NID into nosquash_nids list,
2918 # root should be able to access root file after that
2920 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
2921 NIDLIST="2@gni $NIDLIST 192.168.0.[2,10]@tcp"
2922 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
2923 set_conf_param_and_check mds \
2924 "$LCTL get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2925 "$FSNAME-MDTall.mdt.nosquash_nids" \
2927 wait_update $HOSTNAME \
2928 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
2930 error "check llite nosquash_nids failed!"
2932 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2933 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
2934 error "$ST: root read permission is denied"
2935 echo "$ST: root read permission is granted - ok"
2938 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
2939 error "$ST: root write permission is denied"
2940 echo "$ST: root write permission is granted - ok"
2942 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2943 rm $DIR/$tdir-rootdir/tfile-1 ||
2944 error "$ST: root unlink permission is denied"
2945 echo "$ST: root unlink permission is granted - ok"
2946 touch $DIR/$tdir-rootdir/tfile-2 ||
2947 error "$ST: root create permission is denied"
2948 echo "$ST: root create permission is granted - ok"
2950 run_test 43 "check root_squash and nosquash_nids"
2952 umount_client $MOUNT
2957 check_mount || error "check_mount"
2958 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
2960 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
2961 for VAL in $UUIDS; do
2962 NID=$(echo $VAL | cut -d= -f1)
2963 CLUUID=$(echo $VAL | cut -d= -f2)
2964 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
2966 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
2967 cleanup || error "cleanup failed with $?"
2969 run_test 44 "mounted client proc entry exists"
2973 check_mount || error "check_mount"
2974 stop_mds || error "Unable to stop MDS"
2978 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
2979 do_facet client "$LCTL set_param fail_loc=0x50f"
2982 manual_umount_client --force || error "manual_umount_client failed"
2983 do_facet client "$LCTL set_param fail_loc=0x0"
2984 start_mds || error "unable to start MDS"
2985 mount_client $MOUNT || error "mount_client $MOUNT failed"
2986 cleanup || error "cleanup failed with $?"
2988 run_test 45 "long unlink handling in ptlrpcd"
2995 umount_client $MOUNT2 || rc=$?
2996 umount_client $MOUNT || rc=$?
2997 while [ $count -gt 0 ]; do
2998 stop ost${count} -f || rc=$?
3002 cleanup_nocli || rc=$?
3003 #writeconf to remove all ost2 traces for subsequent tests
3004 writeconf_or_reformat
3009 echo "Testing with $OSTCOUNT OSTs"
3011 start_mds || error "unable to start MDS"
3012 #first client should see only one ost
3013 start_ost || error "Unable to start OST1"
3014 wait_osc_import_state mds ost FULL
3016 mount_client $MOUNT || error "mount_client $MOUNT failed"
3017 trap "cleanup_46a $OSTCOUNT" EXIT ERR
3020 for (( i=2; i<=$OSTCOUNT; i++ )); do
3021 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
3022 error "start_ost$i $(ostdevname $i) failed"
3025 # wait until osts in sync
3026 for (( i=2; i<=$OSTCOUNT; i++ )); do
3027 wait_osc_import_state mds ost$i FULL
3028 wait_osc_import_state client ost$i FULL
3031 #second client see all ost's
3033 mount_client $MOUNT2 || error "mount_client failed"
3034 $SETSTRIPE -c -1 $MOUNT2 || error "$SETSTRIPE -c -1 $MOUNT2 failed"
3035 $GETSTRIPE $MOUNT2 || error "$GETSTRIPE $MOUNT2 failed"
3037 echo "ok" > $MOUNT2/widestripe
3038 $GETSTRIPE $MOUNT2/widestripe ||
3039 error "$GETSTRIPE $MOUNT2/widestripe failed"
3040 # fill acl buffer for avoid expand lsm to them
3041 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
3043 setfacl -m $acl $MOUNT2/widestripe
3047 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3049 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
3051 run_test 46a "handle ost additional - wide striped file"
3056 check_mount || error "check_mount failed"
3057 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
3061 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3062 if echo $ns | grep "MDT[[:digit:]]*"; then
3065 lrs=$(echo $ns | sed 's/.*lru_size=//')
3066 lru_size[count]=$lrs
3071 facet_failover $SINGLEMDS
3072 client_up || error "client_up failed"
3075 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3076 if echo $ns | grep "MDT[[:digit:]]*"; then
3079 lrs=$(echo $ns | sed 's/.*lru_size=//')
3080 if ! test "$lrs" -eq "${lru_size[count]}"; then
3081 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
3082 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
3087 cleanup || error "cleanup failed with $?"
3089 run_test 47 "server restart does not make client loss lru_resize settings"
3094 # reformat after this test is needed - if the test fails,
3095 # we will have unkillable file at FS
3099 test_48() { # bug 17636
3102 check_mount || error "check_mount failed"
3104 $SETSTRIPE -c -1 $MOUNT || error "$SETSTRIPE -c -1 $MOUNT failed"
3105 $GETSTRIPE $MOUNT || error "$GETSTRIPE $MOUNT failed"
3107 echo "ok" > $MOUNT/widestripe
3108 $GETSTRIPE $MOUNT/widestripe ||
3109 error "$GETSTRIPE $MOUNT/widestripe failed"
3111 trap cleanup_48 EXIT ERR
3113 # fill acl buffer for avoid expand lsm to them
3114 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
3115 setfacl -m $acl $MOUNT/widestripe
3118 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3122 run_test 48 "too many acls on file"
3124 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3125 test_49a() { # bug 17710
3126 local timeout_orig=$TIMEOUT
3127 local ldlm_timeout_orig=$LDLM_TIMEOUT
3128 local LOCAL_TIMEOUT=20
3130 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3131 TIMEOUT=$LOCAL_TIMEOUT
3135 check_mount || error "client mount failed"
3137 echo "check ldlm_timout..."
3138 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3139 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3140 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3142 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3143 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3146 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3147 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3150 umount_client $MOUNT || error "umount_client $MOUNT failed"
3151 stop_ost || error "problem stopping OSS"
3152 stop_mds || error "problem stopping MDS"
3154 LDLM_TIMEOUT=$ldlm_timeout_orig
3155 TIMEOUT=$timeout_orig
3157 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3159 test_49b() { # bug 17710
3160 local timeout_orig=$TIMEOUT
3161 local ldlm_timeout_orig=$LDLM_TIMEOUT
3162 local LOCAL_TIMEOUT=20
3164 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3165 TIMEOUT=$LOCAL_TIMEOUT
3169 check_mount || error "client mount failed"
3171 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3172 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3173 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3175 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3176 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3179 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3180 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3183 cleanup || error "cleanup failed"
3185 LDLM_TIMEOUT=$ldlm_timeout_orig
3186 TIMEOUT=$timeout_orig
3188 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3191 # Test both statfs and lfs df and fail if either one fails
3192 multiop_bg_pause $1 f_
3195 killall -USR1 multiop
3196 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
3197 wait $PID || { RC1=$?; log "multiop return error "; }
3204 if [ $RC2 -eq 0 ]; then
3206 log "lazystatfs df failed"
3210 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
3216 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3217 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3219 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3221 cleanup || error "cleanup failed with rc $?"
3223 run_test 50a "lazystatfs all servers available"
3227 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3228 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3230 # Wait for client to detect down OST
3231 stop_ost || error "Unable to stop OST1"
3232 wait_osc_import_state mds ost DISCONN
3234 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
3236 umount_client $MOUNT || error "Unable to unmount client"
3237 stop_mds || error "Unable to stop MDS"
3239 run_test 50b "lazystatfs all servers down"
3242 start_mds || error "Unable to start MDS"
3243 start_ost || error "Unable to start OST1"
3244 start_ost2 || error "Unable to start OST2"
3245 mount_client $MOUNT || error "Unable to mount client"
3246 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3247 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3249 # Wait for client to detect down OST
3250 stop_ost || error "Unable to stop OST1"
3251 wait_osc_import_state mds ost DISCONN
3252 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3254 umount_client $MOUNT || error "Unable to unmount client"
3255 stop_ost2 || error "Unable to stop OST2"
3256 stop_mds || error "Unable to stop MDS"
3257 #writeconf to remove all ost2 traces for subsequent tests
3258 writeconf_or_reformat
3260 run_test 50c "lazystatfs one server down"
3263 start_mds || error "Unable to start MDS"
3264 start_ost || error "Unable to start OST1"
3265 start_ost2 || error "Unable to start OST2"
3266 mount_client $MOUNT || error "Unable to mount client"
3267 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3268 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3270 # Issue the statfs during the window where the client still
3271 # belives the OST to be available but it is in fact down.
3272 # No failure just a statfs which hangs for a timeout interval.
3273 stop_ost || error "Unable to stop OST1"
3274 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3276 umount_client $MOUNT || error "Unable to unmount client"
3277 stop_ost2 || error "Unable to stop OST2"
3278 stop_mds || error "Unable to stop MDS"
3279 #writeconf to remove all ost2 traces for subsequent tests
3280 writeconf_or_reformat
3282 run_test 50d "lazystatfs client/server conn race"
3289 start_mds || error "Unable to start MDS"
3290 #first client should see only one ost
3291 start_ost || error "Unable to start OST1"
3292 wait_osc_import_state mds ost FULL
3294 # Wait for client to detect down OST
3295 stop_ost || error "Unable to stop OST1"
3296 wait_osc_import_state mds ost DISCONN
3298 mount_client $MOUNT || error "Unable to mount client"
3299 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3301 multiop_bg_pause $MOUNT _f
3305 if [ $RC1 -ne 0 ]; then
3306 log "multiop failed $RC1"
3309 sleep $(( $TIMEOUT+1 ))
3311 [ $? -ne 0 ] && error "process isn't sleep"
3312 start_ost || error "Unable to start OST1"
3313 wait $pid || error "statfs failed"
3316 umount_client $MOUNT || error "Unable to unmount client"
3317 stop_ost || error "Unable to stop OST1"
3318 stop_mds || error "Unable to stop MDS"
3320 run_test 50e "normal statfs all servers down"
3325 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3327 start_mds || error "Unable to start mds"
3328 #first client should see only one ost
3329 start_ost || error "Unable to start OST1"
3330 wait_osc_import_state mds ost FULL
3332 start_ost2 || error "Unable to start OST2"
3333 wait_osc_import_state mds ost2 FULL
3335 # Wait for client to detect down OST
3336 stop_ost2 || error "Unable to stop OST2"
3338 wait_osc_import_state mds ost2 DISCONN
3339 mount_client $MOUNT || error "Unable to mount client"
3340 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3342 multiop_bg_pause $MOUNT _f
3346 if [ $RC1 -ne 0 ]; then
3347 log "lazystatfs multiop failed $RC1"
3350 sleep $(( $TIMEOUT+1 ))
3352 [ $? -ne 0 ] && error "process isn't sleep"
3353 start_ost2 || error "Unable to start OST2"
3354 wait $pid || error "statfs failed"
3355 stop_ost2 || error "Unable to stop OST2"
3358 umount_client $MOUNT || error "Unable to unmount client"
3359 stop_ost || error "Unable to stop OST1"
3360 stop_mds || error "Unable to stop MDS"
3361 #writeconf to remove all ost2 traces for subsequent tests
3362 writeconf_or_reformat
3364 run_test 50f "normal statfs one server in down"
3367 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
3369 start_ost2 || error "Unable to start OST2"
3370 wait_osc_import_state mds ost2 FULL
3371 wait_osc_import_state client ost2 FULL
3373 local PARAM="${FSNAME}-OST0001.osc.active"
3375 $SETSTRIPE -c -1 $DIR/$tfile || error "$SETSTRIPE failed"
3376 do_facet mgs $LCTL conf_param $PARAM=0 ||
3377 error "Unable to deactivate OST"
3379 umount_client $MOUNT || error "Unable to unmount client"
3380 mount_client $MOUNT || error "Unable to mount client"
3381 # This df should not cause a panic
3384 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
3385 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
3386 umount_client $MOUNT || error "Unable to unmount client"
3387 stop_ost2 || error "Unable to stop OST2"
3388 stop_ost || error "Unable to stop OST1"
3389 stop_mds || error "Unable to stop MDS"
3390 #writeconf to remove all ost2 traces for subsequent tests
3391 writeconf_or_reformat
3393 run_test 50g "deactivated OST should not cause panic"
3397 # prepare MDT/OST, make OSC inactive for OST1
3398 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
3400 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3401 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3402 error "tunefs OST1 failed"
3403 start_mds || error "Unable to start MDT"
3404 start_ost || error "Unable to start OST1"
3405 start_ost2 || error "Unable to start OST2"
3406 mount_client $MOUNT || error "client start failed"
3408 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3410 # activatate OSC for OST1
3411 local TEST="$LCTL get_param -n osc.${FSNAME}-OST0000-osc-[!M]*.active"
3412 set_conf_param_and_check client \
3413 "$TEST" "${FSNAME}-OST0000.osc.active" 1 ||
3414 error "Unable to activate OST1"
3416 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3417 $SETSTRIPE -c -1 -i 0 $DIR/$tdir/2 ||
3418 error "$SETSTRIPE $DIR/$tdir/2 failed"
3419 sleep 1 && echo "create a file after OST1 is activated"
3421 createmany -o $DIR/$tdir/2/$tfile-%d 1
3423 # check OSC import is working
3424 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3425 error "some OSC imports are still not connected"
3428 umount_client $MOUNT || error "Unable to umount client"
3429 stop_ost2 || error "Unable to stop OST2"
3430 cleanup_nocli || error "cleanup_nocli failed with $?"
3432 run_test 50h "LU-642: activate deactivated OST"
3435 # prepare MDT/OST, make OSC inactive for OST1
3436 [ "$MDSCOUNT" -lt "2" ] && skip_env "$MDSCOUNT < 2, skipping" && return
3438 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3440 do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
3441 error "tunefs MDT2 failed"
3442 start_mds || error "Unable to start MDT"
3443 start_ost || error "Unable to start OST1"
3444 start_ost2 || error "Unable to start OST2"
3445 mount_client $MOUNT || error "client start failed"
3447 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3449 $LCTL conf_param ${FSNAME}-MDT0000.mdc.active=0 &&
3450 error "deactive MDC0 succeeds"
3451 # activate MDC for MDT2
3452 local TEST="$LCTL get_param -n mdc.${FSNAME}-MDT0001-mdc-[!M]*.active"
3453 set_conf_param_and_check client \
3454 "$TEST" "${FSNAME}-MDT0001.mdc.active" 1 ||
3455 error "Unable to activate MDT2"
3457 $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3459 createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
3461 rm -rf $DIR/$tdir/2 || error "unlink dir failed"
3463 # deactivate MDC for MDT2
3464 local TEST="$LCTL get_param -n mdc.${FSNAME}-MDT0001-mdc-[!M]*.active"
3465 set_conf_param_and_check client \
3466 "$TEST" "${FSNAME}-MDT0001.mdc.active" 0 ||
3467 error "Unable to deactivate MDT2"
3469 $LFS mkdir -i1 $DIR/$tdir/2 &&
3470 error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
3473 umount_client $MOUNT || error "Unable to umount client"
3478 run_test 50i "activate deactivated MDT"
3481 local LOCAL_TIMEOUT=20
3485 check_mount || error "check_mount failed"
3487 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3488 $SETSTRIPE -c -1 $MOUNT/$tdir ||
3489 error "$SETSTRIPE -c -1 $MOUNT/$tdir failed"
3490 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3491 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
3492 touch $MOUNT/$tdir/$tfile &
3495 start_ost2 || error "Unable to start OST1"
3497 stop_ost2 || error "Unable to stop OST1"
3498 cleanup || error "cleanup failed with $?"
3499 #writeconf to remove all ost2 traces for subsequent tests
3500 writeconf_or_reformat
3502 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
3511 do_node $node mkdir -p $dest
3512 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3514 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
3515 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3516 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
3518 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
3519 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
3529 local backup2=${TMP}/backup2
3531 do_node $node mkdir -p $backup2
3532 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3534 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
3535 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3536 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
3538 do_node $node "diff -rq $backup $backup2"
3539 [ $? -eq 0 ] || { error "contents differ"; return 3; }
3541 local xattrs2=${TMP}/xattrs2
3542 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
3543 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
3545 do_node $node "diff $xattrs $xattrs2"
3546 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
3548 do_node $node "rm -rf $backup2 $xattrs2"
3549 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
3553 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3554 skip "Only applicable to ldiskfs-based MDTs"
3558 start_mds || error "Unable to start MDS"
3559 start_ost || error "Unable to start OST1"
3560 mount_client $MOUNT || error "Unable to mount client"
3563 local ost1mnt=$(facet_mntpt ost1)
3564 local ost1node=$(facet_active_host ost1)
3565 local ost1tmp=$TMP/conf52
3568 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
3569 touch $TMP/modified_first || error "Unable to create temporary file"
3570 local mtime=$(stat -c %Y $TMP/modified_first)
3571 do_node $ost1node "mkdir -p $ost1tmp &&
3572 touch -m -d @$mtime $ost1tmp/modified_first" ||
3573 error "Unable to create temporary file"
3576 $SETSTRIPE -c -1 -S 1M $DIR/$tdir || error "$SETSTRIPE failed"
3578 for (( i=0; i < nrfiles; i++ )); do
3579 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
3580 error "multiop failed"
3586 echo backup files to $TMP/files
3587 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
3588 copy_files_xattrs $(hostname) $TMP/files $TMP/file_xattrs $files ||
3589 error "Unable to copy files"
3591 umount_client $MOUNT || error "Unable to umount client"
3592 stop_ost || error "Unable to stop ost1"
3594 echo mount ost1 as ldiskfs
3595 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
3596 if ! do_node $ost1node test -b $ost1_dev; then
3599 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
3601 error "Unable to mount ost1 as ldiskfs"
3604 echo backup objects to $ost1tmp/objects
3605 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
3606 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
3607 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
3609 error "Unable to copy objects"
3611 # move objects to lost+found
3612 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
3613 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
3615 # recover objects dry-run
3616 if [ $(lustre_version_code ost1) -ge $(version_code 2.5.56) ]; then
3617 echo "ll_recover_lost_found_objs dry_run"
3619 "ll_recover_lost_found_objs -n -d $ost1mnt/O" ||
3620 error "ll_recover_lost_found_objs failed"
3624 echo "ll_recover_lost_found_objs fix run"
3625 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found" ||
3626 error "ll_recover_lost_found_objs failed"
3628 # compare restored objects against saved ones
3629 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
3630 [ $? -eq 0 ] || error "Unable to diff objects"
3632 do_node $ost1node "umount $ost1mnt" ||
3633 error "Unable to umount ost1 as ldiskfs"
3635 start_ost || error "Unable to start OST1"
3636 mount_client $MOUNT || error "Unable to mount client"
3639 diff_files_xattrs $(hostname) $TMP/files $TMP/file_xattrs $files ||
3640 error "Unable to diff files"
3642 rm -rf $TMP/files $TMP/file_xattrs ||
3643 error "Unable to delete temporary files"
3644 do_node $ost1node "rm -rf $ost1tmp" ||
3645 error "Unable to delete temporary files"
3646 cleanup || error "cleanup failed with $?"
3648 run_test 52 "check recovering objects from lost+found"
3650 # Checks threads_min/max/started for some service
3652 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
3653 # parameter pattern prefix like 'ost.*.ost'.
3666 local msg="Insane $modname thread counts"
3667 local ncpts=$(check_cpt_number $facet)
3671 check_mount || return 41
3673 # We need to expand $parampat, but it may match multiple parameters, so
3674 # we'll pick the first one
3675 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
3676 error "Couldn't expand ${parampat}.threads_min parameter name"
3680 # Remove the .threads_min part
3681 paramp=${paramp%.threads_min}
3683 # Check for sanity in defaults
3684 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
3686 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
3688 tstarted=$(do_facet $facet "$LCTL get_param \
3689 -n ${paramp}.threads_started" || echo 0)
3690 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
3692 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
3694 nthrs=$(expr $tmax - $tmin)
3695 if [ $nthrs -lt $ncpts ]; then
3701 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
3702 skip_env "module parameter forced $facet thread count" &&
3703 tmin=3 && tmax=$((3 * tmax))
3705 # Check that we can change min/max
3706 do_facet $facet "$LCTL set_param \
3707 ${paramp}.threads_min=$((tmin + nthrs))"
3708 do_facet $facet "$LCTL set_param \
3709 ${paramp}.threads_max=$((tmax - nthrs))"
3710 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
3712 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
3714 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
3715 $tmax2 == ($tmax - $nthrs)))' || return $?
3717 # Check that we can set min/max to the same value
3718 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
3720 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
3721 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
3723 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
3725 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
3727 # Check that we can't set max < min
3728 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
3729 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
3731 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
3733 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
3735 # We need to ensure that we get the module options desired; to do this
3736 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
3737 LOAD_MODULES_REMOTE=true
3740 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
3741 setmodopts -a $modname "$newvalue" oldvalue
3745 check_mount || return 41
3747 # Restore previous setting of MODOPTS_*
3748 setmodopts $modname "$oldvalue"
3750 # Check that $opts took
3751 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min")
3752 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max")
3753 tstarted=$(do_facet $facet \
3754 "$LCTL get_param -n ${paramp}.threads_started")
3755 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
3765 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
3766 cleanup || error "cleanup failed with rc $?"
3768 run_test 53a "check OSS thread count params"
3772 local mds=$(do_facet $SINGLEMDS "$LCTL get_param \
3773 -N mds.*.*.threads_max 2>/dev/null")
3774 if [ -z "$mds" ]; then
3775 #running this on an old MDT
3776 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
3778 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
3780 cleanup || error "cleanup failed with $?"
3782 run_test 53b "check MDS thread count params"
3785 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3786 skip "Only applicable to ldiskfs-based MDTs"
3790 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
3791 error "llverdev failed with rc=$?"
3794 run_test 54a "test llverdev and partial verify of device"
3797 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3798 skip "Only applicable to ldiskfs-based MDTs"
3803 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
3804 cleanup || error "cleanup failed with rc=$?"
3806 run_test 54b "test llverfs and partial verify of filesystem"
3810 local max_ost_index=$1
3811 echo -n $(((max_ost_index + 1) * 8))
3815 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3816 skip "Only applicable to ldiskfs-based MDTs"
3820 local mdsdev=$(mdsdevname 1)
3821 local mdsvdev=$(mdsvdevname 1)
3825 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
3827 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
3828 --reformat $(ostdevname 1) $(ostvdevname 1)
3834 echo checking size of lov_objid for ost index $i
3835 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
3836 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
3837 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
3839 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
3846 run_test 55 "check lov_objid size"
3849 local server_version=$(lustre_version_code $SINGLEMDS)
3850 local mds_journal_size_orig=$MDSJOURNALSIZE
3855 for num in $(seq 1 $MDSCOUNT); do
3856 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3857 --reformat $(mdsdevname $num) $(mdsvdevname $num)
3859 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
3860 $(ostdevname 1) $(ostvdevname 1)
3861 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
3862 $(ostdevname 2) $(ostvdevname 2)
3865 start_ost || error "Unable to start first ost (idx 10000)"
3866 start_ost2 || error "Unable to start second ost (idx 1000)"
3867 mount_client $MOUNT || error "Unable to mount client"
3871 if [[ $server_version -ge $(version_code 2.6.54) ]] ||
3872 [[ $server_version -ge $(version_code 2.5.4) &&
3873 $server_version -lt $(version_code 2.5.11) ]]; then
3874 wait_osc_import_state mds ost1 FULL
3875 wait_osc_import_state mds ost2 FULL
3876 $SETSTRIPE --stripe-count=-1 $DIR/$tfile ||
3877 error "Unable to setstripe $DIR/$tfile"
3878 n=$($LFS getstripe --stripe-count $DIR/$tfile)
3879 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
3884 MDSJOURNALSIZE=$mds_journal_size_orig
3887 run_test 56 "check big OST indexes and out-of-index-order start"
3889 test_57a() { # bug 22656
3890 do_rpc_nodes $(facet_active_host ost1) load_modules_local
3891 local NID=$(do_facet ost1 "$LCTL get_param nis" |
3892 tail -1 | awk '{print $1}')
3893 writeconf_or_reformat
3894 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3895 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
3896 error "tunefs failed"
3898 start_ost && error "OST registration from failnode should fail"
3901 run_test 57a "initial registration from failnode should fail (should return errs)"
3904 do_rpc_nodes $(facet_active_host ost1) load_modules_local
3905 local NID=$(do_facet ost1 "$LCTL get_param nis" |
3906 tail -1 | awk '{print $1}')
3907 writeconf_or_reformat
3908 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3909 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
3910 error "tunefs failed"
3912 start_ost || error "OST registration from servicenode should not fail"
3915 run_test 57b "initial registration from servicenode should not fail"
3918 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
3921 test_58() { # bug 22658
3923 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3924 createmany -o $DIR/$tdir/$tfile-%d 100
3925 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
3926 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
3927 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x601"
3928 unlinkmany $DIR/$tdir/$tfile-%d 100
3929 stop_mds || error "Unable to stop MDS"
3931 local MNTDIR=$(facet_mntpt $SINGLEMDS)
3932 local devname=$(mdsdevname ${SINGLEMDS//mds/})
3934 # remove all files from the OBJECTS dir
3935 mount_fstype $SINGLEMDS
3937 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
3939 unmount_fstype $SINGLEMDS
3940 # restart MDS with missing llog files
3941 start_mds || error "unable to start MDS"
3942 do_facet mds "$LCTL set_param fail_loc=0"
3945 run_test 58 "missing llog files must not prevent MDT from mounting"
3948 start_mgsmds >> /dev/null
3949 local C1=$(count_osts)
3950 if [ $C1 -eq 0 ]; then
3951 start_ost >> /dev/null
3955 echo "original ost count: $C1 (expect > 0)"
3956 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
3957 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
3958 local C2=$(count_osts)
3959 echo "after mdt writeconf count: $C2 (expect 0)"
3960 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
3961 echo "OST start without writeconf should fail:"
3962 start_ost >> /dev/null &&
3963 error "OST start without writeconf didn't fail"
3964 echo "OST start with writeconf should succeed:"
3965 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
3966 local C3=$(count_osts)
3967 echo "after ost writeconf count: $C3 (expect 1)"
3968 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
3969 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
3970 local C4=$(count_osts)
3971 echo "after ost2 writeconf count: $C4 (expect 2)"
3972 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
3973 stop_ost2 >> /dev/null
3974 cleanup_nocli >> /dev/null
3975 #writeconf to remove all ost2 traces for subsequent tests
3976 writeconf_or_reformat
3978 run_test 59 "writeconf mount option"
3980 test_60() { # LU-471
3983 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3984 skip "Only applicable to ldiskfs-based MDTs"
3988 for num in $(seq $MDSCOUNT); do
3989 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3990 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
3991 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3995 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
3996 [ ${PIPESTATUS[0]} -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
3998 # MDT default has dirdata feature
3999 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
4000 # we disable uninit_bg feature
4001 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
4002 # we set stride extended options
4003 echo $dump | grep stride > /dev/null || error "stride is not set"
4006 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
4011 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
4012 { skip "Need MDS version at least 2.1.53"; return 0; }
4014 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
4015 ! large_xattr_enabled; then
4018 for num in $(seq $MDSCOUNT); do
4019 do_facet mds${num} $TUNE2FS -O large_xattr \
4020 $(mdsdevname $num) ||
4021 error "tune2fs on mds $num failed"
4025 setup_noconfig || error "setting up the filesystem failed"
4026 client_up || error "starting client failed"
4028 local file=$DIR/$tfile
4029 touch $file || error "touch $file failed"
4031 local large_value="$(generate_string $(max_xattr_size))"
4032 local small_value="bar"
4034 local name="trusted.big"
4035 log "save large xattr $name on $file"
4036 setfattr -n $name -v $large_value $file ||
4037 error "saving $name on $file failed"
4039 local new_value=$(get_xattr_value $name $file)
4040 [[ "$new_value" != "$large_value" ]] &&
4041 error "$name different after saving"
4043 log "shrink value of $name on $file"
4044 setfattr -n $name -v $small_value $file ||
4045 error "shrinking value of $name on $file failed"
4047 new_value=$(get_xattr_value $name $file)
4048 [[ "$new_value" != "$small_value" ]] &&
4049 error "$name different after shrinking"
4051 log "grow value of $name on $file"
4052 setfattr -n $name -v $large_value $file ||
4053 error "growing value of $name on $file failed"
4055 new_value=$(get_xattr_value $name $file)
4056 [[ "$new_value" != "$large_value" ]] &&
4057 error "$name different after growing"
4059 log "check value of $name on $file after remounting MDS"
4061 new_value=$(get_xattr_value $name $file)
4062 [[ "$new_value" != "$large_value" ]] &&
4063 error "$name different after remounting MDS"
4065 log "remove large xattr $name from $file"
4066 setfattr -x $name $file || error "removing $name from $file failed"
4071 for num in $(seq $MDSCOUNT); do
4072 do_facet mds${num} $TUNE2FS -O ^large_xattr \
4073 $(mdsdevname $num) ||
4074 error "tune2fs on mds $num failed"
4078 run_test 61 "large xattr"
4081 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4082 skip "Only applicable to ldiskfs-based MDTs"
4087 local mdsdev=$(mdsdevname 1)
4088 local ostdev=$(ostdevname 1)
4090 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
4091 { skip "Need MDS version at least 2.2.51"; return 0; }
4093 echo "disable journal for mds"
4094 do_facet mds $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
4095 start_mds && error "MDT start should fail"
4096 echo "disable journal for ost"
4097 do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
4098 start_ost && error "OST start should fail"
4099 cleanup || error "cleanup failed with rc $?"
4102 run_test 62 "start with disabled journal"
4105 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4106 skip "Only applicable to ldiskfs-based MDTs"
4110 local inode_slab=$(do_facet $SINGLEMDS \
4111 "awk '/ldiskfs_inode_cache/ { print \\\$5 }' /proc/slabinfo")
4112 if [ -z "$inode_slab" ]; then
4113 skip "ldiskfs module has not been loaded"
4117 echo "$inode_slab ldisk inodes per page"
4118 [ "$inode_slab" -ge "3" ] ||
4119 error "ldisk inode size is too big, $inode_slab objs per page"
4122 run_test 63 "Verify each page can at least hold 3 ldisk inodes"
4125 start_mds || error "unable to start MDS"
4126 start_ost || error "Unable to start OST1"
4127 start_ost2 || error "Unable to start second ost"
4128 mount_client $MOUNT || error "Unable to mount client"
4129 stop_ost2 || error "Unable to stop second ost"
4131 $LFS df --lazy || error "lfs df failed"
4132 cleanup || error "cleanup failed with $?"
4133 #writeconf to remove all ost2 traces for subsequent tests
4134 writeconf_or_reformat
4136 run_test 64 "check lfs df --lazy "
4138 test_65() { # LU-2237
4139 # Currently, the test is only valid for ldiskfs backend
4140 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
4141 skip "non-ldiskfs backend" && return
4143 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4144 local brpt=$(facet_mntpt brpt)
4147 if ! do_facet $SINGLEMDS "test -b $devname"; then
4151 stop_mds || error "Unable to stop MDS"
4152 local obj=$(do_facet $SINGLEMDS \
4153 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
4155 if [ -z "$obj" ]; then
4156 # The MDT may be just re-formatted, mount the MDT for the
4157 # first time to guarantee the "last_rcvd" file is there.
4158 start_mds || error "fail to mount the MDS for the first time"
4159 stop_mds || error "Unable to stop MDS"
4162 # remove the "last_rcvd" file
4163 do_facet $SINGLEMDS "mkdir -p $brpt"
4164 do_facet $SINGLEMDS \
4165 "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
4166 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
4167 do_facet $SINGLEMDS "umount -d $brpt"
4169 # restart MDS, the "last_rcvd" file should be recreated.
4170 start_mds || error "fail to restart the MDS"
4171 stop_mds || error "Unable to stop MDS"
4172 obj=$(do_facet $SINGLEMDS \
4173 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
4174 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
4176 run_test 65 "re-create the lost last_rcvd file when server mount"
4179 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
4180 { skip "Need MGS version at least 2.3.59"; return 0; }
4183 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
4184 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
4186 echo "replace_nids should fail if MDS, OSTs and clients are UP"
4187 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4188 error "replace_nids fail"
4190 umount_client $MOUNT || error "unmounting client failed"
4191 echo "replace_nids should fail if MDS and OSTs are UP"
4192 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4193 error "replace_nids fail"
4195 stop_ost || error "Unable to stop OST1"
4196 echo "replace_nids should fail if MDS is UP"
4197 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4198 error "replace_nids fail"
4200 stop_mds || error "stopping mds failed"
4202 if combined_mgs_mds; then
4203 start_mdt 1 "-o nosvc" ||
4204 error "starting mds with nosvc option failed"
4207 echo "command should accept two parameters"
4208 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
4209 error "command should accept two params"
4211 echo "correct device name should be passed"
4212 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
4213 error "wrong devname"
4215 echo "wrong nids list should not destroy the system"
4216 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
4219 echo "replace OST nid"
4220 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
4221 error "replace nids failed"
4223 echo "command should accept two parameters"
4224 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
4225 error "command should accept two params"
4227 echo "wrong nids list should not destroy the system"
4228 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
4231 echo "replace MDS nid"
4232 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
4233 error "replace nids failed"
4235 if ! combined_mgs_mds ; then
4238 stop_mds || error "Unable to stop MDS"
4242 check_mount || error "error after nid replace"
4243 cleanup || error "cleanup failed"
4246 run_test 66 "replace nids"
4248 test_67() { #LU-2950
4249 local legacy="$TMP/legacy_lnet_config"
4250 local new="$TMP/new_routes_test"
4251 local out="$TMP/config_out_file"
4252 local verify="$TMP/conv_verify"
4253 local verify_conf="$TMP/conf_verify"
4255 # Create the legacy file that will be run through the
4256 # lustre_routes_conversion script
4257 cat <<- LEGACY_LNET_CONFIG > $legacy
4258 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
4259 tcp2 54 10.1.3.2@tcp;
4260 tcp3 10.3.4.3@tcp:3;
4264 # Create the verification file to verify the output of
4265 # lustre_routes_conversion script against.
4266 cat <<- VERIFY_LNET_CONFIG > $verify
4267 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
4268 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
4269 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
4270 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
4271 tcp4: { gateway: 10.3.3.4@tcp }
4274 # Create the verification file to verify the output of
4275 # lustre_routes_config script against
4276 cat <<- VERIFY_LNET_CONFIG > $verify_conf
4277 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
4278 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
4279 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
4280 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
4281 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
4284 lustre_routes_conversion $legacy $new > /dev/null
4285 if [ -f $new ]; then
4286 # verify the conversion output
4287 cmp -s $new $verify > /dev/null
4288 if [ $? -eq 1 ]; then
4289 error "routes conversion failed"
4292 lustre_routes_config --dry-run --verbose $new > $out
4293 # check that the script succeeded
4294 cmp -s $out $verify_conf > /dev/null
4295 if [ $? -eq 1 ]; then
4296 error "routes config failed"
4299 error "routes conversion test failed"
4301 # remove generated files
4302 rm -f $new $legacy $verify $verify_conf $out
4304 run_test 67 "test routes conversion and configuration"
4312 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.53) ] ||
4313 { skip "Need MDS version at least 2.4.53"; return 0; }
4315 umount_client $MOUNT || error "umount client failed"
4317 start_mdt 1 || error "MDT start failed"
4318 start_ost || error "Unable to start OST1"
4320 # START-END - the sequences we'll be reserving
4321 START=$(do_facet $SINGLEMDS \
4322 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4323 END=$((START + (1 << 30)))
4324 do_facet $SINGLEMDS \
4325 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4327 # reset the sequences MDT0000 has already assigned
4328 do_facet $SINGLEMDS \
4329 $LCTL set_param seq.srv*MDT0000.space=clear
4331 # remount to let the client allocate new sequence
4332 mount_client $MOUNT || error "mount client failed"
4334 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4335 do_facet $SINGLEMDS \
4336 $LCTL get_param seq.srv*MDT0000.space
4337 $LFS path2fid $DIR/$tfile
4339 local old_ifs="$IFS"
4341 fid=($($LFS path2fid $DIR/$tfile))
4345 if [[ $seq < $END ]]; then
4346 error "used reserved sequence $seq?"
4348 cleanup || error "cleanup failed with $?"
4350 run_test 68 "be able to reserve specific sequences in FLDB"
4352 # Test 69: is about the total number of objects ever created on an OST.
4353 # so that when it is reformatted the normal MDS->OST orphan recovery won't
4354 # just "precreate" the missing objects. In the past it might try to recreate
4355 # millions of objects after an OST was reformatted
4357 local server_version=$(lustre_version_code $SINGLEMDS)
4359 [[ $server_version -lt $(version_code 2.4.2) ]] &&
4360 skip "Need MDS version at least 2.4.2" && return
4362 [[ $server_version -ge $(version_code 2.4.50) ]] &&
4363 [[ $server_version -lt $(version_code 2.5.0) ]] &&
4364 skip "Need MDS version at least 2.5.0" && return
4367 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4369 # use OST0000 since it probably has the most creations
4370 local OSTNAME=$(ostname_from_index 0)
4371 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4372 local last_id=$(do_facet mds1 $LCTL get_param -n \
4373 osc.$mdtosc_proc1.prealloc_last_id)
4375 # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
4376 # verify that the LAST_ID recovery is working properly. If
4377 # not, then the OST will refuse to allow the MDS connect
4378 # because the LAST_ID value is too different from the MDS
4379 #define OST_MAX_PRECREATE=20000
4380 local ost_max_pre=20000
4381 local num_create=$(( ost_max_pre * 5 + 1 - last_id))
4383 # If the LAST_ID is already over 5 * OST_MAX_PRECREATE, we don't
4384 # need to create any files. So, skip this section.
4385 if [ $num_create -gt 0 ]; then
4386 # Check the number of inodes available on OST0
4388 local ifree=$($LFS df -i $MOUNT | awk '/OST0000/ { print $4 }')
4389 log "On OST0, $ifree inodes available. Want $num_create."
4391 $SETSTRIPE -i 0 $DIR/$tdir ||
4392 error "$SETSTRIPE -i 0 $DIR/$tdir failed"
4393 if [ $ifree -lt 10000 ]; then
4394 files=$(( ifree - 50 ))
4399 local j=$((num_create / files + 1))
4400 for i in $(seq 1 $j); do
4401 createmany -o $DIR/$tdir/$tfile-$i- $files ||
4402 error "createmany fail create $files files: $?"
4403 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
4404 error "unlinkmany failed unlink $files files"
4408 # delete all of the files with objects on OST0 so the
4409 # filesystem is not inconsistent later on
4410 $LFS find $MOUNT --ost 0 -print0 | xargs -0 rm
4412 umount_client $MOUNT || error "umount client failed"
4413 stop_ost || error "OST0 stop failure"
4414 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
4415 $(ostdevname 1) $(ostvdevname 1) ||
4416 error "reformat and replace $ostdev failed"
4417 start_ost || error "OST0 restart failure"
4418 wait_osc_import_state mds ost FULL
4420 mount_client $MOUNT || error "mount client failed"
4421 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
4422 local idx=$($GETSTRIPE -i $DIR/$tdir/$tfile-last)
4423 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
4425 local iused=$($LFS df -i $MOUNT | awk '/OST0000/ { print $3 }')
4426 log "On OST0, $iused used inodes"
4427 [ $iused -ge $((ost_max_pre/2 + 1000)) ] &&
4428 error "OST replacement created too many inodes; $iused"
4429 cleanup || error "cleanup failed with $?"
4431 run_test 69 "replace an OST with the same index"
4434 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4437 cleanup || error "cleanup failed with $?"
4439 start_mdt 1 || error "MDT0 start fail"
4441 start_ost || error "OST0 start fail"
4442 for num in $(seq 2 $MDSCOUNT); do
4443 start_mdt $num || return
4446 mount_client $MOUNT || error "mount client fails"
4448 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
4450 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4451 error "create remote dir fail"
4453 rm -rf $DIR/$tdir || error "delete dir fail"
4454 cleanup || error "cleanup failed with $?"
4456 run_test 70a "start MDT0, then OST, then MDT1"
4459 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4462 start_ost || error "OST0 start fail"
4464 start_mds || error "MDS start fail"
4466 mount_client $MOUNT || error "mount client fails"
4468 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
4470 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4471 error "create remote dir fail"
4473 rm -rf $DIR/$tdir || error "delete dir fail"
4475 cleanup || error "cleanup failed with $?"
4477 run_test 70b "start OST, MDT1, MDT0"
4480 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4483 start_mds || error "MDS start fail"
4484 start_ost || error "OST0 start fail"
4486 mount_client $MOUNT || error "mount client fails"
4487 stop_mdt 1 || error "MDT1 start fail"
4489 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
4490 echo "deactivate $mdc_for_mdt1"
4491 $LCTL --device $mdc_for_mdt1 deactivate ||
4492 error "set $mdc_for_mdt1 deactivate failed"
4494 mkdir $DIR/$tdir && error "mkdir succeed"
4496 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4497 error "create remote dir succeed"
4499 cleanup || error "cleanup failed with $?"
4501 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
4504 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4507 start_mds || error "MDS start fail"
4508 start_ost || error "OST0 start fail"
4510 mount_client $MOUNT || error "mount client fails"
4512 stop_mdt 2 || error "MDT1 start fail"
4514 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
4516 echo "deactivate $mdc_for_mdt2"
4517 $LCTL --device $mdc_for_mdt2 deactivate ||
4518 error "set $mdc_for_mdt2 deactivate failed"
4520 mkdir $DIR/$tdir || error "mkdir fail"
4521 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4522 error "create remote dir succeed"
4524 rm -rf $DIR/$tdir || error "delete dir fail"
4526 cleanup || error "cleanup failed with $?"
4528 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
4531 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4532 if combined_mgs_mds; then
4533 skip "needs separate MGS/MDT" && return
4537 start_mdt 1 || error "MDT0 start fail"
4538 start_ost || error "OST0 start fail"
4539 for num in $(seq 2 $MDSCOUNT); do
4540 start_mdt $num || return
4543 start_ost2 || error "OST1 start fail"
4545 mount_client $MOUNT || error "mount client fails"
4547 mkdir $DIR/$tdir || error "mkdir fail"
4548 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4549 error "create remote dir succeed"
4551 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4552 rm -rf $DIR/$tdir || error "delete dir fail"
4554 umount_client $MOUNT || error "umount_client failed"
4555 stop_mds || error "MDS stop fail"
4556 stop_ost || error "OST0 stop fail"
4557 stop_ost2 || error "OST1 stop fail"
4559 run_test 71a "start MDT0 OST0, MDT1, OST1"
4562 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4563 if combined_mgs_mds; then
4564 skip "needs separate MGS/MDT" && return
4568 for num in $(seq 2 $MDSCOUNT); do
4569 start_mdt $num || return
4571 start_ost || error "OST0 start fail"
4572 start_mdt 1 || error "MDT0 start fail"
4573 start_ost2 || error "OST1 start fail"
4575 mount_client $MOUNT || error "mount client fails"
4577 mkdir $DIR/$tdir || error "mkdir fail"
4578 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4579 error "create remote dir succeed"
4581 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4582 rm -rf $DIR/$tdir || error "delete dir fail"
4584 umount_client $MOUNT || error "umount_client failed"
4585 stop_mds || error "MDT0 stop fail"
4586 stop_ost || error "OST0 stop fail"
4587 stop_ost2 || error "OST1 stop fail"
4589 run_test 71b "start MDT1, OST0, MDT0, OST1"
4592 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4593 if combined_mgs_mds; then
4594 skip "needs separate MGS/MDT" && return
4598 start_ost || error "OST0 start fail"
4599 start_ost2 || error "OST1 start fail"
4600 for num in $(seq 2 $MDSCOUNT); do
4601 start_mdt $num || return
4603 start_mdt 1 || error "MDT0 start fail"
4605 mount_client $MOUNT || error "mount client fails"
4607 mkdir $DIR/$tdir || error "mkdir fail"
4608 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4609 error "create remote dir succeed"
4611 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4612 rm -rf $DIR/$tdir || error "delete dir fail"
4614 umount_client $MOUNT || error "umount_client failed"
4615 stop_mds || error "MDS stop fail"
4616 stop_ost || error "OST0 stop fail"
4617 stop_ost2 || error "OST1 stop fail"
4620 run_test 71c "start OST0, OST1, MDT1, MDT0"
4623 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4624 if combined_mgs_mds; then
4625 skip "needs separate MGS/MDT" && return
4629 start_ost || error "OST0 start fail"
4630 for num in $(seq 2 $MDSCOUNT); do
4631 start_mdt $num || return
4633 start_mdt 1 || error "MDT0 start fail"
4634 start_ost2 || error "OST1 start fail"
4636 mount_client $MOUNT || error "mount client fails"
4638 mkdir $DIR/$tdir || error "mkdir fail"
4639 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4640 error "create remote dir succeed"
4642 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4643 rm -rf $DIR/$tdir || error "delete dir fail"
4645 umount_client $MOUNT || error "umount_client failed"
4646 stop_mds || error "MDS stop fail"
4647 stop_ost || error "OST0 stop fail"
4648 stop_ost2 || error "OST1 stop fail"
4651 run_test 71d "start OST0, MDT1, MDT0, OST1"
4654 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4655 if combined_mgs_mds; then
4656 skip "needs separate MGS/MDT" && return
4660 start_ost || error "OST0 start fail"
4661 for num in $(seq 2 $MDSCOUNT); do
4662 start_mdt $num || return
4664 start_ost2 || error "OST1 start fail"
4665 start_mdt 1 || error "MDT0 start fail"
4667 mount_client $MOUNT || error "mount client fails"
4669 mkdir $DIR/$tdir || error "mkdir fail"
4670 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4671 error "create remote dir succeed"
4673 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4674 rm -rf $DIR/$tdir || error "delete dir fail"
4676 umount_client $MOUNT || error "umount_client failed"
4677 stop_mds || error "MDS stop fail"
4678 stop_ost || error "OST0 stop fail"
4679 stop_ost2 || error "OST1 stop fail"
4682 run_test 71e "start OST0, MDT1, OST1, MDT0"
4684 test_72() { #LU-2634
4685 local mdsdev=$(mdsdevname 1)
4686 local ostdev=$(ostdevname 1)
4687 local cmd="$E2FSCK -fnvd $mdsdev"
4690 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
4691 skip "ldiskfs only test" && return
4693 #tune MDT with "-O extents"
4695 for num in $(seq $MDSCOUNT); do
4696 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
4697 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4698 error "add mds $num failed"
4699 do_facet mds${num} "$TUNE2FS -O extents $(mdsdevname $num)" ||
4700 error "$TUNE2FS failed on mds${num}"
4703 add ost1 $(mkfs_opts ost1 $ostdev) --reformat $ostdev ||
4704 error "add $ostdev failed"
4705 start_mgsmds || error "start mds failed"
4706 start_ost || error "start ost failed"
4707 mount_client $MOUNT || error "mount client failed"
4709 #create some short symlinks
4710 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4711 createmany -o $DIR/$tdir/$tfile-%d $fn
4712 echo "create $fn short symlinks"
4713 for i in $(seq -w 1 $fn); do
4714 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
4719 umount_client $MOUNT || error "umount client failed"
4720 stop_mds || error "stop mds failed"
4721 stop_ost || error "stop ost failed"
4724 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
4726 run_test 72 "test fast symlink with extents flag enabled"
4728 test_73() { #LU-3006
4730 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4731 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
4732 error "1st tunefs failed"
4733 start_mgsmds || error "start mds failed"
4734 start_ost || error "start ost failed"
4735 mount_client $MOUNT || error "mount client failed"
4736 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
4737 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
4738 umount_client $MOUNT || error "umount client failed"
4742 run_test 73 "failnode to update from mountdata properly"
4744 test_75() { # LU-2374
4745 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
4746 skip "Need MDS version at least 2.4.1" && return
4749 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
4750 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
4751 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
4752 --reformat $(ostdevname 1) $(ostvdevname 1)"
4754 #check with default parameters
4755 add mds1 $opts_mds || error "add mds1 failed for default params"
4756 add ost1 $opts_ost || error "add ost1 failed for default params"
4758 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
4759 opts_mds=$(echo $opts_mds |
4760 sed -e "s/--index=$index/--index=$index --mdt/")
4761 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
4762 opts_ost=$(echo $opts_ost |
4763 sed -e "s/--index=$index/--index=$index --ost/")
4765 add mds1 $opts_mds || error "add mds1 failed for new params"
4766 add ost1 $opts_ost || error "add ost1 failed for new params"
4769 run_test 75 "The order of --index should be irrelevant"
4772 [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] ||
4773 { skip "Need MDS version at least 2.4.52" && return 0; }
4775 local MDMB_PARAM="osc.*.max_dirty_mb"
4776 echo "Change MGS params"
4777 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
4779 echo "max_dirty_mb: $MAX_DIRTY_MB"
4780 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB + MAX_DIRTY_MB))
4781 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
4782 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
4783 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
4784 head -1" $NEW_MAX_DIRTY_MB
4785 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
4786 echo "$MAX_DIRTY_MB"
4787 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
4788 error "error while apply max_dirty_mb"
4790 echo "Check the value is stored after remount"
4793 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
4794 head -1" $NEW_MAX_DIRTY_MB
4795 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
4796 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
4797 error "max_dirty_mb is not saved after remount"
4799 echo "Change OST params"
4800 CLIENT_PARAM="obdfilter.*.client_cache_count"
4801 local CLIENT_CACHE_COUNT
4802 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4804 echo "client_cache_count: $CLIENT_CACHE_COUNT"
4805 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
4806 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
4807 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
4808 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
4809 head -1" $NEW_CLIENT_CACHE_COUNT
4810 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4812 echo "$CLIENT_CACHE_COUNT"
4813 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
4814 error "error while apply client_cache_count"
4816 echo "Check the value is stored after remount"
4819 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
4820 head -1" $NEW_CLIENT_CACHE_COUNT
4821 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4823 echo "$CLIENT_CACHE_COUNT"
4824 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
4825 error "client_cache_count is not saved after remount"
4828 run_test 76a "set permanent params set_param -P"
4830 test_76b() { # LU-4783
4831 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.57) ]] ||
4832 { skip "Need MGS version at least 2.5.57" && return 0; }
4835 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
4836 error "start params log failed"
4839 run_test 76b "verify params log setup correctly"
4841 test_77() { # LU-3445
4842 local server_version=$(lustre_version_code $SINGLEMDS)
4844 [[ $server_version -ge $(version_code 2.2.60) ]] &&
4845 [[ $server_version -le $(version_code 2.4.0) ]] &&
4846 skip "Need MDS version < 2.2.60 or > 2.4.0" && return
4848 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
4849 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
4850 skip_env "mixed loopback and real device not working" && return
4853 local fs2mdsdev=$(mdsdevname 1_2)
4854 local fs2ostdev=$(ostdevname 1_2)
4855 local fs2mdsvdev=$(mdsvdevname 1_2)
4856 local fs2ostvdev=$(ostvdevname 1_2)
4857 local fsname=test1234
4859 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
4861 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
4862 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
4863 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
4864 error "start fs2mds failed"
4866 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
4867 [[ $mgsnid = *,* ]] || mgsnid+=",$mgsnid"
4869 add fs2ost $(mkfs_opts ost1 $fs2ostdev) --mgsnode=$mgsnid \
4870 --failnode=$failnid --fsname=$fsname \
4871 --reformat $fs2ostdev $fs2ostvdev ||
4872 error "add fs2ost failed"
4873 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
4875 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
4876 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
4877 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
4880 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
4883 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ||
4884 $(facet_fstype ost1) != ldiskfs ]] &&
4885 skip "only applicable to ldiskfs-based MDTs and OSTs" && return
4887 # reformat the Lustre filesystem with a smaller size
4888 local saved_MDSSIZE=$MDSSIZE
4889 local saved_OSTSIZE=$OSTSIZE
4890 MDSSIZE=$((MDSSIZE - 20000))
4891 OSTSIZE=$((OSTSIZE - 20000))
4892 reformat || error "(1) reformat Lustre filesystem failed"
4893 MDSSIZE=$saved_MDSSIZE
4894 OSTSIZE=$saved_OSTSIZE
4896 # mount the Lustre filesystem
4897 setup_noconfig || error "(2) setup Lustre filesystem failed"
4900 log "create test files"
4904 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
4905 for i in $(seq $num_files); do
4906 file=$MOUNT/$tdir/$tfile-$i
4907 dd if=/dev/urandom of=$file count=1 bs=1M ||
4908 error "(4) create $file failed"
4911 # unmount the Lustre filesystem
4912 cleanup || error "(5) cleanup Lustre filesystem failed"
4914 # run e2fsck on the MDT and OST devices
4915 local mds_host=$(facet_active_host $SINGLEMDS)
4916 local ost_host=$(facet_active_host ost1)
4917 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
4918 local ost_dev=$(ostdevname 1)
4920 run_e2fsck $mds_host $mds_dev "-y"
4921 run_e2fsck $ost_host $ost_dev "-y"
4923 # get the original block count of the MDT and OST filesystems
4924 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
4925 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
4927 # expand the MDT and OST filesystems to the device size
4928 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
4929 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
4931 # run e2fsck on the MDT and OST devices again
4932 run_e2fsck $mds_host $mds_dev "-y"
4933 run_e2fsck $ost_host $ost_dev "-y"
4935 # mount the Lustre filesystem
4939 log "check files after expanding the MDT and OST filesystems"
4940 for i in $(seq $num_files); do
4941 file=$MOUNT/$tdir/$tfile-$i
4942 $CHECKSTAT -t file -s 1048576 $file ||
4943 error "(6) checkstat $file failed"
4947 log "create more files after expanding the MDT and OST filesystems"
4948 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
4949 file=$MOUNT/$tdir/$tfile-$i
4950 dd if=/dev/urandom of=$file count=1 bs=1M ||
4951 error "(7) create $file failed"
4954 # unmount the Lustre filesystem
4955 cleanup || error "(8) cleanup Lustre filesystem failed"
4957 # run e2fsck on the MDT and OST devices
4958 run_e2fsck $mds_host $mds_dev "-y"
4959 run_e2fsck $ost_host $ost_dev "-y"
4961 # get the maximum block count of the MDT and OST filesystems
4962 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
4963 local ost_max_blks=$(get_block_count ost1 $ost_dev)
4965 # get the minimum block count of the MDT and OST filesystems
4966 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
4967 grep minimum | sed -e 's/^.*filesystem: //g')
4968 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
4969 grep minimum | sed -e 's/^.*filesystem: //g')
4971 # shrink the MDT and OST filesystems to a smaller size
4975 if [[ $mds_max_blks -gt $mds_min_blks &&
4976 $mds_max_blks -gt $mds_orig_blks ]]; then
4977 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
4978 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
4979 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
4980 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
4981 error "shrink $SINGLEMDS to $new_blks failed"
4985 if [[ $ost_max_blks -gt $ost_min_blks &&
4986 $ost_max_blks -gt $ost_orig_blks ]]; then
4987 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
4988 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
4989 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
4990 run_resize2fs ost1 $ost_dev $new_blks ||
4991 error "shrink ost1 to $new_blks failed"
4995 # check whether the MDT or OST filesystem was shrunk or not
4997 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
4998 reformat || error "(10) reformat Lustre filesystem failed"
5002 # run e2fsck on the MDT and OST devices again
5003 run_e2fsck $mds_host $mds_dev "-y"
5004 run_e2fsck $ost_host $ost_dev "-y"
5006 # mount the Lustre filesystem again
5010 log "check files after shrinking the MDT and OST filesystems"
5011 for i in $(seq $((num_files + 10))); do
5012 file=$MOUNT/$tdir/$tfile-$i
5013 $CHECKSTAT -t file -s 1048576 $file ||
5014 error "(11) checkstat $file failed"
5017 # unmount and reformat the Lustre filesystem
5018 cleanup || error "(12) cleanup Lustre filesystem failed"
5019 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
5020 reformat || error "(14) reformat Lustre filesystem failed"
5022 run_test 78 "run resize2fs on MDT and OST filesystems"
5024 test_79() { # LU-4227
5025 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.59) ]] ||
5026 { skip "Need MDS version at least 2.5.59"; return 0; }
5028 local mdsdev1=$(mdsdevname 1)
5029 local mdsvdev1=$(mdsvdevname 1)
5030 local mdsdev2=$(mdsdevname 2)
5031 local mdsvdev2=$(mdsvdevname 2)
5032 local ostdev1=$(ostdevname 1)
5033 local ostvdev1=$(ostvdevname 1)
5034 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
5035 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
5036 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
5039 # remove --mgs/--mgsnode from mkfs.lustre options
5040 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
5042 mgsnode_opt=$(echo $opts_mds2 |
5043 awk '{ for ( i = 1; i < NF; i++ )
5044 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5045 [ -n $mgsnode_opt ] &&
5046 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
5048 mgsnode_opt=$(echo $opts_ost1 |
5049 awk '{ for ( i = 1; i < NF; i++ )
5050 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5051 [ -n $mgsnode_opt ] &&
5052 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
5054 # -MGS, format a mdt without --mgs option
5055 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
5056 error "Must specify --mgs when formatting mdt combined with mgs"
5058 # +MGS, format a mdt/ost without --mgsnode option
5059 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
5060 > /dev/null || error "start mds1 failed"
5061 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
5062 error "Must specify --mgsnode when formatting a mdt"
5063 add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
5064 error "Must specify --mgsnode when formatting an ost"
5068 run_test 79 "format MDT/OST without mgs option (should return errors)"
5071 start_mds || error "Failed to start MDT"
5072 start_ost || error "Failed to start OST1"
5073 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
5074 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
5075 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
5076 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
5077 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
5079 start_ost2 || error "Failed to start OST2"
5081 do_facet ost1 "$LCTL set_param fail_loc=0"
5084 run_test 80 "mgc import reconnect race"
5086 #Save the original values of $OSTCOUNT and $OSTINDEX$i.
5088 local new_ostcount=$1
5089 saved_ostcount=$OSTCOUNT
5090 OSTCOUNT=$new_ostcount
5094 for i in $(seq $OSTCOUNT); do
5096 eval saved_ostindex$i=${!index}
5101 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
5102 restore_ostindex() {
5107 for i in $(seq $OSTCOUNT); do
5108 index=saved_ostindex$i
5109 eval OSTINDEX$i=${!index}
5111 OSTCOUNT=$saved_ostcount
5116 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
5117 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
5118 # assigned index and ensures we can mount such a formatted file system
5119 test_81() { # LU-4665
5120 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5121 { skip "Need MDS version at least 2.6.54" && return; }
5122 [[ $OSTCOUNT -ge 3 ]] || { skip_env "Need at least 3 OSTs" && return; }
5126 # Each time RANDOM is referenced, a random integer between 0 and 32767
5129 local saved_ostindex1=$OSTINDEX1
5130 for i in 65535 $((RANDOM + 65536)); do
5131 echo -e "\nFormat ost1 with --index=$i, should fail"
5133 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
5134 $(ostdevname 1) $(ostvdevname 1); then
5135 OSTINDEX1=$saved_ostindex1
5136 error "format ost1 with --index=$i should fail"
5139 OSTINDEX1=$saved_ostindex1
5143 # Format OSTs with random sparse indices.
5144 trap "restore_ostindex" EXIT
5145 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices"
5146 OST_INDEX_LIST=[0,$((RANDOM * 2 % 65533 + 1)),65534] formatall
5148 # Setup and check Lustre filesystem.
5149 start_mgsmds || error "start_mgsmds failed"
5150 for i in $(seq $OSTCOUNT); do
5151 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5152 error "start ost$i failed"
5155 mount_client $MOUNT || error "mount client $MOUNT failed"
5156 check_mount || error "check client $MOUNT failed"
5159 local max_easize=$($LCTL get_param -n llite.*.max_easize)
5160 [[ $max_easize -eq 128 ]] ||
5161 error "max_easize is $max_easize, should be 128 bytes"
5165 run_test 81 "sparse OST indexing"
5167 # Wait OSTs to be active on both client and MDT side.
5169 local cmd="$LCTL get_param -n lov.$FSNAME-clilov-*.target_obd |
5170 awk 'BEGIN {c = 0} /ACTIVE/{c += 1} END {printf \\\"%d\\\", c}'"
5171 wait_update $HOSTNAME "eval $cmd" $OSTCOUNT ||
5172 error "wait_update OSTs up on client failed"
5174 cmd="$LCTL get_param -n lod.$FSNAME-MDT*-*.target_obd | sort -u |
5175 awk 'BEGIN {c = 0} /ACTIVE/{c += 1} END {printf \\\"%d\\\", c}'"
5176 wait_update_facet $SINGLEMDS "eval $cmd" $OSTCOUNT ||
5177 error "wait_update OSTs up on MDT failed"
5180 # Here we exercise the stripe placement functionality on a file system that
5181 # has formatted the OST with a random index. With the file system the following
5182 # functionality is tested:
5184 # 1. Creating a new file with a specific stripe layout.
5186 # 2. Modifiy a existing empty file with a specific stripe layout.
5188 # 3. Ensure we fail to set the stripe layout of a file that already has one.
5190 # 4. If ost-index is defined we need to ensure it is the first entry in the
5191 # ost index list returned by lfs getstripe.
5193 # 5. Lastly ensure this functionality fails with directories.
5194 test_82a() { # LU-4665
5195 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5196 { skip "Need MDS version at least 2.6.54" && return; }
5197 [[ $OSTCOUNT -ge 3 ]] || { skip_env "Need at least 3 OSTs" && return; }
5203 # Format OSTs with random sparse indices.
5207 for i in $(seq $OSTCOUNT); do
5208 index=$((RANDOM * 2))
5209 ost_indices+=" $index"
5211 ost_indices=$(comma_list $ost_indices)
5213 trap "restore_ostindex" EXIT
5214 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5215 OST_INDEX_LIST=[$ost_indices] formatall
5217 # Setup Lustre filesystem.
5218 start_mgsmds || error "start_mgsmds failed"
5219 for i in $(seq $OSTCOUNT); do
5220 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5221 error "start ost$i failed"
5224 mount_client $MOUNT || error "mount client $MOUNT failed"
5227 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
5228 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5230 # 1. If the file does not exist, new file will be created
5231 # with specified OSTs.
5232 local file=$DIR/$tdir/$tfile-1
5233 local cmd="$SETSTRIPE -o $ost_indices $file"
5235 eval $cmd || error "$cmd failed"
5236 check_stripe_count $file $OSTCOUNT
5237 check_obdidx $file $ost_indices
5238 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5239 error "write $file failed"
5241 # 2. If the file already exists and is an empty file, the file
5242 # will be attached with specified layout.
5243 file=$DIR/$tdir/$tfile-2
5244 mcreate $file || error "mcreate $file failed"
5245 cmd="$SETSTRIPE -o $ost_indices $file"
5247 eval $cmd || error "$cmd failed"
5248 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5249 error "write $file failed"
5250 check_stripe_count $file $OSTCOUNT
5251 check_obdidx $file $ost_indices
5253 # 3. If the file already has a valid layout attached, the command
5254 # should fail with EBUSY.
5256 eval $cmd && error "stripe is already set on $file, $cmd should fail"
5258 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
5259 # be in the OST indices list.
5260 local start_ost_idx=${ost_indices##*,}
5261 file=$DIR/$tdir/$tfile-3
5262 cmd="$SETSTRIPE -o $ost_indices -i $start_ost_idx $file"
5264 eval $cmd || error "$cmd failed"
5265 check_stripe_count $file $OSTCOUNT
5266 check_obdidx $file $ost_indices
5267 check_start_ost_idx $file $start_ost_idx
5269 file=$DIR/$tdir/$tfile-4
5271 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
5272 cmd+=" -i $start_ost_idx $file"
5274 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
5276 # 5. Specifying OST indices for directory should fail with ENOSUPP.
5277 local dir=$DIR/$tdir/$tdir
5278 mkdir $dir || error "mkdir $dir failed"
5279 cmd="$SETSTRIPE -o $ost_indices $dir"
5281 eval $cmd && error "$cmd should fail, specifying OST indices" \
5282 "for directory is not supported"
5286 run_test 82a "specify OSTs for file (succeed) or directory (fail)"
5291 # Remove OSTs from a pool and destroy the pool.
5292 destroy_pool $ost_pool || true
5297 # Test 82b is run to ensure that if the user supplies a pool with a specific
5298 # stripe layout that it behaves proprerly. It should fail in the case that
5299 # the supplied OST index list points to OSTs not contained in the user
5301 test_82b() { # LU-4665
5302 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5303 { skip "Need MDS version at least 2.6.54" && return; }
5304 [[ $OSTCOUNT -ge 4 ]] || { skip_env "Need at least 4 OSTs" && return; }
5310 # Format OSTs with random sparse indices.
5314 for i in $(seq $OSTCOUNT); do
5315 index=$((RANDOM * 2))
5316 ost_indices+=" $index"
5318 ost_indices=$(comma_list $ost_indices)
5320 trap "restore_ostindex" EXIT
5321 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5322 OST_INDEX_LIST=[$ost_indices] formatall
5324 # Setup Lustre filesystem.
5325 start_mgsmds || error "start_mgsmds failed"
5326 for i in $(seq $OSTCOUNT); do
5327 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5328 error "start ost$i failed"
5331 mount_client $MOUNT || error "mount client $MOUNT failed"
5333 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
5334 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5336 # Create a new pool and add OSTs into it.
5337 local ost_pool=$FSNAME.$TESTNAME
5338 create_pool $ost_pool || error "create OST pool $ost_pool failed"
5341 trap "cleanup_82b" EXIT
5343 local ost_idx_in_list=${ost_indices##*,}
5344 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
5347 local ost_targets="$FSNAME-OST["
5348 for i in ${ost_idx_in_pool//,/ }; do
5349 ost_targets=$ost_targets$(printf "%04x," $i)
5351 ost_targets="${ost_targets%,}]"
5353 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
5354 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
5355 sort -u | tr '\n' ' ')
5357 local cmd="$LCTL pool_add $ost_pool $ost_targets"
5358 do_facet mgs $cmd || error "$cmd failed"
5359 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
5360 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
5361 error "wait_update $ost_pool failed"
5362 pool_list $ost_pool || error "list OST pool $ost_pool failed"
5364 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
5365 # then the OSTs must be the members of the pool.
5366 local file=$DIR/$tdir/$tfile
5367 cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
5369 eval $cmd && error "OST with index $ost_idx_in_list should be" \
5370 "in OST pool $ost_pool"
5372 # Only select OST $ost_idx_in_list from $ost_pool for file.
5373 ost_idx_in_list=${ost_idx_in_pool#*,}
5374 cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
5376 eval $cmd || error "$cmd failed"
5377 cmd="$GETSTRIPE $file"
5379 eval $cmd || error "$cmd failed"
5380 check_stripe_count $file 2
5381 check_obdidx $file $ost_idx_in_list
5382 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5383 error "write $file failed"
5387 run_test 82b "specify OSTs for file with --pool and --ost-list options"
5390 [[ $(lustre_version_code ost1) -ge $(version_code 2.6.91) ]] ||
5391 { skip "Need OST version at least 2.6.91" && return 0; }
5392 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
5393 skip "Only applicable to ldiskfs-based MDTs"
5403 ostmnt=$(facet_mntpt ost1)
5404 fstype=$(facet_fstype ost1)
5406 # Mount the OST as an ldiskfs filesystem.
5407 log "mount the OST $dev as a $fstype filesystem"
5408 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
5409 --reformat $dev $dev > /dev/null ||
5410 error "format ost1 error"
5412 if ! test -b $dev; then
5413 mnt_opts=$(csa_add "$OST_MOUNT_OPTS" -o loop)
5415 echo "mnt_opts $mnt_opts"
5416 do_facet ost1 mount -t $fstype $dev \
5418 # Run llverfs on the mounted ldiskfs filesystem.
5419 # It is needed to get ENOSPACE.
5420 log "run llverfs in partial mode on the OST $fstype $ostmnt"
5421 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
5422 "no" || error "run_llverfs error on $fstype"
5425 log "unmount the OST $dev"
5428 # Delete file IO_scrub. Later osd_scrub_setup will try to
5429 # create "IO_scrub" but will get ENOSPACE.
5431 echo "start ost1 service on `facet_active_host ost1`"
5432 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
5435 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
5436 echo "string err $err"
5437 [ -z "$err" ] || error $err
5440 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
5441 Busy inodes after unmount ..."
5443 recovery_time_min() {
5444 local CONNECTION_SWITCH_MIN=5
5445 local CONNECTION_SWITCH_INC=5
5446 local CONNECTION_SWITCH_MAX
5447 local RECONNECT_DELAY_MAX
5448 local INITIAL_CONNECT_TIMEOUT
5452 #CONNECTION_SWITCH_MAX=min(50, max($CONNECTION_SWITCH_MIN,$TIMEOUT)
5453 (($CONNECTION_SWITCH_MIN>$TIMEOUT)) && \
5454 max=$CONNECTION_SWITCH_MIN || max=$TIMEOUT
5455 (($max<50)) && CONNECTION_SWITCH_MAX=$max || CONNECTION_SWITCH_MAX=50
5457 #INITIAL_CONNECT_TIMEOUT = max(CONNECTION_SWITCH_MIN, \
5459 TO_20=$(($TIMEOUT/20))
5460 (($CONNECTION_SWITCH_MIN>$TO_20)) && \
5461 INITIAL_CONNECT_TIMEOUT=$CONNECTION_SWITCH_MIN || \
5462 INITIAL_CONNECT_TIMEOUT=$TO_20
5464 RECONNECT_DELAY_MAX=$(($CONNECTION_SWITCH_MAX+$CONNECTION_SWITCH_INC+ \
5465 $INITIAL_CONNECT_TIMEOUT))
5466 echo $((2*$RECONNECT_DELAY_MAX))
5470 local facet=$SINGLEMDS
5471 local num=$(echo $facet | tr -d "mds")
5472 local dev=$(mdsdevname $num)
5473 local time_min=$(recovery_time_min)
5474 local recovery_duration
5475 local completed_clients
5478 echo "start mds service on $(facet_active_host $facet)"
5479 start $facet ${dev} $MDS_MOUNT_OPTS \
5480 "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" $@ ||
5481 error "start MDS failed"
5486 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
5488 mount_client $MOUNT1 || error "mount failed"
5489 mount_client $MOUNT2 || error "mount failed"
5491 replay_barrier $SINGLEMDS
5492 createmany -o $DIR1/$tfile-%d 1000
5494 # We need to catch the end of recovery window to extend it.
5495 # Skip 5 requests and add delay to request handling.
5496 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
5497 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
5499 facet_failover $SINGLEMDS || error "failover: $?"
5502 echo "recovery status"
5503 do_facet $SINGLEMDS \
5504 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
5506 recovery_duration=$(do_facet $SINGLEMDS \
5507 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
5508 awk '/recovery_duration/ { print $2 }')
5509 (( $recovery_duration > $time_min + $wrap_up )) &&
5510 error "recovery_duration > recovery_time_hard + wrap up"
5511 completed_clients=$(do_facet $SINGLEMDS \
5512 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
5513 awk '/completed_clients/ { print $2 }')
5514 [ "$completed_clients" = "1/2" ] ||
5515 error "completed_clients != 1/2: $completed_clients"
5517 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
5518 umount_client $MOUNT1
5519 umount_client $MOUNT2
5525 run_test 84 "check recovery_hard_time"
5528 [[ $(lustre_version_code ost1) -ge $(version_code 2.7.55) ]] ||
5529 { skip "Need OST version at least 2.7.55" && return 0; }
5530 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
5531 do_facet ost1 "lctl set_param fail_loc=0x197"
5535 run_test 85 "osd_ost init: fail ea_fid_set"
5538 [ "$(facet_fstype ost1)" = "zfs" ] &&
5539 skip "LU-6442: no such mkfs params for ZFS OSTs" && return
5541 local OST_OPTS="$(mkfs_opts ost1 $(ostdevname 1)) \
5542 --reformat $(ostdevname 1) $(ostvdevname 1)"
5545 local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
5546 awk '/Flex block group size: / { print $NF; exit; }')
5549 if [[ ${!opts} != *mkfsoptions* ]]; then
5550 eval opts=\"${!opts} \
5551 --mkfsoptions='\\\"-O flex_bg -G $NEWSIZE\\\"'\"
5553 val=${!opts//--mkfsoptions=\\\"/ \
5554 --mkfsoptions=\\\"-O flex_bg -G $NEWSIZE }
5558 echo "params: $opts"
5560 add ost1 $opts || error "add ost1 failed with new params"
5562 local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
5563 awk '/Flex block group size: / { print $NF; exit; }')
5565 [[ $FOUNDSIZE == $NEWSIZE ]] ||
5566 error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
5569 run_test 86 "Replacing mkfs.lustre -G option"
5571 test_87() { #LU-6544
5572 [[ $(lustre_version_code $SINGLEMDS1) -ge $(version_code 2.7.56) ]] ||
5573 { skip "Need MDS version at least 2.7.56" && return; }
5574 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
5575 { skip "Only applicable to ldiskfs-based MDTs" && return; }
5576 [[ $OSTCOUNT -gt 69 ]] &&
5577 { skip "Ignore wide striping situation" && return; }
5579 local mdsdev=$(mdsdevname 1)
5580 local mdsvdev=$(mdsvdevname 1)
5581 local file=$DIR/$tfile
5582 local mntpt=$(facet_mntpt $SINGLEMDS)
5583 local used_xattr_blk=0
5584 local inode_size=${1:-512}
5586 local xtest="trusted.test"
5591 #Please see LU-6544 for MDT inode size calculation
5592 if [ $OSTCOUNT -gt 26 ]; then
5594 elif [ $OSTCOUNT -gt 5 ]; then
5597 left_size=$(expr $inode_size - \
5600 32 - $OSTCOUNT \* 24 - 16 - 3 - \
5602 24 - 18 - $(expr length $tfile) - 16 - 4)
5603 if [ $left_size -le 0 ]; then
5604 echo "No space($left_size) is expected in inode."
5605 echo "Try 1-byte xattr instead to verify this."
5608 echo "Estimate: at most $left_size-byte space left in inode."
5614 add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$OSTCOUNT \
5615 --reformat $mdsdev $mdsvdev || error "add mds1 failed"
5616 start_mdt 1 > /dev/null || error "start mdt1 failed"
5617 for i in $(seq $OSTCOUNT); do
5618 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
5619 error "start ost$i failed"
5621 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
5622 check_mount || error "check client $MOUNT failed"
5625 $SETSTRIPE -c -1 $file || error "$SETSTRIPE -c -1 $file failed"
5626 $GETSTRIPE $file || error "$GETSTRIPE $file failed"
5627 i=$($GETSTRIPE -c $file)
5628 if [ $i -ne $OSTCOUNT ]; then
5629 left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
5630 echo -n "Since only $i out $OSTCOUNT OSTs are used, "
5631 echo -n "the expected left space is changed to "
5632 echo "$left_size bytes at most."
5634 value=$(generate_string $left_size)
5635 setfattr -n $xtest -v $value $file
5636 orig=$(get_xattr_value $xtest $file)
5637 [[ "$orig" != "$value" ]] && error "$xtest changed"
5639 #Verify if inode has some expected space left
5640 umount $MOUNT > /dev/null || error "umount $MOUNT failed"
5641 stop_mdt 1 > /dev/null || error "stop mdt1 failed"
5642 mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
5644 do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
5645 used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
5647 [[ $used_xattr_blk -eq 0 ]] &&
5648 error "Please check MDS inode size calculation: \
5649 more than $left_size-byte space left in inode."
5650 echo "Verified: at most $left_size-byte space left in inode."
5654 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
5657 # $2 (optional) value of max_mod_rpcs_in_flight to set
5658 check_max_mod_rpcs_in_flight() {
5666 idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
5667 facet="mds$((0x$idx + 1))"
5669 if [ -z "$mmr" ]; then
5670 # get value of max_mod_rcps_in_flight
5671 mmr=$($LCTL get_param -n \
5672 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
5673 error "Unable to get max_mod_rpcs_in_flight"
5674 echo "max_mod_rcps_in_flight is $mmr"
5676 # set value of max_mod_rpcs_in_flight
5678 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
5679 error "Unable to set max_mod_rpcs_in_flight to $mmr"
5680 echo "max_mod_rpcs_in_flight set to $mmr"
5683 # create mmr+1 files
5684 echo "creating $((mmr + 1)) files ..."
5686 for i in $(seq $((mmr + 1))); do
5692 # consumes mmr-1 modify RPC slots
5693 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
5694 # drop requests on MDT so that RPC slots are consumed
5695 # during all the request resend interval
5696 do_facet $facet "$LCTL set_param fail_loc=0x159"
5697 echo "launch $((mmr - 1)) chmod in parallel ..."
5698 for i in $(seq $((mmr - 1))); do
5699 chmod 0600 $dir/file-$i &
5702 # send one additional modify RPC
5703 do_facet $facet "$LCTL set_param fail_loc=0"
5704 echo "launch 1 additional chmod in parallel ..."
5705 chmod 0600 $dir/file-$mmr &
5708 # check this additional modify RPC get a modify RPC slot
5709 # and succeed its operation
5710 checkstat -vp 0600 $dir/file-$mmr ||
5711 error "Unable to send $mmr modify RPCs in parallel"
5716 # consumes mmr modify RPC slots
5717 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
5718 # drop requests on MDT so that RPC slots are consumed
5719 # during all the request resend interval
5720 do_facet $facet "$LCTL set_param fail_loc=0x159"
5721 echo "launch $mmr chmod in parallel ..."
5722 for i in $(seq $mmr); do
5723 chmod 0666 $dir/file-$i &
5726 # send one additional modify RPC
5727 do_facet $facet "$LCTL set_param fail_loc=0"
5728 echo "launch 1 additional chmod in parallel ..."
5729 chmod 0666 $dir/file-$((mmr + 1)) &
5732 # check this additional modify RPC blocked getting a modify RPC slot
5733 checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
5734 error "Unexpectedly send $mmr modify RPCs in parallel"
5740 if ! combined_mgs_mds ; then
5745 [[ $($LCTL get_param mdc.*.import |
5746 grep "connect_flags:.*multi_mod_rpc") ]] ||
5747 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
5749 # check default value
5750 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5751 check_max_mod_rpcs_in_flight $DIR/$tdir
5755 run_test 90a "check max_mod_rpcs_in_flight is enforced"
5765 [[ $($LCTL get_param mdc.*.import |
5766 grep "connect_flags:.*multi_mod_rpc") ]] ||
5767 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
5770 # update max_mod_rpcs_in_flight
5771 $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
5772 check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
5775 # check client is able to send multiple modify RPCs in paralell
5776 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
5777 grep -c "multi_mod_rpcs")
5778 if [ "$tmp" -ne $MDSCOUNT ]; then
5779 echo "Client not able to send multiple modify RPCs in parallel"
5784 # update max_mod_rpcs_in_flight
5785 $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
5786 check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
5789 $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
5790 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
5791 facet="mds$((0x$idx + 1))"
5793 # save MDT max_mod_rpcs_per_client
5794 mmrpc=$(do_facet $facet \
5795 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
5797 # update max_mod_rpcs_in_flight
5798 umount_client $MOUNT
5800 "echo 16 > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
5802 $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
5803 check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
5805 # restore MDT max_mod_rpcs_per_client initial value
5807 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
5809 rm -rf $DIR/${tdir}?
5812 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
5821 [[ $($LCTL get_param mdc.*.import |
5822 grep "connect_flags:.*multi_mod_rpc") ]] ||
5823 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
5825 # check client is able to send multiple modify RPCs in paralell
5826 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
5827 grep -c "multi_mod_rpcs")
5828 if [ "$tmp" -ne $MDSCOUNT ]; then
5829 skip "Client not able to send multiple modify RPCs in parallel"
5834 # get max_rpcs_in_flight value
5835 mrif=$($LCTL get_param -n mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
5836 echo "max_rpcs_in_flight is $mrif"
5838 # get MDT max_mod_rpcs_per_client
5839 mmrpc=$(do_facet mds1 \
5840 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
5841 echo "max_mod_rpcs_per_client is $mmrpc"
5844 # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
5845 # prerequisite: set max_mod_rpcs_per_client to max_rpcs_in_flight value
5846 umount_client $MOUNT
5848 "echo $mrif > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
5852 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif &&
5853 error "set max_mod_rpcs_in_flight to $mrif should fail"
5855 umount_client $MOUNT
5857 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
5861 # attempt to set max_mod_rpcs_in_flight to max_mod_rpcs_per_client+1
5862 # prerequisite: set max_rpcs_in_flight to max_mod_rpcs_per_client+2
5864 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc + 2))
5867 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc + 1)) &&
5868 error "set max_mod_rpcs_in_flight to $((mmrpc + 1)) should fail"
5872 run_test 90c "check max_mod_rpcs_in_flight update limits"
5883 [[ $($LCTL get_param mdc.*.import |
5884 grep "connect_flags:.*multi_mod_rpc") ]] ||
5885 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
5887 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5888 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
5889 facet="mds$((0x$idx + 1))"
5891 # check client version supports multislots
5892 tmp=$($LCTL get_param -N \
5893 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
5894 if [ -z "$tmp" ]; then
5895 skip "Client does not support multiple modify RPCs in flight"
5900 # get current value of max_mod_rcps_in_flight
5901 mmr=$($LCTL get_param -n \
5902 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
5903 echo "max_mod_rcps_in_flight is $mmr"
5906 echo "creating $mmr files ..."
5908 for i in $(seq $mmr); do
5909 touch $DIR/$tdir/file-$i
5912 # prepare for close RPC
5913 multiop_bg_pause $DIR/$tdir/file-close O_c
5916 # consumes mmr modify RPC slots
5917 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
5918 # drop requests on MDT so that RPC slots are consumed
5919 # during all the request resend interval
5920 do_facet $facet "$LCTL set_param fail_loc=0x159"
5921 echo "launch $mmr chmod in parallel ..."
5922 for i in $(seq $mmr); do
5923 chmod 0600 $DIR/$tdir/file-$i &
5926 # send one additional close RPC
5927 do_facet $facet "$LCTL set_param fail_loc=0"
5928 echo "launch 1 additional close in parallel ..."
5930 cancel_lru_locks mdc
5933 # check this additional close RPC get a modify RPC slot
5934 # and multiop process completed
5935 [ -d /proc/$pid ] &&
5936 error "Unable to send the additional close RPC in parallel"
5941 run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
5943 if ! combined_mgs_mds ; then
5949 # restore the values of MDSSIZE and OSTSIZE
5950 MDSSIZE=$STORED_MDSSIZE
5951 OSTSIZE=$STORED_OSTSIZE