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 always_except LU-11915 110
20 always_except LU-9795 84 86 103
23 if ! combined_mgs_mds; then
24 always_except LU-11991 32a 32b 32c 32d 32e
25 always_except LU-9897 84
26 always_except LU-12032 123F
30 [ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69 106 111 114"
34 # use small MDS + OST size to speed formatting time
35 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
36 # STORED_MDSSIZE is used in test_18
37 STORED_MDSSIZE=$MDSSIZE
38 STORED_OSTSIZE=$OSTSIZE
40 [ "$mds1_FSTYPE" = zfs ] && MDSSIZE=400000
42 [ "$ost1_FSTYPE" = zfs ] && OSTSIZE=400000
52 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
53 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
54 LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
58 require_dsh_mds || exit 0
59 require_dsh_ost || exit 0
64 # The MGS must be started before the OSTs for a new fs, so start
65 # and stop to generate the startup logs.
68 wait_osc_import_state mds ost FULL
73 reformat_and_config() {
75 if ! combined_mgs_mds ; then
81 writeconf_or_reformat() {
82 # There are at most 2 OSTs for write_conf test
83 # who knows if/where $TUNEFS is installed?
84 # Better reformat if it fails...
85 writeconf_all $MDSCOUNT 2 ||
86 { echo "tunefs failed, reformatting instead" &&
87 reformat_and_config && return 0; }
96 echo "start mgs service on $(facet_active_host mgs)"
97 start mgs $(mgsdevname) $MGS_MOUNT_OPTS "$@"
103 local dev=$(mdsdevname $num)
106 echo "start mds service on `facet_active_host $facet`"
107 start $facet ${dev} $MDS_MOUNT_OPTS "$@" || return 94
110 stop_mdt_no_force() {
113 local dev=$(mdsdevname $num)
116 echo "stop mds service on `facet_active_host $facet`"
117 stop $facet || return 97
123 local dev=$(mdsdevname $num)
126 echo "stop mds service on `facet_active_host $facet`"
127 # These tests all use non-failover stop
128 stop $facet -f || return 97
132 local mdscount=$MDSCOUNT
135 [[ "$1" == "--mdscount" ]] && mdscount=$2 && shift 2
137 for ((num=1; num <= $mdscount; num++ )); do
138 start_mdt $num "$@" || return 94
140 for ((num=1; num <= $mdscount; num++ )); do
141 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds${num} FULL
146 if ! combined_mgs_mds ; then
154 for num in $(seq $MDSCOUNT); do
155 stop_mdt $num || return 97
160 echo "stop mgs service on `facet_active_host mgs`"
161 # These tests all use non-failover stop
162 stop mgs -f || return 97
166 echo "start ost1 service on `facet_active_host ost1`"
167 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS "$@" || return 95
168 wait_clients_import_ready ${CLIENTS:-$HOSTNAME} ost1
172 echo "stop ost1 service on `facet_active_host ost1`"
173 # These tests all use non-failover stop
174 stop ost1 -f || return 98
178 echo "start ost2 service on `facet_active_host ost2`"
179 start ost2 $(ostdevname 2) $OST_MOUNT_OPTS "$@" || return 92
180 wait_clients_import_ready ${CLIENTS:-$HOSTNAME} ost2
184 echo "stop ost2 service on `facet_active_host ost2`"
185 # These tests all use non-failover stop
186 stop ost2 -f || return 93
193 echo "mount $FSNAME ${mountopt:+with opts $mountopt} on $mountpath....."
194 zconf_mount $HOSTNAME $mountpath $mountopt || return 96
200 echo "umount lustre on $mountpath....."
201 zconf_umount $HOSTNAME $mountpath "$@" || return 97
204 manual_umount_client(){
207 echo "manual umount lustre on ${MOUNT}...."
208 do_facet client "umount ${FORCE} $MOUNT"
214 start_mds || error "MDT start failed"
215 start_ost || error "Unable to start OST1"
216 mount_client $MOUNT || error "client start failed"
217 client_up || error "client_up failed"
226 unload_modules_conf () {
227 if combined_mgs_mds || ! local_mode; then
228 unload_modules || return 1
233 stop_ost || return 202
234 stop_mds || return 201
235 unload_modules_conf || return 203
240 [ "x$1" != "x" ] && force='-f'
241 umount_client $MOUNT $force|| return 200
242 cleanup_nocli || return $?
247 echo "umount $MOUNT2 ..."
248 umount $MOUNT2 || true
249 echo "stopping fs2mds ..."
250 stop fs2mds -f || true
251 echo "stopping fs2ost ..."
252 stop fs2ost -f || true
256 do_facet client "cp /etc/passwd $DIR/a" || return 71
257 do_facet client "rm $DIR/a" || return 72
258 # make sure lustre is actually mounted (touch will block,
259 # but grep won't, so do it after)
260 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
261 echo "setup single mount lustre success"
265 do_facet client "touch $DIR/a" || return 71
266 do_facet client "rm $DIR/a" || return 72
267 do_facet client "touch $DIR2/a" || return 73
268 do_facet client "rm $DIR2/a" || return 74
269 echo "setup double mount lustre success"
273 cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
276 if [ "$ONLY" == "setup" ]; then
281 if [ "$ONLY" == "cleanup" ]; then
288 #create single point mountpoint
294 check_mount || error "check_mount failed"
295 cleanup || error "cleanup failed with $?"
297 run_test 0 "single mount setup"
300 start_mds || error "MDS start failed"
301 start_ost || error "unable to start OST"
302 echo "start ost second time..."
303 start_ost && error "2nd OST start should fail"
304 mount_client $MOUNT || error "client start failed"
305 check_mount || error "check_mount failed"
306 cleanup || error "cleanup failed with $?"
308 run_test 1 "start up ost twice (should return errors)"
311 start_mds || error "MDT start failed"
312 echo "start mds second time.."
313 start_mds && error "2nd MDT start should fail"
314 start_ost || error "OST start failed"
315 mount_client $MOUNT || error "mount_client failed to start client"
316 check_mount || error "check_mount failed"
317 cleanup || error "cleanup failed with $?"
319 run_test 2 "start up mds twice (should return err)"
323 #mount.lustre returns an error if already in mtab
324 mount_client $MOUNT && error "2nd client mount should fail"
325 check_mount || error "check_mount failed"
326 cleanup || error "cleanup failed with $?"
328 run_test 3 "mount client twice (should return err)"
332 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
333 stop_ost || error "Unable to stop OST1"
334 umount_client $MOUNT -f || error "unmount $MOUNT failed"
337 # ok for ost to fail shutdown
338 if [ 202 -ne $eno ] && [ 0 -ne $eno ]; then
339 error "cleanup failed with $?"
342 run_test 4 "force cleanup ost, then cleanup"
344 test_5a() { # was test_5
346 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
347 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
349 stop_mds || error "Unable to stop MDS"
351 # cleanup may return an error from the failed
352 # disconnects; for now I'll consider this successful
353 # if all the modules have unloaded.
357 echo "killing umount"
358 kill -TERM $UMOUNT_PID
359 echo "waiting for umount to finish"
361 if grep " $MOUNT " /proc/mounts; then
362 echo "test 5: /proc/mounts after failed umount"
366 echo "killing umount"
367 kill -TERM $UMOUNT_PID
368 echo "waiting for umount to finish"
370 grep " $MOUNT " /proc/mounts &&
371 error "/proc/mounts after second umount"
374 # manual_mount_client may fail due to umount succeeding above
376 # stop_mds is a no-op here, and should not fail
377 cleanup_nocli || error "cleanup_nocli failed with $?"
378 # df may have lingering entry
380 # mtab may have lingering entry
384 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
386 grep -q $MOUNT" " /etc/mtab || break
387 echo "Waiting /etc/mtab updated ... "
388 WAIT=$(( WAIT + sleep))
390 [ "$WAIT" -eq "$MAX_WAIT" ] &&
391 error "/etc/mtab is not updated in $WAIT secs"
392 echo "/etc/mtab updated in $WAIT secs"
394 run_test 5a "force cleanup mds, then cleanup"
402 grep " $MOUNT " /etc/mtab &&
403 error false "unexpected entry in mtab before mount" && return 10
405 start_ost || error "OST start failed"
406 if ! combined_mgs_mds ; then
407 trap cleanup_5b EXIT ERR
408 start_mds || error "MDS start failed"
412 mount_client $MOUNT && error "mount_client $MOUNT should fail"
413 grep " $MOUNT " /etc/mtab &&
414 error "$MOUNT entry in mtab after failed mount"
416 # stop_mds is a no-op here, and should not fail
417 cleanup_nocli || error "cleanup_nocli failed with $?"
418 if ! combined_mgs_mds ; then
422 run_test 5b "Try to start a client with no MGS (should return errs)"
425 grep " $MOUNT " /etc/mtab &&
426 error false "unexpected entry in mtab before mount" && return 10
428 start_mds || error "MDS start failed"
429 start_ost || error "OST start failed"
430 local oldfs="${FSNAME}"
431 FSNAME="wrong.${FSNAME}"
432 mount_client $MOUNT || :
434 grep " $MOUNT " /etc/mtab &&
435 error "$MOUNT entry in mtab after failed mount"
437 cleanup_nocli || error "cleanup_nocli failed with $?"
439 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
442 grep " $MOUNT " /etc/mtab &&
443 error "unexpected entry in mtab before mount"
445 start_ost || error "OST start failed"
446 start_mds || error "MDS start failed"
447 stop_ost -f || error "Unable to stop OST1"
448 mount_client $MOUNT || error "mount_client $MOUNT failed"
449 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
450 cleanup_nocli || error "cleanup_nocli failed with $?"
451 ! grep " $MOUNT " /etc/mtab ||
452 error "$MOUNT entry in mtab after unmount"
454 run_test 5d "mount with ost down"
457 grep " $MOUNT " /etc/mtab &&
458 error false "unexpected entry in mtab before mount" && return 10
460 start_mds || error "MDS start failed"
461 start_ost || error "OST start failed"
463 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
464 do_facet client "$LCTL set_param fail_loc=0x80000506"
465 mount_client $MOUNT || echo "mount failed (not fatal)"
466 cleanup || error "cleanup failed with $?"
467 grep " $MOUNT " /etc/mtab &&
468 error "$MOUNT entry in mtab after unmount"
471 run_test 5e "delayed connect, don't crash (bug 10268)"
474 combined_mgs_mds && skip "needs separate mgs and mds"
476 grep " $MOUNT " /etc/mtab &&
477 error false "unexpected entry in mtab before mount" && return 10
480 start_ost || error "OST start failed"
481 mount_client $MOUNT &
483 echo client_mount pid is $pid
487 if ! ps -f -p $pid >/dev/null; then
490 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
491 error "mount returns $rc, expected to hang"
493 cleanup || error "cleanup failed with $?"
498 start_mds || error "start MDS failed"
500 # mount should succeed after start mds
502 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
503 cleanup || error "final call to cleanup failed with rc $?"
505 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
509 [ "$CLIENT_VERSION" -lt $(version_code 2.9.53) ] &&
510 skip "automount of debugfs missing before 2.9.53"
511 umount /sys/kernel/debug
512 $LCTL get_param -n devices | egrep -v "error" && \
513 error "lctl can't access debugfs data"
514 grep " debugfs " /etc/mtab || error "debugfs failed to remount"
516 run_test 5g "handle missing debugfs"
519 (( $MDS1_VERSION >= $(version_code 2.12.54) )) ||
520 skip "Need MDS version at least 2.12.54"
525 #define OBD_FAIL_MDS_FS_SETUP 0x135
526 do_facet mds1 "$LCTL set_param fail_loc=0x80000135"
527 start_mdt 1 && error "start mdt should fail"
528 start_mdt 1 || error "start mdt failed"
529 client_up || error "client_up failed"
532 run_test 5h "start mdt failure at mdt_fs_setup()"
535 (( $MDS1_VERSION >= $(version_code 2.12.54) )) ||
536 skip "Need MDS version at least 2.12.54"
541 #define OBD_FAIL_QUOTA_INIT 0xA05
542 do_facet mds1 "$LCTL set_param fail_loc=0x80000A05"
543 start_mdt 1 && error "start mdt should fail"
544 start_mdt 1 || error "start mdt failed"
545 client_up || error "client_up failed"
548 run_test 5i "start mdt failure at mdt_quota_init()"
552 load_module ../libcfs/libcfs/libcfs ||
553 error "Failed to load modules libcfs rc = $?"
554 $LCTL set_param debug=all
557 run_test 5j "verify libcfs doesn't crash when setting debug flags"
562 mount_client $MOUNT || error "mount_client $MOUNT failed"
563 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
564 cleanup || error "cleanup failed with rc $?"
566 run_test 6 "manual umount, then mount again"
571 cleanup_nocli || error "cleanup_nocli failed with $?"
573 run_test 7 "manual umount, then cleanup"
577 mount_client $MOUNT2 || error "mount_client $MOUNT2 failed"
578 check_mount2 || error "check_mount2 failed"
579 umount_client $MOUNT2 || error "umount_client $MOUNT2 failed"
580 cleanup || error "cleanup failed with rc $?"
582 run_test 8 "double mount setup"
585 start_ost || error "OST start failed"
587 do_facet ost1 $LCTL set_param debug=\'inode trace\' ||
588 error "do_facet ost1 set_param inode trace failed."
589 do_facet ost1 $LCTL set_param subsystem_debug=\'mds ost\' ||
590 error "do_facet ost1 set_param debug mds ost failed."
592 CHECK_PTLDEBUG="`do_facet ost1 $LCTL get_param -n debug`"
593 if [ "$CHECK_PTLDEBUG" ] && { \
594 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
595 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
596 echo "lnet.debug success"
598 error "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
600 CHECK_SUBSYS="`do_facet ost1 $LCTL get_param -n subsystem_debug`"
601 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
602 echo "lnet.subsystem_debug success"
604 error "lnet.subsystem_debug: want 'mds ost' got '$CHECK_SUBSYS'"
606 stop_ost || error "Unable to stop OST1"
608 run_test 9 "test ptldebug and subsystem for mkfs"
613 if ! combined_mgs_mds; then
614 files=$(do_facet mgs "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
615 [ -z $files ] || echo "MGS $files is a broken symlink"
618 files=$(do_facet mds1 "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
619 [ -z $files ] || echo "MDS $files is a broken symlink"
621 files=$(do_facet ost1 "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
622 [ -z $files ] || echo "OSS $files is a broken symlink"
624 files=$(do_facet client "find /{proc/fs,sys/fs,sys/kernel/debug}/lustre -type l -exec test ! -e {} \; -print")
625 [ -z $files ] || echo "clients $files is a broken symlink"
627 cleanup || error "cleanup failed with rc $?"
629 run_test 10a "find lctl param broken symlinks"
632 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
633 # But with new MDS stack we don't care about the mode of local objects
634 # anymore, so this test is removed. See bug 22944 for more details.
638 if [ "$mds1_FSTYPE" != ldiskfs ]; then
639 skip "ldiskfs only test"
643 check_mount || error "check_mount failed"
644 cleanup || error "cleanup failed with rc $?"
646 echo "Remove mds config log"
647 if ! combined_mgs_mds ; then
651 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' \
652 $(mgsdevname) || return \$?" ||
653 error "do_facet mgs failed with $?"
655 if ! combined_mgs_mds ; then
659 start_ost || error "OST start failed"
660 start_mds && error "MDS start succeeded, but should fail"
663 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
666 if [ "$mds1_FSTYPE" != ldiskfs ]; then
667 skip "ldiskfs only test"
670 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
675 # check if current MDSSIZE is large enough
676 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE &&
677 log "use MDSSIZE=$MDSSIZE"
679 # check if the global config has a large enough MDSSIZE
680 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] &&
681 [ $STORED_MDSSIZE -ge $MIN ] &&
682 OK=1 && myMDSSIZE=$STORED_MDSSIZE &&
683 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
685 # check if the block device is large enough
686 is_blkdev $SINGLEMDS $MDSDEV $MIN
687 local large_enough=$?
688 if [ -n "$OK" ]; then
689 [ $large_enough -ne 0 ] && OK=""
691 [ $large_enough -eq 0 ] && OK=1 && myMDSSIZE=$MIN &&
692 log "use device $MDSDEV with MIN=$MIN"
695 # check if a loopback device has enough space for fs metadata (5%)
697 if [ -z "$OK" ]; then
698 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! \
699 -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
700 awk '($1 != "Filesystem") { print $4 }')
701 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] &&
702 OK=1 && myMDSSIZE=$MIN &&
703 log "use file $MDSDEV with MIN=$MIN"
706 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS"
708 echo "mount mds with large journal..."
710 local OLD_MDSSIZE=$MDSSIZE
714 echo "mount lustre system..."
716 check_mount || error "check_mount failed"
718 echo "check journal size..."
719 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
720 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
721 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
723 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
726 cleanup || error "cleanup failed with rc $?"
731 run_test 18 "check mkfs creates large journals"
734 start_mds || error "MDS start failed"
735 stop_mds || error "Unable to stop MDS"
737 run_test 19a "start/stop MDS without OSTs"
740 start_ost || error "Unable to start OST1"
741 stop_ost -f || error "Unable to stop OST1"
743 run_test 19b "start/stop OSTs without MDS"
746 # first format the ost/mdt
747 start_mds || error "MDS start failed"
748 start_ost || error "Unable to start OST1"
749 mount_client $MOUNT || error "mount_client $MOUNT failed"
750 check_mount || error "check_mount failed"
751 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
752 mount_client $MOUNT remount,ro || error "remount client with ro failed"
753 touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
754 [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
755 mount_client $MOUNT remount,rw || error "remount client with rw failed"
756 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
757 MCNT=$(grep -c $MOUNT' ' /etc/mtab)
758 [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
760 stop_mds || error "Unable to stop MDS"
761 stop_ost || error "Unable to stop OST1"
763 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
766 start_mds || error "MDS start failed"
767 start_ost || error "unable to start OST1"
768 wait_osc_import_state mds ost FULL
769 stop_ost || error "unable to stop OST1"
770 stop_mds || error "unable to stop MDS"
772 run_test 21a "start mds before ost, stop ost first"
775 start_ost || error "unable to start OST1"
776 start_mds || error "MDS start failed"
777 wait_osc_import_state mds ost FULL
778 stop_mds || error "unable to stop MDS"
779 stop_ost || error "unable to stop OST1"
781 run_test 21b "start ost before mds, stop mds first"
784 start_ost || error "Unable to start OST1"
785 start_mds || error "MDS start failed"
786 start_ost2 || error "Unable to start OST2"
787 wait_osc_import_state mds ost2 FULL
788 stop_ost || error "Unable to stop OST1"
789 stop_ost2 || error "Unable to stop OST2"
790 stop_mds || error "Unable to stop MDS"
791 #writeconf to remove all ost2 traces for subsequent tests
792 writeconf_or_reformat
794 run_test 21c "start mds between two osts, stop mds last"
797 combined_mgs_mds && skip "need separate mgs device"
802 start_mgs || error "unable to start MGS"
803 start_ost || error "unable to start OST1"
804 start_ost2 || error "unable to start OST2"
805 start_mds || error "MDS start failed"
806 wait_osc_import_state mds ost2 FULL
808 local zkeeper=${KEEP_ZPOOL}
809 stack_trap "KEEP_ZPOOL=$zkeeper" EXIT
812 stop_ost || error "Unable to stop OST1"
813 stop_ost2 || error "Unable to stop OST2"
814 stop_mds || error "Unable to stop MDS"
816 #writeconf to remove all ost2 traces for subsequent tests
817 writeconf_or_reformat
818 KEEP_ZPOOL="${zkeeper}"
820 start_mgs || error "unable to start MGS"
822 run_test 21d "start mgs then ost and then mds"
825 MGSNID="$saved_mgsnid"
827 echo "stopping fs2mgs ..."
828 stop $fs2mgs -f || true
831 test_21e() { # LU-5863
832 if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
833 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
834 skip_env "mixed loopback and real device not working"
837 local fs2mdsdev=$(mdsdevname 1_2)
838 local fs2ostdev=$(ostdevname 1_2)
839 local fs3ostdev=$(ostdevname 2_2)
841 local fs2mdsvdev=$(mdsvdevname 1_2)
842 local fs2ostvdev=$(ostvdevname 1_2)
843 local fs3ostvdev=$(ostvdevname 2_2)
845 # temporarily use fs3ost as fs2mgs
847 local fs2mgsdev=$fs3ostdev
848 local fs2mgsvdev=$fs3ostvdev
850 local fsname=test1234
852 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
853 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
854 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS && trap cleanup_21e EXIT INT ||
855 error "start fs2mgs failed"
857 local saved_mgsnid="$MGSNID"
858 MGSNID=$(do_facet $fs2mgs $LCTL list_nids | xargs | tr ' ' ,)
860 add fs2mds $(mkfs_opts mds1 $fs2mdsdev $fsname) \
861 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
862 add fs2ost $(mkfs_opts ost1 $fs2ostdev $fsname) \
863 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
865 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
866 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
868 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
869 $MOUNT_CMD $MGSNID:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
870 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
874 run_test 21e "separate MGS and MDS"
877 start_mds || error "MDS start failed"
879 echo "Client mount with ost in logs, but none running"
880 start_ost || error "unable to start OST1"
881 # wait until mds connected to ost and open client connection
882 wait_osc_import_state mds ost FULL
883 stop_ost || error "unable to stop OST1"
884 mount_client $MOUNT || error "mount_client $MOUNT failed"
885 # check_mount will block trying to contact ost
886 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
887 rm -f $DIR/$tfile || error "remove $DIR/$tfile failed"
888 umount_client $MOUNT -f
891 echo "Client mount with a running ost"
892 start_ost || error "unable to start OST1"
894 # if gss enabled, wait full time to let connection from
895 # mds to ost be established, due to the mismatch between
896 # initial connect timeout and gss context negotiation timeout.
897 # This perhaps could be remove after AT landed.
898 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
899 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
901 mount_client $MOUNT || error "mount_client $MOUNT failed"
902 wait_osc_import_state mds ost FULL
903 wait_osc_import_ready client ost
904 check_mount || error "check_mount failed"
907 cleanup || error "cleanup failed with rc $?"
909 run_test 22 "start a client before osts (should return errs)"
911 test_23a() { # was test_23
914 stop $SINGLEMDS || error "failed to stop $SINGLEMDS"
915 # force down client so that recovering mds waits for reconnect
916 local running=$(grep -c $MOUNT /proc/mounts) || true
917 if [ $running -ne 0 ]; then
918 echo "Stopping client $MOUNT (opts: -f)"
922 # enter recovery on failed mds
923 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
924 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "MDS start failed"
925 # try to start a new client
926 mount_client $MOUNT &
928 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
929 MOUNT_LUSTRE_PID=$(ps -ef | grep mount.lustre |
930 grep -v grep | awk '{print $2}')
931 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
933 ps --ppid $MOUNT_LUSTRE_PID
934 echo "waiting for mount to finish"
936 # "ctrl-c" sends SIGINT but it usually (in script) does not work on child process
937 # SIGTERM works but it does not spread to offspring processses
938 kill -s TERM $MOUNT_PID
939 kill -s TERM $MOUNT_LUSTRE_PID
940 # we can not wait $MOUNT_PID because it is not a child of this shell
946 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
948 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
949 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
952 [ -z "$PID1" -a -z "$PID2" ] && break
953 echo "waiting for mount to finish ... "
954 WAIT=$(( WAIT + sleep))
956 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
957 error "MOUNT_PID $MOUNT_PID and "\
958 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
961 cleanup || error "cleanup failed with rc $?"
963 run_test 23a "interrupt client during recovery mount delay"
965 test_23b() { # was test_23
966 start_mds || error "MDS start failed"
967 start_ost || error "Unable to start OST1"
968 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
969 $LCTL set_param fail_loc=0x80000313
971 cleanup || error "cleanup failed with rc $?"
973 run_test 23b "Simulate -EINTR during mount"
976 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
978 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
979 is_blkdev $SINGLEMDS $MDSDEV &&
980 skip_env "mixed loopback and real device not working"
983 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
985 local fs2mdsdev=$(mdsdevname 1_2)
986 local fs2ostdev=$(ostdevname 1_2)
987 local fs2mdsvdev=$(mdsvdevname 1_2)
988 local fs2ostvdev=$(ostvdevname 1_2)
991 # LU-9733 test fsname started with numbers as well
992 local FSNAME2=969362ae
994 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --nomgs --mgsnode=$MGSNID \
995 --fsname=${FSNAME2} --reformat $fs2mdsdev $fs2mdsvdev || exit 10
997 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --fsname=${FSNAME2} \
998 --reformat $fs2ostdev $fs2ostvdev || exit 10
1001 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
1002 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1003 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
1004 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
1006 # LU-9733 test fsname started with numbers
1007 cl_user=$(do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
1008 changelog_register -n) ||
1009 error "register changelog failed"
1011 do_facet $SINGLEMDS lctl --device $FSNAME2-MDT0000 \
1012 changelog_deregister $cl_user ||
1013 error "deregister changelog failed"
1015 check_mount || error "check_mount failed"
1016 # files written on 1 should not show up on 2
1017 cp /etc/passwd $DIR/$tfile
1019 [ -e $MOUNT2/$tfile ] && error "File bleed"
1022 cp /etc/passwd $MOUNT2/$tfile ||
1023 error "cp /etc/passwd $MOUNT2/$tfile failed"
1024 rm $MOUNT2/$tfile || error "remove $MOUNT2/$tfile failed"
1025 # 2 is actually mounted
1026 grep $MOUNT2' ' /proc/mounts > /dev/null || error "$MOUNT2 not mounted"
1028 facet_failover fs2mds
1029 facet_failover fs2ost
1031 umount_client $MOUNT
1032 # the MDS must remain up until last MDT
1034 MDS=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1035 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1036 [ -z "$MDS" ] && error "No MDT"
1038 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1040 run_test 24a "Multiple MDTs on a single node"
1043 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1045 skip "needs combined MGT and MDT device"
1047 if [ -z "$fs2mds_DEV" ]; then
1048 local dev=${SINGLEMDS}_dev
1049 local MDSDEV=${!dev}
1050 is_blkdev $SINGLEMDS $MDSDEV &&
1051 skip_env "mixed loopback and real device not working"
1054 local fs2mdsdev=$(mdsdevname 1_2)
1055 local fs2mdsvdev=$(mdsvdevname 1_2)
1057 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
1058 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
1060 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && {
1062 error "start MDS should fail"
1065 cleanup || error "cleanup failed with rc $?"
1067 run_test 24b "Multiple MGSs on a single node (should return err)"
1071 check_mount || error "check_mount failed"
1072 local MODULES=$($LCTL modules | awk '{ print $2 }')
1073 rmmod $MODULES 2>/dev/null || true
1074 cleanup || error "cleanup failed with $?"
1076 run_test 25 "Verify modules are referenced"
1080 # we need modules before mount for sysctl, so make sure...
1081 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
1082 #define OBD_FAIL_MDS_FS_SETUP 0x135
1083 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000135"
1084 start_mds && error "MDS started but should not have started"
1085 $LCTL get_param -n devices
1086 DEVS=$($LCTL get_param -n devices | egrep -v MG | wc -l)
1087 [ $DEVS -gt 0 ] && error "number of devices is $DEVS, should be zero"
1088 # start mds to drop writeconf setting
1089 start_mds || error "Unable to start MDS"
1090 stop_mds || error "Unable to stop MDS"
1091 unload_modules_conf || error "unload_modules_conf failed with $?"
1093 run_test 26 "MDT startup failure cleans LOV (should return errs)"
1097 start_ost || error "Unable to start OST1"
1098 start_mds || error "Unable to start MDS"
1099 echo "Requeue thread should have started: "
1100 ps -e | grep ll_cfg_requeue
1101 set_persistent_param_and_check ost1 \
1102 "obdfilter.$FSNAME-OST0000.client_cache_seconds" \
1103 "$FSNAME-OST0000.ost.client_cache_seconds"
1104 cleanup_nocli || error "cleanup_nocli failed with rc $?"
1106 run_test 27a "Reacquire MGS lock if OST started first"
1111 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
1112 awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
1114 facet_failover $SINGLEMDS
1115 set_persistent_param_and_check $SINGLEMDS \
1116 "mdt.$device.identity_acquire_expire" \
1117 "$device.mdt.identity_acquire_expire"
1118 set_persistent_param_and_check client \
1119 "mdc.$device-mdc-*.max_rpcs_in_flight" \
1120 "$device.mdc.max_rpcs_in_flight"
1122 cleanup || error "cleanup failed with $?"
1124 run_test 27b "Reacquire MGS lock after failover"
1126 test_28A() { # was test_28
1129 local TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
1130 local PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
1131 local orig=$($LCTL get_param -n $TEST)
1132 local max=$($LCTL get_param -n \
1133 llite.$FSNAME-*.max_read_ahead_per_file_mb)
1135 orig=${orig%%.[0-9]*}
1137 echo "ORIG:$orig MAX:$max"
1138 [[ $max -le $orig ]] && orig=$((max - 3))
1139 echo "ORIG:$orig MAX:$max"
1141 local final=$((orig + 1))
1143 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1144 final=$((final + 1))
1145 set_persistent_param_and_check client "$TEST" "$PARAM" $final
1146 umount_client $MOUNT || error "umount_client $MOUNT failed"
1147 mount_client $MOUNT || error "mount_client $MOUNT failed"
1149 local result=$($LCTL get_param -n $TEST)
1151 if [ $result -ne $final ]; then
1152 error "New config not seen: wanted $final got $result"
1154 echo "New config success: got $result"
1156 set_persistent_param_and_check client "$TEST" "$PARAM" $orig
1157 cleanup || error "cleanup failed with rc $?"
1159 run_test 28A "permanent parameter setting"
1161 test_28a() { # LU-4221
1162 [[ "$OST1_VERSION" -ge $(version_code 2.5.52) ]] ||
1163 skip "Need OST version at least 2.5.52"
1164 [ "$ost1_FSTYPE" = zfs ] &&
1165 skip "LU-4221: no such proc params for ZFS OSTs"
1172 local device="$FSNAME-OST0000"
1176 # In this test we will set three kinds of proc parameters with
1177 # lctl set_param -P or lctl conf_param:
1178 # 1. non-symlink ones in the OFD
1179 # 2. non-symlink ones in the OSD
1182 # prepare a non-symlink parameter in the OFD
1183 name="client_cache_seconds"
1184 param="$device.ost.$name"
1185 cmd="obdfilter.$device.$name"
1187 # permanently setting the parameter in the OFD
1188 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1190 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1191 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1194 # prepare a non-symlink parameter in the OSD
1196 param="$device.osd.$name"
1197 cmd="osd-*.$device.$name"
1199 # conf_param the parameter in the OSD
1200 old=$(do_facet ost1 $LCTL get_param -n $cmd)
1201 new=$(((old + 1) % 2))
1202 set_persistent_param_and_check ost1 "$cmd" "$param" $new
1203 set_persistent_param_and_check ost1 "$cmd" "$param" $old
1205 cleanup || error "cleanup failed with $?"
1207 run_test 28a "set symlink parameters permanently with lctl"
1210 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
1211 setup_noconfig > /dev/null 2>&1
1212 start_ost2 || error "Unable to start OST2"
1215 local PARAM="$FSNAME-OST0001.osc.active"
1216 # With lctl set_param -P the value $PROC_ACT will be sent to
1217 # all nodes. The [!M] filter out the ability to set active
1218 # on the MDS servers which is tested with wait_osp_* below.
1219 # For ost_server_uuid that only exist on client so filtering
1221 local PROC_ACT="os[cp].$FSNAME-OST0001-osc-[^M]*.active"
1222 local PROC_UUID="os[cp].$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1224 ACTV=$($LCTL get_param -n $PROC_ACT)
1226 set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
1227 # also check ost_server_uuid status
1228 RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV)
1229 if [ -z "$RESULT" ]; then
1230 error "Client not deactivated: $($LCTL get_param \
1233 echo "Live client success: got $RESULT"
1237 wait_osp_active ost ${FSNAME}-OST0001 1 0
1239 # test new client starts deactivated
1240 umount_client $MOUNT || error "umount_client $MOUNT failed"
1241 mount_client $MOUNT || error "mount_client $MOUNT failed"
1243 # the 2nd and 3rd field of ost_server_uuid do not update at the same
1244 # time when using lctl set_param -P
1245 wait_update_facet client \
1246 "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'" \
1248 error "New client start active: $($LCTL get_param -n $PROC_UUID)"
1250 echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
1252 # make sure it reactivates
1253 set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
1255 umount_client $MOUNT
1256 stop_ost2 || error "Unable to stop OST2"
1257 cleanup_nocli || error "cleanup_nocli failed with $?"
1258 #writeconf to remove all ost2 traces for subsequent tests
1259 writeconf_or_reformat
1261 run_test 29 "permanently remove an OST"
1266 echo Big config llog
1267 local path="llite.$FSNAME-*"
1268 local cpath="$FSNAME.llite"
1269 local param="max_read_ahead_whole_mb"
1271 local test="${path}.$param"
1272 local conf="${cpath}.$param"
1274 local orig=$($LCTL get_param -n $test)
1275 local list=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1276 for i in ${list[*]}; do
1277 set_persistent_param_and_check client $test $conf $i
1279 # make sure client restart still works
1280 umount_client $MOUNT
1281 mount_client $MOUNT || error "mount_client $MOUNT failed"
1282 [ "$($LCTL get_param -n $test)" -ne "$i" ] &&
1283 error "Param didn't stick across restart $($test) != $i"
1286 echo Erase parameter setting
1287 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1288 do_facet mgs "$PERM_CMD -d $test" ||
1289 error "Erase param $test failed"
1291 do_facet mgs "$PERM_CMD -d $conf" ||
1292 error "Erase param $conf failed"
1294 umount_client $MOUNT
1295 mount_client $MOUNT || error "mount_client $MOUNT failed"
1296 local final=$($LCTL get_param -n $test)
1297 echo "deleted (default) value=$final, orig=$orig"
1298 orig=${orig%%.[0-9]*}
1299 final=${final%%.[0-9]*}
1300 # assumes this parameter started at the default value
1301 [ "$final" -eq "$orig" ] ||
1302 error "Deleted value=$final -ne orig=$orig"
1304 cleanup || error "cleanup failed with rc $?"
1306 run_test 30a "Big config llog and permanent parameter deletion"
1311 local orignids=$($LCTL get_param -n \
1312 osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1314 local orignidcount=$(echo "$orignids" | wc -w)
1316 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1317 # numerical part of it. Hopefully that's not already a failover address
1319 local OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | \
1321 local ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1322 local NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1323 local NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1324 echo "Using fake nid $NEW"
1326 local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1327 grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1328 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1329 PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
1330 echo "Setting $PARAM from $TEST to $NEW"
1331 do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
1332 error "$PERM_CMD $PARAM failed"
1334 PARAM="$FSNAME-OST0000.failover.node"
1335 echo "Setting $PARAM from $TEST to $NEW"
1336 do_facet mgs "$PERM_CMD $PARAM='$NEW'" ||
1337 error "$PARAM $PARAM failed"
1339 wait_update_facet client "$TEST" "$NEW" ||
1340 error "check $PARAM failed!"
1342 local NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1344 local NIDCOUNT=$(echo "$NIDS" | wc -w)
1345 echo "should have $((orignidcount + 1)) entries \
1346 in failover nids string, have $NIDCOUNT"
1347 [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
1348 error "Failover nid not added"
1350 if [[ $PERM_CMD == *"set_param -P"* ]]; then
1351 do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
1353 do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
1354 error "$PERM_CMD delete failed"
1356 umount_client $MOUNT
1357 mount_client $MOUNT || error "mount_client $MOUNT failed"
1359 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
1361 NIDCOUNT=$(echo "$NIDS" | wc -w)
1362 echo "only $orignidcount final entries should remain \
1363 in failover nids string, have $NIDCOUNT"
1364 [ $NIDCOUNT -eq $orignidcount ] || error "Failover nids not removed"
1366 cleanup || error "cleanup failed with rc $?"
1368 run_test 30b "Remove failover nids"
1370 test_31() { # bug 10734
1371 # ipaddr must not exist
1372 $MOUNT_CMD 4.3.2.1@tcp:/lustre $MOUNT || true
1373 cleanup || error "cleanup failed with rc $?"
1375 run_test 31 "Connect to non-existent node (shouldn't crash)"
1379 T32_BLIMIT=40960 # Kbytes
1382 T32_PROLIMIT=$((T32_BLIMIT/10))
1384 # This is not really a test but a tool to create new disk
1385 # image tarballs for the upgrade tests.
1387 # Disk image tarballs should be created on single-node
1388 # clusters by running this test with default configurations
1389 # plus a few mandatory environment settings that are verified
1390 # at the beginning of the test.
1392 test_32newtarball() {
1396 local tmp=$TMP/t32_image_create
1407 local pj_quota_file_old
1410 if [ $FSNAME != t32fs -o \( -z "$MDSDEV" -a -z "$MDSDEV1" \) -o \
1411 $OSTCOUNT -ne 2 -o -z "$OSTDEV1" ]; then
1412 error "Needs FSNAME=t32fs MDSCOUNT=2 " \
1413 "MDSDEV1=<nonexistent_file> " \
1414 "MDSDEV2=<nonexistent_file> " \
1415 "(or MDSDEV, in the case of b1_8) " \
1416 "OSTCOUNT=2 OSTDEV1=<nonexistent_file> " \
1417 "OSTDEV2=<nonexistent_file>"
1421 echo "Found stale $tmp"
1425 mkdir $tmp/src || return 1
1426 tar cf - -C $src . | tar xf - -C $tmp/src
1428 # format ost with comma-separated NIDs to verify LU-4460
1429 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
1430 MGSNID="$MGSNID,$MGSNID" OSTOPT="--failnode=$failnid" formatall
1434 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1435 $LFS quotacheck -ug /mnt/$FSNAME
1436 $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
1439 if [[ $MDSCOUNT -ge 2 ]]; then
1440 remote_dir=/mnt/$FSNAME/remote_dir
1441 $LFS mkdir -i 1 $remote_dir
1442 tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1444 target_dir=$remote_dir
1445 if [[ $MDS1_VERSION -ge $(version_code 2.7.0) ]]; then
1446 striped_dir=/mnt/$FSNAME/striped_dir_old
1447 $LFS mkdir -i 1 -c 2 $striped_dir
1448 tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1451 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1452 target_dir=/mnt/$FSNAME
1455 # add project quota #
1456 [[ $mds1_FSTYPE == "ldiskfs" &&
1457 $MDS1_VERSION -gt $(version_code 2.9.55) ]] ||
1458 [[ $mds1_FSTYPE == "zfs" &&
1459 $MDS1_VERSION -gt $(version_code 2.10.53) ]] && {
1460 pj_quota_dir=$target_dir/project_quota_dir
1461 pj_quota_file_old=$pj_quota_dir/pj_quota_file_old
1463 enable_project_quota
1464 set_mdt_qtype ugp ||
1465 error "enable mdt quota failed"
1467 set_ost_qtype ugp ||
1468 error "enable ost quota failed"
1470 mkdir -p $pj_quota_dir
1471 $LFS setquota -p $T32_PRJID -b 0 -B $T32_PROLIMIT -i 0 \
1472 -I $T32_ILIMIT $pj_quota_dir ||
1473 error "setquota -p $T32_PRJID failed"
1475 $LFS setstripe $pj_quota_file_old -c 1 ||
1476 error "setstripe $pj_quota_file_old failed"
1478 chown $T32_QID:$T32_QID $pj_quota_file_old ||
1479 error "chown $pj_quota_file_old failed"
1481 change_project -p $T32_PRJID $pj_quota_file_old
1483 mkdir -p $tmp/src/project_quota_dir
1484 cp $pj_quota_file_old $tmp/src/project_quota_dir/
1487 #####################
1488 tar cf - -C $tmp/src . | tar xf - -C /mnt/$FSNAME
1490 #if [[ $MDSCOUNT -ge 2 ]]; then
1491 # remote_dir=/mnt/$FSNAME/remote_dir
1492 # $LFS mkdir -i 1 $remote_dir
1493 # tar cf - -C $tmp/src . | tar xf - -C $remote_dir
1495 # if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1496 # striped_dir=/mnt/$FSNAME/striped_dir_old
1497 # $LFS mkdir -i 1 -c 2 $striped_dir
1498 # tar cf - -C $tmp/src . | tar xf - -C $striped_dir
1503 if [[ $MDS1_VERSION -ge $(version_code 2.9.51) ]]; then
1504 pfl_dir=$target_dir/pfl_dir
1505 pfl_file=$pfl_dir/pfl_file
1507 $LFS setstripe -E 2M -c 1 -o 0 -E -1 -S 2M -c 1 -o 1 \
1509 error "Create PFL file failed"
1511 dd if=/dev/urandom of=$pfl_file bs=1k count=3k
1512 mkdir -p $tmp/src/pfl_dir
1513 cp $pfl_file $tmp/src/pfl_dir/
1518 if [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]]; then
1519 dom_dir=$target_dir/dom_dir
1520 dom_file=$dom_dir/dom_file
1521 flr_dir=$target_dir/flr_dir
1522 flr_file=$flr_dir/flr_file
1525 $LFS setstripe -E 1M -L mdt -E -1 -S 4M $dom_file
1526 dd if=/dev/urandom of=$dom_file bs=1k count=2k
1527 mkdir -p $tmp/src/dom_dir
1528 cp $dom_file $tmp/src/dom_dir
1531 $LFS mirror create -N2 $flr_file
1532 dd if=/dev/urandom of=$flr_file bs=1k count=1
1533 mkdir -p $tmp/src/flr_dir
1534 cp $flr_file $tmp/src/flr_dir
1538 local large_xattr_dir=/mnt/$FSNAME/large_xattr_test_dir
1539 local xattr_file=$large_xattr_dir/large_xattr_file
1541 mkdir $large_xattr_dir
1543 setfattr -n user.fooattr -v $(printf "%c" {1..4096} ) $xattr_file ||
1548 mkdir $tmp/img || return 1
1552 pushd_dir=/mnt/$FSNAME
1553 if [[ $MDSCOUNT -ge 2 ]]; then
1554 pushd_dir=$remote_dir
1555 if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
1557 BLOCKSIZE=1024 ls -Rni --time-style=+%s >$tmp/img/list2
1563 BLOCKSIZE=1024 ls -Rni --time-style=+%s >$tmp/img/list
1564 find ! -name .lustre -type f -exec sha1sum {} \; |
1565 sort -k 2 >$tmp/img/sha1sums
1567 $LCTL get_param -n version | head -n 1 |
1568 sed -e 's/^lustre: *//' >$tmp/img/commit
1570 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1571 $LFS quotaon -ug /mnt/$FSNAME
1572 $LFS quota -u $T32_QID -v /mnt/$FSNAME
1573 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1574 awk 'BEGIN { num='1' } { if ($1 == "'/mnt/$FSNAME'") \
1575 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1576 | tr -d "*" > $tmp/img/bspace
1577 $LFS quota -v -u $T32_QID /mnt/$FSNAME |
1578 awk 'BEGIN { num='5' } { if ($1 == "'/mnt/$FSNAME'") \
1579 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1580 | tr -d "*" > $tmp/img/ispace
1581 echo $T32_BLIMIT > $tmp/img/blimit
1582 echo $T32_ILIMIT > $tmp/img/ilimit
1584 $MULTIOP /mnt/$FSNAME/orph_file Ouw_c&
1588 debugfs -R "ls /PENDING" ${MDSDEV1:-$MDSDEV}
1589 cp ${MDSDEV1:-$MDSDEV} $tmp/img
1598 find -type f -exec sha1sum {} \; | sort -k 2 >$tmp/sha1sums.src
1601 if ! diff -u $tmp/sha1sums.src $tmp/img/sha1sums; then
1602 echo "Data verification failed"
1605 uname -r >$tmp/img/kernel
1606 uname -m >$tmp/img/arch
1608 for ((num=1; num <= $MDSCOUNT; num++)); do
1609 local devname=$(mdsdevname $num)
1613 [[ num -eq 1 ]] && image_name=mdt || image_name=mdt$num
1614 [[ $(facet_fstype $facet) != zfs ]] ||
1615 devname=$(mdsvdevname $num)
1616 dd conv=sparse bs=4k if=$devname of=$tmp/img/$image_name
1619 for ((num=1; num <= $OSTCOUNT; num++)); do
1620 local devname=$(ostdevname $num)
1624 [[ num -eq 1 ]] && image_name=ost || image_name=ost$num
1625 [[ $(facet_fstype $facet) != zfs ]] ||
1626 devname=$(ostdevname $num)
1627 dd conv=sparse bs=4k if=$devname of=$tmp/img/$image_name
1630 version=$(sed -e 's/\(^[0-9]\+\.[0-9]\+\)\(.*$\)/\1/' $tmp/img/commit |
1631 sed -e 's/\./_/g') # E.g., "1.8.7" -> "1_8"
1634 tar cjvf $dst/disk$version-"$mds1_FSTYPE".tar.bz2 -S *
1639 # run_test 32newtarball "Create a new test_32 disk image tarball for this version"
1642 # The list of applicable tarballs is returned via the caller's
1643 # variable "tarballs".
1646 [ "$CLIENTONLY" ] && skip "Client-only testing"
1648 check_versions || skip "do not upgrade with mismatched client/server"
1650 local node=$(facet_active_host $SINGLEMDS)
1651 local r="do_node $node"
1653 ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
1655 local IMGTYPE="$mds1_FSTYPE"
1657 [[ -n "$T32IMAGE" ]] && tarballs=$T32IMAGE ||
1658 tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
1659 -name \'disk*-$IMGTYPE.tar.bz2\')
1661 [ -z "$tarballs" ] && skip "No applicable tarballs found"
1664 t32_test_cleanup() {
1666 local facet=$SINGLEMDS
1669 echo "== cleanup with rc=$rc =="
1670 if $shall_cleanup_lustre; then
1671 umount $tmp/mnt/lustre || rc=$?
1673 if $shall_cleanup_mdt; then
1674 $r $UMOUNT $tmp/mnt/mdt || rc=$?
1676 if $shall_cleanup_mdt1; then
1677 $r $UMOUNT $tmp/mnt/mdt1 || rc=$?
1679 if $shall_cleanup_ost; then
1680 $r $UMOUNT $tmp/mnt/ost || rc=$?
1682 if $shall_cleanup_ost1; then
1683 $r $UMOUNT $tmp/mnt/ost1 || rc=$?
1688 if [[ "$mds1_FSTYPE" == zfs ]]; then
1690 local poolname_list="t32fs-mdt1 t32fs-ost1"
1692 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1694 for poolname in $poolname_list; do
1695 destroy_zpool $facet $poolname
1698 combined_mgs_mds || start_mgs || rc=$?
1702 t32_bits_per_long() {
1704 # Yes, this is not meant to be perfect.
1714 t32_reload_modules() {
1716 local all_removed=false
1719 [ "$mds1_FSTYPE" == zfs ] && do_rpc_nodes $node "service zed stop"
1721 while ((i < 20)); do
1722 echo "Unloading modules on $node: Attempt $i"
1723 do_rpc_nodes $node $LUSTRE_RMMOD "$mds1_FSTYPE" &&
1725 do_rpc_nodes $node check_mem_leak || return 1
1726 if $all_removed; then
1727 do_rpc_nodes $node load_modules
1730 if [ "$mds1_FSTYPE" == zfs ]; then
1731 do_rpc_nodes $node "$ZPOOL status -v"
1736 echo "Unloading modules on $node: Given up"
1740 t32_wait_til_devices_gone() {
1746 echo wait for devices to go
1747 while ((i < 20)); do
1748 devices=$(do_rpc_nodes $node $LCTL device_list | wc -l)
1749 loops=$(do_rpc_nodes $node losetup -a | grep -c t32)
1750 ((devices == 0 && loops == 0)) && return 0
1754 echo "waiting for dev on $node: dev $devices loop $loops given up"
1755 do_rpc_nodes $node "losetup -a"
1756 do_rpc_nodes $node "$LCTL device_list"
1760 t32_verify_quota() {
1767 # LU-2435: if the underlying zfs doesn't support userobj_accounting,
1768 # lustre will estimate the object count usage. This fails quota
1769 # verification in 32b. The object quota usage should be accurate after
1770 # zfs-0.7.0 is released.
1771 [ "$mds1_FSTYPE" == zfs ] && {
1772 local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
1774 [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
1775 echo "Skip quota verify for zfs: $zfs_version"
1780 $LFS quota -u $T32_QID -v $mnt
1782 qval=$($LFS quota -v -u $T32_QID $mnt |
1783 awk 'BEGIN { num='1' } { if ($1 == "'$mnt'") \
1784 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1786 [ $qval -eq $img_bspace ] || {
1787 echo "bspace, act:$qval, exp:$img_bspace"
1791 qval=$($LFS quota -v -u $T32_QID $mnt |
1792 awk 'BEGIN { num='5' } { if ($1 == "'$mnt'") \
1793 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1795 [ $qval -eq $img_ispace ] || {
1796 echo "ispace, act:$qval, exp:$img_ispace"
1800 qval=$($LFS quota -v -u $T32_QID $mnt |
1801 awk 'BEGIN { num='3' } { if ($1 == "'$mnt'") \
1802 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1804 [ $qval -eq $img_blimit ] || {
1805 echo "blimit, act:$qval, exp:$img_blimit"
1809 qval=$($LFS quota -v -u $T32_QID $mnt |
1810 awk 'BEGIN { num='7' } { if ($1 == "'$mnt'") \
1811 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1813 [ $qval -eq $img_ilimit ] || {
1814 echo "ilimit, act:$qval, exp:$img_ilimit"
1818 set_persistent_param_and_check $facet \
1819 "osd-$mds1_FSTYPE.$fsname-MDT0000.quota_slave.enabled" \
1820 "$fsname.quota.mdt" ug
1822 set_persistent_param_and_check $facet \
1823 "osd-$mds1_FSTYPE.$fsname-OST0000.quota_slave.enabled" \
1824 "$fsname.quota.ost" ug
1827 runas -u $T32_QID -g $T32_QID dd if=/dev/zero of=$mnt/t32_qf_new \
1828 bs=1M count=$((img_blimit / 1024)) oflag=sync && {
1829 echo "Write succeed, but expect -EDQUOT"
1832 rm -f $mnt/t32_qf_new
1834 runas -u $T32_QID -g $T32_QID createmany -m $mnt/t32_qf_ \
1836 echo "Create succeed, but expect -EDQUOT"
1839 unlinkmany $mnt/t32_qf_ $img_ilimit
1849 sync_all_data > /dev/null 2>&1 || true
1851 [ "$uuid" != "global" ] || uuid=$mnt
1853 $LFS quota -v "$1" "$2" $mnt |
1854 awk 'BEGIN { num='$spec' } { if ($1 == "'$uuid'") \
1855 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
1862 local dne_upgrade=${dne_upgrade:-"no"}
1863 local dom_upgrade=${dom_upgrade:-"no"}
1864 local project_upgrade=${project_upgrade:-"no"}
1865 local ff_convert=${ff_convert:-"no"}
1866 local pfl_upgrade=${pfl_upgrade:-"no"}
1867 local project_quota_upgrade=${project_quota_upgrade:-"no"}
1868 local dom_new_upgrade=${dom_new_upgrade:-"no"}
1869 local flr_upgrade=${flr_upgrade:-"no"}
1870 local shall_cleanup_mdt=false
1871 local shall_cleanup_mdt1=false
1872 local shall_cleanup_ost=false
1873 local shall_cleanup_ost1=false
1874 local shall_cleanup_lustre=false
1875 local mdt2_is_available=false
1876 local ost2_is_available=false
1877 local node=$(facet_active_host $SINGLEMDS)
1878 local r="do_node $node"
1894 local mdt_dev=$tmp/mdt
1895 local mdt2_dev=$tmp/mdt2
1896 local ost_dev=$tmp/ost
1897 local ost2_dev=$tmp/ost2
1901 local pfl_file=$tmp/mnt/lustre/remote_dir/pfl_dir/pfl_file
1902 local flr_file=$tmp/mnt/lustre/remote_dir/flr_dir/flr_file
1903 local dom_file=$tmp/mnt/lustre/remote_dir/dom_dir/dom_file
1904 local quota_dir=$tmp/mnt/lustre/remote_dir/project_quota_dir
1906 combined_mgs_mds || stop_mgs || error "Unable to stop MGS"
1907 trap 'trap - RETURN; t32_test_cleanup' RETURN
1910 nid=$($r $LCTL list_nids | head -1)
1912 mkdir -p $tmp/mnt/lustre || error "mkdir $tmp/mnt/lustre failed"
1913 $r mkdir -p $tmp/mnt/{mdt,mdt1,ost,ost1}
1914 $r tar xjvf $tarball -S -C $tmp || {
1915 error_noexit "Unpacking the disk image tarball"
1918 img_commit=$($r cat $tmp/commit)
1919 img_kernel=$($r cat $tmp/kernel)
1920 img_arch=$($r cat $tmp/arch)
1921 img_bspace=$($r cat $tmp/bspace)
1922 img_ispace=$($r cat $tmp/ispace)
1924 # older images did not have "blimit" and "ilimit" files
1925 # use old values for T32_BLIMIT and T32_ILIMIT
1926 $r test -f $tmp/blimit && img_blimit=$($r cat $tmp/blimit) ||
1928 $r test -f $tmp/ilimit && img_ilimit=$($r cat $tmp/ilimit) ||
1931 echo "Upgrading from $(basename $tarball), created with:"
1932 echo " Commit: $img_commit"
1933 echo " Kernel: $img_kernel"
1934 echo " Arch: $img_arch"
1935 echo "OST version: $(lustre_build_version ost1)"
1937 # The conversion can be made only when both of the following
1938 # conditions are satisfied:
1939 # - ost device img version < 2.3.64
1940 # - ost server version >= 2.5
1941 [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
1942 "$OST1_VERSION" -lt $(version_code 2.5.0) ] &&
1945 ! $r test -f $mdt2_dev || mdt2_is_available=true
1946 ! $r test -f $ost2_dev || ost2_is_available=true
1948 if [[ "$mds1_FSTYPE" == zfs ]]; then
1949 echo "== fstype is zfs =="
1952 local poolname_list="t32fs-mdt1 t32fs-ost1"
1954 ! $mdt2_is_available || poolname_list+=" t32fs-mdt2"
1956 for poolname in $poolname_list; do
1958 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1959 $ZPOOL import -f -d $tmp $poolname"
1962 # upgrade zpool to latest supported features, including
1963 # dnode quota accounting in 0.7.0
1964 $r "$ZPOOL upgrade -a"
1966 mdt_dev=t32fs-mdt1/mdt1
1967 ost_dev=t32fs-ost1/ost1
1968 ! $mdt2_is_available || mdt2_dev=t32fs-mdt2/mdt2
1969 ! $ost2_is_available || ost2_dev=t32fs-ost2/ost2
1970 wait_update_facet $SINGLEMDS "$ZPOOL list |
1971 awk '/^t32fs-mdt1/ { print \\\$1 }'" "t32fs-mdt1" || {
1972 error_noexit "import zfs pool failed"
1975 elif [ "$project_upgrade" != "no" ]; then
1976 echo "== project upgrade =="
1977 ! $r tune2fs -O project $mdt_dev &&
1978 error_noexit "enable project on mdt0 failed" &&
1980 $mdt2_is_available && ! $r tune2fs "-O project" $mdt2_dev &&
1981 error_noexit "enable project on mdt failed" &&
1983 ! $r tune2fs -O project $ost_dev &&
1984 error_noexit "enable project on ost failed" &&
1986 $ost2_is_available && ! $r tune2fs -O project $ost2_dev &&
1987 error_noexit "enable project on ost2 failed" &&
1991 $r $LCTL set_param debug="$PTLDEBUG"
1993 $r $TUNEFS --dryrun $mdt_dev || {
1995 error_noexit "tunefs.lustre before mounting the MDT"
1999 if $mdt2_is_available; then
2000 $r $TUNEFS --dryrun $mdt2_dev || {
2002 error_noexit "tunefs.lustre before mounting the MDT"
2007 if [ "$writeconf" ]; then
2008 echo "== writeconf mdt tunefs and quota =="
2010 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2012 $r $TUNEFS --quota $mdt_dev || {
2014 error_noexit "Enable mdt quota feature"
2018 if [ "$project_quota_upgrade" != "no" ]; then
2019 echo "== enable mdt2 project quota =="
2020 $r $TUNE2FS -O project $mdt_dev || {
2022 error_noexit "tune2fs $mdt_dev failed"
2027 if $mdt2_is_available; then
2028 $r $TUNEFS --quota $mdt2_dev || {
2030 error_noexit "Enable mdt2 quota feature"
2033 if [ "$project_quota_upgrade" != "no" ]; then
2034 echo "== enable mdt2 project quota =="
2035 $r $TUNE2FS -O project $mdt2_dev || {
2038 "tune2fs $mdt2_dev failed"
2045 echo "== replace nids =="
2046 if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
2047 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
2048 skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
2049 "(Need MGS version at least 2.3.59)"
2052 local osthost=$(facet_active_host ost1)
2053 local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
2056 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2059 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
2060 $r $LCTL replace_nids $fsname-OST0000 $ostnid || {
2062 error_noexit "replace_nids $fsname-OST0000 $ostnid failed"
2065 if $ost2_is_available; then
2066 $r $LCTL replace_nids $fsname-OST0001 $ostnid || {
2068 error_noexit "replace_nids $fsname-OST0001 $ostnid failed"
2072 $r $LCTL replace_nids $fsname-MDT0000 $nid || {
2074 error_noexit "replace_nids $fsname-MDT0000 $nid failed"
2077 if $mdt2_is_available; then
2078 $r $LCTL replace_nids $fsname-MDT0001 $nid || {
2080 error_noexit "replace_nids $fsname-MDT0001 $nid failed"
2084 $r $UMOUNT $tmp/mnt/mdt
2086 mopts=exclude=$fsname-OST0000
2087 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2092 t32_wait_til_devices_gone $node
2094 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2096 error_noexit "Mounting the MDT"
2099 shall_cleanup_mdt=true
2101 if $mdt2_is_available; then
2102 echo "== mdt2 available =="
2103 mopts=mgsnode=$nid,$mopts
2104 $r $MOUNT_CMD -o $mopts $mdt2_dev $tmp/mnt/mdt1 || {
2106 error_noexit "Mounting the MDT"
2109 shall_cleanup_mdt1=true
2110 echo "== mount new MDT $mdt2_dev =="
2112 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 || {
2113 error_noexit "enable remote dir create failed"
2117 elif [ "$dne_upgrade" != "no" ]; then
2118 local fs2mdsdev=$(mdsdevname 1_2)
2119 local fs2mdsvdev=$(mdsvdevname 1_2)
2121 echo "== mkfs new MDT on ${fs2mdsdev} =="
2122 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2123 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
2126 add $SINGLEMDS $(mds2failover_HOST="" \
2127 mkfs_opts mds2 $fs2mdsdev $fsname) --reformat \
2128 $mkfsoptions $fs2mdsdev $fs2mdsvdev > /dev/null || {
2129 error_noexit "Mkfs new MDT failed"
2133 [[ "$mds1_FSTYPE" != zfs ]] || import_zpool mds1
2135 $r $TUNEFS --dryrun $fs2mdsdev || {
2136 error_noexit "tunefs.lustre before mounting the MDT"
2140 echo "== mount new MDT....$fs2mdsdev =="
2141 $r $MOUNT_CMD -o $mopts $fs2mdsdev $tmp/mnt/mdt1 || {
2142 error_noexit "mount mdt1 failed"
2146 $r $LCTL set_param -n mdt.${fsname}*.enable_remote_dir=1 ||
2147 error_noexit "enable remote dir create failed"
2149 shall_cleanup_mdt1=true
2152 uuid=$($r $LCTL get_param -n mdt.$fsname-MDT0000.uuid) || {
2153 error_noexit "Getting MDT UUID"
2156 if [ "$uuid" != $fsname-MDT0000_UUID ]; then
2157 error_noexit "Unexpected MDT UUID: \"$uuid\""
2161 $r $TUNEFS --dryrun $ost_dev || {
2162 error_noexit "tunefs.lustre before mounting the OST"
2166 if $ost2_is_available; then
2167 $r $TUNEFS --dryrun $ost2_dev || {
2168 error_noexit "tunefs.lustre before mounting the OST"
2173 if [ "$writeconf" ]; then
2174 echo "== writeconf and ost quota tunefs =="
2175 mopts=mgsnode=$nid,$writeconf
2176 if [ "$ost1_FSTYPE" == ldiskfs ]; then
2178 $r $TUNEFS --quota $ost_dev || {
2180 error_noexit "Enable ost quota feature"
2184 if [ "$project_quota_upgrade" != "no" ]; then
2185 echo "== enable ost project quota =="
2186 $r $TUNE2FS -O project $ost_dev || {
2188 error_noexit "tune2fs $ost_dev failed"
2193 if $ost2_is_available; then
2194 $r $TUNEFS --quota $ost2_dev || {
2196 error_noexit "Enable ost2 quota feature"
2199 if [ "$project_quota_upgrade" != "no" ]; then
2200 echo "== enable ost2 project quota =="
2201 $r $TUNE2FS -O project $ost2_dev || {
2204 "tune2fs $ost2_dev failed"
2212 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2217 $r $MOUNT_CMD -onomgs -o$mopts $ost_dev $tmp/mnt/ost || {
2218 error_noexit "Mounting the OST"
2222 if $ost2_is_available; then
2223 $r $MOUNT_CMD -onomgs -o$mopts $ost2_dev $tmp/mnt/ost1 || {
2224 error_noexit "Mounting the OST2"
2227 shall_cleanup_ost1=true
2230 shall_cleanup_ost=true
2232 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0000.uuid) || {
2233 error_noexit "Getting OST UUID"
2236 if [ "$uuid" != $fsname-OST0000_UUID ]; then
2237 error_noexit "Unexpected OST UUID: \"$uuid\""
2241 if $ost2_is_available; then
2242 uuid=$($r $LCTL get_param -n obdfilter.$fsname-OST0001.uuid) ||{
2243 error_noexit "Getting OST1 UUID"
2246 if [ "$uuid" != $fsname-OST0001_UUID ]; then
2247 error_noexit "Unexpected OST1 UUID: \"$uuid\""
2252 if [[ $PERM_CMD =~ "set_param" ]]; then
2253 echo "== perm cmd = '$PERM_CMD' =="
2254 $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
2255 error_noexit "Setting OST \"failover.node\""
2258 $r $PERM_CMD mdc.$fsname-MDT0000*.import=connection=$nid || {
2259 error_noexit "Setting MDT \"failover.node\""
2262 $r $PERM_CMD osc.$fsname-OST0000-*.max_dirty_mb=15 || {
2263 error_noexit "Setting \"max_dirty_mb\""
2266 $r $PERM_CMD mdc.$fsname-MDT0000-*.max_rpcs_in_flight=9 || {
2267 error_noexit "Setting \"max_rpcs_in_flight\""
2270 $r $PERM_CMD lov.$fsname-MDT0000-*.stripesize=4M || {
2271 error_noexit "Setting \"lov.stripesize\""
2274 $r $PERM_CMD mdd.$fsname-MDT0000-*.atime_diff=70 || {
2275 error_noexit "Setting \"mdd.atime_diff\""
2279 echo "== perm cmd = '$PERM_CMD' =="
2280 $r $PERM_CMD $fsname-OST0000.failover.node=$nid || {
2281 error_noexit "Setting OST \"failover.node\""
2285 $r $PERM_CMD $fsname-MDT0000.failover.node=$nid || {
2286 error_noexit "Setting MDT \"failover.node\""
2290 $r $PERM_CMD $fsname-OST0000.osc.max_dirty_mb=15 || {
2291 error_noexit "Setting \"max_dirty_mb\""
2294 $r $PERM_CMD $fsname-MDT0000.mdc.max_rpcs_in_flight=9 || {
2295 error_noexit "Setting \"max_rpcs_in_flight\""
2298 $r $PERM_CMD $fsname-MDT0000.lov.stripesize=4M || {
2299 error_noexit "Setting \"lov.stripesize\""
2302 $r $PERM_CMD $fsname-MDT0000.mdd.atime_diff=70 || {
2303 error_noexit "Setting \"mdd.atime_diff\""
2308 $r $LCTL pool_new $fsname.interop || {
2309 error_noexit "Setting \"interop\""
2313 if [ "$ff_convert" != "no" -a "$ost1_FSTYPE" == ldiskfs ]; then
2314 echo "== ff convert ($ff_convert) =="
2315 $r $LCTL lfsck_start -M $fsname-OST0000 || {
2316 error_noexit "Start OI scrub on OST0"
2320 # The oi_scrub should be on ost1, but for test_32(),
2321 # all on the SINGLEMDS.
2322 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
2323 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2324 awk '/^status/ { print \\\$2 }'" "completed" 30 || {
2325 error_noexit "Failed to get the expected 'completed'"
2329 local UPDATED=$($r $LCTL get_param -n \
2330 osd-ldiskfs.$fsname-OST0000.oi_scrub |
2331 awk '/^updated/ { print $2 }')
2332 [ $UPDATED -ge 1 ] || {
2333 error_noexit "Only $UPDATED objects have been converted"
2338 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2339 echo "== dne upgrate ($dne_upgrade) or mdt2 available =="
2340 if [[ $PERM_CMD =~ "set_param" ]]; then
2341 $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
2342 error_noexit "Setting MDT1 \"failover.node\""
2346 $r $PERM_CMD mdc.$fsname-MDT0001-*.max_rpcs_in_flight=9 || {
2347 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2350 $r $PERM_CMD lov.$fsname-MDT0001-*.stripesize=4M || {
2351 error_noexit "Setting MDT1 \"lov.stripesize\""
2355 $r $PERM_CMD $fsname-MDT0001.failover.node=$nid || {
2356 error_noexit "Setting MDT1 \"failover.node\""
2359 $r $PERM_CMD $fsname-MDT0001.mdc.max_rpcs_in_flight=9 || {
2360 error_noexit "Setting MDT1 \"max_rpcs_in_flight\""
2363 $r $PERM_CMD $fsname-MDT0001.lov.stripesize=4M || {
2364 error_noexit "Setting MDT1 \"lov.stripesize\""
2370 if [ "$writeconf" ]; then
2371 echo "== writeconf and client mount =="
2372 $MOUNT_CMD $nid:/$fsname -o user_xattr $tmp/mnt/lustre || {
2373 error_noexit "Mounting the client"
2377 shall_cleanup_lustre=true
2378 $r $LCTL set_param debug="$PTLDEBUG"
2380 t32_verify_quota $SINGLEMDS $fsname $tmp/mnt/lustre || {
2381 error_noexit "verify quota failed"
2385 if $r test -f $tmp/list; then
2386 echo "== list verification =="
2388 # There is not a Test Framework API to copy files to or
2389 # from a remote node.
2391 # LU-2393 - do both sorts on same node to ensure locale
2393 local list_file=$tmp/list
2395 if $mdt2_is_available; then
2396 if [[ -d $tmp/mnt/lustre/striped_dir_old ]] &&
2397 $r test -f $tmp/list2; then
2398 list_file=$tmp/list2
2399 pushd $tmp/mnt/lustre/striped_dir_old
2401 pushd $tmp/mnt/lustre/remote_dir
2404 pushd $tmp/mnt/lustre
2406 $r cat $list_file | sort -k 6 >$tmp/list.orig
2407 BLOCKSIZE=1024 ls -Rni --time-style=+%s | sort -k 6 |
2408 sed 's/\. / /' >$tmp/list || {
2414 # 32-bit and 64-bit clients use different algorithms to
2415 # convert FIDs into inode numbers. Hence, remove the
2416 # inode numbers from the lists, if the original list was
2417 # created on an architecture with different number of
2420 if [ $(t32_bits_per_long $(uname -m)) != \
2421 $(t32_bits_per_long $img_arch) ]; then
2422 echo "Different number of bits per \"long\"" \
2423 "from the disk image"
2424 for list in list.orig list; do
2425 sed -i -e 's/^[0-9]\+[ \t]\+//' \
2429 if ! diff -ub $tmp/list.orig $tmp/list; then
2430 error_noexit "list verification failed"
2434 echo "== list verification skipped =="
2437 #non-dom upgrade to dom
2438 if [ "$dom_upgrade" != "no" ]; then
2439 echo "== dom upgrade =="
2440 $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
2441 error_noexit "Verify DoM creation"
2444 [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == "mdt" ] || {
2445 error_noexit "Verify a DoM file"
2448 dd if=/dev/urandom of=$tmp/mnt/lustre/dom bs=4096 \
2449 count=1 conv=fsync || {
2450 error_noexit "Cannot write to DoM file"
2453 [ $(stat -c%s $tmp/mnt/lustre/dom) == 4096 ] || {
2454 error_noexit "DoM: bad size after write"
2457 rm $tmp/mnt/lustre/dom
2459 set_persistent_param_and_check mds \
2460 "lod.*MDT0000*.dom_stripesize" \
2461 "$fsname-MDT0000.lod.dom_stripesize" 0 || {
2462 error_noexit "Changing \"dom_stripesize\""
2468 #$LFS setstripe -E 1M -L mdt -E -1 -S 4M $dom_file
2469 if [ "$dom_new_upgrade" != "no" ]; then
2470 if ! $mdt2_is_available; then
2471 dom_file=$tmp/mnt/lustre/dom_dir/dom_file
2473 echo "== check DoM file can be accessed =="
2474 [ $($LFS getstripe -I1 -L $dom_file) == "mdt" ] || {
2475 error_noexit "Verify a DoM file"
2478 [ $(stat -c%s $dom_file) == $((2 * 1024 * 1024)) ] || {
2479 error_noexit "DoM: bad size after write"
2484 if [ "$flr_upgrade" != "no" ]; then
2485 if ! $mdt2_is_available; then
2486 flr_file=$tmp/mnt/lustre/flr_dir/flr_file
2488 local mirror_count=$($LFS getstripe -N $flr_file)
2489 echo "== check FLR file =="
2490 [ $mirror_count == 2 ] || {
2491 error_noexit "FLR mirror count wrong"
2496 if [ "$dne_upgrade" != "no" ]; then
2497 echo "== dne upgrade striped_dir =="
2498 $LFS mkdir -i 1 -c2 $tmp/mnt/lustre/striped_dir || {
2499 error_noexit "set striped dir failed"
2502 $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
2504 pushd $tmp/mnt/lustre
2505 tar -c --exclude=./striped_dir \
2506 --exclude=./striped_dir_old \
2507 --exclude=./remote_dir -f - .|
2508 tar -xvf - -C striped_dir 1>/dev/null || {
2509 error_noexit "cp to striped dir failed"
2515 if [ "$pfl_upgrade" != "no" ]; then
2522 echo "== check PFL file =="
2523 if ! $mdt2_is_available; then
2524 pfl_file=$tmp/mnt/lustre/pfl_dir/pfl_file
2526 comp_cnt=$($LFS getstripe --component-count $pfl_file)
2527 [ $comp_cnt == 2 ] || {
2528 error_noexit "wrong comp_cnt $comp_cnt"
2532 comp_size=$($LFS getstripe -I1 -E $pfl_file)
2533 [ $comp_size == 2097152 ] || {
2534 error_noexit "wrong component size $comp_size"
2538 comp_id=$($LFS getstripe -I1 -i $pfl_file)
2539 [ $comp_id == 0 ] || {
2540 error_noexit "wrong comp id $comp_id"
2544 comp_id=$($LFS getstripe -I2 -i $pfl_file)
2545 [ $comp_id -eq 1 ] || {
2546 error_noexit "wrong comp id $comp_id"
2550 stripe_size=$($LFS getstripe -I1 -S $pfl_file)
2551 [ $stripe_size -eq 1048576 ] || {
2552 error_noexit "wrong stripe size $stripe_size"
2556 stripe_size=$($LFS getstripe -I2 -S $pfl_file)
2557 [ $comp_size -eq 2097152 ] || {
2558 error_noexit "wrong component size $comp_size"
2563 local large_xattr_dir=$tmp/mnt/lustre/large_xattr_test_dir
2565 if [[ -d $large_xattr_dir ]]; then
2566 echo "== check Large EA =="
2567 local xattr_file=$large_xattr_dir/large_xattr_file
2569 xattr_val=$(getfattr --only-values\
2570 -n user.fooattr $xattr_file) || {
2571 error_noexit "Large EA cannot be read"
2575 [[ $xattr_val == $(printf "%c" {1..4096}) ]] || {
2576 error_noexit "Wrong large EA value"
2581 if [ "$project_quota_upgrade" != "no" ]; then
2582 if ! $mdt2_is_available; then
2583 quota_dir=$tmp/mnt/lustre/project_quota_dir
2587 echo "== check Project Quota =="
2588 hardlimit=$(getquota -p $T32_PRJID global 3 \
2590 [ $hardlimit == $T32_PROLIMIT ] || {
2591 error_noexit "wrong hardlimit $hardlimit"
2596 # If it is upgrade from DNE (2.5), then rename the remote dir,
2597 # which is created in 2.5 to striped dir.
2598 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]]; then
2599 echo "== rename remote_dir =="
2600 stripe_index=$($LFS getdirstripe -i \
2601 $tmp/mnt/lustre/remote_dir)
2603 [[ $stripe_index -eq 1 ]] || {
2604 error_noexit "get index \"$stripe_index\"" \
2605 "from remote dir failed"
2608 mv $tmp/mnt/lustre/remote_dir \
2609 $tmp/mnt/lustre/striped_dir/ || {
2610 error_noexit "mv remote dir failed"
2615 # If it is upgraded from DNE (2.7), then move the striped dir
2616 # which was created in 2.7 to the new striped dir.
2617 if $mdt2_is_available && [[ "$dne_upgrade" != "no" ]] &&
2618 echo "== rename striped dir =="
2619 [[ -d $tmp/mnt/lustre/striped_dir_old ]]; then
2620 stripe_count=$($LFS getdirstripe -c \
2621 $tmp/mnt/lustre/striped_dir_old)
2622 [[ $stripe_count -eq 2 ]] || {
2623 error_noexit "get count $stripe_count" \
2624 "from striped dir failed"
2627 mv $tmp/mnt/lustre/striped_dir_old \
2628 $tmp/mnt/lustre/striped_dir/ || {
2629 error_noexit "mv striped dir failed"
2635 $r $LCTL set_param -n osd*.*.force_sync=1
2636 dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
2637 error_noexit "dd failed"
2640 rm -rf $tmp/mnt/lustre/tmp_file || {
2641 error_noexit "rm failed"
2645 if $r test -f $tmp/sha1sums; then
2646 echo "== checking sha1sums =="
2647 # LU-2393 - do both sorts on same node to ensure locale
2649 $r cat $tmp/sha1sums | sort -k 2 >$tmp/sha1sums.orig
2650 if [[ "$dne_upgrade" != "no" ]]; then
2651 if [[ -d $tmp/mnt/lustre/striped_dir/remote_dir ]]; then
2652 pushd $tmp/mnt/lustre/striped_dir/remote_dir
2654 pushd $tmp/mnt/lustre/striped_dir
2656 elif [[ "$pfl_upgrade" != "no" ]] ||
2657 [[ "$flr_upgrade" != "no" ]] ||
2658 [[ "$dom_new_upgrade" != "no" ]] ||
2659 [[ "$project_quota_upgrade" != "no" ]] ||
2660 [[ -d $tmp/mnt/lustre/remote_dir ]]; then
2661 pushd $tmp/mnt/lustre/remote_dir
2663 pushd $tmp/mnt/lustre
2666 find ! -path "*remote_dir*" ! -path "*striped_dir*" \
2667 ! -name .lustre -type f -exec sha1sum {} \; |
2668 sort -k 2 >$tmp/sha1sums || {
2670 error_noexit "sha1sum"
2676 if ! diff -ub $tmp/sha1sums.orig $tmp/sha1sums; then
2677 echo "==** find $save files start **=="
2678 find $save -type f -ls
2679 echo "==** find $save files finish **=="
2680 error_noexit "sha1sum verification failed"
2684 # if upgrade from DNE(2.5), then check remote directory
2685 # if upgrade from DNE(2.7), then check striped directory
2686 if $mdt2_is_available &&
2687 [[ "$dne_upgrade" != "no" ]]; then
2688 echo "== mdt2 upgrade sha1sum check =="
2689 local new_dir="$tmp/mnt/lustre/striped_dir"
2690 local striped_dir_old="$new_dir/striped_dir_old"
2692 local dir_list="$new_dir/remote_dir"
2693 [[ ! -d $triped_dir_old ]] ||
2694 dir_list+=" $striped_dir_old"
2696 for dir in $dir_list; do
2697 echo "== dir = $dir =="
2699 find ! -name .lustre -type f \
2700 -exec sha1sum {} \; |
2701 sort -k 2 >$tmp/sha1sums || {
2704 error_noexit "sha1sum"
2708 if ! diff -ub $tmp/sha1sums.orig \
2711 error_noexit "sha1sum $dir" \
2718 echo "== sha1sum verification skipped =="
2721 # PFL write test after sha1sum check
2722 if [ "$pfl_upgrade" != "no" ]; then
2723 local rw_len=$((3 * 1034 * 1024))
2725 if ! $mdt2_is_available; then
2726 pfl_file=$tmp/mnt/lustre/pfl_dir/pfl_file
2728 small_write $pfl_file $rw_len || {
2729 error_noexit "PFL RW Failed"
2734 if [ "$dne_upgrade" != "no" ]; then
2735 rm -rf $tmp/mnt/lustre/striped_dir || {
2736 error_noexit "remove remote dir failed"
2741 # migrate files/dirs to remote MDT, then move them back
2742 if [ "$MDS1_VERSION" -ge $(version_code 2.7.50) -a \
2743 $dne_upgrade != "no" ]; then
2744 $r $LCTL set_param -n \
2745 mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
2747 echo "== test migration =="
2748 pushd $tmp/mnt/lustre
2749 for dir in $(find ! -name .lustre ! -name . -type d); do
2750 mdt_index=$($LFS getdirstripe -i $dir)
2751 stripe_cnt=$($LFS getdirstripe -c $dir)
2752 if [ $mdt_index = 0 -a $stripe_cnt -le 1 ]; then
2753 $LFS migrate -m 1 $dir || {
2755 error_noexit "migrate MDT1 failed"
2761 for dir in $(find ! -name . ! -name .lustre -type d); do
2762 mdt_index=$($LFS getdirstripe -i $dir)
2763 stripe_cnt=$($LFS getdirstripe -c $dir)
2764 if [ $mdt_index = 1 -a $stripe_cnt -le 1 ]; then
2765 $LFS migrate -m 0 $dir || {
2767 error_noexit "migrate MDT0 failed"
2776 # When adding new data verification tests, please check for
2777 # the presence of the required reference files first, like
2778 # the "sha1sums" and "list" tests above, to avoid the need to
2779 # regenerate every image for each test addition.
2782 nrpcs_orig=$($LCTL get_param \
2783 -n mdc.*MDT0000*.max_rpcs_in_flight) || {
2784 error_noexit "Getting \"max_rpcs_in_flight\""
2787 nrpcs=$((nrpcs_orig + 5))
2789 set_persistent_param_and_check client \
2790 "mdc.$fsname-MDT0000*.max_rpcs_in_flight" \
2791 "$fsname-MDT0000.mdc.max_rpcs_in_flight" $nrpcs || {
2792 error_noexit "Changing \"max_rpcs_in_flight\""
2796 umount $tmp/mnt/lustre || {
2797 error_noexit "Unmounting the client"
2800 shall_cleanup_lustre=false
2802 $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
2803 error_noexit "Mounting the client"
2807 if [ "$mds1_FSTYPE" == ldiskfs -a \
2808 "$project_upgrade" != "no" ]; then
2809 ! $LFS project -d -p 1 $tmp/mnt/lustre/* &&
2810 error_noexit "set project failed" &&
2814 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) == 0 ]] ||
2815 error "MDD orphan cleanup thread not quit"
2817 umount $tmp/mnt/lustre || {
2818 error_noexit "Unmounting the client"
2822 if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
2823 $r $UMOUNT $tmp/mnt/mdt1 || {
2824 error_noexit "Unmounting the MDT2"
2827 if [[ "$mds1_FSTYPE" == zfs ]]; then
2828 $r "$ZPOOL export t32fs-mdt2"
2830 shall_cleanup_mdt1=false
2833 $r $UMOUNT $tmp/mnt/mdt || {
2834 error_noexit "Unmounting the MDT"
2837 if [[ "$mds1_FSTYPE" == zfs ]]; then
2838 $r "$ZPOOL export t32fs-mdt1"
2840 shall_cleanup_mdt=false
2842 $r $UMOUNT $tmp/mnt/ost || {
2843 error_noexit "Unmounting the OST"
2846 if $ost2_is_available; then
2847 $r $UMOUNT $tmp/mnt/ost1 || {
2848 error_noexit "Unmounting the OST1"
2851 shall_cleanup_ost1=false
2854 if [[ $ost1_FSTYPE == zfs ]]; then
2855 $r "$ZPOOL export t32fs-ost1"
2856 if $ost2_is_available; then
2857 $r "$ZPOOL export t32fs-ost2"
2860 shall_cleanup_ost=false
2862 t32_reload_modules $node || {
2863 error_noexit "Reloading modules"
2867 if [[ "$mds1_FSTYPE" == zfs ]]; then
2868 local poolname=t32fs-mdt1
2870 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
2871 $ZPOOL import -f -d $tmp $poolname"
2873 # upgrade zpool to latest supported features,
2874 # including dnode quota accounting in 0.7.0
2875 $r "$ZPOOL upgrade $poolname"
2878 # mount a second time to make sure we didnt leave upgrade flag on
2879 $r $TUNEFS --dryrun $mdt_dev || {
2881 error_noexit "tunefs.lustre before remounting the MDT"
2885 mopts=exclude=$fsname-OST0000
2886 if [ "$mds1_FSTYPE" == ldiskfs ]; then
2889 $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
2890 error_noexit "Remounting the MDT"
2893 shall_cleanup_mdt=true
2903 for tarball in $tarballs; do
2904 banner "testing $tarball upgrade"
2905 t32_test $tarball || let "rc += $?"
2909 run_test 32a "Upgrade (not live)"
2917 for tarball in $tarballs; do
2918 banner "testing $tarball upgrade with writeconf"
2919 t32_test $tarball writeconf || let "rc += $?"
2923 run_test 32b "Upgrade with writeconf"
2931 for tarball in $tarballs; do
2932 banner "testing $tarball upgrade with DNE"
2934 dne_upgrade=yes t32_test $tarball writeconf || rc=$?
2938 run_test 32c "dne upgrade test"
2946 for tarball in $tarballs; do
2947 banner "testing $tarball with filter_fid upgrade"
2948 ff_convert=yes t32_test $tarball || rc=$?
2952 run_test 32d "convert filter_fid upgrade test"
2955 [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
2956 skip "Need MDS version at least 2.10.56"
2963 for tarball in $tarballs; do
2964 [[ "$tarball" =~ "2_9" ]] ||
2965 { echo "skip $(basename $tarball)"; continue; }
2967 banner "testing $tarball upgrade with DoM"
2968 dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
2972 run_test 32e "dom upgrade test"
2975 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
2976 skip "Need MDS version at least 2.10.56"
2983 for tarball in $tarballs; do
2984 [[ "$tarball" =~ "2_10" ]] ||
2985 { echo "skip $(basename $tarball)"; continue; }
2986 pfl_upgrade=yes project_quota_upgrade=yes \
2987 t32_test $tarball writeconf || let "rc += $?"
2991 run_test 32f "pfl upgrade test"
2994 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
2995 skip "Need MDS version at least 2.10.56"
3002 for tarball in $tarballs; do
3003 [[ $tarball =~ "2_12" ]] ||
3004 { echo "skip $(basename $tarball)"; continue; }
3005 flr_upgrade=yes dom_new_upgrade=yes \
3006 t32_test $tarball writeconf || let "rc += $?"
3010 run_test 32g "flr/dom upgrade test"
3012 test_33a() { # bug 12333, was test_33
3013 local FSNAME2=test-$testnum
3015 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3018 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
3020 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
3021 local dev=${SINGLEMDS}_dev
3022 local MDSDEV=${!dev}
3024 is_blkdev $SINGLEMDS $MDSDEV &&
3025 skip_env "mixed loopback and real device not working"
3028 local fs2mdsdev=$(mdsdevname 1_2)
3029 local fs2ostdev=$(ostdevname 1_2)
3030 local fs2mdsvdev=$(mdsvdevname 1_2)
3031 local fs2ostvdev=$(ostvdevname 1_2)
3033 if [ "$mds1_FSTYPE" == ldiskfs ]; then
3034 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
3037 if combined_mgs_mds; then
3038 local mgs_flag="--mgs"
3041 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME2} \
3042 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
3044 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
3045 --fsname=${FSNAME2} --index=0x1fff --reformat $fs2ostdev \
3046 $fs2ostvdev || exit 10
3048 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
3049 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
3051 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3052 do_facet mgs "$PERM_CMD timeout=200" ||
3053 error "$PERM_CMD timeout=200 failed"
3055 do_facet mgs "$PERM_CMD $FSNAME2.sys.timeout=200" ||
3056 error "$PERM_CMD $FSNAME2.sys.timeout=200 failed"
3058 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
3059 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
3062 cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
3063 $LFS getstripe $MOUNT2/hosts ||
3064 error "$LFS getstripe $MOUNT2/hosts failed"
3068 if (( "$MGS_VERSION" >= $(version_code 2.15.51) &&
3069 "$MDS1_VERSION" >= $(version_code 2.15.51) )); then
3070 # test lctl del_ost on large index
3071 do_facet mgs "$LCTL del_ost -t ${FSNAME2}-OST1fff" ||
3072 error "del_ost failed with $?"
3073 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 ||
3074 error "$MOUNT_CMD failed"
3076 $LFS df | grep -q OST1fff &&
3077 error "del_ost did not remove OST1fff!"
3083 cleanup_nocli || error "cleanup_nocli failed with $?"
3085 run_test 33a "Mount ost with a large index number"
3087 test_33b() { # was test_34
3090 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
3091 # Drop lock cancelation reply during umount
3092 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
3093 do_facet client $LCTL set_param fail_loc=0x80000304
3094 #lctl set_param debug=-1
3095 umount_client $MOUNT
3096 cleanup || error "cleanup failed with $?"
3098 run_test 33b "Drop cancel during umount"
3101 (( MDS1_VERSION >= $(version_code 2.15.57) )) ||
3102 skip "Need MDS version at least 2.15.57"
3103 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3104 local tstid=${TSTID:-"$(id -u $TSTUSR)"}
3106 local qpool="qpool1"
3108 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
3110 local fs2mdsdev=$(mdsdevname 1_2)
3111 local fs2ostdev=$(ostdevname 1_2)
3112 local fs2mdsvdev=$(mdsvdevname 1_2)
3113 local fs2ostvdev=$(ostvdevname 1_2)
3115 if [ "$mds1_FSTYPE" == ldiskfs ]; then
3116 mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
3119 if combined_mgs_mds; then
3120 local mgs_flag="--mgs"
3124 stack_trap unload_modules_conf
3126 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --fsname=${FSNAME} \
3127 --reformat $mgs_flag $mkfsoptions $fs2mdsdev $fs2mdsvdev ||
3129 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
3130 --fsname=${FSNAME} --index=0x7c6 --reformat $fs2ostdev \
3131 $fs2ostvdev || exit 10
3134 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
3135 stack_trap "stop fs2mds -f"
3136 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
3137 stack_trap "stop fs2ost -f"
3139 mount_client $MOUNT || error "client start failed"
3140 stack_trap "umount_client $MOUNT"
3141 mkdir_on_mdt0 $DIR/$tdir || error "cannot create $DIR/$tdir"
3142 chmod 0777 $DIR/$tdir || error "chown failed"
3143 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3144 do_facet mgs $PERM_CMD \
3145 osd-*.$FSNAME-OST*.quota_slave.enable=$QUOTA_TYPE
3147 do_facet mgs $PERM_CMD $FSNAME.quota.ost=$QUOTA_TYPE ||
3148 error "set ost quota type failed"
3151 local old_MDSCOUNT=$MDSCOUNT
3153 stack_trap "MDSCOUNT=$old_MDSCOUNT"
3155 pool_add $qpool || error "pool_add failed"
3156 pool_add_targets $qpool 0x7c6
3158 $LFS setquota -u $tstid -B20M -b 0 $MOUNT
3159 $LFS setquota -g $tstid -B20M -b 0 $MOUNT
3160 $LFS setquota -u $tstid -B20M -b 0 --pool $qpool $MOUNT
3161 $LFS setquota -g $tstid -B20M -b 0 --pool $qpool $MOUNT
3163 for i in {1..10}; do
3164 runas -u $tstid -g $tstid dd if=/dev/zero of=$DIR/$tdir/f1 \
3165 bs=1M count=30 oflag=direct
3171 #umount_client $MOUNT || error "client start failed"
3174 #cleanup_nocli || error "cleanup_nocli failed with $?"
3176 run_test 33c "Mount ost with a large index number"
3182 mkdir_on_mdt0 $DIR/$tdir || error "cannot create $DIR/$tdir"
3184 $LFS setquota -p 1 -I1K $MOUNT
3186 do_facet mgs $LCTL set_param osd*.*.quota_slave.enabled=p
3187 $LFS project -p 1 $DIR/
3189 run_test 33d "Don't panic when enable project quota"
3193 do_facet client "bash runmultiop_bg_pause $DIR/file O_c"
3194 manual_umount_client
3196 do_facet client killall -USR1 multiop
3197 if [ $rc -eq 0 ]; then
3198 error "umount not fail!"
3201 cleanup || error "cleanup failed with rc $?"
3203 run_test 34a "umount with opened file should be fail"
3207 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3208 stop_mds || error "Unable to stop MDS"
3210 manual_umount_client --force || error "mtab after failed umount with $?"
3212 cleanup || error "cleanup failed with $?"
3214 run_test 34b "force umount with failed mds should be normal"
3218 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
3219 stop_ost || error "Unable to stop OST1"
3221 manual_umount_client --force || error "mtab after failed umount with $?"
3223 cleanup || error "cleanup failed with $?"
3225 run_test 34c "force umount with failed ost should be normal"
3227 test_35a() { # bug 12459
3230 DBG_SAVE="`$LCTL get_param -n debug`"
3231 $LCTL set_param debug="ha"
3233 log "Set up a fake failnode for the MDS"
3235 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
3236 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
3238 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3239 do_facet mgs "$PERM_CMD \
3240 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
3241 error "Setting mdc.*${device}*.import=connection=\
3242 $(h2nettype $FAKENID) failed."
3244 do_facet mgs "$PERM_CMD \
3245 ${device}.failover.node=$(h2nettype $FAKENID)" ||
3246 error "Setting ${device}.failover.node=\
3247 $(h2nettype $FAKENID) failed."
3249 log "Wait for RECONNECT_INTERVAL seconds (10s)"
3252 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
3255 log "Stopping the MDT: $device"
3256 stop_mdt 1 || error "MDT0 stop fail"
3258 df $MOUNT > /dev/null 2>&1 &
3260 log "Restarting the MDT: $device"
3261 start_mdt 1 || error "MDT0 start fail"
3262 log "Wait for df ($DFPID) ... "
3265 $LCTL set_param debug="$DBG_SAVE"
3267 # retrieve from the log the first server that the client tried to
3268 # contact after the connection loss
3269 $LCTL dk $TMP/lustre-log-$TESTNAME.log
3270 NEXTCONN=`awk "/${MSG}/ {start = 1;}
3271 /import_select_connection.*$device-mdc.* using connection/ {
3273 if (\\\$NF ~ /$FAKENID/)
3279 }" $TMP/lustre-log-$TESTNAME.log`
3280 [ "$NEXTCONN" != "0" ] &&
3281 error "Tried to connect to ${NEXTCONN} not last active server"
3282 cleanup || error "cleanup failed with $?"
3283 # remove nid settings
3284 writeconf_or_reformat
3286 run_test 35a "Reconnect to the last active server first"
3288 test_35b() { # bug 18674
3289 remote_mds || skip "local MDS"
3293 $LCTL set_param debug="ha"
3295 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
3298 log "Set up a fake failnode for the MDS"
3300 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
3301 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
3303 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3304 do_facet mgs "$PERM_CMD \
3305 mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
3306 error "Set mdc.*${device}*.import=connection=\
3307 $(h2nettype $FAKENID) failed"
3309 do_facet mgs "$PERM_CMD \
3310 ${device}.failover.node=$(h2nettype $FAKENID)" ||
3311 error "Set ${device}.failover.node=\
3312 $(h2nettype $FAKENID) failed"
3315 local at_max_saved=0
3316 # adaptive timeouts may prevent seeing the issue
3317 if at_is_enabled; then
3318 at_max_saved=$(at_max_get mds)
3319 at_max_set 0 mds client
3322 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
3324 log "Injecting EBUSY on MDS"
3325 # Setting OBD_FAIL_MDS_RESEND=0x136
3326 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" ||
3327 error "unable to set param fail_loc=0x80000136"
3329 $LCTL set_param mdc.${FSNAME}*.stats=clear
3331 log "Creating a test file and stat it"
3332 touch $MOUNT/$tdir/$tfile || error "touch $MOUNT/$tdir/$tfile failed"
3333 stat $MOUNT/$tdir/$tfile
3335 log "Stop injecting EBUSY on MDS"
3336 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" ||
3337 error "unable to set param fail_loc=0"
3338 rm -f $MOUNT/$tdir/$tfile || error "remove $MOUNT/$tdir/$tfile failed"
3341 # restore adaptive timeout
3342 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
3344 $LCTL dk $TMP/lustre-log-$TESTNAME.log
3346 CONNCNT=$($LCTL get_param mdc.${FSNAME}*.stats |
3347 awk '/mds_connect/{print $2}')
3349 # retrieve from the log if the client has ever tried to
3350 # contact the fake server after the loss of connection
3351 FAILCONN=`awk "BEGIN {ret = 0;}
3352 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
3354 if (\\\$NF ~ /$FAKENID/) {
3359 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
3361 [ "$FAILCONN" == "0" ] &&
3362 error "The client reconnection has not been triggered"
3363 [ "$FAILCONN" == "2" ] &&
3364 error "Primary server busy, client reconnect to failover failed"
3367 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
3368 # Reconnects are supposed to be rate limited to one every 5s
3369 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] &&
3370 error "Too many reconnects $CONNCNT"
3372 cleanup || error "cleanup failed with $?"
3373 # remove nid settings
3374 writeconf_or_reformat
3376 run_test 35b "Continue reconnection retries, if the active server is busy"
3379 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
3381 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
3385 local FSNAME2=test1234
3386 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3388 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
3390 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
3391 is_blkdev $SINGLEMDS $MDSDEV &&
3392 skip_env "mixed loopback and real device not working"
3395 local fs2mdsdev=$(mdsdevname 1_2)
3396 local fs2ostdev=$(ostdevname 1_2)
3397 local fs3ostdev=$(ostdevname 2_2)
3398 local fs2mdsvdev=$(mdsvdevname 1_2)
3399 local fs2ostvdev=$(ostvdevname 1_2)
3400 local fs3ostvdev=$(ostvdevname 2_2)
3403 add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
3404 --reformat $fs2mdsdev $fs2mdsvdev || exit 10
3405 # XXX after we support non 4K disk blocksize in ldiskfs, specify a
3406 # different one than the default value here.
3407 add fs2ost $(mkfs_opts ost1 ${fs2ostdev}) --mgsnode=$MGSNID \
3408 --fsname=${FSNAME2} --reformat $fs2ostdev $fs2ostvdev || exit 10
3409 add fs3ost $(mkfs_opts ost2 ${fs3ostdev}) --mgsnode=$MGSNID \
3410 --fsname=${FSNAME2} --reformat $fs3ostdev $fs3ostvdev || exit 10
3412 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
3413 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
3414 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
3415 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
3416 $MOUNT_CMD $MGSNID:/${FSNAME2} $MOUNT2 || error "$MOUNT_CMD failed"
3418 sleep 5 # until 11778 fixed
3420 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || error "dd failed"
3422 BKTOTAL=$($LCTL get_param -n obdfilter.*.kbytestotal |
3423 awk 'BEGIN{total=0}; {total+=$1}; END{print total}')
3424 BKFREE=$($LCTL get_param -n obdfilter.*.kbytesfree |
3425 awk 'BEGIN{free=0}; {free+=$1}; END{print free}')
3426 BKAVAIL=$($LCTL get_param -n obdfilter.*.kbytesavail |
3427 awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
3428 STRING=$(df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}')
3429 DFTOTAL=$(echo $STRING | cut -d, -f1)
3430 DFUSED=$(echo $STRING | cut -d, -f2)
3431 DFAVAIL=$(echo $STRING | cut -d, -f3)
3432 DFFREE=$(($DFTOTAL - $DFUSED))
3434 ALLOWANCE=$((64 * $OSTCOUNT))
3436 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
3437 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
3438 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
3441 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
3442 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
3443 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
3446 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
3447 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
3448 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
3453 stop fs3ost -f || error "unable to stop OST3"
3454 stop fs2ost -f || error "unable to stop OST2"
3455 stop fs2mds -f || error "unable to stop second MDS"
3456 unload_modules_conf || error "unable unload modules"
3459 run_test 36 "df report consistency on OSTs with different block size"
3462 local mntpt=$(facet_mntpt $SINGLEMDS)
3463 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
3464 local mdsdev_sym="$TMP/sym_mdt.img"
3465 local opts=$MDS_MOUNT_OPTS
3468 if [ "$mds1_FSTYPE" != ldiskfs ]; then
3469 skip "ldiskfs only test"
3472 echo "MDS : $mdsdev"
3473 echo "SYMLINK : $mdsdev_sym"
3474 do_facet $SINGLEMDS rm -f $mdsdev_sym
3476 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
3478 echo "mount symlink device - $mdsdev_sym"
3480 if ! do_facet $SINGLEMDS test -b $mdsdev; then
3481 opts=$(csa_add "$opts" -o loop)
3485 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
3486 $mdsdev_sym $mntpt 2>&1)
3489 echo mount_op=$mount_op
3491 do_facet $SINGLEMDS "$UMOUNT $mntpt && rm -f $mdsdev_sym"
3493 if $(echo $mount_op | grep -q "unable to set tunable"); then
3494 error "set tunables failed for symlink device"
3497 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
3499 run_test 37 "verify set tunables works for symlink device"
3501 test_38() { # bug 14222
3502 local mntpt=$(facet_mntpt $SINGLEMDS)
3507 local SRC="/etc /bin"
3508 local FILES=$(find $SRC -type f -mtime +1 | head -n $COUNT)
3510 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
3511 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3512 tar cf - $FILES | tar xf - -C $DIR/$tdir ||
3513 error "copying $SRC to $DIR/$tdir"
3515 umount_client $MOUNT || error "umount_client $MOUNT failed"
3516 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
3517 stop_mds || error "Unable to stop MDS"
3518 log "delete lov_objid file on MDS"
3520 mount_fstype $SINGLEMDS || error "mount MDS failed (1)"
3522 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid; rm $mntpt/lov_objid"
3524 unmount_fstype $SINGLEMDS || error "umount failed (1)"
3526 # check create in mds_lov_connect
3527 start_mds || error "unable to start MDS"
3528 mount_client $MOUNT || error "mount_client $MOUNT failed"
3530 [ $V ] && log "verifying $DIR/$tdir/$f"
3531 diff -q $f $DIR/$tdir/$f || ERROR=y
3533 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
3534 if [ "$ERROR" = "y" ]; then
3535 # check it's updates in sync
3536 umount_client $MOUNT
3538 mount_fstype $SIGNLEMDS
3539 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
3540 unmount_fstype $SINGLEMDS
3541 error "old and new files are different after connect" || true
3543 touch $DIR/$tdir/f2 || error "f2 file create failed"
3545 # check it's updates in sync
3546 umount_client $MOUNT || error "second umount_client $MOUNT failed"
3549 mount_fstype $SINGLEMDS || error "mount MDS failed (3)"
3551 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
3552 do_facet $SINGLEMDS dd if=/dev/zero of=$mntpt/lov_objid.clear count=8
3554 unmount_fstype $SINGLEMDS || error "umount failed (3)"
3556 start_mds || error "unable to start MDS"
3557 mount_client $MOUNT || error "mount_client $MOUNT failed"
3559 [ $V ] && log "verifying $DIR/$tdir/$f"
3560 diff -q $f $DIR/$tdir/$f || ERROR=y
3562 touch $DIR/$tdir/f3 || error "f3 file create failed"
3563 do_facet $SINGLEMDS "$LCTL get_param osp.*.prealloc_next_id"
3564 umount_client $MOUNT || error "third umount_client $MOUNT failed"
3566 mount_fstype $SINGLEMDS || error "mount MDS failed (4)"
3567 do_facet $SINGLEMDS "od -Ax -td8 $mntpt/lov_objid"
3568 unmount_fstype $SINGLEMDS || error "umount failed (4)"
3570 [[ "$ERROR" != "y" ]] ||
3571 error "old and new files are different after sync"
3573 log "files compared the same"
3574 cleanup || error "cleanup failed with $?"
3576 run_test 38 "MDS recreates missing lov_objid file from OST data"
3579 [[ -n "$(type -p perl)" ]] || skip_env "need perl for leak_finder.pl"
3583 cleanup || error "cleanup failed with $?"
3584 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
3585 error "memory leak detected" || true
3587 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
3589 test_40() { # bug 15759
3590 start_ost || error "Unable to start OST1"
3591 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
3592 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000706"
3594 cleanup || error "cleanup failed with rc $?"
3596 run_test 40 "race during service thread startup"
3598 test_41a() { #bug 14134
3599 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3600 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
3601 skip "Loop devices does not work with nosvc option"
3604 combined_mgs_mds || skip "needs combined MGT and MDT device"
3606 start_mdt 1 -o nosvc -n
3607 if [ $MDSCOUNT -ge 2 ]; then
3608 for num in $(seq 2 $MDSCOUNT); do
3609 start_mdt $num || return
3612 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
3613 start_mdt 1 -o nomgs,force
3614 mount_client $MOUNT || error "mount_client $MOUNT failed"
3617 echo "blah blah" > $MOUNT/$tfile
3620 umount_client $MOUNT || error "umount_client $MOUNT failed"
3621 stop ost1 -f || error "unable to stop OST1"
3622 stop_mds || error "Unable to stop MDS"
3623 stop_mds || error "Unable to stop MDS on second try"
3625 run_test 41a "mount mds with --nosvc and --nomgs"
3628 if [ "$mds1_FSTYPE" == ldiskfs ] &&
3629 ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
3630 skip "Loop devices does not work with nosvc option"
3633 ! combined_mgs_mds && skip "needs combined mgs device"
3637 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
3639 start_mdt 1 -o nosvc -n
3640 if [ $MDSCOUNT -ge 2 ]; then
3641 for num in $(seq 2 $MDSCOUNT); do
3642 start_mdt $num || return
3645 start_ost || error "Unable to start OST1"
3646 start_mdt 1 -o nomgs,force
3647 mount_client $MOUNT || error "mount_client $MOUNT failed"
3650 echo "blah blah" > $MOUNT/$tfile
3651 cat $MOUNT/$tfile || error "cat $MOUNT/$tfile failed"
3653 umount_client $MOUNT -f || error "umount_client $MOUNT failed"
3654 stop_ost || error "Unable to stop OST1"
3655 stop_mds || error "Unable to stop MDS"
3656 stop_mds || error "Unable to stop MDS on second try"
3658 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
3661 local oss_list=$(comma_list $(osts_nodes))
3663 (( "$MDS1_VERSION" >= $(version_code 2.15.62.4) )) ||
3664 skip "Need MDS >= 2.15.62.4 for parallel device locking"
3666 # ensure mds1 ost1 have been created even if running sub-test standalone
3669 cleanup || error "cleanup failed"
3671 # using directly mount command instead of start() function to avoid
3672 # any side effect of // with others/externals tools/features
3673 # ("zpool import", ...)
3675 # MDT concurrent start
3677 LOAD_MODULES_REMOTE=true load_modules
3678 do_facet $SINGLEMDS "lsmod | grep -q libcfs" ||
3679 error "MDT concurrent start: libcfs module not loaded"
3681 local mds1dev=$(mdsdevname 1)
3682 local mds1mnt=$(facet_mntpt mds1)
3683 local mds1opts=$MDS_MOUNT_OPTS
3685 if [[ "$mds1_FSTYPE" == ldiskfs ]] &&
3686 ! do_facet mds1 test -b $mds1dev; then
3687 mds1opts=$(csa_add "$mds1opts" -o loop)
3689 if [[ "$mds1_FSTYPE" == zfs ]]; then
3690 import_zpool mds1 || return ${PIPESTATUS[0]}
3693 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3694 do_facet mds1 "$LCTL set_param fail_loc=0x80000716"
3696 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts &
3699 do_facet mds1 mount -t lustre $mds1dev $mds1mnt $mds1opts
3704 do_facet mds1 "$LCTL set_param fail_loc=0x0"
3705 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3706 echo "1st MDT start succeed"
3707 echo "2nd MDT start failed with $rc2"
3708 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3709 echo "1st MDT start failed with $rc"
3710 echo "2nd MDT start succeed"
3713 error "unexpected concurrent MDT mounts result, rc=$rc rc2=$rc2"
3716 if [ $MDSCOUNT -ge 2 ]; then
3717 for num in $(seq 2 $MDSCOUNT); do
3718 start_mdt $num || return
3722 # OST concurrent start
3724 do_rpc_nodes $oss_list "lsmod | grep -q libcfs" ||
3725 error "OST concurrent start: libcfs module not loaded"
3727 local ost1dev=$(ostdevname 1)
3728 local ost1mnt=$(facet_mntpt ost1)
3729 local ost1opts=$OST_MOUNT_OPTS
3731 if [ "$ost1_FSTYPE" == ldiskfs ] &&
3732 ! do_facet ost1 test -b $ost1dev; then
3733 ost1opts=$(csa_add "$ost1opts" -o loop)
3735 if [[ "$ost1_FSTYPE" == zfs ]]; then
3736 import_zpool ost1 || return ${PIPESTATUS[0]}
3739 #define OBD_FAIL_TGT_MOUNT_RACE 0x716
3740 do_facet ost1 "$LCTL set_param fail_loc=0x80000716"
3742 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts &
3745 do_facet ost1 mount -t lustre $ost1dev $ost1mnt $ost1opts
3749 do_facet ost1 "$LCTL set_param fail_loc=0x0"
3750 if [ $rc -eq 0 ] && [ $rc2 -ne 0 ]; then
3751 echo "1st OST start succeed"
3752 echo "2nd OST start failed with $rc2"
3753 elif [ $rc2 -eq 0 ] && [ $rc -ne 0 ]; then
3754 echo "1st OST start failed with $rc"
3755 echo "2nd OST start succeed"
3759 error "unexpected concurrent OST mounts result, rc=$rc rc2=$rc2"
3765 # verify everything ok
3770 error "MDT(s) start failed"
3778 error "OST(s) start failed"
3786 error "client start failed"
3793 error "client mount failed"
3797 run_test 41c "concurrent mounts of MDT/OST should all fail but one"
3799 test_42() { #bug 14693
3803 check_mount || error "client was not mounted"
3805 if [[ $PERM_CMD == *"set_param -P"* ]]; then
3806 PARAM="llite.$FSNAME-*.some_wrong_param"
3808 PARAM="$FSNAME.llite.some_wrong_param"
3811 do_facet mgs $PERM_CMD $PARAM=10
3812 umount_client $MOUNT ||
3813 error "unmounting client failed with invalid llite param"
3814 mount_client $MOUNT ||
3815 error "mounting client failed with invalid llite param"
3817 do_facet mgs $PERM_CMD $PARAM=20
3818 cleanup || error "stopping $FSNAME failed with invalid sys param"
3820 check_mount || error "client was not mounted with invalid sys param"
3821 cleanup || error "stopping $FSNAME failed with invalid sys param"
3823 run_test 42 "allow client/server mount/unmount with invalid config param"
3826 [[ "$MGS_VERSION" -ge $(version_code 2.5.58) ]] ||
3827 skip "Need MDS version at least 2.5.58"
3828 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
3831 USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
3832 [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1"
3835 chmod ugo+x $DIR || error "chmod 0 failed"
3836 set_persistent_param_and_check mds1 \
3837 "mdt.$FSNAME-MDT0000.root_squash" \
3838 "$FSNAME.mdt.root_squash" \
3840 wait_update $HOSTNAME \
3841 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3843 error "check llite root_squash failed!"
3844 set_persistent_param_and_check mds1 \
3845 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3846 "$FSNAME.mdt.nosquash_nids" \
3848 wait_update $HOSTNAME \
3849 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3851 error "check llite nosquash_nids failed!"
3854 # create set of test files
3856 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
3857 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
3858 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
3860 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
3861 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
3863 mkdir_on_mdt0 $DIR/$tdir-rootdir || error "mkdir failed"
3864 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
3865 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
3867 echo "777" > $DIR/$tfile-user1file || error "write 7 failed"
3868 chmod go-rw $DIR/$tfile-user1file || error "chmod 7 failed"
3869 chown $ID1.$ID1 $DIR/$tfile-user1file || error "chown failed"
3872 # check root_squash:
3873 # set root squash UID:GID to RUNAS_ID
3874 # root should be able to access only files owned by RUNAS_ID
3876 set_persistent_param_and_check mds1 \
3877 "mdt.$FSNAME-MDT0000.root_squash" \
3878 "$FSNAME.mdt.root_squash" \
3879 "$RUNAS_ID:$RUNAS_ID"
3880 wait_update $HOSTNAME \
3881 "$LCTL get_param -n llite.${FSNAME}*.root_squash" \
3882 "$RUNAS_ID:$RUNAS_ID" ||
3883 error "check llite root_squash failed!"
3885 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
3886 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3887 error "$ST: root read permission is denied"
3888 echo "$ST: root read permission is granted - ok"
3891 dd conv=notrunc of=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null ||
3892 error "$ST: root write permission is denied"
3893 echo "$ST: root write permission is granted - ok"
3895 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3896 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3897 error "$ST: root read permission is granted"
3898 echo "$ST: root read permission is denied - ok"
3901 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null &&
3902 error "$ST: root write permission is granted"
3903 echo "$ST: root write permission is denied - ok"
3905 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3906 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null &&
3907 error "$ST: root unlink permission is granted"
3908 echo "$ST: root unlink permission is denied - ok"
3910 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null &&
3911 error "$ST: root create permission is granted"
3912 echo "$ST: root create permission is denied - ok"
3915 # check root_squash is enforced independently
3916 # of client cache content
3918 # access file by USER1, keep access open
3919 # root should be denied access to user file
3921 runas -u $ID1 tail -f $DIR/$tfile-user1file 1>/dev/null 2>&1 &
3925 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-user1file)
3926 dd if=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3927 { kill $pid; error "$ST: root read permission is granted"; }
3928 echo "$ST: root read permission is denied - ok"
3931 dd conv=notrunc of=$DIR/$tfile-user1file 1>/dev/null 2>&1 &&
3932 { kill $pid; error "$ST: root write permission is granted"; }
3933 echo "$ST: root write permission is denied - ok"
3939 # check nosquash_nids:
3940 # put client's NID into nosquash_nids list,
3941 # root should be able to access root file after that
3943 local NIDLIST=$($LCTL list_nids all | tr '\n' ' ')
3944 NIDLIST="2@gni $NIDLIST 192.168.0.[2,10]@tcp"
3945 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
3946 set_persistent_param_and_check mds1 \
3947 "mdt.$FSNAME-MDT0000.nosquash_nids" \
3948 "$FSNAME-MDTall.mdt.nosquash_nids" \
3950 wait_update $HOSTNAME \
3951 "$LCTL get_param -n llite.${FSNAME}*.nosquash_nids" \
3953 error "check llite nosquash_nids failed!"
3955 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
3956 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3957 error "$ST: root read permission is denied"
3958 echo "$ST: root read permission is granted - ok"
3961 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null ||
3962 error "$ST: root write permission is denied"
3963 echo "$ST: root write permission is granted - ok"
3965 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
3966 rm $DIR/$tdir-rootdir/tfile-1 ||
3967 error "$ST: root unlink permission is denied"
3968 echo "$ST: root unlink permission is granted - ok"
3969 touch $DIR/$tdir-rootdir/tfile-2 ||
3970 error "$ST: root create permission is denied"
3971 echo "$ST: root create permission is granted - ok"
3972 cleanup || error "cleanup failed with $?"
3974 run_test 43a "check root_squash and nosquash_nids"
3976 test_43b() { # LU-5690
3977 [[ "$MGS_VERSION" -ge $(version_code 2.7.62) ]] ||
3978 skip "Need MGS version 2.7.62+"
3980 if [[ -z "$fs2mds_DEV" ]]; then
3981 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
3982 skip_env "mixed loopback and real device not working"
3985 local fs2mdsdev=$(mdsdevname 1_2)
3986 local fs2mdsvdev=$(mdsvdevname 1_2)
3988 # temporarily use fs2mds as fs2mgs
3990 local fs2mgsdev=$fs2mdsdev
3991 local fs2mgsvdev=$fs2mdsvdev
3993 local fsname=test1234
3995 load_module llite/lustre
3996 local client_ip=$(host_nids_address $HOSTNAME $NETTYPE)
3997 local host=${client_ip//*./}
3998 local net=${client_ip/%$host/}
3999 local nosquash_nids=$(h2nettype $net[$host,$host,$host])
4001 add $fs2mgs $(mkfs_opts mgs $fs2mgsdev) --fsname=$fsname \
4002 --param mdt.root_squash=$RUNAS_ID:$RUNAS_ID \
4003 --param mdt.nosquash_nids=$nosquash_nids \
4004 --reformat $fs2mgsdev $fs2mgsvdev || error "add fs2mgs failed"
4005 start $fs2mgs $fs2mgsdev $MGS_MOUNT_OPTS || error "start fs2mgs failed"
4006 stop $fs2mgs -f || error "stop fs2mgs failed"
4007 cleanup || error "cleanup failed with $?"
4009 run_test 43b "parse nosquash_nids with commas in expr_list"
4013 check_mount || error "check_mount"
4014 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
4016 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
4017 for VAL in $UUIDS; do
4018 NID=$(echo $VAL | cut -d= -f1)
4019 CLUUID=$(echo $VAL | cut -d= -f2)
4020 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
4022 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
4023 cleanup || error "cleanup failed with $?"
4025 run_test 44 "mounted client proc entry exists"
4029 check_mount || error "check_mount"
4030 stop_mds || error "Unable to stop MDS"
4034 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
4035 do_facet client "$LCTL set_param fail_loc=0x8000050f"
4038 manual_umount_client --force || error "manual_umount_client failed"
4039 do_facet client "$LCTL set_param fail_loc=0x0"
4040 start_mds || error "unable to start MDS"
4041 mount_client $MOUNT || error "mount_client $MOUNT failed"
4042 cleanup || error "cleanup failed with $?"
4044 run_test 45 "long unlink handling in ptlrpcd"
4051 umount_client $MOUNT2 || rc=$?
4052 umount_client $MOUNT || rc=$?
4053 while [ $count -gt 0 ]; do
4054 stop ost${count} -f || rc=$?
4058 cleanup_nocli || rc=$?
4059 #writeconf to remove all ost2 traces for subsequent tests
4060 writeconf_or_reformat
4065 echo "Testing with $OSTCOUNT OSTs"
4067 start_mds || error "unable to start MDS"
4068 #first client should see only one ost
4069 start_ost || error "Unable to start OST1"
4070 wait_osc_import_state mds ost FULL
4072 mount_client $MOUNT || error "mount_client $MOUNT failed"
4073 trap "cleanup_46a $OSTCOUNT" EXIT ERR
4076 for (( i=2; i<=$OSTCOUNT; i++ )); do
4077 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
4078 error "start_ost$i $(ostdevname $i) failed"
4081 # wait until osts in sync
4082 for (( i=2; i<=$OSTCOUNT; i++ )); do
4083 wait_osc_import_state mds ost$i FULL
4084 wait_osc_import_ready client ost$i
4087 #second client see all ost's
4089 mount_client $MOUNT2 || error "mount_client failed"
4090 $LFS setstripe -c -1 $MOUNT2 ||
4091 error "$LFS setstripe -c -1 $MOUNT2 failed"
4092 $LFS getstripe $MOUNT2 || error "$LFS getstripe $MOUNT2 failed"
4094 echo "ok" > $MOUNT2/widestripe
4095 $LFS getstripe $MOUNT2/widestripe ||
4096 error "$LFS getstripe $MOUNT2/widestripe failed"
4097 # fill acl buffer for avoid expand lsm to them
4098 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
4100 setfacl -m $acl $MOUNT2/widestripe
4104 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
4106 cleanup_46a $OSTCOUNT || error "cleanup_46a failed"
4108 run_test 46a "handle ost additional - wide striped file"
4113 check_mount || error "check_mount failed"
4114 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
4118 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
4119 if echo $ns | grep "MDT[[:digit:]]*"; then
4122 lrs=$(echo $ns | sed 's/.*lru_size=//')
4123 lru_size[count]=$lrs
4128 facet_failover $SINGLEMDS
4129 client_up || error "client_up failed"
4132 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
4133 if echo $ns | grep "MDT[[:digit:]]*"; then
4136 lrs=$(echo $ns | sed 's/.*lru_size=//')
4137 if ! test "$lrs" -eq "${lru_size[count]}"; then
4138 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
4139 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
4144 cleanup || error "cleanup failed with $?"
4146 run_test 47 "server restart does not make client loss lru_resize settings"
4151 # reformat after this test is needed - if the test fails,
4152 # we will have unkillable file at FS
4156 test_48() { # bz-17636 LU-7473
4160 check_mount || error "check_mount failed"
4163 stack_trap "debugrestore"
4164 $LCTL set_param debug=0
4165 do_facet $SINGLEMDS $LCTL set_param debug=0
4167 $LFS setstripe -c -1 $MOUNT ||
4168 error "$LFS setstripe -c -1 $MOUNT failed"
4169 $LFS getstripe $MOUNT || error "$LFS getstripe $MOUNT failed"
4171 echo "ok" > $MOUNT/widestripe
4172 $LFS getstripe $MOUNT/widestripe ||
4173 error "$LFS getstripe $MOUNT/widestripe failed"
4175 # In the future, we may introduce more EAs, such as selinux, enlarged
4176 # LOV EA, and so on. These EA will use some EA space that is shared by
4177 # ACL entries. So here we only check some reasonable ACL entries count,
4178 # instead of the max number that is calculated from the max_ea_size.
4179 if (( $MDS1_VERSION < $(version_code 2.8.57) )); then
4180 count=28 # hard coded of RPC protocol
4181 elif large_xattr_enabled; then
4182 count=4500 # max_num 8187 max_ea_size = 65452
4183 # not create too many (4500) to save test time
4185 count=450 # max_num 497 max_ea_size = 4012
4188 echo "It is expected to hold at least $count ACL entries"
4189 trap cleanup_48 EXIT ERR
4190 for ((i = 0; i < $count; i++)) do
4191 setfacl -m u:$((i + 100)):rw $MOUNT/widestripe ||
4192 error "Fail to setfacl for $MOUNT/widestripe at $i"
4195 cancel_lru_locks mdc
4196 stat $MOUNT/widestripe || error "stat $MOUNT/widestripe failed"
4197 local r_count=$(getfacl $MOUNT/widestripe | grep "user:" | wc -l)
4199 count=$((count + 1)) # for the entry "user::rw-"
4201 (( $count == $r_count )) ||
4202 error "Expected ACL entries $count, but got $r_count"
4206 run_test 48 "too many acls on file"
4208 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
4209 test_49a() { # bug 17710
4210 local timeout_orig=$TIMEOUT
4211 local ldlm_timeout_orig=$LDLM_TIMEOUT
4212 local LOCAL_TIMEOUT=20
4214 LDLM_TIMEOUT=$LOCAL_TIMEOUT
4215 TIMEOUT=$LOCAL_TIMEOUT
4219 check_mount || error "client mount failed"
4221 echo "check ldlm_timout..."
4222 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
4223 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
4224 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
4226 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
4227 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
4230 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
4231 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT / 3))"
4234 umount_client $MOUNT || error "umount_client $MOUNT failed"
4235 stop_ost || error "problem stopping OSS"
4236 stop_mds || error "problem stopping MDS"
4238 LDLM_TIMEOUT=$ldlm_timeout_orig
4239 TIMEOUT=$timeout_orig
4241 run_test 49a "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
4243 test_49b() { # bug 17710
4244 local timeout_orig=$TIMEOUT
4245 local ldlm_timeout_orig=$LDLM_TIMEOUT
4246 local LOCAL_TIMEOUT=20
4248 LDLM_TIMEOUT=$((LOCAL_TIMEOUT - 1))
4249 TIMEOUT=$LOCAL_TIMEOUT
4253 check_mount || error "client mount failed"
4255 local LDLM_MDS="$(do_facet $SINGLEMDS $LCTL get_param -n ldlm_timeout)"
4256 local LDLM_OST1="$(do_facet ost1 $LCTL get_param -n ldlm_timeout)"
4257 local LDLM_CLIENT="$(do_facet client $LCTL get_param -n ldlm_timeout)"
4259 if [ $LDLM_MDS -ne $LDLM_OST1 -o $LDLM_MDS -ne $LDLM_CLIENT ]; then
4260 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
4263 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
4264 error "LDLM_TIMEOUT($LDLM_MDS) is not $((LOCAL_TIMEOUT - 1))"
4267 cleanup || error "cleanup failed"
4269 LDLM_TIMEOUT=$ldlm_timeout_orig
4270 TIMEOUT=$timeout_orig
4272 run_test 49b "check PARAM_SYS_LDLM_TIMEOUT option of mkfs.lustre"
4275 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
4277 # Test both statfs and lfs df and fail if either one fails
4278 multiop_bg_pause $1 f_
4281 killall -USR1 multiop
4282 [ $RC -ne 0 ] && log "lazystatfs multiop failed"
4283 wait $PID || { RC=$?; log "multiop return error "; }
4285 # wait long enough to exceed OBD_STATFS_CACHE_SECONDS = 1
4290 if kill -s 0 $PID; then
4293 log "lazystatfs lfs df failed to complete in 5s"
4301 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
4302 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4304 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
4306 cleanup || error "cleanup failed with rc $?"
4308 run_test 50a "lazystatfs all servers available"
4312 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
4313 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4315 # Wait for client to detect down OST
4316 stop_ost || error "Unable to stop OST1"
4317 wait_osc_import_state client ost DISCONN
4319 log "OSCs should all be DISCONN"
4321 lazystatfs $MOUNT || error "lazystatfs should not return EIO"
4323 umount_client $MOUNT || error "Unable to unmount client"
4324 stop_mds || error "Unable to stop MDS"
4326 run_test 50b "lazystatfs all servers down"
4329 start_mds || error "Unable to start MDS"
4330 start_ost || error "Unable to start OST1"
4331 start_ost2 || error "Unable to start OST2"
4332 mount_client $MOUNT || error "Unable to mount client"
4333 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
4334 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4336 # Wait for client to detect down OST
4337 stop_ost || error "Unable to stop OST1"
4338 wait_osc_import_state mds ost DISCONN
4339 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
4341 umount_client $MOUNT || error "Unable to unmount client"
4342 stop_ost2 || error "Unable to stop OST2"
4343 stop_mds || error "Unable to stop MDS"
4344 #writeconf to remove all ost2 traces for subsequent tests
4345 writeconf_or_reformat
4347 run_test 50c "lazystatfs one server down"
4350 start_mds || error "Unable to start MDS"
4351 start_ost || error "Unable to start OST1"
4352 start_ost2 || error "Unable to start OST2"
4353 mount_client $MOUNT || error "Unable to mount client"
4354 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
4355 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4357 # Issue the statfs during the window where the client still
4358 # belives the OST to be available but it is in fact down.
4359 # No failure just a statfs which hangs for a timeout interval.
4360 stop_ost || error "Unable to stop OST1"
4361 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
4363 umount_client $MOUNT || error "Unable to unmount client"
4364 stop_ost2 || error "Unable to stop OST2"
4365 stop_mds || error "Unable to stop MDS"
4366 #writeconf to remove all ost2 traces for subsequent tests
4367 writeconf_or_reformat
4369 run_test 50d "lazystatfs client/server conn race"
4376 start_mds || error "Unable to start MDS"
4377 #first client should see only one ost
4378 start_ost || error "Unable to start OST1"
4379 wait_osc_import_state mds ost FULL
4381 # Wait for client to detect down OST
4382 stop_ost || error "Unable to stop OST1"
4383 wait_osc_import_state mds ost DISCONN
4385 mount_client $MOUNT || error "Unable to mount client"
4386 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
4388 multiop_bg_pause $MOUNT _f
4392 if [ $RC1 -ne 0 ]; then
4393 log "multiop failed $RC1"
4396 sleep $(( $TIMEOUT+1 ))
4398 [ $? -ne 0 ] && error "process isn't sleep"
4399 start_ost || error "Unable to start OST1"
4400 wait $pid || error "statfs failed"
4403 umount_client $MOUNT || error "Unable to unmount client"
4404 stop_ost || error "Unable to stop OST1"
4405 stop_mds || error "Unable to stop MDS"
4407 run_test 50e "normal statfs all servers down"
4412 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
4414 start_mds || error "Unable to start mds"
4415 #first client should see only one ost
4416 start_ost || error "Unable to start OST1"
4417 wait_osc_import_state mds ost FULL
4419 start_ost2 || error "Unable to start OST2"
4420 wait_osc_import_state mds ost2 FULL
4422 # Wait for client to detect down OST
4423 stop_ost2 || error "Unable to stop OST2"
4425 wait_osc_import_state mds ost2 DISCONN
4426 mount_client $MOUNT || error "Unable to mount client"
4427 $LCTL set_param llite.$FSNAME-*.lazystatfs=0
4429 multiop_bg_pause $MOUNT _f
4433 if [ $RC1 -ne 0 ]; then
4434 log "lazystatfs multiop failed $RC1"
4437 sleep $(( $TIMEOUT+1 ))
4439 [ $? -ne 0 ] && error "process isn't sleep"
4440 start_ost2 || error "Unable to start OST2"
4441 wait $pid || error "statfs failed"
4442 stop_ost2 || error "Unable to stop OST2"
4445 umount_client $MOUNT -f || error "Unable to unmount client"
4446 stop_ost || error "Unable to stop OST1"
4447 stop_mds || error "Unable to stop MDS"
4448 #writeconf to remove all ost2 traces for subsequent tests
4449 writeconf_or_reformat
4451 run_test 50f "normal statfs one server in down"
4454 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
4456 start_ost2 || error "Unable to start OST2"
4457 wait_osc_import_state mds ost2 FULL
4458 wait_osc_import_ready client ost2
4460 if [[ $PERM_CMD == *"set_param -P"* ]]; then
4461 local PARAM="osc.${FSNAME}-OST0001*.active"
4463 local PARAM="${FSNAME}-OST0001.osc.active"
4466 $LFS setstripe -c -1 $DIR/$tfile || error "$LFS setstripe failed"
4467 do_facet mgs $PERM_CMD $PARAM=0 || error "Unable to deactivate OST"
4469 umount_client $MOUNT || error "Unable to unmount client"
4470 mount_client $MOUNT || error "Unable to mount client"
4471 # This df should not cause a panic
4474 do_facet mgs $PERM_CMD $PARAM=1 || error "Unable to activate OST"
4475 rm -f $DIR/$tfile || error "unable to remove file $DIR/$tfile"
4476 umount_client $MOUNT || error "Unable to unmount client"
4477 stop_ost2 || error "Unable to stop OST2"
4478 stop_ost || error "Unable to stop OST1"
4479 stop_mds || error "Unable to stop MDS"
4480 #writeconf to remove all ost2 traces for subsequent tests
4481 writeconf_or_reformat
4483 run_test 50g "deactivated OST should not cause panic"
4487 # prepare MDT/OST, make OSC inactive for OST1
4488 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
4490 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
4491 do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
4492 error "tunefs OST1 failed"
4493 start_mds || error "Unable to start MDT"
4494 start_ost || error "Unable to start OST1"
4495 start_ost2 || error "Unable to start OST2"
4496 mount_client $MOUNT || error "client start failed"
4498 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4500 # activatate OSC for OST1
4501 set_persistent_param_and_check client \
4502 "osc.${FSNAME}-OST0000-osc-[!M]*.active" \
4503 "${FSNAME}-OST0000.osc.active" 1
4505 mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
4506 $LFS setstripe -c -1 -i 0 $DIR/$tdir/2 ||
4507 error "$LFS setstripe $DIR/$tdir/2 failed"
4508 sleep 1 && echo "create a file after OST1 is activated"
4509 # doing some io, shouldn't crash
4510 dd if=/dev/zero of=$DIR/$tdir/2/$tfile-io bs=1M count=10
4512 # check OSC import is working
4513 stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
4514 error "some OSC imports are still not connected"
4518 umount_client $MOUNT || error "Unable to umount client"
4519 stop_ost2 || error "Unable to stop OST2"
4520 cleanup_nocli || error "cleanup_nocli failed with $?"
4522 run_test 50h "LU-642: activate deactivated OST"
4525 # prepare MDT/OST, make OSC inactive for OST1
4526 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
4529 [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
4530 do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
4531 error "tunefs MDT2 failed"
4532 start_mds || error "Unable to start MDT"
4533 start_ost || error "Unable to start OST1"
4534 start_ost2 || error "Unable to start OST2"
4535 mount_client $MOUNT || error "client start failed"
4537 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4539 if [[ $PERM_CMD == *"set_param -P"* ]]; then
4540 $PERM_CMD mdc.${FSNAME}-MDT0001-mdc-*.active=0 &&
4541 error "deactive MDC0 succeeds"
4543 $PERM_CMD ${FSNAME}-MDT0000.mdc.active=0 &&
4544 error "deactive MDC0 succeeds"
4547 # activate MDC for MDT2
4548 set_persistent_param_and_check client \
4549 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
4550 "${FSNAME}-MDT0001.mdc.active" 1
4552 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
4553 if [ "$MDS1_VERSION" -ge $(version_code 2.7.60) ]
4555 wait_dne_interconnect
4557 $LFS mkdir -i1 $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
4559 createmany -o $DIR/$tdir/2/$tfile-%d 1 || error "create files failed"
4561 rm -rf $DIR/$tdir/2 || error "unlink dir failed"
4563 # deactivate MDC for MDT2
4564 set_persistent_param_and_check client \
4565 "mdc.${FSNAME}-MDT0001-mdc-*.active" \
4566 "${FSNAME}-MDT0001.mdc.active" 0
4568 wait_osp_active mds ${FSNAME}-MDT0001 1 0
4570 $LFS mkdir -i1 $DIR/$tdir/2 &&
4571 error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
4573 $LFS mkdir -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
4574 error "mkdir $DIR/$tdir/striped_dir fails after deactive MDT2"
4576 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
4577 [ $stripe_count -eq $((MDSCOUNT - 1)) ] ||
4578 error "wrong $stripe_count != $((MDSCOUNT -1)) for striped_dir"
4581 umount_client $MOUNT || error "Unable to umount client"
4586 run_test 50i "activate deactivated MDT"
4589 local LOCAL_TIMEOUT=20
4593 check_mount || error "check_mount failed"
4595 mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
4596 $LFS setstripe -c -1 $MOUNT/$tdir ||
4597 error "$LFS setstripe -c -1 $MOUNT/$tdir failed"
4598 #define OBD_FAIL_MDS_REINT_DELAY 0x142
4599 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
4600 touch $MOUNT/$tdir/$tfile &
4603 start_ost2 || error "Unable to start OST1"
4605 stop_ost2 || error "Unable to stop OST1"
4606 umount_client $MOUNT -f || error "unmount $MOUNT failed"
4607 cleanup_nocli || error "stop server failed"
4608 #writeconf to remove all ost2 traces for subsequent tests
4609 writeconf_or_reformat
4611 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
4620 do_node $node mkdir -p $dest
4621 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
4623 do_node $node 'tar cf - '$*' | tar xf - -C '$dest';
4624 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
4625 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
4627 do_node $node 'getfattr -d -m "[a-z]*\\." '$*' > '$xattrs
4628 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
4638 local backup2=${TMP}/backup2
4640 do_node $node mkdir -p $backup2
4641 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
4643 do_node $node 'tar cf - '$*' | tar xf - -C '$backup2';
4644 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
4645 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
4647 do_node $node "diff -rq $backup $backup2"
4648 [ $? -eq 0 ] || { error "contents differ"; return 3; }
4650 local xattrs2=${TMP}/xattrs2
4651 do_node $node 'getfattr -d -m "[a-z]*\\." '$*' > '$xattrs2
4652 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
4654 do_node $node "diff $xattrs $xattrs2"
4655 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
4657 do_node $node "rm -rf $backup2 $xattrs2"
4658 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
4662 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4663 skip "ldiskfs only test"
4666 start_mds || error "Unable to start MDS"
4667 start_ost || error "Unable to start OST1"
4668 mount_client $MOUNT || error "Unable to mount client"
4671 local ost1mnt=$(facet_mntpt ost1)
4672 local ost1node=$(facet_active_host ost1)
4673 local ost1tmp=$TMP/conf52
4676 mkdir $DIR/$tdir || error "Unable to create $DIR/$tdir"
4677 touch $TMP/modified_first || error "Unable to create temporary file"
4678 local mtime=$(stat -c %Y $TMP/modified_first)
4679 do_node $ost1node "mkdir -p $ost1tmp &&
4680 touch -m -d @$mtime $ost1tmp/modified_first" ||
4681 error "Unable to create temporary file"
4684 $LFS setstripe -c -1 -S 1M $DIR/$tdir || error "$LFS setstripe failed"
4686 for (( i=0; i < nrfiles; i++ )); do
4687 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
4688 error "multiop failed"
4693 # sync all the data and make sure no pending data on the client,
4694 # thus the SOM xattr would not be changed any more.
4695 cancel_lru_locks osc
4698 echo backup files to $TMP/$tdir
4699 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
4700 copy_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4701 error "Unable to copy files"
4703 umount_client $MOUNT || error "Unable to umount client"
4704 stop_ost || error "Unable to stop ost1"
4706 echo mount ost1 as ldiskfs
4707 do_node $ost1node mkdir -p $ost1mnt || error "Unable to create $ost1mnt"
4708 if ! do_node $ost1node test -b $ost1_dev; then
4711 do_node $ost1node mount -t "$ost1_FSTYPE" $loop $ost1_dev \
4713 error "Unable to mount ost1 as ldiskfs"
4716 echo backup objects to $ost1tmp/objects
4717 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/[0-9]* -type f'\
4718 '-size +0 -newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
4719 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs \
4721 error "Unable to copy objects"
4723 # move objects to lost+found
4724 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
4725 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
4727 do_node $ost1node "umount $ost1mnt" ||
4728 error "Unable to umount ost1 as ldiskfs"
4730 start_ost || error "Unable to start OST1"
4731 mount_client $MOUNT || error "Unable to mount client"
4733 local REPAIRED=$(do_node $ost1node "$LCTL get_param \
4734 -n osd-ldiskfs.$FSNAME-OST0000.oi_scrub" |
4735 awk '/^lf_repa[ri]*ed/ { print $2 }')
4736 [ $REPAIRED -gt 0 ] ||
4737 error "Some entry under /lost+found should be repaired"
4740 diff_files_xattrs $(hostname) $TMP/$tdir $TMP/file_xattrs $files ||
4741 error "Unable to diff files"
4743 rm -rf $TMP/$tdir $TMP/file_xattrs ||
4744 error "Unable to delete temporary files"
4745 do_node $ost1node "rm -rf $ost1tmp" ||
4746 error "Unable to delete temporary files"
4747 cleanup || error "cleanup failed with $?"
4749 run_test 52 "check recovering objects from lost+found"
4751 # Checks threads_min/max/started for some service
4753 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
4754 # parameter pattern prefix like 'ost.*.ost'.
4767 local msg="Insane $modname thread counts"
4768 local ncpts=$(check_cpt_number $facet)
4772 check_mount || return 41
4774 # We need to expand $parampat, but it may match multiple parameters, so
4775 # we'll pick the first one
4776 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
4777 error "Couldn't expand ${parampat}.threads_min parameter name"
4781 # Remove the .threads_min part
4782 paramp=${paramp%.threads_min}
4784 # Check for sanity in defaults
4785 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4787 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4789 tstarted=$(do_facet $facet "$LCTL get_param \
4790 -n ${paramp}.threads_started" || echo 0)
4791 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' ||
4793 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4795 nthrs=$(expr $tmax - $tmin)
4796 if [ $nthrs -lt $ncpts ]; then
4802 [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
4803 skip_env "module parameter forced $facet thread count"
4805 # Check that we can change min/max
4806 do_facet $facet "$LCTL set_param \
4807 ${paramp}.threads_min=$((tmin + nthrs))"
4808 do_facet $facet "$LCTL set_param \
4809 ${paramp}.threads_max=$((tmax - nthrs))"
4810 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4812 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4814 lassert 25 "$msg" '(($tmin2 == ($tmin + $nthrs) &&
4815 $tmax2 == ($tmax - $nthrs)))' || return $?
4817 # Check that we can set min/max to the same value
4818 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4820 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$tmin"
4821 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4823 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4825 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
4827 # Check that we can't set max < min
4828 do_facet $facet "$LCTL set_param ${paramp}.threads_max=$((tmin - 1))"
4829 tmin2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4831 tmax2=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4833 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
4835 # We need to ensure that we get the module options desired; to do this
4836 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
4837 LOAD_MODULES_REMOTE=true
4840 local newvalue="${opts}=$(expr $basethr \* $ncpts)"
4842 setmodopts -a $modname "$newvalue" oldvalue
4845 check_mount || return 41
4847 # Restore previous setting of MODOPTS_*
4848 setmodopts $modname "$oldvalue"
4850 (( $MDS1_VERSION > $(version_code 2.12.52.91) )) || {
4851 echo "skip interop for MDS < v2_12_52-91-g183cb1e3cdd2"
4855 # Check that $opts took
4856 tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
4858 tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
4860 tstarted=$(do_facet $facet \
4861 "$LCTL get_param -n ${paramp}.threads_started" || echo 0)
4862 lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
4868 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads' '16'
4869 cleanup || error "cleanup failed with rc $?"
4871 run_test 53a "check OSS thread count params"
4875 thread_sanity MDT $SINGLEMDS 'mds.*.*.' 'mds_num_threads' 16
4876 cleanup || error "cleanup failed with $?"
4878 run_test 53b "check MDS thread count params"
4881 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4882 skip "ldiskfs only test"
4885 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
4886 error "llverdev failed with rc=$?"
4889 run_test 54a "test llverdev and partial verify of device"
4892 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4893 skip "ldiskfs only test"
4897 run_llverfs $MOUNT -p || error "llverfs failed with rc=$?"
4898 cleanup || error "cleanup failed with rc=$?"
4900 run_test 54b "test llverfs and partial verify of filesystem"
4904 local max_ost_index=$1
4906 echo -n $(((max_ost_index + 1) * 8))
4910 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4911 skip "ldiskfs only test"
4914 local mdsdev=$(mdsdevname 1)
4915 local mdsvdev=$(mdsvdevname 1)
4919 if ! combined_mgs_mds; then
4920 stop_mgs || error "stopping MGS service failed"
4921 format_mgs || error "formatting MGT failed"
4923 add mds1 $(mkfs_opts mds1 ${mdsdev}) --reformat $mdsdev \
4925 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
4926 --reformat $(ostdevname 1) $(ostvdevname 1)
4932 echo checking size of lov_objid for ost index $i
4933 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" |
4934 grep ^User | awk -F 'Size: ' '{print $2}')
4935 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
4936 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
4938 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
4945 run_test 55 "check lov_objid size"
4948 local mds_journal_size_orig=$MDSJOURNALSIZE
4954 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
4955 $(ostdevname 1) $(ostvdevname 1)
4956 add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
4957 $(ostdevname 2) $(ostvdevname 2)
4960 start_ost || error "Unable to start first ost (idx 10000)"
4961 start_ost2 || error "Unable to start second ost (idx 1000)"
4962 mount_client $MOUNT || error "Unable to mount client"
4966 # test instantiating PFL components with sparse index LU-15513
4967 mkdir -p $MOUNT/$tdir
4968 $LFS setstripe -E 4M -c 1 -E 1G -c 4 -S4M -E eof -c -1 $MOUNT/$tdir
4969 dd if=/dev/zero of=$MOUNT/$tdir/$tfile bs=4K count=1 seek=10k ||
4970 error "dd to second component failed"
4972 if [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
4973 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
4974 "$MDS1_VERSION" -lt $(version_code 2.5.11) ]]; then
4975 wait_osc_import_state mds ost1 FULL
4976 wait_osc_import_state mds ost2 FULL
4977 $LFS setstripe --stripe-count=-1 $DIR/$tfile ||
4978 error "Unable to setstripe $DIR/$tfile"
4979 n=$($LFS getstripe --stripe-count $DIR/$tfile)
4980 [ "$n" -eq 2 ] || error "Stripe count not two: $n"
4985 MDSJOURNALSIZE=$mds_journal_size_orig
4988 run_test 56a "check big OST indexes and out-of-index-order start"
4993 umount_client $MOUNT -f || error "unmount client failed"
5002 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
5004 trap cleanup_56b EXIT RETURN ERR
5007 if ! combined_mgs_mds ; then
5012 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) --index=0 --reformat \
5013 $(mdsdevname 1) $(mdsvdevname 1)
5014 add mds2 $(mkfs_opts mds2 $(mdsdevname 2)) --index=1 --reformat \
5015 $(mdsdevname 2) $(mdsvdevname 2)
5016 add mds3 $(mkfs_opts mds3 $(mdsdevname 3)) --index=1000 --reformat \
5017 $(mdsdevname 3) $(mdsvdevname 3)
5021 start_mdt 1 || error "MDT 1 (idx 0) start failed"
5022 start_mdt 2 || error "MDT 2 (idx 1) start failed"
5023 start_mdt 3 || error "MDT 3 (idx 1000) start failed"
5024 start_ost || error "Unable to start first ost"
5025 start_ost2 || error "Unable to start second ost"
5027 do_nodes $(comma_list $(mdts_nodes)) \
5028 "$LCTL set_param mdt.*.enable_remote_dir=1 \
5029 mdt.*.enable_remote_dir_gid=-1"
5031 mount_client $MOUNT || error "Unable to mount client"
5033 $LFS mkdir -c3 $MOUNT/$tdir || error "failed to make testdir"
5035 echo "This is test file 1!" > $MOUNT/$tdir/$tfile.1 ||
5036 error "failed to make test file 1"
5037 echo "This is test file 2!" > $MOUNT/$tdir/$tfile.2 ||
5038 error "failed to make test file 2"
5039 echo "This is test file 1000!" > $MOUNT/$tdir/$tfile.1000 ||
5040 error "failed to make test file 1000"
5042 rm -rf $MOUNT/$tdir || error "failed to remove testdir"
5044 $LFS mkdir -i1000 $MOUNT/$tdir.1000 ||
5045 error "create remote dir at idx 1000 failed"
5048 echo "=== START lfs df OUTPUT ==="
5050 echo "==== END lfs df OUTPUT ===="
5052 mdtcnt=$(echo -e "$output" | grep $FSNAME-MDT | wc -l)
5053 ostcnt=$(echo -e "$output" | grep $FSNAME-OST | wc -l)
5055 echo "lfs df returned mdt count $mdtcnt and ost count $ostcnt"
5056 [ $mdtcnt -eq 3 ] || error "lfs df returned wrong mdt count"
5057 [ $ostcnt -eq 2 ] || error "lfs df returned wrong ost count"
5059 echo "This is test file 1!" > $MOUNT/$tdir.1000/$tfile.1 ||
5060 error "failed to make test file 1"
5061 echo "This is test file 2!" > $MOUNT/$tdir.1000/$tfile.2 ||
5062 error "failed to make test file 2"
5063 echo "This is test file 1000!" > $MOUNT/$tdir.1000/$tfile.1000 ||
5064 error "failed to make test file 1000"
5065 rm -rf $MOUNT/$tdir.1000 || error "failed to remove remote_dir"
5068 echo "=== START lfs mdts OUTPUT ==="
5070 echo "==== END lfs mdts OUTPUT ===="
5072 echo -e "$output" | grep -v "MDTS:" | awk '{print $1}' |
5073 sed 's/://g' > $TMP/mdts-actual.txt
5074 sort $TMP/mdts-actual.txt -o $TMP/mdts-actual.txt
5076 echo -e "0\n1\n1000" > $TMP/mdts-expected.txt
5078 diff $TMP/mdts-expected.txt $TMP/mdts-actual.txt
5081 rm $TMP/mdts-expected.txt $TMP/mdts-actual.txt
5083 [ $result -eq 0 ] || error "target_obd proc file is incorrect!"
5085 run_test 56b "test target_obd correctness with nonconsecutive MDTs"
5087 test_57a() { # bug 22656
5088 do_rpc_nodes $(facet_active_host ost1) load_modules_local
5089 local NID=$(do_facet ost1 "$LCTL get_param nis" |
5090 tail -1 | awk '{print $1}')
5091 writeconf_or_reformat
5092 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
5093 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
5094 error "tunefs failed"
5096 start_ost && error "OST registration from failnode should fail"
5099 run_test 57a "initial registration from failnode should fail (should return errs)"
5102 do_rpc_nodes $(facet_active_host ost1) load_modules_local
5103 local NID=$(do_facet ost1 "$LCTL get_param nis" |
5104 tail -1 | awk '{print $1}')
5105 writeconf_or_reformat
5106 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
5107 do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
5108 error "tunefs failed"
5110 start_ost || error "OST registration from servicenode should not fail"
5113 run_test 57b "initial registration from servicenode should not fail"
5116 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
5119 test_58() { # bug 22658
5120 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
5122 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5123 createmany -o $DIR/$tdir/$tfile-%d 100
5124 unlinkmany $DIR/$tdir/$tfile-%d 100
5125 stop_mds || error "Unable to stop MDS"
5127 local MNTDIR=$(facet_mntpt $SINGLEMDS)
5128 local devname=$(mdsdevname ${SINGLEMDS//mds/})
5130 # remove all files from the OBJECTS dir
5131 mount_fstype $SINGLEMDS
5133 do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
5135 unmount_fstype $SINGLEMDS
5136 # restart MDS with missing llog files
5137 start_mds || error "unable to start MDS"
5138 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
5141 run_test 58 "missing llog files must not prevent MDT from mounting"
5144 start_mgsmds >> /dev/null
5145 local C1=$(count_osts)
5146 if [ $C1 -eq 0 ]; then
5147 start_ost >> /dev/null
5151 echo "original ost count: $C1 (expect > 0)"
5152 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
5153 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
5154 local C2=$(count_osts)
5155 echo "after mdt writeconf count: $C2 (expect 0)"
5156 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
5157 echo "OST start without writeconf should fail:"
5158 start_ost >> /dev/null &&
5159 error "OST start without writeconf didn't fail"
5160 echo "OST start with writeconf should succeed:"
5161 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
5162 local C3=$(count_osts)
5163 echo "after ost writeconf count: $C3 (expect 1)"
5164 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
5165 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
5166 local C4=$(count_osts)
5167 echo "after ost2 writeconf count: $C4 (expect 2)"
5168 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
5169 stop_ost2 >> /dev/null
5170 cleanup_nocli >> /dev/null
5171 #writeconf to remove all ost2 traces for subsequent tests
5172 writeconf_or_reformat
5174 run_test 59 "writeconf mount option"
5176 test_60a() { # LU-471
5177 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5178 skip "ldiskfs only test"
5183 for num in $(seq $MDSCOUNT); do
5184 add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
5185 --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
5186 --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
5190 dump=$(do_facet $SINGLEMDS dumpe2fs $(mdsdevname 1))
5191 [ ${PIPESTATUS[0]} -eq 0 ] || error "dumpe2fs $(mdsdevname 1) failed"
5193 # MDT default has dirdata feature
5194 echo $dump | grep dirdata > /dev/null || error "dirdata is not set"
5195 # we disable uninit_bg feature
5196 echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
5197 # we set stride extended options
5198 echo $dump | grep stride > /dev/null || error "stride is not set"
5202 run_test 60a "check mkfs.lustre --mkfsoptions -E -O options setting"
5205 [[ "$mds1_FSTYPE" == ldiskfs ]] || skip "ldiskfs only test"
5207 local features=$(do_facet $SINGLEMDS $DUMPE2FS $(mdsdevname 1) |
5209 [ ${PIPESTATUS[0]} -eq 0 ] || error "$DUMPE2FS $(mdsdevname 1) failed"
5212 # ea_inode feature should be enabled by default for MDTs
5213 [[ "$features" =~ "ea_inode" ]] || error "ea_inode is not set"
5214 # large_dir feature should be enabled by default for MDTs
5215 [[ "$features" =~ "large_dir" ]] || error "large_dir is not set"
5217 run_test 60b "check mkfs.lustre MDT default features"
5219 test_61a() { # LU-80
5220 local lxattr=$(large_xattr_enabled)
5222 (( "$MDS1_VERSION" >= $(version_code 2.1.53) )) ||
5223 skip "Need MDS version at least 2.1.53 for large_xattr"
5225 if [[ "$mds1_FSTYPE" == ldiskfs ]] && ! large_xattr_enabled; then
5228 for ((num=1; num <= $MDSCOUNT; num++)); do
5229 do_facet mds${num} $TUNE2FS -O ea_inode \
5230 $(mdsdevname $num) ||
5231 error "tune2fs on mds $num failed"
5235 setup || error "setting up the filesystem failed"
5236 client_up || error "starting client failed"
5238 local file=$DIR/$tfile
5239 touch $file || error "touch $file failed"
5241 local large_value="$(generate_string $(max_xattr_size))"
5242 local small_value="bar"
5244 local name="trusted.big"
5245 log "save large xattr of $(max_xattr_size) bytes on $name on $file"
5246 setfattr -n $name -v $large_value $file ||
5247 error "saving $name on $file failed"
5249 local new_value=$(get_xattr_value $name $file)
5250 [[ "$new_value" != "$large_value" ]] &&
5251 error "$name different after saving"
5253 log "shrink value of $name on $file"
5254 setfattr -n $name -v $small_value $file ||
5255 error "shrinking value of $name on $file failed"
5257 new_value=$(get_xattr_value $name $file)
5258 [[ "$new_value" != "$small_value" ]] &&
5259 error "$name different after shrinking"
5261 log "grow value of $name on $file"
5262 setfattr -n $name -v $large_value $file ||
5263 error "growing value of $name on $file failed"
5265 new_value=$(get_xattr_value $name $file)
5266 [[ "$new_value" != "$large_value" ]] &&
5267 error "$name different after growing"
5269 log "check value of $name on $file after remounting MDS"
5271 new_value=$(get_xattr_value $name $file)
5272 [[ "$new_value" != "$large_value" ]] &&
5273 error "$name different after remounting MDS"
5275 log "remove large xattr $name from $file"
5276 setfattr -x $name $file || error "removing $name from $file failed"
5278 if $lxattr && [ "$mds1_FSTYPE" == ldiskfs ]; then
5279 stopall || error "stopping for e2fsck run"
5280 for num in $(seq $MDSCOUNT); do
5281 run_e2fsck $(facet_active_host mds$num) \
5282 $(mdsdevname $num) "-y" ||
5283 error "e2fsck MDT$num failed"
5285 setup_noconfig || error "remounting the filesystem failed"
5288 # need to delete this file to avoid problems in other tests
5290 cleanup || error "stopping systems failed"
5292 run_test 61a "large xattr"
5294 test_61b() { # LU-80
5295 local lxattr=$(large_xattr_enabled)
5297 (( $MDS1_VERSION >= $(version_code 2.15.51) )) ||
5298 skip "Need MDS version at least 2.15.51 for large_xattr fix"
5300 [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs specific bug"
5302 if ! large_xattr_enabled; then
5305 for (( num=1; num <= $MDSCOUNT; num++ )); do
5306 do_facet mds${num} $TUNE2FS -O ea_inode \
5307 $(mdsdevname $num) ||
5308 error "tune2fs on mds $num failed"
5312 setup || error "setting up the filesystem failed"
5313 client_up || error "starting client failed"
5315 local _file=$MOUNT/panda
5316 local large_value="$(generate_string $(max_xattr_size))"
5317 local name="trusted.big"
5319 touch ${_file} || error "touch ${_file} failed"
5320 setfattr -n $name -v $large_value ${_file} ||
5321 error "saving $name on $file failed"
5323 MDT_DEV="${FSNAME}-MDT0000"
5324 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
5326 stopall || error "stopping for e2fsck run"
5329 ino=$(do_facet $SINGLEMDS "$DEBUGFS -R 'stat /ROOT/panda' \
5330 ${MDT_DEVNAME} | grep trusted.big")
5331 ino=$(echo "${ino}" | awk '{print $2;}')
5332 echo "large ea "${ino}
5334 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"ln $ino /lost+found\\\" \
5337 setup_noconfig || error "remounting the filesystem failed"
5339 do_facet $SINGLEMDS $LCTL lfsck_start -M ${MDT_DEV} -t namespace || {
5340 error "can't start lfsck namespace"
5344 wait_update_facet $SINGLEMDS "$LCTL get_param -n \
5345 mdd.${MDT_DEV}.lfsck_namespace |
5346 awk '/^status/ { print \\\$2 }'" "completed" 32 || {
5347 error "(2) unexpected status"
5350 stopall || error "stopping for e2fsck run"
5351 for num in $(seq $MDSCOUNT); do
5352 run_e2fsck $(facet_active_host mds$num) \
5353 $(mdsdevname $num) "-y" ||
5354 error "e2fsck MDT$num failed"
5356 setup_noconfig || error "remounting the filesystem failed"
5358 # need to delete this file to avoid problems in other tests
5360 cleanup || error "stopping systems failed"
5362 run_test 61b "large xattr"
5365 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5366 skip "ldiskfs only test"
5368 [[ "$MDS1_VERSION" -ge $(version_code 2.2.51) ]] ||
5369 skip "Need MDS version at least 2.2.51"
5372 local mdsdev=$(mdsdevname 1)
5373 local ostdev=$(ostdevname 1)
5375 echo "disable journal for mds"
5376 do_facet mds1 $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
5377 start_mds && error "MDT start should fail"
5378 echo "disable journal for ost"
5379 do_facet ost1 $TUNE2FS -O ^has_journal $ostdev || error "tune2fs failed"
5380 start_ost && error "OST start should fail"
5381 cleanup || error "cleanup failed with rc $?"
5384 run_test 62 "start with disabled journal"
5387 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5388 skip "ldiskfs only test"
5391 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ldiskfs
5392 local inode_slab=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
5393 awk '/ldiskfs_inode_cache/ { print $5 / $6 }')
5394 if [ -z "$inode_slab" ]; then
5395 skip "ldiskfs module has not been loaded"
5398 if grep -q "CONFIG_DEBUG_LOCK_ALLOC=y" /boot/config-$(uname -r); then
5399 skip "test is not compatible with CONFIG_DEBUG_LOCK_ALLOC=y"
5402 echo "$inode_slab ldiskfs inodes per page"
5403 [ "${inode_slab%.*}" -ge "3" ] && return 0
5405 # If kmalloc-128 is also 1 per page - this is a debug kernel
5406 # and so this is not an error.
5407 local kmalloc128=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
5408 awk '/^(dma-kmalloc|size)-128 / { print $5 / $6 }')
5409 # 32 128-byte chunks in 4k
5410 [ "${kmalloc128%.*}" -lt "32" ] ||
5411 error "ldiskfs inode too big, only $inode_slab objs/page, " \
5412 "kmalloc128 = $kmalloc128 objs/page"
5414 run_test 63 "Verify each page can at least hold 3 ldiskfs inodes"
5417 start_mds || error "unable to start MDS"
5418 start_ost || error "Unable to start OST1"
5419 start_ost2 || error "Unable to start second ost"
5420 mount_client $MOUNT || error "Unable to mount client"
5421 stop_ost2 || error "Unable to stop second ost"
5424 umount_client $MOUNT -f || error "unmount $MOUNT failed"
5425 cleanup_nocli || error "cleanup_nocli failed with $?"
5426 #writeconf to remove all ost2 traces for subsequent tests
5427 writeconf_or_reformat
5429 run_test 64 "check lfs df --lazy "
5431 test_65() { # LU-2237
5432 # Currently, the test is only valid for ldiskfs backend
5433 [ "$mds1_FSTYPE" != ldiskfs ] &&
5434 skip "ldiskfs only test"
5436 local devname=$(mdsdevname ${SINGLEMDS//mds/})
5437 local brpt=$(facet_mntpt brpt)
5440 if ! do_facet $SINGLEMDS "test -b $devname"; then
5444 stop_mds || error "Unable to stop MDS"
5445 local obj=$(do_facet $SINGLEMDS \
5446 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
5448 if [ -z "$obj" ]; then
5449 # The MDT may be just re-formatted, mount the MDT for the
5450 # first time to guarantee the "last_rcvd" file is there.
5451 start_mds || error "fail to mount the MDS for the first time"
5452 stop_mds || error "Unable to stop MDS"
5455 # remove the "last_rcvd" file
5456 do_facet $SINGLEMDS "mkdir -p $brpt"
5457 do_facet $SINGLEMDS \
5458 "mount -t $mds1_FSTYPE $opts $devname $brpt"
5459 do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
5460 do_facet $SINGLEMDS "$UMOUNT $brpt"
5462 # restart MDS, the "last_rcvd" file should be recreated.
5463 start_mds || error "fail to restart the MDS"
5464 stop_mds || error "Unable to stop MDS"
5465 obj=$(do_facet $SINGLEMDS \
5466 "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
5467 [ -n "$obj" ] || error "fail to re-create the last_rcvd"
5469 run_test 65 "re-create the lost last_rcvd file when server mount"
5472 [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
5473 skip "Need MGS version at least 2.3.59"
5475 check_versions || skip "do not replace_nids with mismatched versions"
5478 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
5479 local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
5481 # add EXCLUDE records to config log, they are not to be
5482 # removed by lctl replace_nids
5483 set_conf_param_and_check mds \
5484 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
5485 "$FSNAME-OST0000.osc.active" \
5488 echo "replace_nids should fail if MDS, OSTs and clients are UP"
5489 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
5490 error "replace_nids fail"
5492 umount_client $MOUNT || error "unmounting client failed"
5493 echo "replace_nids should fail if MDS and OSTs are UP"
5494 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
5495 error "replace_nids fail"
5497 stop_ost || error "Unable to stop OST1"
5498 echo "replace_nids should fail if MDS is UP"
5499 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
5500 error "replace_nids fail"
5502 stop_mds || error "stopping mds failed"
5504 if combined_mgs_mds; then
5505 start_mdt 1 "-o nosvc" ||
5506 error "starting mds with nosvc option failed"
5509 echo "command should accept two parameters"
5510 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
5511 error "command should accept two params"
5513 echo "correct device name should be passed"
5514 do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
5515 error "wrong devname"
5517 echo "wrong nids list should not destroy the system"
5518 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
5520 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "asdfasdf, asdfadf" &&
5523 echo "replace OST nid"
5524 do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
5525 error "replace nids failed"
5527 echo "command should accept two parameters"
5528 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
5529 error "command should accept two params"
5531 echo "wrong nids list should not destroy the system"
5532 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
5535 local FAKE_NIDS="192.168.0.112@tcp1,192.168.0.112@tcp2"
5536 local FAKE_FAILOVER="192.168.0.113@tcp1,192.168.0.113@tcp2"
5537 local NIDS_AND_FAILOVER="$MDS_NID,$FAKE_NIDS:$FAKE_FAILOVER"
5538 echo "set NIDs with failover"
5539 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $NIDS_AND_FAILOVER ||
5540 error "replace nids failed"
5543 echo "replace MDS nid"
5544 do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
5545 error "replace nids failed"
5547 if ! combined_mgs_mds ; then
5550 stop_mds || error "Unable to stop MDS"
5553 start_mgsmds || error "start mgsmds failed"
5554 set_conf_param_and_check mds \
5555 "$LCTL get_param -n osc.$FSNAME-OST0000-osc-MDT0000.active" \
5556 "$FSNAME-OST0000.osc.active" \
5558 start_ost || error "unable to start OST"
5559 mount_client $MOUNT || error "mount client failed"
5561 check_mount || error "error after nid replace"
5562 cleanup || error "cleanup failed"
5565 run_test 66 "replace nids"
5567 test_67() { #LU-2950
5568 local legacy="$TMP/legacy_lnet_config"
5569 local new="$TMP/new_routes_test"
5570 local out="$TMP/config_out_file"
5571 local verify="$TMP/conv_verify"
5572 local verify_conf="$TMP/conf_verify"
5574 # Create the legacy file that will be run through the
5575 # lustre_routes_conversion script
5576 cat <<- LEGACY_LNET_CONFIG > $legacy
5577 tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
5578 tcp2 54 10.1.3.2@tcp;
5579 tcp3 10.3.4.3@tcp:3;
5583 # Create the verification file to verify the output of
5584 # lustre_routes_conversion script against.
5585 cat <<- VERIFY_LNET_CONFIG > $verify
5586 tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
5587 tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
5588 tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
5589 tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
5590 tcp4: { gateway: 10.3.3.4@tcp }
5593 # Create the verification file to verify the output of
5594 # lustre_routes_config script against
5595 cat <<- VERIFY_LNET_CONFIG > $verify_conf
5596 lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
5597 lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
5598 lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
5599 lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
5600 lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
5603 $LUSTRE_ROUTES_CONVERSION $legacy $new > /dev/null
5604 if [ -f $new ]; then
5605 # verify the conversion output
5606 cmp -s $new $verify > /dev/null
5607 if [ $? -eq 1 ]; then
5608 error "routes conversion failed"
5611 lustre_routes_config --dry-run --verbose $new > $out
5612 # check that the script succeeded
5613 cmp -s $out $verify_conf > /dev/null
5614 if [ $? -eq 1 ]; then
5615 error "routes config failed"
5618 error "routes conversion test failed"
5620 # remove generated files
5621 rm -f $new $legacy $verify $verify_conf $out
5623 run_test 67 "test routes conversion and configuration"
5631 [ "$MDS1_VERSION" -ge $(version_code 2.4.53) ] ||
5632 skip "Need MDS version at least 2.4.53"
5634 umount_client $MOUNT || error "umount client failed"
5639 # START-END - the sequences we'll be reserving
5640 START=$(do_facet $SINGLEMDS \
5641 $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
5642 END=$((START + (1 << 30)))
5643 do_facet $SINGLEMDS \
5644 $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
5646 # reset the sequences MDT0000 has already assigned
5647 do_facet $SINGLEMDS \
5648 $LCTL set_param seq.srv*MDT0000.space=clear
5650 # remount to let the client allocate new sequence
5651 mount_client $MOUNT || error "mount client failed"
5653 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
5654 do_facet $SINGLEMDS \
5655 $LCTL get_param seq.srv*MDT0000.space
5656 $LFS path2fid $DIR/$tfile
5658 local old_ifs="$IFS"
5660 fid=($($LFS path2fid $DIR/$tfile))
5664 if [[ $seq < $END ]]; then
5665 error "used reserved sequence $seq?"
5667 cleanup || error "cleanup failed with $?"
5669 run_test 68 "be able to reserve specific sequences in FLDB"
5671 # Test 69: is about the total number of objects ever created on an OST.
5672 # so that when it is reformatted the normal MDS->OST orphan recovery won't
5673 # just "precreate" the missing objects. In the past it might try to recreate
5674 # millions of objects after an OST was reformatted
5676 [[ "$MDS1_VERSION" -lt $(version_code 2.4.2) ]] &&
5677 skip "Need MDS version at least 2.4.2"
5679 [[ "$MDS1_VERSION" -ge $(version_code 2.4.50) ]] &&
5680 [[ "$MDS1_VERSION" -lt $(version_code 2.5.0) ]] &&
5681 skip "Need MDS version at least 2.5.0"
5684 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
5685 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param \
5686 seq.*OST*-super.width=$DATA_SEQ_MAX_WIDTH
5688 # use OST0000 since it probably has the most creations
5689 local OSTNAME=$(ostname_from_index 0)
5690 local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
5691 local last_id=$(do_facet mds1 $LCTL get_param -n \
5692 osp.$mdtosc_proc1.prealloc_last_id)
5694 # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
5695 # verify that the LAST_ID recovery is working properly. If
5696 # not, then the OST will refuse to allow the MDS connect
5697 # because the LAST_ID value is too different from the MDS
5698 #define OST_MAX_PRECREATE=20000
5699 local ost_max_pre=20000
5700 local num_create=$(( ost_max_pre * 5 + 1 - last_id))
5702 # If the LAST_ID is already over 5 * OST_MAX_PRECREATE, we don't
5703 # need to create any files. So, skip this section.
5704 if [ $num_create -gt 0 ]; then
5705 # Check the number of inodes available on OST0
5707 local ifree=$($LFS df -i $MOUNT |
5708 awk '/OST0000/ { print $4 }'; exit ${PIPESTATUS[0]})
5709 log "On OST0, $ifree inodes available. Want $num_create. rc=$?"
5711 $LFS setstripe -i 0 $DIR/$tdir ||
5712 error "$LFS setstripe -i 0 $DIR/$tdir failed"
5713 if [ $ifree -lt 10000 ]; then
5714 files=$(( ifree - 50 ))
5719 local j=$((num_create / files + 1))
5720 for i in $(seq 1 $j); do
5721 createmany -o $DIR/$tdir/$tfile-$i- $files ||
5722 error "createmany fail create $files files: $?"
5723 unlinkmany $DIR/$tdir/$tfile-$i- $files ||
5724 error "unlinkmany failed unlink $files files"
5728 # delete all of the files with objects on OST0 so the
5729 # filesystem is not inconsistent later on
5730 $LFS find $MOUNT --ost 0 -print0 | xargs -0 rm
5732 umount_client $MOUNT || error "umount client failed"
5733 stop_ost || error "OST0 stop failure"
5734 add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
5735 $(ostdevname 1) $(ostvdevname 1) ||
5736 error "reformat and replace $ostdev failed"
5737 start_ost || error "OST0 restart failure"
5738 wait_osc_import_state mds ost FULL
5740 mount_client $MOUNT || error "mount client failed"
5741 touch $DIR/$tdir/$tfile-last || error "create file after reformat"
5742 local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
5743 [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
5745 local iused=$($LFS df -i $MOUNT |
5746 awk '/OST0000/ { print $3 }'; exit ${PIPESTATUS[0]})
5747 log "On OST0, $iused used inodes rc=$?"
5748 [ $iused -ge $((ost_max_pre + 1000)) ] &&
5749 error "OST replacement created too many inodes; $iused"
5750 cleanup || error "cleanup failed with $?"
5752 run_test 69 "replace an OST with the same index"
5755 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5758 cleanup || error "cleanup failed with $?"
5760 start_mdt 1 || error "MDT0 start fail"
5762 start_ost || error "OST0 start fail"
5763 for num in $(seq 2 $MDSCOUNT); do
5764 start_mdt $num || return
5767 mount_client $MOUNT || error "mount client fails"
5769 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5771 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5772 error "create remote dir fail"
5774 rm -rf $DIR/$tdir || error "delete dir fail"
5775 cleanup || error "cleanup failed with $?"
5777 run_test 70a "start MDT0, then OST, then MDT1"
5780 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5783 start_ost || error "OST0 start fail"
5785 start_mds || error "MDS start fail"
5787 mount_client $MOUNT || error "mount client fails"
5789 mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
5791 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5792 error "create remote dir fail"
5794 rm -rf $DIR/$tdir || error "delete dir fail"
5796 cleanup || error "cleanup failed with $?"
5798 run_test 70b "start OST, MDT1, MDT0"
5801 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5804 start_mds || error "MDS start fail"
5805 start_ost || error "OST0 start fail"
5807 mount_client $MOUNT || error "mount client fails"
5808 stop_mdt 1 || error "MDT1 start fail"
5810 local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
5811 echo "deactivate $mdc_for_mdt1"
5812 $LCTL --device $mdc_for_mdt1 deactivate ||
5813 error "set $mdc_for_mdt1 deactivate failed"
5815 mkdir $DIR/$tdir && error "mkdir succeed"
5817 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5818 error "create remote dir succeed"
5820 cleanup || error "cleanup failed with $?"
5822 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
5825 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5828 start_mds || error "MDS start fail"
5829 start_ost || error "OST0 start fail"
5831 mount_client $MOUNT || error "mount client fails"
5833 stop_mdt 2 || error "MDT1 start fail"
5835 local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
5837 echo "deactivate $mdc_for_mdt2"
5838 $LCTL --device $mdc_for_mdt2 deactivate ||
5839 error "set $mdc_for_mdt2 deactivate failed"
5841 mkdir $DIR/$tdir || error "mkdir fail"
5842 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
5843 error "create remote dir succeed"
5845 rm -rf $DIR/$tdir || error "delete dir fail"
5847 cleanup || error "cleanup failed with $?"
5849 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
5852 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5854 [ "$MDS1_VERSION" -ge $(version_code 2.7.62) ] ||
5855 skip "Need MDS version at least 2.7.62"
5857 reformat || error "reformat failed with $?"
5861 local mdsdev=$(mdsdevname 1)
5862 local ostdev=$(ostdevname 1)
5863 local mdsvdev=$(mdsvdevname 1)
5864 local ostvdev=$(ostvdevname 1)
5865 local opts_mds="$(mkfs_opts mds1 $mdsdev) --reformat $mdsdev $mdsvdev"
5866 local opts_ost="$(mkfs_opts ost1 $ostdev) --reformat $ostdev $ostvdev"
5868 if ! combined_mgs_mds ; then
5872 add mds1 $opts_mds || error "add mds1 failed"
5873 start_mdt 1 || error "start mdt1 failed"
5874 add ost1 $opts_ost || error "add ost1 failed"
5875 start_ost || error "start ost failed"
5876 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
5878 local soc=$(do_facet mds1 "$LCTL get_param -n \
5879 mdt.*MDT0000.sync_lock_cancel")
5880 [ $soc == "never" ] || error "SoC enabled on single MDS"
5882 for i in $(seq 2 $MDSCOUNT); do
5883 mdsdev=$(mdsdevname $i)
5884 mdsvdev=$(mdsvdevname $i)
5885 opts_mds="$(mkfs_opts mds$i $mdsdev) --reformat $mdsdev \
5887 add mds$i $opts_mds || error "add mds$i failed"
5888 start_mdt $i || error "start mdt$i fail"
5891 wait_dne_interconnect
5893 for i in $(seq $MDSCOUNT); do
5894 soc=$(do_facet mds$i "$LCTL get_param -n \
5895 mdt.*MDT000$((i - 1)).sync_lock_cancel")
5896 [ $soc == "blocking" ] || error "SoC not enabled on DNE"
5899 for i in $(seq 2 $MDSCOUNT); do
5900 stop_mdt $i || error "stop mdt$i fail"
5902 soc=$(do_facet mds1 "$LCTL get_param -n \
5903 mdt.*MDT0000.sync_lock_cancel")
5904 [ $soc == "never" ] || error "SoC enabled on single MDS"
5905 umount_client $MOUNT -f > /dev/null
5907 cleanup || error "cleanup failed with $?"
5909 run_test 70e "Sync-on-Cancel will be enabled by default on DNE"
5912 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5913 if combined_mgs_mds; then
5914 skip "needs separate MGS/MDT"
5918 start_mdt 1 || error "MDT0 start fail"
5919 start_ost || error "OST0 start fail"
5920 for num in $(seq 2 $MDSCOUNT); do
5921 start_mdt $num || return
5924 start_ost2 || error "OST1 start fail"
5926 mount_client $MOUNT || error "mount client fails"
5928 mkdir $DIR/$tdir || error "mkdir fail"
5929 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5930 error "create remote dir succeed"
5932 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5933 rm -rf $DIR/$tdir || error "delete dir fail"
5935 umount_client $MOUNT || error "umount_client failed"
5936 stop_mds || error "MDS stop fail"
5937 stop_ost || error "OST0 stop fail"
5938 stop_ost2 || error "OST1 stop fail"
5940 run_test 71a "start MDT0 OST0, MDT1, OST1"
5943 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5944 if combined_mgs_mds; then
5945 skip "needs separate MGS/MDT"
5949 for num in $(seq 2 $MDSCOUNT); do
5950 start_mdt $num || return
5952 start_ost || error "OST0 start fail"
5953 start_mdt 1 || error "MDT0 start fail"
5954 start_ost2 || error "OST1 start fail"
5956 mount_client $MOUNT || error "mount client fails"
5958 mkdir $DIR/$tdir || error "mkdir fail"
5959 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5960 error "create remote dir succeed"
5962 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5963 rm -rf $DIR/$tdir || error "delete dir fail"
5965 umount_client $MOUNT || error "umount_client failed"
5966 stop_mds || error "MDT0 stop fail"
5967 stop_ost || error "OST0 stop fail"
5968 stop_ost2 || error "OST1 stop fail"
5970 run_test 71b "start MDT1, OST0, MDT0, OST1"
5973 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
5974 combined_mgs_mds && skip "needs separate MGS/MDT"
5978 start_ost || error "OST0 start fail"
5979 start_ost2 || error "OST1 start fail"
5980 for num in $(seq 2 $MDSCOUNT); do
5981 start_mdt $num || return
5983 start_mdt 1 || error "MDT0 start fail"
5985 mount_client $MOUNT || error "mount client fails"
5987 mkdir $DIR/$tdir || error "mkdir fail"
5988 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
5989 error "create remote dir succeed"
5991 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
5992 rm -rf $DIR/$tdir || error "delete dir fail"
5994 umount_client $MOUNT || error "umount_client failed"
5995 stop_mds || error "MDS stop fail"
5996 stop_ost || error "OST0 stop fail"
5997 stop_ost2 || error "OST1 stop fail"
6000 run_test 71c "start OST0, OST1, MDT1, MDT0"
6003 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6004 combined_mgs_mds && skip "needs separate MGS/MDT"
6008 start_ost || error "OST0 start fail"
6009 for num in $(seq 2 $MDSCOUNT); do
6010 start_mdt $num || return
6012 start_mdt 1 || error "MDT0 start fail"
6013 start_ost2 || error "OST1 start fail"
6015 mount_client $MOUNT || error "mount client fails"
6017 mkdir $DIR/$tdir || error "mkdir fail"
6018 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
6019 error "create remote dir succeed"
6021 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
6022 rm -rf $DIR/$tdir || error "delete dir fail"
6024 umount_client $MOUNT || error "umount_client failed"
6025 stop_mds || error "MDS stop fail"
6026 stop_ost || error "OST0 stop fail"
6027 stop_ost2 || error "OST1 stop fail"
6030 run_test 71d "start OST0, MDT1, MDT0, OST1"
6033 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
6034 combined_mgs_mds && skip "needs separate MGS/MDT"
6038 start_ost || error "OST0 start fail"
6039 for num in $(seq 2 $MDSCOUNT); do
6040 start_mdt $num || return
6042 start_ost2 || error "OST1 start fail"
6043 start_mdt 1 || error "MDT0 start fail"
6045 mount_client $MOUNT || error "mount client fails"
6047 mkdir $DIR/$tdir || error "mkdir fail"
6048 $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
6049 error "create remote dir succeed"
6051 mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
6052 rm -rf $DIR/$tdir || error "delete dir fail"
6054 umount_client $MOUNT || error "umount_client failed"
6055 stop_mds || error "MDS stop fail"
6056 stop_ost || error "OST0 stop fail"
6057 stop_ost2 || error "OST1 stop fail"
6060 run_test 71e "start OST0, MDT1, OST1, MDT0"
6062 test_72() { #LU-2634
6063 [ "$mds1_FSTYPE" != ldiskfs ] &&
6064 skip "ldiskfs only test"
6066 local mdsdev=$(mdsdevname 1)
6067 local ostdev=$(ostdevname 1)
6068 local cmd="$E2FSCK -fnvd $mdsdev"
6075 if combined_mgs_mds; then
6076 add_options='--reformat'
6078 add_options='--reformat --replace'
6081 #tune MDT with "-O extents"
6083 for num in $(seq $MDSCOUNT); do
6084 add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
6085 $add_options $(mdsdevname $num) $(mdsvdevname $num) ||
6086 error "add mds $num failed"
6087 do_facet mds${num} "$TUNE2FS -O extents $(mdsdevname $num)" ||
6088 error "$TUNE2FS failed on mds${num}"
6091 add ost1 $(mkfs_opts ost1 $ostdev) $add_options $ostdev ||
6092 error "add $ostdev failed"
6093 start_mds || error "start mds failed"
6094 start_ost || error "start ost failed"
6095 mount_client $MOUNT || error "mount client failed"
6097 #create some short symlinks
6098 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6099 createmany -o $DIR/$tdir/$tfile-%d $fn
6100 echo "create $fn short symlinks"
6101 for i in $(seq -w 1 $fn); do
6102 ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
6107 umount_client $MOUNT || error "umount client failed"
6108 stop_mds || error "stop mds failed"
6109 stop_ost || error "stop ost failed"
6112 run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
6114 run_test 72 "test fast symlink with extents flag enabled"
6116 test_73() { #LU-3006
6117 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
6118 do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
6119 error "1st tunefs failed"
6120 start_mgsmds || error "start mds failed"
6121 start_ost || error "start ost failed"
6122 mount_client $MOUNT || error "mount client failed"
6123 $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
6124 grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
6125 umount_client $MOUNT || error "umount client failed"
6129 run_test 73 "failnode to update from mountdata properly"
6133 (( $MDS1_VERSION >= $(version_code 2.15.57.16) )) ||
6134 skip "need MDS version >= 2.15.57.16 for per-device timeouts"
6137 stack_trap "cleanup"
6139 # Prepare fs2, share the mgs of fs
6140 local FSNAME2=fs15246
6141 local fs2mdsdev=$(mdsdevname 1_2)
6142 local fs2ostdev=$(ostdevname 1_2)
6143 local fs2mdsvdev=$(mdsvdevname 1_2)
6144 local fs2ostvdev=$(ostvdevname 1_2)
6146 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --fsname=$FSNAME2 \
6147 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
6148 add fs2ost $(mkfs_opts ost1 $fs2ostdev) --fsname=$FSNAME2 \
6149 --reformat $fs2ostdev $fs2ostvdev || error "add fs2ost failed"
6151 stack_trap "cleanup_fs2"
6153 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
6154 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS || error "start fs2mds failed"
6156 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
6157 $MOUNT_CMD $MGSNID:/$FSNAME2 $MOUNT2 || error "mount $MOUNT2 failed"
6159 echo "========== All mounted lustre fs ===================="
6160 mount | grep 'type lustre'
6161 echo "====================================================="
6163 # Set and check osc/ldlm_enqueue_min
6164 $LCTL set_param osc.${FSNAME}-*.ldlm_enqueue_min=99 ||
6165 error "failed to set per-device adaptive parameters on client"
6166 stack_trap "$LCTL set_param osc.${FSNAME}-*.ldlm_enqueue_min=0"
6168 local ldlm_enqueue_min
6169 ldlm_enqueue_min=$($LCTL get_param -n osc.${FSNAME}-*.ldlm_enqueue_min \
6171 (( $ldlm_enqueue_min == 99 )) ||
6172 error "wrong ldlm_enqueue_min value for osc.${FSNAME}-*"
6174 # Check fs2 as reference
6175 ldlm_enqueue_min=$($LCTL get_param -n osc.${FSNAME2}-*.ldlm_enqueue_min\
6177 (( $ldlm_enqueue_min == 0 )) ||
6178 error "wrong ldlm_enqueue_min value for osc.${FSNAME2}-*"
6180 # Set and check obdfilter/at_min
6181 do_facet ost1 $LCTL set_param obdfilter.${FSNAME}-*.at_min=1 ||
6182 error "failed to set per-device adaptive parameters on ost"
6183 stack_trap "do_facet ost1 $LCTL set_param obdfilter.${FSNAME}-*.at_min=0"
6186 at_min=$(do_facet ost1 $LCTL get_param -n obdfilter.${FSNAME}-*.at_min \
6188 (( $at_min == 1 )) ||
6189 error "wrong at_min value for obdfilter.${FSNAME}-*"
6191 # set and check mdc/at_max
6192 $LCTL set_param mdc.${FSNAME}-*.at_max=599 ||
6193 error "failed to set per-device adaptive parameters on client"
6194 stack_trap "$LCTL set_param mdc.${FSNAME}-*.at_max=0"
6197 at_max=$($LCTL get_param -n mdc.${FSNAME}-*.at_max | uniq)
6198 (( $at_max == 599 )) ||
6199 error "wrong at_max value for osc.${FSNAME}-*"
6201 # Check fs2 as reference
6202 at_max=$($LCTL get_param -n mdc.${FSNAME2}-*.at_max | uniq)
6203 (( $at_max == 0 )) ||
6204 error "wrong at_max value for osc.${FSNAME2}-*"
6206 # Set and check mds/at_max
6207 do_facet mds1 $LCTL set_param *.${FSNAME}-*.at_max=599 ||
6208 error "failed to set per-device adaptive parameters on mds"
6209 stack_trap "do_facet mds1 $LCTL set_param *.${FSNAME}-*.at_max=0"
6212 at_max=$(do_facet mds1 $LCTL get_param -n mdt.${FSNAME}-*.at_max | uniq)
6213 (( at_max == 599 )) ||
6214 error "wrong at_max value for mdt.${FSNAME}-*"
6216 # Set and check mgs&mgc/at_history
6217 local mgs_nid=$(do_facet $SINGLEMDS $LCTL list_nids | tail -1)
6218 $LCTL set_param mgc.MGC$mgs_nid.at_history=588
6219 stack_trap "$LCTL set_param mgc.MGC$mgs_nid.at_history=0"
6222 at_history=$($LCTL get_param -n mgc.MGC$mgs_nid.at_history)
6223 (( $at_history == 588 )) ||
6224 error "wrong at_history value for mgc.MGC$mgs_nid"
6226 do_facet mgs $LCTL set_param mgs.MGS.at_history=588
6227 stack_trap "do_facet mgs $LCTL set_param mgs.MGS.at_history=0"
6228 at_history=$(do_facet mgs $LCTL get_param -n mgs.MGS.at_history)
6229 (( $at_history == 588 )) ||
6230 error "wrong at_history value for mgs.MGS"
6232 run_test 74 "Test per-device adaptive timeout parameters"
6234 test_75() { # LU-2374
6235 [[ "$MDS1_VERSION" -lt $(version_code 2.4.1) ]] &&
6236 skip "Need MDS version at least 2.4.1"
6239 local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
6240 --replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
6241 local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
6242 --replace --reformat $(ostdevname 1) $(ostvdevname 1)"
6245 #check with default parameters
6246 add mds1 $opts_mds || error "add mds1 failed for default params"
6247 add ost1 $opts_ost || error "add ost1 failed for default params"
6249 opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
6250 opts_mds=$(echo $opts_mds |
6251 sed -e "s/--index=$index/--index=$index --mdt/")
6252 opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
6253 opts_ost=$(echo $opts_ost |
6254 sed -e "s/--index=$index/--index=$index --ost/")
6256 add mds1 $opts_mds || error "add mds1 failed for new params"
6257 add ost1 $opts_ost || error "add ost1 failed for new params"
6262 run_test 75 "The order of --index should be irrelevant"
6265 [[ "$MGS_VERSION" -ge $(version_code 2.4.52) ]] ||
6266 skip "Need MDS version at least 2.4.52"
6269 local MDMB_PARAM="osc.*.max_dirty_mb"
6270 echo "Change MGS params"
6271 local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
6273 echo "max_dirty_mb: $MAX_DIRTY_MB"
6274 local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB - 10))
6275 echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
6276 do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
6277 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
6278 head -1" $NEW_MAX_DIRTY_MB
6279 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
6280 echo "$MAX_DIRTY_MB"
6281 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
6282 error "error while apply max_dirty_mb"
6284 echo "Check the value is stored after remount"
6287 wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
6288 head -1" $NEW_MAX_DIRTY_MB
6289 MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
6290 [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
6291 error "max_dirty_mb is not saved after remount"
6293 echo "Change OST params"
6294 CLIENT_PARAM="obdfilter.*.client_cache_count"
6295 local CLIENT_CACHE_COUNT
6296 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
6298 echo "client_cache_count: $CLIENT_CACHE_COUNT"
6299 NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
6300 echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
6301 do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
6302 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
6303 head -1" $NEW_CLIENT_CACHE_COUNT
6304 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
6306 echo "$CLIENT_CACHE_COUNT"
6307 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
6308 error "error while apply client_cache_count"
6310 echo "Check the value is stored after remount"
6313 wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
6314 head -1" $NEW_CLIENT_CACHE_COUNT
6315 CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
6317 echo "$CLIENT_CACHE_COUNT"
6318 [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
6319 error "client_cache_count is not saved after remount"
6322 run_test 76a "set permanent params with lctl across mounts"
6324 test_76b() { # LU-4783
6325 [[ "$MGS_VERSION" -ge $(version_code 2.5.57) ]] ||
6326 skip "Need MGS version at least 2.5.57"
6329 do_facet mgs $LCTL get_param mgs.MGS.live.params ||
6330 error "start params log failed"
6333 run_test 76b "verify params log setup correctly"
6336 [[ "$MGS_VERSION" -ge $(version_code 2.8.54) ]] ||
6337 skip "Need MDS version at least 2.4.52"
6339 local MASK_PARAM="mdd.*.changelog_mask"
6340 echo "Change changelog_mask"
6341 do_facet mgs $LCTL set_param -P $MASK_PARAM=-CLOSE ||
6342 error "Can't change changlog_mask"
6343 wait_update $(facet_host mds) "$LCTL get_param -n $MASK_PARAM |
6346 echo "Check the value is stored after mds remount"
6347 stop_mds || error "Failed to stop MDS"
6348 start_mds || error "Failed to start MDS"
6349 local CHANGELOG_MASK=$(do_facet mgs $LCTL get_param -n $MASK_PARAM)
6350 echo $CHANGELOG_MASK | grep CLOSE > /dev/null &&
6351 error "changelog_mask is not changed"
6355 run_test 76c "verify changelog_mask is applied with lctl set_param -P"
6357 test_76d() { #LU-9399
6360 local xattr_cache="llite.*.xattr_cache"
6361 local cmd="$LCTL get_param -n $xattr_cache | head -1"
6362 local new=$((($(eval $cmd) + 1) % 2))
6364 echo "lctl set_param -P llite.*.xattr_cache=$new"
6365 do_facet mgs $LCTL set_param -P $xattr_cache=$new ||
6366 error "Can't change xattr_cache"
6367 wait_update $HOSTNAME "$cmd" "$new"
6369 echo "Check $xattr_cache on client $MOUNT"
6370 umount_client $MOUNT || error "umount $MOUNT failed"
6371 mount_client $MOUNT || error "mount $MOUNT failed"
6372 [ $(eval $cmd) -eq $new ] ||
6373 error "$xattr_cache != $new on client $MOUNT"
6375 echo "Check $xattr_cache on the new client $MOUNT2"
6376 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
6377 [ $(eval $cmd) -eq $new ] ||
6378 error "$xattr_cache != $new on client $MOUNT2"
6379 umount_client $MOUNT2 || error "umount $MOUNT2 failed"
6383 run_test 76d "verify llite.*.xattr_cache can be set by 'lctl set_param -P' correctly"
6385 test_77() { # LU-3445
6386 [[ "$MDS1_VERSION" -ge $(version_code 2.8.55) ]] ||
6387 skip "Need MDS version 2.8.55+ "
6389 if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
6390 is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
6391 skip_env "mixed loopback and real device not working"
6394 local fs2mdsdev=$(mdsdevname 1_2)
6395 local fs2ostdev=$(ostdevname 1_2)
6396 local fs2mdsvdev=$(mdsvdevname 1_2)
6397 local fs2ostvdev=$(ostvdevname 1_2)
6398 local fsname=test1234
6400 local failnid="$(h2nettype 1.2.3.4),$(h2nettype 4.3.2.1)"
6402 combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
6404 add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
6405 --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
6406 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
6407 error "start fs2mds failed"
6409 mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
6410 mgsnid="0.0.0.0@tcp,$mgsnid,$mgsnid:$mgsnid"
6412 add fs2ost --mgsnode=$mgsnid $(mkfs_opts ost1 $fs2ostdev) \
6413 --failnode=$failnid --fsname=$fsname \
6414 --reformat $fs2ostdev $fs2ostvdev ||
6415 error "add fs2ost failed"
6416 start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
6418 mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
6419 $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
6420 DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
6423 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
6426 [[ "$mds1_FSTYPE" != ldiskfs ||
6427 "$ost1_FSTYPE" != ldiskfs ]] &&
6428 skip "ldiskfs only test"
6430 # reformat the Lustre filesystem with a smaller size
6431 local saved_MDSCOUNT=$MDSCOUNT
6432 local saved_MDSSIZE=$MDSSIZE
6433 local saved_OSTCOUNT=$OSTCOUNT
6434 local saved_OSTSIZE=$OSTSIZE
6437 MDSSIZE=$((MDSSIZE - 20000))
6438 OSTSIZE=$((OSTSIZE - 20000))
6439 reformat || error "(1) reformat Lustre filesystem failed"
6440 MDSSIZE=$saved_MDSSIZE
6441 OSTSIZE=$saved_OSTSIZE
6443 # mount the Lustre filesystem
6444 setup_noconfig || error "(2) setup Lustre filesystem failed"
6447 log "create test files"
6452 mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
6454 for i in $(seq $num_files); do
6455 file=$MOUNT/$tdir/$tfile-$i
6456 dd if=/dev/urandom of=$file count=1 bs=1M || {
6457 $LCTL get_param osc.*.cur*grant*
6458 $LFS df; $LFS df -i;
6459 # stop creating files if there is no more space
6460 if [ ! -e $file ]; then
6461 num_files=$((i - 1))
6465 $LFS getstripe -v $file
6466 local ost_idx=$(LFS getstripe -i $file)
6467 do_facet ost$((ost_idx + 1)) \
6468 $LCTL get_param obdfilter.*.*grant*
6469 error "(4) create $file failed"
6473 # unmount the Lustre filesystem
6474 cleanup || error "(5) cleanup Lustre filesystem failed"
6476 # run e2fsck on the MDT and OST devices
6477 local mds_host=$(facet_active_host $SINGLEMDS)
6478 local ost_host=$(facet_active_host ost1)
6479 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
6480 local ost_dev=$(ostdevname 1)
6482 run_e2fsck $mds_host $mds_dev "-y"
6483 run_e2fsck $ost_host $ost_dev "-y"
6485 # get the original block count of the MDT and OST filesystems
6486 local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
6487 local ost_orig_blks=$(get_block_count ost1 $ost_dev)
6489 # expand the MDT and OST filesystems to the device size
6490 run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
6491 run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
6493 # run e2fsck on the MDT and OST devices again
6494 run_e2fsck $mds_host $mds_dev "-y"
6495 run_e2fsck $ost_host $ost_dev "-y"
6497 # mount the Lustre filesystem
6501 log "check files after expanding the MDT and OST filesystems"
6502 for i in $(seq $num_files); do
6503 file=$MOUNT/$tdir/$tfile-$i
6504 $CHECKSTAT -t file -s 1048576 $file ||
6505 error "(6) checkstat $file failed"
6509 log "create more files after expanding the MDT and OST filesystems"
6510 for i in $(seq $((num_files + 1)) $((num_files + 10))); do
6511 file=$MOUNT/$tdir/$tfile-$i
6512 dd if=/dev/urandom of=$file count=1 bs=1M ||
6513 error "(7) create $file failed"
6516 # unmount the Lustre filesystem
6517 cleanup || error "(8) cleanup Lustre filesystem failed"
6519 # run e2fsck on the MDT and OST devices
6520 run_e2fsck $mds_host $mds_dev "-y"
6521 run_e2fsck $ost_host $ost_dev "-y"
6523 # get the maximum block count of the MDT and OST filesystems
6524 local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
6525 local ost_max_blks=$(get_block_count ost1 $ost_dev)
6527 # get the minimum block count of the MDT and OST filesystems
6528 local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
6529 grep minimum | sed -e 's/^.*filesystem: //g')
6530 local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
6531 grep minimum | sed -e 's/^.*filesystem: //g')
6533 # shrink the MDT and OST filesystems to a smaller size
6537 if [[ $mds_max_blks -gt $mds_min_blks &&
6538 $mds_max_blks -gt $mds_orig_blks ]]; then
6539 [[ $mds_orig_blks -gt $mds_min_blks ]] &&
6540 base_blks=$mds_orig_blks || base_blks=$mds_min_blks
6541 new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
6542 run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
6543 error "shrink $SINGLEMDS to $new_blks failed"
6547 if [[ $ost_max_blks -gt $ost_min_blks &&
6548 $ost_max_blks -gt $ost_orig_blks ]]; then
6549 [[ $ost_orig_blks -gt $ost_min_blks ]] &&
6550 base_blks=$ost_orig_blks || base_blks=$ost_min_blks
6551 new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
6552 run_resize2fs ost1 $ost_dev $new_blks ||
6553 error "shrink ost1 to $new_blks failed"
6557 # check whether the MDT or OST filesystem was shrunk or not
6559 combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
6560 reformat_and_config ||
6561 error "(10) reformat Lustre filesystem failed"
6565 # run e2fsck on the MDT and OST devices again
6566 run_e2fsck $mds_host $mds_dev "-y"
6567 run_e2fsck $ost_host $ost_dev "-y"
6569 # mount the Lustre filesystem again
6573 log "check files after shrinking the MDT and OST filesystems"
6574 for i in $(seq $((num_files + 10))); do
6575 file=$MOUNT/$tdir/$tfile-$i
6576 $CHECKSTAT -t file -s 1048576 $file ||
6577 error "(11) checkstat $file failed"
6580 # unmount and reformat the Lustre filesystem
6581 cleanup || error "(12) cleanup Lustre filesystem failed"
6582 combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
6584 MDSCOUNT=$saved_MDSCOUNT
6585 OSTCOUNT=$saved_OSTCOUNT
6586 reformat_and_config || error "(14) reformat Lustre filesystem failed"
6588 run_test 78 "run resize2fs on MDT and OST filesystems"
6590 test_79() { # LU-4227
6591 [[ "$MDS1_VERSION" -ge $(version_code 2.5.59) ]] ||
6592 skip "Need MDS version at least 2.5.59"
6594 local mdsdev1=$(mdsdevname 1)
6595 local mdsvdev1=$(mdsvdevname 1)
6596 local mdsdev2=$(mdsdevname 2)
6597 local mdsvdev2=$(mdsvdevname 2)
6598 local ostdev1=$(ostdevname 1)
6599 local ostvdev1=$(ostvdevname 1)
6600 local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
6601 local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
6602 local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
6605 # remove --mgs/--mgsnode from mkfs.lustre options
6606 opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
6608 mgsnode_opt=$(echo $opts_mds2 |
6609 awk '{ for ( i = 1; i < NF; i++ )
6610 if ( $i ~ "--mgsnode" ) { print $i; break } }')
6611 [ -n "$mgsnode_opt" ] &&
6612 opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
6614 mgsnode_opt=$(echo $opts_ost1 |
6615 awk '{ for ( i = 1; i < NF; i++ )
6616 if ( $i ~ "--mgsnode" ) { print $i; break } }')
6617 [ -n "$mgsnode_opt" ] &&
6618 opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
6620 # -MGS, format a mdt without --mgs option
6621 add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
6622 error "Must specify --mgs when formatting mdt combined with mgs"
6624 # +MGS, format a mdt/ost without --mgsnode option
6625 add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
6626 > /dev/null || error "start mds1 failed"
6627 add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
6628 error "Must specify --mgsnode when formatting a mdt"
6629 add ost1 $opts_ost1 $ostdev1 $ostvdev1 &&
6630 error "Must specify --mgsnode when formatting an ost"
6634 run_test 79 "format MDT/OST without mgs option (should return errors)"
6637 start_mds || error "Failed to start MDT"
6638 start_ost || error "Failed to start OST1"
6639 uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
6640 #define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
6641 do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
6642 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
6643 do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
6645 start_ost2 || error "Failed to start OST2"
6647 do_facet ost1 "$LCTL set_param fail_loc=0"
6652 run_test 80 "mgc import reconnect race"
6654 #Save the original values of $OSTCOUNT and $OSTINDEX$i.
6656 local new_ostcount=$1
6657 saved_ostcount=$OSTCOUNT
6658 OSTCOUNT=$new_ostcount
6662 for ((i = 1; i <= $OSTCOUNT; i++ )); do
6664 eval saved_ostindex$i=${!index}
6669 # Restore the original values of $OSTCOUNT and $OSTINDEX$i.
6670 restore_ostindex() {
6674 echo "restoring OSTCOUNT=$saved_ostcount and OSTINDEXn"
6676 for ((i = 1; i <= $OSTCOUNT; i++ )); do
6677 index=saved_ostindex$i
6678 eval OSTINDEX$i=${!index}
6680 OSTCOUNT=$saved_ostcount
6683 if ! combined_mgs_mds ; then
6688 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
6689 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
6690 # assigned index and ensures we can mount such a formatted file system
6691 test_81() { # LU-4665
6692 (( MDS1_VERSION >= $(version_code 2.6.54) )) ||
6693 skip "Need MDS version at least 2.6.54"
6694 (( OSTCOUNT >= 3 )) || skip_env "needs >= 3 OSTs"
6698 # Each time RANDOM is referenced, a random integer between 0 and 32767
6701 local saved_ostindex1=$OSTINDEX1
6702 for i in 65535 $((RANDOM + 65536)); do
6703 echo -e "\nFormat ost1 with --index=$i, should fail"
6705 if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
6706 $(ostdevname 1) $(ostvdevname 1); then
6707 OSTINDEX1=$saved_ostindex1
6708 error "format ost1 with --index=$i should fail"
6711 OSTINDEX1=$saved_ostindex1
6714 stack_trap restore_ostindex
6716 # Format OSTs with random sparse indices.
6717 local rand_ost=$(((RANDOM * 2 % 65533) + 1))
6718 echo "Format $OSTCOUNT OSTs with OST_INDEX_LIST=[0,$rand_ost,65534]"
6719 OST_INDEX_LIST=[0,$rand_ost,65534] formatall ||
6720 error "formatall failed with $?"
6722 # Setup and check Lustre filesystem.
6723 start_mgsmds || error "start_mgsmds failed"
6724 for ((i = 1; i <= $OSTCOUNT; i++ )); do
6725 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
6726 error "start ost$i failed"
6729 mount_client $MOUNT || error "mount client $MOUNT failed"
6730 check_mount || error "check client $MOUNT failed"
6734 local max_easize=$($LCTL get_param -n llite.*.max_easize)
6735 local xattr_size_max=$((4096 - 84)) # 4096 less ldiskfs ea overhead
6737 # XATTR_SIZE_MAX less ldiskfs ea overhead
6738 large_xattr_enabled && xattr_size_max=$((65536 - 84))
6739 (( max_easize >= xattr_size_max )) ||
6740 error "max_easize $max_easize < $xattr_size_max bytes"
6742 test_mkdir $DIR/$tdir
6743 $LFS setstripe -i $rand_ost $DIR/$tdir/$tfile ||
6744 error "error creating $tfile on ost$rand_ost"
6745 $LFS getstripe $DIR/$tdir/$tfile
6752 cmd="getstripe -i $DIR/$tdir/$tfile"
6755 (( $found == $rand_ost )) || error "index $found is not $rand_ost"
6757 cmd="find $DIR/$tdir -i $rand_ost"
6761 [[ "$found" == "$DIR/$tdir/$tfile" ]] ||
6762 error "'lfs find' returned '$found', not '$tfile' by index"
6765 uuid=$(ostuuid_from_index $rand_ost)
6767 cmd="find $DIR/$tdir -O $uuid"
6772 [[ "$found" == "$DIR/$tdir/$tfile" ]] ||
6773 error "'lfs find' returned '$found', not '$tfile' by UUID"
6775 run_test 81 "sparse OST indexing"
6777 # Here we exercise the stripe placement functionality on a file system that
6778 # has formatted the OST with a random index. With the file system the following
6779 # functionality is tested:
6781 # 1. Creating a new file with a specific stripe layout.
6783 # 2. Modifiy a existing empty file with a specific stripe layout.
6785 # 3. Ensure we fail to set the stripe layout of a file that already has one.
6787 # 4. If ost-index is defined we need to ensure it is the first entry in the
6788 # ost index list returned by lfs getstripe.
6790 # 5. Lastly ensure this functionality fails with directories.
6791 test_82a() { # LU-4665
6792 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
6793 skip "Need MDS version at least 2.6.54"
6794 [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
6800 # Format OSTs with random sparse indices.
6804 local LOV_V1_INSANE_STRIPE_COUNT=65532
6805 for i in $(seq $OSTCOUNT); do
6806 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
6807 ost_indices+=" $index"
6809 ost_indices=$(comma_list $ost_indices)
6811 stack_trap "restore_ostindex" EXIT
6812 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
6813 OST_INDEX_LIST=[$ost_indices] formatall
6815 # Setup Lustre filesystem.
6816 start_mgsmds || error "start_mgsmds failed"
6817 for i in $(seq $OSTCOUNT); do
6818 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
6819 error "start ost$i failed"
6822 # Collect debug information - start of test
6823 do_nodes $(comma_list $(mdts_nodes)) \
6824 $LCTL get_param osp.*.prealloc_*_id
6826 mount_client $MOUNT || error "mount client $MOUNT failed"
6830 check_lfs_df_ret_val $? || error "$LFS df $MOUNT failed"
6831 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6833 stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
6834 $LCTL get_param osp.*.prealloc_*_id || true" EXIT
6836 # 1. If the file does not exist, new file will be created
6837 # with specified OSTs.
6838 local file=$DIR/$tdir/$tfile-1
6839 local cmd="$LFS setstripe -o $ost_indices $file"
6841 eval $cmd || error "$cmd failed"
6842 check_stripe_count $file $OSTCOUNT
6843 check_obdidx $file $ost_indices
6844 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6845 error "write $file failed"
6847 # 2. If the file already exists and is an empty file, the file
6848 # will be attached with specified layout.
6849 file=$DIR/$tdir/$tfile-2
6850 mcreate $file || error "mcreate $file failed"
6851 cmd="$LFS setstripe -o $ost_indices $file"
6853 eval $cmd || error "$cmd failed"
6854 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6855 error "write $file failed"
6856 check_stripe_count $file $OSTCOUNT
6857 check_obdidx $file $ost_indices
6859 # 3. If the file already has a valid layout attached, the command
6860 # should fail with EBUSY.
6862 eval $cmd && error "stripe is already set on $file, $cmd should fail"
6864 # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
6865 # be in the OST indices list.
6866 local start_ost_idx=${ost_indices##*,}
6867 file=$DIR/$tdir/$tfile-3
6868 cmd="$LFS setstripe -o $ost_indices -i $start_ost_idx $file"
6870 eval $cmd || error "$cmd failed"
6871 check_stripe_count $file $OSTCOUNT
6872 check_obdidx $file $ost_indices
6873 check_start_ost_idx $file $start_ost_idx
6875 file=$DIR/$tdir/$tfile-4
6876 cmd="$LFS setstripe"
6877 cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
6878 cmd+=" -i $start_ost_idx $file"
6880 eval $cmd && error "index $start_ost_idx should be in $ost_indices"
6882 # 5. Specifying OST indices for directory should succeed.
6883 local dir=$DIR/$tdir/$tdir
6884 mkdir $dir || error "mkdir $dir failed"
6885 cmd="$LFS setstripe -o $ost_indices $dir"
6886 if [ "$MDS1_VERSION" -gt $(version_code 2.11.53) ] &&
6887 [ "$CLIENT_VERSION" -gt $(version_code 2.11.53) ]; then
6889 eval $cmd || error "unable to specify OST indices on directory"
6891 echo "need MDS+client version at least 2.11.53"
6894 run_test 82a "specify OSTs for file (succeed) or directory (succeed)"
6896 # Test 82b is run to ensure that if the user supplies a pool with a specific
6897 # stripe layout that it behaves proprerly. It should fail in the case that
6898 # the supplied OST index list points to OSTs not contained in the user
6900 test_82b() { # LU-4665
6901 [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
6902 skip "Need MDS version at least 2.6.54"
6903 [[ $OSTCOUNT -ge 4 ]] || skip_env "needs >= 4 OSTs"
6909 # Format OSTs with random sparse indices.
6913 local LOV_V1_INSANE_STRIPE_COUNT=65532
6914 for i in $(seq $OSTCOUNT); do
6915 index=$(((RANDOM * 2) % LOV_V1_INSANE_STRIPE_COUNT))
6916 ost_indices+=" $index"
6918 ost_indices=$(comma_list $ost_indices)
6920 stack_trap "restore_ostindex" EXIT
6921 echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
6922 OST_INDEX_LIST=[$ost_indices] formatall
6924 # Setup Lustre filesystem.
6925 start_mgsmds || error "start_mgsmds failed"
6926 for i in $(seq $OSTCOUNT); do
6927 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
6928 error "start ost$i failed"
6931 mount_client $MOUNT || error "mount client $MOUNT failed"
6935 check_lfs_df_ret_val $? || error "$LFS df $MOUNT failed"
6936 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
6938 # Create a new pool and add OSTs into it.
6939 local ost_pool=$FSNAME.$TESTNAME
6940 create_pool $ost_pool || error "create OST pool $ost_pool failed"
6942 local ost_idx_in_list=${ost_indices##*,}
6943 local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
6946 local ost_targets="$FSNAME-OST["
6947 for i in ${ost_idx_in_pool//,/ }; do
6948 ost_targets=$ost_targets$(printf "%04x," $i)
6950 ost_targets="${ost_targets%,}]"
6952 local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
6953 do printf "$FSNAME-OST%04x_UUID\n" $i; done |
6954 sort -u | tr '\n' ' ')
6956 local cmd="$LCTL pool_add $ost_pool $ost_targets"
6957 do_facet mgs $cmd || error "$cmd failed"
6958 wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
6959 sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
6960 error "wait_update $ost_pool failed"
6961 wait_update_facet $SINGLEMDS "$LCTL pool_list $ost_pool | wc -l" 4 ||
6962 error "wait_update pool_list $ost_pool failed"
6964 # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
6965 # then the OSTs must be the members of the pool.
6966 local file=$DIR/$tdir/$tfile
6967 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6969 eval $cmd && error "OST with index $ost_idx_in_list should be" \
6970 "in OST pool $ost_pool"
6972 # Only select OST $ost_idx_in_list from $ost_pool for file.
6973 ost_idx_in_list=${ost_idx_in_pool#*,}
6974 cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
6976 eval $cmd || error "$cmd failed"
6977 cmd="$LFS getstripe $file"
6979 eval $cmd || error "$cmd failed"
6980 check_stripe_count $file 2
6981 check_obdidx $file $ost_idx_in_list
6982 dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
6983 error "write $file failed"
6985 run_test 82b "specify OSTs for file with --pool and --ost-list options"
6988 [[ "$OST1_VERSION" -ge $(version_code 2.6.91) ]] ||
6989 skip "Need OST version at least 2.6.91"
6990 if [ "$ost1_FSTYPE" != ldiskfs ]; then
6991 skip "ldiskfs only test"
7000 ostmnt=$(facet_mntpt ost1)
7002 # Mount the OST as an ldiskfs filesystem.
7003 log "mount the OST $dev as a $ost1_FSTYPE filesystem"
7004 add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
7005 --reformat $dev > /dev/null ||
7006 error "format ost1 error"
7008 if ! test -b $dev; then
7009 mnt_opts=$(csa_add "$OST_MOUNT_FS_OPTS" -o loop)
7011 echo "mnt_opts $mnt_opts"
7012 do_facet ost1 mount -t "$ost1_FSTYPE" $dev \
7014 # Run llverfs on the mounted ldiskfs filesystem.
7015 # It is needed to get ENOSPACE.
7016 log "run llverfs in partial mode on the OST $ost1_FSTYPE $ostmnt"
7017 do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
7018 "no" || error "run_llverfs error on $ost1_FSTYPE"
7021 log "unmount the OST $dev"
7024 # Delete file IO_scrub. Later osd_scrub_setup will try to
7025 # create "IO_scrub" but will get ENOSPACE.
7027 echo "start ost1 service on `facet_active_host ost1`"
7028 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
7031 err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
7032 echo "string err $err"
7033 [ -z "$err" ] || error $err
7036 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
7037 Busy inodes after unmount ..."
7040 local facet=$SINGLEMDS
7041 local num=$(echo $facet | tr -d "mds")
7042 local dev=$(mdsdevname $num)
7043 local time_min=$(recovery_time_min)
7044 local recovery_duration
7045 local completed_clients
7046 local correct_clients
7049 echo "start mds service on $(facet_active_host $facet)"
7050 start_mds "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" ||
7051 error "start MDS failed"
7053 start_ost || error "start OST0000 failed"
7054 wait_osc_import_state mds ost1 FULL
7055 start_ost2 || error "start OST0001 failed"
7056 wait_osc_import_state mds ost2 FULL
7058 echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
7060 mount_client $MOUNT1 || error "mount $MOUNT1 failed"
7061 mount_client $MOUNT2 || error "mount $MOUNT2 failed"
7062 # make sure new superblock labels are sync'd before disabling writes
7066 replay_barrier $SINGLEMDS
7067 createmany -o $DIR1/$tfile-%d 1000
7069 # We need to catch the end of recovery window to extend it.
7070 # Skip 5 requests and add delay to request handling.
7071 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
7072 do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
7074 facet_failover --fsck $SINGLEMDS || error "failover: $?"
7077 echo "recovery status"
7078 do_facet $SINGLEMDS \
7079 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
7081 recovery_duration=$(do_facet $SINGLEMDS \
7082 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
7083 awk '/recovery_duration/ { print $2 }')
7084 (( $recovery_duration > $time_min + $wrap_up )) &&
7085 error "recovery_duration > recovery_time_hard + wrap up"
7086 completed_clients=$(do_facet $SINGLEMDS \
7087 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
7088 awk '/completed_clients/ { print $2 }')
7090 correct_clients="$MDSCOUNT/$((MDSCOUNT+1))"
7091 [ "$completed_clients" = "${correct_clients}" ] ||
7092 error "$completed_clients != $correct_clients"
7094 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
7095 umount_client $MOUNT1
7096 umount_client $MOUNT2
7102 run_test 84 "check recovery_hard_time"
7105 [[ "$OST1_VERSION" -ge $(version_code 2.7.55) ]] ||
7106 skip "Need OST version at least 2.7.55"
7107 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
7108 do_facet ost1 "lctl set_param fail_loc=0x197"
7112 run_test 85 "osd_ost init: fail ea_fid_set"
7117 # ost1 has already registered to the MGS before the reformat.
7118 # So after reformatting it with option "-G", it could not be
7119 # mounted to the MGS. Cleanup the system for subsequent tests.
7124 [ "$ost1_FSTYPE" = zfs ] &&
7125 skip "LU-6442: no such mkfs params for ZFS OSTs"
7126 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
7127 skip "Need server version newer than 2.7.55"
7130 local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
7131 awk '/Flex block group size: / { print $NF; exit; }')
7133 [ "$OLDSIZE" == "$NEWSIZE" ] && skip "$NEWSIZE groups already"
7135 local opts=" -O flex_bg -G $NEWSIZE"
7136 opts=$(OST_FS_MKFS_OPTS+="$opts" mkfs_opts ost1 $(ostdevname 1))
7137 opts+=" --reformat $(ostdevname 1) $(ostvdevname 1)"
7138 echo "params: $opts"
7140 trap cleanup_86 EXIT ERR
7143 add ost1 $opts || error "add ost1 failed with new params"
7145 local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
7146 awk '/Flex block group size: / { print $NF; exit; }')
7148 [[ $FOUNDSIZE == $NEWSIZE ]] ||
7149 error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE"
7153 run_test 86 "Replacing mkfs.lustre -G option"
7155 test_87() { #LU-6544
7156 [[ "$MDS1_VERSION" -ge $(version_code 2.9.51) ]] ||
7157 skip "Need MDS version at least 2.9.51"
7158 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
7159 skip "ldiskfs only test"
7160 [[ $OSTCOUNT -gt 59 ]] &&
7161 skip "Ignore wide striping situation"
7162 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
7164 local mdsdev=$(mdsdevname 1)
7165 local mdsvdev=$(mdsvdevname 1)
7166 local file=$DIR/$tfile
7167 local mntpt=$(facet_mntpt $SINGLEMDS)
7168 local used_xattr_blk=0
7169 local inode_size=${1:-1024}
7171 local xtest="trusted.test"
7175 local stripe_cnt=$(($OSTCOUNT + 2))
7177 #Please see ldiskfs_make_lustre() for MDT inode size calculation
7178 if [ $stripe_cnt -gt 16 ]; then
7181 left_size=$(expr $inode_size - \
7184 32 - 40 \* 3 - 32 \* 3 - $stripe_cnt \* 24 - 16 - 3 - \
7186 24 - 18 - $(expr length $tfile) - 16 - 4)
7187 if [ $left_size -le 0 ]; then
7188 echo "No space($left_size) is expected in inode."
7189 echo "Try 1-byte xattr instead to verify this."
7192 echo "Estimate: at most $left_size-byte space left in inode."
7198 if ! combined_mgs_mds ; then
7202 add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$stripe_cnt \
7203 --reformat $mdsdev $mdsvdev || error "add mds1 failed"
7204 start_mdt 1 > /dev/null || error "start mdt1 failed"
7205 for i in $(seq $OSTCOUNT); do
7206 start ost$i $(ostdevname $i) $OST_MOUNT_OPTS > /dev/null ||
7207 error "start ost$i failed"
7209 mount_client $MOUNT > /dev/null || error "mount client $MOUNT failed"
7210 check_mount || error "check client $MOUNT failed"
7213 $LFS setstripe -E 1M -S 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
7214 error "Create file with 3 components failed"
7215 $TRUNCATE $file $((1024*1024*64+1)) || error "truncate file failed"
7216 i=$($LFS getstripe -I3 -c $file) || error "get 3rd stripe count failed"
7217 if [ $i -ne $OSTCOUNT ]; then
7218 left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
7219 echo -n "Since only $i out $OSTCOUNT OSTs are used, "
7220 echo -n "the expected left space is changed to "
7221 echo "$left_size bytes at most."
7223 value=$(generate_string $left_size)
7224 setfattr -n $xtest -v $value $file
7225 orig=$(get_xattr_value $xtest $file)
7226 [[ "$orig" != "$value" ]] && error "$xtest changed"
7228 #Verify if inode has some expected space left
7229 umount $MOUNT > /dev/null || error "umount $MOUNT failed"
7230 stop_mdt 1 > /dev/null || error "stop mdt1 failed"
7231 mount_ldiskfs $SINGLEMDS || error "mount -t ldiskfs $SINGLEMDS failed"
7233 do_facet $SINGLEMDS ls -sal $mntpt/ROOT/$tfile
7234 used_xattr_blk=$(do_facet $SINGLEMDS ls -s $mntpt/ROOT/$tfile |
7236 [[ $used_xattr_blk -eq 0 ]] &&
7237 error "Please check MDS inode size calculation: \
7238 more than $left_size-byte space left in inode."
7239 echo "Verified: at most $left_size-byte space left in inode."
7241 unmount_ldiskfs $SINGLEMDS
7243 for i in $(seq $OSTCOUNT); do
7244 stop ost$i -f || error "stop ost$i failed"
7247 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
7250 [ "$mds1_FSTYPE" == zfs ] &&
7251 skip "LU-6662: no implementation for ZFS"
7255 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
7256 --reformat $(mdsdevname 1) || error "add mds1 failed"
7258 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
7259 grep -e \".*opts:.*errors=remount-ro.*\"" ||
7260 error "default mount options is missing"
7262 add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
7263 --mountfsoptions="user_xattr,errors=panic" \
7264 --reformat $(mdsdevname 1) || error "add mds1 failed"
7266 do_facet mds1 "$TUNEFS $(mdsdevname 1) |
7267 grep -e \".*opts:.*errors=panic.*\"" ||
7268 error "user can't override default mount options"
7270 run_test 88 "check the default mount options can be overridden"
7272 test_89() { # LU-7131
7273 [[ "$MDS1_VERSION" -ge $(version_code 2.9.54) ]] ||
7274 skip "Need MDT version at least 2.9.54"
7276 local key=failover.node
7277 local val1=192.0.2.254@tcp0 # Reserved IPs, see RFC 5735
7278 local val2=192.0.2.255@tcp0
7279 local mdsdev=$(mdsdevname 1)
7284 if [[ "$mds1_FSTYPE" == zfs ]]; then
7285 import_zpool mds1 || return ${PIPESTATUS[0]}
7288 # Check that parameters are added correctly
7289 echo "tunefs --param $key=$val1"
7290 do_facet mds1 "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
7291 error "tunefs --param $key=$val1 failed"
7292 params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
7293 error "tunefs --dryrun failed"
7294 params=${params##*Parameters:}
7295 params=${params%%exiting*}
7296 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val1) = "1" ] ||
7297 error "on-disk parameter not added correctly via tunefs"
7299 # Check that parameters replace existing instances when added
7300 echo "tunefs --param $key=$val2"
7301 do_facet mds1 "$TUNEFS --param $key=$val2 $mdsdev >/dev/null" ||
7302 error "tunefs --param $key=$val2 failed"
7303 params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
7304 error "tunefs --dryrun failed"
7305 params=${params##*Parameters:}
7306 params=${params%%exiting*}
7307 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "1" ] ||
7308 error "on-disk parameter not replaced via tunefs"
7309 [ $(echo $params | tr ' ' '\n' | grep -c $key=$val2) = "1" ] ||
7310 error "on-disk parameter not replaced correctly via tunefs"
7312 # Check that a parameter is erased properly
7313 echo "tunefs --erase-param $key"
7314 do_facet mds1 "$TUNEFS --erase-param $key $mdsdev >/dev/null" ||
7315 error "tunefs --erase-param $key failed"
7316 params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
7317 error "tunefs --dryrun failed"
7318 params=${params##*Parameters:}
7319 params=${params%%exiting*}
7320 [ $(echo $params | tr ' ' '\n' | grep -c $key=) = "0" ] ||
7321 error "on-disk parameter not erased correctly via tunefs"
7323 # Check that all the parameters are erased
7324 do_facet mds1 "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
7325 error "tunefs --param $key=$val1 failed"
7326 echo "tunefs --erase-params"
7327 do_facet mds1 "$TUNEFS --erase-params $mdsdev >/dev/null" ||
7328 error "tunefs --erase-params failed"
7329 params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
7330 error "tunefs --dryrun failed"
7331 params=${params##*Parameters:}
7332 params=${params%%exiting*}
7333 params=$(echo $params | tr ' ' '\n')
7335 error "all on-disk parameters not erased correctly via tunefs $params"
7337 # Check the order of options --erase-params and --param
7338 echo "tunefs --param $key=$val1 --erase-params"
7340 "$TUNEFS --param $key=$val1 --erase-params $mdsdev >/dev/null"||
7341 error "tunefs --param $key=$val1 --erase-params failed"
7342 params=$(do_facet mds1 $TUNEFS --dryrun $mdsdev) ||
7343 error "tunefs --dryrun failed"
7344 params=${params##*Parameters:}
7345 params=${params%%exiting*}
7346 [ $(echo $params | tr ' ' '\n') == "$key=$val1" ] ||
7347 error "on-disk param not added correctly with --erase-params"
7351 run_test 89 "check tunefs --param and --erase-param{s} options"
7354 # $2 (optional) value of max_mod_rpcs_in_flight to set
7355 check_max_mod_rpcs_in_flight() {
7363 idx=$(printf "%04x" $($LFS getdirstripe -i $dir))
7364 facet="mds$((0x$idx + 1))"
7366 if [ -z "$mmr" ]; then
7367 # get value of max_mod_rcps_in_flight
7368 mmr=$($LCTL get_param -n \
7369 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight) ||
7370 error "Unable to get max_mod_rpcs_in_flight"
7371 echo "max_mod_rcps_in_flight is $mmr"
7373 # set value of max_mod_rpcs_in_flight
7375 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight=$mmr ||
7376 error "Unable to set max_mod_rpcs_in_flight to $mmr"
7377 echo "max_mod_rpcs_in_flight set to $mmr"
7380 # create mmr+1 files
7381 echo "creating $((mmr + 1)) files ..."
7383 for i in $(seq $((mmr + 1))); do
7389 # consumes mmr-1 modify RPC slots
7390 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
7391 # drop requests on MDT so that RPC slots are consumed
7392 # during all the request resend interval
7393 do_facet $facet "$LCTL set_param fail_loc=0x159"
7394 echo "launch $((mmr - 1)) chmod in parallel ..."
7395 for i in $(seq $((mmr - 1))); do
7396 chmod 0600 $dir/file-$i &
7400 # send one additional modify RPC
7401 do_facet $facet "$LCTL set_param fail_loc=0"
7402 echo "launch 1 additional chmod in parallel ..."
7403 chmod 0600 $dir/file-$mmr &
7406 # check this additional modify RPC get a modify RPC slot
7407 # and succeed its operation
7408 checkstat -vp 0600 $dir/file-$mmr ||
7409 error "Unable to send $mmr modify RPCs in parallel"
7414 # consumes mmr modify RPC slots
7415 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
7416 # drop requests on MDT so that RPC slots are consumed
7417 # during all the request resend interval
7418 do_facet $facet "$LCTL set_param fail_loc=0x159"
7419 echo "launch $mmr chmod in parallel ..."
7420 for i in $(seq $mmr); do
7421 chmod 0666 $dir/file-$i &
7425 # send one additional modify RPC
7426 do_facet $facet "$LCTL set_param fail_loc=0"
7427 echo "launch 1 additional chmod in parallel ..."
7428 chmod 0666 $dir/file-$((mmr + 1)) &
7431 # check this additional modify RPC blocked getting a modify RPC slot
7432 checkstat -vp 0644 $dir/file-$((mmr + 1)) ||
7433 error "Unexpectedly send $(($mmr + 1)) modify RPCs in parallel"
7437 get_mdt_max_mod_rpcs_in_flight_val() {
7441 # It will be enough to get one value from one MDT
7442 max_mrif=$(do_facet $facet \
7443 "$LCTL get_param -n \
7444 mdt.$FSNAME-MDT*.max_mod_rpcs_in_flight | head -n 1")
7445 if [[ $max_mrif ]]; then
7448 max_mrif=$(do_facet $facet \
7449 cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
7454 set_mdt_max_mod_rpcs_in_flight() {
7459 lctl_op=$($LCTL get_param \
7460 mdt.*.max_mod_rpcs_in_flight)
7461 if [[ $lctl_op ]]; then
7464 mdt.$FSNAME-MDT*.max_mod_rpcs_in_flight=$max_mrif"
7468 /sys/module/mdt/parameters/max_mod_rpcs_per_client"
7469 echo "the deprecated max_mod_rpcs_per_client \
7470 parameter was involved"
7477 [[ $($LCTL get_param mdc.*.import |
7478 grep "connect_flags:.*multi_mod_rpc") ]] ||
7479 skip "Need MDC with 'multi_mod_rpcs' feature"
7481 # check default value
7482 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
7483 check_max_mod_rpcs_in_flight $DIR/$tdir
7487 run_test 90a "check max_mod_rpcs_in_flight is enforced"
7497 [[ $($LCTL get_param mdc.*.import |
7498 grep "connect_flags:.*multi_mod_rpc") ]] ||
7499 skip "Need MDC with 'multi_mod_rpcs' feature"
7502 # update max_mod_rpcs_in_flight
7503 $LFS mkdir -c1 $DIR/${tdir}1 || error "mkdir $DIR/${tdir}1 failed"
7504 check_max_mod_rpcs_in_flight $DIR/${tdir}1 1
7507 # check client is able to send multiple modify RPCs in paralell
7508 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
7509 grep -c "multi_mod_rpcs")
7510 if [ "$tmp" -ne $MDSCOUNT ]; then
7512 skip "Client not able to send multiple modify RPCs in parallel"
7515 # update max_mod_rpcs_in_flight
7516 $LFS mkdir -c1 $DIR/${tdir}2 || error "mkdir $DIR/${tdir}2 failed"
7517 check_max_mod_rpcs_in_flight $DIR/${tdir}2 5
7520 $LFS mkdir -c1 $DIR/${tdir}3 || error "mkdir $DIR/${tdir}3 failed"
7521 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/${tdir}3))
7522 facet="mds$((0x$idx + 1))"
7524 mmrpc=$(get_mdt_max_mod_rpcs_in_flight_val $facet)
7525 echo "mdt_max_mod_rpcs_in_flight is $mmrpc"
7526 # update max_mod_rpcs_in_flight
7527 umount_client $MOUNT
7528 set_mdt_max_mod_rpcs_in_flight 16 $facet
7530 $LCTL set_param mdc.$FSNAME-MDT$idx-mdc-*.max_rpcs_in_flight=17
7531 check_max_mod_rpcs_in_flight $DIR/${tdir}3 16
7533 # restore MDT max_mod_rpcs_in_flight initial value
7534 set_mdt_max_mod_rpcs_in_flight $mmrpc $facet
7536 rm -rf $DIR/${tdir}?
7539 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
7542 # get max_rpcs_in_flight value
7543 mrif_90c=$($LCTL get_param -n \
7544 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
7545 echo "max_rpcs_in_flight is $mrif_90c"
7547 # get MDC max_mod_rpcs_in_flight value
7548 mmrif_90c=$($LCTL get_param -n \
7549 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight)
7550 echo "MDC max_mod_rpcs_in_flight is $mmrif_90c"
7552 # get MDT max_mod_rpcs_in_flight value
7553 mmrpc_90c=$(get_mdt_max_mod_rpcs_in_flight_val "mds1")
7554 echo "mdt_max_mod_rpcs_in_flight is $mmrpc_90c"
7557 restore_params_90c() {
7560 # restore max_rpcs_in_flight value
7561 do_facet mgs $LCTL set_param -P \
7562 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
7564 # restore max_mod_rpcs_in_flight value
7565 do_facet mgs $LCTL set_param -P \
7566 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mmrif_90c
7568 # restore MDT max_mod_rpcs_in_flight value
7569 set_mdt_max_mod_rpcs_in_flight $mmrpc_90c "mds1"
7577 [[ $($LCTL get_param mdc.*.import |
7578 grep "connect_flags:.*multi_mod_rpc") ]] ||
7579 skip "Need MDC with 'multi_mod_rpcs' feature"
7581 # check client is able to send multiple modify RPCs in paralell
7582 tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
7583 grep -c "multi_mod_rpcs")
7584 if [ "$tmp" -ne $MDSCOUNT ]; then
7586 skip "Client not able to send multiple modify RPCs in parallel"
7590 stack_trap restore_params_90c
7593 # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
7594 # prerequisite: set MDT max_mod_rpcs_in_flight to
7595 # max_rpcs_in_flight value
7596 set_mdt_max_mod_rpcs_in_flight $mrif_90c "mds1"
7598 # if max_mod_rpcs_in_flight is set to be equal to or larger than
7599 # max_rpcs_in_flight, then max_rpcs_in_flight will be increased
7600 if [[ "$CLIENT_VERSION" -ge $(version_code 2.13.53) ]]; then
7602 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c ||
7603 error "set max_mod_rpcs_in_flight to $mrif_90c failed"
7605 local new_mrif=$($LCTL get_param -n \
7606 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
7607 ((new_mrif == mrif_90c + 1)) ||
7608 error "max_rpcs_in_flight was not increased"
7611 umount_client $MOUNT
7612 set_mdt_max_mod_rpcs_in_flight $mmrpc_90c "mds1"
7616 # attempt to set max_mod_rpcs_in_flight to MDT max_mod_rpcs_in_flight+1
7617 # prerequisite: set max_rpcs_in_flight to MDT max_mod_rpcs_in_flight+2
7619 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc_90c + 2))
7622 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc_90c + 1)) &&
7623 error "set max_mod_rpcs_in_flight to $((mmrpc_90c + 1)) should fail"
7626 # attempt to set max_mod_rpcs_in_flight permanently
7627 do_facet mgs $LCTL set_param -P \
7628 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
7630 do_facet mgs $LCTL set_param -P \
7631 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c
7633 remount_client $MOUNT
7635 wait_update_facet --verbose client "$LCTL get_param -n \
7636 mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight" \
7637 "$((mrif_90c + 1))" ||
7638 error "expected '$((mrif_90c + 1))' for max_rpcs_in_flight"
7640 wait_update_facet --verbose client "$LCTL get_param -n \
7641 mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight" \
7643 error "expected '$mrif_90c' for max_mod_rpcs_in_flight"
7648 run_test 90c "check max_mod_rpcs_in_flight update limits"
7659 [[ $($LCTL get_param mdc.*.import |
7660 grep "connect_flags:.*multi_mod_rpc") ]] ||
7661 skip "Need MDC with 'multi_mod_rpcs' feature"
7663 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
7664 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
7665 facet="mds$((0x$idx + 1))"
7667 # check client version supports multislots
7668 tmp=$($LCTL get_param -N \
7669 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
7670 if [ -z "$tmp" ]; then
7672 skip "Client does not support multiple modify RPCs in flight"
7675 # get current value of max_mod_rcps_in_flight
7676 mmr=$($LCTL get_param -n \
7677 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
7678 echo "max_mod_rcps_in_flight is $mmr"
7681 echo "creating $mmr files ..."
7683 for i in $(seq $mmr); do
7684 touch $DIR/$tdir/file-$i
7687 # prepare for close RPC
7688 multiop_bg_pause $DIR/$tdir/file-close O_c
7691 # consumes mmr modify RPC slots
7692 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
7693 # drop requests on MDT so that RPC slots are consumed
7694 # during all the request resend interval
7695 do_facet $facet "$LCTL set_param fail_loc=0x159"
7696 echo "launch $mmr chmod in parallel ..."
7697 for i in $(seq $mmr); do
7698 chmod 0600 $DIR/$tdir/file-$i &
7701 # send one additional close RPC
7702 do_facet $facet "$LCTL set_param fail_loc=0"
7703 echo "launch 1 additional close in parallel ..."
7705 cancel_lru_locks mdc
7708 # check this additional close RPC get a modify RPC slot
7709 # and multiop process completed
7710 [ -d /proc/$pid ] &&
7711 error "Unable to send the additional close RPC in parallel"
7716 run_test 90d "check one close RPC is allowed above max_mod_rpcs_in_flight"
7718 check_uuid_on_ost() {
7720 do_facet ost1 "$LCTL get_param obdfilter.${FSNAME}*.exports.'$nid'.uuid"
7723 check_uuid_on_mdt() {
7725 do_facet $SINGLEMDS "$LCTL get_param mdt.${mds1_svc}*.exports.'$nid'.uuid"
7733 [[ "$OST1_VERSION" -ge $(version_code 2.7.63) ]] ||
7734 skip "Need OST version at least 2.7.63"
7735 [[ "$MDS1_VERSION" -ge $(version_code 2.7.63) ]] ||
7736 skip "Need MDT version at least 2.7.63"
7738 start_mds || error "MDS start failed"
7739 start_ost || error "unable to start OST"
7740 mount_client $MOUNT || error "client start failed"
7741 check_mount || error "check_mount failed"
7744 nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
7748 uuid=$(get_client_uuid $MOUNT)
7750 echo "list nids on mdt:"
7751 do_facet $SINGLEMDS "$LCTL list_param mdt.${FSNAME}*.exports.*"
7752 echo "uuid from $nid:"
7753 do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
7755 found=$(check_uuid_on_mdt $nid | grep $uuid)
7756 [ -z "$found" ] && error "can't find $uuid $nid on MDT"
7757 found=$(check_uuid_on_ost $nid | grep $uuid)
7758 [ -z "$found" ] && error "can't find $uuid $nid on OST"
7760 # umount the client so it won't reconnect
7761 manual_umount_client --force || error "failed to umount $?"
7762 # shouldn't disappear on MDS after forced umount
7763 found=$(check_uuid_on_mdt $nid | grep $uuid)
7764 [ -z "$found" ] && error "can't find $uuid $nid"
7767 do_facet $SINGLEMDS \
7768 "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
7769 sleep 1 # eviction above is async, give it some time to proceed
7771 found=$(check_uuid_on_mdt $nid | grep $uuid)
7772 [ -n "$found" ] && error "found $uuid $nid on MDT"
7773 found=$(check_uuid_on_ost $nid | grep $uuid)
7774 [ -n "$found" ] && error "found $uuid $nid on OST"
7776 # check it didn't reconnect (being umounted)
7777 sleep $((TIMEOUT+1))
7778 found=$(check_uuid_on_mdt $nid | grep $uuid)
7779 [ -n "$found" ] && error "found $uuid $nid on MDT"
7780 found=$(check_uuid_on_ost $nid | grep $uuid)
7781 [ -n "$found" ] && error "found $uuid $nid on OST"
7785 run_test 91 "evict-by-nid support"
7787 generate_ldev_conf() {
7788 # generate an ldev.conf file
7789 local ldevconfpath=$1
7791 local fsldevformat=""
7794 local facets="mgs,$(get_facets OST),$(get_facets MDS)"
7795 for facet in ${facets//,/ }; do
7797 fstype=$(facet_fstype $facet)
7798 [ "$fstype" = zfs ] && fsldevformat="$fstype:"
7799 local host=$(facet_host $facet)
7801 local varfo=${facet}failover_HOST
7802 if [ $facet == mgs ] && combined_mgs_mds; then
7803 varfo=mds1failover_HOST
7805 [ -n "${!varfo}" ] && fo=${!varfo}
7806 local type=$(echo $facet | tr -d "[:digit:]" | \
7807 tr "[:lower:]" "[:upper:]" | sed s/MDS/MDT/ )
7809 [ ${facet} == mgs ] ||
7810 num=$(facet_number $facet)
7811 printf "%s\t%s\t%s-%s%04x\t%s%s\n" \
7818 $(facet_device $facet) >> $ldevconfpath
7821 echo "----- $ldevconfpath -----"
7823 echo "--- END $ldevconfpath ---"
7828 # generate a nids file (mapping between hostname to nid)
7829 # looks like we only have the MGS nid available to us
7830 # so just echo that to a file
7832 echo -e "${mgs_HOST}\t${MGSNID}" > $nidspath
7834 echo "----- $nidspath -----"
7836 echo "--- END $nidspath ---"
7839 compare_ldev_output() {
7840 local ldev_output=$1
7841 local expected_output=$2
7843 sort $expected_output -o $expected_output
7844 sort $ldev_output -o $ldev_output
7846 echo "-- START OF LDEV OUTPUT --"
7848 echo "--- END OF LDEV OUTPUT ---"
7850 echo "-- START OF EXPECTED OUTPUT --"
7851 cat $expected_output
7852 echo "--- END OF EXPECTED OUTPUT ---"
7854 diff $expected_output $ldev_output
7859 if [ -z "$LDEV" ]; then
7860 error "ldev is missing!"
7863 local LDEVCONFPATH=$TMP/ldev.conf
7864 local NIDSPATH=$TMP/nids
7866 echo "Host is $(hostname)"
7868 generate_ldev_conf $LDEVCONFPATH
7869 generate_nids $NIDSPATH
7871 # echo the mgs nid and compare it to environment variable MGSNID
7872 local facets="$(get_facets OST),$(get_facets MDS),mgs"
7873 for facet in ${facets//,/ }; do
7874 local host=$(facet_host $facet)
7875 local output=$($LDEV -c $LDEVCONFPATH -H $host -n $NIDSPATH echo %m)
7877 echo "-- START OF LDEV OUTPUT --"
7879 echo "--- END OF LDEV OUTPUT ---"
7882 error "ldev failed to execute!"
7884 # need to process multiple lines because of
7885 # several targets on host
7886 echo -e $output | awk '{ print $2 }' | while read -r line ; do
7887 [ "$line" = "$MGSNID" ] ||
7888 error "ldev failed mgs nid '$line', \
7892 rm -f $LDEVCONFPATH $NIDSPATH
7894 run_test 92 "ldev returns MGS NID correctly in command substitution"
7897 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
7900 #start mgs or mgs/mdt0
7901 if ! combined_mgs_mds ; then
7908 start_ost || error "OST0 start fail"
7910 #define OBD_FAIL_MGS_WRITE_TARGET_DELAY 0x90e
7911 do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x8000090e"
7912 for num in $(seq 2 $MDSCOUNT); do
7916 mount_client $MOUNT || error "mount client fails"
7917 wait_osc_import_state mds ost FULL
7918 wait_osc_import_ready client ost
7919 check_mount || error "check_mount failed"
7921 cleanup || error "cleanup failed with $?"
7923 run_test 93 "register mulitple MDT at the same time"
7926 if [ -z "$LDEV" ]; then
7927 error "ldev is missing!"
7930 local LDEVCONFPATH=$TMP/ldev.conf
7931 local NIDSPATH=$TMP/nids
7933 generate_ldev_conf $LDEVCONFPATH
7934 generate_nids $NIDSPATH
7936 local LDEV_OUTPUT=$TMP/ldev-output.txt
7937 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME > $LDEV_OUTPUT
7939 # ldev failed, error
7940 if [ $? -ne 0 ]; then
7941 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
7942 error "ldev failed to execute!"
7946 local EXPECTED_OUTPUT=$TMP/ldev-expected.txt
7948 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
7950 for num in $(seq $MDSCOUNT); do
7951 printf "%s-MDT%04x\n" $FSNAME $((num - 1)) >> $EXPECTED_OUTPUT
7954 for num in $(seq $OSTCOUNT); do
7955 printf "%s-OST%04x\n" $FSNAME $((num - 1)) >> $EXPECTED_OUTPUT
7958 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
7960 if [ $? -ne 0 ]; then
7961 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7962 error "ldev failed to produce the correct hostlist!"
7965 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
7967 run_test 94 "ldev outputs correct labels for file system name query"
7970 if [ -z "$LDEV" ]; then
7971 error "ldev is missing!"
7974 local LDEVCONFPATH=$TMP/ldev.conf
7975 local NIDSPATH=$TMP/nids
7977 generate_ldev_conf $LDEVCONFPATH
7978 generate_nids $NIDSPATH
7982 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME &>/dev/null
7983 if [ $? -ne 0 ]; then
7984 rm $LDEVCONFPATH $NIDSPATH
7985 error "ldev label filtering w/ -F failed!"
7989 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -l &>/dev/null
7990 if [ $? -ne 0 ]; then
7991 rm $LDEVCONFPATH $NIDSPATH
7992 error "ldev label filtering w/ -l failed!"
7996 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f &>/dev/null
7997 if [ $? -ne 0 ]; then
7998 rm $LDEVCONFPATH $NIDSPATH
7999 error "ldev label filtering w/ -f failed!"
8003 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a &>/dev/null
8004 if [ $? -ne 0 ]; then
8005 rm $LDEVCONFPATH $NIDSPATH
8006 error "ldev label filtering w/ -a failed!"
8011 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -F $FSNAME &>/dev/null
8012 if [ $? -eq 0 ]; then
8013 rm $LDEVCONFPATH $NIDSPATH
8014 error "ldev label filtering w/ -a and -F incorrectly succeeded"
8018 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -f &>/dev/null
8019 if [ $? -eq 0 ]; then
8020 rm $LDEVCONFPATH $NIDSPATH
8021 error "ldev label filtering w/ -a and -f incorrectly succeeded"
8025 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -a -l &>/dev/null
8026 if [ $? -eq 0 ]; then
8027 rm $LDEVCONFPATH $NIDSPATH
8028 error "ldev label filtering w/ -a and -l incorrectly succeeded"
8032 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -f -l &>/dev/null
8033 if [ $? -eq 0 ]; then
8034 rm $LDEVCONFPATH $NIDSPATH
8035 error "ldev label filtering w/ -f and -l incorrectly succeeded"
8039 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -l &>/dev/null
8040 if [ $? -eq 0 ]; then
8041 rm $LDEVCONFPATH $NIDSPATH
8042 error "ldev label filtering w/ -F and -l incorrectly succeeded"
8045 # file sys & foreign
8046 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -f &>/dev/null
8047 if [ $? -eq 0 ]; then
8048 rm $LDEVCONFPATH $NIDSPATH
8049 error "ldev label filtering w/ -F and -f incorrectly succeeded"
8052 rm $LDEVCONFPATH $NIDSPATH
8054 run_test 95 "ldev should only allow one label filter"
8057 if [ -z "$LDEV" ]; then
8058 error "ldev is missing!"
8061 local LDEVCONFPATH=$TMP/ldev.conf
8062 local NIDSPATH=$TMP/nids
8064 generate_ldev_conf $LDEVCONFPATH
8065 generate_nids $NIDSPATH
8067 local LDEV_OUTPUT=$TMP/ldev-output.txt
8068 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -H $mgs_HOST \
8070 awk '{print $2}' > $LDEV_OUTPUT
8072 # ldev failed, error
8073 if [ $? -ne 0 ]; then
8074 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
8075 error "ldev failed to execute!"
8079 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
8081 echo "$mgs_HOST-$(facet_fstype mgs)" > $EXPECTED_OUTPUT
8083 local facets="$(get_facets OST),$(get_facets MDS)"
8084 for facet in ${facets//,/ }; do
8085 local host=$(facet_host $facet)
8086 [ "$mgs_HOST" == "$host" ] &&
8087 echo "$host-$(facet_fstype $facet)" \
8091 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
8093 if [ $? -ne 0 ]; then
8094 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8095 error "ldev failed to produce the correct output!"
8098 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8100 run_test 96 "ldev returns hostname and backend fs correctly in command sub"
8103 if [ -z "$LDEV" ]; then
8104 error "ldev is missing!"
8107 local LDEVCONFPATH=$TMP/ldev.conf
8108 local NIDSPATH=$TMP/nids
8110 generate_ldev_conf $LDEVCONFPATH
8111 generate_nids $NIDSPATH
8113 local LDEV_OUTPUT=$TMP/ldev-output.txt
8114 local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
8116 echo -e "\nMDT role"
8117 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mdt > $LDEV_OUTPUT
8119 if [ $? -ne 0 ]; then
8120 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
8121 error "ldev failed to execute for mdt role!"
8124 for num in $(seq $MDSCOUNT); do
8125 printf "%s-MDT%04x\n" $FSNAME $((num - 1)) >> $EXPECTED_OUTPUT
8128 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
8130 if [ $? -ne 0 ]; then
8131 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8132 error "ldev failed to produce the correct output for mdt role!"
8135 echo -e "\nOST role"
8136 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R ost > $LDEV_OUTPUT
8138 if [ $? -ne 0 ]; then
8139 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
8140 error "ldev failed to execute for ost role!"
8144 for num in $(seq $OSTCOUNT); do
8145 printf "%s-OST%04x\n" $FSNAME $((num - 1)) >> $EXPECTED_OUTPUT
8148 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
8150 if [ $? -ne 0 ]; then
8151 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8152 error "ldev failed to produce the correct output for ost role!"
8155 echo -e "\nMGS role"
8156 $LDEV -c $LDEVCONFPATH -n $NIDSPATH -F $FSNAME -R mgs > $LDEV_OUTPUT
8158 if [ $? -ne 0 ]; then
8159 rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT $EXPECTED_OUTPUT
8160 error "ldev failed to execute for mgs role!"
8163 printf "%s-MGS0000\n" $FSNAME > $EXPECTED_OUTPUT
8165 compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
8167 if [ $? -ne 0 ]; then
8168 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8169 error "ldev failed to produce the correct output for mgs role!"
8172 rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
8174 run_test 97 "ldev returns correct ouput when querying based on role"
8181 check_mount || error "mount failed"
8182 mountopt="user_xattr"
8183 for ((x = 1; x <= PAGE_SIZE/11; x++)); do
8184 mountopt="$mountopt,user_xattr"
8186 mount_client $MOUNT remount,$mountopt 2>&1 | grep "too long" ||
8187 error "Buffer overflow check failed"
8188 cleanup || error "cleanup failed"
8190 run_test 98 "Buffer-overflow check while parsing mount_opts"
8194 [[ "$ost1_FSTYPE" != ldiskfs ]] &&
8195 skip "ldiskfs only test"
8196 [[ "$OST1_VERSION" -ge $(version_code 2.8.57) ]] ||
8197 skip "Need OST version at least 2.8.57"
8199 local ost_opts="$(mkfs_opts ost1 $(ostdevname 1)) \
8200 --reformat $(ostdevname 1) $(ostvdevname 1)"
8201 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" &&
8202 skip "meta_bg already set"
8205 if [[ ${!opts} != *mkfsoptions* ]]; then
8206 eval opts=\"${!opts} \
8207 --mkfsoptions='\\\"-O ^resize_inode,meta_bg\\\"'\"
8209 local val=${!opts//--mkfsoptions=\\\"/ \
8210 --mkfsoptions=\\\"-O ^resize_inode,meta_bg }
8214 echo "params: $opts"
8217 add ost1 $opts || error "add ost1 failed with new params"
8219 do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" ||
8220 error "meta_bg is not set"
8222 run_test 99 "Adding meta_bg option"
8227 start_mgsmds || error "MDS start failed"
8228 start_ost || error "unable to start OST"
8229 mount_client $MOUNT || error "client start failed"
8230 check_mount || error "check_mount failed"
8239 do_facet mgs 'lshowmount -v' | awk 'BEGIN {NR == 0; rc=1} /MGS:/ {rc=0}
8240 END {exit rc}' || error "lshowmount have no output MGS"
8242 do_facet mds1 'lshowmount -v' | awk 'BEGIN {NR == 2; rc=1} /-MDT0000:/
8243 {rc=0} END {exit rc}' || error "lshowmount have no output MDT0"
8245 do_facet ost1 'lshowmount -v' | awk 'BEGIN {NR == 4; rc=1} /-OST0000:/
8246 {rc=0} END {exit rc}' || error "lshowmount have no output OST0"
8248 cleanup || error "cleanup failed with $?"
8250 run_test 100 "check lshowmount lists MGS, MDT, OST and 0@lo"
8253 local createmany_pid
8254 local dev=$FSNAME-OST0000-osc-MDT0000
8258 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param \
8259 seq.*OST*-super.width=$DATA_SEQ_MAX_WIDTH
8260 createmany -o $DIR1/$tdir/$tfile-%d 50000 &
8262 # MDT->OST reconnection causes MDT<->OST last_id synchornisation
8263 # via osp_precreate_cleanup_orphans.
8264 for ((i = 0; i < 100; i++)); do
8265 for ((k = 0; k < 10; k++)); do
8266 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;" \
8267 "$LCTL --device $dev activate"
8270 ls -asl $MOUNT | grep '???' &&
8271 { kill -9 $createmany_pid &>/dev/null;
8272 error "File has no object on OST"; }
8274 kill -s 0 $createmany_pid || break
8276 wait $createmany_pid
8278 unlinkmany $DIR1/$tdir/$tfile-%d 50000
8281 run_test 101a "Race MDT->OST reconnection with create"
8284 local dev=$FSNAME-OST0000-osc-MDT0000
8285 local dir=$DIR1/$tdir
8289 $LFS setstripe -c 1 -i 0 $dir
8290 do_facet $SINGLEMDS "$LCTL --device $dev deactivate;"
8291 #define OBD_FAIL_OSP_CON_EVENT_DELAY 0x2107
8292 do_facet mds1 "$LCTL set_param fail_loc=0x80002107 fail_val=20"
8293 do_facet $SINGLEMDS "$LCTL --device $dev activate;"
8298 wait_osc_import_ready client ost1
8299 touch $dir/$tfile || error "Can't create file"
8303 run_test 101b "Race events DISCONNECT and ACTIVE in osp"
8306 [[ "$MDS1_VERSION" -gt $(version_code 2.9.53) ]] ||
8307 skip "Need server version greater than 2.9.53"
8308 [[ "$(mdsdevname 1)" != "$(mgsdevname)" ]] &&
8309 [[ "$(facet_host mds1)" == "$(facet_host mgs)" ]] &&
8310 skip "MGS must be on different node or combined"
8312 cleanup || error "cleanup failed with $?"
8314 local mds1dev=$(mdsdevname 1)
8315 local mds1mnt=$(facet_mntpt mds1)
8316 local mds1opts=$MDS_MOUNT_OPTS
8318 if [ "$mds1_FSTYPE" == ldiskfs ] &&
8319 ! do_facet mds1 test -b $mds1dev; then
8320 mds1opts=$(csa_add "$mds1opts" -o loop)
8322 if [[ "$mds1_FSTYPE" == zfs ]]; then
8323 import_zpool mds1 || return ${PIPESTATUS[0]}
8326 # unload all and only load libcfs to allow fail_loc setting
8327 do_facet mds1 $LUSTRE_RMMOD || error "unable to unload modules"
8328 do_rpc_nodes $(facet_active_host mds1) load_module ../libcfs/libcfs/libcfs
8329 do_facet mds1 lsmod | grep libcfs || error "libcfs not loaded"
8331 #define OBD_FAIL_OBDCLASS_MODULE_LOAD 0x60a
8332 do_facet mds1 "$LCTL set_param fail_loc=0x8000060a"
8334 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
8335 error "mdt start must fail" || log "mount failed as expected"
8336 do_facet mds1 lsmod | grep obdclass && error "obdclass must not load" ||
8337 log "obdclass not loaded as expected"
8339 do_facet mds1 "$LCTL set_param fail_loc=0x0"
8341 do_rpc_nodes $(facet_active_host mds1) load_modules
8342 do_facet mds1 $MOUNT_CMD $mds1dev $mds1mnt $mds1opts &&
8343 log "mds1 mounted properly" ||
8344 error "mdt start must not fail"
8346 cleanup || error "cleanup failed with $?"
8348 run_test 102 "obdclass module cleanup upon error"
8353 echo "rename $FSNAME to $newname"
8355 if ! combined_mgs_mds ; then
8356 local dev=$(mgsdevname)
8359 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
8360 error "(7) Fail to rename MGS"
8361 if [ "$(facet_fstype mgs)" = "zfs" ]; then
8362 reimport_zpool mgs $newname-mgs
8366 for num in $(seq $MDSCOUNT); do
8367 local dev=$(mdsdevname $num)
8369 do_facet mds${num} \
8370 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
8371 error "(8) Fail to rename MDT $num"
8372 if [ "$(facet_fstype mds${num})" = "zfs" ]; then
8373 reimport_zpool mds${num} $newname-mdt${num}
8377 for num in $(seq $OSTCOUNT); do
8378 local dev=$(ostdevname $num)
8380 do_facet ost${num} \
8381 "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
8382 error "(9) Fail to rename OST $num"
8383 if [ "$(facet_fstype ost${num})" = "zfs" ]; then
8384 reimport_zpool ost${num} $newname-ost${num}
8389 test_103_set_pool() {
8393 do_facet mgs $LCTL pool_add $FSNAME.$pname ${FSNAME}-$ost_x ||
8394 error "Fail to add $ost_x to $FSNAME.$pname"
8395 wait_update $HOSTNAME \
8396 "lctl get_param -n lov.$FSNAME-clilov-*.pools.$pname |
8397 grep $ost_x" "$FSNAME-${ost_x}_UUID" ||
8398 error "$ost_x is NOT in pool $FSNAME.$pname"
8401 test_103_check_pool() {
8402 local save_fsname=$1
8405 stat $DIR/$tdir/test-framework.sh ||
8406 error "($errno) Fail to stat"
8407 do_facet mgs $LCTL pool_list $FSNAME.pool1 ||
8408 error "($errno) Fail to list $FSNAME.pool1"
8409 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname ||
8410 error "($errno) Fail to list $FSNAME.$save_fsname"
8411 do_facet mgs $LCTL pool_list $FSNAME.$save_fsname |
8412 grep ${FSNAME}-OST0000 ||
8413 error "($errno) List $FSNAME.$save_fsname is invalid"
8415 local pname=$($LFS getstripe --pool $DIR/$tdir/d0)
8416 [ "$pname" = "$save_fsname" ] ||
8417 error "($errno) Unexpected pool name $pname"
8421 check_mount_and_prep
8423 mkdir $DIR/$tdir || error "(1) Fail to mkdir $DIR/$tdir"
8424 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir ||
8425 error "(2) Fail to copy test-framework.sh"
8427 do_facet mgs $LCTL pool_new $FSNAME.pool1 ||
8428 error "(3) Fail to create $FSNAME.pool1"
8429 # name the pool name as the fsname
8430 do_facet mgs $LCTL pool_new $FSNAME.$FSNAME ||
8431 error "(4) Fail to create $FSNAME.$FSNAME"
8433 test_103_set_pool $FSNAME OST0000
8435 $LFS setstripe -p $FSNAME $DIR/$tdir/d0 ||
8436 error "(6) Fail to setstripe on $DIR/$tdir/d0"
8441 test_renamefs mylustre
8443 local save_fsname=$FSNAME
8447 test_103_check_pool $save_fsname 7
8449 if [ $OSTCOUNT -ge 2 ]; then
8450 test_103_set_pool $save_fsname OST0001
8453 $LFS setstripe -p $save_fsname $DIR/$tdir/f0 ||
8454 error "(16) Fail to setstripe on $DIR/$tdir/f0"
8463 test_103_check_pool $save_fsname 17
8467 test_renamefs $save_fsname
8473 run_test 103 "rename filesystem name"
8475 test_104a() { # LU-6952
8476 local mds_mountopts=$MDS_MOUNT_OPTS
8477 local ost_mountopts=$OST_MOUNT_OPTS
8478 local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
8479 local lctl_ver=$(do_facet $SINGLEMDS $LCTL --version |
8482 [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
8483 skip "this test needs utils above 2.9.55"
8485 # specify "acl" in mount options used by mkfs.lustre
8486 if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
8487 MDS_MOUNT_FS_OPTS="acl,user_xattr"
8490 MDS_MOUNT_FS_OPTS="${MDS_MOUNT_FS_OPTS},acl,user_xattr"
8493 echo "mountfsopt: $MDS_MOUNT_FS_OPTS"
8495 #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
8497 if ! combined_mgs_mds ; then
8501 if [ -z "$MDS_MOUNT_OPTS" ]; then
8502 MDS_MOUNT_OPTS="-o noacl"
8504 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
8507 for num in $(seq $MDSCOUNT); do
8508 start mds$num $(mdsdevname $num) $MDS_MOUNT_OPTS ||
8509 error "Failed to start MDS"
8512 for num in $(seq $OSTCOUNT); do
8513 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
8514 error "Failed to start OST"
8518 setfacl -m "d:$RUNAS_ID:rwx" $MOUNT &&
8519 error "ACL is applied when FS is mounted with noacl."
8521 MDS_MOUNT_OPTS=$mds_mountopts
8522 OST_MOUNT_OPTS=$ost_mountopts
8523 MDS_MOUNT_FS_OPTS=$mds_mountfsopts
8525 run_test 104a "Make sure user defined options are reflected in mount"
8527 test_104b() { # LU-12859
8528 mount_client $MOUNT3 flock,localflock
8529 stack_trap "umount_client $MOUNT3" EXIT
8530 mount | grep "$MOUNT3 .*,flock" && error "flock is still set"
8531 mount | grep "$MOUNT3 .*,localflock" || error "localflock is not set"
8532 umount_client $MOUNT3
8533 mount_client $MOUNT3 localflock,flock
8534 mount | grep "$MOUNT3 .*,localflock" && error "localflock is still set"
8535 mount | grep "$MOUNT3 .*,flock" || error "flock is not set"
8536 umount_client $MOUNT3
8537 mount_client $MOUNT3 localflock,flock,noflock
8538 flock_is_enabled $MOUNT3 && error "some flock is still enabled" || true
8540 run_test 104b "Mount uses last flock argument"
8542 error_and_umount() {
8553 mount --bind $DIR $TMP/$tdir || error "mount bind mnt pt failed"
8554 rm -f $TMP/$tdir/$tfile
8555 rm -f $TMP/$tdir/${tfile}1
8557 # Files should not be created in ro bind mount point
8558 # remounting from rw to ro
8559 mount -o remount,ro $TMP/$tdir ||
8560 error_and_umount "readonly remount of bind mnt pt failed"
8561 touch $TMP/$tdir/$tfile &&
8562 error_and_umount "touch succeeds on ro bind mnt pt"
8563 [ -e $TMP/$tdir/$tfile ] &&
8564 error_and_umount "file created on ro bind mnt pt"
8566 # Files should be created in rw bind mount point
8567 # remounting from ro to rw
8568 mount -o remount,rw $TMP/$tdir ||
8569 error_and_umount "read-write remount of bind mnt pt failed"
8570 touch $TMP/$tdir/${tfile}1 ||
8571 error_and_umount "touch fails on rw bind mnt pt"
8572 [ -e $TMP/$tdir/${tfile}1 ] ||
8573 error_and_umount "file not created on rw bind mnt pt"
8574 umount $TMP/$tdir || error "umount of bind mnt pt failed"
8576 cleanup || error "cleanup failed with $?"
8578 run_test 105 "check file creation for ro and rw bind mnt pt"
8582 local creates=64768 # one full plain llog
8584 # ensure there are enough inodes in the filesystem
8585 (( OSTSIZE < (creates + 1024) * 8)) && OSTSIZE=$(((creates + 1024) * 8))
8589 mkdir -p $DIR/$tdir || error "create $tdir failed"
8590 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param \
8591 seq.*OST*-super.width=$DATA_SEQ_MAX_WIDTH
8592 lfs setstripe -c 1 -i 0 $DIR/$tdir
8593 #define OBD_FAIL_CAT_RECORDS 0x1312
8594 do_facet mds1 $LCTL set_param fail_loc=0x1312 fail_val=$repeat
8596 for ((i = 1; i <= $repeat; i++)); do
8597 createmany -o $DIR/$tdir/f- $creates || lfs df -i
8598 createmany -u $DIR/$tdir/f- $creates
8599 wait_delete_completed $((TIMEOUT * 7))
8601 #ASSERTION osp_sync_thread() ( thread->t_flags != SVC_RUNNING ) failed
8602 #shows that osp code is buggy
8603 do_facet mds1 $LCTL set_param fail_loc=0 fail_val=0
8607 run_test 106 "check osp llog processing when catalog is wrapped"
8610 [[ "$MDS1_VERSION" -ge $(version_code 2.10.50) ]] ||
8611 skip "Need MDS version > 2.10.50"
8614 start_mgsmds || error "start_mgsmds failed"
8615 start_ost || error "unable to start OST"
8617 # add unknown configuration parameter.
8618 if [[ $PERM_CMD == *"set_param -P"* ]]; then
8619 cmd="$PERM_CMD ost.$FSNAME-OST0000*.unknown_param"
8621 cmd="$PERM_CMD $FSNAME-OST0000*.ost.unknown_param"
8623 do_facet mgs "$cmd=50"
8624 cleanup_nocli || error "cleanup_nocli failed with $?"
8627 # unknown param should be ignored while mounting.
8628 start_ost || error "unable to start OST after unknown param set"
8630 cleanup || error "cleanup failed with $?"
8632 run_test 107 "Unknown config param should not fail target mounting"
8637 $rcmd rm -rf $tmp > /dev/null 2>&1
8638 $rcmd mkdir -p $tmp/{mnt,images} || error "failed to mkdir remotely"
8640 for facet in $facets; do
8641 [ "$mds1_FSTYPE" = zfs ] &&
8642 $rcmd $ZPOOL -f export lustre-$facet > /dev/null 2>&1
8643 $rcmd mkdir $tmp/mnt/$facet ||
8644 error "failed to mkdir $tmp/mnt/$facet"
8645 $rcmd dd if=/dev/zero of=$tmp/images/$facet \
8646 seek=199 bs=1M count=1 ||
8647 error "failed to create $tmp/images/$facet"
8656 local facet=${role}$((idx + 1))
8658 [ $# -eq 5 ] && pool=$5
8660 do_facet $SINGLEMDS $MKFS --fsname=lustre --$mgs \
8661 --$role --index=$idx --replace --backfstype=$bkfs \
8662 --device-size=200000 --reformat $pool $tmp/images/$facet ||
8663 error "failed to mkfs for $facet"
8667 echo "mounting client..."
8668 mount -t lustre ${nid}:/lustre $MOUNT ||
8669 error "failed to mount lustre"
8672 ls -l $MOUNT/local_dir || error "failed to list"
8674 echo "check truncate && write"
8675 echo "dummmmmmmmmmmmm" > $MOUNT/remote_dir/fsx.c ||
8676 error "failed to tuncate & write"
8679 touch $MOUNT/foooo ||
8680 error "failed to create"
8682 echo "check read && write && append"
8683 sha1sum $MOUNT/conf-sanity.sh |
8684 awk '{ print $1 }' > $MOUNT/checksum.new ||
8685 error "failed to read(1)"
8686 sha1sum $MOUNT/remote_dir/unlinkmany.c |
8687 awk '{ print $1 }' >> $MOUNT/checksum.new ||
8688 error "failed to read(2)"
8689 sha1sum $MOUNT/striped_dir/lockahead_test.o |
8690 awk '{ print $1 }' >> $MOUNT/checksum.new ||
8691 error "failed to read(3)"
8694 diff $MOUNT/checksum.new $MOUNT/checksum.src ||
8695 error "failed to verify data"
8705 umount -f $MOUNT || error "failed to umount client"
8706 for facet in $facets; do
8707 $rcmd umount -f $tmp/mnt/$facet ||
8708 error "failed to umount $facet"
8709 if [ "$mds1_FSTYPE" = zfs ]; then
8710 $rcmd $ZPOOL export -f lustre-$facet ||
8711 error "failed to export lustre-$facet"
8715 $rcmd rm -rf $tmp || error "failed to rm the dir $tmp"
8719 [ "$CLIENTONLY" ] && skip "Client-only testing"
8720 [ "$mds1_FSTYPE" != zfs ] && skip "zfs only test"
8721 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
8722 skip "Need server version at least 2.10.58"
8727 local tmp=$TMP/$tdir
8728 local rcmd="do_facet $SINGLEMDS"
8729 local facets="mdt1 mdt2 ost1 ost2"
8730 local nid=$($rcmd $LCTL list_nids | head -1)
8733 trap t_108_cleanup EXIT ERR
8736 t_108_mkfs mdt 0 zfs mgs lustre-mdt1/mdt1
8737 t_108_mkfs mdt 1 zfs mgsnode=$nid lustre-mdt2/mdt2
8738 t_108_mkfs ost 0 zfs mgsnode=$nid lustre-ost1/ost1
8739 t_108_mkfs ost 1 zfs mgsnode=$nid lustre-ost2/ost2
8741 for facet in $facets; do
8742 $rcmd zfs set mountpoint=$tmp/mnt/$facet canmount=on \
8743 lustre-$facet/$facet ||
8744 error "failed to zfs set for $facet (1)"
8745 $rcmd zfs mount lustre-$facet/$facet ||
8746 error "failed to local mount $facet"
8747 $rcmd tar jxf $LUSTRE/tests/ldiskfs_${facet}_2_11.tar.bz2 \
8748 --xattrs --xattrs-include="trusted.*" \
8749 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
8750 error "failed to untar image for $facet"
8751 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
8752 error "failed to cleanup for $facet"
8753 $rcmd zfs umount lustre-$facet/$facet ||
8754 error "failed to local umount $facet"
8755 $rcmd zfs set canmount=off lustre-$facet/$facet ||
8756 error "failed to zfs set $facet (2)"
8759 echo "changing server nid..."
8760 $rcmd mount -t lustre -o nosvc lustre-mdt1/mdt1 $tmp/mnt/mdt1
8761 $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
8762 $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
8763 $rcmd lctl replace_nids $FSNAME-OST0000 $nid
8764 $rcmd lctl replace_nids $FSNAME-OST0001 $nid
8765 $rcmd umount $tmp/mnt/mdt1
8767 for facet in $facets; do
8768 echo "mounting $facet from backup..."
8769 $rcmd mount -t lustre -o abort_recov lustre-$facet/$facet \
8770 $tmp/mnt/$facet || error "failed to mount $facet"
8773 # ZFS backend can detect migration and trigger OI scrub automatically
8774 # sleep 3 seconds for scrub done
8780 run_test 108a "migrate from ldiskfs to ZFS"
8783 [ "$CLIENTONLY" ] && skip "Client-only testing"
8784 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
8785 [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
8786 skip "Need server version at least 2.10.58"
8791 local tmp=$TMP/$tdir
8792 local rcmd="do_facet $SINGLEMDS"
8793 local facets="mdt1 mdt2 ost1 ost2"
8794 local scrub_list="MDT0000 MDT0001 OST0000 OST0001"
8795 local nid=$($rcmd $LCTL list_nids | head -1)
8798 trap t_108_cleanup EXIT ERR
8801 t_108_mkfs mdt 0 ldiskfs mgs
8802 t_108_mkfs mdt 1 ldiskfs mgsnode=$nid
8803 t_108_mkfs ost 0 ldiskfs mgsnode=$nid
8804 t_108_mkfs ost 1 ldiskfs mgsnode=$nid
8806 for facet in $facets; do
8807 $rcmd mount -t ldiskfs -o loop $tmp/images/$facet \
8809 error "failed to local mount $facet"
8811 $rcmd tar jxf $LUSTRE/tests/zfs_${facet}_2_11.tar.bz2 \
8812 --xattrs --xattrs-include="*.*" \
8813 -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
8814 error "failed to untar image for $facet"
8815 $rcmd "cd $tmp/mnt/$facet && rm -rf oi.* OI_* lfsck_* LFSCK" ||
8816 error "failed to cleanup for $facet"
8817 $rcmd umount $tmp/mnt/$facet ||
8818 error "failed to local umount $facet"
8821 echo "changing server nid..."
8822 $rcmd mount -t lustre -o nosvc,loop $tmp/images/mdt1 $tmp/mnt/mdt1
8823 $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
8824 $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
8825 $rcmd lctl replace_nids $FSNAME-OST0000 $nid
8826 $rcmd lctl replace_nids $FSNAME-OST0001 $nid
8827 $rcmd umount $tmp/mnt/mdt1
8829 for facet in $facets; do
8830 echo "mounting $facet from backup..."
8831 $rcmd mount -t lustre -o loop,abort_recov $tmp/images/$facet \
8832 $tmp/mnt/$facet || error "failed to mount $facet"
8835 for facet in $scrub_list; do
8836 $rcmd $LCTL lfsck_start -M $FSNAME-$facet -t scrub ||
8837 error "failed to start OI scrub on $facet"
8840 # sleep 3 seconds for scrub done
8846 run_test 108b "migrate from ZFS to ldiskfs"
8849 # set number of permanent parameters
8851 test_109_set_params() {
8854 set_persistent_param_and_check mds \
8855 "mdd.$fsname-MDT0000.atime_diff" \
8856 "$fsname-MDT0000.mdd.atime_diff" \
8858 set_persistent_param_and_check mds \
8859 "mdd.$fsname-MDT0000.atime_diff" \
8860 "$fsname-MDT0000.mdd.atime_diff" \
8862 set_persistent_param_and_check client \
8863 "llite.$fsname*.max_read_ahead_mb" \
8864 "$fsname.llite.max_read_ahead_mb" \
8866 set_persistent_param_and_check client \
8867 "llite.$fsname*.max_read_ahead_mb" \
8868 "$fsname.llite.max_read_ahead_mb" \
8870 create_pool $fsname.pool1 || error "create pool failed"
8871 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
8872 error "pool_add failed"
8873 do_facet mgs $LCTL pool_remove $fsname.pool1 OST0000 ||
8874 error "pool_remove failed"
8875 do_facet mgs $LCTL pool_add $fsname.pool1 OST0000 ||
8876 error "pool_add failed"
8880 # check permanent parameters
8882 test_109_test_params() {
8885 local atime_diff=$(do_facet mds $LCTL \
8886 get_param -n mdd.$fsname-MDT0000.atime_diff)
8887 [ $atime_diff == 63 ] || error "wrong mdd parameter after clear_conf"
8888 local max_read_ahead_mb=$(do_facet client $LCTL \
8889 get_param -n llite.$fsname*.max_read_ahead_mb)
8890 [ $max_read_ahead_mb == 64 ] ||
8891 error "wrong llite parameter after clear_conf"
8892 local ost_in_pool=$(do_facet mds $LCTL pool_list $fsname.pool1 |
8893 grep -v "^Pool:" | sed 's/_UUID//')
8894 [ $ost_in_pool = "$fsname-OST0000" ] ||
8895 error "wrong pool after clear_conf"
8899 # run lctl clear_conf, store CONFIGS before and after that
8901 test_109_clear_conf()
8903 local clear_conf_arg=$1
8906 if ! combined_mgs_mds ; then
8907 mgsdev=$(mgsdevname)
8908 stop_mgs || error "stop_mgs failed"
8909 start_mgs "-o nosvc" || error "start_mgs nosvc failed"
8911 mgsdev=$(mdsdevname 1)
8912 start_mdt 1 "-o nosvc" || error "start_mdt 1 nosvc failed"
8915 do_facet mgs "rm -rf $TMP/${tdir}/conf1; mkdir -p $TMP/${tdir}/conf1;" \
8916 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf1\\\" \
8920 # the command being tested
8922 do_facet mgs $LCTL clear_conf $clear_conf_arg ||
8923 error "clear_conf failed"
8924 if ! combined_mgs_mds ; then
8925 stop_mgs || error "stop_mgs failed"
8927 stop_mdt 1 || error "stop_mdt 1 failed"
8930 do_facet mgs "rm -rf $TMP/${tdir}/conf2; mkdir -p $TMP/${tdir}/conf2;" \
8931 "$DEBUGFS -c -R \\\"rdump CONFIGS $TMP/${tdir}/conf2\\\" \
8935 test_109_file_shortened() {
8937 local sizes=($(do_facet mgs "stat -c %s " \
8938 "$TMP/${tdir}/conf1/CONFIGS/$file" \
8939 "$TMP/${tdir}/conf2/CONFIGS/$file"))
8940 [ ${sizes[1]} -lt ${sizes[0]} ] && return 0
8946 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
8947 skip "Needs MDS version 2.10.59 or later."
8948 [ "$(facet_fstype mgs)" == zfs ] &&
8949 skip "LU-8727: no implementation for ZFS"
8954 client_up || error "client_up failed"
8957 # set number of permanent parameters
8959 test_109_set_params $FSNAME
8961 umount_client $MOUNT || error "umount_client failed"
8962 stop_ost || error "stop_ost failed"
8963 stop_mds || error "stop_mds failed"
8965 test_109_clear_conf $FSNAME
8967 # make sure that all configs are cleared
8969 test_109_file_shortened $FSNAME-MDT0000 ||
8970 error "failed to clear MDT0000 config"
8971 test_109_file_shortened $FSNAME-client ||
8972 error "failed to clear client config"
8977 # check that configurations are intact
8979 test_109_test_params $FSNAME
8984 destroy_test_pools || error "destroy test pools failed"
8988 run_test 109a "test lctl clear_conf fsname"
8992 [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
8993 skip "Needs MDS version 2.10.59 or later."
8994 [ "$(facet_fstype mgs)" == zfs ] &&
8995 skip "LU-8727: no implementation for ZFS"
9000 client_up || error "client_up failed"
9003 # set number of permanent parameters
9005 test_109_set_params $FSNAME
9007 umount_client $MOUNT || error "umount_client failed"
9008 stop_ost || error "stop_ost failed"
9009 stop_mds || error "stop_mds failed"
9011 test_109_clear_conf $FSNAME-MDT0000
9013 # make sure that only one config is cleared
9015 test_109_file_shortened $FSNAME-MDT0000 ||
9016 error "failed to clear MDT0000 config"
9017 test_109_file_shortened $FSNAME-client &&
9018 error "failed to clear client config"
9022 # check that configurations are intact
9024 test_109_test_params $FSNAME
9029 destroy_test_pools || error "destroy test pools failed"
9033 run_test 109b "test lctl clear_conf one config"
9037 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
9038 skip "Only applicable to ldiskfs-based MDTs"
9040 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
9041 skip "large_dir option is not supported on MDS"
9042 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
9043 skip "large_dir option is not supported on OSS"
9045 stopall # stop all targets before modifying the target counts
9046 local old_mdscount=$MDSCOUNT
9047 local old_ostcount=$OSTCOUNT
9049 stack_trap "MDSCOUNT=$old_mdscount OSTCOUNT=$old_ostcount; reformat"
9053 # ext4_dir_entry_2 struct size:264
9054 # dx_root struct size:8
9055 # dx_node struct size:8
9056 # dx_entry struct size:8
9057 # For 1024 bytes block size.
9058 # First level directory entries: 126
9059 # Second level directory entries: 127
9060 # Entries in leaf: 3
9061 # For 2 levels limit: 48006
9062 # For 3 levels limit : 6096762
9063 # Create 80000 files to safely exceed 2-level htree limit.
9064 CONF_SANITY_110_LINKS=${CONF_SANITY_110_LINKS:-80000}
9066 # can fit at most 3 filenames per 1KB leaf block, but each
9067 # leaf/index block will only be 3/4 full before split at each level
9068 (( MDSSIZE < CONF_SANITY_110_LINKS / 3 * 4/3 * 4/3 )) &&
9069 CONF_SANITY_110_LINKS=$((MDSSIZE * 3 * 3/4 * 3/4))
9071 combined_mgs_mds || replace=" --replace "
9072 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
9073 $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
9074 if [[ $opts != *large_dir* ]]; then
9075 if [[ $opts != *mkfsoptions* ]]; then
9076 opts+=" --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536\\\""
9078 opts="${opts//--mkfsoptions=\\\"/ \
9079 --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536 }"
9082 echo "MDT params: $opts"
9084 combined_mgs_mds || start_mgs
9085 add mds1 $opts || error "add mds1 failed with new params"
9086 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
9088 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
9089 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
9091 if [[ $opts != *large_dir* ]]; then
9092 if [[ $opts != *mkfsoptions* ]]; then
9093 opts+=" --mkfsoptions=\\\"-O large_dir\\\" "
9095 opts="${opts//--mkfsoptions=\\\"/ \
9096 --mkfsoptions=\\\"-O large_dir }"
9099 echo "OST params: $opts"
9100 add ost1 $opts || error "add ost1 failed with new params"
9101 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
9103 MOUNT_2=yes mountcli || error "mount clients failed"
9105 mkdir -v $DIR/$tdir || error "cannot create $DIR/$tdir"
9106 local pids count=0 group=0
9108 echo "creating $CONF_SANITY_110_LINKS in total"
9109 while (( count < CONF_SANITY_110_LINKS )); do
9110 local len=$((253 - $(wc -c <<<"$tfile-$group-40000-")))
9111 local dir=DIR$((group % 2 + 1))
9112 local target=${!dir}/$tdir/$tfile-$group
9113 local long=$target-$(generate_name $len)-
9114 local create=$((CONF_SANITY_110_LINKS - count))
9116 (( create > 40000 )) && create=40000
9117 touch $target || error "creating $target failed"
9118 echo "creating $create hard links to $target"
9119 createmany -l $target $long $create &
9122 count=$((count + create))
9123 group=$((group + 1))
9125 echo "waiting for PIDs$pids to complete"
9126 wait $pids || error "createmany failed after $group groups"
9128 umount_client $MOUNT2 -f
9131 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
9132 MDSCOUNT=$old_mdscount
9133 OSTCOUNT=$old_ostcount
9135 run_test 110 "Adding large_dir with 3-level htree"
9138 [[ "$mds1_FSTYPE" != ldiskfs ]] &&
9139 skip "Only applicable to ldiskfs-based MDTs"
9141 is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
9142 skip "This test can not be executed on flakey dev"
9144 do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
9145 skip "large_dir option is not supported on MDS"
9147 do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
9148 skip "large_dir option is not supported on OSS"
9150 # cleanup before changing target counts
9152 local old_mdscount=$MDSCOUNT
9153 local old_ostcount=$OSTCOUNT
9154 local old_mdssize=$MDSSIZE
9156 stack_trap "MDSSIZE=$old_mdssize MDSCOUNT=$old_mdscount \
9157 OSTCOUNT=$old_ostcount; reformat"
9160 (( MDSSIZE < 2400000 )) && MDSSIZE=2400000 # need at least 2.4GB
9162 local mdsdev=$(mdsdevname 1)
9163 combined_mgs_mds || replace=" --replace "
9164 local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
9165 $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
9166 if [[ $opts != *large_dir* ]]; then
9167 if [[ $opts != *mkfsoptions* ]]; then
9168 opts+=" --mkfsoptions=\\\"-O large_dir -i 1048576 \\\" "
9170 opts="${opts//--mkfsoptions=\\\"/ \
9171 --mkfsoptions=\\\"-O large_dir -i 1048576 }"
9174 echo "MDT params: $opts"
9176 combined_mgs_mds || start_mgs
9177 __touch_device mds 1
9178 add mds1 $opts || error "add mds1 failed with new params"
9179 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
9181 opts="$(mkfs_opts ost1 $(ostdevname 1)) \
9182 $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
9183 if [[ $opts != *large_dir* ]]; then
9184 if [[ $opts != *mkfsoptions* ]]; then
9185 opts+=" --mkfsoptions=\\\"-O large_dir \\\""
9187 opts="${opts//--mkfsoptions=\\\"/ --mkfsoptions=\\\"-O large_dir }"
9190 echo "OST params: $opts"
9191 __touch_device ost 1
9192 add ost1 $opts || error "add ost1 failed with new params"
9193 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
9195 MOUNT_2=yes mountcli
9196 mkdir $DIR/$tdir || error "cannot create $DIR/$tdir"
9198 lfs df -i $DIR/$tdir
9202 local start=$SECONDS
9204 local dirmax=$((2 << 30))
9210 while (( !needskip & dirsize < dirmax )); do
9213 for cli in ${CLIENTS//,/ }; do
9214 local len=$((253 - $(wc -c <<<"$cli-$group-60000-")))
9215 local target=$cli-$group
9216 local long=$DIR/$tdir/$target-$(generate_name $len)-
9218 RPWD=$DIR/$tdir do_node $cli touch $target ||
9219 error "creating $target failed"
9220 echo "creating 60000 hardlinks to $target"
9221 RPWD=$DIR/$tdir do_node $cli createmany -l $target $long 60000 &
9224 group=$((group + 1))
9226 long=$DIR2/$tdir/$target-$(generate_name $len)-
9228 RPWD=$DIR2/$tdir do_node $cli touch $target ||
9229 error "creating $target failed"
9230 echo "creating 60000 hardlinks to $target"
9231 RPWD=$DIR2/$tdir do_node $cli createmany -l $target $long 60000 &
9234 group=$((group + 1))
9236 echo "waiting for PIDs$pids to complete"
9237 wait $pids || error "createmany failed after $group groups"
9238 dirsize=$(stat -c %s $DIR/$tdir)
9239 taken=$((SECONDS - start))
9240 rate=$((dirsize / taken))
9241 left=$(((dirmax - dirsize) / rate))
9242 num=$((group * 60000))
9243 echo "estimate ${left}s left after $num files / ${taken}s"
9244 # if the estimated time remaining is too large (it may change
9245 # over time as the create rate is not constant) then exit
9246 # without declaring a failure.
9247 (( left > 1200 )) && needskip=1
9250 umount_client $MOUNT2 -f
9253 ! (( $needskip )) ||
9254 echo "ETA ${left}s after $num files / ${taken}s is too long"
9256 run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
9257 MDSCOUNT=$old_mdscount
9258 OSTCOUNT=$old_ostcount
9259 MDSSIZE=$old_mdssize
9261 run_test 111 "Adding large_dir with over 2GB directory"
9264 local param="no_create"
9266 (( $OST1_VERSION > $(version_code 2.14.0) )) ||
9267 skip "need OSS at least 2.14.0"
9268 (( $OST1_VERSION >= $(version_code 2.15.56.125) )) ||
9269 param="no_precreate"
9271 start_mds || error "MDS start failed"
9272 start_ost || error "OSS start failed"
9273 echo "start ost2 service on $(facet_active_host ost2)"
9274 start ost2 $(ostdevname 2) $(csa_add "$OST_MOUNT_OPTS" -o $param) ||
9275 error "start ost2 facet failed"
9276 local val=$(do_facet ost2 \
9277 "$LCTL get_param -n obdfilter.$FSNAME-OST0001*.$param")
9278 (( $val == 1 )) || error "obdfilter.$FSNAME-OST0001*.$param=$val"
9280 mount_client $MOUNT || error "mount client failed"
9281 wait_osc_import_state mds1 ost1 FULL
9282 wait_osc_import_ready client ost1
9283 wait_osc_import_ready client ost2
9285 $LFS setstripe -i 0 $DIR/$tfile.0 ||
9286 error "problem creating $tfile.0 on OST0000"
9287 $LFS setstripe -i 1 $DIR/$tfile.1 && $LFS getstripe $DIR/$tfile.1 &&
9288 (( $($LFS getstripe -i $DIR/$tfile.1) == 1 )) &&
9289 error "allowed to create $tfile.1 on OST0001"
9291 $LFS df -v $MOUNT | grep -q "OST:1.*N" ||
9292 error "NOCREATE not in 'lfs df'"
9294 do_facet ost2 $LCTL set_param obdfilter.$FSNAME-OST0001*.$param=0
9296 $LFS setstripe -i 1 $DIR/$tfile.2 ||
9297 error "failed to create $tfile.2 on ost1 facet"
9298 # files not cleaned with ONLY_REPEAT because of client unmount below
9299 rm -f $DIR/$tfile.[012]
9300 stop_ost2 || error "stop ost2 facet failed"
9303 run_test 112a "mount OST with no_create option"
9306 (( MDSCOUNT >= 2 )) || skip "need at least 2 MDTs"
9307 (( $MDS1_VERSION >= $(version_code 2.15.56.125) )) ||
9308 skip "need MDS >= 2.15.56.125"
9309 local mdsnum=$MDSCOUNT
9310 local facet=mds$mdsnum
9311 local mdtidx=$((mdsnum - 1))
9312 local mdtname=$FSNAME-MDT$(printf %04x $mdtidx)
9314 start_mds --mdscount $((mdsnum - 1)) || error "MDS start failed"
9315 start_mdt $mdsnum -o no_create || error "start $facet failed"
9316 local val=$(do_facet $facet \
9317 "$LCTL get_param -n mdt.$mdtname*.no_create")
9318 (( $val == 1 )) || error "mdt.$mdtname*.no_create=$val"
9319 start_ost || error "ost1 start failed"
9320 start_ost2 || error "ost1 start failed"
9322 mount_client $MOUNT || error "mount client failed"
9323 wait_osc_import_ready $facet ost2
9326 $LFS df -v $MOUNT | grep -q "MDT:$mdtidx.*N" ||
9327 error "NOCREATE not in 'lfs df'"
9329 $LFS mkdir -i $mdtidx $DIR/$tdir ||
9330 $LFS setdirstripe -D -c 1 -i -1 --max-inherit-rr 2 $DIR/$tdir ||
9331 error "error creating $tdir on $mdtname"
9332 stack_trap "rm -rf $DIR/$tdir"
9334 mkdir $DIR/$tdir/d1.{1..100} || error "mkdir $tdir/d1.{1..100} failed"
9335 $LFS getdirstripe -i $DIR/$tdir/d1.* | sort | uniq -c
9336 do_facet $facet $LCTL set_param mdt.$mdtname*.no_create=0
9337 # allow one initial create for delayed statfs on client
9338 (( $($LFS getdirstripe -i $DIR/$tdir/d1.* | grep -c $mdtidx) < 2 )) ||
9339 error "allowed create on $mdtname"
9342 mkdir $DIR/$tdir/d2.{1..100} || error "mkdir $tdir/d2.{1..100} failed"
9343 $LFS getdirstripe -i $DIR/$tdir/d2.{1..100} | sort | uniq -c
9344 (( $($LFS getdirstripe -i $DIR/$tdir/d2.* | grep -c $mdtidx) > 10 )) ||
9345 error "no create on $mdtname"
9346 # files not cleaned with ONLY_REPEAT because of client unmount below
9348 stop_ost2 || error "ost1 start failed"
9351 run_test 112b "mount MDT with no_create option"
9354 SAVE_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
9355 SAVE_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
9356 SAVE_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
9362 MGS_MOUNT_OPTS=$SAVE_MGS_MOUNT_OPTS
9363 MDS_MOUNT_OPTS=$SAVE_MDS_MOUNT_OPTS
9364 OST_MOUNT_OPTS=$SAVE_OST_MOUNT_OPTS
9365 # Revert old mount options back
9367 # Subsequent following test requires
9368 # conf-sanity to be in stopall state.
9369 # Force 'stopall' so others following
9374 # Error out with mount info
9376 local server_nodes=$(comma_list $(mdts_nodes) $(osts_nodes))
9379 echo "--Client Mount Info--"
9380 mount | grep -i lustre
9381 echo "--Server Mount Info--"
9382 do_nodes $server_nodes mount | grep -i lustre
9388 local ost_version="2.15.51" # Minimum version required
9390 (( OST1_VERSION >= $(version_code $ost_version) )) ||
9391 skip "Need server version at least $ost_version"
9393 stack_trap cleanup_113 EXIT
9395 # Reset before starting
9399 # Verify MDS's should start with "rw"
9400 do_facet $SINGLEMDS mount | grep "lustre.*rw,.*MDT" ||
9401 error_113 "$SINGLEMDS should be read-write"
9403 # Verify OST's should start with "rw"
9404 for (( i=1; i <= OSTCOUNT; i++ )); do
9405 do_facet ost$i mount | grep "lustre.*rw,.*OST" ||
9406 error_113 "ost$i should be read-write"
9409 # rdonly_dev does not currently work for ldiskfs
9410 # We skip the rdonly_dev check until then.
9411 if [[ $ost1_FSTYPE == ldiskfs ]]; then
9412 echo "Shadow Mountpoint correctly reports rw for ldiskfs"
9417 # Only ZFS specific tests below.
9420 # Must stop all (server+client) and restart to verify new
9424 # add rdonly_dev to mount option
9425 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
9426 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
9427 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
9429 # Only restart server(mds/ost). Sufficient for test
9430 setupall server_only || error "Fail to start servers"
9432 # Verify MDS's should be "ro"
9433 do_facet $SINGLEMDS mount | grep "lustre.*ro,.*MDT.*rdonly_dev" ||
9434 error_113 "$SINGLEMDS should be read-only"
9436 # Verify OST's should be "ro"
9437 for (( i=1; i <= OSTCOUNT; i++ )); do
9438 do_facet ost$i mount | grep "lustre.*ro,.*OST.*rdonly_dev" ||
9439 error_113 "ost$i should be read-only"
9442 run_test 113 "Shadow mountpoint correctly report ro/rw for mounts"
9445 # Purpose: To verify dynamic thread (OSS) creation.
9446 # (This was sanity/115)
9449 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9450 remote_ost_nodsh && skip "remote OST with nodsh"
9452 # Lustre does not stop service threads once they are started.
9453 # Reset number of running threads to default.
9458 local save_params="$TMP/sanity-$TESTNAME.parameters"
9460 # Get ll_ost_io count before I/O
9461 OSTIO_pre=$(do_facet ost1 \
9462 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
9463 # Exit if lustre is not running (ll_ost_io not running).
9464 [ -z "$OSTIO_pre" ] && error "no OSS threads"
9466 echo "Starting with $OSTIO_pre threads"
9467 local thread_max=$((OSTIO_pre * 2))
9468 local rpc_in_flight=$((thread_max * 2))
9470 # this is limited to OSC_MAX_RIF_MAX (256)
9471 [ $rpc_in_flight -gt 256 ] && rpc_in_flight=256
9472 thread_max=$((rpc_in_flight / 2))
9473 [ $thread_max -le $OSTIO_pre ] && skip "Too many ost_io threads" &&
9476 # Number of I/O Process proposed to be started.
9478 local facets=$(get_facets OST)
9480 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
9481 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
9483 # Set in_flight to $rpc_in_flight
9484 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
9485 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
9486 nfiles=${rpc_in_flight}
9487 # Set ost thread_max to $thread_max
9488 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
9490 # 5 Minutes should be sufficient for max number of OSS
9491 # threads(thread_max) to be created.
9495 local wtl=${WTL:-"$LUSTRE/tests/write_time_limit"}
9497 test_mkdir $DIR/$tdir
9498 for ((i = 1; i <= nfiles; i++)); do
9499 local file=$DIR/$tdir/${tfile}-$i
9501 $LFS setstripe -c -1 -i 0 $file
9502 ($wtl $file $timeout)&
9505 # I/O Started - Wait for thread_started to reach thread_max or report
9506 # error if thread_started is more than thread_max.
9507 echo "Waiting for thread_started to reach thread_max"
9508 local thread_started=0
9509 local end_time=$((SECONDS + timeout))
9511 while [ $SECONDS -le $end_time ] ; do
9513 # Get ost i/o thread_started count.
9514 thread_started=$(do_facet ost1 \
9516 ost.OSS.ost_io.threads_started | cut -d= -f2")
9517 # Break out if thread_started is equal/greater than thread_max
9518 if (( $thread_started >= $thread_max )); then
9519 echo ll_ost_io thread_started $thread_started, \
9520 equal/greater than thread_max $thread_max
9526 # Cleanup - We have the numbers, Kill i/o jobs if running.
9527 jobcount=($(jobs -p))
9529 for ((i=0; i < ${#jobcount[*]}; i++)); do
9530 kill -9 ${jobcount[$i]}
9531 if [ $? -ne 0 ] ; then
9532 echo "warning: cannot kill WTL pid ${jobcount[$i]}"
9536 # Cleanup files left by WTL binary.
9537 for ((i = 1; i <= nfiles; i++)); do
9538 local file=$DIR/$tdir/${tfile}-$i
9541 if [ $? -ne 0 ] ; then
9542 echo "Warning: Failed to delete file $file"
9546 restore_lustre_params <$save_params
9547 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
9549 # Error out if no new thread has started or Thread started is greater
9551 if (( $thread_started <= $OSTIO_pre ||
9552 $thread_started > $thread_max )); then
9553 error "ll_ost_io: thread_started $thread_started" \
9554 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
9555 "No new thread started or thread started greater " \
9559 run_test 114 "verify dynamic thread creation===================="
9565 do_facet mds1 rm -f $1
9569 if [ "$mds1_FSTYPE" != ldiskfs ]; then
9570 skip "Only applicable to ldiskfs-based MDTs"
9572 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
9574 local dbfs_ver=$(do_facet mds1 $DEBUGFS -V 2>&1)
9576 echo "debugfs version: $dbfs_ver"
9577 echo "$dbfs_ver" | egrep -w "1.44.3.wc1|1.44.5.wc1|1.45.2.wc1" &&
9578 skip_env "This version of debugfs doesn't show inode number"
9580 local IMAGESIZE=$((3072 << 30)) # 3072 GiB
9590 do_facet mds1 "hostname; $LCTL dl; mount"
9592 do_facet ost1 "hostname; $LCTL dl; mount"
9593 # We need MDT size 3072GB, because it is smallest
9594 # partition that can store 2B inodes
9595 do_facet mds1 "mkdir -p $TMP/$tdir"
9596 local mdsimgname=$TMP/$tdir/lustre-mdt
9598 do_facet mds1 "rm -f $mdsimgname"
9599 do_facet mds1 "touch $mdsimgname"
9600 stack_trap "cleanup_115 $mdsimgname" EXIT
9601 do_facet mds1 "$TRUNCATE $mdsimgname $IMAGESIZE" ||
9602 skip "Backend FS doesn't support sparse files"
9603 local mdsdev=$(do_facet mds1 "losetup -f")
9605 do_facet mds1 "losetup $mdsdev $mdsimgname"
9607 local mds_opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
9608 --mkfsoptions='-O ea_inode,^resize_inode,meta_bg \
9609 -N 2247484000 -E lazy_itable_init' --device-size=$IMAGESIZE"
9610 add mds1 $mds_opts --mgs --reformat $mdsdev || {
9611 do_facet $SINGLEMDS \
9612 "losetup -d $mdsdev && rm -f $mdsimgname"
9613 skip_env "format large MDT failed"
9616 local ostdev=$(ostdevname 1)
9618 local opts="$(mkfs_opts ost1 $ostdev) \
9619 --reformat $ostdev $ostdev"
9620 add ost1 $opts || error "add ost1 failed with new params"
9621 start mds1 $mdsdev $MDS_MOUNT_OPTS || error "start MDS failed"
9622 start_ost || error "start OSS failed"
9623 mount_client $MOUNT || error "mount client failed"
9625 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir fail"
9626 local goal="/sys/fs/ldiskfs/$(basename $mdsdev)/inode_goal"
9628 # 2147483648 is 0x80000000
9629 do_facet mds1 "echo 2147483648 >> $goal; grep . $goal"
9630 touch $DIR/$tdir/$tfile
9632 # attrs from 1 to 16 go to block, 17th - to inode
9635 for i in {1..17}; do
9636 local nm="trusted.ea$i"
9637 setfattr -n $nm -v $(printf "xattr%0250d" $i) $DIR/$tdir/$tfile
9640 do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsdev"
9642 # inode <2147483649> trusted.ea16 (255)
9643 local inode_num=$(do_facet mds1 \
9644 "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsdev" |
9645 awk '/ea17/ { print $2 }' |
9646 sed -e 's/>//' -e 's/<//' -e 's/\"//')
9647 echo "inode num: $inode_num"
9648 [ $inode_num -ge 2147483648 ] || error "inode $inode_num too small"
9649 do_facet mds1 "losetup -d $mdsdev"
9651 run_test 115 "Access large xattr with inodes number over 2TB"
9654 [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
9655 [ "$MDS1_VERSION" -lt $(version_code 2.10.59) ] &&
9656 skip "Need server version at least 2.10.59"
9657 do_facet $SINGLEMDS which mkfs.xfs ||
9658 skip_env "No mkfs.xfs installed"
9663 local tmpmnt=$TMP/$tdir
9664 local mdtimg=$tfile-mdt0
9666 do_facet $SINGLEMDS mkdir -p $tmpmnt
9667 stack_trap "do_facet $SINGLEMDS rmdir $tmpmnt" EXIT
9669 do_facet $SINGLEMDS touch $TMP/$mdtimg
9670 stack_trap "do_facet $SINGLEMDS rm -f $TMP/$mdtimg" EXIT
9671 do_facet $SINGLEMDS mkfs -t xfs -d file,size=1t,name=$TMP/$mdtimg ||
9672 error "mkfs temporary xfs image"
9674 do_facet $SINGLEMDS mount $TMP/$mdtimg $tmpmnt ||
9675 error "mount temporary xfs image"
9676 stack_trap "do_facet $SINGLEMDS umount $tmpmnt" EXIT
9677 local old_mdssize=$MDSSIZE
9678 local old_mdsisize=$MDSISIZE
9680 MDSSIZE=$((17 * 1024 * 1024 * 1024)) # 17T MDT
9681 MDSISIZE=$((16 << 20))
9682 local opts17t="$(mkfs_opts $SINGLEMDS)"
9684 MDSSIZE=$old_mdssize
9685 MDSISIZE=$old_mdsisize
9687 do_facet $SINGLEMDS $MKFS \
9688 ${opts17t/-E /-E lazy_itable_init,lazy_journal_init,} \
9690 error "failed to mkfs for $tmpmnt/$mdtimg"
9692 do_facet $SINGLEMDS $TUNE2FS -l $tmpmnt/$mdtimg |
9693 grep -qw 'features.*extent' || error "extent should be enabled"
9696 run_test 116 "big size MDT support"
9699 # Call setup only if LustreFS is not mounted
9700 check_mount || setup
9702 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.nrs_policies=fifo"
9703 do_facet ost1 "$LCTL get_param -n ost.OSS.ost_io.nrs_tbf_rule" &&
9704 error "get_param should fail"
9705 cleanup || error "cleanup failed with rc $?"
9707 run_test 117 "lctl get_param return errors properly"
9713 [[ "$MDSCOUNT" -ge 2 ]] || skip "Need more at least 2 MDTs"
9715 had_config=$(do_facet mds1 "$LCTL get_param debug | grep config")
9716 do_facet mds1 "$LCTL set_param debug=+config"
9717 do_facet mds1 "$LCTL clear"
9720 do_facet mds2 "$TUNEFS --writeconf $(mdsdevname 2)" &>/dev/null
9721 # mount after writeconf will make "add osp" added to mdt0 config:
9722 # 53 (224)marker 60 (flags=0x01, v2.5.1.0) lustre-MDT0001 'add osp'
9723 # 54 (080)add_uuid nid=... 0: 1:...
9724 # 55 (144)attach 0:lustre-MDT0001-osp-MDT0000 1:osp 2:...
9725 # 56 (144)setup 0:lustre-MDT0001-osp-MDT0000 1:... 2:...
9726 # 57 (136)modify_mdc_tgts add 0:lustre-MDT0000-mdtlov 1:... 2:1 3:1
9727 # duplicate modify_mdc_tgts caused crashes
9730 # using larger debug_mb size to avoid lctl dk log truncation
9731 size_mb=$((DEBUG_SIZE_SAVED * 4))
9734 # though config processing stops after failed attach and setup
9735 # it will proceed after the failed command after each writeconf
9736 # this is the original scenario of the issue
9737 do_facet mds2 "$TUNEFS --writeconf $(mdsdevname 2)" &>/dev/null
9738 do_facet mds1 "$LCTL set_param debug_mb=$size_mb"
9741 wait_update_facet_cond mds1 \
9742 "$LCTL dk | grep -c Processed.log.$FSNAME-MDT0000" \
9747 [[ -z "$had_config" ]] && do_facet mds1 lctl set_param debug=-config
9751 run_test 119 "writeconf on slave mdt shouldn't duplicate mdc/osp and crash"
9753 test_120() { # LU-11130
9754 [ "$MDSCOUNT" -lt 2 ] && skip "mdt count < 2"
9755 [ "$mds1_FSTYPE" != ldiskfs ] &&
9756 skip "ldiskfs only test"
9757 [ "$MDS1_VERSION" -lt $(version_code 2.11.56) ] &&
9758 skip "Need DNE2 capable MD target with LU-11130 fix"
9762 local mds1host=$(facet_active_host mds1)
9763 local mds1dev=$(mdsdevname 1)
9765 $LFS mkdir -i 1 $DIR/$tdir
9766 $LFS mkdir -i 0 $DIR/$tdir/mds1dir
9768 ln -s foo $DIR/$tdir/bar
9769 mv $DIR/$tdir/bar $DIR/$tdir/mds1dir/bar2 ||
9770 error "cross-target rename failed"
9774 run_e2fsck $mds1host $mds1dev "-n"
9776 run_test 120 "cross-target rename should not create bad symlinks"
9780 start_mgsmds || error "MGS MDS Start failed"
9782 stop_mds || error "Stopping MDSes failed"
9786 stop_mds || error "Stopping MDSes failed"
9788 run_test 121 "failover MGS"
9791 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
9792 [[ "$OST1_VERSION" -ge $(version_code 2.11.53) ]] ||
9793 skip "Need OST version at least 2.11.53"
9796 LOAD_MODULES_REMOTE=true load_modules
9797 #define OBD_FAIL_OFD_SET_OID 0x1e0
9798 do_facet ost1 $LCTL set_param fail_loc=0x00001e0
9801 $LFS mkdir -i1 -c1 $DIR/$tdir
9802 $LFS setstripe -i0 -c1 $DIR/$tdir
9803 do_facet ost1 $LCTL set_param fail_loc=0
9804 createmany -o $DIR/$tdir/file_ 1000 ||
9805 error "Fail to create a new sequence"
9809 run_test 122a "Check OST sequence update"
9812 remote_mgs_nodsh && skip "remote MGS with nodsh"
9813 [ -d $MOUNT/.lustre ] || setup
9815 # test old logid format until removal from llog_ioctl.c::str2logid()
9816 if (( $MGS_VERSION < $(version_code 2.99.53) )); then
9817 do_facet mgs $LCTL dl | grep MGS
9818 do_facet mgs "$LCTL --device %MGS llog_print \
9819 \\\\\\\$$FSNAME-client 1 10" ||
9820 error "old llog_print failed"
9823 # test new logid format
9824 if [ $MGS_VERSION -ge $(version_code 2.9.53) ]; then
9825 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
9826 error "new llog_print failed"
9829 run_test 123aa "llog_print works with FIDs and simple names"
9832 remote_mgs_nodsh && skip "remote MGS with nodsh"
9833 [[ $MGS_VERSION -gt $(version_code 2.11.51) ]] ||
9834 skip "Need server with working llog_print support"
9836 [ -d $MOUNT/.lustre ] || setup
9842 [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
9843 mgs_arg="--device MGS"
9845 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
9846 do_facet mgs $LCTL set_param -P jobid_name="TESTNAME"
9848 yaml=$(do_facet mgs $LCTL $mgs_arg llog_print params |
9849 grep jobid_name | tail -n 1)
9851 local param=$(awk '{ print $10 }' <<< "$yaml")
9852 local val=$(awk '{ print $12 }' <<< "$yaml")
9853 #return to the default
9854 do_facet mgs $LCTL set_param -P jobid_name=$orig_val
9855 [ $val = "TESTNAME" ] || error "bad value: $val"
9856 [ $param = "jobid_name," ] || error "Bad param: $param"
9858 run_test 123ab "llog_print params output values from set_param -P"
9860 test_123ac() { # LU-11566
9861 remote_mgs_nodsh && skip "remote MGS with nodsh"
9862 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
9863 skip "Need 'lctl llog_print --start' on MGS"
9869 [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
9870 mgs_arg="--device MGS"
9872 [ -d $MOUNT/.lustre ] || setup
9874 # - { index: 10, event: add_uuid, nid: 192.168.20.1@tcp(0x20000c0a81401,
9875 # node: 192.168.20.1@tcp }
9876 do_facet mgs $LCTL $mgs_arg \
9877 llog_print --start $start --end $end $FSNAME-client | tr -d , |
9878 while read DASH BRACE INDEX idx EVENT BLAH BLAH BLAH; do
9879 (( idx >= start )) || error "llog_print index $idx < $start"
9880 (( idx <= end )) || error "llog_print index $idx > $end"
9883 run_test 123ac "llog_print with --start and --end"
9885 test_123ad() { # LU-11566
9886 remote_mgs_nodsh && skip "remote MGS with nodsh"
9887 # older versions of lctl may not print all records properly
9888 do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
9889 skip "Need 'lctl llog_print --start' on MGS"
9891 [ -d $MOUNT/.lustre ] || setup
9893 # append a new record, to avoid issues if last record was cancelled
9894 local old=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
9895 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$old
9897 # logid: [0x3:0xa:0x0]:0
9901 local num=$(do_facet mgs $LCTL --device MGS llog_info $FSNAME-client |
9902 awk '/last_index:/ { print $2 - 1 }')
9904 # - { index: 71, event: set_timeout, num: 0x14, param: sys.timeout=20 }
9905 local last=$(do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
9906 tail -1 | awk '{ print $4 }' | tr -d , )
9907 (( last == num )) || error "llog_print only showed $last/$num records"
9909 run_test 123ad "llog_print shows all records"
9911 test_123ae() { # LU-11566
9919 remote_mgs_nodsh && skip "remote MGS with nodsh"
9920 [ -d $MOUNT/.lustre ] || setupall
9922 max=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
9923 pgs=$($LCTL get_param -n osc.*-OST0000-*.max_pages_per_rpc | head -1)
9924 [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
9925 mgs_arg="--device MGS"
9927 if do_facet mgs "$LCTL help llog_cancel" 2>&1| grep -q -- --log_id; then
9928 # save one set_param -P record in case none exist
9930 do_facet mgs $LCTL set_param -P osc.*.max_pages_per_rpc=$pgs
9931 stack_trap "do_facet mgs $LCTL set_param -P -d \
9932 osc.*.max_pages_per_rpc"
9935 orig=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
9936 tail -1 | awk '{ print $4 }' | tr -d , )
9937 do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
9938 do_facet mgs $LCTL $mgs_arg llog_print $log | tail -1 |
9939 grep "parameter: osc.*.max_dirty_mb" ||
9940 error "new set_param -P wasn't stored in params log"
9942 # - { index: 71, event: set_param, device: general,
9943 # param: osc.*.max_dirty_mb, value: 256 }
9944 id=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
9945 tail -1 | awk '{ print $4 }' | tr -d , )
9946 do_facet mgs $LCTL $mgs_arg llog_cancel $log --log_idx=$id
9947 local new=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
9948 tail -1 | awk '{ print $4 }' | tr -d , )
9949 (( new == orig )) ||
9950 error "new llog_cancel now $new, not at $orig records"
9953 # test old positional parameters for a while still
9954 if [ "$MGS_VERSION" -le $(version_code 3.1.53) ]; then
9957 do_facet mgs $LCTL conf_param \
9958 $FSNAME-OST0000.osc.max_pages_per_rpc=$pgs
9959 stack_trap "do_facet mgs $LCTL conf_param -d \
9960 $FSNAME-OST0000.osc.max_pages_per_rpc"
9962 orig=$(do_facet mgs $LCTL --device MGS llog_print $log |
9963 tail -1 | awk '{ print $4 }' | tr -d , )
9964 do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$max
9965 do_facet mgs $LCTL --device MGS llog_print $log |
9966 tail -1 | grep "parameter: osc.max_dirty_mb" ||
9967 error "old conf_param wasn't stored in params log"
9968 do_facet mgs $LCTL --device MGS llog_print $log
9969 # - { index: 71, event: conf_param, device: testfs-OST0000-osc,
9970 # param: osc.max_dirty_mb=256 }
9971 id=$(do_facet mgs $LCTL --device MGS llog_print $log |
9972 tail -1 | awk '{ print $4 }' | tr -d , )
9973 do_facet mgs $LCTL --device MGS llog_cancel $log $id
9974 do_facet mgs $LCTL --device MGS llog_print $log
9975 new=$(do_facet mgs $LCTL --device MGS llog_print $log |
9976 tail -1 | awk '{ print $4 }' | tr -d , )
9977 (( new == orig )) ||
9978 error "old llog_cancel now $new, not at $orig records"
9981 run_test 123ae "llog_cancel can cancel requested record"
9983 test_123af() { #LU-13609
9984 [ "$MGS_VERSION" -ge $(version_code 2.13.54) -a \
9985 "$MDS1_VERSION" -ge $(version_code 2.13.54) ] ||
9986 skip "Need both MGS and MDS version at least 2.13.54"
9988 [ -d $MOUNT/.lustre ] || setupall
9989 stack_trap "do_facet mds1 $LCTL set_param fail_loc=0" EXIT
9999 for device in "MGS" "$FSNAME-MDT0000"; do
10000 cmd="--device $device llog_catlist"
10001 echo "lctl $cmd ..."
10002 if [ "$device" = "MGS" ]; then
10007 orig_clist=($(do_facet $facet $LCTL $cmd | awk '{ print $2 }'))
10008 orig_count=${#orig_clist[@]}
10009 echo "orig_clist: ${orig_clist[*]}"
10011 #define OBD_FAIL_CATLIST 0x131b
10012 #fetch to llog records from the second one
10013 do_facet $facet $LCTL set_param fail_loc=0x131b fail_val=2
10015 new_clist=($(do_facet $facet $LCTL $cmd | awk '{ print $2 }'))
10016 new_count=${#new_clist[@]}
10017 echo "new_clist: ${new_clist[*]}"
10019 [ $new_count -eq $((orig_count - 1)) ] ||
10020 error "$new_count != $orig_count - 1"
10021 for i in $(seq 0 $new_count); do
10023 [ "${orig_clist[$j]}" = "${new_clist[$i]}" ] ||
10024 error "${orig_clist[$j]} != ${new_clist[$i]}"
10026 do_facet mds1 $LCTL set_param fail_loc=0
10030 run_test 123af "llog_catlist can show all config files correctly"
10032 test_123ag() { # LU-15142
10036 remote_mgs_nodsh && skip "remote MGS with nodsh"
10037 (( $MGS_VERSION >= $(version_code 2.14.55) )) ||
10038 skip "Need server version least 2.14.55"
10040 [ -d $MOUNT/.lustre ] || setup
10042 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
10043 stack_trap "do_facet mgs $LCTL set_param -P jobid_name=$orig_val"
10045 do_facet mgs $LCTL set_param -P jobid_name="TESTNAME1"
10046 do_facet mgs $LCTL set_param -P -d jobid_name
10047 rec=$(do_facet mgs $LCTL --device MGS llog_print params |
10048 grep -c jobid_name)
10049 (( rec == 0 )) || error "parameter was not deleted, check #1"
10050 do_facet mgs $LCTL set_param -P jobid_name="TESTNAME1"
10051 rec=$(do_facet mgs $LCTL --device MGS llog_print params |
10052 grep -c jobid_name)
10053 (( rec == 1)) || error "parameter is not set"
10054 # usage with ordinary set_param format works too
10055 do_facet mgs $LCTL set_param -P -d jobid_name="ANY"
10056 rec=$(do_facet mgs $LCTL --device MGS llog_print params |
10057 grep -c jobid_name)
10058 (( rec == 0 )) || error "parameter was not deleted, check #2"
10060 run_test 123ag "llog_print skips values deleted by set_param -P -d"
10062 test_123ah() { #LU-7668 del_ost
10063 (( "$MGS_VERSION" >= $(version_code 2.15.51) &&
10064 "$MDS1_VERSION" >= $(version_code 2.15.51) )) ||
10065 skip "Need MGS/MDS version >= 2.15.51 for del_ost"
10067 [ -d $MOUNT/.lustre ] || setupall
10068 stack_trap "do_facet mds1 $LCTL set_param fail_loc=0" EXIT
10070 local cmd="--device MGS llog_print"
10072 cli_llogcnt_orig=$(do_facet mgs $LCTL $cmd $FSNAME-client |
10073 grep -c $FSNAME-OST0000)
10074 mds1_llogcnt_orig=$(do_facet mgs $LCTL $cmd $FSNAME-MDT0000 |
10075 grep -c $FSNAME-OST0000)
10077 [ $cli_llogcnt_orig -gt 0 ] ||
10078 error "$FSNAME-OST0000 not found (client)"
10079 [ $mds1_llogcnt_orig -gt 0 ] || error "$FSNAME-OST0000 not found (MDT)"
10081 # -n/--dryrun should NOT modify catalog
10082 do_facet mgs "$LCTL del_ost -n -t $FSNAME-OST0000" ||
10083 error "del_ost --dryrun failed with $?"
10085 local cli_llogcnt=$(do_facet mgs $LCTL $cmd $FSNAME-client |
10086 grep -c $FSNAME-OST0000)
10087 local mds1_llogcnt=$(do_facet mgs $LCTL $cmd $FSNAME-MDT0000 |
10088 grep -c $FSNAME-OST0000)
10090 [ $cli_llogcnt -eq $cli_llogcnt_orig ] ||
10091 error "--dryrun error: $cli_llogcnt != $cli_llogcnt_orig"
10092 [ $mds1_llogcnt -eq $mds1_llogcnt_orig ] ||
10093 error "--dryrun error: $mds1_llogcnt != $mds1_llogcnt_orig"
10096 do_facet mgs "$LCTL del_ost --target $FSNAME-OST0000" ||
10097 error "del_ost failed with $?"
10099 local cli_llogcnt=$(do_facet mgs $LCTL $cmd $FSNAME-client |
10100 grep -c $FSNAME-OST0000)
10101 local mds1_llogcnt=$(do_facet mgs $LCTL $cmd $FSNAME-MDT0000 |
10102 grep -c $FSNAME-OST0000)
10104 # every catalog entry for OST0000 should have been cancelled
10105 [ $cli_llogcnt -eq 0 ] || error "$FSNAME-OST0000 not cancelled (cli)"
10106 [ $mds1_llogcnt -eq 0 ] || error "$FSNAME-OST0000 not cancelled (MDT)"
10108 umount_client $MOUNT
10109 mount_client $MOUNT
10111 $LFS df | grep -q OST0000 && error "del_ost did not remove OST0000!"
10113 reformat_and_config
10115 run_test 123ah "del_ost cancels config log entries correctly"
10120 echo "cleanup test 123ai"
10122 # cancel last timeout record
10123 do_facet mgs "$LCTL set_param -P -d timeout"
10125 # restore timeout value
10126 do_nodes $(comma_list $(all_nodes)) "$LCTL set_param timeout=$timeout"
10129 test_123ai() { #LU-16167
10135 remote_mgs_nodsh && skip "remote MGS with nodsh"
10136 (( MDS1_VERSION >= $(version_code 2.15.51) )) ||
10137 skip "Need MDS version at least 2.15.51"
10139 [ -d $MOUNT/.lustre ] || setup
10141 old_count=$(do_facet mgs "$LCTL --device MGS llog_print -r params" |
10142 grep -c "parameter: timeout")
10144 old_timeout=$($LCTL get_param -n timeout)
10145 stack_trap "cleanup_123ai $old_timeout" EXIT
10147 # add and cancel params (2 * MAX_IOC_BUFLEN / 128 + 1 = 129)
10148 for i in {1..129}; do
10149 do_facet mgs "$LCTL set_param -P timeout=$i" ||
10150 error "fail to set timeout=$i on MGS"
10153 count=$(do_facet mgs "$LCTL --device MGS llog_print -r params" |
10154 grep -c "parameter: timeout")
10156 ((count - old_count == 129)) ||
10157 error "number timeout record missmatch ($count - $old_count != 129)"
10159 do_facet mgs "$LCTL --device MGS llog_print params" |
10160 tail -1 | grep "timeout, value: 129" ||
10161 error "llog_print could not display the last record (timeout=129)"
10164 run_test 123ai "llog_print display all non skipped records"
10167 remote_mgs_nodsh && skip "remote MGS with nodsh"
10169 [ -d $MOUNT/.lustre ] || setup
10170 yaml_file="$TMP/$tfile.yaml"
10172 do_facet mgs rm "$yaml_file"
10173 cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist" |
10174 sed 's/config_log://')
10176 # set jobid_var to a different value for test
10177 orig_val=$(do_facet mgs $LCTL get_param jobid_var)
10179 do_facet mgs $LCTL set_param -P jobid_var="TESTNAME"
10181 for i in $cfgfiles params; do
10182 do_facet mgs "lctl --device MGS llog_print ${i} >> $yaml_file"
10185 echo "Unmounting FS"
10193 test_123_restore() {
10194 set_val=$(do_facet mgs $LCTL get_param jobid_var)
10196 do_facet mgs $LCTL set_param -P $orig_val
10198 [ $set_val == "jobid_var=TESTNAME" ] ||
10199 error "$set_val is not TESTNAME"
10201 do_facet mgs rm "$yaml_file"
10213 # Reapply the config from before
10214 echo "Setting configuration parameters"
10215 do_facet mgs "lctl set_param -F $yaml_file"
10219 run_test 123F "clear and reset all parameters using set_param -F"
10229 # Reapply the config from before
10230 echo "Setting configuration parameters"
10231 do_facet mgs "lctl apply_yaml $yaml_file"
10235 run_test 123G "clear and reset all parameters using apply_yaml"
10240 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
10241 [ -z $mds2failover_HOST ] && skip "needs MDT failover setup"
10244 do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
10245 grep 1.2.3.4@tcp && error "Should not be fake nid"
10246 do_facet mgs $LCTL conf_param $FSNAME-MDT0001.failover.node=1.2.3.4@tcp\
10247 || error "Set params error"
10248 do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
10249 grep 1.2.3.4@tcp || error "Fake nid should be added"
10253 if combined_mgs_mds; then
10254 start_mdt 1 "-o nosvc" ||
10255 error "starting mds with nosvc option failed"
10257 local nid=$(do_facet mds2 $LCTL list_nids | head -1)
10258 local failover_nid=$(do_node $mds2failover_HOST $LCTL list_nids | head -1)
10260 do_facet mgs $LCTL replace_nids $FSNAME-MDT0001 $nid:$failover_nid ||
10261 error "replace_nids execution error"
10263 if combined_mgs_mds; then
10269 echo "lfs setdirstripe"
10270 $LFS setdirstripe -i 1 $MOUNT/$tdir || error "setdirstirpe error"
10273 run_test 124 "check failover after replace_nids"
10275 get_max_sectors_kb() {
10278 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
10279 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
10281 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
10282 cat ${max_sectors_path}"
10285 get_max_hw_sectors_kb() {
10288 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
10289 local max_hw_path="/sys/block/${dev_base}/queue/max_hw_sectors_kb"
10291 do_facet ${facet} "[[ -e ${max_hw_path} ]] && cat ${max_hw_path}"
10294 set_max_sectors_kb() {
10298 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
10299 local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
10301 do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
10302 echo ${value} > ${max_sectors_path}"
10305 [[ $rc -ne 0 ]] && echo "Failed to set ${max_sectors_path} to ${value}"
10310 # Return 0 if all slave devices have max_sectors_kb == max_hw_sectors_kb
10311 # Otherwise return > 0
10312 check_slaves_max_sectors_kb()
10316 local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
10317 local slaves_dir=/sys/block/${dev_base}/slaves
10318 local slave_devices=$(do_facet ${facet} "ls ${slaves_dir} 2>/dev/null")
10319 [[ -z ${slave_devices} ]] && return 0
10321 local slave max_sectors new_max_sectors max_hw_sectors path
10324 for slave in ${slave_devices}; do
10325 path="/dev/${slave}"
10326 ! is_blkdev ${facet} ${path} && continue
10327 max_sectors=$(get_max_sectors_kb ${facet} ${path})
10328 max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${path})
10329 new_max_sectors=${max_hw_sectors}
10330 [[ ${new_max_sectors} -gt ${RQ_SIZE_LIMIT} ]] &&
10331 new_max_sectors=${RQ_SIZE_LIMIT}
10333 if [[ ${max_sectors} -ne ${new_max_sectors} ]]; then
10334 echo "${path} ${max_sectors} ${new_max_sectors}"
10337 check_slaves_max_sectors_kb ${facet} ${path}
10346 local facet_list="mgs mds1 ost1"
10347 combined_mgs_mds && facet_list="mgs ost1"
10350 for facet in ${facet_list}; do
10351 [[ $(facet_fstype ${facet}) != ldiskfs ]] &&
10352 skip "ldiskfs only test" &&
10354 ! is_blkdev ${facet} $(facet_device ${facet}) &&
10355 skip "requires all real devices" &&
10360 # We don't increase IO request size limit past 16MB. See comments in
10361 # lustre/utils/libmount_utils_ldiskfs.c:tune_max_sectors_kb()
10362 RQ_SIZE_LIMIT=$((16 * 1024))
10363 local device old_max_sectors new_max_sectors max_hw_sectors
10364 for facet in ${facet_list}; do
10365 device=$(facet_device ${facet})
10366 old_max_sectors=$(get_max_sectors_kb ${facet} ${device})
10367 max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${device})
10369 # The expected value after l_tunedisk is executed
10370 new_max_sectors=$old_max_sectors
10371 [[ ${new_max_sectors_kb} -gt ${RQ_SIZE_LIMIT} ]] &&
10372 new_max_sectors_kb=${RQ_SIZE_LIMIT}
10374 # Ensure the current value of max_sectors_kb does not equal
10375 # max_hw_sectors_kb, so we can tell whether l_tunedisk did
10377 set_max_sectors_kb ${facet} ${device} $((new_max_sectors - 1))
10379 # Value before l_tunedisk
10380 local pre_max_sectors=$(get_max_sectors_kb ${facet} ${device})
10381 if [[ ${pre_max_sectors} -ne $((new_max_sectors - 1)) ]]; then
10382 echo "unable to satsify test pre-condition:"
10383 echo "${pre_max_sectors} != $((new_max_sectors - 1))"
10388 echo "Before: ${facet} ${device} ${pre_max_sectors} ${max_hw_sectors}"
10390 do_facet ${facet} "l_tunedisk ${device}"
10392 # Value after l_tunedisk
10393 local post_max_sectors=$(get_max_sectors_kb ${facet} ${device})
10395 echo "After: ${facet} ${device} ${post_max_sectors} ${max_hw_sectors}"
10397 if [[ ${facet} != ost1 ]]; then
10398 if [[ ${post_max_sectors} -ne ${pre_max_sectors} ]]; then
10399 echo "l_tunedisk modified max_sectors_kb of ${facet}"
10403 set_max_sectors_kb ${facet} ${device} ${old_max_sectors}
10405 if [[ ${post_max_sectors} -eq ${pre_max_sectors} ]]; then
10406 echo "l_tunedisk failed to modify max_sectors_kb of ${facet}"
10410 check_slaves_max_sectors_kb ${facet} ${device} ||
10417 run_test 125 "check l_tunedisk only tunes OSTs and their slave devices"
10420 [[ "$MDS1_VERSION" -ge $(version_code 2.13.52) ]] ||
10421 skip "Need MDS version at least 2.13.52"
10424 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ../libcfs/libcfs/libcfs
10425 #define OBD_FAIL_OBD_SETUP 0x60d
10426 do_facet mds1 $LCTL set_param fail_loc=0x60d
10427 do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules &
10428 for i in {1..40}; do
10429 do_facet mds1 lsmod | grep -q osd_$mds1_FSTYPE && break
10432 clear_failloc $SINGLEMDS 20 &
10433 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
10435 run_test 126 "mount in parallel shouldn't cause a crash"
10438 [[ "$ost1_FSTYPE" == ldiskfs ]] || skip "ldiskfs only test"
10442 zconf_umount_clients $RCLIENTS $MOUNT
10444 wait_osp_active ost ${FSNAME}-OST0000 0 1
10445 local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
10446 local avail1=($($LCTL get_param -n osc.${osc_tgt}.kbytesavail))
10448 $LFS setstripe -i 0 $DIR/$tfile || error "failed creating $DIR/$tfile"
10449 dd if=/dev/zero of=$DIR/$tfile bs=1M oflag=direct || true
10451 local avail2=($($LCTL get_param -n osc.${osc_tgt}.kbytesavail))
10453 if ((avail2 * 100 / avail1 > 1)); then
10456 error "more than 1% space left: before=$avail1 after=$avail2"
10459 local mbs=$(($(stat -c %s $DIR/$tfile) / (1024 * 1024)))
10461 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$mbs conv=notrunc \
10462 oflag=direct || error "overwrite failed"
10464 run_test 127 "direct io overwrite on full ost"
10468 combined_mgs_mds && skip "need separate mgs device"
10469 [ "$ost2_FSTYPE" == zfs ] && import_zpool ost2
10472 # Try to apply nolocallogs to the virgin OST. Should fail.
10473 do_facet ost2 "$TUNEFS --nolocallogs $(ostdevname 2)" &&
10474 error "nolocallogs should not be allowed on the virgin target"
10479 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
10480 # Start OST without MGS (local configs)
10481 do_facet ost1 "$TUNEFS --dryrun $(ostdevname 1)"
10482 start_ost || error "unable to start OST1"
10483 stop_ost || error "Unable to stop OST1"
10485 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
10486 # Do not allow reading local configs, should fail
10487 do_facet ost1 "$TUNEFS --nolocallogs $(ostdevname 1)" ||
10488 error "Can not set nolocallogs"
10489 start_ost && error "OST1 started, but should fail"
10491 # Connect to MGS successfully, reset nolocallogs flag
10492 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
10493 start_mgs || error "unable to start MGS"
10494 start_ost || error "unable to start OST1"
10496 do_facet ost1 "$TUNEFS --dryrun $(ostdevname 1)" | grep "nolocallogs" &&
10497 error "nolocallogs expected to be reset"
10499 stop_ost || error "Unable to stop OST1"
10501 run_test 128 "Force using remote logs with --nolocallogs"
10505 (( MDS1_VERSION >= $(version_code 2.14.57) )) ||
10506 skip "Need MDS version at least 2.14.57"
10508 start_mgsmds || error "MGS/MDS start failed"
10510 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &&
10511 error "start ost1 should fail" || true
10512 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS &&
10513 error "second start ost1 should fail" || true
10514 do_facet ost1 "$TUNEFS --writeconf $(ostdevname 1)"
10515 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS ||
10516 error "start ost1 failed"
10520 run_test 129 "attempt to connect an OST with the same index should fail"
10524 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
10526 stop_mdt 2 || error "mdt2 stop failed"
10527 do_facet mds2 "$TUNEFS --writeconf $(mdsdevname 2)"
10528 start_mdt 2 || error "mdt2 start failed"
10529 do_facet mds2 "$LCTL dl" | grep MDT0001-osp-MDT0001 &&
10530 error "Illegal OSP device created" || true
10532 run_test 130 "re-register an MDT after writeconf"
10535 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
10536 (( $MDS1_VERSION >= $(version_code 2.14.56.35) )) ||
10537 skip "Need MDS version at least 2.14.56.35"
10538 do_facet mds1 $DEBUGFS -R features $(mdsdevname 1) |
10539 grep -q project || skip "skip project quota not supported"
10544 test_mkdir -c $MDSCOUNT -p $DIR/$tdir
10545 $LFS project -p 1000 $DIR/$tdir || error "set dir project id failed"
10546 createmany -o $DIR/$tdir/f 512
10547 for ((i = 0; i < 512; ++i)); do
10548 $LFS project -p $i $DIR/$tdir/f${i} ||
10549 error "set f${i} project id failed"
10552 test_mkdir -c $MDSCOUNT -p $DIR/$tdir.inherit
10553 $LFS project -p 1001 -s $DIR/$tdir.inherit
10554 createmany -o $DIR/$tdir.inherit/f 128
10555 (( $($LFS project $DIR/$tdir.inherit/f* |
10556 awk '$1 == 1001 { print }' | wc -l) == 128 )) ||
10557 error "files did not inherit projid 1001"
10561 for i in $(seq $MDSCOUNT); do
10562 mds_backup_restore mds$i ||
10563 error "Backup/restore on mds$i failed"
10568 projid=($($LFS project -d $DIR/$tdir))
10569 [ ${projid[0]} == "1000" ] ||
10570 error "projid expected 1000 not ${projid[0]}"
10571 for ((i = 0; i < 512; ++i)); do
10572 projid=($($LFS project $DIR/$tdir/f${i}))
10573 [ ${projid[0]} == "$i" ] ||
10574 error "projid expected $i not ${projid[0]}"
10577 (( $($LFS project $DIR/$tdir.inherit/f* |
10578 awk '$1 == 1001 { print }' | wc -l) == 128 )) ||
10579 error "restore did not copy projid 1001"
10581 run_test 131 "MDT backup restore with project ID"
10587 (( MDS1_VERSION >= $(version_code 2.14.57) )) ||
10588 skip "Need MDS version at least 2.14.57"
10590 combined_mgs_mds || start_mgs || error "unable to start MGS"
10591 start_mdt 1 || error "unable to start mdt1"
10593 err_cnt=$(do_facet mds1 dmesg | grep -c "cannot take the layout locks")
10594 stop_mdt 1 || error "stop mdt1 failed"
10596 [ "$mds1_FSTYPE" == zfs ] && import_zpool mds1
10597 do_facet mds1 $TUNEFS --param mdt.hsm_control=enabled $(mdsdevname 1) ||
10598 error "tunefs failed"
10599 start_mdt 1 || error "cannot start mdt1"
10601 err_cnt2=$(do_facet mds1 dmesg | grep -c "cannot take the layout locks")
10602 [ $err_cnt -eq $err_cnt2 ] || error "Can not take the layout lock"
10603 stop_mdt 1 || error "stop mdt1 failed"
10605 run_test 132 "hsm_actions processed after failover"
10607 # This test verifies we do RR allocation within a pool even if there is a
10608 # significant imbalance vs an OST outside the pool
10610 [[ $OSTCOUNT -lt 4 ]] && skip_env "needs >= 4 OSTs"
10611 [[ "$OST1_VERSION" -ge $(version_code 2.15.51) ]] ||
10612 skip "Need OST version at least 2.15.51"
10613 # This is the easiest way to ensure OSTs start out balanced
10614 reformat_and_config
10617 check_set_fallocate_or_skip
10619 local testfile=$DIR/$tdir/$tfile
10620 local pool="testpool"
10621 local ostrange=$((OSTCOUNT - 1))
10622 # Select all but the last OST to add to the pool
10623 local poolostrange=$((OSTCOUNT - 2))
10631 [ $MINV -eq 0 ] && error "no free space in OST$MINI"
10632 [ $MAXV -gt $((2 * $MINV)) ] &&
10633 error "OSTs badly unbalanced after reformat"
10635 create_pool $FSNAME.$pool || error "failed to create a pool"
10636 do_facet mgs $LCTL pool_add $FSNAME.$pool OST[0-$poolostrange] ||
10637 error "failed to add OST[0-$poolostrange] to the pool"
10639 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
10640 # Consume space on the OSTs in the pool so they are unbalanced with the
10641 # OST outside of the pool
10642 # fill each OST 90% with fallocate so they are widely
10644 local size=$(((MINV * 9 / 10) * 1024))
10645 for ((i = 0; i <= poolostrange; i++)); do
10646 $LFS setstripe -c 1 -i $i $testfile$i ||
10647 error "failed to setstripe $testfile$i"
10648 fallocate -l $size $testfile$i || error "fallocate failed"
10654 # Create files in the pool now that there is an imbalance
10655 filecount=$(((OSTCOUNT - 1) * filenum))
10656 for ((i = 0; i < filecount; i++)); do
10657 $LFS setstripe -p $pool $testfile-$i ||
10658 error "failed to setstripe -p $pool $testfile-$i"
10660 $LFS getstripe -i $testfile-* > /tmp/$tfile.log
10661 # Count the number of files with a stripe on each OST to verify the
10662 # pool allocated with round-robin
10663 for ((i = 0; i <= poolostrange; i++)); do
10664 stripecount=$(grep -c $i /tmp/$tfile.log)
10665 # Allow a little leeway
10666 if (( stripecount < filenum - 1 ||
10667 stripecount > filenum + 1 )); then
10668 cat /tmp/$tfile.log
10669 error "$stripecount != $filenum files on OST$i"
10673 # Create files across the system now that there is an imbalance
10674 filecount=$((OSTCOUNT * filenum))
10675 for ((i = 1; i < filecount; i++)); do
10676 $LFS setstripe $testfile-$i.2 ||
10677 error "failed to setstripe $testfile-$i.2"
10679 $LFS getstripe -i $testfile-*.2 > /tmp/$tfile.log
10681 # Count the number of files with a stripe on each OST to verify the
10682 # files are *NOT* allocated with round-robin
10683 for ((i = 0; i <= ostrange; i++)); do
10684 stripecount=$(grep -c $i /tmp/$tfile.log)
10685 if [[ $stripecount -ne $filenum ]]; then
10687 echo "QOS: $stripecount != $filenum files on OST$i"
10690 if [ -z "$qos_used" ]; then
10691 error "QOS not used on imbalanced OSTs!"
10694 rm -rf /tmp/$tfile.log $DIR/$tdir
10695 do_facet mgs $LCTL pool_remove $FSNAME.$pool OST[0-$poolostrange] ||
10696 "failed to remove OST[0-$poolostrange] from the pool"
10697 do_facet mgs $LCTL pool_destroy $FSNAME.$pool ||
10698 error "failed to destroy pool"
10700 run_test 133 "stripe QOS: free space balance in a pool"
10703 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
10706 local mdt_dev=$(facet_device mds1)
10707 local tmp_dir=$TMP/$tdir
10708 local out=$tmp_dir/check_iam.txt
10709 local CHECK_IAM=${CHECK_IAM:-$(do_facet mds1 "which check_iam 2> /dev/null || true")}
10711 [[ -n "$CHECK_IAM" ]] || skip "check_iam not found"
10714 for ((i=0; i<64; i++)); do
10716 #cmd introduce a random corruption to IAM file
10717 local cmd="dd if=/dev/urandom of=$tmp_dir/$f bs=2 conv=notrunc count=1 seek=$((RANDOM % 36))"
10718 do_facet mds1 "mkdir -p $tmp_dir; \
10719 $DEBUGFS -c -R 'dump $f $tmp_dir/$f' $mdt_dev 2>&1; \
10720 $CHECK_IAM -v $tmp_dir/$f 2>&1; \
10721 echo $cmd; eval $cmd 2>/dev/null;
10722 $CHECK_IAM -v $tmp_dir/$f 2>&1; echo \\\$?" >> $out 2>&1
10727 stack_trap "rm -rf $tmp_dir && do_facet mds1 rm -rf $tmp_dir" EXIT
10729 rc=$(grep -c "fault\|except" $out)
10730 (( rc == 0 )) || { cat $out &&
10731 error "check_iam failed with fault or exception $rc"; }
10733 rc=$(grep -c "^255" $out)
10734 errors=$(grep -c "FINISHED WITH ERRORS" $out)
10736 (( rc == errors )) || { cat $out &&
10737 error "check_iam errcode does not fit with errors $rc $errors"; }
10739 run_test 134 "check_iam works without faults"
10741 cleanup_test_135(){
10744 printf "\nCleanup test_135\n" >&2
10745 do_facet mds1 "$LCTL set_param -n $oldgc"
10746 rm -rf $DIR/$tdir &> /dev/null
10750 __test_135_file_thread() {
10752 local init_time=$(awk '{print $1}' /proc/uptime)
10753 local awkcmd="/crosses index zero/ {if (\$1 > $init_time) exit(1);}"
10755 #Generate a full plain llogs
10756 while dmesg | sed -r 's/(\[|\])//g' | awk "$awkcmd" ; do
10757 createmany -o $DIR/$tdir/f 4500 >&2
10758 createmany -u $DIR/$tdir/f 4500 >&2
10762 __test_135_reader() {
10765 local firstidx=$(changelog_user_rec mds1 $cl_user)
10766 local oldidx=$firstidx
10771 while read -t10 -u$fd newidx other; do
10772 (( (newidx - oldidx) == 1 )) ||
10773 error "changelog jump detected (last: $oldidx, current: $newidx)"
10775 if (( (newidx - firstidx + 1) % 13000 == 0 )); then
10776 [[ $pid -eq 0 ]] ||
10777 wait $pid || error "changelog_clear failed"
10778 changelog_clear $((newidx - 1)) mds1 >&2 & pid=$!
10783 [[ $pid -eq 0 ]] ||
10784 wait $pid || error "changelog_clear failed"
10790 (( MDS1_VERSION >= $(version_code 2.15.52) )) ||
10791 skip "need MDS version at least 2.15.52"
10793 local service=$(facet_svc mds1)
10795 local lastread lastidx
10796 local files_pid reader_pid
10801 # Need to reformat because we are changing llog catalog sizes to 5.
10802 # Otherwise, processing could fail with existing catalogs (last_idx>5).
10806 # Disable changelog garbage colector
10807 local oldgc=$(do_facet mds1 "$LCTL get_param mdd.${service}.changelog_gc")
10808 do_facet mds1 "$LCTL set_param -n mdd.${service}.changelog_gc=0"
10809 stack_trap "cleanup_test_135 $oldgc" EXIT INT
10811 # change the changelog_catalog size to 5 entries for everybody
10812 #define OBD_FAIL_CAT_RECORDS 0x1312
10813 do_node $(comma_list $(all_nodes)) $LCTL set_param fail_loc=0x1312 fail_val=5
10815 # disable console ratelimit
10816 local rl=$(cat /sys/module/libcfs/parameters/libcfs_console_ratelimit)
10817 echo 0 > /sys/module/libcfs/parameters/libcfs_console_ratelimit
10818 stack_trap "echo $rl > /sys/module/libcfs/parameters/libcfs_console_ratelimit" EXIT
10820 test_mkdir -c 1 -i 0 $DIR/$tdir || error "Failed to create directory"
10821 changelog_chmask "ALL" || error "changelog_chmask failed"
10822 changelog_register || error "changelog_register failed"
10824 cl_user="${CL_USERS[mds1]%% *}"
10825 changelog_users mds1 | grep -q $cl_user ||
10826 error "User $cl_user not found in changelog_users"
10828 # Start reader thread
10829 coproc $LFS changelog --follow $service
10832 stack_trap "echo kill changelog reader; kill $reader_pid" EXIT
10834 echo -e "\nWrap arround changelog catalog"
10836 # Start file writer thread
10837 __test_135_file_thread "$service" & files_pid=$!
10838 stack_trap "(pkill -P$files_pid; kill $files_pid) &> /dev/null || true" EXIT
10840 # Check changelog entries
10841 lastread=$(__test_135_reader $fd $cl_user) || exit $?
10842 ! kill -0 $files_pid 2>/dev/null ||
10843 error "creation thread is running. Is changelog reader stuck?"
10845 lastidx=$(changelog_users mds1 | awk '/current_index/ {print $NF}' )
10846 [[ "$lastread" -eq "$lastidx" ]] ||
10847 error "invalid changelog lastidx (read: $lastread, mds: $lastidx)"
10849 run_test 135 "check the behavior when changelog is wrapped around"
10852 do_facet mds2 "$LCTL --device ec cleanup" || true
10853 do_facet mds2 "$LCTL --device ec detach" || true
10856 reformat_and_config
10860 (( MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
10865 do_facet mds2 "$LCTL attach echo_client ec ec_uuid" ||
10866 error "echo attach fail"
10868 stack_trap cleanup_136 EXIT
10870 do_facet mds2 "$LCTL --device ec setup lustre-MDT0001 mdt" &&
10871 error "attach to MDT should fail!"
10873 do_facet mds2 "$LCTL --device ec setup lustre-MDT0001 mdd" ||
10874 error "attach to MDD should OK"
10875 do_facet mds2 "$LCTL --device ec test_mkdir /tt" &&
10876 error "mkdir test should fail with remote object"
10880 run_test 136 "don't panic with bad obdecho setup"
10882 wait_osp_import() {
10884 local remtgt=$(facet_svc $2)
10886 local loctgt=$(facet_svc $facet)
10887 local param="osp.$remtgt-os[pc]-${loctgt#*-}.*_server_uuid"
10889 do_rpc_nodes "$(facet_active_host $facet)" \
10890 wait_import_state $expected $param ||
10891 error "$param: import is not in expected state"
10895 (( MDS1_VERSION >= $(version_code 2.15.61) )) ||
10896 skip "need MDS version at least 2.15.61"
10898 (( $MDSCOUNT >= 3 )) || skip "needs >= 3 MDTs"
10900 local failnode=1.2.3.4@$NETTYPE
10901 local keep_zpool=$KEEP_ZPOOL
10904 #start mgs or mgs/mdt0
10905 if ! combined_mgs_mds ; then
10906 start_mgs || error "Fail to register mgs"
10907 start_mdt 1 || error "Fail to register mds1"
10909 start_mdt 1 || error "Fail to register mds1"
10912 start_ost || error "OST0 start fail"
10914 mount_client $MOUNT || error "mount client fails"
10915 wait_osc_import_ready client ost
10916 check_mount || error "check_mount failed"
10918 # Add failover node on OST0000
10920 [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
10921 do_facet ost1 "$TUNEFS --failnode=$failnode $(ostdevname 1)" ||
10922 error "ost1 tunefs failed"
10923 start_ost || error "OST0 start fail"
10925 # Add pool and parameters on MDT0000 to check the inheritance
10926 do_facet mgs $LCTL pool_new $FSNAME.pool1 || error "pool_new failed"
10927 do_facet mgs $LCTL pool_add $FSNAME.pool1 OST0000 ||
10928 error "pool_add failed"
10930 set_conf_param_and_check mds1 \
10931 "$LCTL get_param -n lod.$FSNAME-MDT0000*.dom_stripesize" \
10932 "$FSNAME-MDT0000.lod.dom_stripesize" \
10935 start_mdt 2 || error "Fail to register mds2"
10937 wait_osp_import mds1 mds2 FULL
10938 wait_osp_import mds2 mds1 FULL
10939 wait_osp_import mds2 ost1 FULL
10941 # Add failover node on MDT0001
10942 stop_mdt 2 || error "Fail to umount mds2"
10943 [ "$mds1_FSTYPE" == zfs ] && import_zpool mds2
10944 do_facet mds2 "$TUNEFS --failnode=$failnode $(mdsdevname 2)" ||
10945 error "mds2 tunefs failed"
10946 start_mdt 2 || error "Fail to mount mds2"
10948 wait_osp_import mds1 mds2 FULL
10949 wait_osp_import mds2 mds1 FULL
10950 wait_osp_import mds2 ost1 FULL
10953 for ((i=3; i <= MDSCOUNT; i++)); do
10954 start_mdt $i || error "Fail to register mds$i"
10957 wait_osc_import_state mds ost FULL
10959 for ((i=2; i <= MDSCOUNT; i++)); do
10962 local tgt=$(facet_svc $facet)
10963 local lod="lod.$tgt*"
10965 wait_osp_active mds $tgt $(( i - 1 )) 1
10967 do_facet $facet $LCTL get_param -n $lod.pools.pool1 |
10968 grep -q "OST0000" || error "pool1 should be inherited"
10970 val=$(do_facet $facet $LCTL get_param -n $lod.dom_stripesize)
10971 (( val == (2<<20) )) ||
10972 error "dom_stripesize should be inherited"
10974 import="osc.$FSNAME-OST0000-osc-${tgt#*-}.import"
10975 do_facet $facet $LCTL get_param -n $import |
10976 grep -q "failover_nids:.*$failnode" ||
10977 error "$failnode not found in $import"
10979 [[ "${tgt#*-}" != MDT0001 ]] || continue
10981 import="osp.$FSNAME-MDT0001-osp-${tgt#*-}.import"
10982 do_facet $facet $LCTL get_param -n $import |
10983 grep -q "failover_nids:.*$failnode" ||
10984 error "$failnode not found in $import"
10987 cleanup || error "cleanup failed with rc $?"
10988 reformat_and_config
10990 run_test 137 "a new MDT should inherit pools, parameters and failnode"
10993 (( MDS1_VERSION >= $(version_code 2.15.55) )) ||
10994 skip "need MDS version at least 2.15.55"
10995 (( MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
10997 RM_UPDATELOG=$(do_facet mds2 "which remove_updatelog 2> /dev/null")
10998 RM_UPDATELOG=${RM_UPDATELOG:-"$LUSTRE/scripts/remove_updatelog"}
11000 [ -f "$RM_UPDATELOG" ] ||
11001 skip_env "remove_updatelog is not found on mds2"
11003 local mntpt=$(facet_mntpt mds2)
11006 test_mkdir -c $MDSCOUNT -p $DIR/$tdir ||
11007 error "mkdir $DIR/$tdir failed"
11008 mkdir $DIR/$tdir/d{1..256}
11013 mount_fstype mds2 || error "mount as fstype mds2 failed"
11014 do_facet mds2 $RM_UPDATELOG -n $mntpt
11015 MDTS=($(do_facet mds2 $RM_UPDATELOG -n $mntpt |
11016 grep -o "Processing MDT[0-9]*" | awk -F'MDT' '{print $2}'))
11017 (( ${#MDTS[@]} == MDSCOUNT )) ||
11018 error "Processed ${#MDTS[@]} from $MDSCOUNT"
11020 do_facet mds2 $RM_UPDATELOG -n -m 1,0 $mntpt
11021 MDTS=($(do_facet mds2 $RM_UPDATELOG -n -m 1,0 $mntpt |
11022 grep -o "Processing MDT[0-9]*" | awk -F'MDT' '{print $2}'))
11023 (( ${#MDTS[@]} == 2 )) ||
11024 error "Processed ${#MDTS[@]} instead of 2"
11025 (( ${MDTS[0]} == 1 && ${MDTS[1]} == 0 )) ||
11026 error "Processed: ${MDTS[*]}, expected: 1 0"
11028 do_facet mds2 $RM_UPDATELOG -m 0 $mntpt
11029 unmount_fstype mds2
11030 start_mdt 2 || error "mds2 start fail"
11031 start_mdt 1 || error "mds1 start fail"
11032 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds1 FULL
11033 wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
11035 rm -rf $DIR/$tdir || error "Can't remove $tdir"
11037 reformat_and_config
11039 run_test 140 "remove_updatelog script actions"
11044 local max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
11045 awk '/^max_cached_mb/ { print $2 }')
11046 stack_trap "$LCTL set_param -n llite.*.max_cached_mb=$max_cached_mb"
11048 $LCTL set_param llite.*.max_cached_mb='100%'
11050 local new_max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
11051 awk '/^max_cached_mb/ { print $2 }')
11052 local total_ram_mb=$(free -m | grep 'Mem:' | awk '{print $2}')
11054 $LCTL get_param llite.*.max_cached_mb
11055 echo "total ram mb: $total_ram_mb"
11056 (( new_max_cached_mb == total_ram_mb )) ||
11057 error "setting cache to 100% not equal to total RAM"
11059 $LCTL set_param llite.*.max_cached_mb='50%'
11060 new_max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
11061 awk '/^max_cached_mb/ { print $2 }')
11063 $LCTL get_param llite.*.max_cached_mb
11064 (( new_max_cached_mb == $((total_ram_mb / 2)) )) ||
11065 error "setting cache to 50% not equal to 50% of RAM"
11067 $LCTL set_param llite.*.max_cached_mb='105%' &&
11068 error "should not be able to set insane value"
11070 $LCTL set_param llite.*.max_cached_mb='0%'
11071 new_max_cached_mb=$($LCTL get_param llite.*.max_cached_mb |
11072 awk '/^max_cached_mb/ { print $2 }')
11073 # Minimum cache size is 64 MiB
11074 $LCTL get_param llite.*.max_cached_mb
11075 (( new_max_cached_mb == 64 )) ||
11076 error "setting cache to 0% != minimum cache size"
11078 run_test 150 "test setting max_cached_mb to a %"
11081 (( MDS1_VERSION >= $(version_code 2.15.58) )) ||
11082 skip "need MDS version at least 2.15.58"
11083 [[ "$ost1_FSTYPE" == ldiskfs ]] || skip "ldiskfs only test"
11086 if ! combined_mgs_mds ; then
11090 echo "Damage ost1 local config log"
11091 do_facet ost1 "$DEBUGFS -w -R 'punch CONFIGS/$FSNAME-OST0000 0 1' \
11092 $(ostdevname 1) || return \$?" ||
11093 error "do_facet ost1 failed with $?"
11095 # expect OST to fail mount with no MGS and bad local config
11096 start_ost && error "OST start should fail"
11098 if ! combined_mgs_mds ; then
11101 start_mds || error "MDS start failed"
11102 # now it should start with MGS config
11103 start_ost || error "OST start failed"
11104 reformat_and_config
11106 run_test 151 "damaged local config doesn't prevent mounting"
11109 (( MDS1_VERSION >= $(version_code 2.15.59.53) )) ||
11110 skip "need MDS >= 2.15.59.53 for sequence allocation retry"
11111 (( MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
11112 local tf=$DIR/$tdir/$tfile
11113 local nost=$((OSTCOUNT+1))
11114 local nostdevname=$(ostdevname $nost)
11117 test_mkdir -i 1 -c1 $DIR/$tdir || error "can't mkdir"
11120 add ost$nost $(mkfs_opts ost1 $nostdevname) --index=$nost \
11121 --reformat $nostdevname $(ostvdevname $nost)
11122 [[ -d "$nostdevname" ]] || stack_trap "do_facet mds1 rm -f $nostdevname"
11124 #define OBD_FAIL_OPS_FAIL_SEQ_ALLOC 0x2109
11125 do_facet mds1 $LCTL set_param fail_loc=0x80002109 fail_val=2
11126 echo "START OST$nost"
11127 stack_trap "stop ost$nost"
11128 start ost$nost $nostdevname $OST_MOUNT_OPTS &
11132 $LFS setstripe -c -1 $tf &
11136 log "STOP OST$nost"
11137 # probably mount hasn't completed yet, so stop races with it
11140 jobs -pr | grep -E "^$PID\$" && sleep 0.5 && continue
11145 do_facet mds1 $LCTL set_param fail_loc=0
11146 log "START OST$nost again"
11147 start ost$nost $nostdevname $OST_MOUNT_OPTS ||
11148 error "can't start ost$nost"
11150 $LFS setstripe -c -1 $tf-2 || error "can't touch $tf-2"
11151 $LFS getstripe -v $tf-2
11152 local stripes=$($LFS getstripe -c $tf-2)
11153 (( stripes == $nost )) || error "$tf-2 $stripes != $nost"
11155 run_test 152 "seq allocation error in OSP"
11158 reformat_and_config
11160 start_mds || error "MDS start failed"
11161 start_ost || error "OST start failed"
11163 local nid=$($LCTL list_nids | grep ${NETTYPE} | head -n1)
11164 local net=${nid#*@}
11165 local MGS_NID=$(do_facet mgs $LCTL list_nids | head -1)
11166 local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
11167 local FAKE_PNID="192.168.252.112@${net}"
11168 local FAKE_NIDS="${FAKE_PNID},${FAKE_PNID}2"
11169 local FAKE_FAILOVER="10.252.252.113@${net},10.252.252.113@${net}2"
11170 local NIDS_AND_FAILOVER="$FAKE_NIDS:$FAKE_FAILOVER:$OST1_NID:$MGS_NID"
11175 mount -t lustre $NIDS_AND_FAILOVER:/lustre $MOUNT &
11177 while (( period < 30 )); do
11178 [[ -n "$(ps -p $pid -o pid=)" ]] || break
11179 echo "waiting for mount ..."
11181 period=$((period + 5))
11183 $LCTL get_param mgc.MGC${FAKE_PNID}.import | grep "uptodate:"
11184 check_mount || error "check_mount failed"
11186 cleanup || error "cleanup failed with rc $?"
11188 run_test 153a "bypass invalid NIDs quickly"
11191 # (This was sanity/802a)
11193 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
11194 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
11195 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
11196 saved_MOUNT_OPTS=$MOUNT_OPTS
11200 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
11201 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
11202 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
11203 MOUNT_OPTS=$saved_MOUNT_OPTS
11208 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
11209 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
11210 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
11211 skip "Need server version at least 2.9.55"
11213 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
11215 # Reset before starting
11219 mkdir $DIR/$tdir || error "(1) fail to mkdir"
11221 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
11222 error "(2) Fail to copy"
11224 stack_trap cleanup_802a EXIT
11226 # sync by force before remount as readonly
11227 sync; sync_all_data; sleep 3; sync_all_data
11231 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
11232 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
11233 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
11235 echo "Mount the server as read only"
11236 setupall server_only || error "(3) Fail to start servers"
11238 echo "Mount client without ro should fail"
11239 mount_client $MOUNT &&
11240 error "(4) Mount client without 'ro' should fail"
11242 echo "Mount client with ro should succeed"
11243 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
11244 mount_client $MOUNT ||
11245 error "(5) Mount client with 'ro' should succeed"
11247 echo "Modify should be refused"
11248 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
11250 echo "Read should be allowed"
11251 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
11252 error "(7) Read should succeed under ro mode"
11254 run_test 802a "simulate readonly device"
11256 if ! combined_mgs_mds ; then
11262 # restore the values of MDSSIZE and OSTSIZE
11263 MDSSIZE=$STORED_MDSSIZE
11264 OSTSIZE=$STORED_OSTSIZE
11267 complete_test $SECONDS
11268 check_and_cleanup_lustre