7 # bug number for skipped test: LU-8972
8 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 101"
9 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
13 if [ -r /etc/SuSE-release ]
15 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
16 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
18 if [ $vers -eq 11 ] && [ $patchlev -eq 2 ]
26 if is_sles11; then # LU-2181
27 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 23a 34b"
30 if [ "$FAILURE_MODE" = "HARD" ]; then
31 CONFIG_EXCEPTIONS="24a " &&
32 echo "Except the tests: $CONFIG_EXCEPTIONS for " \
33 "FAILURE_MODE=$FAILURE_MODE, b=23573" &&
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
37 # bug number for skipped test:
38 # a tool to create lustre filesystem images
39 ALWAYS_EXCEPT="32newtarball $ALWAYS_EXCEPT"
42 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
44 PTLDEBUG=${PTLDEBUG:--1}
46 LUSTRE=${LUSTRE:-$(dirname $0)/..}
47 RLUSTRE=${RLUSTRE:-$LUSTRE}
48 export MULTIOP=${MULTIOP:-multiop}
50 . $LUSTRE/tests/test-framework.sh
52 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
54 # use small MDS + OST size to speed formatting time
55 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
56 # STORED_MDSSIZE is used in test_18
57 STORED_MDSSIZE=$MDSSIZE
58 STORED_OSTSIZE=$OSTSIZE
70 if ! combined_mgs_mds; then
71 # bug number for skipped test: 23954
72 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
75 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
76 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
77 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
80 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
81 # bug number for skipped test:
82 ALWAYS_EXCEPT="$ALWAYS_EXCEPT"
87 require_dsh_mds || exit 0
88 require_dsh_ost || exit 0
91 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69"
96 # The MGS must be started before the OSTs for a new fs, so start
97 # and stop to generate the startup logs.
100 wait_osc_import_state mds ost FULL
105 reformat_and_config() {
107 if ! combined_mgs_mds ; then
113 writeconf_or_reformat() {
114 # There are at most 2 OSTs for write_conf test
115 # who knows if/where $TUNEFS is installed?
116 # Better reformat if it fails...
117 writeconf_all $MDSCOUNT 2 ||
118 { echo "tunefs failed, reformatting instead" &&
119 reformat_and_config && return 0; }
129 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
135 local dev=$(mdsdevname $num)
138 echo "start mds service on `facet_active_host $facet`"
139 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
145 local dev=$(mdsdevname $num)
148 echo "stop mds service on `facet_active_host $facet`"
149 # These tests all use non-failover stop
150 stop $facet -f || return 97
156 for num in $(seq $MDSCOUNT); do
157 start_mdt $num $@ || return 94
162 if ! combined_mgs_mds ; then
170 for num in $(seq $MDSCOUNT); do
171 stop_mdt $num || return 97
176 echo "stop mgs service on `facet_active_host mgs`"
177 # These tests all use non-failover stop
178 stop mgs -f || return 97
182 echo "start ost1 service on `facet_active_host ost1`"
183 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
187 echo "stop ost1 service on `facet_active_host ost1`"
188 # These tests all use non-failover stop
189 stop ost1 -f || return 98
193 echo "start ost2 service on `facet_active_host ost2`"
194 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
198 echo "stop ost2 service on `facet_active_host ost2`"
199 # These tests all use non-failover stop
200 stop ost2 -f || return 93
205 echo "mount $FSNAME on ${MOUNTPATH}....."
206 zconf_mount $(hostname) $MOUNTPATH || return 96
210 local mountopt="remount,$1"
212 echo "remount '$1' lustre on ${MOUNTPATH}....."
213 zconf_mount $(hostname) $MOUNTPATH "$mountopt" || return 96
219 echo "umount lustre on $mountpath....."
220 zconf_umount $HOSTNAME $mountpath $@ || return 97
223 manual_umount_client(){
226 echo "manual umount lustre on ${MOUNT}...."
227 do_facet client "umount ${FORCE} $MOUNT"
233 start_mds || error "MDT start failed"
234 start_ost || error "Unable to start OST1"
235 mount_client $MOUNT || error "client start failed"
236 client_up || error "client_up failed"
245 unload_modules_conf () {
246 if combined_mgs_mds || ! local_mode; then
247 unload_modules || return 1
252 stop_ost || return 202
253 stop_mds || return 201
254 unload_modules_conf || return 203
258 umount_client $MOUNT || return 200
259 cleanup_nocli || return $?
264 echo "umount $MOUNT2 ..."
265 umount $MOUNT2 || true
266 echo "stopping fs2mds ..."
267 stop fs2mds -f || true
268 echo "stopping fs2ost ..."
269 stop fs2ost -f || true
273 do_facet client "cp /etc/passwd $DIR/a" || return 71
274 do_facet client "rm $DIR/a" || return 72
275 # make sure lustre is actually mounted (touch will block,
276 # but grep won't, so do it after)
277 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
278 echo "setup single mount lustre success"
282 do_facet client "touch $DIR/a" || return 71
283 do_facet client "rm $DIR/a" || return 72
284 do_facet client "touch $DIR2/a" || return 73
285 do_facet client "rm $DIR2/a" || return 74
286 echo "setup double mount lustre success"
291 if [ "$ONLY" == "setup" ]; then
296 if [ "$ONLY" == "cleanup" ]; then
303 #create single point mountpoint
309 check_mount || error "check_mount failed"
310 cleanup || error "cleanup failed with $?"
312 run_test 0 "single mount setup"
315 start_mds || error "MDS start failed"
316 start_ost || error "unable to start OST"
317 echo "start ost second time..."
318 start_ost && error "2nd OST start should fail"
319 mount_client $MOUNT || error "client start failed"
320 check_mount || error "check_mount failed"
321 cleanup || error "cleanup failed with $?"
323 run_test 1 "start up ost twice (should return errors)"
326 start_mds || error "MDT start failed"
327 echo "start mds second time.."
328 start_mds && error "2nd MDT start should fail"
329 start_ost || error "OST start failed"
330 mount_client $MOUNT || error "mount_client failed to start client"
331 check_mount || error "check_mount failed"
332 cleanup || error "cleanup failed with $?"
334 run_test 2 "start up mds twice (should return err)"
338 #mount.lustre returns an error if already in mtab
339 mount_client $MOUNT && error "2nd client mount should fail"
340 check_mount || error "check_mount failed"
341 cleanup || error "cleanup failed with $?"
343 run_test 3 "mount client twice (should return err)"
347 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
348 stop_ost || error "Unable to stop OST1"
349 umount_client $MOUNT -f || error “unmount $MOUNT failed”
352 # ok for ost to fail shutdown
353 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
354 error "cleanup failed with $?"
357 run_test 4 "force cleanup ost, then cleanup"
359 test_5a() { # was test_5
361 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
362 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
364 stop_mds || error "Unable to stop MDS"
366 # cleanup may return an error from the failed
367 # disconnects; for now I'll consider this successful
368 # if all the modules have unloaded.
372 echo "killing umount"
373 kill -TERM $UMOUNT_PID
374 echo "waiting for umount to finish"
376 if grep " $MOUNT " /proc/mounts; then
377 echo "test 5: /proc/mounts after failed umount"
381 echo "killing umount"
382 kill -TERM $UMOUNT_PID
383 echo "waiting for umount to finish"
385 grep " $MOUNT " /proc/mounts &&
386 error "/proc/mounts after second umount"
389 # manual_mount_client may fail due to umount succeeding above
391 # stop_mds is a no-op here, and should not fail
392 cleanup_nocli || error "cleanup_nocli failed with $?"
393 # df may have lingering entry
395 # mtab may have lingering entry
399 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
401 grep -q $MOUNT" " /etc/mtab || break
402 echo "Waiting /etc/mtab updated ... "
403 WAIT=$(( WAIT + sleep))
405 [ "$WAIT" -eq "$MAX_WAIT" ] &&
406 error "/etc/mtab is not updated in $WAIT secs"
407 echo "/etc/mtab updated in $WAIT secs"
409 run_test 5a "force cleanup mds, then cleanup"
417 grep " $MOUNT " /etc/mtab &&
418 error false "unexpected entry in mtab before mount" && return 10
420 start_ost || error "OST start failed"
421 if ! combined_mgs_mds ; then
422 trap cleanup_5b EXIT ERR
423 start_mds || error "MDS start failed"
427 mount_client $MOUNT && error "mount_client $MOUNT should fail"
428 grep " $MOUNT " /etc/mtab &&
429 error "$MOUNT entry in mtab after failed mount"
431 # stop_mds is a no-op here, and should not fail
432 cleanup_nocli || error "cleanup_nocli failed with $?"
433 if ! combined_mgs_mds ; then
437 run_test 5b "Try to start a client with no MGS (should return errs)"
440 grep " $MOUNT " /etc/mtab &&
441 error false "unexpected entry in mtab before mount" && return 10
443 start_mds || error "MDS start failed"
444 start_ost || error "OST start failed"
445 local oldfs="${FSNAME}"
446 FSNAME="wrong.${FSNAME}"
447 mount_client $MOUNT || :
449 grep " $MOUNT " /etc/mtab &&
450 error "$MOUNT entry in mtab after failed mount"
452 cleanup_nocli || error "cleanup_nocli failed with $?"
454 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
457 grep " $MOUNT " /etc/mtab &&
458 error false "unexpected entry in mtab before mount" && return 10
460 start_ost || error "OST start failed"
461 start_mds || error "MDS start failed"
462 stop_ost || error "Unable to stop OST1"
463 mount_client $MOUNT || error "mount_client $MOUNT failed"
464 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
465 cleanup_nocli || error "cleanup_nocli failed with $?"
466 grep " $MOUNT " /etc/mtab &&
467 error "$MOUNT entry in mtab after unmount"
470 run_test 5d "mount with ost down"
473 grep " $MOUNT " /etc/mtab &&
474 error false "unexpected entry in mtab before mount" && return 10
476 start_mds || error "MDS start failed"
477 start_ost || error "OST start failed"
479 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
480 do_facet client "$LCTL set_param fail_loc=0x80000506"
481 mount_client $MOUNT || echo "mount failed (not fatal)"
482 cleanup || error "cleanup failed with $?"
483 grep " $MOUNT " /etc/mtab &&
484 error "$MOUNT entry in mtab after unmount"
487 run_test 5e "delayed connect, don't crash (bug 10268)"
490 if combined_mgs_mds ; then
491 skip "combined mgs and mds"
495 grep " $MOUNT " /etc/mtab &&
496 error false "unexpected entry in mtab before mount" && return 10
499 start_ost || error "OST start failed"
500 mount_client $MOUNT &
502 echo client_mount pid is $pid
506 if ! ps -f -p $pid >/dev/null; then
509 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
510 error "mount returns $rc, expected to hang"
512 cleanup || error "cleanup failed with $?"
517 start_mds || error "start MDS failed"
519 # mount should succeed after start mds
521 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
522 cleanup || error "final call to cleanup failed with rc $?"
524 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
529 mount_client $MOUNT || error "mount_client $MOUNT failed"
530 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
531 cleanup || error "cleanup failed with rc $?"
533 run_test 6 "manual umount, then mount again"
538 cleanup_nocli || error "cleanup_nocli failed with $?"
540 run_test 7 "manual umount, then cleanup"
544 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
545 check_mount2 || error "check_mount2 failed"
546 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
547 cleanup || error "cleanup failed with rc $?"
549 run_test 8 "double mount setup"
552 start_ost || error "OST start failed"
554 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
555 error "do_facet ost1 set_param inode trace failed."
556 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
557 error "do_facet ost1 set_param debug mds ost failed."
559 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
560 if [ "$CHECK_PTLDEBUG" ] && { \
561 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
562 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
563 echo "lnet.debug success"
565 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
567 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
568 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
569 echo "lnet.subsystem_debug success"
571 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
573 stop_ost || error "Unable to stop OST1"
575 run_test 9 "test ptldebug and subsystem for mkfs"
583 do_facet $facet "test -b $dev" || rc=1
584 if [[ "$size" ]]; then
585 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k \
586 count=1 skip=$size 2>&1" |
587 awk '($3 == "in") { print $1 }')
588 [[ $in = "1+0" ]] || rc=1
594 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
595 # But with new MDS stack we don't care about the mode of local objects
596 # anymore, so this test is removed. See bug 22944 for more details.
600 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
601 skip "Only applicable to ldiskfs-based MDTs"
606 check_mount || error "check_mount failed"
607 cleanup || error "cleanup failed with rc $?"
609 echo "Remove mds config log"
610 if ! combined_mgs_mds ; then
614 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
615 $(mgsdevname) || return \$?" ||
616 error "do_facet mgs failed with $?"
618 if ! combined_mgs_mds ; then
622 start_ost || error "OST start failed"
623 start_mds && error "MDS start succeeded, but should fail"
626 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
629 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
630 skip "Only applicable to ldiskfs-based MDTs"
634 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
639 # check if current MDSSIZE is large enough
640 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
641 log "use MDSSIZE=$MDSSIZE"
643 # check if the global config has a large enough MDSSIZE
644 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
645 [ $STORED_MDSSIZE -ge $MIN ] &&
646 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
647 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
649 # check if the block device is large enough
650 is_blkdev $SINGLEMDS $MDSDEV $MIN
651 local large_enough=$?
652 if [ -n "$OK" ]; then
653 [ $large_enough -ne 0 ] && OK=""
655 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
656 log "use device $MDSDEV with MIN=$MIN"
659 # check if a loopback device has enough space for fs metadata (5%)
661 if [ -z "$OK" ]; then
662 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
663 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
664 awk '($1 != "Filesystem") { print $4 }')
665 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
666 OK=1 && myMDSSIZE=$MIN &&
667 log "use file $MDSDEV with MIN=$MIN"
670 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
672 echo "mount mds with large journal..."
674 local OLD_MDSSIZE=$MDSSIZE
678 echo "mount lustre system..."
680 check_mount || error "check_mount failed"
682 echo "check journal size..."
683 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
684 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
685 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
687 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
690 cleanup || error "cleanup failed with rc $?"
695 run_test 18 "check mkfs creates large journals"
698 start_mds || error "MDS start failed"
699 stop_mds || error "Unable to stop MDS"
701 run_test 19a "start/stop MDS without OSTs"
704 start_ost || error "Unable to start OST1"
705 stop_ost || error "Unable to stop OST1"
707 run_test 19b "start/stop OSTs without MDS"
710 # first format the ost/mdt
711 start_mds || error "MDS start failed"
712 start_ost || error "Unable to start OST1"
713 mount_client $MOUNT || error "mount_client $MOUNT failed"
714 check_mount || error "check_mount failed"
715 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
716 remount_client ro $MOUNT || error "remount_client with ro failed"
717 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
718 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
719 remount_client rw $MOUNT || error "remount_client with rw failed"
720 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
721 MCNT=$(grep -c $MOUNT /etc/mtab)
722 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
724 stop_mds || error "Unable to stop MDS"
725 stop_ost || error "Unable to stop OST1"
727 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
730 start_mds || error "MDS start failed"
731 start_ost || error "unable to start OST1"
732 wait_osc_import_state mds ost FULL
733 stop_ost || error "unable to stop OST1"
734 stop_mds || error "unable to stop MDS"
736 run_test 21a "start mds before ost, stop ost first"
739 start_ost || error "unable to start OST1"
740 start_mds || error "MDS start failed"
741 wait_osc_import_state mds ost FULL
742 stop_mds || error "unable to stop MDS"
743 stop_ost || error "unable to stop OST1"
745 run_test 21b "start ost before mds, stop mds first"
748 start_ost || error "Unable to start OST1"
749 start_mds || error "MDS start failed"
750 start_ost2 || error "Unable to start OST2"
751 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"
755 #writeconf to remove all ost2 traces for subsequent tests
756 writeconf_or_reformat
758 run_test 21c "start mds between two osts, stop mds last"
761 if combined_mgs_mds ; then
762 skip "need separate mgs device" && return 0
768 start_mgs || error "unable to start MGS"
769 start_ost || error "unable to start OST1"
770 start_ost2 || error "unable to start OST2"
771 start_mds || error "MDS start failed"
772 wait_osc_import_state mds ost2 FULL
774 stop_ost || error "Unable to stop OST1"
775 stop_ost2 || error "Unable to stop OST2"
776 stop_mds || error "Unable to stop MDS"
778 #writeconf to remove all ost2 traces for subsequent tests
779 writeconf_or_reformat
780 start_mgs || error "unable to start MGS"
782 run_test 21d "start mgs then ost and then mds"
785 MGSNID="$saved_mgsnid"
787 echo "stopping fs2mgs ..."
788 stop $fs2mgs -f || true
791 test_21e() { # LU-5863
792 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
793 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
794 skip_env "mixed loopback and real device not working" && return
797 local fs2mdsdev=$(mdsdevname 1_2)
798 local fs2ostdev=$(ostdevname 1_2)
799 local fs3ostdev=$(ostdevname 2_2)
801 local fs2mdsvdev=$(mdsvdevname 1_2)
802 local fs2ostvdev=$(ostvdevname 1_2)
803 local fs3ostvdev=$(ostvdevname 2_2)
805 # temporarily use fs3ost as fs2mgs
807 local fs2mgsdev=$fs3ostdev
808 local fs2mgsvdev=$fs3ostvdev
810 local fsname=test1234
812 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
813 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
814 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
815 error "start fs2mgs failed"
817 local saved_mgsnid="$MGSNID"
818 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
820 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
821 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
822 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
823 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
825 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
826 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
828 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
829 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
830 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
834 run_test 21e "separate MGS and MDS"
837 start_mds || error "MDS start failed"
839 echo "Client mount with ost in logs, but none running"
840 start_ost || error "unable to start OST1"
841 # wait until mds connected to ost and open client connection
842 wait_osc_import_state mds ost FULL
843 stop_ost || error "unable to stop OST1"
844 mount_client $MOUNT || error "mount_client $MOUNT failed"
845 # check_mount will block trying to contact ost
846 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
847 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
848 umount_client $MOUNT -f
851 echo "Client mount with a running ost"
852 start_ost || error "unable to start OST1"
854 # if gss enabled, wait full time to let connection from
855 # mds to ost be established, due to the mismatch between
856 # initial connect timeout and gss context negotiation timeout.
857 # This perhaps could be remove after AT landed.
858 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
859 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
861 mount_client $MOUNT || error "mount_client $MOUNT failed"
862 wait_osc_import_state mds ost FULL
863 wait_osc_import_state client ost FULL
864 check_mount || error "check_mount failed"
867 cleanup || error "cleanup failed with rc $?"
869 run_test 22 "start a client before osts (should return errs)"
871 test_23a() { # was test_23
874 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
875 # force down client so that recovering mds waits for reconnect
876 local running=$(grep -c $MOUNT /proc/mounts) || true
877 if [ $running -ne 0 ]; then
878 echo "Stopping client $MOUNT (opts: -f)"
882 # enter recovery on failed mds
883 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
884 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
885 # try to start a new client
886 mount_client $MOUNT &
888 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
889 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
890 grep -v grep | awk '{print $2}')
891 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
893 ps --ppid $MOUNT_LUSTRE_PID
894 echo "waiting for mount to finish"
896 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
897 # SIGTERM works but it does not spread to offspring processses
898 kill -s TERM $MOUNT_PID
899 kill -s TERM $MOUNT_LUSTRE_PID
900 # we can not wait $MOUNT_PID because it is not a child of this shell
906 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
908 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
909 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
912 [ -z "$PID1" -a -z "$PID2" ] && break
913 echo "waiting for mount to finish ... "
914 WAIT=$(( WAIT + sleep))
916 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
917 error "MOUNT_PID $MOUNT_PID and "\
918 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
921 stop_mds || error "stopping MDSes failed"
922 stop_ost || error "stopping OSSes failed"
924 run_test 23a "interrupt client during recovery mount delay"
929 test_23b() { # was test_23
930 start_mds || error "MDS start failed"
931 start_ost || error "Unable to start OST1"
932 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
933 $LCTL set_param fail_loc=0x80000313
935 cleanup || error "cleanup failed with rc $?"
937 run_test 23b "Simulate -EINTR during mount"
940 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
942 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
943 is_blkdev $SINGLEMDS $MDSDEV &&
944 skip_env "mixed loopback and real device not working" && return
947 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
949 local fs2mdsdev=$(mdsdevname 1_2)
950 local fs2ostdev=$(ostdevname 1_2)
951 local fs2mdsvdev=$(mdsvdevname 1_2)
952 local fs2ostvdev=$(ostvdevname 1_2)
954 # test 8-char fsname as well
955 local FSNAME2=test1234
957 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
958 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
960 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
961 --reformat $fs2ostdev $fs2ostvdev || exit 10
964 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
965 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
966 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
967 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
969 check_mount || error "check_mount failed"
970 # files written on 1 should not show up on 2
971 cp /etc/passwd $DIR/$tfile
973 [ -e $MOUNT2/$tfile ] && error "File bleed"
976 cp /etc/passwd $MOUNT2/$tfile ||
977 error "cp /etc/passwd $MOUNT2/$tfile failed"
978 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
979 # 2 is actually mounted
980 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
982 facet_failover fs2mds
983 facet_failover fs2ost
986 # the MDS must remain up until last MDT
988 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
989 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
990 [ -z "$MDS" ] && error "No MDT"
992 cleanup_nocli || error "cleanup_nocli failed with rc $?"
994 run_test 24a "Multiple MDTs on a single node"
997 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
999 if [ -z "$fs2mds_DEV" ]; then
1000 local dev=${SINGLEMDS}_dev
1001 local MDSDEV=${!dev}
1002 is_blkdev $SINGLEMDS $MDSDEV &&
1003 skip_env "mixed loopback and real device not working" && return
1006 local fs2mdsdev=$(mdsdevname 1_2)
1007 local fs2mdsvdev=$(mdsvdevname 1_2)
1009 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1010 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1012 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS &&
1013 error "start MDS should fail"
1015 cleanup || error "cleanup failed with rc $?"
1017 run_test 24b "Multiple MGSs on a single node (should return err)"
1021 check_mount || error "check_mount failed"
1022 local MODULES=$($LCTL modules | awk '{ print $2 }')
1023 rmmod $MODULES 2>/dev/null || true
1024 cleanup || error "cleanup failed with $?"
1026 run_test 25 "Verify modules are referenced"
1030 # we need modules before mount for sysctl, so make sure...
1031 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1032 #define OBD_FAIL_MDS_FS_SETUP 0x135
1033 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1034 start_mds && error "MDS started but should not have started"
1035 $LCTL get_param -n devices
1036 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1037 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1038 # start mds to drop writeconf setting
1039 start_mds || error "Unable to start MDS"
1040 stop_mds || error "Unable to stop MDS"
1041 unload_modules_conf || error "unload_modules_conf failed with $?"
1043 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1046 start_ost || error "Unable to start OST1"
1047 start_mds || error "Unable to start MDS"
1048 echo "Requeue thread should have started: "
1049 ps -e | grep ll_cfg_requeue
1050 set_conf_param_and_check ost1 \
1051 "$LCTL get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1052 "$FSNAME-OST0000.ost.client_cache_seconds" ||
1053 error "set_conf_param_and_check ost1 failed"
1054 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1056 run_test 27a "Reacquire MGS lock if OST started first"
1061 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1062 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1064 facet_failover $SINGLEMDS
1065 set_conf_param_and_check $SINGLEMDS \
1066 "$LCTL get_param -n mdt.$device.identity_acquire_expire" \
1067 "$device.mdt.identity_acquire_expire" ||
1068 error "set_conf_param_and_check $SINGLEMDS failed"
1069 set_conf_param_and_check client \
1070 "$LCTL get_param -n mdc.$device-mdc-*.max_rpcs_in_flight"\
1071 "$device.mdc.max_rpcs_in_flight" ||
1072 error "set_conf_param_and_check client failed"
1074 cleanup || error "cleanup failed with $?"
1076 run_test 27b "Reacquire MGS lock after failover"
1080 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1081 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1083 FINAL=$(($ORIG + 1))
1084 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1085 error "first set_conf_param_and_check client failed"
1086 FINAL=$(($FINAL + 1))
1087 set_conf_param_and_check client "$TEST" "$PARAM" $FINAL ||
1088 error "second set_conf_param_and_check client failed"
1089 umount_client $MOUNT || error "umount_client $MOUNT failed"
1090 mount_client $MOUNT || error "mount_client $MOUNT failed"
1092 if [ $RESULT -ne $FINAL ]; then
1093 error "New config not seen: wanted $FINAL got $RESULT"
1095 echo "New config success: got $RESULT"
1097 set_conf_param_and_check client "$TEST" "$PARAM" $ORIG ||
1098 error "third set_conf_param_and_check client failed"
1099 cleanup || error "cleanup failed with rc $?"
1101 run_test 28 "permanent parameter setting"
1103 test_28a() { # LU-4221
1104 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1105 { skip "Need OST version at least 2.5.52" && return 0; }
1106 [ "$(facet_fstype ost1)" = "zfs" ] &&
1107 skip "LU-4221: no such proc params for ZFS OSTs" && return
1114 local device="$FSNAME-OST0000"
1118 # In this test we will set three kinds of proc parameters with
1120 # 1. the ones moved from the OFD to the OSD, and only their
1121 # symlinks kept in obdfilter
1122 # 2. non-symlink ones in the OFD
1123 # 3. non-symlink ones in the OSD
1126 # prepare a symlink parameter in the OFD
1127 name="writethrough_cache_enable"
1128 param="$device.ost.$name"
1129 cmd="$LCTL get_param -n obdfilter.$device.$name"
1131 # conf_param the symlink parameter in the OFD
1132 old=$(do_facet ost1 $cmd)
1133 new=$(((old + 1) % 2))
1134 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1135 error "lctl conf_param $device.ost.$param=$new failed"
1137 # conf_param the target parameter in the OSD
1138 param="$device.osd.$name"
1139 cmd="$LCTL get_param -n osd-*.$device.$name"
1140 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1141 error "lctl conf_param $device.osd.$param=$old failed"
1144 # prepare a non-symlink parameter in the OFD
1145 name="client_cache_seconds"
1146 param="$device.ost.$name"
1147 cmd="$LCTL get_param -n obdfilter.$device.$name"
1149 # conf_param the parameter in the OFD
1150 old=$(do_facet ost1 $cmd)
1152 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1153 error "lctl conf_param $device.ost.$param=$new failed"
1154 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1155 error "lctl conf_param $device.ost.$param=$old failed"
1158 # prepare a non-symlink parameter in the OSD
1160 param="$device.osd.$name"
1161 cmd="$LCTL get_param -n osd-*.$device.$name"
1163 # conf_param the parameter in the OSD
1164 old=$(do_facet ost1 $cmd)
1165 new=$(((old + 1) % 2))
1166 set_conf_param_and_check ost1 "$cmd" "$param" $new ||
1167 error "lctl conf_param $device.osd.$param=$new failed"
1168 set_conf_param_and_check ost1 "$cmd" "$param" $old ||
1169 error "lctl conf_param $device.osd.$param=$old failed"
1171 cleanup || error "cleanup failed with $?"
1173 run_test 28a "set symlink parameters permanently with conf_param"
1176 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
1177 setup > /dev/null 2>&1
1178 start_ost2 || error "Unable to start OST2"
1181 local PARAM="$FSNAME-OST0001.osc.active"
1182 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1183 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1185 ACTV=$($LCTL get_param -n $PROC_ACT)
1187 set_conf_param_and_check client \
1188 "$LCTL get_param -n $PROC_ACT" "$PARAM" $DEAC ||
1189 error "set_conf_param_and_check client failed"
1190 # also check ost_server_uuid status
1191 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1192 if [ -z "$RESULT" ]; then
1193 error "Client not deactivated: $($LCTL get_param \
1196 echo "Live client success: got $RESULT"
1200 for num in $(seq $MDSCOUNT); do
1201 local mdtosc=$(get_mdtosc_proc_path mds${num} $FSNAME-OST0001)
1202 local MPROC="osc.$mdtosc.active"
1207 RESULT=$(do_facet mds${num} "$LCTL get_param -n $MPROC")
1208 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1209 if [ $RESULT -eq $DEAC ]; then
1210 echo -n "MDT deactivated also after"
1211 echo "$WAIT sec (got $RESULT)"
1215 if [ $WAIT -eq $MAX ]; then
1216 error "MDT active: wanted $DEAC got $RESULT"
1218 echo "Waiting $(($MAX - $WAIT))secs for MDT deactivated"
1221 # test new client starts deactivated
1222 umount_client $MOUNT || error "umount_client $MOUNT failed"
1223 mount_client $MOUNT || error "mount_client $MOUNT failed"
1224 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1225 if [ -z "$RESULT" ]; then
1226 error "New client start active: $(lctl get_param -n $PROC_UUID)"
1228 echo "New client success: got $RESULT"
1231 # make sure it reactivates
1232 set_conf_param_and_check client \
1233 "$LCTL get_param -n $PROC_ACT" "$PARAM" $ACTV ||
1234 error "lctl get_param $PROC_ACT $PARAM $ACTV failed"
1236 umount_client $MOUNT
1237 stop_ost2 || error "Unable to stop OST2"
1238 cleanup_nocli || error "cleanup_nocli failed with $?"
1239 #writeconf to remove all ost2 traces for subsequent tests
1240 writeconf_or_reformat
1242 run_test 29 "permanently remove an OST"
1247 echo Big config llog
1248 TEST="$LCTL get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1250 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1251 for i in ${LIST[@]}; do
1252 set_conf_param_and_check client "$TEST" \
1253 "$FSNAME.llite.max_read_ahead_whole_mb" $i ||
1254 error "Set $FSNAME.llite.max_read_ahead_whole_mb failed"
1256 # make sure client restart still works
1257 umount_client $MOUNT
1258 mount_client $MOUNT || error "mount_client $MOUNT failed"
1259 [ "$($TEST)" -ne "$i" ] &&
1260 error "Param didn't stick across restart $($TEST) != $i"
1263 echo Erase parameter setting
1264 do_facet mgs "$LCTL conf_param \
1265 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1266 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1267 umount_client $MOUNT
1268 mount_client $MOUNT || error "mount_client $MOUNT failed"
1270 echo "deleted (default) value=$FINAL, orig=$ORIG"
1271 # assumes this parameter started at the default value
1272 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1274 cleanup || error "cleanup failed with rc $?"
1276 run_test 30a "Big config llog and conf_param deletion"
1281 local orignids=$($LCTL get_param -n \
1282 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1284 local orignidcount=$(echo "$orignids" | wc -w)
1286 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1287 # numerical part of it. Hopefully that's not already a failover address
1289 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1291 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1292 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1293 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1294 echo "Using fake nid $NEW"
1296 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1297 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1298 set_conf_param_and_check client "$TEST" \
1299 "$FSNAME-OST0000.failover.node" $NEW ||
1300 error "didn't add failover nid $NEW"
1301 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1304 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1305 echo "should have $((orignidcount + 1)) entries \
1306 in failover nids string, have $NIDCOUNT"
1307 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1308 error "Failover nid not added"
1310 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" ||
1311 error "conf_param delete failed"
1312 umount_client $MOUNT
1313 mount_client $MOUNT || error "mount_client $MOUNT failed"
1315 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1318 NIDCOUNT=$(echo "$NIDS" | wc -w)
1319 echo "only $orignidcount final entries should remain \
1320 in failover nids string, have $NIDCOUNT"
1321 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1323 cleanup || error "cleanup failed with rc $?"
1325 run_test 30b "Remove failover nids"
1327 test_31() { # bug 10734
1328 # ipaddr must not exist
1329 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1330 cleanup || error "cleanup failed with rc $?"
1332 run_test 31 "Connect to non-existent node (shouldn't crash)"
1336 T32_BLIMIT=40960 # Kbytes
1340 # This is not really a test but a tool to create new disk
1341 # image tarballs for the upgrade tests.
1343 # Disk image tarballs should be created on single-node
1344 # clusters by running this test with default configurations
1345 # plus a few mandatory environment settings that are verified
1346 # at the beginning of the test.
1348 test_32newtarball() {
1352 local tmp=$TMP/t32_image_create
1353 local server_version=$(lustre_version_code $SINGLEMDS)
1358 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1359 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1360 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1361 "MDSDEV1=<nonexistent_file>" \
1362 "MDSDEV2=<nonexistent_file>" \
1363 "(or MDSDEV, in the case of b1_8)" \
1364 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1368 echo "Found stale $tmp"
1372 mkdir $tmp/src || return 1
1373 tar cf - -C $src . | tar xf - -C $tmp/src
1374 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1375 count=$(($T32_BLIMIT / 1024 / 4))
1376 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1378 # format ost with comma-separated NIDs to verify LU-4460
1379 local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
1380 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1384 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1385 $LFS quotacheck -ug /mnt/$FSNAME
1386 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1389 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1391 if [[ $MDSCOUNT -ge 2 ]]; then
1392 remote_dir=/mnt/$FSNAME/remote_dir
1393 $LFS mkdir -i 1 $remote_dir
1394 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1396 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1397 striped_dir=/mnt/$FSNAME/striped_dir_old
1398 $LFS mkdir -i 1 -c 2 $striped_dir
1399 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1405 mkdir $tmp/img || return 1
1409 pushd_dir=/mnt/$FSNAME
1410 if [[ $MDSCOUNT -ge 2 ]]; then
1411 pushd_dir=$remote_dir
1412 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1414 ls -Rni --time-style=+%s >$tmp/img/list2
1420 ls -Rni --time-style=+%s >$tmp/img/list
1421 find ! -name .lustre -type f -exec sha1sum {} \; |
1422 sort -k 2 >$tmp/img/sha1sums
1424 $LCTL get_param -n version | head -n 1 |
1425 sed -e 's/^lustre: *//' >$tmp/img/commit
1427 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1428 $LFS quotaon -ug /mnt/$FSNAME
1429 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1430 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1431 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1432 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1433 | tr -d "*" > $tmp/img/bspace
1434 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1435 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1436 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1437 | tr -d "*" > $tmp/img/ispace
1438 echo $T32_BLIMIT > $tmp/img/blimit
1439 echo $T32_ILIMIT > $tmp/img/ilimit
1444 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1447 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1448 echo "Data verification failed"
1451 uname -r >$tmp/img/kernel
1452 uname -m >$tmp/img/arch
1454 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1455 for num in $(seq 2 $MDSCOUNT); do
1456 local devname=$(mdsdevname $num)
1458 [[ $(facet_fstype $facet) != zfs ]] ||
1459 devname=$(mdsvdevname $num)
1460 mv $devname $tmp/img
1462 mv $OSTDEV1 $tmp/img
1464 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1465 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1468 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1473 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1476 # The list of applicable tarballs is returned via the caller's
1477 # variable "tarballs".
1480 local node=$(facet_active_host $SINGLEMDS)
1481 local r="do_node $node"
1483 if [ "$CLIENTONLY" ]; then
1484 skip "Client-only testing"
1488 if ! $r which $TUNEFS; then
1489 skip_env "tunefs.lustre required on $node"
1493 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1495 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 -name \'disk*-$IMGTYPE.tar.bz2\')
1497 if [ -z "$tarballs" ]; then
1498 skip "No applicable tarballs found"
1503 t32_test_cleanup() {
1505 local facet=$SINGLEMDS
1506 local fstype=$(facet_fstype $facet)
1509 if $shall_cleanup_lustre; then
1510 umount $tmp/mnt/lustre || rc=$?
1512 if $shall_cleanup_mdt; then
1513 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1515 if $shall_cleanup_mdt1; then
1516 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1518 if $shall_cleanup_ost; then
1519 $r $UMOUNT $tmp/mnt/ost || rc=$?
1524 if [[ $fstype == zfs ]]; then
1526 local poolname_list="t32fs-mdt1 t32fs-ost1"
1528 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1530 for poolname in $poolname_list; do
1531 destroy_zpool $facet $poolname
1537 t32_bits_per_long() {
1539 # Yes, this is not meant to be perfect.
1549 t32_reload_modules() {
1551 local all_removed=false
1554 while ((i < 20)); do
1555 echo "Unloading modules on $node: Attempt $i"
1556 do_rpc_nodes $node $LUSTRE_RMMOD $(facet_fstype $SINGLEMDS) &&
1558 do_rpc_nodes $node check_mem_leak || return 1
1559 if $all_removed; then
1560 do_rpc_nodes $node load_modules
1566 echo "Unloading modules on $node: Given up"
1570 t32_wait_til_devices_gone() {
1576 echo wait for devices to go
1577 while ((i < 20)); do
1578 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1579 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1580 ((devices == 0 && loops == 0)) && return 0
1584 echo "waiting for dev on $node: dev $devices loop $loops given up"
1585 do_rpc_nodes $node "losetup -a"
1586 do_rpc_nodes $node "$LCTL device_list"
1590 t32_verify_quota() {
1594 local fstype=$(facet_fstype $SINGLEMDS)
1598 $LFS quota -u $T32_QID -v $mnt
1600 qval=$($LFS quota -v -u $T32_QID $mnt |
1601 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1602 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1604 [ $qval -eq $img_bspace ] || {
1605 echo "bspace, act:$qval, exp:$img_bspace"
1609 qval=$($LFS quota -v -u $T32_QID $mnt |
1610 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1611 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1613 [ $qval -eq $img_ispace ] || {
1614 echo "ispace, act:$qval, exp:$img_ispace"
1618 qval=$($LFS quota -v -u $T32_QID $mnt |
1619 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1620 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1622 [ $qval -eq $img_blimit ] || {
1623 echo "blimit, act:$qval, exp:$img_blimit"
1627 qval=$($LFS quota -v -u $T32_QID $mnt |
1628 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1629 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1631 [ $qval -eq $img_ilimit ] || {
1632 echo "ilimit, act:$qval, exp:$img_ilimit"
1636 do_node $node $LCTL conf_param $fsname.quota.mdt=ug
1637 cmd="$LCTL get_param -n osd-$fstype.$fsname-MDT0000"
1638 cmd=$cmd.quota_slave.enabled
1639 wait_update $node "$cmd" "ug" || {
1640 echo "Enable mdt quota failed"
1644 do_node $node $LCTL conf_param $fsname.quota.ost=ug
1645 cmd="$LCTL get_param -n osd-$fstype.$fsname-OST0000"
1646 cmd=$cmd.quota_slave.enabled
1647 wait_update $node "$cmd" "ug" || {
1648 echo "Enable ost quota failed"
1653 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1654 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1655 echo "Write succeed, but expect -EDQUOT"
1658 rm -f $mnt/t32_qf_new
1660 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1662 echo "Create succeed, but expect -EDQUOT"
1665 unlinkmany $mnt/t32_qf_ $img_ilimit
1673 local dne_upgrade=${dne_upgrade:-"no"}
1674 local ff_convert=${ff_convert:-"no"}
1675 local shall_cleanup_mdt=false
1676 local shall_cleanup_mdt1=false
1677 local shall_cleanup_ost=false
1678 local shall_cleanup_lustre=false
1679 local mdt2_is_available=false
1680 local node=$(facet_active_host $SINGLEMDS)
1681 local r="do_node $node"
1682 local node2=$(facet_active_host mds2)
1692 local nid=$($r $LCTL list_nids | head -1)
1698 local fstype=$(facet_fstype $SINGLEMDS)
1699 local mdt_dev=$tmp/mdt
1700 local mdt2_dev=$tmp/mdt2
1701 local ost_dev=$tmp/ost
1706 trap 'trap - RETURN; t32_test_cleanup' RETURN
1709 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1710 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1711 $r tar xjvf $tarball -S -C $tmp || {
1712 error_noexit "Unpacking the disk image tarball"
1715 img_commit=$($r cat $tmp/commit)
1716 img_kernel=$($r cat $tmp/kernel)
1717 img_arch=$($r cat $tmp/arch)
1718 img_bspace=$($r cat $tmp/bspace)
1719 img_ispace=$($r cat $tmp/ispace)
1721 # older images did not have "blimit" and "ilimit" files
1722 # use old values for T32_BLIMIT and T32_ILIMIT
1723 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1725 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1728 echo "Upgrading from $(basename $tarball), created with:"
1729 echo " Commit: $img_commit"
1730 echo " Kernel: $img_kernel"
1731 echo " Arch: $img_arch"
1732 echo "OST version: $(lustre_build_version ost1)"
1734 # The conversion can be made only when both of the following
1735 # conditions are satisfied:
1736 # - ost device img version < 2.3.64
1737 # - ost server version >= 2.5
1738 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1739 $(lustre_version_code ost1) -lt $(version_code 2.5.0) ] &&
1742 ! $r test -f $mdt2_dev || mdt2_is_available=true
1744 if [[ $fstype == zfs ]]; then
1747 local poolname_list="t32fs-mdt1 t32fs-ost1"
1749 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1751 for poolname in $poolname_list; do
1753 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1754 $ZPOOL import -f -d $tmp $poolname"
1757 mdt_dev=t32fs-mdt1/mdt1
1758 ost_dev=t32fs-ost1/ost1
1759 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1760 wait_update_facet $SINGLEMDS "$ZPOOL list |
1761 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1762 error_noexit "import zfs pool failed"
1767 $r $LCTL set_param debug="$PTLDEBUG"
1769 $r $TUNEFS --dryrun $mdt_dev || {
1771 error_noexit "tunefs.lustre before mounting the MDT"
1775 if $mdt2_is_available; then
1776 $r $TUNEFS --dryrun $mdt2_dev || {
1778 error_noexit "tunefs.lustre before mounting the MDT"
1783 if [ "$writeconf" ]; then
1785 if [ $fstype == "ldiskfs" ]; then
1787 $r $TUNEFS --quota $mdt_dev || {
1789 error_noexit "Enable mdt quota feature"
1792 if $mdt2_is_available; then
1793 $r $TUNEFS --quota $mdt2_dev || {
1795 error_noexit "Enable mdt quota feature"
1801 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1802 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1803 { skip "LU-2200: Cannot run over Inifiniband w/o lctl replace_nids "
1804 "(Need MGS version at least 2.3.59)"; return 0; }
1806 local osthost=$(facet_active_host ost1)
1807 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1810 if [ $fstype == "ldiskfs" ]; then
1813 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1814 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1815 $r $LCTL replace_nids $fsname-MDT0000 $nid
1816 $r $UMOUNT $tmp/mnt/mdt
1819 mopts=exclude=$fsname-OST0000
1820 if [ $fstype == "ldiskfs" ]; then
1825 t32_wait_til_devices_gone $node
1827 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1829 error_noexit "Mounting the MDT"
1832 shall_cleanup_mdt=true
1834 if $mdt2_is_available; then
1835 mopts=mgsnode=$nid,$mopts
1836 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1838 error_noexit "Mounting the MDT"
1842 echo "mount new MDT....$mdt2_dev"
1843 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1844 error_noexit "enable remote dir create failed"
1846 shall_cleanup_mdt1=true
1847 elif [ "$dne_upgrade" != "no" ]; then
1848 local fs2mdsdev=$(mdsdevname 1_2)
1849 local fs2mdsvdev=$(mdsvdevname 1_2)
1851 echo "mkfs new MDT on ${fs2mdsdev}...."
1852 if [ $(facet_fstype mds1) == ldiskfs ]; then
1853 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1856 add fs2mds $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1857 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1858 error_noexit "Mkfs new MDT failed"
1862 [[ $(facet_fstype mds1) != zfs ]] || import_zpool fs2mds
1864 $r $TUNEFS --dryrun $fs2mdsdev || {
1865 error_noexit "tunefs.lustre before mounting the MDT"
1869 echo "mount new MDT....$fs2mdsdev"
1870 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1871 error_noexit "mount mdt1 failed"
1875 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1876 error_noexit "enable remote dir create failed"
1878 shall_cleanup_mdt1=true
1881 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1882 error_noexit "Getting MDT UUID"
1885 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1886 error_noexit "Unexpected MDT UUID: \"$uuid\""
1890 $r $TUNEFS --dryrun $ost_dev || {
1891 error_noexit "tunefs.lustre before mounting the OST"
1894 if [ "$writeconf" ]; then
1895 mopts=mgsnode=$nid,$writeconf
1896 if [ $fstype == "ldiskfs" ]; then
1898 $r $TUNEFS --quota $ost_dev || {
1900 error_noexit "Enable ost quota feature"
1906 if [ $fstype == "ldiskfs" ]; then
1910 $r $MOUNT_CMD -o $mopts $ost_dev $tmp/mnt/ost || {
1911 error_noexit "Mounting the OST"
1914 shall_cleanup_ost=true
1916 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1917 error_noexit "Getting OST UUID"
1920 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1921 error_noexit "Unexpected OST UUID: \"$uuid\""
1925 $r $LCTL conf_param $fsname-OST0000.osc.max_dirty_mb=15 || {
1926 error_noexit "Setting \"max_dirty_mb\""
1929 $r $LCTL conf_param $fsname-OST0000.failover.node=$nid || {
1930 error_noexit "Setting OST \"failover.node\""
1933 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1934 error_noexit "Setting \"max_rpcs_in_flight\""
1937 $r $LCTL conf_param $fsname-MDT0000.failover.node=$nid || {
1938 error_noexit "Setting MDT \"failover.node\""
1941 $r $LCTL pool_new $fsname.interop || {
1942 error_noexit "Setting \"interop\""
1945 $r $LCTL conf_param $fsname-MDT0000.lov.stripesize=4M || {
1946 error_noexit "Setting \"lov.stripesize\""
1949 $r $LCTL conf_param $fsname-MDT0000.mdd.atime_diff=70 || {
1950 error_noexit "Setting \"mdd.atime_diff\""
1954 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1955 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1956 error_noexit "Start OI scrub on OST0"
1960 # The oi_scrub should be on ost1, but for test_32(),
1961 # all on the SINGLEMDS.
1962 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1963 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1964 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1965 error_noexit "Failed to get the expected 'completed'"
1969 local UPDATED=$($r $LCTL get_param -n \
1970 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1971 awk '/^updated/ { print $2 }')
1972 [ $UPDATED -ge 1 ] || {
1973 error_noexit "Only $UPDATED objects have been converted"
1978 if [ "$dne_upgrade" != "no" ]; then
1979 $r $LCTL conf_param \
1980 $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
1981 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
1984 $r $LCTL conf_param $fsname-MDT0001.failover.node=$nid || {
1985 error_noexit "Setting MDT1 \"failover.node\""
1988 $r $LCTL conf_param $fsname-MDT0001.lov.stripesize=4M || {
1989 error_noexit "Setting MDT1 \"lov.stripesize\""
1994 if [ "$writeconf" ]; then
1995 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
1996 error_noexit "Mounting the client"
2000 shall_cleanup_lustre=true
2001 $r $LCTL set_param debug="$PTLDEBUG"
2003 t32_verify_quota $node $fsname $tmp/mnt/lustre || {
2004 error_noexit "verify quota failed"
2008 if $r test -f $tmp/list; then
2010 # There is not a Test Framework API to copy files to or
2011 # from a remote node.
2013 # LU-2393 - do both sorts on same node to ensure locale
2015 local list_file=$tmp/list
2017 if $mdt2_is_available; then
2018 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2019 $r test -f $tmp/list2; then
2020 list_file=$tmp/list2
2021 pushd $tmp/mnt/lustre/striped_dir_old
2023 pushd $tmp/mnt/lustre/remote_dir
2026 pushd $tmp/mnt/lustre
2028 $r cat $list_file | sort -k 6 >$tmp/list.orig
2029 ls -Rni --time-style=+%s | sort -k 6 |
2030 sed 's/\. / /' >$tmp/list || {
2036 # 32-bit and 64-bit clients use different algorithms to
2037 # convert FIDs into inode numbers. Hence, remove the
2038 # inode numbers from the lists, if the original list was
2039 # created on an architecture with different number of
2042 if [ $(t32_bits_per_long $(uname -m)) != \
2043 $(t32_bits_per_long $img_arch) ]; then
2044 echo "Different number of bits per \"long\"" \
2045 "from the disk image"
2046 for list in list.orig list; do
2047 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2051 if ! diff -ub $tmp/list.orig $tmp/list; then
2052 error_noexit "list verification failed"
2056 echo "list verification skipped"
2059 if [ "$dne_upgrade" != "no" ]; then
2060 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2061 error_noexit "set striped dir failed"
2065 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2067 pushd $tmp/mnt/lustre
2068 tar -cf - . --exclude=./striped_dir \
2069 --exclude=./striped_dir_old \
2070 --exclude=./remote_dir |
2071 tar -xvf - -C striped_dir 1>/dev/null || {
2072 error_noexit "cp to striped dir failed"
2078 # If it is upgrade from DNE (2.5), then rename the remote dir,
2079 # which is created in 2.5 to striped dir.
2080 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2081 stripe_index=$($LFS getdirstripe -i \
2082 $tmp/mnt/lustre/remote_dir)
2084 [[ $stripe_index -eq 1 ]] || {
2085 error_noexit "get index \"$stripe_index\"" \
2086 "from remote dir failed"
2089 mv $tmp/mnt/lustre/remote_dir \
2090 $tmp/mnt/lustre/striped_dir/ || {
2091 error_noexit "mv remote dir failed"
2096 # If it is upgraded from DNE (2.7), then move the striped dir
2097 # which was created in 2.7 to the new striped dir.
2098 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2099 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2100 stripe_count=$($LFS getdirstripe -c \
2101 $tmp/mnt/lustre/striped_dir_old)
2102 [[ $stripe_count -eq 2 ]] || {
2103 error_noexit "get count $stripe_count" \
2104 "from striped dir failed"
2107 mv $tmp/mnt/lustre/striped_dir_old \
2108 $tmp/mnt/lustre/striped_dir/ || {
2109 error_noexit "mv striped dir failed"
2115 $r $LCTL set_param -n osd*.*.force_sync=1
2116 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2117 error_noexit "dd failed"
2120 rm -rf $tmp/mnt/lustre/tmp_file || {
2121 error_noexit "rm failed"
2125 if $r test -f $tmp/sha1sums; then
2126 # LU-2393 - do both sorts on same node to ensure locale
2128 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2129 if [ "$dne_upgrade" != "no" ]; then
2130 pushd $tmp/mnt/lustre/striped_dir
2132 pushd $tmp/mnt/lustre
2135 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2136 ! -name .lustre -type f -exec sha1sum {} \; |
2137 sort -k 2 >$tmp/sha1sums || {
2139 error_noexit "sha1sum"
2143 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2144 error_noexit "sha1sum verification failed"
2148 # if upgrade from DNE(2.5), then check remote directory
2149 # if upgrade from DNE(2.7), then check striped directory
2150 if $mdt2_is_available &&
2151 [[ "$dne_upgrade" != "no" ]]; then
2152 local new_dir="$tmp/mnt/lustre/striped_dir"
2153 local striped_dir_old="$new_dir/striped_dir_old"
2155 local dir_list="$new_dir/remote_dir"
2156 [[ ! -d $triped_dir_old ]] ||
2157 dir_list+=" $striped_dir_old"
2159 for dir in $dir_list; do
2161 find ! -name .lustre -type f \
2162 -exec sha1sum {} \; |
2163 sort -k 2 >$tmp/sha1sums || {
2165 error_noexit "sha1sum"
2169 if ! diff -ub $tmp/sha1sums.orig \
2171 error_noexit "sha1sum $dir" \
2178 echo "sha1sum verification skipped"
2181 if [ "$dne_upgrade" != "no" ]; then
2182 rm -rf $tmp/mnt/lustre/striped_dir || {
2183 error_noexit "remove remote dir failed"
2188 # migrate files/dirs to remote MDT, then move them back
2189 if [ $(lustre_version_code mds1) -ge $(version_code 2.7.50) -a \
2190 $dne_upgrade != "no" ]; then
2191 $r $LCTL set_param -n \
2192 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2194 echo "test migration"
2195 pushd $tmp/mnt/lustre
2196 for dir in $(find ! -name .lustre ! -name . -type d); do
2197 mdt_index=$($LFS getdirstripe -i $dir)
2198 stripe_cnt=$($LFS getdirstripe -c $dir)
2199 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2200 $LFS mv -M 1 $dir || {
2202 error_noexit "migrate MDT1 failed"
2208 for dir in $(find ! -name . ! -name .lustre -type d); do
2209 mdt_index=$($LFS getdirstripe -i $dir)
2210 stripe_cnt=$($LFS getdirstripe -c $dir)
2211 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2212 $LFS mv -M 0 $dir || {
2214 error_noexit "migrate MDT0 failed"
2223 # When adding new data verification tests, please check for
2224 # the presence of the required reference files first, like
2225 # the "sha1sums" and "list" tests above, to avoid the need to
2226 # regenerate every image for each test addition.
2229 nrpcs_orig=$($LCTL get_param \
2230 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2231 error_noexit "Getting \"max_rpcs_in_flight\""
2234 nrpcs=$((nrpcs_orig + 5))
2235 $r $LCTL conf_param $fsname-MDT0000.mdc.max_rpcs_in_flight=$nrpcs || {
2236 error_noexit "Changing \"max_rpcs_in_flight\""
2239 wait_update $HOSTNAME "$LCTL get_param \
2240 -n mdc.*MDT0000*.max_rpcs_in_flight" $nrpcs || {
2241 error_noexit "Verifying \"max_rpcs_in_flight\""
2245 umount $tmp/mnt/lustre || {
2246 error_noexit "Unmounting the client"
2249 shall_cleanup_lustre=false
2251 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2252 $r $UMOUNT $tmp/mnt/mdt1 || {
2253 error_noexit "Unmounting the MDT2"
2256 shall_cleanup_mdt1=false
2259 $r $UMOUNT $tmp/mnt/mdt || {
2260 error_noexit "Unmounting the MDT"
2263 shall_cleanup_mdt=false
2265 $r $UMOUNT $tmp/mnt/ost || {
2266 error_noexit "Unmounting the OST"
2269 shall_cleanup_ost=false
2271 t32_reload_modules $node || {
2272 error_noexit "Reloading modules"
2276 if [[ $fstype == zfs ]]; then
2277 local poolname=t32fs-mdt1
2279 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2280 $ZPOOL import -f -d $tmp $poolname"
2283 # mount a second time to make sure we didnt leave upgrade flag on
2284 $r $TUNEFS --dryrun $mdt_dev || {
2286 error_noexit "tunefs.lustre before remounting the MDT"
2290 mopts=exclude=$fsname-OST0000
2291 if [ $fstype == "ldiskfs" ]; then
2294 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2295 error_noexit "Remounting the MDT"
2298 shall_cleanup_mdt=true
2308 for tarball in $tarballs; do
2309 t32_test $tarball || let "rc += $?"
2313 run_test 32a "Upgrade (not live)"
2321 for tarball in $tarballs; do
2322 t32_test $tarball writeconf || let "rc += $?"
2326 run_test 32b "Upgrade with writeconf"
2333 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2335 for tarball in $tarballs; do
2336 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2337 echo $tarball | grep "1_8" && continue
2338 echo $tarball | grep "2_1" && continue
2340 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2344 run_test 32c "dne upgrade test"
2352 for tarball in $tarballs; do
2353 ff_convert=yes t32_test $tarball || rc=$?
2357 run_test 32d "convert ff test"
2359 test_33a() { # bug 12333, was test_33
2360 local FSNAME2=test-123
2361 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2364 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2366 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2367 local dev=${SINGLEMDS}_dev
2368 local MDSDEV=${!dev}
2369 is_blkdev $SINGLEMDS $MDSDEV &&
2370 skip_env "mixed loopback and real device not working" &&
2374 local fs2mdsdev=$(mdsdevname 1_2)
2375 local fs2ostdev=$(ostdevname 1_2)
2376 local fs2mdsvdev=$(mdsvdevname 1_2)
2377 local fs2ostvdev=$(ostvdevname 1_2)
2379 if [ $(facet_fstype mds1) == ldiskfs ]; then
2380 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2383 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2384 --reformat $mkfsoptions $fs2mdsdev $fs2mdsvdev || exit 10
2385 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2386 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2387 $fs2ostvdev || exit 10
2389 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2390 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2391 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" ||
2392 error "$LCTL conf_param $FSNAME2.sys.timeout=200 failed"
2393 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2394 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2397 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2398 $GETSTRIPE $MOUNT2/hosts || error "$GETSTRIPE $MOUNT2/hosts failed"
2403 cleanup_nocli || error "cleanup_nocli failed with $?"
2405 run_test 33a "Mount ost with a large index number"
2407 test_33b() { # was test_34
2410 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2411 # Drop lock cancelation reply during umount
2412 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2413 do_facet client $LCTL set_param fail_loc=0x80000304
2414 #lctl set_param debug=-1
2415 umount_client $MOUNT
2416 cleanup || error "cleanup failed with $?"
2418 run_test 33b "Drop cancel during umount"
2422 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2423 manual_umount_client
2425 do_facet client killall -USR1 multiop
2426 if [ $rc -eq 0 ]; then
2427 error "umount not fail!"
2430 cleanup || error "cleanup failed with rc $?"
2432 run_test 34a "umount with opened file should be fail"
2436 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2437 stop_mds || error "Unable to stop MDS"
2439 manual_umount_client --force || error "mtab after failed umount with $?"
2441 cleanup || error "cleanup failed with $?"
2443 run_test 34b "force umount with failed mds should be normal"
2447 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2448 stop_ost || error "Unable to stop OST1"
2450 manual_umount_client --force || error "mtab after failed umount with $?"
2452 cleanup || error "cleanup failed with $?"
2454 run_test 34c "force umount with failed ost should be normal"
2456 test_35a() { # bug 12459
2459 DBG_SAVE="`$LCTL get_param -n debug`"
2460 $LCTL set_param debug="ha"
2462 log "Set up a fake failnode for the MDS"
2464 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2465 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2466 do_facet mgs "$LCTL conf_param \
2467 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" ||
2468 error "Setting ${device}.failover.node=\
2469 $(h2$NETTYPE $FAKENID) failed."
2471 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2474 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2477 log "Stopping the MDT: $device"
2478 stop_mdt 1 || error "MDT0 stop fail"
2480 df $MOUNT > /dev/null 2>&1 &
2482 log "Restarting the MDT: $device"
2483 start_mdt 1 || error "MDT0 start fail"
2484 log "Wait for df ($DFPID) ... "
2487 $LCTL set_param debug="$DBG_SAVE"
2489 # retrieve from the log the first server that the client tried to
2490 # contact after the connection loss
2491 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2492 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2493 /import_select_connection.*$device-mdc.* using connection/ {
2495 if (\\\$NF ~ /$FAKENID/)
2501 }" $TMP/lustre-log-$TESTNAME.log`
2502 [ "$NEXTCONN" != "0" ] &&
2503 error "Tried to connect to ${NEXTCONN} not last active server"
2504 cleanup || error "cleanup failed with $?"
2505 # remove nid settings
2506 writeconf_or_reformat
2508 run_test 35a "Reconnect to the last active server first"
2510 test_35b() { # bug 18674
2511 remote_mds || { skip "local MDS" && return 0; }
2515 $LCTL set_param debug="ha"
2517 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2520 log "Set up a fake failnode for the MDS"
2522 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2523 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2524 do_facet mgs "$LCTL conf_param \
2525 ${device}.failover.node=$(h2$NETTYPE $FAKENID)" ||
2526 error "Set ${device}.failover.node=\
2527 $(h2$NETTYPE $FAKENID) failed"
2529 local at_max_saved=0
2530 # adaptive timeouts may prevent seeing the issue
2531 if at_is_enabled; then
2532 at_max_saved=$(at_max_get mds)
2533 at_max_set 0 mds client
2536 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2538 log "Injecting EBUSY on MDS"
2539 # Setting OBD_FAIL_MDS_RESEND=0x136
2540 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2541 error "unable to set param fail_loc=0x80000136"
2543 $LCTL set_param mdc.${FSNAME}*.stats=clear
2545 log "Creating a test file and stat it"
2546 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2547 stat $MOUNT/$tdir/$tfile
2549 log "Stop injecting EBUSY on MDS"
2550 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2551 error "unable to set param fail_loc=0"
2552 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2555 # restore adaptive timeout
2556 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2558 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2560 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2561 awk '/mds_connect/{print $2}')
2563 # retrieve from the log if the client has ever tried to
2564 # contact the fake server after the loss of connection
2565 FAILCONN=`awk "BEGIN {ret = 0;}
2566 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2568 if (\\\$NF ~ /$FAKENID/) {
2573 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2575 [ "$FAILCONN" == "0" ] &&
2576 error "The client reconnection has not been triggered"
2577 [ "$FAILCONN" == "2" ] &&
2578 error "Primary server busy, client reconnect to failover failed"
2581 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2582 # Reconnects are supposed to be rate limited to one every 5s
2583 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2584 error "Too many reconnects $CONNCNT"
2586 cleanup || error "cleanup failed with $?"
2587 # remove nid settings
2588 writeconf_or_reformat
2590 run_test 35b "Continue reconnection retries, if the active server is busy"
2593 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
2595 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2596 { skip "remote OST" && return 0; }
2599 local FSNAME2=test1234
2600 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2602 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2604 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2605 is_blkdev $SINGLEMDS $MDSDEV &&
2606 skip_env "mixed loopback and real device not working" && return
2609 local fs2mdsdev=$(mdsdevname 1_2)
2610 local fs2ostdev=$(ostdevname 1_2)
2611 local fs3ostdev=$(ostdevname 2_2)
2612 local fs2mdsvdev=$(mdsvdevname 1_2)
2613 local fs2ostvdev=$(ostvdevname 1_2)
2614 local fs3ostvdev=$(ostvdevname 2_2)
2616 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2617 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2618 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2619 # different one than the default value here.
2620 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2621 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2622 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2623 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2625 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2626 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2627 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2628 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2629 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2631 sleep 5 # until 11778 fixed
2633 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2635 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2636 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2637 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2638 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2639 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2640 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2641 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2642 DFTOTAL=$(echo $STRING | cut -d, -f1)
2643 DFUSED=$(echo $STRING | cut -d, -f2)
2644 DFAVAIL=$(echo $STRING | cut -d, -f3)
2645 DFFREE=$(($DFTOTAL - $DFUSED))
2647 ALLOWANCE=$((64 * $OSTCOUNT))
2649 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2650 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2651 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2654 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2655 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2656 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2659 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2660 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2661 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2666 stop fs3ost -f || error "unable to stop OST3"
2667 stop fs2ost -f || error "unable to stop OST2"
2668 stop fs2mds -f || error "unable to stop second MDS"
2669 unload_modules_conf || error "unable unload modules"
2672 run_test 36 "df report consistency on OSTs with different block size"
2675 local mntpt=$(facet_mntpt $SINGLEMDS)
2676 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2677 local mdsdev_sym="$TMP/sym_mdt.img"
2678 local opts=$MDS_MOUNT_OPTS
2681 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2682 skip "Currently only applicable to ldiskfs-based MDTs"
2686 echo "MDS : $mdsdev"
2687 echo "SYMLINK : $mdsdev_sym"
2688 do_facet $SINGLEMDS rm -f $mdsdev_sym
2690 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2692 echo "mount symlink device - $mdsdev_sym"
2694 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2695 opts=$(csa_add "$opts" -o loop)
2697 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2698 $mdsdev_sym $mntpt 2>&1)
2701 echo mount_op=$mount_op
2703 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2705 if $(echo $mount_op | grep -q "unable to set tunable"); then
2706 error "set tunables failed for symlink device"
2709 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2711 run_test 37 "verify set tunables works for symlink device"
2713 test_38() { # bug 14222
2714 local fstype=$(facet_fstype $SINGLEMDS)
2715 local mntpt=$(facet_mntpt $SINGLEMDS)
2720 local SRC="/etc /bin"
2721 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2722 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2723 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2724 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2725 error "copying $SRC to $DIR/$tdir"
2727 umount_client $MOUNT || error "umount_client $MOUNT failed"
2728 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2729 stop_mds || error "Unable to stop MDS"
2730 log "delete lov_objid file on MDS"
2732 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2734 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2736 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2738 # check create in mds_lov_connect
2739 start_mds || error "unable to start MDS"
2740 mount_client $MOUNT || error "mount_client $MOUNT failed"
2742 [ $V ] && log "verifying $DIR/$tdir/$f"
2743 diff -q $f $DIR/$tdir/$f || ERROR=y
2745 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2746 if [ "$ERROR" = "y" ]; then
2747 # check it's updates in sync
2748 umount_client $MOUNT
2750 mount_fstype $SIGNLEMDS
2751 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2752 unmount_fstype $SINGLEMDS
2753 error "old and new files are different after connect" || true
2755 touch $DIR/$tdir/f2 || error "f2 file create failed"
2757 # check it's updates in sync
2758 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2761 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2763 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2764 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2766 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2768 start_mds || error "unable to start MDS"
2769 mount_client $MOUNT || error "mount_client $MOUNT failed"
2771 [ $V ] && log "verifying $DIR/$tdir/$f"
2772 diff -q $f $DIR/$tdir/$f || ERROR=y
2774 touch $DIR/$tdir/f3 || error "f3 file create failed"
2775 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2776 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2778 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2779 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2780 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2782 [ "$ERROR" = "y" ] &&
2783 error "old and new files are different after sync" || true
2785 log "files compared the same"
2786 cleanup || error "cleanup failed with $?"
2788 run_test 38 "MDS recreates missing lov_objid file from OST data"
2793 cleanup || error "cleanup failed with $?"
2794 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2795 error "memory leak detected" || true
2797 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2799 test_40() { # bug 15759
2800 start_ost || error "Unable to start OST1"
2801 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2802 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2804 cleanup || error "cleanup failed with rc $?"
2806 run_test 40 "race during service thread startup"
2808 test_41a() { #bug 14134
2809 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2810 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2811 skip "Loop devices does not work with nosvc option"
2816 { skip "needs combined MGT and MDT device" && return 0; }
2818 start_mdt 1 -o nosvc -n
2819 if [ $MDSCOUNT -ge 2 ]; then
2820 for num in $(seq 2 $MDSCOUNT); do
2821 start_mdt $num || return
2824 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2825 start_mdt 1 -o nomgs,force
2826 mount_client $MOUNT || error "mount_client $MOUNT failed"
2829 echo "blah blah" > $MOUNT/$tfile
2832 umount_client $MOUNT || error "umount_client $MOUNT failed"
2833 stop ost1 -f || error "unable to stop OST1"
2834 stop_mds || error "Unable to stop MDS"
2835 stop_mds || error "Unable to stop MDS on second try"
2837 run_test 41a "mount mds with --nosvc and --nomgs"
2840 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2841 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2842 skip "Loop devices does not work with nosvc option"
2846 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2850 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2852 start_mdt 1 -o nosvc -n
2853 if [ $MDSCOUNT -ge 2 ]; then
2854 for num in $(seq 2 $MDSCOUNT); do
2855 start_mdt $num || return
2858 start_ost || error "Unable to start OST1"
2859 start_mdt 1 -o nomgs,force
2860 mount_client $MOUNT || error "mount_client $MOUNT failed"
2863 echo "blah blah" > $MOUNT/$tfile
2864 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
2866 umount_client $MOUNT || error "umount_client $MOUNT failed"
2867 stop_ost || error "Unable to stop OST1"
2868 stop_mds || error "Unable to stop MDS"
2869 stop_mds || error "Unable to stop MDS on second try"
2871 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2874 local server_version=$(lustre_version_code $SINGLEMDS)
2875 local oss_list=$(comma_list $(osts_nodes))
2877 [[ $server_version -ge $(version_code 2.6.52) ]] ||
2878 [[ $server_version -ge $(version_code 2.5.26) &&
2879 $server_version -lt $(version_code 2.5.50) ]] ||
2880 [[ $server_version -ge $(version_code 2.5.4) &&
2881 $server_version -lt $(version_code 2.5.11) ]] ||
2882 { skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"; return; }
2884 # ensure mds1 ost1 have been created even if running sub-test standalone
2887 cleanup || error "cleanup failed"
2889 # using directly mount command instead of start() function to avoid
2890 # any side effect of // with others/externals tools/features
2891 # ("zpool import", ...)
2893 # MDT concurrent start
2895 LOAD_MODULES_REMOTE=true load_modules
2896 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
2897 error "MDT concurrent start: libcfs module not loaded"
2899 local mds1dev=$(mdsdevname 1)
2900 local mds1mnt=$(facet_mntpt mds1)
2901 local mds1fstype=$(facet_fstype mds1)
2902 local mds1opts=$MDS_MOUNT_OPTS
2904 if [ $mds1fstype == ldiskfs ] &&
2905 ! do_facet mds1 test -b $mds1dev; then
2906 mds1opts=$(csa_add "$mds1opts" -o loop)
2908 if [[ $mds1fstype == zfs ]]; then
2909 import_zpool mds1 || return ${PIPESTATUS[0]}
2912 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
2913 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
2915 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
2918 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
2922 do_facet mds1 "$LCTL set_param fail_loc=0x0"
2923 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
2924 echo "1st MDT start succeed"
2925 echo "2nd MDT start failed with $rc2"
2926 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
2927 echo "1st MDT start failed with $rc"
2928 echo "2nd MDT start succeed"
2931 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
2934 if [ $MDSCOUNT -ge 2 ]; then
2935 for num in $(seq 2 $MDSCOUNT); do
2936 start_mdt $num || return
2940 # OST concurrent start
2942 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
2943 error "OST concurrent start: libcfs module not loaded"
2945 local ost1dev=$(ostdevname 1)
2946 local ost1mnt=$(facet_mntpt ost1)
2947 local ost1fstype=$(facet_fstype ost1)
2948 local ost1opts=$OST_MOUNT_OPTS
2950 if [ $ost1fstype == ldiskfs ] &&
2951 ! do_facet ost1 test -b $ost1dev; then
2952 ost1opts=$(csa_add "$ost1opts" -o loop)
2954 if [[ $ost1fstype == zfs ]]; then
2955 import_zpool ost1 || return ${PIPESTATUS[0]}
2958 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
2959 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
2961 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
2964 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
2968 do_facet ost1 "$LCTL set_param fail_loc=0x0"
2969 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
2970 echo "1st OST start succeed"
2971 echo "2nd OST start failed with $rc2"
2972 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
2973 echo "1st OST start failed with $rc"
2974 echo "2nd OST start succeed"
2978 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
2984 # verify everything ok
2989 error "MDT(s) start failed"
2997 error "OST(s) start failed"
3005 error "client start failed"
3012 error "client mount failed"
3016 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3018 test_42() { #bug 14693
3020 check_mount || error "client was not mounted"
3022 do_facet mgs $LCTL conf_param $FSNAME.llite.some_wrong_param=10
3023 umount_client $MOUNT ||
3024 error "unmounting client failed with invalid llite param"
3025 mount_client $MOUNT ||
3026 error "mounting client failed with invalid llite param"
3028 do_facet mgs $LCTL conf_param $FSNAME.sys.some_wrong_param=20
3029 cleanup || error "stopping $FSNAME failed with invalid sys param"
3031 check_mount || error "client was not mounted with invalid sys param"
3032 cleanup || error "stopping $FSNAME failed with invalid sys param"
3034 run_test 42 "allow client/server mount/unmount with invalid config param"
3037 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.58) ]] ||
3038 { skip "Need MDS version at least 2.5.58" && return 0; }
3039 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
3042 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
3043 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
3047 chmod ugo+x $DIR || error "chmod 0 failed"
3048 set_conf_param_and_check mds1 \
3049 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
3050 "$FSNAME.mdt.root_squash" \
3052 wait_update $HOSTNAME \
3053 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3055 error "check llite root_squash failed!"
3056 set_conf_param_and_check mds1 \
3057 "$LCTL get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
3058 "$FSNAME.mdt.nosquash_nids" \
3060 wait_update $HOSTNAME \
3061 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3063 error "check llite nosquash_nids failed!"
3066 # create set of test files
3068 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
3069 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
3070 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
3072 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
3073 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
3075 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
3076 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
3077 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
3079 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
3080 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
3081 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
3084 # check root_squash:
3085 # set root squash UID:GID to RUNAS_ID
3086 # root should be able to access only files owned by RUNAS_ID
3088 set_conf_param_and_check mds1 \
3089 "$LCTL get_param -n mdt.$FSNAME-MDT0000.root_squash" \
3090 "$FSNAME.mdt.root_squash" \
3091 "$RUNAS_ID:$RUNAS_ID"
3092 wait_update $HOSTNAME \
3093 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3094 "$RUNAS_ID:$RUNAS_ID" ||
3095 error "check llite root_squash failed!"
3097 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
3098 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3099 error "$ST: root read permission is denied"
3100 echo "$ST: root read permission is granted - ok"
3103 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3104 error "$ST: root write permission is denied"
3105 echo "$ST: root write permission is granted - ok"
3107 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3108 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3109 error "$ST: root read permission is granted"
3110 echo "$ST: root read permission is denied - ok"
3113 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3114 error "$ST: root write permission is granted"
3115 echo "$ST: root write permission is denied - ok"
3117 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3118 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
3119 error "$ST: root unlink permission is granted"
3120 echo "$ST: root unlink permission is denied - ok"
3122 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
3123 error "$ST: root create permission is granted"
3124 echo "$ST: root create permission is denied - ok"
3127 # check root_squash is enforced independently
3128 # of client cache content
3130 # access file by USER1, keep access open
3131 # root should be denied access to user file
3133 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
3137 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
3138 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3139 { kill $pid; error "$ST: root read permission is granted"; }
3140 echo "$ST: root read permission is denied - ok"
3143 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3144 { kill $pid; error "$ST: root write permission is granted"; }
3145 echo "$ST: root write permission is denied - ok"
3151 # check nosquash_nids:
3152 # put client's NID into nosquash_nids list,
3153 # root should be able to access root file after that
3155 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
3156 NIDLIST="2@gni $NIDLIST 192.168.0.[2,10]@tcp"
3157 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
3158 set_conf_param_and_check mds1 \
3159 "$LCTL get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
3160 "$FSNAME-MDTall.mdt.nosquash_nids" \
3162 wait_update $HOSTNAME \
3163 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3165 error "check llite nosquash_nids failed!"
3167 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3168 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3169 error "$ST: root read permission is denied"
3170 echo "$ST: root read permission is granted - ok"
3173 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3174 error "$ST: root write permission is denied"
3175 echo "$ST: root write permission is granted - ok"
3177 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3178 rm $DIR/$tdir-rootdir/