8 PTLDEBUG=${PTLDEBUG:--1}
9 LUSTRE=${LUSTRE:-$(dirname $0)/..}
10 . $LUSTRE/tests/test-framework.sh
14 # tool to create lustre filesystem images
15 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 32newtarball"
17 # bug number for skipped test: LU-11915
18 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 110"
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
22 # bug number for skipped tests: LU-9795 (all below)
23 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 84 86 103"
26 if ! combined_mgs_mds; then
27 # bug number for skipped test: LU-11991 LU-11990
28 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 32a 32b 32c 32d 32e 66"
29 # bug number for skipped test: LU-9897 LU-12032
30 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 84 123F"
34 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69 106 111"
38 # use small MDS + OST size to speed formatting time
39 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
40 # STORED_MDSSIZE is used in test_18
41 STORED_MDSSIZE=$MDSSIZE
42 STORED_OSTSIZE=$OSTSIZE
44 [ "$mds1_FSTYPE" = zfs ] && MDSSIZE=400000
46 [ "$ost1_FSTYPE" = zfs ] && OSTSIZE=400000
56 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
57 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
58 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
62 require_dsh_mds || exit 0
63 require_dsh_ost || exit 0
68 # The MGS must be started before the OSTs for a new fs, so start
69 # and stop to generate the startup logs.
72 wait_osc_import_state mds ost FULL
77 reformat_and_config() {
79 if ! combined_mgs_mds ; then
85 writeconf_or_reformat() {
86 # There are at most 2 OSTs for write_conf test
87 # who knows if/where $TUNEFS is installed?
88 # Better reformat if it fails...
89 writeconf_all $MDSCOUNT 2 ||
90 { echo "tunefs failed, reformatting instead" &&
91 reformat_and_config && return 0; }
100 echo "start mgs service on $(facet_active_host mgs)"
101 start mgs $(mgsdevname) $MGS_MOUNT_OPTS $@
107 local dev=$(mdsdevname $num)
110 echo "start mds service on `facet_active_host $facet`"
111 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
114 stop_mdt_no_force() {
117 local dev=$(mdsdevname $num)
120 echo "stop mds service on `facet_active_host $facet`"
121 stop $facet || return 97
127 local dev=$(mdsdevname $num)
130 echo "stop mds service on `facet_active_host $facet`"
131 # These tests all use non-failover stop
132 stop $facet -f || return 97
138 for num in $(seq $MDSCOUNT); do
139 start_mdt $num $@ || return 94
141 for num in $(seq $MDSCOUNT); do
142 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds${num} FULL
147 if ! combined_mgs_mds ; then
155 for num in $(seq $MDSCOUNT); do
156 stop_mdt $num || return 97
161 echo "stop mgs service on `facet_active_host mgs`"
162 # These tests all use non-failover stop
163 stop mgs -f || return 97
167 echo "start ost1 service on `facet_active_host ost1`"
168 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
169 wait_clients_import_state ${CLIENTS:-$HOSTNAME} ost1 FULL
173 echo "stop ost1 service on `facet_active_host ost1`"
174 # These tests all use non-failover stop
175 stop ost1 -f || return 98
179 echo "start ost2 service on `facet_active_host ost2`"
180 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
181 wait_clients_import_state ${CLIENTS:-$HOSTNAME} ost2 FULL
185 echo "stop ost2 service on `facet_active_host ost2`"
186 # These tests all use non-failover stop
187 stop ost2 -f || return 93
194 echo "mount $FSNAME ${mountopt:+with opts $mountopt} on $mountpath....."
195 zconf_mount $HOSTNAME $mountpath $mountopt || return 96
201 echo "umount lustre on $mountpath....."
202 zconf_umount $HOSTNAME $mountpath $@ || return 97
205 manual_umount_client(){
208 echo "manual umount lustre on ${MOUNT}...."
209 do_facet client "umount ${FORCE} $MOUNT"
215 start_mds || error "MDT start failed"
216 start_ost || error "Unable to start OST1"
217 mount_client $MOUNT || error "client start failed"
218 client_up || error "client_up failed"
227 unload_modules_conf () {
228 if combined_mgs_mds || ! local_mode; then
229 unload_modules || return 1
234 stop_ost || return 202
235 stop_mds || return 201
236 unload_modules_conf || return 203
241 [ "x$1" != "x" ] && force='-f'
242 umount_client $MOUNT $force|| return 200
243 cleanup_nocli || return $?
248 echo "umount $MOUNT2 ..."
249 umount $MOUNT2 || true
250 echo "stopping fs2mds ..."
251 stop fs2mds -f || true
252 echo "stopping fs2ost ..."
253 stop fs2ost -f || true
257 do_facet client "cp /etc/passwd $DIR/a" || return 71
258 do_facet client "rm $DIR/a" || return 72
259 # make sure lustre is actually mounted (touch will block,
260 # but grep won't, so do it after)
261 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
262 echo "setup single mount lustre success"
266 do_facet client "touch $DIR/a" || return 71
267 do_facet client "rm $DIR/a" || return 72
268 do_facet client "touch $DIR2/a" || return 73
269 do_facet client "rm $DIR2/a" || return 74
270 echo "setup double mount lustre success"
274 cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
277 if [ "$ONLY" == "setup" ]; then
282 if [ "$ONLY" == "cleanup" ]; then
289 #create single point mountpoint
295 check_mount || error "check_mount failed"
296 cleanup || error "cleanup failed with $?"
298 run_test 0 "single mount setup"
301 start_mds || error "MDS start failed"
302 start_ost || error "unable to start OST"
303 echo "start ost second time..."
304 start_ost && error "2nd OST start should fail"
305 mount_client $MOUNT || error "client start failed"
306 check_mount || error "check_mount failed"
307 cleanup || error "cleanup failed with $?"
309 run_test 1 "start up ost twice (should return errors)"
312 start_mds || error "MDT start failed"
313 echo "start mds second time.."
314 start_mds && error "2nd MDT start should fail"
315 start_ost || error "OST start failed"
316 mount_client $MOUNT || error "mount_client failed to start client"
317 check_mount || error "check_mount failed"
318 cleanup || error "cleanup failed with $?"
320 run_test 2 "start up mds twice (should return err)"
324 #mount.lustre returns an error if already in mtab
325 mount_client $MOUNT && error "2nd client mount should fail"
326 check_mount || error "check_mount failed"
327 cleanup || error "cleanup failed with $?"
329 run_test 3 "mount client twice (should return err)"
333 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
334 stop_ost || error "Unable to stop OST1"
335 umount_client $MOUNT -f || error “unmount $MOUNT failed”
338 # ok for ost to fail shutdown
339 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
340 error "cleanup failed with $?"
343 run_test 4 "force cleanup ost, then cleanup"
345 test_5a() { # was test_5
347 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
348 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
350 stop_mds || error "Unable to stop MDS"
352 # cleanup may return an error from the failed
353 # disconnects; for now I'll consider this successful
354 # if all the modules have unloaded.
358 echo "killing umount"
359 kill -TERM $UMOUNT_PID
360 echo "waiting for umount to finish"
362 if grep " $MOUNT " /proc/mounts; then
363 echo "test 5: /proc/mounts after failed umount"
367 echo "killing umount"
368 kill -TERM $UMOUNT_PID
369 echo "waiting for umount to finish"
371 grep " $MOUNT " /proc/mounts &&
372 error "/proc/mounts after second umount"
375 # manual_mount_client may fail due to umount succeeding above
377 # stop_mds is a no-op here, and should not fail
378 cleanup_nocli || error "cleanup_nocli failed with $?"
379 # df may have lingering entry
381 # mtab may have lingering entry
385 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
387 grep -q $MOUNT" " /etc/mtab || break
388 echo "Waiting /etc/mtab updated ... "
389 WAIT=$(( WAIT + sleep))
391 [ "$WAIT" -eq "$MAX_WAIT" ] &&
392 error "/etc/mtab is not updated in $WAIT secs"
393 echo "/etc/mtab updated in $WAIT secs"
395 run_test 5a "force cleanup mds, then cleanup"
403 grep " $MOUNT " /etc/mtab &&
404 error false "unexpected entry in mtab before mount" && return 10
406 start_ost || error "OST start failed"
407 if ! combined_mgs_mds ; then
408 trap cleanup_5b EXIT ERR
409 start_mds || error "MDS start failed"
413 mount_client $MOUNT && error "mount_client $MOUNT should fail"
414 grep " $MOUNT " /etc/mtab &&
415 error "$MOUNT entry in mtab after failed mount"
417 # stop_mds is a no-op here, and should not fail
418 cleanup_nocli || error "cleanup_nocli failed with $?"
419 if ! combined_mgs_mds ; then
423 run_test 5b "Try to start a client with no MGS (should return errs)"
426 grep " $MOUNT " /etc/mtab &&
427 error false "unexpected entry in mtab before mount" && return 10
429 start_mds || error "MDS start failed"
430 start_ost || error "OST start failed"
431 local oldfs="${FSNAME}"
432 FSNAME="wrong.${FSNAME}"
433 mount_client $MOUNT || :
435 grep " $MOUNT " /etc/mtab &&
436 error "$MOUNT entry in mtab after failed mount"
438 cleanup_nocli || error "cleanup_nocli failed with $?"
440 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
443 grep " $MOUNT " /etc/mtab &&
444 error "unexpected entry in mtab before mount"
446 start_ost || error "OST start failed"
447 start_mds || error "MDS start failed"
448 stop_ost -f || error "Unable to stop OST1"
449 mount_client $MOUNT || error "mount_client $MOUNT failed"
450 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
451 cleanup_nocli || error "cleanup_nocli failed with $?"
452 ! grep " $MOUNT " /etc/mtab ||
453 error "$MOUNT entry in mtab after unmount"
455 run_test 5d "mount with ost down"
458 grep " $MOUNT " /etc/mtab &&
459 error false "unexpected entry in mtab before mount" && return 10
461 start_mds || error "MDS start failed"
462 start_ost || error "OST start failed"
464 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
465 do_facet client "$LCTL set_param fail_loc=0x80000506"
466 mount_client $MOUNT || echo "mount failed (not fatal)"
467 cleanup || error "cleanup failed with $?"
468 grep " $MOUNT " /etc/mtab &&
469 error "$MOUNT entry in mtab after unmount"
472 run_test 5e "delayed connect, don't crash (bug 10268)"
475 combined_mgs_mds && skip "needs separate mgs and mds"
477 grep " $MOUNT " /etc/mtab &&
478 error false "unexpected entry in mtab before mount" && return 10
481 start_ost || error "OST start failed"
482 mount_client $MOUNT &
484 echo client_mount pid is $pid
488 if ! ps -f -p $pid >/dev/null; then
491 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
492 error "mount returns $rc, expected to hang"
494 cleanup || error "cleanup failed with $?"
499 start_mds || error "start MDS failed"
501 # mount should succeed after start mds
503 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
504 cleanup || error "final call to cleanup failed with rc $?"
506 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
510 [ "$CLIENT_VERSION" -lt $(version_code 2.9.53) ] &&
511 skip "automount of debugfs missing before 2.9.53"
512 umount /sys/kernel/debug
513 $LCTL get_param -n devices | egrep -v "error" && \
514 error "lctl can't access debugfs data"
515 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
517 run_test 5g "handle missing debugfs"
523 #define OBD_FAIL_MDS_FS_SETUP 0x135
524 do_facet mds1 "$LCTL set_param fail_loc=0x80000135"
525 start_mdt 1 && error "start mdt should fail"
526 start_mdt 1 || error "start mdt failed"
527 client_up || error "client_up failed"
530 run_test 5h "start mdt failure at mdt_fs_setup()"
533 (( $MDS1_VERSION >= $(version_code 2.12.54) )) ||
534 skip "Need MDS version at least 2.12.54"
539 #define OBD_FAIL_QUOTA_INIT 0xA05
540 do_facet mds1 "$LCTL set_param fail_loc=0x80000A05"
541 start_mdt 1 && error "start mdt should fail"
542 start_mdt 1 || error "start mdt failed"
543 client_up || error "client_up failed"
546 run_test 5i "start mdt failure at mdt_quota_init()"
551 mount_client $MOUNT || error "mount_client $MOUNT failed"
552 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
553 cleanup || error "cleanup failed with rc $?"
555 run_test 6 "manual umount, then mount again"
560 cleanup_nocli || error "cleanup_nocli failed with $?"
562 run_test 7 "manual umount, then cleanup"
566 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
567 check_mount2 || error "check_mount2 failed"
568 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
569 cleanup || error "cleanup failed with rc $?"
571 run_test 8 "double mount setup"
574 start_ost || error "OST start failed"
576 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
577 error "do_facet ost1 set_param inode trace failed."
578 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
579 error "do_facet ost1 set_param debug mds ost failed."
581 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
582 if [ "$CHECK_PTLDEBUG" ] && { \
583 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
584 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
585 echo "lnet.debug success"
587 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
589 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
590 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
591 echo "lnet.subsystem_debug success"
593 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
595 stop_ost || error "Unable to stop OST1"
597 run_test 9 "test ptldebug and subsystem for mkfs"
602 if ! combined_mgs_mds; then
603 files=$(do_facet mgs "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
604 [ -z $files ] || echo "MGS $files is a broken symlink"
607 files=$(do_facet mds1 "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
608 [ -z $files ] || echo "MDS $files is a broken symlink"
610 files=$(do_facet ost1 "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
611 [ -z $files ] || echo "OSS $files is a broken symlink"
613 files=$(do_facet client "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
614 [ -z $files ] || echo "clients $files is a broken symlink"
616 cleanup || error "cleanup failed with rc $?"
618 run_test 10a "find lctl param broken symlinks"
621 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
622 # But with new MDS stack we don't care about the mode of local objects
623 # anymore, so this test is removed. See bug 22944 for more details.
627 if [ "$mds1_FSTYPE" != ldiskfs ]; then
628 skip "ldiskfs only test"
632 check_mount || error "check_mount failed"
633 cleanup || error "cleanup failed with rc $?"
635 echo "Remove mds config log"
636 if ! combined_mgs_mds ; then
640 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
641 $(mgsdevname) || return \$?" ||
642 error "do_facet mgs failed with $?"
644 if ! combined_mgs_mds ; then
648 start_ost || error "OST start failed"
649 start_mds && error "MDS start succeeded, but should fail"
652 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
655 if [ "$mds1_FSTYPE" != ldiskfs ]; then
656 skip "ldiskfs only test"
659 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
664 # check if current MDSSIZE is large enough
665 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
666 log "use MDSSIZE=$MDSSIZE"
668 # check if the global config has a large enough MDSSIZE
669 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
670 [ $STORED_MDSSIZE -ge $MIN ] &&
671 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
672 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
674 # check if the block device is large enough
675 is_blkdev $SINGLEMDS $MDSDEV $MIN
676 local large_enough=$?
677 if [ -n "$OK" ]; then
678 [ $large_enough -ne 0 ] && OK=""
680 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
681 log "use device $MDSDEV with MIN=$MIN"
684 # check if a loopback device has enough space for fs metadata (5%)
686 if [ -z "$OK" ]; then
687 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
688 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
689 awk '($1 != "Filesystem") { print $4 }')
690 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
691 OK=1 && myMDSSIZE=$MIN &&
692 log "use file $MDSDEV with MIN=$MIN"
695 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS"
697 echo "mount mds with large journal..."
699 local OLD_MDSSIZE=$MDSSIZE
703 echo "mount lustre system..."
705 check_mount || error "check_mount failed"
707 echo "check journal size..."
708 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
709 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
710 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
712 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
715 cleanup || error "cleanup failed with rc $?"
720 run_test 18 "check mkfs creates large journals"
723 start_mds || error "MDS start failed"
724 stop_mds || error "Unable to stop MDS"
726 run_test 19a "start/stop MDS without OSTs"
729 start_ost || error "Unable to start OST1"
730 stop_ost -f || error "Unable to stop OST1"
732 run_test 19b "start/stop OSTs without MDS"
735 # first format the ost/mdt
736 start_mds || error "MDS start failed"
737 start_ost || error "Unable to start OST1"
738 mount_client $MOUNT || error "mount_client $MOUNT failed"
739 check_mount || error "check_mount failed"
740 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
741 mount_client $MOUNT remount,ro || error "remount client with ro failed"
742 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
743 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
744 mount_client $MOUNT remount,rw || error "remount client with rw failed"
745 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
746 MCNT=$(grep -c $MOUNT' ' /etc/mtab)
747 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
749 stop_mds || error "Unable to stop MDS"
750 stop_ost || error "Unable to stop OST1"
752 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
755 start_mds || error "MDS start failed"
756 start_ost || error "unable to start OST1"
757 wait_osc_import_state mds ost FULL
758 stop_ost || error "unable to stop OST1"
759 stop_mds || error "unable to stop MDS"
761 run_test 21a "start mds before ost, stop ost first"
764 start_ost || error "unable to start OST1"
765 start_mds || error "MDS start failed"
766 wait_osc_import_state mds ost FULL
767 stop_mds || error "unable to stop MDS"
768 stop_ost || error "unable to stop OST1"
770 run_test 21b "start ost before mds, stop mds first"
773 start_ost || error "Unable to start OST1"
774 start_mds || error "MDS start failed"
775 start_ost2 || error "Unable to start OST2"
776 wait_osc_import_state mds ost2 FULL
777 stop_ost || error "Unable to stop OST1"
778 stop_ost2 || error "Unable to stop OST2"
779 stop_mds || error "Unable to stop MDS"
780 #writeconf to remove all ost2 traces for subsequent tests
781 writeconf_or_reformat
783 run_test 21c "start mds between two osts, stop mds last"
786 combined_mgs_mds && skip "need separate mgs device"
791 start_mgs || error "unable to start MGS"
792 start_ost || error "unable to start OST1"
793 start_ost2 || error "unable to start OST2"
794 start_mds || error "MDS start failed"
795 wait_osc_import_state mds ost2 FULL
797 local zkeeper=${KEEP_ZPOOL}
798 stack_trap "KEEP_ZPOOL=$zkeeper" EXIT
801 stop_ost || error "Unable to stop OST1"
802 stop_ost2 || error "Unable to stop OST2"
803 stop_mds || error "Unable to stop MDS"
805 #writeconf to remove all ost2 traces for subsequent tests
806 writeconf_or_reformat
807 KEEP_ZPOOL="${zkeeper}"
809 start_mgs || error "unable to start MGS"
811 run_test 21d "start mgs then ost and then mds"
814 MGSNID="$saved_mgsnid"
816 echo "stopping fs2mgs ..."
817 stop $fs2mgs -f || true
820 test_21e() { # LU-5863
821 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
822 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
823 skip_env "mixed loopback and real device not working"
826 local fs2mdsdev=$(mdsdevname 1_2)
827 local fs2ostdev=$(ostdevname 1_2)
828 local fs3ostdev=$(ostdevname 2_2)
830 local fs2mdsvdev=$(mdsvdevname 1_2)
831 local fs2ostvdev=$(ostvdevname 1_2)
832 local fs3ostvdev=$(ostvdevname 2_2)
834 # temporarily use fs3ost as fs2mgs
836 local fs2mgsdev=$fs3ostdev
837 local fs2mgsvdev=$fs3ostvdev
839 local fsname=test1234
841 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
842 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
843 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
844 error "start fs2mgs failed"
846 local saved_mgsnid="$MGSNID"
847 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
849 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
850 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
851 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
852 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
854 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
855 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
857 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
858 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
859 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
863 run_test 21e "separate MGS and MDS"
866 start_mds || error "MDS start failed"
868 echo "Client mount with ost in logs, but none running"
869 start_ost || error "unable to start OST1"
870 # wait until mds connected to ost and open client connection
871 wait_osc_import_state mds ost FULL
872 stop_ost || error "unable to stop OST1"
873 mount_client $MOUNT || error "mount_client $MOUNT failed"
874 # check_mount will block trying to contact ost
875 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
876 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
877 umount_client $MOUNT -f
880 echo "Client mount with a running ost"
881 start_ost || error "unable to start OST1"
883 # if gss enabled, wait full time to let connection from
884 # mds to ost be established, due to the mismatch between
885 # initial connect timeout and gss context negotiation timeout.
886 # This perhaps could be remove after AT landed.
887 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
888 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
890 mount_client $MOUNT || error "mount_client $MOUNT failed"
891 wait_osc_import_state mds ost FULL
892 wait_osc_import_ready client ost
893 check_mount || error "check_mount failed"
896 cleanup || error "cleanup failed with rc $?"
898 run_test 22 "start a client before osts (should return errs)"
900 test_23a() { # was test_23
903 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
904 # force down client so that recovering mds waits for reconnect
905 local running=$(grep -c $MOUNT /proc/mounts) || true
906 if [ $running -ne 0 ]; then
907 echo "Stopping client $MOUNT (opts: -f)"
911 # enter recovery on failed mds
912 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
913 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
914 # try to start a new client
915 mount_client $MOUNT &
917 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
918 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
919 grep -v grep | awk '{print $2}')
920 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
922 ps --ppid $MOUNT_LUSTRE_PID
923 echo "waiting for mount to finish"
925 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
926 # SIGTERM works but it does not spread to offspring processses
927 kill -s TERM $MOUNT_PID
928 kill -s TERM $MOUNT_LUSTRE_PID
929 # we can not wait $MOUNT_PID because it is not a child of this shell
935 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
937 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
938 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
941 [ -z "$PID1" -a -z "$PID2" ] && break
942 echo "waiting for mount to finish ... "
943 WAIT=$(( WAIT + sleep))
945 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
946 error "MOUNT_PID $MOUNT_PID and "\
947 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
950 cleanup || error "cleanup failed with rc $?"
952 run_test 23a "interrupt client during recovery mount delay"
954 test_23b() { # was test_23
955 start_mds || error "MDS start failed"
956 start_ost || error "Unable to start OST1"
957 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
958 $LCTL set_param fail_loc=0x80000313
960 cleanup || error "cleanup failed with rc $?"
962 run_test 23b "Simulate -EINTR during mount"
965 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
967 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
968 is_blkdev $SINGLEMDS $MDSDEV &&
969 skip_env "mixed loopback and real device not working"
972 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
974 local fs2mdsdev=$(mdsdevname 1_2)
975 local fs2ostdev=$(ostdevname 1_2)
976 local fs2mdsvdev=$(mdsvdevname 1_2)
977 local fs2ostvdev=$(ostvdevname 1_2)
980 # LU-9733 test fsname started with numbers as well
981 local FSNAME2=969362ae
983 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
984 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
986 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
987 --reformat $fs2ostdev $fs2ostvdev || exit 10
990 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
991 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
992 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
993 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
995 # LU-9733 test fsname started with numbers
996 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
997 changelog_register -n) ||
998 error "register changelog failed"
1000 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
1001 changelog_deregister $cl_user ||
1002 error "deregister changelog failed"
1004 check_mount || error "check_mount failed"
1005 # files written on 1 should not show up on 2
1006 cp /etc/passwd $DIR/$tfile
1008 [ -e $MOUNT2/$tfile ] && error "File bleed"
1011 cp /etc/passwd $MOUNT2/$tfile ||
1012 error "cp /etc/passwd $MOUNT2/$tfile failed"
1013 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
1014 # 2 is actually mounted
1015 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
1017 facet_failover fs2mds
1018 facet_failover fs2ost
1020 umount_client $MOUNT
1021 # the MDS must remain up until last MDT
1023 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1024 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1025 [ -z "$MDS" ] && error "No MDT"
1027 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1029 run_test 24a "Multiple MDTs on a single node"
1032 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1034 skip "needs combined MGT and MDT device"
1036 if [ -z "$fs2mds_DEV" ]; then
1037 local dev=${SINGLEMDS}_dev
1038 local MDSDEV=${!dev}
1039 is_blkdev $SINGLEMDS $MDSDEV &&
1040 skip_env "mixed loopback and real device not working"
1043 local fs2mdsdev=$(mdsdevname 1_2)
1044 local fs2mdsvdev=$(mdsvdevname 1_2)
1046 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1047 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1049 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && {
1051 error "start MDS should fail"
1054 cleanup || error "cleanup failed with rc $?"
1056 run_test 24b "Multiple MGSs on a single node (should return err)"
1060 check_mount || error "check_mount failed"
1061 local MODULES=$($LCTL modules | awk '{ print $2 }')
1062 rmmod $MODULES 2>/dev/null || true
1063 cleanup || error "cleanup failed with $?"
1065 run_test 25 "Verify modules are referenced"
1069 # we need modules before mount for sysctl, so make sure...
1070 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1071 #define OBD_FAIL_MDS_FS_SETUP 0x135
1072 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1073 start_mds && error "MDS started but should not have started"
1074 $LCTL get_param -n devices
1075 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1076 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1077 # start mds to drop writeconf setting
1078 start_mds || error "Unable to start MDS"
1079 stop_mds || error "Unable to stop MDS"
1080 unload_modules_conf || error "unload_modules_conf failed with $?"
1082 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1086 start_ost || error "Unable to start OST1"
1087 start_mds || error "Unable to start MDS"
1088 echo "Requeue thread should have started: "
1089 ps -e | grep ll_cfg_requeue
1090 set_persistent_param_and_check ost1 \
1091 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1092 "$FSNAME-OST0000.ost.client_cache_seconds"
1093 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1095 run_test 27a "Reacquire MGS lock if OST started first"
1100 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1101 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1103 facet_failover $SINGLEMDS
1104 set_persistent_param_and_check $SINGLEMDS \
1105 "mdt.$device.identity_acquire_expire" \
1106 "$device.mdt.identity_acquire_expire"
1107 set_persistent_param_and_check client \
1108 "mdc.$device-mdc-*.max_rpcs_in_flight" \
1109 "$device.mdc.max_rpcs_in_flight"
1111 cleanup || error "cleanup failed with $?"
1113 run_test 27b "Reacquire MGS lock after failover"
1115 test_28A() { # was test_28
1118 local TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1119 local PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1120 local orig=$($LCTL get_param -n $TEST)
1121 local max=$($LCTL get_param -n \
1122 llite.$FSNAME-*.max_read_ahead_per_file_mb)
1124 orig=${orig%%.[0-9]*}
1126 echo "ORIG:$orig MAX:$max"
1127 [[ $max -le $orig ]] && orig=$((max - 3))
1128 echo "ORIG:$orig MAX:$max"
1130 local final=$((orig + 1))
1132 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1133 final=$((final + 1))
1134 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1135 umount_client $MOUNT || error "umount_client $MOUNT failed"
1136 mount_client $MOUNT || error "mount_client $MOUNT failed"
1138 local result=$($LCTL get_param -n $TEST)
1140 if [ $result -ne $final ]; then
1141 error "New config not seen: wanted $final got $result"
1143 echo "New config success: got $result"
1145 set_persistent_param_and_check client "$TEST" "$PARAM" $orig
1146 cleanup || error "cleanup failed with rc $?"
1148 run_test 28A "permanent parameter setting"
1150 test_28a() { # LU-4221
1151 [[ "$OST1_VERSION" -ge $(version_code 2.5.52) ]] ||
1152 skip "Need OST version at least 2.5.52"
1153 [ "$ost1_FSTYPE" = zfs ] &&
1154 skip "LU-4221: no such proc params for ZFS OSTs"
1161 local device="$FSNAME-OST0000"
1165 # In this test we will set three kinds of proc parameters with
1166 # lctl set_param -P or lctl conf_param:
1167 # 1. non-symlink ones in the OFD
1168 # 2. non-symlink ones in the OSD
1171 # prepare a non-symlink parameter in the OFD
1172 name="client_cache_seconds"
1173 param="$device.ost.$name"
1174 cmd="obdfilter.$device.$name"
1176 # permanently setting the parameter in the OFD
1177 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1179 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1180 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1183 # prepare a non-symlink parameter in the OSD
1185 param="$device.osd.$name"
1186 cmd="osd-*.$device.$name"
1188 # conf_param the parameter in the OSD
1189 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1190 new=$(((old + 1) % 2))
1191 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1192 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1194 cleanup || error "cleanup failed with $?"
1196 run_test 28a "set symlink parameters permanently with lctl"
1199 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
1200 setup_noconfig > /dev/null 2>&1
1201 start_ost2 || error "Unable to start OST2"
1204 local PARAM="$FSNAME-OST0001.osc.active"
1205 # With lctl set_param -P the value $PROC_ACT will be sent to
1206 # all nodes. The [!M] filter out the ability to set active
1207 # on the MDS servers which is tested with wait_osp_* below.
1208 # For ost_server_uuid that only exist on client so filtering
1210 local PROC_ACT="os[cp].$FSNAME-OST0001-osc-[^M]*.active"
1211 local PROC_UUID="os[cp].$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1213 ACTV=$($LCTL get_param -n $PROC_ACT)
1215 set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
1216 # also check ost_server_uuid status
1217 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1218 if [ -z "$RESULT" ]; then
1219 error "Client not deactivated: $($LCTL get_param \
1222 echo "Live client success: got $RESULT"
1226 wait_osp_active ost ${FSNAME}-OST0001 1 0
1228 # test new client starts deactivated
1229 umount_client $MOUNT || error "umount_client $MOUNT failed"
1230 mount_client $MOUNT || error "mount_client $MOUNT failed"
1232 # the 2nd and 3rd field of ost_server_uuid do not update at the same
1233 # time when using lctl set_param -P
1234 wait_update_facet client \
1235 "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'" \
1237 error "New client start active: $($LCTL get_param -n $PROC_UUID)"
1239 echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
1241 # make sure it reactivates
1242 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1244 umount_client $MOUNT
1245 stop_ost2 || error "Unable to stop OST2"
1246 cleanup_nocli || error "cleanup_nocli failed with $?"
1247 #writeconf to remove all ost2 traces for subsequent tests
1248 writeconf_or_reformat
1250 run_test 29 "permanently remove an OST"
1255 echo Big config llog
1256 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1257 ORIG=$($LCTL get_param -n $TEST)
1258 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1259 for i in ${LIST[@]}; do
1260 set_persistent_param_and_check client "$TEST" \
1261 "$FSNAME.llite.max_read_ahead_whole_mb" $i
1263 # make sure client restart still works
1264 umount_client $MOUNT
1265 mount_client $MOUNT || error "mount_client $MOUNT failed"
1266 [ "$($LCTL get_param -n $TEST)" -ne "$i" ] &&
1267 error "Param didn't stick across restart $($TEST) != $i"
1270 echo Erase parameter setting
1271 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1272 do_facet mgs "$PERM_CMD -d $TEST" ||
1273 error "Erase param $TEST failed"
1275 do_facet mgs "$PERM_CMD \
1276 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1277 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1279 umount_client $MOUNT
1280 mount_client $MOUNT || error "mount_client $MOUNT failed"
1281 FINAL=$($LCTL get_param -n $TEST)
1282 echo "deleted (default) value=$FINAL, orig=$ORIG"
1283 ORIG=${ORIG%%.[0-9]*}
1284 FINAL=${FINAL%%.[0-9]*}
1285 # assumes this parameter started at the default value
1286 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1288 cleanup || error "cleanup failed with rc $?"
1290 run_test 30a "Big config llog and permanent parameter deletion"
1295 local orignids=$($LCTL get_param -n \
1296 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1298 local orignidcount=$(echo "$orignids" | wc -w)
1300 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1301 # numerical part of it. Hopefully that's not already a failover address
1303 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1305 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1306 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1307 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1308 echo "Using fake nid $NEW"
1310 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1311 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1312 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1313 PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
1314 echo "Setting $PARAM from $TEST to $NEW"
1315 do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
1316 error "$PERM_CMD $PARAM failed"
1318 PARAM="$FSNAME-OST0000.failover.node"
1319 echo "Setting $PARAM from $TEST to $NEW"
1320 do_facet mgs "$PERM_CMD $PARAM='$NEW'" ||
1321 error "$PARAM $PARAM failed"
1323 wait_update_facet client "$TEST" "$NEW" ||
1324 error "check $PARAM failed!"
1326 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1328 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1329 echo "should have $((orignidcount + 1)) entries \
1330 in failover nids string, have $NIDCOUNT"
1331 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1332 error "Failover nid not added"
1334 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1335 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1337 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1338 error "$PERM_CMD delete failed"
1340 umount_client $MOUNT
1341 mount_client $MOUNT || error "mount_client $MOUNT failed"
1343 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1345 NIDCOUNT=$(echo "$NIDS" | wc -w)
1346 echo "only $orignidcount final entries should remain \
1347 in failover nids string, have $NIDCOUNT"
1348 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1350 cleanup || error "cleanup failed with rc $?"
1352 run_test 30b "Remove failover nids"
1354 test_31() { # bug 10734
1355 # ipaddr must not exist
1356 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1357 cleanup || error "cleanup failed with rc $?"
1359 run_test 31 "Connect to non-existent node (shouldn't crash)"
1363 T32_BLIMIT=40960 # Kbytes
1367 # This is not really a test but a tool to create new disk
1368 # image tarballs for the upgrade tests.
1370 # Disk image tarballs should be created on single-node
1371 # clusters by running this test with default configurations
1372 # plus a few mandatory environment settings that are verified
1373 # at the beginning of the test.
1375 test_32newtarball() {
1379 local tmp=$TMP/t32_image_create
1384 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1385 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1386 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1387 "MDSDEV1=<nonexistent_file>" \
1388 "MDSDEV2=<nonexistent_file>" \
1389 "(or MDSDEV, in the case of b1_8)" \
1390 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1394 echo "Found stale $tmp"
1398 mkdir $tmp/src || return 1
1399 tar cf - -C $src . | tar xf - -C $tmp/src
1400 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1401 count=$(($T32_BLIMIT / 1024 / 4))
1402 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1404 # format ost with comma-separated NIDs to verify LU-4460
1405 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1406 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1410 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1411 $LFS quotacheck -ug /mnt/$FSNAME
1412 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1415 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1417 if [[ $MDSCOUNT -ge 2 ]]; then
1418 remote_dir=/mnt/$FSNAME/remote_dir
1419 $LFS mkdir -i 1 $remote_dir
1420 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1422 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1423 striped_dir=/mnt/$FSNAME/striped_dir_old
1424 $LFS mkdir -i 1 -c 2 $striped_dir
1425 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1431 mkdir $tmp/img || return 1
1435 pushd_dir=/mnt/$FSNAME
1436 if [[ $MDSCOUNT -ge 2 ]]; then
1437 pushd_dir=$remote_dir
1438 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1440 ls -Rni --time-style=+%s >$tmp/img/list2
1446 ls -Rni --time-style=+%s >$tmp/img/list
1447 find ! -name .lustre -type f -exec sha1sum {} \; |
1448 sort -k 2 >$tmp/img/sha1sums
1450 $LCTL get_param -n version | head -n 1 |
1451 sed -e 's/^lustre: *//' >$tmp/img/commit
1453 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1454 $LFS quotaon -ug /mnt/$FSNAME
1455 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1456 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1457 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1458 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1459 | tr -d "*" > $tmp/img/bspace
1460 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1461 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1462 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1463 | tr -d "*" > $tmp/img/ispace
1464 echo $T32_BLIMIT > $tmp/img/blimit
1465 echo $T32_ILIMIT > $tmp/img/ilimit
1467 $MULTIOP /mnt/$FSNAME/orph_file Ouw_c&
1471 debugfs -R "ls /PENDING" ${MDSDEV1:-$MDSDEV}
1472 cp ${MDSDEV1:-$MDSDEV} $tmp/img
1480 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1483 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1484 echo "Data verification failed"
1487 uname -r >$tmp/img/kernel
1488 uname -m >$tmp/img/arch
1490 for num in $(seq 2 $MDSCOUNT); do
1491 local devname=$(mdsdevname $num)
1493 [[ $(facet_fstype $facet) != zfs ]] ||
1494 devname=$(mdsvdevname $num)
1495 mv $devname $tmp/img
1497 mv $OSTDEV1 $tmp/img
1499 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1500 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1503 tar cjvf $dst/disk$version-"$mds1_FSTYPE".tar.bz2 -S *
1508 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1511 # The list of applicable tarballs is returned via the caller's
1512 # variable "tarballs".
1515 [ "$CLIENTONLY" ] && skip "Client-only testing"
1517 local node=$(facet_active_host $SINGLEMDS)
1518 local r="do_node $node"
1520 ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
1522 local IMGTYPE="$mds1_FSTYPE"
1524 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1525 -name \'disk*-$IMGTYPE.tar.bz2\')
1527 [ -z "$tarballs" ] && skip "No applicable tarballs found"
1530 t32_test_cleanup() {
1532 local facet=$SINGLEMDS
1535 if $shall_cleanup_lustre; then
1536 umount $tmp/mnt/lustre || rc=$?
1538 if $shall_cleanup_mdt; then
1539 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1541 if $shall_cleanup_mdt1; then
1542 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1544 if $shall_cleanup_ost; then
1545 $r $UMOUNT $tmp/mnt/ost || rc=$?
1550 if [[ "$mds1_FSTYPE" == zfs ]]; then
1552 local poolname_list="t32fs-mdt1 t32fs-ost1"
1554 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1556 for poolname in $poolname_list; do
1557 destroy_zpool $facet $poolname
1560 combined_mgs_mds || start_mgs || rc=$?
1564 t32_bits_per_long() {
1566 # Yes, this is not meant to be perfect.
1576 t32_reload_modules() {
1578 local all_removed=false
1581 [ "$mds1_FSTYPE" == zfs ] && do_rpc_nodes $node "service zed stop"
1583 while ((i < 20)); do
1584 echo "Unloading modules on $node: Attempt $i"
1585 do_rpc_nodes $node $LUSTRE_RMMOD "$mds1_FSTYPE" &&
1587 do_rpc_nodes $node check_mem_leak || return 1
1588 if $all_removed; then
1589 do_rpc_nodes $node load_modules
1592 if [ "$mds1_FSTYPE" == zfs ]; then
1593 do_rpc_nodes $node "$ZPOOL status -v"
1598 echo "Unloading modules on $node: Given up"
1602 t32_wait_til_devices_gone() {
1608 echo wait for devices to go
1609 while ((i < 20)); do
1610 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1611 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1612 ((devices == 0 && loops == 0)) && return 0
1616 echo "waiting for dev on $node: dev $devices loop $loops given up"
1617 do_rpc_nodes $node "losetup -a"
1618 do_rpc_nodes $node "$LCTL device_list"
1622 t32_verify_quota() {
1629 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1630 # lustre will estimate the object count usage. This fails quota
1631 # verification in 32b. The object quota usage should be accurate after
1632 # zfs-0.7.0 is released.
1633 [ "$mds1_FSTYPE" == zfs ] && {
1634 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1636 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1637 echo "Skip quota verify for zfs: $zfs_version"
1642 $LFS quota -u $T32_QID -v $mnt
1644 qval=$($LFS quota -v -u $T32_QID $mnt |
1645 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1646 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1648 [ $qval -eq $img_bspace ] || {
1649 echo "bspace, act:$qval, exp:$img_bspace"
1653 qval=$($LFS quota -v -u $T32_QID $mnt |
1654 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1655 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1657 [ $qval -eq $img_ispace ] || {
1658 echo "ispace, act:$qval, exp:$img_ispace"
1662 qval=$($LFS quota -v -u $T32_QID $mnt |
1663 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1664 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1666 [ $qval -eq $img_blimit ] || {
1667 echo "blimit, act:$qval, exp:$img_blimit"
1671 qval=$($LFS quota -v -u $T32_QID $mnt |
1672 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1673 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1675 [ $qval -eq $img_ilimit ] || {
1676 echo "ilimit, act:$qval, exp:$img_ilimit"
1680 set_persistent_param_and_check $facet \
1681 "osd-$mds1_FSTYPE.$fsname-MDT0000.quota_slave.enabled" \
1682 "$fsname.quota.mdt" ug
1684 set_persistent_param_and_check $facet \
1685 "osd-$mds1_FSTYPE.$fsname-OST0000.quota_slave.enabled" \
1686 "$fsname.quota.ost" ug
1689 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1690 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1691 echo "Write succeed, but expect -EDQUOT"
1694 rm -f $mnt/t32_qf_new
1696 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1698 echo "Create succeed, but expect -EDQUOT"
1701 unlinkmany $mnt/t32_qf_ $img_ilimit
1709 local dne_upgrade=${dne_upgrade:-"no"}
1710 local dom_upgrade=${dom_upgrade:-"no"}
1711 local project_upgrade=${project_upgrade:-"no"}
1712 local ff_convert=${ff_convert:-"no"}
1713 local shall_cleanup_mdt=false
1714 local shall_cleanup_mdt1=false
1715 local shall_cleanup_ost=false
1716 local shall_cleanup_lustre=false
1717 local mdt2_is_available=false
1718 local node=$(facet_active_host $SINGLEMDS)
1719 local r="do_node $node"
1735 local mdt_dev=$tmp/mdt
1736 local mdt2_dev=$tmp/mdt2
1737 local ost_dev=$tmp/ost
1742 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1743 trap 'trap - RETURN; t32_test_cleanup' RETURN
1746 nid=$($r $LCTL list_nids | head -1)
1748 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1749 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1750 $r tar xjvf $tarball -S -C $tmp || {
1751 error_noexit "Unpacking the disk image tarball"
1754 img_commit=$($r cat $tmp/commit)
1755 img_kernel=$($r cat $tmp/kernel)
1756 img_arch=$($r cat $tmp/arch)
1757 img_bspace=$($r cat $tmp/bspace)
1758 img_ispace=$($r cat $tmp/ispace)
1760 # older images did not have "blimit" and "ilimit" files
1761 # use old values for T32_BLIMIT and T32_ILIMIT
1762 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1764 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1767 echo "Upgrading from $(basename $tarball), created with:"
1768 echo " Commit: $img_commit"
1769 echo " Kernel: $img_kernel"
1770 echo " Arch: $img_arch"
1771 echo "OST version: $(lustre_build_version ost1)"
1773 # The conversion can be made only when both of the following
1774 # conditions are satisfied:
1775 # - ost device img version < 2.3.64
1776 # - ost server version >= 2.5
1777 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1778 "$OST1_VERSION" -lt $(version_code 2.5.0) ] &&
1781 ! $r test -f $mdt2_dev || mdt2_is_available=true
1783 if [[ "$mds1_FSTYPE" == zfs ]]; then
1786 local poolname_list="t32fs-mdt1 t32fs-ost1"
1788 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1790 for poolname in $poolname_list; do
1792 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1793 $ZPOOL import -f -d $tmp $poolname"
1796 # upgrade zpool to latest supported features, including
1797 # dnode quota accounting in 0.7.0
1798 $r "$ZPOOL upgrade -a"
1800 mdt_dev=t32fs-mdt1/mdt1
1801 ost_dev=t32fs-ost1/ost1
1802 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1803 wait_update_facet $SINGLEMDS "$ZPOOL list |
1804 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1805 error_noexit "import zfs pool failed"
1808 elif [ "$project_upgrade" != "no" ]; then
1809 ! $r tune2fs -O project $mdt_dev &&
1810 error_noexit "enable project on mdt0 failed" &&
1812 $mdt2_is_available && ! $r tune2fs "-O project" $mdt2_dev &&
1813 error_noexit "enable project on mdt failed" &&
1815 ! $r tune2fs -O project $ost_dev &&
1816 error_noexit "enable project on mdt failed" &&
1820 $r $LCTL set_param debug="$PTLDEBUG"
1822 $r $TUNEFS --dryrun $mdt_dev || {
1824 error_noexit "tunefs.lustre before mounting the MDT"
1828 if $mdt2_is_available; then
1829 $r $TUNEFS --dryrun $mdt2_dev || {
1831 error_noexit "tunefs.lustre before mounting the MDT"
1836 if [ "$writeconf" ]; then
1838 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1840 $r $TUNEFS --quota $mdt_dev || {
1842 error_noexit "Enable mdt quota feature"
1845 if $mdt2_is_available; then
1846 $r $TUNEFS --quota $mdt2_dev || {
1848 error_noexit "Enable mdt quota feature"
1854 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1855 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
1856 skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
1857 "(Need MGS version at least 2.3.59)"
1859 local osthost=$(facet_active_host ost1)
1860 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1863 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1866 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1867 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1868 $r $LCTL replace_nids $fsname-MDT0000 $nid
1869 $r $UMOUNT $tmp/mnt/mdt
1872 mopts=exclude=$fsname-OST0000
1873 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1878 t32_wait_til_devices_gone $node
1880 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1882 error_noexit "Mounting the MDT"
1885 shall_cleanup_mdt=true
1887 if $mdt2_is_available; then
1888 mopts=mgsnode=$nid,$mopts
1889 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1891 error_noexit "Mounting the MDT"
1895 echo "mount new MDT....$mdt2_dev"
1896 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1897 error_noexit "enable remote dir create failed"
1899 shall_cleanup_mdt1=true
1900 elif [ "$dne_upgrade" != "no" ]; then
1901 local fs2mdsdev=$(mdsdevname 1_2)
1902 local fs2mdsvdev=$(mdsvdevname 1_2)
1904 echo "mkfs new MDT on ${fs2mdsdev}...."
1905 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1906 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1909 add $SINGLEMDS $(mds2failover_HOST="" \
1910 mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1911 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1912 error_noexit "Mkfs new MDT failed"
1916 [[ "$mds1_FSTYPE" != zfs ]] || import_zpool mds1
1918 $r $TUNEFS --dryrun $fs2mdsdev || {
1919 error_noexit "tunefs.lustre before mounting the MDT"
1923 echo "mount new MDT....$fs2mdsdev"
1924 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1925 error_noexit "mount mdt1 failed"
1929 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1930 error_noexit "enable remote dir create failed"
1932 shall_cleanup_mdt1=true
1935 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1936 error_noexit "Getting MDT UUID"
1939 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1940 error_noexit "Unexpected MDT UUID: \"$uuid\""
1944 $r $TUNEFS --dryrun $ost_dev || {
1945 error_noexit "tunefs.lustre before mounting the OST"
1948 if [ "$writeconf" ]; then
1949 mopts=mgsnode=$nid,$writeconf
1950 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1952 $r $TUNEFS --quota $ost_dev || {
1954 error_noexit "Enable ost quota feature"
1960 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1965 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1966 error_noexit "Mounting the OST"
1969 shall_cleanup_ost=true
1971 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1972 error_noexit "Getting OST UUID"
1975 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1976 error_noexit "Unexpected OST UUID: \"$uuid\""
1980 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1981 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
1982 error_noexit "Setting OST \"failover.node\""
1985 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
1986 error_noexit "Setting MDT \"failover.node\""
1989 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
1990 error_noexit "Setting \"max_dirty_mb\""
1993 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
1994 error_noexit "Setting \"max_rpcs_in_flight\""
1997 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
1998 error_noexit "Setting \"lov.stripesize\""
2001 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
2002 error_noexit "Setting \"mdd.atime_diff\""
2006 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
2007 error_noexit "Setting OST \"failover.node\""
2011 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
2012 error_noexit "Setting MDT \"failover.node\""
2016 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
2017 error_noexit "Setting \"max_dirty_mb\""
2020 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
2021 error_noexit "Setting \"max_rpcs_in_flight\""
2024 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
2025 error_noexit "Setting \"lov.stripesize\""
2028 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
2029 error_noexit "Setting \"mdd.atime_diff\""
2034 $r $LCTL pool_new $fsname.interop || {
2035 error_noexit "Setting \"interop\""
2039 if [ "$ff_convert" != "no" -a "$ost1_FSTYPE" == ldiskfs ]; then
2040 $r $LCTL lfsck_start -M $fsname-OST0000 || {
2041 error_noexit "Start OI scrub on OST0"
2045 # The oi_scrub should be on ost1, but for test_32(),
2046 # all on the SINGLEMDS.
2047 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
2048 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2049 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
2050 error_noexit "Failed to get the expected 'completed'"
2054 local UPDATED=$($r $LCTL get_param -n \
2055 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2056 awk '/^updated/ { print $2 }')
2057 [ $UPDATED -ge 1 ] || {
2058 error_noexit "Only $UPDATED objects have been converted"
2063 if [ "$dne_upgrade" != "no" ]; then
2064 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2065 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
2066 error_noexit "Setting MDT1 \"failover.node\""
2070 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
2071 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2074 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
2075 error_noexit "Setting MDT1 \"lov.stripesize\""
2079 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
2080 error_noexit "Setting MDT1 \"failover.node\""
2083 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2084 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2087 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2088 error_noexit "Setting MDT1 \"lov.stripesize\""
2094 if [ "$writeconf" ]; then
2095 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2096 error_noexit "Mounting the client"
2100 shall_cleanup_lustre=true
2101 $r $LCTL set_param debug="$PTLDEBUG"
2103 t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2104 error_noexit "verify quota failed"
2108 if $r test -f $tmp/list; then
2110 # There is not a Test Framework API to copy files to or
2111 # from a remote node.
2113 # LU-2393 - do both sorts on same node to ensure locale
2115 local list_file=$tmp/list
2117 if $mdt2_is_available; then
2118 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2119 $r test -f $tmp/list2; then
2120 list_file=$tmp/list2
2121 pushd $tmp/mnt/lustre/striped_dir_old
2123 pushd $tmp/mnt/lustre/remote_dir
2126 pushd $tmp/mnt/lustre
2128 $r cat $list_file | sort -k 6 >$tmp/list.orig
2129 ls -Rni --time-style=+%s | sort -k 6 |
2130 sed 's/\. / /' >$tmp/list || {
2136 # 32-bit and 64-bit clients use different algorithms to
2137 # convert FIDs into inode numbers. Hence, remove the
2138 # inode numbers from the lists, if the original list was
2139 # created on an architecture with different number of
2142 if [ $(t32_bits_per_long $(uname -m)) != \
2143 $(t32_bits_per_long $img_arch) ]; then
2144 echo "Different number of bits per \"long\"" \
2145 "from the disk image"
2146 for list in list.orig list; do
2147 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2151 if ! diff -ub $tmp/list.orig $tmp/list; then
2152 error_noexit "list verification failed"
2156 echo "list verification skipped"
2159 if [ "$dom_upgrade" != "no" ]; then
2160 echo "Check DoM file can be created"
2161 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2162 error_noexit "Verify DoM creation"
2165 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2166 error_noexit "Verify a DoM file"
2169 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2170 count=1 conv=fsync || {
2171 error_noexit "Cannot write to DoM file"
2174 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2175 error_noexit "DoM: bad size after write"
2178 rm $tmp/mnt/lustre/dom
2180 set_persistent_param_and_check mds \
2181 "lod.*MDT0000*.dom_stripesize" \
2182 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2183 error_noexit "Changing \"dom_stripesize\""
2188 if [ "$dne_upgrade" != "no" ]; then
2189 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2190 error_noexit "set striped dir failed"
2194 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2196 pushd $tmp/mnt/lustre
2197 tar -c --exclude=./striped_dir \
2198 --exclude=./striped_dir_old \
2199 --exclude=./remote_dir -f - .|
2200 tar -xvf - -C striped_dir 1>/dev/null || {
2201 error_noexit "cp to striped dir failed"
2207 # If it is upgrade from DNE (2.5), then rename the remote dir,
2208 # which is created in 2.5 to striped dir.
2209 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2210 stripe_index=$($LFS getdirstripe -i \
2211 $tmp/mnt/lustre/remote_dir)
2213 [[ $stripe_index -eq 1 ]] || {
2214 error_noexit "get index \"$stripe_index\"" \
2215 "from remote dir failed"
2218 mv $tmp/mnt/lustre/remote_dir \
2219 $tmp/mnt/lustre/striped_dir/ || {
2220 error_noexit "mv remote dir failed"
2225 # If it is upgraded from DNE (2.7), then move the striped dir
2226 # which was created in 2.7 to the new striped dir.
2227 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2228 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2229 stripe_count=$($LFS getdirstripe -c \
2230 $tmp/mnt/lustre/striped_dir_old)
2231 [[ $stripe_count -eq 2 ]] || {
2232 error_noexit "get count $stripe_count" \
2233 "from striped dir failed"
2236 mv $tmp/mnt/lustre/striped_dir_old \
2237 $tmp/mnt/lustre/striped_dir/ || {
2238 error_noexit "mv striped dir failed"
2244 $r $LCTL set_param -n osd*.*.force_sync=1
2245 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2246 error_noexit "dd failed"
2249 rm -rf $tmp/mnt/lustre/tmp_file || {
2250 error_noexit "rm failed"
2254 if $r test -f $tmp/sha1sums; then
2255 # LU-2393 - do both sorts on same node to ensure locale
2257 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2258 if [ "$dne_upgrade" != "no" ]; then
2259 pushd $tmp/mnt/lustre/striped_dir
2261 pushd $tmp/mnt/lustre
2264 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2265 ! -name .lustre -type f -exec sha1sum {} \; |
2266 sort -k 2 >$tmp/sha1sums || {
2268 error_noexit "sha1sum"
2272 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2273 error_noexit "sha1sum verification failed"
2277 # if upgrade from DNE(2.5), then check remote directory
2278 # if upgrade from DNE(2.7), then check striped directory
2279 if $mdt2_is_available &&
2280 [[ "$dne_upgrade" != "no" ]]; then
2281 local new_dir="$tmp/mnt/lustre/striped_dir"
2282 local striped_dir_old="$new_dir/striped_dir_old"
2284 local dir_list="$new_dir/remote_dir"
2285 [[ ! -d $triped_dir_old ]] ||
2286 dir_list+=" $striped_dir_old"
2288 for dir in $dir_list; do
2290 find ! -name .lustre -type f \
2291 -exec sha1sum {} \; |
2292 sort -k 2 >$tmp/sha1sums || {
2294 error_noexit "sha1sum"
2298 if ! diff -ub $tmp/sha1sums.orig \
2300 error_noexit "sha1sum $dir" \
2307 echo "sha1sum verification skipped"
2310 if [ "$dne_upgrade" != "no" ]; then
2311 rm -rf $tmp/mnt/lustre/striped_dir || {
2312 error_noexit "remove remote dir failed"
2317 # migrate files/dirs to remote MDT, then move them back
2318 if [ "$MDS1_VERSION" -ge $(version_code 2.7.50) -a \
2319 $dne_upgrade != "no" ]; then
2320 $r $LCTL set_param -n \
2321 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2323 echo "test migration"
2324 pushd $tmp/mnt/lustre
2325 for dir in $(find ! -name .lustre ! -name . -type d); do
2326 mdt_index=$($LFS getdirstripe -i $dir)
2327 stripe_cnt=$($LFS getdirstripe -c $dir)
2328 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2329 $LFS migrate -m 1 $dir || {
2331 error_noexit "migrate MDT1 failed"
2337 for dir in $(find ! -name . ! -name .lustre -type d); do
2338 mdt_index=$($LFS getdirstripe -i $dir)
2339 stripe_cnt=$($LFS getdirstripe -c $dir)
2340 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2341 $LFS migrate -m 0 $dir || {
2343 error_noexit "migrate MDT0 failed"
2352 # When adding new data verification tests, please check for
2353 # the presence of the required reference files first, like
2354 # the "sha1sums" and "list" tests above, to avoid the need to
2355 # regenerate every image for each test addition.
2358 nrpcs_orig=$($LCTL get_param \
2359 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2360 error_noexit "Getting \"max_rpcs_in_flight\""
2363 nrpcs=$((nrpcs_orig + 5))
2365 set_persistent_param_and_check client \
2366 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
2367 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
2368 error_noexit "Changing \"max_rpcs_in_flight\""
2372 umount $tmp/mnt/lustre || {
2373 error_noexit "Unmounting the client"
2376 shall_cleanup_lustre=false
2378 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2379 error_noexit "Mounting the client"
2383 if [ "$mds1_FSTYPE" == ldiskfs -a \
2384 "$project_upgrade" != "no" ]; then
2385 ! $LFS project -d -p 1 $tmp/mnt/lustre/* &&
2386 error_noexit "set project failed" &&
2390 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) == 0 ]] ||
2391 error "MDD orphan cleanup thread not quit"
2393 umount $tmp/mnt/lustre || {
2394 error_noexit "Unmounting the client"
2398 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2399 $r $UMOUNT $tmp/mnt/mdt1 || {
2400 error_noexit "Unmounting the MDT2"
2403 if [[ "$mds1_FSTYPE" == zfs ]]; then
2404 $r "$ZPOOL export t32fs-mdt2"
2406 shall_cleanup_mdt1=false
2409 $r $UMOUNT $tmp/mnt/mdt || {
2410 error_noexit "Unmounting the MDT"
2413 if [[ "$mds1_FSTYPE" == zfs ]]; then
2414 $r "$ZPOOL export t32fs-mdt1"
2416 shall_cleanup_mdt=false
2418 $r $UMOUNT $tmp/mnt/ost || {
2419 error_noexit "Unmounting the OST"
2422 if [[ "$mds1_FSTYPE" == zfs ]]; then
2423 $r "$ZPOOL export t32fs-ost1"
2425 shall_cleanup_ost=false
2427 t32_reload_modules $node || {
2428 error_noexit "Reloading modules"
2432 if [[ "$mds1_FSTYPE" == zfs ]]; then
2433 local poolname=t32fs-mdt1
2435 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2436 $ZPOOL import -f -d $tmp $poolname"
2438 # upgrade zpool to latest supported features,
2439 # including dnode quota accounting in 0.7.0
2440 $r "$ZPOOL upgrade $poolname"
2443 # mount a second time to make sure we didnt leave upgrade flag on
2444 $r $TUNEFS --dryrun $mdt_dev || {
2446 error_noexit "tunefs.lustre before remounting the MDT"
2450 mopts=exclude=$fsname-OST0000
2451 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2454 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2455 error_noexit "Remounting the MDT"
2458 shall_cleanup_mdt=true
2468 for tarball in $tarballs; do
2469 banner "testing $tarball upgrade"
2470 t32_test $tarball || let "rc += $?"
2474 run_test 32a "Upgrade (not live)"
2482 for tarball in $tarballs; do
2483 banner "testing $tarball upgrade with writeconf"
2484 t32_test $tarball writeconf || let "rc += $?"
2488 run_test 32b "Upgrade with writeconf"
2495 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2497 for tarball in $tarballs; do
2498 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2499 [[ "$tarball" =~ "1_8" ]] && echo "skip $tarball" && continue
2500 [[ "$tarball" =~ "2_1" ]] && echo "skip $tarball" && continue
2501 banner "testing $tarball upgrade with DNE"
2503 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2507 run_test 32c "dne upgrade test"
2515 for tarball in $tarballs; do
2516 banner "testing $tarball upgrade with ff convert and project upgrade"
2517 project_upgrade="no"
2518 [[ "$MDS1_VERSION" -ge $(version_code 2.13.54) ]] &&
2519 [[ "$tarball" =~ "disk2_4-ldiskfs" ]] &&
2520 project_upgrade="yes"
2521 project_upgrade=$project_upgrade ff_convert=yes t32_test \
2526 run_test 32d "convert ff and project quota upgrade test"
2529 [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
2530 skip "Need MDS version at least 2.10.56"
2537 for tarball in $tarballs; do
2538 [[ "$tarball" =~ "2_9" ]] || continue
2540 banner "testing $tarball upgrade with DoM"
2541 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
2545 run_test 32e "dom upgrade test"
2547 test_33a() { # bug 12333, was test_33
2548 local FSNAME2=test-123
2549 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2552 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2554 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2555 local dev=${SINGLEMDS}_dev
2556 local MDSDEV=${!dev}
2557 is_blkdev $SINGLEMDS $MDSDEV &&
2558 skip_env "mixed loopback and real device not working"
2561 local fs2mdsdev=$(mdsdevname 1_2)
2562 local fs2ostdev=$(ostdevname 1_2)
2563 local fs2mdsvdev=$(mdsvdevname 1_2)
2564 local fs2ostvdev=$(ostvdevname 1_2)
2566 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2567 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2570 if combined_mgs_mds; then
2571 local mgs_flag="--mgs"
2574 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
2575 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
2577 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2578 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2579 $fs2ostvdev || exit 10
2581 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2582 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2584 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2585 do_facet mgs "$PERM_CMD timeout=200" ||
2586 error "$PERM_CMD timeout=200 failed"
2588 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
2589 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
2591 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2592 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2595 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2596 $LFS getstripe $MOUNT2/hosts ||
2597 error "$LFS getstripe $MOUNT2/hosts failed"
2602 cleanup_nocli || error "cleanup_nocli failed with $?"
2604 run_test 33a "Mount ost with a large index number"
2606 test_33b() { # was test_34
2609 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2610 # Drop lock cancelation reply during umount
2611 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2612 do_facet client $LCTL set_param fail_loc=0x80000304
2613 #lctl set_param debug=-1
2614 umount_client $MOUNT
2615 cleanup || error "cleanup failed with $?"
2617 run_test 33b "Drop cancel during umount"
2621 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2622 manual_umount_client
2624 do_facet client killall -USR1 multiop
2625 if [ $rc -eq 0 ]; then
2626 error "umount not fail!"
2629 cleanup || error "cleanup failed with rc $?"
2631 run_test 34a "umount with opened file should be fail"
2635 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2636 stop_mds || error "Unable to stop MDS"
2638 manual_umount_client --force || error "mtab after failed umount with $?"
2640 cleanup || error "cleanup failed with $?"
2642 run_test 34b "force umount with failed mds should be normal"
2646 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2647 stop_ost || error "Unable to stop OST1"
2649 manual_umount_client --force || error "mtab after failed umount with $?"
2651 cleanup || error "cleanup failed with $?"
2653 run_test 34c "force umount with failed ost should be normal"
2655 test_35a() { # bug 12459
2658 DBG_SAVE="`$LCTL get_param -n debug`"
2659 $LCTL set_param debug="ha"
2661 log "Set up a fake failnode for the MDS"
2663 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2664 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2666 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2667 do_facet mgs "$PERM_CMD \
2668 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2669 error "Setting mdc.*${device}*.import=connection=\
2670 $(h2nettype $FAKENID) failed."
2672 do_facet mgs "$PERM_CMD \
2673 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2674 error "Setting ${device}.failover.node=\
2675 $(h2nettype $FAKENID) failed."
2677 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2680 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2683 log "Stopping the MDT: $device"
2684 stop_mdt 1 || error "MDT0 stop fail"
2686 df $MOUNT > /dev/null 2>&1 &
2688 log "Restarting the MDT: $device"
2689 start_mdt 1 || error "MDT0 start fail"
2690 log "Wait for df ($DFPID) ... "
2693 $LCTL set_param debug="$DBG_SAVE"
2695 # retrieve from the log the first server that the client tried to
2696 # contact after the connection loss
2697 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2698 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2699 /import_select_connection.*$device-mdc.* using connection/ {
2701 if (\\\$NF ~ /$FAKENID/)
2707 }" $TMP/lustre-log-$TESTNAME.log`
2708 [ "$NEXTCONN" != "0" ] &&
2709 error "Tried to connect to ${NEXTCONN} not last active server"
2710 cleanup || error "cleanup failed with $?"
2711 # remove nid settings
2712 writeconf_or_reformat
2714 run_test 35a "Reconnect to the last active server first"
2716 test_35b() { # bug 18674
2717 remote_mds || skip "local MDS"
2721 $LCTL set_param debug="ha"
2723 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2726 log "Set up a fake failnode for the MDS"
2728 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2729 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2731 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2732 do_facet mgs "$PERM_CMD \
2733 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2734 error "Set mdc.*${device}*.import=connection=\
2735 $(h2nettype $FAKENID) failed"
2737 do_facet mgs "$PERM_CMD \
2738 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2739 error "Set ${device}.failover.node=\
2740 $(h2nettype $FAKENID) failed"
2743 local at_max_saved=0
2744 # adaptive timeouts may prevent seeing the issue
2745 if at_is_enabled; then
2746 at_max_saved=$(at_max_get mds)
2747 at_max_set 0 mds client
2750 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2752 log "Injecting EBUSY on MDS"
2753 # Setting OBD_FAIL_MDS_RESEND=0x136
2754 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2755 error "unable to set param fail_loc=0x80000136"
2757 $LCTL set_param mdc.${FSNAME}*.stats=clear
2759 log "Creating a test file and stat it"
2760 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2761 stat $MOUNT/$tdir/$tfile
2763 log "Stop injecting EBUSY on MDS"
2764 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2765 error "unable to set param fail_loc=0"
2766 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2769 # restore adaptive timeout
2770 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2772 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2774 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2775 awk '/mds_connect/{print $2}')
2777 # retrieve from the log if the client has ever tried to
2778 # contact the fake server after the loss of connection
2779 FAILCONN=`awk "BEGIN {ret = 0;}
2780 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2782 if (\\\$NF ~ /$FAKENID/) {
2787 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2789 [ "$FAILCONN" == "0" ] &&
2790 error "The client reconnection has not been triggered"
2791 [ "$FAILCONN" == "2" ] &&
2792 error "Primary server busy, client reconnect to failover failed"
2795 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2796 # Reconnects are supposed to be rate limited to one every 5s
2797 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2798 error "Too many reconnects $CONNCNT"
2800 cleanup || error "cleanup failed with $?"
2801 # remove nid settings
2802 writeconf_or_reformat
2804 run_test 35b "Continue reconnection retries, if the active server is busy"
2807 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2809 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2813 local FSNAME2=test1234
2814 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2816 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2818 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2819 is_blkdev $SINGLEMDS $MDSDEV &&
2820 skip_env "mixed loopback and real device not working"
2823 local fs2mdsdev=$(mdsdevname 1_2)
2824 local fs2ostdev=$(ostdevname 1_2)
2825 local fs3ostdev=$(ostdevname 2_2)
2826 local fs2mdsvdev=$(mdsvdevname 1_2)
2827 local fs2ostvdev=$(ostvdevname 1_2)
2828 local fs3ostvdev=$(ostvdevname 2_2)
2831 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2832 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2833 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2834 # different one than the default value here.
2835 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2836 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2837 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2838 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2840 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2841 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2842 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2843 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2844 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2846 sleep 5 # until 11778 fixed
2848 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2850 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2851 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2852 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2853 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2854 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2855 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2856 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2857 DFTOTAL=$(echo $STRING | cut -d, -f1)
2858 DFUSED=$(echo $STRING | cut -d, -f2)
2859 DFAVAIL=$(echo $STRING | cut -d, -f3)
2860 DFFREE=$(($DFTOTAL - $DFUSED))
2862 ALLOWANCE=$((64 * $OSTCOUNT))
2864 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2865 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2866 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2869 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2870 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2871 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2874 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2875 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2876 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2881 stop fs3ost -f || error "unable to stop OST3"
2882 stop fs2ost -f || error "unable to stop OST2"
2883 stop fs2mds -f || error "unable to stop second MDS"
2884 unload_modules_conf || error "unable unload modules"
2887 run_test 36 "df report consistency on OSTs with different block size"
2890 local mntpt=$(facet_mntpt $SINGLEMDS)
2891 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2892 local mdsdev_sym="$TMP/sym_mdt.img"
2893 local opts=$MDS_MOUNT_OPTS
2896 if [ "$mds1_FSTYPE" != ldiskfs ]; then
2897 skip "ldiskfs only test"
2900 echo "MDS : $mdsdev"
2901 echo "SYMLINK : $mdsdev_sym"
2902 do_facet $SINGLEMDS rm -f $mdsdev_sym
2904 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2906 echo "mount symlink device - $mdsdev_sym"
2908 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2909 opts=$(csa_add "$opts" -o loop)
2913 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2914 $mdsdev_sym $mntpt 2>&1)
2917 echo mount_op=$mount_op
2919 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2921 if $(echo $mount_op | grep -q "unable to set tunable"); then
2922 error "set tunables failed for symlink device"
2925 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2927 run_test 37 "verify set tunables works for symlink device"
2929 test_38() { # bug 14222
2930 local mntpt=$(facet_mntpt $SINGLEMDS)
2935 local SRC="/etc /bin"
2936 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2937 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2938 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2939 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2940 error "copying $SRC to $DIR/$tdir"
2942 umount_client $MOUNT || error "umount_client $MOUNT failed"
2943 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2944 stop_mds || error "Unable to stop MDS"
2945 log "delete lov_objid file on MDS"
2947 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2949 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2951 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2953 # check create in mds_lov_connect
2954 start_mds || error "unable to start MDS"
2955 mount_client $MOUNT || error "mount_client $MOUNT failed"
2957 [ $V ] && log "verifying $DIR/$tdir/$f"
2958 diff -q $f $DIR/$tdir/$f || ERROR=y
2960 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2961 if [ "$ERROR" = "y" ]; then
2962 # check it's updates in sync
2963 umount_client $MOUNT
2965 mount_fstype $SIGNLEMDS
2966 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2967 unmount_fstype $SINGLEMDS
2968 error "old and new files are different after connect" || true
2970 touch $DIR/$tdir/f2 || error "f2 file create failed"
2972 # check it's updates in sync
2973 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2976 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2978 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2979 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2981 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2983 start_mds || error "unable to start MDS"
2984 mount_client $MOUNT || error "mount_client $MOUNT failed"
2986 [ $V ] && log "verifying $DIR/$tdir/$f"
2987 diff -q $f $DIR/$tdir/$f || ERROR=y
2989 touch $DIR/$tdir/f3 || error "f3 file create failed"
2990 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2991 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2993 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2994 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2995 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2997 [ "$ERROR" = "y" ] &&
2998 error "old and new files are different after sync" || true
3000 log "files compared the same"
3001 cleanup || error "cleanup failed with $?"
3003 run_test 38 "MDS recreates missing lov_objid file from OST data"
3008 cleanup || error "cleanup failed with $?"
3009 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
3010 error "memory leak detected" || true
3012 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
3014 test_40() { # bug 15759
3015 start_ost || error "Unable to start OST1"
3016 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
3017 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
3019 cleanup || error "cleanup failed with rc $?"
3021 run_test 40 "race during service thread startup"
3023 test_41a() { #bug 14134
3024 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3025 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
3026 skip "Loop devices does not work with nosvc option"
3029 combined_mgs_mds || skip "needs combined MGT and MDT device"
3031 start_mdt 1 -o nosvc -n
3032 if [ $MDSCOUNT -ge 2 ]; then
3033 for num in $(seq 2 $MDSCOUNT); do
3034 start_mdt $num || return
3037 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
3038 start_mdt 1 -o nomgs,force
3039 mount_client $MOUNT || error "mount_client $MOUNT failed"
3042 echo "blah blah" > $MOUNT/$tfile
3045 umount_client $MOUNT || error "umount_client $MOUNT failed"
3046 stop ost1 -f || error "unable to stop OST1"
3047 stop_mds || error "Unable to stop MDS"
3048 stop_mds || error "Unable to stop MDS on second try"
3050 run_test 41a "mount mds with --nosvc and --nomgs"
3053 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3054 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
3055 skip "Loop devices does not work with nosvc option"
3058 ! combined_mgs_mds && skip "needs combined mgs device"
3062 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3064 start_mdt 1 -o nosvc -n
3065 if [ $MDSCOUNT -ge 2 ]; then
3066 for num in $(seq 2 $MDSCOUNT); do
3067 start_mdt $num || return
3070 start_ost || error "Unable to start OST1"
3071 start_mdt 1 -o nomgs,force
3072 mount_client $MOUNT || error "mount_client $MOUNT failed"
3075 echo "blah blah" > $MOUNT/$tfile
3076 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
3078 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
3079 stop_ost || error "Unable to stop OST1"
3080 stop_mds || error "Unable to stop MDS"
3081 stop_mds || error "Unable to stop MDS on second try"
3083 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
3086 local oss_list=$(comma_list $(osts_nodes))
3088 [[ "$MDS1_VERSION" -ge $(version_code 2.6.52) ]] ||
3089 [[ "$MDS1_VERSION" -ge $(version_code 2.5.26) &&
3090 "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
3091 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
3092 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]] ||
3093 skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"
3095 # ensure mds1 ost1 have been created even if running sub-test standalone
3098 cleanup || error "cleanup failed"
3100 # using directly mount command instead of start() function to avoid
3101 # any side effect of // with others/externals tools/features
3102 # ("zpool import", ...)
3104 # MDT concurrent start
3106 LOAD_MODULES_REMOTE=true load_modules
3107 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
3108 error "MDT concurrent start: libcfs module not loaded"
3110 local mds1dev=$(mdsdevname 1)
3111 local mds1mnt=$(facet_mntpt mds1)
3112 local mds1opts=$MDS_MOUNT_OPTS
3114 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3115 ! do_facet mds1 test -b $mds1dev; then
3116 mds1opts=$(csa_add "$mds1opts" -o loop)
3118 if [[ "$mds1_FSTYPE" == zfs ]]; then
3119 import_zpool mds1 || return ${PIPESTATUS[0]}
3122 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3123 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
3125 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
3128 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
3132 do_facet mds1 "$LCTL set_param fail_loc=0x0"
3133 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3134 echo "1st MDT start succeed"
3135 echo "2nd MDT start failed with $rc2"
3136 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3137 echo "1st MDT start failed with $rc"
3138 echo "2nd MDT start succeed"
3141 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
3144 if [ $MDSCOUNT -ge 2 ]; then
3145 for num in $(seq 2 $MDSCOUNT); do
3146 start_mdt $num || return
3150 # OST concurrent start
3152 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
3153 error "OST concurrent start: libcfs module not loaded"
3155 local ost1dev=$(ostdevname 1)
3156 local ost1mnt=$(facet_mntpt ost1)
3157 local ost1opts=$OST_MOUNT_OPTS
3159 if [ "$ost1_FSTYPE" == ldiskfs ] &&
3160 ! do_facet ost1 test -b $ost1dev; then
3161 ost1opts=$(csa_add "$ost1opts" -o loop)