7 # bug number for skipped test: LU-2828
8 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 59 64"
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
62 if ! combined_mgs_mds; then
63 # bug number for skipped test: 23954
64 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
67 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
68 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
69 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
72 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
73 # bug number for skipped test: LU-2778 LU-4444
74 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 57b 69"
79 require_dsh_mds || exit 0
80 require_dsh_ost || exit 0
82 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45 69"
87 # The MGS must be started before the OSTs for a new fs, so start
88 # and stop to generate the startup logs.
91 wait_osc_import_state mds ost FULL
96 reformat_and_config() {
98 if ! combined_mgs_mds ; then
104 writeconf_or_reformat() {
105 # There are at most 2 OSTs for write_conf test
106 # who knows if/where $TUNEFS is installed?
107 # Better reformat if it fails...
108 writeconf_all $MDSCOUNT 2 ||
109 { echo "tunefs failed, reformatting instead" &&
110 reformat_and_config && return 0; }
120 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
126 local dev=$(mdsdevname $num)
129 echo "start mds service on `facet_active_host $facet`"
130 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
136 local dev=$(mdsdevname $num)
139 echo "stop mds service on `facet_active_host $facet`"
140 # These tests all use non-failover stop
141 stop $facet -f || return 97
147 for num in $(seq $MDSCOUNT); do
148 start_mdt $num $@ || return 94
153 if ! combined_mgs_mds ; then
161 for num in $(seq $MDSCOUNT); do
162 stop_mdt $num || return 97
167 echo "stop mgs service on `facet_active_host mgs`"
168 # These tests all use non-failover stop
169 stop mgs -f || return 97
173 echo "start ost1 service on `facet_active_host ost1`"
174 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
178 echo "stop ost1 service on `facet_active_host ost1`"
179 # These tests all use non-failover stop
180 stop ost1 -f || return 98
184 echo "start ost2 service on `facet_active_host ost2`"
185 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
189 echo "stop ost2 service on `facet_active_host ost2`"
190 # These tests all use non-failover stop
191 stop ost2 -f || return 93
196 echo "mount $FSNAME on ${MOUNTPATH}....."
197 zconf_mount $(hostname) $MOUNTPATH || return 96
201 local mountopt="remount,$1"
203 echo "remount '$1' lustre on ${MOUNTPATH}....."
204 zconf_mount $(hostname) $MOUNTPATH "$mountopt" || return 96
209 echo "umount lustre on ${MOUNTPATH}....."
210 zconf_umount $(hostname) $MOUNTPATH || return 97
213 manual_umount_client(){
216 echo "manual umount lustre on ${MOUNT}...."
217 do_facet client "umount -d ${FORCE} $MOUNT"
223 start_mds || error "MDT start failed"
224 start_ost || error "Unable to start OST1"
225 mount_client $MOUNT || error "client start failed"
226 client_up || error "client_up failed"
235 unload_modules_conf () {
236 if combined_mgs_mds || ! local_mode; then
237 unload_modules || return 1
242 stop_ost || return 202
243 stop_mds || return 201
244 unload_modules_conf || return 203
248 umount_client $MOUNT || return 200
249 cleanup_nocli || return $?
253 do_facet client "cp /etc/passwd $DIR/a" || return 71
254 do_facet client "rm $DIR/a" || return 72
255 # make sure lustre is actually mounted (touch will block,
256 # but grep won't, so do it after)
257 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
258 echo "setup single mount lustre success"
262 do_facet client "touch $DIR/a" || return 71
263 do_facet client "rm $DIR/a" || return 72
264 do_facet client "touch $DIR2/a" || return 73
265 do_facet client "rm $DIR2/a" || return 74
266 echo "setup double mount lustre success"
271 if [ "$ONLY" == "setup" ]; then
276 if [ "$ONLY" == "cleanup" ]; then
283 #create single point mountpoint
289 check_mount || error "check_mount failed"
290 cleanup || error "cleanup failed with $?"
292 run_test 0 "single mount setup"
295 start_mds || error "MDS start failed"
296 start_ost || error "unable to start OST"
297 echo "start ost second time..."
298 start_ost && error "2nd OST start should fail"
299 mount_client $MOUNT || error "client start failed"
300 check_mount || error "check_mount failed"
301 cleanup || error "cleanup failed with $?"
303 run_test 1 "start up ost twice (should return errors)"
306 start_mdt 1 || error "MDT0 start fail"
307 echo "start mds second time.."
308 start_mdt 1 && error "2nd MDT start should fail"
309 start_ost || error "OST start failed"
310 mount_client $MOUNT || error "mount_client failed to start client"
311 check_mount || error "check_mount failed"
312 cleanup || error "cleanup failed with $?"
314 run_test 2 "start up mds twice (should return err)"
318 #mount.lustre returns an error if already in mtab
319 mount_client $MOUNT && error "2nd client mount should fail"
320 check_mount || error "check_mount failed"
321 cleanup || error "cleanup failed with $?"
323 run_test 3 "mount client twice (should return err)"
327 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
328 stop_ost || error "Unable to stop OST1"
331 # ok for ost to fail shutdown
332 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
333 error "cleanup failed with $?"
336 run_test 4 "force cleanup ost, then cleanup"
338 test_5a() { # was test_5
340 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
341 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
343 stop_mds || error "Unable to stop MDS"
345 # cleanup may return an error from the failed
346 # disconnects; for now I'll consider this successful
347 # if all the modules have unloaded.
351 echo "killing umount"
352 kill -TERM $UMOUNT_PID
353 echo "waiting for umount to finish"
355 if grep " $MOUNT " /proc/mounts; then
356 echo "test 5: /proc/mounts after failed umount"
360 echo "killing umount"
361 kill -TERM $UMOUNT_PID
362 echo "waiting for umount to finish"
364 grep " $MOUNT " /proc/mounts &&
365 error "/proc/mounts after second umount"
368 # manual_mount_client may fail due to umount succeeding above
370 # stop_mds is a no-op here, and should not fail
371 cleanup_nocli || error "cleanup_nocli failed with $?"
372 # df may have lingering entry
374 # mtab may have lingering entry
378 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
380 grep -q $MOUNT" " /etc/mtab || break
381 echo "Waiting /etc/mtab updated ... "
382 WAIT=$(( WAIT + sleep))
384 [ "$WAIT" -eq "$MAX_WAIT" ] &&
385 error "/etc/mtab is not updated in $WAIT secs"
386 echo "/etc/mtab updated in $WAIT secs"
388 run_test 5a "force cleanup mds, then cleanup"
396 grep " $MOUNT " /etc/mtab &&
397 error false "unexpected entry in mtab before mount" && return 10
399 start_ost || error "OST start failed"
400 if ! combined_mgs_mds ; then
401 trap cleanup_5b EXIT ERR
402 start_mds || error "MDS start failed"
406 mount_client $MOUNT && error "mount_client $MOUNT should fail"
407 grep " $MOUNT " /etc/mtab &&
408 error "$MOUNT entry in mtab after failed mount"
410 # stop_mds is a no-op here, and should not fail
411 cleanup_nocli || error "cleanup_nocli failed with $?"
412 if ! combined_mgs_mds ; then
416 run_test 5b "Try to start a client with no MGS (should return errs)"
419 grep " $MOUNT " /etc/mtab &&
420 error false "unexpected entry in mtab before mount" && return 10
422 start_mds || error "MDS start failed"
423 start_ost || error "OST start failed"
424 local oldfs="${FSNAME}"
425 FSNAME="wrong.${FSNAME}"
426 mount_client $MOUNT || :
428 grep " $MOUNT " /etc/mtab &&
429 error "$MOUNT entry in mtab after failed mount"
431 cleanup_nocli || error "cleanup_nocli failed with $?"
433 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
436 grep " $MOUNT " /etc/mtab &&
437 error false "unexpected entry in mtab before mount" && return 10
439 start_ost || error "OST start failed"
440 start_mds || error "MDS start failed"
441 stop_ost || error "Unable to stop OST1"
442 mount_client $MOUNT || error "mount_client $MOUNT failed"
443 cleanup || error "cleanup_nocli failed with $?"
444 grep " $MOUNT " /etc/mtab &&
445 error "$MOUNT entry in mtab after unmount"
448 run_test 5d "mount with ost down"
451 grep " $MOUNT " /etc/mtab &&
452 error false "unexpected entry in mtab before mount" && return 10
454 start_mds || error "MDS start failed"
455 start_ost || error "OST start failed"
457 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
458 do_facet client "$LCTL set_param fail_loc=0x80000506"
459 mount_client $MOUNT || echo "mount failed (not fatal)"
460 cleanup || error "cleanup failed with $?"
461 grep " $MOUNT " /etc/mtab &&
462 error "$MOUNT entry in mtab after unmount"
465 run_test 5e "delayed connect, don't crash (bug 10268)"
468 if combined_mgs_mds ; then
469 skip "combined mgs and mds"
473 grep " $MOUNT " /etc/mtab &&
474 error false "unexpected entry in mtab before mount" && return 10
477 start_ost || error "OST start failed"
478 mount_client $MOUNT &
480 echo client_mount pid is $pid
484 if ! ps -f -p $pid >/dev/null; then
487 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
488 error "mount returns $rc, expected to hang"
490 cleanup || error "cleanup failed with $?"
495 start_mds || error "start MDS failed"
497 # mount should succeed after start mds
499 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
500 cleanup || error "final call to cleanup failed with rc $?"
502 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
507 mount_client $MOUNT || error "mount_client $MOUNT failed"
508 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
509 cleanup || error "cleanup failed with rc $?"
511 run_test 6 "manual umount, then mount again"
516 cleanup_nocli || error "cleanup_nocli failed with $?"
518 run_test 7 "manual umount, then cleanup"
522 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
523 check_mount2 || error "check_mount2 failed"
524 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
525 cleanup || error "cleanup failed with rc $?"
527 run_test 8 "double mount setup"
530 start_ost || error "OST start failed"
532 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
533 error "do_facet ost1 set_param inode trace failed."
534 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
535 error "do_facet ost1 set_param debug mds ost failed."
537 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
538 if [ "$CHECK_PTLDEBUG" ] && { \
539 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
540 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
541 echo "lnet.debug success"
543 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
545 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
546 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
547 echo "lnet.subsystem_debug success"
549 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
551 stop_ost || error "Unable to stop OST1"
553 run_test 9 "test ptldebug and subsystem for mkfs"
561 do_facet $facet "test -b $dev" || rc=1
562 if [[ "$size" ]]; then
563 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k \
564 count=1 skip=$size 2>&1" |
565 awk '($3 == "in") { print $1 }')
566 [[ $in = "1+0" ]] || rc=1
572 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
573 # But with new MDS stack we don't care about the mode of local objects
574 # anymore, so this test is removed. See bug 22944 for more details.
578 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
579 skip "Only applicable to ldiskfs-based MDTs"
584 check_mount || error "check_mount failed"
585 cleanup || error "cleanup failed with rc $?"
587 echo "Remove mds config log"
588 if ! combined_mgs_mds ; then
592 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
593 $(mgsdevname) || return \$?" ||
594 error "do_facet mgs failed with $?"
596 if ! combined_mgs_mds ; then
600 start_ost || error "OST start failed"
601 start_mds && error "MDS start succeeded, but should fail"
604 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
607 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
608 skip "Only applicable to ldiskfs-based MDTs"
612 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
617 # check if current MDSSIZE is large enough
618 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
619 log "use MDSSIZE=$MDSSIZE"
621 # check if the global config has a large enough MDSSIZE
622 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
623 [ $STORED_MDSSIZE -ge $MIN ] &&
624 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
625 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
627 # check if the block device is large enough
628 is_blkdev $SINGLEMDS $MDSDEV $MIN
629 local large_enough=$?
630 if [ -n "$OK" ]; then
631 [ $large_enough -ne 0 ] && OK=""
633 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
634 log "use device $MDSDEV with MIN=$MIN"
637 # check if a loopback device has enough space for fs metadata (5%)
639 if [ -z "$OK" ]; then
640 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
641 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
642 awk '($1 != "Filesystem") { print $4 }')
643 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
644 OK=1 && myMDSSIZE=$MIN &&
645 log "use file $MDSDEV with MIN=$MIN"
648 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
650 echo "mount mds with large journal..."
652 local OLD_MDSSIZE=$MDSSIZE
656 echo "mount lustre system..."
658 check_mount || error "check_mount failed"
660 echo "check journal size..."
661 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
662 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
663 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
665 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
668 cleanup || error "cleanup failed with rc $?"
673 run_test 18 "check mkfs creates large journals"
676 start_mds || error "MDS start failed"
677 stop_mds || error "Unable to stop MDS"
679 run_test 19a "start/stop MDS without OSTs"
682 start_ost || error "Unable to start OST1"
683 stop_ost || error "Unable to stop OST1"
685 run_test 19b "start/stop OSTs without MDS"
688 # first format the ost/mdt
689 start_mds || error "MDS start failed"
690 start_ost || error "Unable to start OST1"
691 mount_client $MOUNT || error "mount_client $MOUNT failed"
692 check_mount || error "check_mount failed"
693 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
694 remount_client ro $MOUNT || error "remount_client with ro failed"
695 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
696 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
697 remount_client rw $MOUNT || error "remount_client with rw failed"
698 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
699 MCNT=$(grep -c $MOUNT /etc/mtab)
700 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
702 stop_mds || error "Unable to stop MDS"
703 stop_ost || error "Unable to stop OST1"
705 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
708 start_mds || error "MDS start failed"
709 start_ost || error "unable to start OST1"
710 wait_osc_import_state mds ost FULL
711 stop_ost || error "unable to stop OST1"
712 stop_mds || error "unable to stop MDS"
714 run_test 21a "start mds before ost, stop ost first"
717 start_ost || error "unable to start OST1"
718 start_mds || error "MDS start failed"
719 wait_osc_import_state mds ost FULL
720 stop_mds || error "unable to stop MDS"
721 stop_ost || error "unable to stop OST1"
723 run_test 21b "start ost before mds, stop mds first"
726 start_ost || error "Unable to start OST1"
727 start_mds || error "MDS start failed"
728 start_ost2 || error "Unable to start OST2"
729 wait_osc_import_state mds ost2 FULL
730 stop_ost || error "Unable to stop OST1"
731 stop_ost2 || error "Unable to stop OST2"
732 stop_mds || error "Unable to stop MDS"
733 #writeconf to remove all ost2 traces for subsequent tests
734 writeconf_or_reformat
736 run_test 21c "start mds between two osts, stop mds last"
739 if combined_mgs_mds ; then
740 skip "need separate mgs device" && return 0
746 start_mgs || error "unable to start MGS"
747 start_ost || error "unable to start OST1"
748 start_ost2 || error "unable to start OST2"
749 start_mds || error "MDS start failed"
750 wait_osc_import_state mds ost2 FULL
752 stop_ost || error "Unable to stop OST1"
753 stop_ost2 || error "Unable to stop OST2"
754 stop_mds || error "Unable to stop MDS"
756 #writeconf to remove all ost2 traces for subsequent tests
757 writeconf_or_reformat
758 start_mgs || error "unable to start MGS"
760 run_test 21d "start mgs then ost and then mds"
763 start_mds || error "MDS start failed"
765 echo "Client mount with ost in logs, but none running"
766 start_ost || error "unable to start OST1"
767 # wait until mds connected to ost and open client connection
768 wait_osc_import_state mds ost FULL
769 stop_ost || error "unable to stop OST1"
770 mount_client $MOUNT || error "mount_client $MOUNT failed"
771 # check_mount will block trying to contact ost
772 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
773 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
777 echo "Client mount with a running ost"
778 start_ost || error "unable to start OST1"
780 # if gss enabled, wait full time to let connection from
781 # mds to ost be established, due to the mismatch between
782 # initial connect timeout and gss context negotiation timeout.
783 # This perhaps could be remove after AT landed.
784 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
785 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
787 mount_client $MOUNT || error "mount_client $MOUNT failed"
788 wait_osc_import_state mds ost FULL
789 wait_osc_import_state client ost FULL
790 check_mount || error "check_mount failed"
793 cleanup || error "cleanup failed with rc $?"
795 run_test 22 "start a client before osts (should return errs)"
797 test_23a() { # was test_23
800 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
801 # force down client so that recovering mds waits for reconnect
802 local running=$(grep -c $MOUNT /proc/mounts) || true
803 if [ $running -ne 0 ]; then
804 echo "Stopping client $MOUNT (opts: -f)"
808 # enter recovery on failed mds
809 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
810 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
811 # try to start a new client
812 mount_client $MOUNT &
814 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
815 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
816 grep -v grep | awk '{print $2}')
817 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
819 ps --ppid $MOUNT_LUSTRE_PID
820 echo "waiting for mount to finish"
822 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
823 # SIGTERM works but it does not spread to offspring processses
824 kill -s TERM $MOUNT_PID
825 kill -s TERM $MOUNT_LUSTRE_PID
826 # we can not wait $MOUNT_PID because it is not a child of this shell
832 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
834 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
835 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
838 [ -z "$PID1" -a -z "$PID2" ] && break
839 echo "waiting for mount to finish ... "
840 WAIT=$(( WAIT + sleep))
842 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
843 error "MOUNT_PID $MOUNT_PID and "\
844 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
847 stop_mds || error "stopping MDSes failed"
848 stop_ost || error "stopping OSSes failed"
850 run_test 23a "interrupt client during recovery mount delay"
855 test_23b() { # was test_23
856 start_mds || error "MDS start failed"
857 start_ost || error "Unable to start OST1"
858 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
859 $LCTL set_param fail_loc=0x80000313
861 cleanup || error "cleanup failed with rc $?"
863 run_test 23b "Simulate -EINTR during mount"
865 fs2mds_HOST=$mds_HOST
866 fs2ost_HOST=$ost_HOST
868 MDSDEV1_2=$fs2mds_DEV
869 OSTDEV1_2=$fs2ost_DEV
870 OSTDEV2_2=$fs3ost_DEV
874 echo "umount $MOUNT2 ..."
875 umount $MOUNT2 || true
876 echo "stopping fs2mds ..."
877 stop fs2mds -f || true
878 echo "stopping fs2ost ..."
879 stop fs2ost -f || true
883 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
885 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
886 is_blkdev $SINGLEMDS $MDSDEV &&
887 skip_env "mixed loopback and real device not working" && return
890 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
892 local fs2mdsdev=$(mdsdevname 1_2)
893 local fs2ostdev=$(ostdevname 1_2)
894 local fs2mdsvdev=$(mdsvdevname 1_2)
895 local fs2ostvdev=$(ostvdevname 1_2)
897 # test 8-char fsname as well
898 local FSNAME2=test1234
900 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
901 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
903 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
904 --reformat $fs2ostdev $fs2ostvdev || exit 10
907 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
908 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
909 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
910 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
912 check_mount || error "check_mount failed"
913 # files written on 1 should not show up on 2
914 cp /etc/passwd $DIR/$tfile
916 [ -e $MOUNT2/$tfile ] && error "File bleed"
919 cp /etc/passwd $MOUNT2/$tfile ||
920 error "cp /etc/passwd $MOUNT2/$tfile failed"
921 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
922 # 2 is actually mounted
923 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
925 facet_failover fs2mds
926 facet_failover fs2ost
929 # the MDS must remain up until last MDT
931 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
932 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
933 [ -z "$MDS" ] && error "No MDT"
935 cleanup_nocli || error "cleanup_nocli failed with rc $?"
937 run_test 24a "Multiple MDTs on a single node"
940 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
942 if [ -z "$fs2mds_DEV" ]; then
943 local dev=${SINGLEMDS}_dev
945 is_blkdev $SINGLEMDS $MDSDEV &&
946 skip_env "mixed loopback and real device not working" && return
949 local fs2mdsdev=$(mdsdevname 1_2)
950 local fs2mdsvdev=$(mdsvdevname 1_2)
952 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
953 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
955 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS &&
956 error "start MDS should fail"
958 cleanup || error "cleanup failed with rc $?"
960 run_test 24b "Multiple MGSs on a single node (should return err)"
964 check_mount || error "check_mount failed"
965 local MODULES=$($LCTL modules | awk '{ print $2 }')
966 rmmod $MODULES 2>/dev/null || true
967 cleanup || error "cleanup failed with $?"
969 run_test 25 "Verify modules are referenced"
973 # we need modules before mount for sysctl, so make sure...
974 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
975 #define OBD_FAIL_MDS_FS_SETUP 0x135
976 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
977 start_mds && error "MDS started but should not have started"
978 $LCTL get_param -n devices
979 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
980 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
981 # start mds to drop writeconf setting
982 start_mds || error "Unable to start MDS"
983 stop_mds || error "Unable to stop MDS"
984 unload_modules_conf || error "unload_modules_conf failed with $?"
986 run_test 26 "MDT startup failure cleans LOV (should return errs)"
989 start_ost || error "Unable to start OST1"
990 start_mds || error "Unable to start MDS"
991 echo "Requeue thread should have started: "
992 ps -e | grep ll_cfg_requeue
993 set_conf_param_and_check ost1 \
994 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" \
995 "$FSNAME-OST0000.ost.client_cache_seconds" ||
996 error "set_conf_param_and_check ost1 failed"
997 cleanup_nocli || error "cleanup_nocli failed with rc $?"
999 run_test 27a "Reacquire MGS lock if OST started first"
1004 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1005 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1007 facet_failover $SINGLEMDS
1008 set_conf_param_and_check $SINGLEMDS \
1009 "$LCTL get_param -n mdt.$device.identity_acquire_expire" \
1010 "$device.mdt.identity_acquire_expire" ||
1011 error "set_conf_param_and_check $SINGLEMDS failed"
1012 set_conf_param_and_check client \
1013 "$LCTL get_param -n mdc.$device-mdc-*.max_rpcs_in_flight"\
1014 "$device.mdc.max_rpcs_in_flight" ||
1015 error "set_conf_param_and_check client failed"
1017 cleanup || error "cleanup failed with $?"
1019 run_test 27b "Reacquire MGS lock after failover"
1023 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1024 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1026 FINAL=$(($ORIG + 1))
1027 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1028 error "first set_conf_param_and_check client failed"
1029 FINAL=$(($FINAL + 1))
1030 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1031 error "second set_conf_param_and_check client failed"
1032 umount_client $MOUNT || error "umount_client $MOUNT failed"
1033 mount_client $MOUNT || error "mount_client $MOUNT failed"
1035 if [ $RESULT -ne $FINAL ]; then
1036 error "New config not seen: wanted $FINAL got $RESULT"
1038 echo "New config success: got $RESULT"
1040 set_conf_param_and_check client "$TEST" "$PARAM" $ORIG ||
1041 error "third set_conf_param_and_check client failed"
1042 cleanup || error "cleanup failed with rc $?"
1044 run_test 28 "permanent parameter setting"
1046 test_28a() { # LU-4221
1047 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1048 { skip "Need OST version at least 2.5.52" && return 0; }
1049 [ "$(facet_fstype ost1)" = "zfs" ] &&
1050 skip "LU-4221: no such proc params for ZFS OSTs" && return
1057 local device="$FSNAME-OST0000"
1061 # In this test we will set three kinds of proc parameters with
1063 # 1. the ones moved from the OFD to the OSD, and only their
1064 # symlinks kept in obdfilter
1065 # 2. non-symlink ones in the OFD
1066 # 3. non-symlink ones in the OSD
1069 # prepare a symlink parameter in the OFD
1070 name="writethrough_cache_enable"
1071 param="$device.ost.$name"
1072 cmd="$LCTL get_param -n obdfilter.$device.$name"
1074 # conf_param the symlink parameter in the OFD
1075 old=$(do_facet ost1 $cmd)
1076 new=$(((old + 1) % 2))
1077 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1078 error "lctl conf_param $device.ost.$param=$new failed"
1080 # conf_param the target parameter in the OSD
1081 param="$device.osd.$name"
1082 cmd="$LCTL get_param -n osd-*.$device.$name"
1083 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1084 error "lctl conf_param $device.osd.$param=$old failed"
1087 # prepare a non-symlink parameter in the OFD
1088 name="client_cache_seconds"
1089 param="$device.ost.$name"
1090 cmd="$LCTL get_param -n obdfilter.$device.$name"
1092 # conf_param the parameter in the OFD
1093 old=$(do_facet ost1 $cmd)
1095 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1096 error "lctl conf_param $device.ost.$param=$new failed"
1097 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1098 error "lctl conf_param $device.ost.$param=$old failed"
1101 # prepare a non-symlink parameter in the OSD
1102 name="lma_self_repair"
1103 param="$device.osd.$name"
1104 cmd="$LCTL get_param -n osd-*.$device.$name"
1106 # conf_param the parameter in the OSD
1107 old=$(do_facet ost1 $cmd)
1108 new=$(((old + 1) % 2))
1109 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1110 error "lctl conf_param $device.osd.$param=$new failed"
1111 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1112 error "lctl conf_param $device.osd.$param=$old failed"
1114 cleanup || error "cleanup failed with $?"
1116 run_test 28a "set symlink parameters permanently with conf_param"
1119 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1120 setup > /dev/null 2>&1
1121 start_ost2 || error "Unable to start OST2"
1124 local PARAM="$FSNAME-OST0001.osc.active"
1125 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1126 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1128 ACTV=$($LCTL get_param -n $PROC_ACT)
1130 set_conf_param_and_check client \
1131 "$LCTL get_param -n $PROC_ACT" "$PARAM" $DEAC ||
1132 error "set_conf_param_and_check client failed"
1133 # also check ost_server_uuid status
1134 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1135 if [ -z "$RESULT" ]; then
1136 error "Client not deactivated: $($LCTL get_param \
1139 echo "Live client success: got $RESULT"
1143 for num in $(seq $MDSCOUNT); do
1144 local mdtosc=$(get_mdtosc_proc_path mds${num} $FSNAME-OST0001)
1145 local MPROC="osc.$mdtosc.active"
1150 RESULT=$(do_facet mds${num} "$LCTL get_param -n $MPROC")
1151 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1152 if [ $RESULT -eq $DEAC ]; then
1153 echo -n "MDT deactivated also after"
1154 echo "$WAIT sec (got $RESULT)"
1158 if [ $WAIT -eq $MAX ]; then
1159 error "MDT active: wanted $DEAC got $RESULT"
1161 echo "Waiting $(($MAX - $WAIT))secs for MDT deactivated"
1164 # test new client starts deactivated
1165 umount_client $MOUNT || error "umount_client $MOUNT failed"
1166 mount_client $MOUNT || error "mount_client $MOUNT failed"
1167 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1168 if [ -z "$RESULT" ]; then
1169 error "New client start active: $(lctl get_param -n $PROC_UUID)"
1171 echo "New client success: got $RESULT"
1174 # make sure it reactivates
1175 set_conf_param_and_check client \
1176 "$LCTL get_param -n $PROC_ACT" "$PARAM" $ACTV ||
1177 error "lctl get_param $PROC_ACT $PARAM $ACTV failed"
1179 umount_client $MOUNT
1180 stop_ost2 || error "Unable to stop OST2"
1181 cleanup_nocli || error "cleanup_nocli failed with $?"
1182 #writeconf to remove all ost2 traces for subsequent tests
1183 writeconf_or_reformat
1185 run_test 29 "permanently remove an OST"
1190 echo Big config llog
1191 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1193 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1194 for i in ${LIST[@]}; do
1195 set_conf_param_and_check client "$TEST" \
1196 "$FSNAME.llite.max_read_ahead_whole_mb" $i ||
1197 error "Set $FSNAME.llite.max_read_ahead_whole_mb failed"
1199 # make sure client restart still works
1200 umount_client $MOUNT
1201 mount_client $MOUNT || error "mount_client $MOUNT failed"
1202 [ "$($TEST)" -ne "$i" ] &&
1203 error "Param didn't stick across restart $($TEST) != $i"
1206 echo Erase parameter setting
1207 do_facet mgs "$LCTL conf_param \
1208 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1209 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1210 umount_client $MOUNT
1211 mount_client $MOUNT || error "mount_client $MOUNT failed"
1213 echo "deleted (default) value=$FINAL, orig=$ORIG"
1214 # assumes this parameter started at the default value
1215 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1217 cleanup || error "cleanup failed with rc $?"
1219 run_test 30a "Big config llog and conf_param deletion"
1224 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1225 # numerical part of it. Hopefully that's not already a failover address
1227 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1228 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1229 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1230 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1231 echo "Using fake nid $NEW"
1233 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1234 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1235 set_conf_param_and_check client "$TEST" \
1236 "$FSNAME-OST0000.failover.node" $NEW ||
1237 error "didn't add failover nid $NEW"
1238 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1241 # The NIDS value is the failover nid strings and "[" and "]". So
1242 # we need to subtract the space taken by the delimiters. This has
1243 # changed from earlier version of Lustre but this test is run only
1244 # locally so this change will not break interop. See LU-3386
1245 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 3))
1246 echo "should have 2 failover nids: $NIDCOUNT"
1247 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1248 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" ||
1249 error "conf_param delete failed"
1250 umount_client $MOUNT
1251 mount_client $MOUNT || error "mount_client $MOUNT failed"
1253 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1256 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 3))
1257 echo "only 1 final nid should remain: $NIDCOUNT"
1258 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1260 cleanup || error "cleanup failed with rc $?"
1262 run_test 30b "Remove failover nids"
1264 test_31() { # bug 10734
1265 # ipaddr must not exist
1266 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1267 cleanup || error "cleanup failed with rc $?"
1269 run_test 31 "Connect to non-existent node (shouldn't crash)"
1273 T32_BLIMIT=20480 # Kbytes
1277 # This is not really a test but a tool to create new disk
1278 # image tarballs for the upgrade tests.
1280 # Disk image tarballs should be created on single-node
1281 # clusters by running this test with default configurations
1282 # plus a few mandatory environment settings that are verified
1283 # at the beginning of the test.
1285 test_32newtarball() {
1289 local tmp=$TMP/t32_image_create
1291 if [ $FSNAME != t32fs -o $MDSCOUNT -ne 1 -o \
1292 \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o $OSTCOUNT -ne 1 -o \
1293 -z "$OSTDEV1" ]; then
1294 error "Needs FSNAME=t32fs MDSCOUNT=1 MDSDEV1=<nonexistent_file>" \
1295 "(or MDSDEV, in the case of b1_8) OSTCOUNT=1" \
1296 "OSTDEV1=<nonexistent_file>"
1300 echo "Found stale $tmp"
1304 mkdir $tmp/src || return 1
1305 tar cf - -C $src . | tar xf - -C $tmp/src
1306 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1307 count=$(($T32_BLIMIT / 1024 / 2))
1308 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1310 # format ost with comma-separated NIDs to verify LU-4460
1311 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
1312 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1316 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1317 $LFS quotacheck -ug /mnt/$FSNAME
1318 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1321 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1324 mkdir $tmp/img || return 1
1328 ls -Rni --time-style=+%s >$tmp/img/list
1329 find . ! -name .lustre -type f -exec sha1sum {} \; |
1330 sort -k 2 >$tmp/img/sha1sums
1332 $LCTL get_param -n version | head -n 1 |
1333 sed -e 's/^lustre: *//' >$tmp/img/commit
1335 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
1336 $LFS quotaon -ug /mnt/$FSNAME
1337 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1338 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1339 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1340 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1341 | tr -d "*" > $tmp/img/bspace
1342 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1343 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1344 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1345 | tr -d "*" > $tmp/img/ispace
1350 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1353 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1354 echo "Data verification failed"
1357 uname -r >$tmp/img/kernel
1358 uname -m >$tmp/img/arch
1360 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1361 mv $OSTDEV1 $tmp/img
1363 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1364 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1367 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1372 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1375 # The list of applicable tarballs is returned via the caller's
1376 # variable "tarballs".
1379 local node=$(facet_active_host $SINGLEMDS)
1380 local r="do_node $node"
1382 if [ "$CLIENTONLY" ]; then
1383 skip "Client-only testing"
1387 if ! $r which $TUNEFS; then
1388 skip_env "tunefs.lustre required on $node"
1392 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1394 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 -name \'disk*-$IMGTYPE.tar.bz2\')
1396 if [ -z "$tarballs" ]; then
1397 skip "No applicable tarballs found"
1402 t32_test_cleanup() {
1404 local fstype=$(facet_fstype $SINGLEMDS)
1407 if $shall_cleanup_lustre; then
1408 umount $tmp/mnt/lustre || rc=$?
1410 if $shall_cleanup_mdt; then
1411 $r umount -d $tmp/mnt/mdt || rc=$?
1413 if $shall_cleanup_mdt1; then
1414 $r umount -d $tmp/mnt/mdt1 || rc=$?
1416 if $shall_cleanup_ost; then
1417 $r umount -d $tmp/mnt/ost || rc=$?
1422 if [ $fstype == "zfs" ]; then
1423 $r $ZPOOL destroy t32fs-mdt1 || rc=$?
1424 $r $ZPOOL destroy t32fs-ost1 || rc=$?
1429 t32_bits_per_long() {
1431 # Yes, this is not meant to be perfect.
1441 t32_reload_modules() {
1443 local all_removed=false
1446 while ((i < 20)); do
1447 echo "Unloading modules on $node: Attempt $i"
1448 do_rpc_nodes $node $LUSTRE_RMMOD $(facet_fstype $SINGLEMDS) &&
1450 do_rpc_nodes $node check_mem_leak || return 1
1451 if $all_removed; then
1452 do_rpc_nodes $node load_modules
1458 echo "Unloading modules on $node: Given up"
1462 t32_wait_til_devices_gone() {
1468 echo wait for devices to go
1469 while ((i < 20)); do
1470 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1471 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1472 ((devices == 0 && loops == 0)) && return 0
1476 echo "waiting for dev on $node: dev $devices loop $loops given up"
1477 do_rpc_nodes $node "losetup -a"
1478 do_rpc_nodes $node "$LCTL devices_list"
1482 t32_verify_quota() {
1486 local fstype=$(facet_fstype $SINGLEMDS)
1490 $LFS quota -u $T32_QID -v $mnt
1492 qval=$($LFS quota -v -u $T32_QID $mnt |
1493 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1494 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1496 [ $qval -eq $img_bspace ] || {
1497 echo "bspace, act:$qval, exp:$img_bspace"
1501 qval=$($LFS quota -v -u $T32_QID $mnt |
1502 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1503 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1505 [ $qval -eq $img_ispace ] || {
1506 echo "ispace, act:$qval, exp:$img_ispace"
1510 qval=$($LFS quota -v -u $T32_QID $mnt |
1511 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1512 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1514 [ $qval -eq $T32_BLIMIT ] || {
1515 echo "blimit, act:$qval, exp:$T32_BLIMIT"
1519 qval=$($LFS quota -v -u $T32_QID $mnt |
1520 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1521 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1523 [ $qval -eq $T32_ILIMIT ] || {
1524 echo "ilimit, act:$qval, exp:$T32_ILIMIT"
1528 do_node $node $LCTL conf_param $fsname.quota.mdt=ug
1529 cmd="$LCTL get_param -n osd-$fstype.$fsname-MDT0000"
1530 cmd=$cmd.quota_slave.enabled
1531 wait_update $node "$cmd" "ug" || {
1532 echo "Enable mdt quota failed"
1536 do_node $node $LCTL conf_param $fsname.quota.ost=ug
1537 cmd="$LCTL get_param -n osd-$fstype.$fsname-OST0000"
1538 cmd=$cmd.quota_slave.enabled
1539 wait_update $node "$cmd" "ug" || {
1540 echo "Enable ost quota failed"
1545 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1546 bs=1M count=$(($T32_BLIMIT / 1024)) oflag=sync && {
1547 echo "Write succeed, but expect -EDQUOT"
1550 rm -f $mnt/t32_qf_new
1552 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1554 echo "Create succeed, but expect -EDQUOT"
1557 unlinkmany $mnt/t32_qf_ $T32_ILIMIT
1565 local dne_upgrade=${dne_upgrade:-"no"}
1566 local ff_convert=${ff_convert:-"no"}
1567 local shall_cleanup_mdt=false
1568 local shall_cleanup_mdt1=false
1569 local shall_cleanup_ost=false
1570 local shall_cleanup_lustre=false
1571 local node=$(facet_active_host $SINGLEMDS)
1572 local r="do_node $node"
1573 local node2=$(facet_active_host mds2)
1581 local nid=$($r $LCTL list_nids | head -1)
1587 local fstype=$(facet_fstype $SINGLEMDS)
1588 local mdt_dev=$tmp/mdt
1589 local ost_dev=$tmp/ost
1591 trap 'trap - RETURN; t32_test_cleanup' RETURN
1593 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1594 $r mkdir -p $tmp/mnt/{mdt,ost}
1595 $r tar xjvf $tarball -S -C $tmp || {
1596 error_noexit "Unpacking the disk image tarball"
1599 img_commit=$($r cat $tmp/commit)
1600 img_kernel=$($r cat $tmp/kernel)
1601 img_arch=$($r cat $tmp/arch)
1602 img_bspace=$($r cat $tmp/bspace)
1603 img_ispace=$($r cat $tmp/ispace)
1604 echo "Upgrading from $(basename $tarball), created with:"
1605 echo " Commit: $img_commit"
1606 echo " Kernel: $img_kernel"
1607 echo " Arch: $img_arch"
1608 echo "OST version: $(get_lustre_version ost1)"
1610 # The conversion can be made only when both of the following
1611 # conditions are satisfied:
1612 # - ost device img version < 2.3.64
1613 # - ost server version >= 2.5
1614 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1615 $(lustre_version_code ost1) -lt $(version_code 2.5.0) ] &&
1618 if [ $fstype == "zfs" ]; then
1620 $r $ZPOOL import -f -d $tmp t32fs-mdt1
1621 $r $ZPOOL import -f -d $tmp t32fs-ost1
1622 mdt_dev=t32fs-mdt1/mdt1
1623 ost_dev=t32fs-ost1/ost1
1624 wait_update_facet $SINGLEMDS "$ZPOOL list |
1625 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1626 error_noexit "import zfs pool failed"
1631 $r $LCTL set_param debug="$PTLDEBUG"
1633 $r $TUNEFS --dryrun $mdt_dev || {
1635 error_noexit "tunefs.lustre before mounting the MDT"
1638 if [ "$writeconf" ]; then
1640 if [ $fstype == "ldiskfs" ]; then
1642 $r $TUNEFS --quota $mdt_dev || {
1644 error_noexit "Enable mdt quota feature"
1649 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1650 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1651 { skip "LU-2200: Cannot run over Inifiniband w/o lctl replace_nids "
1652 "(Need MGS version at least 2.3.59)"; return 0; }
1654 local osthost=$(facet_active_host ost1)
1655 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1658 if [ $fstype == "ldiskfs" ]; then
1661 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1662 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1663 $r $LCTL replace_nids $fsname-MDT0000 $nid
1664 $r umount -d $tmp/mnt/mdt
1667 mopts=exclude=$fsname-OST0000
1668 if [ $fstype == "ldiskfs" ]; then
1673 t32_wait_til_devices_gone $node
1675 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1677 error_noexit "Mounting the MDT"
1680 shall_cleanup_mdt=true
1682 if [ "$dne_upgrade" != "no" ]; then
1683 local fs2mdsdev=$(mdsdevname 1_2)
1684 local fs2mdsvdev=$(mdsvdevname 1_2)
1686 echo "mkfs new MDT on ${fs2mdsdev}...."
1687 if [ $(facet_fstype mds1) == ldiskfs ]; then
1688 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1691 add fs2mds $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1692 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1693 error_noexit "Mkfs new MDT failed"
1697 $r $TUNEFS --dryrun $fs2mdsdev || {
1698 error_noexit "tunefs.lustre before mounting the MDT"
1702 echo "mount new MDT....$fs2mdsdev"
1703 $r mkdir -p $tmp/mnt/mdt1
1704 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1705 error_noexit "mount mdt1 failed"
1709 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1710 error_noexit "enable remote dir create failed"
1712 shall_cleanup_mdt1=true
1715 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1716 error_noexit "Getting MDT UUID"
1719 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1720 error_noexit "Unexpected MDT UUID: \"$uuid\""
1724 $r $TUNEFS --dryrun $ost_dev || {
1725 error_noexit "tunefs.lustre before mounting the OST"
1728 if [ "$writeconf" ]; then
1729 mopts=mgsnode=$nid,$writeconf
1730 if [ $fstype == "ldiskfs" ]; then
1732 $r $TUNEFS --quota $ost_dev || {
1734 error_noexit "Enable ost quota feature"
1740 if [ $fstype == "ldiskfs" ]; then
1744 $r $MOUNT_CMD -o $mopts $ost_dev $tmp/mnt/ost || {
1745 error_noexit "Mounting the OST"
1748 shall_cleanup_ost=true
1750 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1751 error_noexit "Getting OST UUID"
1754 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1755 error_noexit "Unexpected OST UUID: \"$uuid\""
1759 $r $LCTL conf_param $fsname-OST0000.osc.max_dirty_mb=15 || {
1760 error_noexit "Setting \"max_dirty_mb\""
1763 $r $LCTL conf_param $fsname-OST0000.failover.node=$nid || {
1764 error_noexit "Setting OST \"failover.node\""
1767 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1768 error_noexit "Setting \"max_rpcs_in_flight\""
1771 $r $LCTL conf_param $fsname-MDT0000.failover.node=$nid || {
1772 error_noexit "Setting MDT \"failover.node\""
1775 $r $LCTL pool_new $fsname.interop || {
1776 error_noexit "Setting \"interop\""
1779 $r $LCTL conf_param $fsname-MDT0000.lov.stripesize=4M || {
1780 error_noexit "Setting \"lov.stripesize\""
1784 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1785 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1786 error_noexit "Start OI scrub on OST0"
1790 # The oi_scrub should be on ost1, but for test_32(),
1791 # all on the SINGLEMDS.
1792 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1793 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1794 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1795 error_noexit "Failed to get the expected 'completed'"
1799 local UPDATED=$($r $LCTL get_param -n \
1800 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1801 awk '/^updated/ { print $2 }')
1802 [ $UPDATED -ge 1 ] || {
1803 error_noexit "Only $UPDATED objects have been converted"
1808 if [ "$dne_upgrade" != "no" ]; then
1809 $r $LCTL conf_param \
1810 $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
1811 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
1814 $r $LCTL conf_param $fsname-MDT0001.failover.node=$nid || {
1815 error_noexit "Setting MDT1 \"failover.node\""
1818 $r $LCTL conf_param $fsname-MDT0001.lov.stripesize=4M || {
1819 error_noexit "Setting MDT1 \"lov.stripesize\""
1825 if [ "$writeconf" ]; then
1826 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
1827 error_noexit "Mounting the client"
1830 shall_cleanup_lustre=true
1831 $LCTL set_param debug="$PTLDEBUG"
1833 t32_verify_quota $node $fsname $tmp/mnt/lustre || {
1834 error_noexit "verify quota failed"
1838 if [ "$dne_upgrade" != "no" ]; then
1839 $LFS mkdir -i 1 $tmp/mnt/lustre/remote_dir || {
1840 error_noexit "set remote dir failed"
1844 pushd $tmp/mnt/lustre
1845 tar -cf - . --exclude=./remote_dir |
1846 tar -xvf - -C remote_dir 1>/dev/null || {
1847 error_noexit "cp to remote dir failed"
1853 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
1854 error_noexit "dd failed"
1857 rm -rf $tmp/mnt/lustre/tmp_file || {
1858 error_noexit "rm failed"
1862 if $r test -f $tmp/sha1sums; then
1863 # LU-2393 - do both sorts on same node to ensure locale
1865 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
1866 if [ "$dne_upgrade" != "no" ]; then
1867 pushd $tmp/mnt/lustre/remote_dir
1869 pushd $tmp/mnt/lustre
1872 find ! -name .lustre -type f -exec sha1sum {} \; |
1873 sort -k 2 >$tmp/sha1sums || {
1874 error_noexit "sha1sum"
1878 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
1879 error_noexit "sha1sum verification failed"
1883 echo "sha1sum verification skipped"
1886 if [ "$dne_upgrade" != "no" ]; then
1887 rm -rf $tmp/mnt/lustre/remote_dir || {
1888 error_noexit "remove remote dir failed"
1893 if $r test -f $tmp/list; then
1895 # There is not a Test Framework API to copy files to or
1896 # from a remote node.
1898 # LU-2393 - do both sorts on same node to ensure locale
1900 $r cat $tmp/list | sort -k 6 >$tmp/list.orig
1901 pushd $tmp/mnt/lustre
1902 ls -Rni --time-style=+%s | sort -k 6 >$tmp/list || {
1908 # 32-bit and 64-bit clients use different algorithms to
1909 # convert FIDs into inode numbers. Hence, remove the inode
1910 # numbers from the lists, if the original list was created
1911 # on an architecture with different number of bits per
1914 if [ $(t32_bits_per_long $(uname -m)) != \
1915 $(t32_bits_per_long $img_arch) ]; then
1916 echo "Different number of bits per \"long\" from the disk image"
1917 for list in list.orig list; do
1918 sed -i -e 's/^[0-9]\+[ \t]\+//' $tmp/$list
1921 if ! diff -ub $tmp/list.orig $tmp/list; then
1922 error_noexit "list verification failed"
1926 echo "list verification skipped"
1930 # When adding new data verification tests, please check for
1931 # the presence of the required reference files first, like
1932 # the "sha1sums" and "list" tests above, to avoid the need to
1933 # regenerate every image for each test addition.
1936 nrpcs_orig=$($LCTL get_param \
1937 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
1938 error_noexit "Getting \"max_rpcs_in_flight\""
1941 nrpcs=$((nrpcs_orig + 5))
1942 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=$nrpcs || {
1943 error_noexit "Changing \"max_rpcs_in_flight\""
1946 wait_update $HOSTNAME "$LCTL get_param \
1947 -n mdc.*MDT0000*.max_rpcs_in_flight" $nrpcs || {
1948 error_noexit "Verifying \"max_rpcs_in_flight\""
1952 umount $tmp/mnt/lustre || {
1953 error_noexit "Unmounting the client"
1956 shall_cleanup_lustre=false
1958 if [ "$dne_upgrade" != "no" ]; then
1959 $r umount -d $tmp/mnt/mdt1 || {
1960 error_noexit "Unmounting the MDT2"
1963 shall_cleanup_mdt1=false
1966 $r umount -d $tmp/mnt/mdt || {
1967 error_noexit "Unmounting the MDT"
1970 shall_cleanup_mdt=false
1972 $r umount -d $tmp/mnt/ost || {
1973 error_noexit "Unmounting the OST"
1976 shall_cleanup_ost=false
1978 t32_reload_modules $node || {
1979 error_noexit "Reloading modules"
1983 # mount a second time to make sure we didnt leave upgrade flag on
1984 $r $TUNEFS --dryrun $mdt_dev || {
1986 error_noexit "tunefs.lustre before remounting the MDT"
1990 mopts=exclude=$fsname-OST0000
1991 if [ $fstype == "ldiskfs" ]; then
1994 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1995 error_noexit "Remounting the MDT"
1998 shall_cleanup_mdt=true
2008 for tarball in $tarballs; do
2009 t32_test $tarball || let "rc += $?"
2013 run_test 32a "Upgrade (not live)"
2021 for tarball in $tarballs; do
2022 t32_test $tarball writeconf || let "rc += $?"
2026 run_test 32b "Upgrade with writeconf"
2033 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2035 for tarball in $tarballs; do
2036 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2040 run_test 32c "dne upgrade test"
2048 for tarball in $tarballs; do
2049 ff_convert=yes t32_test $tarball || rc=$?
2053 run_test 32d "convert ff test"
2055 test_33a() { # bug 12333, was test_33
2056 local FSNAME2=test-123
2057 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2060 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2062 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2063 local dev=${SINGLEMDS}_dev
2064 local MDSDEV=${!dev}
2065 is_blkdev $SINGLEMDS $MDSDEV &&
2066 skip_env "mixed loopback and real device not working" &&
2070 local fs2mdsdev=$(mdsdevname 1_2)
2071 local fs2ostdev=$(ostdevname 1_2)
2072 local fs2mdsvdev=$(mdsvdevname 1_2)
2073 local fs2ostvdev=$(ostvdevname 1_2)
2075 if [ $(facet_fstype mds1) == ldiskfs ]; then
2076 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2079 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2080 --reformat $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
2081 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2082 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2083 $fs2ostvdev || exit 10
2085 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2086 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2087 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" ||
2088 error "$LCTL conf_param $FSNAME2.sys.timeout=200 failed"
2089 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2090 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2093 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2094 $GETSTRIPE $MOUNT2/hosts || error "$GETSTRIPE $MOUNT2/hosts failed"
2099 cleanup_nocli || error "cleanup_nocli failed with $?"
2101 run_test 33a "Mount ost with a large index number"
2103 test_33b() { # was test_34
2106 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2107 # Drop lock cancelation reply during umount
2108 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2109 do_facet client $LCTL set_param fail_loc=0x80000304
2110 #lctl set_param debug=-1
2111 umount_client $MOUNT
2112 cleanup || error "cleanup failed with $?"
2114 run_test 33b "Drop cancel during umount"
2118 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2119 manual_umount_client
2121 do_facet client killall -USR1 multiop
2122 if [ $rc -eq 0 ]; then
2123 error "umount not fail!"
2126 cleanup || error "cleanup failed with rc $?"
2128 run_test 34a "umount with opened file should be fail"
2132 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2133 stop_mds || error "Unable to stop MDS"
2135 manual_umount_client --force || error "mtab after failed umount with $?"
2137 cleanup || error "cleanup failed with $?"
2139 run_test 34b "force umount with failed mds should be normal"
2143 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2144 stop_ost || error "Unable to stop OST1"
2146 manual_umount_client --force || error "mtab after failed umount with $?"
2148 cleanup || error "cleanup failed with $?"
2150 run_test 34c "force umount with failed ost should be normal"
2152 test_35a() { # bug 12459
2155 DBG_SAVE="`$LCTL get_param -n debug`"
2156 $LCTL set_param debug="ha"
2158 log "Set up a fake failnode for the MDS"
2160 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2161 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2162 do_facet mgs "$LCTL conf_param \
2163 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" ||
2164 error "Setting ${device}.failover.node=\
2165 $(h2$NETTYPE $FAKENID) failed."
2167 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2170 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2173 log "Stopping the MDT: $device"
2174 stop_mdt 1 || error "MDT0 stop fail"
2176 df $MOUNT > /dev/null 2>&1 &
2178 log "Restarting the MDT: $device"
2179 start_mdt 1 || error "MDT0 start fail"
2180 log "Wait for df ($DFPID) ... "
2183 $LCTL set_param debug="$DBG_SAVE"
2185 # retrieve from the log the first server that the client tried to
2186 # contact after the connection loss
2187 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2188 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2189 /import_select_connection.*$device-mdc.* using connection/ {
2191 if (\\\$NF ~ /$FAKENID/)
2197 }" $TMP/lustre-log-$TESTNAME.log`
2198 [ "$NEXTCONN" != "0" ] &&
2199 error "Tried to connect to ${NEXTCONN} not last active server"
2200 cleanup || error "cleanup failed with $?"
2201 # remove nid settings
2202 writeconf_or_reformat
2204 run_test 35a "Reconnect to the last active server first"
2206 test_35b() { # bug 18674
2207 remote_mds || { skip "local MDS" && return 0; }
2211 $LCTL set_param debug="ha"
2213 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2216 log "Set up a fake failnode for the MDS"
2218 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2219 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2220 do_facet mgs "$LCTL conf_param \
2221 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" ||
2222 error "Set ${device}.failover.node=\
2223 $(h2$NETTYPE $FAKENID) failed"
2225 local at_max_saved=0
2226 # adaptive timeouts may prevent seeing the issue
2227 if at_is_enabled; then
2228 at_max_saved=$(at_max_get mds)
2229 at_max_set 0 mds client
2232 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2234 log "Injecting EBUSY on MDS"
2235 # Setting OBD_FAIL_MDS_RESEND=0x136
2236 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2237 error "unable to set param fail_loc=0x80000136"
2239 $LCTL set_param mdc.${FSNAME}*.stats=clear
2241 log "Creating a test file and stat it"
2242 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2243 stat $MOUNT/$tdir/$tfile
2245 log "Stop injecting EBUSY on MDS"
2246 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2247 error "unable to set param fail_loc=0"
2248 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2251 # restore adaptive timeout
2252 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2254 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2256 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2257 awk '/mds_connect/{print $2}')
2259 # retrieve from the log if the client has ever tried to
2260 # contact the fake server after the loss of connection
2261 FAILCONN=`awk "BEGIN {ret = 0;}
2262 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2264 if (\\\$NF ~ /$FAKENID/) {
2269 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2271 [ "$FAILCONN" == "0" ] &&
2272 error "The client reconnection has not been triggered"
2273 [ "$FAILCONN" == "2" ] &&
2274 error "Primary server busy, client reconnect to failover failed"
2277 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2278 # Reconnects are supposed to be rate limited to one every 5s
2279 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2280 error "Too many reconnects $CONNCNT"
2282 cleanup || error "cleanup failed with $?"
2283 # remove nid settings
2284 writeconf_or_reformat
2286 run_test 35b "Continue reconnection retries, if the active server is busy"
2289 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
2291 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2292 { skip "remote OST" && return 0; }
2295 local FSNAME2=test1234
2296 local fs3ost_HOST=$ost_HOST
2297 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2299 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2301 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2302 is_blkdev $SINGLEMDS $MDSDEV &&
2303 skip_env "mixed loopback and real device not working" && return
2306 local fs2mdsdev=$(mdsdevname 1_2)
2307 local fs2ostdev=$(ostdevname 1_2)
2308 local fs3ostdev=$(ostdevname 2_2)
2309 local fs2mdsvdev=$(mdsvdevname 1_2)
2310 local fs2ostvdev=$(ostvdevname 1_2)
2311 local fs3ostvdev=$(ostvdevname 2_2)
2313 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2314 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2315 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2316 # different one than the default value here.
2317 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2318 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2319 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2320 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2322 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2323 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2324 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2325 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2326 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2328 sleep 5 # until 11778 fixed
2330 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2332 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2333 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2334 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2335 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2336 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2337 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2338 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2339 DFTOTAL=$(echo $STRING | cut -d, -f1)
2340 DFUSED=$(echo $STRING | cut -d, -f2)
2341 DFAVAIL=$(echo $STRING | cut -d, -f3)
2342 DFFREE=$(($DFTOTAL - $DFUSED))
2344 ALLOWANCE=$((64 * $OSTCOUNT))
2346 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2347 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2348 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2351 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2352 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2353 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2356 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2357 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2358 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2363 stop fs3ost -f || error "unable to stop OST3"
2364 stop fs2ost -f || error "unable to stop OST2"
2365 stop fs2mds -f || error "unable to stop second MDS"
2366 unload_modules_conf || error "unable unload modules"
2369 run_test 36 "df report consistency on OSTs with different block size"
2372 local mntpt=$(facet_mntpt $SINGLEMDS)
2373 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2374 local mdsdev_sym="$TMP/sym_mdt.img"
2375 local opts=$MDS_MOUNT_OPTS
2378 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2379 skip "Currently only applicable to ldiskfs-based MDTs"
2383 echo "MDS : $mdsdev"
2384 echo "SYMLINK : $mdsdev_sym"
2385 do_facet $SINGLEMDS rm -f $mdsdev_sym
2387 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2389 echo "mount symlink device - $mdsdev_sym"
2391 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2392 opts=$(csa_add "$opts" -o loop)
2394 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2395 $mdsdev_sym $mntpt 2>&1)
2398 echo mount_op=$mount_op
2400 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
2402 if $(echo $mount_op | grep -q "unable to set tunable"); then
2403 error "set tunables failed for symlink device"
2406 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2408 run_test 37 "verify set tunables works for symlink device"
2410 test_38() { # bug 14222
2411 local fstype=$(facet_fstype $SINGLEMDS)
2412 local mntpt=$(facet_mntpt $SINGLEMDS)
2417 local SRC="/etc /bin"
2418 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2419 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2420 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2421 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2422 error "copying $SRC to $DIR/$tdir"
2424 umount_client $MOUNT || error "umount_client $MOUNT failed"
2425 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2426 stop_mds || error "Unable to stop MDS"
2427 log "delete lov_objid file on MDS"
2429 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2431 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2433 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2435 # check create in mds_lov_connect
2436 start_mds || error "unable to start MDS"
2437 mount_client $MOUNT || error "mount_client $MOUNT failed"
2439 [ $V ] && log "verifying $DIR/$tdir/$f"
2440 diff -q $f $DIR/$tdir/$f || ERROR=y
2442 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2443 if [ "$ERROR" = "y" ]; then
2444 # check it's updates in sync
2445 umount_client $MOUNT
2447 mount_fstype $SIGNLEMDS
2448 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2449 unmount_fstype $SINGLEMDS
2450 error "old and new files are different after connect" || true
2452 touch $DIR/$tdir/f2 || error "f2 file create failed"
2454 # check it's updates in sync
2455 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2458 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2460 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2461 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2463 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2465 start_mds || error "unable to start MDS"
2466 mount_client $MOUNT || error "mount_client $MOUNT failed"
2468 [ $V ] && log "verifying $DIR/$tdir/$f"
2469 diff -q $f $DIR/$tdir/$f || ERROR=y
2471 touch $DIR/$tdir/f3 || error "f3 file create failed"
2472 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2473 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2475 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2476 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2477 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2479 [ "$ERROR" = "y" ] &&
2480 error "old and new files are different after sync" || true
2482 log "files compared the same"
2483 cleanup || error "cleanup failed with $?"
2485 run_test 38 "MDS recreates missing lov_objid file from OST data"
2490 cleanup || error "cleanup failed with $?"
2491 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2492 error "memory leak detected" || true
2494 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2496 test_40() { # bug 15759
2497 start_ost || error "Unable to start OST1"
2498 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2499 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2501 cleanup || error "cleanup failed with rc $?"
2503 run_test 40 "race during service thread startup"
2505 test_41a() { #bug 14134
2506 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2507 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2508 skip "Loop devices does not work with nosvc option"
2512 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2514 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2515 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2516 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2517 mount_client $MOUNT || error "mount_client $MOUNT failed"
2520 echo "blah blah" > $MOUNT/$tfile
2523 umount_client $MOUNT || error "umount_client $MOUNT failed"
2524 stop ost1 -f || error "unable to stop OST1"
2525 stop_mds || error "Unable to stop MDS"
2526 stop_mds || error "Unable to stop MDS on second try"
2527 unload_modules_conf || error "unload_modules_conf failed"
2529 run_test 41a "mount mds with --nosvc and --nomgs"
2532 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2533 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2534 skip "Loop devices does not work with nosvc option"
2538 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2542 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2544 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
2545 start_ost || error "Unable to start OST1"
2546 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
2547 mount_client $MOUNT || error "mount_client $MOUNT failed"
2550 echo "blah blah" > $MOUNT/$tfile
2551 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
2553 umount_client $MOUNT || error "umount_client $MOUNT failed"
2554 stop_ost || error "Unable to stop OST1"
2555 stop_mds || error "Unable to stop MDS"
2556 stop_mds || error "Unable to stop MDS on second try"
2558 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2561 local server_version=$(lustre_version_code $SINGLEMDS)
2563 [[ $server_version -ge $(version_code 2.6.52) ]] ||
2564 [[ $server_version -ge $(version_code 2.5.26) &&
2565 $server_version -lt $(version_code 2.5.50) ]] ||
2566 [[ $server_version -ge $(version_code 2.5.4) &&
2567 $server_version -lt $(version_code 2.5.11) ]] ||
2568 { skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"; return; }
2571 # MDT concurent start
2572 #define OBD_FAIL_TGT_DELAY_CONNECT 0x703
2573 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x703"
2574 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS &
2577 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
2578 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS &
2584 if [ $rc == 0 ] && [ $rc2 == 114 ]; then
2585 echo "1st MDT start succeed"
2586 echo "2nd MDT start failed with EALREADY"
2587 elif [ $rc2 == 0 ] && [ $rc == 114 ]; then
2588 echo "1st MDT start failed with EALREADY"
2589 echo "2nd MDT start succeed"
2592 error "unexpected concurent MDT mounts result, rc=$rc rc2=$rc2"
2595 # OST concurent start
2596 #define OBD_FAIL_TGT_DELAY_CONNECT 0x703
2597 do_facet ost1 "$LCTL set_param fail_loc=0x703"
2598 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &
2601 do_facet ost1 "$LCTL set_param fail_loc=0x0"
2602 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &
2608 if [ $rc == 0 ] && [ $rc2 == 114 ]; then
2609 echo "1st OST start succeed"
2610 echo "2nd OST start failed with EALREADY"
2611 elif [ $rc2 == 0 ] && [ $rc == 114 ]; then
2612 echo "1st OST start failed with EALREADY"
2613 echo "2nd OST start succeed"
2617 error "unexpected concurent OST mounts result, rc=$rc rc2=$rc2"
2623 # verify everything ok
2628 error "MDT(s) start failed"
2636 error "OST(s) start failed"
2644 error "client start failed"
2651 error "client mount failed"
2655 run_test 41c "concurent mounts of MDT/OST should all fail but one"
2657 test_42() { #bug 14693
2659 check_mount || error "client was not mounted"
2661 do_facet mgs $LCTL conf_param $FSNAME.llite.some_wrong_param=10
2662 umount_client $MOUNT ||
2663 error "unmounting client failed with invalid llite param"
2664 mount_client $MOUNT ||
2665 error "mounting client failed with invalid llite param"
2667 do_facet mgs $LCTL conf_param $FSNAME.sys.some_wrong_param=20
2668 cleanup || error "stopping $FSNAME failed with invalid sys param"
2671 check_mount || error "client was not mounted with invalid sys param"
2672 cleanup || error "stopping $FSNAME failed with invalid sys param"
2674 run_test 42 "allow client/server mount/unmount with invalid config param"
2677 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.58) ]] ||
2678 { skip "Need MDS version at least 2.5.58" && return 0; }
2679 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
2682 USER1=$(cat /etc/passwd | grep :$ID1:$ID1: | cut -d: -f1)
2683 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
2687 chmod ugo+x $DIR || error "chmod 0 failed"
2688 set_conf_param_and_check mds \
2689 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2690 "$FSNAME.mdt.root_squash" \
2692 wait_update $HOSTNAME \
2693 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
2695 error "check llite root_squash failed!"
2696 set_conf_param_and_check mds \
2697 "$LCTL get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2698 "$FSNAME.mdt.nosquash_nids" \
2700 wait_update $HOSTNAME \
2701 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
2703 error "check llite nosquash_nids failed!"
2706 # create set of test files
2708 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
2709 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
2710 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
2712 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
2713 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
2715 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
2716 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
2717 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
2719 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
2720 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
2721 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
2724 # check root_squash:
2725 # set root squash UID:GID to RUNAS_ID
2726 # root should be able to access only files owned by RUNAS_ID
2728 set_conf_param_and_check mds \
2729 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
2730 "$FSNAME.mdt.root_squash" \
2731 "$RUNAS_ID:$RUNAS_ID"
2732 wait_update $HOSTNAME \
2733 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
2734 "$RUNAS_ID:$RUNAS_ID" ||
2735 error "check llite root_squash failed!"
2737 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
2738 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
2739 error "$ST: root read permission is denied"
2740 echo "$ST: root read permission is granted - ok"
2743 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
2744 error "$ST: root write permission is denied"
2745 echo "$ST: root write permission is granted - ok"
2747 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2748 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
2749 error "$ST: root read permission is granted"
2750 echo "$ST: root read permission is denied - ok"
2753 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
2754 error "$ST: root write permission is granted"
2755 echo "$ST: root write permission is denied - ok"
2757 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2758 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
2759 error "$ST: root unlink permission is granted"
2760 echo "$ST: root unlink permission is denied - ok"
2762 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
2763 error "$ST: root create permission is granted"
2764 echo "$ST: root create permission is denied - ok"
2767 # check root_squash is enforced independently
2768 # of client cache content
2770 # access file by USER1, keep access open
2771 # root should be denied access to user file
2773 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
2777 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
2778 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
2779 { kill $pid; error "$ST: root read permission is granted"; }
2780 echo "$ST: root read permission is denied - ok"
2783 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
2784 { kill $pid; error "$ST: root write permission is granted"; }
2785 echo "$ST: root write permission is denied - ok"
2791 # check nosquash_nids:
2792 # put client's NID into nosquash_nids list,
2793 # root should be able to access root file after that
2795 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
2796 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
2797 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
2798 set_conf_param_and_check mds \
2799 "$LCTL get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
2800 "$FSNAME-MDTall.mdt.nosquash_nids" \
2802 wait_update $HOSTNAME \
2803 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
2805 error "check llite nosquash_nids failed!"
2807 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
2808 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
2809 error "$ST: root read permission is denied"
2810 echo "$ST: root read permission is granted - ok"
2813 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
2814 error "$ST: root write permission is denied"
2815 echo "$ST: root write permission is granted - ok"
2817 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
2818 rm $DIR/$tdir-rootdir/tfile-1 ||
2819 error "$ST: root unlink permission is denied"
2820 echo "$ST: root unlink permission is granted - ok"
2821 touch $DIR/$tdir-rootdir/tfile-2 ||
2822 error "$ST: root create permission is denied"
2823 echo "$ST: root create permission is granted - ok"
2825 run_test 43 "check root_squash and nosquash_nids"
2827 umount_client $MOUNT
2832 check_mount || error "check_mount"
2833 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
2835 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
2836 for VAL in $UUIDS; do
2837 NID=$(echo $VAL | cut -d= -f1)
2838 CLUUID=$(echo $VAL | cut -d= -f2)
2839 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
2841 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
2842 cleanup || error "cleanup failed with $?"
2844 run_test 44 "mounted client proc entry exists"
2848 check_mount || error "check_mount"
2849 stop_mds || error "Unable to stop MDS"
2853 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
2854 do_facet client "$LCTL set_param fail_loc=0x50f"
2857 manual_umount_client --force || error "manual_umount_client failed"
2858 do_facet client "$LCTL set_param fail_loc=0x0"
2859 start_mds || error "unable to start MDS"
2860 mount_client $MOUNT || error "mount_client $MOUNT failed"
2861 cleanup || error "cleanup failed with $?"
2863 run_test 45 "long unlink handling in ptlrpcd"
2870 umount_client $MOUNT2 || rc=$?
2871 umount_client $MOUNT || rc=$?
2872 while [ $count -gt 0 ]; do
2873 stop ost${count} -f || rc=$?
2877 cleanup_nocli || rc=$?
2878 #writeconf to remove all ost2 traces for subsequent tests
2879 writeconf_or_reformat
2884 echo "Testing with $OSTCOUNT OSTs"
2886 start_mds || error "unable to start MDS"
2887 #first client should see only one ost
2888 start_ost || error "Unable to start OST1"
2889 wait_osc_import_state mds ost FULL
2891 mount_client $MOUNT || error "mount_client $MOUNT failed"
2892 trap "cleanup_46a $OSTCOUNT" EXIT ERR
2895 for (( i=2; i<=$OSTCOUNT; i++ )); do
2896 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
2897 error "start_ost$i $(ostdevname $i) failed"
2900 # wait until osts in sync
2901 for (( i=2; i<=$OSTCOUNT; i++ )); do
2902 wait_osc_import_state mds ost$i FULL
2903 wait_osc_import_state client ost$i FULL
2906 #second client see all ost's
2908 mount_client $MOUNT2 || error "mount_client failed"
2909 $SETSTRIPE -c -1 $MOUNT2 || error "$SETSTRIPE -c -1 $MOUNT2 failed"
2910 $GETSTRIPE $MOUNT2 || error "$GETSTRIPE $MOUNT2 failed"
2912 echo "ok" > $MOUNT2/widestripe
2913 $GETSTRIPE $MOUNT2/widestripe ||
2914 error "$GETSTRIPE $MOUNT2/widestripe failed"
2915 # fill acl buffer for avoid expand lsm to them
2916 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
2918 setfacl -m $acl $MOUNT2/widestripe
2922 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
2924 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
2926 run_test 46a "handle ost additional - wide striped file"
2931 check_mount || error "check_mount failed"
2932 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
2936 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2937 if echo $ns | grep "MDT[[:digit:]]*"; then
2940 lrs=$(echo $ns | sed 's/.*lru_size=//')
2941 lru_size[count]=$lrs
2946 facet_failover $SINGLEMDS
2947 client_up || error "client_up failed"
2950 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
2951 if echo $ns | grep "MDT[[:digit:]]*"; then
2954 lrs=$(echo $ns | sed 's/.*lru_size=//')
2955 if ! test "$lrs" -eq "${lru_size[count]}"; then
2956 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2957 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2962 cleanup || error "cleanup failed with $?"
2964 run_test 47 "server restart does not make client loss lru_resize settings"
2969 # reformat after this test is needed - if test will failed
2970 # we will have unkillable file at FS
2974 test_48() { # bug 17636
2977 check_mount || error "check_mount failed"
2979 $SETSTRIPE -c -1 $MOUNT || error "$SETSTRIPE -c -1 $MOUNT failed"
2980 $GETSTRIPE $MOUNT || error "$GETSTRIPE $MOUNT failed"
2982 echo "ok" > $MOUNT/widestripe
2983 $GETSTRIPE $MOUNT/widestripe ||
2984 error "$GETSTRIPE $MOUNT/widestripe failed"
2986 trap cleanup_48 EXIT ERR
2988 # fill acl buffer for avoid expand lsm to them
2989 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2990 setfacl -m $acl $MOUNT/widestripe
2993 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
2997 run_test 48 "too many acls on file"
2999 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3000 test_49a() { # bug 17710
3001 local timeout_orig=$TIMEOUT
3002 local ldlm_timeout_orig=$LDLM_TIMEOUT
3003 local LOCAL_TIMEOUT=20
3005 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3006 TIMEOUT=$LOCAL_TIMEOUT
3010 check_mount || error "client mount failed"
3012 echo "check ldlm_timout..."
3013 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3014 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3015 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3017 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3018 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3021 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3022 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3025 umount_client $MOUNT || error "umount_client $MOUNT failed"
3026 stop_ost || error "problem stopping OSS"
3027 stop_mds || error "problem stopping MDS"
3029 LDLM_TIMEOUT=$ldlm_timeout_orig
3030 TIMEOUT=$timeout_orig
3032 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3034 test_49b() { # bug 17710
3035 local timeout_orig=$TIMEOUT
3036 local ldlm_timeout_orig=$LDLM_TIMEOUT
3037 local LOCAL_TIMEOUT=20
3039 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3040 TIMEOUT=$LOCAL_TIMEOUT
3044 check_mount || error "client mount failed"
3046 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3047 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3048 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3050 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3051 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3054 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3055 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3058 cleanup || error "cleanup failed"
3060 LDLM_TIMEOUT=$ldlm_timeout_orig
3061 TIMEOUT=$timeout_orig
3063 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3066 # Test both statfs and lfs df and fail if either one fails
3067 multiop_bg_pause $1 f_
3070 killall -USR1 multiop
3071 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
3072 wait $PID || { RC1=$?; log "multiop return error "; }
3079 if [ $RC2 -eq 0 ]; then
3081 log "lazystatfs df failed"
3085 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
3091 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3092 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3094 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3096 cleanup || error "cleanup failed with rc $?"
3098 run_test 50a "lazystatfs all servers available"
3102 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3103 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3105 # Wait for client to detect down OST
3106 stop_ost || error "Unable to stop OST1"
3107 wait_osc_import_state mds ost DISCONN
3109 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
3111 umount_client $MOUNT || error "Unable to unmount client"
3112 stop_mds || error "Unable to stop MDS"
3114 run_test 50b "lazystatfs all servers down"
3117 start_mds || error "Unable to start MDS"
3118 start_ost || error "Unable to start OST1"
3119 start_ost2 || error "Unable to start OST2"
3120 mount_client $MOUNT || error "Unable to mount client"
3121 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3122 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3124 # Wait for client to detect down OST
3125 stop_ost || error "Unable to stop OST1"
3126 wait_osc_import_state mds ost DISCONN
3127 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3129 umount_client $MOUNT || error "Unable to unmount client"
3130 stop_ost2 || error "Unable to stop OST2"
3131 stop_mds || error "Unable to stop MDS"
3132 #writeconf to remove all ost2 traces for subsequent tests
3133 writeconf_or_reformat
3135 run_test 50c "lazystatfs one server down"
3138 start_mds || error "Unable to start MDS"
3139 start_ost || error "Unable to start OST1"
3140 start_ost2 || error "Unable to start OST2"
3141 mount_client $MOUNT || error "Unable to mount client"
3142 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3143 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3145 # Issue the statfs during the window where the client still
3146 # belives the OST to be available but it is in fact down.
3147 # No failure just a statfs which hangs for a timeout interval.
3148 stop_ost || error "Unable to stop OST1"
3149 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3151 umount_client $MOUNT || error "Unable to unmount client"
3152 stop_ost2 || error "Unable to stop OST2"
3153 stop_mds || error "Unable to stop MDS"
3154 #writeconf to remove all ost2 traces for subsequent tests
3155 writeconf_or_reformat
3157 run_test 50d "lazystatfs client/server conn race"
3164 start_mds || error "Unable to start MDS"
3165 #first client should see only one ost
3166 start_ost || error "Unable to start OST1"
3167 wait_osc_import_state mds ost FULL
3169 # Wait for client to detect down OST
3170 stop_ost || error "Unable to stop OST1"
3171 wait_osc_import_state mds ost DISCONN
3173 mount_client $MOUNT || error "Unable to mount client"
3174 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3176 multiop_bg_pause $MOUNT _f
3180 if [ $RC1 -ne 0 ]; then
3181 log "multiop failed $RC1"
3184 sleep $(( $TIMEOUT+1 ))
3186 [ $? -ne 0 ] && error "process isn't sleep"
3187 start_ost || error "Unable to start OST1"
3188 wait $pid || error "statfs failed"
3191 umount_client $MOUNT || error "Unable to unmount client"
3192 stop_ost || error "Unable to stop OST1"
3193 stop_mds || error "Unable to stop MDS"
3195 run_test 50e "normal statfs all servers down"
3200 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3202 start_mds || error "Unable to start mds"
3203 #first client should see only one ost
3204 start_ost || error "Unable to start OST1"
3205 wait_osc_import_state mds ost FULL
3207 start_ost2 || error "Unable to start OST2"
3208 wait_osc_import_state mds ost2 FULL
3210 # Wait for client to detect down OST
3211 stop_ost2 || error "Unable to stop OST2"
3213 wait_osc_import_state mds ost2 DISCONN
3214 mount_client $MOUNT || error "Unable to mount client"
3215 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3217 multiop_bg_pause $MOUNT _f
3221 if [ $RC1 -ne 0 ]; then
3222 log "lazystatfs multiop failed $RC1"
3225 sleep $(( $TIMEOUT+1 ))
3227 [ $? -ne 0 ] && error "process isn't sleep"
3228 start_ost2 || error "Unable to start OST2"
3229 wait $pid || error "statfs failed"
3230 stop_ost2 || error "Unable to stop OST2"
3233 umount_client $MOUNT || error "Unable to unmount client"
3234 stop_ost || error "Unable to stop OST1"
3235 stop_mds || error "Unable to stop MDS"
3236 #writeconf to remove all ost2 traces for subsequent tests
3237 writeconf_or_reformat
3239 run_test 50f "normal statfs one server in down"
3242 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
3244 start_ost2 || error "Unable to start OST2"
3245 wait_osc_import_state mds ost2 FULL
3246 wait_osc_import_state client ost2 FULL
3248 local PARAM="${FSNAME}-OST0001.osc.active"
3250 $SETSTRIPE -c -1 $DIR/$tfile || error "$SETSTRIPE failed"
3251 do_facet mgs $LCTL conf_param $PARAM=0 ||
3252 error "Unable to deactivate OST"
3254 umount_client $MOUNT || error "Unable to unmount client"
3255 mount_client $MOUNT || error "Unable to mount client"
3256 # This df should not cause a panic
3259 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
3260 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
3261 umount_client $MOUNT || error "Unable to unmount client"
3262 stop_ost2 || error "Unable to stop OST2"
3263 stop_ost || error "Unable to stop OST1"
3264 stop_mds || error "Unable to stop MDS"
3265 #writeconf to remove all ost2 traces for subsequent tests
3266 writeconf_or_reformat
3268 run_test 50g "deactivated OST should not cause panic"
3272 # prepare MDT/OST, make OSC inactive for OST1
3273 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
3275 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3276 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3277 error "tunefs OST1 failed"
3278 start_mds || error "Unable to start MDT"
3279 start_ost || error "Unable to start OST1"
3280 start_ost2 || error "Unable to start OST2"
3281 mount_client $MOUNT || error "client start failed"
3283 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3285 # activatate OSC for OST1
3286 local TEST="$LCTL get_param -n osc.${FSNAME}-OST0000-osc-[!M]*.active"
3287 set_conf_param_and_check client \
3288 "$TEST" "${FSNAME}-OST0000.osc.active" 1 ||
3289 error "Unable to activate OST1"
3291 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3292 $SETSTRIPE -c -1 -i 0 $DIR/$tdir/2 ||
3293 error "$SETSTRIPE $DIR/$tdir/2 failed"
3294 sleep 1 && echo "create a file after OST1 is activated"
3296 createmany -o $DIR/$tdir/2/$tfile-%d 1
3298 # check OSC import is working
3299 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3300 error "some OSC imports are still not connected"
3303 umount_client $MOUNT || error "Unable to umount client"
3304 stop_ost2 || error "Unable to stop OST2"
3305 cleanup_nocli || error "cleanup_nocli failed with $?"
3307 run_test 50h "LU-642: activate deactivated OST"
3310 local LOCAL_TIMEOUT=20
3314 check_mount || error "check_mount failed"
3316 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3317 $SETSTRIPE -c -1 $MOUNT/$tdir ||
3318 error "$SETSTRIPE -c -1 $MOUNT/$tdir failed"
3319 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3320 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
3321 touch $MOUNT/$tdir/$tfile &
3324 start_ost2 || error "Unable to start OST1"
3326 stop_ost2 || error "Unable to stop OST1"
3327 cleanup || error "cleanup failed with $?"
3328 #writeconf to remove all ost2 traces for subsequent tests
3329 writeconf_or_reformat
3331 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
3340 do_node $node mkdir -p $dest
3341 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3343 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
3344 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3345 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
3347 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
3348 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
3358 local backup2=${TMP}/backup2
3360 do_node $node mkdir -p $backup2
3361 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3363 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
3364 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3365 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
3367 do_node $node "diff -rq $backup $backup2"
3368 [ $? -eq 0 ] || { error "contents differ"; return 3; }
3370 local xattrs2=${TMP}/xattrs2
3371 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
3372 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
3374 do_node $node "diff $xattrs $xattrs2"
3375 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
3377 do_node $node "rm -rf $backup2 $xattrs2"
3378 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
3382 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3383 skip "Only applicable to ldiskfs-based MDTs"
3387 start_mds || error "Unable to start MDS"
3388 start_ost || error "Unable to start OST1"
3389 mount_client $MOUNT || error "Unable to mount client"
3392 local ost1mnt=$(facet_mntpt ost1)
3393 local ost1node=$(facet_active_host ost1)
3394 local ost1tmp=$TMP/conf52
3397 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
3398 touch $TMP/modified_first || error "Unable to create temporary file"
3399 local mtime=$(stat -c %Y $TMP/modified_first)
3400 do_node $ost1node "mkdir -p $ost1tmp &&
3401 touch -m -d @$mtime $ost1tmp/modified_first" ||
3402 error "Unable to create temporary file"
3405 $SETSTRIPE -c -1 -S 1M $DIR/$tdir || error "$SETSTRIPE failed"
3407 for (( i=0; i < nrfiles; i++ )); do
3408 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
3409 error "multiop failed"
3415 echo backup files to $TMP/files
3416 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
3417 copy_files_xattrs $(hostname) $TMP/files $TMP/file_xattrs $files ||
3418 error "Unable to copy files"
3420 umount_client $MOUNT || error "Unable to umount client"
3421 stop_ost || error "Unable to stop ost1"
3423 echo mount ost1 as ldiskfs
3424 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
3425 if ! do_node $ost1node test -b $ost1_dev; then
3428 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
3430 error "Unable to mount ost1 as ldiskfs"
3433 echo backup objects to $ost1tmp/objects
3434 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
3435 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
3436 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
3438 error "Unable to copy objects"
3440 # move objects to lost+found
3441 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
3442 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
3444 # recover objects dry-run
3445 echo "ll_recover_lost_found_objs dry_run"
3446 do_node $ost1node "ll_recover_lost_found_objs -n -d $ost1mnt/O" ||
3447 error "ll_recover_lost_found_objs failed"
3450 echo "ll_recover_lost_found_objs fix run"
3451 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found" ||
3452 error "ll_recover_lost_found_objs failed"
3454 # compare restored objects against saved ones
3455 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
3456 [ $? -eq 0 ] || error "Unable to diff objects"
3458 do_node $ost1node "umount $ost1mnt" ||
3459 error "Unable to umount ost1 as ldiskfs"
3461 start_ost || error "Unable to start OST1"
3462 mount_client $MOUNT || error "Unable to mount client"
3465 diff_files_xattrs $(hostname) $TMP/files $TMP/file_xattrs $files ||
3466 error "Unable to diff files"
3468 rm -rf $TMP/files $TMP/file_xattrs ||
3469 error "Unable to delete temporary files"
3470 do_node $ost1node "rm -rf $ost1tmp" ||
3471 error "Unable to delete temporary files"
3472 cleanup || error "cleanup failed with $?"
3474 run_test 52 "check recovering objects from lost+found"
3476 # Checks threads_min/max/started for some service
3478 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
3479 # parameter pattern prefix like 'ost.*.ost'.
3492 local msg="Insane $modname thread counts"
3493 local ncpts=$(check_cpt_number $facet)
3497 check_mount || return 41
3499 # We need to expand $parampat, but it may match multiple parameters, so
3500 # we'll pick the first one
3501 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
3502 error "Couldn't expand ${parampat}.threads_min parameter name"
3506 # Remove the .threads_min part
3507 paramp=${paramp%.threads_min}
3509 # Check for sanity in defaults
3510 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
3512 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
3514 tstarted=$(do_facet $facet "$LCTL get_param \
3515 -n ${paramp}.threads_started" || echo 0)
3516 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
3518 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
3520 nthrs=$(expr $tmax - $tmin)
3521 if [ $nthrs -lt $ncpts ]; then
3527 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
3528 skip_env "module parameter forced $facet thread count" &&
3529 tmin=3 && tmax=$((3 * tmax))
3531 # Check that we can change min/max
3532 do_facet $facet "$LCTL set_param \
3533 ${paramp}.threads_min=$((tmin + nthrs))"
3534 do_facet $facet "$LCTL set_param \
3535 ${paramp}.threads_max=$((tmax - nthrs))"
3536 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
3538 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
3540 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
3541 $tmax2 == ($tmax - $nthrs)))' || return $?
3543 # Check that we can set min/max to the same value
3544 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
3546 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
3547 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
3549 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
3551 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
3553 # Check that we can't set max < min
3554 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
3555 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
3557 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
3559 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
3561 # We need to ensure that we get the module options desired; to do this
3562 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
3563 LOAD_MODULES_REMOTE=true
3566 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
3567 setmodopts -a $modname "$newvalue" oldvalue
3571 check_mount || return 41
3573 # Restore previous setting of MODOPTS_*
3574 setmodopts $modname "$oldvalue"
3576 # Check that $opts took
3577 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min")
3578 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max")
3579 tstarted=$(do_facet $facet \
3580 "$LCTL get_param -n ${paramp}.threads_started")
3581 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
3591 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
3592 cleanup || error "cleanup failed with rc $?"
3594 run_test 53a "check OSS thread count params"
3598 local mds=$(do_facet $SINGLEMDS "$LCTL get_param \
3599 -N mds.*.*.threads_max 2>/dev/null")
3600 if [ -z "$mds" ]; then
3601 #running this on an old MDT
3602 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
3604 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
3606 cleanup || error "cleanup failed with $?"
3608 run_test 53b "check MDS thread count params"
3611 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3612 skip "Only applicable to ldiskfs-based MDTs"
3616 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
3617 error "llverdev failed with rc=$?"
3620 run_test 54a "test llverdev and partial verify of device"
3623 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3624 skip "Only applicable to ldiskfs-based MDTs"
3629 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
3630 cleanup || error "cleanup failed with rc=$?"
3632 run_test 54b "test llverfs and partial verify of filesystem"
3636 local max_ost_index=$1
3637 echo -n $(((max_ost_index + 1) * 8))
3641 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3642 skip "Only applicable to ldiskfs-based MDTs"
3646 local mdsdev=$(mdsdevname 1)
3647 local mdsvdev=$(mdsvdevname 1)
3651 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
3653 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
3654 --reformat $(ostdevname 1) $(ostvdevname 1)
3660 echo checking size of lov_objid for ost index $i
3661 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
3662 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
3663 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
3665 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
3672 run_test 55 "check lov_objid size"
3675 local server_version=$(lustre_version_code $SINGLEMDS)
3676 local mds_journal_size_orig=$MDSJOURNALSIZE
3681 for num in $(seq 1 $MDSCOUNT); do
3682 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3683 --reformat $(mdsdevname $num) $(mdsvdevname $num)
3685 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
3686 $(ostdevname 1) $(ostvdevname 1)
3687 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
3688 $(ostdevname 2) $(ostvdevname 2)
3691 start_ost || error "Unable to start first ost (idx 10000)"
3692 start_ost2 || error "Unable to start second ost (idx 1000)"
3693 mount_client $MOUNT || error "Unable to mount client"
3697 if [[ $server_version -ge $(version_code 2.6.54) ]] ||
3698 [[ $server_version -ge $(version_code 2.5.4) &&
3699 $server_version -lt $(version_code 2.5.11) ]]; then
3700 wait_osc_import_state mds ost1 FULL
3701 wait_osc_import_state mds ost2 FULL
3702 $SETSTRIPE --stripe-count=-1 $DIR/$tfile ||
3703 error "Unable to setstripe $DIR/$tfile"
3704 n=$($LFS getstripe --stripe-count $DIR/$tfile)
3705 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
3710 MDSJOURNALSIZE=$mds_journal_size_orig
3713 run_test 56 "check big OST indexes and out-of-index-order start"
3715 test_57a() { # bug 22656
3716 do_rpc_nodes $(facet_active_host ost1) load_modules_local
3717 local NID=$(do_facet ost1 "$LCTL get_param nis" |
3718 tail -1 | awk '{print $1}')
3719 writeconf_or_reformat
3720 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3721 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
3722 error "tunefs failed"
3724 start_ost && error "OST registration from failnode should fail"
3727 run_test 57a "initial registration from failnode should fail (should return errs)"
3730 do_rpc_nodes $(facet_active_host ost1) load_modules_local
3731 local NID=$(do_facet ost1 "$LCTL get_param nis" |
3732 tail -1 | awk '{print $1}')
3733 writeconf_or_reformat
3734 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3735 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
3736 error "tunefs failed"
3738 start_ost || error "OST registration from servicenode should not fail"
3741 run_test 57b "initial registration from servicenode should not fail"
3744 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
3747 test_58() { # bug 22658
3749 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3750 createmany -o $DIR/$tdir/$tfile-%d 100
3751 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
3752 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
3753 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x601"
3754 unlinkmany $DIR/$tdir/$tfile-%d 100
3755 stop_mds || error "Unable to stop MDS"
3757 local MNTDIR=$(facet_mntpt $SINGLEMDS)
3758 local devname=$(mdsdevname ${SINGLEMDS//mds/})
3760 # remove all files from the OBJECTS dir
3761 mount_fstype $SINGLEMDS
3763 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
3765 unmount_fstype $SINGLEMDS
3766 # restart MDS with missing llog files
3767 start_mds || error "unable to start MDS"
3768 do_facet mds "$LCTL set_param fail_loc=0"
3771 run_test 58 "missing llog files must not prevent MDT from mounting"
3774 start_mgsmds >> /dev/null
3775 local C1=$(count_osts)
3776 if [ $C1 -eq 0 ]; then
3777 start_ost >> /dev/null
3781 echo "original ost count: $C1 (expect > 0)"
3782 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
3783 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
3784 local C2=$(count_osts)
3785 echo "after mdt writeconf count: $C2 (expect 0)"
3786 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
3787 echo "OST start without writeconf should fail:"
3788 start_ost >> /dev/null &&
3789 error "OST start without writeconf didn't fail"
3790 echo "OST start with writeconf should succeed:"
3791 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
3792 local C3=$(count_osts)
3793 echo "after ost writeconf count: $C3 (expect 1)"
3794 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
3795 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
3796 local C4=$(count_osts)
3797 echo "after ost2 writeconf count: $C4 (expect 2)"
3798 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
3799 stop_ost2 >> /dev/null
3800 cleanup_nocli >> /dev/null
3801 #writeconf to remove all ost2 traces for subsequent tests
3802 writeconf_or_reformat
3804 run_test 59 "writeconf mount option"
3806 test_60() { # LU-471
3809 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3810 skip "Only applicable to ldiskfs-based MDTs"
3814 for num in $(seq $MDSCOUNT); do
3815 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
3816 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
3817 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3821 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
3822 [ ${PIPESTATUS[0]} -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
3824 # MDT default has dirdata feature
3825 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
3826 # we disable uninit_bg feature
3827 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
3828 # we set stride extended options
3829 echo $dump | grep stride > /dev/null || error "stride is not set"
3832 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
3835 local reformat=false
3837 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
3838 { skip "Need MDS version at least 2.1.53"; return 0; }
3840 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
3841 ! large_xattr_enabled; then
3843 LDISKFS_MKFS_OPTS+=" -O large_xattr"
3845 for num in $(seq $MDSCOUNT); do
3846 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
3847 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
3848 error "add mds $num failed"
3852 setup_noconfig || error "setting up the filesystem failed"
3853 client_up || error "starting client failed"
3855 local file=$DIR/$tfile
3856 touch $file || error "touch $file failed"
3858 local large_value="$(generate_string $(max_xattr_size))"
3859 local small_value="bar"
3861 local name="trusted.big"
3862 log "save large xattr $name on $file"
3863 setfattr -n $name -v $large_value $file ||
3864 error "saving $name on $file failed"
3866 local new_value=$(get_xattr_value $name $file)
3867 [[ "$new_value" != "$large_value" ]] &&
3868 error "$name different after saving"
3870 log "shrink value of $name on $file"
3871 setfattr -n $name -v $small_value $file ||
3872 error "shrinking value of $name on $file failed"
3874 new_value=$(get_xattr_value $name $file)
3875 [[ "$new_value" != "$small_value" ]] &&
3876 error "$name different after shrinking"
3878 log "grow value of $name on $file"
3879 setfattr -n $name -v $large_value $file ||
3880 error "growing value of $name on $file failed"
3882 new_value=$(get_xattr_value $name $file)
3883 [[ "$new_value" != "$large_value" ]] &&
3884 error "$name different after growing"
3886 log "check value of $name on $file after remounting MDS"
3888 new_value=$(get_xattr_value $name $file)
3889 [[ "$new_value" != "$large_value" ]] &&
3890 error "$name different after remounting MDS"
3892 log "remove large xattr $name from $file"
3893 setfattr -x $name $file || error "removing $name from $file failed"
3898 LDISKFS_MKFS_OPTS=${LDISKFS_MKFS_OPTS% -O large_xattr}
3902 run_test 61 "large xattr"
3905 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3906 skip "Only applicable to ldiskfs-based MDTs"
3911 local mdsdev=$(mdsdevname 1)
3912 local ostdev=$(ostdevname 1)
3914 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
3915 { skip "Need MDS version at least 2.2.51"; return 0; }
3917 echo "disable journal for mds"
3918 do_facet mds tune2fs -O ^has_journal $mdsdev || error "tune2fs failed"
3919 start_mds && error "MDT start should fail"
3920 echo "disable journal for ost"
3921 do_facet ost1 tune2fs -O ^has_journal $ostdev || error "tune2fs failed"
3922 start_ost && error "OST start should fail"
3923 cleanup || error "cleanup failed with rc $?"
3926 run_test 62 "start with disabled journal"
3929 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3930 skip "Only applicable to ldiskfs-based MDTs"
3934 local inode_slab=$(do_facet $SINGLEMDS \
3935 "awk '/ldiskfs_inode_cache/ { print \\\$5 }' /proc/slabinfo")
3936 if [ -z "$inode_slab" ]; then
3937 skip "ldiskfs module has not been loaded"
3941 echo "$inode_slab ldisk inodes per page"
3942 [ "$inode_slab" -ge "3" ] ||
3943 error "ldisk inode size is too big, $inode_slab objs per page"
3946 run_test 63 "Verify each page can at least hold 3 ldisk inodes"
3949 start_mds || error "unable to start MDS"
3950 start_ost || error "Unable to start OST1"
3951 start_ost2 || error "Unable to start second ost"
3952 mount_client $MOUNT || error "Unable to mount client"
3953 stop_ost2 || error "Unable to stop second ost"
3955 $LFS df --lazy || error "lfs df failed"
3956 cleanup || error "cleanup failed with $?"
3957 #writeconf to remove all ost2 traces for subsequent tests
3958 writeconf_or_reformat
3960 run_test 64 "check lfs df --lazy "
3962 test_65() { # LU-2237
3963 # Currently, the test is only valid for ldiskfs backend
3964 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
3965 skip "non-ldiskfs backend" && return
3967 local devname=$(mdsdevname ${SINGLEMDS//mds/})
3968 local brpt=$(facet_mntpt brpt)
3971 if ! do_facet $SINGLEMDS "test -b $devname"; then
3975 stop_mds || error "Unable to stop MDS"
3976 local obj=$(do_facet $SINGLEMDS \
3977 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
3979 if [ -z "$obj" ]; then
3980 # The MDT may be just re-formatted, mount the MDT for the
3981 # first time to guarantee the "last_rcvd" file is there.
3982 start_mds || error "fail to mount the MDS for the first time"
3983 stop_mds || error "Unable to stop MDS"
3986 # remove the "last_rcvd" file
3987 do_facet $SINGLEMDS "mkdir -p $brpt"
3988 do_facet $SINGLEMDS \
3989 "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
3990 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
3991 do_facet $SINGLEMDS "umount -d $brpt"
3993 # restart MDS, the "last_rcvd" file should be recreated.
3994 start_mds || error "fail to restart the MDS"
3995 stop_mds || error "Unable to stop MDS"
3996 obj=$(do_facet $SINGLEMDS \
3997 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
3998 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
4000 run_test 65 "re-create the lost last_rcvd file when server mount"
4003 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
4004 { skip "Need MGS version at least 2.3.59"; return 0; }
4007 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
4008 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
4010 echo "replace_nids should fail if MDS, OSTs and clients are UP"
4011 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4012 error "replace_nids fail"
4014 umount_client $MOUNT || error "unmounting client failed"
4015 echo "replace_nids should fail if MDS and OSTs are UP"
4016 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4017 error "replace_nids fail"
4019 stop_ost || error "Unable to stop OST1"
4020 echo "replace_nids should fail if MDS is UP"
4021 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4022 error "replace_nids fail"
4024 stop_mds || error "stopping mds failed"
4026 if combined_mgs_mds; then
4027 start_mdt 1 "-o nosvc" ||
4028 error "starting mds with nosvc option failed"
4031 echo "command should accept two parameters"
4032 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
4033 error "command should accept two params"
4035 echo "correct device name should be passed"
4036 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
4037 error "wrong devname"
4039 echo "wrong nids list should not destroy the system"
4040 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
4043 echo "replace OST nid"
4044 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
4045 error "replace nids failed"
4047 echo "command should accept two parameters"
4048 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
4049 error "command should accept two params"
4051 echo "wrong nids list should not destroy the system"
4052 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
4055 echo "replace MDS nid"
4056 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
4057 error "replace nids failed"
4059 if ! combined_mgs_mds ; then
4062 stop_mds || error "Unable to stop MDS"
4066 check_mount || error "error after nid replace"
4067 cleanup || error "cleanup failed"
4070 run_test 66 "replace nids"
4072 test_67() { #LU-2950
4073 local legacy="$TMP/legacy_lnet_config"
4074 local new="$TMP/new_routes_test"
4075 local out="$TMP/config_out_file"
4076 local verify="$TMP/conv_verify"
4077 local verify_conf="$TMP/conf_verify"
4079 # Create the legacy file that will be run through the
4080 # lustre_routes_conversion script
4081 cat <<- LEGACY_LNET_CONFIG > $legacy
4082 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
4083 tcp2 54 10.1.3.2@tcp;
4084 tcp3 10.3.4.3@tcp:3;
4088 # Create the verification file to verify the output of
4089 # lustre_routes_conversion script against.
4090 cat <<- VERIFY_LNET_CONFIG > $verify
4091 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
4092 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
4093 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
4094 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
4095 tcp4: { gateway: 10.3.3.4@tcp }
4098 # Create the verification file to verify the output of
4099 # lustre_routes_config script against
4100 cat <<- VERIFY_LNET_CONFIG > $verify_conf
4101 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
4102 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
4103 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
4104 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
4105 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
4108 lustre_routes_conversion $legacy $new > /dev/null
4109 if [ -f $new ]; then
4110 # verify the conversion output
4111 cmp -s $new $verify > /dev/null
4112 if [ $? -eq 1 ]; then
4113 error "routes conversion failed"
4116 lustre_routes_config --dry-run --verbose $new > $out
4117 # check that the script succeeded
4118 cmp -s $out $verify_conf > /dev/null
4119 if [ $? -eq 1 ]; then
4120 error "routes config failed"
4123 error "routes conversion test failed"
4125 # remove generated files
4126 rm -f $new $legacy $verify $verify_conf $out
4128 run_test 67 "test routes conversion and configuration"
4136 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.53) ] ||
4137 { skip "Need MDS version at least 2.4.53"; return 0; }
4139 umount_client $MOUNT || error "umount client failed"
4141 start_mdt 1 || error "MDT start failed"
4142 start_ost || error "Unable to start OST1"
4144 # START-END - the sequences we'll be reserving
4145 START=$(do_facet $SINGLEMDS \
4146 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4147 END=$((START + (1 << 30)))
4148 do_facet $SINGLEMDS \
4149 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4151 # reset the sequences MDT0000 has already assigned
4152 do_facet $SINGLEMDS \
4153 $LCTL set_param seq.srv*MDT0000.space=clear
4155 # remount to let the client allocate new sequence
4156 mount_client $MOUNT || error "mount client failed"
4158 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4159 do_facet $SINGLEMDS \
4160 $LCTL get_param seq.srv*MDT0000.space
4161 $LFS path2fid $DIR/$tfile
4163 local old_ifs="$IFS"
4165 fid=($($LFS path2fid $DIR/$tfile))
4169 if [[ $seq < $END ]]; then
4170 error "used reserved sequence $seq?"
4172 cleanup || error "cleanup failed with $?"
4174 run_test 68 "be able to reserve specific sequences in FLDB"
4177 local server_version=$(lustre_version_code $SINGLEMDS)
4179 [[ $server_version -lt $(version_code 2.4.2) ]] &&
4180 skip "Need MDS version at least 2.4.2" && return
4182 [[ $server_version -ge $(version_code 2.4.50) ]] &&
4183 [[ $server_version -lt $(version_code 2.5.0) ]] &&
4184 skip "Need MDS version at least 2.5.0" && return
4188 # use OST0000 since it probably has the most creations
4189 local OSTNAME=$(ostname_from_index 0)
4190 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4191 local last_id=$(do_facet mds1 $LCTL get_param -n \
4192 osc.$mdtosc_proc1.prealloc_last_id)
4194 # Want to have OST LAST_ID over 1.5 * OST_MAX_PRECREATE to
4195 # verify that the LAST_ID recovery is working properly. If
4196 # not, then the OST will refuse to allow the MDS connect
4197 # because the LAST_ID value is too different from the MDS
4198 #define OST_MAX_PRECREATE=20000
4199 local num_create=$((20000 * 5))
4201 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4202 $SETSTRIPE -i 0 $DIR/$tdir || error "$SETSTRIPE -i 0 $DIR/$tdir failed"
4203 createmany -o $DIR/$tdir/$tfile- $num_create ||
4204 error "createmany: failed to create $num_create files: $?"
4205 # delete all of the files with objects on OST0 so the
4206 # filesystem is not inconsistent later on
4207 $LFS find $MOUNT --ost 0 | xargs rm
4209 stop_ost || error "OST0 stop failure"
4210 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
4211 $(ostdevname 1) $(ostvdevname 1) ||
4212 error "reformat and replace $ostdev failed"
4213 start_ost || error "OST0 restart failure"
4214 wait_osc_import_state mds ost FULL
4216 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
4217 local idx=$($GETSTRIPE -i $DIR/$tdir/$tfile-last)
4218 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
4220 cleanup || error "cleanup failed with $?"
4222 run_test 69 "replace an OST with the same index"
4225 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4228 cleanup || error "cleanup failed with $?"
4230 start_mdt 1 || error "MDT0 start fail"
4232 start_ost || error "OST0 start fail"
4234 start_mdt 2 || error "MDT1 start fail"
4236 mount_client $MOUNT || error "mount client fails"
4238 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
4240 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4241 error "create remote dir fail"
4243 rm -rf $DIR/$tdir || error "delete dir fail"
4244 cleanup || error "cleanup failed with $?"
4246 run_test 70a "start MDT0, then OST, then MDT1"
4249 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4252 start_ost || error "OST0 start fail"
4254 start_mdt 1 || error "MDT0 start fail"
4255 start_mdt 2 || error "MDT1 start fail"
4257 mount_client $MOUNT || error "mount client fails"
4259 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
4261 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4262 error "create remote dir fail"
4264 rm -rf $DIR/$tdir || error "delete dir fail"
4266 cleanup || error "cleanup failed with $?"
4268 run_test 70b "start OST, MDT1, MDT0"
4271 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4274 start_mdt 1 || error "MDT0 start fail"
4275 start_mdt 2 || error "MDT1 start fail"
4276 start_ost || error "OST0 start fail"
4278 mount_client $MOUNT || error "mount client fails"
4279 stop_mdt 1 || error "MDT1 start fail"
4281 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
4282 echo "deactivate $mdc_for_mdt1"
4283 $LCTL --device $mdc_for_mdt1 deactivate ||
4284 error "set $mdc_for_mdt1 deactivate failed"
4286 mkdir $DIR/$tdir && error "mkdir succeed"
4288 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4289 error "create remote dir succeed"
4291 cleanup || error "cleanup failed with $?"
4293 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
4296 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4299 start_mdt 1 || error "MDT0 start fail"
4300 start_mdt 2 || error "MDT1 start fail"
4301 start_ost || error "OST0 start fail"
4303 mount_client $MOUNT || error "mount client fails"
4305 stop_mdt 2 || error "MDT1 start fail"
4307 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
4309 echo "deactivate $mdc_for_mdt2"
4310 $LCTL --device $mdc_for_mdt2 deactivate ||
4311 error "set $mdc_for_mdt2 deactivate failed"
4313 mkdir $DIR/$tdir || error "mkdir fail"
4314 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
4315 error "create remote dir succeed"
4317 rm -rf $DIR/$tdir || error "delete dir fail"
4319 cleanup || error "cleanup failed with $?"
4321 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
4324 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4325 if combined_mgs_mds; then
4326 skip "needs separate MGS/MDT" && return
4330 start_mdt 1 || error "MDT0 start fail"
4331 start_ost || error "OST0 start fail"
4332 start_mdt 2 || error "MDT1 start fail"
4333 start_ost2 || error "OST1 start fail"
4335 mount_client $MOUNT || error "mount client fails"
4337 mkdir $DIR/$tdir || error "mkdir fail"
4338 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4339 error "create remote dir succeed"
4341 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4342 rm -rf $DIR/$tdir || error "delete dir fail"
4344 umount_client $MOUNT || error "umount_client failed"
4345 stop_mdt 1 || error "MDT0 stop fail"
4346 stop_mdt 2 || error "MDT1 stop fail"
4347 stop_ost || error "OST0 stop fail"
4348 stop_ost2 || error "OST1 stop fail"
4350 run_test 71a "start MDT0 OST0, MDT1, OST1"
4353 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4354 if combined_mgs_mds; then
4355 skip "needs separate MGS/MDT" && return
4359 start_mdt 2 || error "MDT1 start fail"
4360 start_ost || error "OST0 start fail"
4361 start_mdt 1 || error "MDT0 start fail"
4362 start_ost2 || error "OST1 start fail"
4364 mount_client $MOUNT || error "mount client fails"
4366 mkdir $DIR/$tdir || error "mkdir fail"
4367 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4368 error "create remote dir succeed"
4370 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4371 rm -rf $DIR/$tdir || error "delete dir fail"
4373 umount_client $MOUNT || error "umount_client failed"
4374 stop_mdt 1 || error "MDT0 stop fail"
4375 stop_mdt 2 || error "MDT1 stop fail"
4376 stop_ost || error "OST0 stop fail"
4377 stop_ost2 || error "OST1 stop fail"
4379 run_test 71b "start MDT1, OST0, MDT0, OST1"
4382 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4383 if combined_mgs_mds; then
4384 skip "needs separate MGS/MDT" && return
4388 start_ost || error "OST0 start fail"
4389 start_ost2 || error "OST1 start fail"
4390 start_mdt 2 || error "MDT1 start fail"
4391 start_mdt 1 || error "MDT0 start fail"
4393 mount_client $MOUNT || error "mount client fails"
4395 mkdir $DIR/$tdir || error "mkdir fail"
4396 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4397 error "create remote dir succeed"
4399 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4400 rm -rf $DIR/$tdir || error "delete dir fail"
4402 umount_client $MOUNT || error "umount_client failed"
4403 stop_mdt 1 || error "MDT0 stop fail"
4404 stop_mdt 2 || error "MDT1 stop fail"
4405 stop_ost || error "OST0 stop fail"
4406 stop_ost2 || error "OST1 stop fail"
4409 run_test 71c "start OST0, OST1, MDT1, MDT0"
4412 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4413 if combined_mgs_mds; then
4414 skip "needs separate MGS/MDT" && return
4418 start_ost || error "OST0 start fail"
4419 start_mdt 2 || error "MDT0 start fail"
4420 start_mdt 1 || error "MDT0 start fail"
4421 start_ost2 || error "OST1 start fail"
4423 mount_client $MOUNT || error "mount client fails"
4425 mkdir $DIR/$tdir || error "mkdir fail"
4426 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4427 error "create remote dir succeed"
4429 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4430 rm -rf $DIR/$tdir || error "delete dir fail"
4432 umount_client $MOUNT || error "umount_client failed"
4433 stop_mdt 1 || error "MDT0 stop fail"
4434 stop_mdt 2 || error "MDT1 stop fail"
4435 stop_ost || error "OST0 stop fail"
4436 stop_ost2 || error "OST1 stop fail"
4439 run_test 71d "start OST0, MDT1, MDT0, OST1"
4442 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4443 if combined_mgs_mds; then
4444 skip "needs separate MGS/MDT" && return
4448 start_ost || error "OST0 start fail"
4449 start_mdt 2 || error "MDT1 start fail"
4450 start_ost2 || error "OST1 start fail"
4451 start_mdt 1 || error "MDT0 start fail"
4453 mount_client $MOUNT || error "mount client fails"
4455 mkdir $DIR/$tdir || error "mkdir fail"
4456 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4457 error "create remote dir succeed"
4459 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
4460 rm -rf $DIR/$tdir || error "delete dir fail"
4462 umount_client $MOUNT || error "umount_client failed"
4463 stop_mdt 1 || error "MDT0 stop fail"
4464 stop_mdt 2 || error "MDT1 stop fail"
4465 stop_ost || error "OST0 stop fail"
4466 stop_ost2 || error "OST1 stop fail"
4469 run_test 71e "start OST0, MDT1, OST1, MDT0"
4471 test_72() { #LU-2634
4472 local mdsdev=$(mdsdevname 1)
4473 local ostdev=$(ostdevname 1)
4474 local cmd="$E2FSCK -fnvd $mdsdev"
4477 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
4478 skip "ldiskfs only test" && return
4480 #tune MDT with "-O extents"
4482 for num in $(seq $MDSCOUNT); do
4483 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
4484 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4485 error "add mds $num failed"
4486 $TUNE2FS -O extents $(mdsdevname $num)
4489 add ost1 $(mkfs_opts ost1 $ostdev) --reformat $ostdev ||
4490 error "add $ostdev failed"
4491 start_mgsmds || error "start mds failed"
4492 start_ost || error "start ost failed"
4493 mount_client $MOUNT || error "mount client failed"
4495 #create some short symlinks
4496 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4497 createmany -o $DIR/$tdir/$tfile-%d $fn
4498 echo "create $fn short symlinks"
4499 for i in $(seq -w 1 $fn); do
4500 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
4505 umount_client $MOUNT || error "umount client failed"
4506 stop_mds || error "stop mds failed"
4507 stop_ost || error "stop ost failed"
4510 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
4512 run_test 72 "test fast symlink with extents flag enabled"
4514 test_73() { #LU-3006
4516 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4517 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
4518 error "1st tunefs failed"
4519 start_mgsmds || error "start mds failed"
4520 start_ost || error "start ost failed"
4521 mount_client $MOUNT || error "mount client failed"
4522 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
4523 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
4524 umount_client $MOUNT || error "umount client failed"
4528 run_test 73 "failnode to update from mountdata properly"
4530 test_75() { # LU-2374
4531 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
4532 skip "Need MDS version at least 2.4.1" && return
4535 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
4536 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
4537 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
4538 --reformat $(ostdevname 1) $(ostvdevname 1)"
4540 #check with default parameters
4541 add mds1 $opts_mds || error "add mds1 failed for default params"
4542 add ost1 $opts_ost || error "add ost1 failed for default params"
4544 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
4545 opts_mds=$(echo $opts_mds |
4546 sed -e "s/--index=$index/--index=$index --mdt/")
4547 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
4548 opts_ost=$(echo $opts_ost |
4549 sed -e "s/--index=$index/--index=$index --ost/")
4551 add mds1 $opts_mds || error "add mds1 failed for new params"
4552 add ost1 $opts_ost || error "add ost1 failed for new params"
4555 run_test 75 "The order of --index should be irrelevant"
4558 [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] ||
4559 { skip "Need MDS version at least 2.4.52" && return 0; }
4561 local MDMB_PARAM="osc.*.max_dirty_mb"
4562 echo "Change MGS params"
4563 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
4565 echo "max_dirty_mb: $MAX_DIRTY_MB"
4566 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB + MAX_DIRTY_MB))
4567 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
4568 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
4569 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
4570 head -1" $NEW_MAX_DIRTY_MB
4571 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
4572 echo "$MAX_DIRTY_MB"
4573 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
4574 error "error while apply max_dirty_mb"
4576 echo "Check the value is stored after remount"
4579 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
4580 head -1" $NEW_MAX_DIRTY_MB
4581 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
4582 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
4583 error "max_dirty_mb is not saved after remount"
4585 echo "Change OST params"
4586 CLIENT_PARAM="obdfilter.*.client_cache_count"
4587 local CLIENT_CACHE_COUNT
4588 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4590 echo "client_cache_count: $CLIENT_CACHE_COUNT"
4591 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
4592 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
4593 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
4594 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
4595 head -1" $NEW_CLIENT_CACHE_COUNT
4596 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4598 echo "$CLIENT_CACHE_COUNT"
4599 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
4600 error "error while apply client_cache_count"
4602 echo "Check the value is stored after remount"
4605 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
4606 head -1" $NEW_CLIENT_CACHE_COUNT
4607 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
4609 echo "$CLIENT_CACHE_COUNT"
4610 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
4611 error "client_cache_count is not saved after remount"
4614 run_test 76a "set permanent params set_param -P"
4616 test_76b() { # LU-4783
4617 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.57) ]] ||
4618 { skip "Need MGS version at least 2.5.57" && return 0; }
4621 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
4622 error "start params log failed"
4625 run_test 76b "verify params log setup correctly"
4627 test_77() { # LU-3445
4628 local server_version=$(lustre_version_code $SINGLEMDS)
4630 [[ $server_version -ge $(version_code 2.2.60) ]] &&
4631 [[ $server_version -le $(version_code 2.4.0) ]] &&
4632 skip "Need MDS version < 2.2.60 or > 2.4.0" && return
4634 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
4635 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
4636 skip_env "mixed loopback and real device not working" && return
4639 local fs2mdsdev=$(mdsdevname 1_2)
4640 local fs2ostdev=$(ostdevname 1_2)
4641 local fs2mdsvdev=$(mdsvdevname 1_2)
4642 local fs2ostvdev=$(ostvdevname 1_2)
4643 local fsname=test1234
4645 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
4647 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
4648 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
4649 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
4650 error "start fs2mds failed"
4652 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
4653 [[ $mgsnid = *,* ]] || mgsnid+=",$mgsnid"
4655 add fs2ost $(mkfs_opts ost1 $fs2ostdev) --mgsnode=$mgsnid \
4656 --failnode=$failnid --fsname=$fsname \
4657 --reformat $fs2ostdev $fs2ostvdev ||
4658 error "add fs2ost failed"
4659 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
4661 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
4662 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
4663 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
4666 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
4669 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ||
4670 $(facet_fstype ost1) != ldiskfs ]] &&
4671 skip "only applicable to ldiskfs-based MDTs and OSTs" && return
4673 # reformat the Lustre filesystem with a smaller size
4674 local saved_MDSSIZE=$MDSSIZE
4675 local saved_OSTSIZE=$OSTSIZE
4676 MDSSIZE=$((MDSSIZE - 20000))
4677 OSTSIZE=$((OSTSIZE - 20000))
4678 reformat || error "(1) reformat Lustre filesystem failed"
4679 MDSSIZE=$saved_MDSSIZE
4680 OSTSIZE=$saved_OSTSIZE
4682 # mount the Lustre filesystem
4683 setup_noconfig || error "(2) setup Lustre filesystem failed"
4686 log "create test files"
4690 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
4691 for i in $(seq $num_files); do
4692 file=$MOUNT/$tdir/$tfile-$i
4693 dd if=/dev/urandom of=$file count=1 bs=1M ||
4694 error "(4) create $file failed"
4697 # unmount the Lustre filesystem
4698 cleanup || error "(5) cleanup Lustre filesystem failed"
4700 # run e2fsck on the MDT and OST devices
4701 local mds_host=$(facet_active_host $SINGLEMDS)
4702 local ost_host=$(facet_active_host ost1)
4703 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
4704 local ost_dev=$(ostdevname 1)
4706 run_e2fsck $mds_host $mds_dev "-y"
4707 run_e2fsck $ost_host $ost_dev "-y"
4709 # get the original block count of the MDT and OST filesystems
4710 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
4711 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
4713 # expand the MDT and OST filesystems to the device size
4714 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
4715 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
4717 # run e2fsck on the MDT and OST devices again
4718 run_e2fsck $mds_host $mds_dev "-y"
4719 run_e2fsck $ost_host $ost_dev "-y"
4721 # mount the Lustre filesystem
4725 log "check files after expanding the MDT and OST filesystems"
4726 for i in $(seq $num_files); do
4727 file=$MOUNT/$tdir/$tfile-$i
4728 $CHECKSTAT -t file -s 1048576 $file ||
4729 error "(6) checkstat $file failed"
4733 log "create more files after expanding the MDT and OST filesystems"
4734 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
4735 file=$MOUNT/$tdir/$tfile-$i
4736 dd if=/dev/urandom of=$file count=1 bs=1M ||
4737 error "(7) create $file failed"
4740 # unmount the Lustre filesystem
4741 cleanup || error "(8) cleanup Lustre filesystem failed"
4743 # run e2fsck on the MDT and OST devices
4744 run_e2fsck $mds_host $mds_dev "-y"
4745 run_e2fsck $ost_host $ost_dev "-y"
4747 # get the maximum block count of the MDT and OST filesystems
4748 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
4749 local ost_max_blks=$(get_block_count ost1 $ost_dev)
4751 # get the minimum block count of the MDT and OST filesystems
4752 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
4753 grep minimum | sed -e 's/^.*filesystem: //g')
4754 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
4755 grep minimum | sed -e 's/^.*filesystem: //g')
4757 # shrink the MDT and OST filesystems to a smaller size
4761 if [[ $mds_max_blks -gt $mds_min_blks &&
4762 $mds_max_blks -gt $mds_orig_blks ]]; then
4763 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
4764 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
4765 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
4766 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
4767 error "shrink $SINGLEMDS to $new_blks failed"
4771 if [[ $ost_max_blks -gt $ost_min_blks &&
4772 $ost_max_blks -gt $ost_orig_blks ]]; then
4773 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
4774 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
4775 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
4776 run_resize2fs ost1 $ost_dev $new_blks ||
4777 error "shrink ost1 to $new_blks failed"
4781 # check whether the MDT or OST filesystem was shrunk or not
4783 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
4784 reformat || error "(10) reformat Lustre filesystem failed"
4788 # run e2fsck on the MDT and OST devices again
4789 run_e2fsck $mds_host $mds_dev "-y"
4790 run_e2fsck $ost_host $ost_dev "-y"
4792 # mount the Lustre filesystem again
4796 log "check files after shrinking the MDT and OST filesystems"
4797 for i in $(seq $((num_files + 10))); do
4798 file=$MOUNT/$tdir/$tfile-$i
4799 $CHECKSTAT -t file -s 1048576 $file ||
4800 error "(11) checkstat $file failed"
4803 # unmount and reformat the Lustre filesystem
4804 cleanup || error "(12) cleanup Lustre filesystem failed"
4805 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
4806 reformat || error "(14) reformat Lustre filesystem failed"
4808 run_test 78 "run resize2fs on MDT and OST filesystems"
4810 test_79() { # LU-4227
4811 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.59) ]] ||
4812 { skip "Need MDS version at least 2.5.59"; return 0; }
4814 local mdsdev1=$(mdsdevname 1)
4815 local mdsvdev1=$(mdsvdevname 1)
4816 local mdsdev2=$(mdsdevname 2)
4817 local mdsvdev2=$(mdsvdevname 2)
4818 local ostdev1=$(ostdevname 1)
4819 local ostvdev1=$(ostvdevname 1)
4820 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
4821 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
4822 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
4825 # remove --mgs/--mgsnode from mkfs.lustre options
4826 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
4828 mgsnode_opt=$(echo $opts_mds2 |
4829 awk '{ for ( i = 1; i < NF; i++ )
4830 if ( $i ~ "--mgsnode" ) { print $i; break } }')
4831 [ -n $mgsnode_opt ] &&
4832 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
4834 mgsnode_opt=$(echo $opts_ost1 |
4835 awk '{ for ( i = 1; i < NF; i++ )
4836 if ( $i ~ "--mgsnode" ) { print $i; break } }')
4837 [ -n $mgsnode_opt ] &&
4838 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
4840 # -MGS, format a mdt without --mgs option
4841 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
4842 error "Must specify --mgs when formatting mdt combined with mgs"
4844 # +MGS, format a mdt/ost without --mgsnode option
4845 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
4846 > /dev/null || error "start mds1 failed"
4847 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
4848 error "Must specify --mgsnode when formatting a mdt"
4849 add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
4850 error "Must specify --mgsnode when formatting an ost"
4854 run_test 79 "format MDT/OST without mgs option (should return errors)"
4857 start_mds || error "Failed to start MDT"
4858 start_ost || error "Failed to start OST1"
4859 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
4860 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
4861 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
4862 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
4863 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
4865 start_ost2 || error "Failed to start OST2"
4867 do_facet ost1 "$LCTL set_param fail_loc=0"
4870 run_test 80 "mgc import reconnect race"
4872 # Save the original values of $OSTCOUNT and $OSTINDEX$i.
4874 local new_ostcount=$1
4875 saved_ostcount=$OSTCOUNT
4876 OSTCOUNT=$new_ostcount
4880 for i in $(seq $OSTCOUNT); do
4882 eval saved_ostindex$i=${!index}
4887 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
4888 restore_ostindex() {
4893 for i in $(seq $OSTCOUNT); do
4894 index=saved_ostindex$i
4895 eval OSTINDEX$i=${!index}
4897 OSTCOUNT=$saved_ostcount
4902 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
4903 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
4904 # assigned index and ensures we can mount such a formatted file system
4905 test_81() { # LU-4665
4906 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
4907 { skip "Need MDS version at least 2.6.54" && return; }
4908 [[ $OSTCOUNT -ge 3 ]] || { skip_env "Need at least 3 OSTs" && return; }
4912 # Each time RANDOM is referenced, a random integer between 0 and 32767
4915 local saved_ostindex1=$OSTINDEX1
4916 for i in 65535 $((RANDOM + 65536)); do
4917 echo -e "\nFormat ost1 with --index=$i, should fail"
4919 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
4920 $(ostdevname 1) $(ostvdevname 1); then
4921 OSTINDEX1=$saved_ostindex1
4922 error "format ost1 with --index=$i should fail"
4925 OSTINDEX1=$saved_ostindex1
4929 # Format OSTs with random sparse indices.
4930 trap "restore_ostindex" EXIT
4931 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices"
4932 OST_INDEX_LIST=[0,$((RANDOM * 2 % 65533 + 1)),65534] formatall
4934 # Setup and check Lustre filesystem.
4935 start_mgsmds || error "start_mgsmds failed"
4936 for i in $(seq $OSTCOUNT); do
4937 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
4938 error "start ost$i failed"
4941 mount_client $MOUNT || error "mount client $MOUNT failed"
4942 check_mount || error "check client $MOUNT failed"
4945 local max_easize=$($LCTL get_param -n llite.*.max_easize)
4946 [[ $max_easize -eq 128 ]] ||
4947 error "max_easize is $max_easize, should be 128 bytes"
4951 run_test 81 "sparse OST indexing"
4953 # Wait OSTs to be active on both client and MDT side.
4955 local cmd="$LCTL get_param -n lov.$FSNAME-clilov-*.target_obd |
4956 awk 'BEGIN {c = 0} /ACTIVE/{c += 1} END {printf \\\"%d\\\", c}'"
4957 wait_update $HOSTNAME "eval $cmd" $OSTCOUNT ||
4958 error "wait_update OSTs up on client failed"
4960 cmd="$LCTL get_param -n lod.$FSNAME-MDT*-*.target_obd | sort -u |
4961 awk 'BEGIN {c = 0} /ACTIVE/{c += 1} END {printf \\\"%d\\\", c}'"
4962 wait_update_facet $SINGLEMDS "eval $cmd" $OSTCOUNT ||
4963 error "wait_update OSTs up on MDT failed"
4966 # Here we exercise the stripe placement functionality on a file system that
4967 # has formatted the OST with a random index. With the file system the following
4968 # functionality is tested:
4970 # 1. Creating a new file with a specific stripe layout.
4972 # 2. Modifiy a existing empty file with a specific stripe layout.
4974 # 3. Ensure we fail to set the stripe layout of a file that already has one.
4976 # 4. If ost-index is defined we need to ensure it is the first entry in the
4977 # ost index list returned by lfs getstripe.
4979 # 5. Lastly ensure this functionality fails with directories.
4980 test_82a() { # LU-4665
4981 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
4982 { skip "Need MDS version at least 2.6.54" && return; }
4983 [[ $OSTCOUNT -ge 3 ]] || { skip_env "Need at least 3 OSTs" && return; }
4989 # Format OSTs with random sparse indices.
4993 for i in $(seq $OSTCOUNT); do
4994 index=$((RANDOM * 2))
4995 ost_indices+=" $index"
4997 ost_indices=$(comma_list $ost_indices)
4999 trap "restore_ostindex" EXIT
5000 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5001 OST_INDEX_LIST=[$ost_indices] formatall
5003 # Setup Lustre filesystem.
5004 start_mgsmds || error "start_mgsmds failed"
5005 for i in $(seq $OSTCOUNT); do
5006 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5007 error "start ost$i failed"
5010 mount_client $MOUNT || error "mount client $MOUNT failed"
5013 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
5014 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5016 # 1. If the file does not exist, new file will be created
5017 # with specified OSTs.
5018 local file=$DIR/$tdir/$tfile-1
5019 local cmd="$SETSTRIPE -o $ost_indices $file"
5021 eval $cmd || error "$cmd failed"
5022 check_stripe_count $file $OSTCOUNT
5023 check_obdidx $file $ost_indices
5024 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5025 error "write $file failed"
5027 # 2. If the file already exists and is an empty file, the file
5028 # will be attached with specified layout.
5029 file=$DIR/$tdir/$tfile-2
5030 mcreate $file || error "mcreate $file failed"
5031 cmd="$SETSTRIPE -o $ost_indices $file"
5033 eval $cmd || error "$cmd failed"
5034 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5035 error "write $file failed"
5036 check_stripe_count $file $OSTCOUNT
5037 check_obdidx $file $ost_indices
5039 # 3. If the file already has a valid layout attached, the command
5040 # should fail with EBUSY.
5042 eval $cmd && error "stripe is already set on $file, $cmd should fail"
5044 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
5045 # be in the OST indices list.
5046 local start_ost_idx=${ost_indices##*,}
5047 file=$DIR/$tdir/$tfile-3
5048 cmd="$SETSTRIPE -o $ost_indices -i $start_ost_idx $file"
5050 eval $cmd || error "$cmd failed"
5051 check_stripe_count $file $OSTCOUNT
5052 check_obdidx $file $ost_indices
5053 check_start_ost_idx $file $start_ost_idx
5055 file=$DIR/$tdir/$tfile-4
5057 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
5058 cmd+=" -i $start_ost_idx $file"
5060 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
5062 # 5. Specifying OST indices for directory should fail with ENOSUPP.
5063 local dir=$DIR/$tdir/$tdir
5064 mkdir $dir || error "mkdir $dir failed"
5065 cmd="$SETSTRIPE -o $ost_indices $dir"
5067 eval $cmd && error "$cmd should fail, specifying OST indices" \
5068 "for directory is not supported"
5072 run_test 82a "specify OSTs for file (succeed) or directory (fail)"
5077 # Remove OSTs from a pool and destroy the pool.
5078 destroy_pool $ost_pool || true
5083 # Test 82b is run to ensure that if the user supplies a pool with a specific
5084 # stripe layout that it behaves proprerly. It should fail in the case that
5085 # the supplied OST index list points to OSTs not contained in the user
5087 test_82b() { # LU-4665
5088 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5089 { skip "Need MDS version at least 2.6.54" && return; }
5090 [[ $OSTCOUNT -ge 4 ]] || { skip_env "Need at least 4 OSTs" && return; }
5096 # Format OSTs with random sparse indices.
5100 for i in $(seq $OSTCOUNT); do
5101 index=$((RANDOM * 2))
5102 ost_indices+=" $index"
5104 ost_indices=$(comma_list $ost_indices)
5106 trap "restore_ostindex" EXIT
5107 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5108 OST_INDEX_LIST=[$ost_indices] formatall
5110 # Setup Lustre filesystem.
5111 start_mgsmds || error "start_mgsmds failed"
5112 for i in $(seq $OSTCOUNT); do
5113 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5114 error "start ost$i failed"
5117 mount_client $MOUNT || error "mount client $MOUNT failed"
5119 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
5120 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5122 # Create a new pool and add OSTs into it.
5123 local ost_pool=$FSNAME.$TESTNAME
5124 create_pool $ost_pool || error "create OST pool $ost_pool failed"
5127 trap "cleanup_82b" EXIT
5129 local ost_idx_in_list=${ost_indices##*,}
5130 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
5133 local ost_targets="$FSNAME-OST["
5134 for i in ${ost_idx_in_pool//,/ }; do
5135 ost_targets=$ost_targets$(printf "%04x," $i)
5137 ost_targets="${ost_targets%,}]"
5139 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
5140 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
5141 sort -u | tr '\n' ' ')
5143 local cmd="$LCTL pool_add $ost_pool $ost_targets"
5144 do_facet mgs $cmd || error "$cmd failed"
5145 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
5146 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
5147 error "wait_update $ost_pool failed"
5148 pool_list $ost_pool || error "list OST pool $ost_pool failed"
5150 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
5151 # then the OSTs must be the members of the pool.
5152 local file=$DIR/$tdir/$tfile
5153 cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
5155 eval $cmd && error "OST with index $ost_idx_in_list should be" \
5156 "in OST pool $ost_pool"
5158 # Only select OST $ost_idx_in_list from $ost_pool for file.
5159 ost_idx_in_list=${ost_idx_in_pool#*,}
5160 cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
5162 eval $cmd || error "$cmd failed"
5163 cmd="$GETSTRIPE $file"
5165 eval $cmd || error "$cmd failed"
5166 check_stripe_count $file 2
5167 check_obdidx $file $ost_idx_in_list
5168 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5169 error "write $file failed"
5173 run_test 82b "specify OSTs for file with --pool and --ost-list options"
5181 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
5182 skip "Only applicable to ldiskfs-based MDTs"
5187 ostmnt=$(facet_mntpt ost1)
5188 fstype=$(facet_fstype ost1)
5190 # Mount the OST as an ldiskfs filesystem.
5191 log "mount the OST $dev as a $fstype filesystem"
5192 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
5193 --reformat $dev $dev > /dev/null ||
5194 error "format ost1 error"
5196 if ! test -b $dev; then
5197 mnt_opts=$(csa_add "$OST_MOUNT_OPTS" -o loop)
5199 echo "mnt_opts $mnt_opts"
5200 do_facet ost1 mount -t $fstype $dev \
5202 # Run llverfs on the mounted ldiskfs filesystem.
5203 # It is needed to get ENOSPACE.
5204 log "run llverfs in partial mode on the OST $fstype $ostmnt"
5205 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
5206 "no" || error "run_llverfs error on $fstype"
5209 log "unmount the OST $dev"
5212 # Delete file IO_scrub. Later osd_scrub_setup will try to
5213 # create "IO_scrub" but will get ENOSPACE.
5215 echo "start ost1 service on `facet_active_host ost1`"
5216 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
5219 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
5220 echo "string err $err"
5221 [ -z "$err" ] || error $err
5224 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
5225 Busy inodes after unmount ..."
5227 recovery_time_min() {
5228 local CONNECTION_SWITCH_MIN=5
5229 local CONNECTION_SWITCH_INC=5
5230 local CONNECTION_SWITCH_MAX
5231 local RECONNECT_DELAY_MAX
5232 local INITIAL_CONNECT_TIMEOUT
5236 #CONNECTION_SWITCH_MAX=min(50, max($CONNECTION_SWITCH_MIN,$TIMEOUT)
5237 (($CONNECTION_SWITCH_MIN>$TIMEOUT)) && \
5238 max=$CONNECTION_SWITCH_MIN || max=$TIMEOUT
5239 (($max<50)) && CONNECTION_SWITCH_MAX=$max || CONNECTION_SWITCH_MAX=50
5241 #INITIAL_CONNECT_TIMEOUT = max(CONNECTION_SWITCH_MIN, \
5243 TO_20=$(($TIMEOUT/20))
5244 (($CONNECTION_SWITCH_MIN>$TO_20)) && \
5245 INITIAL_CONNECT_TIMEOUT=$CONNECTION_SWITCH_MIN || \
5246 INITIAL_CONNECT_TIMEOUT=$TO_20
5248 RECONNECT_DELAY_MAX=$(($CONNECTION_SWITCH_MAX+$CONNECTION_SWITCH_INC+ \
5249 $INITIAL_CONNECT_TIMEOUT))
5250 echo $((2*$RECONNECT_DELAY_MAX))
5254 local facet=$SINGLEMDS
5255 local num=$(echo $facet | tr -d "mds")
5256 local dev=$(mdsdevname $num)
5257 local time_min=$(recovery_time_min)
5258 local recovery_duration
5259 local completed_clients
5262 echo "start mds service on $(facet_active_host $facet)"
5263 start $facet ${dev} $MDS_MOUNT_OPTS \
5264 "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" $@ ||
5265 error "start MDS failed"
5270 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
5272 mount_client $MOUNT1 || error "mount failed"
5273 mount_client $MOUNT2 || error "mount failed"
5275 replay_barrier $SINGLEMDS
5276 createmany -o $DIR1/$tfile-%d 1000
5278 # We need to catch the end of recovery window to extend it.
5279 # Skip 5 requests and add delay to request handling.
5280 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
5281 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
5283 facet_failover $SINGLEMDS || error "failover: $?"
5286 echo "recovery status"
5287 do_facet $SINGLEMDS \
5288 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
5290 recovery_duration=$(do_facet $SINGLEMDS \
5291 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
5292 awk '/recovery_duration/ { print $2 }')
5293 (( $recovery_duration > $time_min + $wrap_up )) &&
5294 error "recovery_duration > recovery_time_hard + wrap up"
5295 completed_clients=$(do_facet $SINGLEMDS \
5296 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
5297 awk '/completed_clients/ { print $2 }')
5298 [ "$completed_clients" = "1/2" ] ||
5299 error "completed_clients != 1/2: $completed_clients"
5301 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
5302 umount_client $MOUNT1
5303 umount_client $MOUNT2
5309 run_test 84 "check recovery_hard_time"
5311 if ! combined_mgs_mds ; then
5317 # restore the values of MDSSIZE and OSTSIZE
5318 MDSSIZE=$STORED_MDSSIZE
5319 OSTSIZE=$STORED_OSTSIZE