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
196 unload_modules_conf () {
197 if combined_mgs_mds || ! local_mode; then
198 unload_modules || return 1
203 stop_ost || return 202
204 stop_mds || return 201
205 unload_modules_conf || return 203
209 umount_client $MOUNT || return 200
210 cleanup_nocli || return $?
214 do_facet client "cp /etc/passwd $DIR/a" || return 71
215 do_facet client "rm $DIR/a" || return 72
216 # make sure lustre is actually mounted (touch will block,
217 # but grep won't, so do it after)
218 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
219 echo "setup single mount lustre success"
223 do_facet client "touch $DIR/a" || return 71
224 do_facet client "rm $DIR/a" || return 72
225 do_facet client "touch $DIR2/a" || return 73
226 do_facet client "rm $DIR2/a" || return 74
227 echo "setup double mount lustre success"
232 if [ "$ONLY" == "setup" ]; then
237 if [ "$ONLY" == "cleanup" ]; then
244 #create single point mountpoint
250 check_mount || return 41
253 run_test 0 "single mount setup"
256 start_mds || error "MDT start failed"
258 echo "start ost second time..."
259 start_ost && error "2nd OST start should fail"
260 mount_client $MOUNT || error "client start failed"
261 check_mount || return 42
264 run_test 1 "start up ost twice (should return errors)"
268 echo "start mds second time.."
269 start_mds && error "2nd MDT start should fail"
272 check_mount || return 43
275 run_test 2 "start up mds twice (should return err)"
279 #mount.lustre returns an error if already in mtab
280 mount_client $MOUNT && error "2nd client mount should fail"
281 check_mount || return 44
284 run_test 3 "mount client twice (should return err)"
288 touch $DIR/$tfile || return 85
292 # ok for ost to fail shutdown
293 if [ 202 -ne $eno ]; then
298 run_test 4 "force cleanup ost, then cleanup"
300 test_5a() { # was test_5
302 touch $DIR/$tfile || return 1
303 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
305 stop_mds -f || return 2
307 # cleanup may return an error from the failed
308 # disconnects; for now I'll consider this successful
309 # if all the modules have unloaded.
313 echo "killing umount"
314 kill -TERM $UMOUNT_PID
315 echo "waiting for umount to finish"
317 if grep " $MOUNT " /proc/mounts; then
318 echo "test 5: /proc/mounts after failed umount"
322 echo "killing umount"
323 kill -TERM $UMOUNT_PID
324 echo "waiting for umount to finish"
326 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
330 # stop_mds is a no-op here, and should not fail
331 cleanup_nocli || return $?
332 # df may have lingering entry
334 # mtab may have lingering entry
338 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
340 grep -q $MOUNT" " /etc/mtab || break
341 echo "Waiting /etc/mtab updated ... "
342 WAIT=$(( WAIT + sleep))
344 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
345 echo "/etc/mtab updated in $WAIT secs"
347 run_test 5a "force cleanup mds, then cleanup"
355 grep " $MOUNT " /etc/mtab && \
356 error false "unexpected entry in mtab before mount" && return 10
360 if ! combined_mgs_mds ; then
361 trap cleanup_5b EXIT ERR
366 [ -d $MOUNT ] || mkdir -p $MOUNT
367 mount_client $MOUNT && rc=1
368 grep " $MOUNT " /etc/mtab && \
369 error "$MOUNT entry in mtab after failed mount" && rc=11
371 # stop_mds is a no-op here, and should not fail
372 cleanup_nocli || rc=$?
373 if ! combined_mgs_mds ; then
378 run_test 5b "Try to start a client with no MGS (should return errs)"
381 grep " $MOUNT " /etc/mtab && \
382 error false "unexpected entry in mtab before mount" && return 10
387 [ -d $MOUNT ] || mkdir -p $MOUNT
388 local oldfs="${FSNAME}"
389 FSNAME="wrong.${FSNAME}"
390 mount_client $MOUNT || :
392 grep " $MOUNT " /etc/mtab && \
393 error "$MOUNT entry in mtab after failed mount" && rc=11
395 cleanup_nocli || rc=$?
398 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
401 grep " $MOUNT " /etc/mtab && \
402 error false "unexpected entry in mtab before mount" && return 10
408 mount_client $MOUNT || rc=1
410 grep " $MOUNT " /etc/mtab && \
411 error "$MOUNT entry in mtab after unmount" && rc=11
414 run_test 5d "mount with ost down"
417 grep " $MOUNT " /etc/mtab && \
418 error false "unexpected entry in mtab before mount" && return 10
424 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
425 do_facet client "lctl set_param fail_loc=0x80000506"
426 mount_client $MOUNT || echo "mount failed (not fatal)"
428 grep " $MOUNT " /etc/mtab && \
429 error "$MOUNT entry in mtab after unmount" && rc=11
432 run_test 5e "delayed connect, don't crash (bug 10268)"
435 if combined_mgs_mds ; then
436 skip "combined mgs and mds"
440 grep " $MOUNT " /etc/mtab && \
441 error false "unexpected entry in mtab before mount" && return 10
445 [ -d $MOUNT ] || mkdir -p $MOUNT
446 mount_client $MOUNT &
448 echo client_mount pid is $pid
452 if ! ps -f -p $pid >/dev/null; then
455 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
456 error "mount returns $rc, expected to hang"
465 # mount should succeed after start mds
468 [ $rc -eq 0 ] || error "mount returned $rc"
469 grep " $MOUNT " /etc/mtab && echo "test 5f: mtab after mount"
473 run_test 5f "mds down, cleanup after failed mount (bug 2712)"
478 mount_client ${MOUNT} || return 87
479 touch $DIR/a || return 86
482 run_test 6 "manual umount, then mount again"
487 cleanup_nocli || return $?
489 run_test 7 "manual umount, then cleanup"
494 check_mount2 || return 45
495 umount_client $MOUNT2
498 run_test 8 "double mount setup"
503 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
504 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
506 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
507 if [ "$CHECK_PTLDEBUG" ] && { \
508 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
509 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
510 echo "lnet.debug success"
512 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
515 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
516 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
517 echo "lnet.subsystem_debug success"
519 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
522 stop_ost || return $?
524 run_test 9 "test ptldebug and subsystem for mkfs"
527 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
528 # But with new MDS stack we don't care about the mode of local objects
529 # anymore, so this test is removed. See bug 22944 for more details.
533 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
535 if [ ! -e "$MDSDEV" ]; then
536 echo "no $MDSDEV existing, so mount Lustre to create one"
538 check_mount || return 41
542 echo "Remove mds config log"
543 do_facet $SINGLEMDS "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
546 start_mds && return 42
549 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
552 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
554 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
559 # check if current MDSSIZE is large enough
560 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
561 log "use MDSSIZE=$MDSSIZE"
563 # check if the global config has a large enough MDSSIZE
564 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
565 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
566 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
568 # check if the block device is large enough
569 [ -z "$OK" -a -b $MDSDEV ] && \
570 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
571 awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
572 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
574 # check if a loopback device has enough space for fs metadata (5%)
575 [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
576 SPACE=$(df -P $(dirname $MDSDEV) |
577 awk '($1 != "Filesystem") {print $4}') &&
578 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
579 log "use file $MDSDEV with MIN=$MIN"
581 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
584 echo "mount mds with large journal..."
585 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
587 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
590 echo "mount lustre system..."
592 check_mount || return 41
594 echo "check journal size..."
595 local FOUNDSIZE=`do_facet $SINGLEMDS "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
596 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
597 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
599 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
604 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
607 run_test 18 "check mkfs creates large journals"
610 start_mds || return 1
611 stop_mds -f || return 2
613 run_test 19a "start/stop MDS without OSTs"
616 start_ost || return 1
617 stop_ost -f || return 2
619 run_test 19b "start/stop OSTs without MDS"
622 # first format the ost/mdt
626 check_mount || return 43
628 remount_client ro $MOUNT || return 44
629 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
630 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
631 remount_client rw $MOUNT || return 47
633 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
634 MCNT=`grep -c $MOUNT /etc/mtab`
635 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
640 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
645 wait_osc_import_state mds ost FULL
649 run_test 21a "start mds before ost, stop ost first"
654 wait_osc_import_state mds ost FULL
658 run_test 21b "start ost before mds, stop mds first"
664 wait_osc_import_state mds ost2 FULL
668 #writeconf to remove all ost2 traces for subsequent tests
671 run_test 21c "start mds between two osts, stop mds last"
676 echo Client mount with ost in logs, but none running
678 # wait until mds connected to ost and open client connection
679 wait_osc_import_state mds ost FULL
682 # check_mount will block trying to contact ost
683 mcreate $DIR/$tfile || return 40
684 rm -f $DIR/$tfile || return 42
688 echo Client mount with a running ost
691 # if gss enabled, wait full time to let connection from
692 # mds to ost be established, due to the mismatch between
693 # initial connect timeout and gss context negotiation timeout.
694 # This perhaps could be remove after AT landed.
695 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
696 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
699 check_mount || return 41
704 run_test 22 "start a client before osts (should return errs)"
706 test_23a() { # was test_23
710 # force down client so that recovering mds waits for reconnect
711 local running=$(grep -c $MOUNT /proc/mounts) || true
712 if [ $running -ne 0 ]; then
713 echo "Stopping client $MOUNT (opts: -f)"
717 # enter recovery on mds
719 # try to start a new client
720 mount_client $MOUNT &
722 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
723 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
724 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
726 ps --ppid $MOUNT_LUSTRE_PID
727 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
728 kill -TERM $MOUNT_LUSTRE_PID
729 echo "waiting for mount to finish"
731 # we can not wait $MOUNT_PID because it is not a child of this shell
737 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
739 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
740 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
743 [ -z "$PID1" -a -z "$PID2" ] && break
744 echo "waiting for mount to finish ... "
745 WAIT=$(( WAIT + sleep))
747 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
748 error "MOUNT_PID $MOUNT_PID and "\
749 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
755 run_test 23a "interrupt client during recovery mount delay"
760 test_23b() { # was test_23
763 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
764 lctl set_param fail_loc=0x80000313
768 run_test 23b "Simulate -EINTR during mount"
770 fs2mds_HOST=$mds_HOST
771 fs2ost_HOST=$ost_HOST
775 echo "umount $MOUNT2 ..."
776 umount $MOUNT2 || true
777 echo "stopping fs2mds ..."
778 stop fs2mds -f || true
779 echo "stopping fs2ost ..."
780 stop fs2ost -f || true
788 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
790 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
791 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
792 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
793 skip_env "mixed loopback and real device not working" && return
796 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
797 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
799 # test 8-char fsname as well
800 local FSNAME2=test1234
801 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
803 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
806 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
807 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
809 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
811 check_mount || return 2
812 # files written on 1 should not show up on 2
813 cp /etc/passwd $DIR/$tfile
815 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
818 cp /etc/passwd $MOUNT2/b || return 3
819 rm $MOUNT2/b || return 4
820 # 2 is actually mounted
821 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
823 facet_failover fs2mds
824 facet_failover fs2ost
827 # the MDS must remain up until last MDT
829 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
830 [ -z "$MDS" ] && error "No MDT" && return 8
832 cleanup_nocli || return 6
834 run_test 24a "Multiple MDTs on a single node"
837 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
839 if [ -z "$fs2mds_DEV" ]; then
840 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
841 skip_env "mixed loopback and real device not working" && return
844 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
846 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
848 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
851 run_test 24b "Multiple MGSs on a single node (should return err)"
855 check_mount || return 2
856 local MODULES=$($LCTL modules | awk '{ print $2 }')
857 rmmod $MODULES 2>/dev/null || true
860 run_test 25 "Verify modules are referenced"
864 # we need modules before mount for sysctl, so make sure...
865 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
866 #define OBD_FAIL_MDS_FS_SETUP 0x135
867 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
868 start_mds && echo MDS started && return 1
869 lctl get_param -n devices
870 DEVS=$(lctl get_param -n devices | egrep -v MG | wc -l)
871 [ $DEVS -gt 0 ] && return 2
872 unload_modules_conf || return $?
874 run_test 26 "MDT startup failure cleans LOV (should return errs)"
880 local ORIG=$(do_facet $myfacet "$TEST")
881 if [ $# -gt 3 ]; then
887 echo "Setting $PARAM from $ORIG to $FINAL"
888 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
890 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
894 start_ost || return 1
895 start_mds || return 2
896 echo "Requeue thread should have started: "
897 ps -e | grep ll_cfg_requeue
898 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
901 run_test 27a "Reacquire MGS lock if OST started first"
906 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
908 facet_failover $SINGLEMDS
909 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
910 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
914 run_test 27b "Reacquire MGS lock after failover"
918 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
919 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
922 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
923 FINAL=$(($FINAL + 1))
924 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
925 umount_client $MOUNT || return 200
928 if [ $RESULT -ne $FINAL ]; then
929 echo "New config not seen: wanted $FINAL got $RESULT"
932 echo "New config success: got $RESULT"
934 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
937 run_test 28 "permanent parameter setting"
940 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
941 setup > /dev/null 2>&1
945 local PARAM="$FSNAME-OST0001.osc.active"
946 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
947 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
949 ACTV=$(lctl get_param -n $PROC_ACT)
951 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
952 # also check ost_server_uuid status
953 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
954 if [ -z "$RESULT" ]; then
955 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
958 echo "Live client success: got $RESULT"
962 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0001)
963 mdtosc=${mdtosc/-MDT*/-MDT\*}
964 local MPROC="osc.$mdtosc.active"
969 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
970 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
971 if [ $RESULT -eq $DEAC ]; then
972 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
976 if [ $WAIT -eq $MAX ]; then
977 echo "MDT not deactivated: wanted $DEAC got $RESULT"
980 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
983 # test new client starts deactivated
984 umount_client $MOUNT || return 200
986 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
987 if [ -z "$RESULT" ]; then
988 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
991 echo "New client success: got $RESULT"
994 # make sure it reactivates
995 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
1000 #writeconf to remove all ost2 traces for subsequent tests
1003 run_test 29 "permanently remove an OST"
1008 echo Big config llog
1009 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
1011 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
1012 for i in ${LIST[@]}; do
1013 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
1015 # make sure client restart still works
1016 umount_client $MOUNT
1017 mount_client $MOUNT || return 4
1018 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
1021 echo Erase parameter setting
1022 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
1023 umount_client $MOUNT
1024 mount_client $MOUNT || return 6
1026 echo "deleted (default) value=$FINAL, orig=$ORIG"
1027 # assumes this parameter started at the default value
1028 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
1032 run_test 30a "Big config llog and conf_param deletion"
1037 # Make a fake nid. Use the OST nid, and add 20 to the least significant
1038 # numerical part of it. Hopefully that's not already a failover address for
1040 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
1041 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
1042 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
1043 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
1044 echo "Using fake nid $NEW"
1046 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
1047 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
1048 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1050 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1051 echo "should have 2 failover nids: $NIDCOUNT"
1052 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1053 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1054 umount_client $MOUNT
1055 mount_client $MOUNT || return 3
1057 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1059 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1060 echo "only 1 final nid should remain: $NIDCOUNT"
1061 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1065 run_test 30b "Remove failover nids"
1067 test_31() { # bug 10734
1068 # ipaddr must not exist
1069 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1072 run_test 31 "Connect to non-existent node (shouldn't crash)"
1074 # Use these start32/stop32 fn instead of t-f start/stop fn,
1075 # for local devices, to skip global facet vars init
1079 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1080 umount -d $@ ${MOUNT%/*}/${facet}
1089 mkdir -p ${MOUNT%/*}/${facet}
1091 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1092 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1094 if [ $RC -ne 0 ]; then
1095 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1096 echo "Start of ${device} of local ${facet} failed ${RC}"
1102 cleanup_nocli32 () {
1110 echo "Cleanup test_32 umount $MOUNT ..."
1111 umount -f $MOUNT || true
1112 echo "Cleanup local mds ost1 ..."
1114 combined_mgs_mds || start_mgs
1119 client_only && skip "client only testing" && return 0
1120 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1121 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1123 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1124 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1125 local tmpdir=$TMP/conf32a
1127 tar xjvf $DISK1_8 -C $tmpdir || \
1128 { skip_env "Cannot untar $DISK1_8" && return 0; }
1131 $LCTL set_param debug=$PTLDEBUG
1133 $TUNEFS $tmpdir/mds || error "tunefs failed"
1135 combined_mgs_mds || stop mgs
1137 # nids are wrong, so client wont work, but server should start
1138 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1139 trap cleanup_32 EXIT INT || return 3
1141 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1143 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1145 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1146 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1147 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1149 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1151 local NID=$($LCTL list_nids | head -1)
1153 echo "OSC changes should succeed:"
1154 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1155 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1158 echo "MDC changes should succeed:"
1159 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1160 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1163 echo "LOV changes should succeed:"
1164 $LCTL pool_new lustre.interop || return 11
1165 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1170 # mount a second time to make sure we didnt leave upgrade flag on
1172 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1174 combined_mgs_mds || stop mgs
1176 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1177 trap cleanup_32 EXIT INT || return 12
1181 rm -rf $tmpdir || true # true is only for TMP on NFS
1183 run_test 32a "Upgrade from 1.8 (not live)"
1186 client_only && skip "client only testing" && return 0
1187 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1188 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1190 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1191 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1192 local tmpdir=$TMP/conf32b
1194 tar xjvf $DISK1_8 -C $tmpdir || \
1195 { skip_env "Cannot untar $DISK1_8" && return ; }
1198 $LCTL set_param debug="config"
1199 local NEWNAME=lustre
1201 # writeconf will cause servers to register with their current nids
1202 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1203 combined_mgs_mds || stop mgs
1205 start32 mds1 $tmpdir/mds "-o loop" && \
1206 trap cleanup_32 EXIT INT || return 3
1208 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1210 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1212 $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 ||\
1213 error "tunefs failed"
1214 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1215 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1217 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1219 local NID=$($LCTL list_nids | head -1)
1221 echo "OSC changes should succeed:"
1222 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1223 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1226 echo "MDC changes should succeed:"
1227 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1228 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1231 echo "LOV changes should succeed:"
1232 $LCTL pool_new ${NEWNAME}.interop || return 11
1233 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1236 # MDT and OST should have registered with new nids, so we should have
1237 # a fully-functioning client
1238 echo "Check client and old fs contents"
1240 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1241 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1242 mount -t lustre $device $MOUNT || return 1
1244 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1245 local new=$((old + 5))
1246 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1247 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1249 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1254 rm -rf $tmpdir || true # true is only for TMP on NFS
1256 run_test 32b "Upgrade from 1.8 with writeconf"
1258 test_33a() { # bug 12333, was test_33
1260 local FSNAME2=test-123
1261 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1263 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1265 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1266 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1267 skip_env "mixed loopback and real device not working" && return
1270 combined_mgs_mds || mkfs_opts="$mkfs_opts --nomgs"
1272 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1273 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1274 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1275 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1277 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1278 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1279 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1281 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1284 cp /etc/hosts $MOUNT2/ || rc=3
1285 $LFS getstripe $MOUNT2/hosts
1290 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1291 cleanup_nocli || rc=6
1294 run_test 33a "Mount ost with a large index number"
1296 test_33b() { # was test_34
1299 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1300 # Drop lock cancelation reply during umount
1301 #define OBD_FAIL_LDLM_CANCEL 0x304
1302 do_facet client lctl set_param fail_loc=0x80000304
1303 #lctl set_param debug=-1
1304 umount_client $MOUNT
1307 run_test 33b "Drop cancel during umount"
1311 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1312 manual_umount_client
1314 do_facet client killall -USR1 multiop
1315 if [ $rc -eq 0 ]; then
1316 error "umount not fail!"
1321 run_test 34a "umount with opened file should be fail"
1326 touch $DIR/$tfile || return 1
1327 stop_mds --force || return 2
1329 manual_umount_client --force
1331 if [ $rc -ne 0 ]; then
1332 error "mtab after failed umount - rc $rc"
1338 run_test 34b "force umount with failed mds should be normal"
1342 touch $DIR/$tfile || return 1
1343 stop_ost --force || return 2
1345 manual_umount_client --force
1347 if [ $rc -ne 0 ]; then
1348 error "mtab after failed umount - rc $rc"
1354 run_test 34c "force umount with failed ost should be normal"
1356 test_35a() { # bug 12459
1359 DBG_SAVE="`lctl get_param -n debug`"
1360 lctl set_param debug="ha"
1362 log "Set up a fake failnode for the MDS"
1364 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1365 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1367 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1370 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1373 log "Stopping the MDT:"
1374 stop_mds || return 5
1376 df $MOUNT > /dev/null 2>&1 &
1378 log "Restarting the MDT:"
1379 start_mds || return 6
1380 log "Wait for df ($DFPID) ... "
1383 lctl set_param debug="$DBG_SAVE"
1385 # retrieve from the log the first server that the client tried to
1386 # contact after the connection loss
1387 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1388 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1389 /import_select_connection.*$device-mdc.* using connection/ {
1391 if (\\\$NF ~ /$FAKENID/)
1397 }" $TMP/lustre-log-$TESTNAME.log`
1398 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1400 # remove nid settings
1403 run_test 35a "Reconnect to the last active server first"
1405 test_35b() { # bug 18674
1406 remote_mds || { skip "local MDS" && return 0; }
1410 $LCTL set_param debug="ha"
1412 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1415 log "Set up a fake failnode for the MDS"
1417 local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" | \
1418 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1419 do_facet $SINGLEMDS "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1422 local at_max_saved=0
1423 # adaptive timeouts may prevent seeing the issue
1424 if at_is_enabled; then
1425 at_max_saved=$(at_max_get mds)
1426 at_max_set 0 mds client
1429 mkdir -p $MOUNT/testdir
1430 touch $MOUNT/testdir/test
1432 log "Injecting EBUSY on MDS"
1433 # Setting OBD_FAIL_MDS_RESEND=0x136
1434 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x80000136" || return 2
1436 log "Stat on a test file"
1437 stat $MOUNT/testdir/test
1439 log "Stop injecting EBUSY on MDS"
1440 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0" || return 3
1441 rm -f $MOUNT/testdir/test
1444 # restore adaptive timeout
1445 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1447 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1449 # retrieve from the log if the client has ever tried to
1450 # contact the fake server after the loss of connection
1451 FAILCONN=`awk "BEGIN {ret = 0;}
1452 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1454 if (\\\$NF ~ /$FAKENID/) {
1459 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1461 [ "$FAILCONN" == "0" ] && \
1462 log "ERROR: The client reconnection has not been triggered" && \
1464 [ "$FAILCONN" == "2" ] && \
1465 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1469 # remove nid settings
1472 run_test 35b "Continue reconnection retries, if the active server is busy"
1476 local FSNAME2=test1234
1477 local fs3ost_HOST=$ost_HOST
1478 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1480 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1483 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1484 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1485 skip_env "mixed loopback and real device not working" && return
1487 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1489 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1490 { skip "remote OST" && return 0; }
1492 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1493 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1494 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1495 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1496 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1498 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1499 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1501 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1502 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1503 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1505 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1507 sleep 5 # until 11778 fixed
1509 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1511 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1512 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1513 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1514 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1515 DFTOTAL=`echo $STRING | cut -d, -f1`
1516 DFUSED=`echo $STRING | cut -d, -f2`
1517 DFAVAIL=`echo $STRING | cut -d, -f3`
1518 DFFREE=$(($DFTOTAL - $DFUSED))
1520 ALLOWANCE=$((64 * $OSTCOUNT))
1522 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1523 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1524 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1527 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1528 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1529 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1532 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1533 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1534 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1539 stop fs3ost -f || return 200
1540 stop fs2ost -f || return 201
1541 stop fs2mds -f || return 202
1542 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1543 unload_modules_conf || return 203
1546 run_test 36 "df report consistency on OSTs with different block size"
1549 client_only && skip "client only testing" && return 0
1550 LOCAL_MDSDEV="$TMP/mdt.img"
1551 SYM_MDSDEV="$TMP/sym_mdt.img"
1553 echo "MDS : $LOCAL_MDSDEV"
1554 echo "SYMLINK : $SYM_MDSDEV"
1558 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1559 error "mkfs.lustre $LOCAL_MDSDEV failed"
1560 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1562 echo "mount symlink device - $SYM_MDSDEV"
1564 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1565 umount -d ${MOUNT%/*}/mds
1566 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1568 if [ -n "$mount_op" ]; then
1569 error "**** FAIL: set tunables failed for symlink device"
1573 run_test 37 "verify set tunables works for symlink device"
1575 test_38() { # bug 14222
1580 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1581 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1583 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1584 error "copying $SRC to $DIR/$tdir"
1586 umount_client $MOUNT
1588 log "rename lov_objid file on MDS"
1589 rm -f $TMP/lov_objid.orig
1591 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1592 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1593 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1595 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1596 # check create in mds_lov_connect
1600 [ $V ] && log "verifying $DIR/$tdir/$f"
1601 diff -q $f $DIR/$tdir/$f || ERROR=y
1603 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1604 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1605 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1607 # check it's updates in sync
1608 umount_client $MOUNT
1611 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1612 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1613 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1618 [ $V ] && log "verifying $DIR/$tdir/$f"
1619 diff -q $f $DIR/$tdir/$f || ERROR=y
1621 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1622 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1623 umount_client $MOUNT
1625 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1627 log "files compared the same"
1630 run_test 38 "MDS recreates missing lov_objid file from OST data"
1636 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1637 error "memory leak detected" || true
1639 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1641 test_40() { # bug 15759
1643 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1644 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1648 run_test 40 "race during service thread startup"
1650 test_41() { #bug 14134
1652 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1654 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1655 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1656 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1658 mount_client $MOUNT || return 1
1661 echo "blah blah" > $MOUNT/$tfile
1664 umount_client $MOUNT
1665 stop ost1 -f || return 201
1666 stop_mds -f || return 202
1667 stop_mds -f || return 203
1668 unload_modules_conf || return 204
1671 run_test 41 "mount mds with --nosvc and --nomgs"
1673 test_42() { #bug 14693
1675 check_mount || return 2
1676 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1677 umount_client $MOUNT
1678 mount_client $MOUNT || return 1
1682 run_test 42 "invalid config param should not prevent client from mounting"
1685 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1687 chmod ugo+x $DIR || error "chmod 0 failed"
1689 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1690 "$FSNAME.mdt.root_squash" \
1693 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1694 "$FSNAME.mdt.nosquash_nids" \
1698 # create set of test files
1700 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1701 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1702 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1704 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1705 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1707 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1708 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1709 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1712 # check root_squash:
1713 # set root squash UID:GID to RUNAS_ID
1714 # root should be able to access only files owned by RUNAS_ID
1717 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1718 "$FSNAME.mdt.root_squash" \
1719 "$RUNAS_ID:$RUNAS_ID"
1721 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1722 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1723 error "$ST: root read permission is denied"
1724 echo "$ST: root read permission is granted - ok"
1727 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1728 error "$ST: root write permission is denied"
1729 echo "$ST: root write permission is granted - ok"
1731 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1732 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1733 error "$ST: root read permission is granted"
1734 echo "$ST: root read permission is denied - ok"
1737 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1738 error "$ST: root write permission is granted"
1739 echo "$ST: root write permission is denied - ok"
1741 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1742 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1743 error "$ST: root unlink permission is granted"
1744 echo "$ST: root unlink permission is denied - ok"
1746 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1747 error "$ST: root create permission is granted"
1748 echo "$ST: root create permission is denied - ok"
1751 # check nosquash_nids:
1752 # put client's NID into nosquash_nids list,
1753 # root should be able to access root file after that
1755 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1756 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1757 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1759 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1760 "$FSNAME-MDTall.mdt.nosquash_nids" \
1763 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1764 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1765 error "$ST: root read permission is denied"
1766 echo "$ST: root read permission is granted - ok"
1769 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1770 error "$ST: root write permission is denied"
1771 echo "$ST: root write permission is granted - ok"
1773 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1774 rm $DIR/$tdir-rootdir/tfile-1 || \
1775 error "$ST: root unlink permission is denied"
1776 echo "$ST: root unlink permission is granted - ok"
1777 touch $DIR/$tdir-rootdir/tfile-2 || \
1778 error "$ST: root create permission is denied"
1779 echo "$ST: root create permission is granted - ok"
1783 run_test 43 "check root_squash and nosquash_nids"
1785 umount_client $MOUNT
1790 check_mount || return 2
1791 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1793 UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1794 for VAL in $UUIDS; do
1795 NID=$(echo $VAL | cut -d= -f1)
1796 CLUUID=$(echo $VAL | cut -d= -f2)
1797 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1799 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1803 run_test 44 "mounted client proc entry exists"
1807 check_mount || return 2
1812 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1813 do_facet client "lctl set_param fail_loc=0x50f"
1816 manual_umount_client --force || return 3
1817 do_facet client "lctl set_param fail_loc=0x0"
1819 mount_client $MOUNT || return 4
1823 run_test 45 "long unlink handling in ptlrpcd"
1830 umount_client $MOUNT2 || rc=$?
1831 umount_client $MOUNT || rc=$?
1832 while [ $count -gt 0 ]; do
1833 stop ost${count} -f || rc=$?
1837 cleanup_nocli || rc=$?
1838 #writeconf to remove all ost2 traces for subsequent tests
1844 echo "Testing with $OSTCOUNT OSTs"
1846 start_mds || return 1
1847 #first client should see only one ost
1848 start_ost || return 2
1849 wait_osc_import_state mds ost FULL
1851 mount_client $MOUNT || return 3
1852 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1855 for (( i=2; i<=$OSTCOUNT; i++ )); do
1856 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1859 # wait until osts in sync
1860 for (( i=2; i<=$OSTCOUNT; i++ )); do
1861 wait_osc_import_state mds ost$i FULL
1865 #second client see all ost's
1867 mount_client $MOUNT2 || return 8
1868 $LFS setstripe $MOUNT2 -c -1 || return 9
1869 $LFS getstripe $MOUNT2 || return 10
1871 echo "ok" > $MOUNT2/widestripe
1872 $LFS getstripe $MOUNT2/widestripe || return 11
1873 # fill acl buffer for avoid expand lsm to them
1874 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1875 setfacl -m $acl $MOUNT2/widestripe
1879 stat $MOUNT/widestripe || return 12
1881 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1884 run_test 46a "handle ost additional - wide striped file"
1889 check_mount || return 2
1890 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1894 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1895 if echo $ns | grep "MDT[[:digit:]]*"; then
1898 lrs=$(echo $ns | sed 's/.*lru_size=//')
1899 lru_size[count]=$lrs
1904 facet_failover $SINGLEMDS
1905 client_up || return 3
1908 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1909 if echo $ns | grep "MDT[[:digit:]]*"; then
1912 lrs=$(echo $ns | sed 's/.*lru_size=//')
1913 if ! test "$lrs" -eq "${lru_size[count]}"; then
1914 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1915 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1923 run_test 47 "server restart does not make client loss lru_resize settings"
1928 # reformat after this test is needed - if test will failed
1929 # we will have unkillable file at FS
1933 test_48() { # bug 17636
1936 check_mount || return 2
1938 $LFS setstripe $MOUNT -c -1 || return 9
1939 $LFS getstripe $MOUNT || return 10
1941 echo "ok" > $MOUNT/widestripe
1942 $LFS getstripe $MOUNT/widestripe || return 11
1944 trap cleanup_48 EXIT ERR
1946 # fill acl buffer for avoid expand lsm to them
1947 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1948 setfacl -m $acl $MOUNT/widestripe
1951 stat $MOUNT/widestripe || return 12
1956 run_test 48 "too many acls on file"
1958 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1959 test_49() { # bug 17710
1960 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1961 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1962 local LOCAL_TIMEOUT=20
1965 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1969 check_mount || return 1
1971 echo "check ldlm_timout..."
1972 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
1973 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1974 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1976 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1977 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1980 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1981 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1984 umount_client $MOUNT
1985 stop_ost || return 2
1986 stop_mds || return 3
1988 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"
1992 check_mount || return 7
1994 LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
1995 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1996 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1998 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1999 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
2002 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
2003 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
2006 cleanup || return $?
2008 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
2009 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
2011 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
2014 # Test both statfs and lfs df and fail if either one fails
2015 multiop_bg_pause $1 f_
2018 killall -USR1 multiop
2019 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
2020 wait $PID || { RC1=$?; log "multiop return error "; }
2027 if [ $RC2 -eq 0 ]; then
2029 log "lazystatfs df failed"
2033 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
2039 lctl set_param llite.$FSNAME-*.lazystatfs=1
2042 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
2044 cleanup || return $?
2046 run_test 50a "lazystatfs all servers available =========================="
2050 lctl set_param llite.$FSNAME-*.lazystatfs=1
2053 # Wait for client to detect down OST
2054 stop_ost || error "Unable to stop OST1"
2055 wait_osc_import_state mds ost DISCONN
2057 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2059 umount_client $MOUNT || error "Unable to unmount client"
2060 stop_mds || error "Unable to stop MDS"
2062 run_test 50b "lazystatfs all servers down =========================="
2065 start_mds || error "Unable to start MDS"
2066 start_ost || error "Unable to start OST1"
2067 start_ost2 || error "Unable to start OST2"
2068 mount_client $MOUNT || error "Unable to mount client"
2069 lctl set_param llite.$FSNAME-*.lazystatfs=1
2072 # Wait for client to detect down OST
2073 stop_ost || error "Unable to stop OST1"
2074 wait_osc_import_state mds ost DISCONN
2075 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2077 umount_client $MOUNT || error "Unable to unmount client"
2078 stop_ost2 || error "Unable to stop OST2"
2079 stop_mds || error "Unable to stop MDS"
2081 run_test 50c "lazystatfs one server down =========================="
2084 start_mds || error "Unable to start MDS"
2085 start_ost || error "Unable to start OST1"
2086 start_ost2 || error "Unable to start OST2"
2087 mount_client $MOUNT || error "Unable to mount client"
2088 lctl set_param llite.$FSNAME-*.lazystatfs=1
2091 # Issue the statfs during the window where the client still
2092 # belives the OST to be available but it is in fact down.
2093 # No failure just a statfs which hangs for a timeout interval.
2094 stop_ost || error "Unable to stop OST1"
2095 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2097 umount_client $MOUNT || error "Unable to unmount client"
2098 stop_ost2 || error "Unable to stop OST2"
2099 stop_mds || error "Unable to stop MDS"
2101 run_test 50d "lazystatfs client/server conn race =========================="
2108 start_mds || return 1
2109 #first client should see only one ost
2110 start_ost || return 2
2111 wait_osc_import_state mds ost FULL
2113 # Wait for client to detect down OST
2114 stop_ost || error "Unable to stop OST1"
2115 wait_osc_import_state mds ost DISCONN
2117 mount_client $MOUNT || error "Unable to mount client"
2118 lctl set_param llite.$FSNAME-*.lazystatfs=0
2120 multiop_bg_pause $MOUNT _f
2124 if [ $RC1 -ne 0 ]; then
2125 log "multiop failed $RC1"
2128 sleep $(( $TIMEOUT+1 ))
2130 [ $? -ne 0 ] && error "process isn't sleep"
2131 start_ost || error "Unable to start OST1"
2132 wait $pid || error "statfs failed"
2135 umount_client $MOUNT || error "Unable to unmount client"
2136 stop_ost || error "Unable to stop OST1"
2137 stop_mds || error "Unable to stop MDS"
2139 run_test 50e "normal statfs all servers down =========================="
2144 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2146 start_mds || error "Unable to start mds"
2147 #first client should see only one ost
2148 start_ost || error "Unable to start OST1"
2149 wait_osc_import_state mds ost FULL
2151 start_ost2 || error "Unable to start OST2"
2152 wait_osc_import_state mds ost2 FULL
2154 # Wait for client to detect down OST
2155 stop_ost2 || error "Unable to stop OST2"
2157 wait_osc_import_state mds ost2 DISCONN
2158 mount_client $MOUNT || error "Unable to mount client"
2159 lctl set_param llite.$FSNAME-*.lazystatfs=0
2161 multiop_bg_pause $MOUNT _f
2165 if [ $RC1 -ne 0 ]; then
2166 log "lazystatfs multiop failed $RC1"
2169 sleep $(( $TIMEOUT+1 ))
2171 [ $? -ne 0 ] && error "process isn't sleep"
2172 start_ost2 || error "Unable to start OST2"
2173 wait $pid || error "statfs failed"
2174 stop_ost2 || error "Unable to stop OST2"
2177 umount_client $MOUNT || error "Unable to unmount client"
2178 stop_ost || error "Unable to stop OST1"
2179 stop_mds || error "Unable to stop MDS"
2180 #writeconf to remove all ost2 traces for subsequent tests
2183 run_test 50f "normal statfs one server in down =========================="
2186 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2188 start_ost2 || error "Unable to start OST2"
2189 wait_osc_import_state mds ost2 FULL
2190 wait_osc_import_state client ost2 FULL
2192 local PARAM="${FSNAME}-OST0001.osc.active"
2194 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2195 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2197 umount_client $MOUNT || error "Unable to unmount client"
2198 mount_client $MOUNT || error "Unable to mount client"
2199 # This df should not cause a panic
2202 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2204 umount_client $MOUNT || error "Unable to unmount client"
2205 stop_ost2 || error "Unable to stop OST2"
2206 stop_ost || error "Unable to stop OST1"
2207 stop_mds || error "Unable to stop MDS"
2208 #writeconf to remove all ost2 traces for subsequent tests
2211 run_test 50g "deactivated OST should not cause panic====================="
2214 local LOCAL_TIMEOUT=20
2218 check_mount || return 1
2221 $LFS setstripe -c -1 $MOUNT/d1
2222 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2223 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2224 touch $MOUNT/d1/f1 &
2227 start_ost2 || return 2
2229 stop_ost2 || return 3
2232 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2241 do_node $node mkdir -p $dest
2242 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2244 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2245 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2246 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2248 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2249 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2259 local backup2=${TMP}/backup2
2261 do_node $node mkdir -p $backup2
2262 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2264 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2265 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2266 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2268 do_node $node "diff -rq $backup $backup2"
2269 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2271 local xattrs2=${TMP}/xattrs2
2272 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2273 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2275 do_node $node "diff $xattrs $xattrs2"
2276 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2278 do_node $node "rm -rf $backup2 $xattrs2"
2279 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2284 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2286 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2288 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2291 local ost1mnt=${MOUNT%/*}/ost1
2292 local ost1node=$(facet_active_host ost1)
2293 local ost1tmp=$TMP/conf52
2296 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2297 touch $TMP/modified_first
2298 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2299 local mtime=$(stat -c %Y $TMP/modified_first)
2300 do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
2302 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2305 $LFS setstripe $DIR/$tdir -c -1 -s 1M
2306 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2308 for (( i=0; i < nrfiles; i++ )); do
2309 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2310 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2316 echo backup files to $TMP/files
2317 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2318 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2319 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2321 umount_client $MOUNT
2322 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2324 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2326 echo mount ost1 as ldiskfs
2327 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2328 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2331 echo backup objects to $ost1tmp/objects
2332 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2333 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2334 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2335 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2337 # move objects to lost+found
2338 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2339 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2342 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2343 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2345 # compare restored objects against saved ones
2346 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2347 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2349 do_node $ost1node "umount $ost1_dev"
2350 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2353 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2355 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2358 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2359 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2361 rm -rf $TMP/files $TMP/file_xattrs
2362 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2363 do_node $ost1node "rm -rf $ost1tmp"
2364 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2367 run_test 52 "check recovering objects from lost+found"
2369 # Checks threads_min/max/started for some service
2371 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2372 # parameter pattern prefix like 'ost.*.ost'.
2384 local msg="Insane $modname thread counts"
2388 check_mount || return 41
2390 # We need to expand $parampat, but it may match multiple parameters, so
2391 # we'll pick the first one
2392 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2393 error "Couldn't expand ${parampat}.threads_min parameter name"
2397 # Remove the .threads_min part
2398 paramp=${paramp%.threads_min}
2400 # Check for sanity in defaults
2401 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2402 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2403 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2404 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2405 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
2407 # Check that we can lower min/max
2408 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin - 1))"
2409 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 1))"
2410 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2411 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2412 lassert 25 "$msg" '(($tmin2 == ($tmin - 1) && $tmax2 == ($tmax -1)))' || return $?
2414 # Check that we can set min/max to the same value
2415 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2416 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2417 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2418 lassert 26 "$msg" '(($tmin2 == ($tmin - 1) && $tmax2 == ($tmin - 1)))' || return $?
2420 # Check that we can't set max < min
2421 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 2))"
2422 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2423 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2424 lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
2426 # We need to ensure that we get the module options desired; to do this
2427 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2428 LOAD_MODULES_REMOTE=true
2431 setmodopts -a $modname "$opts" oldvalue
2435 check_mount || return 41
2437 # Restore previous setting of MODOPTS_*
2438 setmodopts $modname "$oldvalue"
2440 # Check that $opts took
2441 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2442 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2443 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2444 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2447 # Workaround a YALA bug where YALA expects that modules will remain
2448 # loaded on the servers
2449 LOAD_MODULES_REMOTE=false
2456 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2458 run_test 53a "check OSS thread count params"
2461 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2463 run_test 53b "check MDT thread count params"
2468 local partial_arg=""
2469 local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
2471 # Run in partial (fast) mode if the size
2472 # of a partition > 10 GB
2473 [ $size -gt 10 ] && partial_arg="-p"
2475 llverfs $partial_arg $dir
2479 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
2480 [ $? -eq 0 ] || error "llverdev failed!"
2483 run_test 54a "llverdev"
2488 [ $? -eq 0 ] || error "llverfs failed!"
2491 run_test 54b "llverfs"
2495 local max_ost_index=$1
2496 echo -n $(((max_ost_index + 1) * 8))
2500 local mdsdev=$(mdsdevname 1)
2501 local ostdev=$(ostdevname 1)
2502 local saved_opts=$OST_MKFS_OPTS
2504 for i in 0 1023 2048
2506 OST_MKFS_OPTS="$saved_opts --index $i"
2514 echo checking size of lov_objid for ost index $i
2515 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2516 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2517 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2519 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2524 OST_MKFS_OPTS=$saved_opts
2527 run_test 55 "check lov_objid size"
2530 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2531 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2532 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2536 start_ost2 || error "Unable to start second ost"
2537 mount_client $MOUNT || error "Unable to mount client"
2540 [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
2544 run_test 56 "check big indexes"
2546 test_57() { # bug 22656
2547 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2549 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2551 start_ost && error "OST registration from failnode should fail"
2555 run_test 57 "initial registration from failnode should fail (should return errs)"
2558 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2562 start_mgsmds >> /dev/null
2563 local C1=$(count_osts)
2564 if [ $C1 -eq 0 ]; then
2565 start_ost >> /dev/null
2569 echo "original ost count: $C1 (expect > 0)"
2570 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2571 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2572 local C2=$(count_osts)
2573 echo "after mdt writeconf count: $C2 (expect 0)"
2574 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2575 echo "OST start without writeconf should fail:"
2576 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2577 echo "OST start with writeconf should succeed:"
2578 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2579 local C3=$(count_osts)
2580 echo "after ost writeconf count: $C3 (expect 1)"
2581 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2582 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2583 local C4=$(count_osts)
2584 echo "after ost2 writeconf count: $C4 (expect 2)"
2585 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2586 stop_ost2 >> /dev/null
2587 cleanup_nocli >> /dev/null
2589 run_test 59 "writeconf mount option"
2592 test_58() { # bug 22658
2593 [ "$FSTYPE" != "ldiskfs" ] && skip "not supported for $FSTYPE" && return
2596 createmany -o $DIR/$tdir/$tfile-%d 100
2597 # make sure that OSTs do not cancel llog cookies before we unmount the MDS
2598 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
2599 do_facet mds "lctl set_param fail_loc=0x601"
2600 unlinkmany $DIR/$tdir/$tfile-%d 100
2602 local MNTDIR=$(facet_mntpt mds)
2603 # remove all files from the OBJECTS dir
2604 do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
2605 do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
2606 do_facet mds "umount $MNTDIR"
2607 # restart MDS with missing llog files
2609 do_facet mds "lctl set_param fail_loc=0"
2612 run_test 58 "missing llog files must not prevent MDT from mounting"
2614 if ! combined_mgs_mds ; then
2618 equals_msg `basename $0`: test complete
2619 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true