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 if combined_mgs_mds ; then
489 skip "needs separate mgs and mds"
493 grep " $MOUNT " /etc/mtab &&
494 error false "unexpected entry in mtab before mount" && return 10
497 start_ost || error "OST start failed"
498 mount_client $MOUNT &
500 echo client_mount pid is $pid
504 if ! ps -f -p $pid >/dev/null; then
507 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
508 error "mount returns $rc, expected to hang"
510 cleanup || error "cleanup failed with $?"
515 start_mds || error "start MDS failed"
517 # mount should succeed after start mds
519 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
520 cleanup || error "final call to cleanup failed with rc $?"
522 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
526 [ $(lustre_version_code client) -lt $(version_code 2.9.53) ] &&
527 { skip "automount of debugfs missing before 2.9.53" && return 0; }
528 umount /sys/kernel/debug
529 $LCTL get_param -n devices | egrep -v "error" && \
530 error "lctl can't access debugfs data"
531 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
533 run_test 5g "handle missing debugfs"
538 mount_client $MOUNT || error "mount_client $MOUNT failed"
539 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
540 cleanup || error "cleanup failed with rc $?"
542 run_test 6 "manual umount, then mount again"
547 cleanup_nocli || error "cleanup_nocli failed with $?"
549 run_test 7 "manual umount, then cleanup"
553 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
554 check_mount2 || error "check_mount2 failed"
555 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
556 cleanup || error "cleanup failed with rc $?"
558 run_test 8 "double mount setup"
561 start_ost || error "OST start failed"
563 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
564 error "do_facet ost1 set_param inode trace failed."
565 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
566 error "do_facet ost1 set_param debug mds ost failed."
568 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
569 if [ "$CHECK_PTLDEBUG" ] && { \
570 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
571 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
572 echo "lnet.debug success"
574 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
576 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
577 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
578 echo "lnet.subsystem_debug success"
580 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
582 stop_ost || error "Unable to stop OST1"
584 run_test 9 "test ptldebug and subsystem for mkfs"
587 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
588 # But with new MDS stack we don't care about the mode of local objects
589 # anymore, so this test is removed. See bug 22944 for more details.
593 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
594 skip "ldiskfs only test"
599 check_mount || error "check_mount failed"
600 cleanup || error "cleanup failed with rc $?"
602 echo "Remove mds config log"
603 if ! combined_mgs_mds ; then
607 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
608 $(mgsdevname) || return \$?" ||
609 error "do_facet mgs failed with $?"
611 if ! combined_mgs_mds ; then
615 start_ost || error "OST start failed"
616 start_mds && error "MDS start succeeded, but should fail"
619 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
622 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
623 skip "ldiskfs only test"
627 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
632 # check if current MDSSIZE is large enough
633 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
634 log "use MDSSIZE=$MDSSIZE"
636 # check if the global config has a large enough MDSSIZE
637 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
638 [ $STORED_MDSSIZE -ge $MIN ] &&
639 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
640 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
642 # check if the block device is large enough
643 is_blkdev $SINGLEMDS $MDSDEV $MIN
644 local large_enough=$?
645 if [ -n "$OK" ]; then
646 [ $large_enough -ne 0 ] && OK=""
648 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
649 log "use device $MDSDEV with MIN=$MIN"
652 # check if a loopback device has enough space for fs metadata (5%)
654 if [ -z "$OK" ]; then
655 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
656 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
657 awk '($1 != "Filesystem") { print $4 }')
658 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
659 OK=1 && myMDSSIZE=$MIN &&
660 log "use file $MDSDEV with MIN=$MIN"
663 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
665 echo "mount mds with large journal..."
667 local OLD_MDSSIZE=$MDSSIZE
671 echo "mount lustre system..."
673 check_mount || error "check_mount failed"
675 echo "check journal size..."
676 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
677 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
678 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
680 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
683 cleanup || error "cleanup failed with rc $?"
688 run_test 18 "check mkfs creates large journals"
691 start_mds || error "MDS start failed"
692 stop_mds || error "Unable to stop MDS"
694 run_test 19a "start/stop MDS without OSTs"
697 start_ost || error "Unable to start OST1"
698 stop_ost -f || error "Unable to stop OST1"
700 run_test 19b "start/stop OSTs without MDS"
703 # first format the ost/mdt
704 start_mds || error "MDS start failed"
705 start_ost || error "Unable to start OST1"
706 mount_client $MOUNT || error "mount_client $MOUNT failed"
707 check_mount || error "check_mount failed"
708 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
709 remount_client ro $MOUNT || error "remount_client with ro failed"
710 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
711 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
712 remount_client rw $MOUNT || error "remount_client with rw failed"
713 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
714 MCNT=$(grep -c $MOUNT' ' /etc/mtab)
715 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
717 stop_mds || error "Unable to stop MDS"
718 stop_ost || error "Unable to stop OST1"
720 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
723 start_mds || error "MDS start failed"
724 start_ost || error "unable to start OST1"
725 wait_osc_import_state mds ost FULL
726 stop_ost || error "unable to stop OST1"
727 stop_mds || error "unable to stop MDS"
729 run_test 21a "start mds before ost, stop ost first"
732 start_ost || error "unable to start OST1"
733 start_mds || error "MDS start failed"
734 wait_osc_import_state mds ost FULL
735 stop_mds || error "unable to stop MDS"
736 stop_ost || error "unable to stop OST1"
738 run_test 21b "start ost before mds, stop mds first"
741 start_ost || error "Unable to start OST1"
742 start_mds || error "MDS start failed"
743 start_ost2 || error "Unable to start OST2"
744 wait_osc_import_state mds ost2 FULL
745 stop_ost || error "Unable to stop OST1"
746 stop_ost2 || error "Unable to stop OST2"
747 stop_mds || error "Unable to stop MDS"
748 #writeconf to remove all ost2 traces for subsequent tests
749 writeconf_or_reformat
751 run_test 21c "start mds between two osts, stop mds last"
754 if combined_mgs_mds ; then
755 skip "need separate mgs device" && return 0
761 start_mgs || error "unable to start MGS"
762 start_ost || error "unable to start OST1"
763 start_ost2 || error "unable to start OST2"
764 start_mds || error "MDS start failed"
765 wait_osc_import_state mds ost2 FULL
767 stop_ost || error "Unable to stop OST1"
768 stop_ost2 || error "Unable to stop OST2"
769 stop_mds || error "Unable to stop MDS"
771 #writeconf to remove all ost2 traces for subsequent tests
772 writeconf_or_reformat
773 start_mgs || error "unable to start MGS"
775 run_test 21d "start mgs then ost and then mds"
778 MGSNID="$saved_mgsnid"
780 echo "stopping fs2mgs ..."
781 stop $fs2mgs -f || true
784 test_21e() { # LU-5863
785 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
786 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
787 skip_env "mixed loopback and real device not working" && return
790 local fs2mdsdev=$(mdsdevname 1_2)
791 local fs2ostdev=$(ostdevname 1_2)
792 local fs3ostdev=$(ostdevname 2_2)
794 local fs2mdsvdev=$(mdsvdevname 1_2)
795 local fs2ostvdev=$(ostvdevname 1_2)
796 local fs3ostvdev=$(ostvdevname 2_2)
798 # temporarily use fs3ost as fs2mgs
800 local fs2mgsdev=$fs3ostdev
801 local fs2mgsvdev=$fs3ostvdev
803 local fsname=test1234
805 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
806 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
807 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
808 error "start fs2mgs failed"
810 local saved_mgsnid="$MGSNID"
811 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
813 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
814 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
815 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
816 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
818 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
819 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
821 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
822 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
823 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
827 run_test 21e "separate MGS and MDS"
830 start_mds || error "MDS start failed"
832 echo "Client mount with ost in logs, but none running"
833 start_ost || error "unable to start OST1"
834 # wait until mds connected to ost and open client connection
835 wait_osc_import_state mds ost FULL
836 stop_ost || error "unable to stop OST1"
837 mount_client $MOUNT || error "mount_client $MOUNT failed"
838 # check_mount will block trying to contact ost
839 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
840 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
841 umount_client $MOUNT -f
844 echo "Client mount with a running ost"
845 start_ost || error "unable to start OST1"
847 # if gss enabled, wait full time to let connection from
848 # mds to ost be established, due to the mismatch between
849 # initial connect timeout and gss context negotiation timeout.
850 # This perhaps could be remove after AT landed.
851 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
852 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
854 mount_client $MOUNT || error "mount_client $MOUNT failed"
855 wait_osc_import_state mds ost FULL
856 wait_osc_import_ready client ost
857 check_mount || error "check_mount failed"
860 cleanup || error "cleanup failed with rc $?"
862 run_test 22 "start a client before osts (should return errs)"
864 test_23a() { # was test_23
867 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
868 # force down client so that recovering mds waits for reconnect
869 local running=$(grep -c $MOUNT /proc/mounts) || true
870 if [ $running -ne 0 ]; then
871 echo "Stopping client $MOUNT (opts: -f)"
875 # enter recovery on failed mds
876 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
877 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
878 # try to start a new client
879 mount_client $MOUNT &
881 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
882 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
883 grep -v grep | awk '{print $2}')
884 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
886 ps --ppid $MOUNT_LUSTRE_PID
887 echo "waiting for mount to finish"
889 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
890 # SIGTERM works but it does not spread to offspring processses
891 kill -s TERM $MOUNT_PID
892 kill -s TERM $MOUNT_LUSTRE_PID
893 # we can not wait $MOUNT_PID because it is not a child of this shell
899 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
901 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
902 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
905 [ -z "$PID1" -a -z "$PID2" ] && break
906 echo "waiting for mount to finish ... "
907 WAIT=$(( WAIT + sleep))
909 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
910 error "MOUNT_PID $MOUNT_PID and "\
911 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
914 cleanup || error "cleanup failed with rc $?"
916 run_test 23a "interrupt client during recovery mount delay"
918 test_23b() { # was test_23
919 start_mds || error "MDS start failed"
920 start_ost || error "Unable to start OST1"
921 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
922 $LCTL set_param fail_loc=0x80000313
924 cleanup || error "cleanup failed with rc $?"
926 run_test 23b "Simulate -EINTR during mount"
929 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
931 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
932 is_blkdev $SINGLEMDS $MDSDEV &&
933 skip_env "mixed loopback and real device not working" && return
936 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
938 local fs2mdsdev=$(mdsdevname 1_2)
939 local fs2ostdev=$(ostdevname 1_2)
940 local fs2mdsvdev=$(mdsvdevname 1_2)
941 local fs2ostvdev=$(ostvdevname 1_2)
944 # LU-9733 test fsname started with numbers as well
945 local FSNAME2=969362ae
947 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
948 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
950 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
951 --reformat $fs2ostdev $fs2ostvdev || exit 10
954 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
955 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
956 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
957 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
959 # LU-9733 test fsname started with numbers
960 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
961 changelog_register -n) ||
962 error "register changelog failed"
964 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
965 changelog_deregister $cl_user ||
966 error "deregister changelog failed"
968 check_mount || error "check_mount failed"
969 # files written on 1 should not show up on 2
970 cp /etc/passwd $DIR/$tfile
972 [ -e $MOUNT2/$tfile ] && error "File bleed"
975 cp /etc/passwd $MOUNT2/$tfile ||
976 error "cp /etc/passwd $MOUNT2/$tfile failed"
977 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
978 # 2 is actually mounted
979 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
981 facet_failover fs2mds
982 facet_failover fs2ost
985 # the MDS must remain up until last MDT
987 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
988 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
989 [ -z "$MDS" ] && error "No MDT"
991 cleanup_nocli || error "cleanup_nocli failed with rc $?"
993 run_test 24a "Multiple MDTs on a single node"
996 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
998 if [ -z "$fs2mds_DEV" ]; then
999 local dev=${SINGLEMDS}_dev
1000 local MDSDEV=${!dev}
1001 is_blkdev $SINGLEMDS $MDSDEV &&
1002 skip_env "mixed loopback and real device not working" && return
1005 local fs2mdsdev=$(mdsdevname 1_2)
1006 local fs2mdsvdev=$(mdsvdevname 1_2)
1008 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1009 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1011 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS &&
1012 error "start MDS should fail"
1014 cleanup || error "cleanup failed with rc $?"
1016 run_test 24b "Multiple MGSs on a single node (should return err)"
1020 check_mount || error "check_mount failed"
1021 local MODULES=$($LCTL modules | awk '{ print $2 }')
1022 rmmod $MODULES 2>/dev/null || true
1023 cleanup || error "cleanup failed with $?"
1025 run_test 25 "Verify modules are referenced"
1029 # we need modules before mount for sysctl, so make sure...
1030 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1031 #define OBD_FAIL_MDS_FS_SETUP 0x135
1032 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1033 start_mds && error "MDS started but should not have started"
1034 $LCTL get_param -n devices
1035 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1036 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1037 # start mds to drop writeconf setting
1038 start_mds || error "Unable to start MDS"
1039 stop_mds || error "Unable to stop MDS"
1040 unload_modules_conf || error "unload_modules_conf failed with $?"
1042 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1045 start_ost || error "Unable to start OST1"
1046 start_mds || error "Unable to start MDS"
1047 echo "Requeue thread should have started: "
1048 ps -e | grep ll_cfg_requeue
1049 set_persistent_param_and_check ost1 \
1050 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1051 "$FSNAME-OST0000.ost.client_cache_seconds"
1052 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1054 run_test 27a "Reacquire MGS lock if OST started first"
1059 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1060 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1062 facet_failover $SINGLEMDS
1063 set_persistent_param_and_check $SINGLEMDS \
1064 "mdt.$device.identity_acquire_expire" \
1065 "$device.mdt.identity_acquire_expire"
1066 set_persistent_param_and_check client \
1067 "mdc.$device-mdc-*.max_rpcs_in_flight" \
1068 "$device.mdc.max_rpcs_in_flight"
1070 cleanup || error "cleanup failed with $?"
1072 run_test 27b "Reacquire MGS lock after failover"
1074 test_28A() { # was test_28
1076 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1077 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1078 ORIG=$($LCTL get_param -n $TEST)
1079 FINAL=$(($ORIG + 1))
1080 set_persistent_param_and_check client "$TEST" "$PARAM" $FINAL
1081 FINAL=$(($FINAL + 1))
1082 set_persistent_param_and_check client "$TEST" "$PARAM" $FINAL
1083 umount_client $MOUNT || error "umount_client $MOUNT failed"
1084 mount_client $MOUNT || error "mount_client $MOUNT failed"
1085 RESULT=$($LCTL get_param -n $TEST)
1086 if [ $RESULT -ne $FINAL ]; then
1087 error "New config not seen: wanted $FINAL got $RESULT"
1089 echo "New config success: got $RESULT"
1091 set_persistent_param_and_check client "$TEST" "$PARAM" $ORIG
1092 cleanup || error "cleanup failed with rc $?"
1094 run_test 28A "permanent parameter setting"
1096 test_28a() { # LU-4221
1097 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1098 { skip "Need OST version at least 2.5.52" && return 0; }
1099 [ "$(facet_fstype ost1)" = "zfs" ] &&
1100 skip "LU-4221: no such proc params for ZFS OSTs" && return
1107 local device="$FSNAME-OST0000"
1111 # In this test we will set three kinds of proc parameters with
1112 # lctl set_param -P or lctl conf_param:
1113 # 1. non-symlink ones in the OFD
1114 # 2. non-symlink ones in the OSD
1117 # prepare a non-symlink parameter in the OFD
1118 name="client_cache_seconds"
1119 param="$device.ost.$name"
1120 cmd="obdfilter.$device.$name"
1122 # permanently setting the parameter in the OFD
1123 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1125 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1126 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1129 # prepare a non-symlink parameter in the OSD
1131 param="$device.osd.$name"
1132 cmd="osd-*.$device.$name"
1134 # conf_param the parameter in the OSD
1135 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1136 new=$(((old + 1) % 2))
1137 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1138 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1140 cleanup || error "cleanup failed with $?"
1142 run_test 28a "set symlink parameters permanently with lctl"
1145 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1146 setup > /dev/null 2>&1
1147 start_ost2 || error "Unable to start OST2"
1150 local PARAM="$FSNAME-OST0001.osc.active"
1151 # With lctl set_param -P the value $PROC_ACT will be sent to
1152 # all nodes. The [!M] filter out the ability to set active
1153 # on the MDS servers which is tested with wait_osp_* below.
1154 # For ost_server_uuid that only exist on client so filtering
1156 local PROC_ACT="osc.$FSNAME-OST0001-osc-*.active"
1157 local PROC_UUID="osc.$FSNAME-OST0001-osc-[!M]*.ost_server_uuid"
1159 ACTV=$($LCTL get_param -n $PROC_ACT)
1161 set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
1162 # also check ost_server_uuid status
1163 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1164 if [ -z "$RESULT" ]; then
1165 error "Client not deactivated: $($LCTL get_param \
1168 echo "Live client success: got $RESULT"
1172 wait_osp_active ost ${FSNAME}-OST0001 1 0
1174 # test new client starts deactivated
1175 umount_client $MOUNT || error "umount_client $MOUNT failed"
1176 mount_client $MOUNT || error "mount_client $MOUNT failed"
1178 # the 2nd and 3rd field of ost_server_uuid do not update at the same
1179 # time when using lctl set_param -P
1180 wait_update_facet client \
1181 "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'" \
1183 error "New client start active: $($LCTL get_param -n $PROC_UUID)"
1185 echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
1187 # make sure it reactivates
1188 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1190 umount_client $MOUNT
1191 stop_ost2 || error "Unable to stop OST2"
1192 cleanup_nocli || error "cleanup_nocli failed with $?"
1193 #writeconf to remove all ost2 traces for subsequent tests
1194 writeconf_or_reformat
1196 run_test 29 "permanently remove an OST"
1201 echo Big config llog
1202 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1203 ORIG=$($LCTL get_param -n $TEST)
1204 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1205 for i in ${LIST[@]}; do
1206 set_persistent_param_and_check client "$TEST" \
1207 "$FSNAME.llite.max_read_ahead_whole_mb" $i
1209 # make sure client restart still works
1210 umount_client $MOUNT
1211 mount_client $MOUNT || error "mount_client $MOUNT failed"
1212 [ "$($LCTL get_param -n $TEST)" -ne "$i" ] &&
1213 error "Param didn't stick across restart $($TEST) != $i"
1216 echo Erase parameter setting
1217 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1218 do_facet mgs "$PERM_CMD -d $TEST" ||
1219 error "Erase param $TEST failed"
1221 do_facet mgs "$PERM_CMD \
1222 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1223 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1225 umount_client $MOUNT
1226 mount_client $MOUNT || error "mount_client $MOUNT failed"
1227 FINAL=$($LCTL get_param -n $TEST)
1228 echo "deleted (default) value=$FINAL, orig=$ORIG"
1229 # assumes this parameter started at the default value
1230 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1232 cleanup || error "cleanup failed with rc $?"
1234 run_test 30a "Big config llog and permanent parameter deletion"
1239 local orignids=$($LCTL get_param -n \
1240 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1242 local orignidcount=$(echo "$orignids" | wc -w)
1244 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1245 # numerical part of it. Hopefully that's not already a failover address
1247 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1249 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1250 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1251 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1252 echo "Using fake nid $NEW"
1254 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1255 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1256 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1257 PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
1258 echo "Setting $PARAM from $TEST to $NEW"
1259 do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
1260 error "$PERM_CMD $PARAM failed"
1262 PARAM="$FSNAME-OST0000.failover.node"
1263 echo "Setting $PARAM from $TEST to $NEW"
1264 do_facet mgs "$PERM_CMD $PARAM='$NEW'" ||
1265 error "$PARAM $PARAM failed"
1267 wait_update_facet client "$TEST" "$NEW" ||
1268 error "check $PARAM failed!"
1270 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1272 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1273 echo "should have $((orignidcount + 1)) entries \
1274 in failover nids string, have $NIDCOUNT"
1275 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1276 error "Failover nid not added"
1278 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1279 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1281 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1282 error "$PERM_CMD delete failed"
1284 umount_client $MOUNT
1285 mount_client $MOUNT || error "mount_client $MOUNT failed"
1287 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1289 NIDCOUNT=$(echo "$NIDS" | wc -w)
1290 echo "only $orignidcount final entries should remain \
1291 in failover nids string, have $NIDCOUNT"
1292 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1294 cleanup || error "cleanup failed with rc $?"
1296 run_test 30b "Remove failover nids"
1298 test_31() { # bug 10734
1299 # ipaddr must not exist
1300 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1301 cleanup || error "cleanup failed with rc $?"
1303 run_test 31 "Connect to non-existent node (shouldn't crash)"
1307 T32_BLIMIT=40960 # Kbytes
1311 # This is not really a test but a tool to create new disk
1312 # image tarballs for the upgrade tests.
1314 # Disk image tarballs should be created on single-node
1315 # clusters by running this test with default configurations
1316 # plus a few mandatory environment settings that are verified
1317 # at the beginning of the test.
1319 test_32newtarball() {
1323 local tmp=$TMP/t32_image_create
1324 local server_version=$(lustre_version_code $SINGLEMDS)
1329 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1330 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1331 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1332 "MDSDEV1=<nonexistent_file>" \
1333 "MDSDEV2=<nonexistent_file>" \
1334 "(or MDSDEV, in the case of b1_8)" \
1335 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1339 echo "Found stale $tmp"
1343 mkdir $tmp/src || return 1
1344 tar cf - -C $src . | tar xf - -C $tmp/src
1345 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1346 count=$(($T32_BLIMIT / 1024 / 4))
1347 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1349 # format ost with comma-separated NIDs to verify LU-4460
1350 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1351 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1355 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1356 $LFS quotacheck -ug /mnt/$FSNAME
1357 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1360 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1362 if [[ $MDSCOUNT -ge 2 ]]; then
1363 remote_dir=/mnt/$FSNAME/remote_dir
1364 $LFS mkdir -i 1 $remote_dir
1365 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1367 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1368 striped_dir=/mnt/$FSNAME/striped_dir_old
1369 $LFS mkdir -i 1 -c 2 $striped_dir
1370 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1376 mkdir $tmp/img || return 1
1380 pushd_dir=/mnt/$FSNAME
1381 if [[ $MDSCOUNT -ge 2 ]]; then
1382 pushd_dir=$remote_dir
1383 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1385 ls -Rni --time-style=+%s >$tmp/img/list2
1391 ls -Rni --time-style=+%s >$tmp/img/list
1392 find ! -name .lustre -type f -exec sha1sum {} \; |
1393 sort -k 2 >$tmp/img/sha1sums
1395 $LCTL get_param -n version | head -n 1 |
1396 sed -e 's/^lustre: *//' >$tmp/img/commit
1398 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1399 $LFS quotaon -ug /mnt/$FSNAME
1400 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1401 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1402 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1403 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1404 | tr -d "*" > $tmp/img/bspace
1405 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1406 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1407 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1408 | tr -d "*" > $tmp/img/ispace
1409 echo $T32_BLIMIT > $tmp/img/blimit
1410 echo $T32_ILIMIT > $tmp/img/ilimit
1415 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1418 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1419 echo "Data verification failed"
1422 uname -r >$tmp/img/kernel
1423 uname -m >$tmp/img/arch
1425 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1426 for num in $(seq 2 $MDSCOUNT); do
1427 local devname=$(mdsdevname $num)
1429 [[ $(facet_fstype $facet) != zfs ]] ||
1430 devname=$(mdsvdevname $num)
1431 mv $devname $tmp/img
1433 mv $OSTDEV1 $tmp/img
1435 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1436 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1439 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1444 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1447 # The list of applicable tarballs is returned via the caller's
1448 # variable "tarballs".
1451 local node=$(facet_active_host $SINGLEMDS)
1452 local r="do_node $node"
1454 if [ "$CLIENTONLY" ]; then
1455 skip "Client-only testing"
1459 if ! $r which $TUNEFS; then
1460 skip_env "tunefs.lustre required on $node"
1464 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1466 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1467 -name \'disk*-$IMGTYPE.tar.bz2\')
1469 if [ -z "$tarballs" ]; then
1470 skip "No applicable tarballs found"
1475 t32_test_cleanup() {
1477 local facet=$SINGLEMDS
1478 local fstype=$(facet_fstype $facet)
1481 if $shall_cleanup_lustre; then
1482 umount $tmp/mnt/lustre || rc=$?
1484 if $shall_cleanup_mdt; then
1485 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1487 if $shall_cleanup_mdt1; then
1488 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1490 if $shall_cleanup_ost; then
1491 $r $UMOUNT $tmp/mnt/ost || rc=$?
1496 if [[ $fstype == zfs ]]; then
1498 local poolname_list="t32fs-mdt1 t32fs-ost1"
1500 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1502 for poolname in $poolname_list; do
1503 destroy_zpool $facet $poolname
1506 combined_mgs_mds || start_mgs || rc=$?
1510 t32_bits_per_long() {
1512 # Yes, this is not meant to be perfect.
1522 t32_reload_modules() {
1524 local all_removed=false
1526 local fstype=$(facet_fstype $SINGLEMDS)
1528 [ $fstype == "zfs" ] && do_rpc_nodes $node "service zed stop"
1530 while ((i < 20)); do
1531 echo "Unloading modules on $node: Attempt $i"
1532 do_rpc_nodes $node $LUSTRE_RMMOD $fstype &&
1534 do_rpc_nodes $node check_mem_leak || return 1
1535 if $all_removed; then
1536 do_rpc_nodes $node load_modules
1539 if [ $fstype == "zfs" ]; then
1540 do_rpc_nodes $node "$ZPOOL status -v"
1545 echo "Unloading modules on $node: Given up"
1549 t32_wait_til_devices_gone() {
1555 echo wait for devices to go
1556 while ((i < 20)); do
1557 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1558 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1559 ((devices == 0 && loops == 0)) && return 0
1563 echo "waiting for dev on $node: dev $devices loop $loops given up"
1564 do_rpc_nodes $node "losetup -a"
1565 do_rpc_nodes $node "$LCTL device_list"
1569 t32_verify_quota() {
1573 local fstype=$(facet_fstype $SINGLEMDS)
1577 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1578 # lustre will estimate the object count usage. This fails quota
1579 # verification in 32b. The object quota usage should be accurate after
1580 # zfs-0.7.0 is released.
1581 [ $fstype == "zfs" ] && {
1582 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1584 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1585 echo "Skip quota verify for zfs: $zfs_version"
1590 $LFS quota -u $T32_QID -v $mnt
1592 qval=$($LFS quota -v -u $T32_QID $mnt |
1593 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1594 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1596 [ $qval -eq $img_bspace ] || {
1597 echo "bspace, act:$qval, exp:$img_bspace"
1601 qval=$($LFS quota -v -u $T32_QID $mnt |
1602 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1603 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1605 [ $qval -eq $img_ispace ] || {
1606 echo "ispace, act:$qval, exp:$img_ispace"
1610 qval=$($LFS quota -v -u $T32_QID $mnt |
1611 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1612 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1614 [ $qval -eq $img_blimit ] || {
1615 echo "blimit, act:$qval, exp:$img_blimit"
1619 qval=$($LFS quota -v -u $T32_QID $mnt |
1620 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1621 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1623 [ $qval -eq $img_ilimit ] || {
1624 echo "ilimit, act:$qval, exp:$img_ilimit"
1628 set_persistent_param_and_check $facet \
1629 "osd-$fstype.$fsname-MDT0000.quota_slave.enabled" \
1630 "$fsname.quota.mdt" ug
1632 set_persistent_param_and_check $facet \
1633 "osd-$fstype.$fsname-OST0000.quota_slave.enabled" \
1634 "$fsname.quota.ost" ug
1637 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1638 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1639 echo "Write succeed, but expect -EDQUOT"
1642 rm -f $mnt/t32_qf_new
1644 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1646 echo "Create succeed, but expect -EDQUOT"
1649 unlinkmany $mnt/t32_qf_ $img_ilimit
1657 local dne_upgrade=${dne_upgrade:-"no"}
1658 local dom_upgrade=${dom_upgrade:-"no"}
1659 local ff_convert=${ff_convert:-"no"}
1660 local shall_cleanup_mdt=false
1661 local shall_cleanup_mdt1=false
1662 local shall_cleanup_ost=false
1663 local shall_cleanup_lustre=false
1664 local mdt2_is_available=false
1665 local node=$(facet_active_host $SINGLEMDS)
1666 local r="do_node $node"
1682 local fstype=$(facet_fstype $SINGLEMDS)
1683 local mdt_dev=$tmp/mdt
1684 local mdt2_dev=$tmp/mdt2
1685 local ost_dev=$tmp/ost
1690 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1691 trap 'trap - RETURN; t32_test_cleanup' RETURN
1694 nid=$($r $LCTL list_nids | head -1)
1696 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1697 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1698 $r tar xjvf $tarball -S -C $tmp || {
1699 error_noexit "Unpacking the disk image tarball"
1702 img_commit=$($r cat $tmp/commit)
1703 img_kernel=$($r cat $tmp/kernel)
1704 img_arch=$($r cat $tmp/arch)
1705 img_bspace=$($r cat $tmp/bspace)
1706 img_ispace=$($r cat $tmp/ispace)
1708 # older images did not have "blimit" and "ilimit" files
1709 # use old values for T32_BLIMIT and T32_ILIMIT
1710 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1712 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1715 echo "Upgrading from $(basename $tarball), created with:"
1716 echo " Commit: $img_commit"
1717 echo " Kernel: $img_kernel"
1718 echo " Arch: $img_arch"
1719 echo "OST version: $(lustre_build_version ost1)"
1721 # The conversion can be made only when both of the following
1722 # conditions are satisfied:
1723 # - ost device img version < 2.3.64
1724 # - ost server version >= 2.5
1725 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1726 $(lustre_version_code ost1) -lt $(version_code 2.5.0) ] &&
1729 ! $r test -f $mdt2_dev || mdt2_is_available=true
1731 if [[ $fstype == zfs ]]; then
1734 local poolname_list="t32fs-mdt1 t32fs-ost1"
1736 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1738 for poolname in $poolname_list; do
1740 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1741 $ZPOOL import -f -d $tmp $poolname"
1744 # upgrade zpool to latest supported features, including
1745 # dnode quota accounting in 0.7.0
1746 $r "$ZPOOL upgrade -a"
1748 mdt_dev=t32fs-mdt1/mdt1
1749 ost_dev=t32fs-ost1/ost1
1750 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1751 wait_update_facet $SINGLEMDS "$ZPOOL list |
1752 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1753 error_noexit "import zfs pool failed"
1758 $r $LCTL set_param debug="$PTLDEBUG"
1760 $r $TUNEFS --dryrun $mdt_dev || {
1762 error_noexit "tunefs.lustre before mounting the MDT"
1766 if $mdt2_is_available; then
1767 $r $TUNEFS --dryrun $mdt2_dev || {
1769 error_noexit "tunefs.lustre before mounting the MDT"
1774 if [ "$writeconf" ]; then
1776 if [ $fstype == "ldiskfs" ]; then
1778 $r $TUNEFS --quota $mdt_dev || {
1780 error_noexit "Enable mdt quota feature"
1783 if $mdt2_is_available; then
1784 $r $TUNEFS --quota $mdt2_dev || {
1786 error_noexit "Enable mdt quota feature"
1792 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1793 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1794 { skip "LU-2200: Cannot run over Inifiniband w/o lctl replace_nids "
1795 "(Need MGS version at least 2.3.59)"; return 0; }
1797 local osthost=$(facet_active_host ost1)
1798 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1801 if [ $fstype == "ldiskfs" ]; then
1804 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1805 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1806 $r $LCTL replace_nids $fsname-MDT0000 $nid
1807 $r $UMOUNT $tmp/mnt/mdt
1810 mopts=exclude=$fsname-OST0000
1811 if [ $fstype == "ldiskfs" ]; then
1816 t32_wait_til_devices_gone $node
1818 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1820 error_noexit "Mounting the MDT"
1823 shall_cleanup_mdt=true
1825 if $mdt2_is_available; then
1826 mopts=mgsnode=$nid,$mopts
1827 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1829 error_noexit "Mounting the MDT"
1833 echo "mount new MDT....$mdt2_dev"
1834 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1835 error_noexit "enable remote dir create failed"
1837 shall_cleanup_mdt1=true
1838 elif [ "$dne_upgrade" != "no" ]; then
1839 local fs2mdsdev=$(mdsdevname 1_2)
1840 local fs2mdsvdev=$(mdsvdevname 1_2)
1842 echo "mkfs new MDT on ${fs2mdsdev}...."
1843 if [ $(facet_fstype mds1) == ldiskfs ]; then
1844 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1847 add $SINGLEMDS $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1848 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1849 error_noexit "Mkfs new MDT failed"
1853 [[ $(facet_fstype mds1) != zfs ]] || import_zpool mds1
1855 $r $TUNEFS --dryrun $fs2mdsdev || {
1856 error_noexit "tunefs.lustre before mounting the MDT"
1860 echo "mount new MDT....$fs2mdsdev"
1861 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1862 error_noexit "mount mdt1 failed"
1866 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1867 error_noexit "enable remote dir create failed"
1869 shall_cleanup_mdt1=true
1872 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1873 error_noexit "Getting MDT UUID"
1876 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1877 error_noexit "Unexpected MDT UUID: \"$uuid\""
1881 $r $TUNEFS --dryrun $ost_dev || {
1882 error_noexit "tunefs.lustre before mounting the OST"
1885 if [ "$writeconf" ]; then
1886 mopts=mgsnode=$nid,$writeconf
1887 if [ $fstype == "ldiskfs" ]; then
1889 $r $TUNEFS --quota $ost_dev || {
1891 error_noexit "Enable ost quota feature"
1897 if [ $fstype == "ldiskfs" ]; then
1902 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1903 error_noexit "Mounting the OST"
1906 shall_cleanup_ost=true
1908 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1909 error_noexit "Getting OST UUID"
1912 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1913 error_noexit "Unexpected OST UUID: \"$uuid\""
1917 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1918 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
1919 error_noexit "Setting OST \"failover.node\""
1922 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
1923 error_noexit "Setting MDT \"failover.node\""
1926 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
1927 error_noexit "Setting \"max_dirty_mb\""
1930 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
1931 error_noexit "Setting \"max_rpcs_in_flight\""
1934 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
1935 error_noexit "Setting \"lov.stripesize\""
1938 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
1939 error_noexit "Setting \"mdd.atime_diff\""
1943 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
1944 error_noexit "Setting OST \"failover.node\""
1948 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
1949 error_noexit "Setting MDT \"failover.node\""
1953 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
1954 error_noexit "Setting \"max_dirty_mb\""
1957 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1958 error_noexit "Setting \"max_rpcs_in_flight\""
1961 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
1962 error_noexit "Setting \"lov.stripesize\""
1965 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
1966 error_noexit "Setting \"mdd.atime_diff\""
1971 $r $LCTL pool_new $fsname.interop || {
1972 error_noexit "Setting \"interop\""
1976 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1977 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1978 error_noexit "Start OI scrub on OST0"
1982 # The oi_scrub should be on ost1, but for test_32(),
1983 # all on the SINGLEMDS.
1984 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1985 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1986 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1987 error_noexit "Failed to get the expected 'completed'"
1991 local UPDATED=$($r $LCTL get_param -n \
1992 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1993 awk '/^updated/ { print $2 }')
1994 [ $UPDATED -ge 1 ] || {
1995 error_noexit "Only $UPDATED objects have been converted"
2000 if [ "$dne_upgrade" != "no" ]; then
2001 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2002 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
2003 error_noexit "Setting MDT1 \"failover.node\""
2007 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
2008 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2011 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
2012 error_noexit "Setting MDT1 \"lov.stripesize\""
2016 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
2017 error_noexit "Setting MDT1 \"failover.node\""
2020 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2021 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2024 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2025 error_noexit "Setting MDT1 \"lov.stripesize\""
2031 if [ "$writeconf" ]; then
2032 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2033 error_noexit "Mounting the client"
2037 shall_cleanup_lustre=true
2038 $r $LCTL set_param debug="$PTLDEBUG"
2040 # Leave re-enabling this to a separate patch for LU-11558
2041 # t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2042 # error_noexit "verify quota failed"
2046 if $r test -f $tmp/list; then
2048 # There is not a Test Framework API to copy files to or
2049 # from a remote node.
2051 # LU-2393 - do both sorts on same node to ensure locale
2053 local list_file=$tmp/list
2055 if $mdt2_is_available; then
2056 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2057 $r test -f $tmp/list2; then
2058 list_file=$tmp/list2
2059 pushd $tmp/mnt/lustre/striped_dir_old
2061 pushd $tmp/mnt/lustre/remote_dir
2064 pushd $tmp/mnt/lustre
2066 $r cat $list_file | sort -k 6 >$tmp/list.orig
2067 ls -Rni --time-style=+%s | sort -k 6 |
2068 sed 's/\. / /' >$tmp/list || {
2074 # 32-bit and 64-bit clients use different algorithms to
2075 # convert FIDs into inode numbers. Hence, remove the
2076 # inode numbers from the lists, if the original list was
2077 # created on an architecture with different number of
2080 if [ $(t32_bits_per_long $(uname -m)) != \
2081 $(t32_bits_per_long $img_arch) ]; then
2082 echo "Different number of bits per \"long\"" \
2083 "from the disk image"
2084 for list in list.orig list; do
2085 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2089 if ! diff -ub $tmp/list.orig $tmp/list; then
2090 error_noexit "list verification failed"
2094 echo "list verification skipped"
2097 if [ "$dom_upgrade" != "no" ]; then
2098 echo "Check DoM file can be created"
2099 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2100 error_noexit "Verify DoM creation"
2103 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2104 error_noexit "Verify a DoM file"
2107 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2108 count=1 conv=fsync || {
2109 error_noexit "Cannot write to DoM file"
2112 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2113 error_noexit "DoM: bad size after write"
2116 rm $tmp/mnt/lustre/dom
2118 set_persistent_param_and_check mds \
2119 "lod.*MDT0000*.dom_stripesize" \
2120 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2121 error_noexit "Changing \"dom_stripesize\""
2126 if [ "$dne_upgrade" != "no" ]; then
2127 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2128 error_noexit "set striped dir failed"
2132 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2134 pushd $tmp/mnt/lustre
2135 tar -cf - . --exclude=./striped_dir \
2136 --exclude=./striped_dir_old \
2137 --exclude=./remote_dir |
2138 tar -xvf - -C striped_dir 1>/dev/null || {
2139 error_noexit "cp to striped dir failed"
2145 # If it is upgrade from DNE (2.5), then rename the remote dir,
2146 # which is created in 2.5 to striped dir.
2147 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2148 stripe_index=$($LFS getdirstripe -i \
2149 $tmp/mnt/lustre/remote_dir)
2151 [[ $stripe_index -eq 1 ]] || {
2152 error_noexit "get index \"$stripe_index\"" \
2153 "from remote dir failed"
2156 mv $tmp/mnt/lustre/remote_dir \
2157 $tmp/mnt/lustre/striped_dir/ || {
2158 error_noexit "mv remote dir failed"
2163 # If it is upgraded from DNE (2.7), then move the striped dir
2164 # which was created in 2.7 to the new striped dir.
2165 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2166 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2167 stripe_count=$($LFS getdirstripe -c \
2168 $tmp/mnt/lustre/striped_dir_old)
2169 [[ $stripe_count -eq 2 ]] || {
2170 error_noexit "get count $stripe_count" \
2171 "from striped dir failed"
2174 mv $tmp/mnt/lustre/striped_dir_old \
2175 $tmp/mnt/lustre/striped_dir/ || {
2176 error_noexit "mv striped dir failed"
2182 $r $LCTL set_param -n osd*.*.force_sync=1
2183 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2184 error_noexit "dd failed"
2187 rm -rf $tmp/mnt/lustre/tmp_file || {
2188 error_noexit "rm failed"
2192 if $r test -f $tmp/sha1sums; then
2193 # LU-2393 - do both sorts on same node to ensure locale
2195 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2196 if [ "$dne_upgrade" != "no" ]; then
2197 pushd $tmp/mnt/lustre/striped_dir
2199 pushd $tmp/mnt/lustre
2202 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2203 ! -name .lustre -type f -exec sha1sum {} \; |
2204 sort -k 2 >$tmp/sha1sums || {
2206 error_noexit "sha1sum"
2210 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2211 error_noexit "sha1sum verification failed"
2215 # if upgrade from DNE(2.5), then check remote directory
2216 # if upgrade from DNE(2.7), then check striped directory
2217 if $mdt2_is_available &&
2218 [[ "$dne_upgrade" != "no" ]]; then
2219 local new_dir="$tmp/mnt/lustre/striped_dir"
2220 local striped_dir_old="$new_dir/striped_dir_old"
2222 local dir_list="$new_dir/remote_dir"
2223 [[ ! -d $triped_dir_old ]] ||
2224 dir_list+=" $striped_dir_old"
2226 for dir in $dir_list; do
2228 find ! -name .lustre -type f \
2229 -exec sha1sum {} \; |
2230 sort -k 2 >$tmp/sha1sums || {
2232 error_noexit "sha1sum"
2236 if ! diff -ub $tmp/sha1sums.orig \
2238 error_noexit "sha1sum $dir" \
2245 echo "sha1sum verification skipped"
2248 if [ "$dne_upgrade" != "no" ]; then
2249 rm -rf $tmp/mnt/lustre/striped_dir || {
2250 error_noexit "remove remote dir failed"
2255 # migrate files/dirs to remote MDT, then move them back
2256 if [ $(lustre_version_code mds1) -ge $(version_code 2.7.50) -a \
2257 $dne_upgrade != "no" ]; then
2258 $r $LCTL set_param -n \
2259 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2261 echo "test migration"
2262 pushd $tmp/mnt/lustre
2263 for dir in $(find ! -name .lustre ! -name . -type d); do
2264 mdt_index=$($LFS getdirstripe -i $dir)
2265 stripe_cnt=$($LFS getdirstripe -c $dir)
2266 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2267 $LFS migrate -m 1 $dir || {
2269 error_noexit "migrate MDT1 failed"
2275 for dir in $(find ! -name . ! -name .lustre -type d); do
2276 mdt_index=$($LFS getdirstripe -i $dir)
2277 stripe_cnt=$($LFS getdirstripe -c $dir)
2278 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2279 $LFS migrate -m 0 $dir || {
2281 error_noexit "migrate MDT0 failed"
2290 # When adding new data verification tests, please check for
2291 # the presence of the required reference files first, like
2292 # the "sha1sums" and "list" tests above, to avoid the need to
2293 # regenerate every image for each test addition.
2296 nrpcs_orig=$($LCTL get_param \
2297 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2298 error_noexit "Getting \"max_rpcs_in_flight\""
2301 nrpcs=$((nrpcs_orig + 5))
2303 set_persistent_param_and_check client \
2304 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
2305 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
2306 error_noexit "Changing \"max_rpcs_in_flight\""
2310 umount $tmp/mnt/lustre || {
2311 error_noexit "Unmounting the client"
2314 shall_cleanup_lustre=false
2316 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2317 $r $UMOUNT $tmp/mnt/mdt1 || {
2318 error_noexit "Unmounting the MDT2"
2321 if [[ $fstype == zfs ]]; then
2322 $r "$ZPOOL export t32fs-mdt2"
2324 shall_cleanup_mdt1=false
2327 $r $UMOUNT $tmp/mnt/mdt || {
2328 error_noexit "Unmounting the MDT"
2331 if [[ $fstype == zfs ]]; then
2332 $r "$ZPOOL export t32fs-mdt1"
2334 shall_cleanup_mdt=false
2336 $r $UMOUNT $tmp/mnt/ost || {
2337 error_noexit "Unmounting the OST"
2340 if [[ $fstype == zfs ]]; then
2341 $r "$ZPOOL export t32fs-ost1"
2343 shall_cleanup_ost=false
2345 t32_reload_modules $node || {
2346 error_noexit "Reloading modules"
2350 if [[ $fstype == zfs ]]; then
2351 local poolname=t32fs-mdt1
2353 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2354 $ZPOOL import -f -d $tmp $poolname"
2356 # upgrade zpool to latest supported features,
2357 # including dnode quota accounting in 0.7.0
2358 $r "$ZPOOL upgrade $poolname"
2361 # mount a second time to make sure we didnt leave upgrade flag on
2362 $r $TUNEFS --dryrun $mdt_dev || {
2364 error_noexit "tunefs.lustre before remounting the MDT"
2368 mopts=exclude=$fsname-OST0000
2369 if [ $fstype == "ldiskfs" ]; then
2372 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2373 error_noexit "Remounting the MDT"
2376 shall_cleanup_mdt=true
2386 for tarball in $tarballs; do
2387 t32_test $tarball || let "rc += $?"
2391 run_test 32a "Upgrade (not live)"
2399 for tarball in $tarballs; do
2400 t32_test $tarball writeconf || let "rc += $?"
2404 run_test 32b "Upgrade with writeconf"
2411 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2413 for tarball in $tarballs; do
2414 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2415 echo $tarball | grep "1_8" && continue
2416 echo $tarball | grep "2_1" && continue
2418 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2422 run_test 32c "dne upgrade test"
2430 for tarball in $tarballs; do
2431 ff_convert=yes t32_test $tarball || rc=$?
2435 run_test 32d "convert ff test"
2438 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
2439 { skip "Need MDS version at least 2.10.56"; return 0; }
2446 for tarball in $tarballs; do
2447 echo $tarball | grep "2_9" || continue
2449 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
2453 run_test 32e "dom upgrade test"
2455 test_33a() { # bug 12333, was test_33
2456 local FSNAME2=test-123
2457 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2460 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2462 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2463 local dev=${SINGLEMDS}_dev
2464 local MDSDEV=${!dev}
2465 is_blkdev $SINGLEMDS $MDSDEV &&
2466 skip_env "mixed loopback and real device not working" &&
2470 local fs2mdsdev=$(mdsdevname 1_2)
2471 local fs2ostdev=$(ostdevname 1_2)
2472 local fs2mdsvdev=$(mdsvdevname 1_2)
2473 local fs2ostvdev=$(ostvdevname 1_2)
2475 if [ $(facet_fstype mds1) == ldiskfs ]; then
2476 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2479 if combined_mgs_mds; then
2480 local mgs_flag="--mgs"
2483 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
2484 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
2486 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2487 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2488 $fs2ostvdev || exit 10
2490 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2491 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2493 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2494 do_facet mgs "$PERM_CMD timeout=200" ||
2495 error "$PERM_CMD timeout=200 failed"
2497 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
2498 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
2500 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2501 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2504 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2505 $LFS getstripe $MOUNT2/hosts ||
2506 error "$LFS getstripe $MOUNT2/hosts failed"
2511 cleanup_nocli || error "cleanup_nocli failed with $?"
2513 run_test 33a "Mount ost with a large index number"
2515 test_33b() { # was test_34
2518 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2519 # Drop lock cancelation reply during umount
2520 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2521 do_facet client $LCTL set_param fail_loc=0x80000304
2522 #lctl set_param debug=-1
2523 umount_client $MOUNT
2524 cleanup || error "cleanup failed with $?"
2526 run_test 33b "Drop cancel during umount"
2530 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2531 manual_umount_client
2533 do_facet client killall -USR1 multiop
2534 if [ $rc -eq 0 ]; then
2535 error "umount not fail!"
2538 cleanup || error "cleanup failed with rc $?"
2540 run_test 34a "umount with opened file should be fail"
2544 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2545 stop_mds || error "Unable to stop MDS"
2547 manual_umount_client --force || error "mtab after failed umount with $?"
2549 cleanup || error "cleanup failed with $?"
2551 run_test 34b "force umount with failed mds should be normal"
2555 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2556 stop_ost || error "Unable to stop OST1"
2558 manual_umount_client --force || error "mtab after failed umount with $?"
2560 cleanup || error "cleanup failed with $?"
2562 run_test 34c "force umount with failed ost should be normal"
2564 test_35a() { # bug 12459
2567 DBG_SAVE="`$LCTL get_param -n debug`"
2568 $LCTL set_param debug="ha"
2570 log "Set up a fake failnode for the MDS"
2572 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2573 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2575 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2576 do_facet mgs "$PERM_CMD \
2577 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2578 error "Setting mdc.*${device}*.import=connection=\
2579 $(h2nettype $FAKENID) failed."
2581 do_facet mgs "$PERM_CMD \
2582 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2583 error "Setting ${device}.failover.node=\
2584 $(h2nettype $FAKENID) failed."
2586 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2589 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2592 log "Stopping the MDT: $device"
2593 stop_mdt 1 || error "MDT0 stop fail"
2595 df $MOUNT > /dev/null 2>&1 &
2597 log "Restarting the MDT: $device"
2598 start_mdt 1 || error "MDT0 start fail"
2599 log "Wait for df ($DFPID) ... "
2602 $LCTL set_param debug="$DBG_SAVE"
2604 # retrieve from the log the first server that the client tried to
2605 # contact after the connection loss
2606 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2607 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2608 /import_select_connection.*$device-mdc.* using connection/ {
2610 if (\\\$NF ~ /$FAKENID/)
2616 }" $TMP/lustre-log-$TESTNAME.log`
2617 [ "$NEXTCONN" != "0" ] &&
2618 error "Tried to connect to ${NEXTCONN} not last active server"
2619 cleanup || error "cleanup failed with $?"
2620 # remove nid settings
2621 writeconf_or_reformat
2623 run_test 35a "Reconnect to the last active server first"
2625 test_35b() { # bug 18674
2626 remote_mds || { skip "local MDS" && return 0; }
2630 $LCTL set_param debug="ha"
2632 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2635 log "Set up a fake failnode for the MDS"
2637 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2638 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2640 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2641 do_facet mgs "$PERM_CMD \
2642 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2643 error "Set mdc.*${device}*.import=connection=\
2644 $(h2nettype $FAKENID) failed"
2646 do_facet mgs "$PERM_CMD \
2647 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2648 error "Set ${device}.failover.node=\
2649 $(h2nettype $FAKENID) failed"
2652 local at_max_saved=0
2653 # adaptive timeouts may prevent seeing the issue
2654 if at_is_enabled; then
2655 at_max_saved=$(at_max_get mds)
2656 at_max_set 0 mds client
2659 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2661 log "Injecting EBUSY on MDS"
2662 # Setting OBD_FAIL_MDS_RESEND=0x136
2663 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2664 error "unable to set param fail_loc=0x80000136"
2666 $LCTL set_param mdc.${FSNAME}*.stats=clear
2668 log "Creating a test file and stat it"
2669 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2670 stat $MOUNT/$tdir/$tfile
2672 log "Stop injecting EBUSY on MDS"
2673 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2674 error "unable to set param fail_loc=0"
2675 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2678 # restore adaptive timeout
2679 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2681 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2683 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2684 awk '/mds_connect/{print $2}')
2686 # retrieve from the log if the client has ever tried to
2687 # contact the fake server after the loss of connection
2688 FAILCONN=`awk "BEGIN {ret = 0;}
2689 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2691 if (\\\$NF ~ /$FAKENID/) {
2696 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2698 [ "$FAILCONN" == "0" ] &&
2699 error "The client reconnection has not been triggered"
2700 [ "$FAILCONN" == "2" ] &&
2701 error "Primary server busy, client reconnect to failover failed"
2704 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2705 # Reconnects are supposed to be rate limited to one every 5s
2706 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2707 error "Too many reconnects $CONNCNT"
2709 cleanup || error "cleanup failed with $?"
2710 # remove nid settings
2711 writeconf_or_reformat
2713 run_test 35b "Continue reconnection retries, if the active server is busy"
2716 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
2718 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2719 { skip "remote OST" && return 0; }
2722 local FSNAME2=test1234
2723 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2725 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2727 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2728 is_blkdev $SINGLEMDS $MDSDEV &&
2729 skip_env "mixed loopback and real device not working" && return
2732 local fs2mdsdev=$(mdsdevname 1_2)
2733 local fs2ostdev=$(ostdevname 1_2)
2734 local fs3ostdev=$(ostdevname 2_2)
2735 local fs2mdsvdev=$(mdsvdevname 1_2)
2736 local fs2ostvdev=$(ostvdevname 1_2)
2737 local fs3ostvdev=$(ostvdevname 2_2)
2739 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2740 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2741 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2742 # different one than the default value here.
2743 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2744 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2745 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2746 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2748 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2749 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2750 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2751 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2752 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2754 sleep 5 # until 11778 fixed
2756 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2758 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2759 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2760 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2761 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2762 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2763 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2764 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2765 DFTOTAL=$(echo $STRING | cut -d, -f1)
2766 DFUSED=$(echo $STRING | cut -d, -f2)
2767 DFAVAIL=$(echo $STRING | cut -d, -f3)
2768 DFFREE=$(($DFTOTAL - $DFUSED))
2770 ALLOWANCE=$((64 * $OSTCOUNT))
2772 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2773 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2774 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2777 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2778 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2779 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2782 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2783 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2784 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2789 stop fs3ost -f || error "unable to stop OST3"
2790 stop fs2ost -f || error "unable to stop OST2"
2791 stop fs2mds -f || error "unable to stop second MDS"
2792 unload_modules_conf || error "unable unload modules"
2795 run_test 36 "df report consistency on OSTs with different block size"
2798 local mntpt=$(facet_mntpt $SINGLEMDS)
2799 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2800 local mdsdev_sym="$TMP/sym_mdt.img"
2801 local opts=$MDS_MOUNT_OPTS
2804 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2805 skip "ldiskfs only test"
2809 echo "MDS : $mdsdev"
2810 echo "SYMLINK : $mdsdev_sym"
2811 do_facet $SINGLEMDS rm -f $mdsdev_sym
2813 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2815 echo "mount symlink device - $mdsdev_sym"
2817 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2818 opts=$(csa_add "$opts" -o loop)
2820 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2821 $mdsdev_sym $mntpt 2>&1)
2824 echo mount_op=$mount_op
2826 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2828 if $(echo $mount_op | grep -q "unable to set tunable"); then
2829 error "set tunables failed for symlink device"
2832 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2834 run_test 37 "verify set tunables works for symlink device"
2836 test_38() { # bug 14222
2837 local fstype=$(facet_fstype $SINGLEMDS)
2838 local mntpt=$(facet_mntpt $SINGLEMDS)
2843 local SRC="/etc /bin"
2844 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2845 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2846 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2847 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2848 error "copying $SRC to $DIR/$tdir"
2850 umount_client $MOUNT || error "umount_client $MOUNT failed"
2851 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2852 stop_mds || error "Unable to stop MDS"
2853 log "delete lov_objid file on MDS"
2855 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2857 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2859 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2861 # check create in mds_lov_connect
2862 start_mds || error "unable to start MDS"
2863 mount_client $MOUNT || error "mount_client $MOUNT failed"
2865 [ $V ] && log "verifying $DIR/$tdir/$f"
2866 diff -q $f $DIR/$tdir/$f || ERROR=y
2868 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2869 if [ "$ERROR" = "y" ]; then
2870 # check it's updates in sync
2871 umount_client $MOUNT
2873 mount_fstype $SIGNLEMDS
2874 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2875 unmount_fstype $SINGLEMDS
2876 error "old and new files are different after connect" || true
2878 touch $DIR/$tdir/f2 || error "f2 file create failed"
2880 # check it's updates in sync
2881 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2884 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2886 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2887 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2889 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2891 start_mds || error "unable to start MDS"
2892 mount_client $MOUNT || error "mount_client $MOUNT failed"
2894 [ $V ] && log "verifying $DIR/$tdir/$f"
2895 diff -q $f $DIR/$tdir/$f || ERROR=y
2897 touch $DIR/$tdir/f3 || error "f3 file create failed"
2898 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2899 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2901 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2902 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2903 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2905 [ "$ERROR" = "y" ] &&
2906 error "old and new files are different after sync" || true
2908 log "files compared the same"
2909 cleanup || error "cleanup failed with $?"
2911 run_test 38 "MDS recreates missing lov_objid file from OST data"
2916 cleanup || error "cleanup failed with $?"
2917 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2918 error "memory leak detected" || true
2920 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2922 test_40() { # bug 15759
2923 start_ost || error "Unable to start OST1"
2924 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2925 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2927 cleanup || error "cleanup failed with rc $?"
2929 run_test 40 "race during service thread startup"
2931 test_41a() { #bug 14134
2932 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2933 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2934 skip "Loop devices does not work with nosvc option"
2939 { skip "needs combined MGT and MDT device" && return 0; }
2941 start_mdt 1 -o nosvc -n
2942 if [ $MDSCOUNT -ge 2 ]; then
2943 for num in $(seq 2 $MDSCOUNT); do
2944 start_mdt $num || return
2947 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2948 start_mdt 1 -o nomgs,force
2949 mount_client $MOUNT || error "mount_client $MOUNT failed"
2952 echo "blah blah" > $MOUNT/$tfile
2955 umount_client $MOUNT || error "umount_client $MOUNT failed"
2956 stop ost1 -f || error "unable to stop OST1"
2957 stop_mds || error "Unable to stop MDS"
2958 stop_mds || error "Unable to stop MDS on second try"
2960 run_test 41a "mount mds with --nosvc and --nomgs"
2963 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2964 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2965 skip "Loop devices does not work with nosvc option"
2969 ! combined_mgs_mds && skip "needs combined mgs device" && return 0
2973 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2975 start_mdt 1 -o nosvc -n
2976 if [ $MDSCOUNT -ge 2 ]; then
2977 for num in $(seq 2 $MDSCOUNT); do
2978 start_mdt $num || return
2981 start_ost || error "Unable to start OST1"
2982 start_mdt 1 -o nomgs,force
2983 mount_client $MOUNT || error "mount_client $MOUNT failed"
2986 echo "blah blah" > $MOUNT/$tfile
2987 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
2989 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
2990 stop_ost || error "Unable to stop OST1"
2991 stop_mds || error "Unable to stop MDS"
2992 stop_mds || error "Unable to stop MDS on second try"
2994 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
2997 local server_version=$(lustre_version_code $SINGLEMDS)
2998 local oss_list=$(comma_list $(osts_nodes))
3000 [[ $server_version -ge $(version_code 2.6.52) ]] ||
3001 [[ $server_version -ge $(version_code 2.5.26) &&
3002 $server_version -lt $(version_code 2.5.50) ]] ||
3003 [[ $server_version -ge $(version_code 2.5.4) &&
3004 $server_version -lt $(version_code 2.5.11) ]] ||
3005 { skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"; return; }
3007 # ensure mds1 ost1 have been created even if running sub-test standalone
3010 cleanup || error "cleanup failed"
3012 # using directly mount command instead of start() function to avoid
3013 # any side effect of // with others/externals tools/features
3014 # ("zpool import", ...)
3016 # MDT concurrent start
3018 LOAD_MODULES_REMOTE=true load_modules
3019 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
3020 error "MDT concurrent start: libcfs module not loaded"
3022 local mds1dev=$(mdsdevname 1)
3023 local mds1mnt=$(facet_mntpt mds1)
3024 local mds1fstype=$(facet_fstype mds1)
3025 local mds1opts=$MDS_MOUNT_OPTS
3027 if [ $mds1fstype == ldiskfs ] &&
3028 ! do_facet mds1 test -b $mds1dev; then
3029 mds1opts=$(csa_add "$mds1opts" -o loop)
3031 if [[ $mds1fstype == zfs ]]; then
3032 import_zpool mds1 || return ${PIPESTATUS[0]}
3035 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3036 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
3038 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
3041 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
3045 do_facet mds1 "$LCTL set_param fail_loc=0x0"
3046 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3047 echo "1st MDT start succeed"
3048 echo "2nd MDT start failed with $rc2"
3049 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3050 echo "1st MDT start failed with $rc"
3051 echo "2nd MDT start succeed"
3054 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
3057 if [ $MDSCOUNT -ge 2 ]; then
3058 for num in $(seq 2 $MDSCOUNT); do
3059 start_mdt $num || return
3063 # OST concurrent start
3065 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
3066 error "OST concurrent start: libcfs module not loaded"
3068 local ost1dev=$(ostdevname 1)
3069 local ost1mnt=$(facet_mntpt ost1)
3070 local ost1fstype=$(facet_fstype ost1)
3071 local ost1opts=$OST_MOUNT_OPTS
3073 if [ $ost1fstype == ldiskfs ] &&
3074 ! do_facet ost1 test -b $ost1dev; then
3075 ost1opts=$(csa_add "$ost1opts" -o loop)
3077 if [[ $ost1fstype == zfs ]]; then
3078 import_zpool ost1 || return ${PIPESTATUS[0]}
3081 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3082 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
3084 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
3087 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
3091 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3092 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3093 echo "1st OST start succeed"
3094 echo "2nd OST start failed with $rc2"
3095 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3096 echo "1st OST start failed with $rc"
3097 echo "2nd OST start succeed"
3101 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3107 # verify everything ok
3112 error "MDT(s) start failed"
3120 error "OST(s) start failed"
3128 error "client start failed"
3135 error "client mount failed"
3139 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3141 test_42() { #bug 14693
3145 check_mount || error "client was not mounted"
3147 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3148 PARAM="llite.$FSNAME-*.some_wrong_param"
3150 PARAM="$FSNAME.llite.some_wrong_param"
3153 do_facet mgs $PERM_CMD $PARAM=10
3154 umount_client $MOUNT ||
3155 error "unmounting client failed with invalid llite param"
3156 mount_client $MOUNT ||
3157 error "mounting client failed with invalid llite param"
3159 do_facet mgs $PERM_CMD $PARAM=20
3160 cleanup || error "stopping $FSNAME failed with invalid sys param"
3162 check_mount || error "client was not mounted with invalid sys param"
3163 cleanup || error "stopping $FSNAME failed with invalid sys param"
3165 run_test 42 "allow client/server mount/unmount with invalid config param"
3168 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.58) ]] ||
3169 { skip "Need MDS version at least 2.5.58" && return 0; }
3170 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
3173 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
3174 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
3178 chmod ugo+x $DIR || error "chmod 0 failed"
3179 set_persistent_param_and_check mds1 \
3180 "mdt.$FSNAME-MDT0000.root_squash" \
3181 "$FSNAME.mdt.root_squash" \
3183 wait_update $HOSTNAME \
3184 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3186 error "check llite root_squash failed!"
3187 set_persistent_param_and_check mds1 \
3188 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3189 "$FSNAME.mdt.nosquash_nids" \
3191 wait_update $HOSTNAME \
3192 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3194 error "check llite nosquash_nids failed!"
3197 # create set of test files
3199 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
3200 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
3201 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
3203 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
3204 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
3206 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
3207 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
3208 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
3210 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
3211 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
3212 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
3215 # check root_squash:
3216 # set root squash UID:GID to RUNAS_ID
3217 # root should be able to access only files owned by RUNAS_ID
3219 set_persistent_param_and_check mds1 \
3220 "mdt.$FSNAME-MDT0000.root_squash" \
3221 "$FSNAME.mdt.root_squash" \
3222 "$RUNAS_ID:$RUNAS_ID"
3223 wait_update $HOSTNAME \
3224 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3225 "$RUNAS_ID:$RUNAS_ID" ||
3226 error "check llite root_squash failed!"
3228 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
3229 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3230 error "$ST: root read permission is denied"
3231 echo "$ST: root read permission is granted - ok"
3234 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3235 error "$ST: root write permission is denied"
3236 echo "$ST: root write permission is granted - ok"
3238 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3239 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3240 error "$ST: root read permission is granted"
3241 echo "$ST: root read permission is denied - ok"
3244 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3245 error "$ST: root write permission is granted"
3246 echo "$ST: root write permission is denied - ok"
3248 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3249 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
3250 error "$ST: root unlink permission is granted"
3251 echo "$ST: root unlink permission is denied - ok"
3253 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
3254 error "$ST: root create permission is granted"
3255 echo "$ST: root create permission is denied - ok"
3258 # check root_squash is enforced independently
3259 # of client cache content
3261 # access file by USER1, keep access open
3262 # root should be denied access to user file
3264 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
3268 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
3269 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3270 { kill $pid; error "$ST: root read permission is granted"; }
3271 echo "$ST: root read permission is denied - ok"
3274 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3275 { kill $pid; error "$ST: root write permission is granted"; }
3276 echo "$ST: root write permission is denied - ok"
3282 # check nosquash_nids:
3283 # put client's NID into nosquash_nids list,
3284 # root should be able to access root file after that
3286 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
3287 NIDLIST="2@gni $NIDLIST 192.168.0.[2,10]@tcp"
3288 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
3289 set_persistent_param_and_check mds1 \
3290 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3291 "$FSNAME-MDTall.mdt.nosquash_nids" \
3293 wait_update $HOSTNAME \
3294 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3296 error "check llite nosquash_nids failed!"
3298 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3299 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3300 error "$ST: root read permission is denied"
3301 echo "$ST: root read permission is granted - ok"
3304 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3305 error "$ST: root write permission is denied"
3306 echo "$ST: root write permission is granted - ok"
3308 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3309 rm $DIR/$tdir-rootdir/tfile-1 ||
3310 error "$ST: root unlink permission is denied"
3311 echo "$ST: root unlink permission is granted - ok"
3312 touch $DIR/$tdir-rootdir/tfile-2 ||
3313 error "$ST: root create permission is denied"
3314 echo "$ST: root create permission is granted - ok"
3315 cleanup || error "cleanup failed with $?"
3317 run_test 43a "check root_squash and nosquash_nids"
3319 test_43b() { # LU-5690
3320 [[ $(lustre_version_code mgs) -ge $(version_code 2.7.62) ]] ||
3321 { skip "Need MGS version 2.7.62+"; return; }
3323 if [[ -z "$fs2mds_DEV" ]]; then
3324 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
3325 skip_env "mixed loopback and real device not working" && return
3328 local fs2mdsdev=$(mdsdevname 1_2)
3329 local fs2mdsvdev=$(mdsvdevname 1_2)
3331 # temporarily use fs2mds as fs2mgs
3333 local fs2mgsdev=$fs2mdsdev
3334 local fs2mgsvdev=$fs2mdsvdev
3336 local fsname=test1234
3338 load_module llite/lustre
3339 local client_ip=$(host_nids_address $HOSTNAME $NETTYPE)
3340 local host=${client_ip//*./}
3341 local net=${client_ip/%$host/}
3342 local nosquash_nids=$(h2nettype $net[$host,$host,$host])
3344 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
3345 --param mdt.root_squash=$RUNAS_ID:$RUNAS_ID \
3346 --param mdt.nosquash_nids=$nosquash_nids \
3347 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
3348 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS || error "start fs2mgs failed"
3349 stop $fs2mgs -f || error "stop fs2mgs failed"
3350 cleanup || error "cleanup failed with $?"
3352 run_test 43b "parse nosquash_nids with commas in expr_list"
3356 check_mount || error "check_mount"
3357 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
3359 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
3360 for VAL in $UUIDS; do
3361 NID=$(echo $VAL | cut -d= -f1)
3362 CLUUID=$(echo $VAL | cut -d= -f2)
3363 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
3365 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
3366 cleanup || error "cleanup failed with $?"
3368 run_test 44 "mounted client proc entry exists"
3372 check_mount || error "check_mount"
3373 stop_mds || error "Unable to stop MDS"
3377 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
3378 do_facet client "$LCTL set_param fail_loc=0x8000050f"
3381 manual_umount_client --force || error "manual_umount_client failed"
3382 do_facet client "$LCTL set_param fail_loc=0x0"
3383 start_mds || error "unable to start MDS"
3384 mount_client $MOUNT || error "mount_client $MOUNT failed"
3385 cleanup || error "cleanup failed with $?"
3387 run_test 45 "long unlink handling in ptlrpcd"
3394 umount_client $MOUNT2 || rc=$?
3395 umount_client $MOUNT || rc=$?
3396 while [ $count -gt 0 ]; do
3397 stop ost${count} -f || rc=$?
3401 cleanup_nocli || rc=$?
3402 #writeconf to remove all ost2 traces for subsequent tests
3403 writeconf_or_reformat
3408 echo "Testing with $OSTCOUNT OSTs"
3410 start_mds || error "unable to start MDS"
3411 #first client should see only one ost
3412 start_ost || error "Unable to start OST1"
3413 wait_osc_import_state mds ost FULL
3415 mount_client $MOUNT || error "mount_client $MOUNT failed"
3416 trap "cleanup_46a $OSTCOUNT" EXIT ERR
3419 for (( i=2; i<=$OSTCOUNT; i++ )); do
3420 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
3421 error "start_ost$i $(ostdevname $i) failed"
3424 # wait until osts in sync
3425 for (( i=2; i<=$OSTCOUNT; i++ )); do
3426 wait_osc_import_state mds ost$i FULL
3427 wait_osc_import_ready client ost$i
3430 #second client see all ost's
3432 mount_client $MOUNT2 || error "mount_client failed"
3433 $LFS setstripe -c -1 $MOUNT2 ||
3434 error "$LFS setstripe -c -1 $MOUNT2 failed"
3435 $LFS getstripe $MOUNT2 || error "$LFS getstripe $MOUNT2 failed"
3437 echo "ok" > $MOUNT2/widestripe
3438 $LFS getstripe $MOUNT2/widestripe ||
3439 error "$LFS getstripe $MOUNT2/widestripe failed"
3440 # fill acl buffer for avoid expand lsm to them
3441 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
3443 setfacl -m $acl $MOUNT2/widestripe
3447 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3449 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
3451 run_test 46a "handle ost additional - wide striped file"
3456 check_mount || error "check_mount failed"
3457 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
3461 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3462 if echo $ns | grep "MDT[[:digit:]]*"; then
3465 lrs=$(echo $ns | sed 's/.*lru_size=//')
3466 lru_size[count]=$lrs
3471 facet_failover $SINGLEMDS
3472 client_up || error "client_up failed"
3475 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3476 if echo $ns | grep "MDT[[:digit:]]*"; then
3479 lrs=$(echo $ns | sed 's/.*lru_size=//')
3480 if ! test "$lrs" -eq "${lru_size[count]}"; then
3481 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
3482 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
3487 cleanup || error "cleanup failed with $?"
3489 run_test 47 "server restart does not make client loss lru_resize settings"
3494 # reformat after this test is needed - if the test fails,
3495 # we will have unkillable file at FS
3499 test_48() { # bz-17636 LU-7473
3503 check_mount || error "check_mount failed"
3505 $LFS setstripe -c -1 $MOUNT ||
3506 error "$LFS setstripe -c -1 $MOUNT failed"
3507 $LFS getstripe $MOUNT || error "$LFS getstripe $MOUNT failed"
3509 echo "ok" > $MOUNT/widestripe
3510 $LFS getstripe $MOUNT/widestripe ||
3511 error "$LFS getstripe $MOUNT/widestripe failed"
3513 # In the future, we may introduce more EAs, such as selinux, enlarged
3514 # LOV EA, and so on. These EA will use some EA space that is shared by
3515 # ACL entries. So here we only check some reasonable ACL entries count,
3516 # instead of the max number that is calculated from the max_ea_size.
3517 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.57) ];
3519 count=28 # hard coded of RPC protocol
3520 elif [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3521 count=4000 # max_num 4091 max_ea_size = 32768
3522 elif ! large_xattr_enabled; then
3523 count=450 # max_num 497 max_ea_size = 4012
3525 count=4500 # max_num 8187 max_ea_size = 1048492
3526 # not create too much (>5000) to save test time
3529 echo "It is expected to hold at least $count ACL entries"
3530 trap cleanup_48 EXIT ERR
3531 for ((i = 0; i < $count; i++)) do
3532 setfacl -m u:$((i + 100)):rw $MOUNT/widestripe ||
3533 error "Fail to setfacl for $MOUNT/widestripe at $i"
3536 cancel_lru_locks mdc
3537 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3538 local r_count=$(getfacl $MOUNT/widestripe | grep "user:" | wc -l)
3539 count=$((count + 1)) # for the entry "user::rw-"
3541 [ $count -eq $r_count ] ||
3542 error "Expected ACL entries $count, but got $r_count"
3546 run_test 48 "too many acls on file"
3548 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3549 test_49a() { # bug 17710
3550 local timeout_orig=$TIMEOUT
3551 local ldlm_timeout_orig=$LDLM_TIMEOUT
3552 local LOCAL_TIMEOUT=20
3554 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3555 TIMEOUT=$LOCAL_TIMEOUT
3559 check_mount || error "client mount failed"
3561 echo "check ldlm_timout..."
3562 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3563 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3564 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3566 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3567 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3570 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3571 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3574 umount_client $MOUNT || error "umount_client $MOUNT failed"
3575 stop_ost || error "problem stopping OSS"
3576 stop_mds || error "problem stopping MDS"
3578 LDLM_TIMEOUT=$ldlm_timeout_orig
3579 TIMEOUT=$timeout_orig
3581 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3583 test_49b() { # bug 17710
3584 local timeout_orig=$TIMEOUT
3585 local ldlm_timeout_orig=$LDLM_TIMEOUT
3586 local LOCAL_TIMEOUT=20
3588 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3589 TIMEOUT=$LOCAL_TIMEOUT
3593 check_mount || error "client mount failed"
3595 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3596 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3597 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3599 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3600 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3603 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3604 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3607 cleanup || error "cleanup failed"
3609 LDLM_TIMEOUT=$ldlm_timeout_orig
3610 TIMEOUT=$timeout_orig
3612 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3615 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3617 # Test both statfs and lfs df and fail if either one fails
3618 multiop_bg_pause $1 f_
3621 killall -USR1 multiop
3622 [ $RC -ne 0 ] && log "lazystatfs multiop failed"
3623 wait $PID || { RC=$?; log "multiop return error "; }
3625 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3630 if kill -s 0 $PID; then
3633 log "lazystatfs lfs df failed to complete in 5s"
3641 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3642 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3644 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3646 cleanup || error "cleanup failed with rc $?"
3648 run_test 50a "lazystatfs all servers available"
3652 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3653 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3655 # Wait for client to detect down OST
3656 stop_ost || error "Unable to stop OST1"
3657 wait_osc_import_state client ost DISCONN
3659 log "OSCs should all be DISCONN"
3661 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
3663 umount_client $MOUNT || error "Unable to unmount client"
3664 stop_mds || error "Unable to stop MDS"
3666 run_test 50b "lazystatfs all servers down"
3669 start_mds || error "Unable to start MDS"
3670 start_ost || error "Unable to start OST1"
3671 start_ost2 || error "Unable to start OST2"
3672 mount_client $MOUNT || error "Unable to mount client"
3673 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3674 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3676 # Wait for client to detect down OST
3677 stop_ost || error "Unable to stop OST1"
3678 wait_osc_import_state mds ost DISCONN
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 50c "lazystatfs one server down"
3690 start_mds || error "Unable to start MDS"
3691 start_ost || error "Unable to start OST1"
3692 start_ost2 || error "Unable to start OST2"
3693 mount_client $MOUNT || error "Unable to mount client"
3694 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3695 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3697 # Issue the statfs during the window where the client still
3698 # belives the OST to be available but it is in fact down.
3699 # No failure just a statfs which hangs for a timeout interval.
3700 stop_ost || error "Unable to stop OST1"
3701 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3703 umount_client $MOUNT || error "Unable to unmount client"
3704 stop_ost2 || error "Unable to stop OST2"
3705 stop_mds || error "Unable to stop MDS"
3706 #writeconf to remove all ost2 traces for subsequent tests
3707 writeconf_or_reformat
3709 run_test 50d "lazystatfs client/server conn race"
3716 start_mds || error "Unable to start MDS"
3717 #first client should see only one ost
3718 start_ost || error "Unable to start OST1"
3719 wait_osc_import_state mds ost FULL
3721 # Wait for client to detect down OST
3722 stop_ost || error "Unable to stop OST1"
3723 wait_osc_import_state mds ost DISCONN
3725 mount_client $MOUNT || error "Unable to mount client"
3726 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3728 multiop_bg_pause $MOUNT _f
3732 if [ $RC1 -ne 0 ]; then
3733 log "multiop failed $RC1"
3736 sleep $(( $TIMEOUT+1 ))
3738 [ $? -ne 0 ] && error "process isn't sleep"
3739 start_ost || error "Unable to start OST1"
3740 wait $pid || error "statfs failed"
3743 umount_client $MOUNT || error "Unable to unmount client"
3744 stop_ost || error "Unable to stop OST1"
3745 stop_mds || error "Unable to stop MDS"
3747 run_test 50e "normal statfs all servers down"
3752 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3754 start_mds || error "Unable to start mds"
3755 #first client should see only one ost
3756 start_ost || error "Unable to start OST1"
3757 wait_osc_import_state mds ost FULL
3759 start_ost2 || error "Unable to start OST2"
3760 wait_osc_import_state mds ost2 FULL
3762 # Wait for client to detect down OST
3763 stop_ost2 || error "Unable to stop OST2"
3765 wait_osc_import_state mds ost2 DISCONN
3766 mount_client $MOUNT || error "Unable to mount client"
3767 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3769 multiop_bg_pause $MOUNT _f
3773 if [ $RC1 -ne 0 ]; then
3774 log "lazystatfs multiop failed $RC1"
3777 sleep $(( $TIMEOUT+1 ))
3779 [ $? -ne 0 ] && error "process isn't sleep"
3780 start_ost2 || error "Unable to start OST2"
3781 wait $pid || error "statfs failed"
3782 stop_ost2 || error "Unable to stop OST2"
3785 umount_client $MOUNT -f || error "Unable to unmount client"
3786 stop_ost || error "Unable to stop OST1"
3787 stop_mds || error "Unable to stop MDS"
3788 #writeconf to remove all ost2 traces for subsequent tests
3789 writeconf_or_reformat
3791 run_test 50f "normal statfs one server in down"
3794 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs" && return
3796 start_ost2 || error "Unable to start OST2"
3797 wait_osc_import_state mds ost2 FULL
3798 wait_osc_import_ready client ost2
3800 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3801 local PARAM="osc.${FSNAME}-OST0001*.active"
3803 local PARAM="${FSNAME}-OST0001.osc.active"
3806 $LFS setstripe -c -1 $DIR/$tfile || error "$LFS setstripe failed"
3807 do_facet mgs $PERM_CMD $PARAM=0 || error "Unable to deactivate OST"
3809 umount_client $MOUNT || error "Unable to unmount client"
3810 mount_client $MOUNT || error "Unable to mount client"
3811 # This df should not cause a panic
3814 do_facet mgs $PERM_CMD $PARAM=1 || error "Unable to activate OST"
3815 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
3816 umount_client $MOUNT || error "Unable to unmount client"
3817 stop_ost2 || error "Unable to stop OST2"
3818 stop_ost || error "Unable to stop OST1"
3819 stop_mds || error "Unable to stop MDS"
3820 #writeconf to remove all ost2 traces for subsequent tests
3821 writeconf_or_reformat
3823 run_test 50g "deactivated OST should not cause panic"
3827 # prepare MDT/OST, make OSC inactive for OST1
3828 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs" && return
3830 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3831 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3832 error "tunefs OST1 failed"
3833 start_mds || error "Unable to start MDT"
3834 start_ost || error "Unable to start OST1"
3835 start_ost2 || error "Unable to start OST2"
3836 mount_client $MOUNT || error "client start failed"
3838 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3840 # activatate OSC for OST1
3841 set_persistent_param_and_check client \
3842 "osc.${FSNAME}-OST0000-osc-[!M]*.active" \
3843 "${FSNAME}-OST0000.osc.active" 1
3845 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3846 $LFS setstripe -c -1 -i 0 $DIR/$tdir/2 ||
3847 error "$LFS setstripe $DIR/$tdir/2 failed"
3848 sleep 1 && echo "create a file after OST1 is activated"
3849 # doing some io, shouldn't crash
3850 dd if=/dev/zero of=$DIR/$tdir/2/$tfile-io bs=1M count=10
3852 # check OSC import is working
3853 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3854 error "some OSC imports are still not connected"
3858 umount_client $MOUNT || error "Unable to umount client"
3859 stop_ost2 || error "Unable to stop OST2"
3860 cleanup_nocli || error "cleanup_nocli failed with $?"
3862 run_test 50h "LU-642: activate deactivated OST"
3865 # prepare MDT/OST, make OSC inactive for OST1
3866 [ "$MDSCOUNT" -lt "2" ] && skip_env "needs >= 2 MDTs" && return
3869 [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
3870 do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
3871 error "tunefs MDT2 failed"
3872 start_mds || error "Unable to start MDT"
3873 start_ost || error "Unable to start OST1"
3874 start_ost2 || error "Unable to start OST2"
3875 mount_client $MOUNT || error "client start failed"
3877 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3879 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3880 $PERM_CMD mdc.${FSNAME}-MDT0001-mdc-*.active=0 &&
3881 error "deactive MDC0 succeeds"
3883 $PERM_CMD ${FSNAME}-MDT0000.mdc.active=0 &&
3884 error "deactive MDC0 succeeds"
3887 # activate MDC for MDT2
3888 set_persistent_param_and_check client \
3889 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3890 "${FSNAME}-MDT0001.mdc.active" 1
3892 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
3893 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.60) ]
3895 wait_dne_interconnect
3897 $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3899 createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
3901 rm -rf $DIR/$tdir/2 || error "unlink dir failed"
3903 # deactivate MDC for MDT2
3904 set_persistent_param_and_check client \
3905 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3906 "${FSNAME}-MDT0001.mdc.active" 0
3908 wait_osp_active mds ${FSNAME}-MDT0001 1 0
3910 $LFS mkdir -i1 $DIR/$tdir/2 &&
3911 error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
3913 $LFS mkdir -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3914 error "mkdir $DIR/$tdir/striped_dir fails after deactive MDT2"
3916 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3917 [ $stripe_count -eq $((MDSCOUNT - 1)) ] ||
3918 error "wrong $stripe_count != $((MDSCOUNT -1)) for striped_dir"
3921 umount_client $MOUNT || error "Unable to umount client"
3926 run_test 50i "activate deactivated MDT"
3929 local LOCAL_TIMEOUT=20
3933 check_mount || error "check_mount failed"
3935 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3936 $LFS setstripe -c -1 $MOUNT/$tdir ||
3937 error "$LFS setstripe -c -1 $MOUNT/$tdir failed"
3938 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3939 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
3940 touch $MOUNT/$tdir/$tfile &
3943 start_ost2 || error "Unable to start OST1"
3945 stop_ost2 || error "Unable to stop OST1"
3946 umount_client $MOUNT -f || error “unmount $MOUNT failed”
3947 cleanup_nocli || error “stop server failed”
3948 #writeconf to remove all ost2 traces for subsequent tests
3949 writeconf_or_reformat
3951 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
3960 do_node $node mkdir -p $dest
3961 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3963 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
3964 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3965 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
3967 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
3968 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
3978 local backup2=${TMP}/backup2
3980 do_node $node mkdir -p $backup2
3981 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3983 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
3984 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3985 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
3987 do_node $node "diff -rq $backup $backup2"
3988 [ $? -eq 0 ] || { error "contents differ"; return 3; }
3990 local xattrs2=${TMP}/xattrs2
3991 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
3992 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
3994 do_node $node "diff $xattrs $xattrs2"
3995 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
3997 do_node $node "rm -rf $backup2 $xattrs2"
3998 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
4002 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4003 skip "ldiskfs only test"
4007 start_mds || error "Unable to start MDS"
4008 start_ost || error "Unable to start OST1"
4009 mount_client $MOUNT || error "Unable to mount client"
4012 local ost1mnt=$(facet_mntpt ost1)
4013 local ost1node=$(facet_active_host ost1)
4014 local ost1tmp=$TMP/conf52
4017 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
4018 touch $TMP/modified_first || error "Unable to create temporary file"
4019 local mtime=$(stat -c %Y $TMP/modified_first)
4020 do_node $ost1node "mkdir -p $ost1tmp &&
4021 touch -m -d @$mtime $ost1tmp/modified_first" ||
4022 error "Unable to create temporary file"
4025 $LFS setstripe -c -1 -S 1M $DIR/$tdir || error "$LFS setstripe failed"
4027 for (( i=0; i < nrfiles; i++ )); do
4028 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
4029 error "multiop failed"
4034 # sync all the data and make sure no pending data on the client,
4035 # thus the SOM xattr would not be changed any more.
4036 cancel_lru_locks osc
4039 echo backup files to $TMP/$tdir
4040 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
4041 copy_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4042 error "Unable to copy files"
4044 umount_client $MOUNT || error "Unable to umount client"
4045 stop_ost || error "Unable to stop ost1"
4047 echo mount ost1 as ldiskfs
4048 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
4049 if ! do_node $ost1node test -b $ost1_dev; then
4052 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
4054 error "Unable to mount ost1 as ldiskfs"
4057 echo backup objects to $ost1tmp/objects
4058 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
4059 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
4060 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
4062 error "Unable to copy objects"
4064 # move objects to lost+found
4065 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
4066 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
4068 do_node $ost1node "umount $ost1mnt" ||
4069 error "Unable to umount ost1 as ldiskfs"
4071 start_ost || error "Unable to start OST1"
4072 mount_client $MOUNT || error "Unable to mount client"
4074 local REPAIRED=$(do_node $ost1node "$LCTL get_param \
4075 -n osd-ldiskfs.$FSNAME-OST0000.oi_scrub" |
4076 awk '/^lf_repa[ri]*ed/ { print $2 }')
4077 [ $REPAIRED -gt 0 ] ||
4078 error "Some entry under /lost+found should be repaired"
4081 diff_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4082 error "Unable to diff files"
4084 rm -rf $TMP/$tdir $TMP/file_xattrs ||
4085 error "Unable to delete temporary files"
4086 do_node $ost1node "rm -rf $ost1tmp" ||
4087 error "Unable to delete temporary files"
4088 cleanup || error "cleanup failed with $?"
4090 run_test 52 "check recovering objects from lost+found"
4092 # Checks threads_min/max/started for some service
4094 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
4095 # parameter pattern prefix like 'ost.*.ost'.
4108 local msg="Insane $modname thread counts"
4109 local ncpts=$(check_cpt_number $facet)
4113 check_mount || return 41
4115 # We need to expand $parampat, but it may match multiple parameters, so
4116 # we'll pick the first one
4117 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
4118 error "Couldn't expand ${parampat}.threads_min parameter name"
4122 # Remove the .threads_min part
4123 paramp=${paramp%.threads_min}
4125 # Check for sanity in defaults
4126 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4128 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4130 tstarted=$(do_facet $facet "$LCTL get_param \
4131 -n ${paramp}.threads_started" || echo 0)
4132 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
4134 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4136 nthrs=$(expr $tmax - $tmin)
4137 if [ $nthrs -lt $ncpts ]; then
4143 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
4144 skip_env "module parameter forced $facet thread count" &&
4145 tmin=3 && tmax=$((3 * tmax))
4147 # Check that we can change min/max
4148 do_facet $facet "$LCTL set_param \
4149 ${paramp}.threads_min=$((tmin + nthrs))"
4150 do_facet $facet "$LCTL set_param \
4151 ${paramp}.threads_max=$((tmax - nthrs))"
4152 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4154 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4156 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
4157 $tmax2 == ($tmax - $nthrs)))' || return $?
4159 # Check that we can set min/max to the same value
4160 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4162 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
4163 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4165 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4167 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
4169 # Check that we can't set max < min
4170 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
4171 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4173 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4175 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
4177 # We need to ensure that we get the module options desired; to do this
4178 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
4179 LOAD_MODULES_REMOTE=true
4182 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
4183 setmodopts -a $modname "$newvalue" oldvalue
4186 check_mount || return 41
4188 # Restore previous setting of MODOPTS_*
4189 setmodopts $modname "$oldvalue"
4191 # Check that $opts took
4192 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4194 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4196 tstarted=$(do_facet $facet \
4197 "$LCTL get_param -n ${paramp}.threads_started" || echo 0)
4198 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4207 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
4208 cleanup || error "cleanup failed with rc $?"
4210 run_test 53a "check OSS thread count params"
4214 local mds=$(do_facet $SINGLEMDS "$LCTL get_param \
4215 -N mds.*.*.threads_max 2>/dev/null")
4216 if [ -z "$mds" ]; then
4217 #running this on an old MDT
4218 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
4220 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
4222 cleanup || error "cleanup failed with $?"
4224 run_test 53b "check MDS thread count params"
4227 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4228 skip "ldiskfs only test"
4232 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
4233 error "llverdev failed with rc=$?"
4236 run_test 54a "test llverdev and partial verify of device"
4239 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4240 skip "ldiskfs only test"
4245 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
4246 cleanup || error "cleanup failed with rc=$?"
4248 run_test 54b "test llverfs and partial verify of filesystem"
4252 local max_ost_index=$1
4253 echo -n $(((max_ost_index + 1) * 8))
4257 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4258 skip "ldiskfs only test"
4262 local mdsdev=$(mdsdevname 1)
4263 local mdsvdev=$(mdsvdevname 1)
4267 if ! combined_mgs_mds; then
4268 stop_mgs || error "stopping MGS service failed"
4269 format_mgs || error "formatting MGT failed"
4271 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
4273 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
4274 --reformat $(ostdevname 1) $(ostvdevname 1)
4280 echo checking size of lov_objid for ost index $i
4281 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" |
4282 grep ^User | awk -F 'Size: ' '{print $2}')
4283 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
4284 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
4286 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
4293 run_test 55 "check lov_objid size"
4296 local server_version=$(lustre_version_code $SINGLEMDS)
4297 local mds_journal_size_orig=$MDSJOURNALSIZE
4303 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
4304 $(ostdevname 1) $(ostvdevname 1)
4305 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
4306 $(ostdevname 2) $(ostvdevname 2)
4309 start_ost || error "Unable to start first ost (idx 10000)"
4310 start_ost2 || error "Unable to start second ost (idx 1000)"
4311 mount_client $MOUNT || error "Unable to mount client"
4315 if [[ $server_version -ge $(version_code 2.6.54) ]] ||
4316 [[ $server_version -ge $(version_code 2.5.4) &&
4317 $server_version -lt $(version_code 2.5.11) ]]; then
4318 wait_osc_import_state mds ost1 FULL
4319 wait_osc_import_state mds ost2 FULL
4320 $LFS setstripe --stripe-count=-1 $DIR/$tfile ||
4321 error "Unable to setstripe $DIR/$tfile"
4322 n=$($LFS getstripe --stripe-count $DIR/$tfile)
4323 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
4328 MDSJOURNALSIZE=$mds_journal_size_orig
4331 run_test 56a "check big OST indexes and out-of-index-order start"
4336 umount_client $MOUNT -f || error "unmount client failed"
4345 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs" && return
4347 trap cleanup_56b EXIT RETURN ERR
4350 if ! combined_mgs_mds ; then
4355 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) --index=0 --reformat \
4356 $(mdsdevname 1) $(mdsvdevname 1)
4357 add mds2 $(mkfs_opts mds2 $(mdsdevname 2)) --index=1 --reformat \
4358 $(mdsdevname 2) $(mdsvdevname 2)
4359 add mds3 $(mkfs_opts mds3 $(mdsdevname 3)) --index=1000 --reformat \
4360 $(mdsdevname 3) $(mdsvdevname 3)
4364 start_mdt 1 || error "MDT 1 (idx 0) start failed"
4365 start_mdt 2 || error "MDT 2 (idx 1) start failed"
4366 start_mdt 3 || error "MDT 3 (idx 1000) start failed"
4367 start_ost || error "Unable to start first ost"
4368 start_ost2 || error "Unable to start second ost"
4370 do_nodes $(comma_list $(mdts_nodes)) \
4371 "$LCTL set_param mdt.*.enable_remote_dir=1 \
4372 mdt.*.enable_remote_dir_gid=-1"
4374 mount_client $MOUNT || error "Unable to mount client"
4376 $LFS mkdir -c3 $MOUNT/$tdir || error "failed to make testdir"
4378 echo "This is test file 1!" > $MOUNT/$tdir/$tfile.1 ||
4379 error "failed to make test file 1"
4380 echo "This is test file 2!" > $MOUNT/$tdir/$tfile.2 ||
4381 error "failed to make test file 2"
4382 echo "This is test file 1000!" > $MOUNT/$tdir/$tfile.1000 ||
4383 error "failed to make test file 1000"
4385 rm -rf $MOUNT/$tdir || error "failed to remove testdir"
4387 $LFS mkdir -i1000 $MOUNT/$tdir.1000 ||
4388 error "create remote dir at idx 1000 failed"
4391 echo "=== START lfs df OUTPUT ==="
4393 echo "==== END lfs df OUTPUT ===="
4395 mdtcnt=$(echo -e "$output" | grep $FSNAME-MDT | wc -l)
4396 ostcnt=$(echo -e "$output" | grep $FSNAME-OST | wc -l)
4398 echo "lfs df returned mdt count $mdtcnt and ost count $ostcnt"
4399 [ $mdtcnt -eq 3 ] || error "lfs df returned wrong mdt count"
4400 [ $ostcnt -eq 2 ] || error "lfs df returned wrong ost count"
4402 echo "This is test file 1!" > $MOUNT/$tdir.1000/$tfile.1 ||
4403 error "failed to make test file 1"
4404 echo "This is test file 2!" > $MOUNT/$tdir.1000/$tfile.2 ||
4405 error "failed to make test file 2"
4406 echo "This is test file 1000!" > $MOUNT/$tdir.1000/$tfile.1000 ||
4407 error "failed to make test file 1000"
4408 rm -rf $MOUNT/$tdir.1000 || error "failed to remove remote_dir"
4411 echo "=== START lfs mdts OUTPUT ==="
4413 echo "==== END lfs mdts OUTPUT ===="
4415 echo -e "$output" | grep -v "MDTS:" | awk '{print $1}' |
4416 sed 's/://g' > $TMP/mdts-actual.txt
4417 sort $TMP/mdts-actual.txt -o $TMP/mdts-actual.txt
4419 echo -e "0\n1\n1000" > $TMP/mdts-expected.txt
4421 diff $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4424 rm $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4426 [ $result -eq 0 ] || error "target_obd proc file is incorrect!"
4428 run_test 56b "test target_obd correctness with nonconsecutive MDTs"
4430 test_57a() { # bug 22656
4431 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4432 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4433 tail -1 | awk '{print $1}')
4434 writeconf_or_reformat
4435 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4436 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
4437 error "tunefs failed"
4439 start_ost && error "OST registration from failnode should fail"
4442 run_test 57a "initial registration from failnode should fail (should return errs)"
4445 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4446 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4447 tail -1 | awk '{print $1}')
4448 writeconf_or_reformat
4449 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4450 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
4451 error "tunefs failed"
4453 start_ost || error "OST registration from servicenode should not fail"
4456 run_test 57b "initial registration from servicenode should not fail"
4459 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
4462 test_58() { # bug 22658
4463 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
4465 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4466 createmany -o $DIR/$tdir/$tfile-%d 100
4467 unlinkmany $DIR/$tdir/$tfile-%d 100
4468 stop_mds || error "Unable to stop MDS"
4470 local MNTDIR=$(facet_mntpt $SINGLEMDS)
4471 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4473 # remove all files from the OBJECTS dir
4474 mount_fstype $SINGLEMDS
4476 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
4478 unmount_fstype $SINGLEMDS
4479 # restart MDS with missing llog files
4480 start_mds || error "unable to start MDS"
4481 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
4484 run_test 58 "missing llog files must not prevent MDT from mounting"
4487 start_mgsmds >> /dev/null
4488 local C1=$(count_osts)
4489 if [ $C1 -eq 0 ]; then
4490 start_ost >> /dev/null
4494 echo "original ost count: $C1 (expect > 0)"
4495 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
4496 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
4497 local C2=$(count_osts)
4498 echo "after mdt writeconf count: $C2 (expect 0)"
4499 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
4500 echo "OST start without writeconf should fail:"
4501 start_ost >> /dev/null &&
4502 error "OST start without writeconf didn't fail"
4503 echo "OST start with writeconf should succeed:"
4504 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
4505 local C3=$(count_osts)
4506 echo "after ost writeconf count: $C3 (expect 1)"
4507 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
4508 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
4509 local C4=$(count_osts)
4510 echo "after ost2 writeconf count: $C4 (expect 2)"
4511 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
4512 stop_ost2 >> /dev/null
4513 cleanup_nocli >> /dev/null
4514 #writeconf to remove all ost2 traces for subsequent tests
4515 writeconf_or_reformat
4517 run_test 59 "writeconf mount option"
4519 test_60() { # LU-471
4522 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4523 skip "ldiskfs only test"
4527 for num in $(seq $MDSCOUNT); do
4528 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
4529 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
4530 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4534 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
4535 [ ${PIPESTATUS[0]} -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
4537 # MDT default has dirdata feature
4538 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
4539 # we disable uninit_bg feature
4540 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
4541 # we set stride extended options
4542 echo $dump | grep stride > /dev/null || error "stride is not set"
4545 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
4550 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
4551 { skip "Need MDS version at least 2.1.53"; return 0; }
4553 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
4554 ! large_xattr_enabled; then
4557 for num in $(seq $MDSCOUNT); do
4558 do_facet mds${num} $TUNE2FS -O ea_inode \
4559 $(mdsdevname $num) ||
4560 error "tune2fs on mds $num failed"
4564 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
4565 setup_noconfig || error "setting up the filesystem failed"
4566 client_up || error "starting client failed"
4568 local file=$DIR/$tfile
4569 touch $file || error "touch $file failed"
4571 local large_value="$(generate_string $(max_xattr_size))"
4572 local small_value="bar"
4574 local name="trusted.big"
4575 log "save large xattr $name on $file"
4576 setfattr -n $name -v $large_value $file ||
4577 error "saving $name on $file failed"
4579 local new_value=$(get_xattr_value $name $file)
4580 [[ "$new_value" != "$large_value" ]] &&
4581 error "$name different after saving"
4583 log "shrink value of $name on $file"
4584 setfattr -n $name -v $small_value $file ||
4585 error "shrinking value of $name on $file failed"
4587 new_value=$(get_xattr_value $name $file)
4588 [[ "$new_value" != "$small_value" ]] &&
4589 error "$name different after shrinking"
4591 log "grow value of $name on $file"
4592 setfattr -n $name -v $large_value $file ||
4593 error "growing value of $name on $file failed"
4595 new_value=$(get_xattr_value $name $file)
4596 [[ "$new_value" != "$large_value" ]] &&
4597 error "$name different after growing"
4599 log "check value of $name on $file after remounting MDS"
4601 new_value=$(get_xattr_value $name $file)
4602 [[ "$new_value" != "$large_value" ]] &&
4603 error "$name different after remounting MDS"
4605 log "remove large xattr $name from $file"
4606 setfattr -x $name $file || error "removing $name from $file failed"
4609 stopall || error "stopping for e2fsck run"
4610 for num in $(seq $MDSCOUNT); do
4611 run_e2fsck $(facet_active_host mds$num) \
4612 $(mdsdevname $num) "-y" ||
4613 error "e2fsck MDT$num failed"
4615 setup_noconfig || error "remounting the filesystem failed"
4618 # need to delete this file to avoid problems in other tests
4620 stopall || error "stopping systems failed"
4622 run_test 61 "large xattr"
4625 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4626 skip "ldiskfs only test"
4631 local mdsdev=$(mdsdevname 1)
4632 local ostdev=$(ostdevname 1)
4634 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
4635 { skip "Need MDS version at least 2.2.51"; return 0; }
4637 echo "disable journal for mds"
4638 do_facet mds1 $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
4639 start_mds && error "MDT start should fail"
4640 echo "disable journal for ost"
4641 do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
4642 start_ost && error "OST start should fail"
4643 cleanup || error "cleanup failed with rc $?"
4646 run_test 62 "start with disabled journal"
4649 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4650 skip "ldiskfs only test"
4654 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ldiskfs
4655 local inode_slab=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4656 awk '/ldiskfs_inode_cache/ { print $5 / $6 }')
4657 if [ -z "$inode_slab" ]; then
4658 skip "ldiskfs module has not been loaded"
4662 echo "$inode_slab ldiskfs inodes per page"
4663 [ "${inode_slab%.*}" -ge "3" ] && return 0
4665 # If kmalloc-128 is also 1 per page - this is a debug kernel
4666 # and so this is not an error.
4667 local kmalloc128=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4668 awk '/^(kmalloc|size)-128 / { print $5 / $6 }')
4669 # 32 128-byte chunks in 4k
4670 [ "${kmalloc128%.*}" -lt "32" ] ||
4671 error "ldiskfs inode too big, only $inode_slab objs/page, " \
4672 "kmalloc128 = $kmalloc128 objs/page"
4674 run_test 63 "Verify each page can at least hold 3 ldiskfs inodes"
4677 start_mds || error "unable to start MDS"
4678 start_ost || error "Unable to start OST1"
4679 start_ost2 || error "Unable to start second ost"
4680 mount_client $MOUNT || error "Unable to mount client"
4681 stop_ost2 || error "Unable to stop second ost"
4684 umount_client $MOUNT -f || error “unmount $MOUNT failed”
4685 cleanup_nocli || error "cleanup_nocli failed with $?"
4686 #writeconf to remove all ost2 traces for subsequent tests
4687 writeconf_or_reformat
4689 run_test 64 "check lfs df --lazy "
4691 test_65() { # LU-2237
4692 # Currently, the test is only valid for ldiskfs backend
4693 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
4694 skip "ldiskfs only test" && return
4696 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4697 local brpt=$(facet_mntpt brpt)
4700 if ! do_facet $SINGLEMDS "test -b $devname"; then
4704 stop_mds || error "Unable to stop MDS"
4705 local obj=$(do_facet $SINGLEMDS \
4706 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
4708 if [ -z "$obj" ]; then
4709 # The MDT may be just re-formatted, mount the MDT for the
4710 # first time to guarantee the "last_rcvd" file is there.
4711 start_mds || error "fail to mount the MDS for the first time"
4712 stop_mds || error "Unable to stop MDS"
4715 # remove the "last_rcvd" file
4716 do_facet $SINGLEMDS "mkdir -p $brpt"
4717 do_facet $SINGLEMDS \
4718 "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
4719 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
4720 do_facet $SINGLEMDS "$UMOUNT $brpt"
4722 # restart MDS, the "last_rcvd" file should be recreated.
4723 start_mds || error "fail to restart the MDS"
4724 stop_mds || error "Unable to stop MDS"
4725 obj=$(do_facet $SINGLEMDS \
4726 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
4727 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
4729 run_test 65 "re-create the lost last_rcvd file when server mount"
4732 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
4733 { skip "Need MGS version at least 2.3.59"; return 0; }
4736 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
4737 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
4739 # add EXCLUDE records to config log, they are not to be
4740 # removed by lctl replace_nids
4741 set_conf_param_and_check mds \
4742 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4743 "$FSNAME-OST0000.osc.active" \
4746 echo "replace_nids should fail if MDS, OSTs and clients are UP"
4747 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4748 error "replace_nids fail"
4750 umount_client $MOUNT || error "unmounting client failed"
4751 echo "replace_nids should fail if MDS and OSTs are UP"
4752 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4753 error "replace_nids fail"
4755 stop_ost || error "Unable to stop OST1"
4756 echo "replace_nids should fail if MDS is UP"
4757 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4758 error "replace_nids fail"
4760 stop_mds || error "stopping mds failed"
4762 if combined_mgs_mds; then
4763 start_mdt 1 "-o nosvc" ||
4764 error "starting mds with nosvc option failed"
4767 echo "command should accept two parameters"
4768 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
4769 error "command should accept two params"
4771 echo "correct device name should be passed"
4772 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
4773 error "wrong devname"
4775 echo "wrong nids list should not destroy the system"
4776 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
4778 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "asdfasdf, asdfadf" &&
4781 echo "replace OST nid"
4782 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
4783 error "replace nids failed"
4785 echo "command should accept two parameters"
4786 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
4787 error "command should accept two params"
4789 echo "wrong nids list should not destroy the system"
4790 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
4793 local FAKE_NIDS="192.168.0.112@tcp1,192.168.0.112@tcp2"
4794 local FAKE_FAILOVER="192.168.0.113@tcp1,192.168.0.113@tcp2"
4795 local NIDS_AND_FAILOVER="$MDS_NID,$FAKE_NIDS:$FAKE_FAILOVER"
4796 echo "set NIDs with failover"
4797 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $NIDS_AND_FAILOVER ||
4798 error "replace nids failed"
4801 echo "replace MDS nid"
4802 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
4803 error "replace nids failed"
4805 if ! combined_mgs_mds ; then
4808 stop_mds || error "Unable to stop MDS"
4811 start_mgsmds || error "start mgsmds failed"
4812 set_conf_param_and_check mds \
4813 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4814 "$FSNAME-OST0000.osc.active" \
4816 start_ost || error "unable to start OST"
4817 mount_client $MOUNT || error "mount client failed"
4819 check_mount || error "error after nid replace"
4820 cleanup || error "cleanup failed"
4823 run_test 66 "replace nids"
4825 test_67() { #LU-2950
4826 local legacy="$TMP/legacy_lnet_config"
4827 local new="$TMP/new_routes_test"
4828 local out="$TMP/config_out_file"
4829 local verify="$TMP/conv_verify"
4830 local verify_conf="$TMP/conf_verify"
4832 # Create the legacy file that will be run through the
4833 # lustre_routes_conversion script
4834 cat <<- LEGACY_LNET_CONFIG > $legacy
4835 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
4836 tcp2 54 10.1.3.2@tcp;
4837 tcp3 10.3.4.3@tcp:3;
4841 # Create the verification file to verify the output of
4842 # lustre_routes_conversion script against.
4843 cat <<- VERIFY_LNET_CONFIG > $verify
4844 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
4845 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
4846 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
4847 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
4848 tcp4: { gateway: 10.3.3.4@tcp }
4851 # Create the verification file to verify the output of
4852 # lustre_routes_config script against
4853 cat <<- VERIFY_LNET_CONFIG > $verify_conf
4854 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
4855 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
4856 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
4857 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
4858 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
4861 $LUSTRE_ROUTES_CONVERSION $legacy $new > /dev/null
4862 if [ -f $new ]; then
4863 # verify the conversion output
4864 cmp -s $new $verify > /dev/null
4865 if [ $? -eq 1 ]; then
4866 error "routes conversion failed"
4869 lustre_routes_config --dry-run --verbose $new > $out
4870 # check that the script succeeded
4871 cmp -s $out $verify_conf > /dev/null
4872 if [ $? -eq 1 ]; then
4873 error "routes config failed"
4876 error "routes conversion test failed"
4878 # remove generated files
4879 rm -f $new $legacy $verify $verify_conf $out
4881 run_test 67 "test routes conversion and configuration"
4889 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.53) ] ||
4890 { skip "Need MDS version at least 2.4.53"; return 0; }
4892 umount_client $MOUNT || error "umount client failed"
4894 if ! combined_mgs_mds; then
4895 start_mgs || error "start mgs failed"
4898 start_mdt 1 || error "MDT start failed"
4899 start_ost || error "Unable to start OST1"
4901 # START-END - the sequences we'll be reserving
4902 START=$(do_facet $SINGLEMDS \
4903 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4904 END=$((START + (1 << 30)))
4905 do_facet $SINGLEMDS \
4906 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4908 # reset the sequences MDT0000 has already assigned
4909 do_facet $SINGLEMDS \
4910 $LCTL set_param seq.srv*MDT0000.space=clear
4912 # remount to let the client allocate new sequence
4913 mount_client $MOUNT || error "mount client failed"
4915 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4916 do_facet $SINGLEMDS \
4917 $LCTL get_param seq.srv*MDT0000.space
4918 $LFS path2fid $DIR/$tfile
4920 local old_ifs="$IFS"
4922 fid=($($LFS path2fid $DIR/$tfile))
4926 if [[ $seq < $END ]]; then
4927 error "used reserved sequence $seq?"
4929 cleanup || error "cleanup failed with $?"
4931 run_test 68 "be able to reserve specific sequences in FLDB"
4933 # Test 69: is about the total number of objects ever created on an OST.
4934 # so that when it is reformatted the normal MDS->OST orphan recovery won't
4935 # just "precreate" the missing objects. In the past it might try to recreate
4936 # millions of objects after an OST was reformatted
4938 local server_version=$(lustre_version_code $SINGLEMDS)
4940 [[ $server_version -lt $(version_code 2.4.2) ]] &&
4941 skip "Need MDS version at least 2.4.2" && return
4943 [[ $server_version -ge $(version_code 2.4.50) ]] &&
4944 [[ $server_version -lt $(version_code 2.5.0) ]] &&
4945 skip "Need MDS version at least 2.5.0" && return
4948 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4950 # use OST0000 since it probably has the most creations
4951 local OSTNAME=$(ostname_from_index 0)
4952 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4953 local last_id=$(do_facet mds1 $LCTL get_param -n \
4954 osc.$mdtosc_proc1.prealloc_last_id)
4956 # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
4957 # verify that the LAST_ID recovery is working properly. If
4958 # not, then the OST will refuse to allow the MDS connect
4959 # because the LAST_ID value is too different from the MDS
4960 #define OST_MAX_PRECREATE=20000
4961 local ost_max_pre=20000
4962 local num_create=$(( ost_max_pre * 5 + 1 - last_id))
4964 # If the LAST_ID is already over 5 * OST_MAX_PRECREATE, we don't
4965 # need to create any files. So, skip this section.
4966 if [ $num_create -gt 0 ]; then
4967 # Check the number of inodes available on OST0
4969 local ifree=$($LFS df -i $MOUNT | awk '/OST0000/ { print $4 }')
4970 log "On OST0, $ifree inodes available. Want $num_create."
4972 $LFS setstripe -i 0 $DIR/$tdir ||
4973 error "$LFS setstripe -i 0 $DIR/$tdir failed"
4974 if [ $ifree -lt 10000 ]; then
4975 files=$(( ifree - 50 ))
4980 local j=$((num_create / files + 1))
4981 for i in $(seq 1 $j); do
4982 createmany -o $DIR/$tdir/$tfile-$i- $files ||
4983 error "createmany fail create $files files: $?"
4984 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
4985 error "unlinkmany failed unlink $files files"
4989 # delete all of the files with objects on OST0 so the
4990 # filesystem is not inconsistent later on
4991 $LFS find $MOUNT --ost 0 -print0 | xargs -0 rm
4993 umount_client $MOUNT || error "umount client failed"
4994 stop_ost || error "OST0 stop failure"
4995 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
4996 $(ostdevname 1) $(ostvdevname 1) ||
4997 error "reformat and replace $ostdev failed"
4998 start_ost || error "OST0 restart failure"
4999 wait_osc_import_state mds ost FULL
5001 mount_client $MOUNT || error "mount client failed"
5002 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
5003 local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
5004 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
5006 local iused=$($LFS df -i $MOUNT | awk '/OST0000/ { print $3 }')
5007 log "On OST0, $iused used inodes"
5008 [ $iused -ge $((ost_max_pre/2 + 1000)) ] &&
5009 error "OST replacement created too many inodes; $iused"
5010 cleanup || error "cleanup failed with $?"
5012 run_test 69 "replace an OST with the same index"
5015 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5018 cleanup || error "cleanup failed with $?"
5020 start_mdt 1 || error "MDT0 start fail"
5022 start_ost || error "OST0 start fail"
5023 for num in $(seq 2 $MDSCOUNT); do
5024 start_mdt $num || return
5027 mount_client $MOUNT || error "mount client fails"
5029 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5031 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5032 error "create remote dir fail"
5034 rm -rf $DIR/$tdir || error "delete dir fail"
5035 cleanup || error "cleanup failed with $?"
5037 run_test 70a "start MDT0, then OST, then MDT1"
5040 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5043 start_ost || error "OST0 start fail"
5045 start_mds || error "MDS start fail"
5047 mount_client $MOUNT || error "mount client fails"
5049 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5051 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5052 error "create remote dir fail"
5054 rm -rf $DIR/$tdir || error "delete dir fail"
5056 cleanup || error "cleanup failed with $?"
5058 run_test 70b "start OST, MDT1, MDT0"
5061 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5064 start_mds || error "MDS start fail"
5065 start_ost || error "OST0 start fail"
5067 mount_client $MOUNT || error "mount client fails"
5068 stop_mdt 1 || error "MDT1 start fail"
5070 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
5071 echo "deactivate $mdc_for_mdt1"
5072 $LCTL --device $mdc_for_mdt1 deactivate ||
5073 error "set $mdc_for_mdt1 deactivate failed"
5075 mkdir $DIR/$tdir && error "mkdir succeed"
5077 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5078 error "create remote dir succeed"
5080 cleanup || error "cleanup failed with $?"
5082 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
5085 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5088 start_mds || error "MDS start fail"
5089 start_ost || error "OST0 start fail"
5091 mount_client $MOUNT || error "mount client fails"
5093 stop_mdt 2 || error "MDT1 start fail"
5095 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
5097 echo "deactivate $mdc_for_mdt2"
5098 $LCTL --device $mdc_for_mdt2 deactivate ||
5099 error "set $mdc_for_mdt2 deactivate failed"
5101 mkdir $DIR/$tdir || error "mkdir fail"
5102 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5103 error "create remote dir succeed"
5105 rm -rf $DIR/$tdir || error "delete dir fail"
5107 cleanup || error "cleanup failed with $?"
5109 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
5112 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5114 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.62) ] ||
5115 { skip "Need MDS version at least 2.7.62"; return 0; }
5117 cleanup || error "cleanup failed with $?"
5119 local mdsdev=$(mdsdevname 1)
5120 local ostdev=$(ostdevname 1)
5121 local mdsvdev=$(mdsvdevname 1)
5122 local ostvdev=$(ostvdevname 1)
5123 local opts_mds="$(mkfs_opts mds1 $mdsdev) --reformat $mdsdev $mdsvdev"
5124 local opts_ost="$(mkfs_opts ost1 $ostdev) --reformat $ostdev $ostvdev"
5126 add mds1 $opts_mds || error "add mds1 failed"
5127 start_mdt 1 || error "start mdt1 failed"
5128 add ost1 $opts_ost || error "add ost1 failed"
5129 start_ost || error "start ost failed"
5130 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
5132 local soc=$(do_facet mds1 "$LCTL get_param -n \
5133 mdt.*MDT0000.sync_lock_cancel")
5134 [ $soc == "never" ] || error "SoC enabled on single MDS"
5136 for i in $(seq 2 $MDSCOUNT); do
5137 mdsdev=$(mdsdevname $i)
5138 mdsvdev=$(mdsvdevname $i)
5139 opts_mds="$(mkfs_opts mds$i $mdsdev) --reformat $mdsdev \
5141 add mds$i $opts_mds || error "add mds$i failed"
5142 start_mdt $i || error "start mdt$i fail"
5145 wait_dne_interconnect
5147 for i in $(seq $MDSCOUNT); do
5148 soc=$(do_facet mds$i "$LCTL get_param -n \
5149 mdt.*MDT000$((i - 1)).sync_lock_cancel")
5150 [ $soc == "blocking" ] || error "SoC not enabled on DNE"
5153 for i in $(seq 2 $MDSCOUNT); do
5154 stop_mdt $i || error "stop mdt$i fail"
5156 soc=$(do_facet mds1 "$LCTL get_param -n \
5157 mdt.*MDT0000.sync_lock_cancel")
5158 [ $soc == "never" ] || error "SoC enabled on single MDS"
5159 umount_client $MOUNT -f > /dev/null
5161 cleanup || error "cleanup failed with $?"
5163 run_test 70e "Sync-on-Cancel will be enabled by default on DNE"
5166 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5167 if combined_mgs_mds; then
5168 skip "needs separate MGS/MDT" && return
5172 start_mdt 1 || error "MDT0 start fail"
5173 start_ost || error "OST0 start fail"
5174 for num in $(seq 2 $MDSCOUNT); do
5175 start_mdt $num || return
5178 start_ost2 || error "OST1 start fail"
5180 mount_client $MOUNT || error "mount client fails"
5182 mkdir $DIR/$tdir || error "mkdir fail"
5183 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5184 error "create remote dir succeed"
5186 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5187 rm -rf $DIR/$tdir || error "delete dir fail"
5189 umount_client $MOUNT || error "umount_client failed"
5190 stop_mds || error "MDS stop fail"
5191 stop_ost || error "OST0 stop fail"
5192 stop_ost2 || error "OST1 stop fail"
5194 run_test 71a "start MDT0 OST0, MDT1, OST1"
5197 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5198 if combined_mgs_mds; then
5199 skip "needs separate MGS/MDT" && return
5203 for num in $(seq 2 $MDSCOUNT); do
5204 start_mdt $num || return
5206 start_ost || error "OST0 start fail"
5207 start_mdt 1 || error "MDT0 start fail"
5208 start_ost2 || error "OST1 start fail"
5210 mount_client $MOUNT || error "mount client fails"
5212 mkdir $DIR/$tdir || error "mkdir fail"
5213 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5214 error "create remote dir succeed"
5216 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5217 rm -rf $DIR/$tdir || error "delete dir fail"
5219 umount_client $MOUNT || error "umount_client failed"
5220 stop_mds || error "MDT0 stop fail"
5221 stop_ost || error "OST0 stop fail"
5222 stop_ost2 || error "OST1 stop fail"
5224 run_test 71b "start MDT1, OST0, MDT0, OST1"
5227 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5228 if combined_mgs_mds; then
5229 skip "needs separate MGS/MDT" && return
5233 start_ost || error "OST0 start fail"
5234 start_ost2 || error "OST1 start fail"
5235 for num in $(seq 2 $MDSCOUNT); do
5236 start_mdt $num || return
5238 start_mdt 1 || error "MDT0 start fail"
5240 mount_client $MOUNT || error "mount client fails"
5242 mkdir $DIR/$tdir || error "mkdir fail"
5243 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5244 error "create remote dir succeed"
5246 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5247 rm -rf $DIR/$tdir || error "delete dir fail"
5249 umount_client $MOUNT || error "umount_client failed"
5250 stop_mds || error "MDS stop fail"
5251 stop_ost || error "OST0 stop fail"
5252 stop_ost2 || error "OST1 stop fail"
5255 run_test 71c "start OST0, OST1, MDT1, MDT0"
5258 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5259 if combined_mgs_mds; then
5260 skip "needs separate MGS/MDT" && return
5264 start_ost || error "OST0 start fail"
5265 for num in $(seq 2 $MDSCOUNT); do
5266 start_mdt $num || return
5268 start_mdt 1 || error "MDT0 start fail"
5269 start_ost2 || error "OST1 start fail"
5271 mount_client $MOUNT || error "mount client fails"
5273 mkdir $DIR/$tdir || error "mkdir fail"
5274 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5275 error "create remote dir succeed"
5277 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5278 rm -rf $DIR/$tdir || error "delete dir fail"
5280 umount_client $MOUNT || error "umount_client failed"
5281 stop_mds || error "MDS stop fail"
5282 stop_ost || error "OST0 stop fail"
5283 stop_ost2 || error "OST1 stop fail"
5286 run_test 71d "start OST0, MDT1, MDT0, OST1"
5289 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5290 if combined_mgs_mds; then
5291 skip "needs separate MGS/MDT" && return
5295 start_ost || error "OST0 start fail"
5296 for num in $(seq 2 $MDSCOUNT); do
5297 start_mdt $num || return
5299 start_ost2 || error "OST1 start fail"
5300 start_mdt 1 || error "MDT0 start fail"
5302 mount_client $MOUNT || error "mount client fails"
5304 mkdir $DIR/$tdir || error "mkdir fail"
5305 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5306 error "create remote dir succeed"
5308 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5309 rm -rf $DIR/$tdir || error "delete dir fail"
5311 umount_client $MOUNT || error "umount_client failed"
5312 stop_mds || error "MDS stop fail"
5313 stop_ost || error "OST0 stop fail"
5314 stop_ost2 || error "OST1 stop fail"
5317 run_test 71e "start OST0, MDT1, OST1, MDT0"
5319 test_72() { #LU-2634
5320 local mdsdev=$(mdsdevname 1)
5321 local ostdev=$(ostdevname 1)
5322 local cmd="$E2FSCK -fnvd $mdsdev"
5326 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
5327 skip "ldiskfs only test" && return
5329 if combined_mgs_mds; then
5330 add_options='--reformat'
5332 add_options='--reformat --replace'
5335 #tune MDT with "-O extents"
5337 for num in $(seq $MDSCOUNT); do
5338 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
5339 $add_options $(mdsdevname $num) $(mdsvdevname $num) ||
5340 error "add mds $num failed"
5341 do_facet mds${num} "$TUNE2FS -O extents $(mdsdevname $num)" ||
5342 error "$TUNE2FS failed on mds${num}"
5345 add ost1 $(mkfs_opts ost1 $ostdev) $add_options $ostdev ||
5346 error "add $ostdev failed"
5347 start_mds || error "start mds failed"
5348 start_ost || error "start ost failed"
5349 mount_client $MOUNT || error "mount client failed"
5351 #create some short symlinks
5352 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5353 createmany -o $DIR/$tdir/$tfile-%d $fn
5354 echo "create $fn short symlinks"
5355 for i in $(seq -w 1 $fn); do
5356 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
5361 umount_client $MOUNT || error "umount client failed"
5362 stop_mds || error "stop mds failed"
5363 stop_ost || error "stop ost failed"
5366 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
5368 run_test 72 "test fast symlink with extents flag enabled"
5370 test_73() { #LU-3006
5371 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
5372 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
5373 error "1st tunefs failed"
5374 start_mgsmds || error "start mds failed"
5375 start_ost || error "start ost failed"
5376 mount_client $MOUNT || error "mount client failed"
5377 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
5378 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
5379 umount_client $MOUNT || error "umount client failed"
5383 run_test 73 "failnode to update from mountdata properly"
5385 test_75() { # LU-2374
5386 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
5387 skip "Need MDS version at least 2.4.1" && return
5390 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
5391 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
5392 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
5393 --reformat $(ostdevname 1) $(ostvdevname 1)"
5395 #check with default parameters
5396 add mds1 $opts_mds || error "add mds1 failed for default params"
5397 add ost1 $opts_ost || error "add ost1 failed for default params"
5399 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
5400 opts_mds=$(echo $opts_mds |
5401 sed -e "s/--index=$index/--index=$index --mdt/")
5402 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
5403 opts_ost=$(echo $opts_ost |
5404 sed -e "s/--index=$index/--index=$index --ost/")
5406 add mds1 $opts_mds || error "add mds1 failed for new params"
5407 add ost1 $opts_ost || error "add ost1 failed for new params"
5408 if ! combined_mgs_mds; then
5409 stop_mgs || error "stop mgs failed"
5414 run_test 75 "The order of --index should be irrelevant"
5417 [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] ||
5418 { skip "Need MDS version at least 2.4.52" && return 0; }
5420 if ! combined_mgs_mds; then
5421 start_mgs || error "start mgs failed"
5424 local MDMB_PARAM="osc.*.max_dirty_mb"
5425 echo "Change MGS params"
5426 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
5428 echo "max_dirty_mb: $MAX_DIRTY_MB"
5429 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB - 10))
5430 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
5431 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
5432 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5433 head -1" $NEW_MAX_DIRTY_MB
5434 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5435 echo "$MAX_DIRTY_MB"
5436 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5437 error "error while apply max_dirty_mb"
5439 echo "Check the value is stored after remount"
5442 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5443 head -1" $NEW_MAX_DIRTY_MB
5444 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5445 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5446 error "max_dirty_mb is not saved after remount"
5448 echo "Change OST params"
5449 CLIENT_PARAM="obdfilter.*.client_cache_count"
5450 local CLIENT_CACHE_COUNT
5451 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5453 echo "client_cache_count: $CLIENT_CACHE_COUNT"
5454 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
5455 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
5456 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
5457 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5458 head -1" $NEW_CLIENT_CACHE_COUNT
5459 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5461 echo "$CLIENT_CACHE_COUNT"
5462 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5463 error "error while apply client_cache_count"
5465 echo "Check the value is stored after remount"
5468 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5469 head -1" $NEW_CLIENT_CACHE_COUNT
5470 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5472 echo "$CLIENT_CACHE_COUNT"
5473 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5474 error "client_cache_count is not saved after remount"
5477 run_test 76a "set permanent params with lctl across mounts"
5479 test_76b() { # LU-4783
5480 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.57) ]] ||
5481 { skip "Need MGS version at least 2.5.57" && return 0; }
5484 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
5485 error "start params log failed"
5488 run_test 76b "verify params log setup correctly"
5491 [[ $(lustre_version_code mgs) -ge $(version_code 2.8.54) ]] ||
5492 { skip "Need MDS version at least 2.4.52" && return 0; }
5494 local MASK_PARAM="mdd.*.changelog_mask"
5495 echo "Change changelog_mask"
5496 do_facet mgs $LCTL set_param -P $MASK_PARAM=-CLOSE ||
5497 error "Can't change changlog_mask"
5498 wait_update $(facet_host mds) "$LCTL get_param -n $MASK_PARAM |
5501 echo "Check the value is stored after mds remount"
5502 stop_mds || error "Failed to stop MDS"
5503 start_mds || error "Failed to start MDS"
5504 local CHANGELOG_MASK=$(do_facet mgs $LCTL get_param -n $MASK_PARAM)
5505 echo $CHANGELOG_MASK | grep CLOSE > /dev/null &&
5506 error "changelog_mask is not changed"
5510 run_test 76c "verify changelog_mask is applied with lctl set_param -P"
5512 test_76d() { #LU-9399
5515 local xattr_cache="llite.*.xattr_cache"
5516 local cmd="$LCTL get_param -n $xattr_cache | head -1"
5517 local new=$((($(eval $cmd) + 1) % 2))
5519 echo "lctl set_param -P llite.*.xattr_cache=$new"
5520 do_facet mgs $LCTL set_param -P $xattr_cache=$new ||
5521 error "Can't change xattr_cache"
5522 wait_update $HOSTNAME "$cmd" "$new"
5524 echo "Check $xattr_cache on client $MOUNT"
5525 umount_client $MOUNT || error "umount $MOUNT failed"
5526 mount_client $MOUNT || error "mount $MOUNT failed"
5527 [ $(eval $cmd) -eq $new ] ||
5528 error "$xattr_cache != $new on client $MOUNT"
5530 echo "Check $xattr_cache on the new client $MOUNT2"
5531 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
5532 [ $(eval $cmd) -eq $new ] ||
5533 error "$xattr_cache != $new on client $MOUNT2"
5534 umount_client $MOUNT2 || error "umount $MOUNT2 failed"
5538 run_test 76d "verify llite.*.xattr_cache can be set by 'lctl set_param -P' correctly"
5540 test_77() { # LU-3445
5541 local server_version=$(lustre_version_code $SINGLEMDS)
5542 [[ $server_version -ge $(version_code 2.8.55) ]] ||
5543 { skip "Need MDS version 2.8.55+ "; return; }
5545 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
5546 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
5547 skip_env "mixed loopback and real device not working" && return
5550 local fs2mdsdev=$(mdsdevname 1_2)
5551 local fs2ostdev=$(ostdevname 1_2)
5552 local fs2mdsvdev=$(mdsvdevname 1_2)
5553 local fs2ostvdev=$(ostvdevname 1_2)
5554 local fsname=test1234
5556 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
5558 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
5560 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
5561 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
5562 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
5563 error "start fs2mds failed"
5565 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
5566 mgsnid="0.0.0.0@tcp,$mgsnid,$mgsnid:$mgsnid"
5568 add fs2ost --mgsnode=$mgsnid $(mkfs_opts ost1 $fs2ostdev) \
5569 --failnode=$failnid --fsname=$fsname \
5570 --reformat $fs2ostdev $fs2ostvdev ||
5571 error "add fs2ost failed"
5572 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
5574 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
5575 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
5576 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
5579 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
5582 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ||
5583 $(facet_fstype ost1) != ldiskfs ]] &&
5584 skip "ldiskfs only test" && return
5586 # reformat the Lustre filesystem with a smaller size
5587 local saved_MDSCOUNT=$MDSCOUNT
5588 local saved_MDSSIZE=$MDSSIZE
5589 local saved_OSTCOUNT=$OSTCOUNT
5590 local saved_OSTSIZE=$OSTSIZE
5593 MDSSIZE=$((MDSSIZE - 20000))
5594 OSTSIZE=$((OSTSIZE - 20000))
5595 reformat || error "(1) reformat Lustre filesystem failed"
5596 MDSSIZE=$saved_MDSSIZE
5597 OSTSIZE=$saved_OSTSIZE
5599 # mount the Lustre filesystem
5600 setup_noconfig || error "(2) setup Lustre filesystem failed"
5603 log "create test files"
5608 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
5610 for i in $(seq $num_files); do
5611 file=$MOUNT/$tdir/$tfile-$i
5612 dd if=/dev/urandom of=$file count=1 bs=1M || {
5613 $LCTL get_param osc.*.cur*grant*
5614 $LFS df; $LFS df -i;
5615 # stop creating files if there is no more space
5616 if [ ! -e $file ]; then
5617 num_files=$((i - 1))
5621 $LFS getstripe -v $file
5622 local ost_idx=$(LFS getstripe -i $file)
5623 do_facet ost$((ost_idx + 1)) \
5624 $LCTL get_param obdfilter.*.*grant*
5625 error "(4) create $file failed"
5629 # unmount the Lustre filesystem
5630 cleanup || error "(5) cleanup Lustre filesystem failed"
5632 # run e2fsck on the MDT and OST devices
5633 local mds_host=$(facet_active_host $SINGLEMDS)
5634 local ost_host=$(facet_active_host ost1)
5635 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
5636 local ost_dev=$(ostdevname 1)
5638 run_e2fsck $mds_host $mds_dev "-y"
5639 run_e2fsck $ost_host $ost_dev "-y"
5641 # get the original block count of the MDT and OST filesystems
5642 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
5643 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
5645 # expand the MDT and OST filesystems to the device size
5646 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
5647 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
5649 # run e2fsck on the MDT and OST devices again
5650 run_e2fsck $mds_host $mds_dev "-y"
5651 run_e2fsck $ost_host $ost_dev "-y"
5653 # mount the Lustre filesystem
5657 log "check files after expanding the MDT and OST filesystems"
5658 for i in $(seq $num_files); do
5659 file=$MOUNT/$tdir/$tfile-$i
5660 $CHECKSTAT -t file -s 1048576 $file ||
5661 error "(6) checkstat $file failed"
5665 log "create more files after expanding the MDT and OST filesystems"
5666 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
5667 file=$MOUNT/$tdir/$tfile-$i
5668 dd if=/dev/urandom of=$file count=1 bs=1M ||
5669 error "(7) create $file failed"
5672 # unmount the Lustre filesystem
5673 cleanup || error "(8) cleanup Lustre filesystem failed"
5675 # run e2fsck on the MDT and OST devices
5676 run_e2fsck $mds_host $mds_dev "-y"
5677 run_e2fsck $ost_host $ost_dev "-y"
5679 # get the maximum block count of the MDT and OST filesystems
5680 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
5681 local ost_max_blks=$(get_block_count ost1 $ost_dev)
5683 # get the minimum block count of the MDT and OST filesystems
5684 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
5685 grep minimum | sed -e 's/^.*filesystem: //g')
5686 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
5687 grep minimum | sed -e 's/^.*filesystem: //g')
5689 # shrink the MDT and OST filesystems to a smaller size
5693 if [[ $mds_max_blks -gt $mds_min_blks &&
5694 $mds_max_blks -gt $mds_orig_blks ]]; then
5695 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
5696 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
5697 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
5698 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
5699 error "shrink $SINGLEMDS to $new_blks failed"
5703 if [[ $ost_max_blks -gt $ost_min_blks &&
5704 $ost_max_blks -gt $ost_orig_blks ]]; then
5705 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
5706 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
5707 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
5708 run_resize2fs ost1 $ost_dev $new_blks ||
5709 error "shrink ost1 to $new_blks failed"
5713 # check whether the MDT or OST filesystem was shrunk or not
5715 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
5716 reformat || error "(10) reformat Lustre filesystem failed"
5720 # run e2fsck on the MDT and OST devices again
5721 run_e2fsck $mds_host $mds_dev "-y"
5722 run_e2fsck $ost_host $ost_dev "-y"
5724 # mount the Lustre filesystem again
5728 log "check files after shrinking the MDT and OST filesystems"
5729 for i in $(seq $((num_files + 10))); do
5730 file=$MOUNT/$tdir/$tfile-$i
5731 $CHECKSTAT -t file -s 1048576 $file ||
5732 error "(11) checkstat $file failed"
5735 # unmount and reformat the Lustre filesystem
5736 cleanup || error "(12) cleanup Lustre filesystem failed"
5737 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
5739 MDSCOUNT=$saved_MDSCOUNT
5740 OSTCOUNT=$saved_OSTCOUNT
5741 reformat || error "(14) reformat Lustre filesystem failed"
5743 run_test 78 "run resize2fs on MDT and OST filesystems"
5745 test_79() { # LU-4227
5746 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.59) ]] ||
5747 { skip "Need MDS version at least 2.5.59"; return 0; }
5749 local mdsdev1=$(mdsdevname 1)
5750 local mdsvdev1=$(mdsvdevname 1)
5751 local mdsdev2=$(mdsdevname 2)
5752 local mdsvdev2=$(mdsvdevname 2)
5753 local ostdev1=$(ostdevname 1)
5754 local ostvdev1=$(ostvdevname 1)
5755 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
5756 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
5757 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
5760 # remove --mgs/--mgsnode from mkfs.lustre options
5761 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
5763 mgsnode_opt=$(echo $opts_mds2 |
5764 awk '{ for ( i = 1; i < NF; i++ )
5765 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5766 [ -n $mgsnode_opt ] &&
5767 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
5769 mgsnode_opt=$(echo $opts_ost1 |
5770 awk '{ for ( i = 1; i < NF; i++ )
5771 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5772 [ -n $mgsnode_opt ] &&
5773 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
5775 # -MGS, format a mdt without --mgs option
5776 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
5777 error "Must specify --mgs when formatting mdt combined with mgs"
5779 # +MGS, format a mdt/ost without --mgsnode option
5780 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
5781 > /dev/null || error "start mds1 failed"
5782 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
5783 error "Must specify --mgsnode when formatting a mdt"
5784 add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
5785 error "Must specify --mgsnode when formatting an ost"
5789 run_test 79 "format MDT/OST without mgs option (should return errors)"
5792 start_mds || error "Failed to start MDT"
5793 start_ost || error "Failed to start OST1"
5794 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
5795 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
5796 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
5797 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
5798 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
5800 start_ost2 || error "Failed to start OST2"
5802 do_facet ost1 "$LCTL set_param fail_loc=0"
5805 run_test 80 "mgc import reconnect race"
5807 #Save the original values of $OSTCOUNT and $OSTINDEX$i.
5809 local new_ostcount=$1
5810 saved_ostcount=$OSTCOUNT
5811 OSTCOUNT=$new_ostcount
5815 for i in $(seq $OSTCOUNT); do
5817 eval saved_ostindex$i=${!index}
5822 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
5823 restore_ostindex() {
5828 for i in $(seq $OSTCOUNT); do
5829 index=saved_ostindex$i
5830 eval OSTINDEX$i=${!index}
5832 OSTCOUNT=$saved_ostcount
5837 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
5838 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
5839 # assigned index and ensures we can mount such a formatted file system
5840 test_81() { # LU-4665
5841 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5842 { skip "Need MDS version at least 2.6.54" && return; }
5843 [[ $OSTCOUNT -ge 3 ]] || { skip_env "needs >= 3 OSTs" && return; }
5847 # Each time RANDOM is referenced, a random integer between 0 and 32767
5850 local saved_ostindex1=$OSTINDEX1
5851 for i in 65535 $((RANDOM + 65536)); do
5852 echo -e "\nFormat ost1 with --index=$i, should fail"
5854 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
5855 $(ostdevname 1) $(ostvdevname 1); then
5856 OSTINDEX1=$saved_ostindex1
5857 error "format ost1 with --index=$i should fail"
5860 OSTINDEX1=$saved_ostindex1
5864 # Format OSTs with random sparse indices.
5865 trap "restore_ostindex" EXIT
5866 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices"
5867 OST_INDEX_LIST=[0,$((RANDOM * 2 % 65533 + 1)),65534] formatall
5869 # Setup and check Lustre filesystem.
5870 start_mgsmds || error "start_mgsmds failed"
5871 for i in $(seq $OSTCOUNT); do
5872 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5873 error "start ost$i failed"
5876 mount_client $MOUNT || error "mount client $MOUNT failed"
5877 check_mount || error "check client $MOUNT failed"
5880 local max_easize=$($LCTL get_param -n llite.*.max_easize)
5881 [[ $max_easize -eq 128 ]] ||
5882 error "max_easize is $max_easize, should be 128 bytes"
5886 run_test 81 "sparse OST indexing"
5888 # Here we exercise the stripe placement functionality on a file system that
5889 # has formatted the OST with a random index. With the file system the following
5890 # functionality is tested:
5892 # 1. Creating a new file with a specific stripe layout.
5894 # 2. Modifiy a existing empty file with a specific stripe layout.
5896 # 3. Ensure we fail to set the stripe layout of a file that already has one.
5898 # 4. If ost-index is defined we need to ensure it is the first entry in the
5899 # ost index list returned by lfs getstripe.
5901 # 5. Lastly ensure this functionality fails with directories.
5902 test_82a() { # LU-4665
5903 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5904 { skip "Need MDS version at least 2.6.54" && return; }
5905 [[ $OSTCOUNT -ge 3 ]] || { skip_env "needs >= 3 OSTs" && return; }
5911 # Format OSTs with random sparse indices.
5915 local LOV_V1_INSANE_STRIPE_COUNT=65532
5916 for i in $(seq $OSTCOUNT); do
5917 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
5918 ost_indices+=" $index"
5920 ost_indices=$(comma_list $ost_indices)
5922 stack_trap "restore_ostindex" EXIT
5923 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5924 OST_INDEX_LIST=[$ost_indices] formatall
5926 # Setup Lustre filesystem.
5927 start_mgsmds || error "start_mgsmds failed"
5928 for i in $(seq $OSTCOUNT); do
5929 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5930 error "start ost$i failed"
5933 # Collect debug information - start of test
5934 do_nodes $(comma_list $(mdts_nodes)) \
5935 $LCTL get_param osc.*.prealloc_*_id
5937 mount_client $MOUNT || error "mount client $MOUNT failed"
5940 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
5941 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5943 stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
5944 $LCTL get_param osc.*.prealloc_*_id" EXIT
5946 # 1. If the file does not exist, new file will be created
5947 # with specified OSTs.
5948 local file=$DIR/$tdir/$tfile-1
5949 local cmd="$LFS setstripe -o $ost_indices $file"
5951 eval $cmd || error "$cmd failed"
5952 check_stripe_count $file $OSTCOUNT
5953 check_obdidx $file $ost_indices
5954 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5955 error "write $file failed"
5957 # 2. If the file already exists and is an empty file, the file
5958 # will be attached with specified layout.
5959 file=$DIR/$tdir/$tfile-2
5960 mcreate $file || error "mcreate $file failed"
5961 cmd="$LFS setstripe -o $ost_indices $file"
5963 eval $cmd || error "$cmd failed"
5964 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5965 error "write $file failed"
5966 check_stripe_count $file $OSTCOUNT
5967 check_obdidx $file $ost_indices
5969 # 3. If the file already has a valid layout attached, the command
5970 # should fail with EBUSY.
5972 eval $cmd && error "stripe is already set on $file, $cmd should fail"
5974 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
5975 # be in the OST indices list.
5976 local start_ost_idx=${ost_indices##*,}
5977 file=$DIR/$tdir/$tfile-3
5978 cmd="$LFS setstripe -o $ost_indices -i $start_ost_idx $file"
5980 eval $cmd || error "$cmd failed"
5981 check_stripe_count $file $OSTCOUNT
5982 check_obdidx $file $ost_indices
5983 check_start_ost_idx $file $start_ost_idx
5985 file=$DIR/$tdir/$tfile-4
5986 cmd="$LFS setstripe"
5987 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
5988 cmd+=" -i $start_ost_idx $file"
5990 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
5992 # 5. Specifying OST indices for directory should succeed.
5993 local dir=$DIR/$tdir/$tdir
5994 mkdir $dir || error "mkdir $dir failed"
5995 cmd="$LFS setstripe -o $ost_indices $dir"
5996 if [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.11.53) &&
5997 $(lustre_version_code client -gt $(version_code 2.11.53)) ]]; then
5999 eval $cmd || error "unable to specify OST indices on directory"
6001 echo "need MDS+client version at least 2.11.53"
6006 run_test 82a "specify OSTs for file (succeed) or directory (succeed)"
6011 # Remove OSTs from a pool and destroy the pool.
6012 destroy_pool $ost_pool || true
6014 if ! combined_mgs_mds ; then
6020 # Test 82b is run to ensure that if the user supplies a pool with a specific
6021 # stripe layout that it behaves proprerly. It should fail in the case that
6022 # the supplied OST index list points to OSTs not contained in the user
6024 test_82b() { # LU-4665
6025 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
6026 { skip "Need MDS version at least 2.6.54" && return; }
6027 [[ $OSTCOUNT -ge 4 ]] || { skip_env "needs >= 4 OSTs" && return; }
6033 # Format OSTs with random sparse indices.
6037 local LOV_V1_INSANE_STRIPE_COUNT=65532
6038 for i in $(seq $OSTCOUNT); do
6039 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
6040 ost_indices+=" $index"
6042 ost_indices=$(comma_list $ost_indices)
6044 trap "restore_ostindex" EXIT
6045 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
6046 OST_INDEX_LIST=[$ost_indices] formatall
6048 # Setup Lustre filesystem.
6049 start_mgsmds || error "start_mgsmds failed"
6050 for i in $(seq $OSTCOUNT); do
6051 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
6052 error "start ost$i failed"
6055 mount_client $MOUNT || error "mount client $MOUNT failed"
6056 if ! combined_mgs_mds ; then
6061 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
6062 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6064 # Create a new pool and add OSTs into it.
6065 local ost_pool=$FSNAME.$TESTNAME
6066 create_pool $ost_pool || error "create OST pool $ost_pool failed"
6069 trap "cleanup_82b" EXIT
6071 local ost_idx_in_list=${ost_indices##*,}
6072 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
6075 local ost_targets="$FSNAME-OST["
6076 for i in ${ost_idx_in_pool//,/ }; do
6077 ost_targets=$ost_targets$(printf "%04x," $i)
6079 ost_targets="${ost_targets%,}]"
6081 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
6082 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
6083 sort -u | tr '\n' ' ')
6085 local cmd="$LCTL pool_add $ost_pool $ost_targets"
6086 do_facet mgs $cmd || error "$cmd failed"
6087 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
6088 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
6089 error "wait_update $ost_pool failed"
6090 wait_update_facet $SINGLEMDS "$LCTL pool_list $ost_pool | wc -l" 4 ||
6091 error "wait_update pool_list $ost_pool failed"
6093 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
6094 # then the OSTs must be the members of the pool.
6095 local file=$DIR/$tdir/$tfile
6096 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6098 eval $cmd && error "OST with index $ost_idx_in_list should be" \
6099 "in OST pool $ost_pool"
6101 # Only select OST $ost_idx_in_list from $ost_pool for file.
6102 ost_idx_in_list=${ost_idx_in_pool#*,}
6103 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6105 eval $cmd || error "$cmd failed"
6106 cmd="$LFS getstripe $file"
6108 eval $cmd || error "$cmd failed"
6109 check_stripe_count $file 2
6110 check_obdidx $file $ost_idx_in_list
6111 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6112 error "write $file failed"
6116 run_test 82b "specify OSTs for file with --pool and --ost-list options"
6119 [[ $(lustre_version_code ost1) -ge $(version_code 2.6.91) ]] ||
6120 { skip "Need OST version at least 2.6.91" && return 0; }
6121 if [ $(facet_fstype ost1) != ldiskfs ]; then
6122 skip "ldiskfs only test"
6132 ostmnt=$(facet_mntpt ost1)
6133 fstype=$(facet_fstype ost1)
6135 # Mount the OST as an ldiskfs filesystem.
6136 log "mount the OST $dev as a $fstype filesystem"
6137 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
6138 --reformat $dev > /dev/null ||
6139 error "format ost1 error"
6141 if ! test -b $dev; then
6142 mnt_opts=$(csa_add "$OST_MOUNT_OPTS" -o loop)
6144 echo "mnt_opts $mnt_opts"
6145 do_facet ost1 mount -t $fstype $dev \
6147 # Run llverfs on the mounted ldiskfs filesystem.
6148 # It is needed to get ENOSPACE.
6149 log "run llverfs in partial mode on the OST $fstype $ostmnt"
6150 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
6151 "no" || error "run_llverfs error on $fstype"
6154 log "unmount the OST $dev"
6157 # Delete file IO_scrub. Later osd_scrub_setup will try to
6158 # create "IO_scrub" but will get ENOSPACE.
6160 echo "start ost1 service on `facet_active_host ost1`"
6161 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
6164 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
6165 echo "string err $err"
6166 [ -z "$err" ] || error $err
6169 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
6170 Busy inodes after unmount ..."
6173 local facet=$SINGLEMDS
6174 local num=$(echo $facet | tr -d "mds")
6175 local dev=$(mdsdevname $num)
6176 local time_min=$(recovery_time_min)
6177 local recovery_duration
6178 local completed_clients
6179 local correct_clients
6182 echo "start mds service on $(facet_active_host $facet)"
6184 "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" $@ ||
6185 error "start MDS failed"
6187 start_ost || error "start OST0000 failed"
6188 start_ost2 || error "start OST0001 failed"
6190 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
6192 mount_client $MOUNT1 || error "mount $MOUNT1 failed"
6193 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
6194 # make sure new superblock labels are sync'd before disabling writes
6198 replay_barrier $SINGLEMDS
6199 createmany -o $DIR1/$tfile-%d 1000
6201 # We need to catch the end of recovery window to extend it.
6202 # Skip 5 requests and add delay to request handling.
6203 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
6204 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
6206 facet_failover --fsck $SINGLEMDS || error "failover: $?"
6209 echo "recovery status"
6210 do_facet $SINGLEMDS \
6211 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
6213 recovery_duration=$(do_facet $SINGLEMDS \
6214 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6215 awk '/recovery_duration/ { print $2 }')
6216 (( $recovery_duration > $time_min + $wrap_up )) &&
6217 error "recovery_duration > recovery_time_hard + wrap up"
6218 completed_clients=$(do_facet $SINGLEMDS \
6219 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6220 awk '/completed_clients/ { print $2 }')
6222 correct_clients="$MDSCOUNT/$((MDSCOUNT+1))"
6223 [ "$completed_clients" = "${correct_clients}" ] ||
6224 error "$completed_clients != $correct_clients"
6226 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
6227 umount_client $MOUNT1
6228 umount_client $MOUNT2
6234 run_test 84 "check recovery_hard_time"
6237 [[ $(lustre_version_code ost1) -ge $(version_code 2.7.55) ]] ||
6238 { skip "Need OST version at least 2.7.55" && return 0; }
6239 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
6240 do_facet ost1 "lctl set_param fail_loc=0x197"
6244 run_test 85 "osd_ost init: fail ea_fid_set"
6249 # ost1 has already registered to the MGS before the reformat.
6250 # So after reformatting it with option "-G", it could not be
6251 # mounted to the MGS. Cleanup the system for subsequent tests.
6256 local server_version=$(lustre_version_code $SINGLEMDS)
6257 [ "$(facet_fstype ost1)" = "zfs" ] &&
6258 skip "LU-6442: no such mkfs params for ZFS OSTs" && return
6259 [[ $server_version -ge $(version_code 2.7.56) ]] ||
6260 { skip "Need server version newer than 2.7.55"; return 0; }
6262 local OST_OPTS="$(mkfs_opts ost1 $(ostdevname 1)) \
6263 --reformat $(ostdevname 1) $(ostvdevname 1)"
6266 local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6267 awk '/Flex block group size: / { print $NF; exit; }')
6270 if [[ ${!opts} != *mkfsoptions* ]]; then
6271 eval opts=\"${!opts} \
6272 --mkfsoptions='\\\"-O flex_bg -G $NEWSIZE\\\"'\"
6274 val=${!opts//--mkfsoptions=\\\"/ \
6275 --mkfsoptions=\\\"-O flex_bg -G $NEWSIZE }
6279 echo "params: $opts"
6281 trap cleanup_86 EXIT ERR
6284 add ost1 $opts || error "add ost1 failed with new params"
6286 local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6287 awk '/Flex block group size: / { print $NF; exit; }')
6289 [[ $FOUNDSIZE == $NEWSIZE ]] ||
6290 error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
6294 run_test 86 "Replacing mkfs.lustre -G option"
6296 test_87() { #LU-6544
6297 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.9.51) ]] ||
6298 { skip "Need MDS version at least 2.9.51" && return; }
6299 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
6300 { skip "ldiskfs only test" && return; }
6301 [[ $OSTCOUNT -gt 59 ]] &&
6302 { skip "Ignore wide striping situation" && return; }
6304 local mdsdev=$(mdsdevname 1)
6305 local mdsvdev=$(mdsvdevname 1)
6306 local file=$DIR/$tfile
6307 local mntpt=$(facet_mntpt $SINGLEMDS)
6308 local used_xattr_blk=0
6309 local inode_size=${1:-1024}
6311 local xtest="trusted.test"
6315 local stripe_cnt=$(($OSTCOUNT + 2))
6317 #Please see ldiskfs_make_lustre() for MDT inode size calculation
6318 if [ $stripe_cnt -gt 16 ]; then
6321 left_size=$(expr $inode_size - \
6324 32 - 40 \* 3 - 32 \* 3 - $stripe_cnt \* 24 - 16 - 3 - \
6326 24 - 18 - $(expr length $tfile) - 16 - 4)
6327 if [ $left_size -le 0 ]; then
6328 echo "No space($left_size) is expected in inode."
6329 echo "Try 1-byte xattr instead to verify this."
6332 echo "Estimate: at most $left_size-byte space left in inode."
6338 add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$stripe_cnt \
6339 --reformat $mdsdev $mdsvdev || error "add mds1 failed"
6340 start_mdt 1 > /dev/null || error "start mdt1 failed"
6341 for i in $(seq $OSTCOUNT); do
6342 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
6343 error "start ost$i failed"
6345 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
6346 check_mount || error "check client $MOUNT failed"
6349 $LFS setstripe -E 1M -S 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
6350 error "Create file with 3 components failed"
6351 $TRUNCATE $file $((1024*1024*64+1)) || error "truncate file failed"
6352 i=$($LFS getstripe -I3 -c $file) || error "get 3rd stripe count failed"
6353 if [ $i -ne $OSTCOUNT ]; then
6354 left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
6355 echo -n "Since only $i out $OSTCOUNT OSTs are used, "
6356 echo -n "the expected left space is changed to "
6357 echo "$left_size bytes at most."
6359 value=$(generate_string $left_size)
6360 setfattr -n $xtest -v $value $file
6361 orig=$(get_xattr_value $xtest $file)
6362 [[ "$orig" != "$value" ]] && error "$xtest changed"
6364 #Verify if inode has some expected space left
6365 umount $MOUNT > /dev/null || error "umount $MOUNT failed"
6366 stop_mdt 1 > /dev/null || error "stop mdt1 failed"
6367 mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
6369 do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
6370 used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
6372 [[ $used_xattr_blk -eq 0 ]] &&
6373 error "Please check MDS inode size calculation: \
6374 more than $left_size-byte space left in inode."
6375 echo "Verified: at most $left_size-byte space left in inode."
6379 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
6382 [ "$(facet_fstype mds1)" == "zfs" ] &&
6383 skip "LU-6662: no implementation for ZFS" && return
6387 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6388 --reformat $(mdsdevname 1) || error "add mds1 failed"
6390 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6391 grep -e \".*opts:.*errors=remount-ro.*\"" ||
6392 error "default mount options is missing"
6394 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6395 --mountfsoptions="user_xattr,errors=panic" \
6396 --reformat $(mdsdevname 1) || error "add mds1 failed"
6398 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6399 grep -e \".*opts:.*errors=panic.*\"" ||
6400 error "user can't override default mount options"
6402 run_test 88 "check the default mount options can be overridden"
6404 test_89() { # LU-7131
6405 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.9.54) ]] ||
6406 { skip "Need MDT version at least 2.9.54" && return 0; }
6408 local key=failover.node
6409 local val1=192.0.2.254@tcp0 # Reserved IPs, see RFC 5735
6410 local val2=192.0.2.255@tcp0
6411 local mdsdev=$(mdsdevname 1)
6416 [ $(facet_fstype mds1) == zfs ] && import_zpool mds1
6417 # Check that parameters are added correctly
6418 echo "tunefs --param $key=$val1"
6419 do_facet mds "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
6420 error "tunefs --param $key=$val1 failed"
6421 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6422 error "tunefs --dryrun failed"
6423 params=${params##*Parameters:}
6424 params=${params%%exiting*}
6425 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val1) = "1" ] ||
6426 error "on-disk parameter not added correctly via tunefs"
6428 # Check that parameters replace existing instances when added
6429 echo "tunefs --param $key=$val2"
6430 do_facet mds "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
6431 error "tunefs --param $key=$val2 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' | grep -c $key=) = "1" ] ||
6437 error "on-disk parameter not replaced via tunefs"
6438 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val2) = "1" ] ||
6439 error "on-disk parameter not replaced correctly via tunefs"
6441 # Check that a parameter is erased properly
6442 echo "tunefs --erase-param $key"
6443 do_facet mds "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
6444 error "tunefs --erase-param $key failed"
6445 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6446 error "tunefs --dryrun failed"
6447 params=${params##*Parameters:}
6448 params=${params%%exiting*}
6449 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "0" ] ||
6450 error "on-disk parameter not erased correctly via tunefs"
6452 # Check that all the parameters are erased
6453 echo "tunefs --erase-params"
6454 do_facet mds "$TUNEFS --erase-params $mdsdev >/dev/null" ||
6455 error "tunefs --erase-params failed"
6456 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6457 error "tunefs --dryrun failed"
6458 params=${params##*Parameters:}
6459 params=${params%%exiting*}
6461 error "all on-disk parameters not erased correctly via tunefs"
6463 # Check the order of options --erase-params and --param
6464 echo "tunefs --param $key=$val1 --erase-params"
6466 "$TUNEFS --param $key=$val1 --erase-params $mdsdev >/dev/null"||
6467 error "tunefs --param $key=$val1 --erase-params failed"
6468 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6469 error "tunefs --dryrun failed"
6470 params=${params##*Parameters:}
6471 params=${params%%exiting*}
6472 [ $(echo $params | tr ' ' '\n') == "$key=$val1" ] ||
6473 error "on-disk param not added correctly with --erase-params"
6477 run_test 89 "check tunefs --param and --erase-param{s} options"
6480 # $2 (optional) value of max_mod_rpcs_in_flight to set
6481 check_max_mod_rpcs_in_flight() {
6489 idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
6490 facet="mds$((0x$idx + 1))"
6492 if [ -z "$mmr" ]; then
6493 # get value of max_mod_rcps_in_flight
6494 mmr=$($LCTL get_param -n \
6495 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
6496 error "Unable to get max_mod_rpcs_in_flight"
6497 echo "max_mod_rcps_in_flight is $mmr"
6499 # set value of max_mod_rpcs_in_flight
6501 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
6502 error "Unable to set max_mod_rpcs_in_flight to $mmr"
6503 echo "max_mod_rpcs_in_flight set to $mmr"
6506 # create mmr+1 files
6507 echo "creating $((mmr + 1)) files ..."
6509 for i in $(seq $((mmr + 1))); do
6515 # consumes mmr-1 modify RPC slots
6516 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6517 # drop requests on MDT so that RPC slots are consumed
6518 # during all the request resend interval
6519 do_facet $facet "$LCTL set_param fail_loc=0x159"
6520 echo "launch $((mmr - 1)) chmod in parallel ..."
6521 for i in $(seq $((mmr - 1))); do
6522 chmod 0600 $dir/file-$i &
6526 # send one additional modify RPC
6527 do_facet $facet "$LCTL set_param fail_loc=0"
6528 echo "launch 1 additional chmod in parallel ..."
6529 chmod 0600 $dir/file-$mmr &
6532 # check this additional modify RPC get a modify RPC slot
6533 # and succeed its operation
6534 checkstat -vp 0600 $dir/file-$mmr ||
6535 error "Unable to send $mmr modify RPCs in parallel"
6540 # consumes mmr modify RPC slots
6541 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6542 # drop requests on MDT so that RPC slots are consumed
6543 # during all the request resend interval
6544 do_facet $facet "$LCTL set_param fail_loc=0x159"
6545 echo "launch $mmr chmod in parallel ..."
6546 for i in $(seq $mmr); do
6547 chmod 0666 $dir/file-$i &
6551 # send one additional modify RPC
6552 do_facet $facet "$LCTL set_param fail_loc=0"
6553 echo "launch 1 additional chmod in parallel ..."
6554 chmod 0666 $dir/file-$((mmr + 1)) &
6557 # check this additional modify RPC blocked getting a modify RPC slot
6558 checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
6559 error "Unexpectedly send $(($mmr + 1)) modify RPCs in parallel"
6565 if ! combined_mgs_mds ; then
6570 [[ $($LCTL get_param mdc.*.import |
6571 grep "connect_flags:.*multi_mod_rpc") ]] ||
6572 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
6574 # check default value
6575 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6576 check_max_mod_rpcs_in_flight $DIR/$tdir
6580 run_test 90a "check max_mod_rpcs_in_flight is enforced"
6590 [[ $($LCTL get_param mdc.*.import |
6591 grep "connect_flags:.*multi_mod_rpc") ]] ||
6592 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
6595 # update max_mod_rpcs_in_flight
6596 $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
6597 check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
6600 # check client is able to send multiple modify RPCs in paralell
6601 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6602 grep -c "multi_mod_rpcs")
6603 if [ "$tmp" -ne $MDSCOUNT ]; then
6604 echo "Client not able to send multiple modify RPCs in parallel"
6609 # update max_mod_rpcs_in_flight
6610 $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
6611 check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
6614 $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
6615 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
6616 facet="mds$((0x$idx + 1))"
6618 # save MDT max_mod_rpcs_per_client
6619 mmrpc=$(do_facet $facet \
6620 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6622 # update max_mod_rpcs_in_flight
6623 umount_client $MOUNT
6625 "echo 16 > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6627 $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
6628 check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
6630 # restore MDT max_mod_rpcs_per_client initial value
6632 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6634 rm -rf $DIR/${tdir}?
6637 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
6646 [[ $($LCTL get_param mdc.*.import |
6647 grep "connect_flags:.*multi_mod_rpc") ]] ||
6648 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
6650 # check client is able to send multiple modify RPCs in paralell
6651 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6652 grep -c "multi_mod_rpcs")
6653 if [ "$tmp" -ne $MDSCOUNT ]; then
6654 skip "Client not able to send multiple modify RPCs in parallel"
6659 # get max_rpcs_in_flight value
6660 mrif=$($LCTL get_param -n mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6661 echo "max_rpcs_in_flight is $mrif"
6663 # get MDT max_mod_rpcs_per_client
6664 mmrpc=$(do_facet mds1 \
6665 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6666 echo "max_mod_rpcs_per_client is $mmrpc"
6669 # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
6670 # prerequisite: set max_mod_rpcs_per_client to max_rpcs_in_flight value
6671 umount_client $MOUNT
6673 "echo $mrif > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6677 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif &&
6678 error "set max_mod_rpcs_in_flight to $mrif should fail"
6680 umount_client $MOUNT
6682 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6686 # attempt to set max_mod_rpcs_in_flight to max_mod_rpcs_per_client+1
6687 # prerequisite: set max_rpcs_in_flight to max_mod_rpcs_per_client+2
6689 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc + 2))
6692 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc + 1)) &&
6693 error "set max_mod_rpcs_in_flight to $((mmrpc + 1)) should fail"
6697 run_test 90c "check max_mod_rpcs_in_flight update limits"
6708 [[ $($LCTL get_param mdc.*.import |
6709 grep "connect_flags:.*multi_mod_rpc") ]] ||
6710 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
6712 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6713 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
6714 facet="mds$((0x$idx + 1))"
6716 # check client version supports multislots
6717 tmp=$($LCTL get_param -N \
6718 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6719 if [ -z "$tmp" ]; then
6720 skip "Client does not support multiple modify RPCs in flight"
6725 # get current value of max_mod_rcps_in_flight
6726 mmr=$($LCTL get_param -n \
6727 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6728 echo "max_mod_rcps_in_flight is $mmr"
6731 echo "creating $mmr files ..."
6733 for i in $(seq $mmr); do
6734 touch $DIR/$tdir/file-$i
6737 # prepare for close RPC
6738 multiop_bg_pause $DIR/$tdir/file-close O_c
6741 # consumes mmr modify RPC slots
6742 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6743 # drop requests on MDT so that RPC slots are consumed
6744 # during all the request resend interval
6745 do_facet $facet "$LCTL set_param fail_loc=0x159"
6746 echo "launch $mmr chmod in parallel ..."
6747 for i in $(seq $mmr); do
6748 chmod 0600 $DIR/$tdir/file-$i &
6751 # send one additional close RPC
6752 do_facet $facet "$LCTL set_param fail_loc=0"
6753 echo "launch 1 additional close in parallel ..."
6755 cancel_lru_locks mdc
6758 # check this additional close RPC get a modify RPC slot
6759 # and multiop process completed
6760 [ -d /proc/$pid ] &&
6761 error "Unable to send the additional close RPC in parallel"
6766 run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
6768 check_uuid_on_ost() {
6770 do_facet ost1 "$LCTL get_param obdfilter.${FSNAME}*.exports.'$nid'.uuid"
6773 check_uuid_on_mdt() {
6775 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6783 [[ $(lustre_version_code ost1) -ge $(version_code 2.7.63) ]] ||
6784 { skip "Need OST version at least 2.7.63" && return 0; }
6785 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.63) ]] ||
6786 { skip "Need MDT version at least 2.7.63" && return 0; }
6788 start_mds || error "MDS start failed"
6789 start_ost || error "unable to start OST"
6790 mount_client $MOUNT || error "client start failed"
6791 check_mount || error "check_mount failed"
6794 nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
6798 uuid=$(get_client_uuid $MOUNT)
6800 echo "list nids on mdt:"
6801 do_facet $SINGLEMDS "$LCTL list_param mdt.${FSNAME}*.exports.*"
6802 echo "uuid from $nid:"
6803 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6805 found=$(check_uuid_on_mdt $nid | grep $uuid)
6806 [ -z "$found" ] && error "can't find $uuid $nid on MDT"
6807 found=$(check_uuid_on_ost $nid | grep $uuid)
6808 [ -z "$found" ] && error "can't find $uuid $nid on OST"
6810 # umount the client so it won't reconnect
6811 manual_umount_client --force || error "failed to umount $?"
6812 # shouldn't disappear on MDS after forced umount
6813 found=$(check_uuid_on_mdt $nid | grep $uuid)
6814 [ -z "$found" ] && error "can't find $uuid $nid"
6817 do_facet $SINGLEMDS \
6818 "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
6820 found=$(check_uuid_on_mdt $nid | grep $uuid)
6821 [ -n "$found" ] && error "found $uuid $nid on MDT"
6822 found=$(check_uuid_on_ost $nid | grep $uuid)
6823 [ -n "$found" ] && error "found $uuid $nid on OST"
6825 # check it didn't reconnect (being umounted)
6826 sleep $((TIMEOUT+1))
6827 found=$(check_uuid_on_mdt $nid | grep $uuid)
6828 [ -n "$found" ] && error "found $uuid $nid on MDT"
6829 found=$(check_uuid_on_ost $nid | grep $uuid)
6830 [ -n "$found" ] && error "found $uuid $nid on OST"
6834 run_test 91 "evict-by-nid support"
6836 generate_ldev_conf() {
6837 # generate an ldev.conf file
6838 local ldevconfpath=$1
6840 local fsldevformat=""
6843 fstype=$(facet_fstype mgs)
6844 if [ "$fstype" == "zfs" ]; then
6845 fsldevformat="$fstype:"
6850 printf "%s\t-\t%s-MGS0000\t%s%s\n" \
6854 $(mgsdevname) > $ldevconfpath
6856 local mdsfo_host=$mdsfailover_HOST;
6857 if [ -z "$mdsfo_host" ]; then
6861 for num in $(seq $MDSCOUNT); do
6862 fstype=$(facet_fstype mds$num)
6863 if [ "$fstype" == "zfs" ]; then
6864 fsldevformat="$fstype:"
6869 printf "%s\t%s\t%s-MDT%04d\t%s%s\n" \
6875 $(mdsdevname $num) >> $ldevconfpath
6878 local ostfo_host=$ostfailover_HOST;
6879 if [ -z "$ostfo_host" ]; then
6883 for num in $(seq $OSTCOUNT); do
6884 fstype=$(facet_fstype ost$num)
6885 if [ "$fstype" == "zfs" ]; then
6886 fsldevformat="$fstype:"
6891 printf "%s\t%s\t%s-OST%04d\t%s%s\n" \
6897 $(ostdevname $num) >> $ldevconfpath
6900 echo "----- $ldevconfpath -----"
6902 echo "--- END $ldevconfpath ---"
6907 # generate a nids file (mapping between hostname to nid)
6908 # looks like we only have the MGS nid available to us
6909 # so just echo that to a file
6911 echo -e "${mgs_HOST}\t${MGSNID}" > $nidspath
6913 echo "----- $nidspath -----"
6915 echo "--- END $nidspath ---"
6918 compare_ldev_output() {
6922 sort $expected_output -o $expected_output
6923 sort $ldev_output -o $ldev_output
6925 echo "-- START OF LDEV OUTPUT --"
6927 echo "--- END OF LDEV OUTPUT ---"
6929 echo "-- START OF EXPECTED OUTPUT --"
6930 cat $expected_output
6931 echo "--- END OF EXPECTED OUTPUT ---"
6933 diff $expected_output $ldev_output
6938 if [ -z "$LDEV" ]; then
6939 error "ldev is missing!"
6942 local LDEVCONFPATH=$TMP/ldev.conf
6943 local NIDSPATH=$TMP/nids
6945 echo "Host is $(hostname)"
6947 generate_ldev_conf $LDEVCONFPATH
6948 generate_nids $NIDSPATH
6950 # echo the mgs nid and compare it to environment variable MGSNID
6951 # also, ldev.conf and nids is a server side thing, use the OSS
6954 output=$($LDEV -c $LDEVCONFPATH -H $ost_HOST -n $NIDSPATH echo %m)
6956 echo "-- START OF LDEV OUTPUT --"
6958 echo "--- END OF LDEV OUTPUT ---"
6960 # ldev failed, error
6961 if [ $? -ne 0 ]; then
6962 rm $LDEVCONFPATH $NIDSPATH
6963 error "ldev failed to execute!"
6966 # need to process multiple lines because of combined MGS and MDS
6967 echo -e $output | awk '{ print $2 }' | while read -r line ; do
6968 if [ "$line" != "$MGSNID" ]; then
6969 rm $LDEVCONFPATH $NIDSPATH
6970 error "ldev failed mgs nid '$line', expected '$MGSNID'"
6974 rm $LDEVCONFPATH $NIDSPATH
6976 run_test 92 "ldev returns MGS NID correctly in command substitution"
6979 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs" && return
6982 #start mgs or mgs/mdt0
6983 if ! combined_mgs_mds ; then
6990 start_ost || error "OST0 start fail"
6992 #define OBD_FAIL_MGS_WRITE_TARGET_DELAY 0x90e
6993 do_facet mgs "$LCTL set_param fail_val = 10 fail_loc=0x8000090e"
6994 for num in $(seq 2 $MDSCOUNT); do
6998 mount_client $MOUNT || error "mount client fails"
6999 wait_osc_import_state mds ost FULL
7000 wait_osc_import_state client ost FULL
7001 check_mount || error "check_mount failed"
7003 cleanup || error "cleanup failed with $?"
7005 run_test 93 "register mulitple MDT at the same time"
7008 if [ -z "$LDEV" ]; then
7009 error "ldev is missing!"
7012 local LDEVCONFPATH=$TMP/ldev.conf
7013 local NIDSPATH=$TMP/nids
7015 generate_ldev_conf $LDEVCONFPATH
7016 generate_nids $NIDSPATH
7018 local LDEV_OUTPUT=$TMP/ldev-output.txt
7019 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME > $LDEV_OUTPUT
7021 # ldev failed, error
7022 if [ $? -ne 0 ]; then
7023 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7024 error "ldev failed to execute!"
7028 local EXPECTED_OUTPUT=$TMP/ldev-expected.txt
7030 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7032 for num in $(seq $MDSCOUNT); do
7033 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7036 for num in $(seq $OSTCOUNT); do
7037 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7040 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7042 if [ $? -ne 0 ]; then
7043 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7044 error "ldev failed to produce the correct hostlist!"
7047 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7049 run_test 94 "ldev outputs correct labels for file system name query"
7052 if [ -z "$LDEV" ]; then
7053 error "ldev is missing!"
7056 local LDEVCONFPATH=$TMP/ldev.conf
7057 local NIDSPATH=$TMP/nids
7059 generate_ldev_conf $LDEVCONFPATH
7060 generate_nids $NIDSPATH
7064 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME &>/dev/null
7065 if [ $? -ne 0 ]; then
7066 rm $LDEVCONFPATH $NIDSPATH
7067 error "ldev label filtering w/ -F failed!"
7071 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -l &>/dev/null
7072 if [ $? -ne 0 ]; then
7073 rm $LDEVCONFPATH $NIDSPATH
7074 error "ldev label filtering w/ -l failed!"
7078 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f &>/dev/null
7079 if [ $? -ne 0 ]; then
7080 rm $LDEVCONFPATH $NIDSPATH
7081 error "ldev label filtering w/ -f failed!"
7085 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a &>/dev/null
7086 if [ $? -ne 0 ]; then
7087 rm $LDEVCONFPATH $NIDSPATH
7088 error "ldev label filtering w/ -a failed!"
7093 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -F $FSNAME &>/dev/null
7094 if [ $? -eq 0 ]; then
7095 rm $LDEVCONFPATH $NIDSPATH
7096 error "ldev label filtering w/ -a and -F incorrectly succeeded"
7100 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -f &>/dev/null
7101 if [ $? -eq 0 ]; then
7102 rm $LDEVCONFPATH $NIDSPATH
7103 error "ldev label filtering w/ -a and -f incorrectly succeeded"
7107 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -l &>/dev/null
7108 if [ $? -eq 0 ]; then
7109 rm $LDEVCONFPATH $NIDSPATH
7110 error "ldev label filtering w/ -a and -l incorrectly succeeded"
7114 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f -l &>/dev/null
7115 if [ $? -eq 0 ]; then
7116 rm $LDEVCONFPATH $NIDSPATH
7117 error "ldev label filtering w/ -f and -l incorrectly succeeded"
7121 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -l &>/dev/null
7122 if [ $? -eq 0 ]; then
7123 rm $LDEVCONFPATH $NIDSPATH
7124 error "ldev label filtering w/ -F and -l incorrectly succeeded"
7127 # file sys & foreign
7128 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -f &>/dev/null
7129 if [ $? -eq 0 ]; then
7130 rm $LDEVCONFPATH $NIDSPATH
7131 error "ldev label filtering w/ -F and -f incorrectly succeeded"
7134 rm $LDEVCONFPATH $NIDSPATH
7136 run_test 95 "ldev should only allow one label filter"
7139 if [ -z "$LDEV" ]; then
7140 error "ldev is missing!"
7143 local LDEVCONFPATH=$TMP/ldev.conf
7144 local NIDSPATH=$TMP/nids
7146 generate_ldev_conf $LDEVCONFPATH
7147 generate_nids $NIDSPATH
7149 local LDEV_OUTPUT=$TMP/ldev-output.txt
7150 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -H $mgs_HOST \
7152 awk '{print $2}' > $LDEV_OUTPUT
7154 # ldev failed, error
7155 if [ $? -ne 0 ]; then
7156 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7157 error "ldev failed to execute!"
7161 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7163 echo "$mgs_HOST-$(facet_fstype mgs)" > $EXPECTED_OUTPUT
7165 if [ "$mgs_HOST" == "$mds_HOST" ]; then
7166 for num in $(seq $MDSCOUNT); do
7167 echo "$mds_HOST-$(facet_fstype mds$num)" \
7172 if [ "$mgs_HOST" == "$ost_HOST" ]; then
7173 for num in $(seq $OSTCOUNT); do
7174 echo "$ost_HOST-$(facet_fstype ost$num)" \
7179 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7181 if [ $? -ne 0 ]; then
7182 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7183 error "ldev failed to produce the correct output!"
7186 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7188 run_test 96 "ldev returns hostname and backend fs correctly in command sub"
7191 if [ -z "$LDEV" ]; then
7192 error "ldev is missing!"
7195 local LDEVCONFPATH=$TMP/ldev.conf
7196 local NIDSPATH=$TMP/nids
7198 generate_ldev_conf $LDEVCONFPATH
7199 generate_nids $NIDSPATH
7201 local LDEV_OUTPUT=$TMP/ldev-output.txt
7202 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7204 echo -e "\nMDT role"
7205 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mdt > $LDEV_OUTPUT
7207 if [ $? -ne 0 ]; then
7208 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7209 error "ldev failed to execute for mdt role!"
7212 for num in $(seq $MDSCOUNT); do
7213 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7216 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7218 if [ $? -ne 0 ]; then
7219 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7220 error "ldev failed to produce the correct output for mdt role!"
7223 echo -e "\nOST role"
7224 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R ost > $LDEV_OUTPUT
7226 if [ $? -ne 0 ]; then
7227 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7228 error "ldev failed to execute for ost role!"
7232 for num in $(seq $OSTCOUNT); do
7233 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7236 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7238 if [ $? -ne 0 ]; then
7239 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7240 error "ldev failed to produce the correct output for ost role!"
7243 echo -e "\nMGS role"
7244 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mgs > $LDEV_OUTPUT
7246 if [ $? -ne 0 ]; then
7247 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7248 error "ldev failed to execute for mgs role!"
7251 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7253 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7255 if [ $? -ne 0 ]; then
7256 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7257 error "ldev failed to produce the correct output for mgs role!"
7260 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7262 run_test 97 "ldev returns correct ouput when querying based on role"
7267 local temp=$MDS_MOUNT_OPTS
7270 check_mount || error "mount failed"
7271 mountopt="user_xattr"
7272 for ((x = 1; x <= 400; x++)); do
7273 mountopt="$mountopt,user_xattr"
7275 remount_client $mountopt $MOUNT 2>&1 | grep "too long" ||
7276 error "Buffer overflow check failed"
7277 cleanup || error "cleanup failed"
7279 run_test 98 "Buffer-overflow check while parsing mount_opts"
7283 [[ $(facet_fstype ost1) != ldiskfs ]] &&
7284 { skip "ldiskfs only test" && return; }
7285 [[ $(lustre_version_code ost1) -ge $(version_code 2.8.57) ]] ||
7286 { skip "Need OST version at least 2.8.57" && return 0; }
7288 local ost_opts="$(mkfs_opts ost1 $(ostdevname 1)) \
7289 --reformat $(ostdevname 1) $(ostvdevname 1)"
7290 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" &&
7291 skip "meta_bg already set" && return
7294 if [[ ${!opts} != *mkfsoptions* ]]; then
7295 eval opts=\"${!opts} \
7296 --mkfsoptions='\\\"-O ^resize_inode,meta_bg\\\"'\"
7298 local val=${!opts//--mkfsoptions=\\\"/ \
7299 --mkfsoptions=\\\"-O ^resize_inode,meta_bg }
7303 echo "params: $opts"
7305 add ost1 $opts || error "add ost1 failed with new params"
7307 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" ||
7308 error "meta_bg is not set"
7312 run_test 99 "Adding meta_bg option"
7316 start_mds || error "MDS start failed"
7317 start_ost || error "unable to start OST"
7318 mount_client $MOUNT || error "client start failed"
7319 check_mount || error "check_mount failed"
7328 do_facet mgs 'lshowmount -v' | awk 'BEGIN {NR == 0; rc=1} /MGS:/ {rc=0}
7329 END {exit rc}' || error "lshowmount have no output MGS"
7331 do_facet mds1 'lshowmount -v' | awk 'BEGIN {NR == 2; rc=1} /-MDT0000:/
7332 {rc=0} END {exit rc}' || error "lshowmount have no output MDT0"
7334 do_facet ost1 'lshowmount -v' | awk 'BEGIN {NR == 4; rc=1} /-OST0000:/
7335 {rc=0} END {exit rc}' || error "lshowmount have no output OST0"
7337 cleanup || error "cleanup failed with $?"
7339 run_test 100 "check lshowmount lists MGS, MDT, OST and 0@lo"
7342 local createmany_pid
7343 local dev=$FSNAME-OST0000-osc-MDT0000
7347 createmany -o $DIR1/$tdir/$tfile-%d 50000 &
7349 # MDT->OST reconnection causes MDT<->OST last_id synchornisation
7350 # via osp_precreate_cleanup_orphans.
7351 for ((i = 0; i < 100; i++)); do
7352 for ((k = 0; k < 10; k++)); do
7353 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;" \
7354 "$LCTL --device $dev activate"
7357 ls -asl $MOUNT | grep '???' &&
7358 { kill -9 $createmany_pid &>/dev/null;
7359 error "File has no object on OST"; }
7361 kill -s 0 $createmany_pid || break
7363 wait $createmany_pid
7365 unlinkmany $DIR1/$tdir/$tfile-%d 50000
7368 run_test 101 "Race MDT->OST reconnection with create"
7371 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.9.53) ]] ||
7372 skip "Need server version greater than 2.9.53"
7373 cleanup || error "cleanup failed with $?"
7375 local mds1dev=$(mdsdevname 1)
7376 local mds1mnt=$(facet_mntpt mds1)
7377 local mds1fstype=$(facet_fstype mds1)
7378 local mds1opts=$MDS_MOUNT_OPTS
7380 if [ $mds1fstype == ldiskfs ] &&
7381 ! do_facet mds1 test -b $mds1dev; then
7382 mds1opts=$(csa_add "$mds1opts" -o loop)
7384 if [[ $mds1fstype == zfs ]]; then
7385 import_zpool mds1 || return ${PIPESTATUS[0]}
7388 # unload all and only load libcfs to allow fail_loc setting
7389 do_facet mds1 $LUSTRE_RMMOD || error "unable to unload modules"
7390 do_facet mds1 modprobe libcfs || error "libcfs not loaded"
7391 do_facet mds1 lsmod \| grep libcfs || error "libcfs not loaded"
7393 #define OBD_FAIL_OBDCLASS_MODULE_LOAD 0x60a
7394 do_facet mds1 "$LCTL set_param fail_loc=0x8000060a"
7396 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
7397 error "mdt start must fail"
7398 do_facet mds1 lsmod \| grep obdclass && error "obdclass must not load"
7400 do_facet mds1 "$LCTL set_param fail_loc=0x0"
7402 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts ||
7403 error "mdt start must not fail"
7405 cleanup || error "cleanup failed with $?"
7407 run_test 102 "obdclass module cleanup upon error"
7412 echo "rename $FSNAME to $newname"
7414 if ! combined_mgs_mds ; then
7415 local facet=$(mgsdevname)
7418 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7419 error "(7) Fail to rename MGS"
7420 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7421 reimport_zpool mgs $newname-mgs
7425 for num in $(seq $MDSCOUNT); do
7426 local facet=$(mdsdevname $num)
7428 do_facet mds${num} \
7429 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7430 error "(8) Fail to rename MDT $num"
7431 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7432 reimport_zpool mds${num} $newname-mdt${num}
7436 for num in $(seq $OSTCOUNT); do
7437 local facet=$(ostdevname $num)
7439 do_facet ost${num} \
7440 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7441 error "(9) Fail to rename OST $num"
7442 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7443 reimport_zpool ost${num} $newname-ost${num}
7448 test_103_set_pool() {
7452 do_facet mgs $LCTL pool_add $FSNAME.$pname ${FSNAME}-$ost_x ||
7453 error "Fail to add $ost_x to $FSNAME.$pname"
7454 wait_update $HOSTNAME \
7455 "lctl get_param -n lov.$FSNAME-clilov-*.pools.$pname |
7456 grep $ost_x" "$FSNAME-${ost_x}_UUID" ||
7457 error "$ost_x is NOT in pool $FSNAME.$pname"
7460 test_103_check_pool() {
7461 local save_fsname=$1
7464 stat $DIR/$tdir/test-framework.sh ||
7465 error "($errno) Fail to stat"
7466 do_facet mgs $LCTL pool_list $FSNAME.pool1 ||
7467 error "($errno) Fail to list $FSNAME.pool1"
7468 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname ||
7469 error "($errno) Fail to list $FSNAME.$save_fsname"
7470 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname |
7471 grep ${FSNAME}-OST0000 ||
7472 error "($errno) List $FSNAME.$save_fsname is invalid"
7474 local pname=$($LFS getstripe --pool $DIR/$tdir/d0)
7475 [ "$pname" = "$save_fsname" ] ||
7476 error "($errno) Unexpected pool name $pname"
7480 check_mount_and_prep
7482 mkdir $DIR/$tdir || error "(1) Fail to mkdir $DIR/$tdir"
7483 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir ||
7484 error "(2) Fail to copy test-framework.sh"
7486 if ! combined_mgs_mds ; then
7489 do_facet mgs $LCTL pool_new $FSNAME.pool1 ||
7490 error "(3) Fail to create $FSNAME.pool1"
7491 # name the pool name as the fsname
7492 do_facet mgs $LCTL pool_new $FSNAME.$FSNAME ||
7493 error "(4) Fail to create $FSNAME.$FSNAME"
7495 test_103_set_pool $FSNAME OST0000
7497 $LFS setstripe -p $FSNAME $DIR/$tdir/d0 ||
7498 error "(6) Fail to setstripe on $DIR/$tdir/d0"
7500 if ! combined_mgs_mds ; then
7506 test_renamefs mylustre
7508 local save_fsname=$FSNAME
7512 if ! combined_mgs_mds ; then
7515 test_103_check_pool $save_fsname 7
7517 if [ $OSTCOUNT -ge 2 ]; then
7518 test_103_set_pool $save_fsname OST0001
7521 $LFS setstripe -p $save_fsname $DIR/$tdir/f0 ||
7522 error "(16) Fail to setstripe on $DIR/$tdir/f0"
7523 if ! combined_mgs_mds ; then
7534 if ! combined_mgs_mds ; then
7537 test_103_check_pool $save_fsname 17
7539 if ! combined_mgs_mds ; then
7544 test_renamefs $save_fsname
7550 run_test 103 "rename filesystem name"
7552 test_104() { # LU-6952
7553 local mds_mountopts=$MDS_MOUNT_OPTS
7554 local ost_mountopts=$OST_MOUNT_OPTS
7555 local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
7556 local lctl_ver=$(do_facet $SINGLEMDS $LCTL --version |
7559 [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
7560 { skip "this test needs utils above 2.9.55" && return 0; }
7562 # specify "acl" in mount options used by mkfs.lustre
7563 if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
7564 MDS_MOUNT_FS_OPTS="acl,user_xattr"
7567 MDS_MOUNT_FS_OPTS="${MDS_MOUNT_FS_OPTS},acl,user_xattr"
7570 echo "mountfsopt: $MDS_MOUNT_FS_OPTS"
7572 #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
7574 if [ -z "$MDS_MOUNT_OPTS" ]; then
7575 MDS_MOUNT_OPTS="-o noacl"
7577 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7580 for num in $(seq $MDSCOUNT); do
7581 start mds$num $(mdsdevname $num) $MDS_MOUNT_OPTS ||
7582 error "Failed to start MDS"
7585 for num in $(seq $OSTCOUNT); do
7586 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
7587 error "Failed to start OST"
7591 setfacl -m "d:$RUNAS_ID:rwx" $MOUNT &&
7592 error "ACL is applied when FS is mounted with noacl."
7594 MDS_MOUNT_OPTS=$mds_mountopts
7595 OST_MOUNT_OPTS=$ost_mountopts
7596 MDS_MOUNT_FS_OPTS=$mds_mountfsopts
7601 run_test 104 "Make sure user defined options are reflected in mount"
7603 error_and_umount() {
7614 mount --bind $DIR $TMP/$tdir || error "mount bind mnt pt failed"
7615 rm -f $TMP/$tdir/$tfile
7616 rm -f $TMP/$tdir/${tfile}1
7618 # Files should not be created in ro bind mount point
7619 # remounting from rw to ro
7620 mount -o remount,ro $TMP/$tdir ||
7621 error_and_umount "readonly remount of bind mnt pt failed"
7622 touch $TMP/$tdir/$tfile &&
7623 error_and_umount "touch succeeds on ro bind mnt pt"
7624 [ -e $TMP/$tdir/$tfile ] &&
7625 error_and_umount "file created on ro bind mnt pt"
7627 # Files should be created in rw bind mount point
7628 # remounting from ro to rw
7629 mount -o remount,rw $TMP/$tdir ||
7630 error_and_umount "read-write remount of bind mnt pt failed"
7631 touch $TMP/$tdir/${tfile}1 ||
7632 error_and_umount "touch fails on rw bind mnt pt"
7633 [ -e $TMP/$tdir/${tfile}1 ] ||
7634 error_and_umount "file not created on rw bind mnt pt"
7635 umount $TMP/$tdir || error "umount of bind mnt pt failed"
7637 cleanup || error "cleanup failed with $?"
7639 run_test 105 "check file creation for ro and rw bind mnt pt"
7646 mkdir -p $DIR/$tdir || error "create $tdir failed"
7647 lfs setstripe -c 1 -i 0 $DIR/$tdir
7648 #define OBD_FAIL_CAT_RECORDS 0x1312
7649 do_facet mds1 $LCTL set_param fail_loc=0x1312 fail_val=$repeat
7651 for ((i = 1; i <= $repeat; i++)); do
7653 #one full plain llog
7654 createmany -o $DIR/$tdir/f- 64768
7656 createmany -u $DIR/$tdir/f- 64768
7658 wait_delete_completed $((TIMEOUT * 7))
7659 #ASSERTION osp_sync_thread() ( thread->t_flags != SVC_RUNNING ) failed
7660 #shows that osp code is buggy
7661 do_facet mds1 $LCTL set_param fail_loc=0 fail_val=0
7665 run_test 106 "check osp llog processing when catalog is wrapped"
7668 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.50) ]] ||
7669 { skip "Need MDS version > 2.10.50"; return; }
7672 start_mgsmds || error "start_mgsmds failed"
7673 start_ost || error "unable to start OST"
7675 # add unknown configuration parameter.
7676 if [[ $PERM_CMD == *"set_param -P"* ]]; then
7677 cmd="$PERM_CMD ost.$FSNAME-OST0000*.unknown_param"
7679 cmd="$PERM_CMD $FSNAME-OST0000*.ost.unknown_param"
7681 do_facet mgs "$cmd=50"
7682 cleanup_nocli || error "cleanup_nocli failed with $?"
7685 # unknown param should be ignored while mounting.
7686 start_ost || error "unable to start OST after unknown param set"
7688 cleanup || error "cleanup failed with $?"
7690 run_test 107 "Unknown config param should not fail target mounting"
7695 $rcmd rm -rf $tmp > /dev/null 2>&1
7696 $rcmd mkdir -p $tmp/{mnt,images} || error "failed to mkdir remotely"
7698 for facet in $facets; do
7699 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
7700 $rcmd $ZPOOL -f export lustre-$facet > /dev/null 2>&1
7701 $rcmd mkdir $tmp/mnt/$facet ||
7702 error "failed to mkdir $tmp/mnt/$facet"
7703 $rcmd dd if=/dev/zero of=$tmp/images/$facet \
7704 seek=199 bs=1M count=1 ||
7705 error "failed to create $tmp/images/$facet"
7714 local facet=${role}$((idx + 1))
7716 [ $# -eq 5 ] && pool=$5
7718 do_facet $SINGLEMDS $MKFS --fsname=lustre --$mgs \
7719 --$role --index=$idx --replace --backfstype=$bkfs \
7720 --device-size=200000 --reformat $pool $tmp/images/$facet ||
7721 error "failed to mkfs for $facet"
7725 echo "mounting client..."
7726 mount -t lustre ${nid}:/lustre $MOUNT ||
7727 error "failed to mount lustre"
7730 ls -l $MOUNT/local_dir || error "failed to list"
7732 echo "check truncate && write"
7733 echo "dummmmmmmmmmmmm" > $MOUNT/remote_dir/fsx.c ||
7734 error "failed to tuncate & write"
7737 touch $MOUNT/foooo ||
7738 error "failed to create"
7740 echo "check read && write && append"
7741 sha1sum $MOUNT/conf-sanity.sh |
7742 awk '{ print $1 }' > $MOUNT/checksum.new ||
7743 error "failed to read(1)"
7744 sha1sum $MOUNT/remote_dir/unlinkmany.c |
7745 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7746 error "failed to read(2)"
7747 sha1sum $MOUNT/striped_dir/lockahead_test.o |
7748 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7749 error "failed to read(3)"
7752 diff $MOUNT/checksum.new $MOUNT/checksum.src ||
7753 error "failed to verify data"
7763 umount -f $MOUNT || error "failed to umount client"
7764 for facet in $facets; do
7765 $rcmd umount -f $tmp/mnt/$facet ||
7766 error "failed to umount $facet"
7767 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
7768 $rcmd $ZPOOL export -f lustre-$facet ||
7769 error "failed to export lustre-$facet"
7773 $rcmd rm -rf $tmp || error "failed to rm the dir $tmp"
7777 [ "$CLIENTONLY" ] && skip "Client-only testing" && return
7779 [ $(facet_fstype $SINGLEMDS) != "zfs" ] &&
7780 skip "zfs only test" && return
7782 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
7783 skip "Need server version at least 2.10.58" && return
7788 local tmp=$TMP/$tdir
7789 local rcmd="do_facet $SINGLEMDS"
7790 local facets="mdt1 mdt2 ost1 ost2"
7791 local nid=$($rcmd $LCTL list_nids | head -1)
7794 trap t_108_cleanup EXIT ERR
7797 t_108_mkfs mdt 0 zfs mgs lustre-mdt1/mdt1
7798 t_108_mkfs mdt 1 zfs mgsnode=$nid lustre-mdt2/mdt2
7799 t_108_mkfs ost 0 zfs mgsnode=$nid lustre-ost1/ost1
7800 t_108_mkfs ost 1 zfs mgsnode=$nid lustre-ost2/ost2
7802 for facet in $facets; do
7803 $rcmd zfs set mountpoint=$tmp/mnt/$facet canmount=on \
7804 lustre-$facet/$facet ||
7805 error "failed to zfs set for $facet (1)"
7806 $rcmd zfs mount lustre-$facet/$facet ||
7807 error "failed to local mount $facet"
7808 $rcmd tar jxf $LUSTRE/tests/ldiskfs_${facet}_2_11.tar.bz2 \
7809 --xattrs --xattrs-include="trusted.*" \
7810 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7811 error "failed to untar image for $facet"
7812 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7813 error "failed to cleanup for $facet"
7814 $rcmd zfs umount lustre-$facet/$facet ||
7815 error "failed to local umount $facet"
7816 $rcmd zfs set canmount=off lustre-$facet/$facet ||
7817 error "failed to zfs set $facet (2)"
7820 echo "changing server nid..."
7821 $rcmd mount -t lustre -o nosvc lustre-mdt1/mdt1 $tmp/mnt/mdt1
7822 $rcmd lctl replace_nids lustre-MDT0000 $nid
7823 $rcmd lctl replace_nids lustre-MDT0001 $nid
7824 $rcmd lctl replace_nids lustre-OST0000 $nid
7825 $rcmd lctl replace_nids lustre-OST0001 $nid
7826 $rcmd umount $tmp/mnt/mdt1
7828 for facet in $facets; do
7829 echo "mounting $facet from backup..."
7830 $rcmd mount -t lustre -o abort_recov lustre-$facet/$facet \
7831 $tmp/mnt/$facet || error "failed to mount $facet"
7834 # ZFS backend can detect migration and trigger OI scrub automatically
7835 # sleep 3 seconds for scrub done
7841 run_test 108a "migrate from ldiskfs to ZFS"
7844 [ "$CLIENTONLY" ] && skip "Client-only testing" && return
7846 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
7847 skip "ldiskfs only test" && return
7849 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
7850 skip "Need server version at least 2.10.58" && return
7855 local tmp=$TMP/$tdir
7856 local rcmd="do_facet $SINGLEMDS"
7857 local facets="mdt1 mdt2 ost1 ost2"
7858 local scrub_list="MDT0000 MDT0001 OST0000 OST0001"
7859 local nid=$($rcmd $LCTL list_nids | head -1)
7862 trap t_108_cleanup EXIT ERR
7865 t_108_mkfs mdt 0 ldiskfs mgs
7866 t_108_mkfs mdt 1 ldiskfs mgsnode=$nid
7867 t_108_mkfs ost 0 ldiskfs mgsnode=$nid
7868 t_108_mkfs ost 1 ldiskfs mgsnode=$nid
7870 for facet in $facets; do
7871 $rcmd mount -t ldiskfs -o loop $tmp/images/$facet \
7873 error "failed to local mount $facet"
7875 $rcmd tar jxf $LUSTRE/tests/zfs_${facet}_2_11.tar.bz2 \
7876 --xattrs --xattrs-include="*.*" \
7877 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7878 error "failed to untar image for $facet"
7879 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7880 error "failed to cleanup for $facet"
7881 $rcmd umount $tmp/mnt/$facet ||
7882 error "failed to local umount $facet"
7885 echo "changing server nid..."
7886 $rcmd mount -t lustre -o nosvc,loop $tmp/images/mdt1 $tmp/mnt/mdt1
7887 $rcmd lctl replace_nids lustre-MDT0000 $nid
7888 $rcmd lctl replace_nids lustre-MDT0001 $nid
7889 $rcmd lctl replace_nids lustre-OST0000 $nid
7890 $rcmd lctl replace_nids lustre-OST0001 $nid
7891 $rcmd umount $tmp/mnt/mdt1
7893 for facet in $facets; do
7894 echo "mounting $facet from backup..."
7895 $rcmd mount -t lustre -o loop,abort_recov $tmp/images/$facet \
7896 $tmp/mnt/$facet || error "failed to mount $facet"
7899 for facet in $scrub_list; do
7900 $rcmd $LCTL lfsck_start -M lustre-$facet -t scrub ||
7901 error "failed to start OI scrub on $facet"
7904 # sleep 3 seconds for scrub done
7910 run_test 108b "migrate from ZFS to ldiskfs"
7914 # set number of permanent parameters
7916 test_109_set_params() {
7919 set_persistent_param_and_check mds \
7920 "mdd.$fsname-MDT0000.atime_diff" \
7921 "$fsname-MDT0000.mdd.atime_diff" \
7923 set_persistent_param_and_check mds \
7924 "mdd.$fsname-MDT0000.atime_diff" \
7925 "$fsname-MDT0000.mdd.atime_diff" \
7927 set_persistent_param_and_check client \
7928 "llite.$fsname*.max_read_ahead_mb" \
7929 "$fsname.llite.max_read_ahead_mb" \
7931 set_persistent_param_and_check client \
7932 "llite.$fsname*.max_read_ahead_mb" \
7933 "$fsname.llite.max_read_ahead_mb" \
7935 create_pool $fsname.pool1 || error "create pool failed"
7936 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
7937 error "pool_add failed"
7938 do_facet mgs $LCTL pool_remove $fsname.pool1 OST0000 ||
7939 error "pool_remove failed"
7940 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
7941 error "pool_add failed"
7945 # check permanent parameters
7947 test_109_test_params() {
7950 local atime_diff=$(do_facet mds $LCTL \
7951 get_param -n mdd.$fsname-MDT0000.atime_diff)
7952 [ $atime_diff == 63 ] || error "wrong mdd parameter after clear_conf"
7953 local max_read_ahead_mb=$(do_facet client $LCTL \
7954 get_param -n llite.$fsname*.max_read_ahead_mb)
7955 [ $max_read_ahead_mb == 64 ] ||
7956 error "wrong llite parameter after clear_conf"
7957 local ost_in_pool=$(do_facet mds $LCTL pool_list $fsname.pool1 |
7958 grep -v "^Pool:" | sed 's/_UUID//')
7959 [ $ost_in_pool = "$fsname-OST0000" ] ||
7960 error "wrong pool after clear_conf"
7964 # run lctl clear_conf, store CONFIGS before and after that
7966 test_109_clear_conf()
7968 local clear_conf_arg=$1
7971 if ! combined_mgs_mds ; then
7973 stop_mgs || error "stop_mgs failed"
7974 start_mgs "-o nosvc" || error "start_mgs nosvc failed"
7976 mgsdev=$(mdsdevname 1)
7977 start_mdt 1 "-o nosvc" || error "start_mdt 1 nosvc failed"
7980 do_facet mgs "rm -rf $TMP/${tdir}/conf1; mkdir -p $TMP/${tdir}/conf1;" \
7981 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf1\\\" \
7985 # the command being tested
7987 do_facet mgs $LCTL clear_conf $clear_conf_arg ||
7988 error "clear_conf failed"
7989 if ! combined_mgs_mds ; then
7990 stop_mgs || error "stop_mgs failed"
7992 stop_mdt 1 || error "stop_mdt 1 failed"
7995 do_facet mgs "rm -rf $TMP/${tdir}/conf2; mkdir -p $TMP/${tdir}/conf2;" \
7996 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf2\\\" \
8000 test_109_file_shortened() {
8002 local sizes=($(do_facet mgs "stat -c %s " \
8003 "$TMP/${tdir}/conf1/CONFIGS/$file" \
8004 "$TMP/${tdir}/conf2/CONFIGS/$file"))
8005 [ ${sizes[1]} -lt ${sizes[0]} ] && return 0
8011 [ "$(facet_fstype mgs)" == "zfs" ] &&
8012 skip "LU-8727: no implementation for ZFS" && return
8016 client_up || error "client_up failed"
8019 # set number of permanent parameters
8021 test_109_set_params $FSNAME
8023 umount_client $MOUNT || error "umount_client failed"
8024 stop_ost || error "stop_ost failed"
8025 stop_mds || error "stop_mds failed"
8027 test_109_clear_conf $FSNAME
8029 # make sure that all configs are cleared
8031 test_109_file_shortened $FSNAME-MDT0000 ||
8032 error "failed to clear MDT0000 config"
8033 test_109_file_shortened $FSNAME-client ||
8034 error "failed to clear client config"
8039 # check that configurations are intact
8041 test_109_test_params $FSNAME
8046 destroy_test_pools || error "destroy test pools failed"
8050 run_test 109a "test lctl clear_conf fsname"
8054 [ "$(facet_fstype mgs)" == "zfs" ] &&
8055 skip "LU-8727: no implementation for ZFS" && return
8059 client_up || error "client_up failed"
8062 # set number of permanent parameters
8064 test_109_set_params $FSNAME
8066 umount_client $MOUNT || error "umount_client failed"
8067 stop_ost || error "stop_ost failed"
8068 stop_mds || error "stop_mds failed"
8070 test_109_clear_conf $FSNAME-MDT0000
8072 # make sure that only one config is cleared
8074 test_109_file_shortened $FSNAME-MDT0000 ||
8075 error "failed to clear MDT0000 config"
8076 test_109_file_shortened $FSNAME-client &&
8077 error "failed to clear client config"
8082 # check that configurations are intact
8084 test_109_test_params $FSNAME
8089 destroy_test_pools || error "destroy test pools failed"
8093 run_test 109b "test lctl clear_conf one config"
8097 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
8098 skip "Only applicable to ldiskfs-based MDTs"
8100 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8101 skip "large_dir option is not supported on MDS"
8102 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8103 skip "large_dir option is not supported on OSS"
8105 stopall # stop all targets before modifying the target counts
8106 stack_trap "MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT" EXIT
8110 # ext4_dir_entry_2 struct size:264
8111 # dx_root struct size:8
8112 # dx_node struct size:8
8113 # dx_entry struct size:8
8114 # For 1024 bytes block size.
8115 # First level directory entries: 126
8116 # Second level directory entries: 127
8117 # Entries in leaf: 3
8118 # For 2 levels limit: 48006
8119 # For 3 levels limit : 6096762
8120 # Create 80000 files to safely exceed 2-level htree limit.
8121 CONF_SANITY_110_LINKS=${CONF_SANITY_110_LINKS:-80000}
8123 # can fit at most 3 filenames per 1KB leaf block, but each
8124 # leaf/index block will only be 3/4 full before split at each level
8125 (( MDSSIZE < CONF_SANITY_110_LINKS / 3 * 4/3 * 4/3 )) &&
8126 CONF_SANITY_110_LINKS=$((MDSSIZE * 3 * 3/4 * 3/4))
8128 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8129 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8130 if [[ $opts != *mkfsoptions* ]]; then
8131 opts+=" --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536\\\""
8133 opts="${opts//--mkfsoptions=\\\"/ \
8134 --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536 }"
8136 echo "MDT params: $opts"
8137 add mds1 $opts || error "add mds1 failed with new params"
8138 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8140 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8141 --reformat $(ostdevname 1) $(ostvdevname 1)"
8143 if [[ $opts != *mkfsoptions* ]]; then
8144 opts+=" --mkfsoptions=\\\"-O large_dir\\\" "
8146 opts="${opts//--mkfsoptions=\\\"/ \
8147 --mkfsoptions=\\\"-O large_dir }"
8149 echo "OST params: $opts"
8150 add ost1 $opts || error "add ost1 failed with new params"
8151 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8153 MOUNT_2=yes mountcli || error "mount clients failed"
8155 mkdir -v $DIR/$tdir || error "cannot create $DIR/$tdir"
8156 local pids count=0 group=0
8158 echo "creating $CONF_SANITY_110_LINKS in total"
8159 while (( count < CONF_SANITY_110_LINKS )); do
8160 local len=$((253 - $(wc -c <<<"$tfile-$group-40000-")))
8161 local dir=DIR$((group % 2 + 1))
8162 local target=${!dir}/$tdir/$tfile-$group
8163 local long=$target-$(generate_name $len)-
8164 local create=$((CONF_SANITY_110_LINKS - count))
8166 (( create > 40000 )) && create=40000
8167 touch $target || error "creating $target failed"
8168 echo "creating $create hard links to $target"
8169 createmany -l $target $long $create &
8172 count=$((count + create))
8173 group=$((group + 1))
8175 echo "waiting for PIDs$pids to complete"
8176 wait $pids || error "createmany failed after $group groups"
8180 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8182 run_test 110 "Adding large_dir with 3-level htree"
8185 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
8186 skip "Only applicable to ldiskfs-based MDTs"
8188 is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
8189 skip "This test can not be executed on flakey dev"
8191 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8192 skip "large_dir option is not supported on MDS"
8194 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8195 skip "large_dir option is not supported on OSS"
8197 # cleanup before changing target counts
8199 stack_trap "MDSSIZE=$MDSSIZE MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT" EXIT
8202 (( MDSSIZE < 2400000 )) && MDSSIZE=2400000 # need at least 2.4GB
8204 local mdsdev=$(mdsdevname 1)
8206 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8207 --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8208 if [[ $opts != *mkfsoptions* ]]; then
8209 opts+=" --mkfsoptions=\\\"-O large_dir -i 1048576 \\\" "
8211 opts="${opts//--mkfsoptions=\\\"/ \
8212 --mkfsoptions=\\\"-O large_dir -i 1048576 }"
8214 echo "MDT params: $opts"
8215 __touch_device mds 1
8216 add mds1 $opts || error "add mds1 failed with new params"
8217 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8219 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8220 --reformat $(ostdevname 1) $(ostvdevname 1)"
8221 if [[ $opts != *mkfsoptions* ]]; then
8222 opts+=" --mkfsoptions=\\\"-O large_dir \\\""
8224 opts="${opts//--mkfsoptions=\\\"/ --mkfsoptions=\\\"-O large_dir }"
8226 echo "OST params: $opts"
8227 __touch_device ost 1
8228 add ost1 $opts || error "add ost1 failed with new params"
8229 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8231 MOUNT_2=yes mountcli
8232 mkdir $DIR/$tdir || error "cannot create $DIR/$tdir"
8234 lfs df -i $DIR/$tdir
8238 local start=$SECONDS
8240 local dirmax=$((2 << 30))
8246 while (( !needskip & dirsize < dirmax )); do
8249 for cli in ${CLIENTS//,/ }; do
8250 local len=$((253 - $(wc -c <<<"$cli-$group-60000-")))
8251 local target=$cli-$group
8252 local long=$DIR/$tdir/$target-$(generate_name $len)-
8254 RPWD=$DIR/$tdir do_node $cli touch $target ||
8255 error "creating $target failed"
8256 echo "creating 60000 hardlinks to $target"
8257 RPWD=$DIR/$tdir do_node $cli createmany -l $target $long 60000 &
8260 group=$((group + 1))
8262 long=$DIR2/$tdir/$target-$(generate_name $len)-
8264 RPWD=$DIR2/$tdir do_node $cli touch $target ||
8265 error "creating $target failed"
8266 echo "creating 60000 hardlinks to $target"
8267 RPWD=$DIR2/$tdir do_node $cli createmany -l $target $long 60000 &
8270 group=$((group + 1))
8272 echo "waiting for PIDs$pids to complete"
8273 wait $pids || error "createmany failed after $group groups"
8274 dirsize=$(stat -c %s $DIR/$tdir)
8275 taken=$((SECONDS - start))
8276 rate=$((dirsize / taken))
8277 left=$(((dirmax - dirsize) / rate))
8278 num=$((group * 60000))
8279 echo "estimate ${left}s left after $num files / ${taken}s"
8280 # if the estimated time remaining is too large (it may change
8281 # over time as the create rate is not constant) then exit
8282 # without declaring a failure.
8283 (( left > 1200 )) && needskip=1
8288 (( $needskip )) && skip "ETA ${left}s after $num files / ${taken}s is too long"
8290 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8292 run_test 111 "Adding large_dir with over 2GB directory"
8299 rm -f $TMP/$tdir/lustre-mdt
8304 IMAGESIZE=$((3072 << 30)) # 3072 GiB
8306 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
8307 skip "Only applicable to ldiskfs-based MDTs"
8312 # We need MDT size 3072GB, because it is smallest
8313 # partition that can store 2B inodes
8314 do_facet $SINGLEMDS "mkdir -p $TMP/$tdir"
8315 local mdsimgname=$TMP/$tdir/lustre-mdt
8316 do_facet $SINGLEMDS "rm -f $mdsimgname"
8317 do_facet $SINGLEMDS "touch $mdsimgname"
8318 trap cleanup_115 RETURN EXIT
8319 do_facet $SINGLEMDS "$TRUNCATE $mdsimgname $IMAGESIZE" ||
8320 { skip "Backend FS doesn't support sparse files"; return 0; }
8321 local mdsdev=$(do_facet $SINGLEMDS "losetup -f")
8322 do_facet $SINGLEMDS "losetup $mdsdev $mdsimgname"
8324 local mds_opts="$(mkfs_opts mds1 ${mdsdev}) --device-size=$IMAGESIZE \
8325 --mkfsoptions='-O lazy_itable_init,ea_inode,^resize_inode,meta_bg \
8327 add mds1 $mds_opts --mgs --reformat $mdsdev ||
8328 { skip_env "format large MDT failed"; return 0; }
8329 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
8330 --reformat $(ostdevname 1) $(ostvdevname 1)
8332 start $SINGLEMDS ${mdsdev} $MDS_MOUNT_OPTS || error "start MDS failed"
8333 start_ost || error "start OSS failed"
8334 mount_client $MOUNT || error "mount client failed"
8336 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir fail"
8337 for goal in $(do_facet $SINGLEMDS "ls /sys/fs/ldiskfs/*/inode_goal"); do
8338 do_facet $SINGLEMDS "echo 2147483947 >> $goal; grep . $goal"
8341 touch $DIR/$tdir/$tfile
8343 # Add > 5k bytes to xattr
8344 for i in {1..30}; do
8345 ln $DIR/$tdir/$tfile $DIR/$tdir/$(printf "link%0250d" $i) ||
8346 error "Can't make link"
8351 local inode_num=$(do_facet $SINGLEMDS \
8352 "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsimgname" |
8353 awk '/link =/ { print $4 }' |
8354 sed -e 's/>//' -e 's/<//' -e 's/\"//')
8355 echo "inode num: $inode_num"
8356 [ $inode_num -ge 2147483947 ] || error "inode $inode_num too small"
8357 do_facet $SINGLEMDS "losetup -d $mdsdev"
8360 run_test 115 "Access large xattr with inodes number over 2TB"
8363 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
8364 skip "ldiskfs only test" && return
8366 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.59) ] &&
8367 skip "Need server version at least 2.10.59" && return
8369 do_facet $SINGLEMDS which mkfs.xfs || {
8370 skip_env "No mkfs.xfs installed"
8377 local tmpmnt=$TMP/$tdir
8378 local mdtimg=$tfile-mdt0
8380 do_facet $SINGLEMDS mkdir -p $tmpmnt
8381 stack_trap "do_facet $SINGLEMDS rmdir $tmpmnt" EXIT
8383 do_facet $SINGLEMDS touch $TMP/$mdtimg
8384 stack_trap "do_facet $SINGLEMDS rm -f $TMP/$mdtimg" EXIT
8385 do_facet $SINGLEMDS mkfs -t xfs -d file,size=1t,name=$TMP/$mdtimg ||
8386 error "mkfs temporary xfs image"
8388 do_facet $SINGLEMDS mount $TMP/$mdtimg $tmpmnt ||
8389 error "mount temporary xfs image"
8390 stack_trap "do_facet $SINGLEMDS umount $tmpmnt" EXIT
8391 local old_mdssize=$MDSSIZE
8392 local old_mdsisize=$MDSISIZE
8394 MDSSIZE=$((17 * 1024 * 1024 * 1024)) # 17T MDT
8395 MDSISIZE=$((16 << 20))
8396 local opts17t="$(mkfs_opts $SINGLEMDS)"
8398 MDSSIZE=$old_mdssize
8399 MDSISIZE=$old_mdsisize
8400 do_facet $SINGLEMDS $MKFS $opts17t $tmpmnt/$mdtimg ||
8401 error "failed to mkfs for $tmpmnt/$mdtimg"
8403 do_facet $SINGLEMDS $TUNE2FS -l $tmpmnt/$mdtimg |
8404 grep -qw 'features.*extent' || error "extent should be enabled"
8406 run_test 116 "big size MDT support"
8410 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.nrs_policies=fifo"
8411 do_facet ost1 "$LCTL get_param -n ost.OSS.ost_io.nrs_tbf_rule" &&
8412 error "get_param should fail"
8413 cleanup || error "cleanup failed with rc $?"
8415 run_test 117 "lctl get_param return errors properly"
8417 test_120() { # LU-11130
8418 [ "$MDSCOUNT" -lt 2 ] && skip "mdt count < 2"
8419 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
8420 skip "ldiskfs only test"
8421 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
8422 skip "Need DNE2 capable MD target with LU-11130 fix"
8426 local mds1host=$(facet_active_host mds1)
8427 local mds1dev=$(mdsdevname 1)
8429 $LFS mkdir -i 1 $DIR/$tdir
8430 $LFS mkdir -i 0 $DIR/$tdir/mds1dir
8432 ln -s foo $DIR/$tdir/bar
8433 mv $DIR/$tdir/bar $DIR/$tdir/mds1dir/bar2 ||
8434 error "cross-target rename failed"
8438 run_e2fsck $mds1host $mds1dev "-n"
8440 run_test 120 "cross-target rename should not create bad symlinks"
8443 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
8444 [[ $(lustre_version_code ost1) -ge $(version_code 2.11.53) ]] ||
8445 { skip "Need OST version at least 2.11.53" && return 0; }
8449 LOAD_MODULES_REMOTE=true load_modules
8450 #define OBD_FAIL_OFD_SET_OID 0x1e0
8451 do_facet ost1 $LCTL set_param fail_loc=0x00001e0
8454 $LFS mkdir -i1 -c1 $DIR/$tdir
8455 $LFS setstripe -i0 -c1 $DIR/$tdir
8456 do_facet ost1 $LCTL set_param fail_loc=0
8457 createmany -o $DIR/$tdir/file_ 1000 ||
8458 error "Fail to create a new sequence"
8462 run_test 122 "Check OST sequence update"
8465 remote_mgs_nodsh && skip "remote MGS with nodsh"
8466 [ -d $MOUNT/.lustre ] || setupall
8468 # test old logid format until removal from llog_ioctl.c::str2logid()
8469 if [ $MGS_VERSION -lt $(version_code 3.1.53) ]; then
8470 do_facet mgs $LCTL dl | grep MGS
8471 do_facet mgs "$LCTL --device %MGS llog_print \
8472 \\\\\\\$$FSNAME-client 1 10" ||
8473 error "old llog_print failed"
8476 # test new logid format
8477 if [ $MGS_VERSION -ge $(version_code 2.9.53) ]; then
8478 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
8479 error "new llog_print failed"
8482 run_test 123aa "llog_print works with FIDs and simple names"
8485 remote_mgs_nodsh && skip "remote MGS with nodsh"
8486 [[ $MGS_VERSION -gt $(version_code 2.11.51) ]] ||
8487 skip "Need server with working llog_print support"
8489 [ -d $MOUNT/.lustre ] || setupall
8494 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
8495 do_facet mgs $LCTL set_param -P jobid_name="testname"
8497 yaml=$(do_facet mgs $LCTL --device MGS llog_print params |
8498 grep jobid_name | tail -n 1)
8500 local param=$(awk '{ print $10 }' <<< "$yaml")
8501 local val=$(awk '{ print $12 }' <<< "$yaml")
8502 #return to the default
8503 do_facet mgs $LCTL set_param -P jobid_name=$orig_val
8504 [ $val = "testname" ] || error "bad value: $val"
8505 [ $param = "jobid_name," ] || error "Bad param: $param"
8507 run_test 123ab "llog_print params output values from set_param -P"
8509 test_123ac() { # LU-11566
8510 remote_mgs_nodsh && skip "remote MGS with nodsh"
8511 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8512 skip "Need 'lctl llog_print --start' on MGS"
8517 [ -d $MOUNT/.lustre ] || setupall
8519 # - { index: 10, event: add_uuid, nid: 192.168.20.1@tcp(0x20000c0a81401,
8520 # node: 192.168.20.1@tcp }
8521 do_facet mgs $LCTL --device MGS \
8522 llog_print --start $start --end $end $FSNAME-client | tr -d , |
8523 while read DASH BRACE INDEX idx EVENT BLAH BLAH BLAH; do
8524 (( idx >= start )) || error "llog_print index $idx < $start"
8525 (( idx <= end )) || error "llog_print index $idx > $end"
8528 run_test 123ac "llog_print with --start and --end"
8530 test_123ad() { # LU-11566
8531 remote_mgs_nodsh && skip "remote MGS with nodsh"
8532 # older versions of lctl may not print all records properly
8533 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8534 skip "Need 'lctl llog_print --start' on MGS"
8536 [ -d $MOUNT/.lustre ] || setupall
8538 # append a new record, to avoid issues if last record was cancelled
8539 local old=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
8540 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$old
8542 # logid: [0x3:0xa:0x0]:0
8546 local num=$(do_facet mgs $LCTL --device MGS llog_info $FSNAME-client |
8547 awk '/last_index:/ { print $2 - 1 }')
8549 # - { index: 71, event: set_timeout, num: 0x14, param: sys.timeout=20 }
8550 local last=$(do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
8551 tail -1 | awk '{ print $4 }' | tr -d , )
8552 (( last == num )) || error "llog_print only showed $last/$num records"
8554 run_test 123ad "llog_print shows all records"
8558 local yaml_file="$TMP/$tfile.yaml"
8559 do_facet mgs rm "$yaml_file"
8560 local cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist" |
8561 sed 's/config_log://')
8563 # set jobid_var to a different value for test
8564 local orig_val=$(do_facet mgs $LCTL get_param jobid_var)
8565 do_facet mgs $LCTL set_param -P jobid_var="testname"
8567 for i in $cfgfiles params; do
8568 do_facet mgs "lctl --device MGS llog_print ${i} >> $yaml_file"
8571 echo "Unmounting FS"
8581 # Reapply the config from before
8582 echo "Setting configuration parameters"
8583 do_facet mgs "lctl set_param -F $yaml_file"
8585 local set_val=$(do_facet mgs $LCTL get_param jobid_var)
8586 do_facet mgs $LCTL set_param -P $orig_val
8588 [ $set_val == "jobid_var=testname" ] ||
8589 error "$set_val is not testname"
8591 do_facet mgs rm "$yaml_file"
8593 run_test 123F "clear and reset all parameters using set_param -F"
8597 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
8598 [ -z $mds2failover_HOST ] && skip "needs MDT failover setup" && return
8604 if combined_mgs_mds; then
8605 start_mdt 1 "-o nosvc" ||
8606 error "starting mds with nosvc option failed"
8608 local nid=$(do_facet mds2 $LCTL list_nids | head -1)
8609 local failover_nid=$(do_node $mds2failover_HOST $LCTL list_nids | head -1)
8610 do_facet mgs $LCTL replace_nids $FSNAME-MDT0001 $nid:$failover_nid ||
8611 error "replace_nids execution error"
8613 if combined_mgs_mds; then
8619 echo "lfs setdirstripe"
8620 $LFS setdirstripe -i 1 $MOUNT/$tdir || error "setdirstirpe error"
8623 run_test 124 "check failover after replace_nids"
8625 if ! combined_mgs_mds ; then
8631 # restore the values of MDSSIZE and OSTSIZE
8632 MDSSIZE=$STORED_MDSSIZE
8633 OSTSIZE=$STORED_OSTSIZE
8637 check_and_cleanup_lustre