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 115"
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 [ "$mds1_FSTYPE" = zfs ] && MDSSIZE=400000
48 [ "$ost1_FSTYPE" = 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
116 stop_mdt_no_force() {
119 local dev=$(mdsdevname $num)
122 echo "stop mds service on `facet_active_host $facet`"
123 stop $facet || return 97
129 local dev=$(mdsdevname $num)
132 echo "stop mds service on `facet_active_host $facet`"
133 # These tests all use non-failover stop
134 stop $facet -f || return 97
140 for num in $(seq $MDSCOUNT); do
141 start_mdt $num $@ || return 94
146 if ! combined_mgs_mds ; then
154 for num in $(seq $MDSCOUNT); do
155 stop_mdt $num || return 97
160 echo "stop mgs service on `facet_active_host mgs`"
161 # These tests all use non-failover stop
162 stop mgs -f || return 97
166 echo "start ost1 service on `facet_active_host ost1`"
167 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
171 echo "stop ost1 service on `facet_active_host ost1`"
172 # These tests all use non-failover stop
173 stop ost1 -f || return 98
177 echo "start ost2 service on `facet_active_host ost2`"
178 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
182 echo "stop ost2 service on `facet_active_host ost2`"
183 # These tests all use non-failover stop
184 stop ost2 -f || return 93
191 echo "mount $FSNAME ${mountopt:+with opts $mountopt} on $mountpath....."
192 zconf_mount $HOSTNAME $mountpath $mountopt || return 96
198 echo "umount lustre on $mountpath....."
199 zconf_umount $HOSTNAME $mountpath $@ || return 97
202 manual_umount_client(){
205 echo "manual umount lustre on ${MOUNT}...."
206 do_facet client "umount ${FORCE} $MOUNT"
212 start_mds || error "MDT start failed"
213 start_ost || error "Unable to start OST1"
214 mount_client $MOUNT || error "client start failed"
215 client_up || error "client_up failed"
224 unload_modules_conf () {
225 if combined_mgs_mds || ! local_mode; then
226 unload_modules || return 1
231 stop_ost || return 202
232 stop_mds || return 201
233 unload_modules_conf || return 203
238 [ "x$1" != "x" ] && force='-f'
239 umount_client $MOUNT $force|| return 200
240 cleanup_nocli || return $?
245 echo "umount $MOUNT2 ..."
246 umount $MOUNT2 || true
247 echo "stopping fs2mds ..."
248 stop fs2mds -f || true
249 echo "stopping fs2ost ..."
250 stop fs2ost -f || true
254 do_facet client "cp /etc/passwd $DIR/a" || return 71
255 do_facet client "rm $DIR/a" || return 72
256 # make sure lustre is actually mounted (touch will block,
257 # but grep won't, so do it after)
258 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
259 echo "setup single mount lustre success"
263 do_facet client "touch $DIR/a" || return 71
264 do_facet client "rm $DIR/a" || return 72
265 do_facet client "touch $DIR2/a" || return 73
266 do_facet client "rm $DIR2/a" || return 74
267 echo "setup double mount lustre success"
271 cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
274 if [ "$ONLY" == "setup" ]; then
279 if [ "$ONLY" == "cleanup" ]; then
286 #create single point mountpoint
292 check_mount || error "check_mount failed"
293 cleanup || error "cleanup failed with $?"
295 run_test 0 "single mount setup"
298 start_mds || error "MDS start failed"
299 start_ost || error "unable to start OST"
300 echo "start ost second time..."
301 start_ost && error "2nd OST start should fail"
302 mount_client $MOUNT || error "client start failed"
303 check_mount || error "check_mount failed"
304 cleanup || error "cleanup failed with $?"
306 run_test 1 "start up ost twice (should return errors)"
309 start_mds || error "MDT start failed"
310 echo "start mds second time.."
311 start_mds && error "2nd MDT start should fail"
312 start_ost || error "OST start failed"
313 mount_client $MOUNT || error "mount_client failed to start client"
314 check_mount || error "check_mount failed"
315 cleanup || error "cleanup failed with $?"
317 run_test 2 "start up mds twice (should return err)"
321 #mount.lustre returns an error if already in mtab
322 mount_client $MOUNT && error "2nd client mount should fail"
323 check_mount || error "check_mount failed"
324 cleanup || error "cleanup failed with $?"
326 run_test 3 "mount client twice (should return err)"
330 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
331 stop_ost || error "Unable to stop OST1"
332 umount_client $MOUNT -f || error “unmount $MOUNT failed”
335 # ok for ost to fail shutdown
336 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
337 error "cleanup failed with $?"
340 run_test 4 "force cleanup ost, then cleanup"
342 test_5a() { # was test_5
344 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
345 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
347 stop_mds || error "Unable to stop MDS"
349 # cleanup may return an error from the failed
350 # disconnects; for now I'll consider this successful
351 # if all the modules have unloaded.
355 echo "killing umount"
356 kill -TERM $UMOUNT_PID
357 echo "waiting for umount to finish"
359 if grep " $MOUNT " /proc/mounts; then
360 echo "test 5: /proc/mounts after failed umount"
364 echo "killing umount"
365 kill -TERM $UMOUNT_PID
366 echo "waiting for umount to finish"
368 grep " $MOUNT " /proc/mounts &&
369 error "/proc/mounts after second umount"
372 # manual_mount_client may fail due to umount succeeding above
374 # stop_mds is a no-op here, and should not fail
375 cleanup_nocli || error "cleanup_nocli failed with $?"
376 # df may have lingering entry
378 # mtab may have lingering entry
382 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
384 grep -q $MOUNT" " /etc/mtab || break
385 echo "Waiting /etc/mtab updated ... "
386 WAIT=$(( WAIT + sleep))
388 [ "$WAIT" -eq "$MAX_WAIT" ] &&
389 error "/etc/mtab is not updated in $WAIT secs"
390 echo "/etc/mtab updated in $WAIT secs"
392 run_test 5a "force cleanup mds, then cleanup"
400 grep " $MOUNT " /etc/mtab &&
401 error false "unexpected entry in mtab before mount" && return 10
403 start_ost || error "OST start failed"
404 if ! combined_mgs_mds ; then
405 trap cleanup_5b EXIT ERR
406 start_mds || error "MDS start failed"
410 mount_client $MOUNT && error "mount_client $MOUNT should fail"
411 grep " $MOUNT " /etc/mtab &&
412 error "$MOUNT entry in mtab after failed mount"
414 # stop_mds is a no-op here, and should not fail
415 cleanup_nocli || error "cleanup_nocli failed with $?"
416 if ! combined_mgs_mds ; then
420 run_test 5b "Try to start a client with no MGS (should return errs)"
423 grep " $MOUNT " /etc/mtab &&
424 error false "unexpected entry in mtab before mount" && return 10
426 start_mds || error "MDS start failed"
427 start_ost || error "OST start failed"
428 local oldfs="${FSNAME}"
429 FSNAME="wrong.${FSNAME}"
430 mount_client $MOUNT || :
432 grep " $MOUNT " /etc/mtab &&
433 error "$MOUNT entry in mtab after failed mount"
435 cleanup_nocli || error "cleanup_nocli failed with $?"
437 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
440 grep " $MOUNT " /etc/mtab &&
441 error "unexpected entry in mtab before mount"
443 start_ost || error "OST start failed"
444 start_mds || error "MDS start failed"
445 stop_ost -f || error "Unable to stop OST1"
446 mount_client $MOUNT || error "mount_client $MOUNT failed"
447 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
448 cleanup_nocli || error "cleanup_nocli failed with $?"
449 ! grep " $MOUNT " /etc/mtab ||
450 error "$MOUNT entry in mtab after unmount"
452 run_test 5d "mount with ost down"
455 grep " $MOUNT " /etc/mtab &&
456 error false "unexpected entry in mtab before mount" && return 10
458 start_mds || error "MDS start failed"
459 start_ost || error "OST start failed"
461 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
462 do_facet client "$LCTL set_param fail_loc=0x80000506"
463 mount_client $MOUNT || echo "mount failed (not fatal)"
464 cleanup || error "cleanup failed with $?"
465 grep " $MOUNT " /etc/mtab &&
466 error "$MOUNT entry in mtab after unmount"
469 run_test 5e "delayed connect, don't crash (bug 10268)"
472 combined_mgs_mds && skip "needs separate mgs and mds"
474 grep " $MOUNT " /etc/mtab &&
475 error false "unexpected entry in mtab before mount" && return 10
478 start_ost || error "OST start failed"
479 mount_client $MOUNT &
481 echo client_mount pid is $pid
485 if ! ps -f -p $pid >/dev/null; then
488 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
489 error "mount returns $rc, expected to hang"
491 cleanup || error "cleanup failed with $?"
496 start_mds || error "start MDS failed"
498 # mount should succeed after start mds
500 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
501 cleanup || error "final call to cleanup failed with rc $?"
503 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
507 [ "$CLIENT_VERSION" -lt $(version_code 2.9.53) ] &&
508 skip "automount of debugfs missing before 2.9.53"
509 umount /sys/kernel/debug
510 $LCTL get_param -n devices | egrep -v "error" && \
511 error "lctl can't access debugfs data"
512 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
514 run_test 5g "handle missing debugfs"
520 #define OBD_FAIL_MDS_FS_SETUP 0x135
521 do_facet mds1 "$LCTL set_param fail_loc=0x80000135"
522 start_mdt 1 && error "start mdt should fail"
523 start_mdt 1 || error "start mdt failed"
524 client_up || error "client_up failed"
527 run_test 5h "start mdt failure at mdt_fs_setup()"
533 #define OBD_FAIL_QUOTA_INIT 0xA05
534 do_facet mds1 "$LCTL set_param fail_loc=0x80000A05"
535 start_mdt 1 && error "start mdt should fail"
536 start_mdt 1 || error "start mdt failed"
537 client_up || error "client_up failed"
540 run_test 5i "start mdt failure at mdt_quota_init()"
545 mount_client $MOUNT || error "mount_client $MOUNT failed"
546 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
547 cleanup || error "cleanup failed with rc $?"
549 run_test 6 "manual umount, then mount again"
554 cleanup_nocli || error "cleanup_nocli failed with $?"
556 run_test 7 "manual umount, then cleanup"
560 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
561 check_mount2 || error "check_mount2 failed"
562 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
563 cleanup || error "cleanup failed with rc $?"
565 run_test 8 "double mount setup"
568 start_ost || error "OST start failed"
570 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
571 error "do_facet ost1 set_param inode trace failed."
572 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
573 error "do_facet ost1 set_param debug mds ost failed."
575 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
576 if [ "$CHECK_PTLDEBUG" ] && { \
577 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
578 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
579 echo "lnet.debug success"
581 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
583 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
584 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
585 echo "lnet.subsystem_debug success"
587 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
589 stop_ost || error "Unable to stop OST1"
591 run_test 9 "test ptldebug and subsystem for mkfs"
594 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
595 # But with new MDS stack we don't care about the mode of local objects
596 # anymore, so this test is removed. See bug 22944 for more details.
600 if [ "$mds1_FSTYPE" != ldiskfs ]; then
601 skip "ldiskfs only test"
605 check_mount || error "check_mount failed"
606 cleanup || error "cleanup failed with rc $?"
608 echo "Remove mds config log"
609 if ! combined_mgs_mds ; then
613 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
614 $(mgsdevname) || return \$?" ||
615 error "do_facet mgs failed with $?"
617 if ! combined_mgs_mds ; then
621 start_ost || error "OST start failed"
622 start_mds && error "MDS start succeeded, but should fail"
625 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
628 if [ "$mds1_FSTYPE" != ldiskfs ]; then
629 skip "ldiskfs only test"
632 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
637 # check if current MDSSIZE is large enough
638 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
639 log "use MDSSIZE=$MDSSIZE"
641 # check if the global config has a large enough MDSSIZE
642 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
643 [ $STORED_MDSSIZE -ge $MIN ] &&
644 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
645 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
647 # check if the block device is large enough
648 is_blkdev $SINGLEMDS $MDSDEV $MIN
649 local large_enough=$?
650 if [ -n "$OK" ]; then
651 [ $large_enough -ne 0 ] && OK=""
653 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
654 log "use device $MDSDEV with MIN=$MIN"
657 # check if a loopback device has enough space for fs metadata (5%)
659 if [ -z "$OK" ]; then
660 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
661 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
662 awk '($1 != "Filesystem") { print $4 }')
663 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
664 OK=1 && myMDSSIZE=$MIN &&
665 log "use file $MDSDEV with MIN=$MIN"
668 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS"
670 echo "mount mds with large journal..."
672 local OLD_MDSSIZE=$MDSSIZE
676 echo "mount lustre system..."
678 check_mount || error "check_mount failed"
680 echo "check journal size..."
681 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
682 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
683 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
685 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
688 cleanup || error "cleanup failed with rc $?"
693 run_test 18 "check mkfs creates large journals"
696 start_mds || error "MDS start failed"
697 stop_mds || error "Unable to stop MDS"
699 run_test 19a "start/stop MDS without OSTs"
702 start_ost || error "Unable to start OST1"
703 stop_ost -f || error "Unable to stop OST1"
705 run_test 19b "start/stop OSTs without MDS"
708 # first format the ost/mdt
709 start_mds || error "MDS start failed"
710 start_ost || error "Unable to start OST1"
711 mount_client $MOUNT || error "mount_client $MOUNT failed"
712 check_mount || error "check_mount failed"
713 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
714 mount_client $MOUNT remount,ro || error "remount client with ro failed"
715 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
716 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
717 mount_client $MOUNT remount,rw || error "remount client with rw failed"
718 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
719 MCNT=$(grep -c $MOUNT' ' /etc/mtab)
720 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
722 stop_mds || error "Unable to stop MDS"
723 stop_ost || error "Unable to stop OST1"
725 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
728 start_mds || error "MDS start failed"
729 start_ost || error "unable to start OST1"
730 wait_osc_import_state mds ost FULL
731 stop_ost || error "unable to stop OST1"
732 stop_mds || error "unable to stop MDS"
734 run_test 21a "start mds before ost, stop ost first"
737 start_ost || error "unable to start OST1"
738 start_mds || error "MDS start failed"
739 wait_osc_import_state mds ost FULL
740 stop_mds || error "unable to stop MDS"
741 stop_ost || error "unable to stop OST1"
743 run_test 21b "start ost before mds, stop mds first"
746 start_ost || error "Unable to start OST1"
747 start_mds || error "MDS start failed"
748 start_ost2 || error "Unable to start OST2"
749 wait_osc_import_state mds ost2 FULL
750 stop_ost || error "Unable to stop OST1"
751 stop_ost2 || error "Unable to stop OST2"
752 stop_mds || error "Unable to stop MDS"
753 #writeconf to remove all ost2 traces for subsequent tests
754 writeconf_or_reformat
756 run_test 21c "start mds between two osts, stop mds last"
759 combined_mgs_mds && skip "need separate mgs device"
764 start_mgs || error "unable to start MGS"
765 start_ost || error "unable to start OST1"
766 start_ost2 || error "unable to start OST2"
767 start_mds || error "MDS start failed"
768 wait_osc_import_state mds ost2 FULL
770 local zkeeper=${KEEP_ZPOOL}
771 stack_trap "KEEP_ZPOOL=$zkeeper" EXIT
774 stop_ost || error "Unable to stop OST1"
775 stop_ost2 || error "Unable to stop OST2"
776 stop_mds || error "Unable to stop MDS"
778 #writeconf to remove all ost2 traces for subsequent tests
779 writeconf_or_reformat
780 KEEP_ZPOOL="${zkeeper}"
782 start_mgs || error "unable to start MGS"
784 run_test 21d "start mgs then ost and then mds"
787 MGSNID="$saved_mgsnid"
789 echo "stopping fs2mgs ..."
790 stop $fs2mgs -f || true
793 test_21e() { # LU-5863
794 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
795 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
796 skip_env "mixed loopback and real device not working"
799 local fs2mdsdev=$(mdsdevname 1_2)
800 local fs2ostdev=$(ostdevname 1_2)
801 local fs3ostdev=$(ostdevname 2_2)
803 local fs2mdsvdev=$(mdsvdevname 1_2)
804 local fs2ostvdev=$(ostvdevname 1_2)
805 local fs3ostvdev=$(ostvdevname 2_2)
807 # temporarily use fs3ost as fs2mgs
809 local fs2mgsdev=$fs3ostdev
810 local fs2mgsvdev=$fs3ostvdev
812 local fsname=test1234
814 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
815 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
816 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
817 error "start fs2mgs failed"
819 local saved_mgsnid="$MGSNID"
820 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
822 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
823 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
824 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
825 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
827 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
828 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
830 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
831 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
832 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
836 run_test 21e "separate MGS and MDS"
839 start_mds || error "MDS start failed"
841 echo "Client mount with ost in logs, but none running"
842 start_ost || error "unable to start OST1"
843 # wait until mds connected to ost and open client connection
844 wait_osc_import_state mds ost FULL
845 stop_ost || error "unable to stop OST1"
846 mount_client $MOUNT || error "mount_client $MOUNT failed"
847 # check_mount will block trying to contact ost
848 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
849 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
850 umount_client $MOUNT -f
853 echo "Client mount with a running ost"
854 start_ost || error "unable to start OST1"
856 # if gss enabled, wait full time to let connection from
857 # mds to ost be established, due to the mismatch between
858 # initial connect timeout and gss context negotiation timeout.
859 # This perhaps could be remove after AT landed.
860 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
861 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
863 mount_client $MOUNT || error "mount_client $MOUNT failed"
864 wait_osc_import_state mds ost FULL
865 wait_osc_import_ready client ost
866 check_mount || error "check_mount failed"
869 cleanup || error "cleanup failed with rc $?"
871 run_test 22 "start a client before osts (should return errs)"
873 test_23a() { # was test_23
876 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
877 # force down client so that recovering mds waits for reconnect
878 local running=$(grep -c $MOUNT /proc/mounts) || true
879 if [ $running -ne 0 ]; then
880 echo "Stopping client $MOUNT (opts: -f)"
884 # enter recovery on failed mds
885 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
886 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
887 # try to start a new client
888 mount_client $MOUNT &
890 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
891 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
892 grep -v grep | awk '{print $2}')
893 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
895 ps --ppid $MOUNT_LUSTRE_PID
896 echo "waiting for mount to finish"
898 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
899 # SIGTERM works but it does not spread to offspring processses
900 kill -s TERM $MOUNT_PID
901 kill -s TERM $MOUNT_LUSTRE_PID
902 # we can not wait $MOUNT_PID because it is not a child of this shell
908 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
910 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
911 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
914 [ -z "$PID1" -a -z "$PID2" ] && break
915 echo "waiting for mount to finish ... "
916 WAIT=$(( WAIT + sleep))
918 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
919 error "MOUNT_PID $MOUNT_PID and "\
920 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
923 cleanup || error "cleanup failed with rc $?"
925 run_test 23a "interrupt client during recovery mount delay"
927 test_23b() { # was test_23
928 start_mds || error "MDS start failed"
929 start_ost || error "Unable to start OST1"
930 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
931 $LCTL set_param fail_loc=0x80000313
933 cleanup || error "cleanup failed with rc $?"
935 run_test 23b "Simulate -EINTR during mount"
938 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
940 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
941 is_blkdev $SINGLEMDS $MDSDEV &&
942 skip_env "mixed loopback and real device not working"
945 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
947 local fs2mdsdev=$(mdsdevname 1_2)
948 local fs2ostdev=$(ostdevname 1_2)
949 local fs2mdsvdev=$(mdsvdevname 1_2)
950 local fs2ostvdev=$(ostvdevname 1_2)
953 # LU-9733 test fsname started with numbers as well
954 local FSNAME2=969362ae
956 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
957 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
959 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
960 --reformat $fs2ostdev $fs2ostvdev || exit 10
963 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
964 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
965 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
966 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
968 # LU-9733 test fsname started with numbers
969 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
970 changelog_register -n) ||
971 error "register changelog failed"
973 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
974 changelog_deregister $cl_user ||
975 error "deregister changelog failed"
977 check_mount || error "check_mount failed"
978 # files written on 1 should not show up on 2
979 cp /etc/passwd $DIR/$tfile
981 [ -e $MOUNT2/$tfile ] && error "File bleed"
984 cp /etc/passwd $MOUNT2/$tfile ||
985 error "cp /etc/passwd $MOUNT2/$tfile failed"
986 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
987 # 2 is actually mounted
988 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
990 facet_failover fs2mds
991 facet_failover fs2ost
994 # the MDS must remain up until last MDT
996 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
997 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
998 [ -z "$MDS" ] && error "No MDT"
1000 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1002 run_test 24a "Multiple MDTs on a single node"
1005 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1007 skip "needs combined MGT and MDT device"
1009 if [ -z "$fs2mds_DEV" ]; then
1010 local dev=${SINGLEMDS}_dev
1011 local MDSDEV=${!dev}
1012 is_blkdev $SINGLEMDS $MDSDEV &&
1013 skip_env "mixed loopback and real device not working"
1016 local fs2mdsdev=$(mdsdevname 1_2)
1017 local fs2mdsvdev=$(mdsvdevname 1_2)
1019 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1020 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1022 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && {
1024 error "start MDS should fail"
1027 cleanup || error "cleanup failed with rc $?"
1029 run_test 24b "Multiple MGSs on a single node (should return err)"
1033 check_mount || error "check_mount failed"
1034 local MODULES=$($LCTL modules | awk '{ print $2 }')
1035 rmmod $MODULES 2>/dev/null || true
1036 cleanup || error "cleanup failed with $?"
1038 run_test 25 "Verify modules are referenced"
1042 # we need modules before mount for sysctl, so make sure...
1043 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1044 #define OBD_FAIL_MDS_FS_SETUP 0x135
1045 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1046 start_mds && error "MDS started but should not have started"
1047 $LCTL get_param -n devices
1048 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1049 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1050 # start mds to drop writeconf setting
1051 start_mds || error "Unable to start MDS"
1052 stop_mds || error "Unable to stop MDS"
1053 unload_modules_conf || error "unload_modules_conf failed with $?"
1055 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1059 start_ost || error "Unable to start OST1"
1060 start_mds || error "Unable to start MDS"
1061 echo "Requeue thread should have started: "
1062 ps -e | grep ll_cfg_requeue
1063 set_persistent_param_and_check ost1 \
1064 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1065 "$FSNAME-OST0000.ost.client_cache_seconds"
1066 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1068 run_test 27a "Reacquire MGS lock if OST started first"
1073 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1074 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1076 facet_failover $SINGLEMDS
1077 set_persistent_param_and_check $SINGLEMDS \
1078 "mdt.$device.identity_acquire_expire" \
1079 "$device.mdt.identity_acquire_expire"
1080 set_persistent_param_and_check client \
1081 "mdc.$device-mdc-*.max_rpcs_in_flight" \
1082 "$device.mdc.max_rpcs_in_flight"
1084 cleanup || error "cleanup failed with $?"
1086 run_test 27b "Reacquire MGS lock after failover"
1088 test_28A() { # was test_28
1091 local TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1092 local PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1093 local orig=$($LCTL get_param -n $TEST)
1094 local max=$($LCTL get_param -n \
1095 llite.$FSNAME-*.max_read_ahead_per_file_mb)
1097 orig=${orig%%.[0-9]*}
1099 echo "ORIG:$orig MAX:$max"
1100 [[ $max -le $orig ]] && orig=$((max - 3))
1101 echo "ORIG:$orig MAX:$max"
1103 local final=$((orig + 1))
1105 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1106 final=$((final + 1))
1107 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1108 umount_client $MOUNT || error "umount_client $MOUNT failed"
1109 mount_client $MOUNT || error "mount_client $MOUNT failed"
1111 local result=$($LCTL get_param -n $TEST)
1113 if [ $result -ne $final ]; then
1114 error "New config not seen: wanted $final got $result"
1116 echo "New config success: got $result"
1118 set_persistent_param_and_check client "$TEST" "$PARAM" $orig
1119 cleanup || error "cleanup failed with rc $?"
1121 run_test 28A "permanent parameter setting"
1123 test_28a() { # LU-4221
1124 [[ "$OST1_VERSION" -ge $(version_code 2.5.52) ]] ||
1125 skip "Need OST version at least 2.5.52"
1126 [ "$ost1_FSTYPE" = zfs ] &&
1127 skip "LU-4221: no such proc params for ZFS OSTs"
1134 local device="$FSNAME-OST0000"
1138 # In this test we will set three kinds of proc parameters with
1139 # lctl set_param -P or lctl conf_param:
1140 # 1. non-symlink ones in the OFD
1141 # 2. non-symlink ones in the OSD
1144 # prepare a non-symlink parameter in the OFD
1145 name="client_cache_seconds"
1146 param="$device.ost.$name"
1147 cmd="obdfilter.$device.$name"
1149 # permanently setting the parameter in the OFD
1150 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1152 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1153 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1156 # prepare a non-symlink parameter in the OSD
1158 param="$device.osd.$name"
1159 cmd="osd-*.$device.$name"
1161 # conf_param the parameter in the OSD
1162 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1163 new=$(((old + 1) % 2))
1164 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1165 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1167 cleanup || error "cleanup failed with $?"
1169 run_test 28a "set symlink parameters permanently with lctl"
1172 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
1173 setup_noconfig > /dev/null 2>&1
1174 start_ost2 || error "Unable to start OST2"
1177 local PARAM="$FSNAME-OST0001.osc.active"
1178 # With lctl set_param -P the value $PROC_ACT will be sent to
1179 # all nodes. The [!M] filter out the ability to set active
1180 # on the MDS servers which is tested with wait_osp_* below.
1181 # For ost_server_uuid that only exist on client so filtering
1183 local PROC_ACT="os[cp].$FSNAME-OST0001-osc-[^M]*.active"
1184 local PROC_UUID="os[cp].$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1186 ACTV=$($LCTL get_param -n $PROC_ACT)
1188 set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
1189 # also check ost_server_uuid status
1190 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1191 if [ -z "$RESULT" ]; then
1192 error "Client not deactivated: $($LCTL get_param \
1195 echo "Live client success: got $RESULT"
1199 wait_osp_active ost ${FSNAME}-OST0001 1 0
1201 # test new client starts deactivated
1202 umount_client $MOUNT || error "umount_client $MOUNT failed"
1203 mount_client $MOUNT || error "mount_client $MOUNT failed"
1205 # the 2nd and 3rd field of ost_server_uuid do not update at the same
1206 # time when using lctl set_param -P
1207 wait_update_facet client \
1208 "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'" \
1210 error "New client start active: $($LCTL get_param -n $PROC_UUID)"
1212 echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
1214 # make sure it reactivates
1215 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1217 umount_client $MOUNT
1218 stop_ost2 || error "Unable to stop OST2"
1219 cleanup_nocli || error "cleanup_nocli failed with $?"
1220 #writeconf to remove all ost2 traces for subsequent tests
1221 writeconf_or_reformat
1223 run_test 29 "permanently remove an OST"
1228 echo Big config llog
1229 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1230 ORIG=$($LCTL get_param -n $TEST)
1231 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1232 for i in ${LIST[@]}; do
1233 set_persistent_param_and_check client "$TEST" \
1234 "$FSNAME.llite.max_read_ahead_whole_mb" $i
1236 # make sure client restart still works
1237 umount_client $MOUNT
1238 mount_client $MOUNT || error "mount_client $MOUNT failed"
1239 [ "$($LCTL get_param -n $TEST)" -ne "$i" ] &&
1240 error "Param didn't stick across restart $($TEST) != $i"
1243 echo Erase parameter setting
1244 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1245 do_facet mgs "$PERM_CMD -d $TEST" ||
1246 error "Erase param $TEST failed"
1248 do_facet mgs "$PERM_CMD \
1249 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1250 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1252 umount_client $MOUNT
1253 mount_client $MOUNT || error "mount_client $MOUNT failed"
1254 FINAL=$($LCTL get_param -n $TEST)
1255 echo "deleted (default) value=$FINAL, orig=$ORIG"
1256 ORIG=${ORIG%%.[0-9]*}
1257 FINAL=${FINAL%%.[0-9]*}
1258 # assumes this parameter started at the default value
1259 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1261 cleanup || error "cleanup failed with rc $?"
1263 run_test 30a "Big config llog and permanent parameter deletion"
1268 local orignids=$($LCTL get_param -n \
1269 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1271 local orignidcount=$(echo "$orignids" | wc -w)
1273 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1274 # numerical part of it. Hopefully that's not already a failover address
1276 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1278 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1279 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1280 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1281 echo "Using fake nid $NEW"
1283 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1284 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1285 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1286 PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
1287 echo "Setting $PARAM from $TEST to $NEW"
1288 do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
1289 error "$PERM_CMD $PARAM failed"
1291 PARAM="$FSNAME-OST0000.failover.node"
1292 echo "Setting $PARAM from $TEST to $NEW"
1293 do_facet mgs "$PERM_CMD $PARAM='$NEW'" ||
1294 error "$PARAM $PARAM failed"
1296 wait_update_facet client "$TEST" "$NEW" ||
1297 error "check $PARAM failed!"
1299 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1301 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1302 echo "should have $((orignidcount + 1)) entries \
1303 in failover nids string, have $NIDCOUNT"
1304 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1305 error "Failover nid not added"
1307 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1308 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1310 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1311 error "$PERM_CMD delete failed"
1313 umount_client $MOUNT
1314 mount_client $MOUNT || error "mount_client $MOUNT failed"
1316 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1318 NIDCOUNT=$(echo "$NIDS" | wc -w)
1319 echo "only $orignidcount final entries should remain \
1320 in failover nids string, have $NIDCOUNT"
1321 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1323 cleanup || error "cleanup failed with rc $?"
1325 run_test 30b "Remove failover nids"
1327 test_31() { # bug 10734
1328 # ipaddr must not exist
1329 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1330 cleanup || error "cleanup failed with rc $?"
1332 run_test 31 "Connect to non-existent node (shouldn't crash)"
1336 T32_BLIMIT=40960 # Kbytes
1340 # This is not really a test but a tool to create new disk
1341 # image tarballs for the upgrade tests.
1343 # Disk image tarballs should be created on single-node
1344 # clusters by running this test with default configurations
1345 # plus a few mandatory environment settings that are verified
1346 # at the beginning of the test.
1348 test_32newtarball() {
1352 local tmp=$TMP/t32_image_create
1357 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1358 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1359 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1360 "MDSDEV1=<nonexistent_file>" \
1361 "MDSDEV2=<nonexistent_file>" \
1362 "(or MDSDEV, in the case of b1_8)" \
1363 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1367 echo "Found stale $tmp"
1371 mkdir $tmp/src || return 1
1372 tar cf - -C $src . | tar xf - -C $tmp/src
1373 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1374 count=$(($T32_BLIMIT / 1024 / 4))
1375 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1377 # format ost with comma-separated NIDs to verify LU-4460
1378 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1379 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1383 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1384 $LFS quotacheck -ug /mnt/$FSNAME
1385 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1388 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1390 if [[ $MDSCOUNT -ge 2 ]]; then
1391 remote_dir=/mnt/$FSNAME/remote_dir
1392 $LFS mkdir -i 1 $remote_dir
1393 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1395 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1396 striped_dir=/mnt/$FSNAME/striped_dir_old
1397 $LFS mkdir -i 1 -c 2 $striped_dir
1398 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1404 mkdir $tmp/img || return 1
1408 pushd_dir=/mnt/$FSNAME
1409 if [[ $MDSCOUNT -ge 2 ]]; then
1410 pushd_dir=$remote_dir
1411 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1413 ls -Rni --time-style=+%s >$tmp/img/list2
1419 ls -Rni --time-style=+%s >$tmp/img/list
1420 find ! -name .lustre -type f -exec sha1sum {} \; |
1421 sort -k 2 >$tmp/img/sha1sums
1423 $LCTL get_param -n version | head -n 1 |
1424 sed -e 's/^lustre: *//' >$tmp/img/commit
1426 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1427 $LFS quotaon -ug /mnt/$FSNAME
1428 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1429 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1430 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1431 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1432 | tr -d "*" > $tmp/img/bspace
1433 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1434 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1435 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1436 | tr -d "*" > $tmp/img/ispace
1437 echo $T32_BLIMIT > $tmp/img/blimit
1438 echo $T32_ILIMIT > $tmp/img/ilimit
1440 $MULTIOP /mnt/$FSNAME/orph_file Ouw_c&
1444 debugfs -R "ls /PENDING" ${MDSDEV1:-$MDSDEV}
1445 cp ${MDSDEV1:-$MDSDEV} $tmp/img
1453 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1456 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1457 echo "Data verification failed"
1460 uname -r >$tmp/img/kernel
1461 uname -m >$tmp/img/arch
1463 for num in $(seq 2 $MDSCOUNT); do
1464 local devname=$(mdsdevname $num)
1466 [[ $(facet_fstype $facet) != zfs ]] ||
1467 devname=$(mdsvdevname $num)
1468 mv $devname $tmp/img
1470 mv $OSTDEV1 $tmp/img
1472 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1473 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1476 tar cjvf $dst/disk$version-"$mds1_FSTYPE".tar.bz2 -S *
1481 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1484 # The list of applicable tarballs is returned via the caller's
1485 # variable "tarballs".
1488 [ "$CLIENTONLY" ] && skip "Client-only testing"
1490 local node=$(facet_active_host $SINGLEMDS)
1491 local r="do_node $node"
1493 ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
1495 local IMGTYPE="$mds1_FSTYPE"
1497 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1498 -name \'disk*-$IMGTYPE.tar.bz2\')
1500 [ -z "$tarballs" ] && skip "No applicable tarballs found"
1503 t32_test_cleanup() {
1505 local facet=$SINGLEMDS
1508 if $shall_cleanup_lustre; then
1509 umount $tmp/mnt/lustre || rc=$?
1511 if $shall_cleanup_mdt; then
1512 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1514 if $shall_cleanup_mdt1; then
1515 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1517 if $shall_cleanup_ost; then
1518 $r $UMOUNT $tmp/mnt/ost || rc=$?
1523 if [[ "$mds1_FSTYPE" == zfs ]]; then
1525 local poolname_list="t32fs-mdt1 t32fs-ost1"
1527 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1529 for poolname in $poolname_list; do
1530 destroy_zpool $facet $poolname
1533 combined_mgs_mds || start_mgs || rc=$?
1537 t32_bits_per_long() {
1539 # Yes, this is not meant to be perfect.
1549 t32_reload_modules() {
1551 local all_removed=false
1554 [ "$mds1_FSTYPE" == zfs ] && do_rpc_nodes $node "service zed stop"
1556 while ((i < 20)); do
1557 echo "Unloading modules on $node: Attempt $i"
1558 do_rpc_nodes $node $LUSTRE_RMMOD "$mds1_FSTYPE" &&
1560 do_rpc_nodes $node check_mem_leak || return 1
1561 if $all_removed; then
1562 do_rpc_nodes $node load_modules
1565 if [ "$mds1_FSTYPE" == zfs ]; then
1566 do_rpc_nodes $node "$ZPOOL status -v"
1571 echo "Unloading modules on $node: Given up"
1575 t32_wait_til_devices_gone() {
1581 echo wait for devices to go
1582 while ((i < 20)); do
1583 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1584 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1585 ((devices == 0 && loops == 0)) && return 0
1589 echo "waiting for dev on $node: dev $devices loop $loops given up"
1590 do_rpc_nodes $node "losetup -a"
1591 do_rpc_nodes $node "$LCTL device_list"
1595 t32_verify_quota() {
1602 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1603 # lustre will estimate the object count usage. This fails quota
1604 # verification in 32b. The object quota usage should be accurate after
1605 # zfs-0.7.0 is released.
1606 [ "$mds1_FSTYPE" == zfs ] && {
1607 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1609 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1610 echo "Skip quota verify for zfs: $zfs_version"
1615 $LFS quota -u $T32_QID -v $mnt
1617 qval=$($LFS quota -v -u $T32_QID $mnt |
1618 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1619 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1621 [ $qval -eq $img_bspace ] || {
1622 echo "bspace, act:$qval, exp:$img_bspace"
1626 qval=$($LFS quota -v -u $T32_QID $mnt |
1627 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1628 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1630 [ $qval -eq $img_ispace ] || {
1631 echo "ispace, act:$qval, exp:$img_ispace"
1635 qval=$($LFS quota -v -u $T32_QID $mnt |
1636 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1637 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1639 [ $qval -eq $img_blimit ] || {
1640 echo "blimit, act:$qval, exp:$img_blimit"
1644 qval=$($LFS quota -v -u $T32_QID $mnt |
1645 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1646 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1648 [ $qval -eq $img_ilimit ] || {
1649 echo "ilimit, act:$qval, exp:$img_ilimit"
1653 set_persistent_param_and_check $facet \
1654 "osd-$mds1_FSTYPE.$fsname-MDT0000.quota_slave.enabled" \
1655 "$fsname.quota.mdt" ug
1657 set_persistent_param_and_check $facet \
1658 "osd-$mds1_FSTYPE.$fsname-OST0000.quota_slave.enabled" \
1659 "$fsname.quota.ost" ug
1662 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1663 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1664 echo "Write succeed, but expect -EDQUOT"
1667 rm -f $mnt/t32_qf_new
1669 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1671 echo "Create succeed, but expect -EDQUOT"
1674 unlinkmany $mnt/t32_qf_ $img_ilimit
1682 local dne_upgrade=${dne_upgrade:-"no"}
1683 local dom_upgrade=${dom_upgrade:-"no"}
1684 local project_upgrade=${project_upgrade:-"no"}
1685 local ff_convert=${ff_convert:-"no"}
1686 local shall_cleanup_mdt=false
1687 local shall_cleanup_mdt1=false
1688 local shall_cleanup_ost=false
1689 local shall_cleanup_lustre=false
1690 local mdt2_is_available=false
1691 local node=$(facet_active_host $SINGLEMDS)
1692 local r="do_node $node"
1708 local mdt_dev=$tmp/mdt
1709 local mdt2_dev=$tmp/mdt2
1710 local ost_dev=$tmp/ost
1715 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1716 trap 'trap - RETURN; t32_test_cleanup' RETURN
1719 nid=$($r $LCTL list_nids | head -1)
1721 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1722 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1723 $r tar xjvf $tarball -S -C $tmp || {
1724 error_noexit "Unpacking the disk image tarball"
1727 img_commit=$($r cat $tmp/commit)
1728 img_kernel=$($r cat $tmp/kernel)
1729 img_arch=$($r cat $tmp/arch)
1730 img_bspace=$($r cat $tmp/bspace)
1731 img_ispace=$($r cat $tmp/ispace)
1733 # older images did not have "blimit" and "ilimit" files
1734 # use old values for T32_BLIMIT and T32_ILIMIT
1735 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1737 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1740 echo "Upgrading from $(basename $tarball), created with:"
1741 echo " Commit: $img_commit"
1742 echo " Kernel: $img_kernel"
1743 echo " Arch: $img_arch"
1744 echo "OST version: $(lustre_build_version ost1)"
1746 # The conversion can be made only when both of the following
1747 # conditions are satisfied:
1748 # - ost device img version < 2.3.64
1749 # - ost server version >= 2.5
1750 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1751 "$OST1_VERSION" -lt $(version_code 2.5.0) ] &&
1754 ! $r test -f $mdt2_dev || mdt2_is_available=true
1756 if [[ "$mds1_FSTYPE" == zfs ]]; then
1759 local poolname_list="t32fs-mdt1 t32fs-ost1"
1761 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1763 for poolname in $poolname_list; do
1765 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1766 $ZPOOL import -f -d $tmp $poolname"
1769 # upgrade zpool to latest supported features, including
1770 # dnode quota accounting in 0.7.0
1771 $r "$ZPOOL upgrade -a"
1773 mdt_dev=t32fs-mdt1/mdt1
1774 ost_dev=t32fs-ost1/ost1
1775 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1776 wait_update_facet $SINGLEMDS "$ZPOOL list |
1777 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1778 error_noexit "import zfs pool failed"
1781 elif [ "$project_upgrade" != "no" ]; then
1782 ! $r tune2fs -O project $mdt_dev &&
1783 error_noexit "enable project on mdt0 failed" &&
1785 $mdt2_is_available && ! $r tune2fs "-O project" $mdt2_dev &&
1786 error_noexit "enable project on mdt failed" &&
1788 ! $r tune2fs -O project $ost_dev &&
1789 error_noexit "enable project on mdt failed" &&
1793 $r $LCTL set_param debug="$PTLDEBUG"
1795 $r $TUNEFS --dryrun $mdt_dev || {
1797 error_noexit "tunefs.lustre before mounting the MDT"
1801 if $mdt2_is_available; then
1802 $r $TUNEFS --dryrun $mdt2_dev || {
1804 error_noexit "tunefs.lustre before mounting the MDT"
1809 if [ "$writeconf" ]; then
1811 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1813 $r $TUNEFS --quota $mdt_dev || {
1815 error_noexit "Enable mdt quota feature"
1818 if $mdt2_is_available; then
1819 $r $TUNEFS --quota $mdt2_dev || {
1821 error_noexit "Enable mdt quota feature"
1827 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1828 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
1829 skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
1830 "(Need MGS version at least 2.3.59)"
1832 local osthost=$(facet_active_host ost1)
1833 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1836 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1839 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1840 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1841 $r $LCTL replace_nids $fsname-MDT0000 $nid
1842 $r $UMOUNT $tmp/mnt/mdt
1845 mopts=exclude=$fsname-OST0000
1846 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1851 t32_wait_til_devices_gone $node
1853 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1855 error_noexit "Mounting the MDT"
1858 shall_cleanup_mdt=true
1860 if $mdt2_is_available; then
1861 mopts=mgsnode=$nid,$mopts
1862 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1864 error_noexit "Mounting the MDT"
1868 echo "mount new MDT....$mdt2_dev"
1869 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1870 error_noexit "enable remote dir create failed"
1872 shall_cleanup_mdt1=true
1873 elif [ "$dne_upgrade" != "no" ]; then
1874 local fs2mdsdev=$(mdsdevname 1_2)
1875 local fs2mdsvdev=$(mdsvdevname 1_2)
1877 echo "mkfs new MDT on ${fs2mdsdev}...."
1878 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1879 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1882 add $SINGLEMDS $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1883 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1884 error_noexit "Mkfs new MDT failed"
1888 [[ "$mds1_FSTYPE" != zfs ]] || import_zpool mds1
1890 $r $TUNEFS --dryrun $fs2mdsdev || {
1891 error_noexit "tunefs.lustre before mounting the MDT"
1895 echo "mount new MDT....$fs2mdsdev"
1896 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1897 error_noexit "mount mdt1 failed"
1901 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1902 error_noexit "enable remote dir create failed"
1904 shall_cleanup_mdt1=true
1907 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1908 error_noexit "Getting MDT UUID"
1911 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1912 error_noexit "Unexpected MDT UUID: \"$uuid\""
1916 $r $TUNEFS --dryrun $ost_dev || {
1917 error_noexit "tunefs.lustre before mounting the OST"
1920 if [ "$writeconf" ]; then
1921 mopts=mgsnode=$nid,$writeconf
1922 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1924 $r $TUNEFS --quota $ost_dev || {
1926 error_noexit "Enable ost quota feature"
1932 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1937 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1938 error_noexit "Mounting the OST"
1941 shall_cleanup_ost=true
1943 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1944 error_noexit "Getting OST UUID"
1947 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1948 error_noexit "Unexpected OST UUID: \"$uuid\""
1952 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1953 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
1954 error_noexit "Setting OST \"failover.node\""
1957 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
1958 error_noexit "Setting MDT \"failover.node\""
1961 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
1962 error_noexit "Setting \"max_dirty_mb\""
1965 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
1966 error_noexit "Setting \"max_rpcs_in_flight\""
1969 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
1970 error_noexit "Setting \"lov.stripesize\""
1973 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
1974 error_noexit "Setting \"mdd.atime_diff\""
1978 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
1979 error_noexit "Setting OST \"failover.node\""
1983 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
1984 error_noexit "Setting MDT \"failover.node\""
1988 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
1989 error_noexit "Setting \"max_dirty_mb\""
1992 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1993 error_noexit "Setting \"max_rpcs_in_flight\""
1996 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
1997 error_noexit "Setting \"lov.stripesize\""
2000 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
2001 error_noexit "Setting \"mdd.atime_diff\""
2006 $r $LCTL pool_new $fsname.interop || {
2007 error_noexit "Setting \"interop\""
2011 if [ "$ff_convert" != "no" -a "$ost1_FSTYPE" == ldiskfs ]; then
2012 $r $LCTL lfsck_start -M $fsname-OST0000 || {
2013 error_noexit "Start OI scrub on OST0"
2017 # The oi_scrub should be on ost1, but for test_32(),
2018 # all on the SINGLEMDS.
2019 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
2020 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2021 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
2022 error_noexit "Failed to get the expected 'completed'"
2026 local UPDATED=$($r $LCTL get_param -n \
2027 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2028 awk '/^updated/ { print $2 }')
2029 [ $UPDATED -ge 1 ] || {
2030 error_noexit "Only $UPDATED objects have been converted"
2035 if [ "$dne_upgrade" != "no" ]; then
2036 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2037 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
2038 error_noexit "Setting MDT1 \"failover.node\""
2042 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
2043 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2046 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
2047 error_noexit "Setting MDT1 \"lov.stripesize\""
2051 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
2052 error_noexit "Setting MDT1 \"failover.node\""
2055 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2056 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2059 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2060 error_noexit "Setting MDT1 \"lov.stripesize\""
2066 if [ "$writeconf" ]; then
2067 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2068 error_noexit "Mounting the client"
2072 shall_cleanup_lustre=true
2073 $r $LCTL set_param debug="$PTLDEBUG"
2075 # Leave re-enabling this to a separate patch for LU-11558
2076 # t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2077 # error_noexit "verify quota failed"
2081 if $r test -f $tmp/list; then
2083 # There is not a Test Framework API to copy files to or
2084 # from a remote node.
2086 # LU-2393 - do both sorts on same node to ensure locale
2088 local list_file=$tmp/list
2090 if $mdt2_is_available; then
2091 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2092 $r test -f $tmp/list2; then
2093 list_file=$tmp/list2
2094 pushd $tmp/mnt/lustre/striped_dir_old
2096 pushd $tmp/mnt/lustre/remote_dir
2099 pushd $tmp/mnt/lustre
2101 $r cat $list_file | sort -k 6 >$tmp/list.orig
2102 ls -Rni --time-style=+%s | sort -k 6 |
2103 sed 's/\. / /' >$tmp/list || {
2109 # 32-bit and 64-bit clients use different algorithms to
2110 # convert FIDs into inode numbers. Hence, remove the
2111 # inode numbers from the lists, if the original list was
2112 # created on an architecture with different number of
2115 if [ $(t32_bits_per_long $(uname -m)) != \
2116 $(t32_bits_per_long $img_arch) ]; then
2117 echo "Different number of bits per \"long\"" \
2118 "from the disk image"
2119 for list in list.orig list; do
2120 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2124 if ! diff -ub $tmp/list.orig $tmp/list; then
2125 error_noexit "list verification failed"
2129 echo "list verification skipped"
2132 if [ "$dom_upgrade" != "no" ]; then
2133 echo "Check DoM file can be created"
2134 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2135 error_noexit "Verify DoM creation"
2138 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2139 error_noexit "Verify a DoM file"
2142 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2143 count=1 conv=fsync || {
2144 error_noexit "Cannot write to DoM file"
2147 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2148 error_noexit "DoM: bad size after write"
2151 rm $tmp/mnt/lustre/dom
2153 set_persistent_param_and_check mds \
2154 "lod.*MDT0000*.dom_stripesize" \
2155 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2156 error_noexit "Changing \"dom_stripesize\""
2161 if [ "$dne_upgrade" != "no" ]; then
2162 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2163 error_noexit "set striped dir failed"
2167 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2169 pushd $tmp/mnt/lustre
2170 tar -c --exclude=./striped_dir \
2171 --exclude=./striped_dir_old \
2172 --exclude=./remote_dir -f - .|
2173 tar -xvf - -C striped_dir 1>/dev/null || {
2174 error_noexit "cp to striped dir failed"
2180 # If it is upgrade from DNE (2.5), then rename the remote dir,
2181 # which is created in 2.5 to striped dir.
2182 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2183 stripe_index=$($LFS getdirstripe -i \
2184 $tmp/mnt/lustre/remote_dir)
2186 [[ $stripe_index -eq 1 ]] || {
2187 error_noexit "get index \"$stripe_index\"" \
2188 "from remote dir failed"
2191 mv $tmp/mnt/lustre/remote_dir \
2192 $tmp/mnt/lustre/striped_dir/ || {
2193 error_noexit "mv remote dir failed"
2198 # If it is upgraded from DNE (2.7), then move the striped dir
2199 # which was created in 2.7 to the new striped dir.
2200 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2201 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2202 stripe_count=$($LFS getdirstripe -c \
2203 $tmp/mnt/lustre/striped_dir_old)
2204 [[ $stripe_count -eq 2 ]] || {
2205 error_noexit "get count $stripe_count" \
2206 "from striped dir failed"
2209 mv $tmp/mnt/lustre/striped_dir_old \
2210 $tmp/mnt/lustre/striped_dir/ || {
2211 error_noexit "mv striped dir failed"
2217 $r $LCTL set_param -n osd*.*.force_sync=1
2218 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2219 error_noexit "dd failed"
2222 rm -rf $tmp/mnt/lustre/tmp_file || {
2223 error_noexit "rm failed"
2227 if $r test -f $tmp/sha1sums; then
2228 # LU-2393 - do both sorts on same node to ensure locale
2230 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2231 if [ "$dne_upgrade" != "no" ]; then
2232 pushd $tmp/mnt/lustre/striped_dir
2234 pushd $tmp/mnt/lustre
2237 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2238 ! -name .lustre -type f -exec sha1sum {} \; |
2239 sort -k 2 >$tmp/sha1sums || {
2241 error_noexit "sha1sum"
2245 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2246 error_noexit "sha1sum verification failed"
2250 # if upgrade from DNE(2.5), then check remote directory
2251 # if upgrade from DNE(2.7), then check striped directory
2252 if $mdt2_is_available &&
2253 [[ "$dne_upgrade" != "no" ]]; then
2254 local new_dir="$tmp/mnt/lustre/striped_dir"
2255 local striped_dir_old="$new_dir/striped_dir_old"
2257 local dir_list="$new_dir/remote_dir"
2258 [[ ! -d $triped_dir_old ]] ||
2259 dir_list+=" $striped_dir_old"
2261 for dir in $dir_list; do
2263 find ! -name .lustre -type f \
2264 -exec sha1sum {} \; |
2265 sort -k 2 >$tmp/sha1sums || {
2267 error_noexit "sha1sum"
2271 if ! diff -ub $tmp/sha1sums.orig \
2273 error_noexit "sha1sum $dir" \
2280 echo "sha1sum verification skipped"
2283 if [ "$dne_upgrade" != "no" ]; then
2284 rm -rf $tmp/mnt/lustre/striped_dir || {
2285 error_noexit "remove remote dir failed"
2290 # migrate files/dirs to remote MDT, then move them back
2291 if [ "$MDS1_VERSION" -ge $(version_code 2.7.50) -a \
2292 $dne_upgrade != "no" ]; then
2293 $r $LCTL set_param -n \
2294 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2296 echo "test migration"
2297 pushd $tmp/mnt/lustre
2298 for dir in $(find ! -name .lustre ! -name . -type d); do
2299 mdt_index=$($LFS getdirstripe -i $dir)
2300 stripe_cnt=$($LFS getdirstripe -c $dir)
2301 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2302 $LFS migrate -m 1 $dir || {
2304 error_noexit "migrate MDT1 failed"
2310 for dir in $(find ! -name . ! -name .lustre -type d); do
2311 mdt_index=$($LFS getdirstripe -i $dir)
2312 stripe_cnt=$($LFS getdirstripe -c $dir)
2313 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2314 $LFS migrate -m 0 $dir || {
2316 error_noexit "migrate MDT0 failed"
2325 # When adding new data verification tests, please check for
2326 # the presence of the required reference files first, like
2327 # the "sha1sums" and "list" tests above, to avoid the need to
2328 # regenerate every image for each test addition.
2331 nrpcs_orig=$($LCTL get_param \
2332 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2333 error_noexit "Getting \"max_rpcs_in_flight\""
2336 nrpcs=$((nrpcs_orig + 5))
2338 set_persistent_param_and_check client \
2339 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
2340 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
2341 error_noexit "Changing \"max_rpcs_in_flight\""
2345 umount $tmp/mnt/lustre || {
2346 error_noexit "Unmounting the client"
2349 shall_cleanup_lustre=false
2351 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2352 error_noexit "Mounting the client"
2356 if [ "$mds1_FSTYPE" == ldiskfs -a \
2357 "$project_upgrade" != "no" ]; then
2358 ! $LFS project -d -p 1 $tmp/mnt/lustre/* &&
2359 error_noexit "set project failed" &&
2363 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) == 0 ]] ||
2364 error "MDD orphan cleanup thread not quit"
2366 umount $tmp/mnt/lustre || {
2367 error_noexit "Unmounting the client"
2371 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2372 $r $UMOUNT $tmp/mnt/mdt1 || {
2373 error_noexit "Unmounting the MDT2"
2376 if [[ "$mds1_FSTYPE" == zfs ]]; then
2377 $r "$ZPOOL export t32fs-mdt2"
2379 shall_cleanup_mdt1=false
2382 $r $UMOUNT $tmp/mnt/mdt || {
2383 error_noexit "Unmounting the MDT"
2386 if [[ "$mds1_FSTYPE" == zfs ]]; then
2387 $r "$ZPOOL export t32fs-mdt1"
2389 shall_cleanup_mdt=false
2391 $r $UMOUNT $tmp/mnt/ost || {
2392 error_noexit "Unmounting the OST"
2395 if [[ "$mds1_FSTYPE" == zfs ]]; then
2396 $r "$ZPOOL export t32fs-ost1"
2398 shall_cleanup_ost=false
2400 t32_reload_modules $node || {
2401 error_noexit "Reloading modules"
2405 if [[ "$mds1_FSTYPE" == zfs ]]; then
2406 local poolname=t32fs-mdt1
2408 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2409 $ZPOOL import -f -d $tmp $poolname"
2411 # upgrade zpool to latest supported features,
2412 # including dnode quota accounting in 0.7.0
2413 $r "$ZPOOL upgrade $poolname"
2416 # mount a second time to make sure we didnt leave upgrade flag on
2417 $r $TUNEFS --dryrun $mdt_dev || {
2419 error_noexit "tunefs.lustre before remounting the MDT"
2423 mopts=exclude=$fsname-OST0000
2424 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2427 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2428 error_noexit "Remounting the MDT"
2431 shall_cleanup_mdt=true
2441 for tarball in $tarballs; do
2442 banner "testing $tarball upgrade"
2443 t32_test $tarball || let "rc += $?"
2447 run_test 32a "Upgrade (not live)"
2455 for tarball in $tarballs; do
2456 banner "testing $tarball upgrade with writeconf"
2457 t32_test $tarball writeconf || let "rc += $?"
2461 run_test 32b "Upgrade with writeconf"
2468 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2470 for tarball in $tarballs; do
2471 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2472 [[ "$tarball" =~ "1_8" ]] && echo "skip $tarball" && continue
2473 [[ "$tarball" =~ "2_1" ]] && echo "skip $tarball" && continue
2474 banner "testing $tarball upgrade with DNE"
2476 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2480 run_test 32c "dne upgrade test"
2488 for tarball in $tarballs; do
2489 banner "testing $tarball upgrade with ff convert and project upgrade"
2490 project_upgrade="no"
2491 [[ "$MDS1_VERSION" -ge $(version_code 2.13.54) ]] &&
2492 [[ "$tarball" =~ "disk2_4-ldiskfs" ]] &&
2493 project_upgrade="yes"
2494 project_upgrade=$project_upgrade ff_convert=yes t32_test \
2499 run_test 32d "convert ff and project quota upgrade test"
2502 [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
2503 skip "Need MDS version at least 2.10.56"
2510 for tarball in $tarballs; do
2511 [[ "$tarball" =~ "2_9" ]] || continue
2513 banner "testing $tarball upgrade with DoM"
2514 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
2518 run_test 32e "dom upgrade test"
2520 test_33a() { # bug 12333, was test_33
2521 local FSNAME2=test-123
2522 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2525 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2527 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2528 local dev=${SINGLEMDS}_dev
2529 local MDSDEV=${!dev}
2530 is_blkdev $SINGLEMDS $MDSDEV &&
2531 skip_env "mixed loopback and real device not working"
2534 local fs2mdsdev=$(mdsdevname 1_2)
2535 local fs2ostdev=$(ostdevname 1_2)
2536 local fs2mdsvdev=$(mdsvdevname 1_2)
2537 local fs2ostvdev=$(ostvdevname 1_2)
2539 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2540 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2543 if combined_mgs_mds; then
2544 local mgs_flag="--mgs"
2547 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
2548 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
2550 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2551 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2552 $fs2ostvdev || exit 10
2554 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2555 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2557 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2558 do_facet mgs "$PERM_CMD timeout=200" ||
2559 error "$PERM_CMD timeout=200 failed"
2561 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
2562 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
2564 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2565 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2568 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2569 $LFS getstripe $MOUNT2/hosts ||
2570 error "$LFS getstripe $MOUNT2/hosts failed"
2575 cleanup_nocli || error "cleanup_nocli failed with $?"
2577 run_test 33a "Mount ost with a large index number"
2579 test_33b() { # was test_34
2582 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2583 # Drop lock cancelation reply during umount
2584 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2585 do_facet client $LCTL set_param fail_loc=0x80000304
2586 #lctl set_param debug=-1
2587 umount_client $MOUNT
2588 cleanup || error "cleanup failed with $?"
2590 run_test 33b "Drop cancel during umount"
2594 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2595 manual_umount_client
2597 do_facet client killall -USR1 multiop
2598 if [ $rc -eq 0 ]; then
2599 error "umount not fail!"
2602 cleanup || error "cleanup failed with rc $?"
2604 run_test 34a "umount with opened file should be fail"
2608 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2609 stop_mds || error "Unable to stop MDS"
2611 manual_umount_client --force || error "mtab after failed umount with $?"
2613 cleanup || error "cleanup failed with $?"
2615 run_test 34b "force umount with failed mds should be normal"
2619 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2620 stop_ost || error "Unable to stop OST1"
2622 manual_umount_client --force || error "mtab after failed umount with $?"
2624 cleanup || error "cleanup failed with $?"
2626 run_test 34c "force umount with failed ost should be normal"
2628 test_35a() { # bug 12459
2631 DBG_SAVE="`$LCTL get_param -n debug`"
2632 $LCTL set_param debug="ha"
2634 log "Set up a fake failnode for the MDS"
2636 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2637 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2639 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2640 do_facet mgs "$PERM_CMD \
2641 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2642 error "Setting mdc.*${device}*.import=connection=\
2643 $(h2nettype $FAKENID) failed."
2645 do_facet mgs "$PERM_CMD \
2646 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2647 error "Setting ${device}.failover.node=\
2648 $(h2nettype $FAKENID) failed."
2650 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2653 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2656 log "Stopping the MDT: $device"
2657 stop_mdt 1 || error "MDT0 stop fail"
2659 df $MOUNT > /dev/null 2>&1 &
2661 log "Restarting the MDT: $device"
2662 start_mdt 1 || error "MDT0 start fail"
2663 log "Wait for df ($DFPID) ... "
2666 $LCTL set_param debug="$DBG_SAVE"
2668 # retrieve from the log the first server that the client tried to
2669 # contact after the connection loss
2670 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2671 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2672 /import_select_connection.*$device-mdc.* using connection/ {
2674 if (\\\$NF ~ /$FAKENID/)
2680 }" $TMP/lustre-log-$TESTNAME.log`
2681 [ "$NEXTCONN" != "0" ] &&
2682 error "Tried to connect to ${NEXTCONN} not last active server"
2683 cleanup || error "cleanup failed with $?"
2684 # remove nid settings
2685 writeconf_or_reformat
2687 run_test 35a "Reconnect to the last active server first"
2689 test_35b() { # bug 18674
2690 remote_mds || skip "local MDS"
2694 $LCTL set_param debug="ha"
2696 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2699 log "Set up a fake failnode for the MDS"
2701 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2702 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2704 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2705 do_facet mgs "$PERM_CMD \
2706 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2707 error "Set mdc.*${device}*.import=connection=\
2708 $(h2nettype $FAKENID) failed"
2710 do_facet mgs "$PERM_CMD \
2711 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2712 error "Set ${device}.failover.node=\
2713 $(h2nettype $FAKENID) failed"
2716 local at_max_saved=0
2717 # adaptive timeouts may prevent seeing the issue
2718 if at_is_enabled; then
2719 at_max_saved=$(at_max_get mds)
2720 at_max_set 0 mds client
2723 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2725 log "Injecting EBUSY on MDS"
2726 # Setting OBD_FAIL_MDS_RESEND=0x136
2727 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2728 error "unable to set param fail_loc=0x80000136"
2730 $LCTL set_param mdc.${FSNAME}*.stats=clear
2732 log "Creating a test file and stat it"
2733 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2734 stat $MOUNT/$tdir/$tfile
2736 log "Stop injecting EBUSY on MDS"
2737 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2738 error "unable to set param fail_loc=0"
2739 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2742 # restore adaptive timeout
2743 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2745 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2747 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2748 awk '/mds_connect/{print $2}')
2750 # retrieve from the log if the client has ever tried to
2751 # contact the fake server after the loss of connection
2752 FAILCONN=`awk "BEGIN {ret = 0;}
2753 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2755 if (\\\$NF ~ /$FAKENID/) {
2760 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2762 [ "$FAILCONN" == "0" ] &&
2763 error "The client reconnection has not been triggered"
2764 [ "$FAILCONN" == "2" ] &&
2765 error "Primary server busy, client reconnect to failover failed"
2768 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2769 # Reconnects are supposed to be rate limited to one every 5s
2770 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2771 error "Too many reconnects $CONNCNT"
2773 cleanup || error "cleanup failed with $?"
2774 # remove nid settings
2775 writeconf_or_reformat
2777 run_test 35b "Continue reconnection retries, if the active server is busy"
2780 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2782 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2786 local FSNAME2=test1234
2787 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2789 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2791 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2792 is_blkdev $SINGLEMDS $MDSDEV &&
2793 skip_env "mixed loopback and real device not working"
2796 local fs2mdsdev=$(mdsdevname 1_2)
2797 local fs2ostdev=$(ostdevname 1_2)
2798 local fs3ostdev=$(ostdevname 2_2)
2799 local fs2mdsvdev=$(mdsvdevname 1_2)
2800 local fs2ostvdev=$(ostvdevname 1_2)
2801 local fs3ostvdev=$(ostvdevname 2_2)
2804 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2805 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2806 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2807 # different one than the default value here.
2808 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2809 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2810 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2811 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2813 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2814 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2815 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2816 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2817 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2819 sleep 5 # until 11778 fixed
2821 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2823 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2824 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2825 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2826 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2827 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2828 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2829 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2830 DFTOTAL=$(echo $STRING | cut -d, -f1)
2831 DFUSED=$(echo $STRING | cut -d, -f2)
2832 DFAVAIL=$(echo $STRING | cut -d, -f3)
2833 DFFREE=$(($DFTOTAL - $DFUSED))
2835 ALLOWANCE=$((64 * $OSTCOUNT))
2837 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2838 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2839 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2842 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2843 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2844 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2847 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2848 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2849 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2854 stop fs3ost -f || error "unable to stop OST3"
2855 stop fs2ost -f || error "unable to stop OST2"
2856 stop fs2mds -f || error "unable to stop second MDS"
2857 unload_modules_conf || error "unable unload modules"
2860 run_test 36 "df report consistency on OSTs with different block size"
2863 local mntpt=$(facet_mntpt $SINGLEMDS)
2864 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2865 local mdsdev_sym="$TMP/sym_mdt.img"
2866 local opts=$MDS_MOUNT_OPTS
2869 if [ "$mds1_FSTYPE" != ldiskfs ]; then
2870 skip "ldiskfs only test"
2873 echo "MDS : $mdsdev"
2874 echo "SYMLINK : $mdsdev_sym"
2875 do_facet $SINGLEMDS rm -f $mdsdev_sym
2877 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2879 echo "mount symlink device - $mdsdev_sym"
2881 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2882 opts=$(csa_add "$opts" -o loop)
2886 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2887 $mdsdev_sym $mntpt 2>&1)
2890 echo mount_op=$mount_op
2892 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2894 if $(echo $mount_op | grep -q "unable to set tunable"); then
2895 error "set tunables failed for symlink device"
2898 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2900 run_test 37 "verify set tunables works for symlink device"
2902 test_38() { # bug 14222
2903 local mntpt=$(facet_mntpt $SINGLEMDS)
2908 local SRC="/etc /bin"
2909 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2910 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2911 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2912 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2913 error "copying $SRC to $DIR/$tdir"
2915 umount_client $MOUNT || error "umount_client $MOUNT failed"
2916 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2917 stop_mds || error "Unable to stop MDS"
2918 log "delete lov_objid file on MDS"
2920 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2922 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2924 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2926 # check create in mds_lov_connect
2927 start_mds || error "unable to start MDS"
2928 mount_client $MOUNT || error "mount_client $MOUNT failed"
2930 [ $V ] && log "verifying $DIR/$tdir/$f"
2931 diff -q $f $DIR/$tdir/$f || ERROR=y
2933 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2934 if [ "$ERROR" = "y" ]; then
2935 # check it's updates in sync
2936 umount_client $MOUNT
2938 mount_fstype $SIGNLEMDS
2939 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2940 unmount_fstype $SINGLEMDS
2941 error "old and new files are different after connect" || true
2943 touch $DIR/$tdir/f2 || error "f2 file create failed"
2945 # check it's updates in sync
2946 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2949 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2951 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2952 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2954 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2956 start_mds || error "unable to start MDS"
2957 mount_client $MOUNT || error "mount_client $MOUNT failed"
2959 [ $V ] && log "verifying $DIR/$tdir/$f"
2960 diff -q $f $DIR/$tdir/$f || ERROR=y
2962 touch $DIR/$tdir/f3 || error "f3 file create failed"
2963 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2964 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2966 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2967 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2968 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2970 [ "$ERROR" = "y" ] &&
2971 error "old and new files are different after sync" || true
2973 log "files compared the same"
2974 cleanup || error "cleanup failed with $?"
2976 run_test 38 "MDS recreates missing lov_objid file from OST data"
2981 cleanup || error "cleanup failed with $?"
2982 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2983 error "memory leak detected" || true
2985 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2987 test_40() { # bug 15759
2988 start_ost || error "Unable to start OST1"
2989 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2990 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2992 cleanup || error "cleanup failed with rc $?"
2994 run_test 40 "race during service thread startup"
2996 test_41a() { #bug 14134
2997 if [ "$mds1_FSTYPE" == ldiskfs ] &&
2998 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
2999 skip "Loop devices does not work with nosvc option"
3002 combined_mgs_mds || skip "needs combined MGT and MDT device"
3004 start_mdt 1 -o nosvc -n
3005 if [ $MDSCOUNT -ge 2 ]; then
3006 for num in $(seq 2 $MDSCOUNT); do
3007 start_mdt $num || return
3010 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
3011 start_mdt 1 -o nomgs,force
3012 mount_client $MOUNT || error "mount_client $MOUNT failed"
3015 echo "blah blah" > $MOUNT/$tfile
3018 umount_client $MOUNT || error "umount_client $MOUNT failed"
3019 stop ost1 -f || error "unable to stop OST1"
3020 stop_mds || error "Unable to stop MDS"
3021 stop_mds || error "Unable to stop MDS on second try"
3023 run_test 41a "mount mds with --nosvc and --nomgs"
3026 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3027 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
3028 skip "Loop devices does not work with nosvc option"
3031 ! combined_mgs_mds && skip "needs combined mgs device"
3035 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3037 start_mdt 1 -o nosvc -n
3038 if [ $MDSCOUNT -ge 2 ]; then
3039 for num in $(seq 2 $MDSCOUNT); do
3040 start_mdt $num || return
3043 start_ost || error "Unable to start OST1"
3044 start_mdt 1 -o nomgs,force
3045 mount_client $MOUNT || error "mount_client $MOUNT failed"
3048 echo "blah blah" > $MOUNT/$tfile
3049 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
3051 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
3052 stop_ost || error "Unable to stop OST1"
3053 stop_mds || error "Unable to stop MDS"
3054 stop_mds || error "Unable to stop MDS on second try"
3056 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
3059 local oss_list=$(comma_list $(osts_nodes))
3061 [[ "$MDS1_VERSION" -ge $(version_code 2.6.52) ]] ||
3062 [[ "$MDS1_VERSION" -ge $(version_code 2.5.26) &&
3063 "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
3064 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
3065 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]] ||
3066 skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"
3068 # ensure mds1 ost1 have been created even if running sub-test standalone
3071 cleanup || error "cleanup failed"
3073 # using directly mount command instead of start() function to avoid
3074 # any side effect of // with others/externals tools/features
3075 # ("zpool import", ...)
3077 # MDT concurrent start
3079 LOAD_MODULES_REMOTE=true load_modules
3080 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
3081 error "MDT concurrent start: libcfs module not loaded"
3083 local mds1dev=$(mdsdevname 1)
3084 local mds1mnt=$(facet_mntpt mds1)
3085 local mds1opts=$MDS_MOUNT_OPTS
3087 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3088 ! do_facet mds1 test -b $mds1dev; then
3089 mds1opts=$(csa_add "$mds1opts" -o loop)
3091 if [[ "$mds1_FSTYPE" == zfs ]]; then
3092 import_zpool mds1 || return ${PIPESTATUS[0]}
3095 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3096 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
3098 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
3101 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
3105 do_facet mds1 "$LCTL set_param fail_loc=0x0"
3106 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3107 echo "1st MDT start succeed"
3108 echo "2nd MDT start failed with $rc2"
3109 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3110 echo "1st MDT start failed with $rc"
3111 echo "2nd MDT start succeed"
3114 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
3117 if [ $MDSCOUNT -ge 2 ]; then
3118 for num in $(seq 2 $MDSCOUNT); do
3119 start_mdt $num || return
3123 # OST concurrent start
3125 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
3126 error "OST concurrent start: libcfs module not loaded"
3128 local ost1dev=$(ostdevname 1)
3129 local ost1mnt=$(facet_mntpt ost1)
3130 local ost1opts=$OST_MOUNT_OPTS
3132 if [ "$ost1_FSTYPE" == ldiskfs ] &&
3133 ! do_facet ost1 test -b $ost1dev; then
3134 ost1opts=$(csa_add "$ost1opts" -o loop)
3136 if [[ "$ost1_FSTYPE" == zfs ]]; then
3137 import_zpool ost1 || return ${PIPESTATUS[0]}
3140 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3141 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
3143 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
3146 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
3150 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3151 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3152 echo "1st OST start succeed"
3153 echo "2nd OST start failed with $rc2"
3154 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3155 echo "1st OST start failed with $rc"
3156 echo "2nd OST start succeed"
3160 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3166 # verify everything ok
3171 error "MDT(s) start failed"
3179 error "OST(s) start failed"
3187 error "client start failed"
3194 error "client mount failed"
3198 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3200 test_42() { #bug 14693
3204 check_mount || error "client was not mounted"
3206 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3207 PARAM="llite.$FSNAME-*.some_wrong_param"
3209 PARAM="$FSNAME.llite.some_wrong_param"
3212 do_facet mgs $PERM_CMD $PARAM=10
3213 umount_client $MOUNT ||
3214 error "unmounting client failed with invalid llite param"
3215 mount_client $MOUNT ||
3216 error "mounting client failed with invalid llite param"
3218 do_facet mgs $PERM_CMD $PARAM=20
3219 cleanup || error "stopping $FSNAME failed with invalid sys param"
3221 check_mount || error "client was not mounted with invalid sys param"
3222 cleanup || error "stopping $FSNAME failed with invalid sys param"
3224 run_test 42 "allow client/server mount/unmount with invalid config param"
3227 [[ "$MGS_VERSION" -ge $(version_code 2.5.58) ]] ||
3228 skip "Need MDS version at least 2.5.58"
3229 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
3232 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
3233 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1"
3236 chmod ugo+x $DIR || error "chmod 0 failed"
3237 set_persistent_param_and_check mds1 \
3238 "mdt.$FSNAME-MDT0000.root_squash" \
3239 "$FSNAME.mdt.root_squash" \
3241 wait_update $HOSTNAME \
3242 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3244 error "check llite root_squash failed!"
3245 set_persistent_param_and_check mds1 \
3246 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3247 "$FSNAME.mdt.nosquash_nids" \
3249 wait_update $HOSTNAME \
3250 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3252 error "check llite nosquash_nids failed!"
3255 # create set of test files
3257 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
3258 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
3259 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
3261 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
3262 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
3264 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
3265 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
3266 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
3268 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
3269 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
3270 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
3273 # check root_squash:
3274 # set root squash UID:GID to RUNAS_ID
3275 # root should be able to access only files owned by RUNAS_ID
3277 set_persistent_param_and_check mds1 \
3278 "mdt.$FSNAME-MDT0000.root_squash" \
3279 "$FSNAME.mdt.root_squash" \
3280 "$RUNAS_ID:$RUNAS_ID"
3281 wait_update $HOSTNAME \
3282 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3283 "$RUNAS_ID:$RUNAS_ID" ||
3284 error "check llite root_squash failed!"
3286 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
3287 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3288 error "$ST: root read permission is denied"
3289 echo "$ST: root read permission is granted - ok"
3292 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3293 error "$ST: root write permission is denied"
3294 echo "$ST: root write permission is granted - ok"
3296 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3297 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3298 error "$ST: root read permission is granted"
3299 echo "$ST: root read permission is denied - ok"
3302 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3303 error "$ST: root write permission is granted"
3304 echo "$ST: root write permission is denied - ok"
3306 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3307 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
3308 error "$ST: root unlink permission is granted"
3309 echo "$ST: root unlink permission is denied - ok"
3311 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
3312 error "$ST: root create permission is granted"
3313 echo "$ST: root create permission is denied - ok"
3316 # check root_squash is enforced independently
3317 # of client cache content
3319 # access file by USER1, keep access open
3320 # root should be denied access to user file
3322 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
3326 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
3327 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3328 { kill $pid; error "$ST: root read permission is granted"; }
3329 echo "$ST: root read permission is denied - ok"
3332 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3333 { kill $pid; error "$ST: root write permission is granted"; }
3334 echo "$ST: root write permission is denied - ok"
3340 # check nosquash_nids:
3341 # put client's NID into nosquash_nids list,
3342 # root should be able to access root file after that
3344 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
3345 NIDLIST="2@gni $NIDLIST 192.168.0.[2,10]@tcp"
3346 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
3347 set_persistent_param_and_check mds1 \
3348 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3349 "$FSNAME-MDTall.mdt.nosquash_nids" \
3351 wait_update $HOSTNAME \
3352 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3354 error "check llite nosquash_nids failed!"
3356 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3357 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3358 error "$ST: root read permission is denied"
3359 echo "$ST: root read permission is granted - ok"
3362 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3363 error "$ST: root write permission is denied"
3364 echo "$ST: root write permission is granted - ok"
3366 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3367 rm $DIR/$tdir-rootdir/tfile-1 ||
3368 error "$ST: root unlink permission is denied"
3369 echo "$ST: root unlink permission is granted - ok"
3370 touch $DIR/$tdir-rootdir/tfile-2 ||
3371 error "$ST: root create permission is denied"
3372 echo "$ST: root create permission is granted - ok"
3373 cleanup || error "cleanup failed with $?"
3375 run_test 43a "check root_squash and nosquash_nids"
3377 test_43b() { # LU-5690
3378 [[ "$MGS_VERSION" -ge $(version_code 2.7.62) ]] ||
3379 skip "Need MGS version 2.7.62+"
3381 if [[ -z "$fs2mds_DEV" ]]; then
3382 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
3383 skip_env "mixed loopback and real device not working"
3386 local fs2mdsdev=$(mdsdevname 1_2)
3387 local fs2mdsvdev=$(mdsvdevname 1_2)
3389 # temporarily use fs2mds as fs2mgs
3391 local fs2mgsdev=$fs2mdsdev
3392 local fs2mgsvdev=$fs2mdsvdev
3394 local fsname=test1234
3396 load_module llite/lustre
3397 local client_ip=$(host_nids_address $HOSTNAME $NETTYPE)
3398 local host=${client_ip//*./}
3399 local net=${client_ip/%$host/}
3400 local nosquash_nids=$(h2nettype $net[$host,$host,$host])
3402 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
3403 --param mdt.root_squash=$RUNAS_ID:$RUNAS_ID \
3404 --param mdt.nosquash_nids=$nosquash_nids \
3405 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
3406 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS || error "start fs2mgs failed"
3407 stop $fs2mgs -f || error "stop fs2mgs failed"
3408 cleanup || error "cleanup failed with $?"
3410 run_test 43b "parse nosquash_nids with commas in expr_list"
3414 check_mount || error "check_mount"
3415 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
3417 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
3418 for VAL in $UUIDS; do
3419 NID=$(echo $VAL | cut -d= -f1)
3420 CLUUID=$(echo $VAL | cut -d= -f2)
3421 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
3423 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
3424 cleanup || error "cleanup failed with $?"
3426 run_test 44 "mounted client proc entry exists"
3430 check_mount || error "check_mount"
3431 stop_mds || error "Unable to stop MDS"
3435 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
3436 do_facet client "$LCTL set_param fail_loc=0x8000050f"
3439 manual_umount_client --force || error "manual_umount_client failed"
3440 do_facet client "$LCTL set_param fail_loc=0x0"
3441 start_mds || error "unable to start MDS"
3442 mount_client $MOUNT || error "mount_client $MOUNT failed"
3443 cleanup || error "cleanup failed with $?"
3445 run_test 45 "long unlink handling in ptlrpcd"
3452 umount_client $MOUNT2 || rc=$?
3453 umount_client $MOUNT || rc=$?
3454 while [ $count -gt 0 ]; do
3455 stop ost${count} -f || rc=$?
3459 cleanup_nocli || rc=$?
3460 #writeconf to remove all ost2 traces for subsequent tests
3461 writeconf_or_reformat
3466 echo "Testing with $OSTCOUNT OSTs"
3468 start_mds || error "unable to start MDS"
3469 #first client should see only one ost
3470 start_ost || error "Unable to start OST1"
3471 wait_osc_import_state mds ost FULL
3473 mount_client $MOUNT || error "mount_client $MOUNT failed"
3474 trap "cleanup_46a $OSTCOUNT" EXIT ERR
3477 for (( i=2; i<=$OSTCOUNT; i++ )); do
3478 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
3479 error "start_ost$i $(ostdevname $i) failed"
3482 # wait until osts in sync
3483 for (( i=2; i<=$OSTCOUNT; i++ )); do
3484 wait_osc_import_state mds ost$i FULL
3485 wait_osc_import_ready client ost$i
3488 #second client see all ost's
3490 mount_client $MOUNT2 || error "mount_client failed"
3491 $LFS setstripe -c -1 $MOUNT2 ||
3492 error "$LFS setstripe -c -1 $MOUNT2 failed"
3493 $LFS getstripe $MOUNT2 || error "$LFS getstripe $MOUNT2 failed"
3495 echo "ok" > $MOUNT2/widestripe
3496 $LFS getstripe $MOUNT2/widestripe ||
3497 error "$LFS getstripe $MOUNT2/widestripe failed"
3498 # fill acl buffer for avoid expand lsm to them
3499 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
3501 setfacl -m $acl $MOUNT2/widestripe
3505 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3507 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
3509 run_test 46a "handle ost additional - wide striped file"
3514 check_mount || error "check_mount failed"
3515 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
3519 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3520 if echo $ns | grep "MDT[[:digit:]]*"; then
3523 lrs=$(echo $ns | sed 's/.*lru_size=//')
3524 lru_size[count]=$lrs
3529 facet_failover $SINGLEMDS
3530 client_up || error "client_up failed"
3533 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3534 if echo $ns | grep "MDT[[:digit:]]*"; then
3537 lrs=$(echo $ns | sed 's/.*lru_size=//')
3538 if ! test "$lrs" -eq "${lru_size[count]}"; then
3539 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
3540 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
3545 cleanup || error "cleanup failed with $?"
3547 run_test 47 "server restart does not make client loss lru_resize settings"
3552 # reformat after this test is needed - if the test fails,
3553 # we will have unkillable file at FS
3557 test_48() { # bz-17636 LU-7473
3561 check_mount || error "check_mount failed"
3563 $LFS setstripe -c -1 $MOUNT ||
3564 error "$LFS setstripe -c -1 $MOUNT failed"
3565 $LFS getstripe $MOUNT || error "$LFS getstripe $MOUNT failed"
3567 echo "ok" > $MOUNT/widestripe
3568 $LFS getstripe $MOUNT/widestripe ||
3569 error "$LFS getstripe $MOUNT/widestripe failed"
3571 # In the future, we may introduce more EAs, such as selinux, enlarged
3572 # LOV EA, and so on. These EA will use some EA space that is shared by
3573 # ACL entries. So here we only check some reasonable ACL entries count,
3574 # instead of the max number that is calculated from the max_ea_size.
3575 if [ "$MDS1_VERSION" -lt $(version_code 2.8.57) ]; then
3576 count=28 # hard coded of RPC protocol
3577 elif large_xattr_enabled; then
3578 count=4500 # max_num 8187 max_ea_size = 65452
3579 # not create too many (4500) to save test time
3581 count=450 # max_num 497 max_ea_size = 4012
3584 echo "It is expected to hold at least $count ACL entries"
3585 trap cleanup_48 EXIT ERR
3586 for ((i = 0; i < $count; i++)) do
3587 setfacl -m u:$((i + 100)):rw $MOUNT/widestripe ||
3588 error "Fail to setfacl for $MOUNT/widestripe at $i"
3591 cancel_lru_locks mdc
3592 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3593 local r_count=$(getfacl $MOUNT/widestripe | grep "user:" | wc -l)
3594 count=$((count + 1)) # for the entry "user::rw-"
3596 [ $count -eq $r_count ] ||
3597 error "Expected ACL entries $count, but got $r_count"
3601 run_test 48 "too many acls on file"
3603 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3604 test_49a() { # bug 17710
3605 local timeout_orig=$TIMEOUT
3606 local ldlm_timeout_orig=$LDLM_TIMEOUT
3607 local LOCAL_TIMEOUT=20
3609 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3610 TIMEOUT=$LOCAL_TIMEOUT
3614 check_mount || error "client mount failed"
3616 echo "check ldlm_timout..."
3617 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3618 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3619 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3621 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3622 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3625 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3626 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3629 umount_client $MOUNT || error "umount_client $MOUNT failed"
3630 stop_ost || error "problem stopping OSS"
3631 stop_mds || error "problem stopping MDS"
3633 LDLM_TIMEOUT=$ldlm_timeout_orig
3634 TIMEOUT=$timeout_orig
3636 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3638 test_49b() { # bug 17710
3639 local timeout_orig=$TIMEOUT
3640 local ldlm_timeout_orig=$LDLM_TIMEOUT
3641 local LOCAL_TIMEOUT=20
3643 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3644 TIMEOUT=$LOCAL_TIMEOUT
3648 check_mount || error "client mount failed"
3650 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3651 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3652 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3654 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3655 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3658 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3659 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3662 cleanup || error "cleanup failed"
3664 LDLM_TIMEOUT=$ldlm_timeout_orig
3665 TIMEOUT=$timeout_orig
3667 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3670 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3672 # Test both statfs and lfs df and fail if either one fails
3673 multiop_bg_pause $1 f_
3676 killall -USR1 multiop
3677 [ $RC -ne 0 ] && log "lazystatfs multiop failed"
3678 wait $PID || { RC=$?; log "multiop return error "; }
3680 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3685 if kill -s 0 $PID; then
3688 log "lazystatfs lfs df failed to complete in 5s"
3696 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3697 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3699 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3701 cleanup || error "cleanup failed with rc $?"
3703 run_test 50a "lazystatfs all servers available"
3707 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3708 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3710 # Wait for client to detect down OST
3711 stop_ost || error "Unable to stop OST1"
3712 wait_osc_import_state client ost DISCONN
3714 log "OSCs should all be DISCONN"
3716 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
3718 umount_client $MOUNT || error "Unable to unmount client"
3719 stop_mds || error "Unable to stop MDS"
3721 run_test 50b "lazystatfs all servers down"
3724 start_mds || error "Unable to start MDS"
3725 start_ost || error "Unable to start OST1"
3726 start_ost2 || error "Unable to start OST2"
3727 mount_client $MOUNT || error "Unable to mount client"
3728 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3729 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3731 # Wait for client to detect down OST
3732 stop_ost || error "Unable to stop OST1"
3733 wait_osc_import_state mds ost DISCONN
3734 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3736 umount_client $MOUNT || error "Unable to unmount client"
3737 stop_ost2 || error "Unable to stop OST2"
3738 stop_mds || error "Unable to stop MDS"
3739 #writeconf to remove all ost2 traces for subsequent tests
3740 writeconf_or_reformat
3742 run_test 50c "lazystatfs one server down"
3745 start_mds || error "Unable to start MDS"
3746 start_ost || error "Unable to start OST1"
3747 start_ost2 || error "Unable to start OST2"
3748 mount_client $MOUNT || error "Unable to mount client"
3749 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3750 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3752 # Issue the statfs during the window where the client still
3753 # belives the OST to be available but it is in fact down.
3754 # No failure just a statfs which hangs for a timeout interval.
3755 stop_ost || error "Unable to stop OST1"
3756 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3758 umount_client $MOUNT || error "Unable to unmount client"
3759 stop_ost2 || error "Unable to stop OST2"
3760 stop_mds || error "Unable to stop MDS"
3761 #writeconf to remove all ost2 traces for subsequent tests
3762 writeconf_or_reformat
3764 run_test 50d "lazystatfs client/server conn race"
3771 start_mds || error "Unable to start MDS"
3772 #first client should see only one ost
3773 start_ost || error "Unable to start OST1"
3774 wait_osc_import_state mds ost FULL
3776 # Wait for client to detect down OST
3777 stop_ost || error "Unable to stop OST1"
3778 wait_osc_import_state mds ost DISCONN
3780 mount_client $MOUNT || error "Unable to mount client"
3781 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3783 multiop_bg_pause $MOUNT _f
3787 if [ $RC1 -ne 0 ]; then
3788 log "multiop failed $RC1"
3791 sleep $(( $TIMEOUT+1 ))
3793 [ $? -ne 0 ] && error "process isn't sleep"
3794 start_ost || error "Unable to start OST1"
3795 wait $pid || error "statfs failed"
3798 umount_client $MOUNT || error "Unable to unmount client"
3799 stop_ost || error "Unable to stop OST1"
3800 stop_mds || error "Unable to stop MDS"
3802 run_test 50e "normal statfs all servers down"
3807 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3809 start_mds || error "Unable to start mds"
3810 #first client should see only one ost
3811 start_ost || error "Unable to start OST1"
3812 wait_osc_import_state mds ost FULL
3814 start_ost2 || error "Unable to start OST2"
3815 wait_osc_import_state mds ost2 FULL
3817 # Wait for client to detect down OST
3818 stop_ost2 || error "Unable to stop OST2"
3820 wait_osc_import_state mds ost2 DISCONN
3821 mount_client $MOUNT || error "Unable to mount client"
3822 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3824 multiop_bg_pause $MOUNT _f
3828 if [ $RC1 -ne 0 ]; then
3829 log "lazystatfs multiop failed $RC1"
3832 sleep $(( $TIMEOUT+1 ))
3834 [ $? -ne 0 ] && error "process isn't sleep"
3835 start_ost2 || error "Unable to start OST2"
3836 wait $pid || error "statfs failed"
3837 stop_ost2 || error "Unable to stop OST2"
3840 umount_client $MOUNT -f || error "Unable to unmount client"
3841 stop_ost || error "Unable to stop OST1"
3842 stop_mds || error "Unable to stop MDS"
3843 #writeconf to remove all ost2 traces for subsequent tests
3844 writeconf_or_reformat
3846 run_test 50f "normal statfs one server in down"
3849 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3851 start_ost2 || error "Unable to start OST2"
3852 wait_osc_import_state mds ost2 FULL
3853 wait_osc_import_ready client ost2
3855 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3856 local PARAM="osc.${FSNAME}-OST0001*.active"
3858 local PARAM="${FSNAME}-OST0001.osc.active"
3861 $LFS setstripe -c -1 $DIR/$tfile || error "$LFS setstripe failed"
3862 do_facet mgs $PERM_CMD $PARAM=0 || error "Unable to deactivate OST"
3864 umount_client $MOUNT || error "Unable to unmount client"
3865 mount_client $MOUNT || error "Unable to mount client"
3866 # This df should not cause a panic
3869 do_facet mgs $PERM_CMD $PARAM=1 || error "Unable to activate OST"
3870 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
3871 umount_client $MOUNT || error "Unable to unmount client"
3872 stop_ost2 || error "Unable to stop OST2"
3873 stop_ost || error "Unable to stop OST1"
3874 stop_mds || error "Unable to stop MDS"
3875 #writeconf to remove all ost2 traces for subsequent tests
3876 writeconf_or_reformat
3878 run_test 50g "deactivated OST should not cause panic"
3882 # prepare MDT/OST, make OSC inactive for OST1
3883 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3885 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
3886 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3887 error "tunefs OST1 failed"
3888 start_mds || error "Unable to start MDT"
3889 start_ost || error "Unable to start OST1"
3890 start_ost2 || error "Unable to start OST2"
3891 mount_client $MOUNT || error "client start failed"
3893 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3895 # activatate OSC for OST1
3896 set_persistent_param_and_check client \
3897 "osc.${FSNAME}-OST0000-osc-[!M]*.active" \
3898 "${FSNAME}-OST0000.osc.active" 1
3900 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3901 $LFS setstripe -c -1 -i 0 $DIR/$tdir/2 ||
3902 error "$LFS setstripe $DIR/$tdir/2 failed"
3903 sleep 1 && echo "create a file after OST1 is activated"
3904 # doing some io, shouldn't crash
3905 dd if=/dev/zero of=$DIR/$tdir/2/$tfile-io bs=1M count=10
3907 # check OSC import is working
3908 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3909 error "some OSC imports are still not connected"
3913 umount_client $MOUNT || error "Unable to umount client"
3914 stop_ost2 || error "Unable to stop OST2"
3915 cleanup_nocli || error "cleanup_nocli failed with $?"
3917 run_test 50h "LU-642: activate deactivated OST"
3920 # prepare MDT/OST, make OSC inactive for OST1
3921 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
3924 [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
3925 do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
3926 error "tunefs MDT2 failed"
3927 start_mds || error "Unable to start MDT"
3928 start_ost || error "Unable to start OST1"
3929 start_ost2 || error "Unable to start OST2"
3930 mount_client $MOUNT || error "client start failed"
3932 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3934 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3935 $PERM_CMD mdc.${FSNAME}-MDT0001-mdc-*.active=0 &&
3936 error "deactive MDC0 succeeds"
3938 $PERM_CMD ${FSNAME}-MDT0000.mdc.active=0 &&
3939 error "deactive MDC0 succeeds"
3942 # activate MDC for MDT2
3943 set_persistent_param_and_check client \
3944 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3945 "${FSNAME}-MDT0001.mdc.active" 1
3947 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
3948 if [ "$MDS1_VERSION" -ge $(version_code 2.7.60) ]
3950 wait_dne_interconnect
3952 $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3954 createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
3956 rm -rf $DIR/$tdir/2 || error "unlink dir failed"
3958 # deactivate MDC for MDT2
3959 set_persistent_param_and_check client \
3960 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3961 "${FSNAME}-MDT0001.mdc.active" 0
3963 wait_osp_active mds ${FSNAME}-MDT0001 1 0
3965 $LFS mkdir -i1 $DIR/$tdir/2 &&
3966 error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
3968 $LFS mkdir -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3969 error "mkdir $DIR/$tdir/striped_dir fails after deactive MDT2"
3971 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3972 [ $stripe_count -eq $((MDSCOUNT - 1)) ] ||
3973 error "wrong $stripe_count != $((MDSCOUNT -1)) for striped_dir"
3976 umount_client $MOUNT || error "Unable to umount client"
3981 run_test 50i "activate deactivated MDT"
3984 local LOCAL_TIMEOUT=20
3988 check_mount || error "check_mount failed"
3990 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3991 $LFS setstripe -c -1 $MOUNT/$tdir ||
3992 error "$LFS setstripe -c -1 $MOUNT/$tdir failed"
3993 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3994 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
3995 touch $MOUNT/$tdir/$tfile &
3998 start_ost2 || error "Unable to start OST1"
4000 stop_ost2 || error "Unable to stop OST1"
4001 umount_client $MOUNT -f || error “unmount $MOUNT failed”
4002 cleanup_nocli || error “stop server failed”
4003 #writeconf to remove all ost2 traces for subsequent tests
4004 writeconf_or_reformat
4006 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
4015 do_node $node mkdir -p $dest
4016 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
4018 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
4019 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
4020 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
4022 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
4023 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
4033 local backup2=${TMP}/backup2
4035 do_node $node mkdir -p $backup2
4036 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
4038 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
4039 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
4040 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
4042 do_node $node "diff -rq $backup $backup2"
4043 [ $? -eq 0 ] || { error "contents differ"; return 3; }
4045 local xattrs2=${TMP}/xattrs2
4046 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
4047 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
4049 do_node $node "diff $xattrs $xattrs2"
4050 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
4052 do_node $node "rm -rf $backup2 $xattrs2"
4053 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
4057 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4058 skip "ldiskfs only test"
4061 start_mds || error "Unable to start MDS"
4062 start_ost || error "Unable to start OST1"
4063 mount_client $MOUNT || error "Unable to mount client"
4066 local ost1mnt=$(facet_mntpt ost1)
4067 local ost1node=$(facet_active_host ost1)
4068 local ost1tmp=$TMP/conf52
4071 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
4072 touch $TMP/modified_first || error "Unable to create temporary file"
4073 local mtime=$(stat -c %Y $TMP/modified_first)
4074 do_node $ost1node "mkdir -p $ost1tmp &&
4075 touch -m -d @$mtime $ost1tmp/modified_first" ||
4076 error "Unable to create temporary file"
4079 $LFS setstripe -c -1 -S 1M $DIR/$tdir || error "$LFS setstripe failed"
4081 for (( i=0; i < nrfiles; i++ )); do
4082 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
4083 error "multiop failed"
4088 # sync all the data and make sure no pending data on the client,
4089 # thus the SOM xattr would not be changed any more.
4090 cancel_lru_locks osc
4093 echo backup files to $TMP/$tdir
4094 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
4095 copy_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4096 error "Unable to copy files"
4098 umount_client $MOUNT || error "Unable to umount client"
4099 stop_ost || error "Unable to stop ost1"
4101 echo mount ost1 as ldiskfs
4102 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
4103 if ! do_node $ost1node test -b $ost1_dev; then
4106 do_node $ost1node mount -t "$ost1_FSTYPE" $loop $ost1_dev \
4108 error "Unable to mount ost1 as ldiskfs"
4111 echo backup objects to $ost1tmp/objects
4112 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
4113 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
4114 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
4116 error "Unable to copy objects"
4118 # move objects to lost+found
4119 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
4120 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
4122 do_node $ost1node "umount $ost1mnt" ||
4123 error "Unable to umount ost1 as ldiskfs"
4125 start_ost || error "Unable to start OST1"
4126 mount_client $MOUNT || error "Unable to mount client"
4128 local REPAIRED=$(do_node $ost1node "$LCTL get_param \
4129 -n osd-ldiskfs.$FSNAME-OST0000.oi_scrub" |
4130 awk '/^lf_repa[ri]*ed/ { print $2 }')
4131 [ $REPAIRED -gt 0 ] ||
4132 error "Some entry under /lost+found should be repaired"
4135 diff_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4136 error "Unable to diff files"
4138 rm -rf $TMP/$tdir $TMP/file_xattrs ||
4139 error "Unable to delete temporary files"
4140 do_node $ost1node "rm -rf $ost1tmp" ||
4141 error "Unable to delete temporary files"
4142 cleanup || error "cleanup failed with $?"
4144 run_test 52 "check recovering objects from lost+found"
4146 # Checks threads_min/max/started for some service
4148 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
4149 # parameter pattern prefix like 'ost.*.ost'.
4162 local msg="Insane $modname thread counts"
4163 local ncpts=$(check_cpt_number $facet)
4167 check_mount || return 41
4169 # We need to expand $parampat, but it may match multiple parameters, so
4170 # we'll pick the first one
4171 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
4172 error "Couldn't expand ${parampat}.threads_min parameter name"
4176 # Remove the .threads_min part
4177 paramp=${paramp%.threads_min}
4179 # Check for sanity in defaults
4180 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4182 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4184 tstarted=$(do_facet $facet "$LCTL get_param \
4185 -n ${paramp}.threads_started" || echo 0)
4186 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
4188 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4190 nthrs=$(expr $tmax - $tmin)
4191 if [ $nthrs -lt $ncpts ]; then
4197 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
4198 skip_env "module parameter forced $facet thread count"
4200 # Check that we can change min/max
4201 do_facet $facet "$LCTL set_param \
4202 ${paramp}.threads_min=$((tmin + nthrs))"
4203 do_facet $facet "$LCTL set_param \
4204 ${paramp}.threads_max=$((tmax - nthrs))"
4205 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4207 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4209 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
4210 $tmax2 == ($tmax - $nthrs)))' || return $?
4212 # Check that we can set min/max to the same value
4213 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4215 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
4216 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4218 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4220 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
4222 # Check that we can't set max < min
4223 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
4224 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4226 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4228 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
4230 # We need to ensure that we get the module options desired; to do this
4231 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
4232 LOAD_MODULES_REMOTE=true
4235 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
4236 setmodopts -a $modname "$newvalue" oldvalue
4239 check_mount || return 41
4241 # Restore previous setting of MODOPTS_*
4242 setmodopts $modname "$oldvalue"
4244 # Check that $opts took
4245 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4247 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4249 tstarted=$(do_facet $facet \
4250 "$LCTL get_param -n ${paramp}.threads_started" || echo 0)
4251 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4260 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
4261 cleanup || error "cleanup failed with rc $?"
4263 run_test 53a "check OSS thread count params"
4267 local mds=$(do_facet $SINGLEMDS "$LCTL get_param \
4268 -N mds.*.*.threads_max 2>/dev/null")
4269 if [ -z "$mds" ]; then
4270 #running this on an old MDT
4271 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
4273 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
4275 cleanup || error "cleanup failed with $?"
4277 run_test 53b "check MDS thread count params"
4280 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4281 skip "ldiskfs only test"
4284 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
4285 error "llverdev failed with rc=$?"
4288 run_test 54a "test llverdev and partial verify of device"
4291 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4292 skip "ldiskfs only test"
4296 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
4297 cleanup || error "cleanup failed with rc=$?"
4299 run_test 54b "test llverfs and partial verify of filesystem"
4303 local max_ost_index=$1
4304 echo -n $(((max_ost_index + 1) * 8))
4308 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4309 skip "ldiskfs only test"
4312 local mdsdev=$(mdsdevname 1)
4313 local mdsvdev=$(mdsvdevname 1)
4317 if ! combined_mgs_mds; then
4318 stop_mgs || error "stopping MGS service failed"
4319 format_mgs || error "formatting MGT failed"
4321 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
4323 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
4324 --reformat $(ostdevname 1) $(ostvdevname 1)
4330 echo checking size of lov_objid for ost index $i
4331 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" |
4332 grep ^User | awk -F 'Size: ' '{print $2}')
4333 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
4334 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
4336 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
4343 run_test 55 "check lov_objid size"
4346 local mds_journal_size_orig=$MDSJOURNALSIZE
4352 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
4353 $(ostdevname 1) $(ostvdevname 1)
4354 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
4355 $(ostdevname 2) $(ostvdevname 2)
4358 start_ost || error "Unable to start first ost (idx 10000)"
4359 start_ost2 || error "Unable to start second ost (idx 1000)"
4360 mount_client $MOUNT || error "Unable to mount client"
4364 if [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
4365 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
4366 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]]; then
4367 wait_osc_import_state mds ost1 FULL
4368 wait_osc_import_state mds ost2 FULL
4369 $LFS setstripe --stripe-count=-1 $DIR/$tfile ||
4370 error "Unable to setstripe $DIR/$tfile"
4371 n=$($LFS getstripe --stripe-count $DIR/$tfile)
4372 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
4377 MDSJOURNALSIZE=$mds_journal_size_orig
4380 run_test 56a "check big OST indexes and out-of-index-order start"
4385 umount_client $MOUNT -f || error "unmount client failed"
4394 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
4396 trap cleanup_56b EXIT RETURN ERR
4399 if ! combined_mgs_mds ; then
4404 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) --index=0 --reformat \
4405 $(mdsdevname 1) $(mdsvdevname 1)
4406 add mds2 $(mkfs_opts mds2 $(mdsdevname 2)) --index=1 --reformat \
4407 $(mdsdevname 2) $(mdsvdevname 2)
4408 add mds3 $(mkfs_opts mds3 $(mdsdevname 3)) --index=1000 --reformat \
4409 $(mdsdevname 3) $(mdsvdevname 3)
4413 start_mdt 1 || error "MDT 1 (idx 0) start failed"
4414 start_mdt 2 || error "MDT 2 (idx 1) start failed"
4415 start_mdt 3 || error "MDT 3 (idx 1000) start failed"
4416 start_ost || error "Unable to start first ost"
4417 start_ost2 || error "Unable to start second ost"
4419 do_nodes $(comma_list $(mdts_nodes)) \
4420 "$LCTL set_param mdt.*.enable_remote_dir=1 \
4421 mdt.*.enable_remote_dir_gid=-1"
4423 mount_client $MOUNT || error "Unable to mount client"
4425 $LFS mkdir -c3 $MOUNT/$tdir || error "failed to make testdir"
4427 echo "This is test file 1!" > $MOUNT/$tdir/$tfile.1 ||
4428 error "failed to make test file 1"
4429 echo "This is test file 2!" > $MOUNT/$tdir/$tfile.2 ||
4430 error "failed to make test file 2"
4431 echo "This is test file 1000!" > $MOUNT/$tdir/$tfile.1000 ||
4432 error "failed to make test file 1000"
4434 rm -rf $MOUNT/$tdir || error "failed to remove testdir"
4436 $LFS mkdir -i1000 $MOUNT/$tdir.1000 ||
4437 error "create remote dir at idx 1000 failed"
4440 echo "=== START lfs df OUTPUT ==="
4442 echo "==== END lfs df OUTPUT ===="
4444 mdtcnt=$(echo -e "$output" | grep $FSNAME-MDT | wc -l)
4445 ostcnt=$(echo -e "$output" | grep $FSNAME-OST | wc -l)
4447 echo "lfs df returned mdt count $mdtcnt and ost count $ostcnt"
4448 [ $mdtcnt -eq 3 ] || error "lfs df returned wrong mdt count"
4449 [ $ostcnt -eq 2 ] || error "lfs df returned wrong ost count"
4451 echo "This is test file 1!" > $MOUNT/$tdir.1000/$tfile.1 ||
4452 error "failed to make test file 1"
4453 echo "This is test file 2!" > $MOUNT/$tdir.1000/$tfile.2 ||
4454 error "failed to make test file 2"
4455 echo "This is test file 1000!" > $MOUNT/$tdir.1000/$tfile.1000 ||
4456 error "failed to make test file 1000"
4457 rm -rf $MOUNT/$tdir.1000 || error "failed to remove remote_dir"
4460 echo "=== START lfs mdts OUTPUT ==="
4462 echo "==== END lfs mdts OUTPUT ===="
4464 echo -e "$output" | grep -v "MDTS:" | awk '{print $1}' |
4465 sed 's/://g' > $TMP/mdts-actual.txt
4466 sort $TMP/mdts-actual.txt -o $TMP/mdts-actual.txt
4468 echo -e "0\n1\n1000" > $TMP/mdts-expected.txt
4470 diff $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4473 rm $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4475 [ $result -eq 0 ] || error "target_obd proc file is incorrect!"
4477 run_test 56b "test target_obd correctness with nonconsecutive MDTs"
4479 test_57a() { # bug 22656
4480 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4481 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4482 tail -1 | awk '{print $1}')
4483 writeconf_or_reformat
4484 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
4485 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
4486 error "tunefs failed"
4488 start_ost && error "OST registration from failnode should fail"
4491 run_test 57a "initial registration from failnode should fail (should return errs)"
4494 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4495 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4496 tail -1 | awk '{print $1}')
4497 writeconf_or_reformat
4498 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
4499 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
4500 error "tunefs failed"
4502 start_ost || error "OST registration from servicenode should not fail"
4505 run_test 57b "initial registration from servicenode should not fail"
4508 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
4511 test_58() { # bug 22658
4512 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
4514 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4515 createmany -o $DIR/$tdir/$tfile-%d 100
4516 unlinkmany $DIR/$tdir/$tfile-%d 100
4517 stop_mds || error "Unable to stop MDS"
4519 local MNTDIR=$(facet_mntpt $SINGLEMDS)
4520 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4522 # remove all files from the OBJECTS dir
4523 mount_fstype $SINGLEMDS
4525 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
4527 unmount_fstype $SINGLEMDS
4528 # restart MDS with missing llog files
4529 start_mds || error "unable to start MDS"
4530 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
4533 run_test 58 "missing llog files must not prevent MDT from mounting"
4536 start_mgsmds >> /dev/null
4537 local C1=$(count_osts)
4538 if [ $C1 -eq 0 ]; then
4539 start_ost >> /dev/null
4543 echo "original ost count: $C1 (expect > 0)"
4544 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
4545 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
4546 local C2=$(count_osts)
4547 echo "after mdt writeconf count: $C2 (expect 0)"
4548 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
4549 echo "OST start without writeconf should fail:"
4550 start_ost >> /dev/null &&
4551 error "OST start without writeconf didn't fail"
4552 echo "OST start with writeconf should succeed:"
4553 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
4554 local C3=$(count_osts)
4555 echo "after ost writeconf count: $C3 (expect 1)"
4556 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
4557 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
4558 local C4=$(count_osts)
4559 echo "after ost2 writeconf count: $C4 (expect 2)"
4560 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
4561 stop_ost2 >> /dev/null
4562 cleanup_nocli >> /dev/null
4563 #writeconf to remove all ost2 traces for subsequent tests
4564 writeconf_or_reformat
4566 run_test 59 "writeconf mount option"
4568 test_60() { # LU-471
4569 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4570 skip "ldiskfs only test"
4575 for num in $(seq $MDSCOUNT); do
4576 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
4577 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
4578 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4582 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
4583 [ ${PIPESTATUS[0]} -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
4585 # MDT default has dirdata feature
4586 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
4587 # we disable uninit_bg feature
4588 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
4589 # we set stride extended options
4590 echo $dump | grep stride > /dev/null || error "stride is not set"
4594 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
4597 local lxattr=$(large_xattr_enabled)
4599 [ "$MDS1_VERSION" -ge $(version_code 2.1.53) ] ||
4600 skip "Need MDS version at least 2.1.53"
4602 if [ "$mds1_FSTYPE" == ldiskfs ] &&
4603 ! large_xattr_enabled; then
4606 for num in $(seq $MDSCOUNT); do
4607 do_facet mds${num} $TUNE2FS -O ea_inode \
4608 $(mdsdevname $num) ||
4609 error "tune2fs on mds $num failed"
4613 setup || error "setting up the filesystem failed"
4614 client_up || error "starting client failed"
4616 local file=$DIR/$tfile
4617 touch $file || error "touch $file failed"
4619 local large_value="$(generate_string $(max_xattr_size))"
4620 local small_value="bar"
4622 local name="trusted.big"
4623 log "save large xattr of $(max_xattr_size) bytes on $name on $file"
4624 setfattr -n $name -v $large_value $file ||
4625 error "saving $name on $file failed"
4627 local new_value=$(get_xattr_value $name $file)
4628 [[ "$new_value" != "$large_value" ]] &&
4629 error "$name different after saving"
4631 log "shrink value of $name on $file"
4632 setfattr -n $name -v $small_value $file ||
4633 error "shrinking value of $name on $file failed"
4635 new_value=$(get_xattr_value $name $file)
4636 [[ "$new_value" != "$small_value" ]] &&
4637 error "$name different after shrinking"
4639 log "grow value of $name on $file"
4640 setfattr -n $name -v $large_value $file ||
4641 error "growing value of $name on $file failed"
4643 new_value=$(get_xattr_value $name $file)
4644 [[ "$new_value" != "$large_value" ]] &&
4645 error "$name different after growing"
4647 log "check value of $name on $file after remounting MDS"
4649 new_value=$(get_xattr_value $name $file)
4650 [[ "$new_value" != "$large_value" ]] &&
4651 error "$name different after remounting MDS"
4653 log "remove large xattr $name from $file"
4654 setfattr -x $name $file || error "removing $name from $file failed"
4656 if $lxattr && [ "$mds1_FSTYPE" == ldiskfs ]; then
4657 stopall || error "stopping for e2fsck run"
4658 for num in $(seq $MDSCOUNT); do
4659 run_e2fsck $(facet_active_host mds$num) \
4660 $(mdsdevname $num) "-y" ||
4661 error "e2fsck MDT$num failed"
4663 setup_noconfig || error "remounting the filesystem failed"
4666 # need to delete this file to avoid problems in other tests
4668 cleanup || error "stopping systems failed"
4670 run_test 61 "large xattr"
4673 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4674 skip "ldiskfs only test"
4676 [[ "$MDS1_VERSION" -ge $(version_code 2.2.51) ]] ||
4677 skip "Need MDS version at least 2.2.51"
4680 local mdsdev=$(mdsdevname 1)
4681 local ostdev=$(ostdevname 1)
4683 echo "disable journal for mds"
4684 do_facet mds1 $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
4685 start_mds && error "MDT start should fail"
4686 echo "disable journal for ost"
4687 do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
4688 start_ost && error "OST start should fail"
4689 cleanup || error "cleanup failed with rc $?"
4692 run_test 62 "start with disabled journal"
4695 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4696 skip "ldiskfs only test"
4699 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ldiskfs
4700 local inode_slab=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4701 awk '/ldiskfs_inode_cache/ { print $5 / $6 }')
4702 if [ -z "$inode_slab" ]; then
4703 skip "ldiskfs module has not been loaded"
4706 if grep -q "CONFIG_DEBUG_LOCK_ALLOC=y" /boot/config-$(uname -r); then
4707 skip "test is not compatible with CONFIG_DEBUG_LOCK_ALLOC=y"
4710 echo "$inode_slab ldiskfs inodes per page"
4711 [ "${inode_slab%.*}" -ge "3" ] && return 0
4713 # If kmalloc-128 is also 1 per page - this is a debug kernel
4714 # and so this is not an error.
4715 local kmalloc128=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4716 awk '/^(dma-kmalloc|size)-128 / { print $5 / $6 }')
4717 # 32 128-byte chunks in 4k
4718 [ "${kmalloc128%.*}" -lt "32" ] ||
4719 error "ldiskfs inode too big, only $inode_slab objs/page, " \
4720 "kmalloc128 = $kmalloc128 objs/page"
4722 run_test 63 "Verify each page can at least hold 3 ldiskfs inodes"
4725 start_mds || error "unable to start MDS"
4726 start_ost || error "Unable to start OST1"
4727 start_ost2 || error "Unable to start second ost"
4728 mount_client $MOUNT || error "Unable to mount client"
4729 stop_ost2 || error "Unable to stop second ost"
4732 umount_client $MOUNT -f || error “unmount $MOUNT failed”
4733 cleanup_nocli || error "cleanup_nocli failed with $?"
4734 #writeconf to remove all ost2 traces for subsequent tests
4735 writeconf_or_reformat
4737 run_test 64 "check lfs df --lazy "
4739 test_65() { # LU-2237
4740 # Currently, the test is only valid for ldiskfs backend
4741 [ "$mds1_FSTYPE" != ldiskfs ] &&
4742 skip "ldiskfs only test"
4744 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4745 local brpt=$(facet_mntpt brpt)
4748 if ! do_facet $SINGLEMDS "test -b $devname"; then
4752 stop_mds || error "Unable to stop MDS"
4753 local obj=$(do_facet $SINGLEMDS \
4754 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
4756 if [ -z "$obj" ]; then
4757 # The MDT may be just re-formatted, mount the MDT for the
4758 # first time to guarantee the "last_rcvd" file is there.
4759 start_mds || error "fail to mount the MDS for the first time"
4760 stop_mds || error "Unable to stop MDS"
4763 # remove the "last_rcvd" file
4764 do_facet $SINGLEMDS "mkdir -p $brpt"
4765 do_facet $SINGLEMDS \
4766 "mount -t $mds1_FSTYPE $opts $devname $brpt"
4767 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
4768 do_facet $SINGLEMDS "$UMOUNT $brpt"
4770 # restart MDS, the "last_rcvd" file should be recreated.
4771 start_mds || error "fail to restart the MDS"
4772 stop_mds || error "Unable to stop MDS"
4773 obj=$(do_facet $SINGLEMDS \
4774 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
4775 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
4777 run_test 65 "re-create the lost last_rcvd file when server mount"
4780 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
4781 skip "Need MGS version at least 2.3.59"
4784 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
4785 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
4787 # add EXCLUDE records to config log, they are not to be
4788 # removed by lctl replace_nids
4789 set_conf_param_and_check mds \
4790 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4791 "$FSNAME-OST0000.osc.active" \
4794 echo "replace_nids should fail if MDS, OSTs and clients are UP"
4795 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4796 error "replace_nids fail"
4798 umount_client $MOUNT || error "unmounting client failed"
4799 echo "replace_nids should fail if MDS and OSTs are UP"
4800 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4801 error "replace_nids fail"
4803 stop_ost || error "Unable to stop OST1"
4804 echo "replace_nids should fail if MDS is UP"
4805 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4806 error "replace_nids fail"
4808 stop_mds || error "stopping mds failed"
4810 if combined_mgs_mds; then
4811 start_mdt 1 "-o nosvc" ||
4812 error "starting mds with nosvc option failed"
4815 echo "command should accept two parameters"
4816 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
4817 error "command should accept two params"
4819 echo "correct device name should be passed"
4820 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
4821 error "wrong devname"
4823 echo "wrong nids list should not destroy the system"
4824 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
4826 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "asdfasdf, asdfadf" &&
4829 echo "replace OST nid"
4830 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
4831 error "replace nids failed"
4833 echo "command should accept two parameters"
4834 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
4835 error "command should accept two params"
4837 echo "wrong nids list should not destroy the system"
4838 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
4841 local FAKE_NIDS="192.168.0.112@tcp1,192.168.0.112@tcp2"
4842 local FAKE_FAILOVER="192.168.0.113@tcp1,192.168.0.113@tcp2"
4843 local NIDS_AND_FAILOVER="$MDS_NID,$FAKE_NIDS:$FAKE_FAILOVER"
4844 echo "set NIDs with failover"
4845 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $NIDS_AND_FAILOVER ||
4846 error "replace nids failed"
4849 echo "replace MDS nid"
4850 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
4851 error "replace nids failed"
4853 if ! combined_mgs_mds ; then
4856 stop_mds || error "Unable to stop MDS"
4859 start_mgsmds || error "start mgsmds failed"
4860 set_conf_param_and_check mds \
4861 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4862 "$FSNAME-OST0000.osc.active" \
4864 start_ost || error "unable to start OST"
4865 mount_client $MOUNT || error "mount client failed"
4867 check_mount || error "error after nid replace"
4868 cleanup || error "cleanup failed"
4871 run_test 66 "replace nids"
4873 test_67() { #LU-2950
4874 local legacy="$TMP/legacy_lnet_config"
4875 local new="$TMP/new_routes_test"
4876 local out="$TMP/config_out_file"
4877 local verify="$TMP/conv_verify"
4878 local verify_conf="$TMP/conf_verify"
4880 # Create the legacy file that will be run through the
4881 # lustre_routes_conversion script
4882 cat <<- LEGACY_LNET_CONFIG > $legacy
4883 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
4884 tcp2 54 10.1.3.2@tcp;
4885 tcp3 10.3.4.3@tcp:3;
4889 # Create the verification file to verify the output of
4890 # lustre_routes_conversion script against.
4891 cat <<- VERIFY_LNET_CONFIG > $verify
4892 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
4893 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
4894 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
4895 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
4896 tcp4: { gateway: 10.3.3.4@tcp }
4899 # Create the verification file to verify the output of
4900 # lustre_routes_config script against
4901 cat <<- VERIFY_LNET_CONFIG > $verify_conf
4902 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
4903 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
4904 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
4905 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
4906 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
4909 $LUSTRE_ROUTES_CONVERSION $legacy $new > /dev/null
4910 if [ -f $new ]; then
4911 # verify the conversion output
4912 cmp -s $new $verify > /dev/null
4913 if [ $? -eq 1 ]; then
4914 error "routes conversion failed"
4917 lustre_routes_config --dry-run --verbose $new > $out
4918 # check that the script succeeded
4919 cmp -s $out $verify_conf > /dev/null
4920 if [ $? -eq 1 ]; then
4921 error "routes config failed"
4924 error "routes conversion test failed"
4926 # remove generated files
4927 rm -f $new $legacy $verify $verify_conf $out
4929 run_test 67 "test routes conversion and configuration"
4937 [ "$MDS1_VERSION" -ge $(version_code 2.4.53) ] ||
4938 skip "Need MDS version at least 2.4.53"
4940 umount_client $MOUNT || error "umount client failed"
4945 # START-END - the sequences we'll be reserving
4946 START=$(do_facet $SINGLEMDS \
4947 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4948 END=$((START + (1 << 30)))
4949 do_facet $SINGLEMDS \
4950 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4952 # reset the sequences MDT0000 has already assigned
4953 do_facet $SINGLEMDS \
4954 $LCTL set_param seq.srv*MDT0000.space=clear
4956 # remount to let the client allocate new sequence
4957 mount_client $MOUNT || error "mount client failed"
4959 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4960 do_facet $SINGLEMDS \
4961 $LCTL get_param seq.srv*MDT0000.space
4962 $LFS path2fid $DIR/$tfile
4964 local old_ifs="$IFS"
4966 fid=($($LFS path2fid $DIR/$tfile))
4970 if [[ $seq < $END ]]; then
4971 error "used reserved sequence $seq?"
4973 cleanup || error "cleanup failed with $?"
4975 run_test 68 "be able to reserve specific sequences in FLDB"
4977 # Test 69: is about the total number of objects ever created on an OST.
4978 # so that when it is reformatted the normal MDS->OST orphan recovery won't
4979 # just "precreate" the missing objects. In the past it might try to recreate
4980 # millions of objects after an OST was reformatted
4982 [[ "$MDS1_VERSION" -lt $(version_code 2.4.2) ]] &&
4983 skip "Need MDS version at least 2.4.2"
4985 [[ "$MDS1_VERSION" -ge $(version_code 2.4.50) ]] &&
4986 [[ "$MDS1_VERSION" -lt $(version_code 2.5.0) ]] &&
4987 skip "Need MDS version at least 2.5.0"
4990 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4992 # use OST0000 since it probably has the most creations
4993 local OSTNAME=$(ostname_from_index 0)
4994 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4995 local last_id=$(do_facet mds1 $LCTL get_param -n \
4996 osp.$mdtosc_proc1.prealloc_last_id)
4998 # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
4999 # verify that the LAST_ID recovery is working properly. If
5000 # not, then the OST will refuse to allow the MDS connect
5001 # because the LAST_ID value is too different from the MDS
5002 #define OST_MAX_PRECREATE=20000
5003 local ost_max_pre=20000
5004 local num_create=$(( ost_max_pre * 5 + 1 - last_id))
5006 # If the LAST_ID is already over 5 * OST_MAX_PRECREATE, we don't
5007 # need to create any files. So, skip this section.
5008 if [ $num_create -gt 0 ]; then
5009 # Check the number of inodes available on OST0
5011 local ifree=$($LFS df -i $MOUNT | awk '/OST0000/ { print $4 }')
5012 log "On OST0, $ifree inodes available. Want $num_create."
5014 $LFS setstripe -i 0 $DIR/$tdir ||
5015 error "$LFS setstripe -i 0 $DIR/$tdir failed"
5016 if [ $ifree -lt 10000 ]; then
5017 files=$(( ifree - 50 ))
5022 local j=$((num_create / files + 1))
5023 for i in $(seq 1 $j); do
5024 createmany -o $DIR/$tdir/$tfile-$i- $files ||
5025 error "createmany fail create $files files: $?"
5026 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
5027 error "unlinkmany failed unlink $files files"
5031 # delete all of the files with objects on OST0 so the
5032 # filesystem is not inconsistent later on
5033 $LFS find $MOUNT --ost 0 -print0 | xargs -0 rm
5035 umount_client $MOUNT || error "umount client failed"
5036 stop_ost || error "OST0 stop failure"
5037 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
5038 $(ostdevname 1) $(ostvdevname 1) ||
5039 error "reformat and replace $ostdev failed"
5040 start_ost || error "OST0 restart failure"
5041 wait_osc_import_state mds ost FULL
5043 mount_client $MOUNT || error "mount client failed"
5044 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
5045 local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
5046 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
5048 local iused=$($LFS df -i $MOUNT | awk '/OST0000/ { print $3 }')
5049 log "On OST0, $iused used inodes"
5050 [ $iused -ge $((ost_max_pre/2 + 1000)) ] &&
5051 error "OST replacement created too many inodes; $iused"
5052 cleanup || error "cleanup failed with $?"
5054 run_test 69 "replace an OST with the same index"
5057 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5060 cleanup || error "cleanup failed with $?"
5062 start_mdt 1 || error "MDT0 start fail"
5064 start_ost || error "OST0 start fail"
5065 for num in $(seq 2 $MDSCOUNT); do
5066 start_mdt $num || return
5069 mount_client $MOUNT || error "mount client fails"
5071 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5073 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5074 error "create remote dir fail"
5076 rm -rf $DIR/$tdir || error "delete dir fail"
5077 cleanup || error "cleanup failed with $?"
5079 run_test 70a "start MDT0, then OST, then MDT1"
5082 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5085 start_ost || error "OST0 start fail"
5087 start_mds || error "MDS start fail"
5089 mount_client $MOUNT || error "mount client fails"
5091 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5093 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5094 error "create remote dir fail"
5096 rm -rf $DIR/$tdir || error "delete dir fail"
5098 cleanup || error "cleanup failed with $?"
5100 run_test 70b "start OST, MDT1, MDT0"
5103 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5106 start_mds || error "MDS start fail"
5107 start_ost || error "OST0 start fail"
5109 mount_client $MOUNT || error "mount client fails"
5110 stop_mdt 1 || error "MDT1 start fail"
5112 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
5113 echo "deactivate $mdc_for_mdt1"
5114 $LCTL --device $mdc_for_mdt1 deactivate ||
5115 error "set $mdc_for_mdt1 deactivate failed"
5117 mkdir $DIR/$tdir && error "mkdir succeed"
5119 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5120 error "create remote dir succeed"
5122 cleanup || error "cleanup failed with $?"
5124 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
5127 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5130 start_mds || error "MDS start fail"
5131 start_ost || error "OST0 start fail"
5133 mount_client $MOUNT || error "mount client fails"
5135 stop_mdt 2 || error "MDT1 start fail"
5137 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
5139 echo "deactivate $mdc_for_mdt2"
5140 $LCTL --device $mdc_for_mdt2 deactivate ||
5141 error "set $mdc_for_mdt2 deactivate failed"
5143 mkdir $DIR/$tdir || error "mkdir fail"
5144 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5145 error "create remote dir succeed"
5147 rm -rf $DIR/$tdir || error "delete dir fail"
5149 cleanup || error "cleanup failed with $?"
5151 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
5154 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5156 [ "$MDS1_VERSION" -ge $(version_code 2.7.62) ] ||
5157 skip "Need MDS version at least 2.7.62"
5159 reformat || error "reformat failed with $?"
5163 local mdsdev=$(mdsdevname 1)
5164 local ostdev=$(ostdevname 1)
5165 local mdsvdev=$(mdsvdevname 1)
5166 local ostvdev=$(ostvdevname 1)
5167 local opts_mds="$(mkfs_opts mds1 $mdsdev) --reformat $mdsdev $mdsvdev"
5168 local opts_ost="$(mkfs_opts ost1 $ostdev) --reformat $ostdev $ostvdev"
5170 if ! combined_mgs_mds ; then
5174 add mds1 $opts_mds || error "add mds1 failed"
5175 start_mdt 1 || error "start mdt1 failed"
5176 add ost1 $opts_ost || error "add ost1 failed"
5177 start_ost || error "start ost failed"
5178 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
5180 local soc=$(do_facet mds1 "$LCTL get_param -n \
5181 mdt.*MDT0000.sync_lock_cancel")
5182 [ $soc == "never" ] || error "SoC enabled on single MDS"
5184 for i in $(seq 2 $MDSCOUNT); do
5185 mdsdev=$(mdsdevname $i)
5186 mdsvdev=$(mdsvdevname $i)
5187 opts_mds="$(mkfs_opts mds$i $mdsdev) --reformat $mdsdev \
5189 add mds$i $opts_mds || error "add mds$i failed"
5190 start_mdt $i || error "start mdt$i fail"
5193 wait_dne_interconnect
5195 for i in $(seq $MDSCOUNT); do
5196 soc=$(do_facet mds$i "$LCTL get_param -n \
5197 mdt.*MDT000$((i - 1)).sync_lock_cancel")
5198 [ $soc == "blocking" ] || error "SoC not enabled on DNE"
5201 for i in $(seq 2 $MDSCOUNT); do
5202 stop_mdt $i || error "stop mdt$i fail"
5204 soc=$(do_facet mds1 "$LCTL get_param -n \
5205 mdt.*MDT0000.sync_lock_cancel")
5206 [ $soc == "never" ] || error "SoC enabled on single MDS"
5207 umount_client $MOUNT -f > /dev/null
5209 cleanup || error "cleanup failed with $?"
5211 run_test 70e "Sync-on-Cancel will be enabled by default on DNE"
5214 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5215 if combined_mgs_mds; then
5216 skip "needs separate MGS/MDT"
5220 start_mdt 1 || error "MDT0 start fail"
5221 start_ost || error "OST0 start fail"
5222 for num in $(seq 2 $MDSCOUNT); do
5223 start_mdt $num || return
5226 start_ost2 || error "OST1 start fail"
5228 mount_client $MOUNT || error "mount client fails"
5230 mkdir $DIR/$tdir || error "mkdir fail"
5231 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5232 error "create remote dir succeed"
5234 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5235 rm -rf $DIR/$tdir || error "delete dir fail"
5237 umount_client $MOUNT || error "umount_client failed"
5238 stop_mds || error "MDS stop fail"
5239 stop_ost || error "OST0 stop fail"
5240 stop_ost2 || error "OST1 stop fail"
5242 run_test 71a "start MDT0 OST0, MDT1, OST1"
5245 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5246 if combined_mgs_mds; then
5247 skip "needs separate MGS/MDT"
5251 for num in $(seq 2 $MDSCOUNT); do
5252 start_mdt $num || return
5254 start_ost || error "OST0 start fail"
5255 start_mdt 1 || error "MDT0 start fail"
5256 start_ost2 || error "OST1 start fail"
5258 mount_client $MOUNT || error "mount client fails"
5260 mkdir $DIR/$tdir || error "mkdir fail"
5261 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5262 error "create remote dir succeed"
5264 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5265 rm -rf $DIR/$tdir || error "delete dir fail"
5267 umount_client $MOUNT || error "umount_client failed"
5268 stop_mds || error "MDT0 stop fail"
5269 stop_ost || error "OST0 stop fail"
5270 stop_ost2 || error "OST1 stop fail"
5272 run_test 71b "start MDT1, OST0, MDT0, OST1"
5275 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5276 combined_mgs_mds && skip "needs separate MGS/MDT"
5280 start_ost || error "OST0 start fail"
5281 start_ost2 || error "OST1 start fail"
5282 for num in $(seq 2 $MDSCOUNT); do
5283 start_mdt $num || return
5285 start_mdt 1 || error "MDT0 start fail"
5287 mount_client $MOUNT || error "mount client fails"
5289 mkdir $DIR/$tdir || error "mkdir fail"
5290 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5291 error "create remote dir succeed"
5293 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5294 rm -rf $DIR/$tdir || error "delete dir fail"
5296 umount_client $MOUNT || error "umount_client failed"
5297 stop_mds || error "MDS stop fail"
5298 stop_ost || error "OST0 stop fail"
5299 stop_ost2 || error "OST1 stop fail"
5302 run_test 71c "start OST0, OST1, MDT1, MDT0"
5305 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5306 combined_mgs_mds && skip "needs separate MGS/MDT"
5310 start_ost || error "OST0 start fail"
5311 for num in $(seq 2 $MDSCOUNT); do
5312 start_mdt $num || return
5314 start_mdt 1 || error "MDT0 start fail"
5315 start_ost2 || error "OST1 start fail"
5317 mount_client $MOUNT || error "mount client fails"
5319 mkdir $DIR/$tdir || error "mkdir fail"
5320 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5321 error "create remote dir succeed"
5323 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5324 rm -rf $DIR/$tdir || error "delete dir fail"
5326 umount_client $MOUNT || error "umount_client failed"
5327 stop_mds || error "MDS stop fail"
5328 stop_ost || error "OST0 stop fail"
5329 stop_ost2 || error "OST1 stop fail"
5332 run_test 71d "start OST0, MDT1, MDT0, OST1"
5335 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5336 combined_mgs_mds && skip "needs separate MGS/MDT"
5340 start_ost || error "OST0 start fail"
5341 for num in $(seq 2 $MDSCOUNT); do
5342 start_mdt $num || return
5344 start_ost2 || error "OST1 start fail"
5345 start_mdt 1 || error "MDT0 start fail"
5347 mount_client $MOUNT || error "mount client fails"
5349 mkdir $DIR/$tdir || error "mkdir fail"
5350 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5351 error "create remote dir succeed"
5353 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5354 rm -rf $DIR/$tdir || error "delete dir fail"
5356 umount_client $MOUNT || error "umount_client failed"
5357 stop_mds || error "MDS stop fail"
5358 stop_ost || error "OST0 stop fail"
5359 stop_ost2 || error "OST1 stop fail"
5362 run_test 71e "start OST0, MDT1, OST1, MDT0"
5364 test_72() { #LU-2634
5365 [ "$mds1_FSTYPE" != ldiskfs ] &&
5366 skip "ldiskfs only test"
5368 local mdsdev=$(mdsdevname 1)
5369 local ostdev=$(ostdevname 1)
5370 local cmd="$E2FSCK -fnvd $mdsdev"
5377 if combined_mgs_mds; then
5378 add_options='--reformat'
5380 add_options='--reformat --replace'
5383 #tune MDT with "-O extents"
5385 for num in $(seq $MDSCOUNT); do
5386 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
5387 $add_options $(mdsdevname $num) $(mdsvdevname $num) ||
5388 error "add mds $num failed"
5389 do_facet mds${num} "$TUNE2FS -O extents $(mdsdevname $num)" ||
5390 error "$TUNE2FS failed on mds${num}"
5393 add ost1 $(mkfs_opts ost1 $ostdev) $add_options $ostdev ||
5394 error "add $ostdev failed"
5395 start_mds || error "start mds failed"
5396 start_ost || error "start ost failed"
5397 mount_client $MOUNT || error "mount client failed"
5399 #create some short symlinks
5400 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5401 createmany -o $DIR/$tdir/$tfile-%d $fn
5402 echo "create $fn short symlinks"
5403 for i in $(seq -w 1 $fn); do
5404 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
5409 umount_client $MOUNT || error "umount client failed"
5410 stop_mds || error "stop mds failed"
5411 stop_ost || error "stop ost failed"
5414 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
5416 run_test 72 "test fast symlink with extents flag enabled"
5418 test_73() { #LU-3006
5419 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
5420 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
5421 error "1st tunefs failed"
5422 start_mgsmds || error "start mds failed"
5423 start_ost || error "start ost failed"
5424 mount_client $MOUNT || error "mount client failed"
5425 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
5426 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
5427 umount_client $MOUNT || error "umount client failed"
5431 run_test 73 "failnode to update from mountdata properly"
5433 test_75() { # LU-2374
5434 [[ "$MDS1_VERSION" -lt $(version_code 2.4.1) ]] &&
5435 skip "Need MDS version at least 2.4.1"
5438 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
5439 --replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
5440 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
5441 --replace --reformat $(ostdevname 1) $(ostvdevname 1)"
5443 #check with default parameters
5444 add mds1 $opts_mds || error "add mds1 failed for default params"
5445 add ost1 $opts_ost || error "add ost1 failed for default params"
5447 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
5448 opts_mds=$(echo $opts_mds |
5449 sed -e "s/--index=$index/--index=$index --mdt/")
5450 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
5451 opts_ost=$(echo $opts_ost |
5452 sed -e "s/--index=$index/--index=$index --ost/")
5454 add mds1 $opts_mds || error "add mds1 failed for new params"
5455 add ost1 $opts_ost || error "add ost1 failed for new params"
5460 run_test 75 "The order of --index should be irrelevant"
5463 [[ "$MGS_VERSION" -ge $(version_code 2.4.52) ]] ||
5464 skip "Need MDS version at least 2.4.52"
5467 local MDMB_PARAM="osc.*.max_dirty_mb"
5468 echo "Change MGS params"
5469 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
5471 echo "max_dirty_mb: $MAX_DIRTY_MB"
5472 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB - 10))
5473 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
5474 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
5475 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5476 head -1" $NEW_MAX_DIRTY_MB
5477 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5478 echo "$MAX_DIRTY_MB"
5479 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5480 error "error while apply max_dirty_mb"
5482 echo "Check the value is stored after remount"
5485 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5486 head -1" $NEW_MAX_DIRTY_MB
5487 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5488 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5489 error "max_dirty_mb is not saved after remount"
5491 echo "Change OST params"
5492 CLIENT_PARAM="obdfilter.*.client_cache_count"
5493 local CLIENT_CACHE_COUNT
5494 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5496 echo "client_cache_count: $CLIENT_CACHE_COUNT"
5497 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
5498 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
5499 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
5500 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5501 head -1" $NEW_CLIENT_CACHE_COUNT
5502 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5504 echo "$CLIENT_CACHE_COUNT"
5505 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5506 error "error while apply client_cache_count"
5508 echo "Check the value is stored after remount"
5511 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5512 head -1" $NEW_CLIENT_CACHE_COUNT
5513 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5515 echo "$CLIENT_CACHE_COUNT"
5516 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5517 error "client_cache_count is not saved after remount"
5520 run_test 76a "set permanent params with lctl across mounts"
5522 test_76b() { # LU-4783
5523 [[ "$MGS_VERSION" -ge $(version_code 2.5.57) ]] ||
5524 skip "Need MGS version at least 2.5.57"
5527 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
5528 error "start params log failed"
5531 run_test 76b "verify params log setup correctly"
5534 [[ "$MGS_VERSION" -ge $(version_code 2.8.54) ]] ||
5535 skip "Need MDS version at least 2.4.52"
5537 local MASK_PARAM="mdd.*.changelog_mask"
5538 echo "Change changelog_mask"
5539 do_facet mgs $LCTL set_param -P $MASK_PARAM=-CLOSE ||
5540 error "Can't change changlog_mask"
5541 wait_update $(facet_host mds) "$LCTL get_param -n $MASK_PARAM |
5544 echo "Check the value is stored after mds remount"
5545 stop_mds || error "Failed to stop MDS"
5546 start_mds || error "Failed to start MDS"
5547 local CHANGELOG_MASK=$(do_facet mgs $LCTL get_param -n $MASK_PARAM)
5548 echo $CHANGELOG_MASK | grep CLOSE > /dev/null &&
5549 error "changelog_mask is not changed"
5553 run_test 76c "verify changelog_mask is applied with lctl set_param -P"
5555 test_76d() { #LU-9399
5558 local xattr_cache="llite.*.xattr_cache"
5559 local cmd="$LCTL get_param -n $xattr_cache | head -1"
5560 local new=$((($(eval $cmd) + 1) % 2))
5562 echo "lctl set_param -P llite.*.xattr_cache=$new"
5563 do_facet mgs $LCTL set_param -P $xattr_cache=$new ||
5564 error "Can't change xattr_cache"
5565 wait_update $HOSTNAME "$cmd" "$new"
5567 echo "Check $xattr_cache on client $MOUNT"
5568 umount_client $MOUNT || error "umount $MOUNT failed"
5569 mount_client $MOUNT || error "mount $MOUNT failed"
5570 [ $(eval $cmd) -eq $new ] ||
5571 error "$xattr_cache != $new on client $MOUNT"
5573 echo "Check $xattr_cache on the new client $MOUNT2"
5574 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
5575 [ $(eval $cmd) -eq $new ] ||
5576 error "$xattr_cache != $new on client $MOUNT2"
5577 umount_client $MOUNT2 || error "umount $MOUNT2 failed"
5581 run_test 76d "verify llite.*.xattr_cache can be set by 'lctl set_param -P' correctly"
5583 test_77() { # LU-3445
5584 [[ "$MDS1_VERSION" -ge $(version_code 2.8.55) ]] ||
5585 skip "Need MDS version 2.8.55+ "
5587 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
5588 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
5589 skip_env "mixed loopback and real device not working"
5592 local fs2mdsdev=$(mdsdevname 1_2)
5593 local fs2ostdev=$(ostdevname 1_2)
5594 local fs2mdsvdev=$(mdsvdevname 1_2)
5595 local fs2ostvdev=$(ostvdevname 1_2)
5596 local fsname=test1234
5598 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
5600 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
5602 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
5603 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
5604 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
5605 error "start fs2mds failed"
5607 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
5608 mgsnid="0.0.0.0@tcp,$mgsnid,$mgsnid:$mgsnid"
5610 add fs2ost --mgsnode=$mgsnid $(mkfs_opts ost1 $fs2ostdev) \
5611 --failnode=$failnid --fsname=$fsname \
5612 --reformat $fs2ostdev $fs2ostvdev ||
5613 error "add fs2ost failed"
5614 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
5616 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
5617 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
5618 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
5621 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
5624 [[ "$mds1_FSTYPE" != ldiskfs ||
5625 "$ost1_FSTYPE" != ldiskfs ]] &&
5626 skip "ldiskfs only test"
5628 # reformat the Lustre filesystem with a smaller size
5629 local saved_MDSCOUNT=$MDSCOUNT
5630 local saved_MDSSIZE=$MDSSIZE
5631 local saved_OSTCOUNT=$OSTCOUNT
5632 local saved_OSTSIZE=$OSTSIZE
5635 MDSSIZE=$((MDSSIZE - 20000))
5636 OSTSIZE=$((OSTSIZE - 20000))
5637 reformat || error "(1) reformat Lustre filesystem failed"
5638 MDSSIZE=$saved_MDSSIZE
5639 OSTSIZE=$saved_OSTSIZE
5641 # mount the Lustre filesystem
5642 setup_noconfig || error "(2) setup Lustre filesystem failed"
5645 log "create test files"
5650 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
5652 for i in $(seq $num_files); do
5653 file=$MOUNT/$tdir/$tfile-$i
5654 dd if=/dev/urandom of=$file count=1 bs=1M || {
5655 $LCTL get_param osc.*.cur*grant*
5656 $LFS df; $LFS df -i;
5657 # stop creating files if there is no more space
5658 if [ ! -e $file ]; then
5659 num_files=$((i - 1))
5663 $LFS getstripe -v $file
5664 local ost_idx=$(LFS getstripe -i $file)
5665 do_facet ost$((ost_idx + 1)) \
5666 $LCTL get_param obdfilter.*.*grant*
5667 error "(4) create $file failed"
5671 # unmount the Lustre filesystem
5672 cleanup || error "(5) cleanup Lustre filesystem failed"
5674 # run e2fsck on the MDT and OST devices
5675 local mds_host=$(facet_active_host $SINGLEMDS)
5676 local ost_host=$(facet_active_host ost1)
5677 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
5678 local ost_dev=$(ostdevname 1)
5680 run_e2fsck $mds_host $mds_dev "-y"
5681 run_e2fsck $ost_host $ost_dev "-y"
5683 # get the original block count of the MDT and OST filesystems
5684 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
5685 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
5687 # expand the MDT and OST filesystems to the device size
5688 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
5689 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
5691 # run e2fsck on the MDT and OST devices again
5692 run_e2fsck $mds_host $mds_dev "-y"
5693 run_e2fsck $ost_host $ost_dev "-y"
5695 # mount the Lustre filesystem
5699 log "check files after expanding the MDT and OST filesystems"
5700 for i in $(seq $num_files); do
5701 file=$MOUNT/$tdir/$tfile-$i
5702 $CHECKSTAT -t file -s 1048576 $file ||
5703 error "(6) checkstat $file failed"
5707 log "create more files after expanding the MDT and OST filesystems"
5708 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
5709 file=$MOUNT/$tdir/$tfile-$i
5710 dd if=/dev/urandom of=$file count=1 bs=1M ||
5711 error "(7) create $file failed"
5714 # unmount the Lustre filesystem
5715 cleanup || error "(8) cleanup Lustre filesystem failed"
5717 # run e2fsck on the MDT and OST devices
5718 run_e2fsck $mds_host $mds_dev "-y"
5719 run_e2fsck $ost_host $ost_dev "-y"
5721 # get the maximum block count of the MDT and OST filesystems
5722 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
5723 local ost_max_blks=$(get_block_count ost1 $ost_dev)
5725 # get the minimum block count of the MDT and OST filesystems
5726 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
5727 grep minimum | sed -e 's/^.*filesystem: //g')
5728 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
5729 grep minimum | sed -e 's/^.*filesystem: //g')
5731 # shrink the MDT and OST filesystems to a smaller size
5735 if [[ $mds_max_blks -gt $mds_min_blks &&
5736 $mds_max_blks -gt $mds_orig_blks ]]; then
5737 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
5738 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
5739 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
5740 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
5741 error "shrink $SINGLEMDS to $new_blks failed"
5745 if [[ $ost_max_blks -gt $ost_min_blks &&
5746 $ost_max_blks -gt $ost_orig_blks ]]; then
5747 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
5748 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
5749 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
5750 run_resize2fs ost1 $ost_dev $new_blks ||
5751 error "shrink ost1 to $new_blks failed"
5755 # check whether the MDT or OST filesystem was shrunk or not
5757 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
5758 reformat_and_config ||
5759 error "(10) reformat Lustre filesystem failed"
5763 # run e2fsck on the MDT and OST devices again
5764 run_e2fsck $mds_host $mds_dev "-y"
5765 run_e2fsck $ost_host $ost_dev "-y"
5767 # mount the Lustre filesystem again
5771 log "check files after shrinking the MDT and OST filesystems"
5772 for i in $(seq $((num_files + 10))); do
5773 file=$MOUNT/$tdir/$tfile-$i
5774 $CHECKSTAT -t file -s 1048576 $file ||
5775 error "(11) checkstat $file failed"
5778 # unmount and reformat the Lustre filesystem
5779 cleanup || error "(12) cleanup Lustre filesystem failed"
5780 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
5782 MDSCOUNT=$saved_MDSCOUNT
5783 OSTCOUNT=$saved_OSTCOUNT
5784 reformat_and_config || error "(14) reformat Lustre filesystem failed"
5786 run_test 78 "run resize2fs on MDT and OST filesystems"
5788 test_79() { # LU-4227
5789 [[ "$MDS1_VERSION" -ge $(version_code 2.5.59) ]] ||
5790 skip "Need MDS version at least 2.5.59"
5792 local mdsdev1=$(mdsdevname 1)
5793 local mdsvdev1=$(mdsvdevname 1)
5794 local mdsdev2=$(mdsdevname 2)
5795 local mdsvdev2=$(mdsvdevname 2)
5796 local ostdev1=$(ostdevname 1)
5797 local ostvdev1=$(ostvdevname 1)
5798 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
5799 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
5800 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
5803 # remove --mgs/--mgsnode from mkfs.lustre options
5804 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
5806 mgsnode_opt=$(echo $opts_mds2 |
5807 awk '{ for ( i = 1; i < NF; i++ )
5808 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5809 [ -n "$mgsnode_opt" ] &&
5810 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
5812 mgsnode_opt=$(echo $opts_ost1 |
5813 awk '{ for ( i = 1; i < NF; i++ )
5814 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5815 [ -n "$mgsnode_opt" ] &&
5816 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
5818 # -MGS, format a mdt without --mgs option
5819 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
5820 error "Must specify --mgs when formatting mdt combined with mgs"
5822 # +MGS, format a mdt/ost without --mgsnode option
5823 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
5824 > /dev/null || error "start mds1 failed"
5825 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
5826 error "Must specify --mgsnode when formatting a mdt"
5827 add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
5828 error "Must specify --mgsnode when formatting an ost"
5832 run_test 79 "format MDT/OST without mgs option (should return errors)"
5835 start_mds || error "Failed to start MDT"
5836 start_ost || error "Failed to start OST1"
5837 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
5838 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
5839 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
5840 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
5841 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
5843 start_ost2 || error "Failed to start OST2"
5845 do_facet ost1 "$LCTL set_param fail_loc=0"
5850 run_test 80 "mgc import reconnect race"
5852 #Save the original values of $OSTCOUNT and $OSTINDEX$i.
5854 local new_ostcount=$1
5855 saved_ostcount=$OSTCOUNT
5856 OSTCOUNT=$new_ostcount
5860 for i in $(seq $OSTCOUNT); do
5862 eval saved_ostindex$i=${!index}
5867 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
5868 restore_ostindex() {
5873 for i in $(seq $OSTCOUNT); do
5874 index=saved_ostindex$i
5875 eval OSTINDEX$i=${!index}
5877 OSTCOUNT=$saved_ostcount
5880 if ! combined_mgs_mds ; then
5885 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
5886 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
5887 # assigned index and ensures we can mount such a formatted file system
5888 test_81() { # LU-4665
5889 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
5890 skip "Need MDS version at least 2.6.54"
5891 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5895 # Each time RANDOM is referenced, a random integer between 0 and 32767
5898 local saved_ostindex1=$OSTINDEX1
5899 for i in 65535 $((RANDOM + 65536)); do
5900 echo -e "\nFormat ost1 with --index=$i, should fail"
5902 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
5903 $(ostdevname 1) $(ostvdevname 1); then
5904 OSTINDEX1=$saved_ostindex1
5905 error "format ost1 with --index=$i should fail"
5908 OSTINDEX1=$saved_ostindex1
5912 # Format OSTs with random sparse indices.
5913 trap "restore_ostindex" EXIT
5914 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices"
5915 OST_INDEX_LIST=[0,$((RANDOM * 2 % 65533 + 1)),65534] formatall
5917 # Setup and check Lustre filesystem.
5918 start_mgsmds || error "start_mgsmds failed"
5919 for i in $(seq $OSTCOUNT); do
5920 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5921 error "start ost$i failed"
5924 mount_client $MOUNT || error "mount client $MOUNT failed"
5925 check_mount || error "check client $MOUNT failed"
5928 local max_easize=$($LCTL get_param -n llite.*.max_easize)
5929 # 65452 is XATTR_SIZE_MAX less ldiskfs ea overhead
5930 if large_xattr_enabled; then
5931 [[ $max_easize -ge 65452 ]] ||
5932 error "max_easize is $max_easize, should be at least 65452 bytes"
5935 # 4012 is 4096 less ldiskfs ea overhead
5936 [[ $max_easize -ge 4012 ]] ||
5937 error "max_easize is $max_easize, should be at least 4012 bytes"
5942 run_test 81 "sparse OST indexing"
5944 # Here we exercise the stripe placement functionality on a file system that
5945 # has formatted the OST with a random index. With the file system the following
5946 # functionality is tested:
5948 # 1. Creating a new file with a specific stripe layout.
5950 # 2. Modifiy a existing empty file with a specific stripe layout.
5952 # 3. Ensure we fail to set the stripe layout of a file that already has one.
5954 # 4. If ost-index is defined we need to ensure it is the first entry in the
5955 # ost index list returned by lfs getstripe.
5957 # 5. Lastly ensure this functionality fails with directories.
5958 test_82a() { # LU-4665
5959 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
5960 skip "Need MDS version at least 2.6.54"
5961 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5967 # Format OSTs with random sparse indices.
5971 local LOV_V1_INSANE_STRIPE_COUNT=65532
5972 for i in $(seq $OSTCOUNT); do
5973 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
5974 ost_indices+=" $index"
5976 ost_indices=$(comma_list $ost_indices)
5978 stack_trap "restore_ostindex" EXIT
5979 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5980 OST_INDEX_LIST=[$ost_indices] formatall
5982 # Setup Lustre filesystem.
5983 start_mgsmds || error "start_mgsmds failed"
5984 for i in $(seq $OSTCOUNT); do
5985 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5986 error "start ost$i failed"
5989 # Collect debug information - start of test
5990 do_nodes $(comma_list $(mdts_nodes)) \
5991 $LCTL get_param osp.*.prealloc_*_id
5993 mount_client $MOUNT || error "mount client $MOUNT failed"
5996 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
5997 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5999 stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
6000 $LCTL get_param osp.*.prealloc_*_id" EXIT
6002 # 1. If the file does not exist, new file will be created
6003 # with specified OSTs.
6004 local file=$DIR/$tdir/$tfile-1
6005 local cmd="$LFS setstripe -o $ost_indices $file"
6007 eval $cmd || error "$cmd failed"
6008 check_stripe_count $file $OSTCOUNT
6009 check_obdidx $file $ost_indices
6010 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6011 error "write $file failed"
6013 # 2. If the file already exists and is an empty file, the file
6014 # will be attached with specified layout.
6015 file=$DIR/$tdir/$tfile-2
6016 mcreate $file || error "mcreate $file failed"
6017 cmd="$LFS setstripe -o $ost_indices $file"
6019 eval $cmd || error "$cmd failed"
6020 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6021 error "write $file failed"
6022 check_stripe_count $file $OSTCOUNT
6023 check_obdidx $file $ost_indices
6025 # 3. If the file already has a valid layout attached, the command
6026 # should fail with EBUSY.
6028 eval $cmd && error "stripe is already set on $file, $cmd should fail"
6030 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
6031 # be in the OST indices list.
6032 local start_ost_idx=${ost_indices##*,}
6033 file=$DIR/$tdir/$tfile-3
6034 cmd="$LFS setstripe -o $ost_indices -i $start_ost_idx $file"
6036 eval $cmd || error "$cmd failed"
6037 check_stripe_count $file $OSTCOUNT
6038 check_obdidx $file $ost_indices
6039 check_start_ost_idx $file $start_ost_idx
6041 file=$DIR/$tdir/$tfile-4
6042 cmd="$LFS setstripe"
6043 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
6044 cmd+=" -i $start_ost_idx $file"
6046 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
6048 # 5. Specifying OST indices for directory should succeed.
6049 local dir=$DIR/$tdir/$tdir
6050 mkdir $dir || error "mkdir $dir failed"
6051 cmd="$LFS setstripe -o $ost_indices $dir"
6052 if [ "$MDS1_VERSION" -gt $(version_code 2.11.53) ] &&
6053 [ "$CLIENT_VERSION" -gt $(version_code 2.11.53) ]; then
6055 eval $cmd || error "unable to specify OST indices on directory"
6057 echo "need MDS+client version at least 2.11.53"
6062 run_test 82a "specify OSTs for file (succeed) or directory (succeed)"
6067 # Remove OSTs from a pool and destroy the pool.
6068 destroy_pool $ost_pool || true
6073 # Test 82b is run to ensure that if the user supplies a pool with a specific
6074 # stripe layout that it behaves proprerly. It should fail in the case that
6075 # the supplied OST index list points to OSTs not contained in the user
6077 test_82b() { # LU-4665
6078 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
6079 skip "Need MDS version at least 2.6.54"
6080 [[ $OSTCOUNT -ge 4 ]] || skip_env "needs >= 4 OSTs"
6086 # Format OSTs with random sparse indices.
6090 local LOV_V1_INSANE_STRIPE_COUNT=65532
6091 for i in $(seq $OSTCOUNT); do
6092 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
6093 ost_indices+=" $index"
6095 ost_indices=$(comma_list $ost_indices)
6097 trap "restore_ostindex" EXIT
6098 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
6099 OST_INDEX_LIST=[$ost_indices] formatall
6101 # Setup Lustre filesystem.
6102 start_mgsmds || error "start_mgsmds failed"
6103 for i in $(seq $OSTCOUNT); do
6104 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
6105 error "start ost$i failed"
6108 mount_client $MOUNT || error "mount client $MOUNT failed"
6111 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
6112 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6114 # Create a new pool and add OSTs into it.
6115 local ost_pool=$FSNAME.$TESTNAME
6116 create_pool $ost_pool || error "create OST pool $ost_pool failed"
6119 trap "cleanup_82b" EXIT
6121 local ost_idx_in_list=${ost_indices##*,}
6122 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
6125 local ost_targets="$FSNAME-OST["
6126 for i in ${ost_idx_in_pool//,/ }; do
6127 ost_targets=$ost_targets$(printf "%04x," $i)
6129 ost_targets="${ost_targets%,}]"
6131 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
6132 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
6133 sort -u | tr '\n' ' ')
6135 local cmd="$LCTL pool_add $ost_pool $ost_targets"
6136 do_facet mgs $cmd || error "$cmd failed"
6137 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
6138 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
6139 error "wait_update $ost_pool failed"
6140 wait_update_facet $SINGLEMDS "$LCTL pool_list $ost_pool | wc -l" 4 ||
6141 error "wait_update pool_list $ost_pool failed"
6143 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
6144 # then the OSTs must be the members of the pool.
6145 local file=$DIR/$tdir/$tfile
6146 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6148 eval $cmd && error "OST with index $ost_idx_in_list should be" \
6149 "in OST pool $ost_pool"
6151 # Only select OST $ost_idx_in_list from $ost_pool for file.
6152 ost_idx_in_list=${ost_idx_in_pool#*,}
6153 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6155 eval $cmd || error "$cmd failed"
6156 cmd="$LFS getstripe $file"
6158 eval $cmd || error "$cmd failed"
6159 check_stripe_count $file 2
6160 check_obdidx $file $ost_idx_in_list
6161 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6162 error "write $file failed"
6166 run_test 82b "specify OSTs for file with --pool and --ost-list options"
6169 [[ "$OST1_VERSION" -ge $(version_code 2.6.91) ]] ||
6170 skip "Need OST version at least 2.6.91"
6171 if [ "$ost1_FSTYPE" != ldiskfs ]; then
6172 skip "ldiskfs only test"
6181 ostmnt=$(facet_mntpt ost1)
6183 # Mount the OST as an ldiskfs filesystem.
6184 log "mount the OST $dev as a $ost1_FSTYPE filesystem"
6185 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
6186 --reformat $dev > /dev/null ||
6187 error "format ost1 error"
6189 if ! test -b $dev; then
6190 mnt_opts=$(csa_add "$OST_MOUNT_FS_OPTS" -o loop)
6192 echo "mnt_opts $mnt_opts"
6193 do_facet ost1 mount -t "$ost1_FSTYPE" $dev \
6195 # Run llverfs on the mounted ldiskfs filesystem.
6196 # It is needed to get ENOSPACE.
6197 log "run llverfs in partial mode on the OST $ost1_FSTYPE $ostmnt"
6198 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
6199 "no" || error "run_llverfs error on $ost1_FSTYPE"
6202 log "unmount the OST $dev"
6205 # Delete file IO_scrub. Later osd_scrub_setup will try to
6206 # create "IO_scrub" but will get ENOSPACE.
6208 echo "start ost1 service on `facet_active_host ost1`"
6209 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
6212 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
6213 echo "string err $err"
6214 [ -z "$err" ] || error $err
6217 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
6218 Busy inodes after unmount ..."
6221 local facet=$SINGLEMDS
6222 local num=$(echo $facet | tr -d "mds")
6223 local dev=$(mdsdevname $num)
6224 local time_min=$(recovery_time_min)
6225 local recovery_duration
6226 local completed_clients
6227 local correct_clients
6230 echo "start mds service on $(facet_active_host $facet)"
6232 "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" $@ ||
6233 error "start MDS failed"
6235 start_ost || error "start OST0000 failed"
6236 start_ost2 || error "start OST0001 failed"
6238 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
6240 mount_client $MOUNT1 || error "mount $MOUNT1 failed"
6241 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
6242 # make sure new superblock labels are sync'd before disabling writes
6246 replay_barrier $SINGLEMDS
6247 createmany -o $DIR1/$tfile-%d 1000
6249 # We need to catch the end of recovery window to extend it.
6250 # Skip 5 requests and add delay to request handling.
6251 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
6252 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
6254 facet_failover --fsck $SINGLEMDS || error "failover: $?"
6257 echo "recovery status"
6258 do_facet $SINGLEMDS \
6259 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
6261 recovery_duration=$(do_facet $SINGLEMDS \
6262 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6263 awk '/recovery_duration/ { print $2 }')
6264 (( $recovery_duration > $time_min + $wrap_up )) &&
6265 error "recovery_duration > recovery_time_hard + wrap up"
6266 completed_clients=$(do_facet $SINGLEMDS \
6267 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6268 awk '/completed_clients/ { print $2 }')
6270 correct_clients="$MDSCOUNT/$((MDSCOUNT+1))"
6271 [ "$completed_clients" = "${correct_clients}" ] ||
6272 error "$completed_clients != $correct_clients"
6274 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
6275 umount_client $MOUNT1
6276 umount_client $MOUNT2
6282 run_test 84 "check recovery_hard_time"
6285 [[ "$OST1_VERSION" -ge $(version_code 2.7.55) ]] ||
6286 skip "Need OST version at least 2.7.55"
6287 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
6288 do_facet ost1 "lctl set_param fail_loc=0x197"
6292 run_test 85 "osd_ost init: fail ea_fid_set"
6297 # ost1 has already registered to the MGS before the reformat.
6298 # So after reformatting it with option "-G", it could not be
6299 # mounted to the MGS. Cleanup the system for subsequent tests.
6304 [ "$ost1_FSTYPE" = zfs ] &&
6305 skip "LU-6442: no such mkfs params for ZFS OSTs"
6306 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
6307 skip "Need server version newer than 2.7.55"
6309 local OST_OPTS="$(mkfs_opts ost1 $(ostdevname 1)) \
6310 --reformat $(ostdevname 1) $(ostvdevname 1)"
6313 local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6314 awk '/Flex block group size: / { print $NF; exit; }')
6317 if [[ ${!opts} != *mkfsoptions* ]]; then
6318 eval opts=\"${!opts} \
6319 --mkfsoptions='\\\"-O flex_bg -G $NEWSIZE\\\"'\"
6321 val=${!opts//--mkfsoptions=\\\"/ \
6322 --mkfsoptions=\\\"-O flex_bg -G $NEWSIZE }
6326 echo "params: $opts"
6328 trap cleanup_86 EXIT ERR
6331 add ost1 $opts || error "add ost1 failed with new params"
6333 local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6334 awk '/Flex block group size: / { print $NF; exit; }')
6336 [[ $FOUNDSIZE == $NEWSIZE ]] ||
6337 error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
6341 run_test 86 "Replacing mkfs.lustre -G option"
6343 test_87() { #LU-6544
6344 [[ "$MDS1_VERSION" -ge $(version_code 2.9.51) ]] ||
6345 skip "Need MDS version at least 2.9.51"
6346 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
6347 skip "ldiskfs only test"
6348 [[ $OSTCOUNT -gt 59 ]] &&
6349 skip "Ignore wide striping situation"
6350 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
6352 local mdsdev=$(mdsdevname 1)
6353 local mdsvdev=$(mdsvdevname 1)
6354 local file=$DIR/$tfile
6355 local mntpt=$(facet_mntpt $SINGLEMDS)
6356 local used_xattr_blk=0
6357 local inode_size=${1:-1024}
6359 local xtest="trusted.test"
6363 local stripe_cnt=$(($OSTCOUNT + 2))
6365 #Please see ldiskfs_make_lustre() for MDT inode size calculation
6366 if [ $stripe_cnt -gt 16 ]; then
6369 left_size=$(expr $inode_size - \
6372 32 - 40 \* 3 - 32 \* 3 - $stripe_cnt \* 24 - 16 - 3 - \
6374 24 - 18 - $(expr length $tfile) - 16 - 4)
6375 if [ $left_size -le 0 ]; then
6376 echo "No space($left_size) is expected in inode."
6377 echo "Try 1-byte xattr instead to verify this."
6380 echo "Estimate: at most $left_size-byte space left in inode."
6386 if ! combined_mgs_mds ; then
6390 add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$stripe_cnt \
6391 --reformat $mdsdev $mdsvdev || error "add mds1 failed"
6392 start_mdt 1 > /dev/null || error "start mdt1 failed"
6393 for i in $(seq $OSTCOUNT); do
6394 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
6395 error "start ost$i failed"
6397 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
6398 check_mount || error "check client $MOUNT failed"
6401 $LFS setstripe -E 1M -S 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
6402 error "Create file with 3 components failed"
6403 $TRUNCATE $file $((1024*1024*64+1)) || error "truncate file failed"
6404 i=$($LFS getstripe -I3 -c $file) || error "get 3rd stripe count failed"
6405 if [ $i -ne $OSTCOUNT ]; then
6406 left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
6407 echo -n "Since only $i out $OSTCOUNT OSTs are used, "
6408 echo -n "the expected left space is changed to "
6409 echo "$left_size bytes at most."
6411 value=$(generate_string $left_size)
6412 setfattr -n $xtest -v $value $file
6413 orig=$(get_xattr_value $xtest $file)
6414 [[ "$orig" != "$value" ]] && error "$xtest changed"
6416 #Verify if inode has some expected space left
6417 umount $MOUNT > /dev/null || error "umount $MOUNT failed"
6418 stop_mdt 1 > /dev/null || error "stop mdt1 failed"
6419 mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
6421 do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
6422 used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
6424 [[ $used_xattr_blk -eq 0 ]] &&
6425 error "Please check MDS inode size calculation: \
6426 more than $left_size-byte space left in inode."
6427 echo "Verified: at most $left_size-byte space left in inode."
6429 unmount_ldiskfs $SINGLEMDS
6431 for i in $(seq $OSTCOUNT); do
6432 stop ost$i -f || error "stop ost$i failed"
6435 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
6438 [ "$mds1_FSTYPE" == zfs ] &&
6439 skip "LU-6662: no implementation for ZFS"
6443 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6444 --reformat $(mdsdevname 1) || error "add mds1 failed"
6446 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6447 grep -e \".*opts:.*errors=remount-ro.*\"" ||
6448 error "default mount options is missing"
6450 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6451 --mountfsoptions="user_xattr,errors=panic" \
6452 --reformat $(mdsdevname 1) || error "add mds1 failed"
6454 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6455 grep -e \".*opts:.*errors=panic.*\"" ||
6456 error "user can't override default mount options"
6458 run_test 88 "check the default mount options can be overridden"
6460 test_89() { # LU-7131
6461 [[ "$MDS1_VERSION" -ge $(version_code 2.9.54) ]] ||
6462 skip "Need MDT version at least 2.9.54"
6464 local key=failover.node
6465 local val1=192.0.2.254@tcp0 # Reserved IPs, see RFC 5735
6466 local val2=192.0.2.255@tcp0
6467 local mdsdev=$(mdsdevname 1)
6472 [ "$mds1_FSTYPE" == zfs ] && import_zpool mds1
6473 # Check that parameters are added correctly
6474 echo "tunefs --param $key=$val1"
6475 do_facet mds "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
6476 error "tunefs --param $key=$val1 failed"
6477 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6478 error "tunefs --dryrun failed"
6479 params=${params##*Parameters:}
6480 params=${params%%exiting*}
6481 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val1) = "1" ] ||
6482 error "on-disk parameter not added correctly via tunefs"
6484 # Check that parameters replace existing instances when added
6485 echo "tunefs --param $key=$val2"
6486 do_facet mds "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
6487 error "tunefs --param $key=$val2 failed"
6488 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6489 error "tunefs --dryrun failed"
6490 params=${params##*Parameters:}
6491 params=${params%%exiting*}
6492 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "1" ] ||
6493 error "on-disk parameter not replaced via tunefs"
6494 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val2) = "1" ] ||
6495 error "on-disk parameter not replaced correctly via tunefs"
6497 # Check that a parameter is erased properly
6498 echo "tunefs --erase-param $key"
6499 do_facet mds "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
6500 error "tunefs --erase-param $key failed"
6501 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6502 error "tunefs --dryrun failed"
6503 params=${params##*Parameters:}
6504 params=${params%%exiting*}
6505 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "0" ] ||
6506 error "on-disk parameter not erased correctly via tunefs"
6508 # Check that all the parameters are erased
6509 echo "tunefs --erase-params"
6510 do_facet mds "$TUNEFS --erase-params $mdsdev >/dev/null" ||
6511 error "tunefs --erase-params failed"
6512 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6513 error "tunefs --dryrun failed"
6514 params=${params##*Parameters:}
6515 params=${params%%exiting*}
6517 error "all on-disk parameters not erased correctly via tunefs"
6519 # Check the order of options --erase-params and --param
6520 echo "tunefs --param $key=$val1 --erase-params"
6522 "$TUNEFS --param $key=$val1 --erase-params $mdsdev >/dev/null"||
6523 error "tunefs --param $key=$val1 --erase-params failed"
6524 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6525 error "tunefs --dryrun failed"
6526 params=${params##*Parameters:}
6527 params=${params%%exiting*}
6528 [ $(echo $params | tr ' ' '\n') == "$key=$val1" ] ||
6529 error "on-disk param not added correctly with --erase-params"
6533 run_test 89 "check tunefs --param and --erase-param{s} options"
6536 # $2 (optional) value of max_mod_rpcs_in_flight to set
6537 check_max_mod_rpcs_in_flight() {
6545 idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
6546 facet="mds$((0x$idx + 1))"
6548 if [ -z "$mmr" ]; then
6549 # get value of max_mod_rcps_in_flight
6550 mmr=$($LCTL get_param -n \
6551 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
6552 error "Unable to get max_mod_rpcs_in_flight"
6553 echo "max_mod_rcps_in_flight is $mmr"
6555 # set value of max_mod_rpcs_in_flight
6557 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
6558 error "Unable to set max_mod_rpcs_in_flight to $mmr"
6559 echo "max_mod_rpcs_in_flight set to $mmr"
6562 # create mmr+1 files
6563 echo "creating $((mmr + 1)) files ..."
6565 for i in $(seq $((mmr + 1))); do
6571 # consumes mmr-1 modify RPC slots
6572 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6573 # drop requests on MDT so that RPC slots are consumed
6574 # during all the request resend interval
6575 do_facet $facet "$LCTL set_param fail_loc=0x159"
6576 echo "launch $((mmr - 1)) chmod in parallel ..."
6577 for i in $(seq $((mmr - 1))); do
6578 chmod 0600 $dir/file-$i &
6582 # send one additional modify RPC
6583 do_facet $facet "$LCTL set_param fail_loc=0"
6584 echo "launch 1 additional chmod in parallel ..."
6585 chmod 0600 $dir/file-$mmr &
6588 # check this additional modify RPC get a modify RPC slot
6589 # and succeed its operation
6590 checkstat -vp 0600 $dir/file-$mmr ||
6591 error "Unable to send $mmr modify RPCs in parallel"
6596 # consumes mmr modify RPC slots
6597 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6598 # drop requests on MDT so that RPC slots are consumed
6599 # during all the request resend interval
6600 do_facet $facet "$LCTL set_param fail_loc=0x159"
6601 echo "launch $mmr chmod in parallel ..."
6602 for i in $(seq $mmr); do
6603 chmod 0666 $dir/file-$i &
6607 # send one additional modify RPC
6608 do_facet $facet "$LCTL set_param fail_loc=0"
6609 echo "launch 1 additional chmod in parallel ..."
6610 chmod 0666 $dir/file-$((mmr + 1)) &
6613 # check this additional modify RPC blocked getting a modify RPC slot
6614 checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
6615 error "Unexpectedly send $(($mmr + 1)) modify RPCs in parallel"
6622 [[ $($LCTL get_param mdc.*.import |
6623 grep "connect_flags:.*multi_mod_rpc") ]] ||
6624 skip "Need MDC with 'multi_mod_rpcs' feature"
6626 # check default value
6627 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6628 check_max_mod_rpcs_in_flight $DIR/$tdir
6632 run_test 90a "check max_mod_rpcs_in_flight is enforced"
6642 [[ $($LCTL get_param mdc.*.import |
6643 grep "connect_flags:.*multi_mod_rpc") ]] ||
6644 skip "Need MDC with 'multi_mod_rpcs' feature"
6647 # update max_mod_rpcs_in_flight
6648 $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
6649 check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
6652 # check client is able to send multiple modify RPCs in paralell
6653 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6654 grep -c "multi_mod_rpcs")
6655 if [ "$tmp" -ne $MDSCOUNT ]; then
6657 skip "Client not able to send multiple modify RPCs in parallel"
6660 # update max_mod_rpcs_in_flight
6661 $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
6662 check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
6665 $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
6666 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
6667 facet="mds$((0x$idx + 1))"
6669 # save MDT max_mod_rpcs_per_client
6670 mmrpc=$(do_facet $facet \
6671 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6673 # update max_mod_rpcs_in_flight
6674 umount_client $MOUNT
6676 "echo 16 > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6678 $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
6679 check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
6681 # restore MDT max_mod_rpcs_per_client initial value
6683 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6685 rm -rf $DIR/${tdir}?
6688 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
6691 # get max_rpcs_in_flight value
6692 mrif_90c=$($LCTL get_param -n \
6693 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6694 echo "max_rpcs_in_flight is $mrif_90c"
6696 # get max_mod_rpcs_in_flight value
6697 mmrif_90c=$($LCTL get_param -n \
6698 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight)
6699 echo "max_mod_rpcs_in_flight is $mmrif_90c"
6701 # get MDT max_mod_rpcs_per_client value
6702 mmrpc_90c=$(do_facet mds1 \
6703 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6704 echo "max_mod_rpcs_per_client is $mmrpc_90c"
6707 restore_params_90c() {
6710 # restore max_rpcs_in_flight value
6711 do_facet mgs $LCTL set_param -P \
6712 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
6714 # restore max_mod_rpcs_in_flight value
6715 do_facet mgs $LCTL set_param -P \
6716 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mmrif_90c
6718 # restore MDT max_mod_rpcs_per_client value
6719 do_facet mds1 "echo $mmrpc_90c > \
6720 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6728 [[ $($LCTL get_param mdc.*.import |
6729 grep "connect_flags:.*multi_mod_rpc") ]] ||
6730 skip "Need MDC with 'multi_mod_rpcs' feature"
6732 # check client is able to send multiple modify RPCs in paralell
6733 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6734 grep -c "multi_mod_rpcs")
6735 if [ "$tmp" -ne $MDSCOUNT ]; then
6737 skip "Client not able to send multiple modify RPCs in parallel"
6741 stack_trap restore_params_90c
6744 # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
6745 # prerequisite: set max_mod_rpcs_per_client to max_rpcs_in_flight value
6746 do_facet mds1 "echo $mrif_90c > \
6747 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6749 # if max_mod_rpcs_in_flight is set to be equal to or larger than
6750 # max_rpcs_in_flight, then max_rpcs_in_flight will be increased
6751 if [[ "$CLIENT_VERSION" -ge $(version_code 2.13.53) ]]; then
6753 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c ||
6754 error "set max_mod_rpcs_in_flight to $mrif_90c failed"
6756 local new_mrif=$($LCTL get_param -n \
6757 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6758 ((new_mrif == mrif_90c + 1)) ||
6759 error "max_rpcs_in_flight was not increased"
6762 umount_client $MOUNT
6763 do_facet mds1 "echo $mmrpc_90c > \
6764 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6768 # attempt to set max_mod_rpcs_in_flight to max_mod_rpcs_per_client+1
6769 # prerequisite: set max_rpcs_in_flight to max_mod_rpcs_per_client+2
6771 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc_90c + 2))
6774 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc_90c + 1)) &&
6775 error "set max_mod_rpcs_in_flight to $((mmrpc_90c + 1)) should fail"
6778 # attempt to set max_mod_rpcs_in_flight permanently
6779 do_facet mgs $LCTL set_param -P \
6780 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
6782 do_facet mgs $LCTL set_param -P \
6783 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c
6785 remount_client $MOUNT
6787 wait_update_facet --verbose client "$LCTL get_param -n \
6788 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight" \
6789 "$((mrif_90c + 1))" ||
6790 error "expected '$((mrif_90c + 1))' for max_rpcs_in_flight"
6792 wait_update_facet --verbose client "$LCTL get_param -n \
6793 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight" \
6795 error "expected '$mrif_90c' for max_mod_rpcs_in_flight"
6800 run_test 90c "check max_mod_rpcs_in_flight update limits"
6811 [[ $($LCTL get_param mdc.*.import |
6812 grep "connect_flags:.*multi_mod_rpc") ]] ||
6813 skip "Need MDC with 'multi_mod_rpcs' feature"
6815 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6816 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
6817 facet="mds$((0x$idx + 1))"
6819 # check client version supports multislots
6820 tmp=$($LCTL get_param -N \
6821 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6822 if [ -z "$tmp" ]; then
6824 skip "Client does not support multiple modify RPCs in flight"
6827 # get current value of max_mod_rcps_in_flight
6828 mmr=$($LCTL get_param -n \
6829 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6830 echo "max_mod_rcps_in_flight is $mmr"
6833 echo "creating $mmr files ..."
6835 for i in $(seq $mmr); do
6836 touch $DIR/$tdir/file-$i
6839 # prepare for close RPC
6840 multiop_bg_pause $DIR/$tdir/file-close O_c
6843 # consumes mmr modify RPC slots
6844 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6845 # drop requests on MDT so that RPC slots are consumed
6846 # during all the request resend interval
6847 do_facet $facet "$LCTL set_param fail_loc=0x159"
6848 echo "launch $mmr chmod in parallel ..."
6849 for i in $(seq $mmr); do
6850 chmod 0600 $DIR/$tdir/file-$i &
6853 # send one additional close RPC
6854 do_facet $facet "$LCTL set_param fail_loc=0"
6855 echo "launch 1 additional close in parallel ..."
6857 cancel_lru_locks mdc
6860 # check this additional close RPC get a modify RPC slot
6861 # and multiop process completed
6862 [ -d /proc/$pid ] &&
6863 error "Unable to send the additional close RPC in parallel"
6868 run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
6870 check_uuid_on_ost() {
6872 do_facet ost1 "$LCTL get_param obdfilter.${FSNAME}*.exports.'$nid'.uuid"
6875 check_uuid_on_mdt() {
6877 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6885 [[ "$OST1_VERSION" -ge $(version_code 2.7.63) ]] ||
6886 skip "Need OST version at least 2.7.63"
6887 [[ "$MDS1_VERSION" -ge $(version_code 2.7.63) ]] ||
6888 skip "Need MDT version at least 2.7.63"
6890 start_mds || error "MDS start failed"
6891 start_ost || error "unable to start OST"
6892 mount_client $MOUNT || error "client start failed"
6893 check_mount || error "check_mount failed"
6896 nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
6900 uuid=$(get_client_uuid $MOUNT)
6902 echo "list nids on mdt:"
6903 do_facet $SINGLEMDS "$LCTL list_param mdt.${FSNAME}*.exports.*"
6904 echo "uuid from $nid:"
6905 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6907 found=$(check_uuid_on_mdt $nid | grep $uuid)
6908 [ -z "$found" ] && error "can't find $uuid $nid on MDT"
6909 found=$(check_uuid_on_ost $nid | grep $uuid)
6910 [ -z "$found" ] && error "can't find $uuid $nid on OST"
6912 # umount the client so it won't reconnect
6913 manual_umount_client --force || error "failed to umount $?"
6914 # shouldn't disappear on MDS after forced umount
6915 found=$(check_uuid_on_mdt $nid | grep $uuid)
6916 [ -z "$found" ] && error "can't find $uuid $nid"
6919 do_facet $SINGLEMDS \
6920 "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
6922 found=$(check_uuid_on_mdt $nid | grep $uuid)
6923 [ -n "$found" ] && error "found $uuid $nid on MDT"
6924 found=$(check_uuid_on_ost $nid | grep $uuid)
6925 [ -n "$found" ] && error "found $uuid $nid on OST"
6927 # check it didn't reconnect (being umounted)
6928 sleep $((TIMEOUT+1))
6929 found=$(check_uuid_on_mdt $nid | grep $uuid)
6930 [ -n "$found" ] && error "found $uuid $nid on MDT"
6931 found=$(check_uuid_on_ost $nid | grep $uuid)
6932 [ -n "$found" ] && error "found $uuid $nid on OST"
6936 run_test 91 "evict-by-nid support"
6938 generate_ldev_conf() {
6939 # generate an ldev.conf file
6940 local ldevconfpath=$1
6942 local fsldevformat=""
6945 fstype=$(facet_fstype mgs)
6946 if [ "$fstype" == zfs ]; then
6947 fsldevformat="$fstype:"
6952 printf "%s\t-\t%s-MGS0000\t%s%s\n" \
6956 $(mgsdevname) > $ldevconfpath
6958 local mdsfo_host=$mdsfailover_HOST;
6959 if [ -z "$mdsfo_host" ]; then
6963 for num in $(seq $MDSCOUNT); do
6964 fstype=$(facet_fstype mds$num)
6965 if [ "$fstype" == zfs ]; then
6966 fsldevformat="$fstype:"
6971 printf "%s\t%s\t%s-MDT%04d\t%s%s\n" \
6977 $(mdsdevname $num) >> $ldevconfpath
6980 local ostfo_host=$ostfailover_HOST;
6981 if [ -z "$ostfo_host" ]; then
6985 for num in $(seq $OSTCOUNT); do
6986 fstype=$(facet_fstype ost$num)
6987 if [ "$fstype" == zfs ]; then
6988 fsldevformat="$fstype:"
6993 printf "%s\t%s\t%s-OST%04d\t%s%s\n" \
6999 $(ostdevname $num) >> $ldevconfpath
7002 echo "----- $ldevconfpath -----"
7004 echo "--- END $ldevconfpath ---"
7009 # generate a nids file (mapping between hostname to nid)
7010 # looks like we only have the MGS nid available to us
7011 # so just echo that to a file
7013 echo -e "${mgs_HOST}\t${MGSNID}" > $nidspath
7015 echo "----- $nidspath -----"
7017 echo "--- END $nidspath ---"
7020 compare_ldev_output() {
7024 sort $expected_output -o $expected_output
7025 sort $ldev_output -o $ldev_output
7027 echo "-- START OF LDEV OUTPUT --"
7029 echo "--- END OF LDEV OUTPUT ---"
7031 echo "-- START OF EXPECTED OUTPUT --"
7032 cat $expected_output
7033 echo "--- END OF EXPECTED OUTPUT ---"
7035 diff $expected_output $ldev_output
7040 if [ -z "$LDEV" ]; then
7041 error "ldev is missing!"
7044 local LDEVCONFPATH=$TMP/ldev.conf
7045 local NIDSPATH=$TMP/nids
7047 echo "Host is $(hostname)"
7049 generate_ldev_conf $LDEVCONFPATH
7050 generate_nids $NIDSPATH
7052 # echo the mgs nid and compare it to environment variable MGSNID
7053 # also, ldev.conf and nids is a server side thing, use the OSS
7056 output=$($LDEV -c $LDEVCONFPATH -H $ost_HOST -n $NIDSPATH echo %m)
7058 echo "-- START OF LDEV OUTPUT --"
7060 echo "--- END OF LDEV OUTPUT ---"
7062 # ldev failed, error
7063 if [ $? -ne 0 ]; then
7064 rm $LDEVCONFPATH $NIDSPATH
7065 error "ldev failed to execute!"
7068 # need to process multiple lines because of combined MGS and MDS
7069 echo -e $output | awk '{ print $2 }' | while read -r line ; do
7070 if [ "$line" != "$MGSNID" ]; then
7071 rm $LDEVCONFPATH $NIDSPATH
7072 error "ldev failed mgs nid '$line', expected '$MGSNID'"
7076 rm $LDEVCONFPATH $NIDSPATH
7078 run_test 92 "ldev returns MGS NID correctly in command substitution"
7081 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
7084 #start mgs or mgs/mdt0
7085 if ! combined_mgs_mds ; then
7092 start_ost || error "OST0 start fail"
7094 #define OBD_FAIL_MGS_WRITE_TARGET_DELAY 0x90e
7095 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x8000090e"
7096 for num in $(seq 2 $MDSCOUNT); do
7100 mount_client $MOUNT || error "mount client fails"
7101 wait_osc_import_state mds ost FULL
7102 wait_osc_import_ready client ost
7103 check_mount || error "check_mount failed"
7105 cleanup || error "cleanup failed with $?"
7107 run_test 93 "register mulitple MDT at the same time"
7110 if [ -z "$LDEV" ]; then
7111 error "ldev is missing!"
7114 local LDEVCONFPATH=$TMP/ldev.conf
7115 local NIDSPATH=$TMP/nids
7117 generate_ldev_conf $LDEVCONFPATH
7118 generate_nids $NIDSPATH
7120 local LDEV_OUTPUT=$TMP/ldev-output.txt
7121 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME > $LDEV_OUTPUT
7123 # ldev failed, error
7124 if [ $? -ne 0 ]; then
7125 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7126 error "ldev failed to execute!"
7130 local EXPECTED_OUTPUT=$TMP/ldev-expected.txt
7132 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7134 for num in $(seq $MDSCOUNT); do
7135 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7138 for num in $(seq $OSTCOUNT); do
7139 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7142 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7144 if [ $? -ne 0 ]; then
7145 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7146 error "ldev failed to produce the correct hostlist!"
7149 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7151 run_test 94 "ldev outputs correct labels for file system name query"
7154 if [ -z "$LDEV" ]; then
7155 error "ldev is missing!"
7158 local LDEVCONFPATH=$TMP/ldev.conf
7159 local NIDSPATH=$TMP/nids
7161 generate_ldev_conf $LDEVCONFPATH
7162 generate_nids $NIDSPATH
7166 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME &>/dev/null
7167 if [ $? -ne 0 ]; then
7168 rm $LDEVCONFPATH $NIDSPATH
7169 error "ldev label filtering w/ -F failed!"
7173 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -l &>/dev/null
7174 if [ $? -ne 0 ]; then
7175 rm $LDEVCONFPATH $NIDSPATH
7176 error "ldev label filtering w/ -l failed!"
7180 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f &>/dev/null
7181 if [ $? -ne 0 ]; then
7182 rm $LDEVCONFPATH $NIDSPATH
7183 error "ldev label filtering w/ -f failed!"
7187 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a &>/dev/null
7188 if [ $? -ne 0 ]; then
7189 rm $LDEVCONFPATH $NIDSPATH
7190 error "ldev label filtering w/ -a failed!"
7195 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -F $FSNAME &>/dev/null
7196 if [ $? -eq 0 ]; then
7197 rm $LDEVCONFPATH $NIDSPATH
7198 error "ldev label filtering w/ -a and -F incorrectly succeeded"
7202 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -f &>/dev/null
7203 if [ $? -eq 0 ]; then
7204 rm $LDEVCONFPATH $NIDSPATH
7205 error "ldev label filtering w/ -a and -f incorrectly succeeded"
7209 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -l &>/dev/null
7210 if [ $? -eq 0 ]; then
7211 rm $LDEVCONFPATH $NIDSPATH
7212 error "ldev label filtering w/ -a and -l incorrectly succeeded"
7216 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f -l &>/dev/null
7217 if [ $? -eq 0 ]; then
7218 rm $LDEVCONFPATH $NIDSPATH
7219 error "ldev label filtering w/ -f and -l incorrectly succeeded"
7223 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -l &>/dev/null
7224 if [ $? -eq 0 ]; then
7225 rm $LDEVCONFPATH $NIDSPATH
7226 error "ldev label filtering w/ -F and -l incorrectly succeeded"
7229 # file sys & foreign
7230 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -f &>/dev/null
7231 if [ $? -eq 0 ]; then
7232 rm $LDEVCONFPATH $NIDSPATH
7233 error "ldev label filtering w/ -F and -f incorrectly succeeded"
7236 rm $LDEVCONFPATH $NIDSPATH
7238 run_test 95 "ldev should only allow one label filter"
7241 if [ -z "$LDEV" ]; then
7242 error "ldev is missing!"
7245 local LDEVCONFPATH=$TMP/ldev.conf
7246 local NIDSPATH=$TMP/nids
7248 generate_ldev_conf $LDEVCONFPATH
7249 generate_nids $NIDSPATH
7251 local LDEV_OUTPUT=$TMP/ldev-output.txt
7252 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -H $mgs_HOST \
7254 awk '{print $2}' > $LDEV_OUTPUT
7256 # ldev failed, error
7257 if [ $? -ne 0 ]; then
7258 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7259 error "ldev failed to execute!"
7263 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7265 echo "$mgs_HOST-$(facet_fstype mgs)" > $EXPECTED_OUTPUT
7267 if [ "$mgs_HOST" == "$mds_HOST" ]; then
7268 for num in $(seq $MDSCOUNT); do
7269 echo "$mds_HOST-$(facet_fstype mds$num)" \
7274 if [ "$mgs_HOST" == "$ost_HOST" ]; then
7275 for num in $(seq $OSTCOUNT); do
7276 echo "$ost_HOST-$(facet_fstype ost$num)" \
7281 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7283 if [ $? -ne 0 ]; then
7284 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7285 error "ldev failed to produce the correct output!"
7288 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7290 run_test 96 "ldev returns hostname and backend fs correctly in command sub"
7293 if [ -z "$LDEV" ]; then
7294 error "ldev is missing!"
7297 local LDEVCONFPATH=$TMP/ldev.conf
7298 local NIDSPATH=$TMP/nids
7300 generate_ldev_conf $LDEVCONFPATH
7301 generate_nids $NIDSPATH
7303 local LDEV_OUTPUT=$TMP/ldev-output.txt
7304 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7306 echo -e "\nMDT role"
7307 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mdt > $LDEV_OUTPUT
7309 if [ $? -ne 0 ]; then
7310 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7311 error "ldev failed to execute for mdt role!"
7314 for num in $(seq $MDSCOUNT); do
7315 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7318 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7320 if [ $? -ne 0 ]; then
7321 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7322 error "ldev failed to produce the correct output for mdt role!"
7325 echo -e "\nOST role"
7326 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R ost > $LDEV_OUTPUT
7328 if [ $? -ne 0 ]; then
7329 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7330 error "ldev failed to execute for ost role!"
7334 for num in $(seq $OSTCOUNT); do
7335 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7338 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7340 if [ $? -ne 0 ]; then
7341 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7342 error "ldev failed to produce the correct output for ost role!"
7345 echo -e "\nMGS role"
7346 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mgs > $LDEV_OUTPUT
7348 if [ $? -ne 0 ]; then
7349 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7350 error "ldev failed to execute for mgs role!"
7353 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7355 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7357 if [ $? -ne 0 ]; then
7358 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7359 error "ldev failed to produce the correct output for mgs role!"
7362 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7364 run_test 97 "ldev returns correct ouput when querying based on role"
7369 local temp=$MDS_MOUNT_OPTS
7372 check_mount || error "mount failed"
7373 mountopt="user_xattr"
7374 for ((x = 1; x <= 400; x++)); do
7375 mountopt="$mountopt,user_xattr"
7377 mount_client $MOUNT remount,$mountopt 2>&1 | grep "too long" ||
7378 error "Buffer overflow check failed"
7379 cleanup || error "cleanup failed"
7381 run_test 98 "Buffer-overflow check while parsing mount_opts"
7385 [[ "$ost1_FSTYPE" != ldiskfs ]] &&
7386 skip "ldiskfs only test"
7387 [[ "$OST1_VERSION" -ge $(version_code 2.8.57) ]] ||
7388 skip "Need OST version at least 2.8.57"
7390 local ost_opts="$(mkfs_opts ost1 $(ostdevname 1)) \
7391 --reformat $(ostdevname 1) $(ostvdevname 1)"
7392 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" &&
7393 skip "meta_bg already set"
7396 if [[ ${!opts} != *mkfsoptions* ]]; then
7397 eval opts=\"${!opts} \
7398 --mkfsoptions='\\\"-O ^resize_inode,meta_bg\\\"'\"
7400 local val=${!opts//--mkfsoptions=\\\"/ \
7401 --mkfsoptions=\\\"-O ^resize_inode,meta_bg }
7405 echo "params: $opts"
7408 add ost1 $opts || error "add ost1 failed with new params"
7410 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" ||
7411 error "meta_bg is not set"
7413 run_test 99 "Adding meta_bg option"
7418 start_mgsmds || error "MDS start failed"
7419 start_ost || error "unable to start OST"
7420 mount_client $MOUNT || error "client start failed"
7421 check_mount || error "check_mount failed"
7430 do_facet mgs 'lshowmount -v' | awk 'BEGIN {NR == 0; rc=1} /MGS:/ {rc=0}
7431 END {exit rc}' || error "lshowmount have no output MGS"
7433 do_facet mds1 'lshowmount -v' | awk 'BEGIN {NR == 2; rc=1} /-MDT0000:/
7434 {rc=0} END {exit rc}' || error "lshowmount have no output MDT0"
7436 do_facet ost1 'lshowmount -v' | awk 'BEGIN {NR == 4; rc=1} /-OST0000:/
7437 {rc=0} END {exit rc}' || error "lshowmount have no output OST0"
7439 cleanup || error "cleanup failed with $?"
7441 run_test 100 "check lshowmount lists MGS, MDT, OST and 0@lo"
7444 local createmany_pid
7445 local dev=$FSNAME-OST0000-osc-MDT0000
7449 createmany -o $DIR1/$tdir/$tfile-%d 50000 &
7451 # MDT->OST reconnection causes MDT<->OST last_id synchornisation
7452 # via osp_precreate_cleanup_orphans.
7453 for ((i = 0; i < 100; i++)); do
7454 for ((k = 0; k < 10; k++)); do
7455 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;" \
7456 "$LCTL --device $dev activate"
7459 ls -asl $MOUNT | grep '???' &&
7460 { kill -9 $createmany_pid &>/dev/null;
7461 error "File has no object on OST"; }
7463 kill -s 0 $createmany_pid || break
7465 wait $createmany_pid
7467 unlinkmany $DIR1/$tdir/$tfile-%d 50000
7470 run_test 101 "Race MDT->OST reconnection with create"
7473 [[ "$MDS1_VERSION" -gt $(version_code 2.9.53) ]] ||
7474 skip "Need server version greater than 2.9.53"
7475 [[ “$(mdsdevname 1)” != “$(mgsdevname)” ]] &&
7476 [[ “$(facet_host mds1)” = “$(facet_host mgs)” ]] &&
7477 skip "MGS must be on different node or combined"
7479 cleanup || error "cleanup failed with $?"
7481 local mds1dev=$(mdsdevname 1)
7482 local mds1mnt=$(facet_mntpt mds1)
7483 local mds1opts=$MDS_MOUNT_OPTS
7485 if [ "$mds1_FSTYPE" == ldiskfs ] &&
7486 ! do_facet mds1 test -b $mds1dev; then
7487 mds1opts=$(csa_add "$mds1opts" -o loop)
7489 if [[ "$mds1_FSTYPE" == zfs ]]; then
7490 import_zpool mds1 || return ${PIPESTATUS[0]}
7493 # unload all and only load libcfs to allow fail_loc setting
7494 do_facet mds1 $LUSTRE_RMMOD || error "unable to unload modules"
7495 do_facet mds1 modprobe libcfs || error "libcfs not loaded"
7496 do_facet mds1 lsmod \| grep libcfs || error "libcfs not loaded"
7498 #define OBD_FAIL_OBDCLASS_MODULE_LOAD 0x60a
7499 do_facet mds1 "$LCTL set_param fail_loc=0x8000060a"
7501 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
7502 error "mdt start must fail"
7503 do_facet mds1 lsmod \| grep obdclass && error "obdclass must not load"
7505 do_facet mds1 "$LCTL set_param fail_loc=0x0"
7507 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts ||
7508 error "mdt start must not fail"
7510 cleanup || error "cleanup failed with $?"
7512 run_test 102 "obdclass module cleanup upon error"
7517 echo "rename $FSNAME to $newname"
7519 if ! combined_mgs_mds ; then
7520 local dev=$(mgsdevname)
7523 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7524 error "(7) Fail to rename MGS"
7525 if [ "$(facet_fstype mgs)" = "zfs" ]; then
7526 reimport_zpool mgs $newname-mgs
7530 for num in $(seq $MDSCOUNT); do
7531 local dev=$(mdsdevname $num)
7533 do_facet mds${num} \
7534 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7535 error "(8) Fail to rename MDT $num"
7536 if [ "$(facet_fstype mds${num})" = "zfs" ]; then
7537 reimport_zpool mds${num} $newname-mdt${num}
7541 for num in $(seq $OSTCOUNT); do
7542 local dev=$(ostdevname $num)
7544 do_facet ost${num} \
7545 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7546 error "(9) Fail to rename OST $num"
7547 if [ "$(facet_fstype ost${num})" = "zfs" ]; then
7548 reimport_zpool ost${num} $newname-ost${num}
7553 test_103_set_pool() {
7557 do_facet mgs $LCTL pool_add $FSNAME.$pname ${FSNAME}-$ost_x ||
7558 error "Fail to add $ost_x to $FSNAME.$pname"
7559 wait_update $HOSTNAME \
7560 "lctl get_param -n lov.$FSNAME-clilov-*.pools.$pname |
7561 grep $ost_x" "$FSNAME-${ost_x}_UUID" ||
7562 error "$ost_x is NOT in pool $FSNAME.$pname"
7565 test_103_check_pool() {
7566 local save_fsname=$1
7569 stat $DIR/$tdir/test-framework.sh ||
7570 error "($errno) Fail to stat"
7571 do_facet mgs $LCTL pool_list $FSNAME.pool1 ||
7572 error "($errno) Fail to list $FSNAME.pool1"
7573 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname ||
7574 error "($errno) Fail to list $FSNAME.$save_fsname"
7575 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname |
7576 grep ${FSNAME}-OST0000 ||
7577 error "($errno) List $FSNAME.$save_fsname is invalid"
7579 local pname=$($LFS getstripe --pool $DIR/$tdir/d0)
7580 [ "$pname" = "$save_fsname" ] ||
7581 error "($errno) Unexpected pool name $pname"
7585 check_mount_and_prep
7587 mkdir $DIR/$tdir || error "(1) Fail to mkdir $DIR/$tdir"
7588 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir ||
7589 error "(2) Fail to copy test-framework.sh"
7591 do_facet mgs $LCTL pool_new $FSNAME.pool1 ||
7592 error "(3) Fail to create $FSNAME.pool1"
7593 # name the pool name as the fsname
7594 do_facet mgs $LCTL pool_new $FSNAME.$FSNAME ||
7595 error "(4) Fail to create $FSNAME.$FSNAME"
7597 test_103_set_pool $FSNAME OST0000
7599 $LFS setstripe -p $FSNAME $DIR/$tdir/d0 ||
7600 error "(6) Fail to setstripe on $DIR/$tdir/d0"
7605 test_renamefs mylustre
7607 local save_fsname=$FSNAME
7611 test_103_check_pool $save_fsname 7
7613 if [ $OSTCOUNT -ge 2 ]; then
7614 test_103_set_pool $save_fsname OST0001
7617 $LFS setstripe -p $save_fsname $DIR/$tdir/f0 ||
7618 error "(16) Fail to setstripe on $DIR/$tdir/f0"
7627 test_103_check_pool $save_fsname 17
7631 test_renamefs $save_fsname
7637 run_test 103 "rename filesystem name"
7639 test_104a() { # LU-6952
7640 local mds_mountopts=$MDS_MOUNT_OPTS
7641 local ost_mountopts=$OST_MOUNT_OPTS
7642 local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
7643 local lctl_ver=$(do_facet $SINGLEMDS $LCTL --version |
7646 [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
7647 skip "this test needs utils above 2.9.55"
7649 # specify "acl" in mount options used by mkfs.lustre
7650 if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
7651 MDS_MOUNT_FS_OPTS="acl,user_xattr"
7654 MDS_MOUNT_FS_OPTS="${MDS_MOUNT_FS_OPTS},acl,user_xattr"
7657 echo "mountfsopt: $MDS_MOUNT_FS_OPTS"
7659 #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
7661 if ! combined_mgs_mds ; then
7665 if [ -z "$MDS_MOUNT_OPTS" ]; then
7666 MDS_MOUNT_OPTS="-o noacl"
7668 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7671 for num in $(seq $MDSCOUNT); do
7672 start mds$num $(mdsdevname $num) $MDS_MOUNT_OPTS ||
7673 error "Failed to start MDS"
7676 for num in $(seq $OSTCOUNT); do
7677 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
7678 error "Failed to start OST"
7682 setfacl -m "d:$RUNAS_ID:rwx" $MOUNT &&
7683 error "ACL is applied when FS is mounted with noacl."
7685 MDS_MOUNT_OPTS=$mds_mountopts
7686 OST_MOUNT_OPTS=$ost_mountopts
7687 MDS_MOUNT_FS_OPTS=$mds_mountfsopts
7689 run_test 104a "Make sure user defined options are reflected in mount"
7691 test_104b() { # LU-12859
7692 mount_client $MOUNT3 flock,localflock
7693 stack_trap "umount_client $MOUNT3" EXIT
7694 mount | grep "$MOUNT3 .*,flock" && error "flock is still set"
7695 mount | grep "$MOUNT3 .*,localflock" || error "localflock is not set"
7696 umount_client $MOUNT3
7697 mount_client $MOUNT3 localflock,flock
7698 mount | grep "$MOUNT3 .*,localflock" && error "localflock is still set"
7699 mount | grep "$MOUNT3 .*,flock" || error "flock is not set"
7700 umount_client $MOUNT3
7701 mount_client $MOUNT3 localflock,flock,noflock
7702 flock_is_enabled $MOUNT3 && error "some flock is still enabled" || true
7704 run_test 104b "Mount uses last flock argument"
7706 error_and_umount() {
7717 mount --bind $DIR $TMP/$tdir || error "mount bind mnt pt failed"
7718 rm -f $TMP/$tdir/$tfile
7719 rm -f $TMP/$tdir/${tfile}1
7721 # Files should not be created in ro bind mount point
7722 # remounting from rw to ro
7723 mount -o remount,ro $TMP/$tdir ||
7724 error_and_umount "readonly remount of bind mnt pt failed"
7725 touch $TMP/$tdir/$tfile &&
7726 error_and_umount "touch succeeds on ro bind mnt pt"
7727 [ -e $TMP/$tdir/$tfile ] &&
7728 error_and_umount "file created on ro bind mnt pt"
7730 # Files should be created in rw bind mount point
7731 # remounting from ro to rw
7732 mount -o remount,rw $TMP/$tdir ||
7733 error_and_umount "read-write remount of bind mnt pt failed"
7734 touch $TMP/$tdir/${tfile}1 ||
7735 error_and_umount "touch fails on rw bind mnt pt"
7736 [ -e $TMP/$tdir/${tfile}1 ] ||
7737 error_and_umount "file not created on rw bind mnt pt"
7738 umount $TMP/$tdir || error "umount of bind mnt pt failed"
7740 cleanup || error "cleanup failed with $?"
7742 run_test 105 "check file creation for ro and rw bind mnt pt"
7749 mkdir -p $DIR/$tdir || error "create $tdir failed"
7750 lfs setstripe -c 1 -i 0 $DIR/$tdir
7751 #define OBD_FAIL_CAT_RECORDS 0x1312
7752 do_facet mds1 $LCTL set_param fail_loc=0x1312 fail_val=$repeat
7754 for ((i = 1; i <= $repeat; i++)); do
7756 #one full plain llog
7757 createmany -o $DIR/$tdir/f- 64768
7759 createmany -u $DIR/$tdir/f- 64768
7761 wait_delete_completed $((TIMEOUT * 7))
7762 #ASSERTION osp_sync_thread() ( thread->t_flags != SVC_RUNNING ) failed
7763 #shows that osp code is buggy
7764 do_facet mds1 $LCTL set_param fail_loc=0 fail_val=0
7768 run_test 106 "check osp llog processing when catalog is wrapped"
7771 [[ "$MDS1_VERSION" -ge $(version_code 2.10.50) ]] ||
7772 skip "Need MDS version > 2.10.50"
7775 start_mgsmds || error "start_mgsmds failed"
7776 start_ost || error "unable to start OST"
7778 # add unknown configuration parameter.
7779 if [[ $PERM_CMD == *"set_param -P"* ]]; then
7780 cmd="$PERM_CMD ost.$FSNAME-OST0000*.unknown_param"
7782 cmd="$PERM_CMD $FSNAME-OST0000*.ost.unknown_param"
7784 do_facet mgs "$cmd=50"
7785 cleanup_nocli || error "cleanup_nocli failed with $?"
7788 # unknown param should be ignored while mounting.
7789 start_ost || error "unable to start OST after unknown param set"
7791 cleanup || error "cleanup failed with $?"
7793 run_test 107 "Unknown config param should not fail target mounting"
7798 $rcmd rm -rf $tmp > /dev/null 2>&1
7799 $rcmd mkdir -p $tmp/{mnt,images} || error "failed to mkdir remotely"
7801 for facet in $facets; do
7802 [ "$mds1_FSTYPE" = zfs ] &&
7803 $rcmd $ZPOOL -f export lustre-$facet > /dev/null 2>&1
7804 $rcmd mkdir $tmp/mnt/$facet ||
7805 error "failed to mkdir $tmp/mnt/$facet"
7806 $rcmd dd if=/dev/zero of=$tmp/images/$facet \
7807 seek=199 bs=1M count=1 ||
7808 error "failed to create $tmp/images/$facet"
7817 local facet=${role}$((idx + 1))
7819 [ $# -eq 5 ] && pool=$5
7821 do_facet $SINGLEMDS $MKFS --fsname=lustre --$mgs \
7822 --$role --index=$idx --replace --backfstype=$bkfs \
7823 --device-size=200000 --reformat $pool $tmp/images/$facet ||
7824 error "failed to mkfs for $facet"
7828 echo "mounting client..."
7829 mount -t lustre ${nid}:/lustre $MOUNT ||
7830 error "failed to mount lustre"
7833 ls -l $MOUNT/local_dir || error "failed to list"
7835 echo "check truncate && write"
7836 echo "dummmmmmmmmmmmm" > $MOUNT/remote_dir/fsx.c ||
7837 error "failed to tuncate & write"
7840 touch $MOUNT/foooo ||
7841 error "failed to create"
7843 echo "check read && write && append"
7844 sha1sum $MOUNT/conf-sanity.sh |
7845 awk '{ print $1 }' > $MOUNT/checksum.new ||
7846 error "failed to read(1)"
7847 sha1sum $MOUNT/remote_dir/unlinkmany.c |
7848 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7849 error "failed to read(2)"
7850 sha1sum $MOUNT/striped_dir/lockahead_test.o |
7851 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7852 error "failed to read(3)"
7855 diff $MOUNT/checksum.new $MOUNT/checksum.src ||
7856 error "failed to verify data"
7866 umount -f $MOUNT || error "failed to umount client"
7867 for facet in $facets; do
7868 $rcmd umount -f $tmp/mnt/$facet ||
7869 error "failed to umount $facet"
7870 if [ "$mds1_FSTYPE" = zfs ]; then
7871 $rcmd $ZPOOL export -f lustre-$facet ||
7872 error "failed to export lustre-$facet"
7876 $rcmd rm -rf $tmp || error "failed to rm the dir $tmp"
7880 [ "$CLIENTONLY" ] && skip "Client-only testing"
7881 [ "$mds1_FSTYPE" != zfs ] && skip "zfs only test"
7882 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
7883 skip "Need server version at least 2.10.58"
7888 local tmp=$TMP/$tdir
7889 local rcmd="do_facet $SINGLEMDS"
7890 local facets="mdt1 mdt2 ost1 ost2"
7891 local nid=$($rcmd $LCTL list_nids | head -1)
7894 trap t_108_cleanup EXIT ERR
7897 t_108_mkfs mdt 0 zfs mgs lustre-mdt1/mdt1
7898 t_108_mkfs mdt 1 zfs mgsnode=$nid lustre-mdt2/mdt2
7899 t_108_mkfs ost 0 zfs mgsnode=$nid lustre-ost1/ost1
7900 t_108_mkfs ost 1 zfs mgsnode=$nid lustre-ost2/ost2
7902 for facet in $facets; do
7903 $rcmd zfs set mountpoint=$tmp/mnt/$facet canmount=on \
7904 lustre-$facet/$facet ||
7905 error "failed to zfs set for $facet (1)"
7906 $rcmd zfs mount lustre-$facet/$facet ||
7907 error "failed to local mount $facet"
7908 $rcmd tar jxf $LUSTRE/tests/ldiskfs_${facet}_2_11.tar.bz2 \
7909 --xattrs --xattrs-include="trusted.*" \
7910 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7911 error "failed to untar image for $facet"
7912 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7913 error "failed to cleanup for $facet"
7914 $rcmd zfs umount lustre-$facet/$facet ||
7915 error "failed to local umount $facet"
7916 $rcmd zfs set canmount=off lustre-$facet/$facet ||
7917 error "failed to zfs set $facet (2)"
7920 echo "changing server nid..."
7921 $rcmd mount -t lustre -o nosvc lustre-mdt1/mdt1 $tmp/mnt/mdt1
7922 $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
7923 $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
7924 $rcmd lctl replace_nids $FSNAME-OST0000 $nid
7925 $rcmd lctl replace_nids $FSNAME-OST0001 $nid
7926 $rcmd umount $tmp/mnt/mdt1
7928 for facet in $facets; do
7929 echo "mounting $facet from backup..."
7930 $rcmd mount -t lustre -o abort_recov lustre-$facet/$facet \
7931 $tmp/mnt/$facet || error "failed to mount $facet"
7934 # ZFS backend can detect migration and trigger OI scrub automatically
7935 # sleep 3 seconds for scrub done
7941 run_test 108a "migrate from ldiskfs to ZFS"
7944 [ "$CLIENTONLY" ] && skip "Client-only testing"
7945 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
7946 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
7947 skip "Need server version at least 2.10.58"
7952 local tmp=$TMP/$tdir
7953 local rcmd="do_facet $SINGLEMDS"
7954 local facets="mdt1 mdt2 ost1 ost2"
7955 local scrub_list="MDT0000 MDT0001 OST0000 OST0001"
7956 local nid=$($rcmd $LCTL list_nids | head -1)
7959 trap t_108_cleanup EXIT ERR
7962 t_108_mkfs mdt 0 ldiskfs mgs
7963 t_108_mkfs mdt 1 ldiskfs mgsnode=$nid
7964 t_108_mkfs ost 0 ldiskfs mgsnode=$nid
7965 t_108_mkfs ost 1 ldiskfs mgsnode=$nid
7967 for facet in $facets; do
7968 $rcmd mount -t ldiskfs -o loop $tmp/images/$facet \
7970 error "failed to local mount $facet"
7972 $rcmd tar jxf $LUSTRE/tests/zfs_${facet}_2_11.tar.bz2 \
7973 --xattrs --xattrs-include="*.*" \
7974 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7975 error "failed to untar image for $facet"
7976 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7977 error "failed to cleanup for $facet"
7978 $rcmd umount $tmp/mnt/$facet ||
7979 error "failed to local umount $facet"
7982 echo "changing server nid..."
7983 $rcmd mount -t lustre -o nosvc,loop $tmp/images/mdt1 $tmp/mnt/mdt1
7984 $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
7985 $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
7986 $rcmd lctl replace_nids $FSNAME-OST0000 $nid
7987 $rcmd lctl replace_nids $FSNAME-OST0001 $nid
7988 $rcmd umount $tmp/mnt/mdt1
7990 for facet in $facets; do
7991 echo "mounting $facet from backup..."
7992 $rcmd mount -t lustre -o loop,abort_recov $tmp/images/$facet \
7993 $tmp/mnt/$facet || error "failed to mount $facet"
7996 for facet in $scrub_list; do
7997 $rcmd $LCTL lfsck_start -M $FSNAME-$facet -t scrub ||
7998 error "failed to start OI scrub on $facet"
8001 # sleep 3 seconds for scrub done
8007 run_test 108b "migrate from ZFS to ldiskfs"
8011 # set number of permanent parameters
8013 test_109_set_params() {
8016 set_persistent_param_and_check mds \
8017 "mdd.$fsname-MDT0000.atime_diff" \
8018 "$fsname-MDT0000.mdd.atime_diff" \
8020 set_persistent_param_and_check mds \
8021 "mdd.$fsname-MDT0000.atime_diff" \
8022 "$fsname-MDT0000.mdd.atime_diff" \
8024 set_persistent_param_and_check client \
8025 "llite.$fsname*.max_read_ahead_mb" \
8026 "$fsname.llite.max_read_ahead_mb" \
8028 set_persistent_param_and_check client \
8029 "llite.$fsname*.max_read_ahead_mb" \
8030 "$fsname.llite.max_read_ahead_mb" \
8032 create_pool $fsname.pool1 || error "create pool failed"
8033 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
8034 error "pool_add failed"
8035 do_facet mgs $LCTL pool_remove $fsname.pool1 OST0000 ||
8036 error "pool_remove failed"
8037 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
8038 error "pool_add failed"
8042 # check permanent parameters
8044 test_109_test_params() {
8047 local atime_diff=$(do_facet mds $LCTL \
8048 get_param -n mdd.$fsname-MDT0000.atime_diff)
8049 [ $atime_diff == 63 ] || error "wrong mdd parameter after clear_conf"
8050 local max_read_ahead_mb=$(do_facet client $LCTL \
8051 get_param -n llite.$fsname*.max_read_ahead_mb)
8052 [ $max_read_ahead_mb == 64 ] ||
8053 error "wrong llite parameter after clear_conf"
8054 local ost_in_pool=$(do_facet mds $LCTL pool_list $fsname.pool1 |
8055 grep -v "^Pool:" | sed 's/_UUID//')
8056 [ $ost_in_pool = "$fsname-OST0000" ] ||
8057 error "wrong pool after clear_conf"
8061 # run lctl clear_conf, store CONFIGS before and after that
8063 test_109_clear_conf()
8065 local clear_conf_arg=$1
8068 if ! combined_mgs_mds ; then
8069 mgsdev=$(mgsdevname)
8070 stop_mgs || error "stop_mgs failed"
8071 start_mgs "-o nosvc" || error "start_mgs nosvc failed"
8073 mgsdev=$(mdsdevname 1)
8074 start_mdt 1 "-o nosvc" || error "start_mdt 1 nosvc failed"
8077 do_facet mgs "rm -rf $TMP/${tdir}/conf1; mkdir -p $TMP/${tdir}/conf1;" \
8078 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf1\\\" \
8082 # the command being tested
8084 do_facet mgs $LCTL clear_conf $clear_conf_arg ||
8085 error "clear_conf failed"
8086 if ! combined_mgs_mds ; then
8087 stop_mgs || error "stop_mgs failed"
8089 stop_mdt 1 || error "stop_mdt 1 failed"
8092 do_facet mgs "rm -rf $TMP/${tdir}/conf2; mkdir -p $TMP/${tdir}/conf2;" \
8093 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf2\\\" \
8097 test_109_file_shortened() {
8099 local sizes=($(do_facet mgs "stat -c %s " \
8100 "$TMP/${tdir}/conf1/CONFIGS/$file" \
8101 "$TMP/${tdir}/conf2/CONFIGS/$file"))
8102 [ ${sizes[1]} -lt ${sizes[0]} ] && return 0
8108 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
8109 skip "Needs MDS version 2.10.59 or later."
8110 [ "$(facet_fstype mgs)" == zfs ] &&
8111 skip "LU-8727: no implementation for ZFS"
8116 client_up || error "client_up failed"
8119 # set number of permanent parameters
8121 test_109_set_params $FSNAME
8123 umount_client $MOUNT || error "umount_client failed"
8124 stop_ost || error "stop_ost failed"
8125 stop_mds || error "stop_mds failed"
8127 test_109_clear_conf $FSNAME
8129 # make sure that all configs are cleared
8131 test_109_file_shortened $FSNAME-MDT0000 ||
8132 error "failed to clear MDT0000 config"
8133 test_109_file_shortened $FSNAME-client ||
8134 error "failed to clear client config"
8139 # check that configurations are intact
8141 test_109_test_params $FSNAME
8146 destroy_test_pools || error "destroy test pools failed"
8150 run_test 109a "test lctl clear_conf fsname"
8154 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
8155 skip "Needs MDS version 2.10.59 or later."
8156 [ "$(facet_fstype mgs)" == zfs ] &&
8157 skip "LU-8727: no implementation for ZFS"
8162 client_up || error "client_up failed"
8165 # set number of permanent parameters
8167 test_109_set_params $FSNAME
8169 umount_client $MOUNT || error "umount_client failed"
8170 stop_ost || error "stop_ost failed"
8171 stop_mds || error "stop_mds failed"
8173 test_109_clear_conf $FSNAME-MDT0000
8175 # make sure that only one config is cleared
8177 test_109_file_shortened $FSNAME-MDT0000 ||
8178 error "failed to clear MDT0000 config"
8179 test_109_file_shortened $FSNAME-client &&
8180 error "failed to clear client config"
8184 # check that configurations are intact
8186 test_109_test_params $FSNAME
8191 destroy_test_pools || error "destroy test pools failed"
8195 run_test 109b "test lctl clear_conf one config"
8199 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
8200 skip "Only applicable to ldiskfs-based MDTs"
8202 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8203 skip "large_dir option is not supported on MDS"
8204 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8205 skip "large_dir option is not supported on OSS"
8207 stopall # stop all targets before modifying the target counts
8208 local old_mdscount=$MDSCOUNT
8209 local old_ostcount=$OSTCOUNT
8211 stack_trap "MDSCOUNT=$old_mdscount OSTCOUNT=$old_ostcount" EXIT
8215 # ext4_dir_entry_2 struct size:264
8216 # dx_root struct size:8
8217 # dx_node struct size:8
8218 # dx_entry struct size:8
8219 # For 1024 bytes block size.
8220 # First level directory entries: 126
8221 # Second level directory entries: 127
8222 # Entries in leaf: 3
8223 # For 2 levels limit: 48006
8224 # For 3 levels limit : 6096762
8225 # Create 80000 files to safely exceed 2-level htree limit.
8226 CONF_SANITY_110_LINKS=${CONF_SANITY_110_LINKS:-80000}
8228 # can fit at most 3 filenames per 1KB leaf block, but each
8229 # leaf/index block will only be 3/4 full before split at each level
8230 (( MDSSIZE < CONF_SANITY_110_LINKS / 3 * 4/3 * 4/3 )) &&
8231 CONF_SANITY_110_LINKS=$((MDSSIZE * 3 * 3/4 * 3/4))
8233 combined_mgs_mds || replace=" --replace "
8234 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8235 $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8236 if [[ $opts != *large_dir* ]]; then
8237 if [[ $opts != *mkfsoptions* ]]; then
8238 opts+=" --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536\\\""
8240 opts="${opts//--mkfsoptions=\\\"/ \
8241 --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536 }"
8244 echo "MDT params: $opts"
8246 combined_mgs_mds || start_mgs
8247 add mds1 $opts || error "add mds1 failed with new params"
8248 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8250 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8251 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
8253 if [[ $opts != *large_dir* ]]; then
8254 if [[ $opts != *mkfsoptions* ]]; then
8255 opts+=" --mkfsoptions=\\\"-O large_dir\\\" "
8257 opts="${opts//--mkfsoptions=\\\"/ \
8258 --mkfsoptions=\\\"-O large_dir }"
8261 echo "OST params: $opts"
8262 add ost1 $opts || error "add ost1 failed with new params"
8263 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8265 MOUNT_2=yes mountcli || error "mount clients failed"
8267 mkdir -v $DIR/$tdir || error "cannot create $DIR/$tdir"
8268 local pids count=0 group=0
8270 echo "creating $CONF_SANITY_110_LINKS in total"
8271 while (( count < CONF_SANITY_110_LINKS )); do
8272 local len=$((253 - $(wc -c <<<"$tfile-$group-40000-")))
8273 local dir=DIR$((group % 2 + 1))
8274 local target=${!dir}/$tdir/$tfile-$group
8275 local long=$target-$(generate_name $len)-
8276 local create=$((CONF_SANITY_110_LINKS - count))
8278 (( create > 40000 )) && create=40000
8279 touch $target || error "creating $target failed"
8280 echo "creating $create hard links to $target"
8281 createmany -l $target $long $create &
8284 count=$((count + create))
8285 group=$((group + 1))
8287 echo "waiting for PIDs$pids to complete"
8288 wait $pids || error "createmany failed after $group groups"
8290 umount_client $MOUNT2 -f
8293 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8294 MDSCOUNT=$old_mdscount
8295 OSTCOUNT=$old_ostcount
8297 run_test 110 "Adding large_dir with 3-level htree"
8300 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
8301 skip "Only applicable to ldiskfs-based MDTs"
8303 is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
8304 skip "This test can not be executed on flakey dev"
8306 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8307 skip "large_dir option is not supported on MDS"
8309 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8310 skip "large_dir option is not supported on OSS"
8312 # cleanup before changing target counts
8314 local old_mdscount=$MDSCOUNT
8315 local old_ostcount=$OSTCOUNT
8316 local old_mdssize=$MDSSIZE
8318 stack_trap "MDSSIZE=$MDSSIZE MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT" EXIT
8321 (( MDSSIZE < 2400000 )) && MDSSIZE=2400000 # need at least 2.4GB
8323 local mdsdev=$(mdsdevname 1)
8324 combined_mgs_mds || replace=" --replace "
8325 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8326 $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8327 if [[ $opts != *large_dir* ]]; then
8328 if [[ $opts != *mkfsoptions* ]]; then
8329 opts+=" --mkfsoptions=\\\"-O large_dir -i 1048576 \\\" "
8331 opts="${opts//--mkfsoptions=\\\"/ \
8332 --mkfsoptions=\\\"-O large_dir -i 1048576 }"
8335 echo "MDT params: $opts"
8337 combined_mgs_mds || start_mgs
8338 __touch_device mds 1
8339 add mds1 $opts || error "add mds1 failed with new params"
8340 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8342 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8343 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
8344 if [[ $opts != *large_dir* ]]; then
8345 if [[ $opts != *mkfsoptions* ]]; then
8346 opts+=" --mkfsoptions=\\\"-O large_dir \\\""
8348 opts="${opts//--mkfsoptions=\\\"/ --mkfsoptions=\\\"-O large_dir }"
8351 echo "OST params: $opts"
8352 __touch_device ost 1
8353 add ost1 $opts || error "add ost1 failed with new params"
8354 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8356 MOUNT_2=yes mountcli
8357 mkdir $DIR/$tdir || error "cannot create $DIR/$tdir"
8359 lfs df -i $DIR/$tdir
8363 local start=$SECONDS
8365 local dirmax=$((2 << 30))
8371 while (( !needskip & dirsize < dirmax )); do
8374 for cli in ${CLIENTS//,/ }; do
8375 local len=$((253 - $(wc -c <<<"$cli-$group-60000-")))
8376 local target=$cli-$group
8377 local long=$DIR/$tdir/$target-$(generate_name $len)-
8379 RPWD=$DIR/$tdir do_node $cli touch $target ||
8380 error "creating $target failed"
8381 echo "creating 60000 hardlinks to $target"
8382 RPWD=$DIR/$tdir do_node $cli createmany -l $target $long 60000 &
8385 group=$((group + 1))
8387 long=$DIR2/$tdir/$target-$(generate_name $len)-
8389 RPWD=$DIR2/$tdir do_node $cli touch $target ||
8390 error "creating $target failed"
8391 echo "creating 60000 hardlinks to $target"
8392 RPWD=$DIR2/$tdir do_node $cli createmany -l $target $long 60000 &
8395 group=$((group + 1))
8397 echo "waiting for PIDs$pids to complete"
8398 wait $pids || error "createmany failed after $group groups"
8399 dirsize=$(stat -c %s $DIR/$tdir)
8400 taken=$((SECONDS - start))
8401 rate=$((dirsize / taken))
8402 left=$(((dirmax - dirsize) / rate))
8403 num=$((group * 60000))
8404 echo "estimate ${left}s left after $num files / ${taken}s"
8405 # if the estimated time remaining is too large (it may change
8406 # over time as the create rate is not constant) then exit
8407 # without declaring a failure.
8408 (( left > 1200 )) && needskip=1
8411 umount_client $MOUNT2 -f
8414 (( $needskip )) && skip "ETA ${left}s after $num files / ${taken}s is too long"
8416 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8417 MDSCOUNT=$old_mdscount
8418 OSTCOUNT=$old_ostcount
8419 MDSSIZE=$old_mdssize
8421 run_test 111 "Adding large_dir with over 2GB directory"
8424 start_mds || error "MDS start failed"
8425 start_ost || error "OSS start failed"
8426 echo "start ost2 service on $(facet_active_host ost2)"
8427 start ost2 $(ostdevname 2) $(csa_add "$OST_MOUNT_OPTS" -o no_precreate) ||
8428 error "start ost2 facet failed"
8429 local val=$(do_facet ost2 \
8430 "$LCTL get_param -n obdfilter.$FSNAME-OST0001*.no_precreate")
8431 (( $val == 1 )) || error "obdfilter.$FSNAME-OST0001*.no_precreate=$val"
8433 mount_client $MOUNT || error "mount client failed"
8434 wait_osc_import_state client ost2 FULL
8436 $LFS setstripe -i 0 $DIR/$tfile.0 ||
8437 error "problem creating $tfile.0 on OST0000"
8438 $LFS setstripe -i 1 $DIR/$tfile.1 && $LFS getstripe $DIR/$tfile.1 &&
8439 (( $($LFS getstripe -i $DIR/$tfile.1) == 1 )) &&
8440 error "allowed to create $tfile.1 on OST0001"
8441 do_facet ost2 $LCTL set_param obdfilter.*.no_precreate=0
8443 $LFS setstripe -i 1 $DIR/$tfile.2 ||
8444 error "failed to create $tfile.2 on ost1 facet"
8445 stop_ost2 || error "stop ost2 facet failed"
8448 run_test 112 "mount OST with nocreate option"
8454 rm -f $TMP/$tdir/lustre-mdt
8458 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8459 skip "Only applicable to ldiskfs-based MDTs"
8461 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
8463 local dbfs_ver=$(do_facet $SINGLEMDS $DEBUGFS -V 2>&1)
8465 echo "debugfs version: $dbfs_ver"
8466 echo "$dbfs_ver" | egrep -w "1.44.3.wc1|1.44.5.wc1|1.45.2.wc1" &&
8467 skip_env "This version of debugfs doesn't show inode number"
8469 is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
8470 skip "This test can not be executed on flakey dev"
8472 IMAGESIZE=$((3072 << 30)) # 3072 GiB
8480 do_facet mds1 "hostname; ifconfig; lctl dl; mount"
8482 do_facet ost1 "hostname; ifconfig; lctl dl; mount"
8483 # We need MDT size 3072GB, because it is smallest
8484 # partition that can store 2B inodes
8485 do_facet $SINGLEMDS "mkdir -p $TMP/$tdir"
8486 local mdsimgname=$TMP/$tdir/lustre-mdt
8487 do_facet $SINGLEMDS "rm -f $mdsimgname"
8488 do_facet $SINGLEMDS "touch $mdsimgname"
8489 trap cleanup_115 RETURN EXIT
8490 do_facet $SINGLEMDS "$TRUNCATE $mdsimgname $IMAGESIZE" ||
8491 skip "Backend FS doesn't support sparse files"
8492 local mdsdev=$(do_facet $SINGLEMDS "losetup -f")
8493 do_facet $SINGLEMDS "losetup $mdsdev $mdsimgname"
8495 local mds_opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8496 --mkfsoptions='-O ea_inode,^resize_inode,meta_bg \
8497 -N 2247484000 -E lazy_itable_init' --device-size=$IMAGESIZE"
8498 add mds1 $mds_opts --mgs --reformat $mdsdev ||
8499 skip_env "format large MDT failed"
8500 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8501 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
8502 add ost1 $opts || error "add ost1 failed with new params"
8503 start $SINGLEMDS $mdsdev $MDS_MOUNT_OPTS || error "start MDS failed"
8504 start_ost || error "start OSS failed"
8505 mount_client $MOUNT || error "mount client failed"
8507 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir fail"
8508 goal="/sys/fs/ldiskfs/$(basename $mdsdev)/inode_goal"
8510 # 2147483648 is 0x80000000
8511 do_facet $SINGLEMDS "echo 2147483648 >> $goal; grep . $goal"
8512 touch $DIR/$tdir/$tfile
8514 # attrs from 1 to 15 go to block, 16th - to inode
8515 for i in {1..16}; do
8516 local nm="trusted.ea$i"
8517 setfattr -n $nm -v $(printf "xattr%0250d" $i) $DIR/$tdir/$tfile
8520 # inode <2147483649> trusted.ea16 (255)
8521 local inode_num=$(do_facet $SINGLEMDS \
8522 "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsdev" |
8523 awk '/ea16/ { print $2 }' |
8524 sed -e 's/>//' -e 's/<//' -e 's/\"//')
8525 echo "inode num: $inode_num"
8526 [ $inode_num -ge 2147483648 ] || error "inode $inode_num too small"
8527 do_facet $SINGLEMDS "losetup -d $mdsdev"
8530 run_test 115 "Access large xattr with inodes number over 2TB"
8533 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
8534 [ "$MDS1_VERSION" -lt $(version_code 2.10.59) ] &&
8535 skip "Need server version at least 2.10.59"
8536 do_facet $SINGLEMDS which mkfs.xfs ||
8537 skip_env "No mkfs.xfs installed"
8542 local tmpmnt=$TMP/$tdir
8543 local mdtimg=$tfile-mdt0
8545 do_facet $SINGLEMDS mkdir -p $tmpmnt
8546 stack_trap "do_facet $SINGLEMDS rmdir $tmpmnt" EXIT
8548 do_facet $SINGLEMDS touch $TMP/$mdtimg
8549 stack_trap "do_facet $SINGLEMDS rm -f $TMP/$mdtimg" EXIT
8550 do_facet $SINGLEMDS mkfs -t xfs -d file,size=1t,name=$TMP/$mdtimg ||
8551 error "mkfs temporary xfs image"
8553 do_facet $SINGLEMDS mount $TMP/$mdtimg $tmpmnt ||
8554 error "mount temporary xfs image"
8555 stack_trap "do_facet $SINGLEMDS umount $tmpmnt" EXIT
8556 local old_mdssize=$MDSSIZE
8557 local old_mdsisize=$MDSISIZE
8559 MDSSIZE=$((17 * 1024 * 1024 * 1024)) # 17T MDT
8560 MDSISIZE=$((16 << 20))
8561 local opts17t="$(mkfs_opts $SINGLEMDS)"
8563 MDSSIZE=$old_mdssize
8564 MDSISIZE=$old_mdsisize
8565 do_facet $SINGLEMDS $MKFS $opts17t $tmpmnt/$mdtimg ||
8566 error "failed to mkfs for $tmpmnt/$mdtimg"
8568 do_facet $SINGLEMDS $TUNE2FS -l $tmpmnt/$mdtimg |
8569 grep -qw 'features.*extent' || error "extent should be enabled"
8572 run_test 116 "big size MDT support"
8576 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.nrs_policies=fifo"
8577 do_facet ost1 "$LCTL get_param -n ost.OSS.ost_io.nrs_tbf_rule" &&
8578 error "get_param should fail"
8579 cleanup || error "cleanup failed with rc $?"
8581 run_test 117 "lctl get_param return errors properly"
8583 test_120() { # LU-11130
8584 [ "$MDSCOUNT" -lt 2 ] && skip "mdt count < 2"
8585 [ "$mds1_FSTYPE" != ldiskfs ] &&
8586 skip "ldiskfs only test"
8587 [ "$MDS1_VERSION" -lt $(version_code 2.11.56) ] &&
8588 skip "Need DNE2 capable MD target with LU-11130 fix"
8592 local mds1host=$(facet_active_host mds1)
8593 local mds1dev=$(mdsdevname 1)
8595 $LFS mkdir -i 1 $DIR/$tdir
8596 $LFS mkdir -i 0 $DIR/$tdir/mds1dir
8598 ln -s foo $DIR/$tdir/bar
8599 mv $DIR/$tdir/bar $DIR/$tdir/mds1dir/bar2 ||
8600 error "cross-target rename failed"
8604 run_e2fsck $mds1host $mds1dev "-n"
8606 run_test 120 "cross-target rename should not create bad symlinks"
8609 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
8610 [[ "$OST1_VERSION" -ge $(version_code 2.11.53) ]] ||
8611 skip "Need OST version at least 2.11.53"
8614 LOAD_MODULES_REMOTE=true load_modules
8615 #define OBD_FAIL_OFD_SET_OID 0x1e0
8616 do_facet ost1 $LCTL set_param fail_loc=0x00001e0
8619 $LFS mkdir -i1 -c1 $DIR/$tdir
8620 $LFS setstripe -i0 -c1 $DIR/$tdir
8621 do_facet ost1 $LCTL set_param fail_loc=0
8622 createmany -o $DIR/$tdir/file_ 1000 ||
8623 error "Fail to create a new sequence"
8627 run_test 122 "Check OST sequence update"
8630 remote_mgs_nodsh && skip "remote MGS with nodsh"
8631 [ -d $MOUNT/.lustre ] || setup
8633 # test old logid format until removal from llog_ioctl.c::str2logid()
8634 if [ $MGS_VERSION -lt $(version_code 3.1.53) ]; then
8635 do_facet mgs $LCTL dl | grep MGS
8636 do_facet mgs "$LCTL --device %MGS llog_print \
8637 \\\\\\\$$FSNAME-client 1 10" ||
8638 error "old llog_print failed"
8641 # test new logid format
8642 if [ $MGS_VERSION -ge $(version_code 2.9.53) ]; then
8643 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
8644 error "new llog_print failed"
8647 run_test 123aa "llog_print works with FIDs and simple names"
8650 remote_mgs_nodsh && skip "remote MGS with nodsh"
8651 [[ $MGS_VERSION -gt $(version_code 2.11.51) ]] ||
8652 skip "Need server with working llog_print support"
8654 [ -d $MOUNT/.lustre ] || setup
8659 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
8660 do_facet mgs $LCTL set_param -P jobid_name="TESTNAME"
8662 yaml=$(do_facet mgs $LCTL --device MGS llog_print params |
8663 grep jobid_name | tail -n 1)
8665 local param=$(awk '{ print $10 }' <<< "$yaml")
8666 local val=$(awk '{ print $12 }' <<< "$yaml")
8667 #return to the default
8668 do_facet mgs $LCTL set_param -P jobid_name=$orig_val
8669 [ $val = "TESTNAME" ] || error "bad value: $val"
8670 [ $param = "jobid_name," ] || error "Bad param: $param"
8672 run_test 123ab "llog_print params output values from set_param -P"
8674 test_123ac() { # LU-11566
8675 remote_mgs_nodsh && skip "remote MGS with nodsh"
8676 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8677 skip "Need 'lctl llog_print --start' on MGS"
8682 [ -d $MOUNT/.lustre ] || setup
8684 # - { index: 10, event: add_uuid, nid: 192.168.20.1@tcp(0x20000c0a81401,
8685 # node: 192.168.20.1@tcp }
8686 do_facet mgs $LCTL --device MGS \
8687 llog_print --start $start --end $end $FSNAME-client | tr -d , |
8688 while read DASH BRACE INDEX idx EVENT BLAH BLAH BLAH; do
8689 (( idx >= start )) || error "llog_print index $idx < $start"
8690 (( idx <= end )) || error "llog_print index $idx > $end"
8693 run_test 123ac "llog_print with --start and --end"
8695 test_123ad() { # LU-11566
8696 remote_mgs_nodsh && skip "remote MGS with nodsh"
8697 # older versions of lctl may not print all records properly
8698 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8699 skip "Need 'lctl llog_print --start' on MGS"
8701 [ -d $MOUNT/.lustre ] || setup
8703 # append a new record, to avoid issues if last record was cancelled
8704 local old=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
8705 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$old
8707 # logid: [0x3:0xa:0x0]:0
8711 local num=$(do_facet mgs $LCTL --device MGS llog_info $FSNAME-client |
8712 awk '/last_index:/ { print $2 - 1 }')
8714 # - { index: 71, event: set_timeout, num: 0x14, param: sys.timeout=20 }
8715 local last=$(do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
8716 tail -1 | awk '{ print $4 }' | tr -d , )
8717 (( last == num )) || error "llog_print only showed $last/$num records"
8719 run_test 123ad "llog_print shows all records"
8721 test_123ae() { # LU-11566
8722 remote_mgs_nodsh && skip "remote MGS with nodsh"
8723 [ -d $MOUNT/.lustre ] || setupall
8725 local max=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
8727 if do_facet mgs "$LCTL help llog_cancel" 2>&1| grep -q -- --log_id; then
8728 # save one set_param -P record in case none exist
8729 do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
8732 local orig=$(do_facet mgs $LCTL --device MGS llog_print $log |
8733 tail -1 | awk '{ print $4 }' | tr -d , )
8734 do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
8735 do_facet mgs $LCTL --device MGS llog_print $log | tail -1 |
8736 grep "parameter: osc.*.max_dirty_mb" ||
8737 error "new set_param -P wasn't stored in params log"
8739 # - { index: 71, event: set_param, device: general,
8740 # param: osc.*.max_dirty_mb, value: 256 }
8741 local id=$(do_facet mgs $LCTL --device MGS llog_print $log |
8742 tail -1 | awk '{ print $4 }' | tr -d , )
8744 do_facet mgs $LCTL --device MGS llog_cancel $log --log_idx=$id
8745 local new=$(do_facet mgs $LCTL --device MGS llog_print $log |
8746 tail -1 | awk '{ print $4 }' | tr -d , )
8747 (( new == orig )) ||
8748 error "new llog_cancel now $new, not at $orig records"
8751 # test old positional parameters for a while still
8752 if [ "$MGS_VERSION" -le $(version_code 3.1.53) ]; then
8754 orig=$(do_facet mgs $LCTL --device MGS llog_print $log |
8755 tail -1 | awk '{ print $4 }' | tr -d , )
8756 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$max
8757 do_facet mgs $LCTL --device MGS llog_print $log |
8758 tail -1 | grep "parameter: osc.max_dirty_mb" ||
8759 error "old conf_param wasn't stored in params log"
8761 # - { index: 71, event: conf_param, device: testfs-OST0000-osc,
8762 # param: osc.max_dirty_mb=256 }
8763 id=$(do_facet mgs $LCTL --device MGS llog_print $log |
8764 tail -1 | awk '{ print $4 }' | tr -d , )
8765 do_facet mgs $LCTL --device MGS llog_cancel $log $id
8766 new=$(do_facet mgs $LCTL --device MGS llog_print $log |
8767 tail -1 | awk '{ print $4 }' | tr -d , )
8768 (( new == orig )) ||
8769 error "old llog_cancel now $new, not at $orig records"
8772 run_test 123ae "llog_cancel can cancel requested record"
8774 test_123af() { #LU-13609
8775 [ "$MGS_VERSION" -ge $(version_code 2.13.54) -a \
8776 "$MDS1_VERSION" -ge $(version_code 2.13.54) ] ||
8777 skip "Need both MGS and MDS version at least 2.13.54"
8779 [ -d $MOUNT/.lustre ] || setupall
8780 stack_trap "do_facet mds1 $LCTL set_param fail_loc=0" EXIT
8790 for device in "MGS" "$FSNAME-MDT0000"; do
8791 cmd="--device $device llog_catlist"
8792 echo "lctl $cmd ..."
8793 if [ "$device" = "MGS" ]; then
8798 orig_clist=($(do_facet $facet $LCTL $cmd | awk '{ print $2 }'))
8799 orig_count=${#orig_clist[@]}
8800 echo "orig_clist: ${orig_clist[@]}"
8802 #define OBD_FAIL_CATLIST 0x131b
8803 #fetch to llog records from the second one
8804 do_facet $facet $LCTL set_param fail_loc=0x131b fail_val=2
8806 new_clist=($(do_facet $facet $LCTL $cmd | awk '{ print $2 }'))
8807 new_count=${#new_clist[@]}
8808 echo "new_clist: ${new_clist[@]}"
8810 [ $new_count -eq $((orig_count - 1)) ] ||
8811 error "$new_count != $orig_count - 1"
8812 for i in $(seq 0 $new_count); do
8814 [ "${orig_clist[$j]}" = "${new_clist[$i]}" ] ||
8815 error "${orig_clist[$j]} != ${new_clist[$i]}"
8817 do_facet mds1 $LCTL set_param fail_loc=0
8821 run_test 123af "llog_catlist can show all config files correctly"
8824 remote_mgs_nodsh && skip "remote MGS with nodsh"
8826 [ -d $MOUNT/.lustre ] || setup
8827 local yaml_file="$TMP/$tfile.yaml"
8828 do_facet mgs rm "$yaml_file"
8829 local cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist" |
8830 sed 's/config_log://')
8832 # set jobid_var to a different value for test
8833 local orig_val=$(do_facet mgs $LCTL get_param jobid_var)
8834 do_facet mgs $LCTL set_param -P jobid_var="TESTNAME"
8836 for i in $cfgfiles params; do
8837 do_facet mgs "lctl --device MGS llog_print ${i} >> $yaml_file"
8840 echo "Unmounting FS"
8850 # Reapply the config from before
8851 echo "Setting configuration parameters"
8852 do_facet mgs "lctl set_param -F $yaml_file"
8854 local set_val=$(do_facet mgs $LCTL get_param jobid_var)
8855 do_facet mgs $LCTL set_param -P $orig_val
8857 [ $set_val == "jobid_var=TESTNAME" ] ||
8858 error "$set_val is not TESTNAME"
8860 do_facet mgs rm "$yaml_file"
8863 run_test 123F "clear and reset all parameters using set_param -F"
8867 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
8868 [ -z $mds2failover_HOST ] && skip "needs MDT failover setup"
8874 if combined_mgs_mds; then
8875 start_mdt 1 "-o nosvc" ||
8876 error "starting mds with nosvc option failed"
8878 local nid=$(do_facet mds2 $LCTL list_nids | head -1)
8879 local failover_nid=$(do_node $mds2failover_HOST $LCTL list_nids | head -1)
8880 do_facet mgs $LCTL replace_nids $FSNAME-MDT0001 $nid:$failover_nid ||
8881 error "replace_nids execution error"
8883 if combined_mgs_mds; then
8889 echo "lfs setdirstripe"
8890 $LFS setdirstripe -i 1 $MOUNT/$tdir || error "setdirstirpe error"
8893 run_test 124 "check failover after replace_nids"
8895 get_max_sectors_kb() {
8898 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8899 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
8901 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
8902 cat ${max_sectors_path}"
8905 get_max_hw_sectors_kb() {
8908 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8909 local max_hw_path="/sys/block/${dev_base}/queue/max_hw_sectors_kb"
8911 do_facet ${facet} "[[ -e ${max_hw_path} ]] && cat ${max_hw_path}"
8914 set_max_sectors_kb() {
8918 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8919 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
8921 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
8922 echo ${value} > ${max_sectors_path}"
8925 [[ $rc -ne 0 ]] && echo "Failed to set ${max_sectors_path} to ${value}"
8930 # Return 0 if all slave devices have max_sectors_kb == max_hw_sectors_kb
8931 # Otherwise return > 0
8932 check_slaves_max_sectors_kb()
8936 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
8937 local slaves_dir=/sys/block/${dev_base}/slaves
8938 local slave_devices=$(do_facet ${facet} "ls ${slaves_dir} 2>/dev/null")
8939 [[ -z ${slave_devices} ]] && return 0
8941 local slave max_sectors new_max_sectors max_hw_sectors path
8943 for slave in ${slave_devices}; do
8944 path="/dev/${slave}"
8945 ! is_blkdev ${facet} ${path} && continue
8946 max_sectors=$(get_max_sectors_kb ${facet} ${path})
8947 max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${path})
8948 new_max_sectors=${max_hw_sectors}
8949 [[ ${new_max_sectors} -gt ${RQ_SIZE_LIMIT} ]] &&
8950 new_max_sectors=${RQ_SIZE_LIMIT}
8952 if [[ ${max_sectors} -ne ${new_max_sectors} ]]; then
8953 echo "${path} ${max_sectors} ${new_max_sectors}"
8956 check_slaves_max_sectors_kb ${facet} ${path}
8965 local facet_list="mgs mds1 ost1"
8966 combined_mgs_mds && facet_list="mgs ost1"
8969 for facet in ${facet_list}; do
8970 [[ $(facet_fstype ${facet}) != ldiskfs ]] &&
8971 skip "ldiskfs only test" &&
8973 ! is_blkdev ${facet} $(facet_device ${facet}) &&
8974 skip "requires all real devices" &&
8979 # We don't increase IO request size limit past 16MB. See comments in
8980 # lustre/utils/libmount_utils_ldiskfs.c:tune_max_sectors_kb()
8981 RQ_SIZE_LIMIT=$((16 * 1024))
8982 local device old_max_sectors new_max_sectors max_hw_sectors
8983 for facet in ${facet_list}; do
8984 device=$(facet_device ${facet})
8985 old_max_sectors=$(get_max_sectors_kb ${facet} ${device})
8986 max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${device})
8988 # The expected value after l_tunedisk is executed
8989 new_max_sectors=$old_max_sectors
8990 [[ ${new_max_sectors_kb} -gt ${RQ_SIZE_LIMIT} ]] &&
8991 new_max_sectors_kb=${RQ_SIZE_LIMIT}
8993 # Ensure the current value of max_sectors_kb does not equal
8994 # max_hw_sectors_kb, so we can tell whether l_tunedisk did
8996 set_max_sectors_kb ${facet} ${device} $((new_max_sectors - 1))
8998 # Value before l_tunedisk
8999 local pre_max_sectors=$(get_max_sectors_kb ${facet} ${device})
9000 if [[ ${pre_max_sectors} -ne $((new_max_sectors - 1)) ]]; then
9001 echo "unable to satsify test pre-condition:"
9002 echo "${pre_max_sectors} != $((new_max_sectors - 1))"
9007 echo "Before: ${facet} ${device} ${pre_max_sectors} ${max_hw_sectors}"
9009 do_facet ${facet} "libtool execute l_tunedisk ${device}"
9011 # Value after l_tunedisk
9012 local post_max_sectors=$(get_max_sectors_kb ${facet} ${device})
9014 echo "After: ${facet} ${device} ${post_max_sectors} ${max_hw_sectors}"
9016 if [[ ${facet} != ost1 ]]; then
9017 if [[ ${post_max_sectors} -ne ${pre_max_sectors} ]]; then
9018 echo "l_tunedisk modified max_sectors_kb of ${facet}"
9022 set_max_sectors_kb ${facet} ${device} ${old_max_sectors}
9024 if [[ ${post_max_sectors} -eq ${pre_max_sectors} ]]; then
9025 echo "l_tunedisk failed to modify max_sectors_kb of ${facet}"
9029 check_slaves_max_sectors_kb ${facet} ${device} ||
9036 run_test 125 "check l_tunedisk only tunes OSTs and their slave devices"
9039 [[ "$MDS1_VERSION" -ge $(version_code 2.13.52) ]] ||
9040 skip "Need MDS version at least 2.13.52"
9043 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ../libcfs/libcfs/libcfs
9044 #define OBD_FAIL_OBD_SETUP 0x60d
9045 do_facet mds1 $LCTL set_param fail_loc=0x60d
9046 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules &
9047 for i in {1..40}; do
9048 do_facet mds1 lsmod | grep -q osd_$mds1_FSTYPE && break
9051 clear_failloc $SINGLEMDS 20 &
9052 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
9054 run_test 126 "mount in parallel shouldn't cause a crash"
9056 if ! combined_mgs_mds ; then
9062 # restore the values of MDSSIZE and OSTSIZE
9063 MDSSIZE=$STORED_MDSSIZE
9064 OSTSIZE=$STORED_OSTSIZE
9068 check_and_cleanup_lustre