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!
20 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
22 PTLDEBUG=${PTLDEBUG:--1}
24 LUSTRE=${LUSTRE:-`dirname $0`/..}
25 RLUSTRE=${RLUSTRE:-$LUSTRE}
27 . $LUSTRE/tests/test-framework.sh
30 # use small MDS + OST size to speed formatting time
31 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
34 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
36 # STORED_MDSSIZE is used in test_18
37 if [ -n "$MDSSIZE" ]; then
38 STORED_MDSSIZE=$MDSSIZE
44 require_dsh_mds || exit 0
45 require_dsh_ost || exit 0
47 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
62 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
63 do_facet ${facet} "$TUNEFS --writeconf $dev" ||
64 { echo "tunefs failed, reformatting instead" && reformat_and_config && return 1; }
69 # if writeconf failed, we reformatted
70 writeconf1 mds $MDSDEV || return 0
71 writeconf1 ost1 `ostdevname 1` || return 0
72 writeconf1 ost2 `ostdevname 2` || return 0
76 # The MGS must be started before the OSTs for a new fs, so start
77 # and stop to generate the startup logs.
80 wait_osc_import_state mds ost FULL
85 reformat_and_config() {
87 if ! combined_mgs_mds ; then
95 start mgs $MGSDEV $mgs_MOUNT_OPTS
99 local facet=$SINGLEMDS
100 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
101 local num=$(echo $facet | tr -d "mds")
102 local dev=$(mdsdevname $num)
103 echo "start mds service on `facet_active_host $facet`"
104 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
108 if ! combined_mgs_mds ; then
115 echo "stop mds service on `facet_active_host $SINGLEMDS`"
116 # These tests all use non-failover stop
117 stop $SINGLEMDS -f || return 97
121 echo "start ost1 service on `facet_active_host ost1`"
122 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
126 echo "stop ost1 service on `facet_active_host ost1`"
127 # These tests all use non-failover stop
128 stop ost1 -f || return 98
132 echo "start ost2 service on `facet_active_host ost2`"
133 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
137 echo "stop ost2 service on `facet_active_host ost2`"
138 # These tests all use non-failover stop
139 stop ost2 -f || return 93
144 echo "mount $FSNAME on ${MOUNTPATH}....."
145 zconf_mount `hostname` $MOUNTPATH || return 96
149 local SAVEMOUNTOPT=$MOUNTOPT
150 MOUNTOPT="remount,$1"
152 echo "remount '$1' lustre on ${MOUNTPATH}....."
153 zconf_mount `hostname` $MOUNTPATH || return 96
154 MOUNTOPT=$SAVEMOUNTOPT
159 echo "umount lustre on ${MOUNTPATH}....."
160 zconf_umount `hostname` $MOUNTPATH || return 97
163 manual_umount_client(){
166 echo "manual umount lustre on ${MOUNT}...."
167 do_facet client "umount -d ${FORCE} $MOUNT"
173 start_mds || error "MDT start failed"
174 start_ost || error "OST start failed"
175 mount_client $MOUNT || error "client start failed"
179 if ! combined_mgs_mds ; then
189 stop_ost || return 202
190 stop_mds || return 201
191 unload_modules || return 203
195 umount_client $MOUNT || return 200
196 cleanup_nocli || return $?
200 do_facet client "cp /etc/passwd $DIR/a" || return 71
201 do_facet client "rm $DIR/a" || return 72
202 # make sure lustre is actually mounted (touch will block,
203 # but grep won't, so do it after)
204 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
205 echo "setup single mount lustre success"
209 do_facet client "touch $DIR/a" || return 71
210 do_facet client "rm $DIR/a" || return 72
211 do_facet client "touch $DIR2/a" || return 73
212 do_facet client "rm $DIR2/a" || return 74
213 echo "setup double mount lustre success"
218 if [ "$ONLY" == "setup" ]; then
223 if [ "$ONLY" == "cleanup" ]; then
230 #create single point mountpoint
236 check_mount || return 41
239 run_test 0 "single mount setup"
242 start_mds || error "MDT start failed"
244 echo "start ost second time..."
245 start_ost && error "2nd OST start should fail"
246 mount_client $MOUNT || error "client start failed"
247 check_mount || return 42
250 run_test 1 "start up ost twice (should return errors)"
254 echo "start mds second time.."
255 start_mds && error "2nd MDT start should fail"
258 check_mount || return 43
261 run_test 2 "start up mds twice (should return err)"
265 #mount.lustre returns an error if already in mtab
266 mount_client $MOUNT && error "2nd client mount should fail"
267 check_mount || return 44
270 run_test 3 "mount client twice (should return err)"
274 touch $DIR/$tfile || return 85
278 # ok for ost to fail shutdown
279 if [ 202 -ne $eno ]; then
284 run_test 4 "force cleanup ost, then cleanup"
286 test_5a() { # was test_5
288 touch $DIR/$tfile || return 1
289 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
291 stop_mds -f || return 2
293 # cleanup may return an error from the failed
294 # disconnects; for now I'll consider this successful
295 # if all the modules have unloaded.
299 echo "killing umount"
300 kill -TERM $UMOUNT_PID
301 echo "waiting for umount to finish"
303 if grep " $MOUNT " /proc/mounts; then
304 echo "test 5: /proc/mounts after failed umount"
308 echo "killing umount"
309 kill -TERM $UMOUNT_PID
310 echo "waiting for umount to finish"
312 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
316 # stop_mds is a no-op here, and should not fail
317 cleanup_nocli || return $?
318 # df may have lingering entry
320 # mtab may have lingering entry
324 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
326 grep -q $MOUNT" " /etc/mtab || break
327 echo "Waiting /etc/mtab updated ... "
328 WAIT=$(( WAIT + sleep))
330 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
331 echo "/etc/mtab updated in $WAIT secs"
333 run_test 5a "force cleanup mds, then cleanup"
337 [ -d $MOUNT ] || mkdir -p $MOUNT
338 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
339 mount_client $MOUNT && return 1
340 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
342 # stop_mds is a no-op here, and should not fail
343 cleanup_nocli || return $?
346 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
351 [ -d $MOUNT ] || mkdir -p $MOUNT
352 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
353 local oldfs="${FSNAME}"
354 FSNAME="wrong.${FSNAME}"
355 mount_client $MOUNT || :
357 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
359 cleanup_nocli || return $?
361 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
367 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
368 mount_client $MOUNT || return 1
370 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
373 run_test 5d "mount with ost down"
379 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
380 do_facet client "lctl set_param fail_loc=0x80000506"
381 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
382 mount_client $MOUNT || echo "mount failed (not fatal)"
384 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
387 run_test 5e "delayed connect, don't crash (bug 10268)"
392 mount_client ${MOUNT} || return 87
393 touch $DIR/a || return 86
396 run_test 6 "manual umount, then mount again"
401 cleanup_nocli || return $?
403 run_test 7 "manual umount, then cleanup"
408 check_mount2 || return 45
409 umount_client $MOUNT2
412 run_test 8 "double mount setup"
417 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
418 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
420 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
421 if [ "$CHECK_PTLDEBUG" ] && { \
422 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
423 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
424 echo "lnet.debug success"
426 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
429 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
430 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
431 echo "lnet.subsystem_debug success"
433 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
436 stop_ost || return $?
438 run_test 9 "test ptldebug and subsystem for mkfs"
441 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
442 # But with new MDS stack we don't care about the mode of local objects
443 # anymore, so this test is removed. See bug 22944 for more details.
447 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
449 if [ ! -e "$MDSDEV" ]; then
450 echo "no $MDSDEV existing, so mount Lustre to create one"
452 check_mount || return 41
456 echo "Remove mds config log"
457 do_facet $SINGLEMDS "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
460 start_mds && return 42
463 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
466 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
468 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
473 # check if current MDSSIZE is large enough
474 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
475 log "use MDSSIZE=$MDSSIZE"
477 # check if the global config has a large enough MDSSIZE
478 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
479 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
480 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
482 # check if the block device is large enough
483 [ -z "$OK" -a -b $MDSDEV ] && \
484 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
485 awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
486 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
488 # check if a loopback device has enough space for fs metadata (5%)
489 [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
490 SPACE=$(df -P $(dirname $MDSDEV) |
491 awk '($1 != "Filesystem") {print $4}') &&
492 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
493 log "use file $MDSDEV with MIN=$MIN"
495 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
498 echo "mount mds with large journal..."
499 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
501 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
504 echo "mount lustre system..."
506 check_mount || return 41
508 echo "check journal size..."
509 local FOUNDSIZE=`do_facet mds "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
510 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
511 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
513 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
518 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
521 run_test 18 "check mkfs creates large journals"
524 start_mds || return 1
525 stop_mds -f || return 2
527 run_test 19a "start/stop MDS without OSTs"
530 start_ost || return 1
531 stop_ost -f || return 2
533 run_test 19b "start/stop OSTs without MDS"
536 # first format the ost/mdt
540 check_mount || return 43
542 remount_client ro $MOUNT || return 44
543 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
544 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
545 remount_client rw $MOUNT || return 47
547 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
548 MCNT=`grep -c $MOUNT /etc/mtab`
549 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
554 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
559 wait_osc_import_state mds ost FULL
563 run_test 21a "start mds before ost, stop ost first"
568 wait_osc_import_state mds ost FULL
572 run_test 21b "start ost before mds, stop mds first"
578 wait_osc_import_state mds ost2 FULL
582 #writeconf to remove all ost2 traces for subsequent tests
585 run_test 21c "start mds between two osts, stop mds last"
590 echo Client mount with ost in logs, but none running
592 # wait until mds connected to ost and open client connection
593 wait_osc_import_state mds ost FULL
596 # check_mount will block trying to contact ost
597 mcreate $DIR/$tfile || return 40
598 rm -f $DIR/$tfile || return 42
602 echo Client mount with a running ost
605 # if gss enabled, wait full time to let connection from
606 # mds to ost be established, due to the mismatch between
607 # initial connect timeout and gss context negotiation timeout.
608 # This perhaps could be remove after AT landed.
609 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
610 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
613 check_mount || return 41
618 run_test 22 "start a client before osts (should return errs)"
620 test_23a() { # was test_23
624 # force down client so that recovering mds waits for reconnect
625 local running=$(grep -c $MOUNT /proc/mounts) || true
626 if [ $running -ne 0 ]; then
627 echo "Stopping client $MOUNT (opts: -f)"
631 # enter recovery on mds
633 # try to start a new client
634 mount_client $MOUNT &
636 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
637 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
638 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
640 ps --ppid $MOUNT_LUSTRE_PID
641 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
642 kill -TERM $MOUNT_LUSTRE_PID
643 echo "waiting for mount to finish"
645 # we can not wait $MOUNT_PID because it is not a child of this shell
651 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
653 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
654 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
657 [ -z "$PID1" -a -z "$PID2" ] && break
658 echo "waiting for mount to finish ... "
659 WAIT=$(( WAIT + sleep))
661 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
662 error "MOUNT_PID $MOUNT_PID and "\
663 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
669 run_test 23a "interrupt client during recovery mount delay"
674 test_23b() { # was test_23
677 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
678 lctl set_param fail_loc=0x80000313
682 run_test 23b "Simulate -EINTR during mount"
684 fs2mds_HOST=$mds_HOST
685 fs2ost_HOST=$ost_HOST
689 echo "umount $MOUNT2 ..."
690 umount $MOUNT2 || true
691 echo "stopping fs2mds ..."
692 stop fs2mds -f || true
693 echo "stopping fs2ost ..."
694 stop fs2ost -f || true
702 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
704 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
705 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
706 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
707 skip_env "mixed loopback and real device not working" && return
710 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
711 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
713 # test 8-char fsname as well
714 local FSNAME2=test1234
715 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
717 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
720 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
721 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
723 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
725 check_mount || return 2
726 # files written on 1 should not show up on 2
727 cp /etc/passwd $DIR/$tfile
729 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
732 cp /etc/passwd $MOUNT2/b || return 3
733 rm $MOUNT2/b || return 4
734 # 2 is actually mounted
735 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
737 facet_failover fs2mds
738 facet_failover fs2ost
741 # the MDS must remain up until last MDT
743 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
744 [ -z "$MDS" ] && error "No MDT" && return 8
746 cleanup_nocli || return 6
748 run_test 24a "Multiple MDTs on a single node"
751 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
753 if [ -z "$fs2mds_DEV" ]; then
754 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
755 skip_env "mixed loopback and real device not working" && return
758 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
760 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
762 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
765 run_test 24b "Multiple MGSs on a single node (should return err)"
769 check_mount || return 2
770 local MODULES=$($LCTL modules | awk '{ print $2 }')
771 rmmod $MODULES 2>/dev/null || true
774 run_test 25 "Verify modules are referenced"
778 # we need modules before mount for sysctl, so make sure...
779 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
780 #define OBD_FAIL_MDS_FS_SETUP 0x135
781 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
782 start_mds && echo MDS started && return 1
783 lctl get_param -n devices
784 DEVS=$(lctl get_param -n devices | wc -l)
785 [ $DEVS -gt 0 ] && return 2
786 unload_modules || return 203
788 run_test 26 "MDT startup failure cleans LOV (should return errs)"
794 local ORIG=$(do_facet $myfacet "$TEST")
795 if [ $# -gt 3 ]; then
801 echo "Setting $PARAM from $ORIG to $FINAL"
802 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
804 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
808 start_ost || return 1
809 start_mds || return 2
810 echo "Requeue thread should have started: "
811 ps -e | grep ll_cfg_requeue
812 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
815 run_test 27a "Reacquire MGS lock if OST started first"
820 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
822 facet_failover $SINGLEMDS
823 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
824 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
828 run_test 27b "Reacquire MGS lock after failover"
832 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
833 PARAM="llite.$FSNAME.max_read_ahead_whole_mb"
836 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
837 FINAL=$(($FINAL + 1))
838 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
839 umount_client $MOUNT || return 200
842 if [ $RESULT -ne $FINAL ]; then
843 echo "New config not seen: wanted $FINAL got $RESULT"
846 echo "New config success: got $RESULT"
848 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
851 run_test 28a "permanent parameter setting"
856 set_and_check $NODE "$LCTL get_param -n $1*.$2 | head -1" "$1.$2" "$3" || \
857 error "conf_param $1.$2 failed"
863 do_facet mgs "$LCTL conf_param foo=1 2>/dev/null" && \
864 error "Bad format should fail"
865 do_facet mgs "$LCTL conf_param osc.notanfs-OST0000.active=0 2>/dev/null" && \
866 error "Setting on unknown fs should fail"
867 do_facet mgs "$LCTL conf_param osc.$FSNAME-OST00000.active=0 2>/dev/null" && \
868 error "Bad target name should fail"
870 check_28b mds mdt.$FSNAME-MDT0000 capa_timeout 1500
871 check_28b mds mdt.$FSNAME-MDT* identity_expire 150
872 check_28b mds mdd.$FSNAME-MDT0000 atime_diff 15
873 check_28b mds mdd.$FSNAME-MDT* sync_permission 0
874 check_28b ost1 obdfilter.$FSNAME-OST0000 client_cache_seconds 15
875 check_28b ost1 obdfilter.$FSNAME-OST* client_cache_count 15
876 check_28b mds lov.$FSNAME-MDT0000 qos_maxage "15 Sec"
877 check_28b mds lov.$FSNAME-MDT0000 qos_prio_free "15%"
878 check_28b client mdc.$FSNAME-MDT0000 max_rpcs_in_flight 15
879 check_28b client osc.$FSNAME-OST0000 active 0
880 check_28b client osc.$FSNAME-OST0000 active 1
881 check_28b client osc.$FSNAME-OST0000 max_dirty_mb 15
882 check_28b client llite.$FSNAME max_read_ahead_mb 15
883 set_and_check client "$LCTL get_param -n at_max" "sys.$FSNAME.at_max" 1500 || \
884 error "conf_param sys.fsname.at_max failed"
887 run_test 28b "permanent parameter setting, set_param syntax"
890 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
891 setup > /dev/null 2>&1
895 local PARAM="osc.$FSNAME-OST0001.active"
896 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
897 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
899 ACTV=$(lctl get_param -n $PROC_ACT)
901 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
902 # also check ost_server_uuid status
903 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
904 if [ -z "$RESULT" ]; then
905 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
908 echo "Live client success: got $RESULT"
912 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0001)
913 mdtosc=${mdtosc/-MDT*/-MDT\*}
914 local MPROC="osc.$mdtosc.active"
919 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
920 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
921 if [ $RESULT -eq $DEAC ]; then
922 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
926 if [ $WAIT -eq $MAX ]; then
927 echo "MDT not deactivated: wanted $DEAC got $RESULT"
930 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
933 # test new client starts deactivated
934 umount_client $MOUNT || return 200
936 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
937 if [ -z "$RESULT" ]; then
938 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
941 echo "New client success: got $RESULT"
944 # make sure it reactivates
945 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
950 #writeconf to remove all ost2 traces for subsequent tests
953 run_test 29 "permanently remove an OST"
959 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
961 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
962 for i in ${LIST[@]}; do
963 set_and_check client "$TEST" "llite.$FSNAME.max_read_ahead_whole_mb" $i || return 3
965 # make sure client restart still works
967 mount_client $MOUNT || return 4
968 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
971 echo Erase parameter setting
972 do_facet mgs "$LCTL conf_param -d llite.$FSNAME.max_read_ahead_whole_mb" || return 6
974 mount_client $MOUNT || return 6
976 echo "deleted (default) value=$FINAL, orig=$ORIG"
977 # assumes this parameter started at the default value
978 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
982 run_test 30a "Big config llog and conf_param deletion"
987 # Make a fake nid. Use the OST nid, and add 20 to the least significant
988 # numerical part of it. Hopefully that's not already a failover address for
990 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
991 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
992 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
993 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
994 echo "Using fake nid $NEW"
996 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
997 set_and_check client "$TEST" "osc.$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
998 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1000 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1001 echo "should have 2 failover nids: $NIDCOUNT"
1002 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
1003 do_facet mgs "$LCTL conf_param -d osc.$FSNAME-OST0000.failover.node" || error "conf_param delete failed"
1004 umount_client $MOUNT
1005 mount_client $MOUNT || return 3
1007 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
1009 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
1010 echo "only 1 final nid should remain: $NIDCOUNT"
1011 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1015 run_test 30b "Remove failover nids"
1017 test_31() { # bug 10734
1018 # ipaddr must not exist
1019 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1022 run_test 31 "Connect to non-existent node (shouldn't crash)"
1024 # Use these start32/stop32 fn instead of t-f start/stop fn,
1025 # for local devices, to skip global facet vars init
1029 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1030 umount -d $@ ${MOUNT%/*}/${facet}
1039 mkdir -p ${MOUNT%/*}/${facet}
1041 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1042 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1044 if [ $RC -ne 0 ]; then
1045 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1046 echo "Start of ${device} of local ${facet} failed ${RC}"
1052 cleanup_nocli32 () {
1060 echo "Cleanup test_32 umount $MOUNT ..."
1061 umount -f $MOUNT || true
1062 echo "Cleanup local mds ost1 ..."
1068 client_only && skip "client only testing" && return 0
1069 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1070 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1072 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1073 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1074 local tmpdir=$TMP/conf32a
1076 tar xjvf $DISK1_8 -C $tmpdir || \
1077 { skip_env "Cannot untar $DISK1_8" && return 0; }
1080 $LCTL set_param debug=$PTLDEBUG
1082 $TUNEFS $tmpdir/mds || error "tunefs failed"
1084 # nids are wrong, so client wont work, but server should start
1085 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1086 trap cleanup_32 EXIT INT || return 3
1088 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1090 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1092 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1093 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1094 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1096 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1098 local NID=$($LCTL list_nids | head -1)
1100 echo "OSC changes should succeed:"
1101 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1102 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1105 echo "MDC changes should succeed:"
1106 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1107 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1110 echo "LOV changes should succeed:"
1111 $LCTL pool_new lustre.interop || return 11
1112 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1117 # mount a second time to make sure we didnt leave upgrade flag on
1119 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1120 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1121 trap cleanup_32 EXIT INT || return 12
1125 rm -rf $tmpdir || true # true is only for TMP on NFS
1127 run_test 32a "Upgrade from 1.8 (not live)"
1130 client_only && skip "client only testing" && return 0
1131 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1132 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1134 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1135 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1136 local tmpdir=$TMP/conf32b
1138 tar xjvf $DISK1_8 -C $tmpdir || \
1139 { skip_env "Cannot untar $DISK1_8" && return ; }
1142 $LCTL set_param debug="config"
1143 local NEWNAME=lustre
1145 # writeconf will cause servers to register with their current nids
1146 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1147 start32 mds1 $tmpdir/mds "-o loop" && \
1148 trap cleanup_32 EXIT INT || return 3
1150 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1152 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1154 $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 ||\
1155 error "tunefs failed"
1156 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1157 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1159 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1161 local NID=$($LCTL list_nids | head -1)
1163 echo "OSC changes should succeed:"
1164 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1165 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1168 echo "MDC changes should succeed:"
1169 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1170 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1173 echo "LOV changes should succeed:"
1174 $LCTL pool_new ${NEWNAME}.interop || return 11
1175 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1178 # MDT and OST should have registered with new nids, so we should have
1179 # a fully-functioning client
1180 echo "Check client and old fs contents"
1182 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1183 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1184 mount -t lustre $device $MOUNT || return 1
1186 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1187 local new=$((old + 5))
1188 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1189 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1191 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1196 rm -rf $tmpdir || true # true is only for TMP on NFS
1198 run_test 32b "Upgrade from 1.8 with writeconf"
1200 test_33a() { # bug 12333, was test_33
1202 local FSNAME2=test-123
1203 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1205 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1207 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1208 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1209 skip_env "mixed loopback and real device not working" && return
1212 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1213 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1214 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1215 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1217 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1218 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1219 do_facet mgs "$LCTL conf_param sys.$FSNAME2.timeout=200" || rc=1
1221 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1224 cp /etc/hosts $MOUNT2/ || rc=3
1225 $LFS getstripe $MOUNT2/hosts
1230 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1231 cleanup_nocli || rc=6
1234 run_test 33a "Mount ost with a large index number"
1236 test_33b() { # was test_34
1239 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1240 # Drop lock cancelation reply during umount
1241 #define OBD_FAIL_LDLM_CANCEL 0x304
1242 do_facet client lctl set_param fail_loc=0x80000304
1243 #lctl set_param debug=-1
1244 umount_client $MOUNT
1247 run_test 33b "Drop cancel during umount"
1251 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1252 manual_umount_client
1254 do_facet client killall -USR1 multiop
1255 if [ $rc -eq 0 ]; then
1256 error "umount not fail!"
1261 run_test 34a "umount with opened file should fail"
1266 touch $DIR/$tfile || return 1
1267 stop_mds --force || return 2
1269 manual_umount_client --force
1271 if [ $rc -ne 0 ]; then
1272 error "mtab after failed umount - rc $rc"
1278 run_test 34b "force umount with failed mds should be normal"
1282 touch $DIR/$tfile || return 1
1283 stop_ost --force || return 2
1285 manual_umount_client --force
1287 if [ $rc -ne 0 ]; then
1288 error "mtab after failed umount - rc $rc"
1294 run_test 34c "force umount with failed ost should be normal"
1296 test_35a() { # bug 12459
1299 DBG_SAVE="`lctl get_param -n debug`"
1300 lctl set_param debug="ha"
1302 log "Set up a fake failnode for the MDS"
1304 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1305 do_facet $SINGLEMDS $LCTL conf_param mdc.${device}.failover.node=$FAKENID || return 4
1307 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1310 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1313 log "Stopping the MDT:"
1314 stop_mds || return 5
1316 df $MOUNT > /dev/null 2>&1 &
1318 log "Restarting the MDT:"
1319 start_mds || return 6
1320 log "Wait for df ($DFPID) ... "
1323 lctl set_param debug="$DBG_SAVE"
1325 # retrieve from the log the first server that the client tried to
1326 # contact after the connection loss
1327 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1328 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1329 /import_select_connection.*$device-mdc.* using connection/ {
1331 if (\\\$NF ~ /$FAKENID/)
1337 }" $TMP/lustre-log-$TESTNAME.log`
1338 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1340 # remove nid settings
1343 run_test 35a "Reconnect to the last active server first"
1345 test_35b() { # bug 18674
1346 remote_mds || { skip "local MDS" && return 0; }
1350 $LCTL set_param debug="ha"
1352 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1355 log "Set up a fake failnode for the MDS"
1357 local device=$(do_facet mds "$LCTL get_param -n devices" | \
1358 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1359 do_facet mds "$LCTL conf_param mdc.${device}.failover.node=$FAKENID" || \
1362 local at_max_saved=0
1363 # adaptive timeouts may prevent seeing the issue
1364 if at_is_enabled; then
1365 at_max_saved=$(at_max_get mds)
1366 at_max_set 0 mds client
1369 mkdir -p $MOUNT/$tdir
1371 log "Injecting EBUSY on MDS"
1372 # Setting OBD_FAIL_MDS_RESEND=0x136
1373 do_facet mds "$LCTL set_param fail_loc=0x80000136" || return 2
1375 $LCTL set_param mdc.${FSNAME}*.stats=clear
1377 log "Creating a test file and stat it"
1378 touch $MOUNT/$tdir/$tfile
1379 stat $MOUNT/$tdir/$tfile
1381 log "Stop injecting EBUSY on MDS"
1382 do_facet mds "$LCTL set_param fail_loc=0" || return 3
1383 rm -f $MOUNT/$tdir/$tfile
1386 # restore adaptive timeout
1387 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1389 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1391 CONNCNT=`$LCTL get_param mdc.${FSNAME}*.stats | awk '/mds_connect/{print $2}'`
1393 # retrieve from the log if the client has ever tried to
1394 # contact the fake server after the loss of connection
1395 FAILCONN=`awk "BEGIN {ret = 0;}
1396 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1398 if (\\\$NF ~ /$FAKENID/) {
1403 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1405 [ "$FAILCONN" == "0" ] && \
1406 log "ERROR: The client reconnection has not been triggered" && \
1408 [ "$FAILCONN" == "2" ] && \
1409 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1412 # When OBD_FAIL_MDS_RESEND is hit, we sleep for 2 * obd_timeout
1413 # Reconnects are supposed to be rate limited to one every 5s
1414 [ $CONNCNT -gt $((2 * $TIMEOUT / 5 + 1)) ] && \
1415 log "ERROR: Too many reconnects $CONNCNT" && \
1419 # remove nid settings
1422 run_test 35b "Continue reconnection retries, if the active server is busy"
1426 local FSNAME2=test1234
1427 local fs3ost_HOST=$ost_HOST
1428 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1430 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1433 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1434 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1435 skip_env "mixed loopback and real device not working" && return
1437 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1439 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1440 { skip "remote OST" && return 0; }
1442 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1443 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1444 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1445 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1446 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1448 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1449 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1451 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1452 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1453 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1455 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1457 sleep 5 # until 11778 fixed
1459 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1461 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1462 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1463 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1464 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1465 DFTOTAL=`echo $STRING | cut -d, -f1`
1466 DFUSED=`echo $STRING | cut -d, -f2`
1467 DFAVAIL=`echo $STRING | cut -d, -f3`
1468 DFFREE=$(($DFTOTAL - $DFUSED))
1470 ALLOWANCE=$((64 * $OSTCOUNT))
1472 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1473 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1474 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1477 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1478 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1479 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1482 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1483 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1484 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1489 stop fs3ost -f || return 200
1490 stop fs2ost -f || return 201
1491 stop fs2mds -f || return 202
1492 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1493 unload_modules || return 203
1496 run_test 36 "df report consistency on OSTs with different block size"
1499 client_only && skip "client only testing" && return 0
1500 LOCAL_MDSDEV="$TMP/mdt.img"
1501 SYM_MDSDEV="$TMP/sym_mdt.img"
1503 echo "MDS : $LOCAL_MDSDEV"
1504 echo "SYMLINK : $SYM_MDSDEV"
1508 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1509 error "mkfs.lustre $LOCAL_MDSDEV failed"
1510 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1512 echo "mount symlink device - $SYM_MDSDEV"
1514 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1515 umount -d ${MOUNT%/*}/mds
1516 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1518 if [ -n "$mount_op" ]; then
1519 error "**** FAIL: set tunables failed for symlink device"
1523 run_test 37 "verify set tunables works for symlink device"
1525 test_38() { # bug 14222
1530 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1531 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1533 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1534 error "copying $SRC to $DIR/$tdir"
1536 umount_client $MOUNT
1538 log "rename lov_objid file on MDS"
1539 rm -f $TMP/lov_objid.orig
1541 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1542 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1543 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1545 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1546 # check create in mds_lov_connect
1550 [ $V ] && log "verifying $DIR/$tdir/$f"
1551 diff -q $f $DIR/$tdir/$f || ERROR=y
1553 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1554 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1555 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1557 # check it's updates in sync
1558 umount_client $MOUNT
1561 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1562 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1563 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1568 [ $V ] && log "verifying $DIR/$tdir/$f"
1569 diff -q $f $DIR/$tdir/$f || ERROR=y
1571 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1572 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1573 umount_client $MOUNT
1575 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1577 log "files compared the same"
1580 run_test 38 "MDS recreates missing lov_objid file from OST data"
1586 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1587 error "memory leak detected" || true
1589 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1591 test_40() { # bug 15759
1593 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1594 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1598 run_test 40 "race during service thread startup"
1600 test_41() { #bug 14134
1602 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1604 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1605 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1606 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1608 mount_client $MOUNT || return 1
1611 echo "blah blah" > $MOUNT/$tfile
1614 umount_client $MOUNT
1615 stop ost1 -f || return 201
1616 stop_mds -f || return 202
1617 stop_mds -f || return 203
1618 unload_modules || return 204
1621 run_test 41 "mount mds with --nosvc and --nomgs"
1623 test_42() { #bug 14693
1625 check_mount || return 2
1626 do_facet mgs $LCTL conf_param llite.$FSNAME.some_wrong_param=10
1627 umount_client $MOUNT
1628 mount_client $MOUNT || return 1
1632 run_test 42 "invalid config param should not prevent client from mounting"
1635 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1637 chmod ugo+x $DIR || error "chmod 0 failed"
1639 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1640 "mdt.$FSNAME-MDT*.root_squash" \
1643 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1644 "mdt.$FSNAME-MDT*.nosquash_nids" \
1648 # create set of test files
1650 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1651 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1652 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1654 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1655 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1657 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1658 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1659 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1662 # check root_squash:
1663 # set root squash UID:GID to RUNAS_ID
1664 # root should be able to access only files owned by RUNAS_ID
1667 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1668 "mdt.$FSNAME-MDT*.root_squash" \
1669 "$RUNAS_ID:$RUNAS_ID"
1671 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1672 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1673 error "$ST: root read permission is denied"
1674 echo "$ST: root read permission is granted - ok"
1677 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1678 error "$ST: root write permission is denied"
1679 echo "$ST: root write permission is granted - ok"
1681 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1682 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1683 error "$ST: root read permission is granted"
1684 echo "$ST: root read permission is denied - ok"
1687 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1688 error "$ST: root write permission is granted"
1689 echo "$ST: root write permission is denied - ok"
1691 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1692 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1693 error "$ST: root unlink permission is granted"
1694 echo "$ST: root unlink permission is denied - ok"
1696 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1697 error "$ST: root create permission is granted"
1698 echo "$ST: root create permission is denied - ok"
1701 # check nosquash_nids:
1702 # put client's NID into nosquash_nids list,
1703 # root should be able to access root file after that
1705 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1706 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1707 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1709 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1710 "mdt.$FSNAME-MDT*.nosquash_nids" \
1713 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1714 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1715 error "$ST: root read permission is denied"
1716 echo "$ST: root read permission is granted - ok"
1719 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1720 error "$ST: root write permission is denied"
1721 echo "$ST: root write permission is granted - ok"
1723 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1724 rm $DIR/$tdir-rootdir/tfile-1 || \
1725 error "$ST: root unlink permission is denied"
1726 echo "$ST: root unlink permission is granted - ok"
1727 touch $DIR/$tdir-rootdir/tfile-2 || \
1728 error "$ST: root create permission is denied"
1729 echo "$ST: root create permission is granted - ok"
1733 run_test 43 "check root_squash and nosquash_nids"
1735 umount_client $MOUNT
1740 check_mount || return 2
1741 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1743 UUIDS=$(do_facet mds "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1744 for VAL in $UUIDS; do
1745 NID=$(echo $VAL | cut -d= -f1)
1746 CLUUID=$(echo $VAL | cut -d= -f2)
1747 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1749 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1753 run_test 44 "mounted client proc entry exists"
1757 check_mount || return 2
1762 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1763 do_facet client "lctl set_param fail_loc=0x50f"
1766 manual_umount_client --force || return 3
1767 do_facet client "lctl set_param fail_loc=0x0"
1769 mount_client $MOUNT || return 4
1773 run_test 45 "long unlink handling in ptlrpcd"
1780 umount_client $MOUNT2 || rc=$?
1781 umount_client $MOUNT || rc=$?
1782 while [ $count -gt 0 ]; do
1783 stop ost${count} -f || rc=$?
1787 cleanup_nocli || rc=$?
1788 #writeconf to remove all ost2 traces for subsequent tests
1794 echo "Testing with $OSTCOUNT OSTs"
1796 start_mds || return 1
1797 #first client should see only one ost
1798 start_ost || return 2
1799 wait_osc_import_state mds ost FULL
1801 mount_client $MOUNT || return 3
1802 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1805 for (( i=2; i<=$OSTCOUNT; i++ )); do
1806 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1809 # wait until osts in sync
1810 for (( i=2; i<=$OSTCOUNT; i++ )); do
1811 wait_osc_import_state mds ost$i FULL
1815 #second client see all ost's
1817 mount_client $MOUNT2 || return 8
1818 $LFS setstripe $MOUNT2 -c -1 || return 9
1819 $LFS getstripe $MOUNT2 || return 10
1821 echo "ok" > $MOUNT2/widestripe
1822 $LFS getstripe $MOUNT2/widestripe || return 11
1823 # fill acl buffer for avoid expand lsm to them
1824 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1825 setfacl -m $acl $MOUNT2/widestripe
1829 stat $MOUNT/widestripe || return 12
1831 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1834 run_test 46a "handle ost additional - wide striped file"
1839 check_mount || return 2
1840 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1844 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1845 if echo $ns | grep "MDT[[:digit:]]*"; then
1848 lrs=$(echo $ns | sed 's/.*lru_size=//')
1849 lru_size[count]=$lrs
1854 facet_failover $SINGLEMDS
1855 client_up || return 3
1858 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1859 if echo $ns | grep "MDT[[:digit:]]*"; then
1862 lrs=$(echo $ns | sed 's/.*lru_size=//')
1863 if ! test "$lrs" -eq "${lru_size[count]}"; then
1864 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1865 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1873 run_test 47 "server restart does not make client loss lru_resize settings"
1878 # reformat after this test is needed - if test will failed
1879 # we will have unkillable file at FS
1883 test_48() { # bug 17636
1886 check_mount || return 2
1888 $LFS setstripe $MOUNT -c -1 || return 9
1889 $LFS getstripe $MOUNT || return 10
1891 echo "ok" > $MOUNT/widestripe
1892 $LFS getstripe $MOUNT/widestripe || return 11
1894 trap cleanup_48 EXIT ERR
1896 # fill acl buffer for avoid expand lsm to them
1897 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1898 setfacl -m $acl $MOUNT/widestripe
1901 stat $MOUNT/widestripe || return 12
1906 run_test 48 "too many acls on file"
1908 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1909 test_49() { # bug 17710
1910 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1911 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1912 local LOCAL_TIMEOUT=20
1915 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1919 check_mount || return 1
1921 echo "check ldlm_timout..."
1922 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1923 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1924 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1926 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1927 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1930 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1931 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1934 umount_client $MOUNT
1935 stop_ost || return 2
1936 stop_mds || return 3
1938 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"
1942 check_mount || return 7
1944 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1945 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1946 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1948 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1949 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1952 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1953 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1956 cleanup || return $?
1958 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1959 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1961 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1964 # Test both statfs and lfs df and fail if either one fails
1965 multiop_bg_pause $1 f_
1968 killall -USR1 multiop
1969 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
1970 wait $PID || { RC1=$?; log "multiop return error "; }
1977 if [ $RC2 -eq 0 ]; then
1979 log "lazystatfs df failed"
1983 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
1989 lctl set_param llite.$FSNAME-*.lazystatfs=1
1992 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
1994 cleanup || return $?
1996 run_test 50a "lazystatfs all servers available =========================="
2000 lctl set_param llite.$FSNAME-*.lazystatfs=1
2003 # Wait for client to detect down OST
2004 stop_ost || error "Unable to stop OST1"
2005 wait_osc_import_state mds ost DISCONN
2007 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
2009 umount_client $MOUNT || error "Unable to unmount client"
2010 stop_mds || error "Unable to stop MDS"
2012 run_test 50b "lazystatfs all servers down =========================="
2015 start_mds || error "Unable to start MDS"
2016 start_ost || error "Unable to start OST1"
2017 start_ost2 || error "Unable to start OST2"
2018 mount_client $MOUNT || error "Unable to mount client"
2019 lctl set_param llite.$FSNAME-*.lazystatfs=1
2022 # Wait for client to detect down OST
2023 stop_ost || error "Unable to stop OST1"
2024 wait_osc_import_state mds ost DISCONN
2025 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2027 umount_client $MOUNT || error "Unable to unmount client"
2028 stop_ost2 || error "Unable to stop OST2"
2029 stop_mds || error "Unable to stop MDS"
2031 run_test 50c "lazystatfs one server down =========================="
2034 start_mds || error "Unable to start MDS"
2035 start_ost || error "Unable to start OST1"
2036 start_ost2 || error "Unable to start OST2"
2037 mount_client $MOUNT || error "Unable to mount client"
2038 lctl set_param llite.$FSNAME-*.lazystatfs=1
2041 # Issue the statfs during the window where the client still
2042 # belives the OST to be available but it is in fact down.
2043 # No failure just a statfs which hangs for a timeout interval.
2044 stop_ost || error "Unable to stop OST1"
2045 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2047 umount_client $MOUNT || error "Unable to unmount client"
2048 stop_ost2 || error "Unable to stop OST2"
2049 stop_mds || error "Unable to stop MDS"
2051 run_test 50d "lazystatfs client/server conn race =========================="
2058 start_mds || return 1
2059 #first client should see only one ost
2060 start_ost || return 2
2061 wait_osc_import_state mds ost FULL
2063 # Wait for client to detect down OST
2064 stop_ost || error "Unable to stop OST1"
2065 wait_osc_import_state mds ost DISCONN
2067 mount_client $MOUNT || error "Unable to mount client"
2068 lctl set_param llite.$FSNAME-*.lazystatfs=0
2070 multiop_bg_pause $MOUNT _f
2074 if [ $RC1 -ne 0 ]; then
2075 log "multiop failed $RC1"
2078 sleep $(( $TIMEOUT+1 ))
2080 [ $? -ne 0 ] && error "process isn't sleep"
2081 start_ost || error "Unable to start OST1"
2082 wait $pid || error "statfs failed"
2085 umount_client $MOUNT || error "Unable to unmount client"
2086 stop_ost || error "Unable to stop OST1"
2087 stop_mds || error "Unable to stop MDS"
2089 run_test 50e "normal statfs all servers down =========================="
2094 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2096 start_mds || error "Unable to start mds"
2097 #first client should see only one ost
2098 start_ost || error "Unable to start OST1"
2099 wait_osc_import_state mds ost FULL
2101 start_ost2 || error "Unable to start OST2"
2102 wait_osc_import_state mds ost2 FULL
2104 # Wait for client to detect down OST
2105 stop_ost2 || error "Unable to stop OST2"
2107 wait_osc_import_state mds ost2 DISCONN
2108 mount_client $MOUNT || error "Unable to mount client"
2109 lctl set_param llite.$FSNAME-*.lazystatfs=0
2111 multiop_bg_pause $MOUNT _f
2115 if [ $RC1 -ne 0 ]; then
2116 log "lazystatfs multiop failed $RC1"
2119 sleep $(( $TIMEOUT+1 ))
2121 [ $? -ne 0 ] && error "process isn't sleep"
2122 start_ost2 || error "Unable to start OST2"
2123 wait $pid || error "statfs failed"
2124 stop_ost2 || error "Unable to stop OST2"
2127 umount_client $MOUNT || error "Unable to unmount client"
2128 stop_ost || error "Unable to stop OST1"
2129 stop_mds || error "Unable to stop MDS"
2130 #writeconf to remove all ost2 traces for subsequent tests
2133 run_test 50f "normal statfs one server in down =========================="
2136 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2138 start_ost2 || error "Unable to start OST2"
2140 local PARAM="${FSNAME}-OST0001.osc.active"
2142 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2143 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2145 umount_client $MOUNT || error "Unable to unmount client"
2146 mount_client $MOUNT || error "Unable to mount client"
2147 # This df should not cause a panic
2150 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2152 umount_client $MOUNT || error "Unable to unmount client"
2153 stop_ost2 || error "Unable to stop OST2"
2154 stop_ost || error "Unable to stop OST1"
2155 stop_mds || error "Unable to stop MDS"
2156 #writeconf to remove all ost2 traces for subsequent tests
2159 run_test 50g "deactivated OST should not cause panic====================="
2162 local LOCAL_TIMEOUT=20
2166 check_mount || return 1
2169 $LFS setstripe -c -1 $MOUNT/d1
2170 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2171 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2172 touch $MOUNT/d1/f1 &
2175 start_ost2 || return 2
2177 stop_ost2 || return 3
2180 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2189 do_node $node mkdir -p $dest
2190 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2192 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2193 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2194 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2196 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2197 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2207 local backup2=${TMP}/backup2
2209 do_node $node mkdir -p $backup2
2210 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2212 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2213 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2214 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2216 do_node $node "diff -rq $backup $backup2"
2217 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2219 local xattrs2=${TMP}/xattrs2
2220 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2221 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2223 do_node $node "diff $xattrs $xattrs2"
2224 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2226 do_node $node "rm -rf $backup2 $xattrs2"
2227 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2232 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2234 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2236 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2239 local ost1mnt=${MOUNT%/*}/ost1
2240 local ost1node=$(facet_active_host ost1)
2241 local ost1tmp=$TMP/conf52
2244 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2245 touch $TMP/modified_first
2246 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2247 do_node $ost1node "mkdir -p $ost1tmp && touch $ost1tmp/modified_first"
2248 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2251 $LFS setstripe $DIR/$tdir -c -1 -s 1M
2252 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2254 for (( i=0; i < nrfiles; i++ )); do
2255 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2256 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2262 echo backup files to $TMP/files
2263 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2264 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2265 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2267 umount_client $MOUNT
2268 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2270 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2272 echo mount ost1 as ldiskfs
2273 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2274 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2277 echo backup objects to $ost1tmp/objects
2278 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2279 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2280 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2281 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2283 # move objects to lost+found
2284 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2285 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2288 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2289 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2291 # compare restored objects against saved ones
2292 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2293 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2295 do_node $ost1node "umount $ost1_dev"
2296 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2299 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2301 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2304 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2305 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2307 rm -rf $TMP/files $TMP/file_xattrs
2308 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2309 do_node $ost1node "rm -rf $ost1tmp"
2310 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2313 run_test 52 "check recovering objects from lost+found"
2315 # Checks threads_min/max/started for some service
2317 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2318 # parameter pattern prefix like 'ost.*.ost'.
2330 local msg="Insane $modname thread counts"
2334 check_mount || return 41
2336 # We need to expand $parampat, but it may match multiple parameters, so
2337 # we'll pick the first one
2338 paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1)
2339 if [ -z "$paramp" ]; then
2340 error "Couldn't expand ${parampat}.threads_min parameter name"
2344 # Remove the .threads_min part
2345 paramp=${paramp%.threads_min}
2347 # Check for sanity in defaults
2348 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2349 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2350 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2351 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2352 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= tmax ))' || return $?
2354 # Check that we can lower min/max
2355 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin - 1))"
2356 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 10))"
2357 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2358 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2359 lassert 25 "$msg" '(($tmin2 == ($tmin - 1) && $tmax2 == ($tmax -10)))' || return $?
2361 # Check that we can set min/max to the same value
2362 do_facet $facet "lctl set_param ${paramp}.threads_min=$tmin"
2363 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2364 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2365 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2366 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2368 # Check that we can't set max < min
2369 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2370 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2371 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2372 lassert 27 "$msg" '(($tmin <= $tmax2))' || return $?
2374 # We need to ensure that we get the module options desired; to do this
2375 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2376 LOAD_MODULES_REMOTE=true
2379 setmodopts -a $modname "$opts" oldvalue
2383 check_mount || return 41
2385 # Restore previous setting of MODOPTS_*
2386 setmodopts $modname "$oldvalue"
2388 # Check that $opts took
2389 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2390 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2391 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2392 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2395 # Workaround a YALA bug where YALA expects that modules will remain
2396 # loaded on the servers
2397 LOAD_MODULES_REMOTE=false
2404 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2406 run_test 53a "check OSS thread count params"
2409 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2411 run_test 53b "check MDT thread count params"
2416 local partial_arg=""
2417 local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
2419 # Run in partial (fast) mode if the size
2420 # of a partition > 10 GB
2421 [ $size -gt 10 ] && partial_arg="-p"
2423 llverfs $partial_arg $dir
2427 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
2428 [ $? -eq 0 ] || error "llverdev failed!"
2431 run_test 54a "llverdev"
2436 [ $? -eq 0 ] || error "llverfs failed!"
2439 run_test 54b "llverfs"
2443 local max_ost_index=$1
2444 echo -n $(((max_ost_index + 1) * 8))
2448 local mdsdev=$(mdsdevname 1)
2449 local ostdev=$(ostdevname 1)
2450 local saved_opts=$OST_MKFS_OPTS
2452 for i in 0 1023 2048
2454 OST_MKFS_OPTS="$saved_opts --index $i"
2462 echo checking size of lov_objid for ost index $i
2463 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2464 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2465 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2467 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2472 OST_MKFS_OPTS=$saved_opts
2475 run_test 55 "check lov_objid size"
2478 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2479 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2480 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2484 start_ost2 || error "Unable to start second ost"
2485 mount_client $MOUNT || error "Unable to mount client"
2491 run_test 56 "check big indexes"
2493 test_57() { # bug 22656
2494 local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
2496 do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
2498 start_ost && error "OST registration from failnode should fail"
2502 run_test 57 "initial registration from failnode should fail (should return errs)"
2505 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2509 start_mgsmds >> /dev/null
2510 local C1=$(count_osts)
2511 if [ $C1 -eq 0 ]; then
2512 start_ost >> /dev/null
2516 echo "original ost count: $C1 (expect > 0)"
2517 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2518 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2519 local C2=$(count_osts)
2520 echo "after mdt writeconf count: $C2 (expect 0)"
2521 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2522 echo "OST start without writeconf should fail:"
2523 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2524 echo "OST start with writeconf should succeed:"
2525 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2526 local C3=$(count_osts)
2527 echo "after ost writeconf count: $C3 (expect 1)"
2528 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2529 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2530 local C4=$(count_osts)
2531 echo "after ost2 writeconf count: $C4 (expect 2)"
2532 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2533 stop_ost2 >> /dev/null
2534 cleanup_nocli >> /dev/null
2536 run_test 59 "writeconf mount option"
2539 if ! combined_mgs_mds ; then
2543 equals_msg `basename $0`: test complete
2544 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true