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 # STORED_MDSSIZE is used in test_18
43 if [ -n "$MDSSIZE" ]; then
44 STORED_MDSSIZE=$MDSSIZE
50 require_dsh_mds || exit 0
51 require_dsh_ost || exit 0
53 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
68 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
69 do_facet ${facet} "$TUNEFS --quiet --writeconf $dev" ||
70 { echo "tunefs failed, reformatting instead" && reformat_and_config && return 1; }
77 # if writeconf fails anywhere, we reformat everything
78 writeconf1 mds `mdsdevname 1` || return 0
79 writeconf1 ost1 `ostdevname 1` || return 0
80 writeconf1 ost2 `ostdevname 2` || return 0
84 # The MGS must be started before the OSTs for a new fs, so start
85 # and stop to generate the startup logs.
88 wait_osc_import_state mds ost FULL
93 reformat_and_config() {
95 if ! combined_mgs_mds ; then
103 start mgs $MGSDEV $MGS_MOUNT_OPTS
107 local facet=$SINGLEMDS
108 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
109 local num=$(echo $facet | tr -d "mds")
110 local dev=$(mdsdevname $num)
111 echo "start mds service on `facet_active_host $facet`"
112 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
116 if ! combined_mgs_mds ; then
123 echo "stop mds service on `facet_active_host $SINGLEMDS`"
124 # These tests all use non-failover stop
125 stop $SINGLEMDS -f || return 97
129 echo "start ost1 service on `facet_active_host ost1`"
130 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
134 echo "stop ost1 service on `facet_active_host ost1`"
135 # These tests all use non-failover stop
136 stop ost1 -f || return 98
140 echo "start ost2 service on `facet_active_host ost2`"
141 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
145 echo "stop ost2 service on `facet_active_host ost2`"
146 # These tests all use non-failover stop
147 stop ost2 -f || return 93
152 echo "mount $FSNAME on ${MOUNTPATH}....."
153 zconf_mount `hostname` $MOUNTPATH || return 96
157 local SAVEMOUNTOPT=$MOUNTOPT
158 MOUNTOPT="remount,$1"
160 echo "remount '$1' lustre on ${MOUNTPATH}....."
161 zconf_mount `hostname` $MOUNTPATH || return 96
162 MOUNTOPT=$SAVEMOUNTOPT
167 echo "umount lustre on ${MOUNTPATH}....."
168 zconf_umount `hostname` $MOUNTPATH || return 97
171 manual_umount_client(){
174 echo "manual umount lustre on ${MOUNT}...."
175 do_facet client "umount -d ${FORCE} $MOUNT"
181 start_mds || error "MDT start failed"
182 start_ost || error "OST start failed"
183 mount_client $MOUNT || error "client start failed"
187 if ! combined_mgs_mds ; then
197 stop_ost || return 202
198 stop_mds || return 201
199 unload_modules || return 203
203 umount_client $MOUNT || return 200
204 cleanup_nocli || return $?
208 do_facet client "cp /etc/passwd $DIR/a" || return 71
209 do_facet client "rm $DIR/a" || return 72
210 # make sure lustre is actually mounted (touch will block,
211 # but grep won't, so do it after)
212 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
213 echo "setup single mount lustre success"
217 do_facet client "touch $DIR/a" || return 71
218 do_facet client "rm $DIR/a" || return 72
219 do_facet client "touch $DIR2/a" || return 73
220 do_facet client "rm $DIR2/a" || return 74
221 echo "setup double mount lustre success"
226 if [ "$ONLY" == "setup" ]; then
231 if [ "$ONLY" == "cleanup" ]; then
238 #create single point mountpoint
244 check_mount || return 41
247 run_test 0 "single mount setup"
250 start_mds || error "MDT start failed"
252 echo "start ost second time..."
253 start_ost && error "2nd OST start should fail"
254 mount_client $MOUNT || error "client start failed"
255 check_mount || return 42
258 run_test 1 "start up ost twice (should return errors)"
262 echo "start mds second time.."
263 start_mds && error "2nd MDT start should fail"
266 check_mount || return 43
269 run_test 2 "start up mds twice (should return err)"
273 #mount.lustre returns an error if already in mtab
274 mount_client $MOUNT && error "2nd client mount should fail"
275 check_mount || return 44
278 run_test 3 "mount client twice (should return err)"
282 touch $DIR/$tfile || return 85
286 # ok for ost to fail shutdown
287 if [ 202 -ne $eno ]; then
292 run_test 4 "force cleanup ost, then cleanup"
294 test_5a() { # was test_5
296 touch $DIR/$tfile || return 1
297 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
299 stop_mds -f || return 2
301 # cleanup may return an error from the failed
302 # disconnects; for now I'll consider this successful
303 # if all the modules have unloaded.
307 echo "killing umount"
308 kill -TERM $UMOUNT_PID
309 echo "waiting for umount to finish"
311 if grep " $MOUNT " /proc/mounts; then
312 echo "test 5: /proc/mounts after failed umount"
316 echo "killing umount"
317 kill -TERM $UMOUNT_PID
318 echo "waiting for umount to finish"
320 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
324 # stop_mds is a no-op here, and should not fail
325 cleanup_nocli || return $?
326 # df may have lingering entry
328 # mtab may have lingering entry
332 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
334 grep -q $MOUNT" " /etc/mtab || break
335 echo "Waiting /etc/mtab updated ... "
336 WAIT=$(( WAIT + sleep))
338 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
339 echo "/etc/mtab updated in $WAIT secs"
341 run_test 5a "force cleanup mds, then cleanup"
345 [ -d $MOUNT ] || mkdir -p $MOUNT
346 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
347 mount_client $MOUNT && return 1
348 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
350 # stop_mds is a no-op here, and should not fail
351 cleanup_nocli || return $?
354 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
359 [ -d $MOUNT ] || mkdir -p $MOUNT
360 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
361 local oldfs="${FSNAME}"
362 FSNAME="wrong.${FSNAME}"
363 mount_client $MOUNT || :
365 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
367 cleanup_nocli || return $?
369 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
375 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
376 mount_client $MOUNT || return 1
378 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
381 run_test 5d "mount with ost down"
387 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
388 do_facet client "lctl set_param fail_loc=0x80000506"
389 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
390 mount_client $MOUNT || echo "mount failed (not fatal)"
392 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
395 run_test 5e "delayed connect, don't crash (bug 10268)"
400 mount_client ${MOUNT} || return 87
401 touch $DIR/a || return 86
404 run_test 6 "manual umount, then mount again"
409 cleanup_nocli || return $?
411 run_test 7 "manual umount, then cleanup"
416 check_mount2 || return 45
417 umount_client $MOUNT2
420 run_test 8 "double mount setup"
425 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
426 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
428 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
429 if [ "$CHECK_PTLDEBUG" ] && { \
430 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
431 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
432 echo "lnet.debug success"
434 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
437 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
438 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
439 echo "lnet.subsystem_debug success"
441 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
444 stop_ost || return $?
446 run_test 9 "test ptldebug and subsystem for mkfs"
449 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
450 # But with new MDS stack we don't care about the mode of local objects
451 # anymore, so this test is removed. See bug 22944 for more details.
455 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
457 if [ ! -e "$MDSDEV" ]; then
458 echo "no $MDSDEV existing, so mount Lustre to create one"
460 check_mount || return 41
464 echo "Remove mds config log"
465 do_facet $SINGLEMDS "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
468 start_mds && return 42
471 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
474 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
476 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
481 # check if current MDSSIZE is large enough
482 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
483 log "use MDSSIZE=$MDSSIZE"
485 # check if the global config has a large enough MDSSIZE
486 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
487 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
488 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
490 # check if the block device is large enough
491 [ -z "$OK" -a -b $MDSDEV ] && \
492 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
493 awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
494 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
496 # check if a loopback device has enough space for fs metadata (5%)
497 [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
498 SPACE=$(df -P $(dirname $MDSDEV) |
499 awk '($1 != "Filesystem") {print $4}') &&
500 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
501 log "use file $MDSDEV with MIN=$MIN"
503 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
506 echo "mount mds with large journal..."
507 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
509 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
512 echo "mount lustre system..."
514 check_mount || return 41
516 echo "check journal size..."
517 local FOUNDSIZE=`do_facet mds "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
518 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
519 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
521 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
526 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
529 run_test 18 "check mkfs creates large journals"
532 start_mds || return 1
533 stop_mds -f || return 2
535 run_test 19a "start/stop MDS without OSTs"
538 start_ost || return 1
539 stop_ost -f || return 2
541 run_test 19b "start/stop OSTs without MDS"
544 # first format the ost/mdt
548 check_mount || return 43
550 remount_client ro $MOUNT || return 44
551 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
552 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
553 remount_client rw $MOUNT || return 47
555 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
556 MCNT=`grep -c $MOUNT /etc/mtab`
557 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
562 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
567 wait_osc_import_state mds ost FULL
571 run_test 21a "start mds before ost, stop ost first"
576 wait_osc_import_state mds ost FULL
580 run_test 21b "start ost before mds, stop mds first"
586 wait_osc_import_state mds ost2 FULL
590 #writeconf to remove all ost2 traces for subsequent tests
593 run_test 21c "start mds between two osts, stop mds last"
598 echo Client mount with ost in logs, but none running
600 # wait until mds connected to ost and open client connection
601 wait_osc_import_state mds ost FULL
604 # check_mount will block trying to contact ost
605 mcreate $DIR/$tfile || return 40
606 rm -f $DIR/$tfile || return 42
610 echo Client mount with a running ost
613 # if gss enabled, wait full time to let connection from
614 # mds to ost be established, due to the mismatch between
615 # initial connect timeout and gss context negotiation timeout.
616 # This perhaps could be remove after AT landed.
617 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
618 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
621 check_mount || return 41
626 run_test 22 "start a client before osts (should return errs)"
628 test_23a() { # was test_23
632 # force down client so that recovering mds waits for reconnect
633 local running=$(grep -c $MOUNT /proc/mounts) || true
634 if [ $running -ne 0 ]; then
635 echo "Stopping client $MOUNT (opts: -f)"
639 # enter recovery on mds
641 # try to start a new client
642 mount_client $MOUNT &
644 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
645 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
646 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
648 ps --ppid $MOUNT_LUSTRE_PID
649 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
650 kill -TERM $MOUNT_LUSTRE_PID
651 echo "waiting for mount to finish"
653 # we can not wait $MOUNT_PID because it is not a child of this shell
659 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
661 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
662 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
665 [ -z "$PID1" -a -z "$PID2" ] && break
666 echo "waiting for mount to finish ... "
667 WAIT=$(( WAIT + sleep))
669 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
670 error "MOUNT_PID $MOUNT_PID and "\
671 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
677 run_test 23a "interrupt client during recovery mount delay"
682 test_23b() { # was test_23
685 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
686 lctl set_param fail_loc=0x80000313
690 run_test 23b "Simulate -EINTR during mount"
692 fs2mds_HOST=$mds_HOST
693 fs2ost_HOST=$ost_HOST
697 echo "umount $MOUNT2 ..."
698 umount $MOUNT2 || true
699 echo "stopping fs2mds ..."
700 stop fs2mds -f || true
701 echo "stopping fs2ost ..."
702 stop fs2ost -f || true
710 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
712 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
713 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
714 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
715 skip_env "mixed loopback and real device not working" && return
718 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
719 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
721 # test 8-char fsname as well
722 local FSNAME2=test1234
723 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
725 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
728 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
729 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
731 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
733 check_mount || return 2
734 # files written on 1 should not show up on 2
735 cp /etc/passwd $DIR/$tfile
737 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
740 cp /etc/passwd $MOUNT2/b || return 3
741 rm $MOUNT2/b || return 4
742 # 2 is actually mounted
743 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
745 facet_failover fs2mds
746 facet_failover fs2ost
749 # the MDS must remain up until last MDT
751 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
752 [ -z "$MDS" ] && error "No MDT" && return 8
754 cleanup_nocli || return 6
756 run_test 24a "Multiple MDTs on a single node"
759 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
761 if [ -z "$fs2mds_DEV" ]; then
762 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
763 skip_env "mixed loopback and real device not working" && return
766 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
768 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
770 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
773 run_test 24b "Multiple MGSs on a single node (should return err)"
777 check_mount || return 2
778 local MODULES=$($LCTL modules | awk '{ print $2 }')
779 rmmod $MODULES 2>/dev/null || true
782 run_test 25 "Verify modules are referenced"
786 # we need modules before mount for sysctl, so make sure...
787 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
788 #define OBD_FAIL_MDS_FS_SETUP 0x135
789 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
790 start_mds && echo MDS started && return 1
791 lctl get_param -n devices
792 DEVS=$(lctl get_param -n devices | wc -l)
793 [ $DEVS -gt 0 ] && return 2
794 unload_modules || return 203
796 run_test 26 "MDT startup failure cleans LOV (should return errs)"
802 local ORIG=$(do_facet $myfacet "$TEST")
803 if [ $# -gt 3 ]; then
809 echo "Setting $PARAM from $ORIG to $FINAL"
810 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
812 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
816 start_ost || return 1
817 start_mds || return 2
818 echo "Requeue thread should have started: "
819 ps -e | grep ll_cfg_requeue
820 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
823 run_test 27a "Reacquire MGS lock if OST started first"
828 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
830 facet_failover $SINGLEMDS
831 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
832 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
836 run_test 27b "Reacquire MGS lock after failover"
840 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
841 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
844 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
845 FINAL=$(($FINAL + 1))
846 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
847 umount_client $MOUNT || return 200
850 if [ $RESULT -ne $FINAL ]; then
851 echo "New config not seen: wanted $FINAL got $RESULT"
854 echo "New config success: got $RESULT"
856 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
859 run_test 28 "permanent parameter setting"
862 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
863 setup > /dev/null 2>&1
867 local PARAM="$FSNAME-OST0001.osc.active"
868 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
869 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
871 ACTV=$(lctl get_param -n $PROC_ACT)
873 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
874 # also check ost_server_uuid status
875 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
876 if [ -z "$RESULT" ]; then
877 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
880 echo "Live client success: got $RESULT"
884 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0001)
885 mdtosc=${mdtosc/-MDT*/-MDT\*}
886 local MPROC="osc.$mdtosc.active"
891 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
892 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
893 if [ $RESULT -eq $DEAC ]; then
894 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
898 if [ $WAIT -eq $MAX ]; then
899 echo "MDT not deactivated: wanted $DEAC got $RESULT"
902 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
905 # test new client starts deactivated
906 umount_client $MOUNT || return 200
908 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
909 if [ -z "$RESULT" ]; then
910 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
913 echo "New client success: got $RESULT"
916 # make sure it reactivates
917 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
922 #writeconf to remove all ost2 traces for subsequent tests
925 run_test 29 "permanently remove an OST"
931 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
933 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
934 for i in ${LIST[@]}; do
935 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
937 # make sure client restart still works
939 mount_client $MOUNT || return 4
940 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
943 echo Erase parameter setting
944 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
946 mount_client $MOUNT || return 6
948 echo "deleted (default) value=$FINAL, orig=$ORIG"
949 # assumes this parameter started at the default value
950 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
954 run_test 30a "Big config llog and conf_param deletion"
959 # Make a fake nid. Use the OST nid, and add 20 to the least significant
960 # numerical part of it. Hopefully that's not already a failover address for
962 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
963 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
964 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
965 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
966 echo "Using fake nid $NEW"
968 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
969 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
970 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
972 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
973 echo "should have 2 failover nids: $NIDCOUNT"
974 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
975 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
977 mount_client $MOUNT || return 3
979 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
981 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
982 echo "only 1 final nid should remain: $NIDCOUNT"
983 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
987 run_test 30b "Remove failover nids"
989 test_31() { # bug 10734
990 # ipaddr must not exist
991 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
994 run_test 31 "Connect to non-existent node (shouldn't crash)"
996 # Use these start32/stop32 fn instead of t-f start/stop fn,
997 # for local devices, to skip global facet vars init
1001 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1002 umount -d $@ ${MOUNT%/*}/${facet}
1011 mkdir -p ${MOUNT%/*}/${facet}
1013 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1014 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1016 if [ $RC -ne 0 ]; then
1017 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1018 echo "Start of ${device} of local ${facet} failed ${RC}"
1024 cleanup_nocli32 () {
1032 echo "Cleanup test_32 umount $MOUNT ..."
1033 umount -f $MOUNT || true
1034 echo "Cleanup local mds ost1 ..."
1040 client_only && skip "client only testing" && return 0
1041 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1042 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1044 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1045 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1046 local tmpdir=$TMP/conf32a
1048 tar xjvf $DISK1_8 -C $tmpdir || \
1049 { skip_env "Cannot untar $DISK1_8" && return 0; }
1052 $LCTL set_param debug=$PTLDEBUG
1054 $TUNEFS $tmpdir/mds || error "tunefs failed"
1056 # nids are wrong, so client wont work, but server should start
1057 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1058 trap cleanup_32 EXIT INT || return 3
1060 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1062 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1064 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1065 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1066 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1068 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1070 local NID=$($LCTL list_nids | head -1)
1072 echo "OSC changes should succeed:"
1073 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1074 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1077 echo "MDC changes should succeed:"
1078 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1079 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1082 echo "LOV changes should succeed:"
1083 $LCTL pool_new lustre.interop || return 11
1084 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1089 # mount a second time to make sure we didnt leave upgrade flag on
1091 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1092 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1093 trap cleanup_32 EXIT INT || return 12
1097 rm -rf $tmpdir || true # true is only for TMP on NFS
1099 run_test 32a "Upgrade from 1.8 (not live)"
1102 client_only && skip "client only testing" && return 0
1103 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1104 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1106 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1107 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1108 local tmpdir=$TMP/conf32b
1110 tar xjvf $DISK1_8 -C $tmpdir || \
1111 { skip_env "Cannot untar $DISK1_8" && return ; }
1114 $LCTL set_param debug="config"
1115 local NEWNAME=lustre
1117 # writeconf will cause servers to register with their current nids
1118 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1119 start32 mds1 $tmpdir/mds "-o loop" && \
1120 trap cleanup_32 EXIT INT || return 3
1122 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1124 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1126 $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 ||\
1127 error "tunefs failed"
1128 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1129 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1131 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1133 local NID=$($LCTL list_nids | head -1)
1135 echo "OSC changes should succeed:"
1136 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1137 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1140 echo "MDC changes should succeed:"
1141 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1142 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1145 echo "LOV changes should succeed:"
1146 $LCTL pool_new ${NEWNAME}.interop || return 11
1147 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1150 # MDT and OST should have registered with new nids, so we should have
1151 # a fully-functioning client
1152 echo "Check client and old fs contents"
1154 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1155 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1156 mount -t lustre $device $MOUNT || return 1
1158 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1159 local new=$((old + 5))
1160 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1161 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1163 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1168 rm -rf $tmpdir || true # true is only for TMP on NFS
1170 run_test 32b "Upgrade from 1.8 with writeconf"
1172 test_33a() { # bug 12333, was test_33
1174 local FSNAME2=test-123
1175 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1177 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1179 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1180 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1181 skip_env "mixed loopback and real device not working" && return
1184 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1185 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1186 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1187 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1189 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1190 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1191 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1193 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1196 cp /etc/hosts $MOUNT2/ || rc=3
1197 $LFS getstripe $MOUNT2/hosts
1202 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1203 cleanup_nocli || rc=6
1206 run_test 33a "Mount ost with a large index number"
1208 test_33b() { # was test_34
1211 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1212 # Drop lock cancelation reply during umount
1213 #define OBD_FAIL_LDLM_CANCEL 0x304
1214 do_facet client lctl set_param fail_loc=0x80000304
1215 #lctl set_param debug=-1
1216 umount_client $MOUNT
1219 run_test 33b "Drop cancel during umount"
1223 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1224 manual_umount_client
1226 do_facet client killall -USR1 multiop
1227 if [ $rc -eq 0 ]; then
1228 error "umount not fail!"
1233 run_test 34a "umount with opened file should be fail"
1238 touch $DIR/$tfile || return 1
1239 stop_mds --force || return 2
1241 manual_umount_client --force
1243 if [ $rc -ne 0 ]; then
1244 error "mtab after failed umount - rc $rc"
1250 run_test 34b "force umount with failed mds should be normal"
1254 touch $DIR/$tfile || return 1
1255 stop_ost --force || return 2
1257 manual_umount_client --force
1259 if [ $rc -ne 0 ]; then
1260 error "mtab after failed umount - rc $rc"
1266 run_test 34c "force umount with failed ost should be normal"
1268 test_35a() { # bug 12459
1271 DBG_SAVE="`lctl get_param -n debug`"
1272 lctl set_param debug="ha"
1274 log "Set up a fake failnode for the MDS"
1276 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1277 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1279 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1282 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1285 log "Stopping the MDT:"
1286 stop_mds || return 5
1288 df $MOUNT > /dev/null 2>&1 &
1290 log "Restarting the MDT:"
1291 start_mds || return 6
1292 log "Wait for df ($DFPID) ... "
1295 lctl set_param debug="$DBG_SAVE"
1297 # retrieve from the log the first server that the client tried to
1298 # contact after the connection loss
1299 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1300 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1301 /import_select_connection.*$device-mdc.* using connection/ {
1303 if (\\\$NF ~ /$FAKENID/)
1309 }" $TMP/lustre-log-$TESTNAME.log`
1310 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1312 # remove nid settings
1315 run_test 35a "Reconnect to the last active server first"
1317 test_35b() { # bug 18674
1318 remote_mds || { skip "local MDS" && return 0; }
1322 $LCTL set_param debug="ha"
1324 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1327 log "Set up a fake failnode for the MDS"
1329 local device=$(do_facet mds "$LCTL get_param -n devices" | \
1330 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1331 do_facet mds "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1334 local at_max_saved=0
1335 # adaptive timeouts may prevent seeing the issue
1336 if at_is_enabled; then
1337 at_max_saved=$(at_max_get mds)
1338 at_max_set 0 mds client
1341 mkdir -p $MOUNT/testdir
1342 touch $MOUNT/testdir/test
1344 log "Injecting EBUSY on MDS"
1345 # Setting OBD_FAIL_MDS_RESEND=0x136
1346 do_facet mds "$LCTL set_param fail_loc=0x80000136" || return 2
1348 log "Stat on a test file"
1349 stat $MOUNT/testdir/test
1351 log "Stop injecting EBUSY on MDS"
1352 do_facet mds "$LCTL set_param fail_loc=0" || return 3
1353 rm -f $MOUNT/testdir/test
1356 # restore adaptive timeout
1357 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1359 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1361 # retrieve from the log if the client has ever tried to
1362 # contact the fake server after the loss of connection
1363 FAILCONN=`awk "BEGIN {ret = 0;}
1364 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1366 if (\\\$NF ~ /$FAKENID/) {
1371 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1373 [ "$FAILCONN" == "0" ] && \
1374 log "ERROR: The client reconnection has not been triggered" && \
1376 [ "$FAILCONN" == "2" ] && \
1377 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1381 # remove nid settings
1384 run_test 35b "Continue reconnection retries, if the active server is busy"
1388 local FSNAME2=test1234
1389 local fs3ost_HOST=$ost_HOST
1390 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1392 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1395 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1396 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1397 skip_env "mixed loopback and real device not working" && return
1399 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1401 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1402 { skip "remote OST" && return 0; }
1404 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1405 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1406 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1407 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1408 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1410 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1411 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1413 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1414 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1415 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1417 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1419 sleep 5 # until 11778 fixed
1421 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1423 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1424 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1425 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1426 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1427 DFTOTAL=`echo $STRING | cut -d, -f1`
1428 DFUSED=`echo $STRING | cut -d, -f2`
1429 DFAVAIL=`echo $STRING | cut -d, -f3`
1430 DFFREE=$(($DFTOTAL - $DFUSED))
1432 ALLOWANCE=$((64 * $OSTCOUNT))
1434 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1435 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1436 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1439 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1440 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1441 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1444 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1445 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1446 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1451 stop fs3ost -f || return 200
1452 stop fs2ost -f || return 201
1453 stop fs2mds -f || return 202
1454 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1455 unload_modules || return 203
1458 run_test 36 "df report consistency on OSTs with different block size"
1461 client_only && skip "client only testing" && return 0
1462 LOCAL_MDSDEV="$TMP/mdt.img"
1463 SYM_MDSDEV="$TMP/sym_mdt.img"
1465 echo "MDS : $LOCAL_MDSDEV"
1466 echo "SYMLINK : $SYM_MDSDEV"
1470 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1471 error "mkfs.lustre $LOCAL_MDSDEV failed"
1472 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1474 echo "mount symlink device - $SYM_MDSDEV"
1476 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1477 umount -d ${MOUNT%/*}/mds
1478 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1480 if [ -n "$mount_op" ]; then
1481 error "**** FAIL: set tunables failed for symlink device"
1485 run_test 37 "verify set tunables works for symlink device"
1487 test_38() { # bug 14222
1492 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1493 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1495 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1496 error "copying $SRC to $DIR/$tdir"
1498 umount_client $MOUNT
1500 log "rename lov_objid file on MDS"
1501 rm -f $TMP/lov_objid.orig
1503 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1504 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1505 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1507 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1508 # check create in mds_lov_connect
1512 [ $V ] && log "verifying $DIR/$tdir/$f"
1513 diff -q $f $DIR/$tdir/$f || ERROR=y
1515 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1516 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1517 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1519 # check it's updates in sync
1520 umount_client $MOUNT
1523 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1524 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1525 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1530 [ $V ] && log "verifying $DIR/$tdir/$f"
1531 diff -q $f $DIR/$tdir/$f || ERROR=y
1533 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1534 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1535 umount_client $MOUNT
1537 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1539 log "files compared the same"
1542 run_test 38 "MDS recreates missing lov_objid file from OST data"
1548 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1549 error "memory leak detected" || true
1551 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1553 test_40() { # bug 15759
1555 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1556 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1560 run_test 40 "race during service thread startup"
1562 test_41() { #bug 14134
1564 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1566 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1567 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1568 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1570 mount_client $MOUNT || return 1
1573 echo "blah blah" > $MOUNT/$tfile
1576 umount_client $MOUNT
1577 stop ost1 -f || return 201
1578 stop_mds -f || return 202
1579 stop_mds -f || return 203
1580 unload_modules || return 204
1583 run_test 41 "mount mds with --nosvc and --nomgs"
1585 test_42() { #bug 14693
1587 check_mount || return 2
1588 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1589 umount_client $MOUNT
1590 mount_client $MOUNT || return 1
1594 run_test 42 "invalid config param should not prevent client from mounting"
1597 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1599 chmod ugo+x $DIR || error "chmod 0 failed"
1601 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1602 "$FSNAME.mdt.root_squash" \
1605 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1606 "$FSNAME.mdt.nosquash_nids" \
1610 # create set of test files
1612 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1613 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1614 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1616 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1617 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1619 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1620 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1621 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1624 # check root_squash:
1625 # set root squash UID:GID to RUNAS_ID
1626 # root should be able to access only files owned by RUNAS_ID
1629 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1630 "$FSNAME.mdt.root_squash" \
1631 "$RUNAS_ID:$RUNAS_ID"
1633 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1634 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1635 error "$ST: root read permission is denied"
1636 echo "$ST: root read permission is granted - ok"
1639 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1640 error "$ST: root write permission is denied"
1641 echo "$ST: root write permission is granted - ok"
1643 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1644 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1645 error "$ST: root read permission is granted"
1646 echo "$ST: root read permission is denied - ok"
1649 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1650 error "$ST: root write permission is granted"
1651 echo "$ST: root write permission is denied - ok"
1653 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1654 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1655 error "$ST: root unlink permission is granted"
1656 echo "$ST: root unlink permission is denied - ok"
1658 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1659 error "$ST: root create permission is granted"
1660 echo "$ST: root create permission is denied - ok"
1663 # check nosquash_nids:
1664 # put client's NID into nosquash_nids list,
1665 # root should be able to access root file after that
1667 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1668 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1669 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1671 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1672 "$FSNAME-MDTall.mdt.nosquash_nids" \
1675 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1676 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1677 error "$ST: root read permission is denied"
1678 echo "$ST: root read permission is granted - ok"
1681 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1682 error "$ST: root write permission is denied"
1683 echo "$ST: root write permission is granted - ok"
1685 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1686 rm $DIR/$tdir-rootdir/tfile-1 || \
1687 error "$ST: root unlink permission is denied"
1688 echo "$ST: root unlink permission is granted - ok"
1689 touch $DIR/$tdir-rootdir/tfile-2 || \
1690 error "$ST: root create permission is denied"
1691 echo "$ST: root create permission is granted - ok"
1695 run_test 43 "check root_squash and nosquash_nids"
1697 umount_client $MOUNT
1702 check_mount || return 2
1703 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1705 UUIDS=$(do_facet mds "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1706 for VAL in $UUIDS; do
1707 NID=$(echo $VAL | cut -d= -f1)
1708 CLUUID=$(echo $VAL | cut -d= -f2)
1709 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1711 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1715 run_test 44 "mounted client proc entry exists"
1719 check_mount || return 2
1724 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1725 do_facet client "lctl set_param fail_loc=0x50f"
1728 manual_umount_client --force || return 3
1729 do_facet client "lctl set_param fail_loc=0x0"
1731 mount_client $MOUNT || return 4
1735 run_test 45 "long unlink handling in ptlrpcd"
1742 umount_client $MOUNT2 || rc=$?
1743 umount_client $MOUNT || rc=$?
1744 while [ $count -gt 0 ]; do
1745 stop ost${count} -f || rc=$?
1749 cleanup_nocli || rc=$?
1750 #writeconf to remove all ost2 traces for subsequent tests
1756 echo "Testing with $OSTCOUNT OSTs"
1758 start_mds || return 1
1759 #first client should see only one ost
1760 start_ost || return 2
1761 wait_osc_import_state mds ost FULL
1763 mount_client $MOUNT || return 3
1764 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1767 for (( i=2; i<=$OSTCOUNT; i++ )); do
1768 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1771 # wait until osts in sync
1772 for (( i=2; i<=$OSTCOUNT; i++ )); do
1773 wait_osc_import_state mds ost$i FULL
1777 #second client see all ost's
1779 mount_client $MOUNT2 || return 8
1780 $LFS setstripe $MOUNT2 -c -1 || return 9
1781 $LFS getstripe $MOUNT2 || return 10
1783 echo "ok" > $MOUNT2/widestripe
1784 $LFS getstripe $MOUNT2/widestripe || return 11
1785 # fill acl buffer for avoid expand lsm to them
1786 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1787 setfacl -m $acl $MOUNT2/widestripe
1791 stat $MOUNT/widestripe || return 12
1793 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1796 run_test 46a "handle ost additional - wide striped file"
1801 check_mount || return 2
1802 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1806 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1807 if echo $ns | grep "MDT[[:digit:]]*"; then
1810 lrs=$(echo $ns | sed 's/.*lru_size=//')
1811 lru_size[count]=$lrs
1816 facet_failover $SINGLEMDS
1817 client_up || return 3
1820 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1821 if echo $ns | grep "MDT[[:digit:]]*"; then
1824 lrs=$(echo $ns | sed 's/.*lru_size=//')
1825 if ! test "$lrs" -eq "${lru_size[count]}"; then
1826 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1827 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1835 run_test 47 "server restart does not make client loss lru_resize settings"
1840 # reformat after this test is needed - if test will failed
1841 # we will have unkillable file at FS
1845 test_48() { # bug 17636
1848 check_mount || return 2
1850 $LFS setstripe $MOUNT -c -1 || return 9
1851 $LFS getstripe $MOUNT || return 10
1853 echo "ok" > $MOUNT/widestripe
1854 $LFS getstripe $MOUNT/widestripe || return 11
1856 trap cleanup_48 EXIT ERR
1858 # fill acl buffer for avoid expand lsm to them
1859 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1860 setfacl -m $acl $MOUNT/widestripe
1863 stat $MOUNT/widestripe || return 12
1868 run_test 48 "too many acls on file"
1870 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1871 test_49() { # bug 17710
1872 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1873 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1874 local LOCAL_TIMEOUT=20
1877 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1881 check_mount || return 1
1883 echo "check ldlm_timout..."
1884 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1885 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1886 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1888 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1889 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1892 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1893 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1896 umount_client $MOUNT
1897 stop_ost || return 2
1898 stop_mds || return 3
1900 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"
1904 check_mount || return 7
1906 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1907 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1908 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1910 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1911 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1914 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1915 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1918 cleanup || return $?
1920 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1921 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1923 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1926 # Test both statfs and lfs df and fail if either one fails
1927 multiop_bg_pause $1 f_
1930 killall -USR1 multiop
1931 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
1932 wait $PID || { RC1=$?; log "multiop return error "; }
1939 if [ $RC2 -eq 0 ]; then
1941 log "lazystatfs df failed"
1945 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
1951 lctl set_param llite.$FSNAME-*.lazystatfs=1
1954 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
1956 cleanup || return $?
1958 run_test 50a "lazystatfs all servers available =========================="
1962 lctl set_param llite.$FSNAME-*.lazystatfs=1
1965 # Wait for client to detect down OST
1966 stop_ost || error "Unable to stop OST1"
1967 wait_osc_import_state mds ost DISCONN
1969 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
1971 umount_client $MOUNT || error "Unable to unmount client"
1972 stop_mds || error "Unable to stop MDS"
1974 run_test 50b "lazystatfs all servers down =========================="
1977 start_mds || error "Unable to start MDS"
1978 start_ost || error "Unable to start OST1"
1979 start_ost2 || error "Unable to start OST2"
1980 mount_client $MOUNT || error "Unable to mount client"
1981 lctl set_param llite.$FSNAME-*.lazystatfs=1
1984 # Wait for client to detect down OST
1985 stop_ost || error "Unable to stop OST1"
1986 wait_osc_import_state mds ost DISCONN
1987 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1989 umount_client $MOUNT || error "Unable to unmount client"
1990 stop_ost2 || error "Unable to stop OST2"
1991 stop_mds || error "Unable to stop MDS"
1993 run_test 50c "lazystatfs one server down =========================="
1996 start_mds || error "Unable to start MDS"
1997 start_ost || error "Unable to start OST1"
1998 start_ost2 || error "Unable to start OST2"
1999 mount_client $MOUNT || error "Unable to mount client"
2000 lctl set_param llite.$FSNAME-*.lazystatfs=1
2003 # Issue the statfs during the window where the client still
2004 # belives the OST to be available but it is in fact down.
2005 # No failure just a statfs which hangs for a timeout interval.
2006 stop_ost || error "Unable to stop OST1"
2007 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2009 umount_client $MOUNT || error "Unable to unmount client"
2010 stop_ost2 || error "Unable to stop OST2"
2011 stop_mds || error "Unable to stop MDS"
2013 run_test 50d "lazystatfs client/server conn race =========================="
2020 start_mds || return 1
2021 #first client should see only one ost
2022 start_ost || return 2
2023 wait_osc_import_state mds ost FULL
2025 # Wait for client to detect down OST
2026 stop_ost || error "Unable to stop OST1"
2027 wait_osc_import_state mds ost DISCONN
2029 mount_client $MOUNT || error "Unable to mount client"
2030 lctl set_param llite.$FSNAME-*.lazystatfs=0
2032 multiop_bg_pause $MOUNT _f
2036 if [ $RC1 -ne 0 ]; then
2037 log "multiop failed $RC1"
2040 sleep $(( $TIMEOUT+1 ))
2042 [ $? -ne 0 ] && error "process isn't sleep"
2043 start_ost || error "Unable to start OST1"
2044 wait $pid || error "statfs failed"
2047 umount_client $MOUNT || error "Unable to unmount client"
2048 stop_ost || error "Unable to stop OST1"
2049 stop_mds || error "Unable to stop MDS"
2051 run_test 50e "normal statfs all servers down =========================="
2056 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2058 start_mds || error "Unable to start mds"
2059 #first client should see only one ost
2060 start_ost || error "Unable to start OST1"
2061 wait_osc_import_state mds ost FULL
2063 start_ost2 || error "Unable to start OST2"
2064 wait_osc_import_state mds ost2 FULL
2066 # Wait for client to detect down OST
2067 stop_ost2 || error "Unable to stop OST2"
2069 wait_osc_import_state mds ost2 DISCONN
2070 mount_client $MOUNT || error "Unable to mount client"
2071 lctl set_param llite.$FSNAME-*.lazystatfs=0
2073 multiop_bg_pause $MOUNT _f
2077 if [ $RC1 -ne 0 ]; then
2078 log "lazystatfs multiop failed $RC1"
2081 sleep $(( $TIMEOUT+1 ))
2083 [ $? -ne 0 ] && error "process isn't sleep"
2084 start_ost2 || error "Unable to start OST2"
2085 wait $pid || error "statfs failed"
2086 stop_ost2 || error "Unable to stop OST2"
2089 umount_client $MOUNT || error "Unable to unmount client"
2090 stop_ost || error "Unable to stop OST1"
2091 stop_mds || error "Unable to stop MDS"
2092 #writeconf to remove all ost2 traces for subsequent tests
2095 run_test 50f "normal statfs one server in down =========================="
2098 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2100 start_ost2 || error "Unable to start OST2"
2101 wait_osc_import_state mds ost2 FULL
2102 wait_osc_import_state client ost2 FULL
2104 local PARAM="${FSNAME}-OST0001.osc.active"
2106 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2107 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2109 umount_client $MOUNT || error "Unable to unmount client"
2110 mount_client $MOUNT || error "Unable to mount client"
2111 # This df should not cause a panic
2114 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2116 umount_client $MOUNT || error "Unable to unmount client"
2117 stop_ost2 || error "Unable to stop OST2"
2118 stop_ost || error "Unable to stop OST1"
2119 stop_mds || error "Unable to stop MDS"
2120 #writeconf to remove all ost2 traces for subsequent tests
2123 run_test 50g "deactivated OST should not cause panic====================="
2126 local LOCAL_TIMEOUT=20
2130 check_mount || return 1
2133 $LFS setstripe -c -1 $MOUNT/d1
2134 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2135 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2136 touch $MOUNT/d1/f1 &
2139 start_ost2 || return 2
2141 stop_ost2 || return 3
2144 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2153 do_node $node mkdir -p $dest
2154 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2156 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2157 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2158 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2160 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2161 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2171 local backup2=${TMP}/backup2
2173 do_node $node mkdir -p $backup2
2174 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2176 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2177 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2178 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2180 do_node $node "diff -rq $backup $backup2"
2181 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2183 local xattrs2=${TMP}/xattrs2
2184 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2185 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2187 do_node $node "diff $xattrs $xattrs2"
2188 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2190 do_node $node "rm -rf $backup2 $xattrs2"
2191 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2196 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2198 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2200 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2203 local ost1mnt=${MOUNT%/*}/ost1
2204 local ost1node=$(facet_active_host ost1)
2205 local ost1tmp=$TMP/conf52
2208 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2209 touch $TMP/modified_first
2210 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2211 local mtime=$(stat -c %Y $TMP/modified_first)
2212 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2214 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2217 $LFS setstripe $DIR/$tdir -c -1 -s 1M
2218 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2220 for (( i=0; i < nrfiles; i++ )); do
2221 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2222 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2228 echo backup files to $TMP/files
2229 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2230 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2231 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2233 umount_client $MOUNT
2234 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2236 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2238 echo mount ost1 as ldiskfs
2239 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2240 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2243 echo backup objects to $ost1tmp/objects
2244 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2245 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2246 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2247 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2249 # move objects to lost+found
2250 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2251 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2254 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2255 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2257 # compare restored objects against saved ones
2258 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2259 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2261 do_node $ost1node "umount $ost1_dev"
2262 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2265 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2267 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2270 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2271 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2273 rm -rf $TMP/files $TMP/file_xattrs
2274 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2275 do_node $ost1node "rm -rf $ost1tmp"
2276 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2279 run_test 52 "check recovering objects from lost+found"
2281 # Checks threads_min/max/started for some service
2283 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2284 # parameter pattern prefix like 'ost.*.ost'.
2296 local msg="Insane $modname thread counts"
2300 check_mount || return 41
2302 # We need to expand $parampat, but it may match multiple parameters, so
2303 # we'll pick the first one
2304 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2305 error "Couldn't expand ${parampat}.threads_min parameter name"
2309 # Remove the .threads_min part
2310 paramp=${paramp%.threads_min}
2312 # Check for sanity in defaults
2313 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2314 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2315 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2316 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2317 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= tmax ))' || return $?
2319 # Check that we can lower min/max
2320 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin - 1))"
2321 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 10))"
2322 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2323 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2324 lassert 25 "$msg" '(($tmin2 == ($tmin - 1) && $tmax2 == ($tmax -10)))' || return $?
2326 # Check that we can set min/max to the same value
2327 do_facet $facet "lctl set_param ${paramp}.threads_min=$tmin"
2328 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2329 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2330 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2331 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2333 # Check that we can't set max < min
2334 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2335 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2336 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2337 lassert 27 "$msg" '(($tmin <= $tmax2))' || return $?
2339 # We need to ensure that we get the module options desired; to do this
2340 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2341 LOAD_MODULES_REMOTE=true
2344 setmodopts -a $modname "$opts" oldvalue
2348 check_mount || return 41
2350 # Restore previous setting of MODOPTS_*
2351 setmodopts $modname "$oldvalue"
2353 # Check that $opts took
2354 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2355 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2356 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2357 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2360 # Workaround a YALA bug where YALA expects that modules will remain
2361 # loaded on the servers
2362 LOAD_MODULES_REMOTE=false
2369 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2371 run_test 53a "check OSS thread count params"
2374 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2376 run_test 53b "check MDT thread count params"
2381 local partial_arg=""
2382 local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
2384 # Run in partial (fast) mode if the size
2385 # of a partition > 10 GB
2386 [ $size -gt 10 ] && partial_arg="-p"
2388 llverfs $partial_arg $dir
2392 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
2393 [ $? -eq 0 ] || error "llverdev failed!"
2396 run_test 54a "llverdev"
2401 [ $? -eq 0 ] || error "llverfs failed!"
2404 run_test 54b "llverfs"
2408 local max_ost_index=$1
2409 echo -n $(((max_ost_index + 1) * 8))
2413 local mdsdev=$(mdsdevname 1)
2414 local ostdev=$(ostdevname 1)
2415 local saved_opts=$OST_MKFS_OPTS
2417 for i in 0 1023 2048
2419 OST_MKFS_OPTS="$saved_opts --index $i"
2427 echo checking size of lov_objid for ost index $i
2428 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2429 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2430 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2432 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2437 OST_MKFS_OPTS=$saved_opts
2440 run_test 55 "check lov_objid size"
2443 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2444 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2445 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2449 start_ost2 || error "Unable to start second ost"
2450 mount_client $MOUNT || error "Unable to mount client"
2456 run_test 56 "check big indexes"
2458 test_57() { # bug 22656
2459 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2461 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2463 start_ost && error "OST registration from failnode should fail"
2467 run_test 57 "initial registration from failnode should fail (should return errs)"
2470 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2474 start_mgsmds >> /dev/null
2475 local C1=$(count_osts)
2476 if [ $C1 -eq 0 ]; then
2477 start_ost >> /dev/null
2481 echo "original ost count: $C1 (expect > 0)"
2482 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2483 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2484 local C2=$(count_osts)
2485 echo "after mdt writeconf count: $C2 (expect 0)"
2486 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2487 echo "OST start without writeconf should fail:"
2488 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2489 echo "OST start with writeconf should succeed:"
2490 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2491 local C3=$(count_osts)
2492 echo "after ost writeconf count: $C3 (expect 1)"
2493 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2494 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2495 local C4=$(count_osts)
2496 echo "after ost2 writeconf count: $C4 (expect 2)"
2497 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2498 stop_ost2 >> /dev/null
2499 cleanup_nocli >> /dev/null
2501 run_test 59 "writeconf mount option"
2504 if ! combined_mgs_mds ; then
2508 equals_msg `basename $0`: test complete
2509 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true