8 PTLDEBUG=${PTLDEBUG:--1}
9 LUSTRE=${LUSTRE:-$(dirname $0)/..}
10 . $LUSTRE/tests/test-framework.sh
14 # tool to create lustre filesystem images
15 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 32newtarball"
17 # bug number for skipped test: LU-11915
18 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 110"
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
22 # bug number for skipped tests: LU-9795 (all below)
23 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 0 31 32a 32d 35a"
24 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 53a 53b 54b 76a 76b"
25 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76c 76d 78 103"
28 if ! combined_mgs_mds; then
29 # bug number for skipped test: LU-11991 LU-11990
30 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 32a 32b 32c 32d 32e 66"
31 # bug number for skipped test: LU-9897 LU-12032
32 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 84 123F"
36 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69 106 111"
40 # use small MDS + OST size to speed formatting time
41 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
42 # STORED_MDSSIZE is used in test_18
43 STORED_MDSSIZE=$MDSSIZE
44 STORED_OSTSIZE=$OSTSIZE
46 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && MDSSIZE=400000
48 [ $(facet_fstype ost1) = "zfs" ] && OSTSIZE=400000
58 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
59 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
60 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
64 require_dsh_mds || exit 0
65 require_dsh_ost || exit 0
70 # The MGS must be started before the OSTs for a new fs, so start
71 # and stop to generate the startup logs.
74 wait_osc_import_state mds ost FULL
79 reformat_and_config() {
81 if ! combined_mgs_mds ; then
87 writeconf_or_reformat() {
88 # There are at most 2 OSTs for write_conf test
89 # who knows if/where $TUNEFS is installed?
90 # Better reformat if it fails...
91 writeconf_all $MDSCOUNT 2 ||
92 { echo "tunefs failed, reformatting instead" &&
93 reformat_and_config && return 0; }
102 echo "start mgs service on $(facet_active_host mgs)"
103 start mgs $(mgsdevname) $MGS_MOUNT_OPTS $@
109 local dev=$(mdsdevname $num)
112 echo "start mds service on `facet_active_host $facet`"
113 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
119 local dev=$(mdsdevname $num)
122 echo "stop mds service on `facet_active_host $facet`"
123 # These tests all use non-failover stop
124 stop $facet -f || return 97
130 for num in $(seq $MDSCOUNT); do
131 start_mdt $num $@ || return 94
136 if ! combined_mgs_mds ; then
144 for num in $(seq $MDSCOUNT); do
145 stop_mdt $num || return 97
150 echo "stop mgs service on `facet_active_host mgs`"
151 # These tests all use non-failover stop
152 stop mgs -f || return 97
156 echo "start ost1 service on `facet_active_host ost1`"
157 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
161 echo "stop ost1 service on `facet_active_host ost1`"
162 # These tests all use non-failover stop
163 stop ost1 -f || return 98
167 echo "start ost2 service on `facet_active_host ost2`"
168 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
172 echo "stop ost2 service on `facet_active_host ost2`"
173 # These tests all use non-failover stop
174 stop ost2 -f || return 93
179 echo "mount $FSNAME on ${MOUNTPATH}....."
180 zconf_mount $(hostname) $MOUNTPATH || return 96
184 local mountopt="remount,$1"
186 echo "remount '$1' lustre on ${MOUNTPATH}....."
187 zconf_mount $(hostname) $MOUNTPATH "$mountopt" || return 96
193 echo "umount lustre on $mountpath....."
194 zconf_umount $HOSTNAME $mountpath $@ || return 97
197 manual_umount_client(){
200 echo "manual umount lustre on ${MOUNT}...."
201 do_facet client "umount ${FORCE} $MOUNT"
207 start_mds || error "MDT start failed"
208 start_ost || error "Unable to start OST1"
209 mount_client $MOUNT || error "client start failed"
210 client_up || error "client_up failed"
219 unload_modules_conf () {
220 if combined_mgs_mds || ! local_mode; then
221 unload_modules || return 1
226 stop_ost || return 202
227 stop_mds || return 201
228 unload_modules_conf || return 203
233 [ "x$1" != "x" ] && force='-f'
234 umount_client $MOUNT $force|| return 200
235 cleanup_nocli || return $?
240 echo "umount $MOUNT2 ..."
241 umount $MOUNT2 || true
242 echo "stopping fs2mds ..."
243 stop fs2mds -f || true
244 echo "stopping fs2ost ..."
245 stop fs2ost -f || true
249 do_facet client "cp /etc/passwd $DIR/a" || return 71
250 do_facet client "rm $DIR/a" || return 72
251 # make sure lustre is actually mounted (touch will block,
252 # but grep won't, so do it after)
253 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
254 echo "setup single mount lustre success"
258 do_facet client "touch $DIR/a" || return 71
259 do_facet client "rm $DIR/a" || return 72
260 do_facet client "touch $DIR2/a" || return 73
261 do_facet client "rm $DIR2/a" || return 74
262 echo "setup double mount lustre success"
266 cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
269 if [ "$ONLY" == "setup" ]; then
274 if [ "$ONLY" == "cleanup" ]; then
281 #create single point mountpoint
287 check_mount || error "check_mount failed"
288 cleanup || error "cleanup failed with $?"
290 run_test 0 "single mount setup"
293 start_mds || error "MDS start failed"
294 start_ost || error "unable to start OST"
295 echo "start ost second time..."
296 start_ost && error "2nd OST start should fail"
297 mount_client $MOUNT || error "client start failed"
298 check_mount || error "check_mount failed"
299 cleanup || error "cleanup failed with $?"
301 run_test 1 "start up ost twice (should return errors)"
304 start_mds || error "MDT start failed"
305 echo "start mds second time.."
306 start_mds && error "2nd MDT start should fail"
307 start_ost || error "OST start failed"
308 mount_client $MOUNT || error "mount_client failed to start client"
309 check_mount || error "check_mount failed"
310 cleanup || error "cleanup failed with $?"
312 run_test 2 "start up mds twice (should return err)"
316 #mount.lustre returns an error if already in mtab
317 mount_client $MOUNT && error "2nd client mount should fail"
318 check_mount || error "check_mount failed"
319 cleanup || error "cleanup failed with $?"
321 run_test 3 "mount client twice (should return err)"
325 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
326 stop_ost || error "Unable to stop OST1"
327 umount_client $MOUNT -f || error “unmount $MOUNT failed”
330 # ok for ost to fail shutdown
331 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
332 error "cleanup failed with $?"
335 run_test 4 "force cleanup ost, then cleanup"
337 test_5a() { # was test_5
339 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
340 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
342 stop_mds || error "Unable to stop MDS"
344 # cleanup may return an error from the failed
345 # disconnects; for now I'll consider this successful
346 # if all the modules have unloaded.
350 echo "killing umount"
351 kill -TERM $UMOUNT_PID
352 echo "waiting for umount to finish"
354 if grep " $MOUNT " /proc/mounts; then
355 echo "test 5: /proc/mounts after failed umount"
359 echo "killing umount"
360 kill -TERM $UMOUNT_PID
361 echo "waiting for umount to finish"
363 grep " $MOUNT " /proc/mounts &&
364 error "/proc/mounts after second umount"
367 # manual_mount_client may fail due to umount succeeding above
369 # stop_mds is a no-op here, and should not fail
370 cleanup_nocli || error "cleanup_nocli failed with $?"
371 # df may have lingering entry
373 # mtab may have lingering entry
377 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
379 grep -q $MOUNT" " /etc/mtab || break
380 echo "Waiting /etc/mtab updated ... "
381 WAIT=$(( WAIT + sleep))
383 [ "$WAIT" -eq "$MAX_WAIT" ] &&
384 error "/etc/mtab is not updated in $WAIT secs"
385 echo "/etc/mtab updated in $WAIT secs"
387 run_test 5a "force cleanup mds, then cleanup"
395 grep " $MOUNT " /etc/mtab &&
396 error false "unexpected entry in mtab before mount" && return 10
398 start_ost || error "OST start failed"
399 if ! combined_mgs_mds ; then
400 trap cleanup_5b EXIT ERR
401 start_mds || error "MDS start failed"
405 mount_client $MOUNT && error "mount_client $MOUNT should fail"
406 grep " $MOUNT " /etc/mtab &&
407 error "$MOUNT entry in mtab after failed mount"
409 # stop_mds is a no-op here, and should not fail
410 cleanup_nocli || error "cleanup_nocli failed with $?"
411 if ! combined_mgs_mds ; then
415 run_test 5b "Try to start a client with no MGS (should return errs)"
418 grep " $MOUNT " /etc/mtab &&
419 error false "unexpected entry in mtab before mount" && return 10
421 start_mds || error "MDS start failed"
422 start_ost || error "OST start failed"
423 local oldfs="${FSNAME}"
424 FSNAME="wrong.${FSNAME}"
425 mount_client $MOUNT || :
427 grep " $MOUNT " /etc/mtab &&
428 error "$MOUNT entry in mtab after failed mount"
430 cleanup_nocli || error "cleanup_nocli failed with $?"
432 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
435 grep " $MOUNT " /etc/mtab &&
436 error "unexpected entry in mtab before mount"
438 start_ost || error "OST start failed"
439 start_mds || error "MDS start failed"
440 stop_ost -f || error "Unable to stop OST1"
441 mount_client $MOUNT || error "mount_client $MOUNT failed"
442 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
443 cleanup_nocli || error "cleanup_nocli failed with $?"
444 ! grep " $MOUNT " /etc/mtab ||
445 error "$MOUNT entry in mtab after unmount"
447 run_test 5d "mount with ost down"
450 grep " $MOUNT " /etc/mtab &&
451 error false "unexpected entry in mtab before mount" && return 10
453 start_mds || error "MDS start failed"
454 start_ost || error "OST start failed"
456 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
457 do_facet client "$LCTL set_param fail_loc=0x80000506"
458 mount_client $MOUNT || echo "mount failed (not fatal)"
459 cleanup || error "cleanup failed with $?"
460 grep " $MOUNT " /etc/mtab &&
461 error "$MOUNT entry in mtab after unmount"
464 run_test 5e "delayed connect, don't crash (bug 10268)"
467 combined_mgs_mds && skip "needs separate mgs and mds"
469 grep " $MOUNT " /etc/mtab &&
470 error false "unexpected entry in mtab before mount" && return 10
473 start_ost || error "OST start failed"
474 mount_client $MOUNT &
476 echo client_mount pid is $pid
480 if ! ps -f -p $pid >/dev/null; then
483 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
484 error "mount returns $rc, expected to hang"
486 cleanup || error "cleanup failed with $?"
491 start_mds || error "start MDS failed"
493 # mount should succeed after start mds
495 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
496 cleanup || error "final call to cleanup failed with rc $?"
498 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
502 [ $(lustre_version_code client) -lt $(version_code 2.9.53) ] &&
503 skip "automount of debugfs missing before 2.9.53"
504 umount /sys/kernel/debug
505 $LCTL get_param -n devices | egrep -v "error" && \
506 error "lctl can't access debugfs data"
507 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
509 run_test 5g "handle missing debugfs"
515 #define OBD_FAIL_MDS_FS_SETUP 0x135
516 do_facet mds1 "$LCTL set_param fail_loc=0x80000135"
517 start_mdt 1 && error "start mdt should fail"
518 start_mdt 1 || error "start mdt failed"
519 client_up || error "client_up failed"
522 run_test 5h "start mdt failure at mdt_fs_setup()"
528 #define OBD_FAIL_QUOTA_INIT 0xA05
529 do_facet mds1 "$LCTL set_param fail_loc=0x80000A05"
530 start_mdt 1 && error "start mdt should fail"
531 start_mdt 1 || error "start mdt failed"
532 client_up || error "client_up failed"
535 run_test 5i "start mdt failure at mdt_quota_init()"
540 mount_client $MOUNT || error "mount_client $MOUNT failed"
541 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
542 cleanup || error "cleanup failed with rc $?"
544 run_test 6 "manual umount, then mount again"
549 cleanup_nocli || error "cleanup_nocli failed with $?"
551 run_test 7 "manual umount, then cleanup"
555 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
556 check_mount2 || error "check_mount2 failed"
557 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
558 cleanup || error "cleanup failed with rc $?"
560 run_test 8 "double mount setup"
563 start_ost || error "OST start failed"
565 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
566 error "do_facet ost1 set_param inode trace failed."
567 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
568 error "do_facet ost1 set_param debug mds ost failed."
570 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
571 if [ "$CHECK_PTLDEBUG" ] && { \
572 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
573 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
574 echo "lnet.debug success"
576 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
578 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
579 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
580 echo "lnet.subsystem_debug success"
582 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
584 stop_ost || error "Unable to stop OST1"
586 run_test 9 "test ptldebug and subsystem for mkfs"
589 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
590 # But with new MDS stack we don't care about the mode of local objects
591 # anymore, so this test is removed. See bug 22944 for more details.
595 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
596 skip "ldiskfs only test"
600 check_mount || error "check_mount failed"
601 cleanup || error "cleanup failed with rc $?"
603 echo "Remove mds config log"
604 if ! combined_mgs_mds ; then
608 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
609 $(mgsdevname) || return \$?" ||
610 error "do_facet mgs failed with $?"
612 if ! combined_mgs_mds ; then
616 start_ost || error "OST start failed"
617 start_mds && error "MDS start succeeded, but should fail"
620 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
623 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
624 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"
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 combined_mgs_mds && skip "need separate mgs device"
759 start_mgs || error "unable to start MGS"
760 start_ost || error "unable to start OST1"
761 start_ost2 || error "unable to start OST2"
762 start_mds || error "MDS start failed"
763 wait_osc_import_state mds ost2 FULL
765 stop_ost || error "Unable to stop OST1"
766 stop_ost2 || error "Unable to stop OST2"
767 stop_mds || error "Unable to stop MDS"
769 #writeconf to remove all ost2 traces for subsequent tests
770 writeconf_or_reformat
771 start_mgs || error "unable to start MGS"
773 run_test 21d "start mgs then ost and then mds"
776 MGSNID="$saved_mgsnid"
778 echo "stopping fs2mgs ..."
779 stop $fs2mgs -f || true
782 test_21e() { # LU-5863
783 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
784 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
785 skip_env "mixed loopback and real device not working"
788 local fs2mdsdev=$(mdsdevname 1_2)
789 local fs2ostdev=$(ostdevname 1_2)
790 local fs3ostdev=$(ostdevname 2_2)
792 local fs2mdsvdev=$(mdsvdevname 1_2)
793 local fs2ostvdev=$(ostvdevname 1_2)
794 local fs3ostvdev=$(ostvdevname 2_2)
796 # temporarily use fs3ost as fs2mgs
798 local fs2mgsdev=$fs3ostdev
799 local fs2mgsvdev=$fs3ostvdev
801 local fsname=test1234
803 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
804 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
805 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
806 error "start fs2mgs failed"
808 local saved_mgsnid="$MGSNID"
809 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
811 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
812 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
813 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
814 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
816 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
817 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
819 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
820 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
821 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
825 run_test 21e "separate MGS and MDS"
828 start_mds || error "MDS start failed"
830 echo "Client mount with ost in logs, but none running"
831 start_ost || error "unable to start OST1"
832 # wait until mds connected to ost and open client connection
833 wait_osc_import_state mds ost FULL
834 stop_ost || error "unable to stop OST1"
835 mount_client $MOUNT || error "mount_client $MOUNT failed"
836 # check_mount will block trying to contact ost
837 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
838 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
839 umount_client $MOUNT -f
842 echo "Client mount with a running ost"
843 start_ost || error "unable to start OST1"
845 # if gss enabled, wait full time to let connection from
846 # mds to ost be established, due to the mismatch between
847 # initial connect timeout and gss context negotiation timeout.
848 # This perhaps could be remove after AT landed.
849 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
850 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
852 mount_client $MOUNT || error "mount_client $MOUNT failed"
853 wait_osc_import_state mds ost FULL
854 wait_osc_import_ready client ost
855 check_mount || error "check_mount failed"
858 cleanup || error "cleanup failed with rc $?"
860 run_test 22 "start a client before osts (should return errs)"
862 test_23a() { # was test_23
865 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
866 # force down client so that recovering mds waits for reconnect
867 local running=$(grep -c $MOUNT /proc/mounts) || true
868 if [ $running -ne 0 ]; then
869 echo "Stopping client $MOUNT (opts: -f)"
873 # enter recovery on failed mds
874 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
875 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
876 # try to start a new client
877 mount_client $MOUNT &
879 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
880 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
881 grep -v grep | awk '{print $2}')
882 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
884 ps --ppid $MOUNT_LUSTRE_PID
885 echo "waiting for mount to finish"
887 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
888 # SIGTERM works but it does not spread to offspring processses
889 kill -s TERM $MOUNT_PID
890 kill -s TERM $MOUNT_LUSTRE_PID
891 # we can not wait $MOUNT_PID because it is not a child of this shell
897 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
899 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
900 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
903 [ -z "$PID1" -a -z "$PID2" ] && break
904 echo "waiting for mount to finish ... "
905 WAIT=$(( WAIT + sleep))
907 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
908 error "MOUNT_PID $MOUNT_PID and "\
909 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
912 cleanup || error "cleanup failed with rc $?"
914 run_test 23a "interrupt client during recovery mount delay"
916 test_23b() { # was test_23
917 start_mds || error "MDS start failed"
918 start_ost || error "Unable to start OST1"
919 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
920 $LCTL set_param fail_loc=0x80000313
922 cleanup || error "cleanup failed with rc $?"
924 run_test 23b "Simulate -EINTR during mount"
927 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
929 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
930 is_blkdev $SINGLEMDS $MDSDEV &&
931 skip_env "mixed loopback and real device not working"
934 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
936 local fs2mdsdev=$(mdsdevname 1_2)
937 local fs2ostdev=$(ostdevname 1_2)
938 local fs2mdsvdev=$(mdsvdevname 1_2)
939 local fs2ostvdev=$(ostvdevname 1_2)
942 # LU-9733 test fsname started with numbers as well
943 local FSNAME2=969362ae
945 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
946 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
948 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
949 --reformat $fs2ostdev $fs2ostvdev || exit 10
952 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
953 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
954 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
955 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
957 # LU-9733 test fsname started with numbers
958 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
959 changelog_register -n) ||
960 error "register changelog failed"
962 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
963 changelog_deregister $cl_user ||
964 error "deregister changelog failed"
966 check_mount || error "check_mount failed"
967 # files written on 1 should not show up on 2
968 cp /etc/passwd $DIR/$tfile
970 [ -e $MOUNT2/$tfile ] && error "File bleed"
973 cp /etc/passwd $MOUNT2/$tfile ||
974 error "cp /etc/passwd $MOUNT2/$tfile failed"
975 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
976 # 2 is actually mounted
977 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
979 facet_failover fs2mds
980 facet_failover fs2ost
983 # the MDS must remain up until last MDT
985 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
986 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
987 [ -z "$MDS" ] && error "No MDT"
989 cleanup_nocli || error "cleanup_nocli failed with rc $?"
991 run_test 24a "Multiple MDTs on a single node"
994 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
996 skip "needs combined MGT and MDT device"
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"
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 && {
1013 error "start MDS should fail"
1016 cleanup || error "cleanup failed with rc $?"
1018 run_test 24b "Multiple MGSs on a single node (should return err)"
1022 check_mount || error "check_mount failed"
1023 local MODULES=$($LCTL modules | awk '{ print $2 }')
1024 rmmod $MODULES 2>/dev/null || true
1025 cleanup || error "cleanup failed with $?"
1027 run_test 25 "Verify modules are referenced"
1031 # we need modules before mount for sysctl, so make sure...
1032 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1033 #define OBD_FAIL_MDS_FS_SETUP 0x135
1034 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1035 start_mds && error "MDS started but should not have started"
1036 $LCTL get_param -n devices
1037 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1038 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1039 # start mds to drop writeconf setting
1040 start_mds || error "Unable to start MDS"
1041 stop_mds || error "Unable to stop MDS"
1042 unload_modules_conf || error "unload_modules_conf failed with $?"
1044 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1048 start_ost || error "Unable to start OST1"
1049 start_mds || error "Unable to start MDS"
1050 echo "Requeue thread should have started: "
1051 ps -e | grep ll_cfg_requeue
1052 set_persistent_param_and_check ost1 \
1053 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1054 "$FSNAME-OST0000.ost.client_cache_seconds"
1055 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1057 run_test 27a "Reacquire MGS lock if OST started first"
1062 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1063 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1065 facet_failover $SINGLEMDS
1066 set_persistent_param_and_check $SINGLEMDS \
1067 "mdt.$device.identity_acquire_expire" \
1068 "$device.mdt.identity_acquire_expire"
1069 set_persistent_param_and_check client \
1070 "mdc.$device-mdc-*.max_rpcs_in_flight" \
1071 "$device.mdc.max_rpcs_in_flight"
1073 cleanup || error "cleanup failed with $?"
1075 run_test 27b "Reacquire MGS lock after failover"
1077 test_28A() { # was test_28
1080 local TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1081 local PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1082 local orig=$($LCTL get_param -n $TEST)
1083 local max=$($LCTL get_param -n \
1084 llite.$FSNAME-*.max_read_ahead_per_file_mb)
1086 orig=${orig%%.[0-9]*}
1088 echo "ORIG:$orig MAX:$max"
1089 [[ $max -le $orig ]] && orig=$((max - 3))
1090 echo "ORIG:$orig MAX:$max"
1092 local final=$((orig + 1))
1094 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1095 final=$((final + 1))
1096 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1097 umount_client $MOUNT || error "umount_client $MOUNT failed"
1098 mount_client $MOUNT || error "mount_client $MOUNT failed"
1100 local result=$($LCTL get_param -n $TEST)
1102 if [ $result -ne $final ]; then
1103 error "New config not seen: wanted $final got $result"
1105 echo "New config success: got $result"
1107 set_persistent_param_and_check client "$TEST" "$PARAM" $orig
1108 cleanup || error "cleanup failed with rc $?"
1110 run_test 28A "permanent parameter setting"
1112 test_28a() { # LU-4221
1113 [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
1114 skip "Need OST version at least 2.5.52"
1115 [ "$(facet_fstype ost1)" = "zfs" ] &&
1116 skip "LU-4221: no such proc params for ZFS OSTs"
1123 local device="$FSNAME-OST0000"
1127 # In this test we will set three kinds of proc parameters with
1128 # lctl set_param -P or lctl conf_param:
1129 # 1. non-symlink ones in the OFD
1130 # 2. non-symlink ones in the OSD
1133 # prepare a non-symlink parameter in the OFD
1134 name="client_cache_seconds"
1135 param="$device.ost.$name"
1136 cmd="obdfilter.$device.$name"
1138 # permanently setting the parameter in the OFD
1139 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1141 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1142 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1145 # prepare a non-symlink parameter in the OSD
1147 param="$device.osd.$name"
1148 cmd="osd-*.$device.$name"
1150 # conf_param the parameter in the OSD
1151 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1152 new=$(((old + 1) % 2))
1153 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1154 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1156 cleanup || error "cleanup failed with $?"
1158 run_test 28a "set symlink parameters permanently with lctl"
1161 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
1162 setup_noconfig > /dev/null 2>&1
1163 start_ost2 || error "Unable to start OST2"
1166 local PARAM="$FSNAME-OST0001.osc.active"
1167 # With lctl set_param -P the value $PROC_ACT will be sent to
1168 # all nodes. The [!M] filter out the ability to set active
1169 # on the MDS servers which is tested with wait_osp_* below.
1170 # For ost_server_uuid that only exist on client so filtering
1172 local PROC_ACT="os[cp].$FSNAME-OST0001-osc-[^M]*.active"
1173 local PROC_UUID="os[cp].$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1175 ACTV=$($LCTL get_param -n $PROC_ACT)
1177 set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
1178 # also check ost_server_uuid status
1179 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1180 if [ -z "$RESULT" ]; then
1181 error "Client not deactivated: $($LCTL get_param \
1184 echo "Live client success: got $RESULT"
1188 wait_osp_active ost ${FSNAME}-OST0001 1 0
1190 # test new client starts deactivated
1191 umount_client $MOUNT || error "umount_client $MOUNT failed"
1192 mount_client $MOUNT || error "mount_client $MOUNT failed"
1194 # the 2nd and 3rd field of ost_server_uuid do not update at the same
1195 # time when using lctl set_param -P
1196 wait_update_facet client \
1197 "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'" \
1199 error "New client start active: $($LCTL get_param -n $PROC_UUID)"
1201 echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
1203 # make sure it reactivates
1204 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1206 umount_client $MOUNT
1207 stop_ost2 || error "Unable to stop OST2"
1208 cleanup_nocli || error "cleanup_nocli failed with $?"
1209 #writeconf to remove all ost2 traces for subsequent tests
1210 writeconf_or_reformat
1212 run_test 29 "permanently remove an OST"
1217 echo Big config llog
1218 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1219 ORIG=$($LCTL get_param -n $TEST)
1220 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1221 for i in ${LIST[@]}; do
1222 set_persistent_param_and_check client "$TEST" \
1223 "$FSNAME.llite.max_read_ahead_whole_mb" $i
1225 # make sure client restart still works
1226 umount_client $MOUNT
1227 mount_client $MOUNT || error "mount_client $MOUNT failed"
1228 [ "$($LCTL get_param -n $TEST)" -ne "$i" ] &&
1229 error "Param didn't stick across restart $($TEST) != $i"
1232 echo Erase parameter setting
1233 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1234 do_facet mgs "$PERM_CMD -d $TEST" ||
1235 error "Erase param $TEST failed"
1237 do_facet mgs "$PERM_CMD \
1238 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1239 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1241 umount_client $MOUNT
1242 mount_client $MOUNT || error "mount_client $MOUNT failed"
1243 FINAL=$($LCTL get_param -n $TEST)
1244 echo "deleted (default) value=$FINAL, orig=$ORIG"
1245 ORIG=${ORIG%%.[0-9]*}
1246 FINAL=${FINAL%%.[0-9]*}
1247 # assumes this parameter started at the default value
1248 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1250 cleanup || error "cleanup failed with rc $?"
1252 run_test 30a "Big config llog and permanent parameter deletion"
1257 local orignids=$($LCTL get_param -n \
1258 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1260 local orignidcount=$(echo "$orignids" | wc -w)
1262 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1263 # numerical part of it. Hopefully that's not already a failover address
1265 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1267 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1268 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1269 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1270 echo "Using fake nid $NEW"
1272 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1273 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1274 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1275 PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
1276 echo "Setting $PARAM from $TEST to $NEW"
1277 do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
1278 error "$PERM_CMD $PARAM failed"
1280 PARAM="$FSNAME-OST0000.failover.node"
1281 echo "Setting $PARAM from $TEST to $NEW"
1282 do_facet mgs "$PERM_CMD $PARAM='$NEW'" ||
1283 error "$PARAM $PARAM failed"
1285 wait_update_facet client "$TEST" "$NEW" ||
1286 error "check $PARAM failed!"
1288 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1290 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1291 echo "should have $((orignidcount + 1)) entries \
1292 in failover nids string, have $NIDCOUNT"
1293 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1294 error "Failover nid not added"
1296 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1297 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1299 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1300 error "$PERM_CMD delete failed"
1302 umount_client $MOUNT
1303 mount_client $MOUNT || error "mount_client $MOUNT failed"
1305 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1307 NIDCOUNT=$(echo "$NIDS" | wc -w)
1308 echo "only $orignidcount final entries should remain \
1309 in failover nids string, have $NIDCOUNT"
1310 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1312 cleanup || error "cleanup failed with rc $?"
1314 run_test 30b "Remove failover nids"
1316 test_31() { # bug 10734
1317 # ipaddr must not exist
1318 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1319 cleanup || error "cleanup failed with rc $?"
1321 run_test 31 "Connect to non-existent node (shouldn't crash)"
1325 T32_BLIMIT=40960 # Kbytes
1329 # This is not really a test but a tool to create new disk
1330 # image tarballs for the upgrade tests.
1332 # Disk image tarballs should be created on single-node
1333 # clusters by running this test with default configurations
1334 # plus a few mandatory environment settings that are verified
1335 # at the beginning of the test.
1337 test_32newtarball() {
1341 local tmp=$TMP/t32_image_create
1342 local server_version=$(lustre_version_code $SINGLEMDS)
1347 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1348 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1349 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1350 "MDSDEV1=<nonexistent_file>" \
1351 "MDSDEV2=<nonexistent_file>" \
1352 "(or MDSDEV, in the case of b1_8)" \
1353 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1357 echo "Found stale $tmp"
1361 mkdir $tmp/src || return 1
1362 tar cf - -C $src . | tar xf - -C $tmp/src
1363 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1364 count=$(($T32_BLIMIT / 1024 / 4))
1365 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1367 # format ost with comma-separated NIDs to verify LU-4460
1368 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1369 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1373 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1374 $LFS quotacheck -ug /mnt/$FSNAME
1375 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1378 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1380 if [[ $MDSCOUNT -ge 2 ]]; then
1381 remote_dir=/mnt/$FSNAME/remote_dir
1382 $LFS mkdir -i 1 $remote_dir
1383 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1385 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1386 striped_dir=/mnt/$FSNAME/striped_dir_old
1387 $LFS mkdir -i 1 -c 2 $striped_dir
1388 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1394 mkdir $tmp/img || return 1
1398 pushd_dir=/mnt/$FSNAME
1399 if [[ $MDSCOUNT -ge 2 ]]; then
1400 pushd_dir=$remote_dir
1401 if [[ $server_version -ge $(version_code 2.7.0) ]]; then
1403 ls -Rni --time-style=+%s >$tmp/img/list2
1409 ls -Rni --time-style=+%s >$tmp/img/list
1410 find ! -name .lustre -type f -exec sha1sum {} \; |
1411 sort -k 2 >$tmp/img/sha1sums
1413 $LCTL get_param -n version | head -n 1 |
1414 sed -e 's/^lustre: *//' >$tmp/img/commit
1416 [[ $server_version -ge $(version_code 2.3.50) ]] ||
1417 $LFS quotaon -ug /mnt/$FSNAME
1418 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1419 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1420 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1421 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1422 | tr -d "*" > $tmp/img/bspace
1423 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1424 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1425 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1426 | tr -d "*" > $tmp/img/ispace
1427 echo $T32_BLIMIT > $tmp/img/blimit
1428 echo $T32_ILIMIT > $tmp/img/ilimit
1433 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1436 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1437 echo "Data verification failed"
1440 uname -r >$tmp/img/kernel
1441 uname -m >$tmp/img/arch
1443 mv ${MDSDEV1:-$MDSDEV} $tmp/img
1444 for num in $(seq 2 $MDSCOUNT); do
1445 local devname=$(mdsdevname $num)
1447 [[ $(facet_fstype $facet) != zfs ]] ||
1448 devname=$(mdsvdevname $num)
1449 mv $devname $tmp/img
1451 mv $OSTDEV1 $tmp/img
1453 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1454 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1457 tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
1462 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1465 # The list of applicable tarballs is returned via the caller's
1466 # variable "tarballs".
1469 [ "$CLIENTONLY" ] && skip "Client-only testing"
1471 local node=$(facet_active_host $SINGLEMDS)
1472 local r="do_node $node"
1474 ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
1476 local IMGTYPE=$(facet_fstype $SINGLEMDS)
1478 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1479 -name \'disk*-$IMGTYPE.tar.bz2\')
1481 [ -z "$tarballs" ] && skip "No applicable tarballs found"
1484 t32_test_cleanup() {
1486 local facet=$SINGLEMDS
1487 local fstype=$(facet_fstype $facet)
1490 if $shall_cleanup_lustre; then
1491 umount $tmp/mnt/lustre || rc=$?
1493 if $shall_cleanup_mdt; then
1494 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1496 if $shall_cleanup_mdt1; then
1497 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1499 if $shall_cleanup_ost; then
1500 $r $UMOUNT $tmp/mnt/ost || rc=$?
1505 if [[ $fstype == zfs ]]; then
1507 local poolname_list="t32fs-mdt1 t32fs-ost1"
1509 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1511 for poolname in $poolname_list; do
1512 destroy_zpool $facet $poolname
1515 combined_mgs_mds || start_mgs || rc=$?
1519 t32_bits_per_long() {
1521 # Yes, this is not meant to be perfect.
1531 t32_reload_modules() {
1533 local all_removed=false
1535 local fstype=$(facet_fstype $SINGLEMDS)
1537 [ $fstype == "zfs" ] && do_rpc_nodes $node "service zed stop"
1539 while ((i < 20)); do
1540 echo "Unloading modules on $node: Attempt $i"
1541 do_rpc_nodes $node $LUSTRE_RMMOD $fstype &&
1543 do_rpc_nodes $node check_mem_leak || return 1
1544 if $all_removed; then
1545 do_rpc_nodes $node load_modules
1548 if [ $fstype == "zfs" ]; then
1549 do_rpc_nodes $node "$ZPOOL status -v"
1554 echo "Unloading modules on $node: Given up"
1558 t32_wait_til_devices_gone() {
1564 echo wait for devices to go
1565 while ((i < 20)); do
1566 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1567 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1568 ((devices == 0 && loops == 0)) && return 0
1572 echo "waiting for dev on $node: dev $devices loop $loops given up"
1573 do_rpc_nodes $node "losetup -a"
1574 do_rpc_nodes $node "$LCTL device_list"
1578 t32_verify_quota() {
1582 local fstype=$(facet_fstype $SINGLEMDS)
1586 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1587 # lustre will estimate the object count usage. This fails quota
1588 # verification in 32b. The object quota usage should be accurate after
1589 # zfs-0.7.0 is released.
1590 [ $fstype == "zfs" ] && {
1591 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1593 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1594 echo "Skip quota verify for zfs: $zfs_version"
1599 $LFS quota -u $T32_QID -v $mnt
1601 qval=$($LFS quota -v -u $T32_QID $mnt |
1602 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1603 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1605 [ $qval -eq $img_bspace ] || {
1606 echo "bspace, act:$qval, exp:$img_bspace"
1610 qval=$($LFS quota -v -u $T32_QID $mnt |
1611 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1612 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1614 [ $qval -eq $img_ispace ] || {
1615 echo "ispace, act:$qval, exp:$img_ispace"
1619 qval=$($LFS quota -v -u $T32_QID $mnt |
1620 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1621 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1623 [ $qval -eq $img_blimit ] || {
1624 echo "blimit, act:$qval, exp:$img_blimit"
1628 qval=$($LFS quota -v -u $T32_QID $mnt |
1629 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1630 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1632 [ $qval -eq $img_ilimit ] || {
1633 echo "ilimit, act:$qval, exp:$img_ilimit"
1637 set_persistent_param_and_check $facet \
1638 "osd-$fstype.$fsname-MDT0000.quota_slave.enabled" \
1639 "$fsname.quota.mdt" ug
1641 set_persistent_param_and_check $facet \
1642 "osd-$fstype.$fsname-OST0000.quota_slave.enabled" \
1643 "$fsname.quota.ost" ug
1646 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1647 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1648 echo "Write succeed, but expect -EDQUOT"
1651 rm -f $mnt/t32_qf_new
1653 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1655 echo "Create succeed, but expect -EDQUOT"
1658 unlinkmany $mnt/t32_qf_ $img_ilimit
1666 local dne_upgrade=${dne_upgrade:-"no"}
1667 local dom_upgrade=${dom_upgrade:-"no"}
1668 local ff_convert=${ff_convert:-"no"}
1669 local shall_cleanup_mdt=false
1670 local shall_cleanup_mdt1=false
1671 local shall_cleanup_ost=false
1672 local shall_cleanup_lustre=false
1673 local mdt2_is_available=false
1674 local node=$(facet_active_host $SINGLEMDS)
1675 local r="do_node $node"
1691 local fstype=$(facet_fstype $SINGLEMDS)
1692 local mdt_dev=$tmp/mdt
1693 local mdt2_dev=$tmp/mdt2
1694 local ost_dev=$tmp/ost
1699 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1700 trap 'trap - RETURN; t32_test_cleanup' RETURN
1703 nid=$($r $LCTL list_nids | head -1)
1705 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1706 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1707 $r tar xjvf $tarball -S -C $tmp || {
1708 error_noexit "Unpacking the disk image tarball"
1711 img_commit=$($r cat $tmp/commit)
1712 img_kernel=$($r cat $tmp/kernel)
1713 img_arch=$($r cat $tmp/arch)
1714 img_bspace=$($r cat $tmp/bspace)
1715 img_ispace=$($r cat $tmp/ispace)
1717 # older images did not have "blimit" and "ilimit" files
1718 # use old values for T32_BLIMIT and T32_ILIMIT
1719 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1721 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1724 echo "Upgrading from $(basename $tarball), created with:"
1725 echo " Commit: $img_commit"
1726 echo " Kernel: $img_kernel"
1727 echo " Arch: $img_arch"
1728 echo "OST version: $(lustre_build_version ost1)"
1730 # The conversion can be made only when both of the following
1731 # conditions are satisfied:
1732 # - ost device img version < 2.3.64
1733 # - ost server version >= 2.5
1734 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1735 $(lustre_version_code ost1) -lt $(version_code 2.5.0) ] &&
1738 ! $r test -f $mdt2_dev || mdt2_is_available=true
1740 if [[ $fstype == zfs ]]; then
1743 local poolname_list="t32fs-mdt1 t32fs-ost1"
1745 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1747 for poolname in $poolname_list; do
1749 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1750 $ZPOOL import -f -d $tmp $poolname"
1753 # upgrade zpool to latest supported features, including
1754 # dnode quota accounting in 0.7.0
1755 $r "$ZPOOL upgrade -a"
1757 mdt_dev=t32fs-mdt1/mdt1
1758 ost_dev=t32fs-ost1/ost1
1759 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1760 wait_update_facet $SINGLEMDS "$ZPOOL list |
1761 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1762 error_noexit "import zfs pool failed"
1767 $r $LCTL set_param debug="$PTLDEBUG"
1769 $r $TUNEFS --dryrun $mdt_dev || {
1771 error_noexit "tunefs.lustre before mounting the MDT"
1775 if $mdt2_is_available; then
1776 $r $TUNEFS --dryrun $mdt2_dev || {
1778 error_noexit "tunefs.lustre before mounting the MDT"
1783 if [ "$writeconf" ]; then
1785 if [ $fstype == "ldiskfs" ]; then
1787 $r $TUNEFS --quota $mdt_dev || {
1789 error_noexit "Enable mdt quota feature"
1792 if $mdt2_is_available; then
1793 $r $TUNEFS --quota $mdt2_dev || {
1795 error_noexit "Enable mdt quota feature"
1801 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1802 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
1803 skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
1804 "(Need MGS version at least 2.3.59)"
1806 local osthost=$(facet_active_host ost1)
1807 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1810 if [ $fstype == "ldiskfs" ]; then
1813 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1814 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1815 $r $LCTL replace_nids $fsname-MDT0000 $nid
1816 $r $UMOUNT $tmp/mnt/mdt
1819 mopts=exclude=$fsname-OST0000
1820 if [ $fstype == "ldiskfs" ]; then
1825 t32_wait_til_devices_gone $node
1827 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1829 error_noexit "Mounting the MDT"
1832 shall_cleanup_mdt=true
1834 if $mdt2_is_available; then
1835 mopts=mgsnode=$nid,$mopts
1836 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1838 error_noexit "Mounting the MDT"
1842 echo "mount new MDT....$mdt2_dev"
1843 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1844 error_noexit "enable remote dir create failed"
1846 shall_cleanup_mdt1=true
1847 elif [ "$dne_upgrade" != "no" ]; then
1848 local fs2mdsdev=$(mdsdevname 1_2)
1849 local fs2mdsvdev=$(mdsvdevname 1_2)
1851 echo "mkfs new MDT on ${fs2mdsdev}...."
1852 if [ $(facet_fstype mds1) == ldiskfs ]; then
1853 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1856 add $SINGLEMDS $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1857 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1858 error_noexit "Mkfs new MDT failed"
1862 [[ $(facet_fstype mds1) != zfs ]] || import_zpool mds1
1864 $r $TUNEFS --dryrun $fs2mdsdev || {
1865 error_noexit "tunefs.lustre before mounting the MDT"
1869 echo "mount new MDT....$fs2mdsdev"
1870 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1871 error_noexit "mount mdt1 failed"
1875 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1876 error_noexit "enable remote dir create failed"
1878 shall_cleanup_mdt1=true
1881 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1882 error_noexit "Getting MDT UUID"
1885 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1886 error_noexit "Unexpected MDT UUID: \"$uuid\""
1890 $r $TUNEFS --dryrun $ost_dev || {
1891 error_noexit "tunefs.lustre before mounting the OST"
1894 if [ "$writeconf" ]; then
1895 mopts=mgsnode=$nid,$writeconf
1896 if [ $fstype == "ldiskfs" ]; then
1898 $r $TUNEFS --quota $ost_dev || {
1900 error_noexit "Enable ost quota feature"
1906 if [ $fstype == "ldiskfs" ]; then
1911 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1912 error_noexit "Mounting the OST"
1915 shall_cleanup_ost=true
1917 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1918 error_noexit "Getting OST UUID"
1921 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1922 error_noexit "Unexpected OST UUID: \"$uuid\""
1926 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1927 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
1928 error_noexit "Setting OST \"failover.node\""
1931 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
1932 error_noexit "Setting MDT \"failover.node\""
1935 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
1936 error_noexit "Setting \"max_dirty_mb\""
1939 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
1940 error_noexit "Setting \"max_rpcs_in_flight\""
1943 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
1944 error_noexit "Setting \"lov.stripesize\""
1947 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
1948 error_noexit "Setting \"mdd.atime_diff\""
1952 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
1953 error_noexit "Setting OST \"failover.node\""
1957 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
1958 error_noexit "Setting MDT \"failover.node\""
1962 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
1963 error_noexit "Setting \"max_dirty_mb\""
1966 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1967 error_noexit "Setting \"max_rpcs_in_flight\""
1970 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
1971 error_noexit "Setting \"lov.stripesize\""
1974 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
1975 error_noexit "Setting \"mdd.atime_diff\""
1980 $r $LCTL pool_new $fsname.interop || {
1981 error_noexit "Setting \"interop\""
1985 if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
1986 $r $LCTL lfsck_start -M $fsname-OST0000 || {
1987 error_noexit "Start OI scrub on OST0"
1991 # The oi_scrub should be on ost1, but for test_32(),
1992 # all on the SINGLEMDS.
1993 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
1994 osd-ldiskfs.$fsname-OST0000.oi_scrub |
1995 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
1996 error_noexit "Failed to get the expected 'completed'"
2000 local UPDATED=$($r $LCTL get_param -n \
2001 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2002 awk '/^updated/ { print $2 }')
2003 [ $UPDATED -ge 1 ] || {
2004 error_noexit "Only $UPDATED objects have been converted"
2009 if [ "$dne_upgrade" != "no" ]; then
2010 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2011 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
2012 error_noexit "Setting MDT1 \"failover.node\""
2016 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
2017 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2020 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
2021 error_noexit "Setting MDT1 \"lov.stripesize\""
2025 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
2026 error_noexit "Setting MDT1 \"failover.node\""
2029 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2030 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2033 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2034 error_noexit "Setting MDT1 \"lov.stripesize\""
2040 if [ "$writeconf" ]; then
2041 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2042 error_noexit "Mounting the client"
2046 shall_cleanup_lustre=true
2047 $r $LCTL set_param debug="$PTLDEBUG"
2049 # Leave re-enabling this to a separate patch for LU-11558
2050 # t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2051 # error_noexit "verify quota failed"
2055 if $r test -f $tmp/list; then
2057 # There is not a Test Framework API to copy files to or
2058 # from a remote node.
2060 # LU-2393 - do both sorts on same node to ensure locale
2062 local list_file=$tmp/list
2064 if $mdt2_is_available; then
2065 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2066 $r test -f $tmp/list2; then
2067 list_file=$tmp/list2
2068 pushd $tmp/mnt/lustre/striped_dir_old
2070 pushd $tmp/mnt/lustre/remote_dir
2073 pushd $tmp/mnt/lustre
2075 $r cat $list_file | sort -k 6 >$tmp/list.orig
2076 ls -Rni --time-style=+%s | sort -k 6 |
2077 sed 's/\. / /' >$tmp/list || {
2083 # 32-bit and 64-bit clients use different algorithms to
2084 # convert FIDs into inode numbers. Hence, remove the
2085 # inode numbers from the lists, if the original list was
2086 # created on an architecture with different number of
2089 if [ $(t32_bits_per_long $(uname -m)) != \
2090 $(t32_bits_per_long $img_arch) ]; then
2091 echo "Different number of bits per \"long\"" \
2092 "from the disk image"
2093 for list in list.orig list; do
2094 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2098 if ! diff -ub $tmp/list.orig $tmp/list; then
2099 error_noexit "list verification failed"
2103 echo "list verification skipped"
2106 if [ "$dom_upgrade" != "no" ]; then
2107 echo "Check DoM file can be created"
2108 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2109 error_noexit "Verify DoM creation"
2112 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2113 error_noexit "Verify a DoM file"
2116 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2117 count=1 conv=fsync || {
2118 error_noexit "Cannot write to DoM file"
2121 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2122 error_noexit "DoM: bad size after write"
2125 rm $tmp/mnt/lustre/dom
2127 set_persistent_param_and_check mds \
2128 "lod.*MDT0000*.dom_stripesize" \
2129 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2130 error_noexit "Changing \"dom_stripesize\""
2135 if [ "$dne_upgrade" != "no" ]; then
2136 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2137 error_noexit "set striped dir failed"
2141 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2143 pushd $tmp/mnt/lustre
2144 tar -cf - . --exclude=./striped_dir \
2145 --exclude=./striped_dir_old \
2146 --exclude=./remote_dir |
2147 tar -xvf - -C striped_dir 1>/dev/null || {
2148 error_noexit "cp to striped dir failed"
2154 # If it is upgrade from DNE (2.5), then rename the remote dir,
2155 # which is created in 2.5 to striped dir.
2156 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2157 stripe_index=$($LFS getdirstripe -i \
2158 $tmp/mnt/lustre/remote_dir)
2160 [[ $stripe_index -eq 1 ]] || {
2161 error_noexit "get index \"$stripe_index\"" \
2162 "from remote dir failed"
2165 mv $tmp/mnt/lustre/remote_dir \
2166 $tmp/mnt/lustre/striped_dir/ || {
2167 error_noexit "mv remote dir failed"
2172 # If it is upgraded from DNE (2.7), then move the striped dir
2173 # which was created in 2.7 to the new striped dir.
2174 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2175 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2176 stripe_count=$($LFS getdirstripe -c \
2177 $tmp/mnt/lustre/striped_dir_old)
2178 [[ $stripe_count -eq 2 ]] || {
2179 error_noexit "get count $stripe_count" \
2180 "from striped dir failed"
2183 mv $tmp/mnt/lustre/striped_dir_old \
2184 $tmp/mnt/lustre/striped_dir/ || {
2185 error_noexit "mv striped dir failed"
2191 $r $LCTL set_param -n osd*.*.force_sync=1
2192 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2193 error_noexit "dd failed"
2196 rm -rf $tmp/mnt/lustre/tmp_file || {
2197 error_noexit "rm failed"
2201 if $r test -f $tmp/sha1sums; then
2202 # LU-2393 - do both sorts on same node to ensure locale
2204 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2205 if [ "$dne_upgrade" != "no" ]; then
2206 pushd $tmp/mnt/lustre/striped_dir
2208 pushd $tmp/mnt/lustre
2211 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2212 ! -name .lustre -type f -exec sha1sum {} \; |
2213 sort -k 2 >$tmp/sha1sums || {
2215 error_noexit "sha1sum"
2219 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2220 error_noexit "sha1sum verification failed"
2224 # if upgrade from DNE(2.5), then check remote directory
2225 # if upgrade from DNE(2.7), then check striped directory
2226 if $mdt2_is_available &&
2227 [[ "$dne_upgrade" != "no" ]]; then
2228 local new_dir="$tmp/mnt/lustre/striped_dir"
2229 local striped_dir_old="$new_dir/striped_dir_old"
2231 local dir_list="$new_dir/remote_dir"
2232 [[ ! -d $triped_dir_old ]] ||
2233 dir_list+=" $striped_dir_old"
2235 for dir in $dir_list; do
2237 find ! -name .lustre -type f \
2238 -exec sha1sum {} \; |
2239 sort -k 2 >$tmp/sha1sums || {
2241 error_noexit "sha1sum"
2245 if ! diff -ub $tmp/sha1sums.orig \
2247 error_noexit "sha1sum $dir" \
2254 echo "sha1sum verification skipped"
2257 if [ "$dne_upgrade" != "no" ]; then
2258 rm -rf $tmp/mnt/lustre/striped_dir || {
2259 error_noexit "remove remote dir failed"
2264 # migrate files/dirs to remote MDT, then move them back
2265 if [ $(lustre_version_code mds1) -ge $(version_code 2.7.50) -a \
2266 $dne_upgrade != "no" ]; then
2267 $r $LCTL set_param -n \
2268 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2270 echo "test migration"
2271 pushd $tmp/mnt/lustre
2272 for dir in $(find ! -name .lustre ! -name . -type d); do
2273 mdt_index=$($LFS getdirstripe -i $dir)
2274 stripe_cnt=$($LFS getdirstripe -c $dir)
2275 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2276 $LFS migrate -m 1 $dir || {
2278 error_noexit "migrate MDT1 failed"
2284 for dir in $(find ! -name . ! -name .lustre -type d); do
2285 mdt_index=$($LFS getdirstripe -i $dir)
2286 stripe_cnt=$($LFS getdirstripe -c $dir)
2287 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2288 $LFS migrate -m 0 $dir || {
2290 error_noexit "migrate MDT0 failed"
2299 # When adding new data verification tests, please check for
2300 # the presence of the required reference files first, like
2301 # the "sha1sums" and "list" tests above, to avoid the need to
2302 # regenerate every image for each test addition.
2305 nrpcs_orig=$($LCTL get_param \
2306 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2307 error_noexit "Getting \"max_rpcs_in_flight\""
2310 nrpcs=$((nrpcs_orig + 5))
2312 set_persistent_param_and_check client \
2313 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
2314 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
2315 error_noexit "Changing \"max_rpcs_in_flight\""
2319 umount $tmp/mnt/lustre || {
2320 error_noexit "Unmounting the client"
2323 shall_cleanup_lustre=false
2325 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2326 $r $UMOUNT $tmp/mnt/mdt1 || {
2327 error_noexit "Unmounting the MDT2"
2330 if [[ $fstype == zfs ]]; then
2331 $r "$ZPOOL export t32fs-mdt2"
2333 shall_cleanup_mdt1=false
2336 $r $UMOUNT $tmp/mnt/mdt || {
2337 error_noexit "Unmounting the MDT"
2340 if [[ $fstype == zfs ]]; then
2341 $r "$ZPOOL export t32fs-mdt1"
2343 shall_cleanup_mdt=false
2345 $r $UMOUNT $tmp/mnt/ost || {
2346 error_noexit "Unmounting the OST"
2349 if [[ $fstype == zfs ]]; then
2350 $r "$ZPOOL export t32fs-ost1"
2352 shall_cleanup_ost=false
2354 t32_reload_modules $node || {
2355 error_noexit "Reloading modules"
2359 if [[ $fstype == zfs ]]; then
2360 local poolname=t32fs-mdt1
2362 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2363 $ZPOOL import -f -d $tmp $poolname"
2365 # upgrade zpool to latest supported features,
2366 # including dnode quota accounting in 0.7.0
2367 $r "$ZPOOL upgrade $poolname"
2370 # mount a second time to make sure we didnt leave upgrade flag on
2371 $r $TUNEFS --dryrun $mdt_dev || {
2373 error_noexit "tunefs.lustre before remounting the MDT"
2377 mopts=exclude=$fsname-OST0000
2378 if [ $fstype == "ldiskfs" ]; then
2381 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2382 error_noexit "Remounting the MDT"
2385 shall_cleanup_mdt=true
2395 for tarball in $tarballs; do
2396 t32_test $tarball || let "rc += $?"
2400 run_test 32a "Upgrade (not live)"
2408 for tarball in $tarballs; do
2409 t32_test $tarball writeconf || let "rc += $?"
2413 run_test 32b "Upgrade with writeconf"
2420 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2422 for tarball in $tarballs; do
2423 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2424 echo $tarball | grep "1_8" && continue
2425 echo $tarball | grep "2_1" && continue
2427 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2431 run_test 32c "dne upgrade test"
2439 for tarball in $tarballs; do
2440 ff_convert=yes t32_test $tarball || rc=$?
2444 run_test 32d "convert ff test"
2447 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
2448 skip "Need MDS version at least 2.10.56"
2455 for tarball in $tarballs; do
2456 echo $tarball | grep "2_9" || continue
2458 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
2462 run_test 32e "dom upgrade test"
2464 test_33a() { # bug 12333, was test_33
2465 local FSNAME2=test-123
2466 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2469 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2471 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2472 local dev=${SINGLEMDS}_dev
2473 local MDSDEV=${!dev}
2474 is_blkdev $SINGLEMDS $MDSDEV &&
2475 skip_env "mixed loopback and real device not working"
2478 local fs2mdsdev=$(mdsdevname 1_2)
2479 local fs2ostdev=$(ostdevname 1_2)
2480 local fs2mdsvdev=$(mdsvdevname 1_2)
2481 local fs2ostvdev=$(ostvdevname 1_2)
2483 if [ $(facet_fstype mds1) == ldiskfs ]; then
2484 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2487 if combined_mgs_mds; then
2488 local mgs_flag="--mgs"
2491 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
2492 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
2494 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2495 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2496 $fs2ostvdev || exit 10
2498 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2499 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2501 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2502 do_facet mgs "$PERM_CMD timeout=200" ||
2503 error "$PERM_CMD timeout=200 failed"
2505 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
2506 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
2508 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2509 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2512 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2513 $LFS getstripe $MOUNT2/hosts ||
2514 error "$LFS getstripe $MOUNT2/hosts failed"
2519 cleanup_nocli || error "cleanup_nocli failed with $?"
2521 run_test 33a "Mount ost with a large index number"
2523 test_33b() { # was test_34
2526 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2527 # Drop lock cancelation reply during umount
2528 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2529 do_facet client $LCTL set_param fail_loc=0x80000304
2530 #lctl set_param debug=-1
2531 umount_client $MOUNT
2532 cleanup || error "cleanup failed with $?"
2534 run_test 33b "Drop cancel during umount"
2538 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2539 manual_umount_client
2541 do_facet client killall -USR1 multiop
2542 if [ $rc -eq 0 ]; then
2543 error "umount not fail!"
2546 cleanup || error "cleanup failed with rc $?"
2548 run_test 34a "umount with opened file should be fail"
2552 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2553 stop_mds || error "Unable to stop MDS"
2555 manual_umount_client --force || error "mtab after failed umount with $?"
2557 cleanup || error "cleanup failed with $?"
2559 run_test 34b "force umount with failed mds should be normal"
2563 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2564 stop_ost || error "Unable to stop OST1"
2566 manual_umount_client --force || error "mtab after failed umount with $?"
2568 cleanup || error "cleanup failed with $?"
2570 run_test 34c "force umount with failed ost should be normal"
2572 test_35a() { # bug 12459
2575 DBG_SAVE="`$LCTL get_param -n debug`"
2576 $LCTL set_param debug="ha"
2578 log "Set up a fake failnode for the MDS"
2580 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2581 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2583 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2584 do_facet mgs "$PERM_CMD \
2585 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2586 error "Setting mdc.*${device}*.import=connection=\
2587 $(h2nettype $FAKENID) failed."
2589 do_facet mgs "$PERM_CMD \
2590 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2591 error "Setting ${device}.failover.node=\
2592 $(h2nettype $FAKENID) failed."
2594 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2597 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2600 log "Stopping the MDT: $device"
2601 stop_mdt 1 || error "MDT0 stop fail"
2603 df $MOUNT > /dev/null 2>&1 &
2605 log "Restarting the MDT: $device"
2606 start_mdt 1 || error "MDT0 start fail"
2607 log "Wait for df ($DFPID) ... "
2610 $LCTL set_param debug="$DBG_SAVE"
2612 # retrieve from the log the first server that the client tried to
2613 # contact after the connection loss
2614 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2615 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2616 /import_select_connection.*$device-mdc.* using connection/ {
2618 if (\\\$NF ~ /$FAKENID/)
2624 }" $TMP/lustre-log-$TESTNAME.log`
2625 [ "$NEXTCONN" != "0" ] &&
2626 error "Tried to connect to ${NEXTCONN} not last active server"
2627 cleanup || error "cleanup failed with $?"
2628 # remove nid settings
2629 writeconf_or_reformat
2631 run_test 35a "Reconnect to the last active server first"
2633 test_35b() { # bug 18674
2634 remote_mds || skip "local MDS"
2638 $LCTL set_param debug="ha"
2640 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2643 log "Set up a fake failnode for the MDS"
2645 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2646 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2648 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2649 do_facet mgs "$PERM_CMD \
2650 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2651 error "Set mdc.*${device}*.import=connection=\
2652 $(h2nettype $FAKENID) failed"
2654 do_facet mgs "$PERM_CMD \
2655 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2656 error "Set ${device}.failover.node=\
2657 $(h2nettype $FAKENID) failed"
2660 local at_max_saved=0
2661 # adaptive timeouts may prevent seeing the issue
2662 if at_is_enabled; then
2663 at_max_saved=$(at_max_get mds)
2664 at_max_set 0 mds client
2667 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2669 log "Injecting EBUSY on MDS"
2670 # Setting OBD_FAIL_MDS_RESEND=0x136
2671 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2672 error "unable to set param fail_loc=0x80000136"
2674 $LCTL set_param mdc.${FSNAME}*.stats=clear
2676 log "Creating a test file and stat it"
2677 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2678 stat $MOUNT/$tdir/$tfile
2680 log "Stop injecting EBUSY on MDS"
2681 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2682 error "unable to set param fail_loc=0"
2683 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2686 # restore adaptive timeout
2687 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2689 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2691 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2692 awk '/mds_connect/{print $2}')
2694 # retrieve from the log if the client has ever tried to
2695 # contact the fake server after the loss of connection
2696 FAILCONN=`awk "BEGIN {ret = 0;}
2697 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2699 if (\\\$NF ~ /$FAKENID/) {
2704 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2706 [ "$FAILCONN" == "0" ] &&
2707 error "The client reconnection has not been triggered"
2708 [ "$FAILCONN" == "2" ] &&
2709 error "Primary server busy, client reconnect to failover failed"
2712 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2713 # Reconnects are supposed to be rate limited to one every 5s
2714 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2715 error "Too many reconnects $CONNCNT"
2717 cleanup || error "cleanup failed with $?"
2718 # remove nid settings
2719 writeconf_or_reformat
2721 run_test 35b "Continue reconnection retries, if the active server is busy"
2724 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2726 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2730 local FSNAME2=test1234
2731 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2733 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2735 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2736 is_blkdev $SINGLEMDS $MDSDEV &&
2737 skip_env "mixed loopback and real device not working"
2740 local fs2mdsdev=$(mdsdevname 1_2)
2741 local fs2ostdev=$(ostdevname 1_2)
2742 local fs3ostdev=$(ostdevname 2_2)
2743 local fs2mdsvdev=$(mdsvdevname 1_2)
2744 local fs2ostvdev=$(ostvdevname 1_2)
2745 local fs3ostvdev=$(ostvdevname 2_2)
2748 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2749 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2750 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2751 # different one than the default value here.
2752 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2753 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2754 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2755 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2757 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2758 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2759 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2760 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2761 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2763 sleep 5 # until 11778 fixed
2765 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2767 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2768 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2769 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2770 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2771 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2772 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2773 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2774 DFTOTAL=$(echo $STRING | cut -d, -f1)
2775 DFUSED=$(echo $STRING | cut -d, -f2)
2776 DFAVAIL=$(echo $STRING | cut -d, -f3)
2777 DFFREE=$(($DFTOTAL - $DFUSED))
2779 ALLOWANCE=$((64 * $OSTCOUNT))
2781 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2782 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2783 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2786 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2787 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2788 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2791 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2792 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2793 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2798 stop fs3ost -f || error "unable to stop OST3"
2799 stop fs2ost -f || error "unable to stop OST2"
2800 stop fs2mds -f || error "unable to stop second MDS"
2801 unload_modules_conf || error "unable unload modules"
2804 run_test 36 "df report consistency on OSTs with different block size"
2807 local mntpt=$(facet_mntpt $SINGLEMDS)
2808 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2809 local mdsdev_sym="$TMP/sym_mdt.img"
2810 local opts=$MDS_MOUNT_OPTS
2813 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
2814 skip "ldiskfs only test"
2817 echo "MDS : $mdsdev"
2818 echo "SYMLINK : $mdsdev_sym"
2819 do_facet $SINGLEMDS rm -f $mdsdev_sym
2821 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2823 echo "mount symlink device - $mdsdev_sym"
2825 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2826 opts=$(csa_add "$opts" -o loop)
2830 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2831 $mdsdev_sym $mntpt 2>&1)
2834 echo mount_op=$mount_op
2836 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2838 if $(echo $mount_op | grep -q "unable to set tunable"); then
2839 error "set tunables failed for symlink device"
2842 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2844 run_test 37 "verify set tunables works for symlink device"
2846 test_38() { # bug 14222
2847 local fstype=$(facet_fstype $SINGLEMDS)
2848 local mntpt=$(facet_mntpt $SINGLEMDS)
2853 local SRC="/etc /bin"
2854 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2855 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2856 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2857 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2858 error "copying $SRC to $DIR/$tdir"
2860 umount_client $MOUNT || error "umount_client $MOUNT failed"
2861 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2862 stop_mds || error "Unable to stop MDS"
2863 log "delete lov_objid file on MDS"
2865 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2867 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2869 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2871 # check create in mds_lov_connect
2872 start_mds || error "unable to start MDS"
2873 mount_client $MOUNT || error "mount_client $MOUNT failed"
2875 [ $V ] && log "verifying $DIR/$tdir/$f"
2876 diff -q $f $DIR/$tdir/$f || ERROR=y
2878 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2879 if [ "$ERROR" = "y" ]; then
2880 # check it's updates in sync
2881 umount_client $MOUNT
2883 mount_fstype $SIGNLEMDS
2884 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2885 unmount_fstype $SINGLEMDS
2886 error "old and new files are different after connect" || true
2888 touch $DIR/$tdir/f2 || error "f2 file create failed"
2890 # check it's updates in sync
2891 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2894 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2896 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2897 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2899 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2901 start_mds || error "unable to start MDS"
2902 mount_client $MOUNT || error "mount_client $MOUNT failed"
2904 [ $V ] && log "verifying $DIR/$tdir/$f"
2905 diff -q $f $DIR/$tdir/$f || ERROR=y
2907 touch $DIR/$tdir/f3 || error "f3 file create failed"
2908 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2909 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2911 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2912 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2913 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2915 [ "$ERROR" = "y" ] &&
2916 error "old and new files are different after sync" || true
2918 log "files compared the same"
2919 cleanup || error "cleanup failed with $?"
2921 run_test 38 "MDS recreates missing lov_objid file from OST data"
2926 cleanup || error "cleanup failed with $?"
2927 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2928 error "memory leak detected" || true
2930 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2932 test_40() { # bug 15759
2933 start_ost || error "Unable to start OST1"
2934 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2935 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2937 cleanup || error "cleanup failed with rc $?"
2939 run_test 40 "race during service thread startup"
2941 test_41a() { #bug 14134
2942 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2943 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2944 skip "Loop devices does not work with nosvc option"
2947 combined_mgs_mds || skip "needs combined MGT and MDT device"
2949 start_mdt 1 -o nosvc -n
2950 if [ $MDSCOUNT -ge 2 ]; then
2951 for num in $(seq 2 $MDSCOUNT); do
2952 start_mdt $num || return
2955 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
2956 start_mdt 1 -o nomgs,force
2957 mount_client $MOUNT || error "mount_client $MOUNT failed"
2960 echo "blah blah" > $MOUNT/$tfile
2963 umount_client $MOUNT || error "umount_client $MOUNT failed"
2964 stop ost1 -f || error "unable to stop OST1"
2965 stop_mds || error "Unable to stop MDS"
2966 stop_mds || error "Unable to stop MDS on second try"
2968 run_test 41a "mount mds with --nosvc and --nomgs"
2971 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
2972 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2973 skip "Loop devices does not work with nosvc option"
2976 ! combined_mgs_mds && skip "needs combined mgs device"
2980 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2982 start_mdt 1 -o nosvc -n
2983 if [ $MDSCOUNT -ge 2 ]; then
2984 for num in $(seq 2 $MDSCOUNT); do
2985 start_mdt $num || return
2988 start_ost || error "Unable to start OST1"
2989 start_mdt 1 -o nomgs,force
2990 mount_client $MOUNT || error "mount_client $MOUNT failed"
2993 echo "blah blah" > $MOUNT/$tfile
2994 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
2996 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
2997 stop_ost || error "Unable to stop OST1"
2998 stop_mds || error "Unable to stop MDS"
2999 stop_mds || error "Unable to stop MDS on second try"
3001 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
3004 local server_version=$(lustre_version_code $SINGLEMDS)
3005 local oss_list=$(comma_list $(osts_nodes))
3007 [[ $server_version -ge $(version_code 2.6.52) ]] ||
3008 [[ $server_version -ge $(version_code 2.5.26) &&
3009 $server_version -lt $(version_code 2.5.50) ]] ||
3010 [[ $server_version -ge $(version_code 2.5.4) &&
3011 $server_version -lt $(version_code 2.5.11) ]] ||
3012 skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"
3014 # ensure mds1 ost1 have been created even if running sub-test standalone
3017 cleanup || error "cleanup failed"
3019 # using directly mount command instead of start() function to avoid
3020 # any side effect of // with others/externals tools/features
3021 # ("zpool import", ...)
3023 # MDT concurrent start
3025 LOAD_MODULES_REMOTE=true load_modules
3026 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
3027 error "MDT concurrent start: libcfs module not loaded"
3029 local mds1dev=$(mdsdevname 1)
3030 local mds1mnt=$(facet_mntpt mds1)
3031 local mds1fstype=$(facet_fstype mds1)
3032 local mds1opts=$MDS_MOUNT_OPTS
3034 if [ $mds1fstype == ldiskfs ] &&
3035 ! do_facet mds1 test -b $mds1dev; then
3036 mds1opts=$(csa_add "$mds1opts" -o loop)
3038 if [[ $mds1fstype == zfs ]]; then
3039 import_zpool mds1 || return ${PIPESTATUS[0]}
3042 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3043 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
3045 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
3048 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
3052 do_facet mds1 "$LCTL set_param fail_loc=0x0"
3053 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3054 echo "1st MDT start succeed"
3055 echo "2nd MDT start failed with $rc2"
3056 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3057 echo "1st MDT start failed with $rc"
3058 echo "2nd MDT start succeed"
3061 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
3064 if [ $MDSCOUNT -ge 2 ]; then
3065 for num in $(seq 2 $MDSCOUNT); do
3066 start_mdt $num || return
3070 # OST concurrent start
3072 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
3073 error "OST concurrent start: libcfs module not loaded"
3075 local ost1dev=$(ostdevname 1)
3076 local ost1mnt=$(facet_mntpt ost1)
3077 local ost1fstype=$(facet_fstype ost1)
3078 local ost1opts=$OST_MOUNT_OPTS
3080 if [ $ost1fstype == ldiskfs ] &&
3081 ! do_facet ost1 test -b $ost1dev; then
3082 ost1opts=$(csa_add "$ost1opts" -o loop)
3084 if [[ $ost1fstype == zfs ]]; then
3085 import_zpool ost1 || return ${PIPESTATUS[0]}
3088 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3089 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
3091 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
3094 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
3098 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3099 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3100 echo "1st OST start succeed"
3101 echo "2nd OST start failed with $rc2"
3102 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3103 echo "1st OST start failed with $rc"
3104 echo "2nd OST start succeed"
3108 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3114 # verify everything ok
3119 error "MDT(s) start failed"
3127 error "OST(s) start failed"
3135 error "client start failed"
3142 error "client mount failed"
3146 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3148 test_42() { #bug 14693
3152 check_mount || error "client was not mounted"
3154 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3155 PARAM="llite.$FSNAME-*.some_wrong_param"
3157 PARAM="$FSNAME.llite.some_wrong_param"
3160 do_facet mgs $PERM_CMD $PARAM=10
3161 umount_client $MOUNT ||
3162 error "unmounting client failed with invalid llite param"
3163 mount_client $MOUNT ||
3164 error "mounting client failed with invalid llite param"
3166 do_facet mgs $PERM_CMD $PARAM=20
3167 cleanup || error "stopping $FSNAME failed with invalid sys param"
3169 check_mount || error "client was not mounted with invalid sys param"
3170 cleanup || error "stopping $FSNAME failed with invalid sys param"
3172 run_test 42 "allow client/server mount/unmount with invalid config param"
3175 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.58) ]] ||
3176 skip "Need MDS version at least 2.5.58"
3177 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
3180 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
3181 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1"
3184 chmod ugo+x $DIR || error "chmod 0 failed"
3185 set_persistent_param_and_check mds1 \
3186 "mdt.$FSNAME-MDT0000.root_squash" \
3187 "$FSNAME.mdt.root_squash" \
3189 wait_update $HOSTNAME \
3190 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3192 error "check llite root_squash failed!"
3193 set_persistent_param_and_check mds1 \
3194 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3195 "$FSNAME.mdt.nosquash_nids" \
3197 wait_update $HOSTNAME \
3198 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3200 error "check llite nosquash_nids failed!"
3203 # create set of test files
3205 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
3206 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
3207 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
3209 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
3210 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
3212 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
3213 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
3214 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
3216 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
3217 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
3218 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
3221 # check root_squash:
3222 # set root squash UID:GID to RUNAS_ID
3223 # root should be able to access only files owned by RUNAS_ID
3225 set_persistent_param_and_check mds1 \
3226 "mdt.$FSNAME-MDT0000.root_squash" \
3227 "$FSNAME.mdt.root_squash" \
3228 "$RUNAS_ID:$RUNAS_ID"
3229 wait_update $HOSTNAME \
3230 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3231 "$RUNAS_ID:$RUNAS_ID" ||
3232 error "check llite root_squash failed!"
3234 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
3235 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3236 error "$ST: root read permission is denied"
3237 echo "$ST: root read permission is granted - ok"
3240 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3241 error "$ST: root write permission is denied"
3242 echo "$ST: root write permission is granted - ok"
3244 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3245 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3246 error "$ST: root read permission is granted"
3247 echo "$ST: root read permission is denied - ok"
3250 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3251 error "$ST: root write permission is granted"
3252 echo "$ST: root write permission is denied - ok"
3254 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3255 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
3256 error "$ST: root unlink permission is granted"
3257 echo "$ST: root unlink permission is denied - ok"
3259 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
3260 error "$ST: root create permission is granted"
3261 echo "$ST: root create permission is denied - ok"
3264 # check root_squash is enforced independently
3265 # of client cache content
3267 # access file by USER1, keep access open
3268 # root should be denied access to user file
3270 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
3274 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
3275 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3276 { kill $pid; error "$ST: root read permission is granted"; }
3277 echo "$ST: root read permission is denied - ok"
3280 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3281 { kill $pid; error "$ST: root write permission is granted"; }
3282 echo "$ST: root write permission is denied - ok"
3288 # check nosquash_nids:
3289 # put client's NID into nosquash_nids list,
3290 # root should be able to access root file after that
3292 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
3293 NIDLIST="2@gni $NIDLIST 192.168.0.[2,10]@tcp"
3294 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
3295 set_persistent_param_and_check mds1 \
3296 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3297 "$FSNAME-MDTall.mdt.nosquash_nids" \
3299 wait_update $HOSTNAME \
3300 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3302 error "check llite nosquash_nids failed!"
3304 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3305 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3306 error "$ST: root read permission is denied"
3307 echo "$ST: root read permission is granted - ok"
3310 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3311 error "$ST: root write permission is denied"
3312 echo "$ST: root write permission is granted - ok"
3314 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3315 rm $DIR/$tdir-rootdir/tfile-1 ||
3316 error "$ST: root unlink permission is denied"
3317 echo "$ST: root unlink permission is granted - ok"
3318 touch $DIR/$tdir-rootdir/tfile-2 ||
3319 error "$ST: root create permission is denied"
3320 echo "$ST: root create permission is granted - ok"
3321 cleanup || error "cleanup failed with $?"
3323 run_test 43a "check root_squash and nosquash_nids"
3325 test_43b() { # LU-5690
3326 [[ $(lustre_version_code mgs) -ge $(version_code 2.7.62) ]] ||
3327 skip "Need MGS version 2.7.62+"
3329 if [[ -z "$fs2mds_DEV" ]]; then
3330 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
3331 skip_env "mixed loopback and real device not working"
3334 local fs2mdsdev=$(mdsdevname 1_2)
3335 local fs2mdsvdev=$(mdsvdevname 1_2)
3337 # temporarily use fs2mds as fs2mgs
3339 local fs2mgsdev=$fs2mdsdev
3340 local fs2mgsvdev=$fs2mdsvdev
3342 local fsname=test1234
3344 load_module llite/lustre
3345 local client_ip=$(host_nids_address $HOSTNAME $NETTYPE)
3346 local host=${client_ip//*./}
3347 local net=${client_ip/%$host/}
3348 local nosquash_nids=$(h2nettype $net[$host,$host,$host])
3350 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
3351 --param mdt.root_squash=$RUNAS_ID:$RUNAS_ID \
3352 --param mdt.nosquash_nids=$nosquash_nids \
3353 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
3354 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS || error "start fs2mgs failed"
3355 stop $fs2mgs -f || error "stop fs2mgs failed"
3356 cleanup || error "cleanup failed with $?"
3358 run_test 43b "parse nosquash_nids with commas in expr_list"
3362 check_mount || error "check_mount"
3363 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
3365 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
3366 for VAL in $UUIDS; do
3367 NID=$(echo $VAL | cut -d= -f1)
3368 CLUUID=$(echo $VAL | cut -d= -f2)
3369 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
3371 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
3372 cleanup || error "cleanup failed with $?"
3374 run_test 44 "mounted client proc entry exists"
3378 check_mount || error "check_mount"
3379 stop_mds || error "Unable to stop MDS"
3383 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
3384 do_facet client "$LCTL set_param fail_loc=0x8000050f"
3387 manual_umount_client --force || error "manual_umount_client failed"
3388 do_facet client "$LCTL set_param fail_loc=0x0"
3389 start_mds || error "unable to start MDS"
3390 mount_client $MOUNT || error "mount_client $MOUNT failed"
3391 cleanup || error "cleanup failed with $?"
3393 run_test 45 "long unlink handling in ptlrpcd"
3400 umount_client $MOUNT2 || rc=$?
3401 umount_client $MOUNT || rc=$?
3402 while [ $count -gt 0 ]; do
3403 stop ost${count} -f || rc=$?
3407 cleanup_nocli || rc=$?
3408 #writeconf to remove all ost2 traces for subsequent tests
3409 writeconf_or_reformat
3414 echo "Testing with $OSTCOUNT OSTs"
3416 start_mds || error "unable to start MDS"
3417 #first client should see only one ost
3418 start_ost || error "Unable to start OST1"
3419 wait_osc_import_state mds ost FULL
3421 mount_client $MOUNT || error "mount_client $MOUNT failed"
3422 trap "cleanup_46a $OSTCOUNT" EXIT ERR
3425 for (( i=2; i<=$OSTCOUNT; i++ )); do
3426 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
3427 error "start_ost$i $(ostdevname $i) failed"
3430 # wait until osts in sync
3431 for (( i=2; i<=$OSTCOUNT; i++ )); do
3432 wait_osc_import_state mds ost$i FULL
3433 wait_osc_import_ready client ost$i
3436 #second client see all ost's
3438 mount_client $MOUNT2 || error "mount_client failed"
3439 $LFS setstripe -c -1 $MOUNT2 ||
3440 error "$LFS setstripe -c -1 $MOUNT2 failed"
3441 $LFS getstripe $MOUNT2 || error "$LFS getstripe $MOUNT2 failed"
3443 echo "ok" > $MOUNT2/widestripe
3444 $LFS getstripe $MOUNT2/widestripe ||
3445 error "$LFS getstripe $MOUNT2/widestripe failed"
3446 # fill acl buffer for avoid expand lsm to them
3447 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
3449 setfacl -m $acl $MOUNT2/widestripe
3453 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3455 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
3457 run_test 46a "handle ost additional - wide striped file"
3462 check_mount || error "check_mount failed"
3463 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
3467 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3468 if echo $ns | grep "MDT[[:digit:]]*"; then
3471 lrs=$(echo $ns | sed 's/.*lru_size=//')
3472 lru_size[count]=$lrs
3477 facet_failover $SINGLEMDS
3478 client_up || error "client_up failed"
3481 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3482 if echo $ns | grep "MDT[[:digit:]]*"; then
3485 lrs=$(echo $ns | sed 's/.*lru_size=//')
3486 if ! test "$lrs" -eq "${lru_size[count]}"; then
3487 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
3488 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
3493 cleanup || error "cleanup failed with $?"
3495 run_test 47 "server restart does not make client loss lru_resize settings"
3500 # reformat after this test is needed - if the test fails,
3501 # we will have unkillable file at FS
3505 test_48() { # bz-17636 LU-7473
3509 check_mount || error "check_mount failed"
3511 $LFS setstripe -c -1 $MOUNT ||
3512 error "$LFS setstripe -c -1 $MOUNT failed"
3513 $LFS getstripe $MOUNT || error "$LFS getstripe $MOUNT failed"
3515 echo "ok" > $MOUNT/widestripe
3516 $LFS getstripe $MOUNT/widestripe ||
3517 error "$LFS getstripe $MOUNT/widestripe failed"
3519 # In the future, we may introduce more EAs, such as selinux, enlarged
3520 # LOV EA, and so on. These EA will use some EA space that is shared by
3521 # ACL entries. So here we only check some reasonable ACL entries count,
3522 # instead of the max number that is calculated from the max_ea_size.
3523 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.57) ];
3525 count=28 # hard coded of RPC protocol
3526 elif [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3527 count=4000 # max_num 4091 max_ea_size = ~65536
3528 elif ! large_xattr_enabled; then
3529 count=450 # max_num 497 max_ea_size = 4012
3531 count=4500 # max_num 8187 max_ea_size = 65452
3532 # not create too much (>5000) to save test time
3535 echo "It is expected to hold at least $count ACL entries"
3536 trap cleanup_48 EXIT ERR
3537 for ((i = 0; i < $count; i++)) do
3538 setfacl -m u:$((i + 100)):rw $MOUNT/widestripe ||
3539 error "Fail to setfacl for $MOUNT/widestripe at $i"
3542 cancel_lru_locks mdc
3543 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3544 local r_count=$(getfacl $MOUNT/widestripe | grep "user:" | wc -l)
3545 count=$((count + 1)) # for the entry "user::rw-"
3547 [ $count -eq $r_count ] ||
3548 error "Expected ACL entries $count, but got $r_count"
3552 run_test 48 "too many acls on file"
3554 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3555 test_49a() { # bug 17710
3556 local timeout_orig=$TIMEOUT
3557 local ldlm_timeout_orig=$LDLM_TIMEOUT
3558 local LOCAL_TIMEOUT=20
3560 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3561 TIMEOUT=$LOCAL_TIMEOUT
3565 check_mount || error "client mount failed"
3567 echo "check ldlm_timout..."
3568 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3569 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3570 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3572 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3573 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3576 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3577 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3580 umount_client $MOUNT || error "umount_client $MOUNT failed"
3581 stop_ost || error "problem stopping OSS"
3582 stop_mds || error "problem stopping MDS"
3584 LDLM_TIMEOUT=$ldlm_timeout_orig
3585 TIMEOUT=$timeout_orig
3587 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3589 test_49b() { # bug 17710
3590 local timeout_orig=$TIMEOUT
3591 local ldlm_timeout_orig=$LDLM_TIMEOUT
3592 local LOCAL_TIMEOUT=20
3594 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3595 TIMEOUT=$LOCAL_TIMEOUT
3599 check_mount || error "client mount failed"
3601 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3602 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3603 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3605 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3606 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3609 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3610 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3613 cleanup || error "cleanup failed"
3615 LDLM_TIMEOUT=$ldlm_timeout_orig
3616 TIMEOUT=$timeout_orig
3618 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3621 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3623 # Test both statfs and lfs df and fail if either one fails
3624 multiop_bg_pause $1 f_
3627 killall -USR1 multiop
3628 [ $RC -ne 0 ] && log "lazystatfs multiop failed"
3629 wait $PID || { RC=$?; log "multiop return error "; }
3631 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3636 if kill -s 0 $PID; then
3639 log "lazystatfs lfs df failed to complete in 5s"
3647 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3648 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3650 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3652 cleanup || error "cleanup failed with rc $?"
3654 run_test 50a "lazystatfs all servers available"
3658 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3659 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3661 # Wait for client to detect down OST
3662 stop_ost || error "Unable to stop OST1"
3663 wait_osc_import_state client ost DISCONN
3665 log "OSCs should all be DISCONN"
3667 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
3669 umount_client $MOUNT || error "Unable to unmount client"
3670 stop_mds || error "Unable to stop MDS"
3672 run_test 50b "lazystatfs all servers down"
3675 start_mds || error "Unable to start MDS"
3676 start_ost || error "Unable to start OST1"
3677 start_ost2 || error "Unable to start OST2"
3678 mount_client $MOUNT || error "Unable to mount client"
3679 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3680 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3682 # Wait for client to detect down OST
3683 stop_ost || error "Unable to stop OST1"
3684 wait_osc_import_state mds ost DISCONN
3685 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3687 umount_client $MOUNT || error "Unable to unmount client"
3688 stop_ost2 || error "Unable to stop OST2"
3689 stop_mds || error "Unable to stop MDS"
3690 #writeconf to remove all ost2 traces for subsequent tests
3691 writeconf_or_reformat
3693 run_test 50c "lazystatfs one server down"
3696 start_mds || error "Unable to start MDS"
3697 start_ost || error "Unable to start OST1"
3698 start_ost2 || error "Unable to start OST2"
3699 mount_client $MOUNT || error "Unable to mount client"
3700 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3701 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3703 # Issue the statfs during the window where the client still
3704 # belives the OST to be available but it is in fact down.
3705 # No failure just a statfs which hangs for a timeout interval.
3706 stop_ost || error "Unable to stop OST1"
3707 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3709 umount_client $MOUNT || error "Unable to unmount client"
3710 stop_ost2 || error "Unable to stop OST2"
3711 stop_mds || error "Unable to stop MDS"
3712 #writeconf to remove all ost2 traces for subsequent tests
3713 writeconf_or_reformat
3715 run_test 50d "lazystatfs client/server conn race"
3722 start_mds || error "Unable to start MDS"
3723 #first client should see only one ost
3724 start_ost || error "Unable to start OST1"
3725 wait_osc_import_state mds ost FULL
3727 # Wait for client to detect down OST
3728 stop_ost || error "Unable to stop OST1"
3729 wait_osc_import_state mds ost DISCONN
3731 mount_client $MOUNT || error "Unable to mount client"
3732 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3734 multiop_bg_pause $MOUNT _f
3738 if [ $RC1 -ne 0 ]; then
3739 log "multiop failed $RC1"
3742 sleep $(( $TIMEOUT+1 ))
3744 [ $? -ne 0 ] && error "process isn't sleep"
3745 start_ost || error "Unable to start OST1"
3746 wait $pid || error "statfs failed"
3749 umount_client $MOUNT || error "Unable to unmount client"
3750 stop_ost || error "Unable to stop OST1"
3751 stop_mds || error "Unable to stop MDS"
3753 run_test 50e "normal statfs all servers down"
3758 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3760 start_mds || error "Unable to start mds"
3761 #first client should see only one ost
3762 start_ost || error "Unable to start OST1"
3763 wait_osc_import_state mds ost FULL
3765 start_ost2 || error "Unable to start OST2"
3766 wait_osc_import_state mds ost2 FULL
3768 # Wait for client to detect down OST
3769 stop_ost2 || error "Unable to stop OST2"
3771 wait_osc_import_state mds ost2 DISCONN
3772 mount_client $MOUNT || error "Unable to mount client"
3773 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3775 multiop_bg_pause $MOUNT _f
3779 if [ $RC1 -ne 0 ]; then
3780 log "lazystatfs multiop failed $RC1"
3783 sleep $(( $TIMEOUT+1 ))
3785 [ $? -ne 0 ] && error "process isn't sleep"
3786 start_ost2 || error "Unable to start OST2"
3787 wait $pid || error "statfs failed"
3788 stop_ost2 || error "Unable to stop OST2"
3791 umount_client $MOUNT -f || error "Unable to unmount client"
3792 stop_ost || error "Unable to stop OST1"
3793 stop_mds || error "Unable to stop MDS"
3794 #writeconf to remove all ost2 traces for subsequent tests
3795 writeconf_or_reformat
3797 run_test 50f "normal statfs one server in down"
3800 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3802 start_ost2 || error "Unable to start OST2"
3803 wait_osc_import_state mds ost2 FULL
3804 wait_osc_import_ready client ost2
3806 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3807 local PARAM="osc.${FSNAME}-OST0001*.active"
3809 local PARAM="${FSNAME}-OST0001.osc.active"
3812 $LFS setstripe -c -1 $DIR/$tfile || error "$LFS setstripe failed"
3813 do_facet mgs $PERM_CMD $PARAM=0 || error "Unable to deactivate OST"
3815 umount_client $MOUNT || error "Unable to unmount client"
3816 mount_client $MOUNT || error "Unable to mount client"
3817 # This df should not cause a panic
3820 do_facet mgs $PERM_CMD $PARAM=1 || error "Unable to activate OST"
3821 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
3822 umount_client $MOUNT || error "Unable to unmount client"
3823 stop_ost2 || error "Unable to stop OST2"
3824 stop_ost || error "Unable to stop OST1"
3825 stop_mds || error "Unable to stop MDS"
3826 #writeconf to remove all ost2 traces for subsequent tests
3827 writeconf_or_reformat
3829 run_test 50g "deactivated OST should not cause panic"
3833 # prepare MDT/OST, make OSC inactive for OST1
3834 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3836 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
3837 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3838 error "tunefs OST1 failed"
3839 start_mds || error "Unable to start MDT"
3840 start_ost || error "Unable to start OST1"
3841 start_ost2 || error "Unable to start OST2"
3842 mount_client $MOUNT || error "client start failed"
3844 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3846 # activatate OSC for OST1
3847 set_persistent_param_and_check client \
3848 "osc.${FSNAME}-OST0000-osc-[!M]*.active" \
3849 "${FSNAME}-OST0000.osc.active" 1
3851 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3852 $LFS setstripe -c -1 -i 0 $DIR/$tdir/2 ||
3853 error "$LFS setstripe $DIR/$tdir/2 failed"
3854 sleep 1 && echo "create a file after OST1 is activated"
3855 # doing some io, shouldn't crash
3856 dd if=/dev/zero of=$DIR/$tdir/2/$tfile-io bs=1M count=10
3858 # check OSC import is working
3859 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3860 error "some OSC imports are still not connected"
3864 umount_client $MOUNT || error "Unable to umount client"
3865 stop_ost2 || error "Unable to stop OST2"
3866 cleanup_nocli || error "cleanup_nocli failed with $?"
3868 run_test 50h "LU-642: activate deactivated OST"
3871 # prepare MDT/OST, make OSC inactive for OST1
3872 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
3875 [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
3876 do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
3877 error "tunefs MDT2 failed"
3878 start_mds || error "Unable to start MDT"
3879 start_ost || error "Unable to start OST1"
3880 start_ost2 || error "Unable to start OST2"
3881 mount_client $MOUNT || error "client start failed"
3883 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3885 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3886 $PERM_CMD mdc.${FSNAME}-MDT0001-mdc-*.active=0 &&
3887 error "deactive MDC0 succeeds"
3889 $PERM_CMD ${FSNAME}-MDT0000.mdc.active=0 &&
3890 error "deactive MDC0 succeeds"
3893 # activate MDC for MDT2
3894 set_persistent_param_and_check client \
3895 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3896 "${FSNAME}-MDT0001.mdc.active" 1
3898 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
3899 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.60) ]
3901 wait_dne_interconnect
3903 $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3905 createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
3907 rm -rf $DIR/$tdir/2 || error "unlink dir failed"
3909 # deactivate MDC for MDT2
3910 set_persistent_param_and_check client \
3911 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3912 "${FSNAME}-MDT0001.mdc.active" 0
3914 wait_osp_active mds ${FSNAME}-MDT0001 1 0
3916 $LFS mkdir -i1 $DIR/$tdir/2 &&
3917 error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
3919 $LFS mkdir -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3920 error "mkdir $DIR/$tdir/striped_dir fails after deactive MDT2"
3922 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3923 [ $stripe_count -eq $((MDSCOUNT - 1)) ] ||
3924 error "wrong $stripe_count != $((MDSCOUNT -1)) for striped_dir"
3927 umount_client $MOUNT || error "Unable to umount client"
3932 run_test 50i "activate deactivated MDT"
3935 local LOCAL_TIMEOUT=20
3939 check_mount || error "check_mount failed"
3941 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3942 $LFS setstripe -c -1 $MOUNT/$tdir ||
3943 error "$LFS setstripe -c -1 $MOUNT/$tdir failed"
3944 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3945 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
3946 touch $MOUNT/$tdir/$tfile &
3949 start_ost2 || error "Unable to start OST1"
3951 stop_ost2 || error "Unable to stop OST1"
3952 umount_client $MOUNT -f || error “unmount $MOUNT failed”
3953 cleanup_nocli || error “stop server failed”
3954 #writeconf to remove all ost2 traces for subsequent tests
3955 writeconf_or_reformat
3957 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
3966 do_node $node mkdir -p $dest
3967 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3969 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
3970 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3971 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
3973 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
3974 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
3984 local backup2=${TMP}/backup2
3986 do_node $node mkdir -p $backup2
3987 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
3989 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
3990 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
3991 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
3993 do_node $node "diff -rq $backup $backup2"
3994 [ $? -eq 0 ] || { error "contents differ"; return 3; }
3996 local xattrs2=${TMP}/xattrs2
3997 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
3998 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
4000 do_node $node "diff $xattrs $xattrs2"
4001 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
4003 do_node $node "rm -rf $backup2 $xattrs2"
4004 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
4008 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4009 skip "ldiskfs only test"
4012 start_mds || error "Unable to start MDS"
4013 start_ost || error "Unable to start OST1"
4014 mount_client $MOUNT || error "Unable to mount client"
4017 local ost1mnt=$(facet_mntpt ost1)
4018 local ost1node=$(facet_active_host ost1)
4019 local ost1tmp=$TMP/conf52
4022 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
4023 touch $TMP/modified_first || error "Unable to create temporary file"
4024 local mtime=$(stat -c %Y $TMP/modified_first)
4025 do_node $ost1node "mkdir -p $ost1tmp &&
4026 touch -m -d @$mtime $ost1tmp/modified_first" ||
4027 error "Unable to create temporary file"
4030 $LFS setstripe -c -1 -S 1M $DIR/$tdir || error "$LFS setstripe failed"
4032 for (( i=0; i < nrfiles; i++ )); do
4033 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
4034 error "multiop failed"
4039 # sync all the data and make sure no pending data on the client,
4040 # thus the SOM xattr would not be changed any more.
4041 cancel_lru_locks osc
4044 echo backup files to $TMP/$tdir
4045 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
4046 copy_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4047 error "Unable to copy files"
4049 umount_client $MOUNT || error "Unable to umount client"
4050 stop_ost || error "Unable to stop ost1"
4052 echo mount ost1 as ldiskfs
4053 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
4054 if ! do_node $ost1node test -b $ost1_dev; then
4057 do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
4059 error "Unable to mount ost1 as ldiskfs"
4062 echo backup objects to $ost1tmp/objects
4063 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
4064 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
4065 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
4067 error "Unable to copy objects"
4069 # move objects to lost+found
4070 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
4071 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
4073 do_node $ost1node "umount $ost1mnt" ||
4074 error "Unable to umount ost1 as ldiskfs"
4076 start_ost || error "Unable to start OST1"
4077 mount_client $MOUNT || error "Unable to mount client"
4079 local REPAIRED=$(do_node $ost1node "$LCTL get_param \
4080 -n osd-ldiskfs.$FSNAME-OST0000.oi_scrub" |
4081 awk '/^lf_repa[ri]*ed/ { print $2 }')
4082 [ $REPAIRED -gt 0 ] ||
4083 error "Some entry under /lost+found should be repaired"
4086 diff_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4087 error "Unable to diff files"
4089 rm -rf $TMP/$tdir $TMP/file_xattrs ||
4090 error "Unable to delete temporary files"
4091 do_node $ost1node "rm -rf $ost1tmp" ||
4092 error "Unable to delete temporary files"
4093 cleanup || error "cleanup failed with $?"
4095 run_test 52 "check recovering objects from lost+found"
4097 # Checks threads_min/max/started for some service
4099 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
4100 # parameter pattern prefix like 'ost.*.ost'.
4113 local msg="Insane $modname thread counts"
4114 local ncpts=$(check_cpt_number $facet)
4118 check_mount || return 41
4120 # We need to expand $parampat, but it may match multiple parameters, so
4121 # we'll pick the first one
4122 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
4123 error "Couldn't expand ${parampat}.threads_min parameter name"
4127 # Remove the .threads_min part
4128 paramp=${paramp%.threads_min}
4130 # Check for sanity in defaults
4131 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4133 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4135 tstarted=$(do_facet $facet "$LCTL get_param \
4136 -n ${paramp}.threads_started" || echo 0)
4137 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
4139 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4141 nthrs=$(expr $tmax - $tmin)
4142 if [ $nthrs -lt $ncpts ]; then
4148 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
4149 skip_env "module parameter forced $facet thread count"
4151 # Check that we can change min/max
4152 do_facet $facet "$LCTL set_param \
4153 ${paramp}.threads_min=$((tmin + nthrs))"
4154 do_facet $facet "$LCTL set_param \
4155 ${paramp}.threads_max=$((tmax - nthrs))"
4156 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4158 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4160 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
4161 $tmax2 == ($tmax - $nthrs)))' || return $?
4163 # Check that we can set min/max to the same value
4164 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4166 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
4167 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4169 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4171 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
4173 # Check that we can't set max < min
4174 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
4175 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4177 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4179 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
4181 # We need to ensure that we get the module options desired; to do this
4182 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
4183 LOAD_MODULES_REMOTE=true
4186 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
4187 setmodopts -a $modname "$newvalue" oldvalue
4190 check_mount || return 41
4192 # Restore previous setting of MODOPTS_*
4193 setmodopts $modname "$oldvalue"
4195 # Check that $opts took
4196 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4198 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4200 tstarted=$(do_facet $facet \
4201 "$LCTL get_param -n ${paramp}.threads_started" || echo 0)
4202 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4211 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
4212 cleanup || error "cleanup failed with rc $?"
4214 run_test 53a "check OSS thread count params"
4218 local mds=$(do_facet $SINGLEMDS "$LCTL get_param \
4219 -N mds.*.*.threads_max 2>/dev/null")
4220 if [ -z "$mds" ]; then
4221 #running this on an old MDT
4222 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
4224 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
4226 cleanup || error "cleanup failed with $?"
4228 run_test 53b "check MDS thread count params"
4231 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4232 skip "ldiskfs only test"
4235 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
4236 error "llverdev failed with rc=$?"
4239 run_test 54a "test llverdev and partial verify of device"
4242 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4243 skip "ldiskfs only test"
4247 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
4248 cleanup || error "cleanup failed with rc=$?"
4250 run_test 54b "test llverfs and partial verify of filesystem"
4254 local max_ost_index=$1
4255 echo -n $(((max_ost_index + 1) * 8))
4259 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4260 skip "ldiskfs only test"
4263 local mdsdev=$(mdsdevname 1)
4264 local mdsvdev=$(mdsvdevname 1)
4268 if ! combined_mgs_mds; then
4269 stop_mgs || error "stopping MGS service failed"
4270 format_mgs || error "formatting MGT failed"
4272 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
4274 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
4275 --reformat $(ostdevname 1) $(ostvdevname 1)
4281 echo checking size of lov_objid for ost index $i
4282 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" |
4283 grep ^User | awk -F 'Size: ' '{print $2}')
4284 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
4285 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
4287 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
4294 run_test 55 "check lov_objid size"
4297 local server_version=$(lustre_version_code $SINGLEMDS)
4298 local mds_journal_size_orig=$MDSJOURNALSIZE
4304 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
4305 $(ostdevname 1) $(ostvdevname 1)
4306 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
4307 $(ostdevname 2) $(ostvdevname 2)
4310 start_ost || error "Unable to start first ost (idx 10000)"
4311 start_ost2 || error "Unable to start second ost (idx 1000)"
4312 mount_client $MOUNT || error "Unable to mount client"
4316 if [[ $server_version -ge $(version_code 2.6.54) ]] ||
4317 [[ $server_version -ge $(version_code 2.5.4) &&
4318 $server_version -lt $(version_code 2.5.11) ]]; then
4319 wait_osc_import_state mds ost1 FULL
4320 wait_osc_import_state mds ost2 FULL
4321 $LFS setstripe --stripe-count=-1 $DIR/$tfile ||
4322 error "Unable to setstripe $DIR/$tfile"
4323 n=$($LFS getstripe --stripe-count $DIR/$tfile)
4324 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
4329 MDSJOURNALSIZE=$mds_journal_size_orig
4332 run_test 56a "check big OST indexes and out-of-index-order start"
4337 umount_client $MOUNT -f || error "unmount client failed"
4346 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
4348 trap cleanup_56b EXIT RETURN ERR
4351 if ! combined_mgs_mds ; then
4356 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) --index=0 --reformat \
4357 $(mdsdevname 1) $(mdsvdevname 1)
4358 add mds2 $(mkfs_opts mds2 $(mdsdevname 2)) --index=1 --reformat \
4359 $(mdsdevname 2) $(mdsvdevname 2)
4360 add mds3 $(mkfs_opts mds3 $(mdsdevname 3)) --index=1000 --reformat \
4361 $(mdsdevname 3) $(mdsvdevname 3)
4365 start_mdt 1 || error "MDT 1 (idx 0) start failed"
4366 start_mdt 2 || error "MDT 2 (idx 1) start failed"
4367 start_mdt 3 || error "MDT 3 (idx 1000) start failed"
4368 start_ost || error "Unable to start first ost"
4369 start_ost2 || error "Unable to start second ost"
4371 do_nodes $(comma_list $(mdts_nodes)) \
4372 "$LCTL set_param mdt.*.enable_remote_dir=1 \
4373 mdt.*.enable_remote_dir_gid=-1"
4375 mount_client $MOUNT || error "Unable to mount client"
4377 $LFS mkdir -c3 $MOUNT/$tdir || error "failed to make testdir"
4379 echo "This is test file 1!" > $MOUNT/$tdir/$tfile.1 ||
4380 error "failed to make test file 1"
4381 echo "This is test file 2!" > $MOUNT/$tdir/$tfile.2 ||
4382 error "failed to make test file 2"
4383 echo "This is test file 1000!" > $MOUNT/$tdir/$tfile.1000 ||
4384 error "failed to make test file 1000"
4386 rm -rf $MOUNT/$tdir || error "failed to remove testdir"
4388 $LFS mkdir -i1000 $MOUNT/$tdir.1000 ||
4389 error "create remote dir at idx 1000 failed"
4392 echo "=== START lfs df OUTPUT ==="
4394 echo "==== END lfs df OUTPUT ===="
4396 mdtcnt=$(echo -e "$output" | grep $FSNAME-MDT | wc -l)
4397 ostcnt=$(echo -e "$output" | grep $FSNAME-OST | wc -l)
4399 echo "lfs df returned mdt count $mdtcnt and ost count $ostcnt"
4400 [ $mdtcnt -eq 3 ] || error "lfs df returned wrong mdt count"
4401 [ $ostcnt -eq 2 ] || error "lfs df returned wrong ost count"
4403 echo "This is test file 1!" > $MOUNT/$tdir.1000/$tfile.1 ||
4404 error "failed to make test file 1"
4405 echo "This is test file 2!" > $MOUNT/$tdir.1000/$tfile.2 ||
4406 error "failed to make test file 2"
4407 echo "This is test file 1000!" > $MOUNT/$tdir.1000/$tfile.1000 ||
4408 error "failed to make test file 1000"
4409 rm -rf $MOUNT/$tdir.1000 || error "failed to remove remote_dir"
4412 echo "=== START lfs mdts OUTPUT ==="
4414 echo "==== END lfs mdts OUTPUT ===="
4416 echo -e "$output" | grep -v "MDTS:" | awk '{print $1}' |
4417 sed 's/://g' > $TMP/mdts-actual.txt
4418 sort $TMP/mdts-actual.txt -o $TMP/mdts-actual.txt
4420 echo -e "0\n1\n1000" > $TMP/mdts-expected.txt
4422 diff $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4425 rm $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4427 [ $result -eq 0 ] || error "target_obd proc file is incorrect!"
4429 run_test 56b "test target_obd correctness with nonconsecutive MDTs"
4431 test_57a() { # bug 22656
4432 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4433 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4434 tail -1 | awk '{print $1}')
4435 writeconf_or_reformat
4436 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4437 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
4438 error "tunefs failed"
4440 start_ost && error "OST registration from failnode should fail"
4443 run_test 57a "initial registration from failnode should fail (should return errs)"
4446 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4447 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4448 tail -1 | awk '{print $1}')
4449 writeconf_or_reformat
4450 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
4451 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
4452 error "tunefs failed"
4454 start_ost || error "OST registration from servicenode should not fail"
4457 run_test 57b "initial registration from servicenode should not fail"
4460 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
4463 test_58() { # bug 22658
4464 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
4466 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4467 createmany -o $DIR/$tdir/$tfile-%d 100
4468 unlinkmany $DIR/$tdir/$tfile-%d 100
4469 stop_mds || error "Unable to stop MDS"
4471 local MNTDIR=$(facet_mntpt $SINGLEMDS)
4472 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4474 # remove all files from the OBJECTS dir
4475 mount_fstype $SINGLEMDS
4477 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
4479 unmount_fstype $SINGLEMDS
4480 # restart MDS with missing llog files
4481 start_mds || error "unable to start MDS"
4482 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
4485 run_test 58 "missing llog files must not prevent MDT from mounting"
4488 start_mgsmds >> /dev/null
4489 local C1=$(count_osts)
4490 if [ $C1 -eq 0 ]; then
4491 start_ost >> /dev/null
4495 echo "original ost count: $C1 (expect > 0)"
4496 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
4497 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
4498 local C2=$(count_osts)
4499 echo "after mdt writeconf count: $C2 (expect 0)"
4500 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
4501 echo "OST start without writeconf should fail:"
4502 start_ost >> /dev/null &&
4503 error "OST start without writeconf didn't fail"
4504 echo "OST start with writeconf should succeed:"
4505 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
4506 local C3=$(count_osts)
4507 echo "after ost writeconf count: $C3 (expect 1)"
4508 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
4509 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
4510 local C4=$(count_osts)
4511 echo "after ost2 writeconf count: $C4 (expect 2)"
4512 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
4513 stop_ost2 >> /dev/null
4514 cleanup_nocli >> /dev/null
4515 #writeconf to remove all ost2 traces for subsequent tests
4516 writeconf_or_reformat
4518 run_test 59 "writeconf mount option"
4520 test_60() { # LU-471
4521 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4522 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"
4546 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
4549 local lxattr=$(large_xattr_enabled)
4551 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
4552 skip "Need MDS version at least 2.1.53"
4554 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
4555 ! large_xattr_enabled; then
4558 for num in $(seq $MDSCOUNT); do
4559 do_facet mds${num} $TUNE2FS -O ea_inode \
4560 $(mdsdevname $num) ||
4561 error "tune2fs on mds $num failed"
4565 setup || 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 of $(max_xattr_size) bytes on $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"
4608 if $lxattr && [ $(facet_fstype $SINGLEMDS) == ldiskfs ]; then
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 cleanup || error "stopping systems failed"
4622 run_test 61 "large xattr"
4625 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4626 skip "ldiskfs only test"
4628 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
4629 skip "Need MDS version at least 2.2.51"
4632 local mdsdev=$(mdsdevname 1)
4633 local ostdev=$(ostdevname 1)
4635 echo "disable journal for mds"
4636 do_facet mds1 $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
4637 start_mds && error "MDT start should fail"
4638 echo "disable journal for ost"
4639 do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
4640 start_ost && error "OST start should fail"
4641 cleanup || error "cleanup failed with rc $?"
4644 run_test 62 "start with disabled journal"
4647 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
4648 skip "ldiskfs only test"
4651 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ldiskfs
4652 local inode_slab=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4653 awk '/ldiskfs_inode_cache/ { print $5 / $6 }')
4654 if [ -z "$inode_slab" ]; then
4655 skip "ldiskfs module has not been loaded"
4658 echo "$inode_slab ldiskfs inodes per page"
4659 [ "${inode_slab%.*}" -ge "3" ] && return 0
4661 # If kmalloc-128 is also 1 per page - this is a debug kernel
4662 # and so this is not an error.
4663 local kmalloc128=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4664 awk '/^(dma-kmalloc|size)-128 / { print $5 / $6 }')
4665 # 32 128-byte chunks in 4k
4666 [ "${kmalloc128%.*}" -lt "32" ] ||
4667 error "ldiskfs inode too big, only $inode_slab objs/page, " \
4668 "kmalloc128 = $kmalloc128 objs/page"
4670 run_test 63 "Verify each page can at least hold 3 ldiskfs inodes"
4673 start_mds || error "unable to start MDS"
4674 start_ost || error "Unable to start OST1"
4675 start_ost2 || error "Unable to start second ost"
4676 mount_client $MOUNT || error "Unable to mount client"
4677 stop_ost2 || error "Unable to stop second ost"
4680 umount_client $MOUNT -f || error “unmount $MOUNT failed”
4681 cleanup_nocli || error "cleanup_nocli failed with $?"
4682 #writeconf to remove all ost2 traces for subsequent tests
4683 writeconf_or_reformat
4685 run_test 64 "check lfs df --lazy "
4687 test_65() { # LU-2237
4688 # Currently, the test is only valid for ldiskfs backend
4689 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
4690 skip "ldiskfs only test"
4692 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4693 local brpt=$(facet_mntpt brpt)
4696 if ! do_facet $SINGLEMDS "test -b $devname"; then
4700 stop_mds || error "Unable to stop MDS"
4701 local obj=$(do_facet $SINGLEMDS \
4702 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
4704 if [ -z "$obj" ]; then
4705 # The MDT may be just re-formatted, mount the MDT for the
4706 # first time to guarantee the "last_rcvd" file is there.
4707 start_mds || error "fail to mount the MDS for the first time"
4708 stop_mds || error "Unable to stop MDS"
4711 # remove the "last_rcvd" file
4712 do_facet $SINGLEMDS "mkdir -p $brpt"
4713 do_facet $SINGLEMDS \
4714 "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
4715 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
4716 do_facet $SINGLEMDS "$UMOUNT $brpt"
4718 # restart MDS, the "last_rcvd" file should be recreated.
4719 start_mds || error "fail to restart the MDS"
4720 stop_mds || error "Unable to stop MDS"
4721 obj=$(do_facet $SINGLEMDS \
4722 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
4723 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
4725 run_test 65 "re-create the lost last_rcvd file when server mount"
4728 [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
4729 skip "Need MGS version at least 2.3.59"
4732 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
4733 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
4735 # add EXCLUDE records to config log, they are not to be
4736 # removed by lctl replace_nids
4737 set_conf_param_and_check mds \
4738 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4739 "$FSNAME-OST0000.osc.active" \
4742 echo "replace_nids should fail if MDS, OSTs and clients are UP"
4743 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4744 error "replace_nids fail"
4746 umount_client $MOUNT || error "unmounting client failed"
4747 echo "replace_nids should fail if MDS and OSTs are UP"
4748 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4749 error "replace_nids fail"
4751 stop_ost || error "Unable to stop OST1"
4752 echo "replace_nids should fail if MDS is UP"
4753 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4754 error "replace_nids fail"
4756 stop_mds || error "stopping mds failed"
4758 if combined_mgs_mds; then
4759 start_mdt 1 "-o nosvc" ||
4760 error "starting mds with nosvc option failed"
4763 echo "command should accept two parameters"
4764 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
4765 error "command should accept two params"
4767 echo "correct device name should be passed"
4768 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
4769 error "wrong devname"
4771 echo "wrong nids list should not destroy the system"
4772 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
4774 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "asdfasdf, asdfadf" &&
4777 echo "replace OST nid"
4778 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
4779 error "replace nids failed"
4781 echo "command should accept two parameters"
4782 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
4783 error "command should accept two params"
4785 echo "wrong nids list should not destroy the system"
4786 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
4789 local FAKE_NIDS="192.168.0.112@tcp1,192.168.0.112@tcp2"
4790 local FAKE_FAILOVER="192.168.0.113@tcp1,192.168.0.113@tcp2"
4791 local NIDS_AND_FAILOVER="$MDS_NID,$FAKE_NIDS:$FAKE_FAILOVER"
4792 echo "set NIDs with failover"
4793 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $NIDS_AND_FAILOVER ||
4794 error "replace nids failed"
4797 echo "replace MDS nid"
4798 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
4799 error "replace nids failed"
4801 if ! combined_mgs_mds ; then
4804 stop_mds || error "Unable to stop MDS"
4807 start_mgsmds || error "start mgsmds failed"
4808 set_conf_param_and_check mds \
4809 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4810 "$FSNAME-OST0000.osc.active" \
4812 start_ost || error "unable to start OST"
4813 mount_client $MOUNT || error "mount client failed"
4815 check_mount || error "error after nid replace"
4816 cleanup || error "cleanup failed"
4819 run_test 66 "replace nids"
4821 test_67() { #LU-2950
4822 local legacy="$TMP/legacy_lnet_config"
4823 local new="$TMP/new_routes_test"
4824 local out="$TMP/config_out_file"
4825 local verify="$TMP/conv_verify"
4826 local verify_conf="$TMP/conf_verify"
4828 # Create the legacy file that will be run through the
4829 # lustre_routes_conversion script
4830 cat <<- LEGACY_LNET_CONFIG > $legacy
4831 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
4832 tcp2 54 10.1.3.2@tcp;
4833 tcp3 10.3.4.3@tcp:3;
4837 # Create the verification file to verify the output of
4838 # lustre_routes_conversion script against.
4839 cat <<- VERIFY_LNET_CONFIG > $verify
4840 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
4841 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
4842 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
4843 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
4844 tcp4: { gateway: 10.3.3.4@tcp }
4847 # Create the verification file to verify the output of
4848 # lustre_routes_config script against
4849 cat <<- VERIFY_LNET_CONFIG > $verify_conf
4850 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
4851 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
4852 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
4853 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
4854 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
4857 $LUSTRE_ROUTES_CONVERSION $legacy $new > /dev/null
4858 if [ -f $new ]; then
4859 # verify the conversion output
4860 cmp -s $new $verify > /dev/null
4861 if [ $? -eq 1 ]; then
4862 error "routes conversion failed"
4865 lustre_routes_config --dry-run --verbose $new > $out
4866 # check that the script succeeded
4867 cmp -s $out $verify_conf > /dev/null
4868 if [ $? -eq 1 ]; then
4869 error "routes config failed"
4872 error "routes conversion test failed"
4874 # remove generated files
4875 rm -f $new $legacy $verify $verify_conf $out
4877 run_test 67 "test routes conversion and configuration"
4885 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.53) ] ||
4886 skip "Need MDS version at least 2.4.53"
4888 umount_client $MOUNT || error "umount client failed"
4893 # START-END - the sequences we'll be reserving
4894 START=$(do_facet $SINGLEMDS \
4895 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4896 END=$((START + (1 << 30)))
4897 do_facet $SINGLEMDS \
4898 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4900 # reset the sequences MDT0000 has already assigned
4901 do_facet $SINGLEMDS \
4902 $LCTL set_param seq.srv*MDT0000.space=clear
4904 # remount to let the client allocate new sequence
4905 mount_client $MOUNT || error "mount client failed"
4907 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4908 do_facet $SINGLEMDS \
4909 $LCTL get_param seq.srv*MDT0000.space
4910 $LFS path2fid $DIR/$tfile
4912 local old_ifs="$IFS"
4914 fid=($($LFS path2fid $DIR/$tfile))
4918 if [[ $seq < $END ]]; then
4919 error "used reserved sequence $seq?"
4921 cleanup || error "cleanup failed with $?"
4923 run_test 68 "be able to reserve specific sequences in FLDB"
4925 # Test 69: is about the total number of objects ever created on an OST.
4926 # so that when it is reformatted the normal MDS->OST orphan recovery won't
4927 # just "precreate" the missing objects. In the past it might try to recreate
4928 # millions of objects after an OST was reformatted
4930 local server_version=$(lustre_version_code $SINGLEMDS)
4932 [[ $server_version -lt $(version_code 2.4.2) ]] &&
4933 skip "Need MDS version at least 2.4.2"
4935 [[ $server_version -ge $(version_code 2.4.50) ]] &&
4936 [[ $server_version -lt $(version_code 2.5.0) ]] &&
4937 skip "Need MDS version at least 2.5.0"
4940 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4942 # use OST0000 since it probably has the most creations
4943 local OSTNAME=$(ostname_from_index 0)
4944 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4945 local last_id=$(do_facet mds1 $LCTL get_param -n \
4946 osp.$mdtosc_proc1.prealloc_last_id)
4948 # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
4949 # verify that the LAST_ID recovery is working properly. If
4950 # not, then the OST will refuse to allow the MDS connect
4951 # because the LAST_ID value is too different from the MDS
4952 #define OST_MAX_PRECREATE=20000
4953 local ost_max_pre=20000
4954 local num_create=$(( ost_max_pre * 5 + 1 - last_id))
4956 # If the LAST_ID is already over 5 * OST_MAX_PRECREATE, we don't
4957 # need to create any files. So, skip this section.
4958 if [ $num_create -gt 0 ]; then
4959 # Check the number of inodes available on OST0
4961 local ifree=$($LFS df -i $MOUNT | awk '/OST0000/ { print $4 }')
4962 log "On OST0, $ifree inodes available. Want $num_create."
4964 $LFS setstripe -i 0 $DIR/$tdir ||
4965 error "$LFS setstripe -i 0 $DIR/$tdir failed"
4966 if [ $ifree -lt 10000 ]; then
4967 files=$(( ifree - 50 ))
4972 local j=$((num_create / files + 1))
4973 for i in $(seq 1 $j); do
4974 createmany -o $DIR/$tdir/$tfile-$i- $files ||
4975 error "createmany fail create $files files: $?"
4976 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
4977 error "unlinkmany failed unlink $files files"
4981 # delete all of the files with objects on OST0 so the
4982 # filesystem is not inconsistent later on
4983 $LFS find $MOUNT --ost 0 -print0 | xargs -0 rm
4985 umount_client $MOUNT || error "umount client failed"
4986 stop_ost || error "OST0 stop failure"
4987 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
4988 $(ostdevname 1) $(ostvdevname 1) ||
4989 error "reformat and replace $ostdev failed"
4990 start_ost || error "OST0 restart failure"
4991 wait_osc_import_state mds ost FULL
4993 mount_client $MOUNT || error "mount client failed"
4994 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
4995 local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
4996 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
4998 local iused=$($LFS df -i $MOUNT | awk '/OST0000/ { print $3 }')
4999 log "On OST0, $iused used inodes"
5000 [ $iused -ge $((ost_max_pre/2 + 1000)) ] &&
5001 error "OST replacement created too many inodes; $iused"
5002 cleanup || error "cleanup failed with $?"
5004 run_test 69 "replace an OST with the same index"
5007 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5010 cleanup || error "cleanup failed with $?"
5012 start_mdt 1 || error "MDT0 start fail"
5014 start_ost || error "OST0 start fail"
5015 for num in $(seq 2 $MDSCOUNT); do
5016 start_mdt $num || return
5019 mount_client $MOUNT || error "mount client fails"
5021 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5023 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5024 error "create remote dir fail"
5026 rm -rf $DIR/$tdir || error "delete dir fail"
5027 cleanup || error "cleanup failed with $?"
5029 run_test 70a "start MDT0, then OST, then MDT1"
5032 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5035 start_ost || error "OST0 start fail"
5037 start_mds || error "MDS start fail"
5039 mount_client $MOUNT || error "mount client fails"
5041 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5043 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5044 error "create remote dir fail"
5046 rm -rf $DIR/$tdir || error "delete dir fail"
5048 cleanup || error "cleanup failed with $?"
5050 run_test 70b "start OST, MDT1, MDT0"
5053 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5056 start_mds || error "MDS start fail"
5057 start_ost || error "OST0 start fail"
5059 mount_client $MOUNT || error "mount client fails"
5060 stop_mdt 1 || error "MDT1 start fail"
5062 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
5063 echo "deactivate $mdc_for_mdt1"
5064 $LCTL --device $mdc_for_mdt1 deactivate ||
5065 error "set $mdc_for_mdt1 deactivate failed"
5067 mkdir $DIR/$tdir && error "mkdir succeed"
5069 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5070 error "create remote dir succeed"
5072 cleanup || error "cleanup failed with $?"
5074 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
5077 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5080 start_mds || error "MDS start fail"
5081 start_ost || error "OST0 start fail"
5083 mount_client $MOUNT || error "mount client fails"
5085 stop_mdt 2 || error "MDT1 start fail"
5087 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
5089 echo "deactivate $mdc_for_mdt2"
5090 $LCTL --device $mdc_for_mdt2 deactivate ||
5091 error "set $mdc_for_mdt2 deactivate failed"
5093 mkdir $DIR/$tdir || error "mkdir fail"
5094 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5095 error "create remote dir succeed"
5097 rm -rf $DIR/$tdir || error "delete dir fail"
5099 cleanup || error "cleanup failed with $?"
5101 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
5104 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5106 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.62) ] ||
5107 skip "Need MDS version at least 2.7.62"
5109 reformat || error "reformat failed with $?"
5113 local mdsdev=$(mdsdevname 1)
5114 local ostdev=$(ostdevname 1)
5115 local mdsvdev=$(mdsvdevname 1)
5116 local ostvdev=$(ostvdevname 1)
5117 local opts_mds="$(mkfs_opts mds1 $mdsdev) --reformat $mdsdev $mdsvdev"
5118 local opts_ost="$(mkfs_opts ost1 $ostdev) --reformat $ostdev $ostvdev"
5120 if ! combined_mgs_mds ; then
5124 add mds1 $opts_mds || error "add mds1 failed"
5125 start_mdt 1 || error "start mdt1 failed"
5126 add ost1 $opts_ost || error "add ost1 failed"
5127 start_ost || error "start ost failed"
5128 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
5130 local soc=$(do_facet mds1 "$LCTL get_param -n \
5131 mdt.*MDT0000.sync_lock_cancel")
5132 [ $soc == "never" ] || error "SoC enabled on single MDS"
5134 for i in $(seq 2 $MDSCOUNT); do
5135 mdsdev=$(mdsdevname $i)
5136 mdsvdev=$(mdsvdevname $i)
5137 opts_mds="$(mkfs_opts mds$i $mdsdev) --reformat $mdsdev \
5139 add mds$i $opts_mds || error "add mds$i failed"
5140 start_mdt $i || error "start mdt$i fail"
5143 wait_dne_interconnect
5145 for i in $(seq $MDSCOUNT); do
5146 soc=$(do_facet mds$i "$LCTL get_param -n \
5147 mdt.*MDT000$((i - 1)).sync_lock_cancel")
5148 [ $soc == "blocking" ] || error "SoC not enabled on DNE"
5151 for i in $(seq 2 $MDSCOUNT); do
5152 stop_mdt $i || error "stop mdt$i fail"
5154 soc=$(do_facet mds1 "$LCTL get_param -n \
5155 mdt.*MDT0000.sync_lock_cancel")
5156 [ $soc == "never" ] || error "SoC enabled on single MDS"
5157 umount_client $MOUNT -f > /dev/null
5159 cleanup || error "cleanup failed with $?"
5161 run_test 70e "Sync-on-Cancel will be enabled by default on DNE"
5164 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5165 if combined_mgs_mds; then
5166 skip "needs separate MGS/MDT"
5170 start_mdt 1 || error "MDT0 start fail"
5171 start_ost || error "OST0 start fail"
5172 for num in $(seq 2 $MDSCOUNT); do
5173 start_mdt $num || return
5176 start_ost2 || error "OST1 start fail"
5178 mount_client $MOUNT || error "mount client fails"
5180 mkdir $DIR/$tdir || error "mkdir fail"
5181 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5182 error "create remote dir succeed"
5184 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5185 rm -rf $DIR/$tdir || error "delete dir fail"
5187 umount_client $MOUNT || error "umount_client failed"
5188 stop_mds || error "MDS stop fail"
5189 stop_ost || error "OST0 stop fail"
5190 stop_ost2 || error "OST1 stop fail"
5192 run_test 71a "start MDT0 OST0, MDT1, OST1"
5195 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5196 if combined_mgs_mds; then
5197 skip "needs separate MGS/MDT"
5201 for num in $(seq 2 $MDSCOUNT); do
5202 start_mdt $num || return
5204 start_ost || error "OST0 start fail"
5205 start_mdt 1 || error "MDT0 start fail"
5206 start_ost2 || error "OST1 start fail"
5208 mount_client $MOUNT || error "mount client fails"
5210 mkdir $DIR/$tdir || error "mkdir fail"
5211 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5212 error "create remote dir succeed"
5214 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5215 rm -rf $DIR/$tdir || error "delete dir fail"
5217 umount_client $MOUNT || error "umount_client failed"
5218 stop_mds || error "MDT0 stop fail"
5219 stop_ost || error "OST0 stop fail"
5220 stop_ost2 || error "OST1 stop fail"
5222 run_test 71b "start MDT1, OST0, MDT0, OST1"
5225 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5226 combined_mgs_mds && skip "needs separate MGS/MDT"
5230 start_ost || error "OST0 start fail"
5231 start_ost2 || error "OST1 start fail"
5232 for num in $(seq 2 $MDSCOUNT); do
5233 start_mdt $num || return
5235 start_mdt 1 || error "MDT0 start fail"
5237 mount_client $MOUNT || error "mount client fails"
5239 mkdir $DIR/$tdir || error "mkdir fail"
5240 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5241 error "create remote dir succeed"
5243 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5244 rm -rf $DIR/$tdir || error "delete dir fail"
5246 umount_client $MOUNT || error "umount_client failed"
5247 stop_mds || error "MDS stop fail"
5248 stop_ost || error "OST0 stop fail"
5249 stop_ost2 || error "OST1 stop fail"
5252 run_test 71c "start OST0, OST1, MDT1, MDT0"
5255 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5256 combined_mgs_mds && skip "needs separate MGS/MDT"
5260 start_ost || error "OST0 start fail"
5261 for num in $(seq 2 $MDSCOUNT); do
5262 start_mdt $num || return
5264 start_mdt 1 || error "MDT0 start fail"
5265 start_ost2 || error "OST1 start fail"
5267 mount_client $MOUNT || error "mount client fails"
5269 mkdir $DIR/$tdir || error "mkdir fail"
5270 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5271 error "create remote dir succeed"
5273 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5274 rm -rf $DIR/$tdir || error "delete dir fail"
5276 umount_client $MOUNT || error "umount_client failed"
5277 stop_mds || error "MDS stop fail"
5278 stop_ost || error "OST0 stop fail"
5279 stop_ost2 || error "OST1 stop fail"
5282 run_test 71d "start OST0, MDT1, MDT0, OST1"
5285 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5286 combined_mgs_mds && skip "needs separate MGS/MDT"
5290 start_ost || error "OST0 start fail"
5291 for num in $(seq 2 $MDSCOUNT); do
5292 start_mdt $num || return
5294 start_ost2 || error "OST1 start fail"
5295 start_mdt 1 || error "MDT0 start fail"
5297 mount_client $MOUNT || error "mount client fails"
5299 mkdir $DIR/$tdir || error "mkdir fail"
5300 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5301 error "create remote dir succeed"
5303 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5304 rm -rf $DIR/$tdir || error "delete dir fail"
5306 umount_client $MOUNT || error "umount_client failed"
5307 stop_mds || error "MDS stop fail"
5308 stop_ost || error "OST0 stop fail"
5309 stop_ost2 || error "OST1 stop fail"
5312 run_test 71e "start OST0, MDT1, OST1, MDT0"
5314 test_72() { #LU-2634
5315 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
5316 skip "ldiskfs only test"
5318 local mdsdev=$(mdsdevname 1)
5319 local ostdev=$(ostdevname 1)
5320 local cmd="$E2FSCK -fnvd $mdsdev"
5327 if combined_mgs_mds; then
5328 add_options='--reformat'
5330 add_options='--reformat --replace'
5333 #tune MDT with "-O extents"
5335 for num in $(seq $MDSCOUNT); do
5336 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
5337 $add_options $(mdsdevname $num) $(mdsvdevname $num) ||
5338 error "add mds $num failed"
5339 do_facet mds${num} "$TUNE2FS -O extents $(mdsdevname $num)" ||
5340 error "$TUNE2FS failed on mds${num}"
5343 add ost1 $(mkfs_opts ost1 $ostdev) $add_options $ostdev ||
5344 error "add $ostdev failed"
5345 start_mds || error "start mds failed"
5346 start_ost || error "start ost failed"
5347 mount_client $MOUNT || error "mount client failed"
5349 #create some short symlinks
5350 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5351 createmany -o $DIR/$tdir/$tfile-%d $fn
5352 echo "create $fn short symlinks"
5353 for i in $(seq -w 1 $fn); do
5354 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
5359 umount_client $MOUNT || error "umount client failed"
5360 stop_mds || error "stop mds failed"
5361 stop_ost || error "stop ost failed"
5364 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
5366 run_test 72 "test fast symlink with extents flag enabled"
5368 test_73() { #LU-3006
5369 [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
5370 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
5371 error "1st tunefs failed"
5372 start_mgsmds || error "start mds failed"
5373 start_ost || error "start ost failed"
5374 mount_client $MOUNT || error "mount client failed"
5375 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
5376 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
5377 umount_client $MOUNT || error "umount client failed"
5381 run_test 73 "failnode to update from mountdata properly"
5383 test_75() { # LU-2374
5384 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
5385 skip "Need MDS version at least 2.4.1"
5388 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
5389 --replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
5390 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
5391 --replace --reformat $(ostdevname 1) $(ostvdevname 1)"
5393 #check with default parameters
5394 add mds1 $opts_mds || error "add mds1 failed for default params"
5395 add ost1 $opts_ost || error "add ost1 failed for default params"
5397 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
5398 opts_mds=$(echo $opts_mds |
5399 sed -e "s/--index=$index/--index=$index --mdt/")
5400 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
5401 opts_ost=$(echo $opts_ost |
5402 sed -e "s/--index=$index/--index=$index --ost/")
5404 add mds1 $opts_mds || error "add mds1 failed for new params"
5405 add ost1 $opts_ost || error "add ost1 failed for new params"
5410 run_test 75 "The order of --index should be irrelevant"
5413 [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] ||
5414 skip "Need MDS version at least 2.4.52"
5417 local MDMB_PARAM="osc.*.max_dirty_mb"
5418 echo "Change MGS params"
5419 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
5421 echo "max_dirty_mb: $MAX_DIRTY_MB"
5422 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB - 10))
5423 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
5424 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
5425 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5426 head -1" $NEW_MAX_DIRTY_MB
5427 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5428 echo "$MAX_DIRTY_MB"
5429 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5430 error "error while apply max_dirty_mb"
5432 echo "Check the value is stored after remount"
5435 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5436 head -1" $NEW_MAX_DIRTY_MB
5437 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5438 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5439 error "max_dirty_mb is not saved after remount"
5441 echo "Change OST params"
5442 CLIENT_PARAM="obdfilter.*.client_cache_count"
5443 local CLIENT_CACHE_COUNT
5444 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5446 echo "client_cache_count: $CLIENT_CACHE_COUNT"
5447 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
5448 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
5449 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
5450 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5451 head -1" $NEW_CLIENT_CACHE_COUNT
5452 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5454 echo "$CLIENT_CACHE_COUNT"
5455 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5456 error "error while apply client_cache_count"
5458 echo "Check the value is stored after remount"
5461 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5462 head -1" $NEW_CLIENT_CACHE_COUNT
5463 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5465 echo "$CLIENT_CACHE_COUNT"
5466 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5467 error "client_cache_count is not saved after remount"
5470 run_test 76a "set permanent params with lctl across mounts"
5472 test_76b() { # LU-4783
5473 [[ $(lustre_version_code mgs) -ge $(version_code 2.5.57) ]] ||
5474 skip "Need MGS version at least 2.5.57"
5477 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
5478 error "start params log failed"
5481 run_test 76b "verify params log setup correctly"
5484 [[ $(lustre_version_code mgs) -ge $(version_code 2.8.54) ]] ||
5485 skip "Need MDS version at least 2.4.52"
5487 local MASK_PARAM="mdd.*.changelog_mask"
5488 echo "Change changelog_mask"
5489 do_facet mgs $LCTL set_param -P $MASK_PARAM=-CLOSE ||
5490 error "Can't change changlog_mask"
5491 wait_update $(facet_host mds) "$LCTL get_param -n $MASK_PARAM |
5494 echo "Check the value is stored after mds remount"
5495 stop_mds || error "Failed to stop MDS"
5496 start_mds || error "Failed to start MDS"
5497 local CHANGELOG_MASK=$(do_facet mgs $LCTL get_param -n $MASK_PARAM)
5498 echo $CHANGELOG_MASK | grep CLOSE > /dev/null &&
5499 error "changelog_mask is not changed"
5503 run_test 76c "verify changelog_mask is applied with lctl set_param -P"
5505 test_76d() { #LU-9399
5508 local xattr_cache="llite.*.xattr_cache"
5509 local cmd="$LCTL get_param -n $xattr_cache | head -1"
5510 local new=$((($(eval $cmd) + 1) % 2))
5512 echo "lctl set_param -P llite.*.xattr_cache=$new"
5513 do_facet mgs $LCTL set_param -P $xattr_cache=$new ||
5514 error "Can't change xattr_cache"
5515 wait_update $HOSTNAME "$cmd" "$new"
5517 echo "Check $xattr_cache on client $MOUNT"
5518 umount_client $MOUNT || error "umount $MOUNT failed"
5519 mount_client $MOUNT || error "mount $MOUNT failed"
5520 [ $(eval $cmd) -eq $new ] ||
5521 error "$xattr_cache != $new on client $MOUNT"
5523 echo "Check $xattr_cache on the new client $MOUNT2"
5524 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
5525 [ $(eval $cmd) -eq $new ] ||
5526 error "$xattr_cache != $new on client $MOUNT2"
5527 umount_client $MOUNT2 || error "umount $MOUNT2 failed"
5531 run_test 76d "verify llite.*.xattr_cache can be set by 'lctl set_param -P' correctly"
5533 test_77() { # LU-3445
5534 local server_version=$(lustre_version_code $SINGLEMDS)
5535 [[ $server_version -ge $(version_code 2.8.55) ]] ||
5536 skip "Need MDS version 2.8.55+ "
5538 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
5539 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
5540 skip_env "mixed loopback and real device not working"
5543 local fs2mdsdev=$(mdsdevname 1_2)
5544 local fs2ostdev=$(ostdevname 1_2)
5545 local fs2mdsvdev=$(mdsvdevname 1_2)
5546 local fs2ostvdev=$(ostvdevname 1_2)
5547 local fsname=test1234
5549 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
5551 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
5553 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
5554 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
5555 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
5556 error "start fs2mds failed"
5558 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
5559 mgsnid="0.0.0.0@tcp,$mgsnid,$mgsnid:$mgsnid"
5561 add fs2ost --mgsnode=$mgsnid $(mkfs_opts ost1 $fs2ostdev) \
5562 --failnode=$failnid --fsname=$fsname \
5563 --reformat $fs2ostdev $fs2ostvdev ||
5564 error "add fs2ost failed"
5565 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
5567 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
5568 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
5569 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
5572 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
5575 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ||
5576 $(facet_fstype ost1) != ldiskfs ]] &&
5577 skip "ldiskfs only test"
5579 # reformat the Lustre filesystem with a smaller size
5580 local saved_MDSCOUNT=$MDSCOUNT
5581 local saved_MDSSIZE=$MDSSIZE
5582 local saved_OSTCOUNT=$OSTCOUNT
5583 local saved_OSTSIZE=$OSTSIZE
5586 MDSSIZE=$((MDSSIZE - 20000))
5587 OSTSIZE=$((OSTSIZE - 20000))
5588 reformat || error "(1) reformat Lustre filesystem failed"
5589 MDSSIZE=$saved_MDSSIZE
5590 OSTSIZE=$saved_OSTSIZE
5592 # mount the Lustre filesystem
5593 setup_noconfig || error "(2) setup Lustre filesystem failed"
5596 log "create test files"
5601 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
5603 for i in $(seq $num_files); do
5604 file=$MOUNT/$tdir/$tfile-$i
5605 dd if=/dev/urandom of=$file count=1 bs=1M || {
5606 $LCTL get_param osc.*.cur*grant*
5607 $LFS df; $LFS df -i;
5608 # stop creating files if there is no more space
5609 if [ ! -e $file ]; then
5610 num_files=$((i - 1))
5614 $LFS getstripe -v $file
5615 local ost_idx=$(LFS getstripe -i $file)
5616 do_facet ost$((ost_idx + 1)) \
5617 $LCTL get_param obdfilter.*.*grant*
5618 error "(4) create $file failed"
5622 # unmount the Lustre filesystem
5623 cleanup || error "(5) cleanup Lustre filesystem failed"
5625 # run e2fsck on the MDT and OST devices
5626 local mds_host=$(facet_active_host $SINGLEMDS)
5627 local ost_host=$(facet_active_host ost1)
5628 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
5629 local ost_dev=$(ostdevname 1)
5631 run_e2fsck $mds_host $mds_dev "-y"
5632 run_e2fsck $ost_host $ost_dev "-y"
5634 # get the original block count of the MDT and OST filesystems
5635 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
5636 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
5638 # expand the MDT and OST filesystems to the device size
5639 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
5640 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
5642 # run e2fsck on the MDT and OST devices again
5643 run_e2fsck $mds_host $mds_dev "-y"
5644 run_e2fsck $ost_host $ost_dev "-y"
5646 # mount the Lustre filesystem
5650 log "check files after expanding the MDT and OST filesystems"
5651 for i in $(seq $num_files); do
5652 file=$MOUNT/$tdir/$tfile-$i
5653 $CHECKSTAT -t file -s 1048576 $file ||
5654 error "(6) checkstat $file failed"
5658 log "create more files after expanding the MDT and OST filesystems"
5659 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
5660 file=$MOUNT/$tdir/$tfile-$i
5661 dd if=/dev/urandom of=$file count=1 bs=1M ||
5662 error "(7) create $file failed"
5665 # unmount the Lustre filesystem
5666 cleanup || error "(8) cleanup Lustre filesystem failed"
5668 # run e2fsck on the MDT and OST devices
5669 run_e2fsck $mds_host $mds_dev "-y"
5670 run_e2fsck $ost_host $ost_dev "-y"
5672 # get the maximum block count of the MDT and OST filesystems
5673 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
5674 local ost_max_blks=$(get_block_count ost1 $ost_dev)
5676 # get the minimum block count of the MDT and OST filesystems
5677 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
5678 grep minimum | sed -e 's/^.*filesystem: //g')
5679 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
5680 grep minimum | sed -e 's/^.*filesystem: //g')
5682 # shrink the MDT and OST filesystems to a smaller size
5686 if [[ $mds_max_blks -gt $mds_min_blks &&
5687 $mds_max_blks -gt $mds_orig_blks ]]; then
5688 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
5689 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
5690 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
5691 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
5692 error "shrink $SINGLEMDS to $new_blks failed"
5696 if [[ $ost_max_blks -gt $ost_min_blks &&
5697 $ost_max_blks -gt $ost_orig_blks ]]; then
5698 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
5699 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
5700 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
5701 run_resize2fs ost1 $ost_dev $new_blks ||
5702 error "shrink ost1 to $new_blks failed"
5706 # check whether the MDT or OST filesystem was shrunk or not
5708 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
5709 reformat_and_config ||
5710 error "(10) reformat Lustre filesystem failed"
5714 # run e2fsck on the MDT and OST devices again
5715 run_e2fsck $mds_host $mds_dev "-y"
5716 run_e2fsck $ost_host $ost_dev "-y"
5718 # mount the Lustre filesystem again
5722 log "check files after shrinking the MDT and OST filesystems"
5723 for i in $(seq $((num_files + 10))); do
5724 file=$MOUNT/$tdir/$tfile-$i
5725 $CHECKSTAT -t file -s 1048576 $file ||
5726 error "(11) checkstat $file failed"
5729 # unmount and reformat the Lustre filesystem
5730 cleanup || error "(12) cleanup Lustre filesystem failed"
5731 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
5733 MDSCOUNT=$saved_MDSCOUNT
5734 OSTCOUNT=$saved_OSTCOUNT
5735 reformat_and_config || error "(14) reformat Lustre filesystem failed"
5737 run_test 78 "run resize2fs on MDT and OST filesystems"
5739 test_79() { # LU-4227
5740 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.59) ]] ||
5741 skip "Need MDS version at least 2.5.59"
5743 local mdsdev1=$(mdsdevname 1)
5744 local mdsvdev1=$(mdsvdevname 1)
5745 local mdsdev2=$(mdsdevname 2)
5746 local mdsvdev2=$(mdsvdevname 2)
5747 local ostdev1=$(ostdevname 1)
5748 local ostvdev1=$(ostvdevname 1)
5749 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
5750 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
5751 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
5754 # remove --mgs/--mgsnode from mkfs.lustre options
5755 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
5757 mgsnode_opt=$(echo $opts_mds2 |
5758 awk '{ for ( i = 1; i < NF; i++ )
5759 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5760 [ -n $mgsnode_opt ] &&
5761 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
5763 mgsnode_opt=$(echo $opts_ost1 |
5764 awk '{ for ( i = 1; i < NF; i++ )
5765 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5766 [ -n $mgsnode_opt ] &&
5767 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
5769 # -MGS, format a mdt without --mgs option
5770 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
5771 error "Must specify --mgs when formatting mdt combined with mgs"
5773 # +MGS, format a mdt/ost without --mgsnode option
5774 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
5775 > /dev/null || error "start mds1 failed"
5776 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
5777 error "Must specify --mgsnode when formatting a mdt"
5778 add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
5779 error "Must specify --mgsnode when formatting an ost"
5783 run_test 79 "format MDT/OST without mgs option (should return errors)"
5786 start_mds || error "Failed to start MDT"
5787 start_ost || error "Failed to start OST1"
5788 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
5789 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
5790 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
5791 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
5792 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
5794 start_ost2 || error "Failed to start OST2"
5796 do_facet ost1 "$LCTL set_param fail_loc=0"
5801 run_test 80 "mgc import reconnect race"
5803 #Save the original values of $OSTCOUNT and $OSTINDEX$i.
5805 local new_ostcount=$1
5806 saved_ostcount=$OSTCOUNT
5807 OSTCOUNT=$new_ostcount
5811 for i in $(seq $OSTCOUNT); do
5813 eval saved_ostindex$i=${!index}
5818 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
5819 restore_ostindex() {
5824 for i in $(seq $OSTCOUNT); do
5825 index=saved_ostindex$i
5826 eval OSTINDEX$i=${!index}
5828 OSTCOUNT=$saved_ostcount
5831 if ! combined_mgs_mds ; then
5836 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
5837 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
5838 # assigned index and ensures we can mount such a formatted file system
5839 test_81() { # LU-4665
5840 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5841 skip "Need MDS version at least 2.6.54"
5842 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5846 # Each time RANDOM is referenced, a random integer between 0 and 32767
5849 local saved_ostindex1=$OSTINDEX1
5850 for i in 65535 $((RANDOM + 65536)); do
5851 echo -e "\nFormat ost1 with --index=$i, should fail"
5853 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
5854 $(ostdevname 1) $(ostvdevname 1); then
5855 OSTINDEX1=$saved_ostindex1
5856 error "format ost1 with --index=$i should fail"
5859 OSTINDEX1=$saved_ostindex1
5863 # Format OSTs with random sparse indices.
5864 trap "restore_ostindex" EXIT
5865 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices"
5866 OST_INDEX_LIST=[0,$((RANDOM * 2 % 65533 + 1)),65534] formatall
5868 # Setup and check Lustre filesystem.
5869 start_mgsmds || error "start_mgsmds failed"
5870 for i in $(seq $OSTCOUNT); do
5871 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5872 error "start ost$i failed"
5875 mount_client $MOUNT || error "mount client $MOUNT failed"
5876 check_mount || error "check client $MOUNT failed"
5879 local max_easize=$($LCTL get_param -n llite.*.max_easize)
5880 if [ $MDS1_VERSION -lt $(version_code 2.12.51) ]
5882 [[ $max_easize -eq 128 ]] ||
5883 error "max_easize is $max_easize, should be 128 bytes"
5886 # 4012 is 4096 - ldiskfs ea overhead
5887 [[ $max_easize -ge 4012 ]] ||
5888 error "max_easize is $max_easize, should be at least 4012 bytes"
5890 # 65452 is XATTR_SIZE_MAX - ldiskfs ea overhead
5891 if large_xattr_enabled;
5893 [[ $max_easize -ge 65452 ]] ||
5894 error "max_easize is $max_easize, should be at least 65452 bytes"
5900 run_test 81 "sparse OST indexing"
5902 # Here we exercise the stripe placement functionality on a file system that
5903 # has formatted the OST with a random index. With the file system the following
5904 # functionality is tested:
5906 # 1. Creating a new file with a specific stripe layout.
5908 # 2. Modifiy a existing empty file with a specific stripe layout.
5910 # 3. Ensure we fail to set the stripe layout of a file that already has one.
5912 # 4. If ost-index is defined we need to ensure it is the first entry in the
5913 # ost index list returned by lfs getstripe.
5915 # 5. Lastly ensure this functionality fails with directories.
5916 test_82a() { # LU-4665
5917 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
5918 skip "Need MDS version at least 2.6.54"
5919 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5925 # Format OSTs with random sparse indices.
5929 local LOV_V1_INSANE_STRIPE_COUNT=65532
5930 for i in $(seq $OSTCOUNT); do
5931 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
5932 ost_indices+=" $index"
5934 ost_indices=$(comma_list $ost_indices)
5936 stack_trap "restore_ostindex" EXIT
5937 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5938 OST_INDEX_LIST=[$ost_indices] formatall
5940 # Setup Lustre filesystem.
5941 start_mgsmds || error "start_mgsmds failed"
5942 for i in $(seq $OSTCOUNT); do
5943 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5944 error "start ost$i failed"
5947 # Collect debug information - start of test
5948 do_nodes $(comma_list $(mdts_nodes)) \
5949 $LCTL get_param osp.*.prealloc_*_id
5951 mount_client $MOUNT || error "mount client $MOUNT failed"
5954 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
5955 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5957 stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
5958 $LCTL get_param osp.*.prealloc_*_id" EXIT
5960 # 1. If the file does not exist, new file will be created
5961 # with specified OSTs.
5962 local file=$DIR/$tdir/$tfile-1
5963 local cmd="$LFS setstripe -o $ost_indices $file"
5965 eval $cmd || error "$cmd failed"
5966 check_stripe_count $file $OSTCOUNT
5967 check_obdidx $file $ost_indices
5968 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5969 error "write $file failed"
5971 # 2. If the file already exists and is an empty file, the file
5972 # will be attached with specified layout.
5973 file=$DIR/$tdir/$tfile-2
5974 mcreate $file || error "mcreate $file failed"
5975 cmd="$LFS setstripe -o $ost_indices $file"
5977 eval $cmd || error "$cmd failed"
5978 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
5979 error "write $file failed"
5980 check_stripe_count $file $OSTCOUNT
5981 check_obdidx $file $ost_indices
5983 # 3. If the file already has a valid layout attached, the command
5984 # should fail with EBUSY.
5986 eval $cmd && error "stripe is already set on $file, $cmd should fail"
5988 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
5989 # be in the OST indices list.
5990 local start_ost_idx=${ost_indices##*,}
5991 file=$DIR/$tdir/$tfile-3
5992 cmd="$LFS setstripe -o $ost_indices -i $start_ost_idx $file"
5994 eval $cmd || error "$cmd failed"
5995 check_stripe_count $file $OSTCOUNT
5996 check_obdidx $file $ost_indices
5997 check_start_ost_idx $file $start_ost_idx
5999 file=$DIR/$tdir/$tfile-4
6000 cmd="$LFS setstripe"
6001 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
6002 cmd+=" -i $start_ost_idx $file"
6004 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
6006 # 5. Specifying OST indices for directory should succeed.
6007 local dir=$DIR/$tdir/$tdir
6008 mkdir $dir || error "mkdir $dir failed"
6009 cmd="$LFS setstripe -o $ost_indices $dir"
6010 if [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.11.53) &&
6011 $(lustre_version_code client -gt $(version_code 2.11.53)) ]]; then
6013 eval $cmd || error "unable to specify OST indices on directory"
6015 echo "need MDS+client version at least 2.11.53"
6020 run_test 82a "specify OSTs for file (succeed) or directory (succeed)"
6025 # Remove OSTs from a pool and destroy the pool.
6026 destroy_pool $ost_pool || true
6028 if ! combined_mgs_mds ; then
6034 # Test 82b is run to ensure that if the user supplies a pool with a specific
6035 # stripe layout that it behaves proprerly. It should fail in the case that
6036 # the supplied OST index list points to OSTs not contained in the user
6038 test_82b() { # LU-4665
6039 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
6040 skip "Need MDS version at least 2.6.54"
6041 [[ $OSTCOUNT -ge 4 ]] || skip_env "needs >= 4 OSTs"
6047 # Format OSTs with random sparse indices.
6051 local LOV_V1_INSANE_STRIPE_COUNT=65532
6052 for i in $(seq $OSTCOUNT); do
6053 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
6054 ost_indices+=" $index"
6056 ost_indices=$(comma_list $ost_indices)
6058 trap "restore_ostindex" EXIT
6059 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
6060 OST_INDEX_LIST=[$ost_indices] formatall
6062 # Setup Lustre filesystem.
6063 start_mgsmds || error "start_mgsmds failed"
6064 for i in $(seq $OSTCOUNT); do
6065 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
6066 error "start ost$i failed"
6069 mount_client $MOUNT || error "mount client $MOUNT failed"
6070 if ! combined_mgs_mds ; then
6075 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
6076 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6078 # Create a new pool and add OSTs into it.
6079 local ost_pool=$FSNAME.$TESTNAME
6080 create_pool $ost_pool || error "create OST pool $ost_pool failed"
6083 trap "cleanup_82b" EXIT
6085 local ost_idx_in_list=${ost_indices##*,}
6086 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
6089 local ost_targets="$FSNAME-OST["
6090 for i in ${ost_idx_in_pool//,/ }; do
6091 ost_targets=$ost_targets$(printf "%04x," $i)
6093 ost_targets="${ost_targets%,}]"
6095 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
6096 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
6097 sort -u | tr '\n' ' ')
6099 local cmd="$LCTL pool_add $ost_pool $ost_targets"
6100 do_facet mgs $cmd || error "$cmd failed"
6101 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
6102 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
6103 error "wait_update $ost_pool failed"
6104 wait_update_facet $SINGLEMDS "$LCTL pool_list $ost_pool | wc -l" 4 ||
6105 error "wait_update pool_list $ost_pool failed"
6107 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
6108 # then the OSTs must be the members of the pool.
6109 local file=$DIR/$tdir/$tfile
6110 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6112 eval $cmd && error "OST with index $ost_idx_in_list should be" \
6113 "in OST pool $ost_pool"
6115 # Only select OST $ost_idx_in_list from $ost_pool for file.
6116 ost_idx_in_list=${ost_idx_in_pool#*,}
6117 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6119 eval $cmd || error "$cmd failed"
6120 cmd="$LFS getstripe $file"
6122 eval $cmd || error "$cmd failed"
6123 check_stripe_count $file 2
6124 check_obdidx $file $ost_idx_in_list
6125 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6126 error "write $file failed"
6130 run_test 82b "specify OSTs for file with --pool and --ost-list options"
6133 [[ $(lustre_version_code ost1) -ge $(version_code 2.6.91) ]] ||
6134 skip "Need OST version at least 2.6.91"
6135 if [ $(facet_fstype ost1) != ldiskfs ]; then
6136 skip "ldiskfs only test"
6145 ostmnt=$(facet_mntpt ost1)
6146 fstype=$(facet_fstype ost1)
6148 # Mount the OST as an ldiskfs filesystem.
6149 log "mount the OST $dev as a $fstype filesystem"
6150 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
6151 --reformat $dev > /dev/null ||
6152 error "format ost1 error"
6154 if ! test -b $dev; then
6155 mnt_opts=$(csa_add "$OST_MOUNT_OPTS" -o loop)
6157 echo "mnt_opts $mnt_opts"
6158 do_facet ost1 mount -t $fstype $dev \
6160 # Run llverfs on the mounted ldiskfs filesystem.
6161 # It is needed to get ENOSPACE.
6162 log "run llverfs in partial mode on the OST $fstype $ostmnt"
6163 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
6164 "no" || error "run_llverfs error on $fstype"
6167 log "unmount the OST $dev"
6170 # Delete file IO_scrub. Later osd_scrub_setup will try to
6171 # create "IO_scrub" but will get ENOSPACE.
6173 echo "start ost1 service on `facet_active_host ost1`"
6174 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
6177 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
6178 echo "string err $err"
6179 [ -z "$err" ] || error $err
6182 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
6183 Busy inodes after unmount ..."
6186 local facet=$SINGLEMDS
6187 local num=$(echo $facet | tr -d "mds")
6188 local dev=$(mdsdevname $num)
6189 local time_min=$(recovery_time_min)
6190 local recovery_duration
6191 local completed_clients
6192 local correct_clients
6195 echo "start mds service on $(facet_active_host $facet)"
6197 "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" $@ ||
6198 error "start MDS failed"
6200 start_ost || error "start OST0000 failed"
6201 start_ost2 || error "start OST0001 failed"
6203 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
6205 mount_client $MOUNT1 || error "mount $MOUNT1 failed"
6206 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
6207 # make sure new superblock labels are sync'd before disabling writes
6211 replay_barrier $SINGLEMDS
6212 createmany -o $DIR1/$tfile-%d 1000
6214 # We need to catch the end of recovery window to extend it.
6215 # Skip 5 requests and add delay to request handling.
6216 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
6217 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
6219 facet_failover --fsck $SINGLEMDS || error "failover: $?"
6222 echo "recovery status"
6223 do_facet $SINGLEMDS \
6224 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
6226 recovery_duration=$(do_facet $SINGLEMDS \
6227 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6228 awk '/recovery_duration/ { print $2 }')
6229 (( $recovery_duration > $time_min + $wrap_up )) &&
6230 error "recovery_duration > recovery_time_hard + wrap up"
6231 completed_clients=$(do_facet $SINGLEMDS \
6232 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6233 awk '/completed_clients/ { print $2 }')
6235 correct_clients="$MDSCOUNT/$((MDSCOUNT+1))"
6236 [ "$completed_clients" = "${correct_clients}" ] ||
6237 error "$completed_clients != $correct_clients"
6239 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
6240 umount_client $MOUNT1
6241 umount_client $MOUNT2
6247 run_test 84 "check recovery_hard_time"
6250 [[ $(lustre_version_code ost1) -ge $(version_code 2.7.55) ]] ||
6251 skip "Need OST version at least 2.7.55"
6252 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
6253 do_facet ost1 "lctl set_param fail_loc=0x197"
6257 run_test 85 "osd_ost init: fail ea_fid_set"
6262 # ost1 has already registered to the MGS before the reformat.
6263 # So after reformatting it with option "-G", it could not be
6264 # mounted to the MGS. Cleanup the system for subsequent tests.
6269 local server_version=$(lustre_version_code $SINGLEMDS)
6270 [ "$(facet_fstype ost1)" = "zfs" ] &&
6271 skip "LU-6442: no such mkfs params for ZFS OSTs"
6272 [[ $server_version -ge $(version_code 2.7.56) ]] ||
6273 skip "Need server version newer than 2.7.55"
6275 local OST_OPTS="$(mkfs_opts ost1 $(ostdevname 1)) \
6276 --reformat $(ostdevname 1) $(ostvdevname 1)"
6279 local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6280 awk '/Flex block group size: / { print $NF; exit; }')
6283 if [[ ${!opts} != *mkfsoptions* ]]; then
6284 eval opts=\"${!opts} \
6285 --mkfsoptions='\\\"-O flex_bg -G $NEWSIZE\\\"'\"
6287 val=${!opts//--mkfsoptions=\\\"/ \
6288 --mkfsoptions=\\\"-O flex_bg -G $NEWSIZE }
6292 echo "params: $opts"
6294 trap cleanup_86 EXIT ERR
6297 add ost1 $opts || error "add ost1 failed with new params"
6299 local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6300 awk '/Flex block group size: / { print $NF; exit; }')
6302 [[ $FOUNDSIZE == $NEWSIZE ]] ||
6303 error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
6307 run_test 86 "Replacing mkfs.lustre -G option"
6309 test_87() { #LU-6544
6310 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.9.51) ]] ||
6311 skip "Need MDS version at least 2.9.51"
6312 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
6313 skip "ldiskfs only test"
6314 [[ $OSTCOUNT -gt 59 ]] &&
6315 skip "Ignore wide striping situation"
6317 local mdsdev=$(mdsdevname 1)
6318 local mdsvdev=$(mdsvdevname 1)
6319 local file=$DIR/$tfile
6320 local mntpt=$(facet_mntpt $SINGLEMDS)
6321 local used_xattr_blk=0
6322 local inode_size=${1:-1024}
6324 local xtest="trusted.test"
6328 local stripe_cnt=$(($OSTCOUNT + 2))
6330 #Please see ldiskfs_make_lustre() for MDT inode size calculation
6331 if [ $stripe_cnt -gt 16 ]; then
6334 left_size=$(expr $inode_size - \
6337 32 - 40 \* 3 - 32 \* 3 - $stripe_cnt \* 24 - 16 - 3 - \
6339 24 - 18 - $(expr length $tfile) - 16 - 4)
6340 if [ $left_size -le 0 ]; then
6341 echo "No space($left_size) is expected in inode."
6342 echo "Try 1-byte xattr instead to verify this."
6345 echo "Estimate: at most $left_size-byte space left in inode."
6351 if ! combined_mgs_mds ; then
6355 add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$stripe_cnt \
6356 --reformat $mdsdev $mdsvdev || error "add mds1 failed"
6357 start_mdt 1 > /dev/null || error "start mdt1 failed"
6358 for i in $(seq $OSTCOUNT); do
6359 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
6360 error "start ost$i failed"
6362 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
6363 check_mount || error "check client $MOUNT failed"
6366 $LFS setstripe -E 1M -S 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
6367 error "Create file with 3 components failed"
6368 $TRUNCATE $file $((1024*1024*64+1)) || error "truncate file failed"
6369 i=$($LFS getstripe -I3 -c $file) || error "get 3rd stripe count failed"
6370 if [ $i -ne $OSTCOUNT ]; then
6371 left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
6372 echo -n "Since only $i out $OSTCOUNT OSTs are used, "
6373 echo -n "the expected left space is changed to "
6374 echo "$left_size bytes at most."
6376 value=$(generate_string $left_size)
6377 setfattr -n $xtest -v $value $file
6378 orig=$(get_xattr_value $xtest $file)
6379 [[ "$orig" != "$value" ]] && error "$xtest changed"
6381 #Verify if inode has some expected space left
6382 umount $MOUNT > /dev/null || error "umount $MOUNT failed"
6383 stop_mdt 1 > /dev/null || error "stop mdt1 failed"
6384 mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
6386 do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
6387 used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
6389 [[ $used_xattr_blk -eq 0 ]] &&
6390 error "Please check MDS inode size calculation: \
6391 more than $left_size-byte space left in inode."
6392 echo "Verified: at most $left_size-byte space left in inode."
6394 umount_ldiskfs $SINGLEMDS
6396 for i in $(seq $OSTCOUNT); do
6397 stop ost$i -f || error "stop ost$i failed"
6400 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
6403 [ "$(facet_fstype mds1)" == "zfs" ] &&
6404 skip "LU-6662: no implementation for ZFS"
6408 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6409 --reformat $(mdsdevname 1) || error "add mds1 failed"
6411 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6412 grep -e \".*opts:.*errors=remount-ro.*\"" ||
6413 error "default mount options is missing"
6415 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6416 --mountfsoptions="user_xattr,errors=panic" \
6417 --reformat $(mdsdevname 1) || error "add mds1 failed"
6419 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6420 grep -e \".*opts:.*errors=panic.*\"" ||
6421 error "user can't override default mount options"
6423 run_test 88 "check the default mount options can be overridden"
6425 test_89() { # LU-7131
6426 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.9.54) ]] ||
6427 skip "Need MDT version at least 2.9.54"
6429 local key=failover.node
6430 local val1=192.0.2.254@tcp0 # Reserved IPs, see RFC 5735
6431 local val2=192.0.2.255@tcp0
6432 local mdsdev=$(mdsdevname 1)
6437 [ $(facet_fstype mds1) == zfs ] && import_zpool mds1
6438 # Check that parameters are added correctly
6439 echo "tunefs --param $key=$val1"
6440 do_facet mds "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
6441 error "tunefs --param $key=$val1 failed"
6442 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6443 error "tunefs --dryrun failed"
6444 params=${params##*Parameters:}
6445 params=${params%%exiting*}
6446 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val1) = "1" ] ||
6447 error "on-disk parameter not added correctly via tunefs"
6449 # Check that parameters replace existing instances when added
6450 echo "tunefs --param $key=$val2"
6451 do_facet mds "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
6452 error "tunefs --param $key=$val2 failed"
6453 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6454 error "tunefs --dryrun failed"
6455 params=${params##*Parameters:}
6456 params=${params%%exiting*}
6457 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "1" ] ||
6458 error "on-disk parameter not replaced via tunefs"
6459 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val2) = "1" ] ||
6460 error "on-disk parameter not replaced correctly via tunefs"
6462 # Check that a parameter is erased properly
6463 echo "tunefs --erase-param $key"
6464 do_facet mds "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
6465 error "tunefs --erase-param $key failed"
6466 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6467 error "tunefs --dryrun failed"
6468 params=${params##*Parameters:}
6469 params=${params%%exiting*}
6470 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "0" ] ||
6471 error "on-disk parameter not erased correctly via tunefs"
6473 # Check that all the parameters are erased
6474 echo "tunefs --erase-params"
6475 do_facet mds "$TUNEFS --erase-params $mdsdev >/dev/null" ||
6476 error "tunefs --erase-params failed"
6477 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6478 error "tunefs --dryrun failed"
6479 params=${params##*Parameters:}
6480 params=${params%%exiting*}
6482 error "all on-disk parameters not erased correctly via tunefs"
6484 # Check the order of options --erase-params and --param
6485 echo "tunefs --param $key=$val1 --erase-params"
6487 "$TUNEFS --param $key=$val1 --erase-params $mdsdev >/dev/null"||
6488 error "tunefs --param $key=$val1 --erase-params failed"
6489 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6490 error "tunefs --dryrun failed"
6491 params=${params##*Parameters:}
6492 params=${params%%exiting*}
6493 [ $(echo $params | tr ' ' '\n') == "$key=$val1" ] ||
6494 error "on-disk param not added correctly with --erase-params"
6498 run_test 89 "check tunefs --param and --erase-param{s} options"
6501 # $2 (optional) value of max_mod_rpcs_in_flight to set
6502 check_max_mod_rpcs_in_flight() {
6510 idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
6511 facet="mds$((0x$idx + 1))"
6513 if [ -z "$mmr" ]; then
6514 # get value of max_mod_rcps_in_flight
6515 mmr=$($LCTL get_param -n \
6516 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
6517 error "Unable to get max_mod_rpcs_in_flight"
6518 echo "max_mod_rcps_in_flight is $mmr"
6520 # set value of max_mod_rpcs_in_flight
6522 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
6523 error "Unable to set max_mod_rpcs_in_flight to $mmr"
6524 echo "max_mod_rpcs_in_flight set to $mmr"
6527 # create mmr+1 files
6528 echo "creating $((mmr + 1)) files ..."
6530 for i in $(seq $((mmr + 1))); do
6536 # consumes mmr-1 modify RPC slots
6537 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6538 # drop requests on MDT so that RPC slots are consumed
6539 # during all the request resend interval
6540 do_facet $facet "$LCTL set_param fail_loc=0x159"
6541 echo "launch $((mmr - 1)) chmod in parallel ..."
6542 for i in $(seq $((mmr - 1))); do
6543 chmod 0600 $dir/file-$i &
6547 # send one additional modify RPC
6548 do_facet $facet "$LCTL set_param fail_loc=0"
6549 echo "launch 1 additional chmod in parallel ..."
6550 chmod 0600 $dir/file-$mmr &
6553 # check this additional modify RPC get a modify RPC slot
6554 # and succeed its operation
6555 checkstat -vp 0600 $dir/file-$mmr ||
6556 error "Unable to send $mmr modify RPCs in parallel"
6561 # consumes mmr modify RPC slots
6562 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6563 # drop requests on MDT so that RPC slots are consumed
6564 # during all the request resend interval
6565 do_facet $facet "$LCTL set_param fail_loc=0x159"
6566 echo "launch $mmr chmod in parallel ..."
6567 for i in $(seq $mmr); do
6568 chmod 0666 $dir/file-$i &
6572 # send one additional modify RPC
6573 do_facet $facet "$LCTL set_param fail_loc=0"
6574 echo "launch 1 additional chmod in parallel ..."
6575 chmod 0666 $dir/file-$((mmr + 1)) &
6578 # check this additional modify RPC blocked getting a modify RPC slot
6579 checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
6580 error "Unexpectedly send $(($mmr + 1)) modify RPCs in parallel"
6587 [[ $($LCTL get_param mdc.*.import |
6588 grep "connect_flags:.*multi_mod_rpc") ]] ||
6589 skip "Need MDC with 'multi_mod_rpcs' feature"
6591 # check default value
6592 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6593 check_max_mod_rpcs_in_flight $DIR/$tdir
6597 run_test 90a "check max_mod_rpcs_in_flight is enforced"
6607 [[ $($LCTL get_param mdc.*.import |
6608 grep "connect_flags:.*multi_mod_rpc") ]] ||
6609 skip "Need MDC with 'multi_mod_rpcs' feature"
6612 # update max_mod_rpcs_in_flight
6613 $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
6614 check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
6617 # check client is able to send multiple modify RPCs in paralell
6618 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6619 grep -c "multi_mod_rpcs")
6620 if [ "$tmp" -ne $MDSCOUNT ]; then
6622 skip "Client not able to send multiple modify RPCs in parallel"
6625 # update max_mod_rpcs_in_flight
6626 $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
6627 check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
6630 $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
6631 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
6632 facet="mds$((0x$idx + 1))"
6634 # save MDT max_mod_rpcs_per_client
6635 mmrpc=$(do_facet $facet \
6636 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6638 # update max_mod_rpcs_in_flight
6639 umount_client $MOUNT
6641 "echo 16 > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6643 $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
6644 check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
6646 # restore MDT max_mod_rpcs_per_client initial value
6648 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6650 rm -rf $DIR/${tdir}?
6653 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
6662 [[ $($LCTL get_param mdc.*.import |
6663 grep "connect_flags:.*multi_mod_rpc") ]] ||
6664 skip "Need MDC with 'multi_mod_rpcs' feature"
6666 # check client is able to send multiple modify RPCs in paralell
6667 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6668 grep -c "multi_mod_rpcs")
6669 if [ "$tmp" -ne $MDSCOUNT ]; then
6671 skip "Client not able to send multiple modify RPCs in parallel"
6674 # get max_rpcs_in_flight value
6675 mrif=$($LCTL get_param -n mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6676 echo "max_rpcs_in_flight is $mrif"
6678 # get MDT max_mod_rpcs_per_client
6679 mmrpc=$(do_facet mds1 \
6680 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6681 echo "max_mod_rpcs_per_client is $mmrpc"
6684 # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
6685 # prerequisite: set max_mod_rpcs_per_client to max_rpcs_in_flight value
6686 umount_client $MOUNT
6688 "echo $mrif > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6692 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif &&
6693 error "set max_mod_rpcs_in_flight to $mrif should fail"
6695 umount_client $MOUNT
6697 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6701 # attempt to set max_mod_rpcs_in_flight to max_mod_rpcs_per_client+1
6702 # prerequisite: set max_rpcs_in_flight to max_mod_rpcs_per_client+2
6704 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc + 2))
6707 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc + 1)) &&
6708 error "set max_mod_rpcs_in_flight to $((mmrpc + 1)) should fail"
6712 run_test 90c "check max_mod_rpcs_in_flight update limits"
6723 [[ $($LCTL get_param mdc.*.import |
6724 grep "connect_flags:.*multi_mod_rpc") ]] ||
6725 skip "Need MDC with 'multi_mod_rpcs' feature"
6727 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6728 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
6729 facet="mds$((0x$idx + 1))"
6731 # check client version supports multislots
6732 tmp=$($LCTL get_param -N \
6733 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6734 if [ -z "$tmp" ]; then
6736 skip "Client does not support multiple modify RPCs in flight"
6739 # get current value of max_mod_rcps_in_flight
6740 mmr=$($LCTL get_param -n \
6741 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6742 echo "max_mod_rcps_in_flight is $mmr"
6745 echo "creating $mmr files ..."
6747 for i in $(seq $mmr); do
6748 touch $DIR/$tdir/file-$i
6751 # prepare for close RPC
6752 multiop_bg_pause $DIR/$tdir/file-close O_c
6755 # consumes mmr modify RPC slots
6756 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6757 # drop requests on MDT so that RPC slots are consumed
6758 # during all the request resend interval
6759 do_facet $facet "$LCTL set_param fail_loc=0x159"
6760 echo "launch $mmr chmod in parallel ..."
6761 for i in $(seq $mmr); do
6762 chmod 0600 $DIR/$tdir/file-$i &
6765 # send one additional close RPC
6766 do_facet $facet "$LCTL set_param fail_loc=0"
6767 echo "launch 1 additional close in parallel ..."
6769 cancel_lru_locks mdc
6772 # check this additional close RPC get a modify RPC slot
6773 # and multiop process completed
6774 [ -d /proc/$pid ] &&
6775 error "Unable to send the additional close RPC in parallel"
6780 run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
6782 check_uuid_on_ost() {
6784 do_facet ost1 "$LCTL get_param obdfilter.${FSNAME}*.exports.'$nid'.uuid"
6787 check_uuid_on_mdt() {
6789 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6797 [[ $(lustre_version_code ost1) -ge $(version_code 2.7.63) ]] ||
6798 skip "Need OST version at least 2.7.63"
6799 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.63) ]] ||
6800 skip "Need MDT version at least 2.7.63"
6802 start_mds || error "MDS start failed"
6803 start_ost || error "unable to start OST"
6804 mount_client $MOUNT || error "client start failed"
6805 check_mount || error "check_mount failed"
6808 nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
6812 uuid=$(get_client_uuid $MOUNT)
6814 echo "list nids on mdt:"
6815 do_facet $SINGLEMDS "$LCTL list_param mdt.${FSNAME}*.exports.*"
6816 echo "uuid from $nid:"
6817 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6819 found=$(check_uuid_on_mdt $nid | grep $uuid)
6820 [ -z "$found" ] && error "can't find $uuid $nid on MDT"
6821 found=$(check_uuid_on_ost $nid | grep $uuid)
6822 [ -z "$found" ] && error "can't find $uuid $nid on OST"
6824 # umount the client so it won't reconnect
6825 manual_umount_client --force || error "failed to umount $?"
6826 # shouldn't disappear on MDS after forced umount
6827 found=$(check_uuid_on_mdt $nid | grep $uuid)
6828 [ -z "$found" ] && error "can't find $uuid $nid"
6831 do_facet $SINGLEMDS \
6832 "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
6834 found=$(check_uuid_on_mdt $nid | grep $uuid)
6835 [ -n "$found" ] && error "found $uuid $nid on MDT"
6836 found=$(check_uuid_on_ost $nid | grep $uuid)
6837 [ -n "$found" ] && error "found $uuid $nid on OST"
6839 # check it didn't reconnect (being umounted)
6840 sleep $((TIMEOUT+1))
6841 found=$(check_uuid_on_mdt $nid | grep $uuid)
6842 [ -n "$found" ] && error "found $uuid $nid on MDT"
6843 found=$(check_uuid_on_ost $nid | grep $uuid)
6844 [ -n "$found" ] && error "found $uuid $nid on OST"
6848 run_test 91 "evict-by-nid support"
6850 generate_ldev_conf() {
6851 # generate an ldev.conf file
6852 local ldevconfpath=$1
6854 local fsldevformat=""
6857 fstype=$(facet_fstype mgs)
6858 if [ "$fstype" == "zfs" ]; then
6859 fsldevformat="$fstype:"
6864 printf "%s\t-\t%s-MGS0000\t%s%s\n" \
6868 $(mgsdevname) > $ldevconfpath
6870 local mdsfo_host=$mdsfailover_HOST;
6871 if [ -z "$mdsfo_host" ]; then
6875 for num in $(seq $MDSCOUNT); do
6876 fstype=$(facet_fstype mds$num)
6877 if [ "$fstype" == "zfs" ]; then
6878 fsldevformat="$fstype:"
6883 printf "%s\t%s\t%s-MDT%04d\t%s%s\n" \
6889 $(mdsdevname $num) >> $ldevconfpath
6892 local ostfo_host=$ostfailover_HOST;
6893 if [ -z "$ostfo_host" ]; then
6897 for num in $(seq $OSTCOUNT); do
6898 fstype=$(facet_fstype ost$num)
6899 if [ "$fstype" == "zfs" ]; then
6900 fsldevformat="$fstype:"
6905 printf "%s\t%s\t%s-OST%04d\t%s%s\n" \
6911 $(ostdevname $num) >> $ldevconfpath
6914 echo "----- $ldevconfpath -----"
6916 echo "--- END $ldevconfpath ---"
6921 # generate a nids file (mapping between hostname to nid)
6922 # looks like we only have the MGS nid available to us
6923 # so just echo that to a file
6925 echo -e "${mgs_HOST}\t${MGSNID}" > $nidspath
6927 echo "----- $nidspath -----"
6929 echo "--- END $nidspath ---"
6932 compare_ldev_output() {
6936 sort $expected_output -o $expected_output
6937 sort $ldev_output -o $ldev_output
6939 echo "-- START OF LDEV OUTPUT --"
6941 echo "--- END OF LDEV OUTPUT ---"
6943 echo "-- START OF EXPECTED OUTPUT --"
6944 cat $expected_output
6945 echo "--- END OF EXPECTED OUTPUT ---"
6947 diff $expected_output $ldev_output
6952 if [ -z "$LDEV" ]; then
6953 error "ldev is missing!"
6956 local LDEVCONFPATH=$TMP/ldev.conf
6957 local NIDSPATH=$TMP/nids
6959 echo "Host is $(hostname)"
6961 generate_ldev_conf $LDEVCONFPATH
6962 generate_nids $NIDSPATH
6964 # echo the mgs nid and compare it to environment variable MGSNID
6965 # also, ldev.conf and nids is a server side thing, use the OSS
6968 output=$($LDEV -c $LDEVCONFPATH -H $ost_HOST -n $NIDSPATH echo %m)
6970 echo "-- START OF LDEV OUTPUT --"
6972 echo "--- END OF LDEV OUTPUT ---"
6974 # ldev failed, error
6975 if [ $? -ne 0 ]; then
6976 rm $LDEVCONFPATH $NIDSPATH
6977 error "ldev failed to execute!"
6980 # need to process multiple lines because of combined MGS and MDS
6981 echo -e $output | awk '{ print $2 }' | while read -r line ; do
6982 if [ "$line" != "$MGSNID" ]; then
6983 rm $LDEVCONFPATH $NIDSPATH
6984 error "ldev failed mgs nid '$line', expected '$MGSNID'"
6988 rm $LDEVCONFPATH $NIDSPATH
6990 run_test 92 "ldev returns MGS NID correctly in command substitution"
6993 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
6996 #start mgs or mgs/mdt0
6997 if ! combined_mgs_mds ; then
7004 start_ost || error "OST0 start fail"
7006 #define OBD_FAIL_MGS_WRITE_TARGET_DELAY 0x90e
7007 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x8000090e"
7008 for num in $(seq 2 $MDSCOUNT); do
7012 mount_client $MOUNT || error "mount client fails"
7013 wait_osc_import_state mds ost FULL
7014 wait_osc_import_ready client ost
7015 check_mount || error "check_mount failed"
7017 cleanup || error "cleanup failed with $?"
7019 run_test 93 "register mulitple MDT at the same time"
7022 if [ -z "$LDEV" ]; then
7023 error "ldev is missing!"
7026 local LDEVCONFPATH=$TMP/ldev.conf
7027 local NIDSPATH=$TMP/nids
7029 generate_ldev_conf $LDEVCONFPATH
7030 generate_nids $NIDSPATH
7032 local LDEV_OUTPUT=$TMP/ldev-output.txt
7033 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME > $LDEV_OUTPUT
7035 # ldev failed, error
7036 if [ $? -ne 0 ]; then
7037 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7038 error "ldev failed to execute!"
7042 local EXPECTED_OUTPUT=$TMP/ldev-expected.txt
7044 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7046 for num in $(seq $MDSCOUNT); do
7047 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7050 for num in $(seq $OSTCOUNT); do
7051 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7054 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7056 if [ $? -ne 0 ]; then
7057 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7058 error "ldev failed to produce the correct hostlist!"
7061 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7063 run_test 94 "ldev outputs correct labels for file system name query"
7066 if [ -z "$LDEV" ]; then
7067 error "ldev is missing!"
7070 local LDEVCONFPATH=$TMP/ldev.conf
7071 local NIDSPATH=$TMP/nids
7073 generate_ldev_conf $LDEVCONFPATH
7074 generate_nids $NIDSPATH
7078 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME &>/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 -l &>/dev/null
7086 if [ $? -ne 0 ]; then
7087 rm $LDEVCONFPATH $NIDSPATH
7088 error "ldev label filtering w/ -l failed!"
7092 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f &>/dev/null
7093 if [ $? -ne 0 ]; then
7094 rm $LDEVCONFPATH $NIDSPATH
7095 error "ldev label filtering w/ -f failed!"
7099 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a &>/dev/null
7100 if [ $? -ne 0 ]; then
7101 rm $LDEVCONFPATH $NIDSPATH
7102 error "ldev label filtering w/ -a failed!"
7107 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -F $FSNAME &>/dev/null
7108 if [ $? -eq 0 ]; then
7109 rm $LDEVCONFPATH $NIDSPATH
7110 error "ldev label filtering w/ -a and -F incorrectly succeeded"
7114 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -f &>/dev/null
7115 if [ $? -eq 0 ]; then
7116 rm $LDEVCONFPATH $NIDSPATH
7117 error "ldev label filtering w/ -a and -f incorrectly succeeded"
7121 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -l &>/dev/null
7122 if [ $? -eq 0 ]; then
7123 rm $LDEVCONFPATH $NIDSPATH
7124 error "ldev label filtering w/ -a and -l incorrectly succeeded"
7128 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f -l &>/dev/null
7129 if [ $? -eq 0 ]; then
7130 rm $LDEVCONFPATH $NIDSPATH
7131 error "ldev label filtering w/ -f and -l incorrectly succeeded"
7135 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -l &>/dev/null
7136 if [ $? -eq 0 ]; then
7137 rm $LDEVCONFPATH $NIDSPATH
7138 error "ldev label filtering w/ -F and -l incorrectly succeeded"
7141 # file sys & foreign
7142 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -f &>/dev/null
7143 if [ $? -eq 0 ]; then
7144 rm $LDEVCONFPATH $NIDSPATH
7145 error "ldev label filtering w/ -F and -f incorrectly succeeded"
7148 rm $LDEVCONFPATH $NIDSPATH
7150 run_test 95 "ldev should only allow one label filter"
7153 if [ -z "$LDEV" ]; then
7154 error "ldev is missing!"
7157 local LDEVCONFPATH=$TMP/ldev.conf
7158 local NIDSPATH=$TMP/nids
7160 generate_ldev_conf $LDEVCONFPATH
7161 generate_nids $NIDSPATH
7163 local LDEV_OUTPUT=$TMP/ldev-output.txt
7164 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -H $mgs_HOST \
7166 awk '{print $2}' > $LDEV_OUTPUT
7168 # ldev failed, error
7169 if [ $? -ne 0 ]; then
7170 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7171 error "ldev failed to execute!"
7175 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7177 echo "$mgs_HOST-$(facet_fstype mgs)" > $EXPECTED_OUTPUT
7179 if [ "$mgs_HOST" == "$mds_HOST" ]; then
7180 for num in $(seq $MDSCOUNT); do
7181 echo "$mds_HOST-$(facet_fstype mds$num)" \
7186 if [ "$mgs_HOST" == "$ost_HOST" ]; then
7187 for num in $(seq $OSTCOUNT); do
7188 echo "$ost_HOST-$(facet_fstype ost$num)" \
7193 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7195 if [ $? -ne 0 ]; then
7196 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7197 error "ldev failed to produce the correct output!"
7200 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7202 run_test 96 "ldev returns hostname and backend fs correctly in command sub"
7205 if [ -z "$LDEV" ]; then
7206 error "ldev is missing!"
7209 local LDEVCONFPATH=$TMP/ldev.conf
7210 local NIDSPATH=$TMP/nids
7212 generate_ldev_conf $LDEVCONFPATH
7213 generate_nids $NIDSPATH
7215 local LDEV_OUTPUT=$TMP/ldev-output.txt
7216 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7218 echo -e "\nMDT role"
7219 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mdt > $LDEV_OUTPUT
7221 if [ $? -ne 0 ]; then
7222 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7223 error "ldev failed to execute for mdt role!"
7226 for num in $(seq $MDSCOUNT); do
7227 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7230 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7232 if [ $? -ne 0 ]; then
7233 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7234 error "ldev failed to produce the correct output for mdt role!"
7237 echo -e "\nOST role"
7238 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R ost > $LDEV_OUTPUT
7240 if [ $? -ne 0 ]; then
7241 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7242 error "ldev failed to execute for ost role!"
7246 for num in $(seq $OSTCOUNT); do
7247 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7250 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7252 if [ $? -ne 0 ]; then
7253 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7254 error "ldev failed to produce the correct output for ost role!"
7257 echo -e "\nMGS role"
7258 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mgs > $LDEV_OUTPUT
7260 if [ $? -ne 0 ]; then
7261 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7262 error "ldev failed to execute for mgs role!"
7265 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7267 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7269 if [ $? -ne 0 ]; then
7270 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7271 error "ldev failed to produce the correct output for mgs role!"
7274 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7276 run_test 97 "ldev returns correct ouput when querying based on role"
7281 local temp=$MDS_MOUNT_OPTS
7284 check_mount || error "mount failed"
7285 mountopt="user_xattr"
7286 for ((x = 1; x <= 400; x++)); do
7287 mountopt="$mountopt,user_xattr"
7289 remount_client $mountopt $MOUNT 2>&1 | grep "too long" ||
7290 error "Buffer overflow check failed"
7291 cleanup || error "cleanup failed"
7293 run_test 98 "Buffer-overflow check while parsing mount_opts"
7297 [[ $(facet_fstype ost1) != ldiskfs ]] &&
7298 skip "ldiskfs only test"
7299 [[ $(lustre_version_code ost1) -ge $(version_code 2.8.57) ]] ||
7300 skip "Need OST version at least 2.8.57"
7302 local ost_opts="$(mkfs_opts ost1 $(ostdevname 1)) \
7303 --reformat $(ostdevname 1) $(ostvdevname 1)"
7304 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" &&
7305 skip "meta_bg already set"
7308 if [[ ${!opts} != *mkfsoptions* ]]; then
7309 eval opts=\"${!opts} \
7310 --mkfsoptions='\\\"-O ^resize_inode,meta_bg\\\"'\"
7312 local val=${!opts//--mkfsoptions=\\\"/ \
7313 --mkfsoptions=\\\"-O ^resize_inode,meta_bg }
7317 echo "params: $opts"
7320 add ost1 $opts || error "add ost1 failed with new params"
7322 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" ||
7323 error "meta_bg is not set"
7325 run_test 99 "Adding meta_bg option"
7330 start_mgsmds || error "MDS start failed"
7331 start_ost || error "unable to start OST"
7332 mount_client $MOUNT || error "client start failed"
7333 check_mount || error "check_mount failed"
7342 do_facet mgs 'lshowmount -v' | awk 'BEGIN {NR == 0; rc=1} /MGS:/ {rc=0}
7343 END {exit rc}' || error "lshowmount have no output MGS"
7345 do_facet mds1 'lshowmount -v' | awk 'BEGIN {NR == 2; rc=1} /-MDT0000:/
7346 {rc=0} END {exit rc}' || error "lshowmount have no output MDT0"
7348 do_facet ost1 'lshowmount -v' | awk 'BEGIN {NR == 4; rc=1} /-OST0000:/
7349 {rc=0} END {exit rc}' || error "lshowmount have no output OST0"
7351 cleanup || error "cleanup failed with $?"
7353 run_test 100 "check lshowmount lists MGS, MDT, OST and 0@lo"
7356 local createmany_pid
7357 local dev=$FSNAME-OST0000-osc-MDT0000
7361 createmany -o $DIR1/$tdir/$tfile-%d 50000 &
7363 # MDT->OST reconnection causes MDT<->OST last_id synchornisation
7364 # via osp_precreate_cleanup_orphans.
7365 for ((i = 0; i < 100; i++)); do
7366 for ((k = 0; k < 10; k++)); do
7367 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;" \
7368 "$LCTL --device $dev activate"
7371 ls -asl $MOUNT | grep '???' &&
7372 { kill -9 $createmany_pid &>/dev/null;
7373 error "File has no object on OST"; }
7375 kill -s 0 $createmany_pid || break
7377 wait $createmany_pid
7379 unlinkmany $DIR1/$tdir/$tfile-%d 50000
7382 run_test 101 "Race MDT->OST reconnection with create"
7385 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.9.53) ]] ||
7386 skip "Need server version greater than 2.9.53"
7387 [[ “$(mdsdevname 1)” != “$(mgsdevname)” ]] &&
7388 [[ “$(facet_host mds1)” = “$(facet_host mgs)” ]] &&
7389 skip "MGS must be on different node or combined"
7391 cleanup || error "cleanup failed with $?"
7393 local mds1dev=$(mdsdevname 1)
7394 local mds1mnt=$(facet_mntpt mds1)
7395 local mds1fstype=$(facet_fstype mds1)
7396 local mds1opts=$MDS_MOUNT_OPTS
7398 if [ $mds1fstype == ldiskfs ] &&
7399 ! do_facet mds1 test -b $mds1dev; then
7400 mds1opts=$(csa_add "$mds1opts" -o loop)
7402 if [[ $mds1fstype == zfs ]]; then
7403 import_zpool mds1 || return ${PIPESTATUS[0]}
7406 # unload all and only load libcfs to allow fail_loc setting
7407 do_facet mds1 $LUSTRE_RMMOD || error "unable to unload modules"
7408 do_facet mds1 modprobe libcfs || error "libcfs not loaded"
7409 do_facet mds1 lsmod \| grep libcfs || error "libcfs not loaded"
7411 #define OBD_FAIL_OBDCLASS_MODULE_LOAD 0x60a
7412 do_facet mds1 "$LCTL set_param fail_loc=0x8000060a"
7414 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
7415 error "mdt start must fail"
7416 do_facet mds1 lsmod \| grep obdclass && error "obdclass must not load"
7418 do_facet mds1 "$LCTL set_param fail_loc=0x0"
7420 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts ||
7421 error "mdt start must not fail"
7423 cleanup || error "cleanup failed with $?"
7425 run_test 102 "obdclass module cleanup upon error"
7430 echo "rename $FSNAME to $newname"
7432 if ! combined_mgs_mds ; then
7433 local facet=$(mgsdevname)
7436 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7437 error "(7) Fail to rename MGS"
7438 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7439 reimport_zpool mgs $newname-mgs
7443 for num in $(seq $MDSCOUNT); do
7444 local facet=$(mdsdevname $num)
7446 do_facet mds${num} \
7447 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7448 error "(8) Fail to rename MDT $num"
7449 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7450 reimport_zpool mds${num} $newname-mdt${num}
7454 for num in $(seq $OSTCOUNT); do
7455 local facet=$(ostdevname $num)
7457 do_facet ost${num} \
7458 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
7459 error "(9) Fail to rename OST $num"
7460 if [ "$(facet_fstype $facet)" = "zfs" ]; then
7461 reimport_zpool ost${num} $newname-ost${num}
7466 test_103_set_pool() {
7470 do_facet mgs $LCTL pool_add $FSNAME.$pname ${FSNAME}-$ost_x ||
7471 error "Fail to add $ost_x to $FSNAME.$pname"
7472 wait_update $HOSTNAME \
7473 "lctl get_param -n lov.$FSNAME-clilov-*.pools.$pname |
7474 grep $ost_x" "$FSNAME-${ost_x}_UUID" ||
7475 error "$ost_x is NOT in pool $FSNAME.$pname"
7478 test_103_check_pool() {
7479 local save_fsname=$1
7482 stat $DIR/$tdir/test-framework.sh ||
7483 error "($errno) Fail to stat"
7484 do_facet mgs $LCTL pool_list $FSNAME.pool1 ||
7485 error "($errno) Fail to list $FSNAME.pool1"
7486 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname ||
7487 error "($errno) Fail to list $FSNAME.$save_fsname"
7488 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname |
7489 grep ${FSNAME}-OST0000 ||
7490 error "($errno) List $FSNAME.$save_fsname is invalid"
7492 local pname=$($LFS getstripe --pool $DIR/$tdir/d0)
7493 [ "$pname" = "$save_fsname" ] ||
7494 error "($errno) Unexpected pool name $pname"
7498 check_mount_and_prep
7500 mkdir $DIR/$tdir || error "(1) Fail to mkdir $DIR/$tdir"
7501 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir ||
7502 error "(2) Fail to copy test-framework.sh"
7504 if ! combined_mgs_mds ; then
7507 do_facet mgs $LCTL pool_new $FSNAME.pool1 ||
7508 error "(3) Fail to create $FSNAME.pool1"
7509 # name the pool name as the fsname
7510 do_facet mgs $LCTL pool_new $FSNAME.$FSNAME ||
7511 error "(4) Fail to create $FSNAME.$FSNAME"
7513 test_103_set_pool $FSNAME OST0000
7515 $LFS setstripe -p $FSNAME $DIR/$tdir/d0 ||
7516 error "(6) Fail to setstripe on $DIR/$tdir/d0"
7518 if ! combined_mgs_mds ; then
7524 test_renamefs mylustre
7526 local save_fsname=$FSNAME
7530 if ! combined_mgs_mds ; then
7533 test_103_check_pool $save_fsname 7
7535 if [ $OSTCOUNT -ge 2 ]; then
7536 test_103_set_pool $save_fsname OST0001
7539 $LFS setstripe -p $save_fsname $DIR/$tdir/f0 ||
7540 error "(16) Fail to setstripe on $DIR/$tdir/f0"
7541 if ! combined_mgs_mds ; then
7552 if ! combined_mgs_mds ; then
7555 test_103_check_pool $save_fsname 17
7557 if ! combined_mgs_mds ; then
7562 test_renamefs $save_fsname
7568 run_test 103 "rename filesystem name"
7570 test_104() { # LU-6952
7571 local mds_mountopts=$MDS_MOUNT_OPTS
7572 local ost_mountopts=$OST_MOUNT_OPTS
7573 local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
7574 local lctl_ver=$(do_facet $SINGLEMDS $LCTL --version |
7577 [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
7578 skip "this test needs utils above 2.9.55"
7580 # specify "acl" in mount options used by mkfs.lustre
7581 if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
7582 MDS_MOUNT_FS_OPTS="acl,user_xattr"
7585 MDS_MOUNT_FS_OPTS="${MDS_MOUNT_FS_OPTS},acl,user_xattr"
7588 echo "mountfsopt: $MDS_MOUNT_FS_OPTS"
7590 #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
7592 if ! combined_mgs_mds ; then
7596 if [ -z "$MDS_MOUNT_OPTS" ]; then
7597 MDS_MOUNT_OPTS="-o noacl"
7599 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7602 for num in $(seq $MDSCOUNT); do
7603 start mds$num $(mdsdevname $num) $MDS_MOUNT_OPTS ||
7604 error "Failed to start MDS"
7607 for num in $(seq $OSTCOUNT); do
7608 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
7609 error "Failed to start OST"
7613 setfacl -m "d:$RUNAS_ID:rwx" $MOUNT &&
7614 error "ACL is applied when FS is mounted with noacl."
7616 MDS_MOUNT_OPTS=$mds_mountopts
7617 OST_MOUNT_OPTS=$ost_mountopts
7618 MDS_MOUNT_FS_OPTS=$mds_mountfsopts
7620 run_test 104 "Make sure user defined options are reflected in mount"
7622 error_and_umount() {
7633 mount --bind $DIR $TMP/$tdir || error "mount bind mnt pt failed"
7634 rm -f $TMP/$tdir/$tfile
7635 rm -f $TMP/$tdir/${tfile}1
7637 # Files should not be created in ro bind mount point
7638 # remounting from rw to ro
7639 mount -o remount,ro $TMP/$tdir ||
7640 error_and_umount "readonly remount of bind mnt pt failed"
7641 touch $TMP/$tdir/$tfile &&
7642 error_and_umount "touch succeeds on ro bind mnt pt"
7643 [ -e $TMP/$tdir/$tfile ] &&
7644 error_and_umount "file created on ro bind mnt pt"
7646 # Files should be created in rw bind mount point
7647 # remounting from ro to rw
7648 mount -o remount,rw $TMP/$tdir ||
7649 error_and_umount "read-write remount of bind mnt pt failed"
7650 touch $TMP/$tdir/${tfile}1 ||
7651 error_and_umount "touch fails on rw bind mnt pt"
7652 [ -e $TMP/$tdir/${tfile}1 ] ||
7653 error_and_umount "file not created on rw bind mnt pt"
7654 umount $TMP/$tdir || error "umount of bind mnt pt failed"
7656 cleanup || error "cleanup failed with $?"
7658 run_test 105 "check file creation for ro and rw bind mnt pt"
7665 mkdir -p $DIR/$tdir || error "create $tdir failed"
7666 lfs setstripe -c 1 -i 0 $DIR/$tdir
7667 #define OBD_FAIL_CAT_RECORDS 0x1312
7668 do_facet mds1 $LCTL set_param fail_loc=0x1312 fail_val=$repeat
7670 for ((i = 1; i <= $repeat; i++)); do
7672 #one full plain llog
7673 createmany -o $DIR/$tdir/f- 64768
7675 createmany -u $DIR/$tdir/f- 64768
7677 wait_delete_completed $((TIMEOUT * 7))
7678 #ASSERTION osp_sync_thread() ( thread->t_flags != SVC_RUNNING ) failed
7679 #shows that osp code is buggy
7680 do_facet mds1 $LCTL set_param fail_loc=0 fail_val=0
7684 run_test 106 "check osp llog processing when catalog is wrapped"
7687 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.50) ]] ||
7688 skip "Need MDS version > 2.10.50"
7691 start_mgsmds || error "start_mgsmds failed"
7692 start_ost || error "unable to start OST"
7694 # add unknown configuration parameter.
7695 if [[ $PERM_CMD == *"set_param -P"* ]]; then
7696 cmd="$PERM_CMD ost.$FSNAME-OST0000*.unknown_param"
7698 cmd="$PERM_CMD $FSNAME-OST0000*.ost.unknown_param"
7700 do_facet mgs "$cmd=50"
7701 cleanup_nocli || error "cleanup_nocli failed with $?"
7704 # unknown param should be ignored while mounting.
7705 start_ost || error "unable to start OST after unknown param set"
7707 cleanup || error "cleanup failed with $?"
7709 run_test 107 "Unknown config param should not fail target mounting"
7714 $rcmd rm -rf $tmp > /dev/null 2>&1
7715 $rcmd mkdir -p $tmp/{mnt,images} || error "failed to mkdir remotely"
7717 for facet in $facets; do
7718 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
7719 $rcmd $ZPOOL -f export lustre-$facet > /dev/null 2>&1
7720 $rcmd mkdir $tmp/mnt/$facet ||
7721 error "failed to mkdir $tmp/mnt/$facet"
7722 $rcmd dd if=/dev/zero of=$tmp/images/$facet \
7723 seek=199 bs=1M count=1 ||
7724 error "failed to create $tmp/images/$facet"
7733 local facet=${role}$((idx + 1))
7735 [ $# -eq 5 ] && pool=$5
7737 do_facet $SINGLEMDS $MKFS --fsname=lustre --$mgs \
7738 --$role --index=$idx --replace --backfstype=$bkfs \
7739 --device-size=200000 --reformat $pool $tmp/images/$facet ||
7740 error "failed to mkfs for $facet"
7744 echo "mounting client..."
7745 mount -t lustre ${nid}:/lustre $MOUNT ||
7746 error "failed to mount lustre"
7749 ls -l $MOUNT/local_dir || error "failed to list"
7751 echo "check truncate && write"
7752 echo "dummmmmmmmmmmmm" > $MOUNT/remote_dir/fsx.c ||
7753 error "failed to tuncate & write"
7756 touch $MOUNT/foooo ||
7757 error "failed to create"
7759 echo "check read && write && append"
7760 sha1sum $MOUNT/conf-sanity.sh |
7761 awk '{ print $1 }' > $MOUNT/checksum.new ||
7762 error "failed to read(1)"
7763 sha1sum $MOUNT/remote_dir/unlinkmany.c |
7764 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7765 error "failed to read(2)"
7766 sha1sum $MOUNT/striped_dir/lockahead_test.o |
7767 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7768 error "failed to read(3)"
7771 diff $MOUNT/checksum.new $MOUNT/checksum.src ||
7772 error "failed to verify data"
7782 umount -f $MOUNT || error "failed to umount client"
7783 for facet in $facets; do
7784 $rcmd umount -f $tmp/mnt/$facet ||
7785 error "failed to umount $facet"
7786 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
7787 $rcmd $ZPOOL export -f lustre-$facet ||
7788 error "failed to export lustre-$facet"
7792 $rcmd rm -rf $tmp || error "failed to rm the dir $tmp"
7796 [ "$CLIENTONLY" ] && skip "Client-only testing"
7797 [ $(facet_fstype $SINGLEMDS) != "zfs" ] && skip "zfs only test"
7798 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
7799 skip "Need server version at least 2.10.58"
7804 local tmp=$TMP/$tdir
7805 local rcmd="do_facet $SINGLEMDS"
7806 local facets="mdt1 mdt2 ost1 ost2"
7807 local nid=$($rcmd $LCTL list_nids | head -1)
7810 trap t_108_cleanup EXIT ERR
7813 t_108_mkfs mdt 0 zfs mgs lustre-mdt1/mdt1
7814 t_108_mkfs mdt 1 zfs mgsnode=$nid lustre-mdt2/mdt2
7815 t_108_mkfs ost 0 zfs mgsnode=$nid lustre-ost1/ost1
7816 t_108_mkfs ost 1 zfs mgsnode=$nid lustre-ost2/ost2
7818 for facet in $facets; do
7819 $rcmd zfs set mountpoint=$tmp/mnt/$facet canmount=on \
7820 lustre-$facet/$facet ||
7821 error "failed to zfs set for $facet (1)"
7822 $rcmd zfs mount lustre-$facet/$facet ||
7823 error "failed to local mount $facet"
7824 $rcmd tar jxf $LUSTRE/tests/ldiskfs_${facet}_2_11.tar.bz2 \
7825 --xattrs --xattrs-include="trusted.*" \
7826 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7827 error "failed to untar image for $facet"
7828 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7829 error "failed to cleanup for $facet"
7830 $rcmd zfs umount lustre-$facet/$facet ||
7831 error "failed to local umount $facet"
7832 $rcmd zfs set canmount=off lustre-$facet/$facet ||
7833 error "failed to zfs set $facet (2)"
7836 echo "changing server nid..."
7837 $rcmd mount -t lustre -o nosvc lustre-mdt1/mdt1 $tmp/mnt/mdt1
7838 $rcmd lctl replace_nids lustre-MDT0000 $nid
7839 $rcmd lctl replace_nids lustre-MDT0001 $nid
7840 $rcmd lctl replace_nids lustre-OST0000 $nid
7841 $rcmd lctl replace_nids lustre-OST0001 $nid
7842 $rcmd umount $tmp/mnt/mdt1
7844 for facet in $facets; do
7845 echo "mounting $facet from backup..."
7846 $rcmd mount -t lustre -o abort_recov lustre-$facet/$facet \
7847 $tmp/mnt/$facet || error "failed to mount $facet"
7850 # ZFS backend can detect migration and trigger OI scrub automatically
7851 # sleep 3 seconds for scrub done
7857 run_test 108a "migrate from ldiskfs to ZFS"
7860 [ "$CLIENTONLY" ] && skip "Client-only testing"
7861 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] && skip "ldiskfs only test"
7862 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
7863 skip "Need server version at least 2.10.58"
7868 local tmp=$TMP/$tdir
7869 local rcmd="do_facet $SINGLEMDS"
7870 local facets="mdt1 mdt2 ost1 ost2"
7871 local scrub_list="MDT0000 MDT0001 OST0000 OST0001"
7872 local nid=$($rcmd $LCTL list_nids | head -1)
7875 trap t_108_cleanup EXIT ERR
7878 t_108_mkfs mdt 0 ldiskfs mgs
7879 t_108_mkfs mdt 1 ldiskfs mgsnode=$nid
7880 t_108_mkfs ost 0 ldiskfs mgsnode=$nid
7881 t_108_mkfs ost 1 ldiskfs mgsnode=$nid
7883 for facet in $facets; do
7884 $rcmd mount -t ldiskfs -o loop $tmp/images/$facet \
7886 error "failed to local mount $facet"
7888 $rcmd tar jxf $LUSTRE/tests/zfs_${facet}_2_11.tar.bz2 \
7889 --xattrs --xattrs-include="*.*" \
7890 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7891 error "failed to untar image for $facet"
7892 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7893 error "failed to cleanup for $facet"
7894 $rcmd umount $tmp/mnt/$facet ||
7895 error "failed to local umount $facet"
7898 echo "changing server nid..."
7899 $rcmd mount -t lustre -o nosvc,loop $tmp/images/mdt1 $tmp/mnt/mdt1
7900 $rcmd lctl replace_nids lustre-MDT0000 $nid
7901 $rcmd lctl replace_nids lustre-MDT0001 $nid
7902 $rcmd lctl replace_nids lustre-OST0000 $nid
7903 $rcmd lctl replace_nids lustre-OST0001 $nid
7904 $rcmd umount $tmp/mnt/mdt1
7906 for facet in $facets; do
7907 echo "mounting $facet from backup..."
7908 $rcmd mount -t lustre -o loop,abort_recov $tmp/images/$facet \
7909 $tmp/mnt/$facet || error "failed to mount $facet"
7912 for facet in $scrub_list; do
7913 $rcmd $LCTL lfsck_start -M lustre-$facet -t scrub ||
7914 error "failed to start OI scrub on $facet"
7917 # sleep 3 seconds for scrub done
7923 run_test 108b "migrate from ZFS to ldiskfs"
7927 # set number of permanent parameters
7929 test_109_set_params() {
7932 set_persistent_param_and_check mds \
7933 "mdd.$fsname-MDT0000.atime_diff" \
7934 "$fsname-MDT0000.mdd.atime_diff" \
7936 set_persistent_param_and_check mds \
7937 "mdd.$fsname-MDT0000.atime_diff" \
7938 "$fsname-MDT0000.mdd.atime_diff" \
7940 set_persistent_param_and_check client \
7941 "llite.$fsname*.max_read_ahead_mb" \
7942 "$fsname.llite.max_read_ahead_mb" \
7944 set_persistent_param_and_check client \
7945 "llite.$fsname*.max_read_ahead_mb" \
7946 "$fsname.llite.max_read_ahead_mb" \
7948 create_pool $fsname.pool1 || error "create pool failed"
7949 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
7950 error "pool_add failed"
7951 do_facet mgs $LCTL pool_remove $fsname.pool1 OST0000 ||
7952 error "pool_remove failed"
7953 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
7954 error "pool_add failed"
7958 # check permanent parameters
7960 test_109_test_params() {
7963 local atime_diff=$(do_facet mds $LCTL \
7964 get_param -n mdd.$fsname-MDT0000.atime_diff)
7965 [ $atime_diff == 63 ] || error "wrong mdd parameter after clear_conf"
7966 local max_read_ahead_mb=$(do_facet client $LCTL \
7967 get_param -n llite.$fsname*.max_read_ahead_mb)
7968 [ $max_read_ahead_mb == 64 ] ||
7969 error "wrong llite parameter after clear_conf"
7970 local ost_in_pool=$(do_facet mds $LCTL pool_list $fsname.pool1 |
7971 grep -v "^Pool:" | sed 's/_UUID//')
7972 [ $ost_in_pool = "$fsname-OST0000" ] ||
7973 error "wrong pool after clear_conf"
7977 # run lctl clear_conf, store CONFIGS before and after that
7979 test_109_clear_conf()
7981 local clear_conf_arg=$1
7984 if ! combined_mgs_mds ; then
7985 mgsdev=$(mgsdevname)
7986 stop_mgs || error "stop_mgs failed"
7987 start_mgs "-o nosvc" || error "start_mgs nosvc failed"
7989 mgsdev=$(mdsdevname 1)
7990 start_mdt 1 "-o nosvc" || error "start_mdt 1 nosvc failed"
7993 do_facet mgs "rm -rf $TMP/${tdir}/conf1; mkdir -p $TMP/${tdir}/conf1;" \
7994 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf1\\\" \
7998 # the command being tested
8000 do_facet mgs $LCTL clear_conf $clear_conf_arg ||
8001 error "clear_conf failed"
8002 if ! combined_mgs_mds ; then
8003 stop_mgs || error "stop_mgs failed"
8005 stop_mdt 1 || error "stop_mdt 1 failed"
8008 do_facet mgs "rm -rf $TMP/${tdir}/conf2; mkdir -p $TMP/${tdir}/conf2;" \
8009 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf2\\\" \
8013 test_109_file_shortened() {
8015 local sizes=($(do_facet mgs "stat -c %s " \
8016 "$TMP/${tdir}/conf1/CONFIGS/$file" \
8017 "$TMP/${tdir}/conf2/CONFIGS/$file"))
8018 [ ${sizes[1]} -lt ${sizes[0]} ] && return 0
8024 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
8025 skip "Needs MDS version 2.10.59 or later."
8026 [ "$(facet_fstype mgs)" == "zfs" ] &&
8027 skip "LU-8727: no implementation for ZFS"
8032 client_up || error "client_up failed"
8033 #pool commands requires a client on MGS for procfs interfaces
8034 if ! combined_mgs_mds ; then
8036 stack_trap umount_mgs_client EXIT
8040 # set number of permanent parameters
8042 test_109_set_params $FSNAME
8044 combined_mgs_mds || umount_mgs_client
8045 umount_client $MOUNT || error "umount_client failed"
8046 stop_ost || error "stop_ost failed"
8047 stop_mds || error "stop_mds failed"
8049 test_109_clear_conf $FSNAME
8051 # make sure that all configs are cleared
8053 test_109_file_shortened $FSNAME-MDT0000 ||
8054 error "failed to clear MDT0000 config"
8055 test_109_file_shortened $FSNAME-client ||
8056 error "failed to clear client config"
8059 combined_mgs_mds || mount_mgs_client
8062 # check that configurations are intact
8064 test_109_test_params $FSNAME
8069 destroy_test_pools || error "destroy test pools failed"
8071 combined_mgs_mds || umount_mgs_client
8074 run_test 109a "test lctl clear_conf fsname"
8078 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
8079 skip "Needs MDS version 2.10.59 or later."
8080 [ "$(facet_fstype mgs)" == "zfs" ] &&
8081 skip "LU-8727: no implementation for ZFS"
8086 client_up || error "client_up failed"
8087 #pool commands requires a client on MGS for procfs interfaces
8088 if ! combined_mgs_mds ; then
8090 stack_trap umount_mgs_client EXIT
8094 # set number of permanent parameters
8096 test_109_set_params $FSNAME
8098 combined_mgs_mds || umount_mgs_client
8099 umount_client $MOUNT || error "umount_client failed"
8100 stop_ost || error "stop_ost failed"
8101 stop_mds || error "stop_mds failed"
8103 test_109_clear_conf $FSNAME-MDT0000
8105 # make sure that only one config is cleared
8107 test_109_file_shortened $FSNAME-MDT0000 ||
8108 error "failed to clear MDT0000 config"
8109 test_109_file_shortened $FSNAME-client &&
8110 error "failed to clear client config"
8113 combined_mgs_mds || mount_mgs_client
8115 # check that configurations are intact
8117 test_109_test_params $FSNAME
8122 destroy_test_pools || error "destroy test pools failed"
8124 combined_mgs_mds || umount_mgs_client
8127 run_test 109b "test lctl clear_conf one config"
8131 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
8132 skip "Only applicable to ldiskfs-based MDTs"
8134 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8135 skip "large_dir option is not supported on MDS"
8136 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8137 skip "large_dir option is not supported on OSS"
8139 stopall # stop all targets before modifying the target counts
8140 local old_mdscount=$MDSCOUNT
8141 local old_ostcount=$OSTCOUNT
8143 stack_trap "MDSCOUNT=$old_mdscount OSTCOUNT=$old_ostcount" EXIT
8147 # ext4_dir_entry_2 struct size:264
8148 # dx_root struct size:8
8149 # dx_node struct size:8
8150 # dx_entry struct size:8
8151 # For 1024 bytes block size.
8152 # First level directory entries: 126
8153 # Second level directory entries: 127
8154 # Entries in leaf: 3
8155 # For 2 levels limit: 48006
8156 # For 3 levels limit : 6096762
8157 # Create 80000 files to safely exceed 2-level htree limit.
8158 CONF_SANITY_110_LINKS=${CONF_SANITY_110_LINKS:-80000}
8160 # can fit at most 3 filenames per 1KB leaf block, but each
8161 # leaf/index block will only be 3/4 full before split at each level
8162 (( MDSSIZE < CONF_SANITY_110_LINKS / 3 * 4/3 * 4/3 )) &&
8163 CONF_SANITY_110_LINKS=$((MDSSIZE * 3 * 3/4 * 3/4))
8165 combined_mgs_mds || replace=" --replace "
8166 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8167 $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8168 if [[ $opts != *mkfsoptions* ]]; then
8169 opts+=" --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536\\\""
8171 opts="${opts//--mkfsoptions=\\\"/ \
8172 --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536 }"
8174 echo "MDT params: $opts"
8176 combined_mgs_mds || start_mgs
8177 add mds1 $opts || error "add mds1 failed with new params"
8178 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8180 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8181 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
8183 if [[ $opts != *mkfsoptions* ]]; then
8184 opts+=" --mkfsoptions=\\\"-O large_dir\\\" "
8186 opts="${opts//--mkfsoptions=\\\"/ \
8187 --mkfsoptions=\\\"-O large_dir }"
8189 echo "OST params: $opts"
8190 add ost1 $opts || error "add ost1 failed with new params"
8191 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8193 MOUNT_2=yes mountcli || error "mount clients failed"
8195 mkdir -v $DIR/$tdir || error "cannot create $DIR/$tdir"
8196 local pids count=0 group=0
8198 echo "creating $CONF_SANITY_110_LINKS in total"
8199 while (( count < CONF_SANITY_110_LINKS )); do
8200 local len=$((253 - $(wc -c <<<"$tfile-$group-40000-")))
8201 local dir=DIR$((group % 2 + 1))
8202 local target=${!dir}/$tdir/$tfile-$group
8203 local long=$target-$(generate_name $len)-
8204 local create=$((CONF_SANITY_110_LINKS - count))
8206 (( create > 40000 )) && create=40000
8207 touch $target || error "creating $target failed"
8208 echo "creating $create hard links to $target"
8209 createmany -l $target $long $create &
8212 count=$((count + create))
8213 group=$((group + 1))
8215 echo "waiting for PIDs$pids to complete"
8216 wait $pids || error "createmany failed after $group groups"
8218 umount_client $MOUNT2 -f
8221 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8222 MDSCOUNT=$old_mdscount
8223 OSTCOUNT=$old_ostcount
8225 run_test 110 "Adding large_dir with 3-level htree"
8228 [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
8229 skip "Only applicable to ldiskfs-based MDTs"
8231 is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
8232 skip "This test can not be executed on flakey dev"
8234 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8235 skip "large_dir option is not supported on MDS"
8237 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8238 skip "large_dir option is not supported on OSS"
8240 # cleanup before changing target counts
8242 local old_mdscount=$MDSCOUNT
8243 local old_ostcount=$OSTCOUNT
8244 local old_mdssize=$MDSSIZE
8246 stack_trap "MDSSIZE=$MDSSIZE MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT" EXIT
8249 (( MDSSIZE < 2400000 )) && MDSSIZE=2400000 # need at least 2.4GB
8251 local mdsdev=$(mdsdevname 1)
8252 combined_mgs_mds || replace=" --replace "
8253 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8254 $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8255 if [[ $opts != *mkfsoptions* ]]; then
8256 opts+=" --mkfsoptions=\\\"-O large_dir -i 1048576 \\\" "
8258 opts="${opts//--mkfsoptions=\\\"/ \
8259 --mkfsoptions=\\\"-O large_dir -i 1048576 }"
8261 echo "MDT params: $opts"
8263 combined_mgs_mds || start_mgs
8264 __touch_device mds 1
8265 add mds1 $opts || error "add mds1 failed with new params"
8266 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8268 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8269 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
8270 if [[ $opts != *mkfsoptions* ]]; then
8271 opts+=" --mkfsoptions=\\\"-O large_dir \\\""
8273 opts="${opts//--mkfsoptions=\\\"/ --mkfsoptions=\\\"-O large_dir }"
8275 echo "OST params: $opts"
8276 __touch_device ost 1
8277 add ost1 $opts || error "add ost1 failed with new params"
8278 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8280 MOUNT_2=yes mountcli
8281 mkdir $DIR/$tdir || error "cannot create $DIR/$tdir"
8283 lfs df -i $DIR/$tdir
8287 local start=$SECONDS
8289 local dirmax=$((2 << 30))
8295 while (( !needskip & dirsize < dirmax )); do
8298 for cli in ${CLIENTS//,/ }; do
8299 local len=$((253 - $(wc -c <<<"$cli-$group-60000-")))
8300 local target=$cli-$group
8301 local long=$DIR/$tdir/$target-$(generate_name $len)-
8303 RPWD=$DIR/$tdir do_node $cli touch $target ||
8304 error "creating $target failed"
8305 echo "creating 60000 hardlinks to $target"
8306 RPWD=$DIR/$tdir do_node $cli createmany -l $target $long 60000 &
8309 group=$((group + 1))
8311 long=$DIR2/$tdir/$target-$(generate_name $len)-
8313 RPWD=$DIR2/$tdir do_node $cli touch $target ||
8314 error "creating $target failed"
8315 echo "creating 60000 hardlinks to $target"
8316 RPWD=$DIR2/$tdir do_node $cli createmany -l $target $long 60000 &
8319 group=$((group + 1))
8321 echo "waiting for PIDs$pids to complete"
8322 wait $pids || error "createmany failed after $group groups"
8323 dirsize=$(stat -c %s $DIR/$tdir)
8324 taken=$((SECONDS - start))
8325 rate=$((dirsize / taken))
8326 left=$(((dirmax - dirsize) / rate))
8327 num=$((group * 60000))
8328 echo "estimate ${left}s left after $num files / ${taken}s"
8329 # if the estimated time remaining is too large (it may change
8330 # over time as the create rate is not constant) then exit
8331 # without declaring a failure.
8332 (( left > 1200 )) && needskip=1
8335 umount_client $MOUNT2 -f
8338 (( $needskip )) && skip "ETA ${left}s after $num files / ${taken}s is too long"
8340 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8341 MDSCOUNT=$old_mdscount
8342 OSTCOUNT=$old_ostcount
8343 MDSSIZE=$old_mdssize
8345 run_test 111 "Adding large_dir with over 2GB directory"
8352 rm -f $TMP/$tdir/lustre-mdt
8357 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
8358 skip "Only applicable to ldiskfs-based MDTs"
8361 IMAGESIZE=$((3072 << 30)) # 3072 GiB
8364 # We need MDT size 3072GB, because it is smallest
8365 # partition that can store 2B inodes
8366 do_facet $SINGLEMDS "mkdir -p $TMP/$tdir"
8367 local mdsimgname=$TMP/$tdir/lustre-mdt
8368 do_facet $SINGLEMDS "rm -f $mdsimgname"
8369 do_facet $SINGLEMDS "touch $mdsimgname"
8370 trap cleanup_115 RETURN EXIT
8371 do_facet $SINGLEMDS "$TRUNCATE $mdsimgname $IMAGESIZE" ||
8372 skip "Backend FS doesn't support sparse files"
8373 local mdsdev=$(do_facet $SINGLEMDS "losetup -f")
8374 do_facet $SINGLEMDS "losetup $mdsdev $mdsimgname"
8376 local mds_opts="$(mkfs_opts mds1 ${mdsdev}) --device-size=$IMAGESIZE \
8377 --mkfsoptions='-O lazy_itable_init,ea_inode,^resize_inode,meta_bg \
8379 add mds1 $mds_opts --mgs --reformat $mdsdev ||
8380 skip_env "format large MDT failed"
8381 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
8382 --reformat $(ostdevname 1) $(ostvdevname 1)
8384 start $SINGLEMDS ${mdsdev} $MDS_MOUNT_OPTS || error "start MDS failed"
8385 start_ost || error "start OSS failed"
8386 mount_client $MOUNT || error "mount client failed"
8388 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir fail"
8389 for goal in $(do_facet $SINGLEMDS "ls /sys/fs/ldiskfs/*/inode_goal"); do
8390 do_facet $SINGLEMDS "echo 2147483947 >> $goal; grep . $goal"
8393 touch $DIR/$tdir/$tfile
8395 # Add > 5k bytes to xattr
8396 for i in {1..30}; do
8397 ln $DIR/$tdir/$tfile $DIR/$tdir/$(printf "link%0250d" $i) ||
8398 error "Can't make link"
8403 local inode_num=$(do_facet $SINGLEMDS \
8404 "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsimgname" |
8405 awk '/link =/ { print $4 }' |
8406 sed -e 's/>//' -e 's/<//' -e 's/\"//')
8407 echo "inode num: $inode_num"
8408 [ $inode_num -ge 2147483947 ] || error "inode $inode_num too small"
8409 do_facet $SINGLEMDS "losetup -d $mdsdev"
8412 run_test 115 "Access large xattr with inodes number over 2TB"
8415 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] && skip "ldiskfs only test"
8416 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.59) ] &&
8417 skip "Need server version at least 2.10.59"
8418 do_facet $SINGLEMDS which mkfs.xfs ||
8419 skip_env "No mkfs.xfs installed"
8424 local tmpmnt=$TMP/$tdir
8425 local mdtimg=$tfile-mdt0
8427 do_facet $SINGLEMDS mkdir -p $tmpmnt
8428 stack_trap "do_facet $SINGLEMDS rmdir $tmpmnt" EXIT
8430 do_facet $SINGLEMDS touch $TMP/$mdtimg
8431 stack_trap "do_facet $SINGLEMDS rm -f $TMP/$mdtimg" EXIT
8432 do_facet $SINGLEMDS mkfs -t xfs -d file,size=1t,name=$TMP/$mdtimg ||
8433 error "mkfs temporary xfs image"
8435 do_facet $SINGLEMDS mount $TMP/$mdtimg $tmpmnt ||
8436 error "mount temporary xfs image"
8437 stack_trap "do_facet $SINGLEMDS umount $tmpmnt" EXIT
8438 local old_mdssize=$MDSSIZE
8439 local old_mdsisize=$MDSISIZE
8441 MDSSIZE=$((17 * 1024 * 1024 * 1024)) # 17T MDT
8442 MDSISIZE=$((16 << 20))
8443 local opts17t="$(mkfs_opts $SINGLEMDS)"
8445 MDSSIZE=$old_mdssize
8446 MDSISIZE=$old_mdsisize
8447 do_facet $SINGLEMDS $MKFS $opts17t $tmpmnt/$mdtimg ||
8448 error "failed to mkfs for $tmpmnt/$mdtimg"
8450 do_facet $SINGLEMDS $TUNE2FS -l $tmpmnt/$mdtimg |
8451 grep -qw 'features.*extent' || error "extent should be enabled"
8454 run_test 116 "big size MDT support"
8458 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.nrs_policies=fifo"
8459 do_facet ost1 "$LCTL get_param -n ost.OSS.ost_io.nrs_tbf_rule" &&
8460 error "get_param should fail"
8461 cleanup || error "cleanup failed with rc $?"
8463 run_test 117 "lctl get_param return errors properly"
8465 test_120() { # LU-11130
8466 [ "$MDSCOUNT" -lt 2 ] && skip "mdt count < 2"
8467 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
8468 skip "ldiskfs only test"
8469 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
8470 skip "Need DNE2 capable MD target with LU-11130 fix"
8474 local mds1host=$(facet_active_host mds1)
8475 local mds1dev=$(mdsdevname 1)
8477 $LFS mkdir -i 1 $DIR/$tdir
8478 $LFS mkdir -i 0 $DIR/$tdir/mds1dir
8480 ln -s foo $DIR/$tdir/bar
8481 mv $DIR/$tdir/bar $DIR/$tdir/mds1dir/bar2 ||
8482 error "cross-target rename failed"
8486 run_e2fsck $mds1host $mds1dev "-n"
8488 run_test 120 "cross-target rename should not create bad symlinks"
8491 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
8492 [[ $(lustre_version_code ost1) -ge $(version_code 2.11.53) ]] ||
8493 skip "Need OST version at least 2.11.53"
8496 LOAD_MODULES_REMOTE=true load_modules
8497 #define OBD_FAIL_OFD_SET_OID 0x1e0
8498 do_facet ost1 $LCTL set_param fail_loc=0x00001e0
8501 $LFS mkdir -i1 -c1 $DIR/$tdir
8502 $LFS setstripe -i0 -c1 $DIR/$tdir
8503 do_facet ost1 $LCTL set_param fail_loc=0
8504 createmany -o $DIR/$tdir/file_ 1000 ||
8505 error "Fail to create a new sequence"
8509 run_test 122 "Check OST sequence update"
8512 remote_mgs_nodsh && skip "remote MGS with nodsh"
8513 [ -d $MOUNT/.lustre ] || setup
8515 # test old logid format until removal from llog_ioctl.c::str2logid()
8516 if [ $MGS_VERSION -lt $(version_code 3.1.53) ]; then
8517 do_facet mgs $LCTL dl | grep MGS
8518 do_facet mgs "$LCTL --device %MGS llog_print \
8519 \\\\\\\$$FSNAME-client 1 10" ||
8520 error "old llog_print failed"
8523 # test new logid format
8524 if [ $MGS_VERSION -ge $(version_code 2.9.53) ]; then
8525 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
8526 error "new llog_print failed"
8529 run_test 123aa "llog_print works with FIDs and simple names"
8532 remote_mgs_nodsh && skip "remote MGS with nodsh"
8533 [[ $MGS_VERSION -gt $(version_code 2.11.51) ]] ||
8534 skip "Need server with working llog_print support"
8536 [ -d $MOUNT/.lustre ] || setup
8541 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
8542 do_facet mgs $LCTL set_param -P jobid_name="testname"
8544 yaml=$(do_facet mgs $LCTL --device MGS llog_print params |
8545 grep jobid_name | tail -n 1)
8547 local param=$(awk '{ print $10 }' <<< "$yaml")
8548 local val=$(awk '{ print $12 }' <<< "$yaml")
8549 #return to the default
8550 do_facet mgs $LCTL set_param -P jobid_name=$orig_val
8551 [ $val = "testname" ] || error "bad value: $val"
8552 [ $param = "jobid_name," ] || error "Bad param: $param"
8554 run_test 123ab "llog_print params output values from set_param -P"
8556 test_123ac() { # LU-11566
8557 remote_mgs_nodsh && skip "remote MGS with nodsh"
8558 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8559 skip "Need 'lctl llog_print --start' on MGS"
8564 [ -d $MOUNT/.lustre ] || setup
8566 # - { index: 10, event: add_uuid, nid: 192.168.20.1@tcp(0x20000c0a81401,
8567 # node: 192.168.20.1@tcp }
8568 do_facet mgs $LCTL --device MGS \
8569 llog_print --start $start --end $end $FSNAME-client | tr -d , |
8570 while read DASH BRACE INDEX idx EVENT BLAH BLAH BLAH; do
8571 (( idx >= start )) || error "llog_print index $idx < $start"
8572 (( idx <= end )) || error "llog_print index $idx > $end"
8575 run_test 123ac "llog_print with --start and --end"
8577 test_123ad() { # LU-11566
8578 remote_mgs_nodsh && skip "remote MGS with nodsh"
8579 # older versions of lctl may not print all records properly
8580 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8581 skip "Need 'lctl llog_print --start' on MGS"
8583 [ -d $MOUNT/.lustre ] || setup
8585 # append a new record, to avoid issues if last record was cancelled
8586 local old=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
8587 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$old
8589 # logid: [0x3:0xa:0x0]:0
8593 local num=$(do_facet mgs $LCTL --device MGS llog_info $FSNAME-client |
8594 awk '/last_index:/ { print $2 - 1 }')
8596 # - { index: 71, event: set_timeout, num: 0x14, param: sys.timeout=20 }
8597 local last=$(do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
8598 tail -1 | awk '{ print $4 }' | tr -d , )
8599 (( last == num )) || error "llog_print only showed $last/$num records"
8601 run_test 123ad "llog_print shows all records"
8603 test_123ae() { # LU-11566
8604 remote_mgs_nodsh && skip "remote MGS with nodsh"
8605 [ -d $MOUNT/.lustre ] || setupall
8607 local max=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
8609 if do_facet mgs "$LCTL help llog_cancel" 2>&1| grep -q -- --log_id; then
8610 # save one set_param -P record in case none exist
8611 do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
8614 local orig=$(do_facet mgs $LCTL --device MGS llog_print $log |
8615 tail -1 | awk '{ print $4 }' | tr -d , )
8616 do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
8617 do_facet mgs $LCTL --device MGS llog_print $log | tail -1 |
8618 grep "parameter: osc.*.max_dirty_mb" ||
8619 error "new set_param -P wasn't stored in params log"
8621 # - { index: 71, event: set_param, device: general,
8622 # param: osc.*.max_dirty_mb, value: 256 }
8623 local id=$(do_facet mgs $LCTL --device MGS llog_print $log |
8624 tail -1 | awk '{ print $4 }' | tr -d , )
8626 do_facet mgs $LCTL --device MGS llog_cancel $log --log_idx=$id
8627 local new=$(do_facet mgs $LCTL --device MGS llog_print $log |
8628 tail -1 | awk '{ print $4 }' | tr -d , )
8629 (( new == orig )) ||
8630 error "new llog_cancel now $new, not at $orig records"
8633 # test old positional parameters for a while still
8634 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
8636 orig=$(do_facet mgs $LCTL --device MGS llog_print $log |
8637 tail -1 | awk '{ print $4 }' | tr -d , )
8638 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$max
8639 do_facet mgs $LCTL --device MGS llog_print $log |
8640 tail -1 | grep "parameter: osc.max_dirty_mb" ||
8641 error "old conf_param wasn't stored in params log"
8643 # - { index: 71, event: conf_param, device: testfs-OST0000-osc,
8644 # param: osc.max_dirty_mb=256 }
8645 id=$(do_facet mgs $LCTL --device MGS llog_print $log |
8646 tail -1 | awk '{ print $4 }' | tr -d , )
8647 do_facet mgs $LCTL --device MGS llog_cancel $log $id
8648 new=$(do_facet mgs $LCTL --device MGS llog_print $log |
8649 tail -1 | awk '{ print $4 }' | tr -d , )
8650 (( new == orig )) ||
8651 error "old llog_cancel now $new, not at $orig records"
8654 run_test 123ae "llog_cancel can cancel requested record"
8657 remote_mgs_nodsh && skip "remote MGS with nodsh"
8659 [ -d $MOUNT/.lustre ] || setup
8660 local yaml_file="$TMP/$tfile.yaml"
8661 do_facet mgs rm "$yaml_file"
8662 local cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist" |
8663 sed 's/config_log://')
8665 # set jobid_var to a different value for test
8666 local orig_val=$(do_facet mgs $LCTL get_param jobid_var)
8667 do_facet mgs $LCTL set_param -P jobid_var="testname"
8669 for i in $cfgfiles params; do
8670 do_facet mgs "lctl --device MGS llog_print ${i} >> $yaml_file"
8673 echo "Unmounting FS"
8683 # Reapply the config from before
8684 echo "Setting configuration parameters"
8685 do_facet mgs "lctl set_param -F $yaml_file"
8687 local set_val=$(do_facet mgs $LCTL get_param jobid_var)
8688 do_facet mgs $LCTL set_param -P $orig_val
8690 [ $set_val == "jobid_var=testname" ] ||
8691 error "$set_val is not testname"
8693 do_facet mgs rm "$yaml_file"
8696 run_test 123F "clear and reset all parameters using set_param -F"
8700 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
8701 [ -z $mds2failover_HOST ] && skip "needs MDT failover setup"
8707 if combined_mgs_mds; then
8708 start_mdt 1 "-o nosvc" ||
8709 error "starting mds with nosvc option failed"
8711 local nid=$(do_facet mds2 $LCTL list_nids | head -1)
8712 local failover_nid=$(do_node $mds2failover_HOST $LCTL list_nids | head -1)
8713 do_facet mgs $LCTL replace_nids $FSNAME-MDT0001 $nid:$failover_nid ||
8714 error "replace_nids execution error"
8716 if combined_mgs_mds; then
8722 echo "lfs setdirstripe"
8723 $LFS setdirstripe -i 1 $MOUNT/$tdir || error "setdirstirpe error"
8726 run_test 124 "check failover after replace_nids"
8728 get_max_sectors_kb() {
8731 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8732 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
8734 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
8735 cat ${max_sectors_path}"
8738 get_max_hw_sectors_kb() {
8741 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8742 local max_hw_path="/sys/block/${dev_base}/queue/max_hw_sectors_kb"
8744 do_facet ${facet} "[[ -e ${max_hw_path} ]] && cat ${max_hw_path}"
8747 set_max_sectors_kb() {
8751 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8752 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
8754 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
8755 echo ${value} > ${max_sectors_path}"
8758 [[ $rc -ne 0 ]] && echo "Failed to set ${max_sectors_path} to ${value}"
8763 # Return 0 if all slave devices have max_sectors_kb == max_hw_sectors_kb
8764 # Otherwise return > 0
8765 check_slaves_max_sectors_kb()
8769 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8770 local slaves_dir=/sys/block/${dev_base}/slaves
8771 local slave_devices=$(do_facet ${facet} "ls ${slaves_dir} 2>/dev/null")
8772 [[ -z ${slave_devices} ]] && return 0
8774 local slave max_sectors new_max_sectors max_hw_sectors path
8776 for slave in ${slave_devices}; do
8777 path="/dev/${slave}"
8778 ! is_blkdev ${facet} ${path} && continue
8779 max_sectors=$(get_max_sectors_kb ${facet} ${path})
8780 max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${path})
8781 new_max_sectors=${max_hw_sectors}
8782 [[ ${new_max_sectors} -gt ${RQ_SIZE_LIMIT} ]] &&
8783 new_max_sectors=${RQ_SIZE_LIMIT}
8785 if [[ ${max_sectors} -ne ${new_max_sectors} ]]; then
8786 echo "${path} ${max_sectors} ${new_max_sectors}"
8789 check_slaves_max_sectors_kb ${facet} ${path}
8798 local facet_list="mgs mds1 ost1"
8799 combined_mgs_mds && facet_list="mgs ost1"
8802 for facet in ${facet_list}; do
8803 [[ $(facet_fstype ${facet}) != ldiskfs ]] &&
8804 skip "ldiskfs only test" &&
8806 ! is_blkdev ${facet} $(facet_device ${facet}) &&
8807 skip "requires all real devices" &&
8812 # We don't increase IO request size limit past 16MB. See comments in
8813 # lustre/utils/libmount_utils_ldiskfs.c:tune_max_sectors_kb()
8814 RQ_SIZE_LIMIT=$((16 * 1024))
8815 local device old_max_sectors new_max_sectors max_hw_sectors
8816 for facet in ${facet_list}; do
8817 device=$(facet_device ${facet})
8818 old_max_sectors=$(get_max_sectors_kb ${facet} ${device})
8819 max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${device})
8821 # The expected value after l_tunedisk is executed
8822 new_max_sectors=$old_max_sectors
8823 [[ ${new_max_sectors_kb} -gt ${RQ_SIZE_LIMIT} ]] &&
8824 new_max_sectors_kb=${RQ_SIZE_LIMIT}
8826 # Ensure the current value of max_sectors_kb does not equal
8827 # max_hw_sectors_kb, so we can tell whether l_tunedisk did
8829 set_max_sectors_kb ${facet} ${device} $((new_max_sectors - 1))
8831 # Value before l_tunedisk
8832 local pre_max_sectors=$(get_max_sectors_kb ${facet} ${device})
8833 if [[ ${pre_max_sectors} -ne $((new_max_sectors - 1)) ]]; then
8834 echo "unable to satsify test pre-condition:"
8835 echo "${pre_max_sectors} != $((new_max_sectors - 1))"
8840 echo "Before: ${facet} ${device} ${pre_max_sectors} ${max_hw_sectors}"
8842 do_facet ${facet} "libtool execute l_tunedisk ${device}"
8844 # Value after l_tunedisk
8845 local post_max_sectors=$(get_max_sectors_kb ${facet} ${device})
8847 echo "After: ${facet} ${device} ${post_max_sectors} ${max_hw_sectors}"
8849 if [[ ${facet} != ost1 ]]; then
8850 if [[ ${post_max_sectors} -ne ${pre_max_sectors} ]]; then
8851 echo "l_tunedisk modified max_sectors_kb of ${facet}"
8855 set_max_sectors_kb ${facet} ${device} ${old_max_sectors}
8857 if [[ ${post_max_sectors} -eq ${pre_max_sectors} ]]; then
8858 echo "l_tunedisk failed to modify max_sectors_kb of ${facet}"
8862 check_slaves_max_sectors_kb ${facet} ${device} ||
8869 run_test 125 "check l_tunedisk only tunes OSTs and their slave devices"
8871 if ! combined_mgs_mds ; then
8877 # restore the values of MDSSIZE and OSTSIZE
8878 MDSSIZE=$STORED_MDSSIZE
8879 OSTSIZE=$STORED_OSTSIZE
8883 check_and_cleanup_lustre