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 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && MDSSIZE=400000
43 [ $(facet_fstype ost1) = "zfs" ] && OSTSIZE=400000
53 if ! combined_mgs_mds; then
54 # bug number for skipped test: LU-9860 LU-9860 LU-9860
55 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 43b 53b 54b"
56 # bug number for skipped test: LU-9875 LU-9879 LU-9879 LU-9879 LU-9879
57 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 70e 80 84 87 100"
58 # bug number for skipped test: LU-8110 LU-9879 LU-9879 LU-9879
59 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 102 104 105 107"
62 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
63 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
64 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
67 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
68 # bug number for skipped test:
69 ALWAYS_EXCEPT="$ALWAYS_EXCEPT"
70 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
72 [ $MDSCOUNT -ge 2 ] &&
73 # bug number for skipped test: LU-11915
75 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
80 require_dsh_mds || exit 0
81 require_dsh_ost || exit 0
84 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69 106 111"
89 # The MGS must be started before the OSTs for a new fs, so start
90 # and stop to generate the startup logs.
93 wait_osc_import_state mds ost FULL
98 reformat_and_config() {
100 if ! combined_mgs_mds ; then
106 writeconf_or_reformat() {
107 # There are at most 2 OSTs for write_conf test
108 # who knows if/where $TUNEFS is installed?
109 # Better reformat if it fails...
110 writeconf_all $MDSCOUNT 2 ||
111 { echo "tunefs failed, reformatting instead" &&
112 reformat_and_config && return 0; }
121 echo "start mgs service on $(facet_active_host mgs)"
122 start mgs $(mgsdevname) $MGS_MOUNT_OPTS $@
128 local dev=$(mdsdevname $num)
131 echo "start mds service on `facet_active_host $facet`"
132 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
138 local dev=$(mdsdevname $num)
141 echo "stop mds service on `facet_active_host $facet`"
142 # These tests all use non-failover stop
143 stop $facet -f || return 97
149 for num in $(seq $MDSCOUNT); do
150 start_mdt $num $@ || return 94
155 if ! combined_mgs_mds ; then
163 for num in $(seq $MDSCOUNT); do
164 stop_mdt $num || return 97
169 echo "stop mgs service on `facet_active_host mgs`"
170 # These tests all use non-failover stop
171 stop mgs -f || return 97
175 echo "start ost1 service on `facet_active_host ost1`"
176 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
180 echo "stop ost1 service on `facet_active_host ost1`"
181 # These tests all use non-failover stop
182 stop ost1 -f || return 98
186 echo "start ost2 service on `facet_active_host ost2`"
187 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
191 echo "stop ost2 service on `facet_active_host ost2`"
192 # These tests all use non-failover stop
193 stop ost2 -f || return 93
198 echo "mount $FSNAME on ${MOUNTPATH}....."
199 zconf_mount $(hostname) $MOUNTPATH || return 96
203 local mountopt="remount,$1"
205 echo "remount '$1' lustre on ${MOUNTPATH}....."
206 zconf_mount $(hostname) $MOUNTPATH "$mountopt" || return 96
212 echo "umount lustre on $mountpath....."
213 zconf_umount $HOSTNAME $mountpath $@ || return 97
216 manual_umount_client(){
219 echo "manual umount lustre on ${MOUNT}...."
220 do_facet client "umount ${FORCE} $MOUNT"
226 start_mds || error "MDT start failed"
227 start_ost || error "Unable to start OST1"
228 mount_client $MOUNT || error "client start failed"
229 client_up || error "client_up failed"
238 unload_modules_conf () {
239 if combined_mgs_mds || ! local_mode; then
240 unload_modules || return 1
245 stop_ost || return 202
246 stop_mds || return 201
247 unload_modules_conf || return 203
252 [ "x$1" != "x" ] && force='-f'
253 umount_client $MOUNT $force|| return 200
254 cleanup_nocli || return $?
259 echo "umount $MOUNT2 ..."
260 umount $MOUNT2 || true
261 echo "stopping fs2mds ..."
262 stop fs2mds -f || true
263 echo "stopping fs2ost ..."
264 stop fs2ost -f || true
268 do_facet client "cp /etc/passwd $DIR/a" || return 71
269 do_facet client "rm $DIR/a" || return 72
270 # make sure lustre is actually mounted (touch will block,
271 # but grep won't, so do it after)
272 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
273 echo "setup single mount lustre success"
277 do_facet client "touch $DIR/a" || return 71
278 do_facet client "rm $DIR/a" || return 72
279 do_facet client "touch $DIR2/a" || return 73
280 do_facet client "rm $DIR2/a" || return 74
281 echo "setup double mount lustre success"
285 cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
290 if [ "$ONLY" == "setup" ]; then
295 if [ "$ONLY" == "cleanup" ]; then
302 #create single point mountpoint
308 check_mount || error "check_mount failed"
309 cleanup || error "cleanup failed with $?"
311 run_test 0 "single mount setup"
314 start_mds || error "MDS start failed"
315 start_ost || error "unable to start OST"
316 echo "start ost second time..."
317 start_ost && error "2nd OST start should fail"
318 mount_client $MOUNT || error "client start failed"
319 check_mount || error "check_mount failed"
320 cleanup || error "cleanup failed with $?"
322 run_test 1 "start up ost twice (should return errors)"
325 start_mds || error "MDT start failed"
326 echo "start mds second time.."
327 start_mds && error "2nd MDT start should fail"
328 start_ost || error "OST start failed"
329 mount_client $MOUNT || error "mount_client failed to start client"
330 check_mount || error "check_mount failed"
331 cleanup || error "cleanup failed with $?"
333 run_test 2 "start up mds twice (should return err)"
337 #mount.lustre returns an error if already in mtab
338 mount_client $MOUNT && error "2nd client mount should fail"
339 check_mount || error "check_mount failed"
340 cleanup || error "cleanup failed with $?"
342 run_test 3 "mount client twice (should return err)"
346 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
347 stop_ost || error "Unable to stop OST1"
348 umount_client $MOUNT -f || error “unmount $MOUNT failed”
351 # ok for ost to fail shutdown
352 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
353 error "cleanup failed with $?"
356 run_test 4 "force cleanup ost, then cleanup"
358 test_5a() { # was test_5
360 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
361 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
363 stop_mds || error "Unable to stop MDS"
365 # cleanup may return an error from the failed
366 # disconnects; for now I'll consider this successful
367 # if all the modules have unloaded.
371 echo "killing umount"
372 kill -TERM $UMOUNT_PID
373 echo "waiting for umount to finish"
375 if grep " $MOUNT " /proc/mounts; then
376 echo "test 5: /proc/mounts after failed umount"
380 echo "killing umount"
381 kill -TERM $UMOUNT_PID
382 echo "waiting for umount to finish"
384 grep " $MOUNT " /proc/mounts &&
385 error "/proc/mounts after second umount"
388 # manual_mount_client may fail due to umount succeeding above
390 # stop_mds is a no-op here, and should not fail
391 cleanup_nocli || error "cleanup_nocli failed with $?"
392 # df may have lingering entry
394 # mtab may have lingering entry
398 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
400 grep -q $MOUNT" " /etc/mtab || break
401 echo "Waiting /etc/mtab updated ... "
402 WAIT=$(( WAIT + sleep))
404 [ "$WAIT" -eq "$MAX_WAIT" ] &&
405 error "/etc/mtab is not updated in $WAIT secs"
406 echo "/etc/mtab updated in $WAIT secs"
408 run_test 5a "force cleanup mds, then cleanup"
416 grep " $MOUNT " /etc/mtab &&
417 error false "unexpected entry in mtab before mount" && return 10
419 start_ost || error "OST start failed"
420 if ! combined_mgs_mds ; then
421 trap cleanup_5b EXIT ERR
422 start_mds || error "MDS start failed"
426 mount_client $MOUNT && error "mount_client $MOUNT should fail"
427 grep " $MOUNT " /etc/mtab &&
428 error "$MOUNT entry in mtab after failed mount"
430 # stop_mds is a no-op here, and should not fail
431 cleanup_nocli || error "cleanup_nocli failed with $?"
432 if ! combined_mgs_mds ; then
436 run_test 5b "Try to start a client with no MGS (should return errs)"
439 grep " $MOUNT " /etc/mtab &&
440 error false "unexpected entry in mtab before mount" && return 10
442 start_mds || error "MDS start failed"
443 start_ost || error "OST start failed"
444 local oldfs="${FSNAME}"
445 FSNAME="wrong.${FSNAME}"
446 mount_client $MOUNT || :
448 grep " $MOUNT " /etc/mtab &&
449 error "$MOUNT entry in mtab after failed mount"
451 cleanup_nocli || error "cleanup_nocli failed with $?"
453 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
456 grep " $MOUNT " /etc/mtab &&
457 error "unexpected entry in mtab before mount"
459 start_ost || error "OST start failed"
460 start_mds || error "MDS start failed"
461 stop_ost -f || error "Unable to stop OST1"
462 mount_client $MOUNT || error "mount_client $MOUNT failed"
463 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
464 cleanup_nocli || error "cleanup_nocli failed with $?"
465 ! grep " $MOUNT " /etc/mtab ||
466 error "$MOUNT entry in mtab after unmount"
468 run_test 5d "mount with ost down"
471 grep " $MOUNT " /etc/mtab &&
472 error false "unexpected entry in mtab before mount" && return 10
474 start_mds || error "MDS start failed"
475 start_ost || error "OST start failed"
477 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
478 do_facet client "$LCTL set_param fail_loc=0x80000506"
479 mount_client $MOUNT || echo "mount failed (not fatal)"
480 cleanup || error "cleanup failed with $?"
481 grep " $MOUNT " /etc/mtab &&
482 error "$MOUNT entry in mtab after unmount"
485 run_test 5e "delayed connect, don't crash (bug 10268)"
488 combined_mgs_mds && skip "needs separate mgs and mds"
490 grep " $MOUNT " /etc/mtab &&
491 error false "unexpected entry in mtab before mount" && return 10
494 start_ost || error "OST start failed"
495 mount_client $MOUNT &
497 echo client_mount pid is $pid
501 if ! ps -f -p $pid >/dev/null; then
504 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
505 error "mount returns $rc, expected to hang"
507 cleanup || error "cleanup failed with $?"
512 start_mds || error "start MDS failed"
514 # mount should succeed after start mds
516 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
517 cleanup || error "final call to cleanup failed with rc $?"
519 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
523 [ $(lustre_version_code client) -lt $(version_code 2.9.53) ] &&
524 skip "automount of debugfs missing before 2.9.53"
525 umount /sys/kernel/debug
526 $LCTL get_param -n devices | egrep -v "error" && \
527 error "lctl can't access debugfs data"
528 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
530 run_test 5g "handle missing debugfs"
535 mount_client $MOUNT || error "mount_client $MOUNT failed"
536 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
537 cleanup || error "cleanup failed with rc $?"
539 run_test 6 "manual umount, then mount again"
544 cleanup_nocli || error "cleanup_nocli failed with $?"
546 run_test 7 "manual umount, then cleanup"
550 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
551 check_mount2 || error "check_mount2 failed"
552 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
553 cleanup || error "cleanup failed with rc $?"
555 run_test 8 "double mount setup"
558 start_ost || error "OST start failed"
560 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
561 error "do_facet ost1 set_param inode trace failed."
562 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
563 error "do_facet ost1 set_param debug mds ost failed."
565 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
566 if [ "$CHECK_PTLDEBUG" ] && { \
567 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
568 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
569 echo "lnet.debug success"
571 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
573 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
574 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
575 echo "lnet.subsystem_debug success"
577 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
579 stop_ost || error "Unable to stop OST1"
581 run_test 9 "test ptldebug and subsystem for mkfs"
584 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
585 # But with new MDS stack we don't care about the mode of local objects
586 # anymore, so this test is removed. See bug 22944 for more details.
590 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
591 skip "ldiskfs only test"
595 check_mount || error "check_mount failed"
596 cleanup || error "cleanup failed with rc $?"
598 echo "Remove mds config log"
599 if ! combined_mgs_mds ; then
603 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
604 $(mgsdevname) || return \$?" ||
605 error "do_facet mgs failed with $?"
607 if ! combined_mgs_mds ; then
611 start_ost || error "OST start failed"
612 start_mds && error "MDS start succeeded, but should fail"
615 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
618 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
619 skip "ldiskfs only test"
622 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
627 # check if current MDSSIZE is large enough
628 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
629 log "use MDSSIZE=$MDSSIZE"
631 # check if the global config has a large enough MDSSIZE
632 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
633 [ $STORED_MDSSIZE -ge $MIN ] &&
634 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
635 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
637 # check if the block device is large enough
638 is_blkdev $SINGLEMDS $MDSDEV $MIN
639 local large_enough=$?
640 if [ -n "$OK" ]; then
641 [ $large_enough -ne 0 ] && OK=""
643 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
644 log "use device $MDSDEV with MIN=$MIN"
647 # check if a loopback device has enough space for fs metadata (5%)
649 if [ -z "$OK" ]; then
650 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
651 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
652 awk '($1 != "Filesystem") { print $4 }')
653 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
654 OK=1 && myMDSSIZE=$MIN &&
655 log "use file $MDSDEV with MIN=$MIN"
658 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS"
660 echo "mount mds with large journal..."
662 local OLD_MDSSIZE=$MDSSIZE
666 echo "mount lustre system..."
668 check_mount || error "check_mount failed"
670 echo "check journal size..."
671 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
672 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
673 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
675 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
678 cleanup || error "cleanup failed with rc $?"
683 run_test 18 "check mkfs creates large journals"
686 start_mds || error "MDS start failed"
687 stop_mds || error "Unable to stop MDS"
689 run_test 19a "start/stop MDS without OSTs"
692 start_ost || error "Unable to start OST1"
693 stop_ost -f || error "Unable to stop OST1"
695 run_test 19b "start/stop OSTs without MDS"
698 # first format the ost/mdt
699 start_mds || error "MDS start failed"
700 start_ost || error "Unable to start OST1"
701 mount_client $MOUNT || error "mount_client $MOUNT failed"
702 check_mount || error "check_mount failed"
703 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
704 remount_client ro $MOUNT || error "remount_client with ro failed"
705 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
706 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
707 remount_client rw $MOUNT || error "remount_client with rw failed"
708 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
709 MCNT=$(grep -c $MOUNT' ' /etc/mtab)
710 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
712 stop_mds || error "Unable to stop MDS"
713 stop_ost || error "Unable to stop OST1"
715 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
718 start_mds || error "MDS start failed"
719 start_ost || error "unable to start OST1"
720 wait_osc_import_state mds ost FULL
721 stop_ost || error "unable to stop OST1"
722 stop_mds || error "unable to stop MDS"
724 run_test 21a "start mds before ost, stop ost first"
727 start_ost || error "unable to start OST1"
728 start_mds || error "MDS start failed"
729 wait_osc_import_state mds ost FULL
730 stop_mds || error "unable to stop MDS"
731 stop_ost || error "unable to stop OST1"
733 run_test 21b "start ost before mds, stop mds first"
736 start_ost || error "Unable to start OST1"
737 start_mds || error "MDS start failed"
738 start_ost2 || error "Unable to start OST2"
739 wait_osc_import_state mds ost2 FULL
740 stop_ost || error "Unable to stop OST1"
741 stop_ost2 || error "Unable to stop OST2"
742 stop_mds || error "Unable to stop MDS"
743 #writeconf to remove all ost2 traces for subsequent tests
744 writeconf_or_reformat
746 run_test 21c "start mds between two osts, stop mds last"
749 combined_mgs_mds && skip "need separate mgs device"
754 start_mgs || error "unable to start MGS"
755 start_ost || error "unable to start OST1"
756 start_ost2 || error "unable to start OST2"
757 start_mds || error "MDS start failed"
758 wait_osc_import_state mds ost2 FULL
760 stop_ost || error "Unable to stop OST1"
761 stop_ost2 || error "Unable to stop OST2"
762 stop_mds || error "Unable to stop MDS"
764 #writeconf to remove all ost2 traces for subsequent tests
765 writeconf_or_reformat
766 start_mgs || error "unable to start MGS"
768 run_test 21d "start mgs then ost and then mds"
771 MGSNID="$saved_mgsnid"
773 echo "stopping fs2mgs ..."
774 stop $fs2mgs -f || true
777 test_21e() { # LU-5863
778 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
779 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
780 skip_env "mixed loopback and real device not working"
783 local fs2mdsdev=$(mdsdevname 1_2)
784 local fs2ostdev=$(ostdevname 1_2)
785 local fs3ostdev=$(ostdevname 2_2)
787 local fs2mdsvdev=$(mdsvdevname 1_2)
788 local fs2ostvdev=$(ostvdevname 1_2)
789 local fs3ostvdev=$(ostvdevname 2_2)
791 # temporarily use fs3ost as fs2mgs
793 local fs2mgsdev=$fs3ostdev
794 local fs2mgsvdev=$fs3ostvdev
796 local fsname=test1234
798 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
799 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
800 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
801 error "start fs2mgs failed"
803 local saved_mgsnid="$MGSNID"
804 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
806 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
807 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
808 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
809 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
811 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
812 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
814 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
815 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
816 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
820 run_test 21e "separate MGS and MDS"
823 start_mds || error "MDS start failed"
825 echo "Client mount with ost in logs, but none running"
826 start_ost || error "unable to start OST1"
827 # wait until mds connected to ost and open client connection
828 wait_osc_import_state mds ost FULL
829 stop_ost || error "unable to stop OST1"
830 mount_client $MOUNT || error "mount_client $MOUNT failed"
831 # check_mount will block trying to contact ost
832 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
833 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
834 umount_client $MOUNT -f
837 echo "Client mount with a running ost"
838 start_ost || error "unable to start OST1"
840 # if gss enabled, wait full time to let connection from
841 # mds to ost be established, due to the mismatch between
842 # initial connect timeout and gss context negotiation timeout.
843 # This perhaps could be remove after AT landed.
844 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
845 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
847 mount_client $MOUNT || error "mount_client $MOUNT failed"
848 wait_osc_import_state mds ost FULL
849 wait_osc_import_ready client ost
850 check_mount || error "check_mount failed"
853 cleanup || error "cleanup failed with rc $?"
855 run_test 22 "start a client before osts (should return errs)"
857 test_23a() { # was test_23
860 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
861 # force down client so that recovering mds waits for reconnect
862 local running=$(grep -c $MOUNT /proc/mounts) || true
863 if [ $running -ne 0 ]; then
864 echo "Stopping client $MOUNT (opts: -f)"
868 # enter recovery on failed mds
869 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
870 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
871 # try to start a new client
872 mount_client $MOUNT &
874 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
875 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
876 grep -v grep | awk '{print $2}')
877 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
879 ps --ppid $MOUNT_LUSTRE_PID
880 echo "waiting for mount to finish"
882 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
883 # SIGTERM works but it does not spread to offspring processses
884 kill -s TERM $MOUNT_PID
885 kill -s TERM $MOUNT_LUSTRE_PID
886 # we can not wait $MOUNT_PID because it is not a child of this shell
892 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
894 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
895 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
898 [ -z "$PID1" -a -z "$PID2" ] && break
899 echo "waiting for mount to finish ... "
900 WAIT=$(( WAIT + sleep))
902 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
903 error "MOUNT_PID $MOUNT_PID and "\
904 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
907 cleanup || error "cleanup failed with rc $?"
909 run_test 23a "interrupt client during recovery mount delay"
911 test_23b() { # was test_23
912 start_mds || error "MDS start failed"
913 start_ost || error "Unable to start OST1"
914 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
915 $LCTL set_param fail_loc=0x80000313
917 cleanup || error "cleanup failed with rc $?"
919 run_test 23b "Simulate -EINTR during mount"
922 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
924 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
925 is_blkdev $SINGLEMDS $MDSDEV &&
926 skip_env "mixed loopback and real device not working"
929 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
931 local fs2mdsdev=$(mdsdevname 1_2)
932 local fs2ostdev=$(ostdevname 1_2)
933 local fs2mdsvdev=$(mdsvdevname 1_2)
934 local fs2ostvdev=$(ostvdevname 1_2)
937 # LU-9733 test fsname started with numbers as well
938 local FSNAME2=969362ae
940 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
941 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
943 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
944 --reformat $fs2ostdev $fs2ostvdev || exit 10
947 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
948 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
949 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
950 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
952 # LU-9733 test fsname started with numbers
953 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
954 changelog_register -n) ||
955 error "register changelog failed"
957 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
958 changelog_deregister $cl_user ||
959 error "deregister changelog failed"
961 check_mount || error "check_mount failed"
962 # files written on 1 should not show up on 2
963 cp /etc/passwd $DIR/$tfile
965 [ -e $MOUNT2/$tfile ] && error "File bleed"
968 cp /etc/passwd $MOUNT2/$tfile ||
969 error "cp /etc/passwd $MOUNT2/$tfile failed"
970 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
971 # 2 is actually mounted
972 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
974 facet_failover fs2mds
975 facet_failover fs2ost
978 # the MDS must remain up until last MDT
980 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
981 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
982 [ -z "$MDS" ] && error "No MDT"
984 cleanup_nocli || error "cleanup_nocli failed with rc $?"
986 run_test 24a "Multiple MDTs on a single node"
989 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
991 if [ -z "$fs2mds_DEV" ]; then
992 local dev=${SINGLEMDS}_dev
994 is_blkdev $SINGLEMDS $MDSDEV &&
995 skip_env "mixed loopback and real device not working"
998 local fs2mdsdev=$(mdsdevname 1_2)
999 local fs2mdsvdev=$(mdsvdevname 1_2)
1001 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1002 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1004 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS &&
1005 error "start MDS should fail"
1007 cleanup || error "cleanup failed with rc $?"
1009 run_test 24b "Multiple MGSs on a single node (should return err)"
1013 check_mount || error "check_mount failed"
1014 local MODULES=$($LCTL modules | awk '{ print $2 }')
1015 rmmod $MODULES 2>/dev/null || true
1016 cleanup || error "cleanup failed with $?"
1018 run_test 25 "Verify modules are referenced"
1022 # we need modules before mount for sysctl, so make sure...
1023 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1024 #define OBD_FAIL_MDS_FS_SETUP 0x135
1025 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1026 start_mds && error "MDS started but should not have started"
1027 $LCTL get_param -n devices
1028 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1029 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1030 # start mds to drop writeconf setting
1031 start_mds || error "Unable to start MDS"
1032 stop_mds || error "Unable to stop MDS"
1033 unload_modules_conf || error "unload_modules_conf failed with $?"
1035 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1038 start_ost || error "Unable to start OST1"
1039 start_mds || error "Unable to start MDS"
1040 echo "Requeue thread should have started: "
1041 ps -e | grep ll_cfg_requeue
1042 set_persistent_param_and_check ost1 \
1043 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1044 "$FSNAME-OST0000.ost.client_cache_seconds"
1045 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1047 run_test 27a "Reacquire MGS lock if OST started first"
1052 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1053 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1055 facet_failover $SINGLEMDS
1056 set_persistent_param_and_check $SINGLEMDS \
1057 "mdt.$device.identity_acquire_expire" \
1058 "$device.mdt.identity_acquire_expire"
1059 set_persistent_param_and_check client \
1060 "mdc.$device-mdc-*.max_rpcs_in_flight" \
1061 "$device.mdc.max_rpcs_in_flight"
1063 cleanup || error "cleanup failed with $?"
1065 run_test 27b "Reacquire MGS lock after failover"
1067 test_28A() { # was test_28
1069 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1070 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1071 ORIG=$($LCTL get_param -n $TEST)
1072 FINAL=$(($ORIG + 1))
1073 set_persistent_param_and_check client "$TEST" "$PARAM" $FINAL
1074 FINAL=$(($FINAL + 1))
1075 set_persistent_param_and_check client "$TEST" "$PARAM" $FINAL
1076 umount_client $MOUNT || error "umount_client $MOUNT failed"
1077 mount_client $MOUNT || error "mount_client $MOUNT failed"
1078 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 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1091 skip "Need OST version at least 2.5.52"
1092 [ "$(facet_fstype ost1)" = "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 > /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="osc.$FSNAME-OST0001-osc-*.active"
1150 local PROC_UUID="osc.$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"
1171 # the 2nd and 3rd field of ost_server_uuid do not update at the same
1172 # time when using lctl set_param -P
1173 wait_update_facet client \
1174 "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'" \
1176 error "New client start active: $($LCTL get_param -n $PROC_UUID)"
1178 echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
1180 # make sure it reactivates
1181 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1183 umount_client $MOUNT
1184 stop_ost2 || error "Unable to stop OST2"
1185 cleanup_nocli || error "cleanup_nocli failed with $?"
1186 #writeconf to remove all ost2 traces for subsequent tests
1187 writeconf_or_reformat
1189 run_test 29 "permanently remove an OST"
1194 echo Big config llog
1195 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1196 ORIG=$($LCTL get_param -n $TEST)
1197 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1198 for i in ${LIST[@]}; do
1199 set_persistent_param_and_check client "$TEST" \
1200 "$FSNAME.llite.max_read_ahead_whole_mb" $i
1202 # make sure client restart still works
1203 umount_client $MOUNT
1204 mount_client $MOUNT || error "mount_client $MOUNT failed"
1205 [ "$($LCTL get_param -n $TEST)" -ne "$i" ] &&
1206 error "Param didn't stick across restart $($TEST) != $i"
1209 echo Erase parameter setting
1210 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1211 do_facet mgs "$PERM_CMD -d $TEST" ||
1212 error "Erase param $TEST failed"
1214 do_facet mgs "$PERM_CMD \
1215 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1216 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1218 umount_client $MOUNT
1219 mount_client $MOUNT || error "mount_client $MOUNT failed"
1220 FINAL=$($LCTL get_param -n $TEST)
1221 echo "deleted (default) value=$FINAL, orig=$ORIG"
1222 # assumes this parameter started at the default value
1223 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1225 cleanup || error "cleanup failed with rc $?"
1227 run_test 30a "Big config llog and permanent parameter deletion"
1232 local orignids=$($LCTL get_param -n \
1233 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1235 local orignidcount=$(echo "$orignids" | wc -w)
1237 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1238 # numerical part of it. Hopefully that's not already a failover address
1240 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1242 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1243 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1244 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1245 echo "Using fake nid $NEW"
1247 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1248 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1249 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1250 PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
1251 echo "Setting $PARAM from $TEST to $NEW"
1252 do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
1253 error "$PERM_CMD $PARAM failed"
1255 PARAM="$FSNAME-OST0000.failover.node"
1256 echo "Setting $PARAM from $TEST to $NEW"
1257 do_facet mgs "$PERM_CMD $PARAM='$NEW'" ||
1258 error "$PARAM $PARAM failed"
1260 wait_update_facet client "$TEST" "$NEW" ||
1261 error "check $PARAM failed!"
1263 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1265 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1266 echo "should have $((orignidcount + 1)) entries \
1267 in failover nids string, have $NIDCOUNT"
1268 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1269 error "Failover nid not added"
1271 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1272 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1274 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1275 error "$PERM_CMD delete failed"
1277 umount_client $MOUNT
1278 mount_client $MOUNT || error "mount_client $MOUNT failed"
1280 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1282 NIDCOUNT=$(echo "$NIDS" | wc -w)
1283 echo "only $orignidcount final entries should remain \
1284 in failover nids string, have $NIDCOUNT"
1285 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1287 cleanup || error "cleanup failed with rc $?"
1289 run_test 30b "Remove failover nids"
1291 test_31() { # bug 10734
1292 # ipaddr must not exist
1293 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1294 cleanup || error "cleanup failed with rc $?"
1296 run_test 31 "Connect to non-existent node (shouldn't crash)"
1300 T32_BLIMIT=40960 # Kbytes
1304 # This is not really a test but a tool to create new disk
1305 # image tarballs for the upgrade tests.
1307 # Disk image tarballs should be created on single-node
1308 # clusters by running this test with default configurations
1309 # plus a few mandatory environment settings that are verified
1310 # at the beginning of the test.
1312 test_32newtarball() {
1316 local tmp=$TMP/t32_image_create
1317 local server_version=$(lustre_version_code $SINGLEMDS)
1322 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1323 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1324 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1325 "MDSDEV1=<nonexistent_file>" \
1326 "MDSDEV2=<nonexistent_file>" \
1327 "(or MDSDEV, in the case of b1_8)" \
1328 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1332 echo "Found stale $tmp"
1336 mkdir $tmp/src || return 1
1337 tar cf - -C $src . | tar xf - -C $tmp/src
1338 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1339 count=$(($T32_BLIMIT / 1024 / 4))
1340 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1342 # format ost with comma-separated NIDs to verify LU-4460
1343 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1344 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1348 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1349 $LFS quotacheck -ug /mnt/$FSNAME
1350 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1353 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1355 if [[ $MDSCOUNT -ge 2 ]]; then
1356 remote_dir=/mnt/$FSNAME/remote_dir
1357 $LFS mkdir -i 1 $remote_dir
1358 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1360 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1361 striped_dir=/mnt/$FSNAME/striped_dir_old
1362 $LFS mkdir -i 1 -c 2 $striped_dir
1363 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1369 mkdir $tmp/img || return 1
1373 pushd_dir=/mnt/$FSNAME
1374 if [[ $MDSCOUNT -ge 2 ]]; then
1375 pushd_dir=$remote_dir
1376 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1378 ls -Rni --time-style=+%s >$tmp/img/list2
1384 ls -Rni --time-style=+%s >$tmp/img/list
1385 find ! -name .lustre -type f -exec sha1sum {} \; |
1386 sort -k 2 >$tmp/img/sha1sums
1388 $LCTL get_param -n version | head -n 1 |
1389 sed -e 's/^lustre: *//' >$tmp/img/commit
1391 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1392 $LFS quotaon -ug /mnt/$FSNAME
1393 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1394 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1395 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1396 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1397 | tr -d "*" > $tmp/img/bspace
1398 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1399 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1400 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1401 | tr -d "*" > $tmp/img/ispace
1402 echo $T32_BLIMIT > $tmp/img/blimit
1403 echo $T32_ILIMIT > $tmp/img/ilimit
1408 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1411 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1412 echo "Data verification failed"
1415 uname -r >$tmp/img/kernel
1416 uname -m >$tmp/img/arch
1418 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1419 for num in $(seq 2 $MDSCOUNT); do
1420 local devname=$(mdsdevname $num)
1422 [[ $(facet_fstype $facet) != zfs ]] ||
1423 devname=$(mdsvdevname $num)
1424 mv $devname $tmp/img
1426 mv $OSTDEV1 $tmp/img
1428 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1429 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1432 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1437 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1440 # The list of applicable tarballs is returned via the caller's
1441 # variable "tarballs".
1444 [ "$CLIENTONLY" ] && skip "Client-only testing"
1446 local node=$(facet_active_host $SINGLEMDS)
1447 local r="do_node $node"
1449 ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
1451 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1453 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1454 -name \'disk*-$IMGTYPE.tar.bz2\')
1456 [ -z "$tarballs" ] && skip "No applicable tarballs found"
1459 t32_test_cleanup() {
1461 local facet=$SINGLEMDS
1462 local fstype=$(facet_fstype $facet)
1465 if $shall_cleanup_lustre; then
1466 umount $tmp/mnt/lustre || rc=$?
1468 if $shall_cleanup_mdt; then
1469 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1471 if $shall_cleanup_mdt1; then
1472 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1474 if $shall_cleanup_ost; then
1475 $r $UMOUNT $tmp/mnt/ost || rc=$?
1480 if [[ $fstype == zfs ]]; then
1482 local poolname_list="t32fs-mdt1 t32fs-ost1"
1484 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1486 for poolname in $poolname_list; do
1487 destroy_zpool $facet $poolname
1490 combined_mgs_mds || start_mgs || rc=$?
1494 t32_bits_per_long() {
1496 # Yes, this is not meant to be perfect.
1506 t32_reload_modules() {
1508 local all_removed=false
1510 local fstype=$(facet_fstype $SINGLEMDS)
1512 [ $fstype == "zfs" ] && do_rpc_nodes $node "service zed stop"
1514 while ((i < 20)); do
1515 echo "Unloading modules on $node: Attempt $i"
1516 do_rpc_nodes $node $LUSTRE_RMMOD $fstype &&
1518 do_rpc_nodes $node check_mem_leak || return 1
1519 if $all_removed; then
1520 do_rpc_nodes $node load_modules
1523 if [ $fstype == "zfs" ]; then
1524 do_rpc_nodes $node "$ZPOOL status -v"
1529 echo "Unloading modules on $node: Given up"
1533 t32_wait_til_devices_gone() {
1539 echo wait for devices to go
1540 while ((i < 20)); do
1541 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1542 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1543 ((devices == 0 && loops == 0)) && return 0
1547 echo "waiting for dev on $node: dev $devices loop $loops given up"
1548 do_rpc_nodes $node "losetup -a"
1549 do_rpc_nodes $node "$LCTL device_list"
1553 t32_verify_quota() {
1557 local fstype=$(facet_fstype $SINGLEMDS)
1561 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1562 # lustre will estimate the object count usage. This fails quota
1563 # verification in 32b. The object quota usage should be accurate after
1564 # zfs-0.7.0 is released.
1565 [ $fstype == "zfs" ] && {
1566 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1568 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1569 echo "Skip quota verify for zfs: $zfs_version"
1574 $LFS quota -u $T32_QID -v $mnt
1576 qval=$($LFS quota -v -u $T32_QID $mnt |
1577 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1578 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1580 [ $qval -eq $img_bspace ] || {
1581 echo "bspace, act:$qval, exp:$img_bspace"
1585 qval=$($LFS quota -v -u $T32_QID $mnt |
1586 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1587 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1589 [ $qval -eq $img_ispace ] || {
1590 echo "ispace, act:$qval, exp:$img_ispace"
1594 qval=$($LFS quota -v -u $T32_QID $mnt |
1595 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1596 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1598 [ $qval -eq $img_blimit ] || {
1599 echo "blimit, act:$qval, exp:$img_blimit"
1603 qval=$($LFS quota -v -u $T32_QID $mnt |
1604 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1605 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1607 [ $qval -eq $img_ilimit ] || {
1608 echo "ilimit, act:$qval, exp:$img_ilimit"
1612 set_persistent_param_and_check $facet \
1613 "osd-$fstype.$fsname-MDT0000.quota_slave.enabled" \
1614 "$fsname.quota.mdt" ug
1616 set_persistent_param_and_check $facet \
1617 "osd-$fstype.$fsname-OST0000.quota_slave.enabled" \
1618 "$fsname.quota.ost" ug
1621 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1622 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1623 echo "Write succeed, but expect -EDQUOT"
1626 rm -f $mnt/t32_qf_new
1628 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1630 echo "Create succeed, but expect -EDQUOT"
1633 unlinkmany $mnt/t32_qf_ $img_ilimit
1641 local dne_upgrade=${dne_upgrade:-"no"}
1642 local dom_upgrade=${dom_upgrade:-"no"}
1643 local ff_convert=${ff_convert:-"no"}
1644 local shall_cleanup_mdt=false
1645 local shall_cleanup_mdt1=false
1646 local shall_cleanup_ost=false
1647 local shall_cleanup_lustre=false
1648 local mdt2_is_available=false
1649 local node=$(facet_active_host $SINGLEMDS)
1650 local r="do_node $node"
1666 local fstype=$(facet_fstype $SINGLEMDS)
1667 local mdt_dev=$tmp/mdt
1668 local mdt2_dev=$tmp/mdt2
1669 local ost_dev=$tmp/ost
1674 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1675 trap 'trap - RETURN; t32_test_cleanup' RETURN
1678 nid=$($r $LCTL list_nids | head -1)
1680 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1681 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1682 $r tar xjvf $tarball -S -C $tmp || {
1683 error_noexit "Unpacking the disk image tarball"
1686 img_commit=$($r cat $tmp/commit)
1687 img_kernel=$($r cat $tmp/kernel)
1688 img_arch=$($r cat $tmp/arch)
1689 img_bspace=$($r cat $tmp/bspace)
1690 img_ispace=$($r cat $tmp/ispace)
1692 # older images did not have "blimit" and "ilimit" files
1693 # use old values for T32_BLIMIT and T32_ILIMIT
1694 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1696 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1699 echo "Upgrading from $(basename $tarball), created with:"
1700 echo " Commit: $img_commit"
1701 echo " Kernel: $img_kernel"
1702 echo " Arch: $img_arch"
1703 echo "OST version: $(lustre_build_version ost1)"
1705 # The conversion can be made only when both of the following
1706 # conditions are satisfied:
1707 # - ost device img version < 2.3.64
1708 # - ost server version >= 2.5
1709 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1710 $(lustre_version_code ost1) -lt $(version_code 2.5.0) ] &&
1713 ! $r test -f $mdt2_dev || mdt2_is_available=true
1715 if [[ $fstype == zfs ]]; then
1718 local poolname_list="t32fs-mdt1 t32fs-ost1"
1720 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1722 for poolname in $poolname_list; do
1724 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1725 $ZPOOL import -f -d $tmp $poolname"
1728 # upgrade zpool to latest supported features, including
1729 # dnode quota accounting in 0.7.0
1730 $r "$ZPOOL upgrade -a"
1732 mdt_dev=t32fs-mdt1/mdt1
1733 ost_dev=t32fs-ost1/ost1
1734 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1735 wait_update_facet $SINGLEMDS "$ZPOOL list |
1736 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1737 error_noexit "import zfs pool failed"
1742 $r $LCTL set_param debug="$PTLDEBUG"
1744 $r $TUNEFS --dryrun $mdt_dev || {
1746 error_noexit "tunefs.lustre before mounting the MDT"
1750 if $mdt2_is_available; then
1751 $r $TUNEFS --dryrun $mdt2_dev || {
1753 error_noexit "tunefs.lustre before mounting the MDT"
1758 if [ "$writeconf" ]; then
1760 if [ $fstype == "ldiskfs" ]; then
1762 $r $TUNEFS --quota $mdt_dev || {
1764 error_noexit "Enable mdt quota feature"
1767 if $mdt2_is_available; then
1768 $r $TUNEFS --quota $mdt2_dev || {
1770 error_noexit "Enable mdt quota feature"
1776 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1777 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1778 skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
1779 "(Need MGS version at least 2.3.59)"
1781 local osthost=$(facet_active_host ost1)
1782 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1785 if [ $fstype == "ldiskfs" ]; then
1788 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1789 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1790 $r $LCTL replace_nids $fsname-MDT0000 $nid
1791 $r $UMOUNT $tmp/mnt/mdt
1794 mopts=exclude=$fsname-OST0000
1795 if [ $fstype == "ldiskfs" ]; then
1800 t32_wait_til_devices_gone $node
1802 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1804 error_noexit "Mounting the MDT"
1807 shall_cleanup_mdt=true
1809 if $mdt2_is_available; then
1810 mopts=mgsnode=$nid,$mopts
1811 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1813 error_noexit "Mounting the MDT"
1817 echo "mount new MDT....$mdt2_dev"
1818 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1819 error_noexit "enable remote dir create failed"
1821 shall_cleanup_mdt1=true
1822 elif [ "$dne_upgrade" != "no" ]; then
1823 local fs2mdsdev=$(mdsdevname 1_2)
1824 local fs2mdsvdev=$(mdsvdevname 1_2)
1826 echo "mkfs new MDT on ${fs2mdsdev}...."
1827 if [ $(facet_fstype mds1) == ldiskfs ]; then
1828 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1831 add $SINGLEMDS $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1832 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1833 error_noexit "Mkfs new MDT failed"
1837 [[ $(facet_fstype mds1) != zfs ]] || import_zpool mds1
1839 $r $TUNEFS --dryrun $fs2mdsdev || {
1840 error_noexit "tunefs.lustre before mounting the MDT"
1844 echo "mount new MDT....$fs2mdsdev"
1845 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1846 error_noexit "mount mdt1 failed"
1850 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1851 error_noexit "enable remote dir create failed"
1853 shall_cleanup_mdt1=true
1856 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1857 error_noexit "Getting MDT UUID"
1860 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1861 error_noexit "Unexpected MDT UUID: \"$uuid\""
1865 $r $TUNEFS --dryrun $ost_dev || {
1866 error_noexit "tunefs.lustre before mounting the OST"
1869 if [ "$writeconf" ]; then
1870 mopts=mgsnode=$nid,$writeconf
1871 if [ $fstype == "ldiskfs" ]; then
1873 $r $TUNEFS --quota $ost_dev || {
1875 error_noexit "Enable ost quota feature"
1881 if [ $fstype == "ldiskfs" ]; then
1886 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1887 error_noexit "Mounting the OST"
1890 shall_cleanup_ost=true
1892 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1893 error_noexit "Getting OST UUID"
1896 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1897 error_noexit "Unexpected OST UUID: \"$uuid\""
1901 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1902 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
1903 error_noexit "Setting OST \"failover.node\""
1906 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
1907 error_noexit "Setting MDT \"failover.node\""
1910 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
1911 error_noexit "Setting \"max_dirty_mb\""
1914 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
1915 error_noexit "Setting \"max_rpcs_in_flight\""
1918 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
1919 error_noexit "Setting \"lov.stripesize\""
1922 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
1923 error_noexit "Setting \"mdd.atime_diff\""
1927 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
1928 error_noexit "Setting OST \"failover.node\""
1932 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
1933 error_noexit "Setting MDT \"failover.node\""
1937 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
1938 error_noexit "Setting \"max_dirty_mb\""
1941 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1942 error_noexit "Setting \"max_rpcs_in_flight\""
1945 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
1946 error_noexit "Setting \"lov.stripesize\""
1949 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
1950 error_noexit "Setting \"mdd.atime_diff\""
1955 $r $LCTL pool_new $fsname.interop || {
1956 error_noexit "Setting \"interop\""
1960 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1961 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1962 error_noexit "Start OI scrub on OST0"
1966 # The oi_scrub should be on ost1, but for test_32(),
1967 # all on the SINGLEMDS.
1968 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1969 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1970 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1971 error_noexit "Failed to get the expected 'completed'"
1975 local UPDATED=$($r $LCTL get_param -n \
1976 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1977 awk '/^updated/ { print $2 }')
1978 [ $UPDATED -ge 1 ] || {
1979 error_noexit "Only $UPDATED objects have been converted"
1984 if [ "$dne_upgrade" != "no" ]; then
1985 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1986 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
1987 error_noexit "Setting MDT1 \"failover.node\""
1991 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
1992 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
1995 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
1996 error_noexit "Setting MDT1 \"lov.stripesize\""
2000 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
2001 error_noexit "Setting MDT1 \"failover.node\""
2004 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2005 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2008 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2009 error_noexit "Setting MDT1 \"lov.stripesize\""
2015 if [ "$writeconf" ]; then
2016 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2017 error_noexit "Mounting the client"
2021 shall_cleanup_lustre=true
2022 $r $LCTL set_param debug="$PTLDEBUG"
2024 # Leave re-enabling this to a separate patch for LU-11558
2025 # t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2026 # error_noexit "verify quota failed"
2030 if $r test -f $tmp/list; then
2032 # There is not a Test Framework API to copy files to or
2033 # from a remote node.
2035 # LU-2393 - do both sorts on same node to ensure locale
2037 local list_file=$tmp/list
2039 if $mdt2_is_available; then
2040 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2041 $r test -f $tmp/list2; then
2042 list_file=$tmp/list2
2043 pushd $tmp/mnt/lustre/striped_dir_old
2045 pushd $tmp/mnt/lustre/remote_dir
2048 pushd $tmp/mnt/lustre
2050 $r cat $list_file | sort -k 6 >$tmp/list.orig
2051 ls -Rni --time-style=+%s | sort -k 6 |
2052 sed 's/\. / /' >$tmp/list || {
2058 # 32-bit and 64-bit clients use different algorithms to
2059 # convert FIDs into inode numbers. Hence, remove the
2060 # inode numbers from the lists, if the original list was
2061 # created on an architecture with different number of
2064 if [ $(t32_bits_per_long $(uname -m)) != \
2065 $(t32_bits_per_long $img_arch) ]; then
2066 echo "Different number of bits per \"long\"" \
2067 "from the disk image"
2068 for list in list.orig list; do
2069 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2073 if ! diff -ub $tmp/list.orig $tmp/list; then
2074 error_noexit "list verification failed"
2078 echo "list verification skipped"
2081 if [ "$dom_upgrade" != "no" ]; then
2082 echo "Check DoM file can be created"
2083 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2084 error_noexit "Verify DoM creation"
2087 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2088 error_noexit "Verify a DoM file"
2091 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2092 count=1 conv=fsync || {
2093 error_noexit "Cannot write to DoM file"
2096 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2097 error_noexit "DoM: bad size after write"
2100 rm $tmp/mnt/lustre/dom
2102 set_persistent_param_and_check mds \
2103 "lod.*MDT0000*.dom_stripesize" \
2104 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2105 error_noexit "Changing \"dom_stripesize\""
2110 if [ "$dne_upgrade" != "no" ]; then
2111 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2112 error_noexit "set striped dir failed"
2116 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2118 pushd $tmp/mnt/lustre
2119 tar -cf - . --exclude=./striped_dir \
2120 --exclude=./striped_dir_old \
2121 --exclude=./remote_dir |
2122 tar -xvf - -C striped_dir 1>/dev/null || {
2123 error_noexit "cp to striped dir failed"
2129 # If it is upgrade from DNE (2.5), then rename the remote dir,
2130 # which is created in 2.5 to striped dir.
2131 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2132 stripe_index=$($LFS getdirstripe -i \
2133 $tmp/mnt/lustre/remote_dir)
2135 [[ $stripe_index -eq 1 ]] || {
2136 error_noexit "get index \"$stripe_index\"" \
2137 "from remote dir failed"
2140 mv $tmp/mnt/lustre/remote_dir \
2141 $tmp/mnt/lustre/striped_dir/ || {
2142 error_noexit "mv remote dir failed"
2147 # If it is upgraded from DNE (2.7), then move the striped dir
2148 # which was created in 2.7 to the new striped dir.
2149 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2150 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2151 stripe_count=$($LFS getdirstripe -c \
2152 $tmp/mnt/lustre/striped_dir_old)
2153 [[ $stripe_count -eq 2 ]] || {
2154 error_noexit "get count $stripe_count" \
2155 "from striped dir failed"
2158 mv $tmp/mnt/lustre/striped_dir_old \
2159 $tmp/mnt/lustre/striped_dir/ || {
2160 error_noexit "mv striped dir failed"
2166 $r $LCTL set_param -n osd*.*.force_sync=1
2167 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2168 error_noexit "dd failed"
2171 rm -rf $tmp/mnt/lustre/tmp_file || {
2172 error_noexit "rm failed"
2176 if $r test -f $tmp/sha1sums; then
2177 # LU-2393 - do both sorts on same node to ensure locale
2179 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2180 if [ "$dne_upgrade" != "no" ]; then
2181 pushd $tmp/mnt/lustre/striped_dir
2183 pushd $tmp/mnt/lustre
2186 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2187 ! -name .lustre -type f -exec sha1sum {} \; |
2188 sort -k 2 >$tmp/sha1sums || {
2190 error_noexit "sha1sum"
2194 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2195 error_noexit "sha1sum verification failed"
2199 # if upgrade from DNE(2.5), then check remote directory
2200 # if upgrade from DNE(2.7), then check striped directory
2201 if $mdt2_is_available &&
2202 [[ "$dne_upgrade" != "no" ]]; then
2203 local new_dir="$tmp/mnt/lustre/striped_dir"
2204 local striped_dir_old="$new_dir/striped_dir_old"
2206 local dir_list="$new_dir/remote_dir"
2207 [[ ! -d $triped_dir_old ]] ||
2208 dir_list+=" $striped_dir_old"
2210 for dir in $dir_list; do
2212 find ! -name .lustre -type f \
2213 -exec sha1sum {} \; |
2214 sort -k 2 >$tmp/sha1sums || {
2216 error_noexit "sha1sum"
2220 if ! diff -ub $tmp/sha1sums.orig \
2222 error_noexit "sha1sum $dir" \
2229 echo "sha1sum verification skipped"
2232 if [ "$dne_upgrade" != "no" ]; then
2233 rm -rf $tmp/mnt/lustre/striped_dir || {
2234 error_noexit "remove remote dir failed"
2239 # migrate files/dirs to remote MDT, then move them back
2240 if [ $(lustre_version_code mds1) -ge $(version_code 2.7.50) -a \
2241 $dne_upgrade != "no" ]; then
2242 $r $LCTL set_param -n \
2243 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2245 echo "test migration"
2246 pushd $tmp/mnt/lustre
2247 for dir in $(find ! -name .lustre ! -name . -type d); do
2248 mdt_index=$($LFS getdirstripe -i $dir)
2249 stripe_cnt=$($LFS getdirstripe -c $dir)
2250 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2251 $LFS migrate -m 1 $dir || {
2253 error_noexit "migrate MDT1 failed"
2259 for dir in $(find ! -name . ! -name .lustre -type d); do
2260 mdt_index=$($LFS getdirstripe -i $dir)
2261 stripe_cnt=$($LFS getdirstripe -c $dir)
2262 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2263 $LFS migrate -m 0 $dir || {
2265 error_noexit "migrate MDT0 failed"
2274 # When adding new data verification tests, please check for
2275 # the presence of the required reference files first, like
2276 # the "sha1sums" and "list" tests above, to avoid the need to
2277 # regenerate every image for each test addition.
2280 nrpcs_orig=$($LCTL get_param \
2281 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2282 error_noexit "Getting \"max_rpcs_in_flight\""
2285 nrpcs=$((nrpcs_orig + 5))
2287 set_persistent_param_and_check client \
2288 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
2289 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
2290 error_noexit "Changing \"max_rpcs_in_flight\""
2294 umount $tmp/mnt/lustre || {
2295 error_noexit "Unmounting the client"
2298 shall_cleanup_lustre=false
2300 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2301 $r $UMOUNT $tmp/mnt/mdt1 || {
2302 error_noexit "Unmounting the MDT2"
2305 if [[ $fstype == zfs ]]; then
2306 $r "$ZPOOL export t32fs-mdt2"
2308 shall_cleanup_mdt1=false
2311 $r $UMOUNT $tmp/mnt/mdt || {
2312 error_noexit "Unmounting the MDT"
2315 if [[ $fstype == zfs ]]; then
2316 $r "$ZPOOL export t32fs-mdt1"
2318 shall_cleanup_mdt=false
2320 $r $UMOUNT $tmp/mnt/ost || {
2321 error_noexit "Unmounting the OST"
2324 if [[ $fstype == zfs ]]; then
2325 $r "$ZPOOL export t32fs-ost1"
2327 shall_cleanup_ost=false
2329 t32_reload_modules $node || {
2330 error_noexit "Reloading modules"
2334 if [[ $fstype == zfs ]]; then
2335 local poolname=t32fs-mdt1
2337 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2338 $ZPOOL import -f -d $tmp $poolname"
2340 # upgrade zpool to latest supported features,
2341 # including dnode quota accounting in 0.7.0
2342 $r "$ZPOOL upgrade $poolname"
2345 # mount a second time to make sure we didnt leave upgrade flag on
2346 $r $TUNEFS --dryrun $mdt_dev || {
2348 error_noexit "tunefs.lustre before remounting the MDT"
2352 mopts=exclude=$fsname-OST0000
2353 if [ $fstype == "ldiskfs" ]; then
2356 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2357 error_noexit "Remounting the MDT"
2360 shall_cleanup_mdt=true
2370 for tarball in $tarballs; do
2371 t32_test $tarball || let "rc += $?"
2375 run_test 32a "Upgrade (not live)"
2383 for tarball in $tarballs; do
2384 t32_test $tarball writeconf || let "rc += $?"
2388 run_test 32b "Upgrade with writeconf"
2395 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2397 for tarball in $tarballs; do
2398 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2399 echo $tarball | grep "1_8" && continue
2400 echo $tarball | grep "2_1" && continue
2402 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2406 run_test 32c "dne upgrade test"
2414 for tarball in $tarballs; do
2415 ff_convert=yes t32_test $tarball || rc=$?
2419 run_test 32d "convert ff test"
2422 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
2423 skip "Need MDS version at least 2.10.56"
2430 for tarball in $tarballs; do
2431 echo $tarball | grep "2_9" || continue
2433 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
2437 run_test 32e "dom upgrade test"
2439 test_33a() { # bug 12333, was test_33
2440 local FSNAME2=test-123
2441 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2444 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2446 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2447 local dev=${SINGLEMDS}_dev
2448 local MDSDEV=${!dev}
2449 is_blkdev $SINGLEMDS $MDSDEV &&
2450 skip_env "mixed loopback and real device not working"
2453 local fs2mdsdev=$(mdsdevname 1_2)
2454 local fs2ostdev=$(ostdevname 1_2)
2455 local fs2mdsvdev=$(mdsvdevname 1_2)
2456 local fs2ostvdev=$(ostvdevname 1_2)
2458 if [ $(facet_fstype mds1) == ldiskfs ]; then
2459 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2462 if combined_mgs_mds; then
2463 local mgs_flag="--mgs"
2466 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
2467 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
2469 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2470 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2471 $fs2ostvdev || exit 10
2473 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2474 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2476 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2477 do_facet mgs "$PERM_CMD timeout=200" ||
2478 error "$PERM_CMD timeout=200 failed"
2480 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
2481 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
2483 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2484 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2487 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2488 $LFS getstripe $MOUNT2/hosts ||
2489 error "$LFS getstripe $MOUNT2/hosts failed"
2494 cleanup_nocli || error "cleanup_nocli failed with $?"
2496 run_test 33a "Mount ost with a large index number"
2498 test_33b() { # was test_34
2501 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2502 # Drop lock cancelation reply during umount
2503 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2504 do_facet client $LCTL set_param fail_loc=0x80000304
2505 #lctl set_param debug=-1
2506 umount_client $MOUNT
2507 cleanup || error "cleanup failed with $?"
2509 run_test 33b "Drop cancel during umount"
2513 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2514 manual_umount_client
2516 do_facet client killall -USR1 multiop
2517 if [ $rc -eq 0 ]; then
2518 error "umount not fail!"
2521 cleanup || error "cleanup failed with rc $?"
2523 run_test 34a "umount with opened file should be fail"
2527 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2528 stop_mds || error "Unable to stop MDS"
2530 manual_umount_client --force || error "mtab after failed umount with $?"
2532 cleanup || error "cleanup failed with $?"
2534 run_test 34b "force umount with failed mds should be normal"
2538 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2539 stop_ost || error "Unable to stop OST1"
2541 manual_umount_client --force || error "mtab after failed umount with $?"
2543 cleanup || error "cleanup failed with $?"
2545 run_test 34c "force umount with failed ost should be normal"
2547 test_35a() { # bug 12459
2550 DBG_SAVE="`$LCTL get_param -n debug`"
2551 $LCTL set_param debug="ha"
2553 log "Set up a fake failnode for the MDS"
2555 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2556 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2558 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2559 do_facet mgs "$PERM_CMD \
2560 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2561 error "Setting mdc.*${device}*.import=connection=\
2562 $(h2nettype $FAKENID) failed."
2564 do_facet mgs "$PERM_CMD \
2565 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2566 error "Setting ${device}.failover.node=\
2567 $(h2nettype $FAKENID) failed."
2569 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2572 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2575 log "Stopping the MDT: $device"
2576 stop_mdt 1 || error "MDT0 stop fail"
2578 df $MOUNT > /dev/null 2>&1 &
2580 log "Restarting the MDT: $device"
2581 start_mdt 1 || error "MDT0 start fail"
2582 log "Wait for df ($DFPID) ... "
2585 $LCTL set_param debug="$DBG_SAVE"
2587 # retrieve from the log the first server that the client tried to
2588 # contact after the connection loss
2589 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2590 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2591 /import_select_connection.*$device-mdc.* using connection/ {
2593 if (\\\$NF ~ /$FAKENID/)
2599 }" $TMP/lustre-log-$TESTNAME.log`
2600 [ "$NEXTCONN" != "0" ] &&
2601 error "Tried to connect to ${NEXTCONN} not last active server"
2602 cleanup || error "cleanup failed with $?"
2603 # remove nid settings
2604 writeconf_or_reformat
2606 run_test 35a "Reconnect to the last active server first"
2608 test_35b() { # bug 18674
2609 remote_mds || skip "local MDS"
2613 $LCTL set_param debug="ha"
2615 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2618 log "Set up a fake failnode for the MDS"
2620 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2621 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2623 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2624 do_facet mgs "$PERM_CMD \
2625 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2626 error "Set mdc.*${device}*.import=connection=\
2627 $(h2nettype $FAKENID) failed"
2629 do_facet mgs "$PERM_CMD \
2630 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2631 error "Set ${device}.failover.node=\
2632 $(h2nettype $FAKENID) failed"
2635 local at_max_saved=0
2636 # adaptive timeouts may prevent seeing the issue
2637 if at_is_enabled; then
2638 at_max_saved=$(at_max_get mds)
2639 at_max_set 0 mds client
2642 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2644 log "Injecting EBUSY on MDS"
2645 # Setting OBD_FAIL_MDS_RESEND=0x136
2646 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2647 error "unable to set param fail_loc=0x80000136"
2649 $LCTL set_param mdc.${FSNAME}*.stats=clear
2651 log "Creating a test file and stat it"
2652 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2653 stat $MOUNT/$tdir/$tfile
2655 log "Stop injecting EBUSY on MDS"
2656 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2657 error "unable to set param fail_loc=0"
2658 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2661 # restore adaptive timeout
2662 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2664 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2666 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2667 awk '/mds_connect/{print $2}')
2669 # retrieve from the log if the client has ever tried to
2670 # contact the fake server after the loss of connection
2671 FAILCONN=`awk "BEGIN {ret = 0;}
2672 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2674 if (\\\$NF ~ /$FAKENID/) {
2679 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2681 [ "$FAILCONN" == "0" ] &&
2682 error "The client reconnection has not been triggered"
2683 [ "$FAILCONN" == "2" ] &&
2684 error "Primary server busy, client reconnect to failover failed"
2687 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2688 # Reconnects are supposed to be rate limited to one every 5s
2689 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2690 error "Too many reconnects $CONNCNT"
2692 cleanup || error "cleanup failed with $?"
2693 # remove nid settings
2694 writeconf_or_reformat
2696 run_test 35b "Continue reconnection retries, if the active server is busy"
2699 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2701 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2705 local FSNAME2=test1234
2706 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2708 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2710 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2711 is_blkdev $SINGLEMDS $MDSDEV &&
2712 skip_env "mixed loopback and real device not working"
2715 local fs2mdsdev=$(mdsdevname 1_2)
2716 local fs2ostdev=$(ostdevname 1_2)
2717 local fs3ostdev=$(ostdevname 2_2)
2718 local fs2mdsvdev=$(mdsvdevname 1_2)
2719 local fs2ostvdev=$(ostvdevname 1_2)
2720 local fs3ostvdev=$(ostvdevname 2_2)
2722 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2723 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2724 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2725 # different one than the default value here.
2726 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2727 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2728 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2729 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2731 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2732 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2733 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2734 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2735 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2737 sleep 5 # until 11778 fixed
2739 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2741 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2742 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2743 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2744 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2745 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2746 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2747 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2748 DFTOTAL=$(echo $STRING | cut -d, -f1)
2749 DFUSED=$(echo $STRING | cut -d, -f2)
2750 DFAVAIL=$(echo $STRING | cut -d, -f3)
2751 DFFREE=$(($DFTOTAL - $DFUSED))
2753 ALLOWANCE=$((64 * $OSTCOUNT))
2755 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2756 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2757 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2760 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2761 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2762 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2765 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2766 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2767 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2772 stop fs3ost -f || error "unable to stop OST3"
2773 stop fs2ost -f || error "unable to stop OST2"
2774 stop fs2mds -f || error "unable to stop second MDS"
2775 unload_modules_conf || error "unable unload modules"
2778 run_test 36 "df report consistency on OSTs with different block size"
2781 local mntpt=$(facet_mntpt $SINGLEMDS)
2782 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2783 local mdsdev_sym="$TMP/sym_mdt.img"
2784 local opts=$MDS_MOUNT_OPTS
2787 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2788 skip "ldiskfs only test"
2791 echo "MDS : $mdsdev"
2792 echo "SYMLINK : $mdsdev_sym"
2793 do_facet $SINGLEMDS rm -f $mdsdev_sym
2795 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2797 echo "mount symlink device - $mdsdev_sym"
2799 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2800 opts=$(csa_add "$opts" -o loop)
2802 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2803 $mdsdev_sym $mntpt 2>&1)
2806 echo mount_op=$mount_op
2808 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2810 if $(echo $mount_op | grep -q "unable to set tunable"); then
2811 error "set tunables failed for symlink device"
2814 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2816 run_test 37 "verify set tunables works for symlink device"
2818 test_38() { # bug 14222
2819 local fstype=$(facet_fstype $SINGLEMDS)
2820 local mntpt=$(facet_mntpt $SINGLEMDS)
2825 local SRC="/etc /bin"
2826 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2827 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2828 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2829 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2830 error "copying $SRC to $DIR/$tdir"
2832 umount_client $MOUNT || error "umount_client $MOUNT failed"
2833 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2834 stop_mds || error "Unable to stop MDS"
2835 log "delete lov_objid file on MDS"
2837 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2839 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2841 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2843 # check create in mds_lov_connect
2844 start_mds || error "unable to start MDS"
2845 mount_client $MOUNT || error "mount_client $MOUNT failed"
2847 [ $V ] && log "verifying $DIR/$tdir/$f"
2848 diff -q $f $DIR/$tdir/$f || ERROR=y
2850 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2851 if [ "$ERROR" = "y" ]; then
2852 # check it's updates in sync
2853 umount_client $MOUNT
2855 mount_fstype $SIGNLEMDS
2856 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2857 unmount_fstype $SINGLEMDS
2858 error "old and new files are different after connect" || true
2860 touch $DIR/$tdir/f2 || error "f2 file create failed"
2862 # check it's updates in sync
2863 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2866 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2868 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2869 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2871 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2873 start_mds || error "unable to start MDS"
2874 mount_client $MOUNT || error "mount_client $MOUNT failed"
2876 [ $V ] && log "verifying $DIR/$tdir/$f"
2877 diff -q $f $DIR/$tdir/$f || ERROR=y
2879 touch $DIR/$tdir/f3 || error "f3 file create failed"
2880 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2881 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2883 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2884 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2885 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2887 [ "$ERROR" = "y" ] &&
2888 error "old and new files are different after sync" || true
2890 log "files compared the same"
2891 cleanup || error "cleanup failed with $?"
2893 run_test 38 "MDS recreates missing lov_objid file from OST data"
2898 cleanup || error "cleanup failed with $?"
2899 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2900 error "memory leak detected" || true
2902 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2904 test_40() { # bug 15759
2905 start_ost || error "Unable to start OST1"
2906 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2907 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2909 cleanup || error "cleanup failed with rc $?"
2911 run_test 40 "race during service thread startup"
2913 test_41a() { #bug 14134
2914 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2915 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2916 skip "Loop devices does not work with nosvc option"
2919 combined_mgs_mds || skip "needs combined MGT and MDT device"
2921 start_mdt 1 -o nosvc -n
2922 if [ $MDSCOUNT -ge 2 ]; then
2923 for num in $(seq 2 $MDSCOUNT); do
2924 start_mdt $num || return
2927 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2928 start_mdt 1 -o nomgs,force
2929 mount_client $MOUNT || error "mount_client $MOUNT failed"
2932 echo "blah blah" > $MOUNT/$tfile
2935 umount_client $MOUNT || error "umount_client $MOUNT failed"
2936 stop ost1 -f || error "unable to stop OST1"
2937 stop_mds || error "Unable to stop MDS"
2938 stop_mds || error "Unable to stop MDS on second try"
2940 run_test 41a "mount mds with --nosvc and --nomgs"
2943 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2944 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2945 skip "Loop devices does not work with nosvc option"
2948 ! combined_mgs_mds && skip "needs combined mgs device"
2952 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2954 start_mdt 1 -o nosvc -n
2955 if [ $MDSCOUNT -ge 2 ]; then
2956 for num in $(seq 2 $MDSCOUNT); do
2957 start_mdt $num || return
2960 start_ost || error "Unable to start OST1"
2961 start_mdt 1 -o nomgs,force
2962 mount_client $MOUNT || error "mount_client $MOUNT failed"
2965 echo "blah blah" > $MOUNT/$tfile
2966 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
2968 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
2969 stop_ost || error "Unable to stop OST1"
2970 stop_mds || error "Unable to stop MDS"
2971 stop_mds || error "Unable to stop MDS on second try"
2973 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2976 local server_version=$(lustre_version_code $SINGLEMDS)
2977 local oss_list=$(comma_list $(osts_nodes))
2979 [[ $server_version -ge $(version_code 2.6.52) ]] ||
2980 [[ $server_version -ge $(version_code 2.5.26) &&
2981 $server_version -lt $(version_code 2.5.50) ]] ||
2982 [[ $server_version -ge $(version_code 2.5.4) &&
2983 $server_version -lt $(version_code 2.5.11) ]] ||
2984 skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"
2986 # ensure mds1 ost1 have been created even if running sub-test standalone
2989 cleanup || error "cleanup failed"
2991 # using directly mount command instead of start() function to avoid
2992 # any side effect of // with others/externals tools/features
2993 # ("zpool import", ...)
2995 # MDT concurrent start
2997 LOAD_MODULES_REMOTE=true load_modules
2998 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
2999 error "MDT concurrent start: libcfs module not loaded"
3001 local mds1dev=$(mdsdevname 1)
3002 local mds1mnt=$(facet_mntpt mds1)
3003 local mds1fstype=$(facet_fstype mds1)
3004 local mds1opts=$MDS_MOUNT_OPTS
3006 if [ $mds1fstype == ldiskfs ] &&
3007 ! do_facet mds1 test -b $mds1dev; then
3008 mds1opts=$(csa_add "$mds1opts" -o loop)
3010 if [[ $mds1fstype == zfs ]]; then
3011 import_zpool mds1 || return ${PIPESTATUS[0]}
3014 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3015 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
3017 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
3020 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
3024 do_facet mds1 "$LCTL set_param fail_loc=0x0"
3025 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3026 echo "1st MDT start succeed"
3027 echo "2nd MDT start failed with $rc2"
3028 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3029 echo "1st MDT start failed with $rc"
3030 echo "2nd MDT start succeed"
3033 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
3036 if [ $MDSCOUNT -ge 2 ]; then
3037 for num in $(seq 2 $MDSCOUNT); do
3038 start_mdt $num || return
3042 # OST concurrent start
3044 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
3045 error "OST concurrent start: libcfs module not loaded"
3047 local ost1dev=$(ostdevname 1)
3048 local ost1mnt=$(facet_mntpt ost1)
3049 local ost1fstype=$(facet_fstype ost1)
3050 local ost1opts=$OST_MOUNT_OPTS
3052 if [ $ost1fstype == ldiskfs ] &&
3053 ! do_facet ost1 test -b $ost1dev; then
3054 ost1opts=$(csa_add "$ost1opts" -o loop)
3056 if [[ $ost1fstype == zfs ]]; then
3057 import_zpool ost1 || return ${PIPESTATUS[0]}
3060 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3061 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
3063 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
3066 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
3070 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3071 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3072 echo "1st OST start succeed"
3073 echo "2nd OST start failed with $rc2"
3074 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3075 echo "1st OST start failed with $rc"
3076 echo "2nd OST start succeed"
3080 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3086 # verify everything ok
3091 error "MDT(s) start failed"
3099 error "OST(s) start failed"
3107 error "client start failed"
3114 error "client mount failed"
3118 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3120 test_42() { #bug 14693
3124 check_mount || error "client was not mounted"
3126 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3127 PARAM="llite.$FSNAME-*.some_wrong_param"
3129 PARAM="$FSNAME.llite.some_wrong_param"
3132 do_facet mgs $PERM_CMD $PARAM=10
3133 umount_client $MOUNT ||
3134 error "unmounting client failed with invalid llite param"
3135 mount_client $MOUNT ||
3136 error "mounting client failed with invalid llite param"
3138 do_facet mgs $PERM_CMD $PARAM=20
3139 cleanup || error "stopping $FSNAME failed with invalid sys param"
3141 check_mount || error "client was not mounted with invalid sys param"
3142 cleanup || error "stopping $FSNAME failed with invalid sys param"
3144 run_test 42 "allow client/server mount/unmount with invalid config param"
3147 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.58) ]] ||
3148 skip "Need MDS version at least 2.5.58"
3149 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
3152 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
3153 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1"
3156 chmod ugo+x $DIR || error "chmod 0 failed"
3157 set_persistent_param_and_check mds1 \
3158 "mdt.$FSNAME-MDT0000.root_squash" \
3159 "$FSNAME.mdt.root_squash" \
3161 wait_update $HOSTNAME \
3162 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3164 error "check llite root_squash failed!"
3165 set_persistent_param_and_check mds1 \
3166 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3167 "$FSNAME.mdt.nosquash_nids" \
3169 wait_update $HOSTNAME \
3170 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3172 error "check llite nosquash_nids failed!"
3175 # create set of test files
3177 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
3178 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
3179 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
3181 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
3182 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
3184 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
3185 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
3186 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
3188 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
3189 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
3190 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
3193 # check root_squash:
3194 # set root squash UID:GID to RUNAS_ID
3195 # root should be able to access only files owned by RUNAS_ID
3197 set_persistent_param_and_check mds1 \
3198 "mdt.$FSNAME-MDT0000.root_squash" \
3199 "$FSNAME.mdt.root_squash" \
3200 "$RUNAS_ID:$RUNAS_ID"
3201 wait_update $HOSTNAME \
3202 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3203 "$RUNAS_ID:$RUNAS_ID" ||
3204 error "check llite root_squash failed!"
3206 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
3207 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3208 error "$ST: root read permission is denied"
3209 echo "$ST: root read permission is granted - ok"
3212 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3213 error "$ST: root write permission is denied"
3214 echo "$ST: root write permission is granted - ok"
3216 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3217 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3218 error "$ST: root read permission is granted"
3219 echo "$ST: root read permission is denied - ok"
3222 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3223 error "$ST: root write permission is granted"
3224 echo "$ST: root write permission is denied - ok"
3226 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3227 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
3228 error "$ST: root unlink permission is granted"
3229 echo "$ST: root unlink permission is denied - ok"
3231 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
3232 error "$ST: root create permission is granted"
3233 echo "$ST: root create permission is denied - ok"
3236 # check root_squash is enforced independently
3237 # of client cache content
3239 # access file by USER1, keep access open
3240 # root should be denied access to user file
3242 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
3246 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
3247 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3248 { kill $pid; error "$ST: root read permission is granted"; }
3249 echo "$ST: root read permission is denied - ok"
3252 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3253 { kill $pid; error "$ST: root write permission is granted"; }
3254 echo "$ST: root write permission is denied - ok"
3260 # check nosquash_nids:
3261 # put client's NID into nosquash_nids list,
3262 # root should be able to access root file after that
3264 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
3265 NIDLIST="2@gni $NIDLIST 192.168.0.[2,10]@tcp"
3266 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
3267 set_persistent_param_and_check mds1 \
3268 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3269 "$FSNAME-MDTall.mdt.nosquash_nids" \
3271 wait_update $HOSTNAME \
3272 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3274 error "check llite nosquash_nids failed!"
3276 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3277 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3278 error "$ST: root read permission is denied"
3279 echo "$ST: root read permission is granted - ok"
3282 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3283 error "$ST: root write permission is denied"
3284 echo "$ST: root write permission is granted - ok"
3286 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3287 rm $DIR/$tdir-rootdir/tfile-1 ||
3288 error "$ST: root unlink permission is denied"
3289 echo "$ST: root unlink permission is granted - ok"
3290 touch $DIR/$tdir-rootdir/tfile-2 ||
3291 error "$ST: root create permission is denied"
3292 echo "$ST: root create permission is granted - ok"
3293 cleanup || error "cleanup failed with $?"
3295 run_test 43a "check root_squash and nosquash_nids"
3297 test_43b() { # LU-5690
3298 [[ $(lustre_version_code mgs) -ge $(version_code 2.7.62) ]] ||
3299 skip "Need MGS version 2.7.62+"
3301 if [[ -z "$fs2mds_DEV" ]]; then
3302 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
3303 skip_env "mixed loopback and real device not working"
3306 local fs2mdsdev=$(mdsdevname 1_2)
3307 local fs2mdsvdev=$(mdsvdevname 1_2)
3309 # temporarily use fs2mds as fs2mgs
3311 local fs2mgsdev=$fs2mdsdev
3312 local fs2mgsvdev=$fs2mdsvdev
3314 local fsname=test1234
3316 load_module llite/lustre
3317 local client_ip=$(host_nids_address $HOSTNAME $NETTYPE)
3318 local host=${client_ip//*./}
3319 local net=${client_ip/%$host/}
3320 local nosquash_nids=$(h2nettype $net[$host,$host,$host])
3322 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
3323 --param mdt.root_squash=$RUNAS_ID:$RUNAS_ID \
3324 --param mdt.nosquash_nids=$nosquash_nids \
3325 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
3326 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS || error "start fs2mgs failed"
3327 stop $fs2mgs -f || error "stop fs2mgs failed"
3328 cleanup || error "cleanup failed with $?"
3330 run_test 43b "parse nosquash_nids with commas in expr_list"
3334 check_mount || error "check_mount"
3335 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
3337 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
3338 for VAL in $UUIDS; do
3339 NID=$(echo $VAL | cut -d= -f1)
3340 CLUUID=$(echo $VAL | cut -d= -f2)
3341 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
3343 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
3344 cleanup || error "cleanup failed with $?"
3346 run_test 44 "mounted client proc entry exists"
3350 check_mount || error "check_mount"
3351 stop_mds || error "Unable to stop MDS"
3355 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
3356 do_facet client "$LCTL set_param fail_loc=0x8000050f"
3359 manual_umount_client --force || error "manual_umount_client failed"
3360 do_facet client "$LCTL set_param fail_loc=0x0"
3361 start_mds || error "unable to start MDS"
3362 mount_client $MOUNT || error "mount_client $MOUNT failed"
3363 cleanup || error "cleanup failed with $?"
3365 run_test 45 "long unlink handling in ptlrpcd"
3372 umount_client $MOUNT2 || rc=$?
3373 umount_client $MOUNT || rc=$?
3374 while [ $count -gt 0 ]; do
3375 stop ost${count} -f || rc=$?
3379 cleanup_nocli || rc=$?
3380 #writeconf to remove all ost2 traces for subsequent tests
3381 writeconf_or_reformat
3386 echo "Testing with $OSTCOUNT OSTs"
3388 start_mds || error "unable to start MDS"
3389 #first client should see only one ost
3390 start_ost || error "Unable to start OST1"
3391 wait_osc_import_state mds ost FULL
3393 mount_client $MOUNT || error "mount_client $MOUNT failed"
3394 trap "cleanup_46a $OSTCOUNT" EXIT ERR
3397 for (( i=2; i<=$OSTCOUNT; i++ )); do
3398 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
3399 error "start_ost$i $(ostdevname $i) failed"
3402 # wait until osts in sync
3403 for (( i=2; i<=$OSTCOUNT; i++ )); do
3404 wait_osc_import_state mds ost$i FULL
3405 wait_osc_import_ready client ost$i
3408 #second client see all ost's
3410 mount_client $MOUNT2 || error "mount_client failed"
3411 $LFS setstripe -c -1 $MOUNT2 ||
3412 error "$LFS setstripe -c -1 $MOUNT2 failed"
3413 $LFS getstripe $MOUNT2 || error "$LFS getstripe $MOUNT2 failed"
3415 echo "ok" > $MOUNT2/widestripe
3416 $LFS getstripe $MOUNT2/widestripe ||
3417 error "$LFS getstripe $MOUNT2/widestripe failed"
3418 # fill acl buffer for avoid expand lsm to them
3419 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
3421 setfacl -m $acl $MOUNT2/widestripe
3425 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3427 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
3429 run_test 46a "handle ost additional - wide striped file"
3434 check_mount || error "check_mount failed"
3435 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
3439 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3440 if echo $ns | grep "MDT[[:digit:]]*"; then
3443 lrs=$(echo $ns | sed 's/.*lru_size=//')
3444 lru_size[count]=$lrs
3449 facet_failover $SINGLEMDS
3450 client_up || error "client_up failed"
3453 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3454 if echo $ns | grep "MDT[[:digit:]]*"; then
3457 lrs=$(echo $ns | sed 's/.*lru_size=//')
3458 if ! test "$lrs" -eq "${lru_size[count]}"; then
3459 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
3460 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
3465 cleanup || error "cleanup failed with $?"
3467 run_test 47 "server restart does not make client loss lru_resize settings"
3472 # reformat after this test is needed - if the test fails,
3473 # we will have unkillable file at FS
3477 test_48() { # bz-17636 LU-7473
3481 check_mount || error "check_mount failed"
3483 $LFS setstripe -c -1 $MOUNT ||
3484 error "$LFS setstripe -c -1 $MOUNT failed"
3485 $LFS getstripe $MOUNT || error "$LFS getstripe $MOUNT failed"
3487 echo "ok" > $MOUNT/widestripe
3488 $LFS getstripe $MOUNT/widestripe ||
3489 error "$LFS getstripe $MOUNT/widestripe failed"
3491 # In the future, we may introduce more EAs, such as selinux, enlarged
3492 # LOV EA, and so on. These EA will use some EA space that is shared by
3493 # ACL entries. So here we only check some reasonable ACL entries count,
3494 # instead of the max number that is calculated from the max_ea_size.
3495 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.57) ];
3497 count=28 # hard coded of RPC protocol
3498 elif [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3499 count=4000 # max_num 4091 max_ea_size = 32768
3500 elif ! large_xattr_enabled; then
3501 count=450 # max_num 497 max_ea_size = 4012
3503 count=4500 # max_num 8187 max_ea_size = 1048492
3504 # not create too much (>5000) to save test time
3507 echo "It is expected to hold at least $count ACL entries"
3508 trap cleanup_48 EXIT ERR
3509 for ((i = 0; i < $count; i++)) do
3510 setfacl -m u:$((i + 100)):rw $MOUNT/widestripe ||
3511 error "Fail to setfacl for $MOUNT/widestripe at $i"
3514 cancel_lru_locks mdc
3515 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3516 local r_count=$(getfacl $MOUNT/widestripe | grep "user:" | wc -l)
3517 count=$((count + 1)) # for the entry "user::rw-"
3519 [ $count -eq $r_count ] ||
3520 error "Expected ACL entries $count, but got $r_count"
3524 run_test 48 "too many acls on file"
3526 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3527 test_49a() { # bug 17710
3528 local timeout_orig=$TIMEOUT
3529 local ldlm_timeout_orig=$LDLM_TIMEOUT
3530 local LOCAL_TIMEOUT=20
3532 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3533 TIMEOUT=$LOCAL_TIMEOUT
3537 check_mount || error "client mount failed"
3539 echo "check ldlm_timout..."
3540 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3541 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3542 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3544 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3545 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3548 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3549 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3552 umount_client $MOUNT || error "umount_client $MOUNT failed"
3553 stop_ost || error "problem stopping OSS"
3554 stop_mds || error "problem stopping MDS"
3556 LDLM_TIMEOUT=$ldlm_timeout_orig
3557 TIMEOUT=$timeout_orig
3559 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3561 test_49b() { # bug 17710
3562 local timeout_orig=$TIMEOUT
3563 local ldlm_timeout_orig=$LDLM_TIMEOUT
3564 local LOCAL_TIMEOUT=20
3566 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3567 TIMEOUT=$LOCAL_TIMEOUT
3571 check_mount || error "client mount failed"
3573 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3574 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3575 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3577 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3578 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3581 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3582 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3585 cleanup || error "cleanup failed"
3587 LDLM_TIMEOUT=$ldlm_timeout_orig
3588 TIMEOUT=$timeout_orig
3590 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3593 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3595 # Test both statfs and lfs df and fail if either one fails
3596 multiop_bg_pause $1 f_
3599 killall -USR1 multiop
3600 [ $RC -ne 0 ] && log "lazystatfs multiop failed"
3601 wait $PID || { RC=$?; log "multiop return error "; }
3603 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3608 if kill -s 0 $PID; then
3611 log "lazystatfs lfs df failed to complete in 5s"
3619 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3620 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3622 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3624 cleanup || error "cleanup failed with rc $?"
3626 run_test 50a "lazystatfs all servers available"
3630 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3631 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3633 # Wait for client to detect down OST
3634 stop_ost || error "Unable to stop OST1"
3635 wait_osc_import_state client ost DISCONN
3637 log "OSCs should all be DISCONN"
3639 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
3641 umount_client $MOUNT || error "Unable to unmount client"
3642 stop_mds || error "Unable to stop MDS"
3644 run_test 50b "lazystatfs all servers down"
3647 start_mds || error "Unable to start MDS"
3648 start_ost || error "Unable to start OST1"
3649 start_ost2 || error "Unable to start OST2"
3650 mount_client $MOUNT || error "Unable to mount client"
3651 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3652 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3654 # Wait for client to detect down OST
3655 stop_ost || error "Unable to stop OST1"
3656 wait_osc_import_state mds ost DISCONN
3657 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3659 umount_client $MOUNT || error "Unable to unmount client"
3660 stop_ost2 || error "Unable to stop OST2"
3661 stop_mds || error "Unable to stop MDS"
3662 #writeconf to remove all ost2 traces for subsequent tests
3663 writeconf_or_reformat
3665 run_test 50c "lazystatfs one server down"
3668 start_mds || error "Unable to start MDS"
3669 start_ost || error "Unable to start OST1"
3670 start_ost2 || error "Unable to start OST2"
3671 mount_client $MOUNT || error "Unable to mount client"
3672 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3673 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3675 # Issue the statfs during the window where the client still
3676 # belives the OST to be available but it is in fact down.
3677 # No failure just a statfs which hangs for a timeout interval.
3678 stop_ost || error "Unable to stop OST1"
3679 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3681 umount_client $MOUNT || error "Unable to unmount client"
3682 stop_ost2 || error "Unable to stop OST2"
3683 stop_mds || error "Unable to stop MDS"
3684 #writeconf to remove all ost2 traces for subsequent tests
3685 writeconf_or_reformat
3687 run_test 50d "lazystatfs client/server conn race"
3694 start_mds || error "Unable to start MDS"
3695 #first client should see only one ost
3696 start_ost || error "Unable to start OST1"
3697 wait_osc_import_state mds ost FULL
3699 # Wait for client to detect down OST
3700 stop_ost || error "Unable to stop OST1"
3701 wait_osc_import_state mds ost DISCONN
3703 mount_client $MOUNT || error "Unable to mount client"
3704 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3706 multiop_bg_pause $MOUNT _f
3710 if [ $RC1 -ne 0 ]; then
3711 log "multiop failed $RC1"
3714 sleep $(( $TIMEOUT+1 ))
3716 [ $? -ne 0 ] && error "process isn't sleep"
3717 start_ost || error "Unable to start OST1"
3718 wait $pid || error "statfs failed"
3721 umount_client $MOUNT || error "Unable to unmount client"
3722 stop_ost || error "Unable to stop OST1"
3723 stop_mds || error "Unable to stop MDS"
3725 run_test 50e "normal statfs all servers down"
3730 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3732 start_mds || error "Unable to start mds"
3733 #first client should see only one ost
3734 start_ost || error "Unable to start OST1"
3735 wait_osc_import_state mds ost FULL
3737 start_ost2 || error "Unable to start OST2"
3738 wait_osc_import_state mds ost2 FULL
3740 # Wait for client to detect down OST
3741 stop_ost2 || error "Unable to stop OST2"
3743 wait_osc_import_state mds ost2 DISCONN
3744 mount_client $MOUNT || error "Unable to mount client"
3745 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3747 multiop_bg_pause $MOUNT _f
3751 if [ $RC1 -ne 0 ]; then
3752 log "lazystatfs multiop failed $RC1"
3755 sleep $(( $TIMEOUT+1 ))
3757 [ $? -ne 0 ] && error "process isn't sleep"
3758 start_ost2 || error "Unable to start OST2"
3759 wait $pid || error "statfs failed"
3760 stop_ost2 || error "Unable to stop OST2"
3763 umount_client $MOUNT -f || error "Unable to unmount client"
3764 stop_ost || error "Unable to stop OST1"
3765 stop_mds || error "Unable to stop MDS"
3766 #writeconf to remove all ost2 traces for subsequent tests
3767 writeconf_or_reformat
3769 run_test 50f "normal statfs one server in down"
3772 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3774 start_ost2 || error "Unable to start OST2"
3775 wait_osc_import_state mds ost2 FULL
3776 wait_osc_import_ready client ost2
3778 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3779 local PARAM="osc.${FSNAME}-OST0001*.active"
3781 local PARAM="${FSNAME}-OST0001.osc.active"
3784 $LFS setstripe -c -1 $DIR/$tfile || error "$LFS setstripe failed"
3785 do_facet mgs $PERM_CMD $PARAM=0 || error "Unable to deactivate OST"
3787 umount_client $MOUNT || error "Unable to unmount client"
3788 mount_client $MOUNT || error "Unable to mount client"
3789 # This df should not cause a panic
3792 do_facet mgs $PERM_CMD $PARAM=1 || error "Unable to activate OST"
3793 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
3794 umount_client $MOUNT || error "Unable to unmount client"
3795 stop_ost2 || error "Unable to stop OST2"
3796 stop_ost || error "Unable to stop OST1"
3797 stop_mds || error "Unable to stop MDS"
3798 #writeconf to remove all ost2 traces for subsequent tests
3799 writeconf_or_reformat
3801 run_test 50g "deactivated OST should not cause panic"
3805 # prepare MDT/OST, make OSC inactive for OST1
3806 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3808 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3809 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3810 error "tunefs OST1 failed"
3811 start_mds || error "Unable to start MDT"
3812 start_ost || error "Unable to start OST1"
3813 start_ost2 || error "Unable to start OST2"
3814 mount_client $MOUNT || error "client start failed"
3816 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3818 # activatate OSC for OST1
3819 set_persistent_param_and_check client \
3820 "osc.${FSNAME}-OST0000-osc-[!M]*.active" \
3821 "${FSNAME}-OST0000.osc.active" 1
3823 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3824 $LFS setstripe -c -1 -i 0 $DIR/$tdir/2 ||
3825 error "$LFS setstripe $DIR/$tdir/2 failed"
3826 sleep 1 && echo "create a file after OST1 is activated"
3827 # doing some io, shouldn't crash
3828 dd if=/dev/zero of=$DIR/$tdir/2/$tfile-io bs=1M count=10
3830 # check OSC import is working
3831 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3832 error "some OSC imports are still not connected"
3836 umount_client $MOUNT || error "Unable to umount client"
3837 stop_ost2 || error "Unable to stop OST2"
3838 cleanup_nocli || error "cleanup_nocli failed with $?"
3840 run_test 50h "LU-642: activate deactivated OST"
3843 # prepare MDT/OST, make OSC inactive for OST1
3844 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
3847 [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
3848 do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
3849 error "tunefs MDT2 failed"
3850 start_mds || error "Unable to start MDT"
3851 start_ost || error "Unable to start OST1"
3852 start_ost2 || error "Unable to start OST2"
3853 mount_client $MOUNT || error "client start failed"
3855 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3857 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3858 $PERM_CMD mdc.${FSNAME}-MDT0001-mdc-*.active=0 &&
3859 error "deactive MDC0 succeeds"
3861 $PERM_CMD ${FSNAME}-MDT0000.mdc.active=0 &&
3862 error "deactive MDC0 succeeds"
3865 # activate MDC for MDT2
3866 set_persistent_param_and_check client \
3867 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3868 "${FSNAME}-MDT0001.mdc.active" 1
3870 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
3871 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.60) ]
3873 wait_dne_interconnect
3875 $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3877 createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
3879 rm -rf $DIR/$tdir/2 || error "unlink dir failed"
3881 # deactivate MDC for MDT2
3882 set_persistent_param_and_check client \
3883 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3884 "${FSNAME}-MDT0001.mdc.active" 0
3886 wait_osp_active mds ${FSNAME}-MDT0001 1 0
3888 $LFS mkdir -i1 $DIR/$tdir/2 &&
3889 error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
3891 $LFS mkdir -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3892 error "mkdir $DIR/$tdir/striped_dir fails after deactive MDT2"
3894 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3895 [ $stripe_count -eq $((MDSCOUNT - 1)) ] ||
3896 error "wrong $stripe_count != $((MDSCOUNT -1)) for striped_dir"
3899 umount_client $MOUNT || error "Unable to umount client"
3904 run_test 50i "activate deactivated MDT"
3907 local LOCAL_TIMEOUT=20
3911 check_mount || error "check_mount failed"
3913 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3914 $LFS setstripe -c -1 $MOUNT/$tdir ||
3915 error "$LFS setstripe -c -1 $MOUNT/$tdir failed"
3916 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3917 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
3918 touch $MOUNT/$tdir/$tfile &
3921 start_ost2 || error "Unable to start OST1"
3923 stop_ost2 || error "Unable to stop OST1"
3924 umount_client $MOUNT -f || error “unmount $MOUNT failed”
3925 cleanup_nocli || error “stop server failed”
3926 #writeconf to remove all ost2 traces for subsequent tests
3927 writeconf_or_reformat
3929 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
3938 do_node $node mkdir -p $dest
3939 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3941 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
3942 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3943 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
3945 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
3946 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
3956 local backup2=${TMP}/backup2
3958 do_node $node mkdir -p $backup2
3959 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3961 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
3962 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3963 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
3965 do_node $node "diff -rq $backup $backup2"
3966 [ $? -eq 0 ] || { error "contents differ"; return 3; }
3968 local xattrs2=${TMP}/xattrs2
3969 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
3970 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
3972 do_node $node "diff $xattrs $xattrs2"
3973 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
3975 do_node $node "rm -rf $backup2 $xattrs2"
3976 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
3980 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3981 skip "ldiskfs only test"
3984 start_mds || error "Unable to start MDS"
3985 start_ost || error "Unable to start OST1"
3986 mount_client $MOUNT || error "Unable to mount client"
3989 local ost1mnt=$(facet_mntpt ost1)
3990 local ost1node=$(facet_active_host ost1)
3991 local ost1tmp=$TMP/conf52
3994 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
3995 touch $TMP/modified_first || error "Unable to create temporary file"
3996 local mtime=$(stat -c %Y $TMP/modified_first)
3997 do_node $ost1node "mkdir -p $ost1tmp &&
3998 touch -m -d @$mtime $ost1tmp/modified_first" ||
3999 error "Unable to create temporary file"
4002 $LFS setstripe -c -1 -S 1M $DIR/$tdir || error "$LFS setstripe failed"
4004 for (( i=0; i < nrfiles; i++ )); do
4005 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
4006 error "multiop failed"
4011 # sync all the data and make sure no pending data on the client,
4012 # thus the SOM xattr would not be changed any more.
4013 cancel_lru_locks osc
4016 echo backup files to $TMP/$tdir
4017 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
4018 copy_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4019 error "Unable to copy files"
4021 umount_client $MOUNT || error "Unable to umount client"
4022 stop_ost || error "Unable to stop ost1"
4024 echo mount ost1 as ldiskfs
4025 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
4026 if ! do_node $ost1node test -b $ost1_dev; then
4029 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
4031 error "Unable to mount ost1 as ldiskfs"
4034 echo backup objects to $ost1tmp/objects
4035 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
4036 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
4037 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
4039 error "Unable to copy objects"
4041 # move objects to lost+found
4042 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
4043 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
4045 do_node $ost1node "umount $ost1mnt" ||
4046 error "Unable to umount ost1 as ldiskfs"
4048 start_ost || error "Unable to start OST1"
4049 mount_client $MOUNT || error "Unable to mount client"
4051 local REPAIRED=$(do_node $ost1node "$LCTL get_param \
4052 -n osd-ldiskfs.$FSNAME-OST0000.oi_scrub" |
4053 awk '/^lf_repa[ri]*ed/ { print $2 }')
4054 [ $REPAIRED -gt 0 ] ||
4055 error "Some entry under /lost+found should be repaired"
4058 diff_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4059 error "Unable to diff files"
4061 rm -rf $TMP/$tdir $TMP/file_xattrs ||
4062 error "Unable to delete temporary files"
4063 do_node $ost1node "rm -rf $ost1tmp" ||
4064 error "Unable to delete temporary files"
4065 cleanup || error "cleanup failed with $?"
4067 run_test 52 "check recovering objects from lost+found"
4069 # Checks threads_min/max/started for some service
4071 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
4072 # parameter pattern prefix like 'ost.*.ost'.
4085 local msg="Insane $modname thread counts"
4086 local ncpts=$(check_cpt_number $facet)
4090 check_mount || return 41
4092 # We need to expand $parampat, but it may match multiple parameters, so
4093 # we'll pick the first one
4094 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
4095 error "Couldn't expand ${parampat}.threads_min parameter name"
4099 # Remove the .threads_min part
4100 paramp=${paramp%.threads_min}
4102 # Check for sanity in defaults
4103 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4105 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4107 tstarted=$(do_facet $facet "$LCTL get_param \
4108 -n ${paramp}.threads_started" || echo 0)
4109 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
4111 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4113 nthrs=$(expr $tmax - $tmin)
4114 if [ $nthrs -lt $ncpts ]; then
4120 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
4121 skip_env "module parameter forced $facet thread count"
4123 # Check that we can change min/max
4124 do_facet $facet "$LCTL set_param \
4125 ${paramp}.threads_min=$((tmin + nthrs))"
4126 do_facet $facet "$LCTL set_param \
4127 ${paramp}.threads_max=$((tmax - nthrs))"
4128 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4130 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4132 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
4133 $tmax2 == ($tmax - $nthrs)))' || return $?
4135 # Check that we can set min/max to the same value
4136 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4138 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
4139 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4141 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4143 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
4145 # Check that we can't set max < min
4146 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
4147 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4149 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4151 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
4153 # We need to ensure that we get the module options desired; to do this
4154 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
4155 LOAD_MODULES_REMOTE=true
4158 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
4159 setmodopts -a $modname "$newvalue" oldvalue
4162 check_mount || return 41
4164 # Restore previous setting of MODOPTS_*
4165 setmodopts $modname "$oldvalue"
4167 # Check that $opts took
4168 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4170 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4172 tstarted=$(do_facet $facet \
4173 "$LCTL get_param -n ${paramp}.threads_started" || echo 0)
4174 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4183 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
4184 cleanup || error "cleanup failed with rc $?"
4186 run_test 53a "check OSS thread count params"
4190 local mds=$(do_facet $SINGLEMDS "$LCTL get_param \
4191 -N mds.*.*.threads_max 2>/dev/null")
4192 if [ -z "$mds" ]; then
4193 #running this on an old MDT
4194 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
4196 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
4198 cleanup || error "cleanup failed with $?"
4200 run_test 53b "check MDS thread count params"
4203 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4204 skip "ldiskfs only test"
4207 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
4208 error "llverdev failed with rc=$?"
4211 run_test 54a "test llverdev and partial verify of device"
4214 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4215 skip "ldiskfs only test"
4219 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
4220 cleanup || error "cleanup failed with rc=$?"
4222 run_test 54b "test llverfs and partial verify of filesystem"
4226 local max_ost_index=$1
4227 echo -n $(((max_ost_index + 1) * 8))
4231 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4232 skip "ldiskfs only test"
4235 local mdsdev=$(mdsdevname 1)
4236 local mdsvdev=$(mdsvdevname 1)
4240 if ! combined_mgs_mds; then
4241 stop_mgs || error "stopping MGS service failed"
4242 format_mgs || error "formatting MGT failed"
4244 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
4246 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
4247 --reformat $(ostdevname 1) $(ostvdevname 1)
4253 echo checking size of lov_objid for ost index $i
4254 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" |
4255 grep ^User | awk -F 'Size: ' '{print $2}')
4256 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
4257 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
4259 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
4266 run_test 55 "check lov_objid size"
4269 local server_version=$(lustre_version_code $SINGLEMDS)
4270 local mds_journal_size_orig=$MDSJOURNALSIZE
4276 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
4277 $(ostdevname 1) $(ostvdevname 1)
4278 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
4279 $(ostdevname 2) $(ostvdevname 2)
4282 start_ost || error "Unable to start first ost (idx 10000)"
4283 start_ost2 || error "Unable to start second ost (idx 1000)"
4284 mount_client $MOUNT || error "Unable to mount client"
4288 if [[ $server_version -ge $(version_code 2.6.54) ]] ||
4289 [[ $server_version -ge $(version_code 2.5.4) &&
4290 $server_version -lt $(version_code 2.5.11) ]]; then
4291 wait_osc_import_state mds ost1 FULL
4292 wait_osc_import_state mds ost2 FULL
4293 $LFS setstripe --stripe-count=-1 $DIR/$tfile ||
4294 error "Unable to setstripe $DIR/$tfile"
4295 n=$($LFS getstripe --stripe-count $DIR/$tfile)
4296 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
4301 MDSJOURNALSIZE=$mds_journal_size_orig
4304 run_test 56a "check big OST indexes and out-of-index-order start"
4309 umount_client $MOUNT -f || error "unmount client failed"
4318 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
4320 trap cleanup_56b EXIT RETURN ERR
4323 if ! combined_mgs_mds ; then
4328 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) --index=0 --reformat \
4329 $(mdsdevname 1) $(mdsvdevname 1)
4330 add mds2 $(mkfs_opts mds2 $(mdsdevname 2)) --index=1 --reformat \
4331 $(mdsdevname 2) $(mdsvdevname 2)
4332 add mds3 $(mkfs_opts mds3 $(mdsdevname 3)) --index=1000 --reformat \
4333 $(mdsdevname 3) $(mdsvdevname 3)
4337 start_mdt 1 || error "MDT 1 (idx 0) start failed"
4338 start_mdt 2 || error "MDT 2 (idx 1) start failed"
4339 start_mdt 3 || error "MDT 3 (idx 1000) start failed"
4340 start_ost || error "Unable to start first ost"
4341 start_ost2 || error "Unable to start second ost"
4343 do_nodes $(comma_list $(mdts_nodes)) \
4344 "$LCTL set_param mdt.*.enable_remote_dir=1 \
4345 mdt.*.enable_remote_dir_gid=-1"
4347 mount_client $MOUNT || error "Unable to mount client"
4349 $LFS mkdir -c3 $MOUNT/$tdir || error "failed to make testdir"
4351 echo "This is test file 1!" > $MOUNT/$tdir/$tfile.1 ||
4352 error "failed to make test file 1"
4353 echo "This is test file 2!" > $MOUNT/$tdir/$tfile.2 ||
4354 error "failed to make test file 2"
4355 echo "This is test file 1000!" > $MOUNT/$tdir/$tfile.1000 ||
4356 error "failed to make test file 1000"
4358 rm -rf $MOUNT/$tdir || error "failed to remove testdir"
4360 $LFS mkdir -i1000 $MOUNT/$tdir.1000 ||
4361 error "create remote dir at idx 1000 failed"
4364 echo "=== START lfs df OUTPUT ==="
4366 echo "==== END lfs df OUTPUT ===="
4368 mdtcnt=$(echo -e "$output" | grep $FSNAME-MDT | wc -l)
4369 ostcnt=$(echo -e "$output" | grep $FSNAME-OST | wc -l)
4371 echo "lfs df returned mdt count $mdtcnt and ost count $ostcnt"
4372 [ $mdtcnt -eq 3 ] || error "lfs df returned wrong mdt count"
4373 [ $ostcnt -eq 2 ] || error "lfs df returned wrong ost count"
4375 echo "This is test file 1!" > $MOUNT/$tdir.1000/$tfile.1 ||
4376 error "failed to make test file 1"
4377 echo "This is test file 2!" > $MOUNT/$tdir.1000/$tfile.2 ||
4378 error "failed to make test file 2"
4379 echo "This is test file 1000!" > $MOUNT/$tdir.1000/$tfile.1000 ||
4380 error "failed to make test file 1000"
4381 rm -rf $MOUNT/$tdir.1000 || error "failed to remove remote_dir"
4384 echo "=== START lfs mdts OUTPUT ==="
4386 echo "==== END lfs mdts OUTPUT ===="
4388 echo -e "$output" | grep -v "MDTS:" | awk '{print $1}' |
4389 sed 's/://g' > $TMP/mdts-actual.txt
4390 sort $TMP/mdts-actual.txt -o $TMP/mdts-actual.txt
4392 echo -e "0\n1\n1000" > $TMP/mdts-expected.txt
4394 diff $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4397 rm $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4399 [ $result -eq 0 ] || error "target_obd proc file is incorrect!"
4401 run_test 56b "test target_obd correctness with nonconsecutive MDTs"
4403 test_57a() { # bug 22656
4404 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4405 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4406 tail -1 | awk '{print $1}')
4407 writeconf_or_reformat
4408 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4409 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
4410 error "tunefs failed"
4412 start_ost && error "OST registration from failnode should fail"
4415 run_test 57a "initial registration from failnode should fail (should return errs)"
4418 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4419 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4420 tail -1 | awk '{print $1}')
4421 writeconf_or_reformat
4422 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4423 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
4424 error "tunefs failed"
4426 start_ost || error "OST registration from servicenode should not fail"
4429 run_test 57b "initial registration from servicenode should not fail"
4432 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
4435 test_58() { # bug 22658
4436 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
4438 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4439 createmany -o $DIR/$tdir/$tfile-%d 100
4440 unlinkmany $DIR/$tdir/$tfile-%d 100
4441 stop_mds || error "Unable to stop MDS"
4443 local MNTDIR=$(facet_mntpt $SINGLEMDS)
4444 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4446 # remove all files from the OBJECTS dir
4447 mount_fstype $SINGLEMDS
4449 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
4451 unmount_fstype $SINGLEMDS
4452 # restart MDS with missing llog files
4453 start_mds || error "unable to start MDS"
4454 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
4457 run_test 58 "missing llog files must not prevent MDT from mounting"
4460 start_mgsmds >> /dev/null
4461 local C1=$(count_osts)
4462 if [ $C1 -eq 0 ]; then
4463 start_ost >> /dev/null
4467 echo "original ost count: $C1 (expect > 0)"
4468 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
4469 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
4470 local C2=$(count_osts)
4471 echo "after mdt writeconf count: $C2 (expect 0)"
4472 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
4473 echo "OST start without writeconf should fail:"
4474 start_ost >> /dev/null &&
4475 error "OST start without writeconf didn't fail"
4476 echo "OST start with writeconf should succeed:"
4477 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
4478 local C3=$(count_osts)
4479 echo "after ost writeconf count: $C3 (expect 1)"
4480 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
4481 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
4482 local C4=$(count_osts)
4483 echo "after ost2 writeconf count: $C4 (expect 2)"
4484 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
4485 stop_ost2 >> /dev/null
4486 cleanup_nocli >> /dev/null
4487 #writeconf to remove all ost2 traces for subsequent tests
4488 writeconf_or_reformat
4490 run_test 59 "writeconf mount option"
4492 test_60() { # LU-471
4493 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4494 skip "ldiskfs only test"
4499 for num in $(seq $MDSCOUNT); do
4500 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
4501 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
4502 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4506 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
4507 [ ${PIPESTATUS[0]} -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
4509 # MDT default has dirdata feature
4510 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
4511 # we disable uninit_bg feature
4512 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
4513 # we set stride extended options
4514 echo $dump | grep stride > /dev/null || error "stride is not set"
4517 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
4522 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
4523 skip "Need MDS version at least 2.1.53"
4525 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
4526 ! large_xattr_enabled; then
4529 for num in $(seq $MDSCOUNT); do
4530 do_facet mds${num} $TUNE2FS -O ea_inode \
4531 $(mdsdevname $num) ||
4532 error "tune2fs on mds $num failed"
4536 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
4537 setup_noconfig || error "setting up the filesystem failed"
4538 client_up || error "starting client failed"
4540 local file=$DIR/$tfile
4541 touch $file || error "touch $file failed"
4543 local large_value="$(generate_string $(max_xattr_size))"
4544 local small_value="bar"
4546 local name="trusted.big"
4547 log "save large xattr $name on $file"
4548 setfattr -n $name -v $large_value $file ||
4549 error "saving $name on $file failed"
4551 local new_value=$(get_xattr_value $name $file)
4552 [[ "$new_value" != "$large_value" ]] &&
4553 error "$name different after saving"
4555 log "shrink value of $name on $file"
4556 setfattr -n $name -v $small_value $file ||
4557 error "shrinking value of $name on $file failed"
4559 new_value=$(get_xattr_value $name $file)
4560 [[ "$new_value" != "$small_value" ]] &&
4561 error "$name different after shrinking"
4563 log "grow value of $name on $file"
4564 setfattr -n $name -v $large_value $file ||
4565 error "growing value of $name on $file failed"
4567 new_value=$(get_xattr_value $name $file)
4568 [[ "$new_value" != "$large_value" ]] &&
4569 error "$name different after growing"
4571 log "check value of $name on $file after remounting MDS"
4573 new_value=$(get_xattr_value $name $file)
4574 [[ "$new_value" != "$large_value" ]] &&
4575 error "$name different after remounting MDS"
4577 log "remove large xattr $name from $file"
4578 setfattr -x $name $file || error "removing $name from $file failed"
4581 stopall || error "stopping for e2fsck run"
4582 for num in $(seq $MDSCOUNT); do
4583 run_e2fsck $(facet_active_host mds$num) \
4584 $(mdsdevname $num) "-y" ||
4585 error "e2fsck MDT$num failed"
4587 setup_noconfig || error "remounting the filesystem failed"
4590 # need to delete this file to avoid problems in other tests
4592 stopall || error "stopping systems failed"
4594 run_test 61 "large xattr"
4597 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4598 skip "ldiskfs only test"
4600 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
4601 skip "Need MDS version at least 2.2.51"
4604 local mdsdev=$(mdsdevname 1)
4605 local ostdev=$(ostdevname 1)
4607 echo "disable journal for mds"
4608 do_facet mds1 $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
4609 start_mds && error "MDT start should fail"
4610 echo "disable journal for ost"
4611 do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
4612 start_ost && error "OST start should fail"
4613 cleanup || error "cleanup failed with rc $?"
4616 run_test 62 "start with disabled journal"
4619 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4620 skip "ldiskfs only test"
4623 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ldiskfs
4624 local inode_slab=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4625 awk '/ldiskfs_inode_cache/ { print $5 / $6 }')
4626 if [ -z "$inode_slab" ]; then
4627 skip "ldiskfs module has not been loaded"
4630 echo "$inode_slab ldiskfs inodes per page"
4631 [ "${inode_slab%.*}" -ge "3" ] && return 0
4633 # If kmalloc-128 is also 1 per page - this is a debug kernel
4634 # and so this is not an error.
4635 local kmalloc128=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4636 awk '/^(kmalloc|size)-128 / { print $5 / $6 }')
4637 # 32 128-byte chunks in 4k
4638 [ "${kmalloc128%.*}" -lt "32" ] ||
4639 error "ldiskfs inode too big, only $inode_slab objs/page, " \
4640 "kmalloc128 = $kmalloc128 objs/page"
4642 run_test 63 "Verify each page can at least hold 3 ldiskfs inodes"
4645 start_mds || error "unable to start MDS"
4646 start_ost || error "Unable to start OST1"
4647 start_ost2 || error "Unable to start second ost"
4648 mount_client $MOUNT || error "Unable to mount client"
4649 stop_ost2 || error "Unable to stop second ost"
4652 umount_client $MOUNT -f || error “unmount $MOUNT failed”
4653 cleanup_nocli || error "cleanup_nocli failed with $?"
4654 #writeconf to remove all ost2 traces for subsequent tests
4655 writeconf_or_reformat
4657 run_test 64 "check lfs df --lazy "
4659 test_65() { # LU-2237
4660 # Currently, the test is only valid for ldiskfs backend
4661 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
4662 skip "ldiskfs only test"
4664 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4665 local brpt=$(facet_mntpt brpt)
4668 if ! do_facet $SINGLEMDS "test -b $devname"; then
4672 stop_mds || error "Unable to stop MDS"
4673 local obj=$(do_facet $SINGLEMDS \
4674 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
4676 if [ -z "$obj" ]; then
4677 # The MDT may be just re-formatted, mount the MDT for the
4678 # first time to guarantee the "last_rcvd" file is there.
4679 start_mds || error "fail to mount the MDS for the first time"
4680 stop_mds || error "Unable to stop MDS"
4683 # remove the "last_rcvd" file
4684 do_facet $SINGLEMDS "mkdir -p $brpt"
4685 do_facet $SINGLEMDS \
4686 "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
4687 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
4688 do_facet $SINGLEMDS "$UMOUNT $brpt"
4690 # restart MDS, the "last_rcvd" file should be recreated.
4691 start_mds || error "fail to restart the MDS"
4692 stop_mds || error "Unable to stop MDS"
4693 obj=$(do_facet $SINGLEMDS \
4694 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
4695 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
4697 run_test 65 "re-create the lost last_rcvd file when server mount"
4700 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
4701 skip "Need MGS version at least 2.3.59"
4704 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
4705 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
4707 # add EXCLUDE records to config log, they are not to be
4708 # removed by lctl replace_nids
4709 set_conf_param_and_check mds \
4710 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4711 "$FSNAME-OST0000.osc.active" \
4714 echo "replace_nids should fail if MDS, OSTs and clients are UP"
4715 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4716 error "replace_nids fail"
4718 umount_client $MOUNT || error "unmounting client failed"
4719 echo "replace_nids should fail if MDS and OSTs are UP"
4720 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4721 error "replace_nids fail"
4723 stop_ost || error "Unable to stop OST1"
4724 echo "replace_nids should fail if MDS is UP"
4725 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4726 error "replace_nids fail"
4728 stop_mds || error "stopping mds failed"
4730 if combined_mgs_mds; then
4731 start_mdt 1 "-o nosvc" ||
4732 error "starting mds with nosvc option failed"
4735 echo "command should accept two parameters"
4736 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
4737 error "command should accept two params"
4739 echo "correct device name should be passed"
4740 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
4741 error "wrong devname"
4743 echo "wrong nids list should not destroy the system"
4744 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
4746 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "asdfasdf, asdfadf" &&
4749 echo "replace OST nid"
4750 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
4751 error "replace nids failed"
4753 echo "command should accept two parameters"
4754 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
4755 error "command should accept two params"
4757 echo "wrong nids list should not destroy the system"
4758 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
4761 local FAKE_NIDS="192.168.0.112@tcp1,192.168.0.112@tcp2"
4762 local FAKE_FAILOVER="192.168.0.113@tcp1,192.168.0.113@tcp2"
4763 local NIDS_AND_FAILOVER="$MDS_NID,$FAKE_NIDS:$FAKE_FAILOVER"
4764 echo "set NIDs with failover"
4765 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $NIDS_AND_FAILOVER ||
4766 error "replace nids failed"
4769 echo "replace MDS nid"
4770 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
4771 error "replace nids failed"
4773 if ! combined_mgs_mds ; then
4776 stop_mds || error "Unable to stop MDS"
4779 start_mgsmds || error "start mgsmds failed"
4780 set_conf_param_and_check mds \
4781 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4782 "$FSNAME-OST0000.osc.active" \
4784 start_ost || error "unable to start OST"
4785 mount_client $MOUNT || error "mount client failed"
4787 check_mount || error "error after nid replace"
4788 cleanup || error "cleanup failed"
4791 run_test 66 "replace nids"
4793 test_67() { #LU-2950
4794 local legacy="$TMP/legacy_lnet_config"
4795 local new="$TMP/new_routes_test"
4796 local out="$TMP/config_out_file"
4797 local verify="$TMP/conv_verify"
4798 local verify_conf="$TMP/conf_verify"
4800 # Create the legacy file that will be run through the
4801 # lustre_routes_conversion script
4802 cat <<- LEGACY_LNET_CONFIG > $legacy
4803 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
4804 tcp2 54 10.1.3.2@tcp;
4805 tcp3 10.3.4.3@tcp:3;
4809 # Create the verification file to verify the output of
4810 # lustre_routes_conversion script against.
4811 cat <<- VERIFY_LNET_CONFIG > $verify
4812 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
4813 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
4814 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
4815 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
4816 tcp4: { gateway: 10.3.3.4@tcp }
4819 # Create the verification file to verify the output of
4820 # lustre_routes_config script against
4821 cat <<- VERIFY_LNET_CONFIG > $verify_conf
4822 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
4823 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
4824 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
4825 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
4826 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
4829 $LUSTRE_ROUTES_CONVERSION $legacy $new > /dev/null
4830 if [ -f $new ]; then
4831 # verify the conversion output
4832 cmp -s $new $verify > /dev/null
4833 if [ $? -eq 1 ]; then
4834 error "routes conversion failed"
4837 lustre_routes_config --dry-run --verbose $new > $out
4838 # check that the script succeeded
4839 cmp -s $out $verify_conf > /dev/null
4840 if [ $? -eq 1 ]; then
4841 error "routes config failed"
4844 error "routes conversion test failed"
4846 # remove generated files
4847 rm -f $new $legacy $verify $verify_conf $out
4849 run_test 67 "test routes conversion and configuration"
4857 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.53) ] ||
4858 skip "Need MDS version at least 2.4.53"
4860 umount_client $MOUNT || error "umount client failed"
4862 if ! combined_mgs_mds; then
4863 start_mgs || error "start mgs failed"
4866 start_mdt 1 || error "MDT start failed"
4867 start_ost || error "Unable to start OST1"
4869 # START-END - the sequences we'll be reserving
4870 START=$(do_facet $SINGLEMDS \
4871 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4872 END=$((START + (1 << 30)))
4873 do_facet $SINGLEMDS \
4874 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4876 # reset the sequences MDT0000 has already assigned
4877 do_facet $SINGLEMDS \
4878 $LCTL set_param seq.srv*MDT0000.space=clear
4880 # remount to let the client allocate new sequence
4881 mount_client $MOUNT || error "mount client failed"
4883 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4884 do_facet $SINGLEMDS \
4885 $LCTL get_param seq.srv*MDT0000.space
4886 $LFS path2fid $DIR/$tfile
4888 local old_ifs="$IFS"
4890 fid=($($LFS path2fid $DIR/$tfile))
4894 if [[ $seq < $END ]]; then
4895 error "used reserved sequence $seq?"
4897 cleanup || error "cleanup failed with $?"
4899 run_test 68 "be able to reserve specific sequences in FLDB"
4901 # Test 69: is about the total number of objects ever created on an OST.
4902 # so that when it is reformatted the normal MDS->OST orphan recovery won't
4903 # just "precreate" the missing objects. In the past it might try to recreate
4904 # millions of objects after an OST was reformatted
4906 local server_version=$(lustre_version_code $SINGLEMDS)
4908 [[ $server_version -lt $(version_code 2.4.2) ]] &&
4909 skip "Need MDS version at least 2.4.2"
4911 [[ $server_version -ge $(version_code 2.4.50) ]] &&
4912 [[ $server_version -lt $(version_code 2.5.0) ]] &&
4913 skip "Need MDS version at least 2.5.0"
4916 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4918 # use OST0000 since it probably has the most creations
4919 local OSTNAME=$(ostname_from_index 0)
4920 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4921 local last_id=$(do_facet mds1 $LCTL get_param -n \
4922 osc.$mdtosc_proc1.prealloc_last_id)
4924 # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
4925 # verify that the LAST_ID recovery is working properly. If
4926 # not, then the OST will refuse to allow the MDS connect
4927 # because the LAST_ID value is too different from the MDS
4928 #define OST_MAX_PRECREATE=20000
4929 local ost_max_pre=20000
4930 local num_create=$(( ost_max_pre * 5 + 1 - last_id))
4932 # If the LAST_ID is already over 5 * OST_MAX_PRECREATE, we don't
4933 # need to create any files. So, skip this section.
4934 if [ $num_create -gt 0 ]; then
4935 # Check the number of inodes available on OST0
4937 local ifree=$($LFS df -i $MOUNT | awk '/OST0000/ { print $4 }')
4938 log "On OST0, $ifree inodes available. Want $num_create."
4940 $LFS setstripe -i 0 $DIR/$tdir ||
4941 error "$LFS setstripe -i 0 $DIR/$tdir failed"
4942 if [ $ifree -lt 10000 ]; then
4943 files=$(( ifree - 50 ))
4948 local j=$((num_create / files + 1))
4949 for i in $(seq 1 $j); do
4950 createmany -o $DIR/$tdir/$tfile-$i- $files ||
4951 error "createmany fail create $files files: $?"
4952 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
4953 error "unlinkmany failed unlink $files files"
4957 # delete all of the files with objects on OST0 so the
4958 # filesystem is not inconsistent later on
4959 $LFS find $MOUNT --ost 0 -print0 | xargs -0 rm
4961 umount_client $MOUNT || error "umount client failed"
4962 stop_ost || error "OST0 stop failure"
4963 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
4964 $(ostdevname 1) $(ostvdevname 1) ||
4965 error "reformat and replace $ostdev failed"
4966 start_ost || error "OST0 restart failure"
4967 wait_osc_import_state mds ost FULL
4969 mount_client $MOUNT || error "mount client failed"
4970 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
4971 local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
4972 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
4974 local iused=$($LFS df -i $MOUNT | awk '/OST0000/ { print $3 }')
4975 log "On OST0, $iused used inodes"
4976 [ $iused -ge $((ost_max_pre/2 + 1000)) ] &&
4977 error "OST replacement created too many inodes; $iused"
4978 cleanup || error "cleanup failed with $?"
4980 run_test 69 "replace an OST with the same index"
4983 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
4986 cleanup || error "cleanup failed with $?"
4988 start_mdt 1 || error "MDT0 start fail"
4990 start_ost || error "OST0 start fail"
4991 for num in $(seq 2 $MDSCOUNT); do
4992 start_mdt $num || return
4995 mount_client $MOUNT || error "mount client fails"
4997 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
4999 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5000 error "create remote dir fail"
5002 rm -rf $DIR/$tdir || error "delete dir fail"
5003 cleanup || error "cleanup failed with $?"
5005 run_test 70a "start MDT0, then OST, then MDT1"
5008 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5011 start_ost || error "OST0 start fail"
5013 start_mds || error "MDS start fail"
5015 mount_client $MOUNT || error "mount client fails"
5017 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5019 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5020 error "create remote dir fail"
5022 rm -rf $DIR/$tdir || error "delete dir fail"
5024 cleanup || error "cleanup failed with $?"
5026 run_test 70b "start OST, MDT1, MDT0"
5029 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5032 start_mds || error "MDS start fail"
5033 start_ost || error "OST0 start fail"
5035 mount_client $MOUNT || error "mount client fails"
5036 stop_mdt 1 || error "MDT1 start fail"
5038 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
5039 echo "deactivate $mdc_for_mdt1"
5040 $LCTL --device $mdc_for_mdt1 deactivate ||
5041 error "set $mdc_for_mdt1 deactivate failed"
5043 mkdir $DIR/$tdir && error "mkdir succeed"
5045 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5046 error "create remote dir succeed"
5048 cleanup || error "cleanup failed with $?"
5050 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
5053 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5056 start_mds || error "MDS start fail"
5057 start_ost || error "OST0 start fail"
5059 mount_client $MOUNT || error "mount client fails"
5061 stop_mdt 2 || error "MDT1 start fail"
5063 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
5065 echo "deactivate $mdc_for_mdt2"
5066 $LCTL --device $mdc_for_mdt2 deactivate ||
5067 error "set $mdc_for_mdt2 deactivate failed"
5069 mkdir $DIR/$tdir || error "mkdir fail"
5070 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5071 error "create remote dir succeed"
5073 rm -rf $DIR/$tdir || error "delete dir fail"
5075 cleanup || error "cleanup failed with $?"
5077 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
5080 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5082 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.62) ] ||
5083 skip "Need MDS version at least 2.7.62"
5085 cleanup || error "cleanup failed with $?"
5087 local mdsdev=$(mdsdevname 1)
5088 local ostdev=$(ostdevname 1)
5089 local mdsvdev=$(mdsvdevname 1)
5090 local ostvdev=$(ostvdevname 1)
5091 local opts_mds="$(mkfs_opts mds1 $mdsdev) --reformat $mdsdev $mdsvdev"
5092 local opts_ost="$(mkfs_opts ost1 $ostdev) --reformat $ostdev $ostvdev"
5094 add mds1 $opts_mds || error "add mds1 failed"
5095 start_mdt 1 || error "start mdt1 failed"
5096 add ost1 $opts_ost || error "add ost1 failed"
5097 start_ost || error "start ost failed"
5098 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
5100 local soc=$(do_facet mds1 "$LCTL get_param -n \
5101 mdt.*MDT0000.sync_lock_cancel")
5102 [ $soc == "never" ] || error "SoC enabled on single MDS"
5104 for i in $(seq 2 $MDSCOUNT); do
5105 mdsdev=$(mdsdevname $i)
5106 mdsvdev=$(mdsvdevname $i)
5107 opts_mds="$(mkfs_opts mds$i $mdsdev) --reformat $mdsdev \
5109 add mds$i $opts_mds || error "add mds$i failed"
5110 start_mdt $i || error "start mdt$i fail"
5113 wait_dne_interconnect
5115 for i in $(seq $MDSCOUNT); do
5116 soc=$(do_facet mds$i "$LCTL get_param -n \
5117 mdt.*MDT000$((i - 1)).sync_lock_cancel")
5118 [ $soc == "blocking" ] || error "SoC not enabled on DNE"
5121 for i in $(seq 2 $MDSCOUNT); do
5122 stop_mdt $i || error "stop mdt$i fail"
5124 soc=$(do_facet mds1 "$LCTL get_param -n \
5125 mdt.*MDT0000.sync_lock_cancel")
5126 [ $soc == "never" ] || error "SoC enabled on single MDS"
5127 umount_client $MOUNT -f > /dev/null
5129 cleanup || error "cleanup failed with $?"
5131 run_test 70e "Sync-on-Cancel will be enabled by default on DNE"
5134 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5135 if combined_mgs_mds; then
5136 skip "needs separate MGS/MDT"
5140 start_mdt 1 || error "MDT0 start fail"
5141 start_ost || error "OST0 start fail"
5142 for num in $(seq 2 $MDSCOUNT); do
5143 start_mdt $num || return
5146 start_ost2 || error "OST1 start fail"
5148 mount_client $MOUNT || error "mount client fails"
5150 mkdir $DIR/$tdir || error "mkdir fail"
5151 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5152 error "create remote dir succeed"
5154 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5155 rm -rf $DIR/$tdir || error "delete dir fail"
5157 umount_client $MOUNT || error "umount_client failed"
5158 stop_mds || error "MDS stop fail"
5159 stop_ost || error "OST0 stop fail"
5160 stop_ost2 || error "OST1 stop fail"
5162 run_test 71a "start MDT0 OST0, MDT1, OST1"
5165 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5166 if combined_mgs_mds; then
5167 skip "needs separate MGS/MDT"
5171 for num in $(seq 2 $MDSCOUNT); do
5172 start_mdt $num || return
5174 start_ost || error "OST0 start fail"
5175 start_mdt 1 || error "MDT0 start fail"
5176 start_ost2 || error "OST1 start fail"
5178 mount_client $MOUNT || error "mount client fails"
5180 mkdir $DIR/$tdir || error "mkdir fail"
5181 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5182 error "create remote dir succeed"
5184 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5185 rm -rf $DIR/$tdir || error "delete dir fail"
5187 umount_client $MOUNT || error "umount_client failed"
5188 stop_mds || error "MDT0 stop fail"
5189 stop_ost || error "OST0 stop fail"
5190 stop_ost2 || error "OST1 stop fail"
5192 run_test 71b "start MDT1, OST0, MDT0, OST1"
5195 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5196 combined_mgs_mds && skip "needs separate MGS/MDT"
5200 start_ost || error "OST0 start fail"
5201 start_ost2 || error "OST1 start fail"
5202 for num in $(seq 2 $MDSCOUNT); do
5203 start_mdt $num || return
5205 start_mdt 1 || error "MDT0 start fail"
5207 mount_client $MOUNT || error "mount client fails"
5209 mkdir $DIR/$tdir || error "mkdir fail"
5210 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5211 error "create remote dir succeed"
5213 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5214 rm -rf $DIR/$tdir || error "delete dir fail"
5216 umount_client $MOUNT || error "umount_client failed"
5217 stop_mds || error "MDS stop fail"
5218 stop_ost || error "OST0 stop fail"
5219 stop_ost2 || error "OST1 stop fail"
5222 run_test 71c "start OST0, OST1, MDT1, MDT0"
5225 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5226 combined_mgs_mds && skip "needs separate MGS/MDT"
5230 start_ost || error "OST0 start fail"
5231 for num in $(seq 2 $MDSCOUNT); do
5232 start_mdt $num || return
5234 start_mdt 1 || error "MDT0 start fail"
5235 start_ost2 || error "OST1 start fail"
5237 mount_client $MOUNT || error "mount client fails"
5239 mkdir $DIR/$tdir || error "mkdir fail"
5240 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5241 error "create remote dir succeed"
5243 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5244 rm -rf $DIR/$tdir || error "delete dir fail"
5246 umount_client $MOUNT || error "umount_client failed"
5247 stop_mds || error "MDS stop fail"
5248 stop_ost || error "OST0 stop fail"
5249 stop_ost2 || error "OST1 stop fail"
5252 run_test 71d "start OST0, MDT1, MDT0, OST1"
5255 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5256 combined_mgs_mds && skip "needs separate MGS/MDT"
5260 start_ost || error "OST0 start fail"
5261 for num in $(seq 2 $MDSCOUNT); do
5262 start_mdt $num || return
5264 start_ost2 || error "OST1 start fail"
5265 start_mdt 1 || error "MDT0 start fail"
5267 mount_client $MOUNT || error "mount client fails"
5269 mkdir $DIR/$tdir || error "mkdir fail"
5270 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5271 error "create remote dir succeed"
5273 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5274 rm -rf $DIR/$tdir || error "delete dir fail"
5276 umount_client $MOUNT || error "umount_client failed"
5277 stop_mds || error "MDS stop fail"
5278 stop_ost || error "OST0 stop fail"
5279 stop_ost2 || error "OST1 stop fail"
5282 run_test 71e "start OST0, MDT1, OST1, MDT0"
5284 test_72() { #LU-2634
5285 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
5286 skip "ldiskfs only test"
5288 local mdsdev=$(mdsdevname 1)
5289 local ostdev=$(ostdevname 1)
5290 local cmd="$E2FSCK -fnvd $mdsdev"
5294 if combined_mgs_mds; then
5295 add_options='--reformat'
5297 add_options='--reformat --replace'
5300 #tune MDT with "-O extents"
5302 for num in $(seq $MDSCOUNT); do
5303 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
5304 $add_options $(mdsdevname $num) $(mdsvdevname $num) ||
5305 error "add mds $num failed"
5306 do_facet mds${num} "$TUNE2FS -O extents $(mdsdevname $num)" ||
5307 error "$TUNE2FS failed on mds${num}"
5310 add ost1 $(mkfs_opts ost1 $ostdev) $add_options $ostdev ||
5311 error "add $ostdev failed"
5312 start_mds || error "start mds failed"
5313 start_ost || error "start ost failed"
5314 mount_client $MOUNT || error "mount client failed"
5316 #create some short symlinks
5317 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5318 createmany -o $DIR/$tdir/$tfile-%d $fn
5319 echo "create $fn short symlinks"
5320 for i in $(seq -w 1 $fn); do
5321 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
5326 umount_client $MOUNT || error "umount client failed"
5327 stop_mds || error "stop mds failed"
5328 stop_ost || error "stop ost failed"
5331 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
5333 run_test 72 "test fast symlink with extents flag enabled"
5335 test_73() { #LU-3006
5336 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
5337 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
5338 error "1st tunefs failed"
5339 start_mgsmds || error "start mds failed"
5340 start_ost || error "start ost failed"
5341 mount_client $MOUNT || error "mount client failed"
5342 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
5343 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
5344 umount_client $MOUNT || error "umount client failed"
5348 run_test 73 "failnode to update from mountdata properly"
5350 test_75() { # LU-2374
5351 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
5352 skip "Need MDS version at least 2.4.1"
5355 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
5356 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
5357 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
5358 --reformat $(ostdevname 1) $(ostvdevname 1)"
5360 #check with default parameters
5361 add mds1 $opts_mds || error "add mds1 failed for default params"
5362 add ost1 $opts_ost || error "add ost1 failed for default params"
5364 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
5365 opts_mds=$(echo $opts_mds |
5366 sed -e "s/--index=$index/--index=$index --mdt/")
5367 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
5368 opts_ost=$(echo $opts_ost |
5369 sed -e "s/--index=$index/--index=$index --ost/")
5371 add mds1 $opts_mds || error "add mds1 failed for new params"
5372 add ost1 $opts_ost || error "add ost1 failed for new params"
5373 if ! combined_mgs_mds; then
5374 stop_mgs || error "stop mgs failed"
5379 run_test 75 "The order of --index should be irrelevant"
5382 [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] ||
5383 skip "Need MDS version at least 2.4.52"
5385 if ! combined_mgs_mds; then
5386 start_mgs || error "start mgs failed"
5389 local MDMB_PARAM="osc.*.max_dirty_mb"
5390 echo "Change MGS params"
5391 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
5393 echo "max_dirty_mb: $MAX_DIRTY_MB"
5394 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB - 10))
5395 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
5396 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
5397 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5398 head -1" $NEW_MAX_DIRTY_MB
5399 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5400 echo "$MAX_DIRTY_MB"
5401 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5402 error "error while apply max_dirty_mb"
5404 echo "Check the value is stored after remount"
5407 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5408 head -1" $NEW_MAX_DIRTY_MB
5409 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5410 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5411 error "max_dirty_mb is not saved after remount"
5413 echo "Change OST params"
5414 CLIENT_PARAM="obdfilter.*.client_cache_count"
5415 local CLIENT_CACHE_COUNT
5416 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5418 echo "client_cache_count: $CLIENT_CACHE_COUNT"
5419 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
5420 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
5421 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
5422 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5423 head -1" $NEW_CLIENT_CACHE_COUNT
5424 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5426 echo "$CLIENT_CACHE_COUNT"
5427 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5428 error "error while apply client_cache_count"
5430 echo "Check the value is stored after remount"
5433 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5434 head -1" $NEW_CLIENT_CACHE_COUNT
5435 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5437 echo "$CLIENT_CACHE_COUNT"
5438 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5439 error "client_cache_count is not saved after remount"
5442 run_test 76a "set permanent params with lctl across mounts"
5444 test_76b() { # LU-4783
5445 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.57) ]] ||
5446 skip "Need MGS version at least 2.5.57"
5449 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
5450 error "start params log failed"
5453 run_test 76b "verify params log setup correctly"
5456 [[ $(lustre_version_code mgs) -ge $(version_code 2.8.54) ]] ||
5457 skip "Need MDS version at least 2.4.52"
5459 local MASK_PARAM="mdd.*.changelog_mask"
5460 echo "Change changelog_mask"
5461 do_facet mgs $LCTL set_param -P $MASK_PARAM=-CLOSE ||
5462 error "Can't change changlog_mask"
5463 wait_update $(facet_host mds) "$LCTL get_param -n $MASK_PARAM |
5466 echo "Check the value is stored after mds remount"
5467 stop_mds || error "Failed to stop MDS"
5468 start_mds || error "Failed to start MDS"
5469 local CHANGELOG_MASK=$(do_facet mgs $LCTL get_param -n $MASK_PARAM)
5470 echo $CHANGELOG_MASK | grep CLOSE > /dev/null &&
5471 error "changelog_mask is not changed"
5475 run_test 76c "verify changelog_mask is applied with lctl set_param -P"
5477 test_76d() { #LU-9399
5480 local xattr_cache="llite.*.xattr_cache"
5481 local cmd="$LCTL get_param -n $xattr_cache | head -1"
5482 local new=$((($(eval $cmd) + 1) % 2))
5484 echo "lctl set_param -P llite.*.xattr_cache=$new"
5485 do_facet mgs $LCTL set_param -P $xattr_cache=$new ||
5486 error "Can't change xattr_cache"
5487 wait_update $HOSTNAME "$cmd" "$new"
5489 echo "Check $xattr_cache on client $MOUNT"
5490 umount_client $MOUNT || error "umount $MOUNT failed"
5491 mount_client $MOUNT || error "mount $MOUNT failed"
5492 [ $(eval $cmd) -eq $new ] ||
5493 error "$xattr_cache != $new on client $MOUNT"
5495 echo "Check $xattr_cache on the new client $MOUNT2"
5496 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
5497 [ $(eval $cmd) -eq $new ] ||
5498 error "$xattr_cache != $new on client $MOUNT2"
5499 umount_client $MOUNT2 || error "umount $MOUNT2 failed"
5503 run_test 76d "verify llite.*.xattr_cache can be set by 'lctl set_param -P' correctly"
5505 test_77() { # LU-3445
5506 local server_version=$(lustre_version_code $SINGLEMDS)
5507 [[ $server_version -ge $(version_code 2.8.55) ]] ||
5508 skip "Need MDS version 2.8.55+ "
5510 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
5511 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
5512 skip_env "mixed loopback and real device not working"
5515 local fs2mdsdev=$(mdsdevname 1_2)
5516 local fs2ostdev=$(ostdevname 1_2)
5517 local fs2mdsvdev=$(mdsvdevname 1_2)
5518 local fs2ostvdev=$(ostvdevname 1_2)
5519 local fsname=test1234
5521 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
5523 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
5525 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
5526 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
5527 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
5528 error "start fs2mds failed"
5530 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
5531 mgsnid="0.0.0.0@tcp,$mgsnid,$mgsnid:$mgsnid"
5533 add fs2ost --mgsnode=$mgsnid $(mkfs_opts ost1 $fs2ostdev) \
5534 --failnode=$failnid --fsname=$fsname \
5535 --reformat $fs2ostdev $fs2ostvdev ||
5536 error "add fs2ost failed"
5537 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
5539 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
5540 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
5541 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
5544 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
5547 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ||
5548 $(facet_fstype ost1) != ldiskfs ]] &&
5549 skip "ldiskfs only test"
5551 # reformat the Lustre filesystem with a smaller size
5552 local saved_MDSCOUNT=$MDSCOUNT
5553 local saved_MDSSIZE=$MDSSIZE
5554 local saved_OSTCOUNT=$OSTCOUNT
5555 local saved_OSTSIZE=$OSTSIZE
5558 MDSSIZE=$((MDSSIZE - 20000))
5559 OSTSIZE=$((OSTSIZE - 20000))
5560 reformat || error "(1) reformat Lustre filesystem failed"
5561 MDSSIZE=$saved_MDSSIZE
5562 OSTSIZE=$saved_OSTSIZE
5564 # mount the Lustre filesystem
5565 setup_noconfig || error "(2) setup Lustre filesystem failed"
5568 log "create test files"
5573 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
5575 for i in $(seq $num_files); do
5576 file=$MOUNT/$tdir/$tfile-$i
5577 dd if=/dev/urandom of=$file count=1 bs=1M || {
5578 $LCTL get_param osc.*.cur*grant*
5579 $LFS df; $LFS df -i;
5580 # stop creating files if there is no more space
5581 if [ ! -e $file ]; then
5582 num_files=$((i - 1))
5586 $LFS getstripe -v $file
5587 local ost_idx=$(LFS getstripe -i $file)
5588 do_facet ost$((ost_idx + 1)) \
5589 $LCTL get_param obdfilter.*.*grant*
5590 error "(4) create $file failed"
5594 # unmount the Lustre filesystem
5595 cleanup || error "(5) cleanup Lustre filesystem failed"
5597 # run e2fsck on the MDT and OST devices
5598 local mds_host=$(facet_active_host $SINGLEMDS)
5599 local ost_host=$(facet_active_host ost1)
5600 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
5601 local ost_dev=$(ostdevname 1)
5603 run_e2fsck $mds_host $mds_dev "-y"
5604 run_e2fsck $ost_host $ost_dev "-y"
5606 # get the original block count of the MDT and OST filesystems
5607 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
5608 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
5610 # expand the MDT and OST filesystems to the device size
5611 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
5612 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
5614 # run e2fsck on the MDT and OST devices again
5615 run_e2fsck $mds_host $mds_dev "-y"
5616 run_e2fsck $ost_host $ost_dev "-y"
5618 # mount the Lustre filesystem
5622 log "check files after expanding the MDT and OST filesystems"
5623 for i in $(seq $num_files); do
5624 file=$MOUNT/$tdir/$tfile-$i
5625 $CHECKSTAT -t file -s 1048576 $file ||
5626 error "(6) checkstat $file failed"
5630 log "create more files after expanding the MDT and OST filesystems"
5631 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
5632 file=$MOUNT/$tdir/$tfile-$i
5633 dd if=/dev/urandom of=$file count=1 bs=1M ||
5634 error "(7) create $file failed"
5637 # unmount the Lustre filesystem
5638 cleanup || error "(8) cleanup Lustre filesystem failed"
5640 # run e2fsck on the MDT and OST devices
5641 run_e2fsck $mds_host $mds_dev "-y"
5642 run_e2fsck $ost_host $ost_dev "-y"
5644 # get the maximum block count of the MDT and OST filesystems
5645 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
5646 local ost_max_blks=$(get_block_count ost1 $ost_dev)
5648 # get the minimum block count of the MDT and OST filesystems
5649 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
5650 grep minimum | sed -e 's/^.*filesystem: //g')
5651 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
5652 grep minimum | sed -e 's/^.*filesystem: //g')
5654 # shrink the MDT and OST filesystems to a smaller size
5658 if [[ $mds_max_blks -gt $mds_min_blks &&
5659 $mds_max_blks -gt $mds_orig_blks ]]; then
5660 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
5661 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
5662 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
5663 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
5664 error "shrink $SINGLEMDS to $new_blks failed"
5668 if [[ $ost_max_blks -gt $ost_min_blks &&
5669 $ost_max_blks -gt $ost_orig_blks ]]; then
5670 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
5671 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
5672 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
5673 run_resize2fs ost1 $ost_dev $new_blks ||
5674 error "shrink ost1 to $new_blks failed"
5678 # check whether the MDT or OST filesystem was shrunk or not
5680 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
5681 reformat || error "(10) reformat Lustre filesystem failed"
5685 # run e2fsck on the MDT and OST devices again
5686 run_e2fsck $mds_host $mds_dev "-y"
5687 run_e2fsck $ost_host $ost_dev "-y"
5689 # mount the Lustre filesystem again
5693 log "check files after shrinking the MDT and OST filesystems"
5694 for i in $(seq $((num_files + 10))); do
5695 file=$MOUNT/$tdir/$tfile-$i
5696 $CHECKSTAT -t file -s 1048576 $file ||
5697 error "(11) checkstat $file failed"
5700 # unmount and reformat the Lustre filesystem
5701 cleanup || error "(12) cleanup Lustre filesystem failed"
5702 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
5704 MDSCOUNT=$saved_MDSCOUNT
5705 OSTCOUNT=$saved_OSTCOUNT
5706 reformat || error "(14) reformat Lustre filesystem failed"
5708 run_test 78 "run resize2fs on MDT and OST filesystems"
5710 test_79() { # LU-4227
5711 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.59) ]] ||
5712 skip "Need MDS version at least 2.5.59"
5714 local mdsdev1=$(mdsdevname 1)
5715 local mdsvdev1=$(mdsvdevname 1)
5716 local mdsdev2=$(mdsdevname 2)
5717 local mdsvdev2=$(mdsvdevname 2)
5718 local ostdev1=$(ostdevname 1)
5719 local ostvdev1=$(ostvdevname 1)
5720 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
5721 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
5722 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
5725 # remove --mgs/--mgsnode from mkfs.lustre options
5726 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
5728 mgsnode_opt=$(echo $opts_mds2 |
5729 awk '{ for ( i = 1; i < NF; i++ )
5730 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5731 [ -n $mgsnode_opt ] &&
5732 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
5734 mgsnode_opt=$(echo $opts_ost1 |
5735 awk '{ for ( i = 1; i < NF; i++ )
5736 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5737 [ -n $mgsnode_opt ] &&
5738 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
5740 # -MGS, format a mdt without --mgs option
5741 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
5742 error "Must specify --mgs when formatting mdt combined with mgs"
5744 # +MGS, format a mdt/ost without --mgsnode option
5745 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
5746 > /dev/null || error "start mds1 failed"
5747 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
5748 error "Must specify --mgsnode when formatting a mdt"
5749 add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
5750 error "Must specify --mgsnode when formatting an ost"
5754 run_test 79 "format MDT/OST without mgs option (should return errors)"
5757 start_mds || error "Failed to start MDT"
5758 start_ost || error "Failed to start OST1"
5759 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
5760 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
5761 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
5762 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
5763 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
5765 start_ost2 || error "Failed to start OST2"
5767 do_facet ost1 "$LCTL set_param fail_loc=0"
5770 run_test 80 "mgc import reconnect race"
5772 #Save the original values of $OSTCOUNT and $OSTINDEX$i.
5774 local new_ostcount=$1
5775 saved_ostcount=$OSTCOUNT
5776 OSTCOUNT=$new_ostcount
5780 for i in $(seq $OSTCOUNT); do
5782 eval saved_ostindex$i=${!index}
5787 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
5788 restore_ostindex() {
5793 for i in $(seq $OSTCOUNT); do
5794 index=saved_ostindex$i
5795 eval OSTINDEX$i=${!index}
5797 OSTCOUNT=$saved_ostcount
5802 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
5803 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
5804 # assigned index and ensures we can mount such a formatted file system
5805 test_81() { # LU-4665
5806 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5807 skip "Need MDS version at least 2.6.54"
5808 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5812 # Each time RANDOM is referenced, a random integer between 0 and 32767
5815 local saved_ostindex1=$OSTINDEX1
5816 for i in 65535 $((RANDOM + 65536)); do
5817 echo -e "\nFormat ost1 with --index=$i, should fail"
5819 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
5820 $(ostdevname 1) $(ostvdevname 1); then
5821 OSTINDEX1=$saved_ostindex1
5822 error "format ost1 with --index=$i should fail"
5825 OSTINDEX1=$saved_ostindex1
5829 # Format OSTs with random sparse indices.
5830 trap "restore_ostindex" EXIT
5831 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices"
5832 OST_INDEX_LIST=[0,$((RANDOM * 2 % 65533 + 1)),65534] formatall
5834 # Setup and check Lustre filesystem.
5835 start_mgsmds || error "start_mgsmds failed"
5836 for i in $(seq $OSTCOUNT); do
5837 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5838 error "start ost$i failed"
5841 mount_client $MOUNT || error "mount client $MOUNT failed"
5842 check_mount || error "check client $MOUNT failed"
5845 local max_easize=$($LCTL get_param -n llite.*.max_easize)
5846 [[ $max_easize -eq 128 ]] ||
5847 error "max_easize is $max_easize, should be 128 bytes"
5851 run_test 81 "sparse OST indexing"
5853 # Here we exercise the stripe placement functionality on a file system that
5854 # has formatted the OST with a random index. With the file system the following
5855 # functionality is tested:
5857 # 1. Creating a new file with a specific stripe layout.
5859 # 2. Modifiy a existing empty file with a specific stripe layout.
5861 # 3. Ensure we fail to set the stripe layout of a file that already has one.
5863 # 4. If ost-index is defined we need to ensure it is the first entry in the
5864 # ost index list returned by lfs getstripe.
5866 # 5. Lastly ensure this functionality fails with directories.
5867 test_82a() { # LU-4665
5868 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5869 skip "Need MDS version at least 2.6.54"
5870 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5876 # Format OSTs with random sparse indices.
5880 local LOV_V1_INSANE_STRIPE_COUNT=65532
5881 for i in $(seq $OSTCOUNT); do
5882 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
5883 ost_indices+=" $index"
5885 ost_indices=$(comma_list $ost_indices)
5887 stack_trap "restore_ostindex" EXIT
5888 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5889 OST_INDEX_LIST=[$ost_indices] formatall
5891 # Setup Lustre filesystem.
5892 start_mgsmds || error "start_mgsmds failed"
5893 for i in $(seq $OSTCOUNT); do
5894 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5895 error "start ost$i failed"
5898 # Collect debug information - start of test
5899 do_nodes $(comma_list $(mdts_nodes)) \
5900 $LCTL get_param osc.*.prealloc_*_id
5902 mount_client $MOUNT || error "mount client $MOUNT failed"
5905 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
5906 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5908 stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
5909 $LCTL get_param osc.*.prealloc_*_id" EXIT
5911 # 1. If the file does not exist, new file will be created
5912 # with specified OSTs.
5913 local file=$DIR/$tdir/$tfile-1
5914 local cmd="$LFS setstripe -o $ost_indices $file"
5916 eval $cmd || error "$cmd failed"
5917 check_stripe_count $file $OSTCOUNT
5918 check_obdidx $file $ost_indices
5919 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5920 error "write $file failed"
5922 # 2. If the file already exists and is an empty file, the file
5923 # will be attached with specified layout.
5924 file=$DIR/$tdir/$tfile-2
5925 mcreate $file || error "mcreate $file failed"
5926 cmd="$LFS setstripe -o $ost_indices $file"
5928 eval $cmd || error "$cmd failed"
5929 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5930 error "write $file failed"
5931 check_stripe_count $file $OSTCOUNT
5932 check_obdidx $file $ost_indices
5934 # 3. If the file already has a valid layout attached, the command
5935 # should fail with EBUSY.
5937 eval $cmd && error "stripe is already set on $file, $cmd should fail"
5939 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
5940 # be in the OST indices list.
5941 local start_ost_idx=${ost_indices##*,}
5942 file=$DIR/$tdir/$tfile-3
5943 cmd="$LFS setstripe -o $ost_indices -i $start_ost_idx $file"
5945 eval $cmd || error "$cmd failed"
5946 check_stripe_count $file $OSTCOUNT
5947 check_obdidx $file $ost_indices
5948 check_start_ost_idx $file $start_ost_idx
5950 file=$DIR/$tdir/$tfile-4
5951 cmd="$LFS setstripe"
5952 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
5953 cmd+=" -i $start_ost_idx $file"
5955 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
5957 # 5. Specifying OST indices for directory should succeed.
5958 local dir=$DIR/$tdir/$tdir
5959 mkdir $dir || error "mkdir $dir failed"
5960 cmd="$LFS setstripe -o $ost_indices $dir"
5961 if [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.11.53) &&
5962 $(lustre_version_code client -gt $(version_code 2.11.53)) ]]; then
5964 eval $cmd || error "unable to specify OST indices on directory"
5966 echo "need MDS+client version at least 2.11.53"
5971 run_test 82a "specify OSTs for file (succeed) or directory (succeed)"
5976 # Remove OSTs from a pool and destroy the pool.
5977 destroy_pool $ost_pool || true
5979 if ! combined_mgs_mds ; then
5985 # Test 82b is run to ensure that if the user supplies a pool with a specific
5986 # stripe layout that it behaves proprerly. It should fail in the case that
5987 # the supplied OST index list points to OSTs not contained in the user
5989 test_82b() { # LU-4665
5990 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5991 skip "Need MDS version at least 2.6.54"
5992 [[ $OSTCOUNT -ge 4 ]] || skip_env "needs >= 4 OSTs"
5998 # Format OSTs with random sparse indices.
6002 local LOV_V1_INSANE_STRIPE_COUNT=65532
6003 for i in $(seq $OSTCOUNT); do
6004 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
6005 ost_indices+=" $index"
6007 ost_indices=$(comma_list $ost_indices)
6009 trap "restore_ostindex" EXIT
6010 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
6011 OST_INDEX_LIST=[$ost_indices] formatall
6013 # Setup Lustre filesystem.
6014 start_mgsmds || error "start_mgsmds failed"
6015 for i in $(seq $OSTCOUNT); do
6016 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
6017 error "start ost$i failed"
6020 mount_client $MOUNT || error "mount client $MOUNT failed"
6021 if ! combined_mgs_mds ; then
6026 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
6027 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6029 # Create a new pool and add OSTs into it.
6030 local ost_pool=$FSNAME.$TESTNAME
6031 create_pool $ost_pool || error "create OST pool $ost_pool failed"
6034 trap "cleanup_82b" EXIT
6036 local ost_idx_in_list=${ost_indices##*,}
6037 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
6040 local ost_targets="$FSNAME-OST["
6041 for i in ${ost_idx_in_pool//,/ }; do
6042 ost_targets=$ost_targets$(printf "%04x," $i)
6044 ost_targets="${ost_targets%,}]"
6046 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
6047 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
6048 sort -u | tr '\n' ' ')
6050 local cmd="$LCTL pool_add $ost_pool $ost_targets"
6051 do_facet mgs $cmd || error "$cmd failed"
6052 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
6053 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
6054 error "wait_update $ost_pool failed"
6055 wait_update_facet $SINGLEMDS "$LCTL pool_list $ost_pool | wc -l" 4 ||
6056 error "wait_update pool_list $ost_pool failed"
6058 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
6059 # then the OSTs must be the members of the pool.
6060 local file=$DIR/$tdir/$tfile
6061 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6063 eval $cmd && error "OST with index $ost_idx_in_list should be" \
6064 "in OST pool $ost_pool"
6066 # Only select OST $ost_idx_in_list from $ost_pool for file.
6067 ost_idx_in_list=${ost_idx_in_pool#*,}
6068 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6070 eval $cmd || error "$cmd failed"
6071 cmd="$LFS getstripe $file"
6073 eval $cmd || error "$cmd failed"
6074 check_stripe_count $file 2
6075 check_obdidx $file $ost_idx_in_list
6076 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6077 error "write $file failed"
6081 run_test 82b "specify OSTs for file with --pool and --ost-list options"
6084 [[ $(lustre_version_code ost1) -ge $(version_code 2.6.91) ]] ||
6085 skip "Need OST version at least 2.6.91"
6086 if [ $(facet_fstype ost1) != ldiskfs ]; then
6087 skip "ldiskfs only test"
6096 ostmnt=$(facet_mntpt ost1)
6097 fstype=$(facet_fstype ost1)
6099 # Mount the OST as an ldiskfs filesystem.
6100 log "mount the OST $dev as a $fstype filesystem"
6101 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
6102 --reformat $dev > /dev/null ||
6103 error "format ost1 error"
6105 if ! test -b $dev; then
6106 mnt_opts=$(csa_add "$OST_MOUNT_OPTS" -o loop)
6108 echo "mnt_opts $mnt_opts"
6109 do_facet ost1 mount -t $fstype $dev \
6111 # Run llverfs on the mounted ldiskfs filesystem.
6112 # It is needed to get ENOSPACE.
6113 log "run llverfs in partial mode on the OST $fstype $ostmnt"
6114 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
6115 "no" || error "run_llverfs error on $fstype"
6118 log "unmount the OST $dev"
6121 # Delete file IO_scrub. Later osd_scrub_setup will try to
6122 # create "IO_scrub" but will get ENOSPACE.
6124 echo "start ost1 service on `facet_active_host ost1`"
6125 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
6128 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
6129 echo "string err $err"
6130 [ -z "$err" ] || error $err
6133 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
6134 Busy inodes after unmount ..."
6137 local facet=$SINGLEMDS
6138 local num=$(echo $facet | tr -d "mds")
6139 local dev=$(mdsdevname $num)
6140 local time_min=$(recovery_time_min)
6141 local recovery_duration
6142 local completed_clients
6143 local correct_clients
6146 echo "start mds service on $(facet_active_host $facet)"
6148 "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" $@ ||
6149 error "start MDS failed"
6151 start_ost || error "start OST0000 failed"
6152 start_ost2 || error "start OST0001 failed"
6154 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
6156 mount_client $MOUNT1 || error "mount $MOUNT1 failed"
6157 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
6158 # make sure new superblock labels are sync'd before disabling writes
6162 replay_barrier $SINGLEMDS
6163 createmany -o $DIR1/$tfile-%d 1000
6165 # We need to catch the end of recovery window to extend it.
6166 # Skip 5 requests and add delay to request handling.
6167 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
6168 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
6170 facet_failover --fsck $SINGLEMDS || error "failover: $?"
6173 echo "recovery status"
6174 do_facet $SINGLEMDS \
6175 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
6177 recovery_duration=$(do_facet $SINGLEMDS \
6178 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6179 awk '/recovery_duration/ { print $2 }')
6180 (( $recovery_duration > $time_min + $wrap_up )) &&
6181 error "recovery_duration > recovery_time_hard + wrap up"
6182 completed_clients=$(do_facet $SINGLEMDS \
6183 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6184 awk '/completed_clients/ { print $2 }')
6186 correct_clients="$MDSCOUNT/$((MDSCOUNT+1))"
6187 [ "$completed_clients" = "${correct_clients}" ] ||
6188 error "$completed_clients != $correct_clients"
6190 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
6191 umount_client $MOUNT1
6192 umount_client $MOUNT2
6198 run_test 84 "check recovery_hard_time"
6201 [[ $(lustre_version_code ost1) -ge $(version_code 2.7.55) ]] ||
6202 skip "Need OST version at least 2.7.55"
6203 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
6204 do_facet ost1 "lctl set_param fail_loc=0x197"
6208 run_test 85 "osd_ost init: fail ea_fid_set"
6213 # ost1 has already registered to the MGS before the reformat.
6214 # So after reformatting it with option "-G", it could not be
6215 # mounted to the MGS. Cleanup the system for subsequent tests.
6220 local server_version=$(lustre_version_code $SINGLEMDS)
6221 [ "$(facet_fstype ost1)" = "zfs" ] &&
6222 skip "LU-6442: no such mkfs params for ZFS OSTs"
6223 [[ $server_version -ge $(version_code 2.7.56) ]] ||
6224 skip "Need server version newer than 2.7.55"
6226 local OST_OPTS="$(mkfs_opts ost1 $(ostdevname 1)) \
6227 --reformat $(ostdevname 1) $(ostvdevname 1)"
6230 local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6231 awk '/Flex block group size: / { print $NF; exit; }')
6234 if [[ ${!opts} != *mkfsoptions* ]]; then
6235 eval opts=\"${!opts} \
6236 --mkfsoptions='\\\"-O flex_bg -G $NEWSIZE\\\"'\"
6238 val=${!opts//--mkfsoptions=\\\"/ \
6239 --mkfsoptions=\\\"-O flex_bg -G $NEWSIZE }
6243 echo "params: $opts"
6245 trap cleanup_86 EXIT ERR
6248 add ost1 $opts || error "add ost1 failed with new params"
6250 local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6251 awk '/Flex block group size: / { print $NF; exit; }')
6253 [[ $FOUNDSIZE == $NEWSIZE ]] ||
6254 error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
6258 run_test 86 "Replacing mkfs.lustre -G option"
6260 test_87() { #LU-6544
6261 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.9.51) ]] ||
6262 skip "Need MDS version at least 2.9.51"
6263 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
6264 skip "ldiskfs only test"
6265 [[ $OSTCOUNT -gt 59 ]] &&
6266 skip "Ignore wide striping situation"
6268 local mdsdev=$(mdsdevname 1)
6269 local mdsvdev=$(mdsvdevname 1)
6270 local file=$DIR/$tfile
6271 local mntpt=$(facet_mntpt $SINGLEMDS)
6272 local used_xattr_blk=0
6273 local inode_size=${1:-1024}
6275 local xtest="trusted.test"
6279 local stripe_cnt=$(($OSTCOUNT + 2))
6281 #Please see ldiskfs_make_lustre() for MDT inode size calculation
6282 if [ $stripe_cnt -gt 16 ]; then
6285 left_size=$(expr $inode_size - \
6288 32 - 40 \* 3 - 32 \* 3 - $stripe_cnt \* 24 - 16 - 3 - \
6290 24 - 18 - $(expr length $tfile) - 16 - 4)
6291 if [ $left_size -le 0 ]; then
6292 echo "No space($left_size) is expected in inode."
6293 echo "Try 1-byte xattr instead to verify this."
6296 echo "Estimate: at most $left_size-byte space left in inode."
6302 add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$stripe_cnt \
6303 --reformat $mdsdev $mdsvdev || error "add mds1 failed"
6304 start_mdt 1 > /dev/null || error "start mdt1 failed"
6305 for i in $(seq $OSTCOUNT); do
6306 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
6307 error "start ost$i failed"
6309 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
6310 check_mount || error "check client $MOUNT failed"
6313 $LFS setstripe -E 1M -S 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
6314 error "Create file with 3 components failed"
6315 $TRUNCATE $file $((1024*1024*64+1)) || error "truncate file failed"
6316 i=$($LFS getstripe -I3 -c $file) || error "get 3rd stripe count failed"
6317 if [ $i -ne $OSTCOUNT ]; then
6318 left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
6319 echo -n "Since only $i out $OSTCOUNT OSTs are used, "
6320 echo -n "the expected left space is changed to "
6321 echo "$left_size bytes at most."
6323 value=$(generate_string $left_size)
6324 setfattr -n $xtest -v $value $file
6325 orig=$(get_xattr_value $xtest $file)
6326 [[ "$orig" != "$value" ]] && error "$xtest changed"
6328 #Verify if inode has some expected space left
6329 umount $MOUNT > /dev/null || error "umount $MOUNT failed"
6330 stop_mdt 1 > /dev/null || error "stop mdt1 failed"
6331 mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
6333 do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
6334 used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
6336 [[ $used_xattr_blk -eq 0 ]] &&
6337 error "Please check MDS inode size calculation: \
6338 more than $left_size-byte space left in inode."
6339 echo "Verified: at most $left_size-byte space left in inode."
6343 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
6346 [ "$(facet_fstype mds1)" == "zfs" ] &&
6347 skip "LU-6662: no implementation for ZFS"
6351 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6352 --reformat $(mdsdevname 1) || error "add mds1 failed"
6354 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6355 grep -e \".*opts:.*errors=remount-ro.*\"" ||
6356 error "default mount options is missing"
6358 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6359 --mountfsoptions="user_xattr,errors=panic" \
6360 --reformat $(mdsdevname 1) || error "add mds1 failed"
6362 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6363 grep -e \".*opts:.*errors=panic.*\"" ||
6364 error "user can't override default mount options"
6366 run_test 88 "check the default mount options can be overridden"
6368 test_89() { # LU-7131
6369 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.9.54) ]] ||
6370 skip "Need MDT version at least 2.9.54"
6372 local key=failover.node
6373 local val1=192.0.2.254@tcp0 # Reserved IPs, see RFC 5735
6374 local val2=192.0.2.255@tcp0
6375 local mdsdev=$(mdsdevname 1)
6380 [ $(facet_fstype mds1) == zfs ] && import_zpool mds1
6381 # Check that parameters are added correctly
6382 echo "tunefs --param $key=$val1"
6383 do_facet mds "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
6384 error "tunefs --param $key=$val1 failed"
6385 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6386 error "tunefs --dryrun failed"
6387 params=${params##*Parameters:}
6388 params=${params%%exiting*}
6389 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val1) = "1" ] ||
6390 error "on-disk parameter not added correctly via tunefs"
6392 # Check that parameters replace existing instances when added
6393 echo "tunefs --param $key=$val2"
6394 do_facet mds "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
6395 error "tunefs --param $key=$val2 failed"
6396 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6397 error "tunefs --dryrun failed"
6398 params=${params##*Parameters:}
6399 params=${params%%exiting*}
6400 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "1" ] ||
6401 error "on-disk parameter not replaced via tunefs"
6402 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val2) = "1" ] ||
6403 error "on-disk parameter not replaced correctly via tunefs"
6405 # Check that a parameter is erased properly
6406 echo "tunefs --erase-param $key"
6407 do_facet mds "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
6408 error "tunefs --erase-param $key failed"
6409 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6410 error "tunefs --dryrun failed"
6411 params=${params##*Parameters:}
6412 params=${params%%exiting*}
6413 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "0" ] ||
6414 error "on-disk parameter not erased correctly via tunefs"
6416 # Check that all the parameters are erased
6417 echo "tunefs --erase-params"
6418 do_facet mds "$TUNEFS --erase-params $mdsdev >/dev/null" ||
6419 error "tunefs --erase-params failed"
6420 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6421 error "tunefs --dryrun failed"
6422 params=${params##*Parameters:}
6423 params=${params%%exiting*}
6425 error "all on-disk parameters not erased correctly via tunefs"
6427 # Check the order of options --erase-params and --param
6428 echo "tunefs --param $key=$val1 --erase-params"
6430 "$TUNEFS --param $key=$val1 --erase-params $mdsdev >/dev/null"||
6431 error "tunefs --param $key=$val1 --erase-params failed"
6432 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6433 error "tunefs --dryrun failed"
6434 params=${params##*Parameters:}
6435 params=${params%%exiting*}
6436 [ $(echo $params | tr ' ' '\n') == "$key=$val1" ] ||
6437 error "on-disk param not added correctly with --erase-params"
6441 run_test 89 "check tunefs --param and --erase-param{s} options"
6444 # $2 (optional) value of max_mod_rpcs_in_flight to set
6445 check_max_mod_rpcs_in_flight() {
6453 idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
6454 facet="mds$((0x$idx + 1))"
6456 if [ -z "$mmr" ]; then
6457 # get value of max_mod_rcps_in_flight
6458 mmr=$($LCTL get_param -n \
6459 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
6460 error "Unable to get max_mod_rpcs_in_flight"
6461 echo "max_mod_rcps_in_flight is $mmr"
6463 # set value of max_mod_rpcs_in_flight
6465 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
6466 error "Unable to set max_mod_rpcs_in_flight to $mmr"
6467 echo "max_mod_rpcs_in_flight set to $mmr"
6470 # create mmr+1 files
6471 echo "creating $((mmr + 1)) files ..."
6473 for i in $(seq $((mmr + 1))); do
6479 # consumes mmr-1 modify RPC slots
6480 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6481 # drop requests on MDT so that RPC slots are consumed
6482 # during all the request resend interval
6483 do_facet $facet "$LCTL set_param fail_loc=0x159"
6484 echo "launch $((mmr - 1)) chmod in parallel ..."
6485 for i in $(seq $((mmr - 1))); do
6486 chmod 0600 $dir/file-$i &
6490 # send one additional modify RPC
6491 do_facet $facet "$LCTL set_param fail_loc=0"
6492 echo "launch 1 additional chmod in parallel ..."
6493 chmod 0600 $dir/file-$mmr &
6496 # check this additional modify RPC get a modify RPC slot
6497 # and succeed its operation
6498 checkstat -vp 0600 $dir/file-$mmr ||
6499 error "Unable to send $mmr modify RPCs in parallel"
6504 # consumes mmr modify RPC slots
6505 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6506 # drop requests on MDT so that RPC slots are consumed
6507 # during all the request resend interval
6508 do_facet $facet "$LCTL set_param fail_loc=0x159"
6509 echo "launch $mmr chmod in parallel ..."
6510 for i in $(seq $mmr); do
6511 chmod 0666 $dir/file-$i &
6515 # send one additional modify RPC
6516 do_facet $facet "$LCTL set_param fail_loc=0"
6517 echo "launch 1 additional chmod in parallel ..."
6518 chmod 0666 $dir/file-$((mmr + 1)) &
6521 # check this additional modify RPC blocked getting a modify RPC slot
6522 checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
6523 error "Unexpectedly send $(($mmr + 1)) modify RPCs in parallel"
6529 if ! combined_mgs_mds ; then
6534 [[ $($LCTL get_param mdc.*.import |
6535 grep "connect_flags:.*multi_mod_rpc") ]] ||
6536 skip "Need MDC with 'multi_mod_rpcs' feature"
6538 # check default value
6539 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6540 check_max_mod_rpcs_in_flight $DIR/$tdir
6544 run_test 90a "check max_mod_rpcs_in_flight is enforced"
6554 [[ $($LCTL get_param mdc.*.import |
6555 grep "connect_flags:.*multi_mod_rpc") ]] ||
6556 skip "Need MDC with 'multi_mod_rpcs' feature"
6559 # update max_mod_rpcs_in_flight
6560 $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
6561 check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
6564 # check client is able to send multiple modify RPCs in paralell
6565 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6566 grep -c "multi_mod_rpcs")
6567 if [ "$tmp" -ne $MDSCOUNT ]; then
6569 skip "Client not able to send multiple modify RPCs in parallel"
6572 # update max_mod_rpcs_in_flight
6573 $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
6574 check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
6577 $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
6578 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
6579 facet="mds$((0x$idx + 1))"
6581 # save MDT max_mod_rpcs_per_client
6582 mmrpc=$(do_facet $facet \
6583 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6585 # update max_mod_rpcs_in_flight
6586 umount_client $MOUNT
6588 "echo 16 > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6590 $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
6591 check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
6593 # restore MDT max_mod_rpcs_per_client initial value
6595 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6597 rm -rf $DIR/${tdir}?
6600 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
6609 [[ $($LCTL get_param mdc.*.import |
6610 grep "connect_flags:.*multi_mod_rpc") ]] ||
6611 skip "Need MDC with 'multi_mod_rpcs' feature"
6613 # check client is able to send multiple modify RPCs in paralell
6614 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6615 grep -c "multi_mod_rpcs")
6616 if [ "$tmp" -ne $MDSCOUNT ]; then
6618 skip "Client not able to send multiple modify RPCs in parallel"
6621 # get max_rpcs_in_flight value
6622 mrif=$($LCTL get_param -n mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6623 echo "max_rpcs_in_flight is $mrif"
6625 # get MDT max_mod_rpcs_per_client
6626 mmrpc=$(do_facet mds1 \
6627 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6628 echo "max_mod_rpcs_per_client is $mmrpc"
6631 # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
6632 # prerequisite: set max_mod_rpcs_per_client to max_rpcs_in_flight value
6633 umount_client $MOUNT
6635 "echo $mrif > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6639 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif &&
6640 error "set max_mod_rpcs_in_flight to $mrif should fail"
6642 umount_client $MOUNT
6644 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6648 # attempt to set max_mod_rpcs_in_flight to max_mod_rpcs_per_client+1
6649 # prerequisite: set max_rpcs_in_flight to max_mod_rpcs_per_client+2
6651 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc + 2))
6654 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc + 1)) &&
6655 error "set max_mod_rpcs_in_flight to $((mmrpc + 1)) should fail"
6659 run_test 90c "check max_mod_rpcs_in_flight update limits"
6670 [[ $($LCTL get_param mdc.*.import |
6671 grep "connect_flags:.*multi_mod_rpc") ]] ||
6672 skip "Need MDC with 'multi_mod_rpcs' feature"
6674 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6675 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
6676 facet="mds$((0x$idx + 1))"
6678 # check client version supports multislots
6679 tmp=$($LCTL get_param -N \
6680 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6681 if [ -z "$tmp" ]; then
6683 skip "Client does not support multiple modify RPCs in flight"
6686 # get current value of max_mod_rcps_in_flight
6687 mmr=$($LCTL get_param -n \
6688 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6689 echo "max_mod_rcps_in_flight is $mmr"
6692 echo "creating $mmr files ..."
6694 for i in $(seq $mmr); do
6695 touch $DIR/$tdir/file-$i
6698 # prepare for close RPC
6699 multiop_bg_pause $DIR/$tdir/file-close O_c
6702 # consumes mmr modify RPC slots
6703 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6704 # drop requests on MDT so that RPC slots are consumed
6705 # during all the request resend interval
6706 do_facet $facet "$LCTL set_param fail_loc=0x159"
6707 echo "launch $mmr chmod in parallel ..."
6708 for i in $(seq $mmr); do
6709 chmod 0600 $DIR/$tdir/file-$i &
6712 # send one additional close RPC
6713 do_facet $facet "$LCTL set_param fail_loc=0"
6714 echo "launch 1 additional close in parallel ..."
6716 cancel_lru_locks mdc
6719 # check this additional close RPC get a modify RPC slot
6720 # and multiop process completed
6721 [ -d /proc/$pid ] &&
6722 error "Unable to send the additional close RPC in parallel"
6727 run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
6729 check_uuid_on_ost() {
6731 do_facet ost1 "$LCTL get_param obdfilter.${FSNAME}*.exports.'$nid'.uuid"
6734 check_uuid_on_mdt() {
6736 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6744 [[ $(lustre_version_code ost1) -ge $(version_code 2.7.63) ]] ||
6745 skip "Need OST version at least 2.7.63"
6746 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.63) ]] ||
6747 skip "Need MDT version at least 2.7.63"
6749 start_mds || error "MDS start failed"
6750 start_ost || error "unable to start OST"
6751 mount_client $MOUNT || error "client start failed"
6752 check_mount || error "check_mount failed"
6755 nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
6759 uuid=$(get_client_uuid $MOUNT)
6761 echo "list nids on mdt:"
6762 do_facet $SINGLEMDS "$LCTL list_param mdt.${FSNAME}*.exports.*"
6763 echo "uuid from $nid:"
6764 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6766 found=$(check_uuid_on_mdt $nid | grep $uuid)
6767 [ -z "$found" ] && error "can't find $uuid $nid on MDT"
6768 found=$(check_uuid_on_ost $nid | grep $uuid)
6769 [ -z "$found" ] && error "can't find $uuid $nid on OST"
6771 # umount the client so it won't reconnect
6772 manual_umount_client --force || error "failed to umount $?"
6773 # shouldn't disappear on MDS after forced umount
6774 found=$(check_uuid_on_mdt $nid | grep $uuid)
6775 [ -z "$found" ] && error "can't find $uuid $nid"
6778 do_facet $SINGLEMDS \
6779 "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
6781 found=$(check_uuid_on_mdt $nid | grep $uuid)
6782 [ -n "$found" ] && error "found $uuid $nid on MDT"
6783 found=$(check_uuid_on_ost $nid | grep $uuid)
6784 [ -n "$found" ] && error "found $uuid $nid on OST"
6786 # check it didn't reconnect (being umounted)
6787 sleep $((TIMEOUT+1))
6788 found=$(check_uuid_on_mdt $nid | grep $uuid)
6789 [ -n "$found" ] && error "found $uuid $nid on MDT"
6790 found=$(check_uuid_on_ost $nid | grep $uuid)
6791 [ -n "$found" ] && error "found $uuid $nid on OST"
6795 run_test 91 "evict-by-nid support"
6797 generate_ldev_conf() {
6798 # generate an ldev.conf file
6799 local ldevconfpath=$1
6801 local fsldevformat=""
6804 fstype=$(facet_fstype mgs)
6805 if [ "$fstype" == "zfs" ]; then
6806 fsldevformat="$fstype:"
6811 printf "%s\t-\t%s-MGS0000\t%s%s\n" \
6815 $(mgsdevname) > $ldevconfpath
6817 local mdsfo_host=$mdsfailover_HOST;
6818 if [ -z "$mdsfo_host" ]; then
6822 for num in $(seq $MDSCOUNT); do
6823 fstype=$(facet_fstype mds$num)
6824 if [ "$fstype" == "zfs" ]; then
6825 fsldevformat="$fstype:"
6830 printf "%s\t%s\t%s-MDT%04d\t%s%s\n" \
6836 $(mdsdevname $num) >> $ldevconfpath
6839 local ostfo_host=$ostfailover_HOST;
6840 if [ -z "$ostfo_host" ]; then
6844 for num in $(seq $OSTCOUNT); do
6845 fstype=$(facet_fstype ost$num)
6846 if [ "$fstype" == "zfs" ]; then
6847 fsldevformat="$fstype:"
6852 printf "%s\t%s\t%s-OST%04d\t%s%s\n" \
6858 $(ostdevname $num) >> $ldevconfpath
6861 echo "----- $ldevconfpath -----"
6863 echo "--- END $ldevconfpath ---"
6868 # generate a nids file (mapping between hostname to nid)
6869 # looks like we only have the MGS nid available to us
6870 # so just echo that to a file
6872 echo -e "${mgs_HOST}\t${MGSNID}" > $nidspath
6874 echo "----- $nidspath -----"
6876 echo "--- END $nidspath ---"
6879 compare_ldev_output() {
6883 sort $expected_output -o $expected_output
6884 sort $ldev_output -o $ldev_output
6886 echo "-- START OF LDEV OUTPUT --"
6888 echo "--- END OF LDEV OUTPUT ---"
6890 echo "-- START OF EXPECTED OUTPUT --"
6891 cat $expected_output
6892 echo "--- END OF EXPECTED OUTPUT ---"
6894 diff $expected_output $ldev_output
6899 if [ -z "$LDEV" ]; then
6900 error "ldev is missing!"
6903 local LDEVCONFPATH=$TMP/ldev.conf
6904 local NIDSPATH=$TMP/nids
6906 echo "Host is $(hostname)"
6908 generate_ldev_conf $LDEVCONFPATH
6909 generate_nids $NIDSPATH
6911 # echo the mgs nid and compare it to environment variable MGSNID
6912 # also, ldev.conf and nids is a server side thing, use the OSS
6915 output=$($LDEV -c $LDEVCONFPATH -H $ost_HOST -n $NIDSPATH echo %m)
6917 echo "-- START OF LDEV OUTPUT --"
6919 echo "--- END OF LDEV OUTPUT ---"
6921 # ldev failed, error
6922 if [ $? -ne 0 ]; then
6923 rm $LDEVCONFPATH $NIDSPATH
6924 error "ldev failed to execute!"
6927 # need to process multiple lines because of combined MGS and MDS
6928 echo -e $output | awk '{ print $2 }' | while read -r line ; do
6929 if [ "$line" != "$MGSNID" ]; then
6930 rm $LDEVCONFPATH $NIDSPATH
6931 error "ldev failed mgs nid '$line', expected '$MGSNID'"
6935 rm $LDEVCONFPATH $NIDSPATH
6937 run_test 92 "ldev returns MGS NID correctly in command substitution"
6940 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
6943 #start mgs or mgs/mdt0
6944 if ! combined_mgs_mds ; then
6951 start_ost || error "OST0 start fail"
6953 #define OBD_FAIL_MGS_WRITE_TARGET_DELAY 0x90e
6954 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x8000090e"
6955 for num in $(seq 2 $MDSCOUNT); do
6959 mount_client $MOUNT || error "mount client fails"
6960 wait_osc_import_state mds ost FULL
6961 wait_osc_import_ready client ost
6962 check_mount || error "check_mount failed"
6964 cleanup || error "cleanup failed with $?"
6966 run_test 93 "register mulitple MDT at the same time"
6969 if [ -z "$LDEV" ]; then
6970 error "ldev is missing!"
6973 local LDEVCONFPATH=$TMP/ldev.conf
6974 local NIDSPATH=$TMP/nids
6976 generate_ldev_conf $LDEVCONFPATH
6977 generate_nids $NIDSPATH
6979 local LDEV_OUTPUT=$TMP/ldev-output.txt
6980 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME > $LDEV_OUTPUT
6982 # ldev failed, error
6983 if [ $? -ne 0 ]; then
6984 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
6985 error "ldev failed to execute!"
6989 local EXPECTED_OUTPUT=$TMP/ldev-expected.txt
6991 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
6993 for num in $(seq $MDSCOUNT); do
6994 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
6997 for num in $(seq $OSTCOUNT); do
6998 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7001 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7003 if [ $? -ne 0 ]; then
7004 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7005 error "ldev failed to produce the correct hostlist!"
7008 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7010 run_test 94 "ldev outputs correct labels for file system name query"
7013 if [ -z "$LDEV" ]; then
7014 error "ldev is missing!"
7017 local LDEVCONFPATH=$TMP/ldev.conf
7018 local NIDSPATH=$TMP/nids
7020 generate_ldev_conf $LDEVCONFPATH
7021 generate_nids $NIDSPATH
7025 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME &>/dev/null
7026 if [ $? -ne 0 ]; then
7027 rm $LDEVCONFPATH $NIDSPATH
7028 error "ldev label filtering w/ -F failed!"
7032 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -l &>/dev/null
7033 if [ $? -ne 0 ]; then
7034 rm $LDEVCONFPATH $NIDSPATH
7035 error "ldev label filtering w/ -l failed!"
7039 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f &>/dev/null
7040 if [ $? -ne 0 ]; then
7041 rm $LDEVCONFPATH $NIDSPATH
7042 error "ldev label filtering w/ -f failed!"
7046 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a &>/dev/null
7047 if [ $? -ne 0 ]; then
7048 rm $LDEVCONFPATH $NIDSPATH
7049 error "ldev label filtering w/ -a failed!"
7054 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -F $FSNAME &>/dev/null
7055 if [ $? -eq 0 ]; then
7056 rm $LDEVCONFPATH $NIDSPATH
7057 error "ldev label filtering w/ -a and -F incorrectly succeeded"
7061 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -f &>/dev/null
7062 if [ $? -eq 0 ]; then
7063 rm $LDEVCONFPATH $NIDSPATH
7064 error "ldev label filtering w/ -a and -f incorrectly succeeded"
7068 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -l &>/dev/null
7069 if [ $? -eq 0 ]; then
7070 rm $LDEVCONFPATH $NIDSPATH
7071 error "ldev label filtering w/ -a and -l incorrectly succeeded"
7075 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f -l &>/dev/null
7076 if [ $? -eq 0 ]; then
7077 rm $LDEVCONFPATH $NIDSPATH
7078 error "ldev label filtering w/ -f and -l incorrectly succeeded"
7082 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -l &>/dev/null
7083 if [ $? -eq 0 ]; then
7084 rm $LDEVCONFPATH $NIDSPATH
7085 error "ldev label filtering w/ -F and -l incorrectly succeeded"
7088 # file sys & foreign
7089 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -f &>/dev/null
7090 if [ $? -eq 0 ]; then
7091 rm $LDEVCONFPATH $NIDSPATH
7092 error "ldev label filtering w/ -F and -f incorrectly succeeded"
7095 rm $LDEVCONFPATH $NIDSPATH
7097 run_test 95 "ldev should only allow one label filter"
7100 if [ -z "$LDEV" ]; then
7101 error "ldev is missing!"
7104 local LDEVCONFPATH=$TMP/ldev.conf
7105 local NIDSPATH=$TMP/nids
7107 generate_ldev_conf $LDEVCONFPATH
7108 generate_nids $NIDSPATH
7110 local LDEV_OUTPUT=$TMP/ldev-output.txt
7111 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -H $mgs_HOST \
7113 awk '{print $2}' > $LDEV_OUTPUT
7115 # ldev failed, error
7116 if [ $? -ne 0 ]; then
7117 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7118 error "ldev failed to execute!"
7122 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7124 echo "$mgs_HOST-$(facet_fstype mgs)" > $EXPECTED_OUTPUT
7126 if [ "$mgs_HOST" == "$mds_HOST" ]; then
7127 for num in $(seq $MDSCOUNT); do
7128 echo "$mds_HOST-$(facet_fstype mds$num)" \
7133 if [ "$mgs_HOST" == "$ost_HOST" ]; then
7134 for num in $(seq $OSTCOUNT); do
7135 echo "$ost_HOST-$(facet_fstype ost$num)" \
7140 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7142 if [ $? -ne 0 ]; then
7143 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7144 error "ldev failed to produce the correct output!"
7147 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7149 run_test 96 "ldev returns hostname and backend fs correctly in command sub"
7152 if [ -z "$LDEV" ]; then
7153 error "ldev is missing!"
7156 local LDEVCONFPATH=$TMP/ldev.conf
7157 local NIDSPATH=$TMP/nids
7159 generate_ldev_conf $LDEVCONFPATH
7160 generate_nids $NIDSPATH
7162 local LDEV_OUTPUT=$TMP/ldev-output.txt
7163 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7165 echo -e "\nMDT role"
7166 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mdt > $LDEV_OUTPUT
7168 if [ $? -ne 0 ]; then
7169 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7170 error "ldev failed to execute for mdt role!"
7173 for num in $(seq $MDSCOUNT); do
7174 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7177 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7179 if [ $? -ne 0 ]; then
7180 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7181 error "ldev failed to produce the correct output for mdt role!"
7184 echo -e "\nOST role"
7185 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R ost > $LDEV_OUTPUT
7187 if [ $? -ne 0 ]; then
7188 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7189 error "ldev failed to execute for ost role!"
7193 for num in $(seq $OSTCOUNT); do
7194 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7197 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7199 if [ $? -ne 0 ]; then
7200 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7201 error "ldev failed to produce the correct output for ost role!"
7204 echo -e "\nMGS role"
7205 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mgs > $LDEV_OUTPUT
7207 if [ $? -ne 0 ]; then
7208 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7209 error "ldev failed to execute for mgs role!"
7212 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7214 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7216 if [ $? -ne 0 ]; then
7217 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7218 error "ldev failed to produce the correct output for mgs role!"
7221 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7223 run_test 97 "ldev returns correct ouput when querying based on role"
7228 local temp=$MDS_MOUNT_OPTS
7231 check_mount || error "mount failed"
7232 mountopt="user_xattr"
7233 for ((x = 1; x <= 400; x++)); do
7234 mountopt="$mountopt,user_xattr"
7236 remount_client $mountopt $MOUNT 2>&1 | grep "too long" ||
7237 error "Buffer overflow check failed"
7238 cleanup || error "cleanup failed"
7240 run_test 98 "Buffer-overflow check while parsing mount_opts"
7244 [[ $(facet_fstype ost1) != ldiskfs ]] &&
7245 skip "ldiskfs only test"
7246 [[ $(lustre_version_code ost1) -ge $(version_code 2.8.57) ]] ||
7247 skip "Need OST version at least 2.8.57"
7249 local ost_opts="$(mkfs_opts ost1 $(ostdevname 1)) \
7250 --reformat $(ostdevname 1) $(ostvdevname 1)"
7251 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" &&
7252 skip "meta_bg already set"
7255 if [[ ${!opts} != *mkfsoptions* ]]; then
7256 eval opts=\"${!opts} \
7257 --mkfsoptions='\\\"-O ^resize_inode,meta_bg\\\"'\"
7259 local val=${!opts//--mkfsoptions=\\\"/ \
7260 --mkfsoptions=\\\"-O ^resize_inode,meta_bg }
7264 echo "params: $opts"
7266 add ost1 $opts || error "add ost1 failed with new params"
7268 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" ||
7269 error "meta_bg is not set"
7273 run_test 99 "Adding meta_bg option"
7277 start_mds || error "MDS start failed"
7278 start_ost || error "unable to start OST"
7279 mount_client $MOUNT || error "client start failed"
7280 check_mount || error "check_mount failed"
7289 do_facet mgs 'lshowmount -v' | awk 'BEGIN {NR == 0; rc=1} /MGS:/ {rc=0}
7290 END {exit rc}' || error "lshowmount have no output MGS"
7292 do_facet mds1 'lshowmount -v' | awk 'BEGIN {NR == 2; rc=1} /-MDT0000:/
7293 {rc=0} END {exit rc}' || error "lshowmount have no output MDT0"
7295 do_facet ost1 'lshowmount -v' | awk 'BEGIN {NR == 4; rc=1} /-OST0000:/
7296 {rc=0} END {exit rc}' || error "lshowmount have no output OST0"
7298 cleanup || error "cleanup failed with $?"
7300 run_test 100 "check lshowmount lists MGS, MDT, OST and 0@lo"
7303 local createmany_pid
7304 local dev=$FSNAME-OST0000-osc-MDT0000
7308 createmany -o $DIR1/$tdir/$tfile-%d 50000 &
7310 # MDT->OST reconnection causes MDT<->OST last_id synchornisation
7311 # via osp_precreate_cleanup_orphans.
7312 for ((i = 0; i < 100; i++)); do
7313 for ((k = 0; k < 10; k++)); do
7314 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;" \
7315 "$LCTL --device $dev activate"
7318 ls -asl $MOUNT | grep '???' &&
7319 { kill -9 $createmany_pid &>/dev/null;
7320 error "File has no object on OST"; }
7322 kill -s 0 $createmany_pid || break
7324 wait $createmany_pid
7326 unlinkmany $DIR1/$tdir/$tfile-%d 50000
7329 run_test 101 "Race MDT->OST reconnection with create"
7332 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.9.53) ]] ||
7333 skip "Need server version greater than 2.9.53"
7334 cleanup || error "cleanup failed with $?"
7336 local mds1dev=$(mdsdevname 1)
7337 local mds1mnt=$(facet_mntpt mds1)
7338 local mds1fstype=$(facet_fstype mds1)
7339 local mds1opts=$MDS_MOUNT_OPTS
7341 if [ $mds1fstype == ldiskfs ] &&
7342 ! do_facet mds1 test -b $mds1dev; then
7343 mds1opts=$(csa_add "$mds1opts" -o loop)
7345 if [[ $mds1fstype == zfs ]]; then
7346 import_zpool mds1 || return ${PIPESTATUS[0]}
7349 # unload all and only load libcfs to allow fail_loc setting
7350 do_facet mds1 $LUSTRE_RMMOD || error "unable to unload modules"
7351 do_facet mds1 modprobe libcfs || error "libcfs not loaded"
7352 do_facet mds1 lsmod \| grep libcfs || error "libcfs not loaded"
7354 #define OBD_FAIL_OBDCLASS_MODULE_LOAD 0x60a
7355 do_facet mds1 "$LCTL set_param fail_loc=0x8000060a"
7357 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
7358 error "mdt start must fail"
7359 do_facet mds1 lsmod \| grep obdclass && error "obdclass must not load"
7361 do_facet mds1 "$LCTL set_param fail_loc=0x0"
7363 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts ||
7364 error "mdt start must not fail"
7366 cleanup || error "cleanup failed with $?"
7368 run_test 102 "obdclass module cleanup upon error"
7373 echo "rename $FSNAME to $newname"
7375 if ! combined_mgs_mds ; then
7376 local facet=$(mgsdevname)
7379 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7380 error "(7) Fail to rename MGS"
7381 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7382 reimport_zpool mgs $newname-mgs
7386 for num in $(seq $MDSCOUNT); do
7387 local facet=$(mdsdevname $num)
7389 do_facet mds${num} \
7390 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7391 error "(8) Fail to rename MDT $num"
7392 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7393 reimport_zpool mds${num} $newname-mdt${num}
7397 for num in $(seq $OSTCOUNT); do
7398 local facet=$(ostdevname $num)
7400 do_facet ost${num} \
7401 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7402 error "(9) Fail to rename OST $num"
7403 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7404 reimport_zpool ost${num} $newname-ost${num}
7409 test_103_set_pool() {
7413 do_facet mgs $LCTL pool_add $FSNAME.$pname ${FSNAME}-$ost_x ||
7414 error "Fail to add $ost_x to $FSNAME.$pname"
7415 wait_update $HOSTNAME \
7416 "lctl get_param -n lov.$FSNAME-clilov-*.pools.$pname |
7417 grep $ost_x" "$FSNAME-${ost_x}_UUID" ||
7418 error "$ost_x is NOT in pool $FSNAME.$pname"
7421 test_103_check_pool() {
7422 local save_fsname=$1
7425 stat $DIR/$tdir/test-framework.sh ||
7426 error "($errno) Fail to stat"
7427 do_facet mgs $LCTL pool_list $FSNAME.pool1 ||
7428 error "($errno) Fail to list $FSNAME.pool1"
7429 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname ||
7430 error "($errno) Fail to list $FSNAME.$save_fsname"
7431 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname |
7432 grep ${FSNAME}-OST0000 ||
7433 error "($errno) List $FSNAME.$save_fsname is invalid"
7435 local pname=$($LFS getstripe --pool $DIR/$tdir/d0)
7436 [ "$pname" = "$save_fsname" ] ||
7437 error "($errno) Unexpected pool name $pname"
7441 check_mount_and_prep
7443 mkdir $DIR/$tdir || error "(1) Fail to mkdir $DIR/$tdir"
7444 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir ||
7445 error "(2) Fail to copy test-framework.sh"
7447 if ! combined_mgs_mds ; then
7450 do_facet mgs $LCTL pool_new $FSNAME.pool1 ||
7451 error "(3) Fail to create $FSNAME.pool1"
7452 # name the pool name as the fsname
7453 do_facet mgs $LCTL pool_new $FSNAME.$FSNAME ||
7454 error "(4) Fail to create $FSNAME.$FSNAME"
7456 test_103_set_pool $FSNAME OST0000
7458 $LFS setstripe -p $FSNAME $DIR/$tdir/d0 ||
7459 error "(6) Fail to setstripe on $DIR/$tdir/d0"
7461 if ! combined_mgs_mds ; then
7467 test_renamefs mylustre
7469 local save_fsname=$FSNAME
7473 if ! combined_mgs_mds ; then
7476 test_103_check_pool $save_fsname 7
7478 if [ $OSTCOUNT -ge 2 ]; then
7479 test_103_set_pool $save_fsname OST0001
7482 $LFS setstripe -p $save_fsname $DIR/$tdir/f0 ||
7483 error "(16) Fail to setstripe on $DIR/$tdir/f0"
7484 if ! combined_mgs_mds ; then
7495 if ! combined_mgs_mds ; then
7498 test_103_check_pool $save_fsname 17
7500 if ! combined_mgs_mds ; then
7505 test_renamefs $save_fsname
7511 run_test 103 "rename filesystem name"
7513 test_104() { # LU-6952
7514 local mds_mountopts=$MDS_MOUNT_OPTS
7515 local ost_mountopts=$OST_MOUNT_OPTS
7516 local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
7517 local lctl_ver=$(do_facet $SINGLEMDS $LCTL --version |
7520 [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
7521 skip "this test needs utils above 2.9.55"
7523 # specify "acl" in mount options used by mkfs.lustre
7524 if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
7525 MDS_MOUNT_FS_OPTS="acl,user_xattr"
7528 MDS_MOUNT_FS_OPTS="${MDS_MOUNT_FS_OPTS},acl,user_xattr"
7531 echo "mountfsopt: $MDS_MOUNT_FS_OPTS"
7533 #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
7535 if [ -z "$MDS_MOUNT_OPTS" ]; then
7536 MDS_MOUNT_OPTS="-o noacl"
7538 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7541 for num in $(seq $MDSCOUNT); do
7542 start mds$num $(mdsdevname $num) $MDS_MOUNT_OPTS ||
7543 error "Failed to start MDS"
7546 for num in $(seq $OSTCOUNT); do
7547 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
7548 error "Failed to start OST"
7552 setfacl -m "d:$RUNAS_ID:rwx" $MOUNT &&
7553 error "ACL is applied when FS is mounted with noacl."
7555 MDS_MOUNT_OPTS=$mds_mountopts
7556 OST_MOUNT_OPTS=$ost_mountopts
7557 MDS_MOUNT_FS_OPTS=$mds_mountfsopts
7562 run_test 104 "Make sure user defined options are reflected in mount"
7564 error_and_umount() {
7575 mount --bind $DIR $TMP/$tdir || error "mount bind mnt pt failed"
7576 rm -f $TMP/$tdir/$tfile
7577 rm -f $TMP/$tdir/${tfile}1
7579 # Files should not be created in ro bind mount point
7580 # remounting from rw to ro
7581 mount -o remount,ro $TMP/$tdir ||
7582 error_and_umount "readonly remount of bind mnt pt failed"
7583 touch $TMP/$tdir/$tfile &&
7584 error_and_umount "touch succeeds on ro bind mnt pt"
7585 [ -e $TMP/$tdir/$tfile ] &&
7586 error_and_umount "file created on ro bind mnt pt"
7588 # Files should be created in rw bind mount point
7589 # remounting from ro to rw
7590 mount -o remount,rw $TMP/$tdir ||
7591 error_and_umount "read-write remount of bind mnt pt failed"
7592 touch $TMP/$tdir/${tfile}1 ||
7593 error_and_umount "touch fails on rw bind mnt pt"
7594 [ -e $TMP/$tdir/${tfile}1 ] ||
7595 error_and_umount "file not created on rw bind mnt pt"
7596 umount $TMP/$tdir || error "umount of bind mnt pt failed"
7598 cleanup || error "cleanup failed with $?"
7600 run_test 105 "check file creation for ro and rw bind mnt pt"
7607 mkdir -p $DIR/$tdir || error "create $tdir failed"
7608 lfs setstripe -c 1 -i 0 $DIR/$tdir
7609 #define OBD_FAIL_CAT_RECORDS 0x1312
7610 do_facet mds1 $LCTL set_param fail_loc=0x1312 fail_val=$repeat
7612 for ((i = 1; i <= $repeat; i++)); do
7614 #one full plain llog
7615 createmany -o $DIR/$tdir/f- 64768
7617 createmany -u $DIR/$tdir/f- 64768
7619 wait_delete_completed $((TIMEOUT * 7))
7620 #ASSERTION osp_sync_thread() ( thread->t_flags != SVC_RUNNING ) failed
7621 #shows that osp code is buggy
7622 do_facet mds1 $LCTL set_param fail_loc=0 fail_val=0
7626 run_test 106 "check osp llog processing when catalog is wrapped"
7629 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.50) ]] ||
7630 skip "Need MDS version > 2.10.50"
7633 start_mgsmds || error "start_mgsmds failed"
7634 start_ost || error "unable to start OST"
7636 # add unknown configuration parameter.
7637 if [[ $PERM_CMD == *"set_param -P"* ]]; then
7638 cmd="$PERM_CMD ost.$FSNAME-OST0000*.unknown_param"
7640 cmd="$PERM_CMD $FSNAME-OST0000*.ost.unknown_param"
7642 do_facet mgs "$cmd=50"
7643 cleanup_nocli || error "cleanup_nocli failed with $?"
7646 # unknown param should be ignored while mounting.
7647 start_ost || error "unable to start OST after unknown param set"
7649 cleanup || error "cleanup failed with $?"
7651 run_test 107 "Unknown config param should not fail target mounting"
7656 $rcmd rm -rf $tmp > /dev/null 2>&1
7657 $rcmd mkdir -p $tmp/{mnt,images} || error "failed to mkdir remotely"
7659 for facet in $facets; do
7660 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
7661 $rcmd $ZPOOL -f export lustre-$facet > /dev/null 2>&1
7662 $rcmd mkdir $tmp/mnt/$facet ||
7663 error "failed to mkdir $tmp/mnt/$facet"
7664 $rcmd dd if=/dev/zero of=$tmp/images/$facet \
7665 seek=199 bs=1M count=1 ||
7666 error "failed to create $tmp/images/$facet"
7675 local facet=${role}$((idx + 1))
7677 [ $# -eq 5 ] && pool=$5
7679 do_facet $SINGLEMDS $MKFS --fsname=lustre --$mgs \
7680 --$role --index=$idx --replace --backfstype=$bkfs \
7681 --device-size=200000 --reformat $pool $tmp/images/$facet ||
7682 error "failed to mkfs for $facet"
7686 echo "mounting client..."
7687 mount -t lustre ${nid}:/lustre $MOUNT ||
7688 error "failed to mount lustre"
7691 ls -l $MOUNT/local_dir || error "failed to list"
7693 echo "check truncate && write"
7694 echo "dummmmmmmmmmmmm" > $MOUNT/remote_dir/fsx.c ||
7695 error "failed to tuncate & write"
7698 touch $MOUNT/foooo ||
7699 error "failed to create"
7701 echo "check read && write && append"
7702 sha1sum $MOUNT/conf-sanity.sh |
7703 awk '{ print $1 }' > $MOUNT/checksum.new ||
7704 error "failed to read(1)"
7705 sha1sum $MOUNT/remote_dir/unlinkmany.c |
7706 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7707 error "failed to read(2)"
7708 sha1sum $MOUNT/striped_dir/lockahead_test.o |
7709 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7710 error "failed to read(3)"
7713 diff $MOUNT/checksum.new $MOUNT/checksum.src ||
7714 error "failed to verify data"
7724 umount -f $MOUNT || error "failed to umount client"
7725 for facet in $facets; do
7726 $rcmd umount -f $tmp/mnt/$facet ||
7727 error "failed to umount $facet"
7728 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
7729 $rcmd $ZPOOL export -f lustre-$facet ||
7730 error "failed to export lustre-$facet"
7734 $rcmd rm -rf $tmp || error "failed to rm the dir $tmp"
7738 [ "$CLIENTONLY" ] && skip "Client-only testing"
7739 [ $(facet_fstype $SINGLEMDS) != "zfs" ] && skip "zfs only test"
7740 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
7741 skip "Need server version at least 2.10.58"
7746 local tmp=$TMP/$tdir
7747 local rcmd="do_facet $SINGLEMDS"
7748 local facets="mdt1 mdt2 ost1 ost2"
7749 local nid=$($rcmd $LCTL list_nids | head -1)
7752 trap t_108_cleanup EXIT ERR
7755 t_108_mkfs mdt 0 zfs mgs lustre-mdt1/mdt1
7756 t_108_mkfs mdt 1 zfs mgsnode=$nid lustre-mdt2/mdt2
7757 t_108_mkfs ost 0 zfs mgsnode=$nid lustre-ost1/ost1
7758 t_108_mkfs ost 1 zfs mgsnode=$nid lustre-ost2/ost2
7760 for facet in $facets; do
7761 $rcmd zfs set mountpoint=$tmp/mnt/$facet canmount=on \
7762 lustre-$facet/$facet ||
7763 error "failed to zfs set for $facet (1)"
7764 $rcmd zfs mount lustre-$facet/$facet ||
7765 error "failed to local mount $facet"
7766 $rcmd tar jxf $LUSTRE/tests/ldiskfs_${facet}_2_11.tar.bz2 \
7767 --xattrs --xattrs-include="trusted.*" \
7768 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7769 error "failed to untar image for $facet"
7770 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7771 error "failed to cleanup for $facet"
7772 $rcmd zfs umount lustre-$facet/$facet ||
7773 error "failed to local umount $facet"
7774 $rcmd zfs set canmount=off lustre-$facet/$facet ||
7775 error "failed to zfs set $facet (2)"
7778 echo "changing server nid..."
7779 $rcmd mount -t lustre -o nosvc lustre-mdt1/mdt1 $tmp/mnt/mdt1
7780 $rcmd lctl replace_nids lustre-MDT0000 $nid
7781 $rcmd lctl replace_nids lustre-MDT0001 $nid
7782 $rcmd lctl replace_nids lustre-OST0000 $nid
7783 $rcmd lctl replace_nids lustre-OST0001 $nid
7784 $rcmd umount $tmp/mnt/mdt1
7786 for facet in $facets; do
7787 echo "mounting $facet from backup..."
7788 $rcmd mount -t lustre -o abort_recov lustre-$facet/$facet \
7789 $tmp/mnt/$facet || error "failed to mount $facet"
7792 # ZFS backend can detect migration and trigger OI scrub automatically
7793 # sleep 3 seconds for scrub done
7799 run_test 108a "migrate from ldiskfs to ZFS"
7802 [ "$CLIENTONLY" ] && skip "Client-only testing"
7803 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] && skip "ldiskfs only test"
7804 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
7805 skip "Need server version at least 2.10.58"
7810 local tmp=$TMP/$tdir
7811 local rcmd="do_facet $SINGLEMDS"
7812 local facets="mdt1 mdt2 ost1 ost2"
7813 local scrub_list="MDT0000 MDT0001 OST0000 OST0001"
7814 local nid=$($rcmd $LCTL list_nids | head -1)
7817 trap t_108_cleanup EXIT ERR
7820 t_108_mkfs mdt 0 ldiskfs mgs
7821 t_108_mkfs mdt 1 ldiskfs mgsnode=$nid
7822 t_108_mkfs ost 0 ldiskfs mgsnode=$nid
7823 t_108_mkfs ost 1 ldiskfs mgsnode=$nid
7825 for facet in $facets; do
7826 $rcmd mount -t ldiskfs -o loop $tmp/images/$facet \
7828 error "failed to local mount $facet"
7830 $rcmd tar jxf $LUSTRE/tests/zfs_${facet}_2_11.tar.bz2 \
7831 --xattrs --xattrs-include="*.*" \
7832 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7833 error "failed to untar image for $facet"
7834 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7835 error "failed to cleanup for $facet"
7836 $rcmd umount $tmp/mnt/$facet ||
7837 error "failed to local umount $facet"
7840 echo "changing server nid..."
7841 $rcmd mount -t lustre -o nosvc,loop $tmp/images/mdt1 $tmp/mnt/mdt1
7842 $rcmd lctl replace_nids lustre-MDT0000 $nid
7843 $rcmd lctl replace_nids lustre-MDT0001 $nid
7844 $rcmd lctl replace_nids lustre-OST0000 $nid
7845 $rcmd lctl replace_nids lustre-OST0001 $nid
7846 $rcmd umount $tmp/mnt/mdt1
7848 for facet in $facets; do
7849 echo "mounting $facet from backup..."
7850 $rcmd mount -t lustre -o loop,abort_recov $tmp/images/$facet \
7851 $tmp/mnt/$facet || error "failed to mount $facet"
7854 for facet in $scrub_list; do
7855 $rcmd $LCTL lfsck_start -M lustre-$facet -t scrub ||
7856 error "failed to start OI scrub on $facet"
7859 # sleep 3 seconds for scrub done
7865 run_test 108b "migrate from ZFS to ldiskfs"
7869 # set number of permanent parameters
7871 test_109_set_params() {
7874 set_persistent_param_and_check mds \
7875 "mdd.$fsname-MDT0000.atime_diff" \
7876 "$fsname-MDT0000.mdd.atime_diff" \
7878 set_persistent_param_and_check mds \
7879 "mdd.$fsname-MDT0000.atime_diff" \
7880 "$fsname-MDT0000.mdd.atime_diff" \
7882 set_persistent_param_and_check client \
7883 "llite.$fsname*.max_read_ahead_mb" \
7884 "$fsname.llite.max_read_ahead_mb" \
7886 set_persistent_param_and_check client \
7887 "llite.$fsname*.max_read_ahead_mb" \
7888 "$fsname.llite.max_read_ahead_mb" \
7890 create_pool $fsname.pool1 || error "create pool failed"
7891 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
7892 error "pool_add failed"
7893 do_facet mgs $LCTL pool_remove $fsname.pool1 OST0000 ||
7894 error "pool_remove failed"
7895 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
7896 error "pool_add failed"
7900 # check permanent parameters
7902 test_109_test_params() {
7905 local atime_diff=$(do_facet mds $LCTL \
7906 get_param -n mdd.$fsname-MDT0000.atime_diff)
7907 [ $atime_diff == 63 ] || error "wrong mdd parameter after clear_conf"
7908 local max_read_ahead_mb=$(do_facet client $LCTL \
7909 get_param -n llite.$fsname*.max_read_ahead_mb)
7910 [ $max_read_ahead_mb == 64 ] ||
7911 error "wrong llite parameter after clear_conf"
7912 local ost_in_pool=$(do_facet mds $LCTL pool_list $fsname.pool1 |
7913 grep -v "^Pool:" | sed 's/_UUID//')
7914 [ $ost_in_pool = "$fsname-OST0000" ] ||
7915 error "wrong pool after clear_conf"
7919 # run lctl clear_conf, store CONFIGS before and after that
7921 test_109_clear_conf()
7923 local clear_conf_arg=$1
7926 if ! combined_mgs_mds ; then
7928 stop_mgs || error "stop_mgs failed"
7929 start_mgs "-o nosvc" || error "start_mgs nosvc failed"
7931 mgsdev=$(mdsdevname 1)
7932 start_mdt 1 "-o nosvc" || error "start_mdt 1 nosvc failed"
7935 do_facet mgs "rm -rf $TMP/${tdir}/conf1; mkdir -p $TMP/${tdir}/conf1;" \
7936 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf1\\\" \
7940 # the command being tested
7942 do_facet mgs $LCTL clear_conf $clear_conf_arg ||
7943 error "clear_conf failed"
7944 if ! combined_mgs_mds ; then
7945 stop_mgs || error "stop_mgs failed"
7947 stop_mdt 1 || error "stop_mdt 1 failed"
7950 do_facet mgs "rm -rf $TMP/${tdir}/conf2; mkdir -p $TMP/${tdir}/conf2;" \
7951 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf2\\\" \
7955 test_109_file_shortened() {
7957 local sizes=($(do_facet mgs "stat -c %s " \
7958 "$TMP/${tdir}/conf1/CONFIGS/$file" \
7959 "$TMP/${tdir}/conf2/CONFIGS/$file"))
7960 [ ${sizes[1]} -lt ${sizes[0]} ] && return 0
7966 [ "$(facet_fstype mgs)" == "zfs" ] &&
7967 skip "LU-8727: no implementation for ZFS"
7971 client_up || error "client_up failed"
7974 # set number of permanent parameters
7976 test_109_set_params $FSNAME
7978 umount_client $MOUNT || error "umount_client failed"
7979 stop_ost || error "stop_ost failed"
7980 stop_mds || error "stop_mds failed"
7982 test_109_clear_conf $FSNAME
7984 # make sure that all configs are cleared
7986 test_109_file_shortened $FSNAME-MDT0000 ||
7987 error "failed to clear MDT0000 config"
7988 test_109_file_shortened $FSNAME-client ||
7989 error "failed to clear client config"
7994 # check that configurations are intact
7996 test_109_test_params $FSNAME
8001 destroy_test_pools || error "destroy test pools failed"
8005 run_test 109a "test lctl clear_conf fsname"
8009 [ "$(facet_fstype mgs)" == "zfs" ] &&
8010 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-MDT0000
8027 # make sure that only one config is 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 109b "test lctl clear_conf one config"
8052 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
8053 skip "Only applicable to ldiskfs-based MDTs"
8055 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8056 skip "large_dir option is not supported on MDS"
8057 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8058 skip "large_dir option is not supported on OSS"
8060 stopall # stop all targets before modifying the target counts
8061 stack_trap "MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT" EXIT
8065 # ext4_dir_entry_2 struct size:264
8066 # dx_root struct size:8
8067 # dx_node struct size:8
8068 # dx_entry struct size:8
8069 # For 1024 bytes block size.
8070 # First level directory entries: 126
8071 # Second level directory entries: 127
8072 # Entries in leaf: 3
8073 # For 2 levels limit: 48006
8074 # For 3 levels limit : 6096762
8075 # Create 80000 files to safely exceed 2-level htree limit.
8076 CONF_SANITY_110_LINKS=${CONF_SANITY_110_LINKS:-80000}
8078 # can fit at most 3 filenames per 1KB leaf block, but each
8079 # leaf/index block will only be 3/4 full before split at each level
8080 (( MDSSIZE < CONF_SANITY_110_LINKS / 3 * 4/3 * 4/3 )) &&
8081 CONF_SANITY_110_LINKS=$((MDSSIZE * 3 * 3/4 * 3/4))
8083 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8084 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8085 if [[ $opts != *mkfsoptions* ]]; then
8086 opts+=" --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536\\\""
8088 opts="${opts//--mkfsoptions=\\\"/ \
8089 --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536 }"
8091 echo "MDT params: $opts"
8092 add mds1 $opts || error "add mds1 failed with new params"
8093 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8095 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8096 --reformat $(ostdevname 1) $(ostvdevname 1)"
8098 if [[ $opts != *mkfsoptions* ]]; then
8099 opts+=" --mkfsoptions=\\\"-O large_dir\\\" "
8101 opts="${opts//--mkfsoptions=\\\"/ \
8102 --mkfsoptions=\\\"-O large_dir }"
8104 echo "OST params: $opts"
8105 add ost1 $opts || error "add ost1 failed with new params"
8106 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8108 MOUNT_2=yes mountcli || error "mount clients failed"
8110 mkdir -v $DIR/$tdir || error "cannot create $DIR/$tdir"
8111 local pids count=0 group=0
8113 echo "creating $CONF_SANITY_110_LINKS in total"
8114 while (( count < CONF_SANITY_110_LINKS )); do
8115 local len=$((253 - $(wc -c <<<"$tfile-$group-40000-")))
8116 local dir=DIR$((group % 2 + 1))
8117 local target=${!dir}/$tdir/$tfile-$group
8118 local long=$target-$(generate_name $len)-
8119 local create=$((CONF_SANITY_110_LINKS - count))
8121 (( create > 40000 )) && create=40000
8122 touch $target || error "creating $target failed"
8123 echo "creating $create hard links to $target"
8124 createmany -l $target $long $create &
8127 count=$((count + create))
8128 group=$((group + 1))
8130 echo "waiting for PIDs$pids to complete"
8131 wait $pids || error "createmany failed after $group groups"
8135 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8137 run_test 110 "Adding large_dir with 3-level htree"
8140 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
8141 skip "Only applicable to ldiskfs-based MDTs"
8143 is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
8144 skip "This test can not be executed on flakey dev"
8146 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8147 skip "large_dir option is not supported on MDS"
8149 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8150 skip "large_dir option is not supported on OSS"
8152 # cleanup before changing target counts
8154 stack_trap "MDSSIZE=$MDSSIZE MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT" EXIT
8157 (( MDSSIZE < 2400000 )) && MDSSIZE=2400000 # need at least 2.4GB
8159 local mdsdev=$(mdsdevname 1)
8161 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8162 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8163 if [[ $opts != *mkfsoptions* ]]; then
8164 opts+=" --mkfsoptions=\\\"-O large_dir -i 1048576 \\\" "
8166 opts="${opts//--mkfsoptions=\\\"/ \
8167 --mkfsoptions=\\\"-O large_dir -i 1048576 }"
8169 echo "MDT params: $opts"
8170 __touch_device mds 1
8171 add mds1 $opts || error "add mds1 failed with new params"
8172 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8174 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8175 --reformat $(ostdevname 1) $(ostvdevname 1)"
8176 if [[ $opts != *mkfsoptions* ]]; then
8177 opts+=" --mkfsoptions=\\\"-O large_dir \\\""
8179 opts="${opts//--mkfsoptions=\\\"/ --mkfsoptions=\\\"-O large_dir }"
8181 echo "OST params: $opts"
8182 __touch_device ost 1
8183 add ost1 $opts || error "add ost1 failed with new params"
8184 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8186 MOUNT_2=yes mountcli
8187 mkdir $DIR/$tdir || error "cannot create $DIR/$tdir"
8189 lfs df -i $DIR/$tdir
8193 local start=$SECONDS
8195 local dirmax=$((2 << 30))
8201 while (( !needskip & dirsize < dirmax )); do
8204 for cli in ${CLIENTS//,/ }; do
8205 local len=$((253 - $(wc -c <<<"$cli-$group-60000-")))
8206 local target=$cli-$group
8207 local long=$DIR/$tdir/$target-$(generate_name $len)-
8209 RPWD=$DIR/$tdir do_node $cli touch $target ||
8210 error "creating $target failed"
8211 echo "creating 60000 hardlinks to $target"
8212 RPWD=$DIR/$tdir do_node $cli createmany -l $target $long 60000 &
8215 group=$((group + 1))
8217 long=$DIR2/$tdir/$target-$(generate_name $len)-
8219 RPWD=$DIR2/$tdir do_node $cli touch $target ||
8220 error "creating $target failed"
8221 echo "creating 60000 hardlinks to $target"
8222 RPWD=$DIR2/$tdir do_node $cli createmany -l $target $long 60000 &
8225 group=$((group + 1))
8227 echo "waiting for PIDs$pids to complete"
8228 wait $pids || error "createmany failed after $group groups"
8229 dirsize=$(stat -c %s $DIR/$tdir)
8230 taken=$((SECONDS - start))
8231 rate=$((dirsize / taken))
8232 left=$(((dirmax - dirsize) / rate))
8233 num=$((group * 60000))
8234 echo "estimate ${left}s left after $num files / ${taken}s"
8235 # if the estimated time remaining is too large (it may change
8236 # over time as the create rate is not constant) then exit
8237 # without declaring a failure.
8238 (( left > 1200 )) && needskip=1
8243 (( $needskip )) && skip "ETA ${left}s after $num files / ${taken}s is too long"
8245 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8247 run_test 111 "Adding large_dir with over 2GB directory"
8254 rm -f $TMP/$tdir/lustre-mdt
8259 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
8260 skip "Only applicable to ldiskfs-based MDTs"
8263 IMAGESIZE=$((3072 << 30)) # 3072 GiB
8266 # We need MDT size 3072GB, because it is smallest
8267 # partition that can store 2B inodes
8268 do_facet $SINGLEMDS "mkdir -p $TMP/$tdir"
8269 local mdsimgname=$TMP/$tdir/lustre-mdt
8270 do_facet $SINGLEMDS "rm -f $mdsimgname"
8271 do_facet $SINGLEMDS "touch $mdsimgname"
8272 trap cleanup_115 RETURN EXIT
8273 do_facet $SINGLEMDS "$TRUNCATE $mdsimgname $IMAGESIZE" ||
8274 skip "Backend FS doesn't support sparse files"
8275 local mdsdev=$(do_facet $SINGLEMDS "losetup -f")
8276 do_facet $SINGLEMDS "losetup $mdsdev $mdsimgname"
8278 local mds_opts="$(mkfs_opts mds1 ${mdsdev}) --device-size=$IMAGESIZE \
8279 --mkfsoptions='-O lazy_itable_init,ea_inode,^resize_inode,meta_bg \
8281 add mds1 $mds_opts --mgs --reformat $mdsdev ||
8282 skip_env "format large MDT failed"
8283 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
8284 --reformat $(ostdevname 1) $(ostvdevname 1)
8286 start $SINGLEMDS ${mdsdev} $MDS_MOUNT_OPTS || error "start MDS failed"
8287 start_ost || error "start OSS failed"
8288 mount_client $MOUNT || error "mount client failed"
8290 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir fail"
8291 for goal in $(do_facet $SINGLEMDS "ls /sys/fs/ldiskfs/*/inode_goal"); do
8292 do_facet $SINGLEMDS "echo 2147483947 >> $goal; grep . $goal"
8295 touch $DIR/$tdir/$tfile
8297 # Add > 5k bytes to xattr
8298 for i in {1..30}; do
8299 ln $DIR/$tdir/$tfile $DIR/$tdir/$(printf "link%0250d" $i) ||
8300 error "Can't make link"
8305 local inode_num=$(do_facet $SINGLEMDS \
8306 "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsimgname" |
8307 awk '/link =/ { print $4 }' |
8308 sed -e 's/>//' -e 's/<//' -e 's/\"//')
8309 echo "inode num: $inode_num"
8310 [ $inode_num -ge 2147483947 ] || error "inode $inode_num too small"
8311 do_facet $SINGLEMDS "losetup -d $mdsdev"
8314 run_test 115 "Access large xattr with inodes number over 2TB"
8317 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] && skip "ldiskfs only test"
8318 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.59) ] &&
8319 skip "Need server version at least 2.10.59"
8320 do_facet $SINGLEMDS which mkfs.xfs ||
8321 skip_env "No mkfs.xfs installed"
8326 local tmpmnt=$TMP/$tdir
8327 local mdtimg=$tfile-mdt0
8329 do_facet $SINGLEMDS mkdir -p $tmpmnt
8330 stack_trap "do_facet $SINGLEMDS rmdir $tmpmnt" EXIT
8332 do_facet $SINGLEMDS touch $TMP/$mdtimg
8333 stack_trap "do_facet $SINGLEMDS rm -f $TMP/$mdtimg" EXIT
8334 do_facet $SINGLEMDS mkfs -t xfs -d file,size=1t,name=$TMP/$mdtimg ||
8335 error "mkfs temporary xfs image"
8337 do_facet $SINGLEMDS mount $TMP/$mdtimg $tmpmnt ||
8338 error "mount temporary xfs image"
8339 stack_trap "do_facet $SINGLEMDS umount $tmpmnt" EXIT
8340 local old_mdssize=$MDSSIZE
8341 local old_mdsisize=$MDSISIZE
8343 MDSSIZE=$((17 * 1024 * 1024 * 1024)) # 17T MDT
8344 MDSISIZE=$((16 << 20))
8345 local opts17t="$(mkfs_opts $SINGLEMDS)"
8347 MDSSIZE=$old_mdssize
8348 MDSISIZE=$old_mdsisize
8349 do_facet $SINGLEMDS $MKFS $opts17t $tmpmnt/$mdtimg ||
8350 error "failed to mkfs for $tmpmnt/$mdtimg"
8352 do_facet $SINGLEMDS $TUNE2FS -l $tmpmnt/$mdtimg |
8353 grep -qw 'features.*extent' || error "extent should be enabled"
8355 run_test 116 "big size MDT support"
8359 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.nrs_policies=fifo"
8360 do_facet ost1 "$LCTL get_param -n ost.OSS.ost_io.nrs_tbf_rule" &&
8361 error "get_param should fail"
8362 cleanup || error "cleanup failed with rc $?"
8364 run_test 117 "lctl get_param return errors properly"
8366 test_120() { # LU-11130
8367 [ "$MDSCOUNT" -lt 2 ] && skip "mdt count < 2"
8368 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
8369 skip "ldiskfs only test"
8370 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
8371 skip "Need DNE2 capable MD target with LU-11130 fix"
8375 local mds1host=$(facet_active_host mds1)
8376 local mds1dev=$(mdsdevname 1)
8378 $LFS mkdir -i 1 $DIR/$tdir
8379 $LFS mkdir -i 0 $DIR/$tdir/mds1dir
8381 ln -s foo $DIR/$tdir/bar
8382 mv $DIR/$tdir/bar $DIR/$tdir/mds1dir/bar2 ||
8383 error "cross-target rename failed"
8387 run_e2fsck $mds1host $mds1dev "-n"
8389 run_test 120 "cross-target rename should not create bad symlinks"
8392 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
8393 [[ $(lustre_version_code ost1) -ge $(version_code 2.11.53) ]] ||
8394 skip "Need OST version at least 2.11.53"
8397 LOAD_MODULES_REMOTE=true load_modules
8398 #define OBD_FAIL_OFD_SET_OID 0x1e0
8399 do_facet ost1 $LCTL set_param fail_loc=0x00001e0
8402 $LFS mkdir -i1 -c1 $DIR/$tdir
8403 $LFS setstripe -i0 -c1 $DIR/$tdir
8404 do_facet ost1 $LCTL set_param fail_loc=0
8405 createmany -o $DIR/$tdir/file_ 1000 ||
8406 error "Fail to create a new sequence"
8410 run_test 122 "Check OST sequence update"
8413 remote_mgs_nodsh && skip "remote MGS with nodsh"
8414 [ -d $MOUNT/.lustre ] || setupall
8416 # test old logid format until removal from llog_ioctl.c::str2logid()
8417 if [ $MGS_VERSION -lt $(version_code 3.1.53) ]; then
8418 do_facet mgs $LCTL dl | grep MGS
8419 do_facet mgs "$LCTL --device %MGS llog_print \
8420 \\\\\\\$$FSNAME-client 1 10" ||
8421 error "old llog_print failed"
8424 # test new logid format
8425 if [ $MGS_VERSION -ge $(version_code 2.9.53) ]; then
8426 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
8427 error "new llog_print failed"
8430 run_test 123aa "llog_print works with FIDs and simple names"
8433 remote_mgs_nodsh && skip "remote MGS with nodsh"
8434 [[ $MGS_VERSION -gt $(version_code 2.11.51) ]] ||
8435 skip "Need server with working llog_print support"
8437 [ -d $MOUNT/.lustre ] || setupall
8442 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
8443 do_facet mgs $LCTL set_param -P jobid_name="testname"
8445 yaml=$(do_facet mgs $LCTL --device MGS llog_print params |
8446 grep jobid_name | tail -n 1)
8448 local param=$(awk '{ print $10 }' <<< "$yaml")
8449 local val=$(awk '{ print $12 }' <<< "$yaml")
8450 #return to the default
8451 do_facet mgs $LCTL set_param -P jobid_name=$orig_val
8452 [ $val = "testname" ] || error "bad value: $val"
8453 [ $param = "jobid_name," ] || error "Bad param: $param"
8455 run_test 123ab "llog_print params output values from set_param -P"
8457 test_123ac() { # LU-11566
8458 remote_mgs_nodsh && skip "remote MGS with nodsh"
8459 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8460 skip "Need 'lctl llog_print --start' on MGS"
8465 [ -d $MOUNT/.lustre ] || setupall
8467 # - { index: 10, event: add_uuid, nid: 192.168.20.1@tcp(0x20000c0a81401,
8468 # node: 192.168.20.1@tcp }
8469 do_facet mgs $LCTL --device MGS \
8470 llog_print --start $start --end $end $FSNAME-client | tr -d , |
8471 while read DASH BRACE INDEX idx EVENT BLAH BLAH BLAH; do
8472 (( idx >= start )) || error "llog_print index $idx < $start"
8473 (( idx <= end )) || error "llog_print index $idx > $end"
8476 run_test 123ac "llog_print with --start and --end"
8478 test_123ad() { # LU-11566
8479 remote_mgs_nodsh && skip "remote MGS with nodsh"
8480 # older versions of lctl may not print all records properly
8481 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8482 skip "Need 'lctl llog_print --start' on MGS"
8484 [ -d $MOUNT/.lustre ] || setupall
8486 # append a new record, to avoid issues if last record was cancelled
8487 local old=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
8488 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$old
8490 # logid: [0x3:0xa:0x0]:0
8494 local num=$(do_facet mgs $LCTL --device MGS llog_info $FSNAME-client |
8495 awk '/last_index:/ { print $2 - 1 }')
8497 # - { index: 71, event: set_timeout, num: 0x14, param: sys.timeout=20 }
8498 local last=$(do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
8499 tail -1 | awk '{ print $4 }' | tr -d , )
8500 (( last == num )) || error "llog_print only showed $last/$num records"
8502 run_test 123ad "llog_print shows all records"
8506 local yaml_file="$TMP/$tfile.yaml"
8507 do_facet mgs rm "$yaml_file"
8508 local cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist" |
8509 sed 's/config_log://')
8511 # set jobid_var to a different value for test
8512 local orig_val=$(do_facet mgs $LCTL get_param jobid_var)
8513 do_facet mgs $LCTL set_param -P jobid_var="testname"
8515 for i in $cfgfiles params; do
8516 do_facet mgs "lctl --device MGS llog_print ${i} >> $yaml_file"
8519 echo "Unmounting FS"
8529 # Reapply the config from before
8530 echo "Setting configuration parameters"
8531 do_facet mgs "lctl set_param -F $yaml_file"
8533 local set_val=$(do_facet mgs $LCTL get_param jobid_var)
8534 do_facet mgs $LCTL set_param -P $orig_val
8536 [ $set_val == "jobid_var=testname" ] ||
8537 error "$set_val is not testname"
8539 do_facet mgs rm "$yaml_file"
8541 run_test 123F "clear and reset all parameters using set_param -F"
8545 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
8546 [ -z $mds2failover_HOST ] && skip "needs MDT failover setup"
8552 if combined_mgs_mds; then
8553 start_mdt 1 "-o nosvc" ||
8554 error "starting mds with nosvc option failed"
8556 local nid=$(do_facet mds2 $LCTL list_nids | head -1)
8557 local failover_nid=$(do_node $mds2failover_HOST $LCTL list_nids | head -1)
8558 do_facet mgs $LCTL replace_nids $FSNAME-MDT0001 $nid:$failover_nid ||
8559 error "replace_nids execution error"
8561 if combined_mgs_mds; then
8567 echo "lfs setdirstripe"
8568 $LFS setdirstripe -i 1 $MOUNT/$tdir || error "setdirstirpe error"
8571 run_test 124 "check failover after replace_nids"
8573 if ! combined_mgs_mds ; then
8579 # restore the values of MDSSIZE and OSTSIZE
8580 MDSSIZE=$STORED_MDSSIZE
8581 OSTSIZE=$STORED_OSTSIZE
8585 check_and_cleanup_lustre