2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:autoindent:shiftwidth=4:tabstop=4:
5 # FIXME - there is no reason to use all of these different
6 # return codes, espcially when most of them are mapped to something
7 # else anyway. The combination of test number and return code
8 # figure out what failed.
14 # bug number for skipped test:
16 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
17 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
19 if [ "$FAILURE_MODE" = "HARD" ]; then
20 CONFIG_EXCEPTIONS="24a " && \
21 echo "Except the tests: $CONFIG_EXCEPTIONS for FAILURE_MODE=$FAILURE_MODE, bug 23573" && \
22 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
26 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
28 PTLDEBUG=${PTLDEBUG:--1}
30 LUSTRE=${LUSTRE:-`dirname $0`/..}
31 RLUSTRE=${RLUSTRE:-$LUSTRE}
33 . $LUSTRE/tests/test-framework.sh
36 # use small MDS + OST size to speed formatting time
37 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
40 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
42 if ! combined_mgs_mds; then
43 # bug number for skipped test: 23954
44 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24b"
47 # STORED_MDSSIZE is used in test_18
48 if [ -n "$MDSSIZE" ]; then
49 STORED_MDSSIZE=$MDSSIZE
55 require_dsh_mds || exit 0
56 require_dsh_ost || exit 0
58 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
73 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
74 do_facet ${facet} "$TUNEFS --quiet --writeconf $dev" ||
75 { echo "tunefs failed, reformatting instead" && reformat_and_config && return 1; }
82 # if writeconf fails anywhere, we reformat everything
83 writeconf1 mds `mdsdevname 1` || return 0
84 writeconf1 ost1 `ostdevname 1` || return 0
85 writeconf1 ost2 `ostdevname 2` || return 0
89 # The MGS must be started before the OSTs for a new fs, so start
90 # and stop to generate the startup logs.
93 wait_osc_import_state mds ost FULL
98 reformat_and_config() {
100 if ! combined_mgs_mds ; then
108 start mgs $MGSDEV $MGS_MOUNT_OPTS
112 local facet=$SINGLEMDS
113 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
114 local num=$(echo $facet | tr -d "mds")
115 local dev=$(mdsdevname $num)
116 echo "start mds service on `facet_active_host $facet`"
117 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
121 if ! combined_mgs_mds ; then
128 echo "stop mds service on `facet_active_host $SINGLEMDS`"
129 # These tests all use non-failover stop
130 stop $SINGLEMDS -f || return 97
134 echo "stop mgs service on `facet_active_host mgs`"
135 # These tests all use non-failover stop
136 stop mgs -f || return 97
140 echo "start ost1 service on `facet_active_host ost1`"
141 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
145 echo "stop ost1 service on `facet_active_host ost1`"
146 # These tests all use non-failover stop
147 stop ost1 -f || return 98
151 echo "start ost2 service on `facet_active_host ost2`"
152 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
156 echo "stop ost2 service on `facet_active_host ost2`"
157 # These tests all use non-failover stop
158 stop ost2 -f || return 93
163 echo "mount $FSNAME on ${MOUNTPATH}....."
164 zconf_mount `hostname` $MOUNTPATH || return 96
168 local mountopt="-o remount,$1"
170 echo "remount '$1' lustre on ${MOUNTPATH}....."
171 zconf_mount `hostname` $MOUNTPATH "$mountopt" || return 96
176 echo "umount lustre on ${MOUNTPATH}....."
177 zconf_umount `hostname` $MOUNTPATH || return 97
180 manual_umount_client(){
183 echo "manual umount lustre on ${MOUNT}...."
184 do_facet client "umount -d ${FORCE} $MOUNT"
190 start_mds || error "MDT start failed"
191 start_ost || error "OST start failed"
192 mount_client $MOUNT || error "client start failed"
196 if ! combined_mgs_mds ; then
205 unload_modules_conf () {
206 if combined_mgs_mds || ! local_mode; then
207 unload_modules || return 1
212 stop_ost || return 202
213 stop_mds || return 201
214 unload_modules_conf || return 203
218 umount_client $MOUNT || return 200
219 cleanup_nocli || return $?
223 do_facet client "cp /etc/passwd $DIR/a" || return 71
224 do_facet client "rm $DIR/a" || return 72
225 # make sure lustre is actually mounted (touch will block,
226 # but grep won't, so do it after)
227 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
228 echo "setup single mount lustre success"
232 do_facet client "touch $DIR/a" || return 71
233 do_facet client "rm $DIR/a" || return 72
234 do_facet client "touch $DIR2/a" || return 73
235 do_facet client "rm $DIR2/a" || return 74
236 echo "setup double mount lustre success"
241 if [ "$ONLY" == "setup" ]; then
246 if [ "$ONLY" == "cleanup" ]; then
253 #create single point mountpoint
259 check_mount || return 41
262 run_test 0 "single mount setup"
265 start_mds || error "MDT start failed"
267 echo "start ost second time..."
268 start_ost && error "2nd OST start should fail"
269 mount_client $MOUNT || error "client start failed"
270 check_mount || return 42
273 run_test 1 "start up ost twice (should return errors)"
277 echo "start mds second time.."
278 start_mds && error "2nd MDT start should fail"
281 check_mount || return 43
284 run_test 2 "start up mds twice (should return err)"
288 #mount.lustre returns an error if already in mtab
289 mount_client $MOUNT && error "2nd client mount should fail"
290 check_mount || return 44
293 run_test 3 "mount client twice (should return err)"
297 touch $DIR/$tfile || return 85
301 # ok for ost to fail shutdown
302 if [ 202 -ne $eno ]; then
307 run_test 4 "force cleanup ost, then cleanup"
309 test_5a() { # was test_5
311 touch $DIR/$tfile || return 1
312 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
314 stop_mds -f || return 2
316 # cleanup may return an error from the failed
317 # disconnects; for now I'll consider this successful
318 # if all the modules have unloaded.
322 echo "killing umount"
323 kill -TERM $UMOUNT_PID
324 echo "waiting for umount to finish"
326 if grep " $MOUNT " /proc/mounts; then
327 echo "test 5: /proc/mounts after failed umount"
331 echo "killing umount"
332 kill -TERM $UMOUNT_PID
333 echo "waiting for umount to finish"
335 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
339 # stop_mds is a no-op here, and should not fail
340 cleanup_nocli || return $?
341 # df may have lingering entry
343 # mtab may have lingering entry
347 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
349 grep -q $MOUNT" " /etc/mtab || break
350 echo "Waiting /etc/mtab updated ... "
351 WAIT=$(( WAIT + sleep))
353 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
354 echo "/etc/mtab updated in $WAIT secs"
356 run_test 5a "force cleanup mds, then cleanup"
364 grep " $MOUNT " /etc/mtab && \
365 error false "unexpected entry in mtab before mount" && return 10
369 if ! combined_mgs_mds ; then
370 trap cleanup_5b EXIT ERR
375 [ -d $MOUNT ] || mkdir -p $MOUNT
376 mount_client $MOUNT && rc=1
377 grep " $MOUNT " /etc/mtab && \
378 error "$MOUNT entry in mtab after failed mount" && rc=11
380 # stop_mds is a no-op here, and should not fail
381 cleanup_nocli || rc=$?
382 if ! combined_mgs_mds ; then
387 run_test 5b "Try to start a client with no MGS (should return errs)"
390 grep " $MOUNT " /etc/mtab && \
391 error false "unexpected entry in mtab before mount" && return 10
396 [ -d $MOUNT ] || mkdir -p $MOUNT
397 local oldfs="${FSNAME}"
398 FSNAME="wrong.${FSNAME}"
399 mount_client $MOUNT || :
401 grep " $MOUNT " /etc/mtab && \
402 error "$MOUNT entry in mtab after failed mount" && rc=11
404 cleanup_nocli || rc=$?
407 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
410 grep " $MOUNT " /etc/mtab && \
411 error false "unexpected entry in mtab before mount" && return 10
417 mount_client $MOUNT || rc=1
419 grep " $MOUNT " /etc/mtab && \
420 error "$MOUNT entry in mtab after unmount" && rc=11
423 run_test 5d "mount with ost down"
426 grep " $MOUNT " /etc/mtab && \
427 error false "unexpected entry in mtab before mount" && return 10
433 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
434 do_facet client "lctl set_param fail_loc=0x80000506"
435 mount_client $MOUNT || echo "mount failed (not fatal)"
437 grep " $MOUNT " /etc/mtab && \
438 error "$MOUNT entry in mtab after unmount" && rc=11
441 run_test 5e "delayed connect, don't crash (bug 10268)"
444 if combined_mgs_mds ; then
445 skip "combined mgs and mds"
449 grep " $MOUNT " /etc/mtab && \
450 error false "unexpected entry in mtab before mount" && return 10
454 [ -d $MOUNT ] || mkdir -p $MOUNT
455 mount_client $MOUNT &
457 echo client_mount pid is $pid
461 if ! ps -f -p $pid >/dev/null; then
464 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
465 error "mount returns $rc, expected to hang"
474 # mount should succeed after start mds
477 [ $rc -eq 0 ] || error "mount returned $rc"
478 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
482 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
487 mount_client ${MOUNT} || return 87
488 touch $DIR/a || return 86
491 run_test 6 "manual umount, then mount again"
496 cleanup_nocli || return $?
498 run_test 7 "manual umount, then cleanup"
503 check_mount2 || return 45
504 umount_client $MOUNT2
507 run_test 8 "double mount setup"
512 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
513 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
515 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
516 if [ "$CHECK_PTLDEBUG" ] && { \
517 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
518 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
519 echo "lnet.debug success"
521 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
524 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
525 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
526 echo "lnet.subsystem_debug success"
528 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
531 stop_ost || return $?
533 run_test 9 "test ptldebug and subsystem for mkfs"
541 do_facet $facet "test -b $dev" || rc=1
542 if [[ "$size" ]]; then
543 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k count=1 skip=$size 2>&1" |\
544 awk '($3 == "in") { print $1 }')
545 [[ $in = "1+0" ]] || rc=1
551 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
552 # But with new MDS stack we don't care about the mode of local objects
553 # anymore, so this test is removed. See bug 22944 for more details.
558 check_mount || return 41
561 echo "Remove mds config log"
562 if ! combined_mgs_mds ; then
566 do_facet mgs "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MGSDEV || return \$?" || return $?
568 if ! combined_mgs_mds ; then
573 start_mds && return 42
576 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
579 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
581 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
586 # check if current MDSSIZE is large enough
587 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
588 log "use MDSSIZE=$MDSSIZE"
590 # check if the global config has a large enough MDSSIZE
591 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
592 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
593 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
595 # check if the block device is large enough
596 [ -z "$OK" ] && $(is_blkdev $SINGLEMDS $MDSDEV $MIN) && OK=1 &&
597 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
599 # check if a loopback device has enough space for fs metadata (5%)
601 if [ -z "$OK" ]; then
602 local SPACE=$(do_facet $SINGLEMDS "[ -f $MDSDEV -o ! -e $MDSDEV ] && df -P \\\$(dirname $MDSDEV)" |
603 awk '($1 != "Filesystem") {print $4}')
604 ! [ -z "$SPACE" ] && [ $SPACE -gt $((MIN / 20)) ] && \
605 OK=1 && myMDSSIZE=$MIN && \
606 log "use file $MDSDEV with MIN=$MIN"
609 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
612 echo "mount mds with large journal..."
613 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
615 local opts="--mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
617 if combined_mgs_mds ; then
618 MDS_MKFS_OPTS="--mgs $opts"
620 MDS_MKFS_OPTS="--mgsnode=$MGSNID $opts"
624 echo "mount lustre system..."
626 check_mount || return 41
628 echo "check journal size..."
629 local FOUNDSIZE=$(do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}')
630 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
631 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
633 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
638 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
641 run_test 18 "check mkfs creates large journals"
644 start_mds || return 1
645 stop_mds -f || return 2
647 run_test 19a "start/stop MDS without OSTs"
650 start_ost || return 1
651 stop_ost -f || return 2
653 run_test 19b "start/stop OSTs without MDS"
656 # first format the ost/mdt
660 check_mount || return 43
662 remount_client ro $MOUNT || return 44
663 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
664 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
665 remount_client rw $MOUNT || return 47
667 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
668 MCNT=`grep -c $MOUNT /etc/mtab`
669 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
674 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
679 wait_osc_import_state mds ost FULL
683 run_test 21a "start mds before ost, stop ost first"
688 wait_osc_import_state mds ost FULL
692 run_test 21b "start ost before mds, stop mds first"
698 wait_osc_import_state mds ost2 FULL
702 #writeconf to remove all ost2 traces for subsequent tests
705 run_test 21c "start mds between two osts, stop mds last"
708 if combined_mgs_mds ; then
709 skip "need separate mgs device" && return 0
719 wait_osc_import_state mds ost2 FULL
726 run_test 21d "start mgs then ost and then mds"
731 echo Client mount with ost in logs, but none running
733 # wait until mds connected to ost and open client connection
734 wait_osc_import_state mds ost FULL
737 # check_mount will block trying to contact ost
738 mcreate $DIR/$tfile || return 40
739 rm -f $DIR/$tfile || return 42
743 echo Client mount with a running ost
746 # if gss enabled, wait full time to let connection from
747 # mds to ost be established, due to the mismatch between
748 # initial connect timeout and gss context negotiation timeout.
749 # This perhaps could be remove after AT landed.
750 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
751 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
754 check_mount || return 41
759 run_test 22 "start a client before osts (should return errs)"
761 test_23a() { # was test_23
765 # force down client so that recovering mds waits for reconnect
766 local running=$(grep -c $MOUNT /proc/mounts) || true
767 if [ $running -ne 0 ]; then
768 echo "Stopping client $MOUNT (opts: -f)"
772 # enter recovery on mds
774 # try to start a new client
775 mount_client $MOUNT &
777 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
778 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
779 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
781 ps --ppid $MOUNT_LUSTRE_PID
782 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
783 kill -TERM $MOUNT_LUSTRE_PID
784 echo "waiting for mount to finish"
786 # we can not wait $MOUNT_PID because it is not a child of this shell
792 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
794 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
795 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
798 [ -z "$PID1" -a -z "$PID2" ] && break
799 echo "waiting for mount to finish ... "
800 WAIT=$(( WAIT + sleep))
802 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
803 error "MOUNT_PID $MOUNT_PID and "\
804 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
810 run_test 23a "interrupt client during recovery mount delay"
815 test_23b() { # was test_23
818 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
819 lctl set_param fail_loc=0x80000313
823 run_test 23b "Simulate -EINTR during mount"
825 fs2mds_HOST=$mds_HOST
826 fs2ost_HOST=$ost_HOST
830 echo "umount $MOUNT2 ..."
831 umount $MOUNT2 || true
832 echo "stopping fs2mds ..."
833 stop fs2mds -f || true
834 echo "stopping fs2ost ..."
835 stop fs2ost -f || true
839 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
841 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
842 is_blkdev $SINGLEMDS $MDSDEV && \
843 skip_env "mixed loopback and real device not working" && return
846 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
848 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
849 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
851 # test 8-char fsname as well
852 local FSNAME2=test1234
853 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
855 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
858 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
859 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
861 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
863 check_mount || return 2
864 # files written on 1 should not show up on 2
865 cp /etc/passwd $DIR/$tfile
867 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
870 cp /etc/passwd $MOUNT2/b || return 3
871 rm $MOUNT2/b || return 4
872 # 2 is actually mounted
873 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
875 facet_failover fs2mds
876 facet_failover fs2ost
879 # the MDS must remain up until last MDT
881 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
882 [ -z "$MDS" ] && error "No MDT" && return 8
884 cleanup_nocli || return 6
886 run_test 24a "Multiple MDTs on a single node"
889 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
891 if [ -z "$fs2mds_DEV" ]; then
892 local dev=${SINGLEMDS}_dev
894 is_blkdev $SINGLEMDS $MDSDEV && \
895 skip_env "mixed loopback and real device not working" && return
898 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
900 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
902 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
905 run_test 24b "Multiple MGSs on a single node (should return err)"
909 check_mount || return 2
910 local MODULES=$($LCTL modules | awk '{ print $2 }')
911 rmmod $MODULES 2>/dev/null || true
914 run_test 25 "Verify modules are referenced"
918 # we need modules before mount for sysctl, so make sure...
919 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
920 #define OBD_FAIL_MDS_FS_SETUP 0x135
921 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
922 start_mds && echo MDS started && return 1
923 lctl get_param -n devices
924 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
925 [ $DEVS -gt 0 ] && return 2
926 unload_modules_conf || return $?
928 run_test 26 "MDT startup failure cleans LOV (should return errs)"
934 local ORIG=$(do_facet $myfacet "$TEST")
935 if [ $# -gt 3 ]; then
941 echo "Setting $PARAM from $ORIG to $FINAL"
942 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
944 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
948 start_ost || return 1
949 start_mds || return 2
950 echo "Requeue thread should have started: "
951 ps -e | grep ll_cfg_requeue
952 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
955 run_test 27a "Reacquire MGS lock if OST started first"
960 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
962 facet_failover $SINGLEMDS
963 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
964 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
968 run_test 27b "Reacquire MGS lock after failover"
972 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
973 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
976 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
977 FINAL=$(($FINAL + 1))
978 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
979 umount_client $MOUNT || return 200
982 if [ $RESULT -ne $FINAL ]; then
983 echo "New config not seen: wanted $FINAL got $RESULT"
986 echo "New config success: got $RESULT"
988 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
991 run_test 28 "permanent parameter setting"
994 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
995 setup > /dev/null 2>&1
999 local PARAM="$FSNAME-OST0001.osc.active"
1000 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
1001 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
1003 ACTV=$(lctl get_param -n $PROC_ACT)
1005 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
1006 # also check ost_server_uuid status
1007 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
1008 if [ -z "$RESULT" ]; then
1009 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
1012 echo "Live client success: got $RESULT"
1016 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0001)
1017 mdtosc=${mdtosc/-MDT*/-MDT\*}
1018 local MPROC="osc.$mdtosc.active"
1023 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
1024 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
1025 if [ $RESULT -eq $DEAC ]; then
1026 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
1030 if [ $WAIT -eq $MAX ]; then
1031 echo "MDT not deactivated: wanted $DEAC got $RESULT"
1034 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
1037 # test new client starts deactivated
1038 umount_client $MOUNT || return 200
1040 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
1041 if [ -z "$RESULT" ]; then
1042 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
1045 echo "New client success: got $RESULT"
1048 # make sure it reactivates
1049 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1051 umount_client $MOUNT
1054 #writeconf to remove all ost2 traces for subsequent tests
1057 run_test 29 "permanently remove an OST"
1062 echo Big config llog
1063 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1065 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1066 for i in ${LIST[@]}; do
1067 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1069 # make sure client restart still works
1070 umount_client $MOUNT
1071 mount_client $MOUNT || return 4
1072 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1075 echo Erase parameter setting
1076 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1077 umount_client $MOUNT
1078 mount_client $MOUNT || return 6
1080 echo "deleted (default) value=$FINAL, orig=$ORIG"
1081 # assumes this parameter started at the default value
1082 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1086 run_test 30a "Big config llog and conf_param deletion"
1091 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1092 # numerical part of it. Hopefully that's not already a failover address for
1094 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1095 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1096 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1097 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1098 echo "Using fake nid $NEW"
1100 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1101 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
1102 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1104 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1105 echo "should have 2 failover nids: $NIDCOUNT"
1106 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1107 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1108 umount_client $MOUNT
1109 mount_client $MOUNT || return 3
1111 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1113 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1114 echo "only 1 final nid should remain: $NIDCOUNT"
1115 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1119 run_test 30b "Remove failover nids"
1121 test_31() { # bug 10734
1122 # ipaddr must not exist
1123 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1126 run_test 31 "Connect to non-existent node (shouldn't crash)"
1128 # Use these start32/stop32 fn instead of t-f start/stop fn,
1129 # for local devices, to skip global facet vars init
1133 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1134 umount -d $@ ${MOUNT%/*}/${facet}
1143 mkdir -p ${MOUNT%/*}/${facet}
1145 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1146 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1148 if [ $RC -ne 0 ]; then
1149 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1150 echo "Start of ${device} of local ${facet} failed ${RC}"
1156 cleanup_nocli32 () {
1164 echo "Cleanup test_32 umount $MOUNT ..."
1165 umount -f $MOUNT || true
1166 echo "Cleanup local mds ost1 ..."
1168 combined_mgs_mds || start_mgs
1173 client_only && skip "client only testing" && return 0
1174 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1175 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1177 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1178 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1179 local tmpdir=$TMP/conf32a
1181 tar xjvf $DISK1_8 -C $tmpdir || \
1182 { skip_env "Cannot untar $DISK1_8" && return 0; }
1185 $LCTL set_param debug=$PTLDEBUG
1187 $TUNEFS $tmpdir/mds || error "tunefs failed"
1189 combined_mgs_mds || stop mgs
1191 # nids are wrong, so client wont work, but server should start
1192 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1193 trap cleanup_32 EXIT INT || return 3
1195 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1197 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1199 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1200 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1201 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1203 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1205 local NID=$($LCTL list_nids | head -1)
1207 echo "OSC changes should succeed:"
1208 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1209 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1212 echo "MDC changes should succeed:"
1213 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1214 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1217 echo "LOV changes should succeed:"
1218 $LCTL pool_new lustre.interop || return 11
1219 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1224 # mount a second time to make sure we didnt leave upgrade flag on
1226 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1228 combined_mgs_mds || stop mgs
1230 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1231 trap cleanup_32 EXIT INT || return 12
1235 rm -rf $tmpdir || true # true is only for TMP on NFS
1237 run_test 32a "Upgrade from 1.8 (not live)"
1240 client_only && skip "client only testing" && return 0
1241 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1242 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1244 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1245 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1246 local tmpdir=$TMP/conf32b
1248 tar xjvf $DISK1_8 -C $tmpdir || \
1249 { skip_env "Cannot untar $DISK1_8" && return ; }
1252 $LCTL set_param debug="config"
1253 local NEWNAME=lustre
1255 # writeconf will cause servers to register with their current nids
1256 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1257 combined_mgs_mds || stop mgs
1259 start32 mds1 $tmpdir/mds "-o loop" && \
1260 trap cleanup_32 EXIT INT || return 3
1262 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1264 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1266 $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 ||\
1267 error "tunefs failed"
1268 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1269 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1271 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1273 local NID=$($LCTL list_nids | head -1)
1275 echo "OSC changes should succeed:"
1276 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1277 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1280 echo "MDC changes should succeed:"
1281 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1282 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1285 echo "LOV changes should succeed:"
1286 $LCTL pool_new ${NEWNAME}.interop || return 11
1287 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1290 # MDT and OST should have registered with new nids, so we should have
1291 # a fully-functioning client
1292 echo "Check client and old fs contents"
1294 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1295 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1296 mount -t lustre $device $MOUNT || return 1
1298 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1299 local new=$((old + 5))
1300 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1301 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1303 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1308 rm -rf $tmpdir || true # true is only for TMP on NFS
1310 run_test 32b "Upgrade from 1.8 with writeconf"
1312 test_33a() { # bug 12333, was test_33
1314 local FSNAME2=test-123
1315 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1317 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1319 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1320 local dev=${SINGLEMDS}_dev
1321 local MDSDEV=${!dev}
1322 is_blkdev $SINGLEMDS $MDSDEV && \
1323 skip_env "mixed loopback and real device not working" && return
1326 combined_mgs_mds || mkfs_opts="$mkfs_opts --nomgs"
1328 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1329 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1330 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1331 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1333 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1334 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1335 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1337 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1340 cp /etc/hosts $MOUNT2/ || rc=3
1341 $LFS getstripe $MOUNT2/hosts
1346 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1347 cleanup_nocli || rc=6
1350 run_test 33a "Mount ost with a large index number"
1352 test_33b() { # was test_34
1355 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1356 # Drop lock cancelation reply during umount
1357 #define OBD_FAIL_LDLM_CANCEL 0x304
1358 do_facet client lctl set_param fail_loc=0x80000304
1359 #lctl set_param debug=-1
1360 umount_client $MOUNT
1363 run_test 33b "Drop cancel during umount"
1367 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1368 manual_umount_client
1370 do_facet client killall -USR1 multiop
1371 if [ $rc -eq 0 ]; then
1372 error "umount not fail!"
1377 run_test 34a "umount with opened file should be fail"
1382 touch $DIR/$tfile || return 1
1383 stop_mds --force || return 2
1385 manual_umount_client --force
1387 if [ $rc -ne 0 ]; then
1388 error "mtab after failed umount - rc $rc"
1394 run_test 34b "force umount with failed mds should be normal"
1398 touch $DIR/$tfile || return 1
1399 stop_ost --force || return 2
1401 manual_umount_client --force
1403 if [ $rc -ne 0 ]; then
1404 error "mtab after failed umount - rc $rc"
1410 run_test 34c "force umount with failed ost should be normal"
1412 test_35a() { # bug 12459
1415 DBG_SAVE="`lctl get_param -n debug`"
1416 lctl set_param debug="ha"
1418 log "Set up a fake failnode for the MDS"
1420 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1421 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1423 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1426 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1429 log "Stopping the MDT:"
1430 stop_mds || return 5
1432 df $MOUNT > /dev/null 2>&1 &
1434 log "Restarting the MDT:"
1435 start_mds || return 6
1436 log "Wait for df ($DFPID) ... "
1439 lctl set_param debug="$DBG_SAVE"
1441 # retrieve from the log the first server that the client tried to
1442 # contact after the connection loss
1443 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1444 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1445 /import_select_connection.*$device-mdc.* using connection/ {
1447 if (\\\$NF ~ /$FAKENID/)
1453 }" $TMP/lustre-log-$TESTNAME.log`
1454 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1456 # remove nid settings
1459 run_test 35a "Reconnect to the last active server first"
1461 test_35b() { # bug 18674
1462 remote_mds || { skip "local MDS" && return 0; }
1466 $LCTL set_param debug="ha"
1468 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1471 log "Set up a fake failnode for the MDS"
1473 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | \
1474 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1475 do_facet $SINGLEMDS "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1478 local at_max_saved=0
1479 # adaptive timeouts may prevent seeing the issue
1480 if at_is_enabled; then
1481 at_max_saved=$(at_max_get mds)
1482 at_max_set 0 mds client
1485 mkdir -p $MOUNT/testdir
1486 touch $MOUNT/testdir/test
1488 log "Injecting EBUSY on MDS"
1489 # Setting OBD_FAIL_MDS_RESEND=0x136
1490 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
1492 log "Stat on a test file"
1493 stat $MOUNT/testdir/test
1495 log "Stop injecting EBUSY on MDS"
1496 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
1497 rm -f $MOUNT/testdir/test
1500 # restore adaptive timeout
1501 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1503 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1505 # retrieve from the log if the client has ever tried to
1506 # contact the fake server after the loss of connection
1507 FAILCONN=`awk "BEGIN {ret = 0;}
1508 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1510 if (\\\$NF ~ /$FAKENID/) {
1515 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1517 [ "$FAILCONN" == "0" ] && \
1518 log "ERROR: The client reconnection has not been triggered" && \
1520 [ "$FAILCONN" == "2" ] && \
1521 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1525 # remove nid settings
1528 run_test 35b "Continue reconnection retries, if the active server is busy"
1531 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1533 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1534 { skip "remote OST" && return 0; }
1537 local FSNAME2=test1234
1538 local fs3ost_HOST=$ost_HOST
1539 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1541 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1543 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1544 is_blkdev $SINGLEMDS $MDSDEV && \
1545 skip_env "mixed loopback and real device not working" && return
1548 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1549 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1550 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1551 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1552 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1554 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1555 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1557 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1558 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1559 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1561 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1563 sleep 5 # until 11778 fixed
1565 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1567 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1568 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1569 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1570 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1571 DFTOTAL=`echo $STRING | cut -d, -f1`
1572 DFUSED=`echo $STRING | cut -d, -f2`
1573 DFAVAIL=`echo $STRING | cut -d, -f3`
1574 DFFREE=$(($DFTOTAL - $DFUSED))
1576 ALLOWANCE=$((64 * $OSTCOUNT))
1578 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1579 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1580 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1583 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1584 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1585 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1588 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1589 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1590 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1595 stop fs3ost -f || return 200
1596 stop fs2ost -f || return 201
1597 stop fs2mds -f || return 202
1598 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1599 unload_modules_conf || return 203
1602 run_test 36 "df report consistency on OSTs with different block size"
1605 local mntpt=$(facet_mntpt $SINGLEMDS)
1606 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
1607 local mdsdev_sym="$TMP/sym_mdt.img"
1609 echo "MDS : $mdsdev"
1610 echo "SYMLINK : $mdsdev_sym"
1611 do_facet $SINGLEMDS rm -f $mdsdev_sym
1613 do_facet $SINGLEMDS ln -s $mdsdev $mdsdev_sym
1615 echo "mount symlink device - $mdsdev_sym"
1618 mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $MDS_MOUNT_OPTS $mdsdev_sym $mntpt 2>&1 )
1621 echo mount_op=$mount_op
1623 do_facet $SINGLEMDS "umount -d $mntpt && rm -f $mdsdev_sym"
1625 if $(echo $mount_op | grep -q "unable to set tunable"); then
1626 error "set tunables failed for symlink device"
1629 [ $rc -eq 0 ] || error "mount symlink $mdsdev_sym failed! rc=$rc"
1633 run_test 37 "verify set tunables works for symlink device"
1635 test_38() { # bug 14222
1640 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1641 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1643 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1644 error "copying $SRC to $DIR/$tdir"
1646 umount_client $MOUNT
1648 log "rename lov_objid file on MDS"
1649 rm -f $TMP/lov_objid.orig
1651 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1652 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1653 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1655 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1656 # check create in mds_lov_connect
1660 [ $V ] && log "verifying $DIR/$tdir/$f"
1661 diff -q $f $DIR/$tdir/$f || ERROR=y
1663 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1664 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1665 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1667 # check it's updates in sync
1668 umount_client $MOUNT
1671 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1672 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1673 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1678 [ $V ] && log "verifying $DIR/$tdir/$f"
1679 diff -q $f $DIR/$tdir/$f || ERROR=y
1681 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1682 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1683 umount_client $MOUNT
1685 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1687 log "files compared the same"
1690 run_test 38 "MDS recreates missing lov_objid file from OST data"
1696 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1697 error "memory leak detected" || true
1699 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1701 test_40() { # bug 15759
1703 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1704 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1708 run_test 40 "race during service thread startup"
1710 test_41a() { #bug 14134
1711 echo $MDS_MOUNT_OPTS | grep "loop" && skip " loop devices does not work with nosvc option" && return
1714 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1716 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1717 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1718 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1720 mount_client $MOUNT || return 1
1723 echo "blah blah" > $MOUNT/$tfile
1726 umount_client $MOUNT
1727 stop ost1 -f || return 201
1728 stop_mds -f || return 202
1729 stop_mds -f || return 203
1730 unload_modules_conf || return 204
1733 run_test 41a "mount mds with --nosvc and --nomgs"
1736 echo $MDS_MOUNT_OPTS | grep "loop" && skip " loop devices does not work with nosvc option" && return
1740 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1742 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1744 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1746 mount_client $MOUNT || return 1
1749 echo "blah blah" > $MOUNT/$tfile
1750 cat $MOUNT/$tfile || return 200
1752 umount_client $MOUNT
1753 stop_ost || return 201
1754 stop_mds -f || return 202
1755 stop_mds -f || return 203
1759 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
1760 test_42() { #bug 14693
1762 check_mount || return 2
1763 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1764 umount_client $MOUNT
1765 mount_client $MOUNT || return 1
1769 run_test 42 "invalid config param should not prevent client from mounting"
1772 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1774 chmod ugo+x $DIR || error "chmod 0 failed"
1776 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1777 "$FSNAME.mdt.root_squash" \
1780 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1781 "$FSNAME.mdt.nosquash_nids" \
1785 # create set of test files
1787 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1788 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1789 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1791 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1792 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1794 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1795 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1796 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1799 # check root_squash:
1800 # set root squash UID:GID to RUNAS_ID
1801 # root should be able to access only files owned by RUNAS_ID
1804 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1805 "$FSNAME.mdt.root_squash" \
1806 "$RUNAS_ID:$RUNAS_ID"
1808 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1809 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1810 error "$ST: root read permission is denied"
1811 echo "$ST: root read permission is granted - ok"
1814 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1815 error "$ST: root write permission is denied"
1816 echo "$ST: root write permission is granted - ok"
1818 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1819 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1820 error "$ST: root read permission is granted"
1821 echo "$ST: root read permission is denied - ok"
1824 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1825 error "$ST: root write permission is granted"
1826 echo "$ST: root write permission is denied - ok"
1828 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1829 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1830 error "$ST: root unlink permission is granted"
1831 echo "$ST: root unlink permission is denied - ok"
1833 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1834 error "$ST: root create permission is granted"
1835 echo "$ST: root create permission is denied - ok"
1838 # check nosquash_nids:
1839 # put client's NID into nosquash_nids list,
1840 # root should be able to access root file after that
1842 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1843 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1844 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1846 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1847 "$FSNAME-MDTall.mdt.nosquash_nids" \
1850 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1851 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1852 error "$ST: root read permission is denied"
1853 echo "$ST: root read permission is granted - ok"
1856 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1857 error "$ST: root write permission is denied"
1858 echo "$ST: root write permission is granted - ok"
1860 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1861 rm $DIR/$tdir-rootdir/tfile-1 || \
1862 error "$ST: root unlink permission is denied"
1863 echo "$ST: root unlink permission is granted - ok"
1864 touch $DIR/$tdir-rootdir/tfile-2 || \
1865 error "$ST: root create permission is denied"
1866 echo "$ST: root create permission is granted - ok"
1870 run_test 43 "check root_squash and nosquash_nids"
1872 umount_client $MOUNT
1877 check_mount || return 2
1878 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1880 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1881 for VAL in $UUIDS; do
1882 NID=$(echo $VAL | cut -d= -f1)
1883 CLUUID=$(echo $VAL | cut -d= -f2)
1884 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1886 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1890 run_test 44 "mounted client proc entry exists"
1894 check_mount || return 2
1899 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1900 do_facet client "lctl set_param fail_loc=0x50f"
1903 manual_umount_client --force || return 3
1904 do_facet client "lctl set_param fail_loc=0x0"
1906 mount_client $MOUNT || return 4
1910 run_test 45 "long unlink handling in ptlrpcd"
1917 umount_client $MOUNT2 || rc=$?
1918 umount_client $MOUNT || rc=$?
1919 while [ $count -gt 0 ]; do
1920 stop ost${count} -f || rc=$?
1924 cleanup_nocli || rc=$?
1925 #writeconf to remove all ost2 traces for subsequent tests
1931 echo "Testing with $OSTCOUNT OSTs"
1933 start_mds || return 1
1934 #first client should see only one ost
1935 start_ost || return 2
1936 wait_osc_import_state mds ost FULL
1938 mount_client $MOUNT || return 3
1939 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1942 for (( i=2; i<=$OSTCOUNT; i++ )); do
1943 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1946 # wait until osts in sync
1947 for (( i=2; i<=$OSTCOUNT; i++ )); do
1948 wait_osc_import_state mds ost$i FULL
1952 #second client see all ost's
1954 mount_client $MOUNT2 || return 8
1955 $LFS setstripe $MOUNT2 -c -1 || return 9
1956 $LFS getstripe $MOUNT2 || return 10
1958 echo "ok" > $MOUNT2/widestripe
1959 $LFS getstripe $MOUNT2/widestripe || return 11
1960 # fill acl buffer for avoid expand lsm to them
1961 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1962 setfacl -m $acl $MOUNT2/widestripe
1966 stat $MOUNT/widestripe || return 12
1968 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1971 run_test 46a "handle ost additional - wide striped file"
1976 check_mount || return 2
1977 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1981 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1982 if echo $ns | grep "MDT[[:digit:]]*"; then
1985 lrs=$(echo $ns | sed 's/.*lru_size=//')
1986 lru_size[count]=$lrs
1991 facet_failover $SINGLEMDS
1992 client_up || return 3
1995 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1996 if echo $ns | grep "MDT[[:digit:]]*"; then
1999 lrs=$(echo $ns | sed 's/.*lru_size=//')
2000 if ! test "$lrs" -eq "${lru_size[count]}"; then
2001 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
2002 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
2010 run_test 47 "server restart does not make client loss lru_resize settings"
2015 # reformat after this test is needed - if test will failed
2016 # we will have unkillable file at FS
2020 test_48() { # bug 17636
2023 check_mount || return 2
2025 $LFS setstripe $MOUNT -c -1 || return 9
2026 $LFS getstripe $MOUNT || return 10
2028 echo "ok" > $MOUNT/widestripe
2029 $LFS getstripe $MOUNT/widestripe || return 11
2031 trap cleanup_48 EXIT ERR
2033 # fill acl buffer for avoid expand lsm to them
2034 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
2035 setfacl -m $acl $MOUNT/widestripe
2038 stat $MOUNT/widestripe || return 12
2043 run_test 48 "too many acls on file"
2045 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
2046 test_49() { # bug 17710
2047 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
2048 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
2049 local LOCAL_TIMEOUT=20
2052 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
2056 check_mount || return 1
2058 echo "check ldlm_timout..."
2059 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2060 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2061 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2063 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2064 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2067 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
2068 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2071 umount_client $MOUNT
2072 stop_ost || return 2
2073 stop_mds || return 3
2075 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$((LOCAL_TIMEOUT - 1)) $MKFSOPT $OSTOPT"
2079 check_mount || return 7
2081 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
2082 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
2083 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
2085 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
2086 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2089 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2090 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2093 cleanup || return $?
2095 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
2096 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
2098 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
2101 # Test both statfs and lfs df and fail if either one fails
2102 multiop_bg_pause $1 f_
2105 killall -USR1 multiop
2106 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2107 wait $PID || { RC1=$?; log "multiop return error "; }
2114 if [ $RC2 -eq 0 ]; then
2116 log "lazystatfs df failed"
2120 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2126 lctl set_param llite.$FSNAME-*.lazystatfs=1
2129 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2131 cleanup || return $?
2133 run_test 50a "lazystatfs all servers available =========================="
2137 lctl set_param llite.$FSNAME-*.lazystatfs=1
2140 # Wait for client to detect down OST
2141 stop_ost || error "Unable to stop OST1"
2142 wait_osc_import_state mds ost DISCONN
2144 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2146 umount_client $MOUNT || error "Unable to unmount client"
2147 stop_mds || error "Unable to stop MDS"
2149 run_test 50b "lazystatfs all servers down =========================="
2152 start_mds || error "Unable to start MDS"
2153 start_ost || error "Unable to start OST1"
2154 start_ost2 || error "Unable to start OST2"
2155 mount_client $MOUNT || error "Unable to mount client"
2156 lctl set_param llite.$FSNAME-*.lazystatfs=1
2159 # Wait for client to detect down OST
2160 stop_ost || error "Unable to stop OST1"
2161 wait_osc_import_state mds ost DISCONN
2162 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2164 umount_client $MOUNT || error "Unable to unmount client"
2165 stop_ost2 || error "Unable to stop OST2"
2166 stop_mds || error "Unable to stop MDS"
2168 run_test 50c "lazystatfs one server down =========================="
2171 start_mds || error "Unable to start MDS"
2172 start_ost || error "Unable to start OST1"
2173 start_ost2 || error "Unable to start OST2"
2174 mount_client $MOUNT || error "Unable to mount client"
2175 lctl set_param llite.$FSNAME-*.lazystatfs=1
2178 # Issue the statfs during the window where the client still
2179 # belives the OST to be available but it is in fact down.
2180 # No failure just a statfs which hangs for a timeout interval.
2181 stop_ost || error "Unable to stop OST1"
2182 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2184 umount_client $MOUNT || error "Unable to unmount client"
2185 stop_ost2 || error "Unable to stop OST2"
2186 stop_mds || error "Unable to stop MDS"
2188 run_test 50d "lazystatfs client/server conn race =========================="
2195 start_mds || return 1
2196 #first client should see only one ost
2197 start_ost || return 2
2198 wait_osc_import_state mds ost FULL
2200 # Wait for client to detect down OST
2201 stop_ost || error "Unable to stop OST1"
2202 wait_osc_import_state mds ost DISCONN
2204 mount_client $MOUNT || error "Unable to mount client"
2205 lctl set_param llite.$FSNAME-*.lazystatfs=0
2207 multiop_bg_pause $MOUNT _f
2211 if [ $RC1 -ne 0 ]; then
2212 log "multiop failed $RC1"
2215 sleep $(( $TIMEOUT+1 ))
2217 [ $? -ne 0 ] && error "process isn't sleep"
2218 start_ost || error "Unable to start OST1"
2219 wait $pid || error "statfs failed"
2222 umount_client $MOUNT || error "Unable to unmount client"
2223 stop_ost || error "Unable to stop OST1"
2224 stop_mds || error "Unable to stop MDS"
2226 run_test 50e "normal statfs all servers down =========================="
2231 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2233 start_mds || error "Unable to start mds"
2234 #first client should see only one ost
2235 start_ost || error "Unable to start OST1"
2236 wait_osc_import_state mds ost FULL
2238 start_ost2 || error "Unable to start OST2"
2239 wait_osc_import_state mds ost2 FULL
2241 # Wait for client to detect down OST
2242 stop_ost2 || error "Unable to stop OST2"
2244 wait_osc_import_state mds ost2 DISCONN
2245 mount_client $MOUNT || error "Unable to mount client"
2246 lctl set_param llite.$FSNAME-*.lazystatfs=0
2248 multiop_bg_pause $MOUNT _f
2252 if [ $RC1 -ne 0 ]; then
2253 log "lazystatfs multiop failed $RC1"
2256 sleep $(( $TIMEOUT+1 ))
2258 [ $? -ne 0 ] && error "process isn't sleep"
2259 start_ost2 || error "Unable to start OST2"
2260 wait $pid || error "statfs failed"
2261 stop_ost2 || error "Unable to stop OST2"
2264 umount_client $MOUNT || error "Unable to unmount client"
2265 stop_ost || error "Unable to stop OST1"
2266 stop_mds || error "Unable to stop MDS"
2267 #writeconf to remove all ost2 traces for subsequent tests
2270 run_test 50f "normal statfs one server in down =========================="
2273 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2275 start_ost2 || error "Unable to start OST2"
2276 wait_osc_import_state mds ost2 FULL
2277 wait_osc_import_state client ost2 FULL
2279 local PARAM="${FSNAME}-OST0001.osc.active"
2281 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2282 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2284 umount_client $MOUNT || error "Unable to unmount client"
2285 mount_client $MOUNT || error "Unable to mount client"
2286 # This df should not cause a panic
2289 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2291 umount_client $MOUNT || error "Unable to unmount client"
2292 stop_ost2 || error "Unable to stop OST2"
2293 stop_ost || error "Unable to stop OST1"
2294 stop_mds || error "Unable to stop MDS"
2295 #writeconf to remove all ost2 traces for subsequent tests
2298 run_test 50g "deactivated OST should not cause panic====================="
2301 local LOCAL_TIMEOUT=20
2305 check_mount || return 1
2308 $LFS setstripe -c -1 $MOUNT/d1
2309 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2310 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2311 touch $MOUNT/d1/f1 &
2314 start_ost2 || return 2
2316 stop_ost2 || return 3
2319 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2328 do_node $node mkdir -p $dest
2329 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2331 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2332 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2333 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2335 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2336 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2346 local backup2=${TMP}/backup2
2348 do_node $node mkdir -p $backup2
2349 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2351 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2352 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2353 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2355 do_node $node "diff -rq $backup $backup2"
2356 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2358 local xattrs2=${TMP}/xattrs2
2359 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2360 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2362 do_node $node "diff $xattrs $xattrs2"
2363 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2365 do_node $node "rm -rf $backup2 $xattrs2"
2366 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2371 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2373 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2375 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2378 local ost1mnt=${MOUNT%/*}/ost1
2379 local ost1node=$(facet_active_host ost1)
2380 local ost1tmp=$TMP/conf52
2383 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2384 touch $TMP/modified_first
2385 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2386 local mtime=$(stat -c %Y $TMP/modified_first)
2387 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2389 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2392 $LFS setstripe $DIR/$tdir -c -1 -s 1M
2393 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2395 for (( i=0; i < nrfiles; i++ )); do
2396 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2397 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2403 echo backup files to $TMP/files
2404 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2405 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2406 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2408 umount_client $MOUNT
2409 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2411 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2413 echo mount ost1 as ldiskfs
2414 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2415 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2418 echo backup objects to $ost1tmp/objects
2419 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2420 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2421 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2422 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2424 # move objects to lost+found
2425 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2426 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2429 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2430 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2432 # compare restored objects against saved ones
2433 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2434 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2436 do_node $ost1node "umount $ost1_dev"
2437 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2440 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2442 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2445 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2446 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2448 rm -rf $TMP/files $TMP/file_xattrs
2449 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2450 do_node $ost1node "rm -rf $ost1tmp"
2451 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2454 run_test 52 "check recovering objects from lost+found"
2456 # Checks threads_min/max/started for some service
2458 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2459 # parameter pattern prefix like 'ost.*.ost'.
2471 local msg="Insane $modname thread counts"
2475 check_mount || return 41
2477 # We need to expand $parampat, but it may match multiple parameters, so
2478 # we'll pick the first one
2479 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2480 error "Couldn't expand ${parampat}.threads_min parameter name"
2484 # Remove the .threads_min part
2485 paramp=${paramp%.threads_min}
2487 # Check for sanity in defaults
2488 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2489 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2490 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2491 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2492 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
2494 # Check that we can change min/max
2495 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin + 1))"
2496 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 1))"
2497 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2498 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2499 lassert 25 "$msg" '(($tmin2 == ($tmin + 1) && $tmax2 == ($tmax -1)))' || return $?
2501 # Check that we can set min/max to the same value
2502 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2503 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2504 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2505 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2506 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2508 # Check that we can't set max < min
2509 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2510 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2511 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2512 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
2514 # We need to ensure that we get the module options desired; to do this
2515 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2516 LOAD_MODULES_REMOTE=true
2519 setmodopts -a $modname "$opts" oldvalue
2523 check_mount || return 41
2525 # Restore previous setting of MODOPTS_*
2526 setmodopts $modname "$oldvalue"
2528 # Check that $opts took
2529 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2530 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2531 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2532 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2535 # Workaround a YALA bug where YALA expects that modules will remain
2536 # loaded on the servers
2537 LOAD_MODULES_REMOTE=false
2544 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2546 run_test 53a "check OSS thread count params"
2549 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2551 run_test 53b "check MDT thread count params"
2556 local partial_arg=""
2557 local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
2559 # Run in partial (fast) mode if the size
2560 # of a partition > 10 GB
2561 [ $size -gt 10 ] && partial_arg="-p"
2563 llverfs $partial_arg $dir
2567 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
2568 [ $? -eq 0 ] || error "llverdev failed!"
2571 run_test 54a "llverdev"
2576 [ $? -eq 0 ] || error "llverfs failed!"
2579 run_test 54b "llverfs"
2583 local max_ost_index=$1
2584 echo -n $(((max_ost_index + 1) * 8))
2588 local mdsdev=$(mdsdevname 1)
2589 local ostdev=$(ostdevname 1)
2590 local saved_opts=$OST_MKFS_OPTS
2592 for i in 0 1023 2048
2594 OST_MKFS_OPTS="$saved_opts --index $i"
2602 echo checking size of lov_objid for ost index $i
2603 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2604 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2605 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2607 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2612 OST_MKFS_OPTS=$saved_opts
2615 run_test 55 "check lov_objid size"
2618 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2619 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2620 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2624 start_ost2 || error "Unable to start second ost"
2625 mount_client $MOUNT || error "Unable to mount client"
2628 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
2632 run_test 56 "check big indexes"
2634 test_57() { # bug 22656
2635 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2637 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2639 start_ost && error "OST registration from failnode should fail"
2643 run_test 57 "initial registration from failnode should fail (should return errs)"
2646 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2650 start_mgsmds >> /dev/null
2651 local C1=$(count_osts)
2652 if [ $C1 -eq 0 ]; then
2653 start_ost >> /dev/null
2657 echo "original ost count: $C1 (expect > 0)"
2658 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2659 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2660 local C2=$(count_osts)
2661 echo "after mdt writeconf count: $C2 (expect 0)"
2662 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2663 echo "OST start without writeconf should fail:"
2664 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2665 echo "OST start with writeconf should succeed:"
2666 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2667 local C3=$(count_osts)
2668 echo "after ost writeconf count: $C3 (expect 1)"
2669 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2670 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2671 local C4=$(count_osts)
2672 echo "after ost2 writeconf count: $C4 (expect 2)"
2673 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2674 stop_ost2 >> /dev/null
2675 cleanup_nocli >> /dev/null
2677 run_test 59 "writeconf mount option"
2680 test_58() { # bug 22658
2681 [ "$FSTYPE" != "ldiskfs" ] && skip "not supported for $FSTYPE" && return
2684 createmany -o $DIR/$tdir/$tfile-%d 100
2685 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
2686 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
2687 do_facet mds "lctl set_param fail_loc=0x601"
2688 unlinkmany $DIR/$tdir/$tfile-%d 100
2690 local MNTDIR=$(facet_mntpt mds)
2691 # remove all files from the OBJECTS dir
2692 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
2693 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
2694 do_facet mds "umount $MNTDIR"
2695 # restart MDS with missing llog files
2697 do_facet mds "lctl set_param fail_loc=0"
2700 run_test 58 "missing llog files must not prevent MDT from mounting"
2702 if ! combined_mgs_mds ; then
2708 complete $(basename $0) $SECONDS