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
143 for num in $(seq $MDSCOUNT); do
144 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds${num} FULL
149 if ! combined_mgs_mds ; then
157 for num in $(seq $MDSCOUNT); do
158 stop_mdt $num || return 97
163 echo "stop mgs service on `facet_active_host mgs`"
164 # These tests all use non-failover stop
165 stop mgs -f || return 97
169 echo "start ost1 service on `facet_active_host ost1`"
170 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
171 wait_clients_import_state ${CLIENTS:-$HOSTNAME} ost1 FULL
175 echo "stop ost1 service on `facet_active_host ost1`"
176 # These tests all use non-failover stop
177 stop ost1 -f || return 98
181 echo "start ost2 service on `facet_active_host ost2`"
182 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
183 wait_clients_import_state ${CLIENTS:-$HOSTNAME} ost2 FULL
187 echo "stop ost2 service on `facet_active_host ost2`"
188 # These tests all use non-failover stop
189 stop ost2 -f || return 93
196 echo "mount $FSNAME ${mountopt:+with opts $mountopt} on $mountpath....."
197 zconf_mount $HOSTNAME $mountpath $mountopt || return 96
203 echo "umount lustre on $mountpath....."
204 zconf_umount $HOSTNAME $mountpath $@ || return 97
207 manual_umount_client(){
210 echo "manual umount lustre on ${MOUNT}...."
211 do_facet client "umount ${FORCE} $MOUNT"
217 start_mds || error "MDT start failed"
218 start_ost || error "Unable to start OST1"
219 mount_client $MOUNT || error "client start failed"
220 client_up || error "client_up failed"
229 unload_modules_conf () {
230 if combined_mgs_mds || ! local_mode; then
231 unload_modules || return 1
236 stop_ost || return 202
237 stop_mds || return 201
238 unload_modules_conf || return 203
243 [ "x$1" != "x" ] && force='-f'
244 umount_client $MOUNT $force|| return 200
245 cleanup_nocli || return $?
250 echo "umount $MOUNT2 ..."
251 umount $MOUNT2 || true
252 echo "stopping fs2mds ..."
253 stop fs2mds -f || true
254 echo "stopping fs2ost ..."
255 stop fs2ost -f || true
259 do_facet client "cp /etc/passwd $DIR/a" || return 71
260 do_facet client "rm $DIR/a" || return 72
261 # make sure lustre is actually mounted (touch will block,
262 # but grep won't, so do it after)
263 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
264 echo "setup single mount lustre success"
268 do_facet client "touch $DIR/a" || return 71
269 do_facet client "rm $DIR/a" || return 72
270 do_facet client "touch $DIR2/a" || return 73
271 do_facet client "rm $DIR2/a" || return 74
272 echo "setup double mount lustre success"
276 cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
279 if [ "$ONLY" == "setup" ]; then
284 if [ "$ONLY" == "cleanup" ]; then
291 #create single point mountpoint
297 check_mount || error "check_mount failed"
298 cleanup || error "cleanup failed with $?"
300 run_test 0 "single mount setup"
303 start_mds || error "MDS start failed"
304 start_ost || error "unable to start OST"
305 echo "start ost second time..."
306 start_ost && error "2nd OST start should fail"
307 mount_client $MOUNT || error "client start failed"
308 check_mount || error "check_mount failed"
309 cleanup || error "cleanup failed with $?"
311 run_test 1 "start up ost twice (should return errors)"
314 start_mds || error "MDT start failed"
315 echo "start mds second time.."
316 start_mds && error "2nd MDT start should fail"
317 start_ost || error "OST start failed"
318 mount_client $MOUNT || error "mount_client failed to start client"
319 check_mount || error "check_mount failed"
320 cleanup || error "cleanup failed with $?"
322 run_test 2 "start up mds twice (should return err)"
326 #mount.lustre returns an error if already in mtab
327 mount_client $MOUNT && error "2nd client mount should fail"
328 check_mount || error "check_mount failed"
329 cleanup || error "cleanup failed with $?"
331 run_test 3 "mount client twice (should return err)"
335 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
336 stop_ost || error "Unable to stop OST1"
337 umount_client $MOUNT -f || error “unmount $MOUNT failed”
340 # ok for ost to fail shutdown
341 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
342 error "cleanup failed with $?"
345 run_test 4 "force cleanup ost, then cleanup"
347 test_5a() { # was test_5
349 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
350 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
352 stop_mds || error "Unable to stop MDS"
354 # cleanup may return an error from the failed
355 # disconnects; for now I'll consider this successful
356 # if all the modules have unloaded.
360 echo "killing umount"
361 kill -TERM $UMOUNT_PID
362 echo "waiting for umount to finish"
364 if grep " $MOUNT " /proc/mounts; then
365 echo "test 5: /proc/mounts after failed umount"
369 echo "killing umount"
370 kill -TERM $UMOUNT_PID
371 echo "waiting for umount to finish"
373 grep " $MOUNT " /proc/mounts &&
374 error "/proc/mounts after second umount"
377 # manual_mount_client may fail due to umount succeeding above
379 # stop_mds is a no-op here, and should not fail
380 cleanup_nocli || error "cleanup_nocli failed with $?"
381 # df may have lingering entry
383 # mtab may have lingering entry
387 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
389 grep -q $MOUNT" " /etc/mtab || break
390 echo "Waiting /etc/mtab updated ... "
391 WAIT=$(( WAIT + sleep))
393 [ "$WAIT" -eq "$MAX_WAIT" ] &&
394 error "/etc/mtab is not updated in $WAIT secs"
395 echo "/etc/mtab updated in $WAIT secs"
397 run_test 5a "force cleanup mds, then cleanup"
405 grep " $MOUNT " /etc/mtab &&
406 error false "unexpected entry in mtab before mount" && return 10
408 start_ost || error "OST start failed"
409 if ! combined_mgs_mds ; then
410 trap cleanup_5b EXIT ERR
411 start_mds || error "MDS start failed"
415 mount_client $MOUNT && error "mount_client $MOUNT should fail"
416 grep " $MOUNT " /etc/mtab &&
417 error "$MOUNT entry in mtab after failed mount"
419 # stop_mds is a no-op here, and should not fail
420 cleanup_nocli || error "cleanup_nocli failed with $?"
421 if ! combined_mgs_mds ; then
425 run_test 5b "Try to start a client with no MGS (should return errs)"
428 grep " $MOUNT " /etc/mtab &&
429 error false "unexpected entry in mtab before mount" && return 10
431 start_mds || error "MDS start failed"
432 start_ost || error "OST start failed"
433 local oldfs="${FSNAME}"
434 FSNAME="wrong.${FSNAME}"
435 mount_client $MOUNT || :
437 grep " $MOUNT " /etc/mtab &&
438 error "$MOUNT entry in mtab after failed mount"
440 cleanup_nocli || error "cleanup_nocli failed with $?"
442 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
445 grep " $MOUNT " /etc/mtab &&
446 error "unexpected entry in mtab before mount"
448 start_ost || error "OST start failed"
449 start_mds || error "MDS start failed"
450 stop_ost -f || error "Unable to stop OST1"
451 mount_client $MOUNT || error "mount_client $MOUNT failed"
452 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
453 cleanup_nocli || error "cleanup_nocli failed with $?"
454 ! grep " $MOUNT " /etc/mtab ||
455 error "$MOUNT entry in mtab after unmount"
457 run_test 5d "mount with ost down"
460 grep " $MOUNT " /etc/mtab &&
461 error false "unexpected entry in mtab before mount" && return 10
463 start_mds || error "MDS start failed"
464 start_ost || error "OST start failed"
466 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
467 do_facet client "$LCTL set_param fail_loc=0x80000506"
468 mount_client $MOUNT || echo "mount failed (not fatal)"
469 cleanup || error "cleanup failed with $?"
470 grep " $MOUNT " /etc/mtab &&
471 error "$MOUNT entry in mtab after unmount"
474 run_test 5e "delayed connect, don't crash (bug 10268)"
477 combined_mgs_mds && skip "needs separate mgs and mds"
479 grep " $MOUNT " /etc/mtab &&
480 error false "unexpected entry in mtab before mount" && return 10
483 start_ost || error "OST start failed"
484 mount_client $MOUNT &
486 echo client_mount pid is $pid
490 if ! ps -f -p $pid >/dev/null; then
493 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
494 error "mount returns $rc, expected to hang"
496 cleanup || error "cleanup failed with $?"
501 start_mds || error "start MDS failed"
503 # mount should succeed after start mds
505 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
506 cleanup || error "final call to cleanup failed with rc $?"
508 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
512 [ "$CLIENT_VERSION" -lt $(version_code 2.9.53) ] &&
513 skip "automount of debugfs missing before 2.9.53"
514 umount /sys/kernel/debug
515 $LCTL get_param -n devices | egrep -v "error" && \
516 error "lctl can't access debugfs data"
517 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
519 run_test 5g "handle missing debugfs"
525 #define OBD_FAIL_MDS_FS_SETUP 0x135
526 do_facet mds1 "$LCTL set_param fail_loc=0x80000135"
527 start_mdt 1 && error "start mdt should fail"
528 start_mdt 1 || error "start mdt failed"
529 client_up || error "client_up failed"
532 run_test 5h "start mdt failure at mdt_fs_setup()"
538 #define OBD_FAIL_QUOTA_INIT 0xA05
539 do_facet mds1 "$LCTL set_param fail_loc=0x80000A05"
540 start_mdt 1 && error "start mdt should fail"
541 start_mdt 1 || error "start mdt failed"
542 client_up || error "client_up failed"
545 run_test 5i "start mdt failure at mdt_quota_init()"
550 mount_client $MOUNT || error "mount_client $MOUNT failed"
551 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
552 cleanup || error "cleanup failed with rc $?"
554 run_test 6 "manual umount, then mount again"
559 cleanup_nocli || error "cleanup_nocli failed with $?"
561 run_test 7 "manual umount, then cleanup"
565 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
566 check_mount2 || error "check_mount2 failed"
567 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
568 cleanup || error "cleanup failed with rc $?"
570 run_test 8 "double mount setup"
573 start_ost || error "OST start failed"
575 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
576 error "do_facet ost1 set_param inode trace failed."
577 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
578 error "do_facet ost1 set_param debug mds ost failed."
580 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
581 if [ "$CHECK_PTLDEBUG" ] && { \
582 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
583 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
584 echo "lnet.debug success"
586 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
588 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
589 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
590 echo "lnet.subsystem_debug success"
592 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
594 stop_ost || error "Unable to stop OST1"
596 run_test 9 "test ptldebug and subsystem for mkfs"
599 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
600 # But with new MDS stack we don't care about the mode of local objects
601 # anymore, so this test is removed. See bug 22944 for more details.
605 if [ "$mds1_FSTYPE" != ldiskfs ]; then
606 skip "ldiskfs only test"
610 check_mount || error "check_mount failed"
611 cleanup || error "cleanup failed with rc $?"
613 echo "Remove mds config log"
614 if ! combined_mgs_mds ; then
618 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
619 $(mgsdevname) || return \$?" ||
620 error "do_facet mgs failed with $?"
622 if ! combined_mgs_mds ; then
626 start_ost || error "OST start failed"
627 start_mds && error "MDS start succeeded, but should fail"
630 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
633 if [ "$mds1_FSTYPE" != ldiskfs ]; then
634 skip "ldiskfs only test"
637 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
642 # check if current MDSSIZE is large enough
643 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
644 log "use MDSSIZE=$MDSSIZE"
646 # check if the global config has a large enough MDSSIZE
647 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
648 [ $STORED_MDSSIZE -ge $MIN ] &&
649 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
650 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
652 # check if the block device is large enough
653 is_blkdev $SINGLEMDS $MDSDEV $MIN
654 local large_enough=$?
655 if [ -n "$OK" ]; then
656 [ $large_enough -ne 0 ] && OK=""
658 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
659 log "use device $MDSDEV with MIN=$MIN"
662 # check if a loopback device has enough space for fs metadata (5%)
664 if [ -z "$OK" ]; then
665 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
666 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
667 awk '($1 != "Filesystem") { print $4 }')
668 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
669 OK=1 && myMDSSIZE=$MIN &&
670 log "use file $MDSDEV with MIN=$MIN"
673 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS"
675 echo "mount mds with large journal..."
677 local OLD_MDSSIZE=$MDSSIZE
681 echo "mount lustre system..."
683 check_mount || error "check_mount failed"
685 echo "check journal size..."
686 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
687 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
688 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
690 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
693 cleanup || error "cleanup failed with rc $?"
698 run_test 18 "check mkfs creates large journals"
701 start_mds || error "MDS start failed"
702 stop_mds || error "Unable to stop MDS"
704 run_test 19a "start/stop MDS without OSTs"
707 start_ost || error "Unable to start OST1"
708 stop_ost -f || error "Unable to stop OST1"
710 run_test 19b "start/stop OSTs without MDS"
713 # first format the ost/mdt
714 start_mds || error "MDS start failed"
715 start_ost || error "Unable to start OST1"
716 mount_client $MOUNT || error "mount_client $MOUNT failed"
717 check_mount || error "check_mount failed"
718 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
719 mount_client $MOUNT remount,ro || error "remount client with ro failed"
720 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
721 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
722 mount_client $MOUNT remount,rw || error "remount client with rw failed"
723 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
724 MCNT=$(grep -c $MOUNT' ' /etc/mtab)
725 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
727 stop_mds || error "Unable to stop MDS"
728 stop_ost || error "Unable to stop OST1"
730 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
733 start_mds || error "MDS start failed"
734 start_ost || error "unable to start OST1"
735 wait_osc_import_state mds ost FULL
736 stop_ost || error "unable to stop OST1"
737 stop_mds || error "unable to stop MDS"
739 run_test 21a "start mds before ost, stop ost first"
742 start_ost || error "unable to start OST1"
743 start_mds || error "MDS start failed"
744 wait_osc_import_state mds ost FULL
745 stop_mds || error "unable to stop MDS"
746 stop_ost || error "unable to stop OST1"
748 run_test 21b "start ost before mds, stop mds first"
751 start_ost || error "Unable to start OST1"
752 start_mds || error "MDS start failed"
753 start_ost2 || error "Unable to start OST2"
754 wait_osc_import_state mds ost2 FULL
755 stop_ost || error "Unable to stop OST1"
756 stop_ost2 || error "Unable to stop OST2"
757 stop_mds || error "Unable to stop MDS"
758 #writeconf to remove all ost2 traces for subsequent tests
759 writeconf_or_reformat
761 run_test 21c "start mds between two osts, stop mds last"
764 combined_mgs_mds && skip "need separate mgs device"
769 start_mgs || error "unable to start MGS"
770 start_ost || error "unable to start OST1"
771 start_ost2 || error "unable to start OST2"
772 start_mds || error "MDS start failed"
773 wait_osc_import_state mds ost2 FULL
775 local zkeeper=${KEEP_ZPOOL}
776 stack_trap "KEEP_ZPOOL=$zkeeper" EXIT
779 stop_ost || error "Unable to stop OST1"
780 stop_ost2 || error "Unable to stop OST2"
781 stop_mds || error "Unable to stop MDS"
783 #writeconf to remove all ost2 traces for subsequent tests
784 writeconf_or_reformat
785 KEEP_ZPOOL="${zkeeper}"
787 start_mgs || error "unable to start MGS"
789 run_test 21d "start mgs then ost and then mds"
792 MGSNID="$saved_mgsnid"
794 echo "stopping fs2mgs ..."
795 stop $fs2mgs -f || true
798 test_21e() { # LU-5863
799 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
800 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
801 skip_env "mixed loopback and real device not working"
804 local fs2mdsdev=$(mdsdevname 1_2)
805 local fs2ostdev=$(ostdevname 1_2)
806 local fs3ostdev=$(ostdevname 2_2)
808 local fs2mdsvdev=$(mdsvdevname 1_2)
809 local fs2ostvdev=$(ostvdevname 1_2)
810 local fs3ostvdev=$(ostvdevname 2_2)
812 # temporarily use fs3ost as fs2mgs
814 local fs2mgsdev=$fs3ostdev
815 local fs2mgsvdev=$fs3ostvdev
817 local fsname=test1234
819 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
820 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
821 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
822 error "start fs2mgs failed"
824 local saved_mgsnid="$MGSNID"
825 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
827 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
828 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
829 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
830 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
832 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
833 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
835 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
836 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
837 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
841 run_test 21e "separate MGS and MDS"
844 start_mds || error "MDS start failed"
846 echo "Client mount with ost in logs, but none running"
847 start_ost || error "unable to start OST1"
848 # wait until mds connected to ost and open client connection
849 wait_osc_import_state mds ost FULL
850 stop_ost || error "unable to stop OST1"
851 mount_client $MOUNT || error "mount_client $MOUNT failed"
852 # check_mount will block trying to contact ost
853 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
854 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
855 umount_client $MOUNT -f
858 echo "Client mount with a running ost"
859 start_ost || error "unable to start OST1"
861 # if gss enabled, wait full time to let connection from
862 # mds to ost be established, due to the mismatch between
863 # initial connect timeout and gss context negotiation timeout.
864 # This perhaps could be remove after AT landed.
865 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
866 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
868 mount_client $MOUNT || error "mount_client $MOUNT failed"
869 wait_osc_import_state mds ost FULL
870 wait_osc_import_ready client ost
871 check_mount || error "check_mount failed"
874 cleanup || error "cleanup failed with rc $?"
876 run_test 22 "start a client before osts (should return errs)"
878 test_23a() { # was test_23
881 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
882 # force down client so that recovering mds waits for reconnect
883 local running=$(grep -c $MOUNT /proc/mounts) || true
884 if [ $running -ne 0 ]; then
885 echo "Stopping client $MOUNT (opts: -f)"
889 # enter recovery on failed mds
890 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
891 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
892 # try to start a new client
893 mount_client $MOUNT &
895 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
896 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
897 grep -v grep | awk '{print $2}')
898 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
900 ps --ppid $MOUNT_LUSTRE_PID
901 echo "waiting for mount to finish"
903 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
904 # SIGTERM works but it does not spread to offspring processses
905 kill -s TERM $MOUNT_PID
906 kill -s TERM $MOUNT_LUSTRE_PID
907 # we can not wait $MOUNT_PID because it is not a child of this shell
913 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
915 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
916 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
919 [ -z "$PID1" -a -z "$PID2" ] && break
920 echo "waiting for mount to finish ... "
921 WAIT=$(( WAIT + sleep))
923 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
924 error "MOUNT_PID $MOUNT_PID and "\
925 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
928 cleanup || error "cleanup failed with rc $?"
930 run_test 23a "interrupt client during recovery mount delay"
932 test_23b() { # was test_23
933 start_mds || error "MDS start failed"
934 start_ost || error "Unable to start OST1"
935 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
936 $LCTL set_param fail_loc=0x80000313
938 cleanup || error "cleanup failed with rc $?"
940 run_test 23b "Simulate -EINTR during mount"
943 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
945 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
946 is_blkdev $SINGLEMDS $MDSDEV &&
947 skip_env "mixed loopback and real device not working"
950 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
952 local fs2mdsdev=$(mdsdevname 1_2)
953 local fs2ostdev=$(ostdevname 1_2)
954 local fs2mdsvdev=$(mdsvdevname 1_2)
955 local fs2ostvdev=$(ostvdevname 1_2)
958 # LU-9733 test fsname started with numbers as well
959 local FSNAME2=969362ae
961 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
962 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
964 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
965 --reformat $fs2ostdev $fs2ostvdev || exit 10
968 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
969 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
970 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
971 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
973 # LU-9733 test fsname started with numbers
974 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
975 changelog_register -n) ||
976 error "register changelog failed"
978 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
979 changelog_deregister $cl_user ||
980 error "deregister changelog failed"
982 check_mount || error "check_mount failed"
983 # files written on 1 should not show up on 2
984 cp /etc/passwd $DIR/$tfile
986 [ -e $MOUNT2/$tfile ] && error "File bleed"
989 cp /etc/passwd $MOUNT2/$tfile ||
990 error "cp /etc/passwd $MOUNT2/$tfile failed"
991 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
992 # 2 is actually mounted
993 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
995 facet_failover fs2mds
996 facet_failover fs2ost
999 # the MDS must remain up until last MDT
1001 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1002 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1003 [ -z "$MDS" ] && error "No MDT"
1005 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1007 run_test 24a "Multiple MDTs on a single node"
1010 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1012 skip "needs combined MGT and MDT device"
1014 if [ -z "$fs2mds_DEV" ]; then
1015 local dev=${SINGLEMDS}_dev
1016 local MDSDEV=${!dev}
1017 is_blkdev $SINGLEMDS $MDSDEV &&
1018 skip_env "mixed loopback and real device not working"
1021 local fs2mdsdev=$(mdsdevname 1_2)
1022 local fs2mdsvdev=$(mdsvdevname 1_2)
1024 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1025 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1027 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && {
1029 error "start MDS should fail"
1032 cleanup || error "cleanup failed with rc $?"
1034 run_test 24b "Multiple MGSs on a single node (should return err)"
1038 check_mount || error "check_mount failed"
1039 local MODULES=$($LCTL modules | awk '{ print $2 }')
1040 rmmod $MODULES 2>/dev/null || true
1041 cleanup || error "cleanup failed with $?"
1043 run_test 25 "Verify modules are referenced"
1047 # we need modules before mount for sysctl, so make sure...
1048 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1049 #define OBD_FAIL_MDS_FS_SETUP 0x135
1050 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1051 start_mds && error "MDS started but should not have started"
1052 $LCTL get_param -n devices
1053 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1054 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1055 # start mds to drop writeconf setting
1056 start_mds || error "Unable to start MDS"
1057 stop_mds || error "Unable to stop MDS"
1058 unload_modules_conf || error "unload_modules_conf failed with $?"
1060 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1064 start_ost || error "Unable to start OST1"
1065 start_mds || error "Unable to start MDS"
1066 echo "Requeue thread should have started: "
1067 ps -e | grep ll_cfg_requeue
1068 set_persistent_param_and_check ost1 \
1069 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1070 "$FSNAME-OST0000.ost.client_cache_seconds"
1071 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1073 run_test 27a "Reacquire MGS lock if OST started first"
1078 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1079 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1081 facet_failover $SINGLEMDS
1082 set_persistent_param_and_check $SINGLEMDS \
1083 "mdt.$device.identity_acquire_expire" \
1084 "$device.mdt.identity_acquire_expire"
1085 set_persistent_param_and_check client \
1086 "mdc.$device-mdc-*.max_rpcs_in_flight" \
1087 "$device.mdc.max_rpcs_in_flight"
1089 cleanup || error "cleanup failed with $?"
1091 run_test 27b "Reacquire MGS lock after failover"
1093 test_28A() { # was test_28
1096 local TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1097 local PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1098 local orig=$($LCTL get_param -n $TEST)
1099 local max=$($LCTL get_param -n \
1100 llite.$FSNAME-*.max_read_ahead_per_file_mb)
1102 orig=${orig%%.[0-9]*}
1104 echo "ORIG:$orig MAX:$max"
1105 [[ $max -le $orig ]] && orig=$((max - 3))
1106 echo "ORIG:$orig MAX:$max"
1108 local final=$((orig + 1))
1110 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1111 final=$((final + 1))
1112 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1113 umount_client $MOUNT || error "umount_client $MOUNT failed"
1114 mount_client $MOUNT || error "mount_client $MOUNT failed"
1116 local result=$($LCTL get_param -n $TEST)
1118 if [ $result -ne $final ]; then
1119 error "New config not seen: wanted $final got $result"
1121 echo "New config success: got $result"
1123 set_persistent_param_and_check client "$TEST" "$PARAM" $orig
1124 cleanup || error "cleanup failed with rc $?"
1126 run_test 28A "permanent parameter setting"
1128 test_28a() { # LU-4221
1129 [[ "$OST1_VERSION" -ge $(version_code 2.5.52) ]] ||
1130 skip "Need OST version at least 2.5.52"
1131 [ "$ost1_FSTYPE" = zfs ] &&
1132 skip "LU-4221: no such proc params for ZFS OSTs"
1139 local device="$FSNAME-OST0000"
1143 # In this test we will set three kinds of proc parameters with
1144 # lctl set_param -P or lctl conf_param:
1145 # 1. non-symlink ones in the OFD
1146 # 2. non-symlink ones in the OSD
1149 # prepare a non-symlink parameter in the OFD
1150 name="client_cache_seconds"
1151 param="$device.ost.$name"
1152 cmd="obdfilter.$device.$name"
1154 # permanently setting the parameter in the OFD
1155 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1157 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1158 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1161 # prepare a non-symlink parameter in the OSD
1163 param="$device.osd.$name"
1164 cmd="osd-*.$device.$name"
1166 # conf_param the parameter in the OSD
1167 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1168 new=$(((old + 1) % 2))
1169 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1170 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1172 cleanup || error "cleanup failed with $?"
1174 run_test 28a "set symlink parameters permanently with lctl"
1177 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
1178 setup_noconfig > /dev/null 2>&1
1179 start_ost2 || error "Unable to start OST2"
1182 local PARAM="$FSNAME-OST0001.osc.active"
1183 # With lctl set_param -P the value $PROC_ACT will be sent to
1184 # all nodes. The [!M] filter out the ability to set active
1185 # on the MDS servers which is tested with wait_osp_* below.
1186 # For ost_server_uuid that only exist on client so filtering
1188 local PROC_ACT="os[cp].$FSNAME-OST0001-osc-[^M]*.active"
1189 local PROC_UUID="os[cp].$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1191 ACTV=$($LCTL get_param -n $PROC_ACT)
1193 set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
1194 # also check ost_server_uuid status
1195 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1196 if [ -z "$RESULT" ]; then
1197 error "Client not deactivated: $($LCTL get_param \
1200 echo "Live client success: got $RESULT"
1204 wait_osp_active ost ${FSNAME}-OST0001 1 0
1206 # test new client starts deactivated
1207 umount_client $MOUNT || error "umount_client $MOUNT failed"
1208 mount_client $MOUNT || error "mount_client $MOUNT failed"
1210 # the 2nd and 3rd field of ost_server_uuid do not update at the same
1211 # time when using lctl set_param -P
1212 wait_update_facet client \
1213 "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'" \
1215 error "New client start active: $($LCTL get_param -n $PROC_UUID)"
1217 echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
1219 # make sure it reactivates
1220 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1222 umount_client $MOUNT
1223 stop_ost2 || error "Unable to stop OST2"
1224 cleanup_nocli || error "cleanup_nocli failed with $?"
1225 #writeconf to remove all ost2 traces for subsequent tests
1226 writeconf_or_reformat
1228 run_test 29 "permanently remove an OST"
1233 echo Big config llog
1234 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1235 ORIG=$($LCTL get_param -n $TEST)
1236 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1237 for i in ${LIST[@]}; do
1238 set_persistent_param_and_check client "$TEST" \
1239 "$FSNAME.llite.max_read_ahead_whole_mb" $i
1241 # make sure client restart still works
1242 umount_client $MOUNT
1243 mount_client $MOUNT || error "mount_client $MOUNT failed"
1244 [ "$($LCTL get_param -n $TEST)" -ne "$i" ] &&
1245 error "Param didn't stick across restart $($TEST) != $i"
1248 echo Erase parameter setting
1249 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1250 do_facet mgs "$PERM_CMD -d $TEST" ||
1251 error "Erase param $TEST failed"
1253 do_facet mgs "$PERM_CMD \
1254 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1255 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1257 umount_client $MOUNT
1258 mount_client $MOUNT || error "mount_client $MOUNT failed"
1259 FINAL=$($LCTL get_param -n $TEST)
1260 echo "deleted (default) value=$FINAL, orig=$ORIG"
1261 ORIG=${ORIG%%.[0-9]*}
1262 FINAL=${FINAL%%.[0-9]*}
1263 # assumes this parameter started at the default value
1264 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1266 cleanup || error "cleanup failed with rc $?"
1268 run_test 30a "Big config llog and permanent parameter deletion"
1273 local orignids=$($LCTL get_param -n \
1274 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1276 local orignidcount=$(echo "$orignids" | wc -w)
1278 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1279 # numerical part of it. Hopefully that's not already a failover address
1281 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1283 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1284 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1285 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1286 echo "Using fake nid $NEW"
1288 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1289 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1290 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1291 PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
1292 echo "Setting $PARAM from $TEST to $NEW"
1293 do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
1294 error "$PERM_CMD $PARAM failed"
1296 PARAM="$FSNAME-OST0000.failover.node"
1297 echo "Setting $PARAM from $TEST to $NEW"
1298 do_facet mgs "$PERM_CMD $PARAM='$NEW'" ||
1299 error "$PARAM $PARAM failed"
1301 wait_update_facet client "$TEST" "$NEW" ||
1302 error "check $PARAM failed!"
1304 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1306 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1307 echo "should have $((orignidcount + 1)) entries \
1308 in failover nids string, have $NIDCOUNT"
1309 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1310 error "Failover nid not added"
1312 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1313 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1315 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1316 error "$PERM_CMD delete failed"
1318 umount_client $MOUNT
1319 mount_client $MOUNT || error "mount_client $MOUNT failed"
1321 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1323 NIDCOUNT=$(echo "$NIDS" | wc -w)
1324 echo "only $orignidcount final entries should remain \
1325 in failover nids string, have $NIDCOUNT"
1326 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1328 cleanup || error "cleanup failed with rc $?"
1330 run_test 30b "Remove failover nids"
1332 test_31() { # bug 10734
1333 # ipaddr must not exist
1334 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1335 cleanup || error "cleanup failed with rc $?"
1337 run_test 31 "Connect to non-existent node (shouldn't crash)"
1341 T32_BLIMIT=40960 # Kbytes
1345 # This is not really a test but a tool to create new disk
1346 # image tarballs for the upgrade tests.
1348 # Disk image tarballs should be created on single-node
1349 # clusters by running this test with default configurations
1350 # plus a few mandatory environment settings that are verified
1351 # at the beginning of the test.
1353 test_32newtarball() {
1357 local tmp=$TMP/t32_image_create
1362 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1363 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1364 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1365 "MDSDEV1=<nonexistent_file>" \
1366 "MDSDEV2=<nonexistent_file>" \
1367 "(or MDSDEV, in the case of b1_8)" \
1368 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1372 echo "Found stale $tmp"
1376 mkdir $tmp/src || return 1
1377 tar cf - -C $src . | tar xf - -C $tmp/src
1378 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1379 count=$(($T32_BLIMIT / 1024 / 4))
1380 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1382 # format ost with comma-separated NIDs to verify LU-4460
1383 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1384 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1388 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1389 $LFS quotacheck -ug /mnt/$FSNAME
1390 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1393 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1395 if [[ $MDSCOUNT -ge 2 ]]; then
1396 remote_dir=/mnt/$FSNAME/remote_dir
1397 $LFS mkdir -i 1 $remote_dir
1398 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1400 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1401 striped_dir=/mnt/$FSNAME/striped_dir_old
1402 $LFS mkdir -i 1 -c 2 $striped_dir
1403 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1409 mkdir $tmp/img || return 1
1413 pushd_dir=/mnt/$FSNAME
1414 if [[ $MDSCOUNT -ge 2 ]]; then
1415 pushd_dir=$remote_dir
1416 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1418 ls -Rni --time-style=+%s >$tmp/img/list2
1424 ls -Rni --time-style=+%s >$tmp/img/list
1425 find ! -name .lustre -type f -exec sha1sum {} \; |
1426 sort -k 2 >$tmp/img/sha1sums
1428 $LCTL get_param -n version | head -n 1 |
1429 sed -e 's/^lustre: *//' >$tmp/img/commit
1431 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1432 $LFS quotaon -ug /mnt/$FSNAME
1433 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1434 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1435 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1436 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1437 | tr -d "*" > $tmp/img/bspace
1438 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1439 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1440 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1441 | tr -d "*" > $tmp/img/ispace
1442 echo $T32_BLIMIT > $tmp/img/blimit
1443 echo $T32_ILIMIT > $tmp/img/ilimit
1445 $MULTIOP /mnt/$FSNAME/orph_file Ouw_c&
1449 debugfs -R "ls /PENDING" ${MDSDEV1:-$MDSDEV}
1450 cp ${MDSDEV1:-$MDSDEV} $tmp/img
1458 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1461 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1462 echo "Data verification failed"
1465 uname -r >$tmp/img/kernel
1466 uname -m >$tmp/img/arch
1468 for num in $(seq 2 $MDSCOUNT); do
1469 local devname=$(mdsdevname $num)
1471 [[ $(facet_fstype $facet) != zfs ]] ||
1472 devname=$(mdsvdevname $num)
1473 mv $devname $tmp/img
1475 mv $OSTDEV1 $tmp/img
1477 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1478 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1481 tar cjvf $dst/disk$version-"$mds1_FSTYPE".tar.bz2 -S *
1486 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1489 # The list of applicable tarballs is returned via the caller's
1490 # variable "tarballs".
1493 [ "$CLIENTONLY" ] && skip "Client-only testing"
1495 local node=$(facet_active_host $SINGLEMDS)
1496 local r="do_node $node"
1498 ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
1500 local IMGTYPE="$mds1_FSTYPE"
1502 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1503 -name \'disk*-$IMGTYPE.tar.bz2\')
1505 [ -z "$tarballs" ] && skip "No applicable tarballs found"
1508 t32_test_cleanup() {
1510 local facet=$SINGLEMDS
1513 if $shall_cleanup_lustre; then
1514 umount $tmp/mnt/lustre || rc=$?
1516 if $shall_cleanup_mdt; then
1517 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1519 if $shall_cleanup_mdt1; then
1520 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1522 if $shall_cleanup_ost; then
1523 $r $UMOUNT $tmp/mnt/ost || rc=$?
1528 if [[ "$mds1_FSTYPE" == zfs ]]; then
1530 local poolname_list="t32fs-mdt1 t32fs-ost1"
1532 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1534 for poolname in $poolname_list; do
1535 destroy_zpool $facet $poolname
1538 combined_mgs_mds || start_mgs || rc=$?
1542 t32_bits_per_long() {
1544 # Yes, this is not meant to be perfect.
1554 t32_reload_modules() {
1556 local all_removed=false
1559 [ "$mds1_FSTYPE" == zfs ] && do_rpc_nodes $node "service zed stop"
1561 while ((i < 20)); do
1562 echo "Unloading modules on $node: Attempt $i"
1563 do_rpc_nodes $node $LUSTRE_RMMOD "$mds1_FSTYPE" &&
1565 do_rpc_nodes $node check_mem_leak || return 1
1566 if $all_removed; then
1567 do_rpc_nodes $node load_modules
1570 if [ "$mds1_FSTYPE" == zfs ]; then
1571 do_rpc_nodes $node "$ZPOOL status -v"
1576 echo "Unloading modules on $node: Given up"
1580 t32_wait_til_devices_gone() {
1586 echo wait for devices to go
1587 while ((i < 20)); do
1588 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1589 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1590 ((devices == 0 && loops == 0)) && return 0
1594 echo "waiting for dev on $node: dev $devices loop $loops given up"
1595 do_rpc_nodes $node "losetup -a"
1596 do_rpc_nodes $node "$LCTL device_list"
1600 t32_verify_quota() {
1607 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1608 # lustre will estimate the object count usage. This fails quota
1609 # verification in 32b. The object quota usage should be accurate after
1610 # zfs-0.7.0 is released.
1611 [ "$mds1_FSTYPE" == zfs ] && {
1612 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1614 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1615 echo "Skip quota verify for zfs: $zfs_version"
1620 $LFS quota -u $T32_QID -v $mnt
1622 qval=$($LFS quota -v -u $T32_QID $mnt |
1623 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1624 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1626 [ $qval -eq $img_bspace ] || {
1627 echo "bspace, act:$qval, exp:$img_bspace"
1631 qval=$($LFS quota -v -u $T32_QID $mnt |
1632 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1633 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1635 [ $qval -eq $img_ispace ] || {
1636 echo "ispace, act:$qval, exp:$img_ispace"
1640 qval=$($LFS quota -v -u $T32_QID $mnt |
1641 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1642 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1644 [ $qval -eq $img_blimit ] || {
1645 echo "blimit, act:$qval, exp:$img_blimit"
1649 qval=$($LFS quota -v -u $T32_QID $mnt |
1650 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1651 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1653 [ $qval -eq $img_ilimit ] || {
1654 echo "ilimit, act:$qval, exp:$img_ilimit"
1658 set_persistent_param_and_check $facet \
1659 "osd-$mds1_FSTYPE.$fsname-MDT0000.quota_slave.enabled" \
1660 "$fsname.quota.mdt" ug
1662 set_persistent_param_and_check $facet \
1663 "osd-$mds1_FSTYPE.$fsname-OST0000.quota_slave.enabled" \
1664 "$fsname.quota.ost" ug
1667 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1668 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1669 echo "Write succeed, but expect -EDQUOT"
1672 rm -f $mnt/t32_qf_new
1674 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1676 echo "Create succeed, but expect -EDQUOT"
1679 unlinkmany $mnt/t32_qf_ $img_ilimit
1687 local dne_upgrade=${dne_upgrade:-"no"}
1688 local dom_upgrade=${dom_upgrade:-"no"}
1689 local project_upgrade=${project_upgrade:-"no"}
1690 local ff_convert=${ff_convert:-"no"}
1691 local shall_cleanup_mdt=false
1692 local shall_cleanup_mdt1=false
1693 local shall_cleanup_ost=false
1694 local shall_cleanup_lustre=false
1695 local mdt2_is_available=false
1696 local node=$(facet_active_host $SINGLEMDS)
1697 local r="do_node $node"
1713 local mdt_dev=$tmp/mdt
1714 local mdt2_dev=$tmp/mdt2
1715 local ost_dev=$tmp/ost
1720 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1721 trap 'trap - RETURN; t32_test_cleanup' RETURN
1724 nid=$($r $LCTL list_nids | head -1)
1726 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1727 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1728 $r tar xjvf $tarball -S -C $tmp || {
1729 error_noexit "Unpacking the disk image tarball"
1732 img_commit=$($r cat $tmp/commit)
1733 img_kernel=$($r cat $tmp/kernel)
1734 img_arch=$($r cat $tmp/arch)
1735 img_bspace=$($r cat $tmp/bspace)
1736 img_ispace=$($r cat $tmp/ispace)
1738 # older images did not have "blimit" and "ilimit" files
1739 # use old values for T32_BLIMIT and T32_ILIMIT
1740 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1742 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1745 echo "Upgrading from $(basename $tarball), created with:"
1746 echo " Commit: $img_commit"
1747 echo " Kernel: $img_kernel"
1748 echo " Arch: $img_arch"
1749 echo "OST version: $(lustre_build_version ost1)"
1751 # The conversion can be made only when both of the following
1752 # conditions are satisfied:
1753 # - ost device img version < 2.3.64
1754 # - ost server version >= 2.5
1755 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1756 "$OST1_VERSION" -lt $(version_code 2.5.0) ] &&
1759 ! $r test -f $mdt2_dev || mdt2_is_available=true
1761 if [[ "$mds1_FSTYPE" == zfs ]]; then
1764 local poolname_list="t32fs-mdt1 t32fs-ost1"
1766 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1768 for poolname in $poolname_list; do
1770 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1771 $ZPOOL import -f -d $tmp $poolname"
1774 # upgrade zpool to latest supported features, including
1775 # dnode quota accounting in 0.7.0
1776 $r "$ZPOOL upgrade -a"
1778 mdt_dev=t32fs-mdt1/mdt1
1779 ost_dev=t32fs-ost1/ost1
1780 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1781 wait_update_facet $SINGLEMDS "$ZPOOL list |
1782 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1783 error_noexit "import zfs pool failed"
1786 elif [ "$project_upgrade" != "no" ]; then
1787 ! $r tune2fs -O project $mdt_dev &&
1788 error_noexit "enable project on mdt0 failed" &&
1790 $mdt2_is_available && ! $r tune2fs "-O project" $mdt2_dev &&
1791 error_noexit "enable project on mdt failed" &&
1793 ! $r tune2fs -O project $ost_dev &&
1794 error_noexit "enable project on mdt failed" &&
1798 $r $LCTL set_param debug="$PTLDEBUG"
1800 $r $TUNEFS --dryrun $mdt_dev || {
1802 error_noexit "tunefs.lustre before mounting the MDT"
1806 if $mdt2_is_available; then
1807 $r $TUNEFS --dryrun $mdt2_dev || {
1809 error_noexit "tunefs.lustre before mounting the MDT"
1814 if [ "$writeconf" ]; then
1816 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1818 $r $TUNEFS --quota $mdt_dev || {
1820 error_noexit "Enable mdt quota feature"
1823 if $mdt2_is_available; then
1824 $r $TUNEFS --quota $mdt2_dev || {
1826 error_noexit "Enable mdt quota feature"
1832 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1833 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
1834 skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
1835 "(Need MGS version at least 2.3.59)"
1837 local osthost=$(facet_active_host ost1)
1838 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1841 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1844 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1845 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1846 $r $LCTL replace_nids $fsname-MDT0000 $nid
1847 $r $UMOUNT $tmp/mnt/mdt
1850 mopts=exclude=$fsname-OST0000
1851 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1856 t32_wait_til_devices_gone $node
1858 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1860 error_noexit "Mounting the MDT"
1863 shall_cleanup_mdt=true
1865 if $mdt2_is_available; then
1866 mopts=mgsnode=$nid,$mopts
1867 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1869 error_noexit "Mounting the MDT"
1873 echo "mount new MDT....$mdt2_dev"
1874 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1875 error_noexit "enable remote dir create failed"
1877 shall_cleanup_mdt1=true
1878 elif [ "$dne_upgrade" != "no" ]; then
1879 local fs2mdsdev=$(mdsdevname 1_2)
1880 local fs2mdsvdev=$(mdsvdevname 1_2)
1882 echo "mkfs new MDT on ${fs2mdsdev}...."
1883 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1884 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1887 add $SINGLEMDS $(mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1888 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1889 error_noexit "Mkfs new MDT failed"
1893 [[ "$mds1_FSTYPE" != zfs ]] || import_zpool mds1
1895 $r $TUNEFS --dryrun $fs2mdsdev || {
1896 error_noexit "tunefs.lustre before mounting the MDT"
1900 echo "mount new MDT....$fs2mdsdev"
1901 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1902 error_noexit "mount mdt1 failed"
1906 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1907 error_noexit "enable remote dir create failed"
1909 shall_cleanup_mdt1=true
1912 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1913 error_noexit "Getting MDT UUID"
1916 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1917 error_noexit "Unexpected MDT UUID: \"$uuid\""
1921 $r $TUNEFS --dryrun $ost_dev || {
1922 error_noexit "tunefs.lustre before mounting the OST"
1925 if [ "$writeconf" ]; then
1926 mopts=mgsnode=$nid,$writeconf
1927 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1929 $r $TUNEFS --quota $ost_dev || {
1931 error_noexit "Enable ost quota feature"
1937 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1942 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1943 error_noexit "Mounting the OST"
1946 shall_cleanup_ost=true
1948 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1949 error_noexit "Getting OST UUID"
1952 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1953 error_noexit "Unexpected OST UUID: \"$uuid\""
1957 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1958 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
1959 error_noexit "Setting OST \"failover.node\""
1962 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
1963 error_noexit "Setting MDT \"failover.node\""
1966 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
1967 error_noexit "Setting \"max_dirty_mb\""
1970 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
1971 error_noexit "Setting \"max_rpcs_in_flight\""
1974 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
1975 error_noexit "Setting \"lov.stripesize\""
1978 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
1979 error_noexit "Setting \"mdd.atime_diff\""
1983 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
1984 error_noexit "Setting OST \"failover.node\""
1988 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
1989 error_noexit "Setting MDT \"failover.node\""
1993 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
1994 error_noexit "Setting \"max_dirty_mb\""
1997 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1998 error_noexit "Setting \"max_rpcs_in_flight\""
2001 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
2002 error_noexit "Setting \"lov.stripesize\""
2005 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
2006 error_noexit "Setting \"mdd.atime_diff\""
2011 $r $LCTL pool_new $fsname.interop || {
2012 error_noexit "Setting \"interop\""
2016 if [ "$ff_convert" != "no" -a "$ost1_FSTYPE" == ldiskfs ]; then
2017 $r $LCTL lfsck_start -M $fsname-OST0000 || {
2018 error_noexit "Start OI scrub on OST0"
2022 # The oi_scrub should be on ost1, but for test_32(),
2023 # all on the SINGLEMDS.
2024 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
2025 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2026 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
2027 error_noexit "Failed to get the expected 'completed'"
2031 local UPDATED=$($r $LCTL get_param -n \
2032 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2033 awk '/^updated/ { print $2 }')
2034 [ $UPDATED -ge 1 ] || {
2035 error_noexit "Only $UPDATED objects have been converted"
2040 if [ "$dne_upgrade" != "no" ]; then
2041 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2042 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
2043 error_noexit "Setting MDT1 \"failover.node\""
2047 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
2048 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2051 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
2052 error_noexit "Setting MDT1 \"lov.stripesize\""
2056 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
2057 error_noexit "Setting MDT1 \"failover.node\""
2060 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2061 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2064 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2065 error_noexit "Setting MDT1 \"lov.stripesize\""
2071 if [ "$writeconf" ]; then
2072 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2073 error_noexit "Mounting the client"
2077 shall_cleanup_lustre=true
2078 $r $LCTL set_param debug="$PTLDEBUG"
2080 # Leave re-enabling this to a separate patch for LU-11558
2081 # t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2082 # error_noexit "verify quota failed"
2086 if $r test -f $tmp/list; then
2088 # There is not a Test Framework API to copy files to or
2089 # from a remote node.
2091 # LU-2393 - do both sorts on same node to ensure locale
2093 local list_file=$tmp/list
2095 if $mdt2_is_available; then
2096 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2097 $r test -f $tmp/list2; then
2098 list_file=$tmp/list2
2099 pushd $tmp/mnt/lustre/striped_dir_old
2101 pushd $tmp/mnt/lustre/remote_dir
2104 pushd $tmp/mnt/lustre
2106 $r cat $list_file | sort -k 6 >$tmp/list.orig
2107 ls -Rni --time-style=+%s | sort -k 6 |
2108 sed 's/\. / /' >$tmp/list || {
2114 # 32-bit and 64-bit clients use different algorithms to
2115 # convert FIDs into inode numbers. Hence, remove the
2116 # inode numbers from the lists, if the original list was
2117 # created on an architecture with different number of
2120 if [ $(t32_bits_per_long $(uname -m)) != \
2121 $(t32_bits_per_long $img_arch) ]; then
2122 echo "Different number of bits per \"long\"" \
2123 "from the disk image"
2124 for list in list.orig list; do
2125 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2129 if ! diff -ub $tmp/list.orig $tmp/list; then
2130 error_noexit "list verification failed"
2134 echo "list verification skipped"
2137 if [ "$dom_upgrade" != "no" ]; then
2138 echo "Check DoM file can be created"
2139 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2140 error_noexit "Verify DoM creation"
2143 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2144 error_noexit "Verify a DoM file"
2147 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2148 count=1 conv=fsync || {
2149 error_noexit "Cannot write to DoM file"
2152 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2153 error_noexit "DoM: bad size after write"
2156 rm $tmp/mnt/lustre/dom
2158 set_persistent_param_and_check mds \
2159 "lod.*MDT0000*.dom_stripesize" \
2160 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2161 error_noexit "Changing \"dom_stripesize\""
2166 if [ "$dne_upgrade" != "no" ]; then
2167 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2168 error_noexit "set striped dir failed"
2172 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2174 pushd $tmp/mnt/lustre
2175 tar -c --exclude=./striped_dir \
2176 --exclude=./striped_dir_old \
2177 --exclude=./remote_dir -f - .|
2178 tar -xvf - -C striped_dir 1>/dev/null || {
2179 error_noexit "cp to striped dir failed"
2185 # If it is upgrade from DNE (2.5), then rename the remote dir,
2186 # which is created in 2.5 to striped dir.
2187 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2188 stripe_index=$($LFS getdirstripe -i \
2189 $tmp/mnt/lustre/remote_dir)
2191 [[ $stripe_index -eq 1 ]] || {
2192 error_noexit "get index \"$stripe_index\"" \
2193 "from remote dir failed"
2196 mv $tmp/mnt/lustre/remote_dir \
2197 $tmp/mnt/lustre/striped_dir/ || {
2198 error_noexit "mv remote dir failed"
2203 # If it is upgraded from DNE (2.7), then move the striped dir
2204 # which was created in 2.7 to the new striped dir.
2205 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2206 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2207 stripe_count=$($LFS getdirstripe -c \
2208 $tmp/mnt/lustre/striped_dir_old)
2209 [[ $stripe_count -eq 2 ]] || {
2210 error_noexit "get count $stripe_count" \
2211 "from striped dir failed"
2214 mv $tmp/mnt/lustre/striped_dir_old \
2215 $tmp/mnt/lustre/striped_dir/ || {
2216 error_noexit "mv striped dir failed"
2222 $r $LCTL set_param -n osd*.*.force_sync=1
2223 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2224 error_noexit "dd failed"
2227 rm -rf $tmp/mnt/lustre/tmp_file || {
2228 error_noexit "rm failed"
2232 if $r test -f $tmp/sha1sums; then
2233 # LU-2393 - do both sorts on same node to ensure locale
2235 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2236 if [ "$dne_upgrade" != "no" ]; then
2237 pushd $tmp/mnt/lustre/striped_dir
2239 pushd $tmp/mnt/lustre
2242 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2243 ! -name .lustre -type f -exec sha1sum {} \; |
2244 sort -k 2 >$tmp/sha1sums || {
2246 error_noexit "sha1sum"
2250 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2251 error_noexit "sha1sum verification failed"
2255 # if upgrade from DNE(2.5), then check remote directory
2256 # if upgrade from DNE(2.7), then check striped directory
2257 if $mdt2_is_available &&
2258 [[ "$dne_upgrade" != "no" ]]; then
2259 local new_dir="$tmp/mnt/lustre/striped_dir"
2260 local striped_dir_old="$new_dir/striped_dir_old"
2262 local dir_list="$new_dir/remote_dir"
2263 [[ ! -d $triped_dir_old ]] ||
2264 dir_list+=" $striped_dir_old"
2266 for dir in $dir_list; do
2268 find ! -name .lustre -type f \
2269 -exec sha1sum {} \; |
2270 sort -k 2 >$tmp/sha1sums || {
2272 error_noexit "sha1sum"
2276 if ! diff -ub $tmp/sha1sums.orig \
2278 error_noexit "sha1sum $dir" \
2285 echo "sha1sum verification skipped"
2288 if [ "$dne_upgrade" != "no" ]; then
2289 rm -rf $tmp/mnt/lustre/striped_dir || {
2290 error_noexit "remove remote dir failed"
2295 # migrate files/dirs to remote MDT, then move them back
2296 if [ "$MDS1_VERSION" -ge $(version_code 2.7.50) -a \
2297 $dne_upgrade != "no" ]; then
2298 $r $LCTL set_param -n \
2299 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2301 echo "test migration"
2302 pushd $tmp/mnt/lustre
2303 for dir in $(find ! -name .lustre ! -name . -type d); do
2304 mdt_index=$($LFS getdirstripe -i $dir)
2305 stripe_cnt=$($LFS getdirstripe -c $dir)
2306 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2307 $LFS migrate -m 1 $dir || {
2309 error_noexit "migrate MDT1 failed"
2315 for dir in $(find ! -name . ! -name .lustre -type d); do
2316 mdt_index=$($LFS getdirstripe -i $dir)
2317 stripe_cnt=$($LFS getdirstripe -c $dir)
2318 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2319 $LFS migrate -m 0 $dir || {
2321 error_noexit "migrate MDT0 failed"
2330 # When adding new data verification tests, please check for
2331 # the presence of the required reference files first, like
2332 # the "sha1sums" and "list" tests above, to avoid the need to
2333 # regenerate every image for each test addition.
2336 nrpcs_orig=$($LCTL get_param \
2337 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2338 error_noexit "Getting \"max_rpcs_in_flight\""
2341 nrpcs=$((nrpcs_orig + 5))
2343 set_persistent_param_and_check client \
2344 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
2345 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
2346 error_noexit "Changing \"max_rpcs_in_flight\""
2350 umount $tmp/mnt/lustre || {
2351 error_noexit "Unmounting the client"
2354 shall_cleanup_lustre=false
2356 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2357 error_noexit "Mounting the client"
2361 if [ "$mds1_FSTYPE" == ldiskfs -a \
2362 "$project_upgrade" != "no" ]; then
2363 ! $LFS project -d -p 1 $tmp/mnt/lustre/* &&
2364 error_noexit "set project failed" &&
2368 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) == 0 ]] ||
2369 error "MDD orphan cleanup thread not quit"
2371 umount $tmp/mnt/lustre || {
2372 error_noexit "Unmounting the client"
2376 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2377 $r $UMOUNT $tmp/mnt/mdt1 || {
2378 error_noexit "Unmounting the MDT2"
2381 if [[ "$mds1_FSTYPE" == zfs ]]; then
2382 $r "$ZPOOL export t32fs-mdt2"
2384 shall_cleanup_mdt1=false
2387 $r $UMOUNT $tmp/mnt/mdt || {
2388 error_noexit "Unmounting the MDT"
2391 if [[ "$mds1_FSTYPE" == zfs ]]; then
2392 $r "$ZPOOL export t32fs-mdt1"
2394 shall_cleanup_mdt=false
2396 $r $UMOUNT $tmp/mnt/ost || {
2397 error_noexit "Unmounting the OST"
2400 if [[ "$mds1_FSTYPE" == zfs ]]; then
2401 $r "$ZPOOL export t32fs-ost1"
2403 shall_cleanup_ost=false
2405 t32_reload_modules $node || {
2406 error_noexit "Reloading modules"
2410 if [[ "$mds1_FSTYPE" == zfs ]]; then
2411 local poolname=t32fs-mdt1
2413 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2414 $ZPOOL import -f -d $tmp $poolname"
2416 # upgrade zpool to latest supported features,
2417 # including dnode quota accounting in 0.7.0
2418 $r "$ZPOOL upgrade $poolname"
2421 # mount a second time to make sure we didnt leave upgrade flag on
2422 $r $TUNEFS --dryrun $mdt_dev || {
2424 error_noexit "tunefs.lustre before remounting the MDT"
2428 mopts=exclude=$fsname-OST0000
2429 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2432 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2433 error_noexit "Remounting the MDT"
2436 shall_cleanup_mdt=true
2446 for tarball in $tarballs; do
2447 banner "testing $tarball upgrade"
2448 t32_test $tarball || let "rc += $?"
2452 run_test 32a "Upgrade (not live)"
2460 for tarball in $tarballs; do
2461 banner "testing $tarball upgrade with writeconf"
2462 t32_test $tarball writeconf || let "rc += $?"
2466 run_test 32b "Upgrade with writeconf"
2473 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2475 for tarball in $tarballs; do
2476 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2477 [[ "$tarball" =~ "1_8" ]] && echo "skip $tarball" && continue
2478 [[ "$tarball" =~ "2_1" ]] && echo "skip $tarball" && continue
2479 banner "testing $tarball upgrade with DNE"
2481 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2485 run_test 32c "dne upgrade test"
2493 for tarball in $tarballs; do
2494 banner "testing $tarball upgrade with ff convert and project upgrade"
2495 project_upgrade="no"
2496 [[ "$MDS1_VERSION" -ge $(version_code 2.13.54) ]] &&
2497 [[ "$tarball" =~ "disk2_4-ldiskfs" ]] &&
2498 project_upgrade="yes"
2499 project_upgrade=$project_upgrade ff_convert=yes t32_test \
2504 run_test 32d "convert ff and project quota upgrade test"
2507 [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
2508 skip "Need MDS version at least 2.10.56"
2515 for tarball in $tarballs; do
2516 [[ "$tarball" =~ "2_9" ]] || continue
2518 banner "testing $tarball upgrade with DoM"
2519 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
2523 run_test 32e "dom upgrade test"
2525 test_33a() { # bug 12333, was test_33
2526 local FSNAME2=test-123
2527 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2530 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2532 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2533 local dev=${SINGLEMDS}_dev
2534 local MDSDEV=${!dev}
2535 is_blkdev $SINGLEMDS $MDSDEV &&
2536 skip_env "mixed loopback and real device not working"
2539 local fs2mdsdev=$(mdsdevname 1_2)
2540 local fs2ostdev=$(ostdevname 1_2)
2541 local fs2mdsvdev=$(mdsvdevname 1_2)
2542 local fs2ostvdev=$(ostvdevname 1_2)
2544 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2545 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2548 if combined_mgs_mds; then
2549 local mgs_flag="--mgs"
2552 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
2553 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
2555 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2556 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2557 $fs2ostvdev || exit 10
2559 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2560 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2562 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2563 do_facet mgs "$PERM_CMD timeout=200" ||
2564 error "$PERM_CMD timeout=200 failed"
2566 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
2567 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
2569 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2570 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2573 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2574 $LFS getstripe $MOUNT2/hosts ||
2575 error "$LFS getstripe $MOUNT2/hosts failed"
2580 cleanup_nocli || error "cleanup_nocli failed with $?"
2582 run_test 33a "Mount ost with a large index number"
2584 test_33b() { # was test_34
2587 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2588 # Drop lock cancelation reply during umount
2589 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2590 do_facet client $LCTL set_param fail_loc=0x80000304
2591 #lctl set_param debug=-1
2592 umount_client $MOUNT
2593 cleanup || error "cleanup failed with $?"
2595 run_test 33b "Drop cancel during umount"
2599 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2600 manual_umount_client
2602 do_facet client killall -USR1 multiop
2603 if [ $rc -eq 0 ]; then
2604 error "umount not fail!"
2607 cleanup || error "cleanup failed with rc $?"
2609 run_test 34a "umount with opened file should be fail"
2613 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2614 stop_mds || error "Unable to stop MDS"
2616 manual_umount_client --force || error "mtab after failed umount with $?"
2618 cleanup || error "cleanup failed with $?"
2620 run_test 34b "force umount with failed mds should be normal"
2624 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2625 stop_ost || error "Unable to stop OST1"
2627 manual_umount_client --force || error "mtab after failed umount with $?"
2629 cleanup || error "cleanup failed with $?"
2631 run_test 34c "force umount with failed ost should be normal"
2633 test_35a() { # bug 12459
2636 DBG_SAVE="`$LCTL get_param -n debug`"
2637 $LCTL set_param debug="ha"
2639 log "Set up a fake failnode for the MDS"
2641 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2642 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2644 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2645 do_facet mgs "$PERM_CMD \
2646 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2647 error "Setting mdc.*${device}*.import=connection=\
2648 $(h2nettype $FAKENID) failed."
2650 do_facet mgs "$PERM_CMD \
2651 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2652 error "Setting ${device}.failover.node=\
2653 $(h2nettype $FAKENID) failed."
2655 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2658 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2661 log "Stopping the MDT: $device"
2662 stop_mdt 1 || error "MDT0 stop fail"
2664 df $MOUNT > /dev/null 2>&1 &
2666 log "Restarting the MDT: $device"
2667 start_mdt 1 || error "MDT0 start fail"
2668 log "Wait for df ($DFPID) ... "
2671 $LCTL set_param debug="$DBG_SAVE"
2673 # retrieve from the log the first server that the client tried to
2674 # contact after the connection loss
2675 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2676 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2677 /import_select_connection.*$device-mdc.* using connection/ {
2679 if (\\\$NF ~ /$FAKENID/)
2685 }" $TMP/lustre-log-$TESTNAME.log`
2686 [ "$NEXTCONN" != "0" ] &&
2687 error "Tried to connect to ${NEXTCONN} not last active server"
2688 cleanup || error "cleanup failed with $?"
2689 # remove nid settings
2690 writeconf_or_reformat
2692 run_test 35a "Reconnect to the last active server first"
2694 test_35b() { # bug 18674
2695 remote_mds || skip "local MDS"
2699 $LCTL set_param debug="ha"
2701 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2704 log "Set up a fake failnode for the MDS"
2706 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2707 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2709 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2710 do_facet mgs "$PERM_CMD \
2711 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2712 error "Set mdc.*${device}*.import=connection=\
2713 $(h2nettype $FAKENID) failed"
2715 do_facet mgs "$PERM_CMD \
2716 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2717 error "Set ${device}.failover.node=\
2718 $(h2nettype $FAKENID) failed"
2721 local at_max_saved=0
2722 # adaptive timeouts may prevent seeing the issue
2723 if at_is_enabled; then
2724 at_max_saved=$(at_max_get mds)
2725 at_max_set 0 mds client
2728 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2730 log "Injecting EBUSY on MDS"
2731 # Setting OBD_FAIL_MDS_RESEND=0x136
2732 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2733 error "unable to set param fail_loc=0x80000136"
2735 $LCTL set_param mdc.${FSNAME}*.stats=clear
2737 log "Creating a test file and stat it"
2738 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2739 stat $MOUNT/$tdir/$tfile
2741 log "Stop injecting EBUSY on MDS"
2742 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2743 error "unable to set param fail_loc=0"
2744 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2747 # restore adaptive timeout
2748 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2750 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2752 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2753 awk '/mds_connect/{print $2}')
2755 # retrieve from the log if the client has ever tried to
2756 # contact the fake server after the loss of connection
2757 FAILCONN=`awk "BEGIN {ret = 0;}
2758 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2760 if (\\\$NF ~ /$FAKENID/) {
2765 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2767 [ "$FAILCONN" == "0" ] &&
2768 error "The client reconnection has not been triggered"
2769 [ "$FAILCONN" == "2" ] &&
2770 error "Primary server busy, client reconnect to failover failed"
2773 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2774 # Reconnects are supposed to be rate limited to one every 5s
2775 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2776 error "Too many reconnects $CONNCNT"
2778 cleanup || error "cleanup failed with $?"
2779 # remove nid settings
2780 writeconf_or_reformat
2782 run_test 35b "Continue reconnection retries, if the active server is busy"
2785 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2787 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2791 local FSNAME2=test1234
2792 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2794 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2796 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2797 is_blkdev $SINGLEMDS $MDSDEV &&
2798 skip_env "mixed loopback and real device not working"
2801 local fs2mdsdev=$(mdsdevname 1_2)
2802 local fs2ostdev=$(ostdevname 1_2)
2803 local fs3ostdev=$(ostdevname 2_2)
2804 local fs2mdsvdev=$(mdsvdevname 1_2)
2805 local fs2ostvdev=$(ostvdevname 1_2)
2806 local fs3ostvdev=$(ostvdevname 2_2)
2809 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2810 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2811 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2812 # different one than the default value here.
2813 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2814 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2815 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2816 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2818 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2819 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2820 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2821 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2822 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2824 sleep 5 # until 11778 fixed
2826 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2828 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2829 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2830 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2831 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2832 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2833 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2834 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2835 DFTOTAL=$(echo $STRING | cut -d, -f1)
2836 DFUSED=$(echo $STRING | cut -d, -f2)
2837 DFAVAIL=$(echo $STRING | cut -d, -f3)
2838 DFFREE=$(($DFTOTAL - $DFUSED))
2840 ALLOWANCE=$((64 * $OSTCOUNT))
2842 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2843 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2844 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2847 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2848 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2849 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2852 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2853 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2854 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2859 stop fs3ost -f || error "unable to stop OST3"
2860 stop fs2ost -f || error "unable to stop OST2"
2861 stop fs2mds -f || error "unable to stop second MDS"
2862 unload_modules_conf || error "unable unload modules"
2865 run_test 36 "df report consistency on OSTs with different block size"
2868 local mntpt=$(facet_mntpt $SINGLEMDS)
2869 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2870 local mdsdev_sym="$TMP/sym_mdt.img"
2871 local opts=$MDS_MOUNT_OPTS
2874 if [ "$mds1_FSTYPE" != ldiskfs ]; then
2875 skip "ldiskfs only test"
2878 echo "MDS : $mdsdev"
2879 echo "SYMLINK : $mdsdev_sym"
2880 do_facet $SINGLEMDS rm -f $mdsdev_sym
2882 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2884 echo "mount symlink device - $mdsdev_sym"
2886 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2887 opts=$(csa_add "$opts" -o loop)
2891 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2892 $mdsdev_sym $mntpt 2>&1)
2895 echo mount_op=$mount_op
2897 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2899 if $(echo $mount_op | grep -q "unable to set tunable"); then
2900 error "set tunables failed for symlink device"
2903 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2905 run_test 37 "verify set tunables works for symlink device"
2907 test_38() { # bug 14222
2908 local mntpt=$(facet_mntpt $SINGLEMDS)
2913 local SRC="/etc /bin"
2914 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2915 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2916 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2917 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2918 error "copying $SRC to $DIR/$tdir"
2920 umount_client $MOUNT || error "umount_client $MOUNT failed"
2921 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2922 stop_mds || error "Unable to stop MDS"
2923 log "delete lov_objid file on MDS"
2925 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2927 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2929 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2931 # check create in mds_lov_connect
2932 start_mds || error "unable to start MDS"
2933 mount_client $MOUNT || error "mount_client $MOUNT failed"
2935 [ $V ] && log "verifying $DIR/$tdir/$f"
2936 diff -q $f $DIR/$tdir/$f || ERROR=y
2938 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2939 if [ "$ERROR" = "y" ]; then
2940 # check it's updates in sync
2941 umount_client $MOUNT
2943 mount_fstype $SIGNLEMDS
2944 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2945 unmount_fstype $SINGLEMDS
2946 error "old and new files are different after connect" || true
2948 touch $DIR/$tdir/f2 || error "f2 file create failed"
2950 # check it's updates in sync
2951 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2954 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2956 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2957 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2959 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2961 start_mds || error "unable to start MDS"
2962 mount_client $MOUNT || error "mount_client $MOUNT failed"
2964 [ $V ] && log "verifying $DIR/$tdir/$f"
2965 diff -q $f $DIR/$tdir/$f || ERROR=y
2967 touch $DIR/$tdir/f3 || error "f3 file create failed"
2968 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2969 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2971 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2972 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2973 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2975 [ "$ERROR" = "y" ] &&
2976 error "old and new files are different after sync" || true
2978 log "files compared the same"
2979 cleanup || error "cleanup failed with $?"
2981 run_test 38 "MDS recreates missing lov_objid file from OST data"
2986 cleanup || error "cleanup failed with $?"
2987 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2988 error "memory leak detected" || true
2990 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2992 test_40() { # bug 15759
2993 start_ost || error "Unable to start OST1"
2994 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2995 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2997 cleanup || error "cleanup failed with rc $?"
2999 run_test 40 "race during service thread startup"
3001 test_41a() { #bug 14134
3002 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3003 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
3004 skip "Loop devices does not work with nosvc option"
3007 combined_mgs_mds || skip "needs combined MGT and MDT device"
3009 start_mdt 1 -o nosvc -n
3010 if [ $MDSCOUNT -ge 2 ]; then
3011 for num in $(seq 2 $MDSCOUNT); do
3012 start_mdt $num || return
3015 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
3016 start_mdt 1 -o nomgs,force
3017 mount_client $MOUNT || error "mount_client $MOUNT failed"
3020 echo "blah blah" > $MOUNT/$tfile
3023 umount_client $MOUNT || error "umount_client $MOUNT failed"
3024 stop ost1 -f || error "unable to stop OST1"
3025 stop_mds || error "Unable to stop MDS"
3026 stop_mds || error "Unable to stop MDS on second try"
3028 run_test 41a "mount mds with --nosvc and --nomgs"
3031 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3032 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
3033 skip "Loop devices does not work with nosvc option"
3036 ! combined_mgs_mds && skip "needs combined mgs device"
3040 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3042 start_mdt 1 -o nosvc -n
3043 if [ $MDSCOUNT -ge 2 ]; then
3044 for num in $(seq 2 $MDSCOUNT); do
3045 start_mdt $num || return
3048 start_ost || error "Unable to start OST1"
3049 start_mdt 1 -o nomgs,force
3050 mount_client $MOUNT || error "mount_client $MOUNT failed"
3053 echo "blah blah" > $MOUNT/$tfile
3054 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
3056 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
3057 stop_ost || error "Unable to stop OST1"
3058 stop_mds || error "Unable to stop MDS"
3059 stop_mds || error "Unable to stop MDS on second try"
3061 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
3064 local oss_list=$(comma_list $(osts_nodes))
3066 [[ "$MDS1_VERSION" -ge $(version_code 2.6.52) ]] ||
3067 [[ "$MDS1_VERSION" -ge $(version_code 2.5.26) &&
3068 "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
3069 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
3070 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]] ||
3071 skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"
3073 # ensure mds1 ost1 have been created even if running sub-test standalone
3076 cleanup || error "cleanup failed"
3078 # using directly mount command instead of start() function to avoid
3079 # any side effect of // with others/externals tools/features
3080 # ("zpool import", ...)
3082 # MDT concurrent start
3084 LOAD_MODULES_REMOTE=true load_modules
3085 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
3086 error "MDT concurrent start: libcfs module not loaded"
3088 local mds1dev=$(mdsdevname 1)
3089 local mds1mnt=$(facet_mntpt mds1)
3090 local mds1opts=$MDS_MOUNT_OPTS
3092 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3093 ! do_facet mds1 test -b $mds1dev; then
3094 mds1opts=$(csa_add "$mds1opts" -o loop)
3096 if [[ "$mds1_FSTYPE" == zfs ]]; then
3097 import_zpool mds1 || return ${PIPESTATUS[0]}
3100 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3101 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
3103 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
3106 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
3110 do_facet mds1 "$LCTL set_param fail_loc=0x0"
3111 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3112 echo "1st MDT start succeed"
3113 echo "2nd MDT start failed with $rc2"
3114 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3115 echo "1st MDT start failed with $rc"
3116 echo "2nd MDT start succeed"
3119 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
3122 if [ $MDSCOUNT -ge 2 ]; then
3123 for num in $(seq 2 $MDSCOUNT); do
3124 start_mdt $num || return
3128 # OST concurrent start
3130 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
3131 error "OST concurrent start: libcfs module not loaded"
3133 local ost1dev=$(ostdevname 1)
3134 local ost1mnt=$(facet_mntpt ost1)
3135 local ost1opts=$OST_MOUNT_OPTS
3137 if [ "$ost1_FSTYPE" == ldiskfs ] &&
3138 ! do_facet ost1 test -b $ost1dev; then
3139 ost1opts=$(csa_add "$ost1opts" -o loop)
3141 if [[ "$ost1_FSTYPE" == zfs ]]; then
3142 import_zpool ost1 || return ${PIPESTATUS[0]}
3145 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3146 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
3148 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
3151 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
3155 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3156 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3157 echo "1st OST start succeed"
3158 echo "2nd OST start failed with $rc2"
3159 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3160 echo "1st OST start failed with $rc"
3161 echo "2nd OST start succeed"
3165 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3171 # verify everything ok
3176 error "MDT(s) start failed"
3184 error "OST(s) start failed"
3192 error "client start failed"
3199 error "client mount failed"
3203 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3205 test_42() { #bug 14693
3209 check_mount || error "client was not mounted"
3211 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3212 PARAM="llite.$FSNAME-*.some_wrong_param"
3214 PARAM="$FSNAME.llite.some_wrong_param"
3217 do_facet mgs $PERM_CMD $PARAM=10
3218 umount_client $MOUNT ||
3219 error "unmounting client failed with invalid llite param"
3220 mount_client $MOUNT ||
3221 error "mounting client failed with invalid llite param"
3223 do_facet mgs $PERM_CMD $PARAM=20
3224 cleanup || error "stopping $FSNAME failed with invalid sys param"
3226 check_mount || error "client was not mounted with invalid sys param"
3227 cleanup || error "stopping $FSNAME failed with invalid sys param"
3229 run_test 42 "allow client/server mount/unmount with invalid config param"
3232 [[ "$MGS_VERSION" -ge $(version_code 2.5.58) ]] ||
3233 skip "Need MDS version at least 2.5.58"
3234 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
3237 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
3238 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1"
3241 chmod ugo+x $DIR || error "chmod 0 failed"
3242 set_persistent_param_and_check mds1 \
3243 "mdt.$FSNAME-MDT0000.root_squash" \
3244 "$FSNAME.mdt.root_squash" \
3246 wait_update $HOSTNAME \
3247 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3249 error "check llite root_squash failed!"
3250 set_persistent_param_and_check mds1 \
3251 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3252 "$FSNAME.mdt.nosquash_nids" \
3254 wait_update $HOSTNAME \
3255 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3257 error "check llite nosquash_nids failed!"
3260 # create set of test files
3262 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
3263 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
3264 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
3266 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
3267 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
3269 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
3270 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
3271 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
3273 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
3274 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
3275 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
3278 # check root_squash:
3279 # set root squash UID:GID to RUNAS_ID
3280 # root should be able to access only files owned by RUNAS_ID
3282 set_persistent_param_and_check mds1 \
3283 "mdt.$FSNAME-MDT0000.root_squash" \
3284 "$FSNAME.mdt.root_squash" \
3285 "$RUNAS_ID:$RUNAS_ID"
3286 wait_update $HOSTNAME \
3287 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3288 "$RUNAS_ID:$RUNAS_ID" ||
3289 error "check llite root_squash failed!"
3291 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
3292 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3293 error "$ST: root read permission is denied"
3294 echo "$ST: root read permission is granted - ok"
3297 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3298 error "$ST: root write permission is denied"
3299 echo "$ST: root write permission is granted - ok"
3301 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3302 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3303 error "$ST: root read permission is granted"
3304 echo "$ST: root read permission is denied - ok"
3307 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3308 error "$ST: root write permission is granted"
3309 echo "$ST: root write permission is denied - ok"
3311 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3312 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
3313 error "$ST: root unlink permission is granted"
3314 echo "$ST: root unlink permission is denied - ok"
3316 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
3317 error "$ST: root create permission is granted"
3318 echo "$ST: root create permission is denied - ok"
3321 # check root_squash is enforced independently
3322 # of client cache content
3324 # access file by USER1, keep access open
3325 # root should be denied access to user file
3327 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
3331 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
3332 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3333 { kill $pid; error "$ST: root read permission is granted"; }
3334 echo "$ST: root read permission is denied - ok"
3337 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3338 { kill $pid; error "$ST: root write permission is granted"; }
3339 echo "$ST: root write permission is denied - ok"
3345 # check nosquash_nids:
3346 # put client's NID into nosquash_nids list,
3347 # root should be able to access root file after that
3349 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
3350 NIDLIST="2@gni $NIDLIST 192.168.0.[2,10]@tcp"
3351 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
3352 set_persistent_param_and_check mds1 \
3353 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3354 "$FSNAME-MDTall.mdt.nosquash_nids" \
3356 wait_update $HOSTNAME \
3357 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3359 error "check llite nosquash_nids failed!"
3361 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3362 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3363 error "$ST: root read permission is denied"
3364 echo "$ST: root read permission is granted - ok"
3367 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3368 error "$ST: root write permission is denied"
3369 echo "$ST: root write permission is granted - ok"
3371 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3372 rm $DIR/$tdir-rootdir/tfile-1 ||
3373 error "$ST: root unlink permission is denied"
3374 echo "$ST: root unlink permission is granted - ok"
3375 touch $DIR/$tdir-rootdir/tfile-2 ||
3376 error "$ST: root create permission is denied"
3377 echo "$ST: root create permission is granted - ok"
3378 cleanup || error "cleanup failed with $?"
3380 run_test 43a "check root_squash and nosquash_nids"
3382 test_43b() { # LU-5690
3383 [[ "$MGS_VERSION" -ge $(version_code 2.7.62) ]] ||
3384 skip "Need MGS version 2.7.62+"
3386 if [[ -z "$fs2mds_DEV" ]]; then
3387 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
3388 skip_env "mixed loopback and real device not working"
3391 local fs2mdsdev=$(mdsdevname 1_2)
3392 local fs2mdsvdev=$(mdsvdevname 1_2)
3394 # temporarily use fs2mds as fs2mgs
3396 local fs2mgsdev=$fs2mdsdev
3397 local fs2mgsvdev=$fs2mdsvdev
3399 local fsname=test1234
3401 load_module llite/lustre
3402 local client_ip=$(host_nids_address $HOSTNAME $NETTYPE)
3403 local host=${client_ip//*./}
3404 local net=${client_ip/%$host/}
3405 local nosquash_nids=$(h2nettype $net[$host,$host,$host])
3407 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
3408 --param mdt.root_squash=$RUNAS_ID:$RUNAS_ID \
3409 --param mdt.nosquash_nids=$nosquash_nids \
3410 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
3411 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS || error "start fs2mgs failed"
3412 stop $fs2mgs -f || error "stop fs2mgs failed"
3413 cleanup || error "cleanup failed with $?"
3415 run_test 43b "parse nosquash_nids with commas in expr_list"
3419 check_mount || error "check_mount"
3420 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
3422 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
3423 for VAL in $UUIDS; do
3424 NID=$(echo $VAL | cut -d= -f1)
3425 CLUUID=$(echo $VAL | cut -d= -f2)
3426 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
3428 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
3429 cleanup || error "cleanup failed with $?"
3431 run_test 44 "mounted client proc entry exists"
3435 check_mount || error "check_mount"
3436 stop_mds || error "Unable to stop MDS"
3440 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
3441 do_facet client "$LCTL set_param fail_loc=0x8000050f"
3444 manual_umount_client --force || error "manual_umount_client failed"
3445 do_facet client "$LCTL set_param fail_loc=0x0"
3446 start_mds || error "unable to start MDS"
3447 mount_client $MOUNT || error "mount_client $MOUNT failed"
3448 cleanup || error "cleanup failed with $?"
3450 run_test 45 "long unlink handling in ptlrpcd"
3457 umount_client $MOUNT2 || rc=$?
3458 umount_client $MOUNT || rc=$?
3459 while [ $count -gt 0 ]; do
3460 stop ost${count} -f || rc=$?
3464 cleanup_nocli || rc=$?
3465 #writeconf to remove all ost2 traces for subsequent tests
3466 writeconf_or_reformat
3471 echo "Testing with $OSTCOUNT OSTs"
3473 start_mds || error "unable to start MDS"
3474 #first client should see only one ost
3475 start_ost || error "Unable to start OST1"
3476 wait_osc_import_state mds ost FULL
3478 mount_client $MOUNT || error "mount_client $MOUNT failed"
3479 trap "cleanup_46a $OSTCOUNT" EXIT ERR
3482 for (( i=2; i<=$OSTCOUNT; i++ )); do
3483 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
3484 error "start_ost$i $(ostdevname $i) failed"
3487 # wait until osts in sync
3488 for (( i=2; i<=$OSTCOUNT; i++ )); do
3489 wait_osc_import_state mds ost$i FULL
3490 wait_osc_import_ready client ost$i
3493 #second client see all ost's
3495 mount_client $MOUNT2 || error "mount_client failed"
3496 $LFS setstripe -c -1 $MOUNT2 ||
3497 error "$LFS setstripe -c -1 $MOUNT2 failed"
3498 $LFS getstripe $MOUNT2 || error "$LFS getstripe $MOUNT2 failed"
3500 echo "ok" > $MOUNT2/widestripe
3501 $LFS getstripe $MOUNT2/widestripe ||
3502 error "$LFS getstripe $MOUNT2/widestripe failed"
3503 # fill acl buffer for avoid expand lsm to them
3504 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
3506 setfacl -m $acl $MOUNT2/widestripe
3510 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3512 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
3514 run_test 46a "handle ost additional - wide striped file"
3519 check_mount || error "check_mount failed"
3520 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
3524 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3525 if echo $ns | grep "MDT[[:digit:]]*"; then
3528 lrs=$(echo $ns | sed 's/.*lru_size=//')
3529 lru_size[count]=$lrs
3534 facet_failover $SINGLEMDS
3535 client_up || error "client_up failed"
3538 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3539 if echo $ns | grep "MDT[[:digit:]]*"; then
3542 lrs=$(echo $ns | sed 's/.*lru_size=//')
3543 if ! test "$lrs" -eq "${lru_size[count]}"; then
3544 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
3545 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
3550 cleanup || error "cleanup failed with $?"
3552 run_test 47 "server restart does not make client loss lru_resize settings"
3557 # reformat after this test is needed - if the test fails,
3558 # we will have unkillable file at FS
3562 test_48() { # bz-17636 LU-7473
3566 check_mount || error "check_mount failed"
3568 $LFS setstripe -c -1 $MOUNT ||
3569 error "$LFS setstripe -c -1 $MOUNT failed"
3570 $LFS getstripe $MOUNT || error "$LFS getstripe $MOUNT failed"
3572 echo "ok" > $MOUNT/widestripe
3573 $LFS getstripe $MOUNT/widestripe ||
3574 error "$LFS getstripe $MOUNT/widestripe failed"
3576 # In the future, we may introduce more EAs, such as selinux, enlarged
3577 # LOV EA, and so on. These EA will use some EA space that is shared by
3578 # ACL entries. So here we only check some reasonable ACL entries count,
3579 # instead of the max number that is calculated from the max_ea_size.
3580 if [ "$MDS1_VERSION" -lt $(version_code 2.8.57) ]; then
3581 count=28 # hard coded of RPC protocol
3582 elif large_xattr_enabled; then
3583 count=4500 # max_num 8187 max_ea_size = 65452
3584 # not create too many (4500) to save test time
3586 count=450 # max_num 497 max_ea_size = 4012
3589 echo "It is expected to hold at least $count ACL entries"
3590 trap cleanup_48 EXIT ERR
3591 for ((i = 0; i < $count; i++)) do
3592 setfacl -m u:$((i + 100)):rw $MOUNT/widestripe ||
3593 error "Fail to setfacl for $MOUNT/widestripe at $i"
3596 cancel_lru_locks mdc
3597 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3598 local r_count=$(getfacl $MOUNT/widestripe | grep "user:" | wc -l)
3599 count=$((count + 1)) # for the entry "user::rw-"
3601 [ $count -eq $r_count ] ||
3602 error "Expected ACL entries $count, but got $r_count"
3606 run_test 48 "too many acls on file"
3608 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3609 test_49a() { # bug 17710
3610 local timeout_orig=$TIMEOUT
3611 local ldlm_timeout_orig=$LDLM_TIMEOUT
3612 local LOCAL_TIMEOUT=20
3614 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3615 TIMEOUT=$LOCAL_TIMEOUT
3619 check_mount || error "client mount failed"
3621 echo "check ldlm_timout..."
3622 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3623 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3624 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3626 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3627 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3630 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3631 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3634 umount_client $MOUNT || error "umount_client $MOUNT failed"
3635 stop_ost || error "problem stopping OSS"
3636 stop_mds || error "problem stopping MDS"
3638 LDLM_TIMEOUT=$ldlm_timeout_orig
3639 TIMEOUT=$timeout_orig
3641 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3643 test_49b() { # bug 17710
3644 local timeout_orig=$TIMEOUT
3645 local ldlm_timeout_orig=$LDLM_TIMEOUT
3646 local LOCAL_TIMEOUT=20
3648 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3649 TIMEOUT=$LOCAL_TIMEOUT
3653 check_mount || error "client mount failed"
3655 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3656 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3657 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3659 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3660 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3663 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3664 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3667 cleanup || error "cleanup failed"
3669 LDLM_TIMEOUT=$ldlm_timeout_orig
3670 TIMEOUT=$timeout_orig
3672 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3675 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3677 # Test both statfs and lfs df and fail if either one fails
3678 multiop_bg_pause $1 f_
3681 killall -USR1 multiop
3682 [ $RC -ne 0 ] && log "lazystatfs multiop failed"
3683 wait $PID || { RC=$?; log "multiop return error "; }
3685 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3690 if kill -s 0 $PID; then
3693 log "lazystatfs lfs df failed to complete in 5s"
3701 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3702 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3704 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3706 cleanup || error "cleanup failed with rc $?"
3708 run_test 50a "lazystatfs all servers available"
3712 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3713 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3715 # Wait for client to detect down OST
3716 stop_ost || error "Unable to stop OST1"
3717 wait_osc_import_state client ost DISCONN
3719 log "OSCs should all be DISCONN"
3721 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
3723 umount_client $MOUNT || error "Unable to unmount client"
3724 stop_mds || error "Unable to stop MDS"
3726 run_test 50b "lazystatfs all servers down"
3729 start_mds || error "Unable to start MDS"
3730 start_ost || error "Unable to start OST1"
3731 start_ost2 || error "Unable to start OST2"
3732 mount_client $MOUNT || error "Unable to mount client"
3733 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3734 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3736 # Wait for client to detect down OST
3737 stop_ost || error "Unable to stop OST1"
3738 wait_osc_import_state mds ost DISCONN
3739 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3741 umount_client $MOUNT || error "Unable to unmount client"
3742 stop_ost2 || error "Unable to stop OST2"
3743 stop_mds || error "Unable to stop MDS"
3744 #writeconf to remove all ost2 traces for subsequent tests
3745 writeconf_or_reformat
3747 run_test 50c "lazystatfs one server down"
3750 start_mds || error "Unable to start MDS"
3751 start_ost || error "Unable to start OST1"
3752 start_ost2 || error "Unable to start OST2"
3753 mount_client $MOUNT || error "Unable to mount client"
3754 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3755 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3757 # Issue the statfs during the window where the client still
3758 # belives the OST to be available but it is in fact down.
3759 # No failure just a statfs which hangs for a timeout interval.
3760 stop_ost || error "Unable to stop OST1"
3761 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3763 umount_client $MOUNT || error "Unable to unmount client"
3764 stop_ost2 || error "Unable to stop OST2"
3765 stop_mds || error "Unable to stop MDS"
3766 #writeconf to remove all ost2 traces for subsequent tests
3767 writeconf_or_reformat
3769 run_test 50d "lazystatfs client/server conn race"
3776 start_mds || error "Unable to start MDS"
3777 #first client should see only one ost
3778 start_ost || error "Unable to start OST1"
3779 wait_osc_import_state mds ost FULL
3781 # Wait for client to detect down OST
3782 stop_ost || error "Unable to stop OST1"
3783 wait_osc_import_state mds ost DISCONN
3785 mount_client $MOUNT || error "Unable to mount client"
3786 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3788 multiop_bg_pause $MOUNT _f
3792 if [ $RC1 -ne 0 ]; then
3793 log "multiop failed $RC1"
3796 sleep $(( $TIMEOUT+1 ))
3798 [ $? -ne 0 ] && error "process isn't sleep"
3799 start_ost || error "Unable to start OST1"
3800 wait $pid || error "statfs failed"
3803 umount_client $MOUNT || error "Unable to unmount client"
3804 stop_ost || error "Unable to stop OST1"
3805 stop_mds || error "Unable to stop MDS"
3807 run_test 50e "normal statfs all servers down"
3812 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3814 start_mds || error "Unable to start mds"
3815 #first client should see only one ost
3816 start_ost || error "Unable to start OST1"
3817 wait_osc_import_state mds ost FULL
3819 start_ost2 || error "Unable to start OST2"
3820 wait_osc_import_state mds ost2 FULL
3822 # Wait for client to detect down OST
3823 stop_ost2 || error "Unable to stop OST2"
3825 wait_osc_import_state mds ost2 DISCONN
3826 mount_client $MOUNT || error "Unable to mount client"
3827 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3829 multiop_bg_pause $MOUNT _f
3833 if [ $RC1 -ne 0 ]; then
3834 log "lazystatfs multiop failed $RC1"
3837 sleep $(( $TIMEOUT+1 ))
3839 [ $? -ne 0 ] && error "process isn't sleep"
3840 start_ost2 || error "Unable to start OST2"
3841 wait $pid || error "statfs failed"
3842 stop_ost2 || error "Unable to stop OST2"
3845 umount_client $MOUNT -f || error "Unable to unmount client"
3846 stop_ost || error "Unable to stop OST1"
3847 stop_mds || error "Unable to stop MDS"
3848 #writeconf to remove all ost2 traces for subsequent tests
3849 writeconf_or_reformat
3851 run_test 50f "normal statfs one server in down"
3854 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3856 start_ost2 || error "Unable to start OST2"
3857 wait_osc_import_state mds ost2 FULL
3858 wait_osc_import_ready client ost2
3860 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3861 local PARAM="osc.${FSNAME}-OST0001*.active"
3863 local PARAM="${FSNAME}-OST0001.osc.active"
3866 $LFS setstripe -c -1 $DIR/$tfile || error "$LFS setstripe failed"
3867 do_facet mgs $PERM_CMD $PARAM=0 || error "Unable to deactivate OST"
3869 umount_client $MOUNT || error "Unable to unmount client"
3870 mount_client $MOUNT || error "Unable to mount client"
3871 # This df should not cause a panic
3874 do_facet mgs $PERM_CMD $PARAM=1 || error "Unable to activate OST"
3875 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
3876 umount_client $MOUNT || error "Unable to unmount client"
3877 stop_ost2 || error "Unable to stop OST2"
3878 stop_ost || error "Unable to stop OST1"
3879 stop_mds || error "Unable to stop MDS"
3880 #writeconf to remove all ost2 traces for subsequent tests
3881 writeconf_or_reformat
3883 run_test 50g "deactivated OST should not cause panic"
3887 # prepare MDT/OST, make OSC inactive for OST1
3888 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3890 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
3891 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3892 error "tunefs OST1 failed"
3893 start_mds || error "Unable to start MDT"
3894 start_ost || error "Unable to start OST1"
3895 start_ost2 || error "Unable to start OST2"
3896 mount_client $MOUNT || error "client start failed"
3898 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3900 # activatate OSC for OST1
3901 set_persistent_param_and_check client \
3902 "osc.${FSNAME}-OST0000-osc-[!M]*.active" \
3903 "${FSNAME}-OST0000.osc.active" 1
3905 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3906 $LFS setstripe -c -1 -i 0 $DIR/$tdir/2 ||
3907 error "$LFS setstripe $DIR/$tdir/2 failed"
3908 sleep 1 && echo "create a file after OST1 is activated"
3909 # doing some io, shouldn't crash
3910 dd if=/dev/zero of=$DIR/$tdir/2/$tfile-io bs=1M count=10
3912 # check OSC import is working
3913 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3914 error "some OSC imports are still not connected"
3918 umount_client $MOUNT || error "Unable to umount client"
3919 stop_ost2 || error "Unable to stop OST2"
3920 cleanup_nocli || error "cleanup_nocli failed with $?"
3922 run_test 50h "LU-642: activate deactivated OST"
3925 # prepare MDT/OST, make OSC inactive for OST1
3926 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
3929 [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
3930 do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
3931 error "tunefs MDT2 failed"
3932 start_mds || error "Unable to start MDT"
3933 start_ost || error "Unable to start OST1"
3934 start_ost2 || error "Unable to start OST2"
3935 mount_client $MOUNT || error "client start failed"
3937 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3939 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3940 $PERM_CMD mdc.${FSNAME}-MDT0001-mdc-*.active=0 &&
3941 error "deactive MDC0 succeeds"
3943 $PERM_CMD ${FSNAME}-MDT0000.mdc.active=0 &&
3944 error "deactive MDC0 succeeds"
3947 # activate MDC for MDT2
3948 set_persistent_param_and_check client \
3949 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3950 "${FSNAME}-MDT0001.mdc.active" 1
3952 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
3953 if [ "$MDS1_VERSION" -ge $(version_code 2.7.60) ]
3955 wait_dne_interconnect
3957 $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3959 createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
3961 rm -rf $DIR/$tdir/2 || error "unlink dir failed"
3963 # deactivate MDC for MDT2
3964 set_persistent_param_and_check client \
3965 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3966 "${FSNAME}-MDT0001.mdc.active" 0
3968 wait_osp_active mds ${FSNAME}-MDT0001 1 0
3970 $LFS mkdir -i1 $DIR/$tdir/2 &&
3971 error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
3973 $LFS mkdir -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3974 error "mkdir $DIR/$tdir/striped_dir fails after deactive MDT2"
3976 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3977 [ $stripe_count -eq $((MDSCOUNT - 1)) ] ||
3978 error "wrong $stripe_count != $((MDSCOUNT -1)) for striped_dir"
3981 umount_client $MOUNT || error "Unable to umount client"
3986 run_test 50i "activate deactivated MDT"
3989 local LOCAL_TIMEOUT=20
3993 check_mount || error "check_mount failed"
3995 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3996 $LFS setstripe -c -1 $MOUNT/$tdir ||
3997 error "$LFS setstripe -c -1 $MOUNT/$tdir failed"
3998 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3999 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
4000 touch $MOUNT/$tdir/$tfile &
4003 start_ost2 || error "Unable to start OST1"
4005 stop_ost2 || error "Unable to stop OST1"
4006 umount_client $MOUNT -f || error “unmount $MOUNT failed”
4007 cleanup_nocli || error “stop server failed”
4008 #writeconf to remove all ost2 traces for subsequent tests
4009 writeconf_or_reformat
4011 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
4020 do_node $node mkdir -p $dest
4021 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
4023 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
4024 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
4025 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
4027 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
4028 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
4038 local backup2=${TMP}/backup2
4040 do_node $node mkdir -p $backup2
4041 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
4043 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
4044 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
4045 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
4047 do_node $node "diff -rq $backup $backup2"
4048 [ $? -eq 0 ] || { error "contents differ"; return 3; }
4050 local xattrs2=${TMP}/xattrs2
4051 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
4052 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
4054 do_node $node "diff $xattrs $xattrs2"
4055 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
4057 do_node $node "rm -rf $backup2 $xattrs2"
4058 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
4062 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4063 skip "ldiskfs only test"
4066 start_mds || error "Unable to start MDS"
4067 start_ost || error "Unable to start OST1"
4068 mount_client $MOUNT || error "Unable to mount client"
4071 local ost1mnt=$(facet_mntpt ost1)
4072 local ost1node=$(facet_active_host ost1)
4073 local ost1tmp=$TMP/conf52
4076 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
4077 touch $TMP/modified_first || error "Unable to create temporary file"
4078 local mtime=$(stat -c %Y $TMP/modified_first)
4079 do_node $ost1node "mkdir -p $ost1tmp &&
4080 touch -m -d @$mtime $ost1tmp/modified_first" ||
4081 error "Unable to create temporary file"
4084 $LFS setstripe -c -1 -S 1M $DIR/$tdir || error "$LFS setstripe failed"
4086 for (( i=0; i < nrfiles; i++ )); do
4087 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
4088 error "multiop failed"
4093 # sync all the data and make sure no pending data on the client,
4094 # thus the SOM xattr would not be changed any more.
4095 cancel_lru_locks osc
4098 echo backup files to $TMP/$tdir
4099 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
4100 copy_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4101 error "Unable to copy files"
4103 umount_client $MOUNT || error "Unable to umount client"
4104 stop_ost || error "Unable to stop ost1"
4106 echo mount ost1 as ldiskfs
4107 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
4108 if ! do_node $ost1node test -b $ost1_dev; then
4111 do_node $ost1node mount -t "$ost1_FSTYPE" $loop $ost1_dev \
4113 error "Unable to mount ost1 as ldiskfs"
4116 echo backup objects to $ost1tmp/objects
4117 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
4118 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
4119 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
4121 error "Unable to copy objects"
4123 # move objects to lost+found
4124 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
4125 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
4127 do_node $ost1node "umount $ost1mnt" ||
4128 error "Unable to umount ost1 as ldiskfs"
4130 start_ost || error "Unable to start OST1"
4131 mount_client $MOUNT || error "Unable to mount client"
4133 local REPAIRED=$(do_node $ost1node "$LCTL get_param \
4134 -n osd-ldiskfs.$FSNAME-OST0000.oi_scrub" |
4135 awk '/^lf_repa[ri]*ed/ { print $2 }')
4136 [ $REPAIRED -gt 0 ] ||
4137 error "Some entry under /lost+found should be repaired"
4140 diff_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4141 error "Unable to diff files"
4143 rm -rf $TMP/$tdir $TMP/file_xattrs ||
4144 error "Unable to delete temporary files"
4145 do_node $ost1node "rm -rf $ost1tmp" ||
4146 error "Unable to delete temporary files"
4147 cleanup || error "cleanup failed with $?"
4149 run_test 52 "check recovering objects from lost+found"
4151 # Checks threads_min/max/started for some service
4153 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
4154 # parameter pattern prefix like 'ost.*.ost'.
4167 local msg="Insane $modname thread counts"
4168 local ncpts=$(check_cpt_number $facet)
4172 check_mount || return 41
4174 # We need to expand $parampat, but it may match multiple parameters, so
4175 # we'll pick the first one
4176 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
4177 error "Couldn't expand ${parampat}.threads_min parameter name"
4181 # Remove the .threads_min part
4182 paramp=${paramp%.threads_min}
4184 # Check for sanity in defaults
4185 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4187 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4189 tstarted=$(do_facet $facet "$LCTL get_param \
4190 -n ${paramp}.threads_started" || echo 0)
4191 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
4193 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4195 nthrs=$(expr $tmax - $tmin)
4196 if [ $nthrs -lt $ncpts ]; then
4202 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
4203 skip_env "module parameter forced $facet thread count"
4205 # Check that we can change min/max
4206 do_facet $facet "$LCTL set_param \
4207 ${paramp}.threads_min=$((tmin + nthrs))"
4208 do_facet $facet "$LCTL set_param \
4209 ${paramp}.threads_max=$((tmax - nthrs))"
4210 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4212 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4214 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
4215 $tmax2 == ($tmax - $nthrs)))' || return $?
4217 # Check that we can set min/max to the same value
4218 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4220 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
4221 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4223 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4225 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
4227 # Check that we can't set max < min
4228 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
4229 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4231 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4233 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
4235 # We need to ensure that we get the module options desired; to do this
4236 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
4237 LOAD_MODULES_REMOTE=true
4240 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
4241 setmodopts -a $modname "$newvalue" oldvalue
4244 check_mount || return 41
4246 # Restore previous setting of MODOPTS_*
4247 setmodopts $modname "$oldvalue"
4249 # Check that $opts took
4250 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4252 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4254 tstarted=$(do_facet $facet \
4255 "$LCTL get_param -n ${paramp}.threads_started" || echo 0)
4256 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4265 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
4266 cleanup || error "cleanup failed with rc $?"
4268 run_test 53a "check OSS thread count params"
4272 local mds=$(do_facet $SINGLEMDS "$LCTL get_param \
4273 -N mds.*.*.threads_max 2>/dev/null")
4274 if [ -z "$mds" ]; then
4275 #running this on an old MDT
4276 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
4278 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
4280 cleanup || error "cleanup failed with $?"
4282 run_test 53b "check MDS thread count params"
4285 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4286 skip "ldiskfs only test"
4289 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
4290 error "llverdev failed with rc=$?"
4293 run_test 54a "test llverdev and partial verify of device"
4296 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4297 skip "ldiskfs only test"
4301 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
4302 cleanup || error "cleanup failed with rc=$?"
4304 run_test 54b "test llverfs and partial verify of filesystem"
4308 local max_ost_index=$1
4309 echo -n $(((max_ost_index + 1) * 8))
4313 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4314 skip "ldiskfs only test"
4317 local mdsdev=$(mdsdevname 1)
4318 local mdsvdev=$(mdsvdevname 1)
4322 if ! combined_mgs_mds; then
4323 stop_mgs || error "stopping MGS service failed"
4324 format_mgs || error "formatting MGT failed"
4326 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
4328 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
4329 --reformat $(ostdevname 1) $(ostvdevname 1)
4335 echo checking size of lov_objid for ost index $i
4336 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" |
4337 grep ^User | awk -F 'Size: ' '{print $2}')
4338 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
4339 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
4341 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
4348 run_test 55 "check lov_objid size"
4351 local mds_journal_size_orig=$MDSJOURNALSIZE
4357 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
4358 $(ostdevname 1) $(ostvdevname 1)
4359 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
4360 $(ostdevname 2) $(ostvdevname 2)
4363 start_ost || error "Unable to start first ost (idx 10000)"
4364 start_ost2 || error "Unable to start second ost (idx 1000)"
4365 mount_client $MOUNT || error "Unable to mount client"
4369 if [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
4370 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
4371 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]]; then
4372 wait_osc_import_state mds ost1 FULL
4373 wait_osc_import_state mds ost2 FULL
4374 $LFS setstripe --stripe-count=-1 $DIR/$tfile ||
4375 error "Unable to setstripe $DIR/$tfile"
4376 n=$($LFS getstripe --stripe-count $DIR/$tfile)
4377 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
4382 MDSJOURNALSIZE=$mds_journal_size_orig
4385 run_test 56a "check big OST indexes and out-of-index-order start"
4390 umount_client $MOUNT -f || error "unmount client failed"
4399 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
4401 trap cleanup_56b EXIT RETURN ERR
4404 if ! combined_mgs_mds ; then
4409 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) --index=0 --reformat \
4410 $(mdsdevname 1) $(mdsvdevname 1)
4411 add mds2 $(mkfs_opts mds2 $(mdsdevname 2)) --index=1 --reformat \
4412 $(mdsdevname 2) $(mdsvdevname 2)
4413 add mds3 $(mkfs_opts mds3 $(mdsdevname 3)) --index=1000 --reformat \
4414 $(mdsdevname 3) $(mdsvdevname 3)
4418 start_mdt 1 || error "MDT 1 (idx 0) start failed"
4419 start_mdt 2 || error "MDT 2 (idx 1) start failed"
4420 start_mdt 3 || error "MDT 3 (idx 1000) start failed"
4421 start_ost || error "Unable to start first ost"
4422 start_ost2 || error "Unable to start second ost"
4424 do_nodes $(comma_list $(mdts_nodes)) \
4425 "$LCTL set_param mdt.*.enable_remote_dir=1 \
4426 mdt.*.enable_remote_dir_gid=-1"
4428 mount_client $MOUNT || error "Unable to mount client"
4430 $LFS mkdir -c3 $MOUNT/$tdir || error "failed to make testdir"
4432 echo "This is test file 1!" > $MOUNT/$tdir/$tfile.1 ||
4433 error "failed to make test file 1"
4434 echo "This is test file 2!" > $MOUNT/$tdir/$tfile.2 ||
4435 error "failed to make test file 2"
4436 echo "This is test file 1000!" > $MOUNT/$tdir/$tfile.1000 ||
4437 error "failed to make test file 1000"
4439 rm -rf $MOUNT/$tdir || error "failed to remove testdir"
4441 $LFS mkdir -i1000 $MOUNT/$tdir.1000 ||
4442 error "create remote dir at idx 1000 failed"
4445 echo "=== START lfs df OUTPUT ==="
4447 echo "==== END lfs df OUTPUT ===="
4449 mdtcnt=$(echo -e "$output" | grep $FSNAME-MDT | wc -l)
4450 ostcnt=$(echo -e "$output" | grep $FSNAME-OST | wc -l)
4452 echo "lfs df returned mdt count $mdtcnt and ost count $ostcnt"
4453 [ $mdtcnt -eq 3 ] || error "lfs df returned wrong mdt count"
4454 [ $ostcnt -eq 2 ] || error "lfs df returned wrong ost count"
4456 echo "This is test file 1!" > $MOUNT/$tdir.1000/$tfile.1 ||
4457 error "failed to make test file 1"
4458 echo "This is test file 2!" > $MOUNT/$tdir.1000/$tfile.2 ||
4459 error "failed to make test file 2"
4460 echo "This is test file 1000!" > $MOUNT/$tdir.1000/$tfile.1000 ||
4461 error "failed to make test file 1000"
4462 rm -rf $MOUNT/$tdir.1000 || error "failed to remove remote_dir"
4465 echo "=== START lfs mdts OUTPUT ==="
4467 echo "==== END lfs mdts OUTPUT ===="
4469 echo -e "$output" | grep -v "MDTS:" | awk '{print $1}' |
4470 sed 's/://g' > $TMP/mdts-actual.txt
4471 sort $TMP/mdts-actual.txt -o $TMP/mdts-actual.txt
4473 echo -e "0\n1\n1000" > $TMP/mdts-expected.txt
4475 diff $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4478 rm $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4480 [ $result -eq 0 ] || error "target_obd proc file is incorrect!"
4482 run_test 56b "test target_obd correctness with nonconsecutive MDTs"
4484 test_57a() { # bug 22656
4485 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4486 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4487 tail -1 | awk '{print $1}')
4488 writeconf_or_reformat
4489 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
4490 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
4491 error "tunefs failed"
4493 start_ost && error "OST registration from failnode should fail"
4496 run_test 57a "initial registration from failnode should fail (should return errs)"
4499 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4500 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4501 tail -1 | awk '{print $1}')
4502 writeconf_or_reformat
4503 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
4504 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
4505 error "tunefs failed"
4507 start_ost || error "OST registration from servicenode should not fail"
4510 run_test 57b "initial registration from servicenode should not fail"
4513 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
4516 test_58() { # bug 22658
4517 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
4519 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4520 createmany -o $DIR/$tdir/$tfile-%d 100
4521 unlinkmany $DIR/$tdir/$tfile-%d 100
4522 stop_mds || error "Unable to stop MDS"
4524 local MNTDIR=$(facet_mntpt $SINGLEMDS)
4525 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4527 # remove all files from the OBJECTS dir
4528 mount_fstype $SINGLEMDS
4530 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
4532 unmount_fstype $SINGLEMDS
4533 # restart MDS with missing llog files
4534 start_mds || error "unable to start MDS"
4535 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
4538 run_test 58 "missing llog files must not prevent MDT from mounting"
4541 start_mgsmds >> /dev/null
4542 local C1=$(count_osts)
4543 if [ $C1 -eq 0 ]; then
4544 start_ost >> /dev/null
4548 echo "original ost count: $C1 (expect > 0)"
4549 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
4550 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
4551 local C2=$(count_osts)
4552 echo "after mdt writeconf count: $C2 (expect 0)"
4553 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
4554 echo "OST start without writeconf should fail:"
4555 start_ost >> /dev/null &&
4556 error "OST start without writeconf didn't fail"
4557 echo "OST start with writeconf should succeed:"
4558 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
4559 local C3=$(count_osts)
4560 echo "after ost writeconf count: $C3 (expect 1)"
4561 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
4562 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
4563 local C4=$(count_osts)
4564 echo "after ost2 writeconf count: $C4 (expect 2)"
4565 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
4566 stop_ost2 >> /dev/null
4567 cleanup_nocli >> /dev/null
4568 #writeconf to remove all ost2 traces for subsequent tests
4569 writeconf_or_reformat
4571 run_test 59 "writeconf mount option"
4573 test_60() { # LU-471
4574 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4575 skip "ldiskfs only test"
4580 for num in $(seq $MDSCOUNT); do
4581 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
4582 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
4583 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4587 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
4588 [ ${PIPESTATUS[0]} -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
4590 # MDT default has dirdata feature
4591 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
4592 # we disable uninit_bg feature
4593 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
4594 # we set stride extended options
4595 echo $dump | grep stride > /dev/null || error "stride is not set"
4599 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
4602 local lxattr=$(large_xattr_enabled)
4604 [ "$MDS1_VERSION" -ge $(version_code 2.1.53) ] ||
4605 skip "Need MDS version at least 2.1.53"
4607 if [ "$mds1_FSTYPE" == ldiskfs ] &&
4608 ! large_xattr_enabled; then
4611 for num in $(seq $MDSCOUNT); do
4612 do_facet mds${num} $TUNE2FS -O ea_inode \
4613 $(mdsdevname $num) ||
4614 error "tune2fs on mds $num failed"
4618 setup || error "setting up the filesystem failed"
4619 client_up || error "starting client failed"
4621 local file=$DIR/$tfile
4622 touch $file || error "touch $file failed"
4624 local large_value="$(generate_string $(max_xattr_size))"
4625 local small_value="bar"
4627 local name="trusted.big"
4628 log "save large xattr of $(max_xattr_size) bytes on $name on $file"
4629 setfattr -n $name -v $large_value $file ||
4630 error "saving $name on $file failed"
4632 local new_value=$(get_xattr_value $name $file)
4633 [[ "$new_value" != "$large_value" ]] &&
4634 error "$name different after saving"
4636 log "shrink value of $name on $file"
4637 setfattr -n $name -v $small_value $file ||
4638 error "shrinking value of $name on $file failed"
4640 new_value=$(get_xattr_value $name $file)
4641 [[ "$new_value" != "$small_value" ]] &&
4642 error "$name different after shrinking"
4644 log "grow value of $name on $file"
4645 setfattr -n $name -v $large_value $file ||
4646 error "growing value of $name on $file failed"
4648 new_value=$(get_xattr_value $name $file)
4649 [[ "$new_value" != "$large_value" ]] &&
4650 error "$name different after growing"
4652 log "check value of $name on $file after remounting MDS"
4654 new_value=$(get_xattr_value $name $file)
4655 [[ "$new_value" != "$large_value" ]] &&
4656 error "$name different after remounting MDS"
4658 log "remove large xattr $name from $file"
4659 setfattr -x $name $file || error "removing $name from $file failed"
4661 if $lxattr && [ "$mds1_FSTYPE" == ldiskfs ]; then
4662 stopall || error "stopping for e2fsck run"
4663 for num in $(seq $MDSCOUNT); do
4664 run_e2fsck $(facet_active_host mds$num) \
4665 $(mdsdevname $num) "-y" ||
4666 error "e2fsck MDT$num failed"
4668 setup_noconfig || error "remounting the filesystem failed"
4671 # need to delete this file to avoid problems in other tests
4673 cleanup || error "stopping systems failed"
4675 run_test 61 "large xattr"
4678 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4679 skip "ldiskfs only test"
4681 [[ "$MDS1_VERSION" -ge $(version_code 2.2.51) ]] ||
4682 skip "Need MDS version at least 2.2.51"
4685 local mdsdev=$(mdsdevname 1)
4686 local ostdev=$(ostdevname 1)
4688 echo "disable journal for mds"
4689 do_facet mds1 $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
4690 start_mds && error "MDT start should fail"
4691 echo "disable journal for ost"
4692 do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
4693 start_ost && error "OST start should fail"
4694 cleanup || error "cleanup failed with rc $?"
4697 run_test 62 "start with disabled journal"
4700 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4701 skip "ldiskfs only test"
4704 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ldiskfs
4705 local inode_slab=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4706 awk '/ldiskfs_inode_cache/ { print $5 / $6 }')
4707 if [ -z "$inode_slab" ]; then
4708 skip "ldiskfs module has not been loaded"
4711 if grep -q "CONFIG_DEBUG_LOCK_ALLOC=y" /boot/config-$(uname -r); then
4712 skip "test is not compatible with CONFIG_DEBUG_LOCK_ALLOC=y"
4715 echo "$inode_slab ldiskfs inodes per page"
4716 [ "${inode_slab%.*}" -ge "3" ] && return 0
4718 # If kmalloc-128 is also 1 per page - this is a debug kernel
4719 # and so this is not an error.
4720 local kmalloc128=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4721 awk '/^(dma-kmalloc|size)-128 / { print $5 / $6 }')
4722 # 32 128-byte chunks in 4k
4723 [ "${kmalloc128%.*}" -lt "32" ] ||
4724 error "ldiskfs inode too big, only $inode_slab objs/page, " \
4725 "kmalloc128 = $kmalloc128 objs/page"
4727 run_test 63 "Verify each page can at least hold 3 ldiskfs inodes"
4730 start_mds || error "unable to start MDS"
4731 start_ost || error "Unable to start OST1"
4732 start_ost2 || error "Unable to start second ost"
4733 mount_client $MOUNT || error "Unable to mount client"
4734 stop_ost2 || error "Unable to stop second ost"
4737 umount_client $MOUNT -f || error “unmount $MOUNT failed”
4738 cleanup_nocli || error "cleanup_nocli failed with $?"
4739 #writeconf to remove all ost2 traces for subsequent tests
4740 writeconf_or_reformat
4742 run_test 64 "check lfs df --lazy "
4744 test_65() { # LU-2237
4745 # Currently, the test is only valid for ldiskfs backend
4746 [ "$mds1_FSTYPE" != ldiskfs ] &&
4747 skip "ldiskfs only test"
4749 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4750 local brpt=$(facet_mntpt brpt)
4753 if ! do_facet $SINGLEMDS "test -b $devname"; then
4757 stop_mds || error "Unable to stop MDS"
4758 local obj=$(do_facet $SINGLEMDS \
4759 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
4761 if [ -z "$obj" ]; then
4762 # The MDT may be just re-formatted, mount the MDT for the
4763 # first time to guarantee the "last_rcvd" file is there.
4764 start_mds || error "fail to mount the MDS for the first time"
4765 stop_mds || error "Unable to stop MDS"
4768 # remove the "last_rcvd" file
4769 do_facet $SINGLEMDS "mkdir -p $brpt"
4770 do_facet $SINGLEMDS \
4771 "mount -t $mds1_FSTYPE $opts $devname $brpt"
4772 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
4773 do_facet $SINGLEMDS "$UMOUNT $brpt"
4775 # restart MDS, the "last_rcvd" file should be recreated.
4776 start_mds || error "fail to restart the MDS"
4777 stop_mds || error "Unable to stop MDS"
4778 obj=$(do_facet $SINGLEMDS \
4779 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
4780 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
4782 run_test 65 "re-create the lost last_rcvd file when server mount"
4785 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
4786 skip "Need MGS version at least 2.3.59"
4789 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
4790 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
4792 # add EXCLUDE records to config log, they are not to be
4793 # removed by lctl replace_nids
4794 set_conf_param_and_check mds \
4795 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4796 "$FSNAME-OST0000.osc.active" \
4799 echo "replace_nids should fail if MDS, OSTs and clients are UP"
4800 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4801 error "replace_nids fail"
4803 umount_client $MOUNT || error "unmounting client failed"
4804 echo "replace_nids should fail if MDS and OSTs are UP"
4805 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4806 error "replace_nids fail"
4808 stop_ost || error "Unable to stop OST1"
4809 echo "replace_nids should fail if MDS is UP"
4810 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4811 error "replace_nids fail"
4813 stop_mds || error "stopping mds failed"
4815 if combined_mgs_mds; then
4816 start_mdt 1 "-o nosvc" ||
4817 error "starting mds with nosvc option failed"
4820 echo "command should accept two parameters"
4821 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
4822 error "command should accept two params"
4824 echo "correct device name should be passed"
4825 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
4826 error "wrong devname"
4828 echo "wrong nids list should not destroy the system"
4829 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
4831 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "asdfasdf, asdfadf" &&
4834 echo "replace OST nid"
4835 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
4836 error "replace nids failed"
4838 echo "command should accept two parameters"
4839 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
4840 error "command should accept two params"
4842 echo "wrong nids list should not destroy the system"
4843 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
4846 local FAKE_NIDS="192.168.0.112@tcp1,192.168.0.112@tcp2"
4847 local FAKE_FAILOVER="192.168.0.113@tcp1,192.168.0.113@tcp2"
4848 local NIDS_AND_FAILOVER="$MDS_NID,$FAKE_NIDS:$FAKE_FAILOVER"
4849 echo "set NIDs with failover"
4850 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $NIDS_AND_FAILOVER ||
4851 error "replace nids failed"
4854 echo "replace MDS nid"
4855 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
4856 error "replace nids failed"
4858 if ! combined_mgs_mds ; then
4861 stop_mds || error "Unable to stop MDS"
4864 start_mgsmds || error "start mgsmds failed"
4865 set_conf_param_and_check mds \
4866 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4867 "$FSNAME-OST0000.osc.active" \
4869 start_ost || error "unable to start OST"
4870 mount_client $MOUNT || error "mount client failed"
4872 check_mount || error "error after nid replace"
4873 cleanup || error "cleanup failed"
4876 run_test 66 "replace nids"
4878 test_67() { #LU-2950
4879 local legacy="$TMP/legacy_lnet_config"
4880 local new="$TMP/new_routes_test"
4881 local out="$TMP/config_out_file"
4882 local verify="$TMP/conv_verify"
4883 local verify_conf="$TMP/conf_verify"
4885 # Create the legacy file that will be run through the
4886 # lustre_routes_conversion script
4887 cat <<- LEGACY_LNET_CONFIG > $legacy
4888 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
4889 tcp2 54 10.1.3.2@tcp;
4890 tcp3 10.3.4.3@tcp:3;
4894 # Create the verification file to verify the output of
4895 # lustre_routes_conversion script against.
4896 cat <<- VERIFY_LNET_CONFIG > $verify
4897 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
4898 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
4899 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
4900 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
4901 tcp4: { gateway: 10.3.3.4@tcp }
4904 # Create the verification file to verify the output of
4905 # lustre_routes_config script against
4906 cat <<- VERIFY_LNET_CONFIG > $verify_conf
4907 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
4908 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
4909 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
4910 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
4911 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
4914 $LUSTRE_ROUTES_CONVERSION $legacy $new > /dev/null
4915 if [ -f $new ]; then
4916 # verify the conversion output
4917 cmp -s $new $verify > /dev/null
4918 if [ $? -eq 1 ]; then
4919 error "routes conversion failed"
4922 lustre_routes_config --dry-run --verbose $new > $out
4923 # check that the script succeeded
4924 cmp -s $out $verify_conf > /dev/null
4925 if [ $? -eq 1 ]; then
4926 error "routes config failed"
4929 error "routes conversion test failed"
4931 # remove generated files
4932 rm -f $new $legacy $verify $verify_conf $out
4934 run_test 67 "test routes conversion and configuration"
4942 [ "$MDS1_VERSION" -ge $(version_code 2.4.53) ] ||
4943 skip "Need MDS version at least 2.4.53"
4945 umount_client $MOUNT || error "umount client failed"
4950 # START-END - the sequences we'll be reserving
4951 START=$(do_facet $SINGLEMDS \
4952 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4953 END=$((START + (1 << 30)))
4954 do_facet $SINGLEMDS \
4955 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4957 # reset the sequences MDT0000 has already assigned
4958 do_facet $SINGLEMDS \
4959 $LCTL set_param seq.srv*MDT0000.space=clear
4961 # remount to let the client allocate new sequence
4962 mount_client $MOUNT || error "mount client failed"
4964 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4965 do_facet $SINGLEMDS \
4966 $LCTL get_param seq.srv*MDT0000.space
4967 $LFS path2fid $DIR/$tfile
4969 local old_ifs="$IFS"
4971 fid=($($LFS path2fid $DIR/$tfile))
4975 if [[ $seq < $END ]]; then
4976 error "used reserved sequence $seq?"
4978 cleanup || error "cleanup failed with $?"
4980 run_test 68 "be able to reserve specific sequences in FLDB"
4982 # Test 69: is about the total number of objects ever created on an OST.
4983 # so that when it is reformatted the normal MDS->OST orphan recovery won't
4984 # just "precreate" the missing objects. In the past it might try to recreate
4985 # millions of objects after an OST was reformatted
4987 [[ "$MDS1_VERSION" -lt $(version_code 2.4.2) ]] &&
4988 skip "Need MDS version at least 2.4.2"
4990 [[ "$MDS1_VERSION" -ge $(version_code 2.4.50) ]] &&
4991 [[ "$MDS1_VERSION" -lt $(version_code 2.5.0) ]] &&
4992 skip "Need MDS version at least 2.5.0"
4995 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4997 # use OST0000 since it probably has the most creations
4998 local OSTNAME=$(ostname_from_index 0)
4999 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
5000 local last_id=$(do_facet mds1 $LCTL get_param -n \
5001 osp.$mdtosc_proc1.prealloc_last_id)
5003 # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
5004 # verify that the LAST_ID recovery is working properly. If
5005 # not, then the OST will refuse to allow the MDS connect
5006 # because the LAST_ID value is too different from the MDS
5007 #define OST_MAX_PRECREATE=20000
5008 local ost_max_pre=20000
5009 local num_create=$(( ost_max_pre * 5 + 1 - last_id))
5011 # If the LAST_ID is already over 5 * OST_MAX_PRECREATE, we don't
5012 # need to create any files. So, skip this section.
5013 if [ $num_create -gt 0 ]; then
5014 # Check the number of inodes available on OST0
5016 local ifree=$($LFS df -i $MOUNT | awk '/OST0000/ { print $4 }')
5017 log "On OST0, $ifree inodes available. Want $num_create."
5019 $LFS setstripe -i 0 $DIR/$tdir ||
5020 error "$LFS setstripe -i 0 $DIR/$tdir failed"
5021 if [ $ifree -lt 10000 ]; then
5022 files=$(( ifree - 50 ))
5027 local j=$((num_create / files + 1))
5028 for i in $(seq 1 $j); do
5029 createmany -o $DIR/$tdir/$tfile-$i- $files ||
5030 error "createmany fail create $files files: $?"
5031 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
5032 error "unlinkmany failed unlink $files files"
5036 # delete all of the files with objects on OST0 so the
5037 # filesystem is not inconsistent later on
5038 $LFS find $MOUNT --ost 0 -print0 | xargs -0 rm
5040 umount_client $MOUNT || error "umount client failed"
5041 stop_ost || error "OST0 stop failure"
5042 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
5043 $(ostdevname 1) $(ostvdevname 1) ||
5044 error "reformat and replace $ostdev failed"
5045 start_ost || error "OST0 restart failure"
5046 wait_osc_import_state mds ost FULL
5048 mount_client $MOUNT || error "mount client failed"
5049 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
5050 local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
5051 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
5053 local iused=$($LFS df -i $MOUNT | awk '/OST0000/ { print $3 }')
5054 log "On OST0, $iused used inodes"
5055 [ $iused -ge $((ost_max_pre/2 + 1000)) ] &&
5056 error "OST replacement created too many inodes; $iused"
5057 cleanup || error "cleanup failed with $?"
5059 run_test 69 "replace an OST with the same index"
5062 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5065 cleanup || error "cleanup failed with $?"
5067 start_mdt 1 || error "MDT0 start fail"
5069 start_ost || error "OST0 start fail"
5070 for num in $(seq 2 $MDSCOUNT); do
5071 start_mdt $num || return
5074 mount_client $MOUNT || error "mount client fails"
5076 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5078 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5079 error "create remote dir fail"
5081 rm -rf $DIR/$tdir || error "delete dir fail"
5082 cleanup || error "cleanup failed with $?"
5084 run_test 70a "start MDT0, then OST, then MDT1"
5087 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5090 start_ost || error "OST0 start fail"
5092 start_mds || error "MDS start fail"
5094 mount_client $MOUNT || error "mount client fails"
5096 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5098 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5099 error "create remote dir fail"
5101 rm -rf $DIR/$tdir || error "delete dir fail"
5103 cleanup || error "cleanup failed with $?"
5105 run_test 70b "start OST, MDT1, MDT0"
5108 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5111 start_mds || error "MDS start fail"
5112 start_ost || error "OST0 start fail"
5114 mount_client $MOUNT || error "mount client fails"
5115 stop_mdt 1 || error "MDT1 start fail"
5117 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
5118 echo "deactivate $mdc_for_mdt1"
5119 $LCTL --device $mdc_for_mdt1 deactivate ||
5120 error "set $mdc_for_mdt1 deactivate failed"
5122 mkdir $DIR/$tdir && error "mkdir succeed"
5124 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5125 error "create remote dir succeed"
5127 cleanup || error "cleanup failed with $?"
5129 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
5132 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5135 start_mds || error "MDS start fail"
5136 start_ost || error "OST0 start fail"
5138 mount_client $MOUNT || error "mount client fails"
5140 stop_mdt 2 || error "MDT1 start fail"
5142 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
5144 echo "deactivate $mdc_for_mdt2"
5145 $LCTL --device $mdc_for_mdt2 deactivate ||
5146 error "set $mdc_for_mdt2 deactivate failed"
5148 mkdir $DIR/$tdir || error "mkdir fail"
5149 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5150 error "create remote dir succeed"
5152 rm -rf $DIR/$tdir || error "delete dir fail"
5154 cleanup || error "cleanup failed with $?"
5156 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
5159 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5161 [ "$MDS1_VERSION" -ge $(version_code 2.7.62) ] ||
5162 skip "Need MDS version at least 2.7.62"
5164 reformat || error "reformat failed with $?"
5168 local mdsdev=$(mdsdevname 1)
5169 local ostdev=$(ostdevname 1)
5170 local mdsvdev=$(mdsvdevname 1)
5171 local ostvdev=$(ostvdevname 1)
5172 local opts_mds="$(mkfs_opts mds1 $mdsdev) --reformat $mdsdev $mdsvdev"
5173 local opts_ost="$(mkfs_opts ost1 $ostdev) --reformat $ostdev $ostvdev"
5175 if ! combined_mgs_mds ; then
5179 add mds1 $opts_mds || error "add mds1 failed"
5180 start_mdt 1 || error "start mdt1 failed"
5181 add ost1 $opts_ost || error "add ost1 failed"
5182 start_ost || error "start ost failed"
5183 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
5185 local soc=$(do_facet mds1 "$LCTL get_param -n \
5186 mdt.*MDT0000.sync_lock_cancel")
5187 [ $soc == "never" ] || error "SoC enabled on single MDS"
5189 for i in $(seq 2 $MDSCOUNT); do
5190 mdsdev=$(mdsdevname $i)
5191 mdsvdev=$(mdsvdevname $i)
5192 opts_mds="$(mkfs_opts mds$i $mdsdev) --reformat $mdsdev \
5194 add mds$i $opts_mds || error "add mds$i failed"
5195 start_mdt $i || error "start mdt$i fail"
5198 wait_dne_interconnect
5200 for i in $(seq $MDSCOUNT); do
5201 soc=$(do_facet mds$i "$LCTL get_param -n \
5202 mdt.*MDT000$((i - 1)).sync_lock_cancel")
5203 [ $soc == "blocking" ] || error "SoC not enabled on DNE"
5206 for i in $(seq 2 $MDSCOUNT); do
5207 stop_mdt $i || error "stop mdt$i fail"
5209 soc=$(do_facet mds1 "$LCTL get_param -n \
5210 mdt.*MDT0000.sync_lock_cancel")
5211 [ $soc == "never" ] || error "SoC enabled on single MDS"
5212 umount_client $MOUNT -f > /dev/null
5214 cleanup || error "cleanup failed with $?"
5216 run_test 70e "Sync-on-Cancel will be enabled by default on DNE"
5219 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5220 if combined_mgs_mds; then
5221 skip "needs separate MGS/MDT"
5225 start_mdt 1 || error "MDT0 start fail"
5226 start_ost || error "OST0 start fail"
5227 for num in $(seq 2 $MDSCOUNT); do
5228 start_mdt $num || return
5231 start_ost2 || error "OST1 start fail"
5233 mount_client $MOUNT || error "mount client fails"
5235 mkdir $DIR/$tdir || error "mkdir fail"
5236 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5237 error "create remote dir succeed"
5239 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5240 rm -rf $DIR/$tdir || error "delete dir fail"
5242 umount_client $MOUNT || error "umount_client failed"
5243 stop_mds || error "MDS stop fail"
5244 stop_ost || error "OST0 stop fail"
5245 stop_ost2 || error "OST1 stop fail"
5247 run_test 71a "start MDT0 OST0, MDT1, OST1"
5250 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5251 if combined_mgs_mds; then
5252 skip "needs separate MGS/MDT"
5256 for num in $(seq 2 $MDSCOUNT); do
5257 start_mdt $num || return
5259 start_ost || error "OST0 start fail"
5260 start_mdt 1 || error "MDT0 start fail"
5261 start_ost2 || error "OST1 start fail"
5263 mount_client $MOUNT || error "mount client fails"
5265 mkdir $DIR/$tdir || error "mkdir fail"
5266 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5267 error "create remote dir succeed"
5269 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5270 rm -rf $DIR/$tdir || error "delete dir fail"
5272 umount_client $MOUNT || error "umount_client failed"
5273 stop_mds || error "MDT0 stop fail"
5274 stop_ost || error "OST0 stop fail"
5275 stop_ost2 || error "OST1 stop fail"
5277 run_test 71b "start MDT1, OST0, MDT0, OST1"
5280 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5281 combined_mgs_mds && skip "needs separate MGS/MDT"
5285 start_ost || error "OST0 start fail"
5286 start_ost2 || error "OST1 start fail"
5287 for num in $(seq 2 $MDSCOUNT); do
5288 start_mdt $num || return
5290 start_mdt 1 || error "MDT0 start fail"
5292 mount_client $MOUNT || error "mount client fails"
5294 mkdir $DIR/$tdir || error "mkdir fail"
5295 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5296 error "create remote dir succeed"
5298 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5299 rm -rf $DIR/$tdir || error "delete dir fail"
5301 umount_client $MOUNT || error "umount_client failed"
5302 stop_mds || error "MDS stop fail"
5303 stop_ost || error "OST0 stop fail"
5304 stop_ost2 || error "OST1 stop fail"
5307 run_test 71c "start OST0, OST1, MDT1, MDT0"
5310 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5311 combined_mgs_mds && skip "needs separate MGS/MDT"
5315 start_ost || error "OST0 start fail"
5316 for num in $(seq 2 $MDSCOUNT); do
5317 start_mdt $num || return
5319 start_mdt 1 || error "MDT0 start fail"
5320 start_ost2 || error "OST1 start fail"
5322 mount_client $MOUNT || error "mount client fails"
5324 mkdir $DIR/$tdir || error "mkdir fail"
5325 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5326 error "create remote dir succeed"
5328 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5329 rm -rf $DIR/$tdir || error "delete dir fail"
5331 umount_client $MOUNT || error "umount_client failed"
5332 stop_mds || error "MDS stop fail"
5333 stop_ost || error "OST0 stop fail"
5334 stop_ost2 || error "OST1 stop fail"
5337 run_test 71d "start OST0, MDT1, MDT0, OST1"
5340 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5341 combined_mgs_mds && skip "needs separate MGS/MDT"
5345 start_ost || error "OST0 start fail"
5346 for num in $(seq 2 $MDSCOUNT); do
5347 start_mdt $num || return
5349 start_ost2 || error "OST1 start fail"
5350 start_mdt 1 || error "MDT0 start fail"
5352 mount_client $MOUNT || error "mount client fails"
5354 mkdir $DIR/$tdir || error "mkdir fail"
5355 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5356 error "create remote dir succeed"
5358 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5359 rm -rf $DIR/$tdir || error "delete dir fail"
5361 umount_client $MOUNT || error "umount_client failed"
5362 stop_mds || error "MDS stop fail"
5363 stop_ost || error "OST0 stop fail"
5364 stop_ost2 || error "OST1 stop fail"
5367 run_test 71e "start OST0, MDT1, OST1, MDT0"
5369 test_72() { #LU-2634
5370 [ "$mds1_FSTYPE" != ldiskfs ] &&
5371 skip "ldiskfs only test"
5373 local mdsdev=$(mdsdevname 1)
5374 local ostdev=$(ostdevname 1)
5375 local cmd="$E2FSCK -fnvd $mdsdev"
5382 if combined_mgs_mds; then
5383 add_options='--reformat'
5385 add_options='--reformat --replace'
5388 #tune MDT with "-O extents"
5390 for num in $(seq $MDSCOUNT); do
5391 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
5392 $add_options $(mdsdevname $num) $(mdsvdevname $num) ||
5393 error "add mds $num failed"
5394 do_facet mds${num} "$TUNE2FS -O extents $(mdsdevname $num)" ||
5395 error "$TUNE2FS failed on mds${num}"
5398 add ost1 $(mkfs_opts ost1 $ostdev) $add_options $ostdev ||
5399 error "add $ostdev failed"
5400 start_mds || error "start mds failed"
5401 start_ost || error "start ost failed"
5402 mount_client $MOUNT || error "mount client failed"
5404 #create some short symlinks
5405 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5406 createmany -o $DIR/$tdir/$tfile-%d $fn
5407 echo "create $fn short symlinks"
5408 for i in $(seq -w 1 $fn); do
5409 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
5414 umount_client $MOUNT || error "umount client failed"
5415 stop_mds || error "stop mds failed"
5416 stop_ost || error "stop ost failed"
5419 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
5421 run_test 72 "test fast symlink with extents flag enabled"
5423 test_73() { #LU-3006
5424 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
5425 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
5426 error "1st tunefs failed"
5427 start_mgsmds || error "start mds failed"
5428 start_ost || error "start ost failed"
5429 mount_client $MOUNT || error "mount client failed"
5430 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
5431 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
5432 umount_client $MOUNT || error "umount client failed"
5436 run_test 73 "failnode to update from mountdata properly"
5438 test_75() { # LU-2374
5439 [[ "$MDS1_VERSION" -lt $(version_code 2.4.1) ]] &&
5440 skip "Need MDS version at least 2.4.1"
5443 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
5444 --replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
5445 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
5446 --replace --reformat $(ostdevname 1) $(ostvdevname 1)"
5448 #check with default parameters
5449 add mds1 $opts_mds || error "add mds1 failed for default params"
5450 add ost1 $opts_ost || error "add ost1 failed for default params"
5452 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
5453 opts_mds=$(echo $opts_mds |
5454 sed -e "s/--index=$index/--index=$index --mdt/")
5455 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
5456 opts_ost=$(echo $opts_ost |
5457 sed -e "s/--index=$index/--index=$index --ost/")
5459 add mds1 $opts_mds || error "add mds1 failed for new params"
5460 add ost1 $opts_ost || error "add ost1 failed for new params"
5465 run_test 75 "The order of --index should be irrelevant"
5468 [[ "$MGS_VERSION" -ge $(version_code 2.4.52) ]] ||
5469 skip "Need MDS version at least 2.4.52"
5472 local MDMB_PARAM="osc.*.max_dirty_mb"
5473 echo "Change MGS params"
5474 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
5476 echo "max_dirty_mb: $MAX_DIRTY_MB"
5477 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB - 10))
5478 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
5479 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
5480 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5481 head -1" $NEW_MAX_DIRTY_MB
5482 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5483 echo "$MAX_DIRTY_MB"
5484 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5485 error "error while apply max_dirty_mb"
5487 echo "Check the value is stored after remount"
5490 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5491 head -1" $NEW_MAX_DIRTY_MB
5492 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5493 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5494 error "max_dirty_mb is not saved after remount"
5496 echo "Change OST params"
5497 CLIENT_PARAM="obdfilter.*.client_cache_count"
5498 local CLIENT_CACHE_COUNT
5499 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5501 echo "client_cache_count: $CLIENT_CACHE_COUNT"
5502 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
5503 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
5504 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
5505 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5506 head -1" $NEW_CLIENT_CACHE_COUNT
5507 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5509 echo "$CLIENT_CACHE_COUNT"
5510 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5511 error "error while apply client_cache_count"
5513 echo "Check the value is stored after remount"
5516 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5517 head -1" $NEW_CLIENT_CACHE_COUNT
5518 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5520 echo "$CLIENT_CACHE_COUNT"
5521 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5522 error "client_cache_count is not saved after remount"
5525 run_test 76a "set permanent params with lctl across mounts"
5527 test_76b() { # LU-4783
5528 [[ "$MGS_VERSION" -ge $(version_code 2.5.57) ]] ||
5529 skip "Need MGS version at least 2.5.57"
5532 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
5533 error "start params log failed"
5536 run_test 76b "verify params log setup correctly"
5539 [[ "$MGS_VERSION" -ge $(version_code 2.8.54) ]] ||
5540 skip "Need MDS version at least 2.4.52"
5542 local MASK_PARAM="mdd.*.changelog_mask"
5543 echo "Change changelog_mask"
5544 do_facet mgs $LCTL set_param -P $MASK_PARAM=-CLOSE ||
5545 error "Can't change changlog_mask"
5546 wait_update $(facet_host mds) "$LCTL get_param -n $MASK_PARAM |
5549 echo "Check the value is stored after mds remount"
5550 stop_mds || error "Failed to stop MDS"
5551 start_mds || error "Failed to start MDS"
5552 local CHANGELOG_MASK=$(do_facet mgs $LCTL get_param -n $MASK_PARAM)
5553 echo $CHANGELOG_MASK | grep CLOSE > /dev/null &&
5554 error "changelog_mask is not changed"
5558 run_test 76c "verify changelog_mask is applied with lctl set_param -P"
5560 test_76d() { #LU-9399
5563 local xattr_cache="llite.*.xattr_cache"
5564 local cmd="$LCTL get_param -n $xattr_cache | head -1"
5565 local new=$((($(eval $cmd) + 1) % 2))
5567 echo "lctl set_param -P llite.*.xattr_cache=$new"
5568 do_facet mgs $LCTL set_param -P $xattr_cache=$new ||
5569 error "Can't change xattr_cache"
5570 wait_update $HOSTNAME "$cmd" "$new"
5572 echo "Check $xattr_cache on client $MOUNT"
5573 umount_client $MOUNT || error "umount $MOUNT failed"
5574 mount_client $MOUNT || error "mount $MOUNT failed"
5575 [ $(eval $cmd) -eq $new ] ||
5576 error "$xattr_cache != $new on client $MOUNT"
5578 echo "Check $xattr_cache on the new client $MOUNT2"
5579 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
5580 [ $(eval $cmd) -eq $new ] ||
5581 error "$xattr_cache != $new on client $MOUNT2"
5582 umount_client $MOUNT2 || error "umount $MOUNT2 failed"
5586 run_test 76d "verify llite.*.xattr_cache can be set by 'lctl set_param -P' correctly"
5588 test_77() { # LU-3445
5589 [[ "$MDS1_VERSION" -ge $(version_code 2.8.55) ]] ||
5590 skip "Need MDS version 2.8.55+ "
5592 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
5593 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
5594 skip_env "mixed loopback and real device not working"
5597 local fs2mdsdev=$(mdsdevname 1_2)
5598 local fs2ostdev=$(ostdevname 1_2)
5599 local fs2mdsvdev=$(mdsvdevname 1_2)
5600 local fs2ostvdev=$(ostvdevname 1_2)
5601 local fsname=test1234
5603 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
5605 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
5607 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
5608 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
5609 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
5610 error "start fs2mds failed"
5612 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
5613 mgsnid="0.0.0.0@tcp,$mgsnid,$mgsnid:$mgsnid"
5615 add fs2ost --mgsnode=$mgsnid $(mkfs_opts ost1 $fs2ostdev) \
5616 --failnode=$failnid --fsname=$fsname \
5617 --reformat $fs2ostdev $fs2ostvdev ||
5618 error "add fs2ost failed"
5619 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
5621 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
5622 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
5623 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
5626 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
5629 [[ "$mds1_FSTYPE" != ldiskfs ||
5630 "$ost1_FSTYPE" != ldiskfs ]] &&
5631 skip "ldiskfs only test"
5633 # reformat the Lustre filesystem with a smaller size
5634 local saved_MDSCOUNT=$MDSCOUNT
5635 local saved_MDSSIZE=$MDSSIZE
5636 local saved_OSTCOUNT=$OSTCOUNT
5637 local saved_OSTSIZE=$OSTSIZE
5640 MDSSIZE=$((MDSSIZE - 20000))
5641 OSTSIZE=$((OSTSIZE - 20000))
5642 reformat || error "(1) reformat Lustre filesystem failed"
5643 MDSSIZE=$saved_MDSSIZE
5644 OSTSIZE=$saved_OSTSIZE
5646 # mount the Lustre filesystem
5647 setup_noconfig || error "(2) setup Lustre filesystem failed"
5650 log "create test files"
5655 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
5657 for i in $(seq $num_files); do
5658 file=$MOUNT/$tdir/$tfile-$i
5659 dd if=/dev/urandom of=$file count=1 bs=1M || {
5660 $LCTL get_param osc.*.cur*grant*
5661 $LFS df; $LFS df -i;
5662 # stop creating files if there is no more space
5663 if [ ! -e $file ]; then
5664 num_files=$((i - 1))
5668 $LFS getstripe -v $file
5669 local ost_idx=$(LFS getstripe -i $file)
5670 do_facet ost$((ost_idx + 1)) \
5671 $LCTL get_param obdfilter.*.*grant*
5672 error "(4) create $file failed"
5676 # unmount the Lustre filesystem
5677 cleanup || error "(5) cleanup Lustre filesystem failed"
5679 # run e2fsck on the MDT and OST devices
5680 local mds_host=$(facet_active_host $SINGLEMDS)
5681 local ost_host=$(facet_active_host ost1)
5682 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
5683 local ost_dev=$(ostdevname 1)
5685 run_e2fsck $mds_host $mds_dev "-y"
5686 run_e2fsck $ost_host $ost_dev "-y"
5688 # get the original block count of the MDT and OST filesystems
5689 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
5690 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
5692 # expand the MDT and OST filesystems to the device size
5693 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
5694 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
5696 # run e2fsck on the MDT and OST devices again
5697 run_e2fsck $mds_host $mds_dev "-y"
5698 run_e2fsck $ost_host $ost_dev "-y"
5700 # mount the Lustre filesystem
5704 log "check files after expanding the MDT and OST filesystems"
5705 for i in $(seq $num_files); do
5706 file=$MOUNT/$tdir/$tfile-$i
5707 $CHECKSTAT -t file -s 1048576 $file ||
5708 error "(6) checkstat $file failed"
5712 log "create more files after expanding the MDT and OST filesystems"
5713 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
5714 file=$MOUNT/$tdir/$tfile-$i
5715 dd if=/dev/urandom of=$file count=1 bs=1M ||
5716 error "(7) create $file failed"
5719 # unmount the Lustre filesystem
5720 cleanup || error "(8) cleanup Lustre filesystem failed"
5722 # run e2fsck on the MDT and OST devices
5723 run_e2fsck $mds_host $mds_dev "-y"
5724 run_e2fsck $ost_host $ost_dev "-y"
5726 # get the maximum block count of the MDT and OST filesystems
5727 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
5728 local ost_max_blks=$(get_block_count ost1 $ost_dev)
5730 # get the minimum block count of the MDT and OST filesystems
5731 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
5732 grep minimum | sed -e 's/^.*filesystem: //g')
5733 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
5734 grep minimum | sed -e 's/^.*filesystem: //g')
5736 # shrink the MDT and OST filesystems to a smaller size
5740 if [[ $mds_max_blks -gt $mds_min_blks &&
5741 $mds_max_blks -gt $mds_orig_blks ]]; then
5742 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
5743 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
5744 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
5745 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
5746 error "shrink $SINGLEMDS to $new_blks failed"
5750 if [[ $ost_max_blks -gt $ost_min_blks &&
5751 $ost_max_blks -gt $ost_orig_blks ]]; then
5752 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
5753 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
5754 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
5755 run_resize2fs ost1 $ost_dev $new_blks ||
5756 error "shrink ost1 to $new_blks failed"
5760 # check whether the MDT or OST filesystem was shrunk or not
5762 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
5763 reformat_and_config ||
5764 error "(10) reformat Lustre filesystem failed"
5768 # run e2fsck on the MDT and OST devices again
5769 run_e2fsck $mds_host $mds_dev "-y"
5770 run_e2fsck $ost_host $ost_dev "-y"
5772 # mount the Lustre filesystem again
5776 log "check files after shrinking the MDT and OST filesystems"
5777 for i in $(seq $((num_files + 10))); do
5778 file=$MOUNT/$tdir/$tfile-$i
5779 $CHECKSTAT -t file -s 1048576 $file ||
5780 error "(11) checkstat $file failed"
5783 # unmount and reformat the Lustre filesystem
5784 cleanup || error "(12) cleanup Lustre filesystem failed"
5785 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
5787 MDSCOUNT=$saved_MDSCOUNT
5788 OSTCOUNT=$saved_OSTCOUNT
5789 reformat_and_config || error "(14) reformat Lustre filesystem failed"
5791 run_test 78 "run resize2fs on MDT and OST filesystems"
5793 test_79() { # LU-4227
5794 [[ "$MDS1_VERSION" -ge $(version_code 2.5.59) ]] ||
5795 skip "Need MDS version at least 2.5.59"
5797 local mdsdev1=$(mdsdevname 1)
5798 local mdsvdev1=$(mdsvdevname 1)
5799 local mdsdev2=$(mdsdevname 2)
5800 local mdsvdev2=$(mdsvdevname 2)
5801 local ostdev1=$(ostdevname 1)
5802 local ostvdev1=$(ostvdevname 1)
5803 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
5804 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
5805 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
5808 # remove --mgs/--mgsnode from mkfs.lustre options
5809 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
5811 mgsnode_opt=$(echo $opts_mds2 |
5812 awk '{ for ( i = 1; i < NF; i++ )
5813 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5814 [ -n "$mgsnode_opt" ] &&
5815 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
5817 mgsnode_opt=$(echo $opts_ost1 |
5818 awk '{ for ( i = 1; i < NF; i++ )
5819 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5820 [ -n "$mgsnode_opt" ] &&
5821 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
5823 # -MGS, format a mdt without --mgs option
5824 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
5825 error "Must specify --mgs when formatting mdt combined with mgs"
5827 # +MGS, format a mdt/ost without --mgsnode option
5828 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
5829 > /dev/null || error "start mds1 failed"
5830 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
5831 error "Must specify --mgsnode when formatting a mdt"
5832 add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
5833 error "Must specify --mgsnode when formatting an ost"
5837 run_test 79 "format MDT/OST without mgs option (should return errors)"
5840 start_mds || error "Failed to start MDT"
5841 start_ost || error "Failed to start OST1"
5842 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
5843 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
5844 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
5845 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
5846 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
5848 start_ost2 || error "Failed to start OST2"
5850 do_facet ost1 "$LCTL set_param fail_loc=0"
5855 run_test 80 "mgc import reconnect race"
5857 #Save the original values of $OSTCOUNT and $OSTINDEX$i.
5859 local new_ostcount=$1
5860 saved_ostcount=$OSTCOUNT
5861 OSTCOUNT=$new_ostcount
5865 for i in $(seq $OSTCOUNT); do
5867 eval saved_ostindex$i=${!index}
5872 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
5873 restore_ostindex() {
5878 for i in $(seq $OSTCOUNT); do
5879 index=saved_ostindex$i
5880 eval OSTINDEX$i=${!index}
5882 OSTCOUNT=$saved_ostcount
5885 if ! combined_mgs_mds ; then
5890 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
5891 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
5892 # assigned index and ensures we can mount such a formatted file system
5893 test_81() { # LU-4665
5894 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
5895 skip "Need MDS version at least 2.6.54"
5896 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5900 # Each time RANDOM is referenced, a random integer between 0 and 32767
5903 local saved_ostindex1=$OSTINDEX1
5904 for i in 65535 $((RANDOM + 65536)); do
5905 echo -e "\nFormat ost1 with --index=$i, should fail"
5907 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
5908 $(ostdevname 1) $(ostvdevname 1); then
5909 OSTINDEX1=$saved_ostindex1
5910 error "format ost1 with --index=$i should fail"
5913 OSTINDEX1=$saved_ostindex1
5917 # Format OSTs with random sparse indices.
5918 trap "restore_ostindex" EXIT
5919 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices"
5920 OST_INDEX_LIST=[0,$((RANDOM * 2 % 65533 + 1)),65534] formatall
5922 # Setup and check Lustre filesystem.
5923 start_mgsmds || error "start_mgsmds failed"
5924 for i in $(seq $OSTCOUNT); do
5925 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5926 error "start ost$i failed"
5929 mount_client $MOUNT || error "mount client $MOUNT failed"
5930 check_mount || error "check client $MOUNT failed"
5933 local max_easize=$($LCTL get_param -n llite.*.max_easize)
5934 # 65452 is XATTR_SIZE_MAX less ldiskfs ea overhead
5935 if large_xattr_enabled; then
5936 [[ $max_easize -ge 65452 ]] ||
5937 error "max_easize is $max_easize, should be at least 65452 bytes"
5940 # 4012 is 4096 less ldiskfs ea overhead
5941 [[ $max_easize -ge 4012 ]] ||
5942 error "max_easize is $max_easize, should be at least 4012 bytes"
5947 run_test 81 "sparse OST indexing"
5949 # Here we exercise the stripe placement functionality on a file system that
5950 # has formatted the OST with a random index. With the file system the following
5951 # functionality is tested:
5953 # 1. Creating a new file with a specific stripe layout.
5955 # 2. Modifiy a existing empty file with a specific stripe layout.
5957 # 3. Ensure we fail to set the stripe layout of a file that already has one.
5959 # 4. If ost-index is defined we need to ensure it is the first entry in the
5960 # ost index list returned by lfs getstripe.
5962 # 5. Lastly ensure this functionality fails with directories.
5963 test_82a() { # LU-4665
5964 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
5965 skip "Need MDS version at least 2.6.54"
5966 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5972 # Format OSTs with random sparse indices.
5976 local LOV_V1_INSANE_STRIPE_COUNT=65532
5977 for i in $(seq $OSTCOUNT); do
5978 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
5979 ost_indices+=" $index"
5981 ost_indices=$(comma_list $ost_indices)
5983 stack_trap "restore_ostindex" EXIT
5984 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5985 OST_INDEX_LIST=[$ost_indices] formatall
5987 # Setup Lustre filesystem.
5988 start_mgsmds || error "start_mgsmds failed"
5989 for i in $(seq $OSTCOUNT); do
5990 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5991 error "start ost$i failed"
5994 # Collect debug information - start of test
5995 do_nodes $(comma_list $(mdts_nodes)) \
5996 $LCTL get_param osp.*.prealloc_*_id
5998 mount_client $MOUNT || error "mount client $MOUNT failed"
6001 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
6002 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6004 stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
6005 $LCTL get_param osp.*.prealloc_*_id" EXIT
6007 # 1. If the file does not exist, new file will be created
6008 # with specified OSTs.
6009 local file=$DIR/$tdir/$tfile-1
6010 local cmd="$LFS setstripe -o $ost_indices $file"
6012 eval $cmd || error "$cmd failed"
6013 check_stripe_count $file $OSTCOUNT
6014 check_obdidx $file $ost_indices
6015 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6016 error "write $file failed"
6018 # 2. If the file already exists and is an empty file, the file
6019 # will be attached with specified layout.
6020 file=$DIR/$tdir/$tfile-2
6021 mcreate $file || error "mcreate $file failed"
6022 cmd="$LFS setstripe -o $ost_indices $file"
6024 eval $cmd || error "$cmd failed"
6025 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6026 error "write $file failed"
6027 check_stripe_count $file $OSTCOUNT
6028 check_obdidx $file $ost_indices
6030 # 3. If the file already has a valid layout attached, the command
6031 # should fail with EBUSY.
6033 eval $cmd && error "stripe is already set on $file, $cmd should fail"
6035 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
6036 # be in the OST indices list.
6037 local start_ost_idx=${ost_indices##*,}
6038 file=$DIR/$tdir/$tfile-3
6039 cmd="$LFS setstripe -o $ost_indices -i $start_ost_idx $file"
6041 eval $cmd || error "$cmd failed"
6042 check_stripe_count $file $OSTCOUNT
6043 check_obdidx $file $ost_indices
6044 check_start_ost_idx $file $start_ost_idx
6046 file=$DIR/$tdir/$tfile-4
6047 cmd="$LFS setstripe"
6048 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
6049 cmd+=" -i $start_ost_idx $file"
6051 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
6053 # 5. Specifying OST indices for directory should succeed.
6054 local dir=$DIR/$tdir/$tdir
6055 mkdir $dir || error "mkdir $dir failed"
6056 cmd="$LFS setstripe -o $ost_indices $dir"
6057 if [ "$MDS1_VERSION" -gt $(version_code 2.11.53) ] &&
6058 [ "$CLIENT_VERSION" -gt $(version_code 2.11.53) ]; then
6060 eval $cmd || error "unable to specify OST indices on directory"
6062 echo "need MDS+client version at least 2.11.53"
6067 run_test 82a "specify OSTs for file (succeed) or directory (succeed)"
6072 # Remove OSTs from a pool and destroy the pool.
6073 destroy_pool $ost_pool || true
6078 # Test 82b is run to ensure that if the user supplies a pool with a specific
6079 # stripe layout that it behaves proprerly. It should fail in the case that
6080 # the supplied OST index list points to OSTs not contained in the user
6082 test_82b() { # LU-4665
6083 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
6084 skip "Need MDS version at least 2.6.54"
6085 [[ $OSTCOUNT -ge 4 ]] || skip_env "needs >= 4 OSTs"
6091 # Format OSTs with random sparse indices.
6095 local LOV_V1_INSANE_STRIPE_COUNT=65532
6096 for i in $(seq $OSTCOUNT); do
6097 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
6098 ost_indices+=" $index"
6100 ost_indices=$(comma_list $ost_indices)
6102 trap "restore_ostindex" EXIT
6103 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
6104 OST_INDEX_LIST=[$ost_indices] formatall
6106 # Setup Lustre filesystem.
6107 start_mgsmds || error "start_mgsmds failed"
6108 for i in $(seq $OSTCOUNT); do
6109 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
6110 error "start ost$i failed"
6113 mount_client $MOUNT || error "mount client $MOUNT failed"
6116 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
6117 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6119 # Create a new pool and add OSTs into it.
6120 local ost_pool=$FSNAME.$TESTNAME
6121 create_pool $ost_pool || error "create OST pool $ost_pool failed"
6124 trap "cleanup_82b" EXIT
6126 local ost_idx_in_list=${ost_indices##*,}
6127 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
6130 local ost_targets="$FSNAME-OST["
6131 for i in ${ost_idx_in_pool//,/ }; do
6132 ost_targets=$ost_targets$(printf "%04x," $i)
6134 ost_targets="${ost_targets%,}]"
6136 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
6137 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
6138 sort -u | tr '\n' ' ')
6140 local cmd="$LCTL pool_add $ost_pool $ost_targets"
6141 do_facet mgs $cmd || error "$cmd failed"
6142 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
6143 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
6144 error "wait_update $ost_pool failed"
6145 wait_update_facet $SINGLEMDS "$LCTL pool_list $ost_pool | wc -l" 4 ||
6146 error "wait_update pool_list $ost_pool failed"
6148 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
6149 # then the OSTs must be the members of the pool.
6150 local file=$DIR/$tdir/$tfile
6151 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6153 eval $cmd && error "OST with index $ost_idx_in_list should be" \
6154 "in OST pool $ost_pool"
6156 # Only select OST $ost_idx_in_list from $ost_pool for file.
6157 ost_idx_in_list=${ost_idx_in_pool#*,}
6158 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6160 eval $cmd || error "$cmd failed"
6161 cmd="$LFS getstripe $file"
6163 eval $cmd || error "$cmd failed"
6164 check_stripe_count $file 2
6165 check_obdidx $file $ost_idx_in_list
6166 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6167 error "write $file failed"
6171 run_test 82b "specify OSTs for file with --pool and --ost-list options"
6174 [[ "$OST1_VERSION" -ge $(version_code 2.6.91) ]] ||
6175 skip "Need OST version at least 2.6.91"
6176 if [ "$ost1_FSTYPE" != ldiskfs ]; then
6177 skip "ldiskfs only test"
6186 ostmnt=$(facet_mntpt ost1)
6188 # Mount the OST as an ldiskfs filesystem.
6189 log "mount the OST $dev as a $ost1_FSTYPE filesystem"
6190 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
6191 --reformat $dev > /dev/null ||
6192 error "format ost1 error"
6194 if ! test -b $dev; then
6195 mnt_opts=$(csa_add "$OST_MOUNT_FS_OPTS" -o loop)
6197 echo "mnt_opts $mnt_opts"
6198 do_facet ost1 mount -t "$ost1_FSTYPE" $dev \
6200 # Run llverfs on the mounted ldiskfs filesystem.
6201 # It is needed to get ENOSPACE.
6202 log "run llverfs in partial mode on the OST $ost1_FSTYPE $ostmnt"
6203 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
6204 "no" || error "run_llverfs error on $ost1_FSTYPE"
6207 log "unmount the OST $dev"
6210 # Delete file IO_scrub. Later osd_scrub_setup will try to
6211 # create "IO_scrub" but will get ENOSPACE.
6213 echo "start ost1 service on `facet_active_host ost1`"
6214 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
6217 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
6218 echo "string err $err"
6219 [ -z "$err" ] || error $err
6222 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
6223 Busy inodes after unmount ..."
6226 local facet=$SINGLEMDS
6227 local num=$(echo $facet | tr -d "mds")
6228 local dev=$(mdsdevname $num)
6229 local time_min=$(recovery_time_min)
6230 local recovery_duration
6231 local completed_clients
6232 local correct_clients
6235 echo "start mds service on $(facet_active_host $facet)"
6237 "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" $@ ||
6238 error "start MDS failed"
6240 start_ost || error "start OST0000 failed"
6241 start_ost2 || error "start OST0001 failed"
6243 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
6245 mount_client $MOUNT1 || error "mount $MOUNT1 failed"
6246 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
6247 # make sure new superblock labels are sync'd before disabling writes
6251 replay_barrier $SINGLEMDS
6252 createmany -o $DIR1/$tfile-%d 1000
6254 # We need to catch the end of recovery window to extend it.
6255 # Skip 5 requests and add delay to request handling.
6256 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
6257 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
6259 facet_failover --fsck $SINGLEMDS || error "failover: $?"
6262 echo "recovery status"
6263 do_facet $SINGLEMDS \
6264 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
6266 recovery_duration=$(do_facet $SINGLEMDS \
6267 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6268 awk '/recovery_duration/ { print $2 }')
6269 (( $recovery_duration > $time_min + $wrap_up )) &&
6270 error "recovery_duration > recovery_time_hard + wrap up"
6271 completed_clients=$(do_facet $SINGLEMDS \
6272 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6273 awk '/completed_clients/ { print $2 }')
6275 correct_clients="$MDSCOUNT/$((MDSCOUNT+1))"
6276 [ "$completed_clients" = "${correct_clients}" ] ||
6277 error "$completed_clients != $correct_clients"
6279 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
6280 umount_client $MOUNT1
6281 umount_client $MOUNT2
6287 run_test 84 "check recovery_hard_time"
6290 [[ "$OST1_VERSION" -ge $(version_code 2.7.55) ]] ||
6291 skip "Need OST version at least 2.7.55"
6292 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
6293 do_facet ost1 "lctl set_param fail_loc=0x197"
6297 run_test 85 "osd_ost init: fail ea_fid_set"
6302 # ost1 has already registered to the MGS before the reformat.
6303 # So after reformatting it with option "-G", it could not be
6304 # mounted to the MGS. Cleanup the system for subsequent tests.
6309 [ "$ost1_FSTYPE" = zfs ] &&
6310 skip "LU-6442: no such mkfs params for ZFS OSTs"
6311 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
6312 skip "Need server version newer than 2.7.55"
6315 local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6316 awk '/Flex block group size: / { print $NF; exit; }')
6318 [ "$OLDSIZE" == "$NEWSIZE" ] && skip "$NEWSIZE groups already"
6320 local opts=" -O flex_bg -G $NEWSIZE"
6321 opts=$(OST_FS_MKFS_OPTS+="$opts" mkfs_opts ost1 $(ostdevname 1))
6322 opts+=" --reformat $(ostdevname 1) $(ostvdevname 1)"
6323 echo "params: $opts"
6325 trap cleanup_86 EXIT ERR
6328 add ost1 $opts || error "add ost1 failed with new params"
6330 local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6331 awk '/Flex block group size: / { print $NF; exit; }')
6333 [[ $FOUNDSIZE == $NEWSIZE ]] ||
6334 error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
6338 run_test 86 "Replacing mkfs.lustre -G option"
6340 test_87() { #LU-6544
6341 [[ "$MDS1_VERSION" -ge $(version_code 2.9.51) ]] ||
6342 skip "Need MDS version at least 2.9.51"
6343 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
6344 skip "ldiskfs only test"
6345 [[ $OSTCOUNT -gt 59 ]] &&
6346 skip "Ignore wide striping situation"
6347 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
6349 local mdsdev=$(mdsdevname 1)
6350 local mdsvdev=$(mdsvdevname 1)
6351 local file=$DIR/$tfile
6352 local mntpt=$(facet_mntpt $SINGLEMDS)
6353 local used_xattr_blk=0
6354 local inode_size=${1:-1024}
6356 local xtest="trusted.test"
6360 local stripe_cnt=$(($OSTCOUNT + 2))
6362 #Please see ldiskfs_make_lustre() for MDT inode size calculation
6363 if [ $stripe_cnt -gt 16 ]; then
6366 left_size=$(expr $inode_size - \
6369 32 - 40 \* 3 - 32 \* 3 - $stripe_cnt \* 24 - 16 - 3 - \
6371 24 - 18 - $(expr length $tfile) - 16 - 4)
6372 if [ $left_size -le 0 ]; then
6373 echo "No space($left_size) is expected in inode."
6374 echo "Try 1-byte xattr instead to verify this."
6377 echo "Estimate: at most $left_size-byte space left in inode."
6383 if ! combined_mgs_mds ; then
6387 add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$stripe_cnt \
6388 --reformat $mdsdev $mdsvdev || error "add mds1 failed"
6389 start_mdt 1 > /dev/null || error "start mdt1 failed"
6390 for i in $(seq $OSTCOUNT); do
6391 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
6392 error "start ost$i failed"
6394 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
6395 check_mount || error "check client $MOUNT failed"
6398 $LFS setstripe -E 1M -S 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
6399 error "Create file with 3 components failed"
6400 $TRUNCATE $file $((1024*1024*64+1)) || error "truncate file failed"
6401 i=$($LFS getstripe -I3 -c $file) || error "get 3rd stripe count failed"
6402 if [ $i -ne $OSTCOUNT ]; then
6403 left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
6404 echo -n "Since only $i out $OSTCOUNT OSTs are used, "
6405 echo -n "the expected left space is changed to "
6406 echo "$left_size bytes at most."
6408 value=$(generate_string $left_size)
6409 setfattr -n $xtest -v $value $file
6410 orig=$(get_xattr_value $xtest $file)
6411 [[ "$orig" != "$value" ]] && error "$xtest changed"
6413 #Verify if inode has some expected space left
6414 umount $MOUNT > /dev/null || error "umount $MOUNT failed"
6415 stop_mdt 1 > /dev/null || error "stop mdt1 failed"
6416 mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
6418 do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
6419 used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
6421 [[ $used_xattr_blk -eq 0 ]] &&
6422 error "Please check MDS inode size calculation: \
6423 more than $left_size-byte space left in inode."
6424 echo "Verified: at most $left_size-byte space left in inode."
6426 unmount_ldiskfs $SINGLEMDS
6428 for i in $(seq $OSTCOUNT); do
6429 stop ost$i -f || error "stop ost$i failed"
6432 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
6435 [ "$mds1_FSTYPE" == zfs ] &&
6436 skip "LU-6662: no implementation for ZFS"
6440 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6441 --reformat $(mdsdevname 1) || error "add mds1 failed"
6443 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6444 grep -e \".*opts:.*errors=remount-ro.*\"" ||
6445 error "default mount options is missing"
6447 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6448 --mountfsoptions="user_xattr,errors=panic" \
6449 --reformat $(mdsdevname 1) || error "add mds1 failed"
6451 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6452 grep -e \".*opts:.*errors=panic.*\"" ||
6453 error "user can't override default mount options"
6455 run_test 88 "check the default mount options can be overridden"
6457 test_89() { # LU-7131
6458 [[ "$MDS1_VERSION" -ge $(version_code 2.9.54) ]] ||
6459 skip "Need MDT version at least 2.9.54"
6461 local key=failover.node
6462 local val1=192.0.2.254@tcp0 # Reserved IPs, see RFC 5735
6463 local val2=192.0.2.255@tcp0
6464 local mdsdev=$(mdsdevname 1)
6469 [ "$mds1_FSTYPE" == zfs ] && import_zpool mds1
6470 # Check that parameters are added correctly
6471 echo "tunefs --param $key=$val1"
6472 do_facet mds "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
6473 error "tunefs --param $key=$val1 failed"
6474 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6475 error "tunefs --dryrun failed"
6476 params=${params##*Parameters:}
6477 params=${params%%exiting*}
6478 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val1) = "1" ] ||
6479 error "on-disk parameter not added correctly via tunefs"
6481 # Check that parameters replace existing instances when added
6482 echo "tunefs --param $key=$val2"
6483 do_facet mds "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
6484 error "tunefs --param $key=$val2 failed"
6485 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6486 error "tunefs --dryrun failed"
6487 params=${params##*Parameters:}
6488 params=${params%%exiting*}
6489 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "1" ] ||
6490 error "on-disk parameter not replaced via tunefs"
6491 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val2) = "1" ] ||
6492 error "on-disk parameter not replaced correctly via tunefs"
6494 # Check that a parameter is erased properly
6495 echo "tunefs --erase-param $key"
6496 do_facet mds "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
6497 error "tunefs --erase-param $key failed"
6498 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6499 error "tunefs --dryrun failed"
6500 params=${params##*Parameters:}
6501 params=${params%%exiting*}
6502 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "0" ] ||
6503 error "on-disk parameter not erased correctly via tunefs"
6505 # Check that all the parameters are erased
6506 echo "tunefs --erase-params"
6507 do_facet mds "$TUNEFS --erase-params $mdsdev >/dev/null" ||
6508 error "tunefs --erase-params failed"
6509 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6510 error "tunefs --dryrun failed"
6511 params=${params##*Parameters:}
6512 params=${params%%exiting*}
6514 error "all on-disk parameters not erased correctly via tunefs"
6516 # Check the order of options --erase-params and --param
6517 echo "tunefs --param $key=$val1 --erase-params"
6519 "$TUNEFS --param $key=$val1 --erase-params $mdsdev >/dev/null"||
6520 error "tunefs --param $key=$val1 --erase-params failed"
6521 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6522 error "tunefs --dryrun failed"
6523 params=${params##*Parameters:}
6524 params=${params%%exiting*}
6525 [ $(echo $params | tr ' ' '\n') == "$key=$val1" ] ||
6526 error "on-disk param not added correctly with --erase-params"
6530 run_test 89 "check tunefs --param and --erase-param{s} options"
6533 # $2 (optional) value of max_mod_rpcs_in_flight to set
6534 check_max_mod_rpcs_in_flight() {
6542 idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
6543 facet="mds$((0x$idx + 1))"
6545 if [ -z "$mmr" ]; then
6546 # get value of max_mod_rcps_in_flight
6547 mmr=$($LCTL get_param -n \
6548 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
6549 error "Unable to get max_mod_rpcs_in_flight"
6550 echo "max_mod_rcps_in_flight is $mmr"
6552 # set value of max_mod_rpcs_in_flight
6554 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
6555 error "Unable to set max_mod_rpcs_in_flight to $mmr"
6556 echo "max_mod_rpcs_in_flight set to $mmr"
6559 # create mmr+1 files
6560 echo "creating $((mmr + 1)) files ..."
6562 for i in $(seq $((mmr + 1))); do
6568 # consumes mmr-1 modify RPC slots
6569 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6570 # drop requests on MDT so that RPC slots are consumed
6571 # during all the request resend interval
6572 do_facet $facet "$LCTL set_param fail_loc=0x159"
6573 echo "launch $((mmr - 1)) chmod in parallel ..."
6574 for i in $(seq $((mmr - 1))); do
6575 chmod 0600 $dir/file-$i &
6579 # send one additional modify RPC
6580 do_facet $facet "$LCTL set_param fail_loc=0"
6581 echo "launch 1 additional chmod in parallel ..."
6582 chmod 0600 $dir/file-$mmr &
6585 # check this additional modify RPC get a modify RPC slot
6586 # and succeed its operation
6587 checkstat -vp 0600 $dir/file-$mmr ||
6588 error "Unable to send $mmr modify RPCs in parallel"
6593 # consumes mmr modify RPC slots
6594 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6595 # drop requests on MDT so that RPC slots are consumed
6596 # during all the request resend interval
6597 do_facet $facet "$LCTL set_param fail_loc=0x159"
6598 echo "launch $mmr chmod in parallel ..."
6599 for i in $(seq $mmr); do
6600 chmod 0666 $dir/file-$i &
6604 # send one additional modify RPC
6605 do_facet $facet "$LCTL set_param fail_loc=0"
6606 echo "launch 1 additional chmod in parallel ..."
6607 chmod 0666 $dir/file-$((mmr + 1)) &
6610 # check this additional modify RPC blocked getting a modify RPC slot
6611 checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
6612 error "Unexpectedly send $(($mmr + 1)) modify RPCs in parallel"
6619 [[ $($LCTL get_param mdc.*.import |
6620 grep "connect_flags:.*multi_mod_rpc") ]] ||
6621 skip "Need MDC with 'multi_mod_rpcs' feature"
6623 # check default value
6624 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6625 check_max_mod_rpcs_in_flight $DIR/$tdir
6629 run_test 90a "check max_mod_rpcs_in_flight is enforced"
6639 [[ $($LCTL get_param mdc.*.import |
6640 grep "connect_flags:.*multi_mod_rpc") ]] ||
6641 skip "Need MDC with 'multi_mod_rpcs' feature"
6644 # update max_mod_rpcs_in_flight
6645 $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
6646 check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
6649 # check client is able to send multiple modify RPCs in paralell
6650 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6651 grep -c "multi_mod_rpcs")
6652 if [ "$tmp" -ne $MDSCOUNT ]; then
6654 skip "Client not able to send multiple modify RPCs in parallel"
6657 # update max_mod_rpcs_in_flight
6658 $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
6659 check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
6662 $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
6663 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
6664 facet="mds$((0x$idx + 1))"
6666 # save MDT max_mod_rpcs_per_client
6667 mmrpc=$(do_facet $facet \
6668 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6670 # update max_mod_rpcs_in_flight
6671 umount_client $MOUNT
6673 "echo 16 > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6675 $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
6676 check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
6678 # restore MDT max_mod_rpcs_per_client initial value
6680 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6682 rm -rf $DIR/${tdir}?
6685 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
6688 # get max_rpcs_in_flight value
6689 mrif_90c=$($LCTL get_param -n \
6690 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6691 echo "max_rpcs_in_flight is $mrif_90c"
6693 # get max_mod_rpcs_in_flight value
6694 mmrif_90c=$($LCTL get_param -n \
6695 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight)
6696 echo "max_mod_rpcs_in_flight is $mmrif_90c"
6698 # get MDT max_mod_rpcs_per_client value
6699 mmrpc_90c=$(do_facet mds1 \
6700 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6701 echo "max_mod_rpcs_per_client is $mmrpc_90c"
6704 restore_params_90c() {
6707 # restore max_rpcs_in_flight value
6708 do_facet mgs $LCTL set_param -P \
6709 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
6711 # restore max_mod_rpcs_in_flight value
6712 do_facet mgs $LCTL set_param -P \
6713 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mmrif_90c
6715 # restore MDT max_mod_rpcs_per_client value
6716 do_facet mds1 "echo $mmrpc_90c > \
6717 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6725 [[ $($LCTL get_param mdc.*.import |
6726 grep "connect_flags:.*multi_mod_rpc") ]] ||
6727 skip "Need MDC with 'multi_mod_rpcs' feature"
6729 # check client is able to send multiple modify RPCs in paralell
6730 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6731 grep -c "multi_mod_rpcs")
6732 if [ "$tmp" -ne $MDSCOUNT ]; then
6734 skip "Client not able to send multiple modify RPCs in parallel"
6738 stack_trap restore_params_90c
6741 # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
6742 # prerequisite: set max_mod_rpcs_per_client to max_rpcs_in_flight value
6743 do_facet mds1 "echo $mrif_90c > \
6744 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6746 # if max_mod_rpcs_in_flight is set to be equal to or larger than
6747 # max_rpcs_in_flight, then max_rpcs_in_flight will be increased
6748 if [[ "$CLIENT_VERSION" -ge $(version_code 2.13.53) ]]; then
6750 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c ||
6751 error "set max_mod_rpcs_in_flight to $mrif_90c failed"
6753 local new_mrif=$($LCTL get_param -n \
6754 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6755 ((new_mrif == mrif_90c + 1)) ||
6756 error "max_rpcs_in_flight was not increased"
6759 umount_client $MOUNT
6760 do_facet mds1 "echo $mmrpc_90c > \
6761 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6765 # attempt to set max_mod_rpcs_in_flight to max_mod_rpcs_per_client+1
6766 # prerequisite: set max_rpcs_in_flight to max_mod_rpcs_per_client+2
6768 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc_90c + 2))
6771 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc_90c + 1)) &&
6772 error "set max_mod_rpcs_in_flight to $((mmrpc_90c + 1)) should fail"
6775 # attempt to set max_mod_rpcs_in_flight permanently
6776 do_facet mgs $LCTL set_param -P \
6777 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
6779 do_facet mgs $LCTL set_param -P \
6780 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c
6782 remount_client $MOUNT
6784 wait_update_facet --verbose client "$LCTL get_param -n \
6785 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight" \
6786 "$((mrif_90c + 1))" ||
6787 error "expected '$((mrif_90c + 1))' for max_rpcs_in_flight"
6789 wait_update_facet --verbose client "$LCTL get_param -n \
6790 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight" \
6792 error "expected '$mrif_90c' for max_mod_rpcs_in_flight"
6797 run_test 90c "check max_mod_rpcs_in_flight update limits"
6808 [[ $($LCTL get_param mdc.*.import |
6809 grep "connect_flags:.*multi_mod_rpc") ]] ||
6810 skip "Need MDC with 'multi_mod_rpcs' feature"
6812 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6813 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
6814 facet="mds$((0x$idx + 1))"
6816 # check client version supports multislots
6817 tmp=$($LCTL get_param -N \
6818 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6819 if [ -z "$tmp" ]; then
6821 skip "Client does not support multiple modify RPCs in flight"
6824 # get current value of max_mod_rcps_in_flight
6825 mmr=$($LCTL get_param -n \
6826 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6827 echo "max_mod_rcps_in_flight is $mmr"
6830 echo "creating $mmr files ..."
6832 for i in $(seq $mmr); do
6833 touch $DIR/$tdir/file-$i
6836 # prepare for close RPC
6837 multiop_bg_pause $DIR/$tdir/file-close O_c
6840 # consumes mmr modify RPC slots
6841 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6842 # drop requests on MDT so that RPC slots are consumed
6843 # during all the request resend interval
6844 do_facet $facet "$LCTL set_param fail_loc=0x159"
6845 echo "launch $mmr chmod in parallel ..."
6846 for i in $(seq $mmr); do
6847 chmod 0600 $DIR/$tdir/file-$i &
6850 # send one additional close RPC
6851 do_facet $facet "$LCTL set_param fail_loc=0"
6852 echo "launch 1 additional close in parallel ..."
6854 cancel_lru_locks mdc
6857 # check this additional close RPC get a modify RPC slot
6858 # and multiop process completed
6859 [ -d /proc/$pid ] &&
6860 error "Unable to send the additional close RPC in parallel"
6865 run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
6867 check_uuid_on_ost() {
6869 do_facet ost1 "$LCTL get_param obdfilter.${FSNAME}*.exports.'$nid'.uuid"
6872 check_uuid_on_mdt() {
6874 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6882 [[ "$OST1_VERSION" -ge $(version_code 2.7.63) ]] ||
6883 skip "Need OST version at least 2.7.63"
6884 [[ "$MDS1_VERSION" -ge $(version_code 2.7.63) ]] ||
6885 skip "Need MDT version at least 2.7.63"
6887 start_mds || error "MDS start failed"
6888 start_ost || error "unable to start OST"
6889 mount_client $MOUNT || error "client start failed"
6890 check_mount || error "check_mount failed"
6893 nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
6897 uuid=$(get_client_uuid $MOUNT)
6899 echo "list nids on mdt:"
6900 do_facet $SINGLEMDS "$LCTL list_param mdt.${FSNAME}*.exports.*"
6901 echo "uuid from $nid:"
6902 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6904 found=$(check_uuid_on_mdt $nid | grep $uuid)
6905 [ -z "$found" ] && error "can't find $uuid $nid on MDT"
6906 found=$(check_uuid_on_ost $nid | grep $uuid)
6907 [ -z "$found" ] && error "can't find $uuid $nid on OST"
6909 # umount the client so it won't reconnect
6910 manual_umount_client --force || error "failed to umount $?"
6911 # shouldn't disappear on MDS after forced umount
6912 found=$(check_uuid_on_mdt $nid | grep $uuid)
6913 [ -z "$found" ] && error "can't find $uuid $nid"
6916 do_facet $SINGLEMDS \
6917 "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
6919 found=$(check_uuid_on_mdt $nid | grep $uuid)
6920 [ -n "$found" ] && error "found $uuid $nid on MDT"
6921 found=$(check_uuid_on_ost $nid | grep $uuid)
6922 [ -n "$found" ] && error "found $uuid $nid on OST"
6924 # check it didn't reconnect (being umounted)
6925 sleep $((TIMEOUT+1))
6926 found=$(check_uuid_on_mdt $nid | grep $uuid)
6927 [ -n "$found" ] && error "found $uuid $nid on MDT"
6928 found=$(check_uuid_on_ost $nid | grep $uuid)
6929 [ -n "$found" ] && error "found $uuid $nid on OST"
6933 run_test 91 "evict-by-nid support"
6935 generate_ldev_conf() {
6936 # generate an ldev.conf file
6937 local ldevconfpath=$1
6939 local fsldevformat=""
6942 fstype=$(facet_fstype mgs)
6943 if [ "$fstype" == zfs ]; then
6944 fsldevformat="$fstype:"
6949 printf "%s\t-\t%s-MGS0000\t%s%s\n" \
6953 $(mgsdevname) > $ldevconfpath
6955 local mdsfo_host=$mdsfailover_HOST;
6956 if [ -z "$mdsfo_host" ]; then
6960 for num in $(seq $MDSCOUNT); do
6961 fstype=$(facet_fstype mds$num)
6962 if [ "$fstype" == zfs ]; then
6963 fsldevformat="$fstype:"
6968 printf "%s\t%s\t%s-MDT%04d\t%s%s\n" \
6974 $(mdsdevname $num) >> $ldevconfpath
6977 local ostfo_host=$ostfailover_HOST;
6978 if [ -z "$ostfo_host" ]; then
6982 for num in $(seq $OSTCOUNT); do
6983 fstype=$(facet_fstype ost$num)
6984 if [ "$fstype" == zfs ]; then
6985 fsldevformat="$fstype:"
6990 printf "%s\t%s\t%s-OST%04d\t%s%s\n" \
6996 $(ostdevname $num) >> $ldevconfpath
6999 echo "----- $ldevconfpath -----"
7001 echo "--- END $ldevconfpath ---"
7006 # generate a nids file (mapping between hostname to nid)
7007 # looks like we only have the MGS nid available to us
7008 # so just echo that to a file
7010 echo -e "${mgs_HOST}\t${MGSNID}" > $nidspath
7012 echo "----- $nidspath -----"
7014 echo "--- END $nidspath ---"
7017 compare_ldev_output() {
7021 sort $expected_output -o $expected_output
7022 sort $ldev_output -o $ldev_output
7024 echo "-- START OF LDEV OUTPUT --"
7026 echo "--- END OF LDEV OUTPUT ---"
7028 echo "-- START OF EXPECTED OUTPUT --"
7029 cat $expected_output
7030 echo "--- END OF EXPECTED OUTPUT ---"
7032 diff $expected_output $ldev_output
7037 if [ -z "$LDEV" ]; then
7038 error "ldev is missing!"
7041 local LDEVCONFPATH=$TMP/ldev.conf
7042 local NIDSPATH=$TMP/nids
7044 echo "Host is $(hostname)"
7046 generate_ldev_conf $LDEVCONFPATH
7047 generate_nids $NIDSPATH
7049 # echo the mgs nid and compare it to environment variable MGSNID
7050 # also, ldev.conf and nids is a server side thing, use the OSS
7053 output=$($LDEV -c $LDEVCONFPATH -H $ost_HOST -n $NIDSPATH echo %m)
7055 echo "-- START OF LDEV OUTPUT --"
7057 echo "--- END OF LDEV OUTPUT ---"
7059 # ldev failed, error
7060 if [ $? -ne 0 ]; then
7061 rm $LDEVCONFPATH $NIDSPATH
7062 error "ldev failed to execute!"
7065 # need to process multiple lines because of combined MGS and MDS
7066 echo -e $output | awk '{ print $2 }' | while read -r line ; do
7067 if [ "$line" != "$MGSNID" ]; then
7068 rm $LDEVCONFPATH $NIDSPATH
7069 error "ldev failed mgs nid '$line', expected '$MGSNID'"
7073 rm $LDEVCONFPATH $NIDSPATH
7075 run_test 92 "ldev returns MGS NID correctly in command substitution"
7078 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
7081 #start mgs or mgs/mdt0
7082 if ! combined_mgs_mds ; then
7089 start_ost || error "OST0 start fail"
7091 #define OBD_FAIL_MGS_WRITE_TARGET_DELAY 0x90e
7092 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x8000090e"
7093 for num in $(seq 2 $MDSCOUNT); do
7097 mount_client $MOUNT || error "mount client fails"
7098 wait_osc_import_state mds ost FULL
7099 wait_osc_import_ready client ost
7100 check_mount || error "check_mount failed"
7102 cleanup || error "cleanup failed with $?"
7104 run_test 93 "register mulitple MDT at the same time"
7107 if [ -z "$LDEV" ]; then
7108 error "ldev is missing!"
7111 local LDEVCONFPATH=$TMP/ldev.conf
7112 local NIDSPATH=$TMP/nids
7114 generate_ldev_conf $LDEVCONFPATH
7115 generate_nids $NIDSPATH
7117 local LDEV_OUTPUT=$TMP/ldev-output.txt
7118 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME > $LDEV_OUTPUT
7120 # ldev failed, error
7121 if [ $? -ne 0 ]; then
7122 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7123 error "ldev failed to execute!"
7127 local EXPECTED_OUTPUT=$TMP/ldev-expected.txt
7129 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7131 for num in $(seq $MDSCOUNT); do
7132 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7135 for num in $(seq $OSTCOUNT); do
7136 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7139 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7141 if [ $? -ne 0 ]; then
7142 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7143 error "ldev failed to produce the correct hostlist!"
7146 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7148 run_test 94 "ldev outputs correct labels for file system name query"
7151 if [ -z "$LDEV" ]; then
7152 error "ldev is missing!"
7155 local LDEVCONFPATH=$TMP/ldev.conf
7156 local NIDSPATH=$TMP/nids
7158 generate_ldev_conf $LDEVCONFPATH
7159 generate_nids $NIDSPATH
7163 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME &>/dev/null
7164 if [ $? -ne 0 ]; then
7165 rm $LDEVCONFPATH $NIDSPATH
7166 error "ldev label filtering w/ -F failed!"
7170 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -l &>/dev/null
7171 if [ $? -ne 0 ]; then
7172 rm $LDEVCONFPATH $NIDSPATH
7173 error "ldev label filtering w/ -l failed!"
7177 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f &>/dev/null
7178 if [ $? -ne 0 ]; then
7179 rm $LDEVCONFPATH $NIDSPATH
7180 error "ldev label filtering w/ -f failed!"
7184 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a &>/dev/null
7185 if [ $? -ne 0 ]; then
7186 rm $LDEVCONFPATH $NIDSPATH
7187 error "ldev label filtering w/ -a failed!"
7192 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -F $FSNAME &>/dev/null
7193 if [ $? -eq 0 ]; then
7194 rm $LDEVCONFPATH $NIDSPATH
7195 error "ldev label filtering w/ -a and -F incorrectly succeeded"
7199 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -f &>/dev/null
7200 if [ $? -eq 0 ]; then
7201 rm $LDEVCONFPATH $NIDSPATH
7202 error "ldev label filtering w/ -a and -f incorrectly succeeded"
7206 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -l &>/dev/null
7207 if [ $? -eq 0 ]; then
7208 rm $LDEVCONFPATH $NIDSPATH
7209 error "ldev label filtering w/ -a and -l incorrectly succeeded"
7213 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f -l &>/dev/null
7214 if [ $? -eq 0 ]; then
7215 rm $LDEVCONFPATH $NIDSPATH
7216 error "ldev label filtering w/ -f and -l incorrectly succeeded"
7220 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -l &>/dev/null
7221 if [ $? -eq 0 ]; then
7222 rm $LDEVCONFPATH $NIDSPATH
7223 error "ldev label filtering w/ -F and -l incorrectly succeeded"
7226 # file sys & foreign
7227 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -f &>/dev/null
7228 if [ $? -eq 0 ]; then
7229 rm $LDEVCONFPATH $NIDSPATH
7230 error "ldev label filtering w/ -F and -f incorrectly succeeded"
7233 rm $LDEVCONFPATH $NIDSPATH
7235 run_test 95 "ldev should only allow one label filter"
7238 if [ -z "$LDEV" ]; then
7239 error "ldev is missing!"
7242 local LDEVCONFPATH=$TMP/ldev.conf
7243 local NIDSPATH=$TMP/nids
7245 generate_ldev_conf $LDEVCONFPATH
7246 generate_nids $NIDSPATH
7248 local LDEV_OUTPUT=$TMP/ldev-output.txt
7249 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -H $mgs_HOST \
7251 awk '{print $2}' > $LDEV_OUTPUT
7253 # ldev failed, error
7254 if [ $? -ne 0 ]; then
7255 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7256 error "ldev failed to execute!"
7260 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7262 echo "$mgs_HOST-$(facet_fstype mgs)" > $EXPECTED_OUTPUT
7264 if [ "$mgs_HOST" == "$mds_HOST" ]; then
7265 for num in $(seq $MDSCOUNT); do
7266 echo "$mds_HOST-$(facet_fstype mds$num)" \
7271 if [ "$mgs_HOST" == "$ost_HOST" ]; then
7272 for num in $(seq $OSTCOUNT); do
7273 echo "$ost_HOST-$(facet_fstype ost$num)" \
7278 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7280 if [ $? -ne 0 ]; then
7281 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7282 error "ldev failed to produce the correct output!"
7285 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7287 run_test 96 "ldev returns hostname and backend fs correctly in command sub"
7290 if [ -z "$LDEV" ]; then
7291 error "ldev is missing!"
7294 local LDEVCONFPATH=$TMP/ldev.conf
7295 local NIDSPATH=$TMP/nids
7297 generate_ldev_conf $LDEVCONFPATH
7298 generate_nids $NIDSPATH
7300 local LDEV_OUTPUT=$TMP/ldev-output.txt
7301 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
7303 echo -e "\nMDT role"
7304 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mdt > $LDEV_OUTPUT
7306 if [ $? -ne 0 ]; then
7307 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7308 error "ldev failed to execute for mdt role!"
7311 for num in $(seq $MDSCOUNT); do
7312 printf "%s-MDT%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7315 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7317 if [ $? -ne 0 ]; then
7318 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7319 error "ldev failed to produce the correct output for mdt role!"
7322 echo -e "\nOST role"
7323 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R ost > $LDEV_OUTPUT
7325 if [ $? -ne 0 ]; then
7326 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7327 error "ldev failed to execute for ost role!"
7331 for num in $(seq $OSTCOUNT); do
7332 printf "%s-OST%04d\n" $FSNAME $num >> $EXPECTED_OUTPUT
7335 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7337 if [ $? -ne 0 ]; then
7338 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7339 error "ldev failed to produce the correct output for ost role!"
7342 echo -e "\nMGS role"
7343 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mgs > $LDEV_OUTPUT
7345 if [ $? -ne 0 ]; then
7346 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
7347 error "ldev failed to execute for mgs role!"
7350 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7352 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7354 if [ $? -ne 0 ]; then
7355 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7356 error "ldev failed to produce the correct output for mgs role!"
7359 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7361 run_test 97 "ldev returns correct ouput when querying based on role"
7366 local temp=$MDS_MOUNT_OPTS
7369 check_mount || error "mount failed"
7370 mountopt="user_xattr"
7371 for ((x = 1; x <= 400; x++)); do
7372 mountopt="$mountopt,user_xattr"
7374 mount_client $MOUNT remount,$mountopt 2>&1 | grep "too long" ||
7375 error "Buffer overflow check failed"
7376 cleanup || error "cleanup failed"
7378 run_test 98 "Buffer-overflow check while parsing mount_opts"
7382 [[ "$ost1_FSTYPE" != ldiskfs ]] &&
7383 skip "ldiskfs only test"
7384 [[ "$OST1_VERSION" -ge $(version_code 2.8.57) ]] ||
7385 skip "Need OST version at least 2.8.57"
7387 local ost_opts="$(mkfs_opts ost1 $(ostdevname 1)) \
7388 --reformat $(ostdevname 1) $(ostvdevname 1)"
7389 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" &&
7390 skip "meta_bg already set"
7393 if [[ ${!opts} != *mkfsoptions* ]]; then
7394 eval opts=\"${!opts} \
7395 --mkfsoptions='\\\"-O ^resize_inode,meta_bg\\\"'\"
7397 local val=${!opts//--mkfsoptions=\\\"/ \
7398 --mkfsoptions=\\\"-O ^resize_inode,meta_bg }
7402 echo "params: $opts"
7405 add ost1 $opts || error "add ost1 failed with new params"
7407 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" ||
7408 error "meta_bg is not set"
7410 run_test 99 "Adding meta_bg option"
7415 start_mgsmds || error "MDS start failed"
7416 start_ost || error "unable to start OST"
7417 mount_client $MOUNT || error "client start failed"
7418 check_mount || error "check_mount failed"
7427 do_facet mgs 'lshowmount -v' | awk 'BEGIN {NR == 0; rc=1} /MGS:/ {rc=0}
7428 END {exit rc}' || error "lshowmount have no output MGS"
7430 do_facet mds1 'lshowmount -v' | awk 'BEGIN {NR == 2; rc=1} /-MDT0000:/
7431 {rc=0} END {exit rc}' || error "lshowmount have no output MDT0"
7433 do_facet ost1 'lshowmount -v' | awk 'BEGIN {NR == 4; rc=1} /-OST0000:/
7434 {rc=0} END {exit rc}' || error "lshowmount have no output OST0"
7436 cleanup || error "cleanup failed with $?"
7438 run_test 100 "check lshowmount lists MGS, MDT, OST and 0@lo"
7441 local createmany_pid
7442 local dev=$FSNAME-OST0000-osc-MDT0000
7446 createmany -o $DIR1/$tdir/$tfile-%d 50000 &
7448 # MDT->OST reconnection causes MDT<->OST last_id synchornisation
7449 # via osp_precreate_cleanup_orphans.
7450 for ((i = 0; i < 100; i++)); do
7451 for ((k = 0; k < 10; k++)); do
7452 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;" \
7453 "$LCTL --device $dev activate"
7456 ls -asl $MOUNT | grep '???' &&
7457 { kill -9 $createmany_pid &>/dev/null;
7458 error "File has no object on OST"; }
7460 kill -s 0 $createmany_pid || break
7462 wait $createmany_pid
7464 unlinkmany $DIR1/$tdir/$tfile-%d 50000
7467 run_test 101 "Race MDT->OST reconnection with create"
7470 [[ "$MDS1_VERSION" -gt $(version_code 2.9.53) ]] ||
7471 skip "Need server version greater than 2.9.53"
7472 [[ “$(mdsdevname 1)” != “$(mgsdevname)” ]] &&
7473 [[ “$(facet_host mds1)” = “$(facet_host mgs)” ]] &&
7474 skip "MGS must be on different node or combined"
7476 cleanup || error "cleanup failed with $?"
7478 local mds1dev=$(mdsdevname 1)
7479 local mds1mnt=$(facet_mntpt mds1)
7480 local mds1opts=$MDS_MOUNT_OPTS
7482 if [ "$mds1_FSTYPE" == ldiskfs ] &&
7483 ! do_facet mds1 test -b $mds1dev; then
7484 mds1opts=$(csa_add "$mds1opts" -o loop)
7486 if [[ "$mds1_FSTYPE" == zfs ]]; then
7487 import_zpool mds1 || return ${PIPESTATUS[0]}
7490 # unload all and only load libcfs to allow fail_loc setting
7491 do_facet mds1 $LUSTRE_RMMOD || error "unable to unload modules"
7492 do_facet mds1 modprobe libcfs || error "libcfs not loaded"
7493 do_facet mds1 lsmod \| grep libcfs || error "libcfs not loaded"
7495 #define OBD_FAIL_OBDCLASS_MODULE_LOAD 0x60a
7496 do_facet mds1 "$LCTL set_param fail_loc=0x8000060a"
7498 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
7499 error "mdt start must fail"
7500 do_facet mds1 lsmod \| grep obdclass && error "obdclass must not load"
7502 do_facet mds1 "$LCTL set_param fail_loc=0x0"
7504 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts ||
7505 error "mdt start must not fail"
7507 cleanup || error "cleanup failed with $?"
7509 run_test 102 "obdclass module cleanup upon error"
7514 echo "rename $FSNAME to $newname"
7516 if ! combined_mgs_mds ; then
7517 local dev=$(mgsdevname)
7520 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7521 error "(7) Fail to rename MGS"
7522 if [ "$(facet_fstype mgs)" = "zfs" ]; then
7523 reimport_zpool mgs $newname-mgs
7527 for num in $(seq $MDSCOUNT); do
7528 local dev=$(mdsdevname $num)
7530 do_facet mds${num} \
7531 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7532 error "(8) Fail to rename MDT $num"
7533 if [ "$(facet_fstype mds${num})" = "zfs" ]; then
7534 reimport_zpool mds${num} $newname-mdt${num}
7538 for num in $(seq $OSTCOUNT); do
7539 local dev=$(ostdevname $num)
7541 do_facet ost${num} \
7542 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7543 error "(9) Fail to rename OST $num"
7544 if [ "$(facet_fstype ost${num})" = "zfs" ]; then
7545 reimport_zpool ost${num} $newname-ost${num}
7550 test_103_set_pool() {
7554 do_facet mgs $LCTL pool_add $FSNAME.$pname ${FSNAME}-$ost_x ||
7555 error "Fail to add $ost_x to $FSNAME.$pname"
7556 wait_update $HOSTNAME \
7557 "lctl get_param -n lov.$FSNAME-clilov-*.pools.$pname |
7558 grep $ost_x" "$FSNAME-${ost_x}_UUID" ||
7559 error "$ost_x is NOT in pool $FSNAME.$pname"
7562 test_103_check_pool() {
7563 local save_fsname=$1
7566 stat $DIR/$tdir/test-framework.sh ||
7567 error "($errno) Fail to stat"
7568 do_facet mgs $LCTL pool_list $FSNAME.pool1 ||
7569 error "($errno) Fail to list $FSNAME.pool1"
7570 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname ||
7571 error "($errno) Fail to list $FSNAME.$save_fsname"
7572 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname |
7573 grep ${FSNAME}-OST0000 ||
7574 error "($errno) List $FSNAME.$save_fsname is invalid"
7576 local pname=$($LFS getstripe --pool $DIR/$tdir/d0)
7577 [ "$pname" = "$save_fsname" ] ||
7578 error "($errno) Unexpected pool name $pname"
7582 check_mount_and_prep
7584 mkdir $DIR/$tdir || error "(1) Fail to mkdir $DIR/$tdir"
7585 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir ||
7586 error "(2) Fail to copy test-framework.sh"
7588 do_facet mgs $LCTL pool_new $FSNAME.pool1 ||
7589 error "(3) Fail to create $FSNAME.pool1"
7590 # name the pool name as the fsname
7591 do_facet mgs $LCTL pool_new $FSNAME.$FSNAME ||
7592 error "(4) Fail to create $FSNAME.$FSNAME"
7594 test_103_set_pool $FSNAME OST0000
7596 $LFS setstripe -p $FSNAME $DIR/$tdir/d0 ||
7597 error "(6) Fail to setstripe on $DIR/$tdir/d0"
7602 test_renamefs mylustre
7604 local save_fsname=$FSNAME
7608 test_103_check_pool $save_fsname 7
7610 if [ $OSTCOUNT -ge 2 ]; then
7611 test_103_set_pool $save_fsname OST0001
7614 $LFS setstripe -p $save_fsname $DIR/$tdir/f0 ||
7615 error "(16) Fail to setstripe on $DIR/$tdir/f0"
7624 test_103_check_pool $save_fsname 17
7628 test_renamefs $save_fsname
7634 run_test 103 "rename filesystem name"
7636 test_104a() { # LU-6952
7637 local mds_mountopts=$MDS_MOUNT_OPTS
7638 local ost_mountopts=$OST_MOUNT_OPTS
7639 local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
7640 local lctl_ver=$(do_facet $SINGLEMDS $LCTL --version |
7643 [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
7644 skip "this test needs utils above 2.9.55"
7646 # specify "acl" in mount options used by mkfs.lustre
7647 if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
7648 MDS_MOUNT_FS_OPTS="acl,user_xattr"
7651 MDS_MOUNT_FS_OPTS="${MDS_MOUNT_FS_OPTS},acl,user_xattr"
7654 echo "mountfsopt: $MDS_MOUNT_FS_OPTS"
7656 #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
7658 if ! combined_mgs_mds ; then
7662 if [ -z "$MDS_MOUNT_OPTS" ]; then
7663 MDS_MOUNT_OPTS="-o noacl"
7665 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7668 for num in $(seq $MDSCOUNT); do
7669 start mds$num $(mdsdevname $num) $MDS_MOUNT_OPTS ||
7670 error "Failed to start MDS"
7673 for num in $(seq $OSTCOUNT); do
7674 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
7675 error "Failed to start OST"
7679 setfacl -m "d:$RUNAS_ID:rwx" $MOUNT &&
7680 error "ACL is applied when FS is mounted with noacl."
7682 MDS_MOUNT_OPTS=$mds_mountopts
7683 OST_MOUNT_OPTS=$ost_mountopts
7684 MDS_MOUNT_FS_OPTS=$mds_mountfsopts
7686 run_test 104a "Make sure user defined options are reflected in mount"
7688 test_104b() { # LU-12859
7689 mount_client $MOUNT3 flock,localflock
7690 stack_trap "umount_client $MOUNT3" EXIT
7691 mount | grep "$MOUNT3 .*,flock" && error "flock is still set"
7692 mount | grep "$MOUNT3 .*,localflock" || error "localflock is not set"
7693 umount_client $MOUNT3
7694 mount_client $MOUNT3 localflock,flock
7695 mount | grep "$MOUNT3 .*,localflock" && error "localflock is still set"
7696 mount | grep "$MOUNT3 .*,flock" || error "flock is not set"
7697 umount_client $MOUNT3
7698 mount_client $MOUNT3 localflock,flock,noflock
7699 flock_is_enabled $MOUNT3 && error "some flock is still enabled" || true
7701 run_test 104b "Mount uses last flock argument"
7703 error_and_umount() {
7714 mount --bind $DIR $TMP/$tdir || error "mount bind mnt pt failed"
7715 rm -f $TMP/$tdir/$tfile
7716 rm -f $TMP/$tdir/${tfile}1
7718 # Files should not be created in ro bind mount point
7719 # remounting from rw to ro
7720 mount -o remount,ro $TMP/$tdir ||
7721 error_and_umount "readonly remount of bind mnt pt failed"
7722 touch $TMP/$tdir/$tfile &&
7723 error_and_umount "touch succeeds on ro bind mnt pt"
7724 [ -e $TMP/$tdir/$tfile ] &&
7725 error_and_umount "file created on ro bind mnt pt"
7727 # Files should be created in rw bind mount point
7728 # remounting from ro to rw
7729 mount -o remount,rw $TMP/$tdir ||
7730 error_and_umount "read-write remount of bind mnt pt failed"
7731 touch $TMP/$tdir/${tfile}1 ||
7732 error_and_umount "touch fails on rw bind mnt pt"
7733 [ -e $TMP/$tdir/${tfile}1 ] ||
7734 error_and_umount "file not created on rw bind mnt pt"
7735 umount $TMP/$tdir || error "umount of bind mnt pt failed"
7737 cleanup || error "cleanup failed with $?"
7739 run_test 105 "check file creation for ro and rw bind mnt pt"
7746 mkdir -p $DIR/$tdir || error "create $tdir failed"
7747 lfs setstripe -c 1 -i 0 $DIR/$tdir
7748 #define OBD_FAIL_CAT_RECORDS 0x1312
7749 do_facet mds1 $LCTL set_param fail_loc=0x1312 fail_val=$repeat
7751 for ((i = 1; i <= $repeat; i++)); do
7753 #one full plain llog
7754 createmany -o $DIR/$tdir/f- 64768
7756 createmany -u $DIR/$tdir/f- 64768
7758 wait_delete_completed $((TIMEOUT * 7))
7759 #ASSERTION osp_sync_thread() ( thread->t_flags != SVC_RUNNING ) failed
7760 #shows that osp code is buggy
7761 do_facet mds1 $LCTL set_param fail_loc=0 fail_val=0
7765 run_test 106 "check osp llog processing when catalog is wrapped"
7768 [[ "$MDS1_VERSION" -ge $(version_code 2.10.50) ]] ||
7769 skip "Need MDS version > 2.10.50"
7772 start_mgsmds || error "start_mgsmds failed"
7773 start_ost || error "unable to start OST"
7775 # add unknown configuration parameter.
7776 if [[ $PERM_CMD == *"set_param -P"* ]]; then
7777 cmd="$PERM_CMD ost.$FSNAME-OST0000*.unknown_param"
7779 cmd="$PERM_CMD $FSNAME-OST0000*.ost.unknown_param"
7781 do_facet mgs "$cmd=50"
7782 cleanup_nocli || error "cleanup_nocli failed with $?"
7785 # unknown param should be ignored while mounting.
7786 start_ost || error "unable to start OST after unknown param set"
7788 cleanup || error "cleanup failed with $?"
7790 run_test 107 "Unknown config param should not fail target mounting"
7795 $rcmd rm -rf $tmp > /dev/null 2>&1
7796 $rcmd mkdir -p $tmp/{mnt,images} || error "failed to mkdir remotely"
7798 for facet in $facets; do
7799 [ "$mds1_FSTYPE" = zfs ] &&
7800 $rcmd $ZPOOL -f export lustre-$facet > /dev/null 2>&1
7801 $rcmd mkdir $tmp/mnt/$facet ||
7802 error "failed to mkdir $tmp/mnt/$facet"
7803 $rcmd dd if=/dev/zero of=$tmp/images/$facet \
7804 seek=199 bs=1M count=1 ||
7805 error "failed to create $tmp/images/$facet"
7814 local facet=${role}$((idx + 1))
7816 [ $# -eq 5 ] && pool=$5
7818 do_facet $SINGLEMDS $MKFS --fsname=lustre --$mgs \
7819 --$role --index=$idx --replace --backfstype=$bkfs \
7820 --device-size=200000 --reformat $pool $tmp/images/$facet ||
7821 error "failed to mkfs for $facet"
7825 echo "mounting client..."
7826 mount -t lustre ${nid}:/lustre $MOUNT ||
7827 error "failed to mount lustre"
7830 ls -l $MOUNT/local_dir || error "failed to list"
7832 echo "check truncate && write"
7833 echo "dummmmmmmmmmmmm" > $MOUNT/remote_dir/fsx.c ||
7834 error "failed to tuncate & write"
7837 touch $MOUNT/foooo ||
7838 error "failed to create"
7840 echo "check read && write && append"
7841 sha1sum $MOUNT/conf-sanity.sh |
7842 awk '{ print $1 }' > $MOUNT/checksum.new ||
7843 error "failed to read(1)"
7844 sha1sum $MOUNT/remote_dir/unlinkmany.c |
7845 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7846 error "failed to read(2)"
7847 sha1sum $MOUNT/striped_dir/lockahead_test.o |
7848 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7849 error "failed to read(3)"
7852 diff $MOUNT/checksum.new $MOUNT/checksum.src ||
7853 error "failed to verify data"
7863 umount -f $MOUNT || error "failed to umount client"
7864 for facet in $facets; do
7865 $rcmd umount -f $tmp/mnt/$facet ||
7866 error "failed to umount $facet"
7867 if [ "$mds1_FSTYPE" = zfs ]; then
7868 $rcmd $ZPOOL export -f lustre-$facet ||
7869 error "failed to export lustre-$facet"
7873 $rcmd rm -rf $tmp || error "failed to rm the dir $tmp"
7877 [ "$CLIENTONLY" ] && skip "Client-only testing"
7878 [ "$mds1_FSTYPE" != zfs ] && skip "zfs only test"
7879 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
7880 skip "Need server version at least 2.10.58"
7885 local tmp=$TMP/$tdir
7886 local rcmd="do_facet $SINGLEMDS"
7887 local facets="mdt1 mdt2 ost1 ost2"
7888 local nid=$($rcmd $LCTL list_nids | head -1)
7891 trap t_108_cleanup EXIT ERR
7894 t_108_mkfs mdt 0 zfs mgs lustre-mdt1/mdt1
7895 t_108_mkfs mdt 1 zfs mgsnode=$nid lustre-mdt2/mdt2
7896 t_108_mkfs ost 0 zfs mgsnode=$nid lustre-ost1/ost1
7897 t_108_mkfs ost 1 zfs mgsnode=$nid lustre-ost2/ost2
7899 for facet in $facets; do
7900 $rcmd zfs set mountpoint=$tmp/mnt/$facet canmount=on \
7901 lustre-$facet/$facet ||
7902 error "failed to zfs set for $facet (1)"
7903 $rcmd zfs mount lustre-$facet/$facet ||
7904 error "failed to local mount $facet"
7905 $rcmd tar jxf $LUSTRE/tests/ldiskfs_${facet}_2_11.tar.bz2 \
7906 --xattrs --xattrs-include="trusted.*" \
7907 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7908 error "failed to untar image for $facet"
7909 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7910 error "failed to cleanup for $facet"
7911 $rcmd zfs umount lustre-$facet/$facet ||
7912 error "failed to local umount $facet"
7913 $rcmd zfs set canmount=off lustre-$facet/$facet ||
7914 error "failed to zfs set $facet (2)"
7917 echo "changing server nid..."
7918 $rcmd mount -t lustre -o nosvc lustre-mdt1/mdt1 $tmp/mnt/mdt1
7919 $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
7920 $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
7921 $rcmd lctl replace_nids $FSNAME-OST0000 $nid
7922 $rcmd lctl replace_nids $FSNAME-OST0001 $nid
7923 $rcmd umount $tmp/mnt/mdt1
7925 for facet in $facets; do
7926 echo "mounting $facet from backup..."
7927 $rcmd mount -t lustre -o abort_recov lustre-$facet/$facet \
7928 $tmp/mnt/$facet || error "failed to mount $facet"
7931 # ZFS backend can detect migration and trigger OI scrub automatically
7932 # sleep 3 seconds for scrub done
7938 run_test 108a "migrate from ldiskfs to ZFS"
7941 [ "$CLIENTONLY" ] && skip "Client-only testing"
7942 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
7943 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
7944 skip "Need server version at least 2.10.58"
7949 local tmp=$TMP/$tdir
7950 local rcmd="do_facet $SINGLEMDS"
7951 local facets="mdt1 mdt2 ost1 ost2"
7952 local scrub_list="MDT0000 MDT0001 OST0000 OST0001"
7953 local nid=$($rcmd $LCTL list_nids | head -1)
7956 trap t_108_cleanup EXIT ERR
7959 t_108_mkfs mdt 0 ldiskfs mgs
7960 t_108_mkfs mdt 1 ldiskfs mgsnode=$nid
7961 t_108_mkfs ost 0 ldiskfs mgsnode=$nid
7962 t_108_mkfs ost 1 ldiskfs mgsnode=$nid
7964 for facet in $facets; do
7965 $rcmd mount -t ldiskfs -o loop $tmp/images/$facet \
7967 error "failed to local mount $facet"
7969 $rcmd tar jxf $LUSTRE/tests/zfs_${facet}_2_11.tar.bz2 \
7970 --xattrs --xattrs-include="*.*" \
7971 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7972 error "failed to untar image for $facet"
7973 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7974 error "failed to cleanup for $facet"
7975 $rcmd umount $tmp/mnt/$facet ||
7976 error "failed to local umount $facet"
7979 echo "changing server nid..."
7980 $rcmd mount -t lustre -o nosvc,loop $tmp/images/mdt1 $tmp/mnt/mdt1
7981 $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
7982 $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
7983 $rcmd lctl replace_nids $FSNAME-OST0000 $nid
7984 $rcmd lctl replace_nids $FSNAME-OST0001 $nid
7985 $rcmd umount $tmp/mnt/mdt1
7987 for facet in $facets; do
7988 echo "mounting $facet from backup..."
7989 $rcmd mount -t lustre -o loop,abort_recov $tmp/images/$facet \
7990 $tmp/mnt/$facet || error "failed to mount $facet"
7993 for facet in $scrub_list; do
7994 $rcmd $LCTL lfsck_start -M $FSNAME-$facet -t scrub ||
7995 error "failed to start OI scrub on $facet"
7998 # sleep 3 seconds for scrub done
8004 run_test 108b "migrate from ZFS to ldiskfs"
8008 # set number of permanent parameters
8010 test_109_set_params() {
8013 set_persistent_param_and_check mds \
8014 "mdd.$fsname-MDT0000.atime_diff" \
8015 "$fsname-MDT0000.mdd.atime_diff" \
8017 set_persistent_param_and_check mds \
8018 "mdd.$fsname-MDT0000.atime_diff" \
8019 "$fsname-MDT0000.mdd.atime_diff" \
8021 set_persistent_param_and_check client \
8022 "llite.$fsname*.max_read_ahead_mb" \
8023 "$fsname.llite.max_read_ahead_mb" \
8025 set_persistent_param_and_check client \
8026 "llite.$fsname*.max_read_ahead_mb" \
8027 "$fsname.llite.max_read_ahead_mb" \
8029 create_pool $fsname.pool1 || error "create pool failed"
8030 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
8031 error "pool_add failed"
8032 do_facet mgs $LCTL pool_remove $fsname.pool1 OST0000 ||
8033 error "pool_remove failed"
8034 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
8035 error "pool_add failed"
8039 # check permanent parameters
8041 test_109_test_params() {
8044 local atime_diff=$(do_facet mds $LCTL \
8045 get_param -n mdd.$fsname-MDT0000.atime_diff)
8046 [ $atime_diff == 63 ] || error "wrong mdd parameter after clear_conf"
8047 local max_read_ahead_mb=$(do_facet client $LCTL \
8048 get_param -n llite.$fsname*.max_read_ahead_mb)
8049 [ $max_read_ahead_mb == 64 ] ||
8050 error "wrong llite parameter after clear_conf"
8051 local ost_in_pool=$(do_facet mds $LCTL pool_list $fsname.pool1 |
8052 grep -v "^Pool:" | sed 's/_UUID//')
8053 [ $ost_in_pool = "$fsname-OST0000" ] ||
8054 error "wrong pool after clear_conf"
8058 # run lctl clear_conf, store CONFIGS before and after that
8060 test_109_clear_conf()
8062 local clear_conf_arg=$1
8065 if ! combined_mgs_mds ; then
8066 mgsdev=$(mgsdevname)
8067 stop_mgs || error "stop_mgs failed"
8068 start_mgs "-o nosvc" || error "start_mgs nosvc failed"
8070 mgsdev=$(mdsdevname 1)
8071 start_mdt 1 "-o nosvc" || error "start_mdt 1 nosvc failed"
8074 do_facet mgs "rm -rf $TMP/${tdir}/conf1; mkdir -p $TMP/${tdir}/conf1;" \
8075 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf1\\\" \
8079 # the command being tested
8081 do_facet mgs $LCTL clear_conf $clear_conf_arg ||
8082 error "clear_conf failed"
8083 if ! combined_mgs_mds ; then
8084 stop_mgs || error "stop_mgs failed"
8086 stop_mdt 1 || error "stop_mdt 1 failed"
8089 do_facet mgs "rm -rf $TMP/${tdir}/conf2; mkdir -p $TMP/${tdir}/conf2;" \
8090 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf2\\\" \
8094 test_109_file_shortened() {
8096 local sizes=($(do_facet mgs "stat -c %s " \
8097 "$TMP/${tdir}/conf1/CONFIGS/$file" \
8098 "$TMP/${tdir}/conf2/CONFIGS/$file"))
8099 [ ${sizes[1]} -lt ${sizes[0]} ] && return 0
8105 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
8106 skip "Needs MDS version 2.10.59 or later."
8107 [ "$(facet_fstype mgs)" == zfs ] &&
8108 skip "LU-8727: no implementation for ZFS"
8113 client_up || error "client_up failed"
8116 # set number of permanent parameters
8118 test_109_set_params $FSNAME
8120 umount_client $MOUNT || error "umount_client failed"
8121 stop_ost || error "stop_ost failed"
8122 stop_mds || error "stop_mds failed"
8124 test_109_clear_conf $FSNAME
8126 # make sure that all configs are cleared
8128 test_109_file_shortened $FSNAME-MDT0000 ||
8129 error "failed to clear MDT0000 config"
8130 test_109_file_shortened $FSNAME-client ||
8131 error "failed to clear client config"
8136 # check that configurations are intact
8138 test_109_test_params $FSNAME
8143 destroy_test_pools || error "destroy test pools failed"
8147 run_test 109a "test lctl clear_conf fsname"
8151 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
8152 skip "Needs MDS version 2.10.59 or later."
8153 [ "$(facet_fstype mgs)" == zfs ] &&
8154 skip "LU-8727: no implementation for ZFS"
8159 client_up || error "client_up failed"
8162 # set number of permanent parameters
8164 test_109_set_params $FSNAME
8166 umount_client $MOUNT || error "umount_client failed"
8167 stop_ost || error "stop_ost failed"
8168 stop_mds || error "stop_mds failed"
8170 test_109_clear_conf $FSNAME-MDT0000
8172 # make sure that only one config is cleared
8174 test_109_file_shortened $FSNAME-MDT0000 ||
8175 error "failed to clear MDT0000 config"
8176 test_109_file_shortened $FSNAME-client &&
8177 error "failed to clear client config"
8181 # check that configurations are intact
8183 test_109_test_params $FSNAME
8188 destroy_test_pools || error "destroy test pools failed"
8192 run_test 109b "test lctl clear_conf one config"
8196 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
8197 skip "Only applicable to ldiskfs-based MDTs"
8199 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8200 skip "large_dir option is not supported on MDS"
8201 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8202 skip "large_dir option is not supported on OSS"
8204 stopall # stop all targets before modifying the target counts
8205 local old_mdscount=$MDSCOUNT
8206 local old_ostcount=$OSTCOUNT
8208 stack_trap "MDSCOUNT=$old_mdscount OSTCOUNT=$old_ostcount" EXIT
8212 # ext4_dir_entry_2 struct size:264
8213 # dx_root struct size:8
8214 # dx_node struct size:8
8215 # dx_entry struct size:8
8216 # For 1024 bytes block size.
8217 # First level directory entries: 126
8218 # Second level directory entries: 127
8219 # Entries in leaf: 3
8220 # For 2 levels limit: 48006
8221 # For 3 levels limit : 6096762
8222 # Create 80000 files to safely exceed 2-level htree limit.
8223 CONF_SANITY_110_LINKS=${CONF_SANITY_110_LINKS:-80000}
8225 # can fit at most 3 filenames per 1KB leaf block, but each
8226 # leaf/index block will only be 3/4 full before split at each level
8227 (( MDSSIZE < CONF_SANITY_110_LINKS / 3 * 4/3 * 4/3 )) &&
8228 CONF_SANITY_110_LINKS=$((MDSSIZE * 3 * 3/4 * 3/4))
8230 combined_mgs_mds || replace=" --replace "
8231 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8232 $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8233 if [[ $opts != *large_dir* ]]; then
8234 if [[ $opts != *mkfsoptions* ]]; then
8235 opts+=" --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536\\\""
8237 opts="${opts//--mkfsoptions=\\\"/ \
8238 --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536 }"
8241 echo "MDT params: $opts"
8243 combined_mgs_mds || start_mgs
8244 add mds1 $opts || error "add mds1 failed with new params"
8245 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8247 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8248 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
8250 if [[ $opts != *large_dir* ]]; then
8251 if [[ $opts != *mkfsoptions* ]]; then
8252 opts+=" --mkfsoptions=\\\"-O large_dir\\\" "
8254 opts="${opts//--mkfsoptions=\\\"/ \
8255 --mkfsoptions=\\\"-O large_dir }"
8258 echo "OST params: $opts"
8259 add ost1 $opts || error "add ost1 failed with new params"
8260 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8262 MOUNT_2=yes mountcli || error "mount clients failed"
8264 mkdir -v $DIR/$tdir || error "cannot create $DIR/$tdir"
8265 local pids count=0 group=0
8267 echo "creating $CONF_SANITY_110_LINKS in total"
8268 while (( count < CONF_SANITY_110_LINKS )); do
8269 local len=$((253 - $(wc -c <<<"$tfile-$group-40000-")))
8270 local dir=DIR$((group % 2 + 1))
8271 local target=${!dir}/$tdir/$tfile-$group
8272 local long=$target-$(generate_name $len)-
8273 local create=$((CONF_SANITY_110_LINKS - count))
8275 (( create > 40000 )) && create=40000
8276 touch $target || error "creating $target failed"
8277 echo "creating $create hard links to $target"
8278 createmany -l $target $long $create &
8281 count=$((count + create))
8282 group=$((group + 1))
8284 echo "waiting for PIDs$pids to complete"
8285 wait $pids || error "createmany failed after $group groups"
8287 umount_client $MOUNT2 -f
8290 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8291 MDSCOUNT=$old_mdscount
8292 OSTCOUNT=$old_ostcount
8294 run_test 110 "Adding large_dir with 3-level htree"
8297 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
8298 skip "Only applicable to ldiskfs-based MDTs"
8300 is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
8301 skip "This test can not be executed on flakey dev"
8303 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8304 skip "large_dir option is not supported on MDS"
8306 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8307 skip "large_dir option is not supported on OSS"
8309 # cleanup before changing target counts
8311 local old_mdscount=$MDSCOUNT
8312 local old_ostcount=$OSTCOUNT
8313 local old_mdssize=$MDSSIZE
8315 stack_trap "MDSSIZE=$MDSSIZE MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT" EXIT
8318 (( MDSSIZE < 2400000 )) && MDSSIZE=2400000 # need at least 2.4GB
8320 local mdsdev=$(mdsdevname 1)
8321 combined_mgs_mds || replace=" --replace "
8322 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8323 $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8324 if [[ $opts != *large_dir* ]]; then
8325 if [[ $opts != *mkfsoptions* ]]; then
8326 opts+=" --mkfsoptions=\\\"-O large_dir -i 1048576 \\\" "
8328 opts="${opts//--mkfsoptions=\\\"/ \
8329 --mkfsoptions=\\\"-O large_dir -i 1048576 }"
8332 echo "MDT params: $opts"
8334 combined_mgs_mds || start_mgs
8335 __touch_device mds 1
8336 add mds1 $opts || error "add mds1 failed with new params"
8337 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8339 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8340 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
8341 if [[ $opts != *large_dir* ]]; then
8342 if [[ $opts != *mkfsoptions* ]]; then
8343 opts+=" --mkfsoptions=\\\"-O large_dir \\\""
8345 opts="${opts//--mkfsoptions=\\\"/ --mkfsoptions=\\\"-O large_dir }"
8348 echo "OST params: $opts"
8349 __touch_device ost 1
8350 add ost1 $opts || error "add ost1 failed with new params"
8351 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8353 MOUNT_2=yes mountcli
8354 mkdir $DIR/$tdir || error "cannot create $DIR/$tdir"
8356 lfs df -i $DIR/$tdir
8360 local start=$SECONDS
8362 local dirmax=$((2 << 30))
8368 while (( !needskip & dirsize < dirmax )); do
8371 for cli in ${CLIENTS//,/ }; do
8372 local len=$((253 - $(wc -c <<<"$cli-$group-60000-")))
8373 local target=$cli-$group
8374 local long=$DIR/$tdir/$target-$(generate_name $len)-
8376 RPWD=$DIR/$tdir do_node $cli touch $target ||
8377 error "creating $target failed"
8378 echo "creating 60000 hardlinks to $target"
8379 RPWD=$DIR/$tdir do_node $cli createmany -l $target $long 60000 &
8382 group=$((group + 1))
8384 long=$DIR2/$tdir/$target-$(generate_name $len)-
8386 RPWD=$DIR2/$tdir do_node $cli touch $target ||
8387 error "creating $target failed"
8388 echo "creating 60000 hardlinks to $target"
8389 RPWD=$DIR2/$tdir do_node $cli createmany -l $target $long 60000 &
8392 group=$((group + 1))
8394 echo "waiting for PIDs$pids to complete"
8395 wait $pids || error "createmany failed after $group groups"
8396 dirsize=$(stat -c %s $DIR/$tdir)
8397 taken=$((SECONDS - start))
8398 rate=$((dirsize / taken))
8399 left=$(((dirmax - dirsize) / rate))
8400 num=$((group * 60000))
8401 echo "estimate ${left}s left after $num files / ${taken}s"
8402 # if the estimated time remaining is too large (it may change
8403 # over time as the create rate is not constant) then exit
8404 # without declaring a failure.
8405 (( left > 1200 )) && needskip=1
8408 umount_client $MOUNT2 -f
8411 (( $needskip )) && skip "ETA ${left}s after $num files / ${taken}s is too long"
8413 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8414 MDSCOUNT=$old_mdscount
8415 OSTCOUNT=$old_ostcount
8416 MDSSIZE=$old_mdssize
8418 run_test 111 "Adding large_dir with over 2GB directory"
8421 start_mds || error "MDS start failed"
8422 start_ost || error "OSS start failed"
8423 echo "start ost2 service on $(facet_active_host ost2)"
8424 start ost2 $(ostdevname 2) $(csa_add "$OST_MOUNT_OPTS" -o no_precreate) ||
8425 error "start ost2 facet failed"
8426 local val=$(do_facet ost2 \
8427 "$LCTL get_param -n obdfilter.$FSNAME-OST0001*.no_precreate")
8428 (( $val == 1 )) || error "obdfilter.$FSNAME-OST0001*.no_precreate=$val"
8430 mount_client $MOUNT || error "mount client failed"
8431 wait_osc_import_state client ost2 FULL
8433 $LFS setstripe -i 0 $DIR/$tfile.0 ||
8434 error "problem creating $tfile.0 on OST0000"
8435 $LFS setstripe -i 1 $DIR/$tfile.1 && $LFS getstripe $DIR/$tfile.1 &&
8436 (( $($LFS getstripe -i $DIR/$tfile.1) == 1 )) &&
8437 error "allowed to create $tfile.1 on OST0001"
8438 do_facet ost2 $LCTL set_param obdfilter.*.no_precreate=0
8440 $LFS setstripe -i 1 $DIR/$tfile.2 ||
8441 error "failed to create $tfile.2 on ost1 facet"
8442 stop_ost2 || error "stop ost2 facet failed"
8445 run_test 112 "mount OST with nocreate option"
8451 rm -f $TMP/$tdir/lustre-mdt
8455 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8456 skip "Only applicable to ldiskfs-based MDTs"
8458 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
8460 local dbfs_ver=$(do_facet $SINGLEMDS $DEBUGFS -V 2>&1)
8462 echo "debugfs version: $dbfs_ver"
8463 echo "$dbfs_ver" | egrep -w "1.44.3.wc1|1.44.5.wc1|1.45.2.wc1" &&
8464 skip_env "This version of debugfs doesn't show inode number"
8466 is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
8467 skip "This test can not be executed on flakey dev"
8469 IMAGESIZE=$((3072 << 30)) # 3072 GiB
8477 do_facet mds1 "hostname; ifconfig; lctl dl; mount"
8479 do_facet ost1 "hostname; ifconfig; lctl dl; mount"
8480 # We need MDT size 3072GB, because it is smallest
8481 # partition that can store 2B inodes
8482 do_facet $SINGLEMDS "mkdir -p $TMP/$tdir"
8483 local mdsimgname=$TMP/$tdir/lustre-mdt
8484 do_facet $SINGLEMDS "rm -f $mdsimgname"
8485 do_facet $SINGLEMDS "touch $mdsimgname"
8486 trap cleanup_115 RETURN EXIT
8487 do_facet $SINGLEMDS "$TRUNCATE $mdsimgname $IMAGESIZE" ||
8488 skip "Backend FS doesn't support sparse files"
8489 local mdsdev=$(do_facet $SINGLEMDS "losetup -f")
8490 do_facet $SINGLEMDS "losetup $mdsdev $mdsimgname"
8492 local mds_opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8493 --mkfsoptions='-O ea_inode,^resize_inode,meta_bg \
8494 -N 2247484000 -E lazy_itable_init' --device-size=$IMAGESIZE"
8495 add mds1 $mds_opts --mgs --reformat $mdsdev ||
8496 skip_env "format large MDT failed"
8497 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8498 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
8499 add ost1 $opts || error "add ost1 failed with new params"
8500 start $SINGLEMDS $mdsdev $MDS_MOUNT_OPTS || error "start MDS failed"
8501 start_ost || error "start OSS failed"
8502 mount_client $MOUNT || error "mount client failed"
8504 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir fail"
8505 goal="/sys/fs/ldiskfs/$(basename $mdsdev)/inode_goal"
8507 # 2147483648 is 0x80000000
8508 do_facet $SINGLEMDS "echo 2147483648 >> $goal; grep . $goal"
8509 touch $DIR/$tdir/$tfile
8511 # attrs from 1 to 15 go to block, 16th - to inode
8512 for i in {1..16}; do
8513 local nm="trusted.ea$i"
8514 setfattr -n $nm -v $(printf "xattr%0250d" $i) $DIR/$tdir/$tfile
8517 # inode <2147483649> trusted.ea16 (255)
8518 local inode_num=$(do_facet $SINGLEMDS \
8519 "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsdev" |
8520 awk '/ea16/ { print $2 }' |
8521 sed -e 's/>//' -e 's/<//' -e 's/\"//')
8522 echo "inode num: $inode_num"
8523 [ $inode_num -ge 2147483648 ] || error "inode $inode_num too small"
8524 do_facet $SINGLEMDS "losetup -d $mdsdev"
8527 run_test 115 "Access large xattr with inodes number over 2TB"
8530 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
8531 [ "$MDS1_VERSION" -lt $(version_code 2.10.59) ] &&
8532 skip "Need server version at least 2.10.59"
8533 do_facet $SINGLEMDS which mkfs.xfs ||
8534 skip_env "No mkfs.xfs installed"
8539 local tmpmnt=$TMP/$tdir
8540 local mdtimg=$tfile-mdt0
8542 do_facet $SINGLEMDS mkdir -p $tmpmnt
8543 stack_trap "do_facet $SINGLEMDS rmdir $tmpmnt" EXIT
8545 do_facet $SINGLEMDS touch $TMP/$mdtimg
8546 stack_trap "do_facet $SINGLEMDS rm -f $TMP/$mdtimg" EXIT
8547 do_facet $SINGLEMDS mkfs -t xfs -d file,size=1t,name=$TMP/$mdtimg ||
8548 error "mkfs temporary xfs image"
8550 do_facet $SINGLEMDS mount $TMP/$mdtimg $tmpmnt ||
8551 error "mount temporary xfs image"
8552 stack_trap "do_facet $SINGLEMDS umount $tmpmnt" EXIT
8553 local old_mdssize=$MDSSIZE
8554 local old_mdsisize=$MDSISIZE
8556 MDSSIZE=$((17 * 1024 * 1024 * 1024)) # 17T MDT
8557 MDSISIZE=$((16 << 20))
8558 local opts17t="$(mkfs_opts $SINGLEMDS)"
8560 MDSSIZE=$old_mdssize
8561 MDSISIZE=$old_mdsisize
8563 do_facet $SINGLEMDS $MKFS \
8564 ${opts17t/-E /-E lazy_itable_init,lazy_journal_init,} \
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"
9057 [[ "$ost1_FSTYPE" == ldiskfs ]] || skip "ldiskfs only test"
9061 zconf_umount_clients $RCLIENTS $MOUNT
9063 wait_osp_active ost ${FSNAME}-OST0000 0 1
9064 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9065 local avail1=($($LCTL get_param -n osc.${osc_tgt}.kbytesavail))
9067 $LFS setstripe -i 0 $DIR/$tfile || error "failed creating $DIR/$tfile"
9068 dd if=/dev/zero of=$DIR/$tfile bs=1M oflag=direct || true
9070 local avail2=($($LCTL get_param -n osc.${osc_tgt}.kbytesavail))
9072 if ((avail2 * 100 / avail1 > 1)); then
9075 error "more than 1% space left: before=$avail1 after=$avail2"
9078 local mbs=$(($(stat -c %s $DIR/$tfile) / (1024 * 1024)))
9080 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$mbs conv=notrunc \
9081 oflag=direct || error "overwrite failed"
9083 run_test 127 "direct io overwrite on full ost"
9085 if ! combined_mgs_mds ; then
9091 # restore the values of MDSSIZE and OSTSIZE
9092 MDSSIZE=$STORED_MDSSIZE
9093 OSTSIZE=$STORED_OSTSIZE
9097 check_and_cleanup_lustre