7 # bug number for skipped test:
8 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
9 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
11 # bug number for skipped test:
12 # a tool to create lustre filesystem images
13 ALWAYS_EXCEPT="32newtarball $ALWAYS_EXCEPT"
15 # bug number for skipped tests: LU-9795 (all below)
16 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 0 31 32a 32d 35a"
17 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 53a 53b 54b 76a 76b"
18 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76c 76d 78 103"
22 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
24 PTLDEBUG=${PTLDEBUG:--1}
26 LUSTRE=${LUSTRE:-$(dirname $0)/..}
27 RLUSTRE=${RLUSTRE:-$LUSTRE}
28 export MULTIOP=${MULTIOP:-multiop}
30 . $LUSTRE/tests/test-framework.sh
32 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
35 # use small MDS + OST size to speed formatting time
36 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
37 # STORED_MDSSIZE is used in test_18
38 STORED_MDSSIZE=$MDSSIZE
39 STORED_OSTSIZE=$OSTSIZE
41 [ "$mds1_FSTYPE" = zfs ] && MDSSIZE=400000
43 [ "$ost1_FSTYPE" = zfs ] && OSTSIZE=400000
53 # bug number for skipped test: LU-11915
54 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 110"
56 if ! combined_mgs_mds; then
57 # bug number for skipped test: LU-11991 LU-11990
58 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 32a 32b 32c 32d 32e 66"
59 # bug number for skipped test: LU-9897 LU-12032
60 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 84 123F"
63 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
64 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
65 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
71 require_dsh_mds || exit 0
72 require_dsh_ost || exit 0
75 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69"
80 # The MGS must be started before the OSTs for a new fs, so start
81 # and stop to generate the startup logs.
84 wait_osc_import_state mds ost FULL
89 reformat_and_config() {
91 if ! combined_mgs_mds ; then
97 writeconf_or_reformat() {
98 # There are at most 2 OSTs for write_conf test
99 # who knows if/where $TUNEFS is installed?
100 # Better reformat if it fails...
101 writeconf_all $MDSCOUNT 2 ||
102 { echo "tunefs failed, reformatting instead" &&
103 reformat_and_config && return 0; }
112 echo "start mgs service on $(facet_active_host mgs)"
113 start mgs $(mgsdevname) $MGS_MOUNT_OPTS $@
119 local dev=$(mdsdevname $num)
122 echo "start mds service on `facet_active_host $facet`"
123 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
129 local dev=$(mdsdevname $num)
132 echo "stop mds service on `facet_active_host $facet`"
133 # These tests all use non-failover stop
134 stop $facet -f || return 97
140 for num in $(seq $MDSCOUNT); do
141 start_mdt $num $@ || return 94
146 if ! combined_mgs_mds ; then
154 for num in $(seq $MDSCOUNT); do
155 stop_mdt $num || return 97
160 echo "stop mgs service on `facet_active_host mgs`"
161 # These tests all use non-failover stop
162 stop mgs -f || return 97
166 echo "start ost1 service on `facet_active_host ost1`"
167 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
171 echo "stop ost1 service on `facet_active_host ost1`"
172 # These tests all use non-failover stop
173 stop ost1 -f || return 98
177 echo "start ost2 service on `facet_active_host ost2`"
178 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
182 echo "stop ost2 service on `facet_active_host ost2`"
183 # These tests all use non-failover stop
184 stop ost2 -f || return 93
191 echo "mount $FSNAME ${mountopt:+with opts $mountopt} on $mountpath....."
192 zconf_mount $HOSTNAME $mountpath $mountopt || return 96
198 echo "umount lustre on $mountpath....."
199 zconf_umount $HOSTNAME $mountpath $@ || return 97
202 manual_umount_client(){
205 echo "manual umount lustre on ${MOUNT}...."
206 do_facet client "umount ${FORCE} $MOUNT"
212 start_mds || error "MDT start failed"
213 start_ost || error "Unable to start OST1"
214 mount_client $MOUNT || error "client start failed"
215 client_up || error "client_up failed"
224 unload_modules_conf () {
225 if combined_mgs_mds || ! local_mode; then
226 unload_modules || return 1
231 stop_ost || return 202
232 stop_mds || return 201
233 unload_modules_conf || return 203
238 [ "x$1" != "x" ] && force='-f'
239 umount_client $MOUNT $force|| return 200
240 cleanup_nocli || return $?
245 echo "umount $MOUNT2 ..."
246 umount $MOUNT2 || true
247 echo "stopping fs2mds ..."
248 stop fs2mds -f || true
249 echo "stopping fs2ost ..."
250 stop fs2ost -f || true
254 do_facet client "cp /etc/passwd $DIR/a" || return 71
255 do_facet client "rm $DIR/a" || return 72
256 # make sure lustre is actually mounted (touch will block,
257 # but grep won't, so do it after)
258 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
259 echo "setup single mount lustre success"
263 do_facet client "touch $DIR/a" || return 71
264 do_facet client "rm $DIR/a" || return 72
265 do_facet client "touch $DIR2/a" || return 73
266 do_facet client "rm $DIR2/a" || return 74
267 echo "setup double mount lustre success"
272 if [ "$ONLY" == "setup" ]; then
277 if [ "$ONLY" == "cleanup" ]; then
284 #create single point mountpoint
290 check_mount || error "check_mount failed"
291 cleanup || error "cleanup failed with $?"
293 run_test 0 "single mount setup"
296 start_mds || error "MDS start failed"
297 start_ost || error "unable to start OST"
298 echo "start ost second time..."
299 start_ost && error "2nd OST start should fail"
300 mount_client $MOUNT || error "client start failed"
301 check_mount || error "check_mount failed"
302 cleanup || error "cleanup failed with $?"
304 run_test 1 "start up ost twice (should return errors)"
307 start_mds || error "MDT start failed"
308 echo "start mds second time.."
309 start_mds && error "2nd MDT start should fail"
310 start_ost || error "OST start failed"
311 mount_client $MOUNT || error "mount_client failed to start client"
312 check_mount || error "check_mount failed"
313 cleanup || error "cleanup failed with $?"
315 run_test 2 "start up mds twice (should return err)"
319 #mount.lustre returns an error if already in mtab
320 mount_client $MOUNT && error "2nd client mount should fail"
321 check_mount || error "check_mount failed"
322 cleanup || error "cleanup failed with $?"
324 run_test 3 "mount client twice (should return err)"
328 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
329 stop_ost || error "Unable to stop OST1"
330 umount_client $MOUNT -f || error “unmount $MOUNT failed”
333 # ok for ost to fail shutdown
334 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
335 error "cleanup failed with $?"
338 run_test 4 "force cleanup ost, then cleanup"
340 test_5a() { # was test_5
342 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
343 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
345 stop_mds || error "Unable to stop MDS"
347 # cleanup may return an error from the failed
348 # disconnects; for now I'll consider this successful
349 # if all the modules have unloaded.
353 echo "killing umount"
354 kill -TERM $UMOUNT_PID
355 echo "waiting for umount to finish"
357 if grep " $MOUNT " /proc/mounts; then
358 echo "test 5: /proc/mounts after failed umount"
362 echo "killing umount"
363 kill -TERM $UMOUNT_PID
364 echo "waiting for umount to finish"
366 grep " $MOUNT " /proc/mounts &&
367 error "/proc/mounts after second umount"
370 # manual_mount_client may fail due to umount succeeding above
372 # stop_mds is a no-op here, and should not fail
373 cleanup_nocli || error "cleanup_nocli failed with $?"
374 # df may have lingering entry
376 # mtab may have lingering entry
380 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
382 grep -q $MOUNT" " /etc/mtab || break
383 echo "Waiting /etc/mtab updated ... "
384 WAIT=$(( WAIT + sleep))
386 [ "$WAIT" -eq "$MAX_WAIT" ] &&
387 error "/etc/mtab is not updated in $WAIT secs"
388 echo "/etc/mtab updated in $WAIT secs"
390 run_test 5a "force cleanup mds, then cleanup"
398 grep " $MOUNT " /etc/mtab &&
399 error false "unexpected entry in mtab before mount" && return 10
401 start_ost || error "OST start failed"
402 if ! combined_mgs_mds ; then
403 trap cleanup_5b EXIT ERR
404 start_mds || error "MDS start failed"
408 mount_client $MOUNT && error "mount_client $MOUNT should fail"
409 grep " $MOUNT " /etc/mtab &&
410 error "$MOUNT entry in mtab after failed mount"
412 # stop_mds is a no-op here, and should not fail
413 cleanup_nocli || error "cleanup_nocli failed with $?"
414 if ! combined_mgs_mds ; then
418 run_test 5b "Try to start a client with no MGS (should return errs)"
421 grep " $MOUNT " /etc/mtab &&
422 error false "unexpected entry in mtab before mount" && return 10
424 start_mds || error "MDS start failed"
425 start_ost || error "OST start failed"
426 local oldfs="${FSNAME}"
427 FSNAME="wrong.${FSNAME}"
428 mount_client $MOUNT || :
430 grep " $MOUNT " /etc/mtab &&
431 error "$MOUNT entry in mtab after failed mount"
433 cleanup_nocli || error "cleanup_nocli failed with $?"
435 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
438 grep " $MOUNT " /etc/mtab &&
439 error "unexpected entry in mtab before mount"
441 start_ost || error "OST start failed"
442 start_mds || error "MDS start failed"
443 stop_ost -f || error "Unable to stop OST1"
444 mount_client $MOUNT || error "mount_client $MOUNT failed"
445 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
446 cleanup_nocli || error "cleanup_nocli failed with $?"
447 ! grep " $MOUNT " /etc/mtab ||
448 error "$MOUNT entry in mtab after unmount"
450 run_test 5d "mount with ost down"
453 grep " $MOUNT " /etc/mtab &&
454 error false "unexpected entry in mtab before mount" && return 10
456 start_mds || error "MDS start failed"
457 start_ost || error "OST start failed"
459 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
460 do_facet client "$LCTL set_param fail_loc=0x80000506"
461 mount_client $MOUNT || echo "mount failed (not fatal)"
462 cleanup || error "cleanup failed with $?"
463 grep " $MOUNT " /etc/mtab &&
464 error "$MOUNT entry in mtab after unmount"
467 run_test 5e "delayed connect, don't crash (bug 10268)"
470 combined_mgs_mds && skip "needs separate mgs and mds"
472 grep " $MOUNT " /etc/mtab &&
473 error false "unexpected entry in mtab before mount" && return 10
476 start_ost || error "OST start failed"
477 mount_client $MOUNT &
479 echo client_mount pid is $pid
483 if ! ps -f -p $pid >/dev/null; then
486 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
487 error "mount returns $rc, expected to hang"
489 cleanup || error "cleanup failed with $?"
494 start_mds || error "start MDS failed"
496 # mount should succeed after start mds
498 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
499 cleanup || error "final call to cleanup failed with rc $?"
501 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
505 [ "$CLIENT_VERSION" -lt $(version_code 2.9.53) ] &&
506 skip "automount of debugfs missing before 2.9.53"
507 umount /sys/kernel/debug
508 $LCTL get_param -n devices | egrep -v "error" && \
509 error "lctl can't access debugfs data"
510 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
512 run_test 5g "handle missing debugfs"
517 mount_client $MOUNT || error "mount_client $MOUNT failed"
518 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
519 cleanup || error "cleanup failed with rc $?"
521 run_test 6 "manual umount, then mount again"
526 cleanup_nocli || error "cleanup_nocli failed with $?"
528 run_test 7 "manual umount, then cleanup"
532 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
533 check_mount2 || error "check_mount2 failed"
534 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
535 cleanup || error "cleanup failed with rc $?"
537 run_test 8 "double mount setup"
540 start_ost || error "OST start failed"
542 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
543 error "do_facet ost1 set_param inode trace failed."
544 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
545 error "do_facet ost1 set_param debug mds ost failed."
547 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
548 if [ "$CHECK_PTLDEBUG" ] && { \
549 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
550 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
551 echo "lnet.debug success"
553 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
555 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
556 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
557 echo "lnet.subsystem_debug success"
559 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
561 stop_ost || error "Unable to stop OST1"
563 run_test 9 "test ptldebug and subsystem for mkfs"
566 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
567 # But with new MDS stack we don't care about the mode of local objects
568 # anymore, so this test is removed. See bug 22944 for more details.
572 if [ "$mds1_FSTYPE" != ldiskfs ]; then
573 skip "ldiskfs only test"
577 check_mount || error "check_mount failed"
578 cleanup || error "cleanup failed with rc $?"
580 echo "Remove mds config log"
581 if ! combined_mgs_mds ; then
585 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
586 $(mgsdevname) || return \$?" ||
587 error "do_facet mgs failed with $?"
589 if ! combined_mgs_mds ; then
593 start_ost || error "OST start failed"
594 start_mds && error "MDS start succeeded, but should fail"
597 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
600 if [ "$mds1_FSTYPE" != ldiskfs ]; then
601 skip "ldiskfs only test"
604 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
609 # check if current MDSSIZE is large enough
610 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
611 log "use MDSSIZE=$MDSSIZE"
613 # check if the global config has a large enough MDSSIZE
614 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
615 [ $STORED_MDSSIZE -ge $MIN ] &&
616 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
617 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
619 # check if the block device is large enough
620 is_blkdev $SINGLEMDS $MDSDEV $MIN
621 local large_enough=$?
622 if [ -n "$OK" ]; then
623 [ $large_enough -ne 0 ] && OK=""
625 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
626 log "use device $MDSDEV with MIN=$MIN"
629 # check if a loopback device has enough space for fs metadata (5%)
631 if [ -z "$OK" ]; then
632 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
633 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
634 awk '($1 != "Filesystem") { print $4 }')
635 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
636 OK=1 && myMDSSIZE=$MIN &&
637 log "use file $MDSDEV with MIN=$MIN"
640 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS"
642 echo "mount mds with large journal..."
644 local OLD_MDSSIZE=$MDSSIZE
648 echo "mount lustre system..."
650 check_mount || error "check_mount failed"
652 echo "check journal size..."
653 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
654 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
655 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
657 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
660 cleanup || error "cleanup failed with rc $?"
665 run_test 18 "check mkfs creates large journals"
668 start_mds || error "MDS start failed"
669 stop_mds || error "Unable to stop MDS"
671 run_test 19a "start/stop MDS without OSTs"
674 start_ost || error "Unable to start OST1"
675 stop_ost -f || error "Unable to stop OST1"
677 run_test 19b "start/stop OSTs without MDS"
680 # first format the ost/mdt
681 start_mds || error "MDS start failed"
682 start_ost || error "Unable to start OST1"
683 mount_client $MOUNT || error "mount_client $MOUNT failed"
684 check_mount || error "check_mount failed"
685 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
686 mount_client $MOUNT remount,ro || error "remount client with ro failed"
687 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
688 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
689 mount_client $MOUNT remount,rw || error "remount client with rw failed"
690 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
691 MCNT=$(grep -c $MOUNT' ' /etc/mtab)
692 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
694 stop_mds || error "Unable to stop MDS"
695 stop_ost || error "Unable to stop OST1"
697 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
700 start_mds || error "MDS start failed"
701 start_ost || error "unable to start OST1"
702 wait_osc_import_state mds ost FULL
703 stop_ost || error "unable to stop OST1"
704 stop_mds || error "unable to stop MDS"
706 run_test 21a "start mds before ost, stop ost first"
709 start_ost || error "unable to start OST1"
710 start_mds || error "MDS start failed"
711 wait_osc_import_state mds ost FULL
712 stop_mds || error "unable to stop MDS"
713 stop_ost || error "unable to stop OST1"
715 run_test 21b "start ost before mds, stop mds first"
718 start_ost || error "Unable to start OST1"
719 start_mds || error "MDS start failed"
720 start_ost2 || error "Unable to start OST2"
721 wait_osc_import_state mds ost2 FULL
722 stop_ost || error "Unable to stop OST1"
723 stop_ost2 || error "Unable to stop OST2"
724 stop_mds || error "Unable to stop MDS"
725 #writeconf to remove all ost2 traces for subsequent tests
726 writeconf_or_reformat
728 run_test 21c "start mds between two osts, stop mds last"
731 combined_mgs_mds && skip "need separate mgs device"
736 start_mgs || error "unable to start MGS"
737 start_ost || error "unable to start OST1"
738 start_ost2 || error "unable to start OST2"
739 start_mds || error "MDS start failed"
740 wait_osc_import_state mds ost2 FULL
742 stop_ost || error "Unable to stop OST1"
743 stop_ost2 || error "Unable to stop OST2"
744 stop_mds || error "Unable to stop MDS"
746 #writeconf to remove all ost2 traces for subsequent tests
747 writeconf_or_reformat
748 start_mgs || error "unable to start MGS"
750 run_test 21d "start mgs then ost and then mds"
753 MGSNID="$saved_mgsnid"
755 echo "stopping fs2mgs ..."
756 stop $fs2mgs -f || true
759 test_21e() { # LU-5863
760 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
761 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
762 skip_env "mixed loopback and real device not working"
765 local fs2mdsdev=$(mdsdevname 1_2)
766 local fs2ostdev=$(ostdevname 1_2)
767 local fs3ostdev=$(ostdevname 2_2)
769 local fs2mdsvdev=$(mdsvdevname 1_2)
770 local fs2ostvdev=$(ostvdevname 1_2)
771 local fs3ostvdev=$(ostvdevname 2_2)
773 # temporarily use fs3ost as fs2mgs
775 local fs2mgsdev=$fs3ostdev
776 local fs2mgsvdev=$fs3ostvdev
778 local fsname=test1234
780 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
781 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
782 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
783 error "start fs2mgs failed"
785 local saved_mgsnid="$MGSNID"
786 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
788 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
789 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
790 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
791 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
793 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
794 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
796 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
797 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
798 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
802 run_test 21e "separate MGS and MDS"
805 start_mds || error "MDS start failed"
807 echo "Client mount with ost in logs, but none running"
808 start_ost || error "unable to start OST1"
809 # wait until mds connected to ost and open client connection
810 wait_osc_import_state mds ost FULL
811 stop_ost || error "unable to stop OST1"
812 mount_client $MOUNT || error "mount_client $MOUNT failed"
813 # check_mount will block trying to contact ost
814 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
815 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
816 umount_client $MOUNT -f
819 echo "Client mount with a running ost"
820 start_ost || error "unable to start OST1"
822 # if gss enabled, wait full time to let connection from
823 # mds to ost be established, due to the mismatch between
824 # initial connect timeout and gss context negotiation timeout.
825 # This perhaps could be remove after AT landed.
826 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
827 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
829 mount_client $MOUNT || error "mount_client $MOUNT failed"
830 wait_osc_import_state mds ost FULL
831 wait_osc_import_ready client ost
832 check_mount || error "check_mount failed"
835 cleanup || error "cleanup failed with rc $?"
837 run_test 22 "start a client before osts (should return errs)"
839 test_23a() { # was test_23
842 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
843 # force down client so that recovering mds waits for reconnect
844 local running=$(grep -c $MOUNT /proc/mounts) || true
845 if [ $running -ne 0 ]; then
846 echo "Stopping client $MOUNT (opts: -f)"
850 # enter recovery on failed mds
851 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
852 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
853 # try to start a new client
854 mount_client $MOUNT &
856 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
857 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
858 grep -v grep | awk '{print $2}')
859 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
861 ps --ppid $MOUNT_LUSTRE_PID
862 echo "waiting for mount to finish"
864 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
865 # SIGTERM works but it does not spread to offspring processses
866 kill -s TERM $MOUNT_PID
867 kill -s TERM $MOUNT_LUSTRE_PID
868 # we can not wait $MOUNT_PID because it is not a child of this shell
874 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
876 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
877 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
880 [ -z "$PID1" -a -z "$PID2" ] && break
881 echo "waiting for mount to finish ... "
882 WAIT=$(( WAIT + sleep))
884 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
885 error "MOUNT_PID $MOUNT_PID and "\
886 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
889 cleanup || error "cleanup failed with rc $?"
891 run_test 23a "interrupt client during recovery mount delay"
893 test_23b() { # was test_23
894 start_mds || error "MDS start failed"
895 start_ost || error "Unable to start OST1"
896 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
897 $LCTL set_param fail_loc=0x80000313
899 cleanup || error "cleanup failed with rc $?"
901 run_test 23b "Simulate -EINTR during mount"
904 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
906 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
907 is_blkdev $SINGLEMDS $MDSDEV &&
908 skip_env "mixed loopback and real device not working"
911 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
913 local fs2mdsdev=$(mdsdevname 1_2)
914 local fs2ostdev=$(ostdevname 1_2)
915 local fs2mdsvdev=$(mdsvdevname 1_2)
916 local fs2ostvdev=$(ostvdevname 1_2)
919 # LU-9733 test fsname started with numbers as well
920 local FSNAME2=969362ae
922 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
923 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
925 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
926 --reformat $fs2ostdev $fs2ostvdev || exit 10
929 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
930 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
931 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
932 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
934 # LU-9733 test fsname started with numbers
935 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
936 changelog_register -n) ||
937 error "register changelog failed"
939 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
940 changelog_deregister $cl_user ||
941 error "deregister changelog failed"
943 check_mount || error "check_mount failed"
944 # files written on 1 should not show up on 2
945 cp /etc/passwd $DIR/$tfile
947 [ -e $MOUNT2/$tfile ] && error "File bleed"
950 cp /etc/passwd $MOUNT2/$tfile ||
951 error "cp /etc/passwd $MOUNT2/$tfile failed"
952 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
953 # 2 is actually mounted
954 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
956 facet_failover fs2mds
957 facet_failover fs2ost
960 # the MDS must remain up until last MDT
962 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
963 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
964 [ -z "$MDS" ] && error "No MDT"
966 cleanup_nocli || error "cleanup_nocli failed with rc $?"
968 run_test 24a "Multiple MDTs on a single node"
971 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
973 skip "needs combined MGT and MDT device"
975 if [ -z "$fs2mds_DEV" ]; then
976 local dev=${SINGLEMDS}_dev
978 is_blkdev $SINGLEMDS $MDSDEV &&
979 skip_env "mixed loopback and real device not working"
982 local fs2mdsdev=$(mdsdevname 1_2)
983 local fs2mdsvdev=$(mdsvdevname 1_2)
985 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
986 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
988 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && {
990 error "start MDS should fail"
993 cleanup || error "cleanup failed with rc $?"
995 run_test 24b "Multiple MGSs on a single node (should return err)"
999 check_mount || error "check_mount failed"
1000 local MODULES=$($LCTL modules | awk '{ print $2 }')
1001 rmmod $MODULES 2>/dev/null || true
1002 cleanup || error "cleanup failed with $?"
1004 run_test 25 "Verify modules are referenced"
1008 # we need modules before mount for sysctl, so make sure...
1009 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1010 #define OBD_FAIL_MDS_FS_SETUP 0x135
1011 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1012 start_mds && error "MDS started but should not have started"
1013 $LCTL get_param -n devices
1014 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1015 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1016 # start mds to drop writeconf setting
1017 start_mds || error "Unable to start MDS"
1018 stop_mds || error "Unable to stop MDS"
1019 unload_modules_conf || error "unload_modules_conf failed with $?"
1021 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1025 start_ost || error "Unable to start OST1"
1026 start_mds || error "Unable to start MDS"
1027 echo "Requeue thread should have started: "
1028 ps -e | grep ll_cfg_requeue
1029 set_persistent_param_and_check ost1 \
1030 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1031 "$FSNAME-OST0000.ost.client_cache_seconds"
1032 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1034 run_test 27a "Reacquire MGS lock if OST started first"
1039 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1040 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1042 facet_failover $SINGLEMDS
1043 set_persistent_param_and_check $SINGLEMDS \
1044 "mdt.$device.identity_acquire_expire" \
1045 "$device.mdt.identity_acquire_expire"
1046 set_persistent_param_and_check client \
1047 "mdc.$device-mdc-*.max_rpcs_in_flight" \
1048 "$device.mdc.max_rpcs_in_flight"
1050 cleanup || error "cleanup failed with $?"
1052 run_test 27b "Reacquire MGS lock after failover"
1054 test_28A() { # was test_28
1057 local TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1058 local PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1059 local orig=$($LCTL get_param -n $TEST)
1060 local max=$($LCTL get_param -n \
1061 llite.$FSNAME-*.max_read_ahead_per_file_mb)
1063 orig=${orig%%.[0-9]*}
1065 echo "ORIG:$orig MAX:$max"
1066 [[ $max -le $orig ]] && orig=$((max - 3))
1067 echo "ORIG:$orig MAX:$max"
1069 local final=$((orig + 1))
1071 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1072 final=$((final + 1))
1073 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1074 umount_client $MOUNT || error "umount_client $MOUNT failed"
1075 mount_client $MOUNT || error "mount_client $MOUNT failed"
1077 local result=$($LCTL get_param -n $TEST)
1079 if [ $result -ne $final ]; then
1080 error "New config not seen: wanted $final got $result"
1082 echo "New config success: got $result"
1084 set_persistent_param_and_check client "$TEST" "$PARAM" $orig
1085 cleanup || error "cleanup failed with rc $?"
1087 run_test 28A "permanent parameter setting"
1089 test_28a() { # LU-4221
1090 [[ "$OST1_VERSION" -ge $(version_code 2.5.52) ]] ||
1091 skip "Need OST version at least 2.5.52"
1092 [ "$ost1_FSTYPE" = zfs ] &&
1093 skip "LU-4221: no such proc params for ZFS OSTs"
1100 local device="$FSNAME-OST0000"
1104 # In this test we will set three kinds of proc parameters with
1105 # lctl set_param -P or lctl conf_param:
1106 # 1. non-symlink ones in the OFD
1107 # 2. non-symlink ones in the OSD
1110 # prepare a non-symlink parameter in the OFD
1111 name="client_cache_seconds"
1112 param="$device.ost.$name"
1113 cmd="obdfilter.$device.$name"
1115 # permanently setting the parameter in the OFD
1116 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1118 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1119 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1122 # prepare a non-symlink parameter in the OSD
1124 param="$device.osd.$name"
1125 cmd="osd-*.$device.$name"
1127 # conf_param the parameter in the OSD
1128 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1129 new=$(((old + 1) % 2))
1130 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1131 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1133 cleanup || error "cleanup failed with $?"
1135 run_test 28a "set symlink parameters permanently with lctl"
1138 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
1139 setup_noconfig > /dev/null 2>&1
1140 start_ost2 || error "Unable to start OST2"
1143 local PARAM="$FSNAME-OST0001.osc.active"
1144 # With lctl set_param -P the value $PROC_ACT will be sent to
1145 # all nodes. The [^M] filter out the ability to set active
1146 # on the MDS servers which is tested with wait_osp_* below.
1147 # For ost_server_uuid that only exist on client so filtering
1149 local PROC_ACT="os[cp].$FSNAME-OST0001-osc-[^M]*.active"
1150 local PROC_UUID="os[cp].$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1152 ACTV=$($LCTL get_param -n $PROC_ACT)
1154 set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
1155 # also check ost_server_uuid status
1156 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1157 if [ -z "$RESULT" ]; then
1158 error "Client not deactivated: $($LCTL get_param \
1161 echo "Live client success: got $RESULT"
1165 wait_osp_active ost ${FSNAME}-OST0001 1 0
1167 # test new client starts deactivated
1168 umount_client $MOUNT || error "umount_client $MOUNT failed"
1169 mount_client $MOUNT || error "mount_client $MOUNT failed"
1170 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1171 if [ -z "$RESULT" ]; then
1172 error "New client start active: $(lctl get_param -n $PROC_UUID)"
1174 echo "New client success: got $RESULT"
1177 # make sure it reactivates
1178 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1180 umount_client $MOUNT
1181 stop_ost2 || error "Unable to stop OST2"
1182 cleanup_nocli || error "cleanup_nocli failed with $?"
1183 #writeconf to remove all ost2 traces for subsequent tests
1184 writeconf_or_reformat
1186 run_test 29 "permanently remove an OST"
1191 echo Big config llog
1192 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1193 ORIG=$($LCTL get_param -n $TEST)
1194 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1195 for i in ${LIST[@]}; do
1196 set_persistent_param_and_check client "$TEST" \
1197 "$FSNAME.llite.max_read_ahead_whole_mb" $i
1199 # make sure client restart still works
1200 umount_client $MOUNT
1201 mount_client $MOUNT || error "mount_client $MOUNT failed"
1202 [ "$($LCTL get_param -n $TEST)" -ne "$i" ] &&
1203 error "Param didn't stick across restart $($TEST) != $i"
1206 echo Erase parameter setting
1207 if [[ $PERM_CMD = *"set_param -P"* ]]; then
1208 do_facet mgs "$PERM_CMD -d $TEST" ||
1209 error "Erase param $TEST failed"
1211 do_facet mgs "$PERM_CMD \
1212 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1213 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1215 umount_client $MOUNT
1216 mount_client $MOUNT || error "mount_client $MOUNT failed"
1217 FINAL=$($LCTL get_param -n $TEST)
1218 echo "deleted (default) value=$FINAL, orig=$ORIG"
1219 ORIG=${ORIG%%.[0-9]*}
1220 FINAL=${FINAL%%.[0-9]*}
1221 # assumes this parameter started at the default value
1222 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1224 cleanup || error "cleanup failed with rc $?"
1226 run_test 30a "Big config llog and permanent parameter deletion"
1231 local orignids=$($LCTL get_param -n \
1232 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1234 local orignidcount=$(echo "$orignids" | wc -w)
1236 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1237 # numerical part of it. Hopefully that's not already a failover address
1239 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1241 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1242 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1243 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1244 echo "Using fake nid $NEW"
1246 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1247 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1248 if [[ $PERM_CMD = *"set_param -P"* ]]; then
1249 PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
1250 echo "Setting $PARAM from $TEST to $NEW"
1251 do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
1252 error "$PERM_CMD $PARAM failed"
1254 PARAM="$FSNAME-OST0000.failover.node"
1255 echo "Setting $PARAM from $TEST to $NEW"
1256 do_facet mgs "$PERM_CMD $PARAM='$NEW'" ||
1257 error "$PARAM $PARAM failed"
1259 wait_update_facet client "$TEST" "$NEW" ||
1260 error "check $PARAM failed!"
1262 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1264 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1265 echo "should have $((orignidcount + 1)) entries \
1266 in failover nids string, have $NIDCOUNT"
1267 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1268 error "Failover nid not added"
1270 if [[ $PERM_CMD = *"set_param -P"* ]]; then
1271 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1273 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1274 error "$PERM_CMD delete failed"
1276 umount_client $MOUNT
1277 mount_client $MOUNT || error "mount_client $MOUNT failed"
1279 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1281 NIDCOUNT=$(echo "$NIDS" | wc -w)
1282 echo "only $orignidcount final entries should remain \
1283 in failover nids string, have $NIDCOUNT"
1284 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1286 cleanup || error "cleanup failed with rc $?"
1288 run_test 30b "Remove failover nids"
1290 test_31() { # bug 10734
1291 # ipaddr must not exist
1292 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1293 cleanup || error "cleanup failed with rc $?"
1295 run_test 31 "Connect to non-existent node (shouldn't crash)"
1299 T32_BLIMIT=40960 # Kbytes
1303 # This is not really a test but a tool to create new disk
1304 # image tarballs for the upgrade tests.
1306 # Disk image tarballs should be created on single-node
1307 # clusters by running this test with default configurations
1308 # plus a few mandatory environment settings that are verified
1309 # at the beginning of the test.
1311 test_32newtarball() {
1315 local tmp=$TMP/t32_image_create
1320 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1321 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1322 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1323 "MDSDEV1=<nonexistent_file>" \
1324 "MDSDEV2=<nonexistent_file>" \
1325 "(or MDSDEV, in the case of b1_8)" \
1326 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1330 echo "Found stale $tmp"
1334 mkdir $tmp/src || return 1
1335 tar cf - -C $src . | tar xf - -C $tmp/src
1336 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1337 count=$(($T32_BLIMIT / 1024 / 4))
1338 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1340 # format ost with comma-separated NIDs to verify LU-4460
1341 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1342 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1346 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1347 $LFS quotacheck -ug /mnt/$FSNAME
1348 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1351 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1353 if [[ $MDSCOUNT -ge 2 ]]; then
1354 remote_dir=/mnt/$FSNAME/remote_dir
1355 $LFS mkdir -i 1 $remote_dir
1356 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1358 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1359 striped_dir=/mnt/$FSNAME/striped_dir_old
1360 $LFS mkdir -i 1 -c 2 $striped_dir
1361 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1367 mkdir $tmp/img || return 1
1371 pushd_dir=/mnt/$FSNAME
1372 if [[ $MDSCOUNT -ge 2 ]]; then
1373 pushd_dir=$remote_dir
1374 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1376 ls -Rni --time-style=+%s >$tmp/img/list2
1382 ls -Rni --time-style=+%s >$tmp/img/list
1383 find ! -name .lustre -type f -exec sha1sum {} \; |
1384 sort -k 2 >$tmp/img/sha1sums
1386 $LCTL get_param -n version | head -n 1 |
1387 sed -e 's/^lustre: *//' >$tmp/img/commit
1389 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1390 $LFS quotaon -ug /mnt/$FSNAME
1391 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1392 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1393 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1394 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1395 | tr -d "*" > $tmp/img/bspace
1396 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1397 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1398 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1399 | tr -d "*" > $tmp/img/ispace
1400 echo $T32_BLIMIT > $tmp/img/blimit
1401 echo $T32_ILIMIT > $tmp/img/ilimit
1406 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1409 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1410 echo "Data verification failed"
1413 uname -r >$tmp/img/kernel
1414 uname -m >$tmp/img/arch
1416 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1417 for num in $(seq 2 $MDSCOUNT); do
1418 local devname=$(mdsdevname $num)
1420 [[ $(facet_fstype $facet) != zfs ]] ||
1421 devname=$(mdsvdevname $num)
1422 mv $devname $tmp/img
1424 mv $OSTDEV1 $tmp/img
1426 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1427 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1430 tar cjvf $dst/disk$version-"$mds1_FSTYPE".tar.bz2 -S *
1435 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1438 # The list of applicable tarballs is returned via the caller's
1439 # variable "tarballs".
1442 [ "$CLIENTONLY" ] && skip "Client-only testing"
1444 local node=$(facet_active_host $SINGLEMDS)
1445 local r="do_node $node"
1447 ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
1449 local IMGTYPE="$mds1_FSTYPE"
1451 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1452 -name \'disk*-$IMGTYPE.tar.bz2\')
1454 [ -z "$tarballs" ] && skip "No applicable tarballs found"
1457 t32_test_cleanup() {
1459 local facet=$SINGLEMDS
1462 if $shall_cleanup_lustre; then
1463 umount $tmp/mnt/lustre || rc=$?
1465 if $shall_cleanup_mdt; then
1466 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1468 if $shall_cleanup_mdt1; then
1469 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1471 if $shall_cleanup_ost; then
1472 $r $UMOUNT $tmp/mnt/ost || rc=$?
1477 if [[ "$mds1_FSTYPE" == zfs ]]; then
1479 local poolname_list="t32fs-mdt1 t32fs-ost1"
1481 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1483 for poolname in $poolname_list; do
1484 destroy_zpool $facet $poolname
1487 combined_mgs_mds || start_mgs || rc=$?
1491 t32_bits_per_long() {
1493 # Yes, this is not meant to be perfect.
1503 t32_reload_modules() {
1505 local all_removed=false
1508 [ "$mds1_FSTYPE" == zfs ] && do_rpc_nodes $node "service zed stop"
1510 while ((i < 20)); do
1511 echo "Unloading modules on $node: Attempt $i"
1512 do_rpc_nodes $node $LUSTRE_RMMOD "$mds1_FSTYPE" &&
1514 do_rpc_nodes $node check_mem_leak || return 1
1515 if $all_removed; then
1516 do_rpc_nodes $node load_modules
1519 if [ "$mds1_FSTYPE" == zfs ]; then
1520 do_rpc_nodes $node "$ZPOOL status -v"
1525 echo "Unloading modules on $node: Given up"
1529 t32_wait_til_devices_gone() {
1535 echo wait for devices to go
1536 while ((i < 20)); do
1537 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1538 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1539 ((devices == 0 && loops == 0)) && return 0
1543 echo "waiting for dev on $node: dev $devices loop $loops given up"
1544 do_rpc_nodes $node "losetup -a"
1545 do_rpc_nodes $node "$LCTL device_list"
1549 t32_verify_quota() {
1556 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1557 # lustre will estimate the object count usage. This fails quota
1558 # verification in 32b. The object quota usage should be accurate after
1559 # zfs-0.7.0 is released.
1560 [ "$mds1_FSTYPE" == zfs ] && {
1561 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1563 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1564 echo "Skip quota verify for zfs: $zfs_version"
1569 $LFS quota -u $T32_QID -v $mnt
1571 qval=$($LFS quota -v -u $T32_QID $mnt |
1572 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1573 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1575 [ $qval -eq $img_bspace ] || {
1576 echo "bspace, act:$qval, exp:$img_bspace"
1580 qval=$($LFS quota -v -u $T32_QID $mnt |
1581 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1582 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1584 [ $qval -eq $img_ispace ] || {
1585 echo "ispace, act:$qval, exp:$img_ispace"
1589 qval=$($LFS quota -v -u $T32_QID $mnt |
1590 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1591 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1593 [ $qval -eq $img_blimit ] || {
1594 echo "blimit, act:$qval, exp:$img_blimit"
1598 qval=$($LFS quota -v -u $T32_QID $mnt |
1599 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1600 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1602 [ $qval -eq $img_ilimit ] || {
1603 echo "ilimit, act:$qval, exp:$img_ilimit"
1607 set_persistent_param_and_check $facet \
1608 "osd-$mds1_FSTYPE.$fsname-MDT0000.quota_slave.enabled" \
1609 "$fsname.quota.mdt" ug
1611 set_persistent_param_and_check $facet \
1612 "osd-$mds1_FSTYPE.$fsname-OST0000.quota_slave.enabled" \
1613 "$fsname.quota.ost" ug
1616 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1617 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1618 echo "Write succeed, but expect -EDQUOT"
1621 rm -f $mnt/t32_qf_new
1623 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1625 echo "Create succeed, but expect -EDQUOT"
1628 unlinkmany $mnt/t32_qf_ $img_ilimit
1636 local dne_upgrade=${dne_upgrade:-"no"}
1637 local dom_upgrade=${dom_upgrade:-"no"}
1638 local ff_convert=${ff_convert:-"no"}
1639 local shall_cleanup_mdt=false
1640 local shall_cleanup_mdt1=false
1641 local shall_cleanup_ost=false
1642 local shall_cleanup_lustre=false
1643 local mdt2_is_available=false
1644 local node=$(facet_active_host $SINGLEMDS)
1645 local r="do_node $node"
1661 local mdt_dev=$tmp/mdt
1662 local mdt2_dev=$tmp/mdt2
1663 local ost_dev=$tmp/ost
1668 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1669 trap 'trap - RETURN; t32_test_cleanup' RETURN
1672 nid=$($r $LCTL list_nids | head -1)
1674 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1675 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1676 $r tar xjvf $tarball -S -C $tmp || {
1677 error_noexit "Unpacking the disk image tarball"
1680 img_commit=$($r cat $tmp/commit)
1681 img_kernel=$($r cat $tmp/kernel)
1682 img_arch=$($r cat $tmp/arch)
1683 img_bspace=$($r cat $tmp/bspace)
1684 img_ispace=$($r cat $tmp/ispace)
1686 # older images did not have "blimit" and "ilimit" files
1687 # use old values for T32_BLIMIT and T32_ILIMIT
1688 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1690 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1693 echo "Upgrading from $(basename $tarball), created with:"
1694 echo " Commit: $img_commit"
1695 echo " Kernel: $img_kernel"
1696 echo " Arch: $img_arch"
1697 echo "OST version: $(lustre_build_version ost1)"
1699 # The conversion can be made only when both of the following
1700 # conditions are satisfied:
1701 # - ost device img version < 2.3.64
1702 # - ost server version >= 2.5
1703 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1704 "$OST1_VERSION" -lt $(version_code 2.5.0) ] &&
1707 ! $r test -f $mdt2_dev || mdt2_is_available=true
1709 if [[ "$mds1_FSTYPE" == zfs ]]; then
1712 local poolname_list="t32fs-mdt1 t32fs-ost1"
1714 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1716 for poolname in $poolname_list; do
1718 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1719 $ZPOOL import -f -d $tmp $poolname"
1722 # upgrade zpool to latest supported features, including
1723 # dnode quota accounting in 0.7.0
1724 $r "$ZPOOL upgrade -a"
1726 mdt_dev=t32fs-mdt1/mdt1
1727 ost_dev=t32fs-ost1/ost1
1728 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1729 wait_update_facet $SINGLEMDS "$ZPOOL list |
1730 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1731 error_noexit "import zfs pool failed"
1736 $r $LCTL set_param debug="$PTLDEBUG"
1738 $r $TUNEFS --dryrun $mdt_dev || {
1740 error_noexit "tunefs.lustre before mounting the MDT"
1744 if $mdt2_is_available; then
1745 $r $TUNEFS --dryrun $mdt2_dev || {
1747 error_noexit "tunefs.lustre before mounting the MDT"
1752 if [ "$writeconf" ]; then
1754 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1756 $r $TUNEFS --quota $mdt_dev || {
1758 error_noexit "Enable mdt quota feature"
1761 if $mdt2_is_available; then
1762 $r $TUNEFS --quota $mdt2_dev || {
1764 error_noexit "Enable mdt quota feature"
1770 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1771 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
1772 skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
1773 "(Need MGS version at least 2.3.59)"
1775 local osthost=$(facet_active_host ost1)
1776 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1779 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1782 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1783 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1784 $r $LCTL replace_nids $fsname-MDT0000 $nid
1785 $r $UMOUNT $tmp/mnt/mdt
1788 mopts=exclude=$fsname-OST0000
1789 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1794 t32_wait_til_devices_gone $node
1796 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1798 error_noexit "Mounting the MDT"
1801 shall_cleanup_mdt=true
1803 if $mdt2_is_available; then
1804 mopts=mgsnode=$nid,$mopts
1805 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1807 error_noexit "Mounting the MDT"
1811 echo "mount new MDT....$mdt2_dev"
1812 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1813 error_noexit "enable remote dir create failed"
1815 shall_cleanup_mdt1=true
1816 elif [ "$dne_upgrade" != "no" ]; then
1817 local fs2mdsdev=$(mdsdevname 1_2)
1818 local fs2mdsvdev=$(mdsvdevname 1_2)
1820 echo "mkfs new MDT on ${fs2mdsdev}...."
1821 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1822 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1825 add $SINGLEMDS $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1826 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1827 error_noexit "Mkfs new MDT failed"
1831 [[ "$mds1_FSTYPE" != zfs ]] || import_zpool mds1
1833 $r $TUNEFS --dryrun $fs2mdsdev || {
1834 error_noexit "tunefs.lustre before mounting the MDT"
1838 echo "mount new MDT....$fs2mdsdev"
1839 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1840 error_noexit "mount mdt1 failed"
1844 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1845 error_noexit "enable remote dir create failed"
1847 shall_cleanup_mdt1=true
1850 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1851 error_noexit "Getting MDT UUID"
1854 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1855 error_noexit "Unexpected MDT UUID: \"$uuid\""
1859 $r $TUNEFS --dryrun $ost_dev || {
1860 error_noexit "tunefs.lustre before mounting the OST"
1863 if [ "$writeconf" ]; then
1864 mopts=mgsnode=$nid,$writeconf
1865 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1867 $r $TUNEFS --quota $ost_dev || {
1869 error_noexit "Enable ost quota feature"
1875 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1880 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1881 error_noexit "Mounting the OST"
1884 shall_cleanup_ost=true
1886 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1887 error_noexit "Getting OST UUID"
1890 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1891 error_noexit "Unexpected OST UUID: \"$uuid\""
1895 if [[ $PERM_CMD = *"set_param -P"* ]]; then
1896 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
1897 error_noexit "Setting OST \"failover.node\""
1900 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
1901 error_noexit "Setting MDT \"failover.node\""
1904 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
1905 error_noexit "Setting \"max_dirty_mb\""
1908 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
1909 error_noexit "Setting \"max_rpcs_in_flight\""
1912 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
1913 error_noexit "Setting \"lov.stripesize\""
1916 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
1917 error_noexit "Setting \"mdd.atime_diff\""
1921 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
1922 error_noexit "Setting OST \"failover.node\""
1926 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
1927 error_noexit "Setting MDT \"failover.node\""
1931 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
1932 error_noexit "Setting \"max_dirty_mb\""
1935 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1936 error_noexit "Setting \"max_rpcs_in_flight\""
1939 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
1940 error_noexit "Setting \"lov.stripesize\""
1943 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
1944 error_noexit "Setting \"mdd.atime_diff\""
1949 $r $LCTL pool_new $fsname.interop || {
1950 error_noexit "Setting \"interop\""
1954 if [ "$ff_convert" != "no" -a "$ost1_FSTYPE" == 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 if [[ $PERM_CMD = *"set_param -P"* ]]; then
1980 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
1981 error_noexit "Setting MDT1 \"failover.node\""
1985 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
1986 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
1989 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
1990 error_noexit "Setting MDT1 \"lov.stripesize\""
1994 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
1995 error_noexit "Setting MDT1 \"failover.node\""
1998 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
1999 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2002 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2003 error_noexit "Setting MDT1 \"lov.stripesize\""
2009 if [ "$writeconf" ]; then
2010 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2011 error_noexit "Mounting the client"
2015 shall_cleanup_lustre=true
2016 $r $LCTL set_param debug="$PTLDEBUG"
2018 # Leave re-enabling this to a separate patch for LU-11558
2019 # t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2020 # error_noexit "verify quota failed"
2024 if $r test -f $tmp/list; then
2026 # There is not a Test Framework API to copy files to or
2027 # from a remote node.
2029 # LU-2393 - do both sorts on same node to ensure locale
2031 local list_file=$tmp/list
2033 if $mdt2_is_available; then
2034 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2035 $r test -f $tmp/list2; then
2036 list_file=$tmp/list2
2037 pushd $tmp/mnt/lustre/striped_dir_old
2039 pushd $tmp/mnt/lustre/remote_dir
2042 pushd $tmp/mnt/lustre
2044 $r cat $list_file | sort -k 6 >$tmp/list.orig
2045 ls -Rni --time-style=+%s | sort -k 6 |
2046 sed 's/\. / /' >$tmp/list || {
2052 # 32-bit and 64-bit clients use different algorithms to
2053 # convert FIDs into inode numbers. Hence, remove the
2054 # inode numbers from the lists, if the original list was
2055 # created on an architecture with different number of
2058 if [ $(t32_bits_per_long $(uname -m)) != \
2059 $(t32_bits_per_long $img_arch) ]; then
2060 echo "Different number of bits per \"long\"" \
2061 "from the disk image"
2062 for list in list.orig list; do
2063 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2067 if ! diff -ub $tmp/list.orig $tmp/list; then
2068 error_noexit "list verification failed"
2072 echo "list verification skipped"
2075 if [ "$dom_upgrade" != "no" ]; then
2076 echo "Check DoM file can be created"
2077 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2078 error_noexit "Verify DoM creation"
2081 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2082 error_noexit "Verify a DoM file"
2085 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2086 count=1 conv=fsync || {
2087 error_noexit "Cannot write to DoM file"
2090 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2091 error_noexit "DoM: bad size after write"
2094 rm $tmp/mnt/lustre/dom
2096 set_persistent_param_and_check mds \
2097 "lod.*MDT0000*.dom_stripesize" \
2098 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2099 error_noexit "Changing \"dom_stripesize\""
2104 if [ "$dne_upgrade" != "no" ]; then
2105 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2106 error_noexit "set striped dir failed"
2110 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2112 pushd $tmp/mnt/lustre
2113 tar -c --exclude=./striped_dir \
2114 --exclude=./striped_dir_old \
2115 --exclude=./remote_dir -f - .|
2116 tar -xvf - -C striped_dir 1>/dev/null || {
2117 error_noexit "cp to striped dir failed"
2123 # If it is upgrade from DNE (2.5), then rename the remote dir,
2124 # which is created in 2.5 to striped dir.
2125 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2126 stripe_index=$($LFS getdirstripe -i \
2127 $tmp/mnt/lustre/remote_dir)
2129 [[ $stripe_index -eq 1 ]] || {
2130 error_noexit "get index \"$stripe_index\"" \
2131 "from remote dir failed"
2134 mv $tmp/mnt/lustre/remote_dir \
2135 $tmp/mnt/lustre/striped_dir/ || {
2136 error_noexit "mv remote dir failed"
2141 # If it is upgraded from DNE (2.7), then move the striped dir
2142 # which was created in 2.7 to the new striped dir.
2143 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2144 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2145 stripe_count=$($LFS getdirstripe -c \
2146 $tmp/mnt/lustre/striped_dir_old)
2147 [[ $stripe_count -eq 2 ]] || {
2148 error_noexit "get count $stripe_count" \
2149 "from striped dir failed"
2152 mv $tmp/mnt/lustre/striped_dir_old \
2153 $tmp/mnt/lustre/striped_dir/ || {
2154 error_noexit "mv striped dir failed"
2160 $r $LCTL set_param -n osd*.*.force_sync=1
2161 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2162 error_noexit "dd failed"
2165 rm -rf $tmp/mnt/lustre/tmp_file || {
2166 error_noexit "rm failed"
2170 if $r test -f $tmp/sha1sums; then
2171 # LU-2393 - do both sorts on same node to ensure locale
2173 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2174 if [ "$dne_upgrade" != "no" ]; then
2175 pushd $tmp/mnt/lustre/striped_dir
2177 pushd $tmp/mnt/lustre
2180 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2181 ! -name .lustre -type f -exec sha1sum {} \; |
2182 sort -k 2 >$tmp/sha1sums || {
2184 error_noexit "sha1sum"
2188 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2189 error_noexit "sha1sum verification failed"
2193 # if upgrade from DNE(2.5), then check remote directory
2194 # if upgrade from DNE(2.7), then check striped directory
2195 if $mdt2_is_available &&
2196 [[ "$dne_upgrade" != "no" ]]; then
2197 local new_dir="$tmp/mnt/lustre/striped_dir"
2198 local striped_dir_old="$new_dir/striped_dir_old"
2200 local dir_list="$new_dir/remote_dir"
2201 [[ ! -d $triped_dir_old ]] ||
2202 dir_list+=" $striped_dir_old"
2204 for dir in $dir_list; do
2206 find ! -name .lustre -type f \
2207 -exec sha1sum {} \; |
2208 sort -k 2 >$tmp/sha1sums || {
2210 error_noexit "sha1sum"
2214 if ! diff -ub $tmp/sha1sums.orig \
2216 error_noexit "sha1sum $dir" \
2223 echo "sha1sum verification skipped"
2226 if [ "$dne_upgrade" != "no" ]; then
2227 rm -rf $tmp/mnt/lustre/striped_dir || {
2228 error_noexit "remove remote dir failed"
2233 # migrate files/dirs to remote MDT, then move them back
2234 if [ "$MDS1_VERSION" -ge $(version_code 2.7.50) -a \
2235 $dne_upgrade != "no" ]; then
2236 $r $LCTL set_param -n \
2237 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2239 echo "test migration"
2240 pushd $tmp/mnt/lustre
2241 for dir in $(find ! -name .lustre ! -name . -type d); do
2242 mdt_index=$($LFS getdirstripe -i $dir)
2243 stripe_cnt=$($LFS getdirstripe -c $dir)
2244 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2245 $LFS migrate -m 1 $dir || {
2247 error_noexit "migrate MDT1 failed"
2253 for dir in $(find ! -name . ! -name .lustre -type d); do
2254 mdt_index=$($LFS getdirstripe -i $dir)
2255 stripe_cnt=$($LFS getdirstripe -c $dir)
2256 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2257 $LFS migrate -m 0 $dir || {
2259 error_noexit "migrate MDT0 failed"
2268 # When adding new data verification tests, please check for
2269 # the presence of the required reference files first, like
2270 # the "sha1sums" and "list" tests above, to avoid the need to
2271 # regenerate every image for each test addition.
2274 nrpcs_orig=$($LCTL get_param \
2275 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2276 error_noexit "Getting \"max_rpcs_in_flight\""
2279 nrpcs=$((nrpcs_orig + 5))
2281 set_persistent_param_and_check client \
2282 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
2283 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
2284 error_noexit "Changing \"max_rpcs_in_flight\""
2288 umount $tmp/mnt/lustre || {
2289 error_noexit "Unmounting the client"
2292 shall_cleanup_lustre=false
2294 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2295 $r $UMOUNT $tmp/mnt/mdt1 || {
2296 error_noexit "Unmounting the MDT2"
2299 if [[ "$mds1_FSTYPE" == zfs ]]; then
2300 $r "$ZPOOL export t32fs-mdt2"
2302 shall_cleanup_mdt1=false
2305 $r $UMOUNT $tmp/mnt/mdt || {
2306 error_noexit "Unmounting the MDT"
2309 if [[ "$mds1_FSTYPE" == zfs ]]; then
2310 $r "$ZPOOL export t32fs-mdt1"
2312 shall_cleanup_mdt=false
2314 $r $UMOUNT $tmp/mnt/ost || {
2315 error_noexit "Unmounting the OST"
2318 if [[ "$mds1_FSTYPE" == zfs ]]; then
2319 $r "$ZPOOL export t32fs-ost1"
2321 shall_cleanup_ost=false
2323 t32_reload_modules $node || {
2324 error_noexit "Reloading modules"
2328 if [[ "$mds1_FSTYPE" == zfs ]]; then
2329 local poolname=t32fs-mdt1
2331 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2332 $ZPOOL import -f -d $tmp $poolname"
2334 # upgrade zpool to latest supported features,
2335 # including dnode quota accounting in 0.7.0
2336 $r "$ZPOOL upgrade $poolname"
2339 # mount a second time to make sure we didnt leave upgrade flag on
2340 $r $TUNEFS --dryrun $mdt_dev || {
2342 error_noexit "tunefs.lustre before remounting the MDT"
2346 mopts=exclude=$fsname-OST0000
2347 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2350 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2351 error_noexit "Remounting the MDT"
2354 shall_cleanup_mdt=true
2364 for tarball in $tarballs; do
2365 t32_test $tarball || let "rc += $?"
2369 run_test 32a "Upgrade (not live)"
2377 for tarball in $tarballs; do
2378 t32_test $tarball writeconf || let "rc += $?"
2382 run_test 32b "Upgrade with writeconf"
2389 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2391 for tarball in $tarballs; do
2392 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2393 echo $tarball | grep "1_8" && continue
2394 echo $tarball | grep "2_1" && continue
2396 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2400 run_test 32c "dne upgrade test"
2408 for tarball in $tarballs; do
2409 ff_convert=yes t32_test $tarball || rc=$?
2413 run_test 32d "convert ff test"
2416 [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
2417 skip "Need MDS version at least 2.10.56"
2424 for tarball in $tarballs; do
2425 echo $tarball | grep "2_9" || continue
2427 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
2431 run_test 32e "dom upgrade test"
2433 test_33a() { # bug 12333, was test_33
2434 local FSNAME2=test-123
2435 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2438 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2440 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2441 local dev=${SINGLEMDS}_dev
2442 local MDSDEV=${!dev}
2443 is_blkdev $SINGLEMDS $MDSDEV &&
2444 skip_env "mixed loopback and real device not working"
2447 local fs2mdsdev=$(mdsdevname 1_2)
2448 local fs2ostdev=$(ostdevname 1_2)
2449 local fs2mdsvdev=$(mdsvdevname 1_2)
2450 local fs2ostvdev=$(ostvdevname 1_2)
2452 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2453 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2456 if combined_mgs_mds; then
2457 local mgs_flag="--mgs"
2460 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
2461 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
2463 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2464 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2465 $fs2ostvdev || exit 10
2467 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2468 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2470 if [[ $PERM_CMD = *"set_param -P"* ]]; then
2471 do_facet mgs "$PERM_CMD timeout=200" ||
2472 error "$PERM_CMD timeout=200 failed"
2474 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
2475 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
2477 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2478 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2481 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2482 $GETSTRIPE $MOUNT2/hosts || error "$GETSTRIPE $MOUNT2/hosts failed"
2487 cleanup_nocli || error "cleanup_nocli failed with $?"
2489 run_test 33a "Mount ost with a large index number"
2491 test_33b() { # was test_34
2494 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2495 # Drop lock cancelation reply during umount
2496 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2497 do_facet client $LCTL set_param fail_loc=0x80000304
2498 #lctl set_param debug=-1
2499 umount_client $MOUNT
2500 cleanup || error "cleanup failed with $?"
2502 run_test 33b "Drop cancel during umount"
2506 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2507 manual_umount_client
2509 do_facet client killall -USR1 multiop
2510 if [ $rc -eq 0 ]; then
2511 error "umount not fail!"
2514 cleanup || error "cleanup failed with rc $?"
2516 run_test 34a "umount with opened file should be fail"
2520 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2521 stop_mds || error "Unable to stop MDS"
2523 manual_umount_client --force || error "mtab after failed umount with $?"
2525 cleanup || error "cleanup failed with $?"
2527 run_test 34b "force umount with failed mds should be normal"
2531 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2532 stop_ost || error "Unable to stop OST1"
2534 manual_umount_client --force || error "mtab after failed umount with $?"
2536 cleanup || error "cleanup failed with $?"
2538 run_test 34c "force umount with failed ost should be normal"
2540 test_35a() { # bug 12459
2543 DBG_SAVE="`$LCTL get_param -n debug`"
2544 $LCTL set_param debug="ha"
2546 log "Set up a fake failnode for the MDS"
2548 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2549 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2551 if [[ $PERM_CMD = *"set_param -P"* ]]; then
2552 do_facet mgs "$PERM_CMD \
2553 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2554 error "Setting mdc.*${device}*.import=connection=\
2555 $(h2nettype $FAKENID) failed."
2557 do_facet mgs "$PERM_CMD \
2558 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2559 error "Setting ${device}.failover.node=\
2560 $(h2nettype $FAKENID) failed."
2562 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2565 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2568 log "Stopping the MDT: $device"
2569 stop_mdt 1 || error "MDT0 stop fail"
2571 df $MOUNT > /dev/null 2>&1 &
2573 log "Restarting the MDT: $device"
2574 start_mdt 1 || error "MDT0 start fail"
2575 log "Wait for df ($DFPID) ... "
2578 $LCTL set_param debug="$DBG_SAVE"
2580 # retrieve from the log the first server that the client tried to
2581 # contact after the connection loss
2582 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2583 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2584 /import_select_connection.*$device-mdc.* using connection/ {
2586 if (\\\$NF ~ /$FAKENID/)
2592 }" $TMP/lustre-log-$TESTNAME.log`
2593 [ "$NEXTCONN" != "0" ] &&
2594 error "Tried to connect to ${NEXTCONN} not last active server"
2595 cleanup || error "cleanup failed with $?"
2596 # remove nid settings
2597 writeconf_or_reformat
2599 run_test 35a "Reconnect to the last active server first"
2601 test_35b() { # bug 18674
2602 remote_mds || skip "local MDS"
2606 $LCTL set_param debug="ha"
2608 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2611 log "Set up a fake failnode for the MDS"
2613 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2614 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2616 if [[ $PERM_CMD = *"set_param -P"* ]]; then
2617 do_facet mgs "$PERM_CMD \
2618 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2619 error "Set mdc.*${device}*.import=connection=\
2620 $(h2nettype $FAKENID) failed"
2622 do_facet mgs "$PERM_CMD \
2623 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2624 error "Set ${device}.failover.node=\
2625 $(h2nettype $FAKENID) failed"
2628 local at_max_saved=0
2629 # adaptive timeouts may prevent seeing the issue
2630 if at_is_enabled; then
2631 at_max_saved=$(at_max_get mds)
2632 at_max_set 0 mds client
2635 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2637 log "Injecting EBUSY on MDS"
2638 # Setting OBD_FAIL_MDS_RESEND=0x136
2639 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2640 error "unable to set param fail_loc=0x80000136"
2642 $LCTL set_param mdc.${FSNAME}*.stats=clear
2644 log "Creating a test file and stat it"
2645 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2646 stat $MOUNT/$tdir/$tfile
2648 log "Stop injecting EBUSY on MDS"
2649 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2650 error "unable to set param fail_loc=0"
2651 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2654 # restore adaptive timeout
2655 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2657 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2659 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2660 awk '/mds_connect/{print $2}')
2662 # retrieve from the log if the client has ever tried to
2663 # contact the fake server after the loss of connection
2664 FAILCONN=`awk "BEGIN {ret = 0;}
2665 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2667 if (\\\$NF ~ /$FAKENID/) {
2672 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2674 [ "$FAILCONN" == "0" ] &&
2675 error "The client reconnection has not been triggered"
2676 [ "$FAILCONN" == "2" ] &&
2677 error "Primary server busy, client reconnect to failover failed"
2680 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2681 # Reconnects are supposed to be rate limited to one every 5s
2682 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2683 error "Too many reconnects $CONNCNT"
2685 cleanup || error "cleanup failed with $?"
2686 # remove nid settings
2687 writeconf_or_reformat
2689 run_test 35b "Continue reconnection retries, if the active server is busy"
2692 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2694 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2698 local FSNAME2=test1234
2699 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2701 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2703 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2704 is_blkdev $SINGLEMDS $MDSDEV &&
2705 skip_env "mixed loopback and real device not working"
2708 local fs2mdsdev=$(mdsdevname 1_2)
2709 local fs2ostdev=$(ostdevname 1_2)
2710 local fs3ostdev=$(ostdevname 2_2)
2711 local fs2mdsvdev=$(mdsvdevname 1_2)
2712 local fs2ostvdev=$(ostvdevname 1_2)
2713 local fs3ostvdev=$(ostvdevname 2_2)
2716 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2717 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2718 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2719 # different one than the default value here.
2720 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2721 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2722 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2723 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2725 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2726 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2727 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2728 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2729 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2731 sleep 5 # until 11778 fixed
2733 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2735 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2736 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2737 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2738 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2739 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2740 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2741 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2742 DFTOTAL=$(echo $STRING | cut -d, -f1)
2743 DFUSED=$(echo $STRING | cut -d, -f2)
2744 DFAVAIL=$(echo $STRING | cut -d, -f3)
2745 DFFREE=$(($DFTOTAL - $DFUSED))
2747 ALLOWANCE=$((64 * $OSTCOUNT))
2749 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2750 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2751 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2754 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2755 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2756 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2759 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2760 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2761 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2766 stop fs3ost -f || error "unable to stop OST3"
2767 stop fs2ost -f || error "unable to stop OST2"
2768 stop fs2mds -f || error "unable to stop second MDS"
2769 unload_modules_conf || error "unable unload modules"
2772 run_test 36 "df report consistency on OSTs with different block size"
2775 local mntpt=$(facet_mntpt $SINGLEMDS)
2776 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2777 local mdsdev_sym="$TMP/sym_mdt.img"
2778 local opts=$MDS_MOUNT_OPTS
2781 if [ "$mds1_FSTYPE" != ldiskfs ]; then
2782 skip "ldiskfs only test"
2785 echo "MDS : $mdsdev"
2786 echo "SYMLINK : $mdsdev_sym"
2787 do_facet $SINGLEMDS rm -f $mdsdev_sym
2789 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2791 echo "mount symlink device - $mdsdev_sym"
2793 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2794 opts=$(csa_add "$opts" -o loop)
2798 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2799 $mdsdev_sym $mntpt 2>&1)
2802 echo mount_op=$mount_op
2804 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2806 if $(echo $mount_op | grep -q "unable to set tunable"); then
2807 error "set tunables failed for symlink device"
2810 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2812 run_test 37 "verify set tunables works for symlink device"
2814 test_38() { # bug 14222
2815 local mntpt=$(facet_mntpt $SINGLEMDS)
2820 local SRC="/etc /bin"
2821 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2822 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2823 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2824 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2825 error "copying $SRC to $DIR/$tdir"
2827 umount_client $MOUNT || error "umount_client $MOUNT failed"
2828 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2829 stop_mds || error "Unable to stop MDS"
2830 log "delete lov_objid file on MDS"
2832 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2834 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2836 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2838 # check create in mds_lov_connect
2839 start_mds || error "unable to start MDS"
2840 mount_client $MOUNT || error "mount_client $MOUNT failed"
2842 [ $V ] && log "verifying $DIR/$tdir/$f"
2843 diff -q $f $DIR/$tdir/$f || ERROR=y
2845 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2846 if [ "$ERROR" = "y" ]; then
2847 # check it's updates in sync
2848 umount_client $MOUNT
2850 mount_fstype $SIGNLEMDS
2851 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2852 unmount_fstype $SINGLEMDS
2853 error "old and new files are different after connect" || true
2855 touch $DIR/$tdir/f2 || error "f2 file create failed"
2857 # check it's updates in sync
2858 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2861 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2863 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2864 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2866 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2868 start_mds || error "unable to start MDS"
2869 mount_client $MOUNT || error "mount_client $MOUNT failed"
2871 [ $V ] && log "verifying $DIR/$tdir/$f"
2872 diff -q $f $DIR/$tdir/$f || ERROR=y
2874 touch $DIR/$tdir/f3 || error "f3 file create failed"
2875 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2876 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2878 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2879 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2880 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2882 [ "$ERROR" = "y" ] &&
2883 error "old and new files are different after sync" || true
2885 log "files compared the same"
2886 cleanup || error "cleanup failed with $?"
2888 run_test 38 "MDS recreates missing lov_objid file from OST data"
2893 cleanup || error "cleanup failed with $?"
2894 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2895 error "memory leak detected" || true
2897 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2899 test_40() { # bug 15759
2900 start_ost || error "Unable to start OST1"
2901 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2902 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2904 cleanup || error "cleanup failed with rc $?"
2906 run_test 40 "race during service thread startup"
2908 test_41a() { #bug 14134
2909 if [ "$mds1_FSTYPE" == ldiskfs ] &&
2910 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2911 skip "Loop devices does not work with nosvc option"
2914 combined_mgs_mds || skip "needs combined MGT and MDT device"
2916 start_mdt 1 -o nosvc -n
2917 if [ $MDSCOUNT -ge 2 ]; then
2918 for num in $(seq 2 $MDSCOUNT); do
2919 start_mdt $num || return
2922 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2923 start_mdt 1 -o nomgs,force
2924 mount_client $MOUNT || error "mount_client $MOUNT failed"
2927 echo "blah blah" > $MOUNT/$tfile
2930 umount_client $MOUNT || error "umount_client $MOUNT failed"
2931 stop ost1 -f || error "unable to stop OST1"
2932 stop_mds || error "Unable to stop MDS"
2933 stop_mds || error "Unable to stop MDS on second try"
2935 run_test 41a "mount mds with --nosvc and --nomgs"
2938 if [ "$mds1_FSTYPE" == ldiskfs ] &&
2939 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2940 skip "Loop devices does not work with nosvc option"
2943 ! combined_mgs_mds && skip "needs combined mgs device"
2947 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2949 start_mdt 1 -o nosvc -n
2950 if [ $MDSCOUNT -ge 2 ]; then
2951 for num in $(seq 2 $MDSCOUNT); do
2952 start_mdt $num || return
2955 start_ost || error "Unable to start OST1"
2956 start_mdt 1 -o nomgs,force
2957 mount_client $MOUNT || error "mount_client $MOUNT failed"
2960 echo "blah blah" > $MOUNT/$tfile
2961 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
2963 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
2964 stop_ost || error "Unable to stop OST1"
2965 stop_mds || error "Unable to stop MDS"
2966 stop_mds || error "Unable to stop MDS on second try"
2968 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2971 local oss_list=$(comma_list $(osts_nodes))
2973 [[ "$MDS1_VERSION" -ge $(version_code 2.6.52) ]] ||
2974 [[ "$MDS1_VERSION" -ge $(version_code 2.5.26) &&
2975 "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
2976 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
2977 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]] ||
2978 skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"
2980 # ensure mds1 ost1 have been created even if running sub-test standalone
2983 cleanup || error "cleanup failed"
2985 # using directly mount command instead of start() function to avoid
2986 # any side effect of // with others/externals tools/features
2987 # ("zpool import", ...)
2989 # MDT concurrent start
2991 LOAD_MODULES_REMOTE=true load_modules
2992 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
2993 error "MDT concurrent start: libcfs module not loaded"
2995 local mds1dev=$(mdsdevname 1)
2996 local mds1mnt=$(facet_mntpt mds1)
2997 local mds1opts=$MDS_MOUNT_OPTS
2999 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3000 ! do_facet mds1 test -b $mds1dev; then
3001 mds1opts=$(csa_add "$mds1opts" -o loop)
3003 if [[ "$mds1_FSTYPE" == zfs ]]; then
3004 import_zpool mds1 || return ${PIPESTATUS[0]}
3007 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3008 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
3010 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
3013 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
3017 do_facet mds1 "$LCTL set_param fail_loc=0x0"
3018 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3019 echo "1st MDT start succeed"
3020 echo "2nd MDT start failed with $rc2"
3021 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3022 echo "1st MDT start failed with $rc"
3023 echo "2nd MDT start succeed"
3026 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
3029 if [ $MDSCOUNT -ge 2 ]; then
3030 for num in $(seq 2 $MDSCOUNT); do
3031 start_mdt $num || return
3035 # OST concurrent start
3037 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
3038 error "OST concurrent start: libcfs module not loaded"
3040 local ost1dev=$(ostdevname 1)
3041 local ost1mnt=$(facet_mntpt ost1)
3042 local ost1opts=$OST_MOUNT_OPTS
3044 if [ "$ost1_FSTYPE" == ldiskfs ] &&
3045 ! do_facet ost1 test -b $ost1dev; then
3046 ost1opts=$(csa_add "$ost1opts" -o loop)
3048 if [[ "$ost1_FSTYPE" == zfs ]]; then
3049 import_zpool ost1 || return ${PIPESTATUS[0]}
3052 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3053 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
3055 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
3058 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
3062 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3063 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3064 echo "1st OST start succeed"
3065 echo "2nd OST start failed with $rc2"
3066 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3067 echo "1st OST start failed with $rc"
3068 echo "2nd OST start succeed"
3072 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3078 # verify everything ok
3083 error "MDT(s) start failed"
3091 error "OST(s) start failed"
3099 error "client start failed"
3106 error "client mount failed"
3110 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3112 test_42() { #bug 14693
3116 check_mount || error "client was not mounted"
3118 if [[ $PERM_CMD = *"set_param -P"* ]]; then
3119 PARAM="llite.$FSNAME-*.some_wrong_param"
3121 PARAM="$FSNAME.llite.some_wrong_param"
3124 do_facet mgs $PERM_CMD $PARAM=10
3125 umount_client $MOUNT ||
3126 error "unmounting client failed with invalid llite param"
3127 mount_client $MOUNT ||
3128 error "mounting client failed with invalid llite param"
3130 do_facet mgs $PERM_CMD $PARAM=20
3131 cleanup || error "stopping $FSNAME failed with invalid sys param"
3133 check_mount || error "client was not mounted with invalid sys param"
3134 cleanup || error "stopping $FSNAME failed with invalid sys param"
3136 run_test 42 "allow client/server mount/unmount with invalid config param"
3139 [[ "$MGS_VERSION" -ge $(version_code 2.5.58) ]] ||
3140 skip "Need MDS version at least 2.5.58"
3141 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
3144 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
3145 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1"
3148 chmod ugo+x $DIR || error "chmod 0 failed"
3149 set_persistent_param_and_check mds1 \
3150 "mdt.$FSNAME-MDT0000.root_squash" \
3151 "$FSNAME.mdt.root_squash" \
3153 wait_update $HOSTNAME \
3154 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3156 error "check llite root_squash failed!"
3157 set_persistent_param_and_check mds1 \
3158 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3159 "$FSNAME.mdt.nosquash_nids" \
3161 wait_update $HOSTNAME \
3162 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3164 error "check llite nosquash_nids failed!"
3167 # create set of test files
3169 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
3170 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
3171 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
3173 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
3174 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
3176 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
3177 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
3178 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
3180 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
3181 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
3182 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
3185 # check root_squash:
3186 # set root squash UID:GID to RUNAS_ID
3187 # root should be able to access only files owned by RUNAS_ID
3189 set_persistent_param_and_check mds1 \
3190 "mdt.$FSNAME-MDT0000.root_squash" \
3191 "$FSNAME.mdt.root_squash" \
3192 "$RUNAS_ID:$RUNAS_ID"
3193 wait_update $HOSTNAME \
3194 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3195 "$RUNAS_ID:$RUNAS_ID" ||
3196 error "check llite root_squash failed!"
3198 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
3199 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3200 error "$ST: root read permission is denied"
3201 echo "$ST: root read permission is granted - ok"
3204 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3205 error "$ST: root write permission is denied"
3206 echo "$ST: root write permission is granted - ok"
3208 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3209 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3210 error "$ST: root read permission is granted"
3211 echo "$ST: root read permission is denied - ok"
3214 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3215 error "$ST: root write permission is granted"
3216 echo "$ST: root write permission is denied - ok"
3218 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3219 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
3220 error "$ST: root unlink permission is granted"
3221 echo "$ST: root unlink permission is denied - ok"
3223 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
3224 error "$ST: root create permission is granted"
3225 echo "$ST: root create permission is denied - ok"
3228 # check root_squash is enforced independently
3229 # of client cache content
3231 # access file by USER1, keep access open
3232 # root should be denied access to user file
3234 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
3238 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
3239 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3240 { kill $pid; error "$ST: root read permission is granted"; }
3241 echo "$ST: root read permission is denied - ok"
3244 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3245 { kill $pid; error "$ST: root write permission is granted"; }
3246 echo "$ST: root write permission is denied - ok"
3252 # check nosquash_nids:
3253 # put client's NID into nosquash_nids list,
3254 # root should be able to access root file after that
3256 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
3257 NIDLIST="2@gni $NIDLIST 192.168.0.[2,10]@tcp"
3258 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
3259 set_persistent_param_and_check mds1 \
3260 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3261 "$FSNAME-MDTall.mdt.nosquash_nids" \
3263 wait_update $HOSTNAME \
3264 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3266 error "check llite nosquash_nids failed!"
3268 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3269 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3270 error "$ST: root read permission is denied"
3271 echo "$ST: root read permission is granted - ok"
3274 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3275 error "$ST: root write permission is denied"
3276 echo "$ST: root write permission is granted - ok"
3278 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3279 rm $DIR/$tdir-rootdir/tfile-1 ||
3280 error "$ST: root unlink permission is denied"
3281 echo "$ST: root unlink permission is granted - ok"
3282 touch $DIR/$tdir-rootdir/tfile-2 ||
3283 error "$ST: root create permission is denied"
3284 echo "$ST: root create permission is granted - ok"
3285 cleanup || error "cleanup failed with $?"
3287 run_test 43a "check root_squash and nosquash_nids"
3289 test_43b() { # LU-5690
3290 [[ "$MGS_VERSION" -ge $(version_code 2.7.62) ]] ||
3291 skip "Need MGS version 2.7.62+"
3293 if [[ -z "$fs2mds_DEV" ]]; then
3294 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
3295 skip_env "mixed loopback and real device not working"
3298 local fs2mdsdev=$(mdsdevname 1_2)
3299 local fs2mdsvdev=$(mdsvdevname 1_2)
3301 # temporarily use fs2mds as fs2mgs
3303 local fs2mgsdev=$fs2mdsdev
3304 local fs2mgsvdev=$fs2mdsvdev
3306 local fsname=test1234
3308 load_module llite/lustre
3309 local client_ip=$(host_nids_address $HOSTNAME $NETTYPE)
3310 local host=${client_ip//*./}
3311 local net=${client_ip/%$host/}
3312 local nosquash_nids=$(h2nettype $net[$host,$host,$host])
3314 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
3315 --param mdt.root_squash=$RUNAS_ID:$RUNAS_ID \
3316 --param mdt.nosquash_nids=$nosquash_nids \
3317 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
3318 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS || error "start fs2mgs failed"
3319 stop $fs2mgs -f || error "stop fs2mgs failed"
3320 cleanup || error "cleanup failed with $?"
3322 run_test 43b "parse nosquash_nids with commas in expr_list"
3326 check_mount || error "check_mount"
3327 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
3329 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
3330 for VAL in $UUIDS; do
3331 NID=$(echo $VAL | cut -d= -f1)
3332 CLUUID=$(echo $VAL | cut -d= -f2)
3333 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
3335 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
3336 cleanup || error "cleanup failed with $?"
3338 run_test 44 "mounted client proc entry exists"
3342 check_mount || error "check_mount"
3343 stop_mds || error "Unable to stop MDS"
3347 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
3348 do_facet client "$LCTL set_param fail_loc=0x8000050f"
3351 manual_umount_client --force || error "manual_umount_client failed"
3352 do_facet client "$LCTL set_param fail_loc=0x0"
3353 start_mds || error "unable to start MDS"
3354 mount_client $MOUNT || error "mount_client $MOUNT failed"
3355 cleanup || error "cleanup failed with $?"
3357 run_test 45 "long unlink handling in ptlrpcd"
3364 umount_client $MOUNT2 || rc=$?
3365 umount_client $MOUNT || rc=$?
3366 while [ $count -gt 0 ]; do
3367 stop ost${count} -f || rc=$?
3371 cleanup_nocli || rc=$?
3372 #writeconf to remove all ost2 traces for subsequent tests
3373 writeconf_or_reformat
3378 echo "Testing with $OSTCOUNT OSTs"
3380 start_mds || error "unable to start MDS"
3381 #first client should see only one ost
3382 start_ost || error "Unable to start OST1"
3383 wait_osc_import_state mds ost FULL
3385 mount_client $MOUNT || error "mount_client $MOUNT failed"
3386 trap "cleanup_46a $OSTCOUNT" EXIT ERR
3389 for (( i=2; i<=$OSTCOUNT; i++ )); do
3390 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
3391 error "start_ost$i $(ostdevname $i) failed"
3394 # wait until osts in sync
3395 for (( i=2; i<=$OSTCOUNT; i++ )); do
3396 wait_osc_import_state mds ost$i FULL
3397 wait_osc_import_ready client ost$i
3400 #second client see all ost's
3402 mount_client $MOUNT2 || error "mount_client failed"
3403 $SETSTRIPE -c -1 $MOUNT2 || error "$SETSTRIPE -c -1 $MOUNT2 failed"
3404 $GETSTRIPE $MOUNT2 || error "$GETSTRIPE $MOUNT2 failed"
3406 echo "ok" > $MOUNT2/widestripe
3407 $GETSTRIPE $MOUNT2/widestripe ||
3408 error "$GETSTRIPE $MOUNT2/widestripe failed"
3409 # fill acl buffer for avoid expand lsm to them
3410 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
3412 setfacl -m $acl $MOUNT2/widestripe
3416 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3418 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
3420 run_test 46a "handle ost additional - wide striped file"
3425 check_mount || error "check_mount failed"
3426 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
3430 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3431 if echo $ns | grep "MDT[[:digit:]]*"; then
3434 lrs=$(echo $ns | sed 's/.*lru_size=//')
3435 lru_size[count]=$lrs
3440 facet_failover $SINGLEMDS
3441 client_up || error "client_up failed"
3444 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3445 if echo $ns | grep "MDT[[:digit:]]*"; then
3448 lrs=$(echo $ns | sed 's/.*lru_size=//')
3449 if ! test "$lrs" -eq "${lru_size[count]}"; then
3450 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
3451 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
3456 cleanup || error "cleanup failed with $?"
3458 run_test 47 "server restart does not make client loss lru_resize settings"
3463 # reformat after this test is needed - if the test fails,
3464 # we will have unkillable file at FS
3468 test_48() { # bz-17636 LU-7473
3472 check_mount || error "check_mount failed"
3474 $SETSTRIPE -c -1 $MOUNT || error "$SETSTRIPE -c -1 $MOUNT failed"
3475 $GETSTRIPE $MOUNT || error "$GETSTRIPE $MOUNT failed"
3477 echo "ok" > $MOUNT/widestripe
3478 $GETSTRIPE $MOUNT/widestripe ||
3479 error "$GETSTRIPE $MOUNT/widestripe failed"
3481 # In the future, we may introduce more EAs, such as selinux, enlarged
3482 # LOV EA, and so on. These EA will use some EA space that is shared by
3483 # ACL entries. So here we only check some reasonable ACL entries count,
3484 # instead of the max number that is calculated from the max_ea_size.
3485 if [ "$MDS1_VERSION" -lt $(version_code 2.8.57) ];
3487 count=28 # hard coded of RPC protocol
3488 elif [ "$mds1_FSTYPE" != ldiskfs ]; then
3489 count=4000 # max_num 4091 max_ea_size = 32768
3490 elif ! large_xattr_enabled; then
3491 count=450 # max_num 497 max_ea_size = 4012
3493 count=4500 # max_num 8187 max_ea_size = 1048492
3494 # not create too much (>5000) to save test time
3497 echo "It is expected to hold at least $count ACL entries"
3498 trap cleanup_48 EXIT ERR
3499 for ((i = 0; i < $count; i++)) do
3500 setfacl -m u:$((i + 100)):rw $MOUNT/widestripe ||
3501 error "Fail to setfacl for $MOUNT/widestripe at $i"
3504 cancel_lru_locks mdc
3505 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3506 local r_count=$(getfacl $MOUNT/widestripe | grep "user:" | wc -l)
3507 count=$((count + 1)) # for the entry "user::rw-"
3509 [ $count -eq $r_count ] ||
3510 error "Expected ACL entries $count, but got $r_count"
3514 run_test 48 "too many acls on file"
3516 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3517 test_49a() { # bug 17710
3518 local timeout_orig=$TIMEOUT
3519 local ldlm_timeout_orig=$LDLM_TIMEOUT
3520 local LOCAL_TIMEOUT=20
3522 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3523 TIMEOUT=$LOCAL_TIMEOUT
3527 check_mount || error "client mount failed"
3529 echo "check ldlm_timout..."
3530 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3531 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3532 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3534 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3535 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3538 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3539 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3542 umount_client $MOUNT || error "umount_client $MOUNT failed"
3543 stop_ost || error "problem stopping OSS"
3544 stop_mds || error "problem stopping MDS"
3546 LDLM_TIMEOUT=$ldlm_timeout_orig
3547 TIMEOUT=$timeout_orig
3549 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3551 test_49b() { # bug 17710
3552 local timeout_orig=$TIMEOUT
3553 local ldlm_timeout_orig=$LDLM_TIMEOUT
3554 local LOCAL_TIMEOUT=20
3556 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3557 TIMEOUT=$LOCAL_TIMEOUT
3561 check_mount || error "client mount failed"
3563 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3564 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3565 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3567 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3568 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3571 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3572 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3575 cleanup || error "cleanup failed"
3577 LDLM_TIMEOUT=$ldlm_timeout_orig
3578 TIMEOUT=$timeout_orig
3580 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3583 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3585 # Test both statfs and lfs df and fail if either one fails
3586 multiop_bg_pause $1 f_
3589 killall -USR1 multiop
3590 [ $RC -ne 0 ] && log "lazystatfs multiop failed"
3591 wait $PID || { RC=$?; log "multiop return error "; }
3593 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3598 if kill -s 0 $PID; then
3601 log "lazystatfs lfs df failed to complete in 5s"
3609 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3610 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3612 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3614 cleanup || error "cleanup failed with rc $?"
3616 run_test 50a "lazystatfs all servers available"
3620 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3621 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3623 # Wait for client to detect down OST
3624 stop_ost || error "Unable to stop OST1"
3625 wait_osc_import_state client ost DISCONN
3627 log "OSCs should all be DISCONN"
3629 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
3631 umount_client $MOUNT || error "Unable to unmount client"
3632 stop_mds || error "Unable to stop MDS"
3634 run_test 50b "lazystatfs all servers down"
3637 start_mds || error "Unable to start MDS"
3638 start_ost || error "Unable to start OST1"
3639 start_ost2 || error "Unable to start OST2"
3640 mount_client $MOUNT || error "Unable to mount client"
3641 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3642 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3644 # Wait for client to detect down OST
3645 stop_ost || error "Unable to stop OST1"
3646 wait_osc_import_state mds ost DISCONN
3647 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3649 umount_client $MOUNT || error "Unable to unmount client"
3650 stop_ost2 || error "Unable to stop OST2"
3651 stop_mds || error "Unable to stop MDS"
3652 #writeconf to remove all ost2 traces for subsequent tests
3653 writeconf_or_reformat
3655 run_test 50c "lazystatfs one server down"
3658 start_mds || error "Unable to start MDS"
3659 start_ost || error "Unable to start OST1"
3660 start_ost2 || error "Unable to start OST2"
3661 mount_client $MOUNT || error "Unable to mount client"
3662 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3663 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3665 # Issue the statfs during the window where the client still
3666 # belives the OST to be available but it is in fact down.
3667 # No failure just a statfs which hangs for a timeout interval.
3668 stop_ost || error "Unable to stop OST1"
3669 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3671 umount_client $MOUNT || error "Unable to unmount client"
3672 stop_ost2 || error "Unable to stop OST2"
3673 stop_mds || error "Unable to stop MDS"
3674 #writeconf to remove all ost2 traces for subsequent tests
3675 writeconf_or_reformat
3677 run_test 50d "lazystatfs client/server conn race"
3684 start_mds || error "Unable to start MDS"
3685 #first client should see only one ost
3686 start_ost || error "Unable to start OST1"
3687 wait_osc_import_state mds ost FULL
3689 # Wait for client to detect down OST
3690 stop_ost || error "Unable to stop OST1"
3691 wait_osc_import_state mds ost DISCONN
3693 mount_client $MOUNT || error "Unable to mount client"
3694 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3696 multiop_bg_pause $MOUNT _f
3700 if [ $RC1 -ne 0 ]; then
3701 log "multiop failed $RC1"
3704 sleep $(( $TIMEOUT+1 ))
3706 [ $? -ne 0 ] && error "process isn't sleep"
3707 start_ost || error "Unable to start OST1"
3708 wait $pid || error "statfs failed"
3711 umount_client $MOUNT || error "Unable to unmount client"
3712 stop_ost || error "Unable to stop OST1"
3713 stop_mds || error "Unable to stop MDS"
3715 run_test 50e "normal statfs all servers down"
3720 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3722 start_mds || error "Unable to start mds"
3723 #first client should see only one ost
3724 start_ost || error "Unable to start OST1"
3725 wait_osc_import_state mds ost FULL
3727 start_ost2 || error "Unable to start OST2"
3728 wait_osc_import_state mds ost2 FULL
3730 # Wait for client to detect down OST
3731 stop_ost2 || error "Unable to stop OST2"
3733 wait_osc_import_state mds ost2 DISCONN
3734 mount_client $MOUNT || error "Unable to mount client"
3735 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3737 multiop_bg_pause $MOUNT _f
3741 if [ $RC1 -ne 0 ]; then
3742 log "lazystatfs multiop failed $RC1"
3745 sleep $(( $TIMEOUT+1 ))
3747 [ $? -ne 0 ] && error "process isn't sleep"
3748 start_ost2 || error "Unable to start OST2"
3749 wait $pid || error "statfs failed"
3750 stop_ost2 || error "Unable to stop OST2"
3753 umount_client $MOUNT -f || error "Unable to unmount client"
3754 stop_ost || error "Unable to stop OST1"
3755 stop_mds || error "Unable to stop MDS"
3756 #writeconf to remove all ost2 traces for subsequent tests
3757 writeconf_or_reformat
3759 run_test 50f "normal statfs one server in down"
3762 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3764 start_ost2 || error "Unable to start OST2"
3765 wait_osc_import_state mds ost2 FULL
3766 wait_osc_import_ready client ost2
3768 if [[ $PERM_CMD = *"set_param -P"* ]]; then
3769 local PARAM="osc.${FSNAME}-OST0001*.active"
3771 local PARAM="${FSNAME}-OST0001.osc.active"
3774 $SETSTRIPE -c -1 $DIR/$tfile || error "$SETSTRIPE failed"
3775 do_facet mgs $PERM_CMD $PARAM=0 || error "Unable to deactivate OST"
3777 umount_client $MOUNT || error "Unable to unmount client"
3778 mount_client $MOUNT || error "Unable to mount client"
3779 # This df should not cause a panic
3782 do_facet mgs $PERM_CMD $PARAM=1 || error "Unable to activate OST"
3783 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
3784 umount_client $MOUNT || error "Unable to unmount client"
3785 stop_ost2 || error "Unable to stop OST2"
3786 stop_ost || error "Unable to stop OST1"
3787 stop_mds || error "Unable to stop MDS"
3788 #writeconf to remove all ost2 traces for subsequent tests
3789 writeconf_or_reformat
3791 run_test 50g "deactivated OST should not cause panic"
3795 # prepare MDT/OST, make OSC inactive for OST1
3796 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3798 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
3799 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3800 error "tunefs OST1 failed"
3801 start_mds || error "Unable to start MDT"
3802 start_ost || error "Unable to start OST1"
3803 start_ost2 || error "Unable to start OST2"
3804 mount_client $MOUNT || error "client start failed"
3806 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3808 # activatate OSC for OST1
3809 set_persistent_param_and_check client \
3810 "osc.${FSNAME}-OST0000-osc-[!M]*.active" \
3811 "${FSNAME}-OST0000.osc.active" 1
3813 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3814 $SETSTRIPE -c -1 -i 0 $DIR/$tdir/2 ||
3815 error "$SETSTRIPE $DIR/$tdir/2 failed"
3816 sleep 1 && echo "create a file after OST1 is activated"
3817 # doing some io, shouldn't crash
3818 dd if=/dev/zero of=$DIR/$tdir/2/$tfile-io bs=1M count=10
3820 # check OSC import is working
3821 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3822 error "some OSC imports are still not connected"
3826 umount_client $MOUNT || error "Unable to umount client"
3827 stop_ost2 || error "Unable to stop OST2"
3828 cleanup_nocli || error "cleanup_nocli failed with $?"
3830 run_test 50h "LU-642: activate deactivated OST"
3833 # prepare MDT/OST, make OSC inactive for OST1
3834 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
3837 [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
3838 do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
3839 error "tunefs MDT2 failed"
3840 start_mds || error "Unable to start MDT"
3841 start_ost || error "Unable to start OST1"
3842 start_ost2 || error "Unable to start OST2"
3843 mount_client $MOUNT || error "client start failed"
3845 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3847 if [[ $PERM_CMD = *"set_param -P"* ]]; then
3848 $PERM_CMD mdc.${FSNAME}-MDT0001-mdc-*.active=0 &&
3849 error "deactive MDC0 succeeds"
3851 $PERM_CMD ${FSNAME}-MDT0000.mdc.active=0 &&
3852 error "deactive MDC0 succeeds"
3855 # activate MDC for MDT2
3856 set_persistent_param_and_check client \
3857 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3858 "${FSNAME}-MDT0001.mdc.active" 1
3860 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
3861 if [ "$MDS1_VERSION" -ge $(version_code 2.7.60) ]
3863 wait_dne_interconnect
3865 $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3867 createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
3869 rm -rf $DIR/$tdir/2 || error "unlink dir failed"
3871 # deactivate MDC for MDT2
3872 set_persistent_param_and_check client \
3873 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3874 "${FSNAME}-MDT0001.mdc.active" 0
3876 wait_osp_active mds ${FSNAME}-MDT0001 1 0
3878 $LFS mkdir -i1 $DIR/$tdir/2 &&
3879 error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
3881 $LFS mkdir -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3882 error "mkdir $DIR/$tdir/striped_dir fails after deactive MDT2"
3884 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3885 [ $stripe_count -eq $((MDSCOUNT - 1)) ] ||
3886 error "wrong $stripe_count != $((MDSCOUNT -1)) for striped_dir"
3889 umount_client $MOUNT || error "Unable to umount client"
3894 run_test 50i "activate deactivated MDT"
3897 local LOCAL_TIMEOUT=20
3901 check_mount || error "check_mount failed"
3903 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3904 $SETSTRIPE -c -1 $MOUNT/$tdir ||
3905 error "$SETSTRIPE -c -1 $MOUNT/$tdir failed"
3906 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3907 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
3908 touch $MOUNT/$tdir/$tfile &
3911 start_ost2 || error "Unable to start OST1"
3913 stop_ost2 || error "Unable to stop OST1"
3914 umount_client $MOUNT -f || error “unmount $MOUNT failed”
3915 cleanup_nocli || error “stop server failed”
3916 #writeconf to remove all ost2 traces for subsequent tests
3917 writeconf_or_reformat
3919 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
3928 do_node $node mkdir -p $dest
3929 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3931 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
3932 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3933 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
3935 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
3936 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
3946 local backup2=${TMP}/backup2
3948 do_node $node mkdir -p $backup2
3949 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3951 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
3952 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3953 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
3955 do_node $node "diff -rq $backup $backup2"
3956 [ $? -eq 0 ] || { error "contents differ"; return 3; }
3958 local xattrs2=${TMP}/xattrs2
3959 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
3960 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
3962 do_node $node "diff $xattrs $xattrs2"
3963 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
3965 do_node $node "rm -rf $backup2 $xattrs2"
3966 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
3970 if [ "$mds1_FSTYPE" != ldiskfs ]; then
3971 skip "ldiskfs only test"
3974 start_mds || error "Unable to start MDS"
3975 start_ost || error "Unable to start OST1"
3976 mount_client $MOUNT || error "Unable to mount client"
3979 local ost1mnt=$(facet_mntpt ost1)
3980 local ost1node=$(facet_active_host ost1)
3981 local ost1tmp=$TMP/conf52
3984 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
3985 touch $TMP/modified_first || error "Unable to create temporary file"
3986 local mtime=$(stat -c %Y $TMP/modified_first)
3987 do_node $ost1node "mkdir -p $ost1tmp &&
3988 touch -m -d @$mtime $ost1tmp/modified_first" ||
3989 error "Unable to create temporary file"
3992 $SETSTRIPE -c -1 -S 1M $DIR/$tdir || error "$SETSTRIPE failed"
3994 for (( i=0; i < nrfiles; i++ )); do
3995 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
3996 error "multiop failed"
4001 # sync all the data and make sure no pending data on the client,
4002 # thus the SOM xattr would not be changed any more.
4003 cancel_lru_locks osc
4006 echo backup files to $TMP/$tdir
4007 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
4008 copy_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4009 error "Unable to copy files"
4011 umount_client $MOUNT || error "Unable to umount client"
4012 stop_ost || error "Unable to stop ost1"
4014 echo mount ost1 as ldiskfs
4015 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
4016 if ! do_node $ost1node test -b $ost1_dev; then
4019 do_node $ost1node mount -t "$ost1_FSTYPE" $loop $ost1_dev \
4021 error "Unable to mount ost1 as ldiskfs"
4024 echo backup objects to $ost1tmp/objects
4025 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
4026 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
4027 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
4029 error "Unable to copy objects"
4031 # move objects to lost+found
4032 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
4033 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
4035 do_node $ost1node "umount $ost1mnt" ||
4036 error "Unable to umount ost1 as ldiskfs"
4038 start_ost || error "Unable to start OST1"
4039 mount_client $MOUNT || error "Unable to mount client"
4041 local REPAIRED=$(do_node $ost1node "$LCTL get_param \
4042 -n osd-ldiskfs.$FSNAME-OST0000.oi_scrub" |
4043 awk '/^lf_repa[ri]*ed/ { print $2 }')
4044 [ $REPAIRED -gt 0 ] ||
4045 error "Some entry under /lost+found should be repaired"
4048 diff_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4049 error "Unable to diff files"
4051 rm -rf $TMP/$tdir $TMP/file_xattrs ||
4052 error "Unable to delete temporary files"
4053 do_node $ost1node "rm -rf $ost1tmp" ||
4054 error "Unable to delete temporary files"
4055 cleanup || error "cleanup failed with $?"
4057 run_test 52 "check recovering objects from lost+found"
4059 # Checks threads_min/max/started for some service
4061 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
4062 # parameter pattern prefix like 'ost.*.ost'.
4075 local msg="Insane $modname thread counts"
4076 local ncpts=$(check_cpt_number $facet)
4080 check_mount || return 41
4082 # We need to expand $parampat, but it may match multiple parameters, so
4083 # we'll pick the first one
4084 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
4085 error "Couldn't expand ${parampat}.threads_min parameter name"
4089 # Remove the .threads_min part
4090 paramp=${paramp%.threads_min}
4092 # Check for sanity in defaults
4093 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4095 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4097 tstarted=$(do_facet $facet "$LCTL get_param \
4098 -n ${paramp}.threads_started" || echo 0)
4099 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
4101 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4103 nthrs=$(expr $tmax - $tmin)
4104 if [ $nthrs -lt $ncpts ]; then
4110 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
4111 skip_env "module parameter forced $facet thread count"
4113 # Check that we can change min/max
4114 do_facet $facet "$LCTL set_param \
4115 ${paramp}.threads_min=$((tmin + nthrs))"
4116 do_facet $facet "$LCTL set_param \
4117 ${paramp}.threads_max=$((tmax - nthrs))"
4118 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4120 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4122 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
4123 $tmax2 == ($tmax - $nthrs)))' || return $?
4125 # Check that we can set min/max to the same value
4126 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4128 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
4129 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4131 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4133 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
4135 # Check that we can't set max < min
4136 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
4137 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4139 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4141 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
4143 # We need to ensure that we get the module options desired; to do this
4144 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
4145 LOAD_MODULES_REMOTE=true
4148 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
4149 setmodopts -a $modname "$newvalue" oldvalue
4152 check_mount || return 41
4154 # Restore previous setting of MODOPTS_*
4155 setmodopts $modname "$oldvalue"
4157 # Check that $opts took
4158 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4160 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4162 tstarted=$(do_facet $facet \
4163 "$LCTL get_param -n ${paramp}.threads_started" || echo 0)
4164 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4173 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
4174 cleanup || error "cleanup failed with rc $?"
4176 run_test 53a "check OSS thread count params"
4180 local mds=$(do_facet $SINGLEMDS "$LCTL get_param \
4181 -N mds.*.*.threads_max 2>/dev/null")
4182 if [ -z "$mds" ]; then
4183 #running this on an old MDT
4184 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
4186 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
4188 cleanup || error "cleanup failed with $?"
4190 run_test 53b "check MDS thread count params"
4193 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4194 skip "ldiskfs only test"
4197 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
4198 error "llverdev failed with rc=$?"
4201 run_test 54a "test llverdev and partial verify of device"
4204 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4205 skip "ldiskfs only test"
4209 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
4210 cleanup || error "cleanup failed with rc=$?"
4212 run_test 54b "test llverfs and partial verify of filesystem"
4216 local max_ost_index=$1
4217 echo -n $(((max_ost_index + 1) * 8))
4221 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4222 skip "ldiskfs only test"
4225 local mdsdev=$(mdsdevname 1)
4226 local mdsvdev=$(mdsvdevname 1)
4230 if ! combined_mgs_mds; then
4231 stop_mgs || error "stopping MGS service failed"
4232 format_mgs || error "formatting MGT failed"
4234 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
4236 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
4237 --reformat $(ostdevname 1) $(ostvdevname 1)
4243 echo checking size of lov_objid for ost index $i
4244 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" |
4245 grep ^User | awk -F 'Size: ' '{print $2}')
4246 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
4247 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
4249 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
4256 run_test 55 "check lov_objid size"
4259 local mds_journal_size_orig=$MDSJOURNALSIZE
4265 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
4266 $(ostdevname 1) $(ostvdevname 1)
4267 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
4268 $(ostdevname 2) $(ostvdevname 2)
4271 start_ost || error "Unable to start first ost (idx 10000)"
4272 start_ost2 || error "Unable to start second ost (idx 1000)"
4273 mount_client $MOUNT || error "Unable to mount client"
4277 if [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
4278 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
4279 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]]; then
4280 wait_osc_import_state mds ost1 FULL
4281 wait_osc_import_state mds ost2 FULL
4282 $SETSTRIPE --stripe-count=-1 $DIR/$tfile ||
4283 error "Unable to setstripe $DIR/$tfile"
4284 n=$($LFS getstripe --stripe-count $DIR/$tfile)
4285 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
4290 MDSJOURNALSIZE=$mds_journal_size_orig
4293 run_test 56a "check big OST indexes and out-of-index-order start"
4298 umount_client $MOUNT -f || error "unmount client failed"
4307 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
4309 trap cleanup_56b EXIT RETURN ERR
4312 if ! combined_mgs_mds ; then
4317 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) --index=0 --reformat \
4318 $(mdsdevname 1) $(mdsvdevname 1)
4319 add mds2 $(mkfs_opts mds2 $(mdsdevname 2)) --index=1 --reformat \
4320 $(mdsdevname 2) $(mdsvdevname 2)
4321 add mds3 $(mkfs_opts mds3 $(mdsdevname 3)) --index=1000 --reformat \
4322 $(mdsdevname 3) $(mdsvdevname 3)
4326 start_mdt 1 || error "MDT 1 (idx 0) start failed"
4327 start_mdt 2 || error "MDT 2 (idx 1) start failed"
4328 start_mdt 3 || error "MDT 3 (idx 1000) start failed"
4329 start_ost || error "Unable to start first ost"
4330 start_ost2 || error "Unable to start second ost"
4332 do_nodes $(comma_list $(mdts_nodes)) \
4333 "$LCTL set_param mdt.*.enable_remote_dir=1 \
4334 mdt.*.enable_remote_dir_gid=-1"
4336 mount_client $MOUNT || error "Unable to mount client"
4338 $LFS mkdir -c3 $MOUNT/$tdir || error "failed to make testdir"
4340 echo "This is test file 1!" > $MOUNT/$tdir/$tfile.1 ||
4341 error "failed to make test file 1"
4342 echo "This is test file 2!" > $MOUNT/$tdir/$tfile.2 ||
4343 error "failed to make test file 2"
4344 echo "This is test file 1000!" > $MOUNT/$tdir/$tfile.1000 ||
4345 error "failed to make test file 1000"
4347 rm -rf $MOUNT/$tdir || error "failed to remove testdir"
4349 $LFS mkdir -i1000 $MOUNT/$tdir.1000 ||
4350 error "create remote dir at idx 1000 failed"
4353 echo "=== START lfs df OUTPUT ==="
4355 echo "==== END lfs df OUTPUT ===="
4357 mdtcnt=$(echo -e "$output" | grep $FSNAME-MDT | wc -l)
4358 ostcnt=$(echo -e "$output" | grep $FSNAME-OST | wc -l)
4360 echo "lfs df returned mdt count $mdtcnt and ost count $ostcnt"
4361 [ $mdtcnt -eq 3 ] || error "lfs df returned wrong mdt count"
4362 [ $ostcnt -eq 2 ] || error "lfs df returned wrong ost count"
4364 echo "This is test file 1!" > $MOUNT/$tdir.1000/$tfile.1 ||
4365 error "failed to make test file 1"
4366 echo "This is test file 2!" > $MOUNT/$tdir.1000/$tfile.2 ||
4367 error "failed to make test file 2"
4368 echo "This is test file 1000!" > $MOUNT/$tdir.1000/$tfile.1000 ||
4369 error "failed to make test file 1000"
4370 rm -rf $MOUNT/$tdir.1000 || error "failed to remove remote_dir"
4373 echo "=== START lfs mdts OUTPUT ==="
4375 echo "==== END lfs mdts OUTPUT ===="
4377 echo -e "$output" | grep -v "MDTS:" | awk '{print $1}' |
4378 sed 's/://g' > $TMP/mdts-actual.txt
4379 sort $TMP/mdts-actual.txt -o $TMP/mdts-actual.txt
4381 echo -e "0\n1\n1000" > $TMP/mdts-expected.txt
4383 diff $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4386 rm $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4388 [ $result -eq 0 ] || error "target_obd proc file is incorrect!"
4390 run_test 56b "test target_obd correctness with nonconsecutive MDTs"
4392 test_57a() { # bug 22656
4393 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4394 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4395 tail -1 | awk '{print $1}')
4396 writeconf_or_reformat
4397 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
4398 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
4399 error "tunefs failed"
4401 start_ost && error "OST registration from failnode should fail"
4404 run_test 57a "initial registration from failnode should fail (should return errs)"
4407 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4408 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4409 tail -1 | awk '{print $1}')
4410 writeconf_or_reformat
4411 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
4412 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
4413 error "tunefs failed"
4415 start_ost || error "OST registration from servicenode should not fail"
4418 run_test 57b "initial registration from servicenode should not fail"
4421 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
4424 test_58() { # bug 22658
4425 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
4427 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4428 createmany -o $DIR/$tdir/$tfile-%d 100
4429 unlinkmany $DIR/$tdir/$tfile-%d 100
4430 stop_mds || error "Unable to stop MDS"
4432 local MNTDIR=$(facet_mntpt $SINGLEMDS)
4433 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4435 # remove all files from the OBJECTS dir
4436 mount_fstype $SINGLEMDS
4438 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
4440 unmount_fstype $SINGLEMDS
4441 # restart MDS with missing llog files
4442 start_mds || error "unable to start MDS"
4443 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
4446 run_test 58 "missing llog files must not prevent MDT from mounting"
4449 start_mgsmds >> /dev/null
4450 local C1=$(count_osts)
4451 if [ $C1 -eq 0 ]; then
4452 start_ost >> /dev/null
4456 echo "original ost count: $C1 (expect > 0)"
4457 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
4458 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
4459 local C2=$(count_osts)
4460 echo "after mdt writeconf count: $C2 (expect 0)"
4461 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
4462 echo "OST start without writeconf should fail:"
4463 start_ost >> /dev/null &&
4464 error "OST start without writeconf didn't fail"
4465 echo "OST start with writeconf should succeed:"
4466 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
4467 local C3=$(count_osts)
4468 echo "after ost writeconf count: $C3 (expect 1)"
4469 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
4470 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
4471 local C4=$(count_osts)
4472 echo "after ost2 writeconf count: $C4 (expect 2)"
4473 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
4474 stop_ost2 >> /dev/null
4475 cleanup_nocli >> /dev/null
4476 #writeconf to remove all ost2 traces for subsequent tests
4477 writeconf_or_reformat
4479 run_test 59 "writeconf mount option"
4481 test_60() { # LU-471
4482 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4483 skip "ldiskfs only test"
4488 for num in $(seq $MDSCOUNT); do
4489 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
4490 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
4491 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4495 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
4496 [ ${PIPESTATUS[0]} -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
4498 # MDT default has dirdata feature
4499 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
4500 # we disable uninit_bg feature
4501 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
4502 # we set stride extended options
4503 echo $dump | grep stride > /dev/null || error "stride is not set"
4507 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
4510 local lxattr=$(large_xattr_enabled)
4512 [ "$MDS1_VERSION" -ge $(version_code 2.1.53) ] ||
4513 skip "Need MDS version at least 2.1.53"
4515 if [ "$mds1_FSTYPE" == ldiskfs ] &&
4516 ! large_xattr_enabled; then
4519 for num in $(seq $MDSCOUNT); do
4520 do_facet mds${num} $TUNE2FS -O ea_inode \
4521 $(mdsdevname $num) ||
4522 error "tune2fs on mds $num failed"
4526 setup || error "setting up the filesystem failed"
4527 client_up || error "starting client failed"
4529 local file=$DIR/$tfile
4530 touch $file || error "touch $file failed"
4532 local large_value="$(generate_string $(max_xattr_size))"
4533 local small_value="bar"
4535 local name="trusted.big"
4536 log "save large xattr $name on $file"
4537 setfattr -n $name -v $large_value $file ||
4538 error "saving $name on $file failed"
4540 local new_value=$(get_xattr_value $name $file)
4541 [[ "$new_value" != "$large_value" ]] &&
4542 error "$name different after saving"
4544 log "shrink value of $name on $file"
4545 setfattr -n $name -v $small_value $file ||
4546 error "shrinking value of $name on $file failed"
4548 new_value=$(get_xattr_value $name $file)
4549 [[ "$new_value" != "$small_value" ]] &&
4550 error "$name different after shrinking"
4552 log "grow value of $name on $file"
4553 setfattr -n $name -v $large_value $file ||
4554 error "growing value of $name on $file failed"
4556 new_value=$(get_xattr_value $name $file)
4557 [[ "$new_value" != "$large_value" ]] &&
4558 error "$name different after growing"
4560 log "check value of $name on $file after remounting MDS"
4562 new_value=$(get_xattr_value $name $file)
4563 [[ "$new_value" != "$large_value" ]] &&
4564 error "$name different after remounting MDS"
4566 log "remove large xattr $name from $file"
4567 setfattr -x $name $file || error "removing $name from $file failed"
4569 if $lxattr && [ "$mds1_FSTYPE" == ldiskfs ]; then
4570 stopall || error "stopping for e2fsck run"
4571 for num in $(seq $MDSCOUNT); do
4572 run_e2fsck $(facet_active_host mds$num) \
4573 $(mdsdevname $num) "-y" ||
4574 error "e2fsck MDT$num failed"
4576 setup_noconfig || error "remounting the filesystem failed"
4579 # need to delete this file to avoid problems in other tests
4581 cleanup || error "stopping systems failed"
4583 run_test 61 "large xattr"
4586 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4587 skip "ldiskfs only test"
4589 [[ "$MDS1_VERSION" -ge $(version_code 2.2.51) ]] ||
4590 skip "Need MDS version at least 2.2.51"
4593 local mdsdev=$(mdsdevname 1)
4594 local ostdev=$(ostdevname 1)
4596 echo "disable journal for mds"
4597 do_facet mds1 $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
4598 start_mds && error "MDT start should fail"
4599 echo "disable journal for ost"
4600 do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
4601 start_ost && error "OST start should fail"
4602 cleanup || error "cleanup failed with rc $?"
4605 run_test 62 "start with disabled journal"
4608 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4609 skip "ldiskfs only test"
4612 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ldiskfs
4613 local inode_slab=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4614 awk '/ldiskfs_inode_cache/ { print $5 / $6 }')
4615 if [ -z "$inode_slab" ]; then
4616 skip "ldiskfs module has not been loaded"
4619 echo "$inode_slab ldiskfs inodes per page"
4620 [ "${inode_slab%.*}" -ge "3" ] && return 0
4622 # If kmalloc-128 is also 1 per page - this is a debug kernel
4623 # and so this is not an error.
4624 local kmalloc128=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4625 awk '/^(dma-kmalloc|size)-128 / { print $5 / $6 }')
4626 # 32 128-byte chunks in 4k
4627 [ "${kmalloc128%.*}" -lt "32" ] ||
4628 error "ldiskfs inode too big, only $inode_slab objs/page, " \
4629 "kmalloc128 = $kmalloc128 objs/page"
4631 run_test 63 "Verify each page can at least hold 3 ldiskfs inodes"
4634 start_mds || error "unable to start MDS"
4635 start_ost || error "Unable to start OST1"
4636 start_ost2 || error "Unable to start second ost"
4637 mount_client $MOUNT || error "Unable to mount client"
4638 stop_ost2 || error "Unable to stop second ost"
4641 umount_client $MOUNT -f || error “unmount $MOUNT failed”
4642 cleanup_nocli || error "cleanup_nocli failed with $?"
4643 #writeconf to remove all ost2 traces for subsequent tests
4644 writeconf_or_reformat
4646 run_test 64 "check lfs df --lazy "
4648 test_65() { # LU-2237
4649 # Currently, the test is only valid for ldiskfs backend
4650 [ "$mds1_FSTYPE" != ldiskfs ] &&
4651 skip "ldiskfs only test"
4653 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4654 local brpt=$(facet_mntpt brpt)
4657 if ! do_facet $SINGLEMDS "test -b $devname"; then
4661 stop_mds || error "Unable to stop MDS"
4662 local obj=$(do_facet $SINGLEMDS \
4663 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
4665 if [ -z "$obj" ]; then
4666 # The MDT may be just re-formatted, mount the MDT for the
4667 # first time to guarantee the "last_rcvd" file is there.
4668 start_mds || error "fail to mount the MDS for the first time"
4669 stop_mds || error "Unable to stop MDS"
4672 # remove the "last_rcvd" file
4673 do_facet $SINGLEMDS "mkdir -p $brpt"
4674 do_facet $SINGLEMDS \
4675 "mount -t $mds1_FSTYPE $opts $devname $brpt"
4676 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
4677 do_facet $SINGLEMDS "$UMOUNT $brpt"
4679 # restart MDS, the "last_rcvd" file should be recreated.
4680 start_mds || error "fail to restart the MDS"
4681 stop_mds || error "Unable to stop MDS"
4682 obj=$(do_facet $SINGLEMDS \
4683 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
4684 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
4686 run_test 65 "re-create the lost last_rcvd file when server mount"
4689 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
4690 skip "Need MGS version at least 2.3.59"
4693 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
4694 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
4696 # add EXCLUDE records to config log, they are not to be
4697 # removed by lctl replace_nids
4698 set_conf_param_and_check mds \
4699 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4700 "$FSNAME-OST0000.osc.active" \
4703 echo "replace_nids should fail if MDS, OSTs and clients are UP"
4704 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4705 error "replace_nids fail"
4707 umount_client $MOUNT || error "unmounting client failed"
4708 echo "replace_nids should fail if MDS and OSTs are UP"
4709 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4710 error "replace_nids fail"
4712 stop_ost || error "Unable to stop OST1"
4713 echo "replace_nids should fail if MDS is UP"
4714 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4715 error "replace_nids fail"
4717 stop_mds || error "stopping mds failed"
4719 if combined_mgs_mds; then
4720 start_mdt 1 "-o nosvc" ||
4721 error "starting mds with nosvc option failed"
4724 echo "command should accept two parameters"
4725 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
4726 error "command should accept two params"
4728 echo "correct device name should be passed"
4729 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
4730 error "wrong devname"
4732 echo "wrong nids list should not destroy the system"
4733 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
4735 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "asdfasdf, asdfadf" &&
4738 echo "replace OST nid"
4739 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
4740 error "replace nids failed"
4742 echo "command should accept two parameters"
4743 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
4744 error "command should accept two params"
4746 echo "wrong nids list should not destroy the system"
4747 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
4750 local FAKE_NIDS="192.168.0.112@tcp1,192.168.0.112@tcp2"
4751 local FAKE_FAILOVER="192.168.0.113@tcp1,192.168.0.113@tcp2"
4752 local NIDS_AND_FAILOVER="$MDS_NID,$FAKE_NIDS:$FAKE_FAILOVER"
4753 echo "set NIDs with failover"
4754 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $NIDS_AND_FAILOVER ||
4755 error "replace nids failed"
4758 echo "replace MDS nid"
4759 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
4760 error "replace nids failed"
4762 if ! combined_mgs_mds ; then
4765 stop_mds || error "Unable to stop MDS"
4768 start_mgsmds || error "start mgsmds failed"
4769 set_conf_param_and_check mds \
4770 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4771 "$FSNAME-OST0000.osc.active" \
4773 start_ost || error "unable to start OST"
4774 mount_client $MOUNT || error "mount client failed"
4776 check_mount || error "error after nid replace"
4777 cleanup || error "cleanup failed"
4780 run_test 66 "replace nids"
4782 test_67() { #LU-2950
4783 local legacy="$TMP/legacy_lnet_config"
4784 local new="$TMP/new_routes_test"
4785 local out="$TMP/config_out_file"
4786 local verify="$TMP/conv_verify"
4787 local verify_conf="$TMP/conf_verify"
4789 # Create the legacy file that will be run through the
4790 # lustre_routes_conversion script
4791 cat <<- LEGACY_LNET_CONFIG > $legacy
4792 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
4793 tcp2 54 10.1.3.2@tcp;
4794 tcp3 10.3.4.3@tcp:3;
4798 # Create the verification file to verify the output of
4799 # lustre_routes_conversion script against.
4800 cat <<- VERIFY_LNET_CONFIG > $verify
4801 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
4802 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
4803 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
4804 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
4805 tcp4: { gateway: 10.3.3.4@tcp }
4808 # Create the verification file to verify the output of
4809 # lustre_routes_config script against
4810 cat <<- VERIFY_LNET_CONFIG > $verify_conf
4811 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
4812 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
4813 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
4814 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
4815 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
4818 $LUSTRE_ROUTES_CONVERSION $legacy $new > /dev/null
4819 if [ -f $new ]; then
4820 # verify the conversion output
4821 cmp -s $new $verify > /dev/null
4822 if [ $? -eq 1 ]; then
4823 error "routes conversion failed"
4826 lustre_routes_config --dry-run --verbose $new > $out
4827 # check that the script succeeded
4828 cmp -s $out $verify_conf > /dev/null
4829 if [ $? -eq 1 ]; then
4830 error "routes config failed"
4833 error "routes conversion test failed"
4835 # remove generated files
4836 rm -f $new $legacy $verify $verify_conf $out
4838 run_test 67 "test routes conversion and configuration"
4846 [ "$MDS1_VERSION" -ge $(version_code 2.4.53) ] ||
4847 skip "Need MDS version at least 2.4.53"
4849 umount_client $MOUNT || error "umount client failed"
4854 # START-END - the sequences we'll be reserving
4855 START=$(do_facet $SINGLEMDS \
4856 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4857 END=$((START + (1 << 30)))
4858 do_facet $SINGLEMDS \
4859 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4861 # reset the sequences MDT0000 has already assigned
4862 do_facet $SINGLEMDS \
4863 $LCTL set_param seq.srv*MDT0000.space=clear
4865 # remount to let the client allocate new sequence
4866 mount_client $MOUNT || error "mount client failed"
4868 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4869 do_facet $SINGLEMDS \
4870 $LCTL get_param seq.srv*MDT0000.space
4871 $LFS path2fid $DIR/$tfile
4873 local old_ifs="$IFS"
4875 fid=($($LFS path2fid $DIR/$tfile))
4879 if [[ $seq < $END ]]; then
4880 error "used reserved sequence $seq?"
4882 cleanup || error "cleanup failed with $?"
4884 run_test 68 "be able to reserve specific sequences in FLDB"
4886 # Test 69: is about the total number of objects ever created on an OST.
4887 # so that when it is reformatted the normal MDS->OST orphan recovery won't
4888 # just "precreate" the missing objects. In the past it might try to recreate
4889 # millions of objects after an OST was reformatted
4891 [[ "$MDS1_VERSION" -lt $(version_code 2.4.2) ]] &&
4892 skip "Need MDS version at least 2.4.2"
4894 [[ "$MDS1_VERSION" -ge $(version_code 2.4.50) ]] &&
4895 [[ "$MDS1_VERSION" -lt $(version_code 2.5.0) ]] &&
4896 skip "Need MDS version at least 2.5.0"
4899 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4901 # use OST0000 since it probably has the most creations
4902 local OSTNAME=$(ostname_from_index 0)
4903 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4904 local last_id=$(do_facet mds1 $LCTL get_param -n \
4905 osp.$mdtosc_proc1.prealloc_last_id)
4907 # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
4908 # verify that the LAST_ID recovery is working properly. If
4909 # not, then the OST will refuse to allow the MDS connect
4910 # because the LAST_ID value is too different from the MDS
4911 #define OST_MAX_PRECREATE=20000
4912 local ost_max_pre=20000
4913 local num_create=$(( ost_max_pre * 5 + 1 - last_id))
4915 # If the LAST_ID is already over 5 * OST_MAX_PRECREATE, we don't
4916 # need to create any files. So, skip this section.
4917 if [ $num_create -gt 0 ]; then
4918 # Check the number of inodes available on OST0
4920 local ifree=$($LFS df -i $MOUNT | awk '/OST0000/ { print $4 }')
4921 log "On OST0, $ifree inodes available. Want $num_create."
4923 $SETSTRIPE -i 0 $DIR/$tdir ||
4924 error "$SETSTRIPE -i 0 $DIR/$tdir failed"
4925 if [ $ifree -lt 10000 ]; then
4926 files=$(( ifree - 50 ))
4931 local j=$((num_create / files + 1))
4932 for i in $(seq 1 $j); do
4933 createmany -o $DIR/$tdir/$tfile-$i- $files ||
4934 error "createmany fail create $files files: $?"
4935 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
4936 error "unlinkmany failed unlink $files files"
4940 # delete all of the files with objects on OST0 so the
4941 # filesystem is not inconsistent later on
4942 $LFS find $MOUNT --ost 0 -print0 | xargs -0 rm
4944 umount_client $MOUNT || error "umount client failed"
4945 stop_ost || error "OST0 stop failure"
4946 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
4947 $(ostdevname 1) $(ostvdevname 1) ||
4948 error "reformat and replace $ostdev failed"
4949 start_ost || error "OST0 restart failure"
4950 wait_osc_import_state mds ost FULL
4952 mount_client $MOUNT || error "mount client failed"
4953 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
4954 local idx=$($GETSTRIPE -i $DIR/$tdir/$tfile-last)
4955 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
4957 local iused=$($LFS df -i $MOUNT | awk '/OST0000/ { print $3 }')
4958 log "On OST0, $iused used inodes"
4959 [ $iused -ge $((ost_max_pre/2 + 1000)) ] &&
4960 error "OST replacement created too many inodes; $iused"
4961 cleanup || error "cleanup failed with $?"
4963 run_test 69 "replace an OST with the same index"
4966 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
4969 cleanup || error "cleanup failed with $?"
4971 start_mdt 1 || error "MDT0 start fail"
4973 start_ost || error "OST0 start fail"
4974 for num in $(seq 2 $MDSCOUNT); do
4975 start_mdt $num || return
4978 mount_client $MOUNT || error "mount client fails"
4980 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
4982 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
4983 error "create remote dir fail"
4985 rm -rf $DIR/$tdir || error "delete dir fail"
4986 cleanup || error "cleanup failed with $?"
4988 run_test 70a "start MDT0, then OST, then MDT1"
4991 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
4994 start_ost || error "OST0 start fail"
4996 start_mds || error "MDS start fail"
4998 mount_client $MOUNT || error "mount client fails"
5000 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5002 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5003 error "create remote dir fail"
5005 rm -rf $DIR/$tdir || error "delete dir fail"
5007 cleanup || error "cleanup failed with $?"
5009 run_test 70b "start OST, MDT1, MDT0"
5012 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5015 start_mds || error "MDS start fail"
5016 start_ost || error "OST0 start fail"
5018 mount_client $MOUNT || error "mount client fails"
5019 stop_mdt 1 || error "MDT1 start fail"
5021 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
5022 echo "deactivate $mdc_for_mdt1"
5023 $LCTL --device $mdc_for_mdt1 deactivate ||
5024 error "set $mdc_for_mdt1 deactivate failed"
5026 mkdir $DIR/$tdir && error "mkdir succeed"
5028 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5029 error "create remote dir succeed"
5031 cleanup || error "cleanup failed with $?"
5033 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
5036 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5039 start_mds || error "MDS start fail"
5040 start_ost || error "OST0 start fail"
5042 mount_client $MOUNT || error "mount client fails"
5044 stop_mdt 2 || error "MDT1 start fail"
5046 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
5048 echo "deactivate $mdc_for_mdt2"
5049 $LCTL --device $mdc_for_mdt2 deactivate ||
5050 error "set $mdc_for_mdt2 deactivate failed"
5052 mkdir $DIR/$tdir || error "mkdir fail"
5053 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5054 error "create remote dir succeed"
5056 rm -rf $DIR/$tdir || error "delete dir fail"
5058 cleanup || error "cleanup failed with $?"
5060 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
5063 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5065 [ "$MDS1_VERSION" -ge $(version_code 2.7.62) ] ||
5066 skip "Need MDS version at least 2.7.62"
5068 reformat || error "reformat failed with $?"
5072 local mdsdev=$(mdsdevname 1)
5073 local ostdev=$(ostdevname 1)
5074 local mdsvdev=$(mdsvdevname 1)
5075 local ostvdev=$(ostvdevname 1)
5076 local opts_mds="$(mkfs_opts mds1 $mdsdev) --reformat $mdsdev $mdsvdev"
5077 local opts_ost="$(mkfs_opts ost1 $ostdev) --reformat $ostdev $ostvdev"
5079 if ! combined_mgs_mds ; then
5083 add mds1 $opts_mds || error "add mds1 failed"
5084 start_mdt 1 || error "start mdt1 failed"
5085 add ost1 $opts_ost || error "add ost1 failed"
5086 start_ost || error "start ost failed"
5087 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
5089 local soc=$(do_facet mds1 "$LCTL get_param -n \
5090 mdt.*MDT0000.sync_lock_cancel")
5091 [ $soc == "never" ] || error "SoC enabled on single MDS"
5093 for i in $(seq 2 $MDSCOUNT); do
5094 mdsdev=$(mdsdevname $i)
5095 mdsvdev=$(mdsvdevname $i)
5096 opts_mds="$(mkfs_opts mds$i $mdsdev) --reformat $mdsdev \
5098 add mds$i $opts_mds || error "add mds$i failed"
5099 start_mdt $i || error "start mdt$i fail"
5102 wait_dne_interconnect
5104 for i in $(seq $MDSCOUNT); do
5105 soc=$(do_facet mds$i "$LCTL get_param -n \
5106 mdt.*MDT000$((i - 1)).sync_lock_cancel")
5107 [ $soc == "blocking" ] || error "SoC not enabled on DNE"
5110 for i in $(seq 2 $MDSCOUNT); do
5111 stop_mdt $i || error "stop mdt$i fail"
5113 soc=$(do_facet mds1 "$LCTL get_param -n \
5114 mdt.*MDT0000.sync_lock_cancel")
5115 [ $soc == "never" ] || error "SoC enabled on single MDS"
5116 umount_client $MOUNT -f > /dev/null
5118 cleanup || error "cleanup failed with $?"
5120 run_test 70e "Sync-on-Cancel will be enabled by default on DNE"
5123 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5124 if combined_mgs_mds; then
5125 skip "needs separate MGS/MDT"
5129 start_mdt 1 || error "MDT0 start fail"
5130 start_ost || error "OST0 start fail"
5131 for num in $(seq 2 $MDSCOUNT); do
5132 start_mdt $num || return
5135 start_ost2 || error "OST1 start fail"
5137 mount_client $MOUNT || error "mount client fails"
5139 mkdir $DIR/$tdir || error "mkdir fail"
5140 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5141 error "create remote dir succeed"
5143 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5144 rm -rf $DIR/$tdir || error "delete dir fail"
5146 umount_client $MOUNT || error "umount_client failed"
5147 stop_mds || error "MDS stop fail"
5148 stop_ost || error "OST0 stop fail"
5149 stop_ost2 || error "OST1 stop fail"
5151 run_test 71a "start MDT0 OST0, MDT1, OST1"
5154 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5155 if combined_mgs_mds; then
5156 skip "needs separate MGS/MDT"
5160 for num in $(seq 2 $MDSCOUNT); do
5161 start_mdt $num || return
5163 start_ost || error "OST0 start fail"
5164 start_mdt 1 || error "MDT0 start fail"
5165 start_ost2 || error "OST1 start fail"
5167 mount_client $MOUNT || error "mount client fails"
5169 mkdir $DIR/$tdir || error "mkdir fail"
5170 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5171 error "create remote dir succeed"
5173 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5174 rm -rf $DIR/$tdir || error "delete dir fail"
5176 umount_client $MOUNT || error "umount_client failed"
5177 stop_mds || error "MDT0 stop fail"
5178 stop_ost || error "OST0 stop fail"
5179 stop_ost2 || error "OST1 stop fail"
5181 run_test 71b "start MDT1, OST0, MDT0, OST1"
5184 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5185 combined_mgs_mds && skip "needs separate MGS/MDT"
5189 start_ost || error "OST0 start fail"
5190 start_ost2 || error "OST1 start fail"
5191 for num in $(seq 2 $MDSCOUNT); do
5192 start_mdt $num || return
5194 start_mdt 1 || error "MDT0 start fail"
5196 mount_client $MOUNT || error "mount client fails"
5198 mkdir $DIR/$tdir || error "mkdir fail"
5199 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5200 error "create remote dir succeed"
5202 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5203 rm -rf $DIR/$tdir || error "delete dir fail"
5205 umount_client $MOUNT || error "umount_client failed"
5206 stop_mds || error "MDS stop fail"
5207 stop_ost || error "OST0 stop fail"
5208 stop_ost2 || error "OST1 stop fail"
5211 run_test 71c "start OST0, OST1, MDT1, MDT0"
5214 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5215 combined_mgs_mds && skip "needs separate MGS/MDT"
5219 start_ost || error "OST0 start fail"
5220 for num in $(seq 2 $MDSCOUNT); do
5221 start_mdt $num || return
5223 start_mdt 1 || error "MDT0 start fail"
5224 start_ost2 || error "OST1 start fail"
5226 mount_client $MOUNT || error "mount client fails"
5228 mkdir $DIR/$tdir || error "mkdir fail"
5229 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5230 error "create remote dir succeed"
5232 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5233 rm -rf $DIR/$tdir || error "delete dir fail"
5235 umount_client $MOUNT || error "umount_client failed"
5236 stop_mds || error "MDS stop fail"
5237 stop_ost || error "OST0 stop fail"
5238 stop_ost2 || error "OST1 stop fail"
5241 run_test 71d "start OST0, MDT1, MDT0, OST1"
5244 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5245 combined_mgs_mds && skip "needs separate MGS/MDT"
5249 start_ost || error "OST0 start fail"
5250 for num in $(seq 2 $MDSCOUNT); do
5251 start_mdt $num || return
5253 start_ost2 || error "OST1 start fail"
5254 start_mdt 1 || error "MDT0 start fail"
5256 mount_client $MOUNT || error "mount client fails"
5258 mkdir $DIR/$tdir || error "mkdir fail"
5259 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5260 error "create remote dir succeed"
5262 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5263 rm -rf $DIR/$tdir || error "delete dir fail"
5265 umount_client $MOUNT || error "umount_client failed"
5266 stop_mds || error "MDS stop fail"
5267 stop_ost || error "OST0 stop fail"
5268 stop_ost2 || error "OST1 stop fail"
5271 run_test 71e "start OST0, MDT1, OST1, MDT0"
5273 test_72() { #LU-2634
5274 [ "$mds1_FSTYPE" != ldiskfs ] &&
5275 skip "ldiskfs only test"
5277 local mdsdev=$(mdsdevname 1)
5278 local ostdev=$(ostdevname 1)
5279 local cmd="$E2FSCK -fnvd $mdsdev"
5286 if combined_mgs_mds; then
5287 add_options='--reformat'
5289 add_options='--reformat --replace'
5292 #tune MDT with "-O extents"
5294 for num in $(seq $MDSCOUNT); do
5295 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
5296 $add_options $(mdsdevname $num) $(mdsvdevname $num) ||
5297 error "add mds $num failed"
5298 do_facet mds${num} "$TUNE2FS -O extents $(mdsdevname $num)" ||
5299 error "$TUNE2FS failed on mds${num}"
5302 add ost1 $(mkfs_opts ost1 $ostdev) $add_options $ostdev ||
5303 error "add $ostdev failed"
5304 start_mds || error "start mds failed"
5305 start_ost || error "start ost failed"
5306 mount_client $MOUNT || error "mount client failed"
5308 #create some short symlinks
5309 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5310 createmany -o $DIR/$tdir/$tfile-%d $fn
5311 echo "create $fn short symlinks"
5312 for i in $(seq -w 1 $fn); do
5313 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
5318 umount_client $MOUNT || error "umount client failed"
5319 stop_mds || error "stop mds failed"
5320 stop_ost || error "stop ost failed"
5323 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
5325 run_test 72 "test fast symlink with extents flag enabled"
5327 test_73() { #LU-3006
5328 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
5329 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
5330 error "1st tunefs failed"
5331 start_mgsmds || error "start mds failed"
5332 start_ost || error "start ost failed"
5333 mount_client $MOUNT || error "mount client failed"
5334 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
5335 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
5336 umount_client $MOUNT || error "umount client failed"
5340 run_test 73 "failnode to update from mountdata properly"
5342 test_75() { # LU-2374
5343 [[ "$MDS1_VERSION" -lt $(version_code 2.4.1) ]] &&
5344 skip "Need MDS version at least 2.4.1"
5347 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
5348 --replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
5349 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
5350 --replace --reformat $(ostdevname 1) $(ostvdevname 1)"
5352 #check with default parameters
5353 add mds1 $opts_mds || error "add mds1 failed for default params"
5354 add ost1 $opts_ost || error "add ost1 failed for default params"
5356 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
5357 opts_mds=$(echo $opts_mds |
5358 sed -e "s/--index=$index/--index=$index --mdt/")
5359 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
5360 opts_ost=$(echo $opts_ost |
5361 sed -e "s/--index=$index/--index=$index --ost/")
5363 add mds1 $opts_mds || error "add mds1 failed for new params"
5364 add ost1 $opts_ost || error "add ost1 failed for new params"
5369 run_test 75 "The order of --index should be irrelevant"
5372 [[ "$MGS_VERSION" -ge $(version_code 2.4.52) ]] ||
5373 skip "Need MDS version at least 2.4.52"
5376 local MDMB_PARAM="osc.*.max_dirty_mb"
5377 echo "Change MGS params"
5378 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
5380 echo "max_dirty_mb: $MAX_DIRTY_MB"
5381 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB - 10))
5382 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
5383 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
5384 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5385 head -1" $NEW_MAX_DIRTY_MB
5386 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5387 echo "$MAX_DIRTY_MB"
5388 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5389 error "error while apply max_dirty_mb"
5391 echo "Check the value is stored after remount"
5394 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5395 head -1" $NEW_MAX_DIRTY_MB
5396 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5397 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5398 error "max_dirty_mb is not saved after remount"
5400 echo "Change OST params"
5401 CLIENT_PARAM="obdfilter.*.client_cache_count"
5402 local CLIENT_CACHE_COUNT
5403 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5405 echo "client_cache_count: $CLIENT_CACHE_COUNT"
5406 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
5407 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
5408 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
5409 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5410 head -1" $NEW_CLIENT_CACHE_COUNT
5411 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5413 echo "$CLIENT_CACHE_COUNT"
5414 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5415 error "error while apply client_cache_count"
5417 echo "Check the value is stored after remount"
5420 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5421 head -1" $NEW_CLIENT_CACHE_COUNT
5422 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5424 echo "$CLIENT_CACHE_COUNT"
5425 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5426 error "client_cache_count is not saved after remount"
5429 run_test 76a "set permanent params with lctl across mounts"
5431 test_76b() { # LU-4783
5432 [[ "$MGS_VERSION" -ge $(version_code 2.5.57) ]] ||
5433 skip "Need MGS version at least 2.5.57"
5436 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
5437 error "start params log failed"
5440 run_test 76b "verify params log setup correctly"
5443 [[ "$MGS_VERSION" -ge $(version_code 2.8.54) ]] ||
5444 skip "Need MDS version at least 2.4.52"
5446 local MASK_PARAM="mdd.*.changelog_mask"
5447 echo "Change changelog_mask"
5448 do_facet mgs $LCTL set_param -P $MASK_PARAM=-CLOSE ||
5449 error "Can't change changlog_mask"
5450 wait_update $(facet_host mds) "$LCTL get_param -n $MASK_PARAM |
5453 echo "Check the value is stored after mds remount"
5454 stop_mds || error "Failed to stop MDS"
5455 start_mds || error "Failed to start MDS"
5456 local CHANGELOG_MASK=$(do_facet mgs $LCTL get_param -n $MASK_PARAM)
5457 echo $CHANGELOG_MASK | grep CLOSE > /dev/null &&
5458 error "changelog_mask is not changed"
5462 run_test 76c "verify changelog_mask is applied with lctl set_param -P"
5464 test_76d() { #LU-9399
5467 local xattr_cache="llite.*.xattr_cache"
5468 local cmd="$LCTL get_param -n $xattr_cache | head -1"
5469 local new=$((($(eval $cmd) + 1) % 2))
5471 echo "lctl set_param -P llite.*.xattr_cache=$new"
5472 do_facet mgs $LCTL set_param -P $xattr_cache=$new ||
5473 error "Can't change xattr_cache"
5474 wait_update $HOSTNAME "$cmd" "$new"
5476 echo "Check $xattr_cache on client $MOUNT"
5477 umount_client $MOUNT || error "umount $MOUNT failed"
5478 mount_client $MOUNT || error "mount $MOUNT failed"
5479 [ $(eval $cmd) -eq $new ] ||
5480 error "$xattr_cache != $new on client $MOUNT"
5482 echo "Check $xattr_cache on the new client $MOUNT2"
5483 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
5484 [ $(eval $cmd) -eq $new ] ||
5485 error "$xattr_cache != $new on client $MOUNT2"
5486 umount_client $MOUNT2 || error "umount $MOUNT2 failed"
5490 run_test 76d "verify llite.*.xattr_cache can be set by 'lctl set_param -P' correctly"
5492 test_77() { # LU-3445
5493 [[ "$MDS1_VERSION" -ge $(version_code 2.8.55) ]] ||
5494 skip "Need MDS version 2.8.55+ "
5496 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
5497 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
5498 skip_env "mixed loopback and real device not working"
5501 local fs2mdsdev=$(mdsdevname 1_2)
5502 local fs2ostdev=$(ostdevname 1_2)
5503 local fs2mdsvdev=$(mdsvdevname 1_2)
5504 local fs2ostvdev=$(ostvdevname 1_2)
5505 local fsname=test1234
5507 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
5509 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
5511 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
5512 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
5513 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
5514 error "start fs2mds failed"
5516 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
5517 mgsnid="0.0.0.0@tcp,$mgsnid,$mgsnid:$mgsnid"
5519 add fs2ost --mgsnode=$mgsnid $(mkfs_opts ost1 $fs2ostdev) \
5520 --failnode=$failnid --fsname=$fsname \
5521 --reformat $fs2ostdev $fs2ostvdev ||
5522 error "add fs2ost failed"
5523 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
5525 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
5526 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
5527 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
5530 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
5533 [[ "$mds1_FSTYPE" != ldiskfs ||
5534 "$ost1_FSTYPE" != ldiskfs ]] &&
5535 skip "ldiskfs only test"
5537 # reformat the Lustre filesystem with a smaller size
5538 local saved_MDSCOUNT=$MDSCOUNT
5539 local saved_MDSSIZE=$MDSSIZE
5540 local saved_OSTCOUNT=$OSTCOUNT
5541 local saved_OSTSIZE=$OSTSIZE
5544 MDSSIZE=$((MDSSIZE - 20000))
5545 OSTSIZE=$((OSTSIZE - 20000))
5546 reformat || error "(1) reformat Lustre filesystem failed"
5547 MDSSIZE=$saved_MDSSIZE
5548 OSTSIZE=$saved_OSTSIZE
5550 # mount the Lustre filesystem
5551 setup_noconfig || error "(2) setup Lustre filesystem failed"
5554 log "create test files"
5559 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
5561 for i in $(seq $num_files); do
5562 file=$MOUNT/$tdir/$tfile-$i
5563 dd if=/dev/urandom of=$file count=1 bs=1M || {
5564 $LCTL get_param osc.*.cur*grant*
5565 $LFS df; $LFS df -i;
5566 # stop creating files if there is no more space
5567 if [ ! -e $file ]; then
5568 num_files=$((i - 1))
5572 $LFS getstripe -v $file
5573 local ost_idx=$(LFS getstripe -i $file)
5574 do_facet ost$((ost_idx + 1)) \
5575 $LCTL get_param obdfilter.*.*grant*
5576 error "(4) create $file failed"
5580 # unmount the Lustre filesystem
5581 cleanup || error "(5) cleanup Lustre filesystem failed"
5583 # run e2fsck on the MDT and OST devices
5584 local mds_host=$(facet_active_host $SINGLEMDS)
5585 local ost_host=$(facet_active_host ost1)
5586 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
5587 local ost_dev=$(ostdevname 1)
5589 run_e2fsck $mds_host $mds_dev "-y"
5590 run_e2fsck $ost_host $ost_dev "-y"
5592 # get the original block count of the MDT and OST filesystems
5593 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
5594 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
5596 # expand the MDT and OST filesystems to the device size
5597 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
5598 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
5600 # run e2fsck on the MDT and OST devices again
5601 run_e2fsck $mds_host $mds_dev "-y"
5602 run_e2fsck $ost_host $ost_dev "-y"
5604 # mount the Lustre filesystem
5608 log "check files after expanding the MDT and OST filesystems"
5609 for i in $(seq $num_files); do
5610 file=$MOUNT/$tdir/$tfile-$i
5611 $CHECKSTAT -t file -s 1048576 $file ||
5612 error "(6) checkstat $file failed"
5616 log "create more files after expanding the MDT and OST filesystems"
5617 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
5618 file=$MOUNT/$tdir/$tfile-$i
5619 dd if=/dev/urandom of=$file count=1 bs=1M ||
5620 error "(7) create $file failed"
5623 # unmount the Lustre filesystem
5624 cleanup || error "(8) cleanup Lustre filesystem failed"
5626 # run e2fsck on the MDT and OST devices
5627 run_e2fsck $mds_host $mds_dev "-y"
5628 run_e2fsck $ost_host $ost_dev "-y"
5630 # get the maximum block count of the MDT and OST filesystems
5631 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
5632 local ost_max_blks=$(get_block_count ost1 $ost_dev)
5634 # get the minimum block count of the MDT and OST filesystems
5635 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
5636 grep minimum | sed -e 's/^.*filesystem: //g')
5637 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
5638 grep minimum | sed -e 's/^.*filesystem: //g')
5640 # shrink the MDT and OST filesystems to a smaller size
5644 if [[ $mds_max_blks -gt $mds_min_blks &&
5645 $mds_max_blks -gt $mds_orig_blks ]]; then
5646 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
5647 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
5648 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
5649 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
5650 error "shrink $SINGLEMDS to $new_blks failed"
5654 if [[ $ost_max_blks -gt $ost_min_blks &&
5655 $ost_max_blks -gt $ost_orig_blks ]]; then
5656 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
5657 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
5658 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
5659 run_resize2fs ost1 $ost_dev $new_blks ||
5660 error "shrink ost1 to $new_blks failed"
5664 # check whether the MDT or OST filesystem was shrunk or not
5666 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
5667 reformat_and_config ||
5668 error "(10) reformat Lustre filesystem failed"
5672 # run e2fsck on the MDT and OST devices again
5673 run_e2fsck $mds_host $mds_dev "-y"
5674 run_e2fsck $ost_host $ost_dev "-y"
5676 # mount the Lustre filesystem again
5680 log "check files after shrinking the MDT and OST filesystems"
5681 for i in $(seq $((num_files + 10))); do
5682 file=$MOUNT/$tdir/$tfile-$i
5683 $CHECKSTAT -t file -s 1048576 $file ||
5684 error "(11) checkstat $file failed"
5687 # unmount and reformat the Lustre filesystem
5688 cleanup || error "(12) cleanup Lustre filesystem failed"
5689 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
5691 MDSCOUNT=$saved_MDSCOUNT
5692 OSTCOUNT=$saved_OSTCOUNT
5693 reformat_and_config || error "(14) reformat Lustre filesystem failed"
5695 run_test 78 "run resize2fs on MDT and OST filesystems"
5697 test_79() { # LU-4227
5698 [[ "$MDS1_VERSION" -ge $(version_code 2.5.59) ]] ||
5699 skip "Need MDS version at least 2.5.59"
5701 local mdsdev1=$(mdsdevname 1)
5702 local mdsvdev1=$(mdsvdevname 1)
5703 local mdsdev2=$(mdsdevname 2)
5704 local mdsvdev2=$(mdsvdevname 2)
5705 local ostdev1=$(ostdevname 1)
5706 local ostvdev1=$(ostvdevname 1)
5707 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
5708 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
5709 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
5712 # remove --mgs/--mgsnode from mkfs.lustre options
5713 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
5715 mgsnode_opt=$(echo $opts_mds2 |
5716 awk '{ for ( i = 1; i < NF; i++ )
5717 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5718 [ -n "$mgsnode_opt" ] &&
5719 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
5721 mgsnode_opt=$(echo $opts_ost1 |
5722 awk '{ for ( i = 1; i < NF; i++ )
5723 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5724 [ -n "$mgsnode_opt" ] &&
5725 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
5727 # -MGS, format a mdt without --mgs option
5728 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
5729 error "Must specify --mgs when formatting mdt combined with mgs"
5731 # +MGS, format a mdt/ost without --mgsnode option
5732 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
5733 > /dev/null || error "start mds1 failed"
5734 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
5735 error "Must specify --mgsnode when formatting a mdt"
5736 add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
5737 error "Must specify --mgsnode when formatting an ost"
5741 run_test 79 "format MDT/OST without mgs option (should return errors)"
5744 start_mds || error "Failed to start MDT"
5745 start_ost || error "Failed to start OST1"
5746 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
5747 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
5748 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
5749 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
5750 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
5752 start_ost2 || error "Failed to start OST2"
5754 do_facet ost1 "$LCTL set_param fail_loc=0"
5759 run_test 80 "mgc import reconnect race"
5761 #Save the original values of $OSTCOUNT and $OSTINDEX$i.
5763 local new_ostcount=$1
5764 saved_ostcount=$OSTCOUNT
5765 OSTCOUNT=$new_ostcount
5769 for i in $(seq $OSTCOUNT); do
5771 eval saved_ostindex$i=${!index}
5776 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
5777 restore_ostindex() {
5782 for i in $(seq $OSTCOUNT); do
5783 index=saved_ostindex$i
5784 eval OSTINDEX$i=${!index}
5786 OSTCOUNT=$saved_ostcount
5789 if ! combined_mgs_mds ; then
5794 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
5795 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
5796 # assigned index and ensures we can mount such a formatted file system
5797 test_81() { # LU-4665
5798 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
5799 skip "Need MDS version at least 2.6.54"
5800 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5804 # Each time RANDOM is referenced, a random integer between 0 and 32767
5807 local saved_ostindex1=$OSTINDEX1
5808 for i in 65535 $((RANDOM + 65536)); do
5809 echo -e "\nFormat ost1 with --index=$i, should fail"
5811 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
5812 $(ostdevname 1) $(ostvdevname 1); then
5813 OSTINDEX1=$saved_ostindex1
5814 error "format ost1 with --index=$i should fail"
5817 OSTINDEX1=$saved_ostindex1
5821 # Format OSTs with random sparse indices.
5822 trap "restore_ostindex" EXIT
5823 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices"
5824 OST_INDEX_LIST=[0,$((RANDOM * 2 % 65533 + 1)),65534] formatall
5826 # Setup and check Lustre filesystem.
5827 start_mgsmds || error "start_mgsmds failed"
5828 for i in $(seq $OSTCOUNT); do
5829 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5830 error "start ost$i failed"
5833 mount_client $MOUNT || error "mount client $MOUNT failed"
5834 check_mount || error "check client $MOUNT failed"
5837 local max_easize=$($LCTL get_param -n llite.*.max_easize)
5838 [[ $max_easize -eq 128 ]] ||
5839 error "max_easize is $max_easize, should be 128 bytes"
5843 run_test 81 "sparse OST indexing"
5845 # Here we exercise the stripe placement functionality on a file system that
5846 # has formatted the OST with a random index. With the file system the following
5847 # functionality is tested:
5849 # 1. Creating a new file with a specific stripe layout.
5851 # 2. Modifiy a existing empty file with a specific stripe layout.
5853 # 3. Ensure we fail to set the stripe layout of a file that already has one.
5855 # 4. If ost-index is defined we need to ensure it is the first entry in the
5856 # ost index list returned by lfs getstripe.
5858 # 5. Lastly ensure this functionality fails with directories.
5859 test_82a() { # LU-4665
5860 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
5861 skip "Need MDS version at least 2.6.54"
5862 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5868 # Format OSTs with random sparse indices.
5872 local LOV_V1_INSANE_STRIPE_COUNT=65532
5873 for i in $(seq $OSTCOUNT); do
5874 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
5875 ost_indices+=" $index"
5877 ost_indices=$(comma_list $ost_indices)
5879 stack_trap "restore_ostindex" EXIT
5880 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5881 OST_INDEX_LIST=[$ost_indices] formatall
5883 # Setup Lustre filesystem.
5884 start_mgsmds || error "start_mgsmds failed"
5885 for i in $(seq $OSTCOUNT); do
5886 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5887 error "start ost$i failed"
5890 # Collect debug information - start of test
5891 do_nodes $(comma_list $(mdts_nodes)) \
5892 $LCTL get_param osp.*.prealloc_*_id
5894 mount_client $MOUNT || error "mount client $MOUNT failed"
5897 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
5898 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5900 stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
5901 $LCTL get_param osp.*.prealloc_*_id" EXIT
5903 # 1. If the file does not exist, new file will be created
5904 # with specified OSTs.
5905 local file=$DIR/$tdir/$tfile-1
5906 local cmd="$SETSTRIPE -o $ost_indices $file"
5908 eval $cmd || error "$cmd failed"
5909 check_stripe_count $file $OSTCOUNT
5910 check_obdidx $file $ost_indices
5911 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5912 error "write $file failed"
5914 # 2. If the file already exists and is an empty file, the file
5915 # will be attached with specified layout.
5916 file=$DIR/$tdir/$tfile-2
5917 mcreate $file || error "mcreate $file failed"
5918 cmd="$SETSTRIPE -o $ost_indices $file"
5920 eval $cmd || error "$cmd failed"
5921 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5922 error "write $file failed"
5923 check_stripe_count $file $OSTCOUNT
5924 check_obdidx $file $ost_indices
5926 # 3. If the file already has a valid layout attached, the command
5927 # should fail with EBUSY.
5929 eval $cmd && error "stripe is already set on $file, $cmd should fail"
5931 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
5932 # be in the OST indices list.
5933 local start_ost_idx=${ost_indices##*,}
5934 file=$DIR/$tdir/$tfile-3
5935 cmd="$SETSTRIPE -o $ost_indices -i $start_ost_idx $file"
5937 eval $cmd || error "$cmd failed"
5938 check_stripe_count $file $OSTCOUNT
5939 check_obdidx $file $ost_indices
5940 check_start_ost_idx $file $start_ost_idx
5942 file=$DIR/$tdir/$tfile-4
5944 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
5945 cmd+=" -i $start_ost_idx $file"
5947 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
5949 # 5. Specifying OST indices for directory should succeed.
5950 local dir=$DIR/$tdir/$tdir
5951 mkdir $dir || error "mkdir $dir failed"
5952 cmd="$SETSTRIPE -o $ost_indices $dir"
5953 if [ "$MDS1_VERSION" -gt $(version_code 2.11.53) ] &&
5954 [ "$CLIENT_VERSION" -gt $(version_code 2.11.53) ]; then
5956 eval $cmd || error "unable to specify OST indices on directory"
5958 echo "need MDS+client version at least 2.11.53"
5963 run_test 82a "specify OSTs for file (succeed) or directory (succeed)"
5968 # Remove OSTs from a pool and destroy the pool.
5969 destroy_pool $ost_pool || true
5974 # Test 82b is run to ensure that if the user supplies a pool with a specific
5975 # stripe layout that it behaves proprerly. It should fail in the case that
5976 # the supplied OST index list points to OSTs not contained in the user
5978 test_82b() { # LU-4665
5979 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
5980 skip "Need MDS version at least 2.6.54"
5981 [[ $OSTCOUNT -ge 4 ]] || skip_env "needs >= 4 OSTs"
5987 # Format OSTs with random sparse indices.
5991 local LOV_V1_INSANE_STRIPE_COUNT=65532
5992 for i in $(seq $OSTCOUNT); do
5993 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
5994 ost_indices+=" $index"
5996 ost_indices=$(comma_list $ost_indices)
5998 trap "restore_ostindex" EXIT
5999 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
6000 OST_INDEX_LIST=[$ost_indices] formatall
6002 # Setup Lustre filesystem.
6003 start_mgsmds || error "start_mgsmds failed"
6004 for i in $(seq $OSTCOUNT); do
6005 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
6006 error "start ost$i failed"
6009 mount_client $MOUNT || error "mount client $MOUNT failed"
6012 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
6013 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6015 # Create a new pool and add OSTs into it.
6016 local ost_pool=$FSNAME.$TESTNAME
6017 create_pool $ost_pool || error "create OST pool $ost_pool failed"
6020 trap "cleanup_82b" EXIT
6022 local ost_idx_in_list=${ost_indices##*,}
6023 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
6026 local ost_targets="$FSNAME-OST["
6027 for i in ${ost_idx_in_pool//,/ }; do
6028 ost_targets=$ost_targets$(printf "%04x," $i)
6030 ost_targets="${ost_targets%,}]"
6032 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
6033 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
6034 sort -u | tr '\n' ' ')
6036 local cmd="$LCTL pool_add $ost_pool $ost_targets"
6037 do_facet mgs $cmd || error "$cmd failed"
6038 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
6039 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
6040 error "wait_update $ost_pool failed"
6041 wait_update_facet $SINGLEMDS "$LCTL pool_list $ost_pool | wc -l" 4 ||
6042 error "wait_update pool_list $ost_pool failed"
6044 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
6045 # then the OSTs must be the members of the pool.
6046 local file=$DIR/$tdir/$tfile
6047 cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
6049 eval $cmd && error "OST with index $ost_idx_in_list should be" \
6050 "in OST pool $ost_pool"
6052 # Only select OST $ost_idx_in_list from $ost_pool for file.
6053 ost_idx_in_list=${ost_idx_in_pool#*,}
6054 cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
6056 eval $cmd || error "$cmd failed"
6057 cmd="$GETSTRIPE $file"
6059 eval $cmd || error "$cmd failed"
6060 check_stripe_count $file 2
6061 check_obdidx $file $ost_idx_in_list
6062 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6063 error "write $file failed"
6067 run_test 82b "specify OSTs for file with --pool and --ost-list options"
6070 [[ "$OST1_VERSION" -ge $(version_code 2.6.91) ]] ||
6071 skip "Need OST version at least 2.6.91"
6072 if [ "$ost1_FSTYPE" != ldiskfs ]; then
6073 skip "ldiskfs only test"
6082 ostmnt=$(facet_mntpt ost1)
6084 # Mount the OST as an ldiskfs filesystem.
6085 log "mount the OST $dev as a $ost1_FSTYPE filesystem"
6086 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
6087 --reformat $dev > /dev/null ||
6088 error "format ost1 error"
6090 if ! test -b $dev; then
6091 mnt_opts=$(csa_add "$OST_MOUNT_OPTS" -o loop)
6093 echo "mnt_opts $mnt_opts"
6094 do_facet ost1 mount -t "$ost1_FSTYPE" $dev \
6096 # Run llverfs on the mounted ldiskfs filesystem.
6097 # It is needed to get ENOSPACE.
6098 log "run llverfs in partial mode on the OST $ost1_FSTYPE $ostmnt"
6099 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
6100 "no" || error "run_llverfs error on $ost1_FSTYPE"
6103 log "unmount the OST $dev"
6106 # Delete file IO_scrub. Later osd_scrub_setup will try to
6107 # create "IO_scrub" but will get ENOSPACE.
6109 echo "start ost1 service on `facet_active_host ost1`"
6110 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
6113 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
6114 echo "string err $err"
6115 [ -z "$err" ] || error $err
6118 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
6119 Busy inodes after unmount ..."
6122 local facet=$SINGLEMDS
6123 local num=$(echo $facet | tr -d "mds")
6124 local dev=$(mdsdevname $num)
6125 local time_min=$(recovery_time_min)
6126 local recovery_duration
6127 local completed_clients
6128 local correct_clients
6131 echo "start mds service on $(facet_active_host $facet)"
6133 "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" $@ ||
6134 error "start MDS failed"
6136 start_ost || error "start OST0000 failed"
6137 start_ost2 || error "start OST0001 failed"
6139 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
6141 mount_client $MOUNT1 || error "mount $MOUNT1 failed"
6142 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
6143 # make sure new superblock labels are sync'd before disabling writes
6147 replay_barrier $SINGLEMDS
6148 createmany -o $DIR1/$tfile-%d 1000
6150 # We need to catch the end of recovery window to extend it.
6151 # Skip 5 requests and add delay to request handling.
6152 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
6153 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
6155 facet_failover --fsck $SINGLEMDS || error "failover: $?"
6158 echo "recovery status"
6159 do_facet $SINGLEMDS \
6160 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
6162 recovery_duration=$(do_facet $SINGLEMDS \
6163 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6164 awk '/recovery_duration/ { print $2 }')
6165 (( $recovery_duration > $time_min + $wrap_up )) &&
6166 error "recovery_duration > recovery_time_hard + wrap up"
6167 completed_clients=$(do_facet $SINGLEMDS \
6168 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6169 awk '/completed_clients/ { print $2 }')
6171 correct_clients="$MDSCOUNT/$((MDSCOUNT+1))"
6172 [ "$completed_clients" = "${correct_clients}" ] ||
6173 error "$completed_clients != $correct_clients"
6175 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
6176 umount_client $MOUNT1
6177 umount_client $MOUNT2
6183 run_test 84 "check recovery_hard_time"
6186 [[ "$OST1_VERSION" -ge $(version_code 2.7.55) ]] ||
6187 skip "Need OST version at least 2.7.55"
6188 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
6189 do_facet ost1 "lctl set_param fail_loc=0x197"
6193 run_test 85 "osd_ost init: fail ea_fid_set"
6198 # ost1 has already registered to the MGS before the reformat.
6199 # So after reformatting it with option "-G", it could not be
6200 # mounted to the MGS. Cleanup the system for subsequent tests.
6205 [ "$ost1_FSTYPE" = zfs ] &&
6206 skip "LU-6442: no such mkfs params for ZFS OSTs"
6207 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
6208 skip "Need server version newer than 2.7.55"
6210 local OST_OPTS="$(mkfs_opts ost1 $(ostdevname 1)) \
6211 --reformat $(ostdevname 1) $(ostvdevname 1)"
6214 local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6215 awk '/Flex block group size: / { print $NF; exit; }')
6218 if [[ ${!opts} != *mkfsoptions* ]]; then
6219 eval opts=\"${!opts} \
6220 --mkfsoptions='\\\"-O flex_bg -G $NEWSIZE\\\"'\"
6222 val=${!opts//--mkfsoptions=\\\"/ \
6223 --mkfsoptions=\\\"-O flex_bg -G $NEWSIZE }
6227 echo "params: $opts"
6229 trap cleanup_86 EXIT ERR
6232 add ost1 $opts || error "add ost1 failed with new params"
6234 local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6235 awk '/Flex block group size: / { print $NF; exit; }')
6237 [[ $FOUNDSIZE == $NEWSIZE ]] ||
6238 error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
6242 run_test 86 "Replacing mkfs.lustre -G option"
6244 test_87() { #LU-6544
6245 [[ "$MDS1_VERSION" -ge $(version_code 2.9.51) ]] ||
6246 skip "Need MDS version at least 2.9.51"
6247 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
6248 skip "ldiskfs only test"
6249 [[ $OSTCOUNT -gt 59 ]] &&
6250 skip "Ignore wide striping situation"
6252 local mdsdev=$(mdsdevname 1)
6253 local mdsvdev=$(mdsvdevname 1)
6254 local file=$DIR/$tfile
6255 local mntpt=$(facet_mntpt $SINGLEMDS)
6256 local used_xattr_blk=0
6257 local inode_size=${1:-1024}
6259 local xtest="trusted.test"
6263 local stripe_cnt=$(($OSTCOUNT + 2))
6265 #Please see ldiskfs_make_lustre() for MDT inode size calculation
6266 if [ $stripe_cnt -gt 16 ]; then
6269 left_size=$(expr $inode_size - \
6272 32 - 40 \* 3 - 32 \* 3 - $stripe_cnt \* 24 - 16 - 3 - \
6274 24 - 18 - $(expr length $tfile) - 16 - 4)
6275 if [ $left_size -le 0 ]; then
6276 echo "No space($left_size) is expected in inode."
6277 echo "Try 1-byte xattr instead to verify this."
6280 echo "Estimate: at most $left_size-byte space left in inode."
6286 if ! combined_mgs_mds ; then
6290 add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$stripe_cnt \
6291 --reformat $mdsdev $mdsvdev || error "add mds1 failed"
6292 start_mdt 1 > /dev/null || error "start mdt1 failed"
6293 for i in $(seq $OSTCOUNT); do
6294 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
6295 error "start ost$i failed"
6297 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
6298 check_mount || error "check client $MOUNT failed"
6301 $SETSTRIPE -E 1M -S 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
6302 error "Create file with 3 components failed"
6303 $TRUNCATE $file $((1024*1024*64+1)) || error "truncate file failed"
6304 i=$($GETSTRIPE -I3 -c $file) || error "get 3rd stripe count failed"
6305 if [ $i -ne $OSTCOUNT ]; then
6306 left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
6307 echo -n "Since only $i out $OSTCOUNT OSTs are used, "
6308 echo -n "the expected left space is changed to "
6309 echo "$left_size bytes at most."
6311 value=$(generate_string $left_size)
6312 setfattr -n $xtest -v $value $file
6313 orig=$(get_xattr_value $xtest $file)
6314 [[ "$orig" != "$value" ]] && error "$xtest changed"
6316 #Verify if inode has some expected space left
6317 umount $MOUNT > /dev/null || error "umount $MOUNT failed"
6318 stop_mdt 1 > /dev/null || error "stop mdt1 failed"
6319 mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
6321 do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
6322 used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
6324 [[ $used_xattr_blk -eq 0 ]] &&
6325 error "Please check MDS inode size calculation: \
6326 more than $left_size-byte space left in inode."
6327 echo "Verified: at most $left_size-byte space left in inode."
6329 umount_ldiskfs $SINGLEMDS
6331 for i in $(seq $OSTCOUNT); do
6332 stop ost$i -f || error "stop ost$i failed"
6335 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
6338 [ "$mds1_FSTYPE" == zfs ] &&
6339 skip "LU-6662: no implementation for ZFS"
6343 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6344 --reformat $(mdsdevname 1) || error "add mds1 failed"
6346 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6347 grep -e \".*opts:.*errors=remount-ro.*\"" ||
6348 error "default mount options is missing"
6350 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6351 --mountfsoptions="user_xattr,errors=panic" \
6352 --reformat $(mdsdevname 1) || error "add mds1 failed"
6354 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6355 grep -e \".*opts:.*errors=panic.*\"" ||
6356 error "user can't override default mount options"
6358 run_test 88 "check the default mount options can be overridden"
6360 test_89() { # LU-7131
6361 [[ "$MDS1_VERSION" -ge $(version_code 2.9.54) ]] ||
6362 skip "Need MDT version at least 2.9.54"
6364 local key=failover.node
6365 local val1=192.0.2.254@tcp0 # Reserved IPs, see RFC 5735
6366 local val2=192.0.2.255@tcp0
6367 local mdsdev=$(mdsdevname 1)
6372 [ "$mds1_FSTYPE" == zfs ] && import_zpool mds1
6373 # Check that parameters are added correctly
6374 echo "tunefs --param $key=$val1"
6375 do_facet mds "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
6376 error "tunefs --param $key=$val1 failed"
6377 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6378 error "tunefs --dryrun failed"
6379 params=${params##*Parameters:}
6380 params=${params%%exiting*}
6381 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val1) = "1" ] ||
6382 error "on-disk parameter not added correctly via tunefs"
6384 # Check that parameters replace existing instances when added
6385 echo "tunefs --param $key=$val2"
6386 do_facet mds "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
6387 error "tunefs --param $key=$val2 failed"
6388 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6389 error "tunefs --dryrun failed"
6390 params=${params##*Parameters:}
6391 params=${params%%exiting*}
6392 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "1" ] ||
6393 error "on-disk parameter not replaced via tunefs"
6394 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val2) = "1" ] ||
6395 error "on-disk parameter not replaced correctly via tunefs"
6397 # Check that a parameter is erased properly
6398 echo "tunefs --erase-param $key"
6399 do_facet mds "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
6400 error "tunefs --erase-param $key failed"
6401 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6402 error "tunefs --dryrun failed"
6403 params=${params##*Parameters:}
6404 params=${params%%exiting*}
6405 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "0" ] ||
6406 error "on-disk parameter not erased correctly via tunefs"
6408 # Check that all the parameters are erased
6409 echo "tunefs --erase-params"
6410 do_facet mds "$TUNEFS --erase-params $mdsdev >/dev/null" ||
6411 error "tunefs --erase-params failed"
6412 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6413 error "tunefs --dryrun failed"
6414 params=${params##*Parameters:}
6415 params=${params%%exiting*}
6417 error "all on-disk parameters not erased correctly via tunefs"
6419 # Check the order of options --erase-params and --param
6420 echo "tunefs --param $key=$val1 --erase-params"
6422 "$TUNEFS --param $key=$val1 --erase-params $mdsdev >/dev/null"||
6423 error "tunefs --param $key=$val1 --erase-params failed"
6424 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6425 error "tunefs --dryrun failed"
6426 params=${params##*Parameters:}
6427 params=${params%%exiting*}
6428 [ $(echo $params | tr ' ' '\n') == "$key=$val1" ] ||
6429 error "on-disk param not added correctly with --erase-params"
6433 run_test 89 "check tunefs --param and --erase-param{s} options"
6436 # $2 (optional) value of max_mod_rpcs_in_flight to set
6437 check_max_mod_rpcs_in_flight() {
6445 idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
6446 facet="mds$((0x$idx + 1))"
6448 if [ -z "$mmr" ]; then
6449 # get value of max_mod_rcps_in_flight
6450 mmr=$($LCTL get_param -n \
6451 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
6452 error "Unable to get max_mod_rpcs_in_flight"
6453 echo "max_mod_rcps_in_flight is $mmr"
6455 # set value of max_mod_rpcs_in_flight
6457 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
6458 error "Unable to set max_mod_rpcs_in_flight to $mmr"
6459 echo "max_mod_rpcs_in_flight set to $mmr"
6462 # create mmr+1 files
6463 echo "creating $((mmr + 1)) files ..."
6465 for i in $(seq $((mmr + 1))); do
6471 # consumes mmr-1 modify RPC slots
6472 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6473 # drop requests on MDT so that RPC slots are consumed
6474 # during all the request resend interval
6475 do_facet $facet "$LCTL set_param fail_loc=0x159"
6476 echo "launch $((mmr - 1)) chmod in parallel ..."
6477 for i in $(seq $((mmr - 1))); do
6478 chmod 0600 $dir/file-$i &
6482 # send one additional modify RPC
6483 do_facet $facet "$LCTL set_param fail_loc=0"
6484 echo "launch 1 additional chmod in parallel ..."
6485 chmod 0600 $dir/file-$mmr &
6488 # check this additional modify RPC get a modify RPC slot
6489 # and succeed its operation
6490 checkstat -vp 0600 $dir/file-$mmr ||
6491 error "Unable to send $mmr modify RPCs in parallel"
6496 # consumes mmr modify RPC slots
6497 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6498 # drop requests on MDT so that RPC slots are consumed
6499 # during all the request resend interval
6500 do_facet $facet "$LCTL set_param fail_loc=0x159"
6501 echo "launch $mmr chmod in parallel ..."
6502 for i in $(seq $mmr); do
6503 chmod 0666 $dir/file-$i &
6507 # send one additional modify RPC
6508 do_facet $facet "$LCTL set_param fail_loc=0"
6509 echo "launch 1 additional chmod in parallel ..."
6510 chmod 0666 $dir/file-$((mmr + 1)) &
6513 # check this additional modify RPC blocked getting a modify RPC slot
6514 checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
6515 error "Unexpectedly send $(($mmr + 1)) modify RPCs in parallel"
6522 [[ $($LCTL get_param mdc.*.import |
6523 grep "connect_flags:.*multi_mod_rpc") ]] ||
6524 skip "Need MDC with 'multi_mod_rpcs' feature"
6526 # check default value
6527 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6528 check_max_mod_rpcs_in_flight $DIR/$tdir
6532 run_test 90a "check max_mod_rpcs_in_flight is enforced"
6542 [[ $($LCTL get_param mdc.*.import |
6543 grep "connect_flags:.*multi_mod_rpc") ]] ||
6544 skip "Need MDC with 'multi_mod_rpcs' feature"
6547 # update max_mod_rpcs_in_flight
6548 $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
6549 check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
6552 # check client is able to send multiple modify RPCs in paralell
6553 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6554 grep -c "multi_mod_rpcs")
6555 if [ "$tmp" -ne $MDSCOUNT ]; then
6557 skip "Client not able to send multiple modify RPCs in parallel"
6560 # update max_mod_rpcs_in_flight
6561 $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
6562 check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
6565 $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
6566 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
6567 facet="mds$((0x$idx + 1))"
6569 # save MDT max_mod_rpcs_per_client
6570 mmrpc=$(do_facet $facet \
6571 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6573 # update max_mod_rpcs_in_flight
6574 umount_client $MOUNT
6576 "echo 16 > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6578 $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
6579 check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
6581 # restore MDT max_mod_rpcs_per_client initial value
6583 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6585 rm -rf $DIR/${tdir}?
6588 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
6591 # get max_rpcs_in_flight value
6592 mrif_90c=$($LCTL get_param -n \
6593 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6594 echo "max_rpcs_in_flight is $mrif_90c"
6596 # get max_mod_rpcs_in_flight value
6597 mmrif_90c=$($LCTL get_param -n \
6598 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight)
6599 echo "max_mod_rpcs_in_flight is $mmrif_90c"
6601 # get MDT max_mod_rpcs_per_client value
6602 mmrpc_90c=$(do_facet mds1 \
6603 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6604 echo "max_mod_rpcs_per_client is $mmrpc_90c"
6607 restore_params_90c() {
6610 # restore max_rpcs_in_flight value
6611 do_facet mgs $LCTL set_param -P \
6612 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
6614 # restore max_mod_rpcs_in_flight value
6615 do_facet mgs $LCTL set_param -P \
6616 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mmrif_90c
6618 # restore MDT max_mod_rpcs_per_client value
6619 do_facet mds1 "echo $mmrpc_90c > \
6620 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6628 [[ $($LCTL get_param mdc.*.import |
6629 grep "connect_flags:.*multi_mod_rpc") ]] ||
6630 skip "Need MDC with 'multi_mod_rpcs' feature"
6632 # check client is able to send multiple modify RPCs in paralell
6633 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6634 grep -c "multi_mod_rpcs")
6635 if [ "$tmp" -ne $MDSCOUNT ]; then
6637 skip "Client not able to send multiple modify RPCs in parallel"
6641 stack_trap restore_params_90c
6644 # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
6645 # prerequisite: set max_mod_rpcs_per_client to max_rpcs_in_flight value
6646 do_facet mds1 "echo $mrif_90c > \
6647 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6649 # if max_mod_rpcs_in_flight is set to be equal to or larger than
6650 # max_rpcs_in_flight, then max_rpcs_in_flight will be increased
6651 if [[ "$CLIENT_VERSION" -ge $(version_code 2.12.5) ]]; then
6653 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c ||
6654 error "set max_mod_rpcs_in_flight to $mrif_90c failed"
6656 local new_mrif=$($LCTL get_param -n \
6657 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6658 ((new_mrif == mrif_90c + 1)) ||
6659 error "max_rpcs_in_flight was not increased"
6662 umount_client $MOUNT
6663 do_facet mds1 "echo $mmrpc_90c > \
6664 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6668 # attempt to set max_mod_rpcs_in_flight to max_mod_rpcs_per_client+1
6669 # prerequisite: set max_rpcs_in_flight to max_mod_rpcs_per_client+2
6671 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc_90c + 2))
6674 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc_90c + 1)) &&
6675 error "set max_mod_rpcs_in_flight to $((mmrpc_90c + 1)) should fail"
6678 # attempt to set max_mod_rpcs_in_flight permanently
6679 do_facet mgs $LCTL set_param -P \
6680 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
6682 do_facet mgs $LCTL set_param -P \
6683 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c
6685 remount_client $MOUNT
6687 wait_update_facet --verbose client "$LCTL get_param -n \
6688 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight" \
6689 "$((mrif_90c + 1))" ||
6690 error "expected '$((mrif_90c + 1))' for max_rpcs_in_flight"
6692 wait_update_facet --verbose client "$LCTL get_param -n \
6693 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight" \
6695 error "expected '$mrif_90c' for max_mod_rpcs_in_flight"
6700 run_test 90c "check max_mod_rpcs_in_flight update limits"
6711 [[ $($LCTL get_param mdc.*.import |
6712 grep "connect_flags:.*multi_mod_rpc") ]] ||
6713 skip "Need MDC with 'multi_mod_rpcs' feature"
6715 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6716 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
6717 facet="mds$((0x$idx + 1))"
6719 # check client version supports multislots
6720 tmp=$($LCTL get_param -N \
6721 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6722 if [ -z "$tmp" ]; then
6724 skip "Client does not support multiple modify RPCs in flight"
6727 # get current value of max_mod_rcps_in_flight
6728 mmr=$($LCTL get_param -n \
6729 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6730 echo "max_mod_rcps_in_flight is $mmr"
6733 echo "creating $mmr files ..."
6735 for i in $(seq $mmr); do
6736 touch $DIR/$tdir/file-$i
6739 # prepare for close RPC
6740 multiop_bg_pause $DIR/$tdir/file-close O_c
6743 # consumes mmr modify RPC slots
6744 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6745 # drop requests on MDT so that RPC slots are consumed
6746 # during all the request resend interval
6747 do_facet $facet "$LCTL set_param fail_loc=0x159"
6748 echo "launch $mmr chmod in parallel ..."
6749 for i in $(seq $mmr); do
6750 chmod 0600 $DIR/$tdir/file-$i &
6753 # send one additional close RPC
6754 do_facet $facet "$LCTL set_param fail_loc=0"
6755 echo "launch 1 additional close in parallel ..."
6757 cancel_lru_locks mdc
6760 # check this additional close RPC get a modify RPC slot
6761 # and multiop process completed
6762 [ -d /proc/$pid ] &&
6763 error "Unable to send the additional close RPC in parallel"
6768 run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
6770 check_uuid_on_ost() {
6772 do_facet ost1 "$LCTL get_param obdfilter.${FSNAME}*.exports.'$nid'.uuid"
6775 check_uuid_on_mdt() {
6777 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6785 [[ "$OST1_VERSION" -ge $(version_code 2.7.63) ]] ||
6786 skip "Need OST version at least 2.7.63"
6787 [[ "$MDS1_VERSION" -ge $(version_code 2.7.63) ]] ||
6788 skip "Need MDT version at least 2.7.63"
6790 start_mds || error "MDS start failed"
6791 start_ost || error "unable to start OST"
6792 mount_client $MOUNT || error "client start failed"
6793 check_mount || error "check_mount failed"
6796 nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
6800 uuid=$(get_client_uuid $MOUNT)
6802 echo "list nids on mdt:"
6803 do_facet $SINGLEMDS "$LCTL list_param mdt.${FSNAME}*.exports.*"
6804 echo "uuid from $nid:"
6805 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6807 found=$(check_uuid_on_mdt $nid | grep $uuid)
6808 [ -z "$found" ] && error "can't find $uuid $nid on MDT"
6809 found=$(check_uuid_on_ost $nid | grep $uuid)
6810 [ -z "$found" ] && error "can't find $uuid $nid on OST"
6812 # umount the client so it won't reconnect
6813 manual_umount_client --force || error "failed to umount $?"
6814 # shouldn't disappear on MDS after forced umount
6815 found=$(check_uuid_on_mdt $nid | grep $uuid)
6816 [ -z "$found" ] && error "can't find $uuid $nid"
6819 do_facet $SINGLEMDS \
6820 "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
6822 found=$(check_uuid_on_mdt $nid | grep $uuid)
6823 [ -n "$found" ] && error "found $uuid $nid on MDT"
6824 found=$(check_uuid_on_ost $nid | grep $uuid)
6825 [ -n "$found" ] && error "found $uuid $nid on OST"
6827 # check it didn't reconnect (being umounted)
6828 sleep $((TIMEOUT+1))
6829 found=$(check_uuid_on_mdt $nid | grep $uuid)
6830 [ -n "$found" ] && error "found $uuid $nid on MDT"
6831 found=$(check_uuid_on_ost $nid | grep $uuid)
6832 [ -n "$found" ] && error "found $uuid $nid on OST"
6836 run_test 91 "evict-by-nid support"
6838 generate_ldev_conf() {
6839 # generate an ldev.conf file
6840 local ldevconfpath=$1
6842 local fsldevformat=""
6845 fstype=$(facet_fstype mgs)
6846 if [ "$fstype" == zfs ]; then
6847 fsldevformat="$fstype:"
6852 printf "%s\t-\t%s-MGS0000\t%s%s\n" \
6856 $(mgsdevname) > $ldevconfpath
6858 local mdsfo_host=$mdsfailover_HOST;
6859 if [ -z "$mdsfo_host" ]; then
6863 for num in $(seq $MDSCOUNT); do
6864 fstype=$(facet_fstype mds$num)
6865 if [ "$fstype" == zfs ]; then
6866 fsldevformat="$fstype:"
6871 printf "%s\t%s\t%s-MDT%04d\t%s%s\n" \
6877 $(mdsdevname $num) >> $ldevconfpath
6880 local ostfo_host=$ostfailover_HOST;
6881 if [ -z "$ostfo_host" ]; then
6885 for num in $(seq $OSTCOUNT); do
6886 fstype=$(facet_fstype ost$num)
6887 if [ "$fstype" == zfs ]; then
6888 fsldevformat="$fstype:"
6893 printf "%s\t%s\t%s-OST%04d\t%s%s\n" \
6899 $(ostdevname $num) >> $ldevconfpath
6902 echo "----- $ldevconfpath -----"
6904 echo "--- END $ldevconfpath ---"
6909 # generate a nids file (mapping between hostname to nid)
6910 # looks like we only have the MGS nid available to us
6911 # so just echo that to a file
6913 echo -e "${mgs_HOST}\t${MGSNID}" > $nidspath
6915 echo "----- $nidspath -----"
6917 echo "--- END $nidspath ---"
6920 compare_ldev_output() {
6924 sort $expected_output -o $expected_output
6925 sort $ldev_output -o $ldev_output
6927 echo "-- START OF LDEV OUTPUT --"
6929 echo "--- END OF LDEV OUTPUT ---"
6931 echo "-- START OF EXPECTED OUTPUT --"
6932 cat $expected_output
6933 echo "--- END OF EXPECTED OUTPUT ---"
6935 diff $expected_output $ldev_output
6940 if [ -z "$LDEV" ]; then
6941 error "ldev is missing!"
6944 local LDEVCONFPATH=$TMP/ldev.conf
6945 local NIDSPATH=$TMP/nids
6947 echo "Host is $(hostname)"
6949 generate_ldev_conf $LDEVCONFPATH
6950 generate_nids $NIDSPATH
6952 # echo the mgs nid and compare it to environment variable MGSNID
6953 # also, ldev.conf and nids is a server side thing, use the OSS
6956 output=$($LDEV -c $LDEVCONFPATH -H $ost_HOST -n $NIDSPATH echo %m)
6958 echo "-- START OF LDEV OUTPUT --"
6960 echo "--- END OF LDEV OUTPUT ---"
6962 # ldev failed, error
6963 if [ $? -ne 0 ]; then
6964 rm $LDEVCONFPATH $NIDSPATH
6965 error "ldev failed to execute!"
6968 # need to process multiple lines because of combined MGS and MDS
6969 echo -e $output | awk '{ print $2 }' | while read -r line ; do
6970 if [ "$line" != "$MGSNID" ]; then
6971 rm $LDEVCONFPATH $NIDSPATH
6972 error "ldev failed mgs nid '$line', expected '$MGSNID'"
6976 rm $LDEVCONFPATH $NIDSPATH
6978 run_test 92 "ldev returns MGS NID correctly in command substitution"
6981 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
6984 #start mgs or mgs/mdt0
6985 if ! combined_mgs_mds ; then
6992 start_ost || error "OST0 start fail"
6994 #define OBD_FAIL_MGS_WRITE_TARGET_DELAY 0x90e
6995 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x8000090e"
6996 for num in $(seq 2 $MDSCOUNT); do
7000 mount_client $MOUNT || error "mount client fails"
7001 wait_osc_import_state mds ost FULL
7002 wait_osc_import_ready client ost
7003 check_mount || error "check_mount failed"
7005 cleanup || error "cleanup failed with $?"
7007 run_test 93 "register mulitple MDT at the same time"
7010 if [ -z "$LDEV" ]; then
7011 error "ldev is missing!"
7014 local LDEVCONFPATH=$TMP/ldev.conf
7015 local NIDSPATH=$TMP/nids
7017 generate_ldev_conf $LDEVCONFPATH
7018 generate_nids $NIDSPATH
7020 local LDEV_OUTPUT=$TMP/ldev-output.txt
7021 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME > $LDEV_OUTPUT
7023 # ldev failed, error
7024 if [ $? -ne 0 ]; then
7025 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7026 error "ldev failed to execute!"
7030 local EXPECTED_OUTPUT=$TMP/ldev-expected.txt
7032 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7034 for num in $(seq $MDSCOUNT); do
7035 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7038 for num in $(seq $OSTCOUNT); do
7039 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7042 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7044 if [ $? -ne 0 ]; then
7045 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7046 error "ldev failed to produce the correct hostlist!"
7049 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7051 run_test 94 "ldev outputs correct labels for file system name query"
7054 if [ -z "$LDEV" ]; then
7055 error "ldev is missing!"
7058 local LDEVCONFPATH=$TMP/ldev.conf
7059 local NIDSPATH=$TMP/nids
7061 generate_ldev_conf $LDEVCONFPATH
7062 generate_nids $NIDSPATH
7066 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME &>/dev/null
7067 if [ $? -ne 0 ]; then
7068 rm $LDEVCONFPATH $NIDSPATH
7069 error "ldev label filtering w/ -F failed!"
7073 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -l &>/dev/null
7074 if [ $? -ne 0 ]; then
7075 rm $LDEVCONFPATH $NIDSPATH
7076 error "ldev label filtering w/ -l failed!"
7080 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f &>/dev/null
7081 if [ $? -ne 0 ]; then
7082 rm $LDEVCONFPATH $NIDSPATH
7083 error "ldev label filtering w/ -f failed!"
7087 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a &>/dev/null
7088 if [ $? -ne 0 ]; then
7089 rm $LDEVCONFPATH $NIDSPATH
7090 error "ldev label filtering w/ -a failed!"
7095 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -F $FSNAME &>/dev/null
7096 if [ $? -eq 0 ]; then
7097 rm $LDEVCONFPATH $NIDSPATH
7098 error "ldev label filtering w/ -a and -F incorrectly succeeded"
7102 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -f &>/dev/null
7103 if [ $? -eq 0 ]; then
7104 rm $LDEVCONFPATH $NIDSPATH
7105 error "ldev label filtering w/ -a and -f incorrectly succeeded"
7109 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -l &>/dev/null
7110 if [ $? -eq 0 ]; then
7111 rm $LDEVCONFPATH $NIDSPATH
7112 error "ldev label filtering w/ -a and -l incorrectly succeeded"
7116 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f -l &>/dev/null
7117 if [ $? -eq 0 ]; then
7118 rm $LDEVCONFPATH $NIDSPATH
7119 error "ldev label filtering w/ -f and -l incorrectly succeeded"
7123 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -l &>/dev/null
7124 if [ $? -eq 0 ]; then
7125 rm $LDEVCONFPATH $NIDSPATH
7126 error "ldev label filtering w/ -F and -l incorrectly succeeded"
7129 # file sys & foreign
7130 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -f &>/dev/null
7131 if [ $? -eq 0 ]; then
7132 rm $LDEVCONFPATH $NIDSPATH
7133 error "ldev label filtering w/ -F and -f incorrectly succeeded"
7136 rm $LDEVCONFPATH $NIDSPATH
7138 run_test 95 "ldev should only allow one label filter"
7141 if [ -z "$LDEV" ]; then
7142 error "ldev is missing!"
7145 local LDEVCONFPATH=$TMP/ldev.conf
7146 local NIDSPATH=$TMP/nids
7148 generate_ldev_conf $LDEVCONFPATH
7149 generate_nids $NIDSPATH
7151 local LDEV_OUTPUT=$TMP/ldev-output.txt
7152 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -H $mgs_HOST \
7154 awk '{print $2}' > $LDEV_OUTPUT
7156 # ldev failed, error
7157 if [ $? -ne 0 ]; then
7158 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7159 error "ldev failed to execute!"
7163 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7165 echo "$mgs_HOST-$(facet_fstype mgs)" > $EXPECTED_OUTPUT
7167 if [ "$mgs_HOST" == "$mds_HOST" ]; then
7168 for num in $(seq $MDSCOUNT); do
7169 echo "$mds_HOST-$(facet_fstype mds$num)" \
7174 if [ "$mgs_HOST" == "$ost_HOST" ]; then
7175 for num in $(seq $OSTCOUNT); do
7176 echo "$ost_HOST-$(facet_fstype ost$num)" \
7181 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7183 if [ $? -ne 0 ]; then
7184 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7185 error "ldev failed to produce the correct output!"
7188 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7190 run_test 96 "ldev returns hostname and backend fs correctly in command sub"
7193 if [ -z "$LDEV" ]; then
7194 error "ldev is missing!"
7197 local LDEVCONFPATH=$TMP/ldev.conf
7198 local NIDSPATH=$TMP/nids
7200 generate_ldev_conf $LDEVCONFPATH
7201 generate_nids $NIDSPATH
7203 local LDEV_OUTPUT=$TMP/ldev-output.txt
7204 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7206 echo -e "\nMDT role"
7207 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mdt > $LDEV_OUTPUT
7209 if [ $? -ne 0 ]; then
7210 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7211 error "ldev failed to execute for mdt role!"
7214 for num in $(seq $MDSCOUNT); do
7215 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7218 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7220 if [ $? -ne 0 ]; then
7221 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7222 error "ldev failed to produce the correct output for mdt role!"
7225 echo -e "\nOST role"
7226 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R ost > $LDEV_OUTPUT
7228 if [ $? -ne 0 ]; then
7229 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7230 error "ldev failed to execute for ost role!"
7234 for num in $(seq $OSTCOUNT); do
7235 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7238 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7240 if [ $? -ne 0 ]; then
7241 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7242 error "ldev failed to produce the correct output for ost role!"
7245 echo -e "\nMGS role"
7246 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mgs > $LDEV_OUTPUT
7248 if [ $? -ne 0 ]; then
7249 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7250 error "ldev failed to execute for mgs role!"
7253 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7255 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7257 if [ $? -ne 0 ]; then
7258 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7259 error "ldev failed to produce the correct output for mgs role!"
7262 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7264 run_test 97 "ldev returns correct ouput when querying based on role"
7269 local temp=$MDS_MOUNT_OPTS
7272 check_mount || error "mount failed"
7273 mountopt="user_xattr"
7274 for ((x = 1; x <= 400; x++)); do
7275 mountopt="$mountopt,user_xattr"
7277 mount_client $MOUNT remount,$mountopt 2>&1 | grep "too long" ||
7278 error "Buffer overflow check failed"
7279 cleanup || error "cleanup failed"
7281 run_test 98 "Buffer-overflow check while parsing mount_opts"
7285 [[ "$ost1_FSTYPE" != ldiskfs ]] &&
7286 skip "ldiskfs only test"
7287 [[ "$OST1_VERSION" -ge $(version_code 2.8.57) ]] ||
7288 skip "Need OST version at least 2.8.57"
7290 local ost_opts="$(mkfs_opts ost1 $(ostdevname 1)) \
7291 --reformat $(ostdevname 1) $(ostvdevname 1)"
7292 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" &&
7293 skip "meta_bg already set"
7296 if [[ ${!opts} != *mkfsoptions* ]]; then
7297 eval opts=\"${!opts} \
7298 --mkfsoptions='\\\"-O ^resize_inode,meta_bg\\\"'\"
7300 local val=${!opts//--mkfsoptions=\\\"/ \
7301 --mkfsoptions=\\\"-O ^resize_inode,meta_bg }
7305 echo "params: $opts"
7308 add ost1 $opts || error "add ost1 failed with new params"
7310 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" ||
7311 error "meta_bg is not set"
7313 run_test 99 "Adding meta_bg option"
7318 start_mgsmds || error "MDS start failed"
7319 start_ost || error "unable to start OST"
7320 mount_client $MOUNT || error "client start failed"
7321 check_mount || error "check_mount failed"
7330 do_facet mgs 'lshowmount -v' | awk 'BEGIN {NR == 0; rc=1} /MGS:/ {rc=0}
7331 END {exit rc}' || error "lshowmount have no output MGS"
7333 do_facet mds1 'lshowmount -v' | awk 'BEGIN {NR == 2; rc=1} /-MDT0000:/
7334 {rc=0} END {exit rc}' || error "lshowmount have no output MDT0"
7336 do_facet ost1 'lshowmount -v' | awk 'BEGIN {NR == 4; rc=1} /-OST0000:/
7337 {rc=0} END {exit rc}' || error "lshowmount have no output OST0"
7339 cleanup || error "cleanup failed with $?"
7341 run_test 100 "check lshowmount lists MGS, MDT, OST and 0@lo"
7344 local createmany_pid
7345 local dev=$FSNAME-OST0000-osc-MDT0000
7349 createmany -o $DIR1/$tdir/$tfile-%d 50000 &
7351 # MDT->OST reconnection causes MDT<->OST last_id synchornisation
7352 # via osp_precreate_cleanup_orphans.
7353 for ((i = 0; i < 100; i++)); do
7354 for ((k = 0; k < 10; k++)); do
7355 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;" \
7356 "$LCTL --device $dev activate"
7359 ls -asl $MOUNT | grep '???' &&
7360 { kill -9 $createmany_pid &>/dev/null;
7361 error "File has no object on OST"; }
7363 kill -s 0 $createmany_pid || break
7365 wait $createmany_pid
7367 unlinkmany $DIR1/$tdir/$tfile-%d 50000
7370 run_test 101 "Race MDT->OST reconnection with create"
7373 [[ "$MDS1_VERSION" -gt $(version_code 2.9.53) ]] ||
7374 skip "Need server version greater than 2.9.53"
7375 [[ “$(mdsdevname 1)” != “$(mgsdevname)” ]] &&
7376 [[ “$(facet_host mds1)” = “$(facet_host mgs)” ]] &&
7377 skip "MGS must be on different node or combined"
7379 cleanup || error "cleanup failed with $?"
7381 local mds1dev=$(mdsdevname 1)
7382 local mds1mnt=$(facet_mntpt mds1)
7383 local mds1opts=$MDS_MOUNT_OPTS
7385 if [ "$mds1_FSTYPE" == ldiskfs ] &&
7386 ! do_facet mds1 test -b $mds1dev; then
7387 mds1opts=$(csa_add "$mds1opts" -o loop)
7389 if [[ "$mds1_FSTYPE" == zfs ]]; then
7390 import_zpool mds1 || return ${PIPESTATUS[0]}
7393 # unload all and only load libcfs to allow fail_loc setting
7394 do_facet mds1 $LUSTRE_RMMOD || error "unable to unload modules"
7395 do_facet mds1 modprobe libcfs || error "libcfs not loaded"
7396 do_facet mds1 lsmod \| grep libcfs || error "libcfs not loaded"
7398 #define OBD_FAIL_OBDCLASS_MODULE_LOAD 0x60a
7399 do_facet mds1 "$LCTL set_param fail_loc=0x8000060a"
7401 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
7402 error "mdt start must fail"
7403 do_facet mds1 lsmod \| grep obdclass && error "obdclass must not load"
7405 do_facet mds1 "$LCTL set_param fail_loc=0x0"
7407 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts ||
7408 error "mdt start must not fail"
7410 cleanup || error "cleanup failed with $?"
7412 run_test 102 "obdclass module cleanup upon error"
7417 echo "rename $FSNAME to $newname"
7419 if ! combined_mgs_mds ; then
7420 local dev=$(mgsdevname)
7423 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7424 error "(7) Fail to rename MGS"
7425 if [ "$(facet_fstype mgs)" = "zfs" ]; then
7426 reimport_zpool mgs $newname-mgs
7430 for num in $(seq $MDSCOUNT); do
7431 local dev=$(mdsdevname $num)
7433 do_facet mds${num} \
7434 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7435 error "(8) Fail to rename MDT $num"
7436 if [ "$(facet_fstype mds${num})" = "zfs" ]; then
7437 reimport_zpool mds${num} $newname-mdt${num}
7441 for num in $(seq $OSTCOUNT); do
7442 local dev=$(ostdevname $num)
7444 do_facet ost${num} \
7445 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7446 error "(9) Fail to rename OST $num"
7447 if [ "$(facet_fstype ost${num})" = "zfs" ]; then
7448 reimport_zpool ost${num} $newname-ost${num}
7453 test_103_set_pool() {
7457 do_facet mgs $LCTL pool_add $FSNAME.$pname ${FSNAME}-$ost_x ||
7458 error "Fail to add $ost_x to $FSNAME.$pname"
7459 wait_update $HOSTNAME \
7460 "lctl get_param -n lov.$FSNAME-clilov-*.pools.$pname |
7461 grep $ost_x" "$FSNAME-${ost_x}_UUID" ||
7462 error "$ost_x is NOT in pool $FSNAME.$pname"
7465 test_103_check_pool() {
7466 local save_fsname=$1
7469 stat $DIR/$tdir/test-framework.sh ||
7470 error "($errno) Fail to stat"
7471 do_facet mgs $LCTL pool_list $FSNAME.pool1 ||
7472 error "($errno) Fail to list $FSNAME.pool1"
7473 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname ||
7474 error "($errno) Fail to list $FSNAME.$save_fsname"
7475 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname |
7476 grep ${FSNAME}-OST0000 ||
7477 error "($errno) List $FSNAME.$save_fsname is invalid"
7479 local pname=$($LFS getstripe --pool $DIR/$tdir/d0)
7480 [ "$pname" = "$save_fsname" ] ||
7481 error "($errno) Unexpected pool name $pname"
7485 check_mount_and_prep
7487 mkdir $DIR/$tdir || error "(1) Fail to mkdir $DIR/$tdir"
7488 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir ||
7489 error "(2) Fail to copy test-framework.sh"
7491 do_facet mgs $LCTL pool_new $FSNAME.pool1 ||
7492 error "(3) Fail to create $FSNAME.pool1"
7493 # name the pool name as the fsname
7494 do_facet mgs $LCTL pool_new $FSNAME.$FSNAME ||
7495 error "(4) Fail to create $FSNAME.$FSNAME"
7497 test_103_set_pool $FSNAME OST0000
7499 $SETSTRIPE -p $FSNAME $DIR/$tdir/d0 ||
7500 error "(6) Fail to setstripe on $DIR/$tdir/d0"
7505 test_renamefs mylustre
7507 local save_fsname=$FSNAME
7511 test_103_check_pool $save_fsname 7
7513 if [ $OSTCOUNT -ge 2 ]; then
7514 test_103_set_pool $save_fsname OST0001
7517 $SETSTRIPE -p $save_fsname $DIR/$tdir/f0 ||
7518 error "(16) Fail to setstripe on $DIR/$tdir/f0"
7527 test_103_check_pool $save_fsname 17
7531 test_renamefs $save_fsname
7537 run_test 103 "rename filesystem name"
7539 test_104a() { # LU-6952
7540 local mds_mountopts=$MDS_MOUNT_OPTS
7541 local ost_mountopts=$OST_MOUNT_OPTS
7542 local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
7543 local lctl_ver=$(do_facet $SINGLEMDS $LCTL --version |
7546 [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
7547 skip "this test needs utils above 2.9.55"
7549 # specify "acl" in mount options used by mkfs.lustre
7550 if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
7551 MDS_MOUNT_FS_OPTS="acl,user_xattr"
7554 MDS_MOUNT_FS_OPTS="${MDS_MOUNT_FS_OPTS},acl,user_xattr"
7557 echo "mountfsopt: $MDS_MOUNT_FS_OPTS"
7559 #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
7561 if ! combined_mgs_mds ; then
7565 if [ -z "$MDS_MOUNT_OPTS" ]; then
7566 MDS_MOUNT_OPTS="-o noacl"
7568 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7571 for num in $(seq $MDSCOUNT); do
7572 start mds$num $(mdsdevname $num) $MDS_MOUNT_OPTS ||
7573 error "Failed to start MDS"
7576 for num in $(seq $OSTCOUNT); do
7577 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
7578 error "Failed to start OST"
7582 setfacl -m "d:$RUNAS_ID:rwx" $MOUNT &&
7583 error "ACL is applied when FS is mounted with noacl."
7585 MDS_MOUNT_OPTS=$mds_mountopts
7586 OST_MOUNT_OPTS=$ost_mountopts
7587 MDS_MOUNT_FS_OPTS=$mds_mountfsopts
7589 run_test 104a "Make sure user defined options are reflected in mount"
7591 test_104b() { # LU-12859
7592 mount_client $MOUNT3 flock,localflock
7593 stack_trap "umount_client $MOUNT3" EXIT
7594 mount | grep "$MOUNT3 .*,flock" && error "flock is still set"
7595 mount | grep "$MOUNT3 .*,localflock" || error "localflock is not set"
7596 umount_client $MOUNT3
7597 mount_client $MOUNT3 localflock,flock
7598 mount | grep "$MOUNT3 .*,localflock" && error "localflock is still set"
7599 mount | grep "$MOUNT3 .*,flock" || error "flock is not set"
7600 umount_client $MOUNT3
7601 mount_client $MOUNT3 localflock,flock,noflock
7602 flock_is_enabled $MOUNT3 && error "some flock is still enabled" || true
7604 run_test 104b "Mount uses last flock argument"
7606 error_and_umount() {
7617 mount --bind $DIR $TMP/$tdir || error "mount bind mnt pt failed"
7618 rm -f $TMP/$tdir/$tfile
7619 rm -f $TMP/$tdir/${tfile}1
7621 # Files should not be created in ro bind mount point
7622 # remounting from rw to ro
7623 mount -o remount,ro $TMP/$tdir ||
7624 error_and_umount "readonly remount of bind mnt pt failed"
7625 touch $TMP/$tdir/$tfile &&
7626 error_and_umount "touch succeeds on ro bind mnt pt"
7627 [ -e $TMP/$tdir/$tfile ] &&
7628 error_and_umount "file created on ro bind mnt pt"
7630 # Files should be created in rw bind mount point
7631 # remounting from ro to rw
7632 mount -o remount,rw $TMP/$tdir ||
7633 error_and_umount "read-write remount of bind mnt pt failed"
7634 touch $TMP/$tdir/${tfile}1 ||
7635 error_and_umount "touch fails on rw bind mnt pt"
7636 [ -e $TMP/$tdir/${tfile}1 ] ||
7637 error_and_umount "file not created on rw bind mnt pt"
7638 umount $TMP/$tdir || error "umount of bind mnt pt failed"
7640 cleanup || error "cleanup failed with $?"
7642 run_test 105 "check file creation for ro and rw bind mnt pt"
7649 mkdir -p $DIR/$tdir || error "create $tdir failed"
7650 lfs setstripe -c 1 -i 0 $DIR/$tdir
7651 #define OBD_FAIL_CAT_RECORDS 0x1312
7652 do_facet mds1 $LCTL set_param fail_loc=0x1312 fail_val=$repeat
7654 for ((i = 1; i <= $repeat; i++)); do
7656 #one full plain llog
7657 createmany -o $DIR/$tdir/f- 64768
7659 createmany -u $DIR/$tdir/f- 64768
7661 wait_delete_completed $((TIMEOUT * 7))
7662 #ASSERTION osp_sync_thread() ( thread->t_flags != SVC_RUNNING ) failed
7663 #shows that osp code is buggy
7664 do_facet mds1 $LCTL set_param fail_loc=0 fail_val=0
7668 run_test 106 "check osp llog processing when catalog is wrapped"
7671 [[ "$MDS1_VERSION" -ge $(version_code 2.10.50) ]] ||
7672 skip "Need MDS version > 2.10.50"
7675 start_mgsmds || error "start_mgsmds failed"
7676 start_ost || error "unable to start OST"
7678 # add unknown configuration parameter.
7679 if [[ $PERM_CMD = *"set_param -P"* ]]; then
7680 cmd="$PERM_CMD ost.$FSNAME-OST0000*.unknown_param"
7682 cmd="$PERM_CMD $FSNAME-OST0000*.ost.unknown_param"
7684 do_facet mgs "$cmd=50"
7685 cleanup_nocli || error "cleanup_nocli failed with $?"
7688 # unknown param should be ignored while mounting.
7689 start_ost || error "unable to start OST after unknown param set"
7691 cleanup || error "cleanup failed with $?"
7693 run_test 107 "Unknown config param should not fail target mounting"
7698 $rcmd rm -rf $tmp > /dev/null 2>&1
7699 $rcmd mkdir -p $tmp/{mnt,images} || error "failed to mkdir remotely"
7701 for facet in $facets; do
7702 [ "$mds1_FSTYPE" = zfs ] &&
7703 $rcmd $ZPOOL -f export lustre-$facet > /dev/null 2>&1
7704 $rcmd mkdir $tmp/mnt/$facet ||
7705 error "failed to mkdir $tmp/mnt/$facet"
7706 $rcmd dd if=/dev/zero of=$tmp/images/$facet \
7707 seek=199 bs=1M count=1 ||
7708 error "failed to create $tmp/images/$facet"
7717 local facet=${role}$((idx + 1))
7719 [ $# -eq 5 ] && pool=$5
7721 do_facet $SINGLEMDS $MKFS --fsname=lustre --$mgs \
7722 --$role --index=$idx --replace --backfstype=$bkfs \
7723 --device-size=200000 --reformat $pool $tmp/images/$facet ||
7724 error "failed to mkfs for $facet"
7728 echo "mounting client..."
7729 mount -t lustre ${nid}:/lustre $MOUNT ||
7730 error "failed to mount lustre"
7733 ls -l $MOUNT/local_dir || error "failed to list"
7735 echo "check truncate && write"
7736 echo "dummmmmmmmmmmmm" > $MOUNT/remote_dir/fsx.c ||
7737 error "failed to tuncate & write"
7740 touch $MOUNT/foooo ||
7741 error "failed to create"
7743 echo "check read && write && append"
7744 sha1sum $MOUNT/conf-sanity.sh |
7745 awk '{ print $1 }' > $MOUNT/checksum.new ||
7746 error "failed to read(1)"
7747 sha1sum $MOUNT/remote_dir/unlinkmany.c |
7748 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7749 error "failed to read(2)"
7750 sha1sum $MOUNT/striped_dir/lockahead_test.o |
7751 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7752 error "failed to read(3)"
7755 diff $MOUNT/checksum.new $MOUNT/checksum.src ||
7756 error "failed to verify data"
7766 umount -f $MOUNT || error "failed to umount client"
7767 for facet in $facets; do
7768 $rcmd umount -f $tmp/mnt/$facet ||
7769 error "failed to umount $facet"
7770 if [ "$mds1_FSTYPE" = zfs ]; then
7771 $rcmd $ZPOOL export -f lustre-$facet ||
7772 error "failed to export lustre-$facet"
7776 $rcmd rm -rf $tmp || error "failed to rm the dir $tmp"
7780 [ "$CLIENTONLY" ] && skip "Client-only testing"
7781 [ "$mds1_FSTYPE" != zfs ] && skip "zfs only test"
7782 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
7783 skip "Need server version at least 2.10.58"
7788 local tmp=$TMP/$tdir
7789 local rcmd="do_facet $SINGLEMDS"
7790 local facets="mdt1 mdt2 ost1 ost2"
7791 local nid=$($rcmd $LCTL list_nids | head -1)
7794 trap t_108_cleanup EXIT ERR
7797 t_108_mkfs mdt 0 zfs mgs lustre-mdt1/mdt1
7798 t_108_mkfs mdt 1 zfs mgsnode=$nid lustre-mdt2/mdt2
7799 t_108_mkfs ost 0 zfs mgsnode=$nid lustre-ost1/ost1
7800 t_108_mkfs ost 1 zfs mgsnode=$nid lustre-ost2/ost2
7802 for facet in $facets; do
7803 $rcmd zfs set mountpoint=$tmp/mnt/$facet canmount=on \
7804 lustre-$facet/$facet ||
7805 error "failed to zfs set for $facet (1)"
7806 $rcmd zfs mount lustre-$facet/$facet ||
7807 error "failed to local mount $facet"
7808 $rcmd tar jxf $LUSTRE/tests/ldiskfs_${facet}_2_11.tar.bz2 \
7809 --xattrs --xattrs-include="trusted.*" \
7810 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7811 error "failed to untar image for $facet"
7812 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7813 error "failed to cleanup for $facet"
7814 $rcmd zfs umount lustre-$facet/$facet ||
7815 error "failed to local umount $facet"
7816 $rcmd zfs set canmount=off lustre-$facet/$facet ||
7817 error "failed to zfs set $facet (2)"
7820 echo "changing server nid..."
7821 $rcmd mount -t lustre -o nosvc lustre-mdt1/mdt1 $tmp/mnt/mdt1
7822 $rcmd lctl replace_nids lustre-MDT0000 $nid
7823 $rcmd lctl replace_nids lustre-MDT0001 $nid
7824 $rcmd lctl replace_nids lustre-OST0000 $nid
7825 $rcmd lctl replace_nids lustre-OST0001 $nid
7826 $rcmd umount $tmp/mnt/mdt1
7828 for facet in $facets; do
7829 echo "mounting $facet from backup..."
7830 $rcmd mount -t lustre -o abort_recov lustre-$facet/$facet \
7831 $tmp/mnt/$facet || error "failed to mount $facet"
7834 # ZFS backend can detect migration and trigger OI scrub automatically
7835 # sleep 3 seconds for scrub done
7841 run_test 108a "migrate from ldiskfs to ZFS"
7844 [ "$CLIENTONLY" ] && skip "Client-only testing"
7845 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
7846 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
7847 skip "Need server version at least 2.10.58"
7852 local tmp=$TMP/$tdir
7853 local rcmd="do_facet $SINGLEMDS"
7854 local facets="mdt1 mdt2 ost1 ost2"
7855 local scrub_list="MDT0000 MDT0001 OST0000 OST0001"
7856 local nid=$($rcmd $LCTL list_nids | head -1)
7859 trap t_108_cleanup EXIT ERR
7862 t_108_mkfs mdt 0 ldiskfs mgs
7863 t_108_mkfs mdt 1 ldiskfs mgsnode=$nid
7864 t_108_mkfs ost 0 ldiskfs mgsnode=$nid
7865 t_108_mkfs ost 1 ldiskfs mgsnode=$nid
7867 for facet in $facets; do
7868 $rcmd mount -t ldiskfs -o loop $tmp/images/$facet \
7870 error "failed to local mount $facet"
7872 $rcmd tar jxf $LUSTRE/tests/zfs_${facet}_2_11.tar.bz2 \
7873 --xattrs --xattrs-include="*.*" \
7874 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7875 error "failed to untar image for $facet"
7876 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7877 error "failed to cleanup for $facet"
7878 $rcmd umount $tmp/mnt/$facet ||
7879 error "failed to local umount $facet"
7882 echo "changing server nid..."
7883 $rcmd mount -t lustre -o nosvc,loop $tmp/images/mdt1 $tmp/mnt/mdt1
7884 $rcmd lctl replace_nids lustre-MDT0000 $nid
7885 $rcmd lctl replace_nids lustre-MDT0001 $nid
7886 $rcmd lctl replace_nids lustre-OST0000 $nid
7887 $rcmd lctl replace_nids lustre-OST0001 $nid
7888 $rcmd umount $tmp/mnt/mdt1
7890 for facet in $facets; do
7891 echo "mounting $facet from backup..."
7892 $rcmd mount -t lustre -o loop,abort_recov $tmp/images/$facet \
7893 $tmp/mnt/$facet || error "failed to mount $facet"
7896 for facet in $scrub_list; do
7897 $rcmd $LCTL lfsck_start -M lustre-$facet -t scrub ||
7898 error "failed to start OI scrub on $facet"
7901 # sleep 3 seconds for scrub done
7907 run_test 108b "migrate from ZFS to ldiskfs"
7911 # set number of permanent parameters
7913 test_109_set_params() {
7916 set_persistent_param_and_check mds \
7917 "mdd.$fsname-MDT0000.atime_diff" \
7918 "$fsname-MDT0000.mdd.atime_diff" \
7920 set_persistent_param_and_check mds \
7921 "mdd.$fsname-MDT0000.atime_diff" \
7922 "$fsname-MDT0000.mdd.atime_diff" \
7924 set_persistent_param_and_check client \
7925 "llite.$fsname*.max_read_ahead_mb" \
7926 "$fsname.llite.max_read_ahead_mb" \
7928 set_persistent_param_and_check client \
7929 "llite.$fsname*.max_read_ahead_mb" \
7930 "$fsname.llite.max_read_ahead_mb" \
7932 create_pool $fsname.pool1 || error "create pool failed"
7933 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
7934 error "pool_add failed"
7935 do_facet mgs $LCTL pool_remove $fsname.pool1 OST0000 ||
7936 error "pool_remove failed"
7937 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
7938 error "pool_add failed"
7942 # check permanent parameters
7944 test_109_test_params() {
7947 local atime_diff=$(do_facet mds $LCTL \
7948 get_param -n mdd.$fsname-MDT0000.atime_diff)
7949 [ $atime_diff == 63 ] || error "wrong mdd parameter after clear_conf"
7950 local max_read_ahead_mb=$(do_facet client $LCTL \
7951 get_param -n llite.$fsname*.max_read_ahead_mb)
7952 [ $max_read_ahead_mb == 64 ] ||
7953 error "wrong llite parameter after clear_conf"
7954 local ost_in_pool=$(do_facet mds $LCTL pool_list $fsname.pool1 |
7955 grep -v "^Pool:" | sed 's/_UUID//')
7956 [ $ost_in_pool = "$fsname-OST0000" ] ||
7957 error "wrong pool after clear_conf"
7961 # run lctl clear_conf, store CONFIGS before and after that
7963 test_109_clear_conf()
7965 local clear_conf_arg=$1
7968 if ! combined_mgs_mds ; then
7969 mgsdev=$(mgsdevname)
7970 stop_mgs || error "stop_mgs failed"
7971 start_mgs "-o nosvc" || error "start_mgs nosvc failed"
7973 mgsdev=$(mdsdevname 1)
7974 start_mdt 1 "-o nosvc" || error "start_mdt 1 nosvc failed"
7977 do_facet mgs "rm -rf $TMP/${tdir}/conf1; mkdir -p $TMP/${tdir}/conf1;" \
7978 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf1\\\" \
7982 # the command being tested
7984 do_facet mgs $LCTL clear_conf $clear_conf_arg ||
7985 error "clear_conf failed"
7986 if ! combined_mgs_mds ; then
7987 stop_mgs || error "stop_mgs failed"
7989 stop_mdt 1 || error "stop_mdt 1 failed"
7992 do_facet mgs "rm -rf $TMP/${tdir}/conf2; mkdir -p $TMP/${tdir}/conf2;" \
7993 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf2\\\" \
7997 test_109_file_shortened() {
7999 local sizes=($(do_facet mgs "stat -c %s " \
8000 "$TMP/${tdir}/conf1/CONFIGS/$file" \
8001 "$TMP/${tdir}/conf2/CONFIGS/$file"))
8002 [ ${sizes[1]} -lt ${sizes[0]} ] && return 0
8008 [ "$(facet_fstype mgs)" == zfs ] &&
8009 skip "LU-8727: no implementation for ZFS"
8014 client_up || error "client_up failed"
8017 # set number of permanent parameters
8019 test_109_set_params $FSNAME
8021 umount_client $MOUNT || error "umount_client failed"
8022 stop_ost || error "stop_ost failed"
8023 stop_mds || error "stop_mds failed"
8025 test_109_clear_conf $FSNAME
8027 # make sure that all configs are cleared
8029 test_109_file_shortened $FSNAME-MDT0000 ||
8030 error "failed to clear MDT0000 config"
8031 test_109_file_shortened $FSNAME-client ||
8032 error "failed to clear client config"
8037 # check that configurations are intact
8039 test_109_test_params $FSNAME
8044 destroy_test_pools || error "destroy test pools failed"
8048 run_test 109a "test lctl clear_conf fsname"
8052 [ "$(facet_fstype mgs)" == zfs ] &&
8053 skip "LU-8727: no implementation for ZFS"
8058 client_up || error "client_up failed"
8061 # set number of permanent parameters
8063 test_109_set_params $FSNAME
8065 umount_client $MOUNT || error "umount_client failed"
8066 stop_ost || error "stop_ost failed"
8067 stop_mds || error "stop_mds failed"
8069 test_109_clear_conf $FSNAME-MDT0000
8071 # make sure that only one config is cleared
8073 test_109_file_shortened $FSNAME-MDT0000 ||
8074 error "failed to clear MDT0000 config"
8075 test_109_file_shortened $FSNAME-client &&
8076 error "failed to clear client config"
8080 # check that configurations are intact
8082 test_109_test_params $FSNAME
8087 destroy_test_pools || error "destroy test pools failed"
8091 run_test 109b "test lctl clear_conf one config"
8097 rm -f $TMP/$tdir/lustre-mdt
8102 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8103 skip "Only applicable to ldiskfs-based MDTs"
8106 IMAGESIZE=$((3072 << 30)) # 3072 GiB
8109 # We need MDT size 3072GB, because it is smallest
8110 # partition that can store 2B inodes
8111 do_facet $SINGLEMDS "mkdir -p $TMP/$tdir"
8112 local mdsimgname=$TMP/$tdir/lustre-mdt
8113 do_facet $SINGLEMDS "rm -f $mdsimgname"
8114 do_facet $SINGLEMDS "touch $mdsimgname"
8115 trap cleanup_115 RETURN EXIT
8116 do_facet $SINGLEMDS "$TRUNCATE $mdsimgname $IMAGESIZE" ||
8117 skip "Backend FS doesn't support sparse files"
8118 local mdsdev=$(do_facet $SINGLEMDS "losetup -f")
8119 do_facet $SINGLEMDS "losetup $mdsdev $mdsimgname"
8121 local mds_opts="$(mkfs_opts mds1 ${mdsdev}) --device-size=$IMAGESIZE \
8122 --mkfsoptions='-O lazy_itable_init,ea_inode,^resize_inode,meta_bg \
8124 add mds1 $mds_opts --mgs --reformat $mdsdev ||
8125 skip_env "format large MDT failed"
8126 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
8127 --reformat $(ostdevname 1) $(ostvdevname 1)
8129 start $SINGLEMDS ${mdsdev} $MDS_MOUNT_OPTS || error "start MDS failed"
8130 start_ost || error "start OSS failed"
8131 mount_client $MOUNT || error "mount client failed"
8133 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir fail"
8134 for goal in $(do_facet $SINGLEMDS "ls /sys/fs/ldiskfs/*/inode_goal"); do
8135 do_facet $SINGLEMDS "echo 2147483947 >> $goal; grep . $goal"
8138 touch $DIR/$tdir/$tfile
8140 # Add > 5k bytes to xattr
8141 for i in {1..30}; do
8142 ln $DIR/$tdir/$tfile $DIR/$tdir/$(printf "link%0250d" $i) ||
8143 error "Can't make link"
8148 local inode_num=$(do_facet $SINGLEMDS \
8149 "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsimgname" |
8150 awk '/link =/ { print $4 }' |
8151 sed -e 's/>//' -e 's/<//' -e 's/\"//')
8152 echo "inode num: $inode_num"
8153 [ $inode_num -ge 2147483947 ] || error "inode $inode_num too small"
8154 do_facet $SINGLEMDS "losetup -d $mdsdev"
8157 run_test 115 "Access large xattr with inodes number over 2TB"
8160 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
8161 [ "$MDS1_VERSION" -lt $(version_code 2.10.59) ] &&
8162 skip "Need server version at least 2.10.59"
8163 do_facet $SINGLEMDS which mkfs.xfs ||
8164 skip_env "No mkfs.xfs installed"
8169 local tmpmnt=$TMP/$tdir
8170 local mdtimg=$tfile-mdt0
8172 do_facet $SINGLEMDS mkdir -p $tmpmnt
8173 stack_trap "do_facet $SINGLEMDS rmdir $tmpmnt" EXIT
8175 do_facet $SINGLEMDS touch $TMP/$mdtimg
8176 stack_trap "do_facet $SINGLEMDS rm -f $TMP/$mdtimg" EXIT
8177 do_facet $SINGLEMDS mkfs -t xfs -d file,size=1t,name=$TMP/$mdtimg ||
8178 error "mkfs temporary xfs image"
8180 do_facet $SINGLEMDS mount $TMP/$mdtimg $tmpmnt ||
8181 error "mount temporary xfs image"
8182 stack_trap "do_facet $SINGLEMDS umount $tmpmnt" EXIT
8183 local old_mdssize=$MDSSIZE
8184 local old_mdsisize=$MDSISIZE
8186 MDSSIZE=$((17 * 1024 * 1024 * 1024)) # 17T MDT
8187 MDSISIZE=$((16 << 20))
8188 local opts17t="$(mkfs_opts $SINGLEMDS)"
8190 MDSSIZE=$old_mdssize
8191 MDSISIZE=$old_mdsisize
8192 do_facet $SINGLEMDS $MKFS $opts17t $tmpmnt/$mdtimg ||
8193 error "failed to mkfs for $tmpmnt/$mdtimg"
8195 do_facet $SINGLEMDS $TUNE2FS -l $tmpmnt/$mdtimg |
8196 grep -qw 'features.*extent' || error "extent should be enabled"
8199 run_test 116 "big size MDT support"
8202 [[ "$OST1_VERSION" -lt $(version_code 2.12.0) ]] &&
8203 skip "Need OST version at least 2.12.0"
8206 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.nrs_policies=fifo"
8207 do_facet ost1 "$LCTL get_param -n ost.OSS.ost_io.nrs_tbf_rule" &&
8208 error "get_param should fail"
8209 cleanup || error "cleanup failed with rc $?"
8211 run_test 117 "lctl get_param return errors properly"
8213 test_120() { # LU-11130
8214 [ "$MDSCOUNT" -lt 2 ] && skip "mdt count < 2"
8215 [ "$mds1_FSTYPE" != ldiskfs ] &&
8216 skip "ldiskfs only test"
8217 [ "$MDS1_VERSION" -lt $(version_code 2.11.56) ] &&
8218 skip "Need DNE2 capable MD target with LU-11130 fix"
8222 local mds1host=$(facet_active_host mds1)
8223 local mds1dev=$(mdsdevname 1)
8225 $LFS mkdir -i 1 $DIR/$tdir
8226 $LFS mkdir -i 0 $DIR/$tdir/mds1dir
8228 ln -s foo $DIR/$tdir/bar
8229 mv $DIR/$tdir/bar $DIR/$tdir/mds1dir/bar2 ||
8230 error "cross-target rename failed"
8234 run_e2fsck $mds1host $mds1dev "-n"
8236 run_test 120 "cross-target rename should not create bad symlinks"
8239 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
8240 [[ "$OST1_VERSION" -ge $(version_code 2.11.53) ]] ||
8241 skip "Need OST version at least 2.11.53"
8244 LOAD_MODULES_REMOTE=true load_modules
8245 #define OBD_FAIL_OFD_SET_OID 0x1e0
8246 do_facet ost1 $LCTL set_param fail_loc=0x00001e0
8249 $LFS mkdir -i1 -c1 $DIR/$tdir
8250 $LFS setstripe -i0 -c1 $DIR/$tdir
8251 do_facet ost1 $LCTL set_param fail_loc=0
8252 createmany -o $DIR/$tdir/file_ 1000 ||
8253 error "Fail to create a new sequence"
8257 run_test 122 "Check OST sequence update"
8260 remote_mgs_nodsh && skip "remote MGS with nodsh"
8261 [ -d $MOUNT/.lustre ] || setup
8263 # test old logid format until removal from llog_ioctl.c::str2logid()
8264 if [ $MGS_VERSION -lt $(version_code 3.1.53) ]; then
8265 do_facet mgs $LCTL dl | grep MGS
8266 do_facet mgs "$LCTL --device %MGS llog_print \
8267 \\\\\\\$$FSNAME-client 1 10" ||
8268 error "old llog_print failed"
8271 # test new logid format
8272 if [ $MGS_VERSION -ge $(version_code 2.9.53) ]; then
8273 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
8274 error "new llog_print failed"
8277 run_test 123aa "llog_print works with FIDs and simple names"
8280 remote_mgs_nodsh && skip "remote MGS with nodsh"
8281 [[ $MGS_VERSION -gt $(version_code 2.11.51) ]] ||
8282 skip "Need server with working llog_print support"
8284 [ -d $MOUNT/.lustre ] || setup
8289 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
8290 do_facet mgs $LCTL set_param -P jobid_name="TESTNAME"
8292 yaml=$(do_facet mgs $LCTL --device MGS llog_print params |
8293 grep jobid_name | tail -n 1)
8295 local param=$(awk '{ print $10 }' <<< "$yaml")
8296 local val=$(awk '{ print $12 }' <<< "$yaml")
8297 #return to the default
8298 do_facet mgs $LCTL set_param -P jobid_name=$orig_val
8299 [ $val = "TESTNAME" ] || error "bad value: $val"
8300 [ $param = "jobid_name," ] || error "Bad param: $param"
8302 run_test 123ab "llog_print params output values from set_param -P"
8304 test_123ac() { # LU-11566
8305 remote_mgs_nodsh && skip "remote MGS with nodsh"
8306 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8307 skip "Need 'lctl llog_print --start' on MGS"
8312 [ -d $MOUNT/.lustre ] || setup
8314 # - { index: 10, event: add_uuid, nid: 192.168.20.1@tcp(0x20000c0a81401,
8315 # node: 192.168.20.1@tcp }
8316 do_facet mgs $LCTL --device MGS \
8317 llog_print --start $start --end $end $FSNAME-client | tr -d , |
8318 while read DASH BRACE INDEX idx EVENT BLAH BLAH BLAH; do
8319 (( idx >= start )) || error "llog_print index $idx < $start"
8320 (( idx <= end )) || error "llog_print index $idx > $end"
8323 run_test 123ac "llog_print with --start and --end"
8325 test_123ad() { # LU-11566
8326 remote_mgs_nodsh && skip "remote MGS with nodsh"
8327 # older versions of lctl may not print all records properly
8328 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8329 skip "Need 'lctl llog_print --start' on MGS"
8331 [ -d $MOUNT/.lustre ] || setup
8333 # append a new record, to avoid issues if last record was cancelled
8334 local old=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
8335 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$old
8337 # logid: [0x3:0xa:0x0]:0
8341 local num=$(do_facet mgs $LCTL --device MGS llog_info $FSNAME-client |
8342 awk '/last_index:/ { print $2 - 1 }')
8344 # - { index: 71, event: set_timeout, num: 0x14, param: sys.timeout=20 }
8345 local last=$(do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
8346 tail -1 | awk '{ print $4 }' | tr -d , )
8347 (( last == num )) || error "llog_print only showed $last/$num records"
8349 run_test 123ad "llog_print shows all records"
8352 remote_mgs_nodsh && skip "remote MGS with nodsh"
8354 [ -d $MOUNT/.lustre ] || setup
8355 local yaml_file="$TMP/$tfile.yaml"
8356 do_facet mgs rm "$yaml_file"
8357 local cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist" |
8358 sed 's/config_log://')
8360 # set jobid_var to a different value for test
8361 local orig_val=$(do_facet mgs $LCTL get_param jobid_var)
8362 do_facet mgs $LCTL set_param -P jobid_var="TESTNAME"
8364 for i in $cfgfiles params; do
8365 do_facet mgs "lctl --device MGS llog_print ${i} >> $yaml_file"
8368 echo "Unmounting FS"
8378 # Reapply the config from before
8379 echo "Setting configuration parameters"
8380 do_facet mgs "lctl set_param -F $yaml_file"
8382 local set_val=$(do_facet mgs $LCTL get_param jobid_var)
8383 do_facet mgs $LCTL set_param -P $orig_val
8385 [ $set_val == "jobid_var=TESTNAME" ] ||
8386 error "$set_val is not TESTNAME"
8388 do_facet mgs rm "$yaml_file"
8391 run_test 123F "clear and reset all parameters using set_param -F"
8395 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
8396 [ -z $mds2failover_HOST ] && skip "needs MDT failover setup"
8402 if combined_mgs_mds; then
8403 start_mdt 1 "-o nosvc" ||
8404 error "starting mds with nosvc option failed"
8406 local nid=$(do_facet mds2 $LCTL list_nids | head -1)
8407 local failover_nid=$(do_node $mds2failover_HOST $LCTL list_nids | head -1)
8408 do_facet mgs $LCTL replace_nids $FSNAME-MDT0001 $nid:$failover_nid ||
8409 error "replace_nids execution error"
8411 if combined_mgs_mds; then
8417 echo "lfs setdirstripe"
8418 $LFS setdirstripe -i 1 $MOUNT/$tdir || error "setdirstirpe error"
8421 run_test 124 "check failover after replace_nids"
8423 get_max_sectors_kb() {
8426 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8427 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
8429 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
8430 cat ${max_sectors_path}"
8433 get_max_hw_sectors_kb() {
8436 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8437 local max_hw_path="/sys/block/${dev_base}/queue/max_hw_sectors_kb"
8439 do_facet ${facet} "[[ -e ${max_hw_path} ]] && cat ${max_hw_path}"
8442 set_max_sectors_kb() {
8446 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8447 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
8449 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
8450 echo ${value} > ${max_sectors_path}"
8453 [[ $rc -ne 0 ]] && echo "Failed to set ${max_sectors_path} to ${value}"
8458 # Return 0 if all slave devices have max_sectors_kb == max_hw_sectors_kb
8459 # Otherwise return > 0
8460 check_slaves_max_sectors_kb()
8464 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8465 local slaves_dir=/sys/block/${dev_base}/slaves
8466 local slave_devices=$(do_facet ${facet} "ls ${slaves_dir} 2>/dev/null")
8467 [[ -z ${slave_devices} ]] && return 0
8469 local slave max_sectors new_max_sectors max_hw_sectors path
8471 for slave in ${slave_devices}; do
8472 path="/dev/${slave}"
8473 ! is_blkdev ${facet} ${path} && continue
8474 max_sectors=$(get_max_sectors_kb ${facet} ${path})
8475 max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${path})
8476 new_max_sectors=${max_hw_sectors}
8477 [[ ${new_max_sectors} -gt ${RQ_SIZE_LIMIT} ]] &&
8478 new_max_sectors=${RQ_SIZE_LIMIT}
8480 if [[ ${max_sectors} -ne ${new_max_sectors} ]]; then
8481 echo "${path} ${max_sectors} ${new_max_sectors}"
8484 check_slaves_max_sectors_kb ${facet} ${path}
8493 [[ "$MDS1_VERSION" -lt $(version_code 2.12.3) ]] &&
8494 skip "Need MDS version at least 2.12.3"
8496 local facet_list="mgs mds1 ost1"
8497 combined_mgs_mds && facet_list="mgs ost1"
8500 for facet in ${facet_list}; do
8501 [[ $(facet_fstype ${facet}) != ldiskfs ]] &&
8502 skip "ldiskfs only test" &&
8504 ! is_blkdev ${facet} $(facet_device ${facet}) &&
8505 skip "requires all real devices" &&
8510 # We don't increase IO request size limit past 16MB. See comments in
8511 # lustre/utils/libmount_utils_ldiskfs.c:tune_max_sectors_kb()
8512 RQ_SIZE_LIMIT=$((16 * 1024))
8513 local device old_max_sectors new_max_sectors max_hw_sectors
8514 for facet in ${facet_list}; do
8515 device=$(facet_device ${facet})
8516 old_max_sectors=$(get_max_sectors_kb ${facet} ${device})
8517 max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${device})
8519 # The expected value after l_tunedisk is executed
8520 new_max_sectors=$old_max_sectors
8521 [[ ${new_max_sectors_kb} -gt ${RQ_SIZE_LIMIT} ]] &&
8522 new_max_sectors_kb=${RQ_SIZE_LIMIT}
8524 # Ensure the current value of max_sectors_kb does not equal
8525 # max_hw_sectors_kb, so we can tell whether l_tunedisk did
8527 set_max_sectors_kb ${facet} ${device} $((new_max_sectors - 1))
8529 # Value before l_tunedisk
8530 local pre_max_sectors=$(get_max_sectors_kb ${facet} ${device})
8531 if [[ ${pre_max_sectors} -ne $((new_max_sectors - 1)) ]]; then
8532 echo "unable to satsify test pre-condition:"
8533 echo "${pre_max_sectors} != $((new_max_sectors - 1))"
8538 echo "Before: ${facet} ${device} ${pre_max_sectors} ${max_hw_sectors}"
8540 do_facet ${facet} "libtool execute l_tunedisk ${device}"
8542 # Value after l_tunedisk
8543 local post_max_sectors=$(get_max_sectors_kb ${facet} ${device})
8545 echo "After: ${facet} ${device} ${post_max_sectors} ${max_hw_sectors}"
8547 if [[ ${facet} != ost1 ]]; then
8548 if [[ ${post_max_sectors} -ne ${pre_max_sectors} ]]; then
8549 echo "l_tunedisk modified max_sectors_kb of ${facet}"
8553 set_max_sectors_kb ${facet} ${device} ${old_max_sectors}
8555 if [[ ${post_max_sectors} -eq ${pre_max_sectors} ]]; then
8556 echo "l_tunedisk failed to modify max_sectors_kb of ${facet}"
8560 check_slaves_max_sectors_kb ${facet} ${device} ||
8567 run_test 125 "check l_tunedisk only tunes OSTs and their slave devices"
8569 if ! combined_mgs_mds ; then
8575 # restore the values of MDSSIZE and OSTSIZE
8576 MDSSIZE=$STORED_MDSSIZE
8577 OSTSIZE=$STORED_OSTSIZE
8581 check_and_cleanup_lustre