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 84 86 103"
26 if ! combined_mgs_mds; then
27 # bug number for skipped test: LU-11991 LU-11990
28 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 32a 32b 32c 32d 32e 66"
29 # bug number for skipped test: LU-9897 LU-12032
30 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 84 123F"
34 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69 106 111"
38 # use small MDS + OST size to speed formatting time
39 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
40 # STORED_MDSSIZE is used in test_18
41 STORED_MDSSIZE=$MDSSIZE
42 STORED_OSTSIZE=$OSTSIZE
44 [ "$mds1_FSTYPE" = zfs ] && MDSSIZE=400000
46 [ "$ost1_FSTYPE" = zfs ] && OSTSIZE=400000
56 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
57 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
58 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
62 require_dsh_mds || exit 0
63 require_dsh_ost || exit 0
68 # The MGS must be started before the OSTs for a new fs, so start
69 # and stop to generate the startup logs.
72 wait_osc_import_state mds ost FULL
77 reformat_and_config() {
79 if ! combined_mgs_mds ; then
85 writeconf_or_reformat() {
86 # There are at most 2 OSTs for write_conf test
87 # who knows if/where $TUNEFS is installed?
88 # Better reformat if it fails...
89 writeconf_all $MDSCOUNT 2 ||
90 { echo "tunefs failed, reformatting instead" &&
91 reformat_and_config && return 0; }
100 echo "start mgs service on $(facet_active_host mgs)"
101 start mgs $(mgsdevname) $MGS_MOUNT_OPTS $@
107 local dev=$(mdsdevname $num)
110 echo "start mds service on `facet_active_host $facet`"
111 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
114 stop_mdt_no_force() {
117 local dev=$(mdsdevname $num)
120 echo "stop mds service on `facet_active_host $facet`"
121 stop $facet || return 97
127 local dev=$(mdsdevname $num)
130 echo "stop mds service on `facet_active_host $facet`"
131 # These tests all use non-failover stop
132 stop $facet -f || return 97
138 for num in $(seq $MDSCOUNT); do
139 start_mdt $num $@ || return 94
141 for num in $(seq $MDSCOUNT); do
142 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds${num} FULL
147 if ! combined_mgs_mds ; then
155 for num in $(seq $MDSCOUNT); do
156 stop_mdt $num || return 97
161 echo "stop mgs service on `facet_active_host mgs`"
162 # These tests all use non-failover stop
163 stop mgs -f || return 97
167 echo "start ost1 service on `facet_active_host ost1`"
168 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
169 wait_clients_import_state ${CLIENTS:-$HOSTNAME} ost1 FULL
173 echo "stop ost1 service on `facet_active_host ost1`"
174 # These tests all use non-failover stop
175 stop ost1 -f || return 98
179 echo "start ost2 service on `facet_active_host ost2`"
180 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
181 wait_clients_import_state ${CLIENTS:-$HOSTNAME} ost2 FULL
185 echo "stop ost2 service on `facet_active_host ost2`"
186 # These tests all use non-failover stop
187 stop ost2 -f || return 93
194 echo "mount $FSNAME ${mountopt:+with opts $mountopt} on $mountpath....."
195 zconf_mount $HOSTNAME $mountpath $mountopt || return 96
201 echo "umount lustre on $mountpath....."
202 zconf_umount $HOSTNAME $mountpath $@ || return 97
205 manual_umount_client(){
208 echo "manual umount lustre on ${MOUNT}...."
209 do_facet client "umount ${FORCE} $MOUNT"
215 start_mds || error "MDT start failed"
216 start_ost || error "Unable to start OST1"
217 mount_client $MOUNT || error "client start failed"
218 client_up || error "client_up failed"
227 unload_modules_conf () {
228 if combined_mgs_mds || ! local_mode; then
229 unload_modules || return 1
234 stop_ost || return 202
235 stop_mds || return 201
236 unload_modules_conf || return 203
241 [ "x$1" != "x" ] && force='-f'
242 umount_client $MOUNT $force|| return 200
243 cleanup_nocli || return $?
248 echo "umount $MOUNT2 ..."
249 umount $MOUNT2 || true
250 echo "stopping fs2mds ..."
251 stop fs2mds -f || true
252 echo "stopping fs2ost ..."
253 stop fs2ost -f || true
257 do_facet client "cp /etc/passwd $DIR/a" || return 71
258 do_facet client "rm $DIR/a" || return 72
259 # make sure lustre is actually mounted (touch will block,
260 # but grep won't, so do it after)
261 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
262 echo "setup single mount lustre success"
266 do_facet client "touch $DIR/a" || return 71
267 do_facet client "rm $DIR/a" || return 72
268 do_facet client "touch $DIR2/a" || return 73
269 do_facet client "rm $DIR2/a" || return 74
270 echo "setup double mount lustre success"
274 cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
277 if [ "$ONLY" == "setup" ]; then
282 if [ "$ONLY" == "cleanup" ]; then
289 #create single point mountpoint
295 check_mount || error "check_mount failed"
296 cleanup || error "cleanup failed with $?"
298 run_test 0 "single mount setup"
301 start_mds || error "MDS start failed"
302 start_ost || error "unable to start OST"
303 echo "start ost second time..."
304 start_ost && error "2nd OST start should fail"
305 mount_client $MOUNT || error "client start failed"
306 check_mount || error "check_mount failed"
307 cleanup || error "cleanup failed with $?"
309 run_test 1 "start up ost twice (should return errors)"
312 start_mds || error "MDT start failed"
313 echo "start mds second time.."
314 start_mds && error "2nd MDT start should fail"
315 start_ost || error "OST start failed"
316 mount_client $MOUNT || error "mount_client failed to start client"
317 check_mount || error "check_mount failed"
318 cleanup || error "cleanup failed with $?"
320 run_test 2 "start up mds twice (should return err)"
324 #mount.lustre returns an error if already in mtab
325 mount_client $MOUNT && error "2nd client mount should fail"
326 check_mount || error "check_mount failed"
327 cleanup || error "cleanup failed with $?"
329 run_test 3 "mount client twice (should return err)"
333 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
334 stop_ost || error "Unable to stop OST1"
335 umount_client $MOUNT -f || error “unmount $MOUNT failed”
338 # ok for ost to fail shutdown
339 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
340 error "cleanup failed with $?"
343 run_test 4 "force cleanup ost, then cleanup"
345 test_5a() { # was test_5
347 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
348 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
350 stop_mds || error "Unable to stop MDS"
352 # cleanup may return an error from the failed
353 # disconnects; for now I'll consider this successful
354 # if all the modules have unloaded.
358 echo "killing umount"
359 kill -TERM $UMOUNT_PID
360 echo "waiting for umount to finish"
362 if grep " $MOUNT " /proc/mounts; then
363 echo "test 5: /proc/mounts after failed umount"
367 echo "killing umount"
368 kill -TERM $UMOUNT_PID
369 echo "waiting for umount to finish"
371 grep " $MOUNT " /proc/mounts &&
372 error "/proc/mounts after second umount"
375 # manual_mount_client may fail due to umount succeeding above
377 # stop_mds is a no-op here, and should not fail
378 cleanup_nocli || error "cleanup_nocli failed with $?"
379 # df may have lingering entry
381 # mtab may have lingering entry
385 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
387 grep -q $MOUNT" " /etc/mtab || break
388 echo "Waiting /etc/mtab updated ... "
389 WAIT=$(( WAIT + sleep))
391 [ "$WAIT" -eq "$MAX_WAIT" ] &&
392 error "/etc/mtab is not updated in $WAIT secs"
393 echo "/etc/mtab updated in $WAIT secs"
395 run_test 5a "force cleanup mds, then cleanup"
403 grep " $MOUNT " /etc/mtab &&
404 error false "unexpected entry in mtab before mount" && return 10
406 start_ost || error "OST start failed"
407 if ! combined_mgs_mds ; then
408 trap cleanup_5b EXIT ERR
409 start_mds || error "MDS start failed"
413 mount_client $MOUNT && error "mount_client $MOUNT should fail"
414 grep " $MOUNT " /etc/mtab &&
415 error "$MOUNT entry in mtab after failed mount"
417 # stop_mds is a no-op here, and should not fail
418 cleanup_nocli || error "cleanup_nocli failed with $?"
419 if ! combined_mgs_mds ; then
423 run_test 5b "Try to start a client with no MGS (should return errs)"
426 grep " $MOUNT " /etc/mtab &&
427 error false "unexpected entry in mtab before mount" && return 10
429 start_mds || error "MDS start failed"
430 start_ost || error "OST start failed"
431 local oldfs="${FSNAME}"
432 FSNAME="wrong.${FSNAME}"
433 mount_client $MOUNT || :
435 grep " $MOUNT " /etc/mtab &&
436 error "$MOUNT entry in mtab after failed mount"
438 cleanup_nocli || error "cleanup_nocli failed with $?"
440 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
443 grep " $MOUNT " /etc/mtab &&
444 error "unexpected entry in mtab before mount"
446 start_ost || error "OST start failed"
447 start_mds || error "MDS start failed"
448 stop_ost -f || error "Unable to stop OST1"
449 mount_client $MOUNT || error "mount_client $MOUNT failed"
450 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
451 cleanup_nocli || error "cleanup_nocli failed with $?"
452 ! grep " $MOUNT " /etc/mtab ||
453 error "$MOUNT entry in mtab after unmount"
455 run_test 5d "mount with ost down"
458 grep " $MOUNT " /etc/mtab &&
459 error false "unexpected entry in mtab before mount" && return 10
461 start_mds || error "MDS start failed"
462 start_ost || error "OST start failed"
464 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
465 do_facet client "$LCTL set_param fail_loc=0x80000506"
466 mount_client $MOUNT || echo "mount failed (not fatal)"
467 cleanup || error "cleanup failed with $?"
468 grep " $MOUNT " /etc/mtab &&
469 error "$MOUNT entry in mtab after unmount"
472 run_test 5e "delayed connect, don't crash (bug 10268)"
475 combined_mgs_mds && skip "needs separate mgs and mds"
477 grep " $MOUNT " /etc/mtab &&
478 error false "unexpected entry in mtab before mount" && return 10
481 start_ost || error "OST start failed"
482 mount_client $MOUNT &
484 echo client_mount pid is $pid
488 if ! ps -f -p $pid >/dev/null; then
491 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
492 error "mount returns $rc, expected to hang"
494 cleanup || error "cleanup failed with $?"
499 start_mds || error "start MDS failed"
501 # mount should succeed after start mds
503 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
504 cleanup || error "final call to cleanup failed with rc $?"
506 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
510 [ "$CLIENT_VERSION" -lt $(version_code 2.9.53) ] &&
511 skip "automount of debugfs missing before 2.9.53"
512 umount /sys/kernel/debug
513 $LCTL get_param -n devices | egrep -v "error" && \
514 error "lctl can't access debugfs data"
515 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
517 run_test 5g "handle missing debugfs"
523 #define OBD_FAIL_MDS_FS_SETUP 0x135
524 do_facet mds1 "$LCTL set_param fail_loc=0x80000135"
525 start_mdt 1 && error "start mdt should fail"
526 start_mdt 1 || error "start mdt failed"
527 client_up || error "client_up failed"
530 run_test 5h "start mdt failure at mdt_fs_setup()"
536 #define OBD_FAIL_QUOTA_INIT 0xA05
537 do_facet mds1 "$LCTL set_param fail_loc=0x80000A05"
538 start_mdt 1 && error "start mdt should fail"
539 start_mdt 1 || error "start mdt failed"
540 client_up || error "client_up failed"
543 run_test 5i "start mdt failure at mdt_quota_init()"
548 mount_client $MOUNT || error "mount_client $MOUNT failed"
549 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
550 cleanup || error "cleanup failed with rc $?"
552 run_test 6 "manual umount, then mount again"
557 cleanup_nocli || error "cleanup_nocli failed with $?"
559 run_test 7 "manual umount, then cleanup"
563 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
564 check_mount2 || error "check_mount2 failed"
565 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
566 cleanup || error "cleanup failed with rc $?"
568 run_test 8 "double mount setup"
571 start_ost || error "OST start failed"
573 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
574 error "do_facet ost1 set_param inode trace failed."
575 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
576 error "do_facet ost1 set_param debug mds ost failed."
578 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
579 if [ "$CHECK_PTLDEBUG" ] && { \
580 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
581 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
582 echo "lnet.debug success"
584 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
586 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
587 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
588 echo "lnet.subsystem_debug success"
590 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
592 stop_ost || error "Unable to stop OST1"
594 run_test 9 "test ptldebug and subsystem for mkfs"
597 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
598 # But with new MDS stack we don't care about the mode of local objects
599 # anymore, so this test is removed. See bug 22944 for more details.
603 if [ "$mds1_FSTYPE" != ldiskfs ]; then
604 skip "ldiskfs only test"
608 check_mount || error "check_mount failed"
609 cleanup || error "cleanup failed with rc $?"
611 echo "Remove mds config log"
612 if ! combined_mgs_mds ; then
616 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
617 $(mgsdevname) || return \$?" ||
618 error "do_facet mgs failed with $?"
620 if ! combined_mgs_mds ; then
624 start_ost || error "OST start failed"
625 start_mds && error "MDS start succeeded, but should fail"
628 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
631 if [ "$mds1_FSTYPE" != ldiskfs ]; then
632 skip "ldiskfs only test"
635 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
640 # check if current MDSSIZE is large enough
641 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
642 log "use MDSSIZE=$MDSSIZE"
644 # check if the global config has a large enough MDSSIZE
645 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
646 [ $STORED_MDSSIZE -ge $MIN ] &&
647 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
648 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
650 # check if the block device is large enough
651 is_blkdev $SINGLEMDS $MDSDEV $MIN
652 local large_enough=$?
653 if [ -n "$OK" ]; then
654 [ $large_enough -ne 0 ] && OK=""
656 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
657 log "use device $MDSDEV with MIN=$MIN"
660 # check if a loopback device has enough space for fs metadata (5%)
662 if [ -z "$OK" ]; then
663 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
664 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
665 awk '($1 != "Filesystem") { print $4 }')
666 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
667 OK=1 && myMDSSIZE=$MIN &&
668 log "use file $MDSDEV with MIN=$MIN"
671 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS"
673 echo "mount mds with large journal..."
675 local OLD_MDSSIZE=$MDSSIZE
679 echo "mount lustre system..."
681 check_mount || error "check_mount failed"
683 echo "check journal size..."
684 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
685 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
686 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
688 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
691 cleanup || error "cleanup failed with rc $?"
696 run_test 18 "check mkfs creates large journals"
699 start_mds || error "MDS start failed"
700 stop_mds || error "Unable to stop MDS"
702 run_test 19a "start/stop MDS without OSTs"
705 start_ost || error "Unable to start OST1"
706 stop_ost -f || error "Unable to stop OST1"
708 run_test 19b "start/stop OSTs without MDS"
711 # first format the ost/mdt
712 start_mds || error "MDS start failed"
713 start_ost || error "Unable to start OST1"
714 mount_client $MOUNT || error "mount_client $MOUNT failed"
715 check_mount || error "check_mount failed"
716 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
717 mount_client $MOUNT remount,ro || error "remount client with ro failed"
718 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
719 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
720 mount_client $MOUNT remount,rw || error "remount client with rw failed"
721 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
722 MCNT=$(grep -c $MOUNT' ' /etc/mtab)
723 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
725 stop_mds || error "Unable to stop MDS"
726 stop_ost || error "Unable to stop OST1"
728 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
731 start_mds || error "MDS start failed"
732 start_ost || error "unable to start OST1"
733 wait_osc_import_state mds ost FULL
734 stop_ost || error "unable to stop OST1"
735 stop_mds || error "unable to stop MDS"
737 run_test 21a "start mds before ost, stop ost first"
740 start_ost || error "unable to start OST1"
741 start_mds || error "MDS start failed"
742 wait_osc_import_state mds ost FULL
743 stop_mds || error "unable to stop MDS"
744 stop_ost || error "unable to stop OST1"
746 run_test 21b "start ost before mds, stop mds first"
749 start_ost || error "Unable to start OST1"
750 start_mds || error "MDS start failed"
751 start_ost2 || error "Unable to start OST2"
752 wait_osc_import_state mds ost2 FULL
753 stop_ost || error "Unable to stop OST1"
754 stop_ost2 || error "Unable to stop OST2"
755 stop_mds || error "Unable to stop MDS"
756 #writeconf to remove all ost2 traces for subsequent tests
757 writeconf_or_reformat
759 run_test 21c "start mds between two osts, stop mds last"
762 combined_mgs_mds && skip "need separate mgs device"
767 start_mgs || error "unable to start MGS"
768 start_ost || error "unable to start OST1"
769 start_ost2 || error "unable to start OST2"
770 start_mds || error "MDS start failed"
771 wait_osc_import_state mds ost2 FULL
773 local zkeeper=${KEEP_ZPOOL}
774 stack_trap "KEEP_ZPOOL=$zkeeper" EXIT
777 stop_ost || error "Unable to stop OST1"
778 stop_ost2 || error "Unable to stop OST2"
779 stop_mds || error "Unable to stop MDS"
781 #writeconf to remove all ost2 traces for subsequent tests
782 writeconf_or_reformat
783 KEEP_ZPOOL="${zkeeper}"
785 start_mgs || error "unable to start MGS"
787 run_test 21d "start mgs then ost and then mds"
790 MGSNID="$saved_mgsnid"
792 echo "stopping fs2mgs ..."
793 stop $fs2mgs -f || true
796 test_21e() { # LU-5863
797 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
798 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
799 skip_env "mixed loopback and real device not working"
802 local fs2mdsdev=$(mdsdevname 1_2)
803 local fs2ostdev=$(ostdevname 1_2)
804 local fs3ostdev=$(ostdevname 2_2)
806 local fs2mdsvdev=$(mdsvdevname 1_2)
807 local fs2ostvdev=$(ostvdevname 1_2)
808 local fs3ostvdev=$(ostvdevname 2_2)
810 # temporarily use fs3ost as fs2mgs
812 local fs2mgsdev=$fs3ostdev
813 local fs2mgsvdev=$fs3ostvdev
815 local fsname=test1234
817 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
818 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
819 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
820 error "start fs2mgs failed"
822 local saved_mgsnid="$MGSNID"
823 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
825 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
826 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
827 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
828 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
830 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
831 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
833 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
834 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
835 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
839 run_test 21e "separate MGS and MDS"
842 start_mds || error "MDS start failed"
844 echo "Client mount with ost in logs, but none running"
845 start_ost || error "unable to start OST1"
846 # wait until mds connected to ost and open client connection
847 wait_osc_import_state mds ost FULL
848 stop_ost || error "unable to stop OST1"
849 mount_client $MOUNT || error "mount_client $MOUNT failed"
850 # check_mount will block trying to contact ost
851 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
852 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
853 umount_client $MOUNT -f
856 echo "Client mount with a running ost"
857 start_ost || error "unable to start OST1"
859 # if gss enabled, wait full time to let connection from
860 # mds to ost be established, due to the mismatch between
861 # initial connect timeout and gss context negotiation timeout.
862 # This perhaps could be remove after AT landed.
863 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
864 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
866 mount_client $MOUNT || error "mount_client $MOUNT failed"
867 wait_osc_import_state mds ost FULL
868 wait_osc_import_ready client ost
869 check_mount || error "check_mount failed"
872 cleanup || error "cleanup failed with rc $?"
874 run_test 22 "start a client before osts (should return errs)"
876 test_23a() { # was test_23
879 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
880 # force down client so that recovering mds waits for reconnect
881 local running=$(grep -c $MOUNT /proc/mounts) || true
882 if [ $running -ne 0 ]; then
883 echo "Stopping client $MOUNT (opts: -f)"
887 # enter recovery on failed mds
888 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
889 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
890 # try to start a new client
891 mount_client $MOUNT &
893 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
894 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
895 grep -v grep | awk '{print $2}')
896 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
898 ps --ppid $MOUNT_LUSTRE_PID
899 echo "waiting for mount to finish"
901 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
902 # SIGTERM works but it does not spread to offspring processses
903 kill -s TERM $MOUNT_PID
904 kill -s TERM $MOUNT_LUSTRE_PID
905 # we can not wait $MOUNT_PID because it is not a child of this shell
911 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
913 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
914 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
917 [ -z "$PID1" -a -z "$PID2" ] && break
918 echo "waiting for mount to finish ... "
919 WAIT=$(( WAIT + sleep))
921 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
922 error "MOUNT_PID $MOUNT_PID and "\
923 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
926 cleanup || error "cleanup failed with rc $?"
928 run_test 23a "interrupt client during recovery mount delay"
930 test_23b() { # was test_23
931 start_mds || error "MDS start failed"
932 start_ost || error "Unable to start OST1"
933 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
934 $LCTL set_param fail_loc=0x80000313
936 cleanup || error "cleanup failed with rc $?"
938 run_test 23b "Simulate -EINTR during mount"
941 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
943 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
944 is_blkdev $SINGLEMDS $MDSDEV &&
945 skip_env "mixed loopback and real device not working"
948 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
950 local fs2mdsdev=$(mdsdevname 1_2)
951 local fs2ostdev=$(ostdevname 1_2)
952 local fs2mdsvdev=$(mdsvdevname 1_2)
953 local fs2ostvdev=$(ostvdevname 1_2)
956 # LU-9733 test fsname started with numbers as well
957 local FSNAME2=969362ae
959 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
960 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
962 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
963 --reformat $fs2ostdev $fs2ostvdev || exit 10
966 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
967 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
968 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
969 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
971 # LU-9733 test fsname started with numbers
972 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
973 changelog_register -n) ||
974 error "register changelog failed"
976 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
977 changelog_deregister $cl_user ||
978 error "deregister changelog failed"
980 check_mount || error "check_mount failed"
981 # files written on 1 should not show up on 2
982 cp /etc/passwd $DIR/$tfile
984 [ -e $MOUNT2/$tfile ] && error "File bleed"
987 cp /etc/passwd $MOUNT2/$tfile ||
988 error "cp /etc/passwd $MOUNT2/$tfile failed"
989 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
990 # 2 is actually mounted
991 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
993 facet_failover fs2mds
994 facet_failover fs2ost
997 # the MDS must remain up until last MDT
999 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1000 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1001 [ -z "$MDS" ] && error "No MDT"
1003 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1005 run_test 24a "Multiple MDTs on a single node"
1008 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1010 skip "needs combined MGT and MDT device"
1012 if [ -z "$fs2mds_DEV" ]; then
1013 local dev=${SINGLEMDS}_dev
1014 local MDSDEV=${!dev}
1015 is_blkdev $SINGLEMDS $MDSDEV &&
1016 skip_env "mixed loopback and real device not working"
1019 local fs2mdsdev=$(mdsdevname 1_2)
1020 local fs2mdsvdev=$(mdsvdevname 1_2)
1022 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1023 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1025 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && {
1027 error "start MDS should fail"
1030 cleanup || error "cleanup failed with rc $?"
1032 run_test 24b "Multiple MGSs on a single node (should return err)"
1036 check_mount || error "check_mount failed"
1037 local MODULES=$($LCTL modules | awk '{ print $2 }')
1038 rmmod $MODULES 2>/dev/null || true
1039 cleanup || error "cleanup failed with $?"
1041 run_test 25 "Verify modules are referenced"
1045 # we need modules before mount for sysctl, so make sure...
1046 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1047 #define OBD_FAIL_MDS_FS_SETUP 0x135
1048 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1049 start_mds && error "MDS started but should not have started"
1050 $LCTL get_param -n devices
1051 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1052 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1053 # start mds to drop writeconf setting
1054 start_mds || error "Unable to start MDS"
1055 stop_mds || error "Unable to stop MDS"
1056 unload_modules_conf || error "unload_modules_conf failed with $?"
1058 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1062 start_ost || error "Unable to start OST1"
1063 start_mds || error "Unable to start MDS"
1064 echo "Requeue thread should have started: "
1065 ps -e | grep ll_cfg_requeue
1066 set_persistent_param_and_check ost1 \
1067 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1068 "$FSNAME-OST0000.ost.client_cache_seconds"
1069 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1071 run_test 27a "Reacquire MGS lock if OST started first"
1076 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1077 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1079 facet_failover $SINGLEMDS
1080 set_persistent_param_and_check $SINGLEMDS \
1081 "mdt.$device.identity_acquire_expire" \
1082 "$device.mdt.identity_acquire_expire"
1083 set_persistent_param_and_check client \
1084 "mdc.$device-mdc-*.max_rpcs_in_flight" \
1085 "$device.mdc.max_rpcs_in_flight"
1087 cleanup || error "cleanup failed with $?"
1089 run_test 27b "Reacquire MGS lock after failover"
1091 test_28A() { # was test_28
1094 local TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1095 local PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1096 local orig=$($LCTL get_param -n $TEST)
1097 local max=$($LCTL get_param -n \
1098 llite.$FSNAME-*.max_read_ahead_per_file_mb)
1100 orig=${orig%%.[0-9]*}
1102 echo "ORIG:$orig MAX:$max"
1103 [[ $max -le $orig ]] && orig=$((max - 3))
1104 echo "ORIG:$orig MAX:$max"
1106 local final=$((orig + 1))
1108 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1109 final=$((final + 1))
1110 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1111 umount_client $MOUNT || error "umount_client $MOUNT failed"
1112 mount_client $MOUNT || error "mount_client $MOUNT failed"
1114 local result=$($LCTL get_param -n $TEST)
1116 if [ $result -ne $final ]; then
1117 error "New config not seen: wanted $final got $result"
1119 echo "New config success: got $result"
1121 set_persistent_param_and_check client "$TEST" "$PARAM" $orig
1122 cleanup || error "cleanup failed with rc $?"
1124 run_test 28A "permanent parameter setting"
1126 test_28a() { # LU-4221
1127 [[ "$OST1_VERSION" -ge $(version_code 2.5.52) ]] ||
1128 skip "Need OST version at least 2.5.52"
1129 [ "$ost1_FSTYPE" = zfs ] &&
1130 skip "LU-4221: no such proc params for ZFS OSTs"
1137 local device="$FSNAME-OST0000"
1141 # In this test we will set three kinds of proc parameters with
1142 # lctl set_param -P or lctl conf_param:
1143 # 1. non-symlink ones in the OFD
1144 # 2. non-symlink ones in the OSD
1147 # prepare a non-symlink parameter in the OFD
1148 name="client_cache_seconds"
1149 param="$device.ost.$name"
1150 cmd="obdfilter.$device.$name"
1152 # permanently setting the parameter in the OFD
1153 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1155 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1156 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1159 # prepare a non-symlink parameter in the OSD
1161 param="$device.osd.$name"
1162 cmd="osd-*.$device.$name"
1164 # conf_param the parameter in the OSD
1165 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1166 new=$(((old + 1) % 2))
1167 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1168 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1170 cleanup || error "cleanup failed with $?"
1172 run_test 28a "set symlink parameters permanently with lctl"
1175 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
1176 setup_noconfig > /dev/null 2>&1
1177 start_ost2 || error "Unable to start OST2"
1180 local PARAM="$FSNAME-OST0001.osc.active"
1181 # With lctl set_param -P the value $PROC_ACT will be sent to
1182 # all nodes. The [!M] filter out the ability to set active
1183 # on the MDS servers which is tested with wait_osp_* below.
1184 # For ost_server_uuid that only exist on client so filtering
1186 local PROC_ACT="os[cp].$FSNAME-OST0001-osc-[^M]*.active"
1187 local PROC_UUID="os[cp].$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1189 ACTV=$($LCTL get_param -n $PROC_ACT)
1191 set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
1192 # also check ost_server_uuid status
1193 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1194 if [ -z "$RESULT" ]; then
1195 error "Client not deactivated: $($LCTL get_param \
1198 echo "Live client success: got $RESULT"
1202 wait_osp_active ost ${FSNAME}-OST0001 1 0
1204 # test new client starts deactivated
1205 umount_client $MOUNT || error "umount_client $MOUNT failed"
1206 mount_client $MOUNT || error "mount_client $MOUNT failed"
1208 # the 2nd and 3rd field of ost_server_uuid do not update at the same
1209 # time when using lctl set_param -P
1210 wait_update_facet client \
1211 "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'" \
1213 error "New client start active: $($LCTL get_param -n $PROC_UUID)"
1215 echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
1217 # make sure it reactivates
1218 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1220 umount_client $MOUNT
1221 stop_ost2 || error "Unable to stop OST2"
1222 cleanup_nocli || error "cleanup_nocli failed with $?"
1223 #writeconf to remove all ost2 traces for subsequent tests
1224 writeconf_or_reformat
1226 run_test 29 "permanently remove an OST"
1231 echo Big config llog
1232 TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1233 ORIG=$($LCTL get_param -n $TEST)
1234 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1235 for i in ${LIST[@]}; do
1236 set_persistent_param_and_check client "$TEST" \
1237 "$FSNAME.llite.max_read_ahead_whole_mb" $i
1239 # make sure client restart still works
1240 umount_client $MOUNT
1241 mount_client $MOUNT || error "mount_client $MOUNT failed"
1242 [ "$($LCTL get_param -n $TEST)" -ne "$i" ] &&
1243 error "Param didn't stick across restart $($TEST) != $i"
1246 echo Erase parameter setting
1247 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1248 do_facet mgs "$PERM_CMD -d $TEST" ||
1249 error "Erase param $TEST failed"
1251 do_facet mgs "$PERM_CMD \
1252 -d $FSNAME.llite.max_read_ahead_whole_mb" ||
1253 error "Erase param $FSNAME.llite.max_read_ahead_whole_mb failed"
1255 umount_client $MOUNT
1256 mount_client $MOUNT || error "mount_client $MOUNT failed"
1257 FINAL=$($LCTL get_param -n $TEST)
1258 echo "deleted (default) value=$FINAL, orig=$ORIG"
1259 ORIG=${ORIG%%.[0-9]*}
1260 FINAL=${FINAL%%.[0-9]*}
1261 # assumes this parameter started at the default value
1262 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1264 cleanup || error "cleanup failed with rc $?"
1266 run_test 30a "Big config llog and permanent parameter deletion"
1271 local orignids=$($LCTL get_param -n \
1272 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1274 local orignidcount=$(echo "$orignids" | wc -w)
1276 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1277 # numerical part of it. Hopefully that's not already a failover address
1279 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1281 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1282 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1283 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1284 echo "Using fake nid $NEW"
1286 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1287 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1288 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1289 PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
1290 echo "Setting $PARAM from $TEST to $NEW"
1291 do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
1292 error "$PERM_CMD $PARAM failed"
1294 PARAM="$FSNAME-OST0000.failover.node"
1295 echo "Setting $PARAM from $TEST to $NEW"
1296 do_facet mgs "$PERM_CMD $PARAM='$NEW'" ||
1297 error "$PARAM $PARAM failed"
1299 wait_update_facet client "$TEST" "$NEW" ||
1300 error "check $PARAM failed!"
1302 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1304 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1305 echo "should have $((orignidcount + 1)) entries \
1306 in failover nids string, have $NIDCOUNT"
1307 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1308 error "Failover nid not added"
1310 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1311 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1313 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1314 error "$PERM_CMD delete failed"
1316 umount_client $MOUNT
1317 mount_client $MOUNT || error "mount_client $MOUNT failed"
1319 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1321 NIDCOUNT=$(echo "$NIDS" | wc -w)
1322 echo "only $orignidcount final entries should remain \
1323 in failover nids string, have $NIDCOUNT"
1324 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1326 cleanup || error "cleanup failed with rc $?"
1328 run_test 30b "Remove failover nids"
1330 test_31() { # bug 10734
1331 # ipaddr must not exist
1332 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1333 cleanup || error "cleanup failed with rc $?"
1335 run_test 31 "Connect to non-existent node (shouldn't crash)"
1339 T32_BLIMIT=40960 # Kbytes
1343 # This is not really a test but a tool to create new disk
1344 # image tarballs for the upgrade tests.
1346 # Disk image tarballs should be created on single-node
1347 # clusters by running this test with default configurations
1348 # plus a few mandatory environment settings that are verified
1349 # at the beginning of the test.
1351 test_32newtarball() {
1355 local tmp=$TMP/t32_image_create
1360 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1361 $OSTCOUNT -ne 1 -o -z "$OSTDEV1" ]; then
1362 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1363 "MDSDEV1=<nonexistent_file>" \
1364 "MDSDEV2=<nonexistent_file>" \
1365 "(or MDSDEV, in the case of b1_8)" \
1366 "OSTCOUNT=1 OSTDEV1=<nonexistent_file>"
1370 echo "Found stale $tmp"
1374 mkdir $tmp/src || return 1
1375 tar cf - -C $src . | tar xf - -C $tmp/src
1376 dd if=/dev/zero of=$tmp/src/t32_qf_old bs=1M \
1377 count=$(($T32_BLIMIT / 1024 / 4))
1378 chown $T32_QID.$T32_QID $tmp/src/t32_qf_old
1380 # format ost with comma-separated NIDs to verify LU-4460
1381 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1382 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1386 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1387 $LFS quotacheck -ug /mnt/$FSNAME
1388 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1391 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1393 if [[ $MDSCOUNT -ge 2 ]]; then
1394 remote_dir=/mnt/$FSNAME/remote_dir
1395 $LFS mkdir -i 1 $remote_dir
1396 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1398 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1399 striped_dir=/mnt/$FSNAME/striped_dir_old
1400 $LFS mkdir -i 1 -c 2 $striped_dir
1401 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1407 mkdir $tmp/img || return 1
1411 pushd_dir=/mnt/$FSNAME
1412 if [[ $MDSCOUNT -ge 2 ]]; then
1413 pushd_dir=$remote_dir
1414 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1416 ls -Rni --time-style=+%s >$tmp/img/list2
1422 ls -Rni --time-style=+%s >$tmp/img/list
1423 find ! -name .lustre -type f -exec sha1sum {} \; |
1424 sort -k 2 >$tmp/img/sha1sums
1426 $LCTL get_param -n version | head -n 1 |
1427 sed -e 's/^lustre: *//' >$tmp/img/commit
1429 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1430 $LFS quotaon -ug /mnt/$FSNAME
1431 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1432 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1433 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1434 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1435 | tr -d "*" > $tmp/img/bspace
1436 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1437 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1438 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1439 | tr -d "*" > $tmp/img/ispace
1440 echo $T32_BLIMIT > $tmp/img/blimit
1441 echo $T32_ILIMIT > $tmp/img/ilimit
1443 $MULTIOP /mnt/$FSNAME/orph_file Ouw_c&
1447 debugfs -R "ls /PENDING" ${MDSDEV1:-$MDSDEV}
1448 cp ${MDSDEV1:-$MDSDEV} $tmp/img
1456 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1459 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1460 echo "Data verification failed"
1463 uname -r >$tmp/img/kernel
1464 uname -m >$tmp/img/arch
1466 for num in $(seq 2 $MDSCOUNT); do
1467 local devname=$(mdsdevname $num)
1469 [[ $(facet_fstype $facet) != zfs ]] ||
1470 devname=$(mdsvdevname $num)
1471 mv $devname $tmp/img
1473 mv $OSTDEV1 $tmp/img
1475 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1476 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1479 tar cjvf $dst/disk$version-"$mds1_FSTYPE".tar.bz2 -S *
1484 #run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1487 # The list of applicable tarballs is returned via the caller's
1488 # variable "tarballs".
1491 [ "$CLIENTONLY" ] && skip "Client-only testing"
1493 local node=$(facet_active_host $SINGLEMDS)
1494 local r="do_node $node"
1496 ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
1498 local IMGTYPE="$mds1_FSTYPE"
1500 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1501 -name \'disk*-$IMGTYPE.tar.bz2\')
1503 [ -z "$tarballs" ] && skip "No applicable tarballs found"
1506 t32_test_cleanup() {
1508 local facet=$SINGLEMDS
1511 if $shall_cleanup_lustre; then
1512 umount $tmp/mnt/lustre || rc=$?
1514 if $shall_cleanup_mdt; then
1515 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1517 if $shall_cleanup_mdt1; then
1518 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1520 if $shall_cleanup_ost; then
1521 $r $UMOUNT $tmp/mnt/ost || rc=$?
1526 if [[ "$mds1_FSTYPE" == zfs ]]; then
1528 local poolname_list="t32fs-mdt1 t32fs-ost1"
1530 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1532 for poolname in $poolname_list; do
1533 destroy_zpool $facet $poolname
1536 combined_mgs_mds || start_mgs || rc=$?
1540 t32_bits_per_long() {
1542 # Yes, this is not meant to be perfect.
1552 t32_reload_modules() {
1554 local all_removed=false
1557 [ "$mds1_FSTYPE" == zfs ] && do_rpc_nodes $node "service zed stop"
1559 while ((i < 20)); do
1560 echo "Unloading modules on $node: Attempt $i"
1561 do_rpc_nodes $node $LUSTRE_RMMOD "$mds1_FSTYPE" &&
1563 do_rpc_nodes $node check_mem_leak || return 1
1564 if $all_removed; then
1565 do_rpc_nodes $node load_modules
1568 if [ "$mds1_FSTYPE" == zfs ]; then
1569 do_rpc_nodes $node "$ZPOOL status -v"
1574 echo "Unloading modules on $node: Given up"
1578 t32_wait_til_devices_gone() {
1584 echo wait for devices to go
1585 while ((i < 20)); do
1586 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1587 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1588 ((devices == 0 && loops == 0)) && return 0
1592 echo "waiting for dev on $node: dev $devices loop $loops given up"
1593 do_rpc_nodes $node "losetup -a"
1594 do_rpc_nodes $node "$LCTL device_list"
1598 t32_verify_quota() {
1605 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1606 # lustre will estimate the object count usage. This fails quota
1607 # verification in 32b. The object quota usage should be accurate after
1608 # zfs-0.7.0 is released.
1609 [ "$mds1_FSTYPE" == zfs ] && {
1610 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1612 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1613 echo "Skip quota verify for zfs: $zfs_version"
1618 $LFS quota -u $T32_QID -v $mnt
1620 qval=$($LFS quota -v -u $T32_QID $mnt |
1621 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1622 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1624 [ $qval -eq $img_bspace ] || {
1625 echo "bspace, act:$qval, exp:$img_bspace"
1629 qval=$($LFS quota -v -u $T32_QID $mnt |
1630 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1631 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1633 [ $qval -eq $img_ispace ] || {
1634 echo "ispace, act:$qval, exp:$img_ispace"
1638 qval=$($LFS quota -v -u $T32_QID $mnt |
1639 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1640 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1642 [ $qval -eq $img_blimit ] || {
1643 echo "blimit, act:$qval, exp:$img_blimit"
1647 qval=$($LFS quota -v -u $T32_QID $mnt |
1648 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1649 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1651 [ $qval -eq $img_ilimit ] || {
1652 echo "ilimit, act:$qval, exp:$img_ilimit"
1656 set_persistent_param_and_check $facet \
1657 "osd-$mds1_FSTYPE.$fsname-MDT0000.quota_slave.enabled" \
1658 "$fsname.quota.mdt" ug
1660 set_persistent_param_and_check $facet \
1661 "osd-$mds1_FSTYPE.$fsname-OST0000.quota_slave.enabled" \
1662 "$fsname.quota.ost" ug
1665 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1666 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1667 echo "Write succeed, but expect -EDQUOT"
1670 rm -f $mnt/t32_qf_new
1672 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1674 echo "Create succeed, but expect -EDQUOT"
1677 unlinkmany $mnt/t32_qf_ $img_ilimit
1685 local dne_upgrade=${dne_upgrade:-"no"}
1686 local dom_upgrade=${dom_upgrade:-"no"}
1687 local project_upgrade=${project_upgrade:-"no"}
1688 local ff_convert=${ff_convert:-"no"}
1689 local shall_cleanup_mdt=false
1690 local shall_cleanup_mdt1=false
1691 local shall_cleanup_ost=false
1692 local shall_cleanup_lustre=false
1693 local mdt2_is_available=false
1694 local node=$(facet_active_host $SINGLEMDS)
1695 local r="do_node $node"
1711 local mdt_dev=$tmp/mdt
1712 local mdt2_dev=$tmp/mdt2
1713 local ost_dev=$tmp/ost
1718 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1719 trap 'trap - RETURN; t32_test_cleanup' RETURN
1722 nid=$($r $LCTL list_nids | head -1)
1724 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1725 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost}
1726 $r tar xjvf $tarball -S -C $tmp || {
1727 error_noexit "Unpacking the disk image tarball"
1730 img_commit=$($r cat $tmp/commit)
1731 img_kernel=$($r cat $tmp/kernel)
1732 img_arch=$($r cat $tmp/arch)
1733 img_bspace=$($r cat $tmp/bspace)
1734 img_ispace=$($r cat $tmp/ispace)
1736 # older images did not have "blimit" and "ilimit" files
1737 # use old values for T32_BLIMIT and T32_ILIMIT
1738 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1740 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1743 echo "Upgrading from $(basename $tarball), created with:"
1744 echo " Commit: $img_commit"
1745 echo " Kernel: $img_kernel"
1746 echo " Arch: $img_arch"
1747 echo "OST version: $(lustre_build_version ost1)"
1749 # The conversion can be made only when both of the following
1750 # conditions are satisfied:
1751 # - ost device img version < 2.3.64
1752 # - ost server version >= 2.5
1753 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1754 "$OST1_VERSION" -lt $(version_code 2.5.0) ] &&
1757 ! $r test -f $mdt2_dev || mdt2_is_available=true
1759 if [[ "$mds1_FSTYPE" == zfs ]]; then
1762 local poolname_list="t32fs-mdt1 t32fs-ost1"
1764 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1766 for poolname in $poolname_list; do
1768 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1769 $ZPOOL import -f -d $tmp $poolname"
1772 # upgrade zpool to latest supported features, including
1773 # dnode quota accounting in 0.7.0
1774 $r "$ZPOOL upgrade -a"
1776 mdt_dev=t32fs-mdt1/mdt1
1777 ost_dev=t32fs-ost1/ost1
1778 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1779 wait_update_facet $SINGLEMDS "$ZPOOL list |
1780 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1781 error_noexit "import zfs pool failed"
1784 elif [ "$project_upgrade" != "no" ]; then
1785 ! $r tune2fs -O project $mdt_dev &&
1786 error_noexit "enable project on mdt0 failed" &&
1788 $mdt2_is_available && ! $r tune2fs "-O project" $mdt2_dev &&
1789 error_noexit "enable project on mdt failed" &&
1791 ! $r tune2fs -O project $ost_dev &&
1792 error_noexit "enable project on mdt failed" &&
1796 $r $LCTL set_param debug="$PTLDEBUG"
1798 $r $TUNEFS --dryrun $mdt_dev || {
1800 error_noexit "tunefs.lustre before mounting the MDT"
1804 if $mdt2_is_available; then
1805 $r $TUNEFS --dryrun $mdt2_dev || {
1807 error_noexit "tunefs.lustre before mounting the MDT"
1812 if [ "$writeconf" ]; then
1814 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1816 $r $TUNEFS --quota $mdt_dev || {
1818 error_noexit "Enable mdt quota feature"
1821 if $mdt2_is_available; then
1822 $r $TUNEFS --quota $mdt2_dev || {
1824 error_noexit "Enable mdt quota feature"
1830 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
1831 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
1832 skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
1833 "(Need MGS version at least 2.3.59)"
1835 local osthost=$(facet_active_host ost1)
1836 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
1839 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1842 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
1843 $r $LCTL replace_nids $fsname-OST0000 $ostnid
1844 $r $LCTL replace_nids $fsname-MDT0000 $nid
1845 $r $UMOUNT $tmp/mnt/mdt
1848 mopts=exclude=$fsname-OST0000
1849 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1854 t32_wait_til_devices_gone $node
1856 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
1858 error_noexit "Mounting the MDT"
1861 shall_cleanup_mdt=true
1863 if $mdt2_is_available; then
1864 mopts=mgsnode=$nid,$mopts
1865 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
1867 error_noexit "Mounting the MDT"
1871 echo "mount new MDT....$mdt2_dev"
1872 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1873 error_noexit "enable remote dir create failed"
1875 shall_cleanup_mdt1=true
1876 elif [ "$dne_upgrade" != "no" ]; then
1877 local fs2mdsdev=$(mdsdevname 1_2)
1878 local fs2mdsvdev=$(mdsvdevname 1_2)
1880 echo "mkfs new MDT on ${fs2mdsdev}...."
1881 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1882 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
1885 add $SINGLEMDS $(mds2failover_HOST="" \
1886 mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
1887 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
1888 error_noexit "Mkfs new MDT failed"
1892 [[ "$mds1_FSTYPE" != zfs ]] || import_zpool mds1
1894 $r $TUNEFS --dryrun $fs2mdsdev || {
1895 error_noexit "tunefs.lustre before mounting the MDT"
1899 echo "mount new MDT....$fs2mdsdev"
1900 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
1901 error_noexit "mount mdt1 failed"
1905 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
1906 error_noexit "enable remote dir create failed"
1908 shall_cleanup_mdt1=true
1911 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
1912 error_noexit "Getting MDT UUID"
1915 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
1916 error_noexit "Unexpected MDT UUID: \"$uuid\""
1920 $r $TUNEFS --dryrun $ost_dev || {
1921 error_noexit "tunefs.lustre before mounting the OST"
1924 if [ "$writeconf" ]; then
1925 mopts=mgsnode=$nid,$writeconf
1926 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1928 $r $TUNEFS --quota $ost_dev || {
1930 error_noexit "Enable ost quota feature"
1936 if [ "$mds1_FSTYPE" == ldiskfs ]; then
1941 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
1942 error_noexit "Mounting the OST"
1945 shall_cleanup_ost=true
1947 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
1948 error_noexit "Getting OST UUID"
1951 if [ "$uuid" != $fsname-OST0000_UUID ]; then
1952 error_noexit "Unexpected OST UUID: \"$uuid\""
1956 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1957 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
1958 error_noexit "Setting OST \"failover.node\""
1961 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
1962 error_noexit "Setting MDT \"failover.node\""
1965 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
1966 error_noexit "Setting \"max_dirty_mb\""
1969 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
1970 error_noexit "Setting \"max_rpcs_in_flight\""
1973 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
1974 error_noexit "Setting \"lov.stripesize\""
1977 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
1978 error_noexit "Setting \"mdd.atime_diff\""
1982 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
1983 error_noexit "Setting OST \"failover.node\""
1987 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
1988 error_noexit "Setting MDT \"failover.node\""
1992 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
1993 error_noexit "Setting \"max_dirty_mb\""
1996 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
1997 error_noexit "Setting \"max_rpcs_in_flight\""
2000 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
2001 error_noexit "Setting \"lov.stripesize\""
2004 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
2005 error_noexit "Setting \"mdd.atime_diff\""
2010 $r $LCTL pool_new $fsname.interop || {
2011 error_noexit "Setting \"interop\""
2015 if [ "$ff_convert" != "no" -a "$ost1_FSTYPE" == ldiskfs ]; then
2016 $r $LCTL lfsck_start -M $fsname-OST0000 || {
2017 error_noexit "Start OI scrub on OST0"
2021 # The oi_scrub should be on ost1, but for test_32(),
2022 # all on the SINGLEMDS.
2023 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
2024 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2025 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
2026 error_noexit "Failed to get the expected 'completed'"
2030 local UPDATED=$($r $LCTL get_param -n \
2031 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2032 awk '/^updated/ { print $2 }')
2033 [ $UPDATED -ge 1 ] || {
2034 error_noexit "Only $UPDATED objects have been converted"
2039 if [ "$dne_upgrade" != "no" ]; then
2040 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2041 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
2042 error_noexit "Setting MDT1 \"failover.node\""
2046 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
2047 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2050 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
2051 error_noexit "Setting MDT1 \"lov.stripesize\""
2055 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
2056 error_noexit "Setting MDT1 \"failover.node\""
2059 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2060 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2063 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2064 error_noexit "Setting MDT1 \"lov.stripesize\""
2070 if [ "$writeconf" ]; then
2071 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2072 error_noexit "Mounting the client"
2076 shall_cleanup_lustre=true
2077 $r $LCTL set_param debug="$PTLDEBUG"
2079 # Leave re-enabling this to a separate patch for LU-11558
2080 # t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2081 # error_noexit "verify quota failed"
2085 if $r test -f $tmp/list; then
2087 # There is not a Test Framework API to copy files to or
2088 # from a remote node.
2090 # LU-2393 - do both sorts on same node to ensure locale
2092 local list_file=$tmp/list
2094 if $mdt2_is_available; then
2095 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2096 $r test -f $tmp/list2; then
2097 list_file=$tmp/list2
2098 pushd $tmp/mnt/lustre/striped_dir_old
2100 pushd $tmp/mnt/lustre/remote_dir
2103 pushd $tmp/mnt/lustre
2105 $r cat $list_file | sort -k 6 >$tmp/list.orig
2106 ls -Rni --time-style=+%s | sort -k 6 |
2107 sed 's/\. / /' >$tmp/list || {
2113 # 32-bit and 64-bit clients use different algorithms to
2114 # convert FIDs into inode numbers. Hence, remove the
2115 # inode numbers from the lists, if the original list was
2116 # created on an architecture with different number of
2119 if [ $(t32_bits_per_long $(uname -m)) != \
2120 $(t32_bits_per_long $img_arch) ]; then
2121 echo "Different number of bits per \"long\"" \
2122 "from the disk image"
2123 for list in list.orig list; do
2124 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2128 if ! diff -ub $tmp/list.orig $tmp/list; then
2129 error_noexit "list verification failed"
2133 echo "list verification skipped"
2136 if [ "$dom_upgrade" != "no" ]; then
2137 echo "Check DoM file can be created"
2138 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2139 error_noexit "Verify DoM creation"
2142 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2143 error_noexit "Verify a DoM file"
2146 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2147 count=1 conv=fsync || {
2148 error_noexit "Cannot write to DoM file"
2151 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2152 error_noexit "DoM: bad size after write"
2155 rm $tmp/mnt/lustre/dom
2157 set_persistent_param_and_check mds \
2158 "lod.*MDT0000*.dom_stripesize" \
2159 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2160 error_noexit "Changing \"dom_stripesize\""
2165 if [ "$dne_upgrade" != "no" ]; then
2166 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2167 error_noexit "set striped dir failed"
2171 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2173 pushd $tmp/mnt/lustre
2174 tar -c --exclude=./striped_dir \
2175 --exclude=./striped_dir_old \
2176 --exclude=./remote_dir -f - .|
2177 tar -xvf - -C striped_dir 1>/dev/null || {
2178 error_noexit "cp to striped dir failed"
2184 # If it is upgrade from DNE (2.5), then rename the remote dir,
2185 # which is created in 2.5 to striped dir.
2186 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2187 stripe_index=$($LFS getdirstripe -i \
2188 $tmp/mnt/lustre/remote_dir)
2190 [[ $stripe_index -eq 1 ]] || {
2191 error_noexit "get index \"$stripe_index\"" \
2192 "from remote dir failed"
2195 mv $tmp/mnt/lustre/remote_dir \
2196 $tmp/mnt/lustre/striped_dir/ || {
2197 error_noexit "mv remote dir failed"
2202 # If it is upgraded from DNE (2.7), then move the striped dir
2203 # which was created in 2.7 to the new striped dir.
2204 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2205 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2206 stripe_count=$($LFS getdirstripe -c \
2207 $tmp/mnt/lustre/striped_dir_old)
2208 [[ $stripe_count -eq 2 ]] || {
2209 error_noexit "get count $stripe_count" \
2210 "from striped dir failed"
2213 mv $tmp/mnt/lustre/striped_dir_old \
2214 $tmp/mnt/lustre/striped_dir/ || {
2215 error_noexit "mv striped dir failed"
2221 $r $LCTL set_param -n osd*.*.force_sync=1
2222 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2223 error_noexit "dd failed"
2226 rm -rf $tmp/mnt/lustre/tmp_file || {
2227 error_noexit "rm failed"
2231 if $r test -f $tmp/sha1sums; then
2232 # LU-2393 - do both sorts on same node to ensure locale
2234 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2235 if [ "$dne_upgrade" != "no" ]; then
2236 pushd $tmp/mnt/lustre/striped_dir
2238 pushd $tmp/mnt/lustre
2241 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2242 ! -name .lustre -type f -exec sha1sum {} \; |
2243 sort -k 2 >$tmp/sha1sums || {
2245 error_noexit "sha1sum"
2249 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2250 error_noexit "sha1sum verification failed"
2254 # if upgrade from DNE(2.5), then check remote directory
2255 # if upgrade from DNE(2.7), then check striped directory
2256 if $mdt2_is_available &&
2257 [[ "$dne_upgrade" != "no" ]]; then
2258 local new_dir="$tmp/mnt/lustre/striped_dir"
2259 local striped_dir_old="$new_dir/striped_dir_old"
2261 local dir_list="$new_dir/remote_dir"
2262 [[ ! -d $triped_dir_old ]] ||
2263 dir_list+=" $striped_dir_old"
2265 for dir in $dir_list; do
2267 find ! -name .lustre -type f \
2268 -exec sha1sum {} \; |
2269 sort -k 2 >$tmp/sha1sums || {
2271 error_noexit "sha1sum"
2275 if ! diff -ub $tmp/sha1sums.orig \
2277 error_noexit "sha1sum $dir" \
2284 echo "sha1sum verification skipped"
2287 if [ "$dne_upgrade" != "no" ]; then
2288 rm -rf $tmp/mnt/lustre/striped_dir || {
2289 error_noexit "remove remote dir failed"
2294 # migrate files/dirs to remote MDT, then move them back
2295 if [ "$MDS1_VERSION" -ge $(version_code 2.7.50) -a \
2296 $dne_upgrade != "no" ]; then
2297 $r $LCTL set_param -n \
2298 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2300 echo "test migration"
2301 pushd $tmp/mnt/lustre
2302 for dir in $(find ! -name .lustre ! -name . -type d); do
2303 mdt_index=$($LFS getdirstripe -i $dir)
2304 stripe_cnt=$($LFS getdirstripe -c $dir)
2305 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2306 $LFS migrate -m 1 $dir || {
2308 error_noexit "migrate MDT1 failed"
2314 for dir in $(find ! -name . ! -name .lustre -type d); do
2315 mdt_index=$($LFS getdirstripe -i $dir)
2316 stripe_cnt=$($LFS getdirstripe -c $dir)
2317 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2318 $LFS migrate -m 0 $dir || {
2320 error_noexit "migrate MDT0 failed"
2329 # When adding new data verification tests, please check for
2330 # the presence of the required reference files first, like
2331 # the "sha1sums" and "list" tests above, to avoid the need to
2332 # regenerate every image for each test addition.
2335 nrpcs_orig=$($LCTL get_param \
2336 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2337 error_noexit "Getting \"max_rpcs_in_flight\""
2340 nrpcs=$((nrpcs_orig + 5))
2342 set_persistent_param_and_check client \
2343 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
2344 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
2345 error_noexit "Changing \"max_rpcs_in_flight\""
2349 umount $tmp/mnt/lustre || {
2350 error_noexit "Unmounting the client"
2353 shall_cleanup_lustre=false
2355 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2356 error_noexit "Mounting the client"
2360 if [ "$mds1_FSTYPE" == ldiskfs -a \
2361 "$project_upgrade" != "no" ]; then
2362 ! $LFS project -d -p 1 $tmp/mnt/lustre/* &&
2363 error_noexit "set project failed" &&
2367 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) == 0 ]] ||
2368 error "MDD orphan cleanup thread not quit"
2370 umount $tmp/mnt/lustre || {
2371 error_noexit "Unmounting the client"
2375 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2376 $r $UMOUNT $tmp/mnt/mdt1 || {
2377 error_noexit "Unmounting the MDT2"
2380 if [[ "$mds1_FSTYPE" == zfs ]]; then
2381 $r "$ZPOOL export t32fs-mdt2"
2383 shall_cleanup_mdt1=false
2386 $r $UMOUNT $tmp/mnt/mdt || {
2387 error_noexit "Unmounting the MDT"
2390 if [[ "$mds1_FSTYPE" == zfs ]]; then
2391 $r "$ZPOOL export t32fs-mdt1"
2393 shall_cleanup_mdt=false
2395 $r $UMOUNT $tmp/mnt/ost || {
2396 error_noexit "Unmounting the OST"
2399 if [[ "$mds1_FSTYPE" == zfs ]]; then
2400 $r "$ZPOOL export t32fs-ost1"
2402 shall_cleanup_ost=false
2404 t32_reload_modules $node || {
2405 error_noexit "Reloading modules"
2409 if [[ "$mds1_FSTYPE" == zfs ]]; then
2410 local poolname=t32fs-mdt1
2412 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2413 $ZPOOL import -f -d $tmp $poolname"
2415 # upgrade zpool to latest supported features,
2416 # including dnode quota accounting in 0.7.0
2417 $r "$ZPOOL upgrade $poolname"
2420 # mount a second time to make sure we didnt leave upgrade flag on
2421 $r $TUNEFS --dryrun $mdt_dev || {
2423 error_noexit "tunefs.lustre before remounting the MDT"
2427 mopts=exclude=$fsname-OST0000
2428 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2431 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2432 error_noexit "Remounting the MDT"
2435 shall_cleanup_mdt=true
2445 for tarball in $tarballs; do
2446 banner "testing $tarball upgrade"
2447 t32_test $tarball || let "rc += $?"
2451 run_test 32a "Upgrade (not live)"
2459 for tarball in $tarballs; do
2460 banner "testing $tarball upgrade with writeconf"
2461 t32_test $tarball writeconf || let "rc += $?"
2465 run_test 32b "Upgrade with writeconf"
2472 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2474 for tarball in $tarballs; do
2475 # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
2476 [[ "$tarball" =~ "1_8" ]] && echo "skip $tarball" && continue
2477 [[ "$tarball" =~ "2_1" ]] && echo "skip $tarball" && continue
2478 banner "testing $tarball upgrade with DNE"
2480 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2484 run_test 32c "dne upgrade test"
2492 for tarball in $tarballs; do
2493 banner "testing $tarball upgrade with ff convert and project upgrade"
2494 project_upgrade="no"
2495 [[ "$MDS1_VERSION" -ge $(version_code 2.13.54) ]] &&
2496 [[ "$tarball" =~ "disk2_4-ldiskfs" ]] &&
2497 project_upgrade="yes"
2498 project_upgrade=$project_upgrade ff_convert=yes t32_test \
2503 run_test 32d "convert ff and project quota upgrade test"
2506 [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
2507 skip "Need MDS version at least 2.10.56"
2514 for tarball in $tarballs; do
2515 [[ "$tarball" =~ "2_9" ]] || continue
2517 banner "testing $tarball upgrade with DoM"
2518 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
2522 run_test 32e "dom upgrade test"
2524 test_33a() { # bug 12333, was test_33
2525 local FSNAME2=test-123
2526 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2529 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
2531 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
2532 local dev=${SINGLEMDS}_dev
2533 local MDSDEV=${!dev}
2534 is_blkdev $SINGLEMDS $MDSDEV &&
2535 skip_env "mixed loopback and real device not working"
2538 local fs2mdsdev=$(mdsdevname 1_2)
2539 local fs2ostdev=$(ostdevname 1_2)
2540 local fs2mdsvdev=$(mdsvdevname 1_2)
2541 local fs2ostvdev=$(ostvdevname 1_2)
2543 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2544 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
2547 if combined_mgs_mds; then
2548 local mgs_flag="--mgs"
2551 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
2552 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
2554 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2555 --fsname=${FSNAME2} --index=8191 --reformat $fs2ostdev \
2556 $fs2ostvdev || exit 10
2558 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
2559 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2561 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2562 do_facet mgs "$PERM_CMD timeout=200" ||
2563 error "$PERM_CMD timeout=200 failed"
2565 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
2566 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
2568 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2569 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2572 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
2573 $LFS getstripe $MOUNT2/hosts ||
2574 error "$LFS getstripe $MOUNT2/hosts failed"
2579 cleanup_nocli || error "cleanup_nocli failed with $?"
2581 run_test 33a "Mount ost with a large index number"
2583 test_33b() { # was test_34
2586 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
2587 # Drop lock cancelation reply during umount
2588 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
2589 do_facet client $LCTL set_param fail_loc=0x80000304
2590 #lctl set_param debug=-1
2591 umount_client $MOUNT
2592 cleanup || error "cleanup failed with $?"
2594 run_test 33b "Drop cancel during umount"
2598 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
2599 manual_umount_client
2601 do_facet client killall -USR1 multiop
2602 if [ $rc -eq 0 ]; then
2603 error "umount not fail!"
2606 cleanup || error "cleanup failed with rc $?"
2608 run_test 34a "umount with opened file should be fail"
2612 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2613 stop_mds || error "Unable to stop MDS"
2615 manual_umount_client --force || error "mtab after failed umount with $?"
2617 cleanup || error "cleanup failed with $?"
2619 run_test 34b "force umount with failed mds should be normal"
2623 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2624 stop_ost || error "Unable to stop OST1"
2626 manual_umount_client --force || error "mtab after failed umount with $?"
2628 cleanup || error "cleanup failed with $?"
2630 run_test 34c "force umount with failed ost should be normal"
2632 test_35a() { # bug 12459
2635 DBG_SAVE="`$LCTL get_param -n debug`"
2636 $LCTL set_param debug="ha"
2638 log "Set up a fake failnode for the MDS"
2640 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2641 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2643 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2644 do_facet mgs "$PERM_CMD \
2645 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2646 error "Setting mdc.*${device}*.import=connection=\
2647 $(h2nettype $FAKENID) failed."
2649 do_facet mgs "$PERM_CMD \
2650 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2651 error "Setting ${device}.failover.node=\
2652 $(h2nettype $FAKENID) failed."
2654 log "Wait for RECONNECT_INTERVAL seconds (10s)"
2657 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
2660 log "Stopping the MDT: $device"
2661 stop_mdt 1 || error "MDT0 stop fail"
2663 df $MOUNT > /dev/null 2>&1 &
2665 log "Restarting the MDT: $device"
2666 start_mdt 1 || error "MDT0 start fail"
2667 log "Wait for df ($DFPID) ... "
2670 $LCTL set_param debug="$DBG_SAVE"
2672 # retrieve from the log the first server that the client tried to
2673 # contact after the connection loss
2674 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2675 NEXTCONN=`awk "/${MSG}/ {start = 1;}
2676 /import_select_connection.*$device-mdc.* using connection/ {
2678 if (\\\$NF ~ /$FAKENID/)
2684 }" $TMP/lustre-log-$TESTNAME.log`
2685 [ "$NEXTCONN" != "0" ] &&
2686 error "Tried to connect to ${NEXTCONN} not last active server"
2687 cleanup || error "cleanup failed with $?"
2688 # remove nid settings
2689 writeconf_or_reformat
2691 run_test 35a "Reconnect to the last active server first"
2693 test_35b() { # bug 18674
2694 remote_mds || skip "local MDS"
2698 $LCTL set_param debug="ha"
2700 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
2703 log "Set up a fake failnode for the MDS"
2705 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
2706 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
2708 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2709 do_facet mgs "$PERM_CMD \
2710 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
2711 error "Set mdc.*${device}*.import=connection=\
2712 $(h2nettype $FAKENID) failed"
2714 do_facet mgs "$PERM_CMD \
2715 ${device}.failover.node=$(h2nettype $FAKENID)" ||
2716 error "Set ${device}.failover.node=\
2717 $(h2nettype $FAKENID) failed"
2720 local at_max_saved=0
2721 # adaptive timeouts may prevent seeing the issue
2722 if at_is_enabled; then
2723 at_max_saved=$(at_max_get mds)
2724 at_max_set 0 mds client
2727 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
2729 log "Injecting EBUSY on MDS"
2730 # Setting OBD_FAIL_MDS_RESEND=0x136
2731 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
2732 error "unable to set param fail_loc=0x80000136"
2734 $LCTL set_param mdc.${FSNAME}*.stats=clear
2736 log "Creating a test file and stat it"
2737 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
2738 stat $MOUNT/$tdir/$tfile
2740 log "Stop injecting EBUSY on MDS"
2741 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
2742 error "unable to set param fail_loc=0"
2743 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
2746 # restore adaptive timeout
2747 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
2749 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2751 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
2752 awk '/mds_connect/{print $2}')
2754 # retrieve from the log if the client has ever tried to
2755 # contact the fake server after the loss of connection
2756 FAILCONN=`awk "BEGIN {ret = 0;}
2757 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
2759 if (\\\$NF ~ /$FAKENID/) {
2764 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
2766 [ "$FAILCONN" == "0" ] &&
2767 error "The client reconnection has not been triggered"
2768 [ "$FAILCONN" == "2" ] &&
2769 error "Primary server busy, client reconnect to failover failed"
2772 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
2773 # Reconnects are supposed to be rate limited to one every 5s
2774 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
2775 error "Too many reconnects $CONNCNT"
2777 cleanup || error "cleanup failed with $?"
2778 # remove nid settings
2779 writeconf_or_reformat
2781 run_test 35b "Continue reconnection retries, if the active server is busy"
2784 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2786 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
2790 local FSNAME2=test1234
2791 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
2793 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
2795 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
2796 is_blkdev $SINGLEMDS $MDSDEV &&
2797 skip_env "mixed loopback and real device not working"
2800 local fs2mdsdev=$(mdsdevname 1_2)
2801 local fs2ostdev=$(ostdevname 1_2)
2802 local fs3ostdev=$(ostdevname 2_2)
2803 local fs2mdsvdev=$(mdsvdevname 1_2)
2804 local fs2ostvdev=$(ostvdevname 1_2)
2805 local fs3ostvdev=$(ostvdevname 2_2)
2808 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
2809 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
2810 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
2811 # different one than the default value here.
2812 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
2813 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
2814 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
2815 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
2817 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
2818 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
2819 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
2820 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
2821 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
2823 sleep 5 # until 11778 fixed
2825 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
2827 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
2828 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
2829 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
2830 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
2831 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
2832 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2833 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
2834 DFTOTAL=$(echo $STRING | cut -d, -f1)
2835 DFUSED=$(echo $STRING | cut -d, -f2)
2836 DFAVAIL=$(echo $STRING | cut -d, -f3)
2837 DFFREE=$(($DFTOTAL - $DFUSED))
2839 ALLOWANCE=$((64 * $OSTCOUNT))
2841 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
2842 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
2843 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
2846 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
2847 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
2848 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
2851 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
2852 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
2853 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
2858 stop fs3ost -f || error "unable to stop OST3"
2859 stop fs2ost -f || error "unable to stop OST2"
2860 stop fs2mds -f || error "unable to stop second MDS"
2861 unload_modules_conf || error "unable unload modules"
2864 run_test 36 "df report consistency on OSTs with different block size"
2867 local mntpt=$(facet_mntpt $SINGLEMDS)
2868 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2869 local mdsdev_sym="$TMP/sym_mdt.img"
2870 local opts=$MDS_MOUNT_OPTS
2873 if [ "$mds1_FSTYPE" != ldiskfs ]; then
2874 skip "ldiskfs only test"
2877 echo "MDS : $mdsdev"
2878 echo "SYMLINK : $mdsdev_sym"
2879 do_facet $SINGLEMDS rm -f $mdsdev_sym
2881 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
2883 echo "mount symlink device - $mdsdev_sym"
2885 if ! do_facet $SINGLEMDS test -b $mdsdev; then
2886 opts=$(csa_add "$opts" -o loop)
2890 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
2891 $mdsdev_sym $mntpt 2>&1)
2894 echo mount_op=$mount_op
2896 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
2898 if $(echo $mount_op | grep -q "unable to set tunable"); then
2899 error "set tunables failed for symlink device"
2902 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
2904 run_test 37 "verify set tunables works for symlink device"
2906 test_38() { # bug 14222
2907 local mntpt=$(facet_mntpt $SINGLEMDS)
2912 local SRC="/etc /bin"
2913 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
2914 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
2915 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2916 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
2917 error "copying $SRC to $DIR/$tdir"
2919 umount_client $MOUNT || error "umount_client $MOUNT failed"
2920 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2921 stop_mds || error "Unable to stop MDS"
2922 log "delete lov_objid file on MDS"
2924 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
2926 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
2928 unmount_fstype $SINGLEMDS || error "umount failed (1)"
2930 # check create in mds_lov_connect
2931 start_mds || error "unable to start MDS"
2932 mount_client $MOUNT || error "mount_client $MOUNT failed"
2934 [ $V ] && log "verifying $DIR/$tdir/$f"
2935 diff -q $f $DIR/$tdir/$f || ERROR=y
2937 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2938 if [ "$ERROR" = "y" ]; then
2939 # check it's updates in sync
2940 umount_client $MOUNT
2942 mount_fstype $SIGNLEMDS
2943 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2944 unmount_fstype $SINGLEMDS
2945 error "old and new files are different after connect" || true
2947 touch $DIR/$tdir/f2 || error "f2 file create failed"
2949 # check it's updates in sync
2950 umount_client $MOUNT || error "second umount_client $MOUNT failed"
2953 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
2955 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2956 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
2958 unmount_fstype $SINGLEMDS || error "umount failed (3)"
2960 start_mds || error "unable to start MDS"
2961 mount_client $MOUNT || error "mount_client $MOUNT failed"
2963 [ $V ] && log "verifying $DIR/$tdir/$f"
2964 diff -q $f $DIR/$tdir/$f || ERROR=y
2966 touch $DIR/$tdir/f3 || error "f3 file create failed"
2967 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
2968 umount_client $MOUNT || error "third umount_client $MOUNT failed"
2970 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
2971 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
2972 unmount_fstype $SINGLEMDS || error "umount failed (4)"
2974 [ "$ERROR" = "y" ] &&
2975 error "old and new files are different after sync" || true
2977 log "files compared the same"
2978 cleanup || error "cleanup failed with $?"
2980 run_test 38 "MDS recreates missing lov_objid file from OST data"
2985 cleanup || error "cleanup failed with $?"
2986 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
2987 error "memory leak detected" || true
2989 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
2991 test_40() { # bug 15759
2992 start_ost || error "Unable to start OST1"
2993 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
2994 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
2996 cleanup || error "cleanup failed with rc $?"
2998 run_test 40 "race during service thread startup"
3000 test_41a() { #bug 14134
3001 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3002 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
3003 skip "Loop devices does not work with nosvc option"
3006 combined_mgs_mds || skip "needs combined MGT and MDT device"
3008 start_mdt 1 -o nosvc -n
3009 if [ $MDSCOUNT -ge 2 ]; then
3010 for num in $(seq 2 $MDSCOUNT); do
3011 start_mdt $num || return
3014 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
3015 start_mdt 1 -o nomgs,force
3016 mount_client $MOUNT || error "mount_client $MOUNT failed"
3019 echo "blah blah" > $MOUNT/$tfile
3022 umount_client $MOUNT || error "umount_client $MOUNT failed"
3023 stop ost1 -f || error "unable to stop OST1"
3024 stop_mds || error "Unable to stop MDS"
3025 stop_mds || error "Unable to stop MDS on second try"
3027 run_test 41a "mount mds with --nosvc and --nomgs"
3030 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3031 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
3032 skip "Loop devices does not work with nosvc option"
3035 ! combined_mgs_mds && skip "needs combined mgs device"
3039 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3041 start_mdt 1 -o nosvc -n
3042 if [ $MDSCOUNT -ge 2 ]; then
3043 for num in $(seq 2 $MDSCOUNT); do
3044 start_mdt $num || return
3047 start_ost || error "Unable to start OST1"
3048 start_mdt 1 -o nomgs,force
3049 mount_client $MOUNT || error "mount_client $MOUNT failed"
3052 echo "blah blah" > $MOUNT/$tfile
3053 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
3055 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
3056 stop_ost || error "Unable to stop OST1"
3057 stop_mds || error "Unable to stop MDS"
3058 stop_mds || error "Unable to stop MDS on second try"
3060 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
3063 local oss_list=$(comma_list $(osts_nodes))
3065 [[ "$MDS1_VERSION" -ge $(version_code 2.6.52) ]] ||
3066 [[ "$MDS1_VERSION" -ge $(version_code 2.5.26) &&
3067 "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
3068 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
3069 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]] ||
3070 skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"
3072 # ensure mds1 ost1 have been created even if running sub-test standalone
3075 cleanup || error "cleanup failed"
3077 # using directly mount command instead of start() function to avoid
3078 # any side effect of // with others/externals tools/features
3079 # ("zpool import", ...)
3081 # MDT concurrent start
3083 LOAD_MODULES_REMOTE=true load_modules
3084 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
3085 error "MDT concurrent start: libcfs module not loaded"
3087 local mds1dev=$(mdsdevname 1)
3088 local mds1mnt=$(facet_mntpt mds1)
3089 local mds1opts=$MDS_MOUNT_OPTS
3091 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3092 ! do_facet mds1 test -b $mds1dev; then
3093 mds1opts=$(csa_add "$mds1opts" -o loop)
3095 if [[ "$mds1_FSTYPE" == zfs ]]; then
3096 import_zpool mds1 || return ${PIPESTATUS[0]}
3099 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3100 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
3102 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
3105 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
3109 do_facet mds1 "$LCTL set_param fail_loc=0x0"
3110 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3111 echo "1st MDT start succeed"
3112 echo "2nd MDT start failed with $rc2"
3113 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3114 echo "1st MDT start failed with $rc"
3115 echo "2nd MDT start succeed"
3118 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
3121 if [ $MDSCOUNT -ge 2 ]; then
3122 for num in $(seq 2 $MDSCOUNT); do
3123 start_mdt $num || return
3127 # OST concurrent start
3129 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
3130 error "OST concurrent start: libcfs module not loaded"
3132 local ost1dev=$(ostdevname 1)
3133 local ost1mnt=$(facet_mntpt ost1)
3134 local ost1opts=$OST_MOUNT_OPTS
3136 if [ "$ost1_FSTYPE" == ldiskfs ] &&
3137 ! do_facet ost1 test -b $ost1dev; then
3138 ost1opts=$(csa_add "$ost1opts" -o loop)
3140 if [[ "$ost1_FSTYPE" == zfs ]]; then
3141 import_zpool ost1 || return ${PIPESTATUS[0]}
3144 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3145 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
3147 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
3150 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
3154 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3155 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3156 echo "1st OST start succeed"
3157 echo "2nd OST start failed with $rc2"
3158 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3159 echo "1st OST start failed with $rc"
3160 echo "2nd OST start succeed"
3164 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3170 # verify everything ok
3175 error "MDT(s) start failed"
3183 error "OST(s) start failed"
3191 error "client start failed"
3198 error "client mount failed"
3202 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3204 test_42() { #bug 14693
3208 check_mount || error "client was not mounted"
3210 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3211 PARAM="llite.$FSNAME-*.some_wrong_param"
3213 PARAM="$FSNAME.llite.some_wrong_param"
3216 do_facet mgs $PERM_CMD $PARAM=10
3217 umount_client $MOUNT ||
3218 error "unmounting client failed with invalid llite param"
3219 mount_client $MOUNT ||
3220 error "mounting client failed with invalid llite param"
3222 do_facet mgs $PERM_CMD $PARAM=20
3223 cleanup || error "stopping $FSNAME failed with invalid sys param"
3225 check_mount || error "client was not mounted with invalid sys param"
3226 cleanup || error "stopping $FSNAME failed with invalid sys param"
3228 run_test 42 "allow client/server mount/unmount with invalid config param"
3231 [[ "$MGS_VERSION" -ge $(version_code 2.5.58) ]] ||
3232 skip "Need MDS version at least 2.5.58"
3233 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
3236 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
3237 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1"
3240 chmod ugo+x $DIR || error "chmod 0 failed"
3241 set_persistent_param_and_check mds1 \
3242 "mdt.$FSNAME-MDT0000.root_squash" \
3243 "$FSNAME.mdt.root_squash" \
3245 wait_update $HOSTNAME \
3246 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3248 error "check llite root_squash failed!"
3249 set_persistent_param_and_check mds1 \
3250 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3251 "$FSNAME.mdt.nosquash_nids" \
3253 wait_update $HOSTNAME \
3254 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3256 error "check llite nosquash_nids failed!"
3259 # create set of test files
3261 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
3262 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
3263 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
3265 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
3266 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
3268 mkdir $DIR/$tdir-rootdir || error "mkdir failed"
3269 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
3270 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
3272 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
3273 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
3274 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
3277 # check root_squash:
3278 # set root squash UID:GID to RUNAS_ID
3279 # root should be able to access only files owned by RUNAS_ID
3281 set_persistent_param_and_check mds1 \
3282 "mdt.$FSNAME-MDT0000.root_squash" \
3283 "$FSNAME.mdt.root_squash" \
3284 "$RUNAS_ID:$RUNAS_ID"
3285 wait_update $HOSTNAME \
3286 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3287 "$RUNAS_ID:$RUNAS_ID" ||
3288 error "check llite root_squash failed!"
3290 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
3291 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3292 error "$ST: root read permission is denied"
3293 echo "$ST: root read permission is granted - ok"
3296 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3297 error "$ST: root write permission is denied"
3298 echo "$ST: root write permission is granted - ok"
3300 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3301 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3302 error "$ST: root read permission is granted"
3303 echo "$ST: root read permission is denied - ok"
3306 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3307 error "$ST: root write permission is granted"
3308 echo "$ST: root write permission is denied - ok"
3310 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3311 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
3312 error "$ST: root unlink permission is granted"
3313 echo "$ST: root unlink permission is denied - ok"
3315 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
3316 error "$ST: root create permission is granted"
3317 echo "$ST: root create permission is denied - ok"
3320 # check root_squash is enforced independently
3321 # of client cache content
3323 # access file by USER1, keep access open
3324 # root should be denied access to user file
3326 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
3330 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
3331 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3332 { kill $pid; error "$ST: root read permission is granted"; }
3333 echo "$ST: root read permission is denied - ok"
3336 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3337 { kill $pid; error "$ST: root write permission is granted"; }
3338 echo "$ST: root write permission is denied - ok"
3344 # check nosquash_nids:
3345 # put client's NID into nosquash_nids list,
3346 # root should be able to access root file after that
3348 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
3349 NIDLIST="2@gni $NIDLIST 192.168.0.[2,10]@tcp"
3350 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
3351 set_persistent_param_and_check mds1 \
3352 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3353 "$FSNAME-MDTall.mdt.nosquash_nids" \
3355 wait_update $HOSTNAME \
3356 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3358 error "check llite nosquash_nids failed!"
3360 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3361 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3362 error "$ST: root read permission is denied"
3363 echo "$ST: root read permission is granted - ok"
3366 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3367 error "$ST: root write permission is denied"
3368 echo "$ST: root write permission is granted - ok"
3370 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3371 rm $DIR/$tdir-rootdir/tfile-1 ||
3372 error "$ST: root unlink permission is denied"
3373 echo "$ST: root unlink permission is granted - ok"
3374 touch $DIR/$tdir-rootdir/tfile-2 ||
3375 error "$ST: root create permission is denied"
3376 echo "$ST: root create permission is granted - ok"
3377 cleanup || error "cleanup failed with $?"
3379 run_test 43a "check root_squash and nosquash_nids"
3381 test_43b() { # LU-5690
3382 [[ "$MGS_VERSION" -ge $(version_code 2.7.62) ]] ||
3383 skip "Need MGS version 2.7.62+"
3385 if [[ -z "$fs2mds_DEV" ]]; then
3386 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
3387 skip_env "mixed loopback and real device not working"
3390 local fs2mdsdev=$(mdsdevname 1_2)
3391 local fs2mdsvdev=$(mdsvdevname 1_2)
3393 # temporarily use fs2mds as fs2mgs
3395 local fs2mgsdev=$fs2mdsdev
3396 local fs2mgsvdev=$fs2mdsvdev
3398 local fsname=test1234
3400 load_module llite/lustre
3401 local client_ip=$(host_nids_address $HOSTNAME $NETTYPE)
3402 local host=${client_ip//*./}
3403 local net=${client_ip/%$host/}
3404 local nosquash_nids=$(h2nettype $net[$host,$host,$host])
3406 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
3407 --param mdt.root_squash=$RUNAS_ID:$RUNAS_ID \
3408 --param mdt.nosquash_nids=$nosquash_nids \
3409 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
3410 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS || error "start fs2mgs failed"
3411 stop $fs2mgs -f || error "stop fs2mgs failed"
3412 cleanup || error "cleanup failed with $?"
3414 run_test 43b "parse nosquash_nids with commas in expr_list"
3418 check_mount || error "check_mount"
3419 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
3421 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
3422 for VAL in $UUIDS; do
3423 NID=$(echo $VAL | cut -d= -f1)
3424 CLUUID=$(echo $VAL | cut -d= -f2)
3425 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
3427 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
3428 cleanup || error "cleanup failed with $?"
3430 run_test 44 "mounted client proc entry exists"
3434 check_mount || error "check_mount"
3435 stop_mds || error "Unable to stop MDS"
3439 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
3440 do_facet client "$LCTL set_param fail_loc=0x8000050f"
3443 manual_umount_client --force || error "manual_umount_client failed"
3444 do_facet client "$LCTL set_param fail_loc=0x0"
3445 start_mds || error "unable to start MDS"
3446 mount_client $MOUNT || error "mount_client $MOUNT failed"
3447 cleanup || error "cleanup failed with $?"
3449 run_test 45 "long unlink handling in ptlrpcd"
3456 umount_client $MOUNT2 || rc=$?
3457 umount_client $MOUNT || rc=$?
3458 while [ $count -gt 0 ]; do
3459 stop ost${count} -f || rc=$?
3463 cleanup_nocli || rc=$?
3464 #writeconf to remove all ost2 traces for subsequent tests
3465 writeconf_or_reformat
3470 echo "Testing with $OSTCOUNT OSTs"
3472 start_mds || error "unable to start MDS"
3473 #first client should see only one ost
3474 start_ost || error "Unable to start OST1"
3475 wait_osc_import_state mds ost FULL
3477 mount_client $MOUNT || error "mount_client $MOUNT failed"
3478 trap "cleanup_46a $OSTCOUNT" EXIT ERR
3481 for (( i=2; i<=$OSTCOUNT; i++ )); do
3482 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
3483 error "start_ost$i $(ostdevname $i) failed"
3486 # wait until osts in sync
3487 for (( i=2; i<=$OSTCOUNT; i++ )); do
3488 wait_osc_import_state mds ost$i FULL
3489 wait_osc_import_ready client ost$i
3492 #second client see all ost's
3494 mount_client $MOUNT2 || error "mount_client failed"
3495 $LFS setstripe -c -1 $MOUNT2 ||
3496 error "$LFS setstripe -c -1 $MOUNT2 failed"
3497 $LFS getstripe $MOUNT2 || error "$LFS getstripe $MOUNT2 failed"
3499 echo "ok" > $MOUNT2/widestripe
3500 $LFS getstripe $MOUNT2/widestripe ||
3501 error "$LFS getstripe $MOUNT2/widestripe failed"
3502 # fill acl buffer for avoid expand lsm to them
3503 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
3505 setfacl -m $acl $MOUNT2/widestripe
3509 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3511 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
3513 run_test 46a "handle ost additional - wide striped file"
3518 check_mount || error "check_mount failed"
3519 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
3523 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3524 if echo $ns | grep "MDT[[:digit:]]*"; then
3527 lrs=$(echo $ns | sed 's/.*lru_size=//')
3528 lru_size[count]=$lrs
3533 facet_failover $SINGLEMDS
3534 client_up || error "client_up failed"
3537 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
3538 if echo $ns | grep "MDT[[:digit:]]*"; then
3541 lrs=$(echo $ns | sed 's/.*lru_size=//')
3542 if ! test "$lrs" -eq "${lru_size[count]}"; then
3543 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
3544 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
3549 cleanup || error "cleanup failed with $?"
3551 run_test 47 "server restart does not make client loss lru_resize settings"
3556 # reformat after this test is needed - if the test fails,
3557 # we will have unkillable file at FS
3561 test_48() { # bz-17636 LU-7473
3565 check_mount || error "check_mount failed"
3567 $LFS setstripe -c -1 $MOUNT ||
3568 error "$LFS setstripe -c -1 $MOUNT failed"
3569 $LFS getstripe $MOUNT || error "$LFS getstripe $MOUNT failed"
3571 echo "ok" > $MOUNT/widestripe
3572 $LFS getstripe $MOUNT/widestripe ||
3573 error "$LFS getstripe $MOUNT/widestripe failed"
3575 # In the future, we may introduce more EAs, such as selinux, enlarged
3576 # LOV EA, and so on. These EA will use some EA space that is shared by
3577 # ACL entries. So here we only check some reasonable ACL entries count,
3578 # instead of the max number that is calculated from the max_ea_size.
3579 if [ "$MDS1_VERSION" -lt $(version_code 2.8.57) ]; then
3580 count=28 # hard coded of RPC protocol
3581 elif large_xattr_enabled; then
3582 count=4500 # max_num 8187 max_ea_size = 65452
3583 # not create too many (4500) to save test time
3585 count=450 # max_num 497 max_ea_size = 4012
3588 echo "It is expected to hold at least $count ACL entries"
3589 trap cleanup_48 EXIT ERR
3590 for ((i = 0; i < $count; i++)) do
3591 setfacl -m u:$((i + 100)):rw $MOUNT/widestripe ||
3592 error "Fail to setfacl for $MOUNT/widestripe at $i"
3595 cancel_lru_locks mdc
3596 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
3597 local r_count=$(getfacl $MOUNT/widestripe | grep "user:" | wc -l)
3598 count=$((count + 1)) # for the entry "user::rw-"
3600 [ $count -eq $r_count ] ||
3601 error "Expected ACL entries $count, but got $r_count"
3605 run_test 48 "too many acls on file"
3607 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
3608 test_49a() { # bug 17710
3609 local timeout_orig=$TIMEOUT
3610 local ldlm_timeout_orig=$LDLM_TIMEOUT
3611 local LOCAL_TIMEOUT=20
3613 LDLM_TIMEOUT=$LOCAL_TIMEOUT
3614 TIMEOUT=$LOCAL_TIMEOUT
3618 check_mount || error "client mount failed"
3620 echo "check ldlm_timout..."
3621 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3622 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3623 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3625 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3626 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3629 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
3630 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
3633 umount_client $MOUNT || error "umount_client $MOUNT failed"
3634 stop_ost || error "problem stopping OSS"
3635 stop_mds || error "problem stopping MDS"
3637 LDLM_TIMEOUT=$ldlm_timeout_orig
3638 TIMEOUT=$timeout_orig
3640 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3642 test_49b() { # bug 17710
3643 local timeout_orig=$TIMEOUT
3644 local ldlm_timeout_orig=$LDLM_TIMEOUT
3645 local LOCAL_TIMEOUT=20
3647 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
3648 TIMEOUT=$LOCAL_TIMEOUT
3652 check_mount || error "client mount failed"
3654 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
3655 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
3656 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
3658 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
3659 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
3662 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
3663 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
3666 cleanup || error "cleanup failed"
3668 LDLM_TIMEOUT=$ldlm_timeout_orig
3669 TIMEOUT=$timeout_orig
3671 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
3674 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3676 # Test both statfs and lfs df and fail if either one fails
3677 multiop_bg_pause $1 f_
3680 killall -USR1 multiop
3681 [ $RC -ne 0 ] && log "lazystatfs multiop failed"
3682 wait $PID || { RC=$?; log "multiop return error "; }
3684 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
3689 if kill -s 0 $PID; then
3692 log "lazystatfs lfs df failed to complete in 5s"
3700 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3701 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3703 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
3705 cleanup || error "cleanup failed with rc $?"
3707 run_test 50a "lazystatfs all servers available"
3711 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3712 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3714 # Wait for client to detect down OST
3715 stop_ost || error "Unable to stop OST1"
3716 wait_osc_import_state client ost DISCONN
3718 log "OSCs should all be DISCONN"
3720 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
3722 umount_client $MOUNT || error "Unable to unmount client"
3723 stop_mds || error "Unable to stop MDS"
3725 run_test 50b "lazystatfs all servers down"
3728 start_mds || error "Unable to start MDS"
3729 start_ost || error "Unable to start OST1"
3730 start_ost2 || error "Unable to start OST2"
3731 mount_client $MOUNT || error "Unable to mount client"
3732 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3733 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3735 # Wait for client to detect down OST
3736 stop_ost || error "Unable to stop OST1"
3737 wait_osc_import_state mds ost DISCONN
3738 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3740 umount_client $MOUNT || error "Unable to unmount client"
3741 stop_ost2 || error "Unable to stop OST2"
3742 stop_mds || error "Unable to stop MDS"
3743 #writeconf to remove all ost2 traces for subsequent tests
3744 writeconf_or_reformat
3746 run_test 50c "lazystatfs one server down"
3749 start_mds || error "Unable to start MDS"
3750 start_ost || error "Unable to start OST1"
3751 start_ost2 || error "Unable to start OST2"
3752 mount_client $MOUNT || error "Unable to mount client"
3753 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3754 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3756 # Issue the statfs during the window where the client still
3757 # belives the OST to be available but it is in fact down.
3758 # No failure just a statfs which hangs for a timeout interval.
3759 stop_ost || error "Unable to stop OST1"
3760 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
3762 umount_client $MOUNT || error "Unable to unmount client"
3763 stop_ost2 || error "Unable to stop OST2"
3764 stop_mds || error "Unable to stop MDS"
3765 #writeconf to remove all ost2 traces for subsequent tests
3766 writeconf_or_reformat
3768 run_test 50d "lazystatfs client/server conn race"
3775 start_mds || error "Unable to start MDS"
3776 #first client should see only one ost
3777 start_ost || error "Unable to start OST1"
3778 wait_osc_import_state mds ost FULL
3780 # Wait for client to detect down OST
3781 stop_ost || error "Unable to stop OST1"
3782 wait_osc_import_state mds ost DISCONN
3784 mount_client $MOUNT || error "Unable to mount client"
3785 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3787 multiop_bg_pause $MOUNT _f
3791 if [ $RC1 -ne 0 ]; then
3792 log "multiop failed $RC1"
3795 sleep $(( $TIMEOUT+1 ))
3797 [ $? -ne 0 ] && error "process isn't sleep"
3798 start_ost || error "Unable to start OST1"
3799 wait $pid || error "statfs failed"
3802 umount_client $MOUNT || error "Unable to unmount client"
3803 stop_ost || error "Unable to stop OST1"
3804 stop_mds || error "Unable to stop MDS"
3806 run_test 50e "normal statfs all servers down"
3811 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
3813 start_mds || error "Unable to start mds"
3814 #first client should see only one ost
3815 start_ost || error "Unable to start OST1"
3816 wait_osc_import_state mds ost FULL
3818 start_ost2 || error "Unable to start OST2"
3819 wait_osc_import_state mds ost2 FULL
3821 # Wait for client to detect down OST
3822 stop_ost2 || error "Unable to stop OST2"
3824 wait_osc_import_state mds ost2 DISCONN
3825 mount_client $MOUNT || error "Unable to mount client"
3826 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
3828 multiop_bg_pause $MOUNT _f
3832 if [ $RC1 -ne 0 ]; then
3833 log "lazystatfs multiop failed $RC1"
3836 sleep $(( $TIMEOUT+1 ))
3838 [ $? -ne 0 ] && error "process isn't sleep"
3839 start_ost2 || error "Unable to start OST2"
3840 wait $pid || error "statfs failed"
3841 stop_ost2 || error "Unable to stop OST2"
3844 umount_client $MOUNT -f || error "Unable to unmount client"
3845 stop_ost || error "Unable to stop OST1"
3846 stop_mds || error "Unable to stop MDS"
3847 #writeconf to remove all ost2 traces for subsequent tests
3848 writeconf_or_reformat
3850 run_test 50f "normal statfs one server in down"
3853 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3855 start_ost2 || error "Unable to start OST2"
3856 wait_osc_import_state mds ost2 FULL
3857 wait_osc_import_ready client ost2
3859 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3860 local PARAM="osc.${FSNAME}-OST0001*.active"
3862 local PARAM="${FSNAME}-OST0001.osc.active"
3865 $LFS setstripe -c -1 $DIR/$tfile || error "$LFS setstripe failed"
3866 do_facet mgs $PERM_CMD $PARAM=0 || error "Unable to deactivate OST"
3868 umount_client $MOUNT || error "Unable to unmount client"
3869 mount_client $MOUNT || error "Unable to mount client"
3870 # This df should not cause a panic
3873 do_facet mgs $PERM_CMD $PARAM=1 || error "Unable to activate OST"
3874 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
3875 umount_client $MOUNT || error "Unable to unmount client"
3876 stop_ost2 || error "Unable to stop OST2"
3877 stop_ost || error "Unable to stop OST1"
3878 stop_mds || error "Unable to stop MDS"
3879 #writeconf to remove all ost2 traces for subsequent tests
3880 writeconf_or_reformat
3882 run_test 50g "deactivated OST should not cause panic"
3886 # prepare MDT/OST, make OSC inactive for OST1
3887 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
3889 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
3890 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
3891 error "tunefs OST1 failed"
3892 start_mds || error "Unable to start MDT"
3893 start_ost || error "Unable to start OST1"
3894 start_ost2 || error "Unable to start OST2"
3895 mount_client $MOUNT || error "client start failed"
3897 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3899 # activatate OSC for OST1
3900 set_persistent_param_and_check client \
3901 "osc.${FSNAME}-OST0000-osc-[!M]*.active" \
3902 "${FSNAME}-OST0000.osc.active" 1
3904 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3905 $LFS setstripe -c -1 -i 0 $DIR/$tdir/2 ||
3906 error "$LFS setstripe $DIR/$tdir/2 failed"
3907 sleep 1 && echo "create a file after OST1 is activated"
3908 # doing some io, shouldn't crash
3909 dd if=/dev/zero of=$DIR/$tdir/2/$tfile-io bs=1M count=10
3911 # check OSC import is working
3912 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
3913 error "some OSC imports are still not connected"
3917 umount_client $MOUNT || error "Unable to umount client"
3918 stop_ost2 || error "Unable to stop OST2"
3919 cleanup_nocli || error "cleanup_nocli failed with $?"
3921 run_test 50h "LU-642: activate deactivated OST"
3924 # prepare MDT/OST, make OSC inactive for OST1
3925 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
3928 [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
3929 do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
3930 error "tunefs MDT2 failed"
3931 start_mds || error "Unable to start MDT"
3932 start_ost || error "Unable to start OST1"
3933 start_ost2 || error "Unable to start OST2"
3934 mount_client $MOUNT || error "client start failed"
3936 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3938 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3939 $PERM_CMD mdc.${FSNAME}-MDT0001-mdc-*.active=0 &&
3940 error "deactive MDC0 succeeds"
3942 $PERM_CMD ${FSNAME}-MDT0000.mdc.active=0 &&
3943 error "deactive MDC0 succeeds"
3946 # activate MDC for MDT2
3947 set_persistent_param_and_check client \
3948 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3949 "${FSNAME}-MDT0001.mdc.active" 1
3951 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
3952 if [ "$MDS1_VERSION" -ge $(version_code 2.7.60) ]
3954 wait_dne_interconnect
3956 $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
3958 createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
3960 rm -rf $DIR/$tdir/2 || error "unlink dir failed"
3962 # deactivate MDC for MDT2
3963 set_persistent_param_and_check client \
3964 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
3965 "${FSNAME}-MDT0001.mdc.active" 0
3967 wait_osp_active mds ${FSNAME}-MDT0001 1 0
3969 $LFS mkdir -i1 $DIR/$tdir/2 &&
3970 error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
3972 $LFS mkdir -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3973 error "mkdir $DIR/$tdir/striped_dir fails after deactive MDT2"
3975 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3976 [ $stripe_count -eq $((MDSCOUNT - 1)) ] ||
3977 error "wrong $stripe_count != $((MDSCOUNT -1)) for striped_dir"
3980 umount_client $MOUNT || error "Unable to umount client"
3985 run_test 50i "activate deactivated MDT"
3988 local LOCAL_TIMEOUT=20
3992 check_mount || error "check_mount failed"
3994 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3995 $LFS setstripe -c -1 $MOUNT/$tdir ||
3996 error "$LFS setstripe -c -1 $MOUNT/$tdir failed"
3997 #define OBD_FAIL_MDS_REINT_DELAY 0x142
3998 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
3999 touch $MOUNT/$tdir/$tfile &
4002 start_ost2 || error "Unable to start OST1"
4004 stop_ost2 || error "Unable to stop OST1"
4005 umount_client $MOUNT -f || error “unmount $MOUNT failed”
4006 cleanup_nocli || error “stop server failed”
4007 #writeconf to remove all ost2 traces for subsequent tests
4008 writeconf_or_reformat
4010 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
4019 do_node $node mkdir -p $dest
4020 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
4022 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
4023 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
4024 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
4026 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
4027 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
4037 local backup2=${TMP}/backup2
4039 do_node $node mkdir -p $backup2
4040 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
4042 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
4043 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
4044 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
4046 do_node $node "diff -rq $backup $backup2"
4047 [ $? -eq 0 ] || { error "contents differ"; return 3; }
4049 local xattrs2=${TMP}/xattrs2
4050 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
4051 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
4053 do_node $node "diff $xattrs $xattrs2"
4054 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
4056 do_node $node "rm -rf $backup2 $xattrs2"
4057 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
4061 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4062 skip "ldiskfs only test"
4065 start_mds || error "Unable to start MDS"
4066 start_ost || error "Unable to start OST1"
4067 mount_client $MOUNT || error "Unable to mount client"
4070 local ost1mnt=$(facet_mntpt ost1)
4071 local ost1node=$(facet_active_host ost1)
4072 local ost1tmp=$TMP/conf52
4075 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
4076 touch $TMP/modified_first || error "Unable to create temporary file"
4077 local mtime=$(stat -c %Y $TMP/modified_first)
4078 do_node $ost1node "mkdir -p $ost1tmp &&
4079 touch -m -d @$mtime $ost1tmp/modified_first" ||
4080 error "Unable to create temporary file"
4083 $LFS setstripe -c -1 -S 1M $DIR/$tdir || error "$LFS setstripe failed"
4085 for (( i=0; i < nrfiles; i++ )); do
4086 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
4087 error "multiop failed"
4092 # sync all the data and make sure no pending data on the client,
4093 # thus the SOM xattr would not be changed any more.
4094 cancel_lru_locks osc
4097 echo backup files to $TMP/$tdir
4098 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
4099 copy_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4100 error "Unable to copy files"
4102 umount_client $MOUNT || error "Unable to umount client"
4103 stop_ost || error "Unable to stop ost1"
4105 echo mount ost1 as ldiskfs
4106 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
4107 if ! do_node $ost1node test -b $ost1_dev; then
4110 do_node $ost1node mount -t "$ost1_FSTYPE" $loop $ost1_dev \
4112 error "Unable to mount ost1 as ldiskfs"
4115 echo backup objects to $ost1tmp/objects
4116 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
4117 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
4118 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
4120 error "Unable to copy objects"
4122 # move objects to lost+found
4123 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
4124 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
4126 do_node $ost1node "umount $ost1mnt" ||
4127 error "Unable to umount ost1 as ldiskfs"
4129 start_ost || error "Unable to start OST1"
4130 mount_client $MOUNT || error "Unable to mount client"
4132 local REPAIRED=$(do_node $ost1node "$LCTL get_param \
4133 -n osd-ldiskfs.$FSNAME-OST0000.oi_scrub" |
4134 awk '/^lf_repa[ri]*ed/ { print $2 }')
4135 [ $REPAIRED -gt 0 ] ||
4136 error "Some entry under /lost+found should be repaired"
4139 diff_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4140 error "Unable to diff files"
4142 rm -rf $TMP/$tdir $TMP/file_xattrs ||
4143 error "Unable to delete temporary files"
4144 do_node $ost1node "rm -rf $ost1tmp" ||
4145 error "Unable to delete temporary files"
4146 cleanup || error "cleanup failed with $?"
4148 run_test 52 "check recovering objects from lost+found"
4150 # Checks threads_min/max/started for some service
4152 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
4153 # parameter pattern prefix like 'ost.*.ost'.
4166 local msg="Insane $modname thread counts"
4167 local ncpts=$(check_cpt_number $facet)
4171 check_mount || return 41
4173 # We need to expand $parampat, but it may match multiple parameters, so
4174 # we'll pick the first one
4175 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
4176 error "Couldn't expand ${parampat}.threads_min parameter name"
4180 # Remove the .threads_min part
4181 paramp=${paramp%.threads_min}
4183 # Check for sanity in defaults
4184 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4186 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4188 tstarted=$(do_facet $facet "$LCTL get_param \
4189 -n ${paramp}.threads_started" || echo 0)
4190 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
4192 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4194 nthrs=$(expr $tmax - $tmin)
4195 if [ $nthrs -lt $ncpts ]; then
4201 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
4202 skip_env "module parameter forced $facet thread count"
4204 # Check that we can change min/max
4205 do_facet $facet "$LCTL set_param \
4206 ${paramp}.threads_min=$((tmin + nthrs))"
4207 do_facet $facet "$LCTL set_param \
4208 ${paramp}.threads_max=$((tmax - nthrs))"
4209 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4211 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4213 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
4214 $tmax2 == ($tmax - $nthrs)))' || return $?
4216 # Check that we can set min/max to the same value
4217 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4219 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
4220 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4222 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4224 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
4226 # Check that we can't set max < min
4227 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
4228 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4230 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4232 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
4234 # We need to ensure that we get the module options desired; to do this
4235 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
4236 LOAD_MODULES_REMOTE=true
4239 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
4240 setmodopts -a $modname "$newvalue" oldvalue
4243 check_mount || return 41
4245 # Restore previous setting of MODOPTS_*
4246 setmodopts $modname "$oldvalue"
4248 # Check that $opts took
4249 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4251 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4253 tstarted=$(do_facet $facet \
4254 "$LCTL get_param -n ${paramp}.threads_started" || echo 0)
4255 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4264 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
4265 cleanup || error "cleanup failed with rc $?"
4267 run_test 53a "check OSS thread count params"
4271 local mds=$(do_facet $SINGLEMDS "$LCTL get_param \
4272 -N mds.*.*.threads_max 2>/dev/null")
4273 if [ -z "$mds" ]; then
4274 #running this on an old MDT
4275 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads' 16
4277 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
4279 cleanup || error "cleanup failed with $?"
4281 run_test 53b "check MDS thread count params"
4284 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4285 skip "ldiskfs only test"
4288 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
4289 error "llverdev failed with rc=$?"
4292 run_test 54a "test llverdev and partial verify of device"
4295 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4296 skip "ldiskfs only test"
4300 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
4301 cleanup || error "cleanup failed with rc=$?"
4303 run_test 54b "test llverfs and partial verify of filesystem"
4307 local max_ost_index=$1
4308 echo -n $(((max_ost_index + 1) * 8))
4312 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4313 skip "ldiskfs only test"
4316 local mdsdev=$(mdsdevname 1)
4317 local mdsvdev=$(mdsvdevname 1)
4321 if ! combined_mgs_mds; then
4322 stop_mgs || error "stopping MGS service failed"
4323 format_mgs || error "formatting MGT failed"
4325 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
4327 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
4328 --reformat $(ostdevname 1) $(ostvdevname 1)
4334 echo checking size of lov_objid for ost index $i
4335 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" |
4336 grep ^User | awk -F 'Size: ' '{print $2}')
4337 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
4338 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
4340 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
4347 run_test 55 "check lov_objid size"
4350 local mds_journal_size_orig=$MDSJOURNALSIZE
4356 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
4357 $(ostdevname 1) $(ostvdevname 1)
4358 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
4359 $(ostdevname 2) $(ostvdevname 2)
4362 start_ost || error "Unable to start first ost (idx 10000)"
4363 start_ost2 || error "Unable to start second ost (idx 1000)"
4364 mount_client $MOUNT || error "Unable to mount client"
4368 if [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
4369 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
4370 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]]; then
4371 wait_osc_import_state mds ost1 FULL
4372 wait_osc_import_state mds ost2 FULL
4373 $LFS setstripe --stripe-count=-1 $DIR/$tfile ||
4374 error "Unable to setstripe $DIR/$tfile"
4375 n=$($LFS getstripe --stripe-count $DIR/$tfile)
4376 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
4381 MDSJOURNALSIZE=$mds_journal_size_orig
4384 run_test 56a "check big OST indexes and out-of-index-order start"
4389 umount_client $MOUNT -f || error "unmount client failed"
4398 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
4400 trap cleanup_56b EXIT RETURN ERR
4403 if ! combined_mgs_mds ; then
4408 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) --index=0 --reformat \
4409 $(mdsdevname 1) $(mdsvdevname 1)
4410 add mds2 $(mkfs_opts mds2 $(mdsdevname 2)) --index=1 --reformat \
4411 $(mdsdevname 2) $(mdsvdevname 2)
4412 add mds3 $(mkfs_opts mds3 $(mdsdevname 3)) --index=1000 --reformat \
4413 $(mdsdevname 3) $(mdsvdevname 3)
4417 start_mdt 1 || error "MDT 1 (idx 0) start failed"
4418 start_mdt 2 || error "MDT 2 (idx 1) start failed"
4419 start_mdt 3 || error "MDT 3 (idx 1000) start failed"
4420 start_ost || error "Unable to start first ost"
4421 start_ost2 || error "Unable to start second ost"
4423 do_nodes $(comma_list $(mdts_nodes)) \
4424 "$LCTL set_param mdt.*.enable_remote_dir=1 \
4425 mdt.*.enable_remote_dir_gid=-1"
4427 mount_client $MOUNT || error "Unable to mount client"
4429 $LFS mkdir -c3 $MOUNT/$tdir || error "failed to make testdir"
4431 echo "This is test file 1!" > $MOUNT/$tdir/$tfile.1 ||
4432 error "failed to make test file 1"
4433 echo "This is test file 2!" > $MOUNT/$tdir/$tfile.2 ||
4434 error "failed to make test file 2"
4435 echo "This is test file 1000!" > $MOUNT/$tdir/$tfile.1000 ||
4436 error "failed to make test file 1000"
4438 rm -rf $MOUNT/$tdir || error "failed to remove testdir"
4440 $LFS mkdir -i1000 $MOUNT/$tdir.1000 ||
4441 error "create remote dir at idx 1000 failed"
4444 echo "=== START lfs df OUTPUT ==="
4446 echo "==== END lfs df OUTPUT ===="
4448 mdtcnt=$(echo -e "$output" | grep $FSNAME-MDT | wc -l)
4449 ostcnt=$(echo -e "$output" | grep $FSNAME-OST | wc -l)
4451 echo "lfs df returned mdt count $mdtcnt and ost count $ostcnt"
4452 [ $mdtcnt -eq 3 ] || error "lfs df returned wrong mdt count"
4453 [ $ostcnt -eq 2 ] || error "lfs df returned wrong ost count"
4455 echo "This is test file 1!" > $MOUNT/$tdir.1000/$tfile.1 ||
4456 error "failed to make test file 1"
4457 echo "This is test file 2!" > $MOUNT/$tdir.1000/$tfile.2 ||
4458 error "failed to make test file 2"
4459 echo "This is test file 1000!" > $MOUNT/$tdir.1000/$tfile.1000 ||
4460 error "failed to make test file 1000"
4461 rm -rf $MOUNT/$tdir.1000 || error "failed to remove remote_dir"
4464 echo "=== START lfs mdts OUTPUT ==="
4466 echo "==== END lfs mdts OUTPUT ===="
4468 echo -e "$output" | grep -v "MDTS:" | awk '{print $1}' |
4469 sed 's/://g' > $TMP/mdts-actual.txt
4470 sort $TMP/mdts-actual.txt -o $TMP/mdts-actual.txt
4472 echo -e "0\n1\n1000" > $TMP/mdts-expected.txt
4474 diff $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4477 rm $TMP/mdts-expected.txt $TMP/mdts-actual.txt
4479 [ $result -eq 0 ] || error "target_obd proc file is incorrect!"
4481 run_test 56b "test target_obd correctness with nonconsecutive MDTs"
4483 test_57a() { # bug 22656
4484 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4485 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4486 tail -1 | awk '{print $1}')
4487 writeconf_or_reformat
4488 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
4489 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
4490 error "tunefs failed"
4492 start_ost && error "OST registration from failnode should fail"
4495 run_test 57a "initial registration from failnode should fail (should return errs)"
4498 do_rpc_nodes $(facet_active_host ost1) load_modules_local
4499 local NID=$(do_facet ost1 "$LCTL get_param nis" |
4500 tail -1 | awk '{print $1}')
4501 writeconf_or_reformat
4502 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
4503 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
4504 error "tunefs failed"
4506 start_ost || error "OST registration from servicenode should not fail"
4509 run_test 57b "initial registration from servicenode should not fail"
4512 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
4515 test_58() { # bug 22658
4516 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
4518 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4519 createmany -o $DIR/$tdir/$tfile-%d 100
4520 unlinkmany $DIR/$tdir/$tfile-%d 100
4521 stop_mds || error "Unable to stop MDS"
4523 local MNTDIR=$(facet_mntpt $SINGLEMDS)
4524 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4526 # remove all files from the OBJECTS dir
4527 mount_fstype $SINGLEMDS
4529 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
4531 unmount_fstype $SINGLEMDS
4532 # restart MDS with missing llog files
4533 start_mds || error "unable to start MDS"
4534 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
4537 run_test 58 "missing llog files must not prevent MDT from mounting"
4540 start_mgsmds >> /dev/null
4541 local C1=$(count_osts)
4542 if [ $C1 -eq 0 ]; then
4543 start_ost >> /dev/null
4547 echo "original ost count: $C1 (expect > 0)"
4548 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
4549 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
4550 local C2=$(count_osts)
4551 echo "after mdt writeconf count: $C2 (expect 0)"
4552 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
4553 echo "OST start without writeconf should fail:"
4554 start_ost >> /dev/null &&
4555 error "OST start without writeconf didn't fail"
4556 echo "OST start with writeconf should succeed:"
4557 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
4558 local C3=$(count_osts)
4559 echo "after ost writeconf count: $C3 (expect 1)"
4560 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
4561 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
4562 local C4=$(count_osts)
4563 echo "after ost2 writeconf count: $C4 (expect 2)"
4564 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
4565 stop_ost2 >> /dev/null
4566 cleanup_nocli >> /dev/null
4567 #writeconf to remove all ost2 traces for subsequent tests
4568 writeconf_or_reformat
4570 run_test 59 "writeconf mount option"
4572 test_60() { # LU-471
4573 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4574 skip "ldiskfs only test"
4579 for num in $(seq $MDSCOUNT); do
4580 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
4581 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
4582 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
4586 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
4587 [ ${PIPESTATUS[0]} -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
4589 # MDT default has dirdata feature
4590 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
4591 # we disable uninit_bg feature
4592 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
4593 # we set stride extended options
4594 echo $dump | grep stride > /dev/null || error "stride is not set"
4598 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
4601 local lxattr=$(large_xattr_enabled)
4603 [ "$MDS1_VERSION" -ge $(version_code 2.1.53) ] ||
4604 skip "Need MDS version at least 2.1.53"
4606 if [ "$mds1_FSTYPE" == ldiskfs ] &&
4607 ! large_xattr_enabled; then
4610 for num in $(seq $MDSCOUNT); do
4611 do_facet mds${num} $TUNE2FS -O ea_inode \
4612 $(mdsdevname $num) ||
4613 error "tune2fs on mds $num failed"
4617 setup || error "setting up the filesystem failed"
4618 client_up || error "starting client failed"
4620 local file=$DIR/$tfile
4621 touch $file || error "touch $file failed"
4623 local large_value="$(generate_string $(max_xattr_size))"
4624 local small_value="bar"
4626 local name="trusted.big"
4627 log "save large xattr of $(max_xattr_size) bytes on $name on $file"
4628 setfattr -n $name -v $large_value $file ||
4629 error "saving $name on $file failed"
4631 local new_value=$(get_xattr_value $name $file)
4632 [[ "$new_value" != "$large_value" ]] &&
4633 error "$name different after saving"
4635 log "shrink value of $name on $file"
4636 setfattr -n $name -v $small_value $file ||
4637 error "shrinking value of $name on $file failed"
4639 new_value=$(get_xattr_value $name $file)
4640 [[ "$new_value" != "$small_value" ]] &&
4641 error "$name different after shrinking"
4643 log "grow value of $name on $file"
4644 setfattr -n $name -v $large_value $file ||
4645 error "growing value of $name on $file failed"
4647 new_value=$(get_xattr_value $name $file)
4648 [[ "$new_value" != "$large_value" ]] &&
4649 error "$name different after growing"
4651 log "check value of $name on $file after remounting MDS"
4653 new_value=$(get_xattr_value $name $file)
4654 [[ "$new_value" != "$large_value" ]] &&
4655 error "$name different after remounting MDS"
4657 log "remove large xattr $name from $file"
4658 setfattr -x $name $file || error "removing $name from $file failed"
4660 if $lxattr && [ "$mds1_FSTYPE" == ldiskfs ]; then
4661 stopall || error "stopping for e2fsck run"
4662 for num in $(seq $MDSCOUNT); do
4663 run_e2fsck $(facet_active_host mds$num) \
4664 $(mdsdevname $num) "-y" ||
4665 error "e2fsck MDT$num failed"
4667 setup_noconfig || error "remounting the filesystem failed"
4670 # need to delete this file to avoid problems in other tests
4672 cleanup || error "stopping systems failed"
4674 run_test 61 "large xattr"
4677 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4678 skip "ldiskfs only test"
4680 [[ "$MDS1_VERSION" -ge $(version_code 2.2.51) ]] ||
4681 skip "Need MDS version at least 2.2.51"
4684 local mdsdev=$(mdsdevname 1)
4685 local ostdev=$(ostdevname 1)
4687 echo "disable journal for mds"
4688 do_facet mds1 $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
4689 start_mds && error "MDT start should fail"
4690 echo "disable journal for ost"
4691 do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
4692 start_ost && error "OST start should fail"
4693 cleanup || error "cleanup failed with rc $?"
4696 run_test 62 "start with disabled journal"
4699 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4700 skip "ldiskfs only test"
4703 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ldiskfs
4704 local inode_slab=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4705 awk '/ldiskfs_inode_cache/ { print $5 / $6 }')
4706 if [ -z "$inode_slab" ]; then
4707 skip "ldiskfs module has not been loaded"
4710 if grep -q "CONFIG_DEBUG_LOCK_ALLOC=y" /boot/config-$(uname -r); then
4711 skip "test is not compatible with CONFIG_DEBUG_LOCK_ALLOC=y"
4714 echo "$inode_slab ldiskfs inodes per page"
4715 [ "${inode_slab%.*}" -ge "3" ] && return 0
4717 # If kmalloc-128 is also 1 per page - this is a debug kernel
4718 # and so this is not an error.
4719 local kmalloc128=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
4720 awk '/^(dma-kmalloc|size)-128 / { print $5 / $6 }')
4721 # 32 128-byte chunks in 4k
4722 [ "${kmalloc128%.*}" -lt "32" ] ||
4723 error "ldiskfs inode too big, only $inode_slab objs/page, " \
4724 "kmalloc128 = $kmalloc128 objs/page"
4726 run_test 63 "Verify each page can at least hold 3 ldiskfs inodes"
4729 start_mds || error "unable to start MDS"
4730 start_ost || error "Unable to start OST1"
4731 start_ost2 || error "Unable to start second ost"
4732 mount_client $MOUNT || error "Unable to mount client"
4733 stop_ost2 || error "Unable to stop second ost"
4736 umount_client $MOUNT -f || error “unmount $MOUNT failed”
4737 cleanup_nocli || error "cleanup_nocli failed with $?"
4738 #writeconf to remove all ost2 traces for subsequent tests
4739 writeconf_or_reformat
4741 run_test 64 "check lfs df --lazy "
4743 test_65() { # LU-2237
4744 # Currently, the test is only valid for ldiskfs backend
4745 [ "$mds1_FSTYPE" != ldiskfs ] &&
4746 skip "ldiskfs only test"
4748 local devname=$(mdsdevname ${SINGLEMDS//mds/})
4749 local brpt=$(facet_mntpt brpt)
4752 if ! do_facet $SINGLEMDS "test -b $devname"; then
4756 stop_mds || error "Unable to stop MDS"
4757 local obj=$(do_facet $SINGLEMDS \
4758 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
4760 if [ -z "$obj" ]; then
4761 # The MDT may be just re-formatted, mount the MDT for the
4762 # first time to guarantee the "last_rcvd" file is there.
4763 start_mds || error "fail to mount the MDS for the first time"
4764 stop_mds || error "Unable to stop MDS"
4767 # remove the "last_rcvd" file
4768 do_facet $SINGLEMDS "mkdir -p $brpt"
4769 do_facet $SINGLEMDS \
4770 "mount -t $mds1_FSTYPE $opts $devname $brpt"
4771 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
4772 do_facet $SINGLEMDS "$UMOUNT $brpt"
4774 # restart MDS, the "last_rcvd" file should be recreated.
4775 start_mds || error "fail to restart the MDS"
4776 stop_mds || error "Unable to stop MDS"
4777 obj=$(do_facet $SINGLEMDS \
4778 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
4779 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
4781 run_test 65 "re-create the lost last_rcvd file when server mount"
4784 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
4785 skip "Need MGS version at least 2.3.59"
4788 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
4789 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
4791 # add EXCLUDE records to config log, they are not to be
4792 # removed by lctl replace_nids
4793 set_conf_param_and_check mds \
4794 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4795 "$FSNAME-OST0000.osc.active" \
4798 echo "replace_nids should fail if MDS, OSTs and clients are UP"
4799 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4800 error "replace_nids fail"
4802 umount_client $MOUNT || error "unmounting client failed"
4803 echo "replace_nids should fail if MDS and OSTs are UP"
4804 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4805 error "replace_nids fail"
4807 stop_ost || error "Unable to stop OST1"
4808 echo "replace_nids should fail if MDS is UP"
4809 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
4810 error "replace_nids fail"
4812 stop_mds || error "stopping mds failed"
4814 if combined_mgs_mds; then
4815 start_mdt 1 "-o nosvc" ||
4816 error "starting mds with nosvc option failed"
4819 echo "command should accept two parameters"
4820 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
4821 error "command should accept two params"
4823 echo "correct device name should be passed"
4824 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
4825 error "wrong devname"
4827 echo "wrong nids list should not destroy the system"
4828 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
4830 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "asdfasdf, asdfadf" &&
4833 echo "replace OST nid"
4834 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
4835 error "replace nids failed"
4837 echo "command should accept two parameters"
4838 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
4839 error "command should accept two params"
4841 echo "wrong nids list should not destroy the system"
4842 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
4845 local FAKE_NIDS="192.168.0.112@tcp1,192.168.0.112@tcp2"
4846 local FAKE_FAILOVER="192.168.0.113@tcp1,192.168.0.113@tcp2"
4847 local NIDS_AND_FAILOVER="$MDS_NID,$FAKE_NIDS:$FAKE_FAILOVER"
4848 echo "set NIDs with failover"
4849 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $NIDS_AND_FAILOVER ||
4850 error "replace nids failed"
4853 echo "replace MDS nid"
4854 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
4855 error "replace nids failed"
4857 if ! combined_mgs_mds ; then
4860 stop_mds || error "Unable to stop MDS"
4863 start_mgsmds || error "start mgsmds failed"
4864 set_conf_param_and_check mds \
4865 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
4866 "$FSNAME-OST0000.osc.active" \
4868 start_ost || error "unable to start OST"
4869 mount_client $MOUNT || error "mount client failed"
4871 check_mount || error "error after nid replace"
4872 cleanup || error "cleanup failed"
4875 run_test 66 "replace nids"
4877 test_67() { #LU-2950
4878 local legacy="$TMP/legacy_lnet_config"
4879 local new="$TMP/new_routes_test"
4880 local out="$TMP/config_out_file"
4881 local verify="$TMP/conv_verify"
4882 local verify_conf="$TMP/conf_verify"
4884 # Create the legacy file that will be run through the
4885 # lustre_routes_conversion script
4886 cat <<- LEGACY_LNET_CONFIG > $legacy
4887 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
4888 tcp2 54 10.1.3.2@tcp;
4889 tcp3 10.3.4.3@tcp:3;
4893 # Create the verification file to verify the output of
4894 # lustre_routes_conversion script against.
4895 cat <<- VERIFY_LNET_CONFIG > $verify
4896 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
4897 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
4898 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
4899 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
4900 tcp4: { gateway: 10.3.3.4@tcp }
4903 # Create the verification file to verify the output of
4904 # lustre_routes_config script against
4905 cat <<- VERIFY_LNET_CONFIG > $verify_conf
4906 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
4907 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
4908 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
4909 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
4910 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
4913 $LUSTRE_ROUTES_CONVERSION $legacy $new > /dev/null
4914 if [ -f $new ]; then
4915 # verify the conversion output
4916 cmp -s $new $verify > /dev/null
4917 if [ $? -eq 1 ]; then
4918 error "routes conversion failed"
4921 lustre_routes_config --dry-run --verbose $new > $out
4922 # check that the script succeeded
4923 cmp -s $out $verify_conf > /dev/null
4924 if [ $? -eq 1 ]; then
4925 error "routes config failed"
4928 error "routes conversion test failed"
4930 # remove generated files
4931 rm -f $new $legacy $verify $verify_conf $out
4933 run_test 67 "test routes conversion and configuration"
4941 [ "$MDS1_VERSION" -ge $(version_code 2.4.53) ] ||
4942 skip "Need MDS version at least 2.4.53"
4944 umount_client $MOUNT || error "umount client failed"
4949 # START-END - the sequences we'll be reserving
4950 START=$(do_facet $SINGLEMDS \
4951 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
4952 END=$((START + (1 << 30)))
4953 do_facet $SINGLEMDS \
4954 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
4956 # reset the sequences MDT0000 has already assigned
4957 do_facet $SINGLEMDS \
4958 $LCTL set_param seq.srv*MDT0000.space=clear
4960 # remount to let the client allocate new sequence
4961 mount_client $MOUNT || error "mount client failed"
4963 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4964 do_facet $SINGLEMDS \
4965 $LCTL get_param seq.srv*MDT0000.space
4966 $LFS path2fid $DIR/$tfile
4968 local old_ifs="$IFS"
4970 fid=($($LFS path2fid $DIR/$tfile))
4974 if [[ $seq < $END ]]; then
4975 error "used reserved sequence $seq?"
4977 cleanup || error "cleanup failed with $?"
4979 run_test 68 "be able to reserve specific sequences in FLDB"
4981 # Test 69: is about the total number of objects ever created on an OST.
4982 # so that when it is reformatted the normal MDS->OST orphan recovery won't
4983 # just "precreate" the missing objects. In the past it might try to recreate
4984 # millions of objects after an OST was reformatted
4986 [[ "$MDS1_VERSION" -lt $(version_code 2.4.2) ]] &&
4987 skip "Need MDS version at least 2.4.2"
4989 [[ "$MDS1_VERSION" -ge $(version_code 2.4.50) ]] &&
4990 [[ "$MDS1_VERSION" -lt $(version_code 2.5.0) ]] &&
4991 skip "Need MDS version at least 2.5.0"
4994 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4996 # use OST0000 since it probably has the most creations
4997 local OSTNAME=$(ostname_from_index 0)
4998 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
4999 local last_id=$(do_facet mds1 $LCTL get_param -n \
5000 osp.$mdtosc_proc1.prealloc_last_id)
5002 # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
5003 # verify that the LAST_ID recovery is working properly. If
5004 # not, then the OST will refuse to allow the MDS connect
5005 # because the LAST_ID value is too different from the MDS
5006 #define OST_MAX_PRECREATE=20000
5007 local ost_max_pre=20000
5008 local num_create=$(( ost_max_pre * 5 + 1 - last_id))
5010 # If the LAST_ID is already over 5 * OST_MAX_PRECREATE, we don't
5011 # need to create any files. So, skip this section.
5012 if [ $num_create -gt 0 ]; then
5013 # Check the number of inodes available on OST0
5015 local ifree=$($LFS df -i $MOUNT | awk '/OST0000/ { print $4 }')
5016 log "On OST0, $ifree inodes available. Want $num_create."
5018 $LFS setstripe -i 0 $DIR/$tdir ||
5019 error "$LFS setstripe -i 0 $DIR/$tdir failed"
5020 if [ $ifree -lt 10000 ]; then
5021 files=$(( ifree - 50 ))
5026 local j=$((num_create / files + 1))
5027 for i in $(seq 1 $j); do
5028 createmany -o $DIR/$tdir/$tfile-$i- $files ||
5029 error "createmany fail create $files files: $?"
5030 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
5031 error "unlinkmany failed unlink $files files"
5035 # delete all of the files with objects on OST0 so the
5036 # filesystem is not inconsistent later on
5037 $LFS find $MOUNT --ost 0 -print0 | xargs -0 rm
5039 umount_client $MOUNT || error "umount client failed"
5040 stop_ost || error "OST0 stop failure"
5041 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
5042 $(ostdevname 1) $(ostvdevname 1) ||
5043 error "reformat and replace $ostdev failed"
5044 start_ost || error "OST0 restart failure"
5045 wait_osc_import_state mds ost FULL
5047 mount_client $MOUNT || error "mount client failed"
5048 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
5049 local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
5050 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
5052 local iused=$($LFS df -i $MOUNT | awk '/OST0000/ { print $3 }')
5053 log "On OST0, $iused used inodes"
5054 [ $iused -ge $((ost_max_pre/2 + 1000)) ] &&
5055 error "OST replacement created too many inodes; $iused"
5056 cleanup || error "cleanup failed with $?"
5058 run_test 69 "replace an OST with the same index"
5061 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5064 cleanup || error "cleanup failed with $?"
5066 start_mdt 1 || error "MDT0 start fail"
5068 start_ost || error "OST0 start fail"
5069 for num in $(seq 2 $MDSCOUNT); do
5070 start_mdt $num || return
5073 mount_client $MOUNT || error "mount client fails"
5075 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5077 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5078 error "create remote dir fail"
5080 rm -rf $DIR/$tdir || error "delete dir fail"
5081 cleanup || error "cleanup failed with $?"
5083 run_test 70a "start MDT0, then OST, then MDT1"
5086 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5089 start_ost || error "OST0 start fail"
5091 start_mds || error "MDS start fail"
5093 mount_client $MOUNT || error "mount client fails"
5095 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5097 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5098 error "create remote dir fail"
5100 rm -rf $DIR/$tdir || error "delete dir fail"
5102 cleanup || error "cleanup failed with $?"
5104 run_test 70b "start OST, MDT1, MDT0"
5107 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5110 start_mds || error "MDS start fail"
5111 start_ost || error "OST0 start fail"
5113 mount_client $MOUNT || error "mount client fails"
5114 stop_mdt 1 || error "MDT1 start fail"
5116 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
5117 echo "deactivate $mdc_for_mdt1"
5118 $LCTL --device $mdc_for_mdt1 deactivate ||
5119 error "set $mdc_for_mdt1 deactivate failed"
5121 mkdir $DIR/$tdir && error "mkdir succeed"
5123 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5124 error "create remote dir succeed"
5126 cleanup || error "cleanup failed with $?"
5128 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
5131 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5134 start_mds || error "MDS start fail"
5135 start_ost || error "OST0 start fail"
5137 mount_client $MOUNT || error "mount client fails"
5139 stop_mdt 2 || error "MDT1 start fail"
5141 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
5143 echo "deactivate $mdc_for_mdt2"
5144 $LCTL --device $mdc_for_mdt2 deactivate ||
5145 error "set $mdc_for_mdt2 deactivate failed"
5147 mkdir $DIR/$tdir || error "mkdir fail"
5148 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5149 error "create remote dir succeed"
5151 rm -rf $DIR/$tdir || error "delete dir fail"
5153 cleanup || error "cleanup failed with $?"
5155 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
5158 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5160 [ "$MDS1_VERSION" -ge $(version_code 2.7.62) ] ||
5161 skip "Need MDS version at least 2.7.62"
5163 reformat || error "reformat failed with $?"
5167 local mdsdev=$(mdsdevname 1)
5168 local ostdev=$(ostdevname 1)
5169 local mdsvdev=$(mdsvdevname 1)
5170 local ostvdev=$(ostvdevname 1)
5171 local opts_mds="$(mkfs_opts mds1 $mdsdev) --reformat $mdsdev $mdsvdev"
5172 local opts_ost="$(mkfs_opts ost1 $ostdev) --reformat $ostdev $ostvdev"
5174 if ! combined_mgs_mds ; then
5178 add mds1 $opts_mds || error "add mds1 failed"
5179 start_mdt 1 || error "start mdt1 failed"
5180 add ost1 $opts_ost || error "add ost1 failed"
5181 start_ost || error "start ost failed"
5182 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
5184 local soc=$(do_facet mds1 "$LCTL get_param -n \
5185 mdt.*MDT0000.sync_lock_cancel")
5186 [ $soc == "never" ] || error "SoC enabled on single MDS"
5188 for i in $(seq 2 $MDSCOUNT); do
5189 mdsdev=$(mdsdevname $i)
5190 mdsvdev=$(mdsvdevname $i)
5191 opts_mds="$(mkfs_opts mds$i $mdsdev) --reformat $mdsdev \
5193 add mds$i $opts_mds || error "add mds$i failed"
5194 start_mdt $i || error "start mdt$i fail"
5197 wait_dne_interconnect
5199 for i in $(seq $MDSCOUNT); do
5200 soc=$(do_facet mds$i "$LCTL get_param -n \
5201 mdt.*MDT000$((i - 1)).sync_lock_cancel")
5202 [ $soc == "blocking" ] || error "SoC not enabled on DNE"
5205 for i in $(seq 2 $MDSCOUNT); do
5206 stop_mdt $i || error "stop mdt$i fail"
5208 soc=$(do_facet mds1 "$LCTL get_param -n \
5209 mdt.*MDT0000.sync_lock_cancel")
5210 [ $soc == "never" ] || error "SoC enabled on single MDS"
5211 umount_client $MOUNT -f > /dev/null
5213 cleanup || error "cleanup failed with $?"
5215 run_test 70e "Sync-on-Cancel will be enabled by default on DNE"
5218 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5219 if combined_mgs_mds; then
5220 skip "needs separate MGS/MDT"
5224 start_mdt 1 || error "MDT0 start fail"
5225 start_ost || error "OST0 start fail"
5226 for num in $(seq 2 $MDSCOUNT); do
5227 start_mdt $num || return
5230 start_ost2 || error "OST1 start fail"
5232 mount_client $MOUNT || error "mount client fails"
5234 mkdir $DIR/$tdir || error "mkdir fail"
5235 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5236 error "create remote dir succeed"
5238 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5239 rm -rf $DIR/$tdir || error "delete dir fail"
5241 umount_client $MOUNT || error "umount_client failed"
5242 stop_mds || error "MDS stop fail"
5243 stop_ost || error "OST0 stop fail"
5244 stop_ost2 || error "OST1 stop fail"
5246 run_test 71a "start MDT0 OST0, MDT1, OST1"
5249 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5250 if combined_mgs_mds; then
5251 skip "needs separate MGS/MDT"
5255 for num in $(seq 2 $MDSCOUNT); do
5256 start_mdt $num || return
5258 start_ost || error "OST0 start fail"
5259 start_mdt 1 || error "MDT0 start fail"
5260 start_ost2 || error "OST1 start fail"
5262 mount_client $MOUNT || error "mount client fails"
5264 mkdir $DIR/$tdir || error "mkdir fail"
5265 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5266 error "create remote dir succeed"
5268 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5269 rm -rf $DIR/$tdir || error "delete dir fail"
5271 umount_client $MOUNT || error "umount_client failed"
5272 stop_mds || error "MDT0 stop fail"
5273 stop_ost || error "OST0 stop fail"
5274 stop_ost2 || error "OST1 stop fail"
5276 run_test 71b "start MDT1, OST0, MDT0, OST1"
5279 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5280 combined_mgs_mds && skip "needs separate MGS/MDT"
5284 start_ost || error "OST0 start fail"
5285 start_ost2 || error "OST1 start fail"
5286 for num in $(seq 2 $MDSCOUNT); do
5287 start_mdt $num || return
5289 start_mdt 1 || error "MDT0 start fail"
5291 mount_client $MOUNT || error "mount client fails"
5293 mkdir $DIR/$tdir || error "mkdir fail"
5294 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5295 error "create remote dir succeed"
5297 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5298 rm -rf $DIR/$tdir || error "delete dir fail"
5300 umount_client $MOUNT || error "umount_client failed"
5301 stop_mds || error "MDS stop fail"
5302 stop_ost || error "OST0 stop fail"
5303 stop_ost2 || error "OST1 stop fail"
5306 run_test 71c "start OST0, OST1, MDT1, MDT0"
5309 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5310 combined_mgs_mds && skip "needs separate MGS/MDT"
5314 start_ost || error "OST0 start fail"
5315 for num in $(seq 2 $MDSCOUNT); do
5316 start_mdt $num || return
5318 start_mdt 1 || error "MDT0 start fail"
5319 start_ost2 || error "OST1 start fail"
5321 mount_client $MOUNT || error "mount client fails"
5323 mkdir $DIR/$tdir || error "mkdir fail"
5324 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5325 error "create remote dir succeed"
5327 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5328 rm -rf $DIR/$tdir || error "delete dir fail"
5330 umount_client $MOUNT || error "umount_client failed"
5331 stop_mds || error "MDS stop fail"
5332 stop_ost || error "OST0 stop fail"
5333 stop_ost2 || error "OST1 stop fail"
5336 run_test 71d "start OST0, MDT1, MDT0, OST1"
5339 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5340 combined_mgs_mds && skip "needs separate MGS/MDT"
5344 start_ost || error "OST0 start fail"
5345 for num in $(seq 2 $MDSCOUNT); do
5346 start_mdt $num || return
5348 start_ost2 || error "OST1 start fail"
5349 start_mdt 1 || error "MDT0 start fail"
5351 mount_client $MOUNT || error "mount client fails"
5353 mkdir $DIR/$tdir || error "mkdir fail"
5354 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5355 error "create remote dir succeed"
5357 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5358 rm -rf $DIR/$tdir || error "delete dir fail"
5360 umount_client $MOUNT || error "umount_client failed"
5361 stop_mds || error "MDS stop fail"
5362 stop_ost || error "OST0 stop fail"
5363 stop_ost2 || error "OST1 stop fail"
5366 run_test 71e "start OST0, MDT1, OST1, MDT0"
5368 test_72() { #LU-2634
5369 [ "$mds1_FSTYPE" != ldiskfs ] &&
5370 skip "ldiskfs only test"
5372 local mdsdev=$(mdsdevname 1)
5373 local ostdev=$(ostdevname 1)
5374 local cmd="$E2FSCK -fnvd $mdsdev"
5381 if combined_mgs_mds; then
5382 add_options='--reformat'
5384 add_options='--reformat --replace'
5387 #tune MDT with "-O extents"
5389 for num in $(seq $MDSCOUNT); do
5390 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
5391 $add_options $(mdsdevname $num) $(mdsvdevname $num) ||
5392 error "add mds $num failed"
5393 do_facet mds${num} "$TUNE2FS -O extents $(mdsdevname $num)" ||
5394 error "$TUNE2FS failed on mds${num}"
5397 add ost1 $(mkfs_opts ost1 $ostdev) $add_options $ostdev ||
5398 error "add $ostdev failed"
5399 start_mds || error "start mds failed"
5400 start_ost || error "start ost failed"
5401 mount_client $MOUNT || error "mount client failed"
5403 #create some short symlinks
5404 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5405 createmany -o $DIR/$tdir/$tfile-%d $fn
5406 echo "create $fn short symlinks"
5407 for i in $(seq -w 1 $fn); do
5408 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
5413 umount_client $MOUNT || error "umount client failed"
5414 stop_mds || error "stop mds failed"
5415 stop_ost || error "stop ost failed"
5418 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
5420 run_test 72 "test fast symlink with extents flag enabled"
5422 test_73() { #LU-3006
5423 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
5424 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
5425 error "1st tunefs failed"
5426 start_mgsmds || error "start mds failed"
5427 start_ost || error "start ost failed"
5428 mount_client $MOUNT || error "mount client failed"
5429 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
5430 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
5431 umount_client $MOUNT || error "umount client failed"
5435 run_test 73 "failnode to update from mountdata properly"
5437 test_75() { # LU-2374
5438 [[ "$MDS1_VERSION" -lt $(version_code 2.4.1) ]] &&
5439 skip "Need MDS version at least 2.4.1"
5442 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
5443 --replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
5444 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
5445 --replace --reformat $(ostdevname 1) $(ostvdevname 1)"
5447 #check with default parameters
5448 add mds1 $opts_mds || error "add mds1 failed for default params"
5449 add ost1 $opts_ost || error "add ost1 failed for default params"
5451 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
5452 opts_mds=$(echo $opts_mds |
5453 sed -e "s/--index=$index/--index=$index --mdt/")
5454 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
5455 opts_ost=$(echo $opts_ost |
5456 sed -e "s/--index=$index/--index=$index --ost/")
5458 add mds1 $opts_mds || error "add mds1 failed for new params"
5459 add ost1 $opts_ost || error "add ost1 failed for new params"
5464 run_test 75 "The order of --index should be irrelevant"
5467 [[ "$MGS_VERSION" -ge $(version_code 2.4.52) ]] ||
5468 skip "Need MDS version at least 2.4.52"
5471 local MDMB_PARAM="osc.*.max_dirty_mb"
5472 echo "Change MGS params"
5473 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
5475 echo "max_dirty_mb: $MAX_DIRTY_MB"
5476 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB - 10))
5477 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
5478 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
5479 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5480 head -1" $NEW_MAX_DIRTY_MB
5481 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5482 echo "$MAX_DIRTY_MB"
5483 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5484 error "error while apply max_dirty_mb"
5486 echo "Check the value is stored after remount"
5489 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
5490 head -1" $NEW_MAX_DIRTY_MB
5491 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
5492 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
5493 error "max_dirty_mb is not saved after remount"
5495 echo "Change OST params"
5496 CLIENT_PARAM="obdfilter.*.client_cache_count"
5497 local CLIENT_CACHE_COUNT
5498 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5500 echo "client_cache_count: $CLIENT_CACHE_COUNT"
5501 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
5502 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
5503 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
5504 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5505 head -1" $NEW_CLIENT_CACHE_COUNT
5506 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5508 echo "$CLIENT_CACHE_COUNT"
5509 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5510 error "error while apply client_cache_count"
5512 echo "Check the value is stored after remount"
5515 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
5516 head -1" $NEW_CLIENT_CACHE_COUNT
5517 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
5519 echo "$CLIENT_CACHE_COUNT"
5520 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
5521 error "client_cache_count is not saved after remount"
5524 run_test 76a "set permanent params with lctl across mounts"
5526 test_76b() { # LU-4783
5527 [[ "$MGS_VERSION" -ge $(version_code 2.5.57) ]] ||
5528 skip "Need MGS version at least 2.5.57"
5531 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
5532 error "start params log failed"
5535 run_test 76b "verify params log setup correctly"
5538 [[ "$MGS_VERSION" -ge $(version_code 2.8.54) ]] ||
5539 skip "Need MDS version at least 2.4.52"
5541 local MASK_PARAM="mdd.*.changelog_mask"
5542 echo "Change changelog_mask"
5543 do_facet mgs $LCTL set_param -P $MASK_PARAM=-CLOSE ||
5544 error "Can't change changlog_mask"
5545 wait_update $(facet_host mds) "$LCTL get_param -n $MASK_PARAM |
5548 echo "Check the value is stored after mds remount"
5549 stop_mds || error "Failed to stop MDS"
5550 start_mds || error "Failed to start MDS"
5551 local CHANGELOG_MASK=$(do_facet mgs $LCTL get_param -n $MASK_PARAM)
5552 echo $CHANGELOG_MASK | grep CLOSE > /dev/null &&
5553 error "changelog_mask is not changed"
5557 run_test 76c "verify changelog_mask is applied with lctl set_param -P"
5559 test_76d() { #LU-9399
5562 local xattr_cache="llite.*.xattr_cache"
5563 local cmd="$LCTL get_param -n $xattr_cache | head -1"
5564 local new=$((($(eval $cmd) + 1) % 2))
5566 echo "lctl set_param -P llite.*.xattr_cache=$new"
5567 do_facet mgs $LCTL set_param -P $xattr_cache=$new ||
5568 error "Can't change xattr_cache"
5569 wait_update $HOSTNAME "$cmd" "$new"
5571 echo "Check $xattr_cache on client $MOUNT"
5572 umount_client $MOUNT || error "umount $MOUNT failed"
5573 mount_client $MOUNT || error "mount $MOUNT failed"
5574 [ $(eval $cmd) -eq $new ] ||
5575 error "$xattr_cache != $new on client $MOUNT"
5577 echo "Check $xattr_cache on the new client $MOUNT2"
5578 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
5579 [ $(eval $cmd) -eq $new ] ||
5580 error "$xattr_cache != $new on client $MOUNT2"
5581 umount_client $MOUNT2 || error "umount $MOUNT2 failed"
5585 run_test 76d "verify llite.*.xattr_cache can be set by 'lctl set_param -P' correctly"
5587 test_77() { # LU-3445
5588 [[ "$MDS1_VERSION" -ge $(version_code 2.8.55) ]] ||
5589 skip "Need MDS version 2.8.55+ "
5591 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
5592 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
5593 skip_env "mixed loopback and real device not working"
5596 local fs2mdsdev=$(mdsdevname 1_2)
5597 local fs2ostdev=$(ostdevname 1_2)
5598 local fs2mdsvdev=$(mdsvdevname 1_2)
5599 local fs2ostvdev=$(ostvdevname 1_2)
5600 local fsname=test1234
5602 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
5604 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
5606 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
5607 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
5608 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
5609 error "start fs2mds failed"
5611 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
5612 mgsnid="0.0.0.0@tcp,$mgsnid,$mgsnid:$mgsnid"
5614 add fs2ost --mgsnode=$mgsnid $(mkfs_opts ost1 $fs2ostdev) \
5615 --failnode=$failnid --fsname=$fsname \
5616 --reformat $fs2ostdev $fs2ostvdev ||
5617 error "add fs2ost failed"
5618 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
5620 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
5621 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
5622 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
5625 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
5628 [[ "$mds1_FSTYPE" != ldiskfs ||
5629 "$ost1_FSTYPE" != ldiskfs ]] &&
5630 skip "ldiskfs only test"
5632 # reformat the Lustre filesystem with a smaller size
5633 local saved_MDSCOUNT=$MDSCOUNT
5634 local saved_MDSSIZE=$MDSSIZE
5635 local saved_OSTCOUNT=$OSTCOUNT
5636 local saved_OSTSIZE=$OSTSIZE
5639 MDSSIZE=$((MDSSIZE - 20000))
5640 OSTSIZE=$((OSTSIZE - 20000))
5641 reformat || error "(1) reformat Lustre filesystem failed"
5642 MDSSIZE=$saved_MDSSIZE
5643 OSTSIZE=$saved_OSTSIZE
5645 # mount the Lustre filesystem
5646 setup_noconfig || error "(2) setup Lustre filesystem failed"
5649 log "create test files"
5654 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
5656 for i in $(seq $num_files); do
5657 file=$MOUNT/$tdir/$tfile-$i
5658 dd if=/dev/urandom of=$file count=1 bs=1M || {
5659 $LCTL get_param osc.*.cur*grant*
5660 $LFS df; $LFS df -i;
5661 # stop creating files if there is no more space
5662 if [ ! -e $file ]; then
5663 num_files=$((i - 1))
5667 $LFS getstripe -v $file
5668 local ost_idx=$(LFS getstripe -i $file)
5669 do_facet ost$((ost_idx + 1)) \
5670 $LCTL get_param obdfilter.*.*grant*
5671 error "(4) create $file failed"
5675 # unmount the Lustre filesystem
5676 cleanup || error "(5) cleanup Lustre filesystem failed"
5678 # run e2fsck on the MDT and OST devices
5679 local mds_host=$(facet_active_host $SINGLEMDS)
5680 local ost_host=$(facet_active_host ost1)
5681 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
5682 local ost_dev=$(ostdevname 1)
5684 run_e2fsck $mds_host $mds_dev "-y"
5685 run_e2fsck $ost_host $ost_dev "-y"
5687 # get the original block count of the MDT and OST filesystems
5688 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
5689 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
5691 # expand the MDT and OST filesystems to the device size
5692 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
5693 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
5695 # run e2fsck on the MDT and OST devices again
5696 run_e2fsck $mds_host $mds_dev "-y"
5697 run_e2fsck $ost_host $ost_dev "-y"
5699 # mount the Lustre filesystem
5703 log "check files after expanding the MDT and OST filesystems"
5704 for i in $(seq $num_files); do
5705 file=$MOUNT/$tdir/$tfile-$i
5706 $CHECKSTAT -t file -s 1048576 $file ||
5707 error "(6) checkstat $file failed"
5711 log "create more files after expanding the MDT and OST filesystems"
5712 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
5713 file=$MOUNT/$tdir/$tfile-$i
5714 dd if=/dev/urandom of=$file count=1 bs=1M ||
5715 error "(7) create $file failed"
5718 # unmount the Lustre filesystem
5719 cleanup || error "(8) cleanup Lustre filesystem failed"
5721 # run e2fsck on the MDT and OST devices
5722 run_e2fsck $mds_host $mds_dev "-y"
5723 run_e2fsck $ost_host $ost_dev "-y"
5725 # get the maximum block count of the MDT and OST filesystems
5726 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
5727 local ost_max_blks=$(get_block_count ost1 $ost_dev)
5729 # get the minimum block count of the MDT and OST filesystems
5730 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
5731 grep minimum | sed -e 's/^.*filesystem: //g')
5732 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
5733 grep minimum | sed -e 's/^.*filesystem: //g')
5735 # shrink the MDT and OST filesystems to a smaller size
5739 if [[ $mds_max_blks -gt $mds_min_blks &&
5740 $mds_max_blks -gt $mds_orig_blks ]]; then
5741 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
5742 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
5743 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
5744 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
5745 error "shrink $SINGLEMDS to $new_blks failed"
5749 if [[ $ost_max_blks -gt $ost_min_blks &&
5750 $ost_max_blks -gt $ost_orig_blks ]]; then
5751 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
5752 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
5753 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
5754 run_resize2fs ost1 $ost_dev $new_blks ||
5755 error "shrink ost1 to $new_blks failed"
5759 # check whether the MDT or OST filesystem was shrunk or not
5761 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
5762 reformat_and_config ||
5763 error "(10) reformat Lustre filesystem failed"
5767 # run e2fsck on the MDT and OST devices again
5768 run_e2fsck $mds_host $mds_dev "-y"
5769 run_e2fsck $ost_host $ost_dev "-y"
5771 # mount the Lustre filesystem again
5775 log "check files after shrinking the MDT and OST filesystems"
5776 for i in $(seq $((num_files + 10))); do
5777 file=$MOUNT/$tdir/$tfile-$i
5778 $CHECKSTAT -t file -s 1048576 $file ||
5779 error "(11) checkstat $file failed"
5782 # unmount and reformat the Lustre filesystem
5783 cleanup || error "(12) cleanup Lustre filesystem failed"
5784 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
5786 MDSCOUNT=$saved_MDSCOUNT
5787 OSTCOUNT=$saved_OSTCOUNT
5788 reformat_and_config || error "(14) reformat Lustre filesystem failed"
5790 run_test 78 "run resize2fs on MDT and OST filesystems"
5792 test_79() { # LU-4227
5793 [[ "$MDS1_VERSION" -ge $(version_code 2.5.59) ]] ||
5794 skip "Need MDS version at least 2.5.59"
5796 local mdsdev1=$(mdsdevname 1)
5797 local mdsvdev1=$(mdsvdevname 1)
5798 local mdsdev2=$(mdsdevname 2)
5799 local mdsvdev2=$(mdsvdevname 2)
5800 local ostdev1=$(ostdevname 1)
5801 local ostvdev1=$(ostvdevname 1)
5802 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
5803 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
5804 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
5807 # remove --mgs/--mgsnode from mkfs.lustre options
5808 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
5810 mgsnode_opt=$(echo $opts_mds2 |
5811 awk '{ for ( i = 1; i < NF; i++ )
5812 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5813 [ -n "$mgsnode_opt" ] &&
5814 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
5816 mgsnode_opt=$(echo $opts_ost1 |
5817 awk '{ for ( i = 1; i < NF; i++ )
5818 if ( $i ~ "--mgsnode" ) { print $i; break } }')
5819 [ -n "$mgsnode_opt" ] &&
5820 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
5822 # -MGS, format a mdt without --mgs option
5823 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
5824 error "Must specify --mgs when formatting mdt combined with mgs"
5826 # +MGS, format a mdt/ost without --mgsnode option
5827 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
5828 > /dev/null || error "start mds1 failed"
5829 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
5830 error "Must specify --mgsnode when formatting a mdt"
5831 add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
5832 error "Must specify --mgsnode when formatting an ost"
5836 run_test 79 "format MDT/OST without mgs option (should return errors)"
5839 start_mds || error "Failed to start MDT"
5840 start_ost || error "Failed to start OST1"
5841 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
5842 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
5843 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
5844 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
5845 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
5847 start_ost2 || error "Failed to start OST2"
5849 do_facet ost1 "$LCTL set_param fail_loc=0"
5854 run_test 80 "mgc import reconnect race"
5856 #Save the original values of $OSTCOUNT and $OSTINDEX$i.
5858 local new_ostcount=$1
5859 saved_ostcount=$OSTCOUNT
5860 OSTCOUNT=$new_ostcount
5864 for i in $(seq $OSTCOUNT); do
5866 eval saved_ostindex$i=${!index}
5871 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
5872 restore_ostindex() {
5877 for i in $(seq $OSTCOUNT); do
5878 index=saved_ostindex$i
5879 eval OSTINDEX$i=${!index}
5881 OSTCOUNT=$saved_ostcount
5884 if ! combined_mgs_mds ; then
5889 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
5890 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
5891 # assigned index and ensures we can mount such a formatted file system
5892 test_81() { # LU-4665
5893 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
5894 skip "Need MDS version at least 2.6.54"
5895 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5899 # Each time RANDOM is referenced, a random integer between 0 and 32767
5902 local saved_ostindex1=$OSTINDEX1
5903 for i in 65535 $((RANDOM + 65536)); do
5904 echo -e "\nFormat ost1 with --index=$i, should fail"
5906 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
5907 $(ostdevname 1) $(ostvdevname 1); then
5908 OSTINDEX1=$saved_ostindex1
5909 error "format ost1 with --index=$i should fail"
5912 OSTINDEX1=$saved_ostindex1
5916 # Format OSTs with random sparse indices.
5917 trap "restore_ostindex" EXIT
5918 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices"
5919 OST_INDEX_LIST=[0,$((RANDOM * 2 % 65533 + 1)),65534] formatall
5921 # Setup and check Lustre filesystem.
5922 start_mgsmds || error "start_mgsmds failed"
5923 for i in $(seq $OSTCOUNT); do
5924 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5925 error "start ost$i failed"
5928 mount_client $MOUNT || error "mount client $MOUNT failed"
5929 check_mount || error "check client $MOUNT failed"
5932 local max_easize=$($LCTL get_param -n llite.*.max_easize)
5933 # 65452 is XATTR_SIZE_MAX less ldiskfs ea overhead
5934 if large_xattr_enabled; then
5935 [[ $max_easize -ge 65452 ]] ||
5936 error "max_easize is $max_easize, should be at least 65452 bytes"
5939 # 4012 is 4096 less ldiskfs ea overhead
5940 [[ $max_easize -ge 4012 ]] ||
5941 error "max_easize is $max_easize, should be at least 4012 bytes"
5946 run_test 81 "sparse OST indexing"
5948 # Here we exercise the stripe placement functionality on a file system that
5949 # has formatted the OST with a random index. With the file system the following
5950 # functionality is tested:
5952 # 1. Creating a new file with a specific stripe layout.
5954 # 2. Modifiy a existing empty file with a specific stripe layout.
5956 # 3. Ensure we fail to set the stripe layout of a file that already has one.
5958 # 4. If ost-index is defined we need to ensure it is the first entry in the
5959 # ost index list returned by lfs getstripe.
5961 # 5. Lastly ensure this functionality fails with directories.
5962 test_82a() { # LU-4665
5963 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
5964 skip "Need MDS version at least 2.6.54"
5965 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
5971 # Format OSTs with random sparse indices.
5975 local LOV_V1_INSANE_STRIPE_COUNT=65532
5976 for i in $(seq $OSTCOUNT); do
5977 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
5978 ost_indices+=" $index"
5980 ost_indices=$(comma_list $ost_indices)
5982 stack_trap "restore_ostindex" EXIT
5983 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
5984 OST_INDEX_LIST=[$ost_indices] formatall
5986 # Setup Lustre filesystem.
5987 start_mgsmds || error "start_mgsmds failed"
5988 for i in $(seq $OSTCOUNT); do
5989 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
5990 error "start ost$i failed"
5993 # Collect debug information - start of test
5994 do_nodes $(comma_list $(mdts_nodes)) \
5995 $LCTL get_param osp.*.prealloc_*_id
5997 mount_client $MOUNT || error "mount client $MOUNT failed"
6000 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
6001 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6003 stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
6004 $LCTL get_param osp.*.prealloc_*_id" EXIT
6006 # 1. If the file does not exist, new file will be created
6007 # with specified OSTs.
6008 local file=$DIR/$tdir/$tfile-1
6009 local cmd="$LFS setstripe -o $ost_indices $file"
6011 eval $cmd || error "$cmd failed"
6012 check_stripe_count $file $OSTCOUNT
6013 check_obdidx $file $ost_indices
6014 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6015 error "write $file failed"
6017 # 2. If the file already exists and is an empty file, the file
6018 # will be attached with specified layout.
6019 file=$DIR/$tdir/$tfile-2
6020 mcreate $file || error "mcreate $file failed"
6021 cmd="$LFS setstripe -o $ost_indices $file"
6023 eval $cmd || error "$cmd failed"
6024 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6025 error "write $file failed"
6026 check_stripe_count $file $OSTCOUNT
6027 check_obdidx $file $ost_indices
6029 # 3. If the file already has a valid layout attached, the command
6030 # should fail with EBUSY.
6032 eval $cmd && error "stripe is already set on $file, $cmd should fail"
6034 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
6035 # be in the OST indices list.
6036 local start_ost_idx=${ost_indices##*,}
6037 file=$DIR/$tdir/$tfile-3
6038 cmd="$LFS setstripe -o $ost_indices -i $start_ost_idx $file"
6040 eval $cmd || error "$cmd failed"
6041 check_stripe_count $file $OSTCOUNT
6042 check_obdidx $file $ost_indices
6043 check_start_ost_idx $file $start_ost_idx
6045 file=$DIR/$tdir/$tfile-4
6046 cmd="$LFS setstripe"
6047 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
6048 cmd+=" -i $start_ost_idx $file"
6050 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
6052 # 5. Specifying OST indices for directory should succeed.
6053 local dir=$DIR/$tdir/$tdir
6054 mkdir $dir || error "mkdir $dir failed"
6055 cmd="$LFS setstripe -o $ost_indices $dir"
6056 if [ "$MDS1_VERSION" -gt $(version_code 2.11.53) ] &&
6057 [ "$CLIENT_VERSION" -gt $(version_code 2.11.53) ]; then
6059 eval $cmd || error "unable to specify OST indices on directory"
6061 echo "need MDS+client version at least 2.11.53"
6066 run_test 82a "specify OSTs for file (succeed) or directory (succeed)"
6071 # Remove OSTs from a pool and destroy the pool.
6072 destroy_pool $ost_pool || true
6077 # Test 82b is run to ensure that if the user supplies a pool with a specific
6078 # stripe layout that it behaves proprerly. It should fail in the case that
6079 # the supplied OST index list points to OSTs not contained in the user
6081 test_82b() { # LU-4665
6082 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
6083 skip "Need MDS version at least 2.6.54"
6084 [[ $OSTCOUNT -ge 4 ]] || skip_env "needs >= 4 OSTs"
6090 # Format OSTs with random sparse indices.
6094 local LOV_V1_INSANE_STRIPE_COUNT=65532
6095 for i in $(seq $OSTCOUNT); do
6096 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
6097 ost_indices+=" $index"
6099 ost_indices=$(comma_list $ost_indices)
6101 trap "restore_ostindex" EXIT
6102 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
6103 OST_INDEX_LIST=[$ost_indices] formatall
6105 # Setup Lustre filesystem.
6106 start_mgsmds || error "start_mgsmds failed"
6107 for i in $(seq $OSTCOUNT); do
6108 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
6109 error "start ost$i failed"
6112 mount_client $MOUNT || error "mount client $MOUNT failed"
6115 $LFS df $MOUNT || error "$LFS df $MOUNT failed"
6116 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6118 # Create a new pool and add OSTs into it.
6119 local ost_pool=$FSNAME.$TESTNAME
6120 create_pool $ost_pool || error "create OST pool $ost_pool failed"
6123 trap "cleanup_82b" EXIT
6125 local ost_idx_in_list=${ost_indices##*,}
6126 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
6129 local ost_targets="$FSNAME-OST["
6130 for i in ${ost_idx_in_pool//,/ }; do
6131 ost_targets=$ost_targets$(printf "%04x," $i)
6133 ost_targets="${ost_targets%,}]"
6135 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
6136 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
6137 sort -u | tr '\n' ' ')
6139 local cmd="$LCTL pool_add $ost_pool $ost_targets"
6140 do_facet mgs $cmd || error "$cmd failed"
6141 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
6142 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
6143 error "wait_update $ost_pool failed"
6144 wait_update_facet $SINGLEMDS "$LCTL pool_list $ost_pool | wc -l" 4 ||
6145 error "wait_update pool_list $ost_pool failed"
6147 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
6148 # then the OSTs must be the members of the pool.
6149 local file=$DIR/$tdir/$tfile
6150 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6152 eval $cmd && error "OST with index $ost_idx_in_list should be" \
6153 "in OST pool $ost_pool"
6155 # Only select OST $ost_idx_in_list from $ost_pool for file.
6156 ost_idx_in_list=${ost_idx_in_pool#*,}
6157 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6159 eval $cmd || error "$cmd failed"
6160 cmd="$LFS getstripe $file"
6162 eval $cmd || error "$cmd failed"
6163 check_stripe_count $file 2
6164 check_obdidx $file $ost_idx_in_list
6165 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6166 error "write $file failed"
6170 run_test 82b "specify OSTs for file with --pool and --ost-list options"
6173 [[ "$OST1_VERSION" -ge $(version_code 2.6.91) ]] ||
6174 skip "Need OST version at least 2.6.91"
6175 if [ "$ost1_FSTYPE" != ldiskfs ]; then
6176 skip "ldiskfs only test"
6185 ostmnt=$(facet_mntpt ost1)
6187 # Mount the OST as an ldiskfs filesystem.
6188 log "mount the OST $dev as a $ost1_FSTYPE filesystem"
6189 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
6190 --reformat $dev > /dev/null ||
6191 error "format ost1 error"
6193 if ! test -b $dev; then
6194 mnt_opts=$(csa_add "$OST_MOUNT_FS_OPTS" -o loop)
6196 echo "mnt_opts $mnt_opts"
6197 do_facet ost1 mount -t "$ost1_FSTYPE" $dev \
6199 # Run llverfs on the mounted ldiskfs filesystem.
6200 # It is needed to get ENOSPACE.
6201 log "run llverfs in partial mode on the OST $ost1_FSTYPE $ostmnt"
6202 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
6203 "no" || error "run_llverfs error on $ost1_FSTYPE"
6206 log "unmount the OST $dev"
6209 # Delete file IO_scrub. Later osd_scrub_setup will try to
6210 # create "IO_scrub" but will get ENOSPACE.
6212 echo "start ost1 service on `facet_active_host ost1`"
6213 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
6216 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
6217 echo "string err $err"
6218 [ -z "$err" ] || error $err
6221 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
6222 Busy inodes after unmount ..."
6225 local facet=$SINGLEMDS
6226 local num=$(echo $facet | tr -d "mds")
6227 local dev=$(mdsdevname $num)
6228 local time_min=$(recovery_time_min)
6229 local recovery_duration
6230 local completed_clients
6231 local correct_clients
6234 echo "start mds service on $(facet_active_host $facet)"
6236 "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" $@ ||
6237 error "start MDS failed"
6239 start_ost || error "start OST0000 failed"
6240 start_ost2 || error "start OST0001 failed"
6242 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
6244 mount_client $MOUNT1 || error "mount $MOUNT1 failed"
6245 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
6246 # make sure new superblock labels are sync'd before disabling writes
6250 replay_barrier $SINGLEMDS
6251 createmany -o $DIR1/$tfile-%d 1000
6253 # We need to catch the end of recovery window to extend it.
6254 # Skip 5 requests and add delay to request handling.
6255 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
6256 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
6258 facet_failover --fsck $SINGLEMDS || error "failover: $?"
6261 echo "recovery status"
6262 do_facet $SINGLEMDS \
6263 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
6265 recovery_duration=$(do_facet $SINGLEMDS \
6266 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6267 awk '/recovery_duration/ { print $2 }')
6268 (( $recovery_duration > $time_min + $wrap_up )) &&
6269 error "recovery_duration > recovery_time_hard + wrap up"
6270 completed_clients=$(do_facet $SINGLEMDS \
6271 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
6272 awk '/completed_clients/ { print $2 }')
6274 correct_clients="$MDSCOUNT/$((MDSCOUNT+1))"
6275 [ "$completed_clients" = "${correct_clients}" ] ||
6276 error "$completed_clients != $correct_clients"
6278 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
6279 umount_client $MOUNT1
6280 umount_client $MOUNT2
6286 run_test 84 "check recovery_hard_time"
6289 [[ "$OST1_VERSION" -ge $(version_code 2.7.55) ]] ||
6290 skip "Need OST version at least 2.7.55"
6291 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
6292 do_facet ost1 "lctl set_param fail_loc=0x197"
6296 run_test 85 "osd_ost init: fail ea_fid_set"
6301 # ost1 has already registered to the MGS before the reformat.
6302 # So after reformatting it with option "-G", it could not be
6303 # mounted to the MGS. Cleanup the system for subsequent tests.
6308 [ "$ost1_FSTYPE" = zfs ] &&
6309 skip "LU-6442: no such mkfs params for ZFS OSTs"
6310 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
6311 skip "Need server version newer than 2.7.55"
6314 local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6315 awk '/Flex block group size: / { print $NF; exit; }')
6317 [ "$OLDSIZE" == "$NEWSIZE" ] && skip "$NEWSIZE groups already"
6319 local opts=" -O flex_bg -G $NEWSIZE"
6320 opts=$(OST_FS_MKFS_OPTS+="$opts" mkfs_opts ost1 $(ostdevname 1))
6321 opts+=" --reformat $(ostdevname 1) $(ostvdevname 1)"
6322 echo "params: $opts"
6324 trap cleanup_86 EXIT ERR
6327 add ost1 $opts || error "add ost1 failed with new params"
6329 local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
6330 awk '/Flex block group size: / { print $NF; exit; }')
6332 [[ $FOUNDSIZE == $NEWSIZE ]] ||
6333 error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
6337 run_test 86 "Replacing mkfs.lustre -G option"
6339 test_87() { #LU-6544
6340 [[ "$MDS1_VERSION" -ge $(version_code 2.9.51) ]] ||
6341 skip "Need MDS version at least 2.9.51"
6342 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
6343 skip "ldiskfs only test"
6344 [[ $OSTCOUNT -gt 59 ]] &&
6345 skip "Ignore wide striping situation"
6346 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
6348 local mdsdev=$(mdsdevname 1)
6349 local mdsvdev=$(mdsvdevname 1)
6350 local file=$DIR/$tfile
6351 local mntpt=$(facet_mntpt $SINGLEMDS)
6352 local used_xattr_blk=0
6353 local inode_size=${1:-1024}
6355 local xtest="trusted.test"
6359 local stripe_cnt=$(($OSTCOUNT + 2))
6361 #Please see ldiskfs_make_lustre() for MDT inode size calculation
6362 if [ $stripe_cnt -gt 16 ]; then
6365 left_size=$(expr $inode_size - \
6368 32 - 40 \* 3 - 32 \* 3 - $stripe_cnt \* 24 - 16 - 3 - \
6370 24 - 18 - $(expr length $tfile) - 16 - 4)
6371 if [ $left_size -le 0 ]; then
6372 echo "No space($left_size) is expected in inode."
6373 echo "Try 1-byte xattr instead to verify this."
6376 echo "Estimate: at most $left_size-byte space left in inode."
6382 if ! combined_mgs_mds ; then
6386 add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$stripe_cnt \
6387 --reformat $mdsdev $mdsvdev || error "add mds1 failed"
6388 start_mdt 1 > /dev/null || error "start mdt1 failed"
6389 for i in $(seq $OSTCOUNT); do
6390 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
6391 error "start ost$i failed"
6393 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
6394 check_mount || error "check client $MOUNT failed"
6397 $LFS setstripe -E 1M -S 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
6398 error "Create file with 3 components failed"
6399 $TRUNCATE $file $((1024*1024*64+1)) || error "truncate file failed"
6400 i=$($LFS getstripe -I3 -c $file) || error "get 3rd stripe count failed"
6401 if [ $i -ne $OSTCOUNT ]; then
6402 left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
6403 echo -n "Since only $i out $OSTCOUNT OSTs are used, "
6404 echo -n "the expected left space is changed to "
6405 echo "$left_size bytes at most."
6407 value=$(generate_string $left_size)
6408 setfattr -n $xtest -v $value $file
6409 orig=$(get_xattr_value $xtest $file)
6410 [[ "$orig" != "$value" ]] && error "$xtest changed"
6412 #Verify if inode has some expected space left
6413 umount $MOUNT > /dev/null || error "umount $MOUNT failed"
6414 stop_mdt 1 > /dev/null || error "stop mdt1 failed"
6415 mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
6417 do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
6418 used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
6420 [[ $used_xattr_blk -eq 0 ]] &&
6421 error "Please check MDS inode size calculation: \
6422 more than $left_size-byte space left in inode."
6423 echo "Verified: at most $left_size-byte space left in inode."
6425 unmount_ldiskfs $SINGLEMDS
6427 for i in $(seq $OSTCOUNT); do
6428 stop ost$i -f || error "stop ost$i failed"
6431 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
6434 [ "$mds1_FSTYPE" == zfs ] &&
6435 skip "LU-6662: no implementation for ZFS"
6439 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6440 --reformat $(mdsdevname 1) || error "add mds1 failed"
6442 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6443 grep -e \".*opts:.*errors=remount-ro.*\"" ||
6444 error "default mount options is missing"
6446 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
6447 --mountfsoptions="user_xattr,errors=panic" \
6448 --reformat $(mdsdevname 1) || error "add mds1 failed"
6450 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
6451 grep -e \".*opts:.*errors=panic.*\"" ||
6452 error "user can't override default mount options"
6454 run_test 88 "check the default mount options can be overridden"
6456 test_89() { # LU-7131
6457 [[ "$MDS1_VERSION" -ge $(version_code 2.9.54) ]] ||
6458 skip "Need MDT version at least 2.9.54"
6460 local key=failover.node
6461 local val1=192.0.2.254@tcp0 # Reserved IPs, see RFC 5735
6462 local val2=192.0.2.255@tcp0
6463 local mdsdev=$(mdsdevname 1)
6468 [ "$mds1_FSTYPE" == zfs ] && import_zpool mds1
6469 # Check that parameters are added correctly
6470 echo "tunefs --param $key=$val1"
6471 do_facet mds "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
6472 error "tunefs --param $key=$val1 failed"
6473 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6474 error "tunefs --dryrun failed"
6475 params=${params##*Parameters:}
6476 params=${params%%exiting*}
6477 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val1) = "1" ] ||
6478 error "on-disk parameter not added correctly via tunefs"
6480 # Check that parameters replace existing instances when added
6481 echo "tunefs --param $key=$val2"
6482 do_facet mds "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
6483 error "tunefs --param $key=$val2 failed"
6484 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6485 error "tunefs --dryrun failed"
6486 params=${params##*Parameters:}
6487 params=${params%%exiting*}
6488 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "1" ] ||
6489 error "on-disk parameter not replaced via tunefs"
6490 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val2) = "1" ] ||
6491 error "on-disk parameter not replaced correctly via tunefs"
6493 # Check that a parameter is erased properly
6494 echo "tunefs --erase-param $key"
6495 do_facet mds "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
6496 error "tunefs --erase-param $key failed"
6497 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6498 error "tunefs --dryrun failed"
6499 params=${params##*Parameters:}
6500 params=${params%%exiting*}
6501 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "0" ] ||
6502 error "on-disk parameter not erased correctly via tunefs"
6504 # Check that all the parameters are erased
6505 echo "tunefs --erase-params"
6506 do_facet mds "$TUNEFS --erase-params $mdsdev >/dev/null" ||
6507 error "tunefs --erase-params failed"
6508 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6509 error "tunefs --dryrun failed"
6510 params=${params##*Parameters:}
6511 params=${params%%exiting*}
6513 error "all on-disk parameters not erased correctly via tunefs"
6515 # Check the order of options --erase-params and --param
6516 echo "tunefs --param $key=$val1 --erase-params"
6518 "$TUNEFS --param $key=$val1 --erase-params $mdsdev >/dev/null"||
6519 error "tunefs --param $key=$val1 --erase-params failed"
6520 params=$(do_facet mds $TUNEFS --dryrun $mdsdev) ||
6521 error "tunefs --dryrun failed"
6522 params=${params##*Parameters:}
6523 params=${params%%exiting*}
6524 [ $(echo $params | tr ' ' '\n') == "$key=$val1" ] ||
6525 error "on-disk param not added correctly with --erase-params"
6529 run_test 89 "check tunefs --param and --erase-param{s} options"
6532 # $2 (optional) value of max_mod_rpcs_in_flight to set
6533 check_max_mod_rpcs_in_flight() {
6541 idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
6542 facet="mds$((0x$idx + 1))"
6544 if [ -z "$mmr" ]; then
6545 # get value of max_mod_rcps_in_flight
6546 mmr=$($LCTL get_param -n \
6547 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
6548 error "Unable to get max_mod_rpcs_in_flight"
6549 echo "max_mod_rcps_in_flight is $mmr"
6551 # set value of max_mod_rpcs_in_flight
6553 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
6554 error "Unable to set max_mod_rpcs_in_flight to $mmr"
6555 echo "max_mod_rpcs_in_flight set to $mmr"
6558 # create mmr+1 files
6559 echo "creating $((mmr + 1)) files ..."
6561 for i in $(seq $((mmr + 1))); do
6567 # consumes mmr-1 modify RPC slots
6568 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6569 # drop requests on MDT so that RPC slots are consumed
6570 # during all the request resend interval
6571 do_facet $facet "$LCTL set_param fail_loc=0x159"
6572 echo "launch $((mmr - 1)) chmod in parallel ..."
6573 for i in $(seq $((mmr - 1))); do
6574 chmod 0600 $dir/file-$i &
6578 # send one additional modify RPC
6579 do_facet $facet "$LCTL set_param fail_loc=0"
6580 echo "launch 1 additional chmod in parallel ..."
6581 chmod 0600 $dir/file-$mmr &
6584 # check this additional modify RPC get a modify RPC slot
6585 # and succeed its operation
6586 checkstat -vp 0600 $dir/file-$mmr ||
6587 error "Unable to send $mmr modify RPCs in parallel"
6592 # consumes mmr modify RPC slots
6593 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6594 # drop requests on MDT so that RPC slots are consumed
6595 # during all the request resend interval
6596 do_facet $facet "$LCTL set_param fail_loc=0x159"
6597 echo "launch $mmr chmod in parallel ..."
6598 for i in $(seq $mmr); do
6599 chmod 0666 $dir/file-$i &
6603 # send one additional modify RPC
6604 do_facet $facet "$LCTL set_param fail_loc=0"
6605 echo "launch 1 additional chmod in parallel ..."
6606 chmod 0666 $dir/file-$((mmr + 1)) &
6609 # check this additional modify RPC blocked getting a modify RPC slot
6610 checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
6611 error "Unexpectedly send $(($mmr + 1)) modify RPCs in parallel"
6618 [[ $($LCTL get_param mdc.*.import |
6619 grep "connect_flags:.*multi_mod_rpc") ]] ||
6620 skip "Need MDC with 'multi_mod_rpcs' feature"
6622 # check default value
6623 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6624 check_max_mod_rpcs_in_flight $DIR/$tdir
6628 run_test 90a "check max_mod_rpcs_in_flight is enforced"
6638 [[ $($LCTL get_param mdc.*.import |
6639 grep "connect_flags:.*multi_mod_rpc") ]] ||
6640 skip "Need MDC with 'multi_mod_rpcs' feature"
6643 # update max_mod_rpcs_in_flight
6644 $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
6645 check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
6648 # check client is able to send multiple modify RPCs in paralell
6649 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6650 grep -c "multi_mod_rpcs")
6651 if [ "$tmp" -ne $MDSCOUNT ]; then
6653 skip "Client not able to send multiple modify RPCs in parallel"
6656 # update max_mod_rpcs_in_flight
6657 $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
6658 check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
6661 $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
6662 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
6663 facet="mds$((0x$idx + 1))"
6665 # save MDT max_mod_rpcs_per_client
6666 mmrpc=$(do_facet $facet \
6667 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6669 # update max_mod_rpcs_in_flight
6670 umount_client $MOUNT
6672 "echo 16 > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6674 $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
6675 check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
6677 # restore MDT max_mod_rpcs_per_client initial value
6679 "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6681 rm -rf $DIR/${tdir}?
6684 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
6687 # get max_rpcs_in_flight value
6688 mrif_90c=$($LCTL get_param -n \
6689 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6690 echo "max_rpcs_in_flight is $mrif_90c"
6692 # get max_mod_rpcs_in_flight value
6693 mmrif_90c=$($LCTL get_param -n \
6694 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight)
6695 echo "max_mod_rpcs_in_flight is $mmrif_90c"
6697 # get MDT max_mod_rpcs_per_client value
6698 mmrpc_90c=$(do_facet mds1 \
6699 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
6700 echo "max_mod_rpcs_per_client is $mmrpc_90c"
6703 restore_params_90c() {
6706 # restore max_rpcs_in_flight value
6707 do_facet mgs $LCTL set_param -P \
6708 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
6710 # restore max_mod_rpcs_in_flight value
6711 do_facet mgs $LCTL set_param -P \
6712 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mmrif_90c
6714 # restore MDT max_mod_rpcs_per_client value
6715 do_facet mds1 "echo $mmrpc_90c > \
6716 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6724 [[ $($LCTL get_param mdc.*.import |
6725 grep "connect_flags:.*multi_mod_rpc") ]] ||
6726 skip "Need MDC with 'multi_mod_rpcs' feature"
6728 # check client is able to send multiple modify RPCs in paralell
6729 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
6730 grep -c "multi_mod_rpcs")
6731 if [ "$tmp" -ne $MDSCOUNT ]; then
6733 skip "Client not able to send multiple modify RPCs in parallel"
6737 stack_trap restore_params_90c
6740 # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
6741 # prerequisite: set max_mod_rpcs_per_client to max_rpcs_in_flight value
6742 do_facet mds1 "echo $mrif_90c > \
6743 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6745 # if max_mod_rpcs_in_flight is set to be equal to or larger than
6746 # max_rpcs_in_flight, then max_rpcs_in_flight will be increased
6747 if [[ "$CLIENT_VERSION" -ge $(version_code 2.13.53) ]]; then
6749 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c ||
6750 error "set max_mod_rpcs_in_flight to $mrif_90c failed"
6752 local new_mrif=$($LCTL get_param -n \
6753 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
6754 ((new_mrif == mrif_90c + 1)) ||
6755 error "max_rpcs_in_flight was not increased"
6758 umount_client $MOUNT
6759 do_facet mds1 "echo $mmrpc_90c > \
6760 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
6764 # attempt to set max_mod_rpcs_in_flight to max_mod_rpcs_per_client+1
6765 # prerequisite: set max_rpcs_in_flight to max_mod_rpcs_per_client+2
6767 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc_90c + 2))
6770 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc_90c + 1)) &&
6771 error "set max_mod_rpcs_in_flight to $((mmrpc_90c + 1)) should fail"
6774 # attempt to set max_mod_rpcs_in_flight permanently
6775 do_facet mgs $LCTL set_param -P \
6776 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
6778 do_facet mgs $LCTL set_param -P \
6779 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c
6781 remount_client $MOUNT
6783 wait_update_facet --verbose client "$LCTL get_param -n \
6784 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight" \
6785 "$((mrif_90c + 1))" ||
6786 error "expected '$((mrif_90c + 1))' for max_rpcs_in_flight"
6788 wait_update_facet --verbose client "$LCTL get_param -n \
6789 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight" \
6791 error "expected '$mrif_90c' for max_mod_rpcs_in_flight"
6796 run_test 90c "check max_mod_rpcs_in_flight update limits"
6807 [[ $($LCTL get_param mdc.*.import |
6808 grep "connect_flags:.*multi_mod_rpc") ]] ||
6809 skip "Need MDC with 'multi_mod_rpcs' feature"
6811 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6812 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
6813 facet="mds$((0x$idx + 1))"
6815 # check client version supports multislots
6816 tmp=$($LCTL get_param -N \
6817 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6818 if [ -z "$tmp" ]; then
6820 skip "Client does not support multiple modify RPCs in flight"
6823 # get current value of max_mod_rcps_in_flight
6824 mmr=$($LCTL get_param -n \
6825 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
6826 echo "max_mod_rcps_in_flight is $mmr"
6829 echo "creating $mmr files ..."
6831 for i in $(seq $mmr); do
6832 touch $DIR/$tdir/file-$i
6835 # prepare for close RPC
6836 multiop_bg_pause $DIR/$tdir/file-close O_c
6839 # consumes mmr modify RPC slots
6840 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
6841 # drop requests on MDT so that RPC slots are consumed
6842 # during all the request resend interval
6843 do_facet $facet "$LCTL set_param fail_loc=0x159"
6844 echo "launch $mmr chmod in parallel ..."
6845 for i in $(seq $mmr); do
6846 chmod 0600 $DIR/$tdir/file-$i &
6849 # send one additional close RPC
6850 do_facet $facet "$LCTL set_param fail_loc=0"
6851 echo "launch 1 additional close in parallel ..."
6853 cancel_lru_locks mdc
6856 # check this additional close RPC get a modify RPC slot
6857 # and multiop process completed
6858 [ -d /proc/$pid ] &&
6859 error "Unable to send the additional close RPC in parallel"
6864 run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
6866 check_uuid_on_ost() {
6868 do_facet ost1 "$LCTL get_param obdfilter.${FSNAME}*.exports.'$nid'.uuid"
6871 check_uuid_on_mdt() {
6873 do_facet $SINGLEMDS "$LCTL get_param mdt.${mds1_svc}*.exports.'$nid'.uuid"
6881 [[ "$OST1_VERSION" -ge $(version_code 2.7.63) ]] ||
6882 skip "Need OST version at least 2.7.63"
6883 [[ "$MDS1_VERSION" -ge $(version_code 2.7.63) ]] ||
6884 skip "Need MDT version at least 2.7.63"
6886 start_mds || error "MDS start failed"
6887 start_ost || error "unable to start OST"
6888 mount_client $MOUNT || error "client start failed"
6889 check_mount || error "check_mount failed"
6892 nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
6896 uuid=$(get_client_uuid $MOUNT)
6898 echo "list nids on mdt:"
6899 do_facet $SINGLEMDS "$LCTL list_param mdt.${FSNAME}*.exports.*"
6900 echo "uuid from $nid:"
6901 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
6903 found=$(check_uuid_on_mdt $nid | grep $uuid)
6904 [ -z "$found" ] && error "can't find $uuid $nid on MDT"
6905 found=$(check_uuid_on_ost $nid | grep $uuid)
6906 [ -z "$found" ] && error "can't find $uuid $nid on OST"
6908 # umount the client so it won't reconnect
6909 manual_umount_client --force || error "failed to umount $?"
6910 # shouldn't disappear on MDS after forced umount
6911 found=$(check_uuid_on_mdt $nid | grep $uuid)
6912 [ -z "$found" ] && error "can't find $uuid $nid"
6915 do_facet $SINGLEMDS \
6916 "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
6917 sleep 1 # eviction above is async, give it some time to proceed
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 101a "Race MDT->OST reconnection with create"
7470 local dev=$FSNAME-OST0000-osc-MDT0000
7471 local dir=$DIR1/$tdir
7475 $LFS setstripe -c 1 -i 0 $dir
7476 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;"
7477 #define OBD_FAIL_OSP_CON_EVENT_DELAY 0x2107
7478 do_facet mds1 "$LCTL set_param fail_loc=0x80002107 fail_val=20"
7479 do_facet $SINGLEMDS "$LCTL --device $dev activate;"
7484 wait_osc_import_state client ost1 FULL
7485 touch $dir/$tfile || error "Can't create file"
7489 run_test 101b "Race events DISCONNECT and ACTIVE in osp"
7492 [[ "$MDS1_VERSION" -gt $(version_code 2.9.53) ]] ||
7493 skip "Need server version greater than 2.9.53"
7494 [[ “$(mdsdevname 1)” != “$(mgsdevname)” ]] &&
7495 [[ “$(facet_host mds1)” = “$(facet_host mgs)” ]] &&
7496 skip "MGS must be on different node or combined"
7498 cleanup || error "cleanup failed with $?"
7500 local mds1dev=$(mdsdevname 1)
7501 local mds1mnt=$(facet_mntpt mds1)
7502 local mds1opts=$MDS_MOUNT_OPTS
7504 if [ "$mds1_FSTYPE" == ldiskfs ] &&
7505 ! do_facet mds1 test -b $mds1dev; then
7506 mds1opts=$(csa_add "$mds1opts" -o loop)
7508 if [[ "$mds1_FSTYPE" == zfs ]]; then
7509 import_zpool mds1 || return ${PIPESTATUS[0]}
7512 # unload all and only load libcfs to allow fail_loc setting
7513 do_facet mds1 $LUSTRE_RMMOD || error "unable to unload modules"
7514 do_facet mds1 modprobe libcfs || error "libcfs not loaded"
7515 do_facet mds1 lsmod \| grep libcfs || error "libcfs not loaded"
7517 #define OBD_FAIL_OBDCLASS_MODULE_LOAD 0x60a
7518 do_facet mds1 "$LCTL set_param fail_loc=0x8000060a"
7520 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
7521 error "mdt start must fail"
7522 do_facet mds1 lsmod \| grep obdclass && error "obdclass must not load"
7524 do_facet mds1 "$LCTL set_param fail_loc=0x0"
7526 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts ||
7527 error "mdt start must not fail"
7529 cleanup || error "cleanup failed with $?"
7531 run_test 102 "obdclass module cleanup upon error"
7536 echo "rename $FSNAME to $newname"
7538 if ! combined_mgs_mds ; then
7539 local dev=$(mgsdevname)
7542 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7543 error "(7) Fail to rename MGS"
7544 if [ "$(facet_fstype mgs)" = "zfs" ]; then
7545 reimport_zpool mgs $newname-mgs
7549 for num in $(seq $MDSCOUNT); do
7550 local dev=$(mdsdevname $num)
7552 do_facet mds${num} \
7553 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7554 error "(8) Fail to rename MDT $num"
7555 if [ "$(facet_fstype mds${num})" = "zfs" ]; then
7556 reimport_zpool mds${num} $newname-mdt${num}
7560 for num in $(seq $OSTCOUNT); do
7561 local dev=$(ostdevname $num)
7563 do_facet ost${num} \
7564 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
7565 error "(9) Fail to rename OST $num"
7566 if [ "$(facet_fstype ost${num})" = "zfs" ]; then
7567 reimport_zpool ost${num} $newname-ost${num}
7572 test_103_set_pool() {
7576 do_facet mgs $LCTL pool_add $FSNAME.$pname ${FSNAME}-$ost_x ||
7577 error "Fail to add $ost_x to $FSNAME.$pname"
7578 wait_update $HOSTNAME \
7579 "lctl get_param -n lov.$FSNAME-clilov-*.pools.$pname |
7580 grep $ost_x" "$FSNAME-${ost_x}_UUID" ||
7581 error "$ost_x is NOT in pool $FSNAME.$pname"
7584 test_103_check_pool() {
7585 local save_fsname=$1
7588 stat $DIR/$tdir/test-framework.sh ||
7589 error "($errno) Fail to stat"
7590 do_facet mgs $LCTL pool_list $FSNAME.pool1 ||
7591 error "($errno) Fail to list $FSNAME.pool1"
7592 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname ||
7593 error "($errno) Fail to list $FSNAME.$save_fsname"
7594 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname |
7595 grep ${FSNAME}-OST0000 ||
7596 error "($errno) List $FSNAME.$save_fsname is invalid"
7598 local pname=$($LFS getstripe --pool $DIR/$tdir/d0)
7599 [ "$pname" = "$save_fsname" ] ||
7600 error "($errno) Unexpected pool name $pname"
7604 check_mount_and_prep
7606 mkdir $DIR/$tdir || error "(1) Fail to mkdir $DIR/$tdir"
7607 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir ||
7608 error "(2) Fail to copy test-framework.sh"
7610 do_facet mgs $LCTL pool_new $FSNAME.pool1 ||
7611 error "(3) Fail to create $FSNAME.pool1"
7612 # name the pool name as the fsname
7613 do_facet mgs $LCTL pool_new $FSNAME.$FSNAME ||
7614 error "(4) Fail to create $FSNAME.$FSNAME"
7616 test_103_set_pool $FSNAME OST0000
7618 $LFS setstripe -p $FSNAME $DIR/$tdir/d0 ||
7619 error "(6) Fail to setstripe on $DIR/$tdir/d0"
7624 test_renamefs mylustre
7626 local save_fsname=$FSNAME
7630 test_103_check_pool $save_fsname 7
7632 if [ $OSTCOUNT -ge 2 ]; then
7633 test_103_set_pool $save_fsname OST0001
7636 $LFS setstripe -p $save_fsname $DIR/$tdir/f0 ||
7637 error "(16) Fail to setstripe on $DIR/$tdir/f0"
7646 test_103_check_pool $save_fsname 17
7650 test_renamefs $save_fsname
7656 run_test 103 "rename filesystem name"
7658 test_104a() { # LU-6952
7659 local mds_mountopts=$MDS_MOUNT_OPTS
7660 local ost_mountopts=$OST_MOUNT_OPTS
7661 local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
7662 local lctl_ver=$(do_facet $SINGLEMDS $LCTL --version |
7665 [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
7666 skip "this test needs utils above 2.9.55"
7668 # specify "acl" in mount options used by mkfs.lustre
7669 if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
7670 MDS_MOUNT_FS_OPTS="acl,user_xattr"
7673 MDS_MOUNT_FS_OPTS="${MDS_MOUNT_FS_OPTS},acl,user_xattr"
7676 echo "mountfsopt: $MDS_MOUNT_FS_OPTS"
7678 #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
7680 if ! combined_mgs_mds ; then
7684 if [ -z "$MDS_MOUNT_OPTS" ]; then
7685 MDS_MOUNT_OPTS="-o noacl"
7687 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7690 for num in $(seq $MDSCOUNT); do
7691 start mds$num $(mdsdevname $num) $MDS_MOUNT_OPTS ||
7692 error "Failed to start MDS"
7695 for num in $(seq $OSTCOUNT); do
7696 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
7697 error "Failed to start OST"
7701 setfacl -m "d:$RUNAS_ID:rwx" $MOUNT &&
7702 error "ACL is applied when FS is mounted with noacl."
7704 MDS_MOUNT_OPTS=$mds_mountopts
7705 OST_MOUNT_OPTS=$ost_mountopts
7706 MDS_MOUNT_FS_OPTS=$mds_mountfsopts
7708 run_test 104a "Make sure user defined options are reflected in mount"
7710 test_104b() { # LU-12859
7711 mount_client $MOUNT3 flock,localflock
7712 stack_trap "umount_client $MOUNT3" EXIT
7713 mount | grep "$MOUNT3 .*,flock" && error "flock is still set"
7714 mount | grep "$MOUNT3 .*,localflock" || error "localflock is not set"
7715 umount_client $MOUNT3
7716 mount_client $MOUNT3 localflock,flock
7717 mount | grep "$MOUNT3 .*,localflock" && error "localflock is still set"
7718 mount | grep "$MOUNT3 .*,flock" || error "flock is not set"
7719 umount_client $MOUNT3
7720 mount_client $MOUNT3 localflock,flock,noflock
7721 flock_is_enabled $MOUNT3 && error "some flock is still enabled" || true
7723 run_test 104b "Mount uses last flock argument"
7725 error_and_umount() {
7736 mount --bind $DIR $TMP/$tdir || error "mount bind mnt pt failed"
7737 rm -f $TMP/$tdir/$tfile
7738 rm -f $TMP/$tdir/${tfile}1
7740 # Files should not be created in ro bind mount point
7741 # remounting from rw to ro
7742 mount -o remount,ro $TMP/$tdir ||
7743 error_and_umount "readonly remount of bind mnt pt failed"
7744 touch $TMP/$tdir/$tfile &&
7745 error_and_umount "touch succeeds on ro bind mnt pt"
7746 [ -e $TMP/$tdir/$tfile ] &&
7747 error_and_umount "file created on ro bind mnt pt"
7749 # Files should be created in rw bind mount point
7750 # remounting from ro to rw
7751 mount -o remount,rw $TMP/$tdir ||
7752 error_and_umount "read-write remount of bind mnt pt failed"
7753 touch $TMP/$tdir/${tfile}1 ||
7754 error_and_umount "touch fails on rw bind mnt pt"
7755 [ -e $TMP/$tdir/${tfile}1 ] ||
7756 error_and_umount "file not created on rw bind mnt pt"
7757 umount $TMP/$tdir || error "umount of bind mnt pt failed"
7759 cleanup || error "cleanup failed with $?"
7761 run_test 105 "check file creation for ro and rw bind mnt pt"
7768 mkdir -p $DIR/$tdir || error "create $tdir failed"
7769 lfs setstripe -c 1 -i 0 $DIR/$tdir
7770 #define OBD_FAIL_CAT_RECORDS 0x1312
7771 do_facet mds1 $LCTL set_param fail_loc=0x1312 fail_val=$repeat
7773 for ((i = 1; i <= $repeat; i++)); do
7775 #one full plain llog
7776 createmany -o $DIR/$tdir/f- 64768
7778 createmany -u $DIR/$tdir/f- 64768
7780 wait_delete_completed $((TIMEOUT * 7))
7781 #ASSERTION osp_sync_thread() ( thread->t_flags != SVC_RUNNING ) failed
7782 #shows that osp code is buggy
7783 do_facet mds1 $LCTL set_param fail_loc=0 fail_val=0
7787 run_test 106 "check osp llog processing when catalog is wrapped"
7790 [[ "$MDS1_VERSION" -ge $(version_code 2.10.50) ]] ||
7791 skip "Need MDS version > 2.10.50"
7794 start_mgsmds || error "start_mgsmds failed"
7795 start_ost || error "unable to start OST"
7797 # add unknown configuration parameter.
7798 if [[ $PERM_CMD == *"set_param -P"* ]]; then
7799 cmd="$PERM_CMD ost.$FSNAME-OST0000*.unknown_param"
7801 cmd="$PERM_CMD $FSNAME-OST0000*.ost.unknown_param"
7803 do_facet mgs "$cmd=50"
7804 cleanup_nocli || error "cleanup_nocli failed with $?"
7807 # unknown param should be ignored while mounting.
7808 start_ost || error "unable to start OST after unknown param set"
7810 cleanup || error "cleanup failed with $?"
7812 run_test 107 "Unknown config param should not fail target mounting"
7817 $rcmd rm -rf $tmp > /dev/null 2>&1
7818 $rcmd mkdir -p $tmp/{mnt,images} || error "failed to mkdir remotely"
7820 for facet in $facets; do
7821 [ "$mds1_FSTYPE" = zfs ] &&
7822 $rcmd $ZPOOL -f export lustre-$facet > /dev/null 2>&1
7823 $rcmd mkdir $tmp/mnt/$facet ||
7824 error "failed to mkdir $tmp/mnt/$facet"
7825 $rcmd dd if=/dev/zero of=$tmp/images/$facet \
7826 seek=199 bs=1M count=1 ||
7827 error "failed to create $tmp/images/$facet"
7836 local facet=${role}$((idx + 1))
7838 [ $# -eq 5 ] && pool=$5
7840 do_facet $SINGLEMDS $MKFS --fsname=lustre --$mgs \
7841 --$role --index=$idx --replace --backfstype=$bkfs \
7842 --device-size=200000 --reformat $pool $tmp/images/$facet ||
7843 error "failed to mkfs for $facet"
7847 echo "mounting client..."
7848 mount -t lustre ${nid}:/lustre $MOUNT ||
7849 error "failed to mount lustre"
7852 ls -l $MOUNT/local_dir || error "failed to list"
7854 echo "check truncate && write"
7855 echo "dummmmmmmmmmmmm" > $MOUNT/remote_dir/fsx.c ||
7856 error "failed to tuncate & write"
7859 touch $MOUNT/foooo ||
7860 error "failed to create"
7862 echo "check read && write && append"
7863 sha1sum $MOUNT/conf-sanity.sh |
7864 awk '{ print $1 }' > $MOUNT/checksum.new ||
7865 error "failed to read(1)"
7866 sha1sum $MOUNT/remote_dir/unlinkmany.c |
7867 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7868 error "failed to read(2)"
7869 sha1sum $MOUNT/striped_dir/lockahead_test.o |
7870 awk '{ print $1 }' >> $MOUNT/checksum.new ||
7871 error "failed to read(3)"
7874 diff $MOUNT/checksum.new $MOUNT/checksum.src ||
7875 error "failed to verify data"
7885 umount -f $MOUNT || error "failed to umount client"
7886 for facet in $facets; do
7887 $rcmd umount -f $tmp/mnt/$facet ||
7888 error "failed to umount $facet"
7889 if [ "$mds1_FSTYPE" = zfs ]; then
7890 $rcmd $ZPOOL export -f lustre-$facet ||
7891 error "failed to export lustre-$facet"
7895 $rcmd rm -rf $tmp || error "failed to rm the dir $tmp"
7899 [ "$CLIENTONLY" ] && skip "Client-only testing"
7900 [ "$mds1_FSTYPE" != zfs ] && skip "zfs only test"
7901 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
7902 skip "Need server version at least 2.10.58"
7907 local tmp=$TMP/$tdir
7908 local rcmd="do_facet $SINGLEMDS"
7909 local facets="mdt1 mdt2 ost1 ost2"
7910 local nid=$($rcmd $LCTL list_nids | head -1)
7913 trap t_108_cleanup EXIT ERR
7916 t_108_mkfs mdt 0 zfs mgs lustre-mdt1/mdt1
7917 t_108_mkfs mdt 1 zfs mgsnode=$nid lustre-mdt2/mdt2
7918 t_108_mkfs ost 0 zfs mgsnode=$nid lustre-ost1/ost1
7919 t_108_mkfs ost 1 zfs mgsnode=$nid lustre-ost2/ost2
7921 for facet in $facets; do
7922 $rcmd zfs set mountpoint=$tmp/mnt/$facet canmount=on \
7923 lustre-$facet/$facet ||
7924 error "failed to zfs set for $facet (1)"
7925 $rcmd zfs mount lustre-$facet/$facet ||
7926 error "failed to local mount $facet"
7927 $rcmd tar jxf $LUSTRE/tests/ldiskfs_${facet}_2_11.tar.bz2 \
7928 --xattrs --xattrs-include="trusted.*" \
7929 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7930 error "failed to untar image for $facet"
7931 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7932 error "failed to cleanup for $facet"
7933 $rcmd zfs umount lustre-$facet/$facet ||
7934 error "failed to local umount $facet"
7935 $rcmd zfs set canmount=off lustre-$facet/$facet ||
7936 error "failed to zfs set $facet (2)"
7939 echo "changing server nid..."
7940 $rcmd mount -t lustre -o nosvc lustre-mdt1/mdt1 $tmp/mnt/mdt1
7941 $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
7942 $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
7943 $rcmd lctl replace_nids $FSNAME-OST0000 $nid
7944 $rcmd lctl replace_nids $FSNAME-OST0001 $nid
7945 $rcmd umount $tmp/mnt/mdt1
7947 for facet in $facets; do
7948 echo "mounting $facet from backup..."
7949 $rcmd mount -t lustre -o abort_recov lustre-$facet/$facet \
7950 $tmp/mnt/$facet || error "failed to mount $facet"
7953 # ZFS backend can detect migration and trigger OI scrub automatically
7954 # sleep 3 seconds for scrub done
7960 run_test 108a "migrate from ldiskfs to ZFS"
7963 [ "$CLIENTONLY" ] && skip "Client-only testing"
7964 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
7965 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
7966 skip "Need server version at least 2.10.58"
7971 local tmp=$TMP/$tdir
7972 local rcmd="do_facet $SINGLEMDS"
7973 local facets="mdt1 mdt2 ost1 ost2"
7974 local scrub_list="MDT0000 MDT0001 OST0000 OST0001"
7975 local nid=$($rcmd $LCTL list_nids | head -1)
7978 trap t_108_cleanup EXIT ERR
7981 t_108_mkfs mdt 0 ldiskfs mgs
7982 t_108_mkfs mdt 1 ldiskfs mgsnode=$nid
7983 t_108_mkfs ost 0 ldiskfs mgsnode=$nid
7984 t_108_mkfs ost 1 ldiskfs mgsnode=$nid
7986 for facet in $facets; do
7987 $rcmd mount -t ldiskfs -o loop $tmp/images/$facet \
7989 error "failed to local mount $facet"
7991 $rcmd tar jxf $LUSTRE/tests/zfs_${facet}_2_11.tar.bz2 \
7992 --xattrs --xattrs-include="*.*" \
7993 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
7994 error "failed to untar image for $facet"
7995 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
7996 error "failed to cleanup for $facet"
7997 $rcmd umount $tmp/mnt/$facet ||
7998 error "failed to local umount $facet"
8001 echo "changing server nid..."
8002 $rcmd mount -t lustre -o nosvc,loop $tmp/images/mdt1 $tmp/mnt/mdt1
8003 $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
8004 $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
8005 $rcmd lctl replace_nids $FSNAME-OST0000 $nid
8006 $rcmd lctl replace_nids $FSNAME-OST0001 $nid
8007 $rcmd umount $tmp/mnt/mdt1
8009 for facet in $facets; do
8010 echo "mounting $facet from backup..."
8011 $rcmd mount -t lustre -o loop,abort_recov $tmp/images/$facet \
8012 $tmp/mnt/$facet || error "failed to mount $facet"
8015 for facet in $scrub_list; do
8016 $rcmd $LCTL lfsck_start -M $FSNAME-$facet -t scrub ||
8017 error "failed to start OI scrub on $facet"
8020 # sleep 3 seconds for scrub done
8026 run_test 108b "migrate from ZFS to ldiskfs"
8030 # set number of permanent parameters
8032 test_109_set_params() {
8035 set_persistent_param_and_check mds \
8036 "mdd.$fsname-MDT0000.atime_diff" \
8037 "$fsname-MDT0000.mdd.atime_diff" \
8039 set_persistent_param_and_check mds \
8040 "mdd.$fsname-MDT0000.atime_diff" \
8041 "$fsname-MDT0000.mdd.atime_diff" \
8043 set_persistent_param_and_check client \
8044 "llite.$fsname*.max_read_ahead_mb" \
8045 "$fsname.llite.max_read_ahead_mb" \
8047 set_persistent_param_and_check client \
8048 "llite.$fsname*.max_read_ahead_mb" \
8049 "$fsname.llite.max_read_ahead_mb" \
8051 create_pool $fsname.pool1 || error "create pool failed"
8052 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
8053 error "pool_add failed"
8054 do_facet mgs $LCTL pool_remove $fsname.pool1 OST0000 ||
8055 error "pool_remove failed"
8056 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
8057 error "pool_add failed"
8061 # check permanent parameters
8063 test_109_test_params() {
8066 local atime_diff=$(do_facet mds $LCTL \
8067 get_param -n mdd.$fsname-MDT0000.atime_diff)
8068 [ $atime_diff == 63 ] || error "wrong mdd parameter after clear_conf"
8069 local max_read_ahead_mb=$(do_facet client $LCTL \
8070 get_param -n llite.$fsname*.max_read_ahead_mb)
8071 [ $max_read_ahead_mb == 64 ] ||
8072 error "wrong llite parameter after clear_conf"
8073 local ost_in_pool=$(do_facet mds $LCTL pool_list $fsname.pool1 |
8074 grep -v "^Pool:" | sed 's/_UUID//')
8075 [ $ost_in_pool = "$fsname-OST0000" ] ||
8076 error "wrong pool after clear_conf"
8080 # run lctl clear_conf, store CONFIGS before and after that
8082 test_109_clear_conf()
8084 local clear_conf_arg=$1
8087 if ! combined_mgs_mds ; then
8088 mgsdev=$(mgsdevname)
8089 stop_mgs || error "stop_mgs failed"
8090 start_mgs "-o nosvc" || error "start_mgs nosvc failed"
8092 mgsdev=$(mdsdevname 1)
8093 start_mdt 1 "-o nosvc" || error "start_mdt 1 nosvc failed"
8096 do_facet mgs "rm -rf $TMP/${tdir}/conf1; mkdir -p $TMP/${tdir}/conf1;" \
8097 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf1\\\" \
8101 # the command being tested
8103 do_facet mgs $LCTL clear_conf $clear_conf_arg ||
8104 error "clear_conf failed"
8105 if ! combined_mgs_mds ; then
8106 stop_mgs || error "stop_mgs failed"
8108 stop_mdt 1 || error "stop_mdt 1 failed"
8111 do_facet mgs "rm -rf $TMP/${tdir}/conf2; mkdir -p $TMP/${tdir}/conf2;" \
8112 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf2\\\" \
8116 test_109_file_shortened() {
8118 local sizes=($(do_facet mgs "stat -c %s " \
8119 "$TMP/${tdir}/conf1/CONFIGS/$file" \
8120 "$TMP/${tdir}/conf2/CONFIGS/$file"))
8121 [ ${sizes[1]} -lt ${sizes[0]} ] && return 0
8127 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
8128 skip "Needs MDS version 2.10.59 or later."
8129 [ "$(facet_fstype mgs)" == zfs ] &&
8130 skip "LU-8727: no implementation for ZFS"
8135 client_up || error "client_up failed"
8138 # set number of permanent parameters
8140 test_109_set_params $FSNAME
8142 umount_client $MOUNT || error "umount_client failed"
8143 stop_ost || error "stop_ost failed"
8144 stop_mds || error "stop_mds failed"
8146 test_109_clear_conf $FSNAME
8148 # make sure that all configs are cleared
8150 test_109_file_shortened $FSNAME-MDT0000 ||
8151 error "failed to clear MDT0000 config"
8152 test_109_file_shortened $FSNAME-client ||
8153 error "failed to clear client config"
8158 # check that configurations are intact
8160 test_109_test_params $FSNAME
8165 destroy_test_pools || error "destroy test pools failed"
8169 run_test 109a "test lctl clear_conf fsname"
8173 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
8174 skip "Needs MDS version 2.10.59 or later."
8175 [ "$(facet_fstype mgs)" == zfs ] &&
8176 skip "LU-8727: no implementation for ZFS"
8181 client_up || error "client_up failed"
8184 # set number of permanent parameters
8186 test_109_set_params $FSNAME
8188 umount_client $MOUNT || error "umount_client failed"
8189 stop_ost || error "stop_ost failed"
8190 stop_mds || error "stop_mds failed"
8192 test_109_clear_conf $FSNAME-MDT0000
8194 # make sure that only one config is cleared
8196 test_109_file_shortened $FSNAME-MDT0000 ||
8197 error "failed to clear MDT0000 config"
8198 test_109_file_shortened $FSNAME-client &&
8199 error "failed to clear client config"
8203 # check that configurations are intact
8205 test_109_test_params $FSNAME
8210 destroy_test_pools || error "destroy test pools failed"
8214 run_test 109b "test lctl clear_conf one config"
8218 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
8219 skip "Only applicable to ldiskfs-based MDTs"
8221 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8222 skip "large_dir option is not supported on MDS"
8223 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8224 skip "large_dir option is not supported on OSS"
8226 stopall # stop all targets before modifying the target counts
8227 local old_mdscount=$MDSCOUNT
8228 local old_ostcount=$OSTCOUNT
8230 stack_trap "MDSCOUNT=$old_mdscount OSTCOUNT=$old_ostcount" EXIT
8234 # ext4_dir_entry_2 struct size:264
8235 # dx_root struct size:8
8236 # dx_node struct size:8
8237 # dx_entry struct size:8
8238 # For 1024 bytes block size.
8239 # First level directory entries: 126
8240 # Second level directory entries: 127
8241 # Entries in leaf: 3
8242 # For 2 levels limit: 48006
8243 # For 3 levels limit : 6096762
8244 # Create 80000 files to safely exceed 2-level htree limit.
8245 CONF_SANITY_110_LINKS=${CONF_SANITY_110_LINKS:-80000}
8247 # can fit at most 3 filenames per 1KB leaf block, but each
8248 # leaf/index block will only be 3/4 full before split at each level
8249 (( MDSSIZE < CONF_SANITY_110_LINKS / 3 * 4/3 * 4/3 )) &&
8250 CONF_SANITY_110_LINKS=$((MDSSIZE * 3 * 3/4 * 3/4))
8252 combined_mgs_mds || replace=" --replace "
8253 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8254 $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8255 if [[ $opts != *large_dir* ]]; then
8256 if [[ $opts != *mkfsoptions* ]]; then
8257 opts+=" --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536\\\""
8259 opts="${opts//--mkfsoptions=\\\"/ \
8260 --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536 }"
8263 echo "MDT params: $opts"
8265 combined_mgs_mds || start_mgs
8266 add mds1 $opts || error "add mds1 failed with new params"
8267 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8269 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8270 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
8272 if [[ $opts != *large_dir* ]]; then
8273 if [[ $opts != *mkfsoptions* ]]; then
8274 opts+=" --mkfsoptions=\\\"-O large_dir\\\" "
8276 opts="${opts//--mkfsoptions=\\\"/ \
8277 --mkfsoptions=\\\"-O large_dir }"
8280 echo "OST params: $opts"
8281 add ost1 $opts || error "add ost1 failed with new params"
8282 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8284 MOUNT_2=yes mountcli || error "mount clients failed"
8286 mkdir -v $DIR/$tdir || error "cannot create $DIR/$tdir"
8287 local pids count=0 group=0
8289 echo "creating $CONF_SANITY_110_LINKS in total"
8290 while (( count < CONF_SANITY_110_LINKS )); do
8291 local len=$((253 - $(wc -c <<<"$tfile-$group-40000-")))
8292 local dir=DIR$((group % 2 + 1))
8293 local target=${!dir}/$tdir/$tfile-$group
8294 local long=$target-$(generate_name $len)-
8295 local create=$((CONF_SANITY_110_LINKS - count))
8297 (( create > 40000 )) && create=40000
8298 touch $target || error "creating $target failed"
8299 echo "creating $create hard links to $target"
8300 createmany -l $target $long $create &
8303 count=$((count + create))
8304 group=$((group + 1))
8306 echo "waiting for PIDs$pids to complete"
8307 wait $pids || error "createmany failed after $group groups"
8309 umount_client $MOUNT2 -f
8312 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8313 MDSCOUNT=$old_mdscount
8314 OSTCOUNT=$old_ostcount
8316 run_test 110 "Adding large_dir with 3-level htree"
8319 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
8320 skip "Only applicable to ldiskfs-based MDTs"
8322 is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
8323 skip "This test can not be executed on flakey dev"
8325 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
8326 skip "large_dir option is not supported on MDS"
8328 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
8329 skip "large_dir option is not supported on OSS"
8331 # cleanup before changing target counts
8333 local old_mdscount=$MDSCOUNT
8334 local old_ostcount=$OSTCOUNT
8335 local old_mdssize=$MDSSIZE
8337 stack_trap "MDSSIZE=$MDSSIZE MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT" EXIT
8340 (( MDSSIZE < 2400000 )) && MDSSIZE=2400000 # need at least 2.4GB
8342 local mdsdev=$(mdsdevname 1)
8343 combined_mgs_mds || replace=" --replace "
8344 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8345 $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
8346 if [[ $opts != *large_dir* ]]; then
8347 if [[ $opts != *mkfsoptions* ]]; then
8348 opts+=" --mkfsoptions=\\\"-O large_dir -i 1048576 \\\" "
8350 opts="${opts//--mkfsoptions=\\\"/ \
8351 --mkfsoptions=\\\"-O large_dir -i 1048576 }"
8354 echo "MDT params: $opts"
8356 combined_mgs_mds || start_mgs
8357 __touch_device mds 1
8358 add mds1 $opts || error "add mds1 failed with new params"
8359 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
8361 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8362 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
8363 if [[ $opts != *large_dir* ]]; then
8364 if [[ $opts != *mkfsoptions* ]]; then
8365 opts+=" --mkfsoptions=\\\"-O large_dir \\\""
8367 opts="${opts//--mkfsoptions=\\\"/ --mkfsoptions=\\\"-O large_dir }"
8370 echo "OST params: $opts"
8371 __touch_device ost 1
8372 add ost1 $opts || error "add ost1 failed with new params"
8373 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
8375 MOUNT_2=yes mountcli
8376 mkdir $DIR/$tdir || error "cannot create $DIR/$tdir"
8378 lfs df -i $DIR/$tdir
8382 local start=$SECONDS
8384 local dirmax=$((2 << 30))
8390 while (( !needskip & dirsize < dirmax )); do
8393 for cli in ${CLIENTS//,/ }; do
8394 local len=$((253 - $(wc -c <<<"$cli-$group-60000-")))
8395 local target=$cli-$group
8396 local long=$DIR/$tdir/$target-$(generate_name $len)-
8398 RPWD=$DIR/$tdir do_node $cli touch $target ||
8399 error "creating $target failed"
8400 echo "creating 60000 hardlinks to $target"
8401 RPWD=$DIR/$tdir do_node $cli createmany -l $target $long 60000 &
8404 group=$((group + 1))
8406 long=$DIR2/$tdir/$target-$(generate_name $len)-
8408 RPWD=$DIR2/$tdir do_node $cli touch $target ||
8409 error "creating $target failed"
8410 echo "creating 60000 hardlinks to $target"
8411 RPWD=$DIR2/$tdir do_node $cli createmany -l $target $long 60000 &
8414 group=$((group + 1))
8416 echo "waiting for PIDs$pids to complete"
8417 wait $pids || error "createmany failed after $group groups"
8418 dirsize=$(stat -c %s $DIR/$tdir)
8419 taken=$((SECONDS - start))
8420 rate=$((dirsize / taken))
8421 left=$(((dirmax - dirsize) / rate))
8422 num=$((group * 60000))
8423 echo "estimate ${left}s left after $num files / ${taken}s"
8424 # if the estimated time remaining is too large (it may change
8425 # over time as the create rate is not constant) then exit
8426 # without declaring a failure.
8427 (( left > 1200 )) && needskip=1
8430 umount_client $MOUNT2 -f
8433 (( $needskip )) && skip "ETA ${left}s after $num files / ${taken}s is too long"
8435 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
8436 MDSCOUNT=$old_mdscount
8437 OSTCOUNT=$old_ostcount
8438 MDSSIZE=$old_mdssize
8440 run_test 111 "Adding large_dir with over 2GB directory"
8443 start_mds || error "MDS start failed"
8444 start_ost || error "OSS start failed"
8445 echo "start ost2 service on $(facet_active_host ost2)"
8446 start ost2 $(ostdevname 2) $(csa_add "$OST_MOUNT_OPTS" -o no_precreate) ||
8447 error "start ost2 facet failed"
8448 local val=$(do_facet ost2 \
8449 "$LCTL get_param -n obdfilter.$FSNAME-OST0001*.no_precreate")
8450 (( $val == 1 )) || error "obdfilter.$FSNAME-OST0001*.no_precreate=$val"
8452 mount_client $MOUNT || error "mount client failed"
8453 wait_osc_import_state mds1 ost1 FULL
8454 wait_osc_import_state client ost1 FULL
8455 wait_osc_import_state client ost2 FULL
8457 $LFS setstripe -i 0 $DIR/$tfile.0 ||
8458 error "problem creating $tfile.0 on OST0000"
8459 $LFS setstripe -i 1 $DIR/$tfile.1 && $LFS getstripe $DIR/$tfile.1 &&
8460 (( $($LFS getstripe -i $DIR/$tfile.1) == 1 )) &&
8461 error "allowed to create $tfile.1 on OST0001"
8462 do_facet ost2 $LCTL set_param obdfilter.*.no_precreate=0
8464 $LFS setstripe -i 1 $DIR/$tfile.2 ||
8465 error "failed to create $tfile.2 on ost1 facet"
8466 # files not cleaned with ONLY_REPEAT because of client unmount below
8467 rm -f $DIR/$tfile.[012]
8468 stop_ost2 || error "stop ost2 facet failed"
8471 run_test 112 "mount OST with nocreate option"
8477 rm -f $TMP/$tdir/lustre-mdt
8481 if [ "$mds1_FSTYPE" != ldiskfs ]; then
8482 skip "Only applicable to ldiskfs-based MDTs"
8484 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
8486 local dbfs_ver=$(do_facet $SINGLEMDS $DEBUGFS -V 2>&1)
8488 echo "debugfs version: $dbfs_ver"
8489 echo "$dbfs_ver" | egrep -w "1.44.3.wc1|1.44.5.wc1|1.45.2.wc1" &&
8490 skip_env "This version of debugfs doesn't show inode number"
8492 is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
8493 skip "This test can not be executed on flakey dev"
8495 IMAGESIZE=$((3072 << 30)) # 3072 GiB
8503 do_facet mds1 "hostname; ifconfig; lctl dl; mount"
8505 do_facet ost1 "hostname; ifconfig; lctl dl; mount"
8506 # We need MDT size 3072GB, because it is smallest
8507 # partition that can store 2B inodes
8508 do_facet $SINGLEMDS "mkdir -p $TMP/$tdir"
8509 local mdsimgname=$TMP/$tdir/lustre-mdt
8510 do_facet $SINGLEMDS "rm -f $mdsimgname"
8511 do_facet $SINGLEMDS "touch $mdsimgname"
8512 trap cleanup_115 RETURN EXIT
8513 do_facet $SINGLEMDS "$TRUNCATE $mdsimgname $IMAGESIZE" ||
8514 skip "Backend FS doesn't support sparse files"
8515 local mdsdev=$(do_facet $SINGLEMDS "losetup -f")
8516 do_facet $SINGLEMDS "losetup $mdsdev $mdsimgname"
8518 local mds_opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
8519 --mkfsoptions='-O ea_inode,^resize_inode,meta_bg \
8520 -N 2247484000 -E lazy_itable_init' --device-size=$IMAGESIZE"
8521 add mds1 $mds_opts --mgs --reformat $mdsdev ||
8522 skip_env "format large MDT failed"
8523 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8524 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
8525 add ost1 $opts || error "add ost1 failed with new params"
8526 start $SINGLEMDS $mdsdev $MDS_MOUNT_OPTS || error "start MDS failed"
8527 start_ost || error "start OSS failed"
8528 mount_client $MOUNT || error "mount client failed"
8530 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir fail"
8531 goal="/sys/fs/ldiskfs/$(basename $mdsdev)/inode_goal"
8533 # 2147483648 is 0x80000000
8534 do_facet $SINGLEMDS "echo 2147483648 >> $goal; grep . $goal"
8535 touch $DIR/$tdir/$tfile
8537 # attrs from 1 to 15 go to block, 16th - to inode
8538 for i in {1..16}; do
8539 local nm="trusted.ea$i"
8540 setfattr -n $nm -v $(printf "xattr%0250d" $i) $DIR/$tdir/$tfile
8543 # inode <2147483649> trusted.ea16 (255)
8544 local inode_num=$(do_facet $SINGLEMDS \
8545 "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsdev" |
8546 awk '/ea16/ { print $2 }' |
8547 sed -e 's/>//' -e 's/<//' -e 's/\"//')
8548 echo "inode num: $inode_num"
8549 [ $inode_num -ge 2147483648 ] || error "inode $inode_num too small"
8550 do_facet $SINGLEMDS "losetup -d $mdsdev"
8553 run_test 115 "Access large xattr with inodes number over 2TB"
8556 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
8557 [ "$MDS1_VERSION" -lt $(version_code 2.10.59) ] &&
8558 skip "Need server version at least 2.10.59"
8559 do_facet $SINGLEMDS which mkfs.xfs ||
8560 skip_env "No mkfs.xfs installed"
8565 local tmpmnt=$TMP/$tdir
8566 local mdtimg=$tfile-mdt0
8568 do_facet $SINGLEMDS mkdir -p $tmpmnt
8569 stack_trap "do_facet $SINGLEMDS rmdir $tmpmnt" EXIT
8571 do_facet $SINGLEMDS touch $TMP/$mdtimg
8572 stack_trap "do_facet $SINGLEMDS rm -f $TMP/$mdtimg" EXIT
8573 do_facet $SINGLEMDS mkfs -t xfs -d file,size=1t,name=$TMP/$mdtimg ||
8574 error "mkfs temporary xfs image"
8576 do_facet $SINGLEMDS mount $TMP/$mdtimg $tmpmnt ||
8577 error "mount temporary xfs image"
8578 stack_trap "do_facet $SINGLEMDS umount $tmpmnt" EXIT
8579 local old_mdssize=$MDSSIZE
8580 local old_mdsisize=$MDSISIZE
8582 MDSSIZE=$((17 * 1024 * 1024 * 1024)) # 17T MDT
8583 MDSISIZE=$((16 << 20))
8584 local opts17t="$(mkfs_opts $SINGLEMDS)"
8586 MDSSIZE=$old_mdssize
8587 MDSISIZE=$old_mdsisize
8589 do_facet $SINGLEMDS $MKFS \
8590 ${opts17t/-E /-E lazy_itable_init,lazy_journal_init,} \
8592 error "failed to mkfs for $tmpmnt/$mdtimg"
8594 do_facet $SINGLEMDS $TUNE2FS -l $tmpmnt/$mdtimg |
8595 grep -qw 'features.*extent' || error "extent should be enabled"
8598 run_test 116 "big size MDT support"
8602 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.nrs_policies=fifo"
8603 do_facet ost1 "$LCTL get_param -n ost.OSS.ost_io.nrs_tbf_rule" &&
8604 error "get_param should fail"
8605 cleanup || error "cleanup failed with rc $?"
8607 run_test 117 "lctl get_param return errors properly"
8609 test_120() { # LU-11130
8610 [ "$MDSCOUNT" -lt 2 ] && skip "mdt count < 2"
8611 [ "$mds1_FSTYPE" != ldiskfs ] &&
8612 skip "ldiskfs only test"
8613 [ "$MDS1_VERSION" -lt $(version_code 2.11.56) ] &&
8614 skip "Need DNE2 capable MD target with LU-11130 fix"
8618 local mds1host=$(facet_active_host mds1)
8619 local mds1dev=$(mdsdevname 1)
8621 $LFS mkdir -i 1 $DIR/$tdir
8622 $LFS mkdir -i 0 $DIR/$tdir/mds1dir
8624 ln -s foo $DIR/$tdir/bar
8625 mv $DIR/$tdir/bar $DIR/$tdir/mds1dir/bar2 ||
8626 error "cross-target rename failed"
8630 run_e2fsck $mds1host $mds1dev "-n"
8632 run_test 120 "cross-target rename should not create bad symlinks"
8635 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
8636 [[ "$OST1_VERSION" -ge $(version_code 2.11.53) ]] ||
8637 skip "Need OST version at least 2.11.53"
8640 LOAD_MODULES_REMOTE=true load_modules
8641 #define OBD_FAIL_OFD_SET_OID 0x1e0
8642 do_facet ost1 $LCTL set_param fail_loc=0x00001e0
8645 $LFS mkdir -i1 -c1 $DIR/$tdir
8646 $LFS setstripe -i0 -c1 $DIR/$tdir
8647 do_facet ost1 $LCTL set_param fail_loc=0
8648 createmany -o $DIR/$tdir/file_ 1000 ||
8649 error "Fail to create a new sequence"
8653 run_test 122a "Check OST sequence update"
8656 [[ "$OST1_VERSION" -ge $(version_code 2.11.53) ]] ||
8657 skip "Need OST version at least 2.11.53"
8661 LOAD_MODULES_REMOTE=true load_modules
8662 #define OBD_FAIL_OFD_SET_OID 0x1e0
8663 do_facet ost1 $LCTL set_param fail_loc=0x00001e0
8665 stack_trap cleanup EXIT
8667 do_facet ost1 $LCTL set_param obdfilter.*.precreate_batch=256
8668 $LFS mkdir -i0 -c1 $DIR/$tdir || error "failed to create directory"
8669 $LFS setstripe -i0 -c1 $DIR/$tdir || error "failed to setstripe"
8670 do_facet ost1 $LCTL set_param fail_loc=0
8671 # overflow IDIF 32bit and create > OST_MAX_PRECREATE*5
8672 # so a new wrong sequence would differ from an original with error
8673 #define OST_MAX_PRECREATE 20000
8674 local ost_max_precreate=20100
8675 local num_create=$(( ost_max_precreate * 5 ))
8677 # Check the number of inodes available on OST0
8679 local ifree=$($LFS df -i $MOUNT | awk '/OST0000/ { print $4 }')
8681 log "On OST0, $ifree inodes available. Want $num_create."
8683 if [ $ifree -lt 10000 ]; then
8684 files=$(( ifree - 50 ))
8689 local j=$((num_create / files + 1))
8691 for i in $(seq 1 $j); do
8692 createmany -o $DIR/$tdir/$tfile-$i- $files ||
8693 error "createmany fail create $files files: $?"
8694 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
8695 error "unlinkmany failed unlink $files files"
8699 #we need a write req during recovery for ofd_seq_load
8701 dd if=/dev/urandom of=$DIR/$tdir/$tfile bs=1024k count=1 oflag=sync ||
8702 error "failed to write file"
8704 # OBD_FAIL_OST_CREATE_NET 0x204
8705 do_facet ost1 $LCTL set_param fail_loc=0x80000204
8707 createmany -o $DIR/$tdir/file_ 100
8710 err=$(do_facet ost1 dmesg | tac | sed "/Recovery over/,$ d" |
8711 grep "OST replaced or reformatted")
8712 [ -z "$err" ] || error $err
8714 run_test 122b "Check OST sequence wouldn't change when IDIF 32bit overflows"
8717 remote_mgs_nodsh && skip "remote MGS with nodsh"
8718 [ -d $MOUNT/.lustre ] || setup
8720 # test old logid format until removal from llog_ioctl.c::str2logid()
8721 if [ $MGS_VERSION -lt $(version_code 3.1.53) ]; then
8722 do_facet mgs $LCTL dl | grep MGS
8723 do_facet mgs "$LCTL --device %MGS llog_print \
8724 \\\\\\\$$FSNAME-client 1 10" ||
8725 error "old llog_print failed"
8728 # test new logid format
8729 if [ $MGS_VERSION -ge $(version_code 2.9.53) ]; then
8730 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
8731 error "new llog_print failed"
8734 run_test 123aa "llog_print works with FIDs and simple names"
8737 remote_mgs_nodsh && skip "remote MGS with nodsh"
8738 [[ $MGS_VERSION -gt $(version_code 2.11.51) ]] ||
8739 skip "Need server with working llog_print support"
8741 [ -d $MOUNT/.lustre ] || setup
8747 [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
8748 mgs_arg="--device MGS"
8750 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
8751 do_facet mgs $LCTL set_param -P jobid_name="TESTNAME"
8753 yaml=$(do_facet mgs $LCTL $mgs_arg llog_print params |
8754 grep jobid_name | tail -n 1)
8756 local param=$(awk '{ print $10 }' <<< "$yaml")
8757 local val=$(awk '{ print $12 }' <<< "$yaml")
8758 #return to the default
8759 do_facet mgs $LCTL set_param -P jobid_name=$orig_val
8760 [ $val = "TESTNAME" ] || error "bad value: $val"
8761 [ $param = "jobid_name," ] || error "Bad param: $param"
8763 run_test 123ab "llog_print params output values from set_param -P"
8765 test_123ac() { # LU-11566
8766 remote_mgs_nodsh && skip "remote MGS with nodsh"
8767 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8768 skip "Need 'lctl llog_print --start' on MGS"
8774 [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
8775 mgs_arg="--device MGS"
8777 [ -d $MOUNT/.lustre ] || setup
8779 # - { index: 10, event: add_uuid, nid: 192.168.20.1@tcp(0x20000c0a81401,
8780 # node: 192.168.20.1@tcp }
8781 do_facet mgs $LCTL $mgs_arg \
8782 llog_print --start $start --end $end $FSNAME-client | tr -d , |
8783 while read DASH BRACE INDEX idx EVENT BLAH BLAH BLAH; do
8784 (( idx >= start )) || error "llog_print index $idx < $start"
8785 (( idx <= end )) || error "llog_print index $idx > $end"
8788 run_test 123ac "llog_print with --start and --end"
8790 test_123ad() { # LU-11566
8791 remote_mgs_nodsh && skip "remote MGS with nodsh"
8792 # older versions of lctl may not print all records properly
8793 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
8794 skip "Need 'lctl llog_print --start' on MGS"
8796 [ -d $MOUNT/.lustre ] || setup
8798 # append a new record, to avoid issues if last record was cancelled
8799 local old=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
8800 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$old
8802 # logid: [0x3:0xa:0x0]:0
8806 local num=$(do_facet mgs $LCTL --device MGS llog_info $FSNAME-client |
8807 awk '/last_index:/ { print $2 - 1 }')
8809 # - { index: 71, event: set_timeout, num: 0x14, param: sys.timeout=20 }
8810 local last=$(do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
8811 tail -1 | awk '{ print $4 }' | tr -d , )
8812 (( last == num )) || error "llog_print only showed $last/$num records"
8814 run_test 123ad "llog_print shows all records"
8816 test_123ae() { # LU-11566
8817 remote_mgs_nodsh && skip "remote MGS with nodsh"
8818 [ -d $MOUNT/.lustre ] || setupall
8820 local max=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
8823 [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
8824 mgs_arg="--device MGS"
8826 if do_facet mgs "$LCTL help llog_cancel" 2>&1| grep -q -- --log_id; then
8827 # save one set_param -P record in case none exist
8828 do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
8831 local orig=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
8832 tail -1 | awk '{ print $4 }' | tr -d , )
8833 do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
8834 do_facet mgs $LCTL $mgs_arg llog_print $log | tail -1 |
8835 grep "parameter: osc.*.max_dirty_mb" ||
8836 error "new set_param -P wasn't stored in params log"
8838 # - { index: 71, event: set_param, device: general,
8839 # param: osc.*.max_dirty_mb, value: 256 }
8840 local id=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
8841 tail -1 | awk '{ print $4 }' | tr -d , )
8843 do_facet mgs $LCTL $mgs_arg llog_cancel $log --log_idx=$id
8844 local new=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
8845 tail -1 | awk '{ print $4 }' | tr -d , )
8846 (( new == orig )) ||
8847 error "new llog_cancel now $new, not at $orig records"
8850 # test old positional parameters for a while still
8851 if [ "$MGS_VERSION" -le $(version_code 3.1.53) ]; then
8853 orig=$(do_facet mgs $LCTL --device MGS llog_print $log |
8854 tail -1 | awk '{ print $4 }' | tr -d , )
8855 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$max
8856 do_facet mgs $LCTL --device MGS llog_print $log |
8857 tail -1 | grep "parameter: osc.max_dirty_mb" ||
8858 error "old conf_param wasn't stored in params log"
8860 # - { index: 71, event: conf_param, device: testfs-OST0000-osc,
8861 # param: osc.max_dirty_mb=256 }
8862 id=$(do_facet mgs $LCTL --device MGS llog_print $log |
8863 tail -1 | awk '{ print $4 }' | tr -d , )
8864 do_facet mgs $LCTL --device MGS llog_cancel $log $id
8865 new=$(do_facet mgs $LCTL --device MGS llog_print $log |
8866 tail -1 | awk '{ print $4 }' | tr -d , )
8867 (( new == orig )) ||
8868 error "old llog_cancel now $new, not at $orig records"
8871 run_test 123ae "llog_cancel can cancel requested record"
8873 test_123af() { #LU-13609
8874 [ "$MGS_VERSION" -ge $(version_code 2.13.54) -a \
8875 "$MDS1_VERSION" -ge $(version_code 2.13.54) ] ||
8876 skip "Need both MGS and MDS version at least 2.13.54"
8878 [ -d $MOUNT/.lustre ] || setupall
8879 stack_trap "do_facet mds1 $LCTL set_param fail_loc=0" EXIT
8889 for device in "MGS" "$FSNAME-MDT0000"; do
8890 cmd="--device $device llog_catlist"
8891 echo "lctl $cmd ..."
8892 if [ "$device" = "MGS" ]; then
8897 orig_clist=($(do_facet $facet $LCTL $cmd | awk '{ print $2 }'))
8898 orig_count=${#orig_clist[@]}
8899 echo "orig_clist: ${orig_clist[@]}"
8901 #define OBD_FAIL_CATLIST 0x131b
8902 #fetch to llog records from the second one
8903 do_facet $facet $LCTL set_param fail_loc=0x131b fail_val=2
8905 new_clist=($(do_facet $facet $LCTL $cmd | awk '{ print $2 }'))
8906 new_count=${#new_clist[@]}
8907 echo "new_clist: ${new_clist[@]}"
8909 [ $new_count -eq $((orig_count - 1)) ] ||
8910 error "$new_count != $orig_count - 1"
8911 for i in $(seq 0 $new_count); do
8913 [ "${orig_clist[$j]}" = "${new_clist[$i]}" ] ||
8914 error "${orig_clist[$j]} != ${new_clist[$i]}"
8916 do_facet mds1 $LCTL set_param fail_loc=0
8920 run_test 123af "llog_catlist can show all config files correctly"
8923 remote_mgs_nodsh && skip "remote MGS with nodsh"
8925 [ -d $MOUNT/.lustre ] || setup
8926 local yaml_file="$TMP/$tfile.yaml"
8927 do_facet mgs rm "$yaml_file"
8928 local cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist" |
8929 sed 's/config_log://')
8931 # set jobid_var to a different value for test
8932 local orig_val=$(do_facet mgs $LCTL get_param jobid_var)
8933 do_facet mgs $LCTL set_param -P jobid_var="TESTNAME"
8935 for i in $cfgfiles params; do
8936 do_facet mgs "lctl --device MGS llog_print ${i} >> $yaml_file"
8939 echo "Unmounting FS"
8949 # Reapply the config from before
8950 echo "Setting configuration parameters"
8951 do_facet mgs "lctl set_param -F $yaml_file"
8953 local set_val=$(do_facet mgs $LCTL get_param jobid_var)
8954 do_facet mgs $LCTL set_param -P $orig_val
8956 [ $set_val == "jobid_var=TESTNAME" ] ||
8957 error "$set_val is not TESTNAME"
8959 do_facet mgs rm "$yaml_file"
8962 run_test 123F "clear and reset all parameters using set_param -F"
8966 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
8967 [ -z $mds2failover_HOST ] && skip "needs MDT failover setup"
8970 do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
8971 grep 1.2.3.4@tcp && error "Should not be fake nid"
8972 do_facet mgs $LCTL conf_param $FSNAME-MDT0001.failover.node=1.2.3.4@tcp\
8973 || error "Set params error"
8974 do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
8975 grep 1.2.3.4@tcp || error "Fake nid should be added"
8979 if combined_mgs_mds; then
8980 start_mdt 1 "-o nosvc" ||
8981 error "starting mds with nosvc option failed"
8983 local nid=$(do_facet mds2 $LCTL list_nids | head -1)
8984 local failover_nid=$(do_node $mds2failover_HOST $LCTL list_nids | head -1)
8985 do_facet mgs $LCTL replace_nids $FSNAME-MDT0001 $nid:$failover_nid ||
8986 error "replace_nids execution error"
8988 if combined_mgs_mds; then
8994 echo "lfs setdirstripe"
8995 $LFS setdirstripe -i 1 $MOUNT/$tdir || error "setdirstirpe error"
8998 run_test 124 "check failover after replace_nids"
9000 get_max_sectors_kb() {
9003 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
9004 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
9006 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
9007 cat ${max_sectors_path}"
9010 get_max_hw_sectors_kb() {
9013 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
9014 local max_hw_path="/sys/block/${dev_base}/queue/max_hw_sectors_kb"
9016 do_facet ${facet} "[[ -e ${max_hw_path} ]] && cat ${max_hw_path}"
9019 set_max_sectors_kb() {
9023 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
9024 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
9026 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
9027 echo ${value} > ${max_sectors_path}"
9030 [[ $rc -ne 0 ]] && echo "Failed to set ${max_sectors_path} to ${value}"
9035 # Return 0 if all slave devices have max_sectors_kb == max_hw_sectors_kb
9036 # Otherwise return > 0
9037 check_slaves_max_sectors_kb()
9041 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
9042 local slaves_dir=/sys/block/${dev_base}/slaves
9043 local slave_devices=$(do_facet ${facet} "ls ${slaves_dir} 2>/dev/null")
9044 [[ -z ${slave_devices} ]] && return 0
9046 local slave max_sectors new_max_sectors max_hw_sectors path
9048 for slave in ${slave_devices}; do
9049 path="/dev/${slave}"
9050 ! is_blkdev ${facet} ${path} && continue
9051 max_sectors=$(get_max_sectors_kb ${facet} ${path})
9052 max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${path})
9053 new_max_sectors=${max_hw_sectors}
9054 [[ ${new_max_sectors} -gt ${RQ_SIZE_LIMIT} ]] &&
9055 new_max_sectors=${RQ_SIZE_LIMIT}
9057 if [[ ${max_sectors} -ne ${new_max_sectors} ]]; then
9058 echo "${path} ${max_sectors} ${new_max_sectors}"
9061 check_slaves_max_sectors_kb ${facet} ${path}
9070 local facet_list="mgs mds1 ost1"
9071 combined_mgs_mds && facet_list="mgs ost1"
9074 for facet in ${facet_list}; do
9075 [[ $(facet_fstype ${facet}) != ldiskfs ]] &&
9076 skip "ldiskfs only test" &&
9078 ! is_blkdev ${facet} $(facet_device ${facet}) &&
9079 skip "requires all real devices" &&
9084 # We don't increase IO request size limit past 16MB. See comments in
9085 # lustre/utils/libmount_utils_ldiskfs.c:tune_max_sectors_kb()
9086 RQ_SIZE_LIMIT=$((16 * 1024))
9087 local device old_max_sectors new_max_sectors max_hw_sectors
9088 for facet in ${facet_list}; do
9089 device=$(facet_device ${facet})
9090 old_max_sectors=$(get_max_sectors_kb ${facet} ${device})
9091 max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${device})
9093 # The expected value after l_tunedisk is executed
9094 new_max_sectors=$old_max_sectors
9095 [[ ${new_max_sectors_kb} -gt ${RQ_SIZE_LIMIT} ]] &&
9096 new_max_sectors_kb=${RQ_SIZE_LIMIT}
9098 # Ensure the current value of max_sectors_kb does not equal
9099 # max_hw_sectors_kb, so we can tell whether l_tunedisk did
9101 set_max_sectors_kb ${facet} ${device} $((new_max_sectors - 1))
9103 # Value before l_tunedisk
9104 local pre_max_sectors=$(get_max_sectors_kb ${facet} ${device})
9105 if [[ ${pre_max_sectors} -ne $((new_max_sectors - 1)) ]]; then
9106 echo "unable to satsify test pre-condition:"
9107 echo "${pre_max_sectors} != $((new_max_sectors - 1))"
9112 echo "Before: ${facet} ${device} ${pre_max_sectors} ${max_hw_sectors}"
9114 do_facet ${facet} "l_tunedisk ${device}"
9116 # Value after l_tunedisk
9117 local post_max_sectors=$(get_max_sectors_kb ${facet} ${device})
9119 echo "After: ${facet} ${device} ${post_max_sectors} ${max_hw_sectors}"
9121 if [[ ${facet} != ost1 ]]; then
9122 if [[ ${post_max_sectors} -ne ${pre_max_sectors} ]]; then
9123 echo "l_tunedisk modified max_sectors_kb of ${facet}"
9127 set_max_sectors_kb ${facet} ${device} ${old_max_sectors}
9129 if [[ ${post_max_sectors} -eq ${pre_max_sectors} ]]; then
9130 echo "l_tunedisk failed to modify max_sectors_kb of ${facet}"
9134 check_slaves_max_sectors_kb ${facet} ${device} ||
9141 run_test 125 "check l_tunedisk only tunes OSTs and their slave devices"
9144 [[ "$MDS1_VERSION" -ge $(version_code 2.13.52) ]] ||
9145 skip "Need MDS version at least 2.13.52"
9148 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ../libcfs/libcfs/libcfs
9149 #define OBD_FAIL_OBD_SETUP 0x60d
9150 do_facet mds1 $LCTL set_param fail_loc=0x60d
9151 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules &
9152 for i in {1..40}; do
9153 do_facet mds1 lsmod | grep -q osd_$mds1_FSTYPE && break
9156 clear_failloc $SINGLEMDS 20 &
9157 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
9159 run_test 126 "mount in parallel shouldn't cause a crash"
9162 [[ "$ost1_FSTYPE" == ldiskfs ]] || skip "ldiskfs only test"
9166 zconf_umount_clients $RCLIENTS $MOUNT
9168 wait_osp_active ost ${FSNAME}-OST0000 0 1
9169 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
9170 local avail1=($($LCTL get_param -n osc.${osc_tgt}.kbytesavail))
9172 $LFS setstripe -i 0 $DIR/$tfile || error "failed creating $DIR/$tfile"
9173 dd if=/dev/zero of=$DIR/$tfile bs=1M oflag=direct || true
9175 local avail2=($($LCTL get_param -n osc.${osc_tgt}.kbytesavail))
9177 if ((avail2 * 100 / avail1 > 1)); then
9180 error "more than 1% space left: before=$avail1 after=$avail2"
9183 local mbs=$(($(stat -c %s $DIR/$tfile) / (1024 * 1024)))
9185 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$mbs conv=notrunc \
9186 oflag=direct || error "overwrite failed"
9188 run_test 127 "direct io overwrite on full ost"
9192 combined_mgs_mds && skip "need separate mgs device"
9193 [ "$ost2_FSTYPE" == zfs ] && import_zpool ost2
9196 # Try to apply nolocallogs to the virgin OST. Should fail.
9197 do_facet ost2 "$TUNEFS --nolocallogs $(ostdevname 2)" &&
9198 error "nolocallogs should not be allowed on the virgin target"
9203 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
9204 # Start OST without MGS (local configs)
9205 do_facet ost1 "$TUNEFS --dryrun $(ostdevname 1)"
9206 start_ost || error "unable to start OST1"
9207 stop_ost || error "Unable to stop OST1"
9209 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
9210 # Do not allow reading local configs, should fail
9211 do_facet ost1 "$TUNEFS --nolocallogs $(ostdevname 1)" ||
9212 error "Can not set nolocallogs"
9213 start_ost && error "OST1 started, but should fail"
9215 # Connect to MGS successfully, reset nolocallogs flag
9216 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
9217 start_mgs || error "unable to start MGS"
9218 start_ost || error "unable to start OST1"
9220 do_facet ost1 "$TUNEFS --dryrun $(ostdevname 1)" | grep "nolocallogs" &&
9221 error "nolocallogs expected to be reset"
9223 stop_ost || error "Unable to stop OST1"
9225 run_test 128 "Force using remote logs with --nolocallogs"
9227 if ! combined_mgs_mds ; then
9233 # restore the values of MDSSIZE and OSTSIZE
9234 MDSSIZE=$STORED_MDSSIZE
9235 OSTSIZE=$STORED_OSTSIZE
9239 check_and_cleanup_lustre