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 [ -e ${WCDIR}/$@ ] && rm ${WCDIR}/$@
81 # The MGS must be started before the OSTs for a new fs, so start
82 # and stop to generate the startup logs.
85 wait_osc_import_state mds ost FULL
90 reformat_and_config() {
92 if ! combined_mgs_mds ; then
100 start mgs $MGSDEV $mgs_MOUNT_OPTS
104 local facet=$SINGLEMDS
105 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
106 local num=$(echo $facet | tr -d "mds")
107 local dev=$(mdsdevname $num)
108 echo "start mds service on `facet_active_host $facet`"
109 start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
113 if ! combined_mgs_mds ; then
120 echo "stop mds service on `facet_active_host $SINGLEMDS`"
121 # These tests all use non-failover stop
122 stop $SINGLEMDS -f || return 97
126 echo "start ost1 service on `facet_active_host ost1`"
127 start ost1 `ostdevname 1` $OST_MOUNT_OPTS $@ || return 95
131 echo "stop ost1 service on `facet_active_host ost1`"
132 # These tests all use non-failover stop
133 stop ost1 -f || return 98
137 echo "start ost2 service on `facet_active_host ost2`"
138 start ost2 `ostdevname 2` $OST_MOUNT_OPTS $@ || return 92
142 echo "stop ost2 service on `facet_active_host ost2`"
143 # These tests all use non-failover stop
144 stop ost2 -f || return 93
149 echo "mount $FSNAME on ${MOUNTPATH}....."
150 zconf_mount `hostname` $MOUNTPATH || return 96
154 local SAVEMOUNTOPT=$MOUNTOPT
155 MOUNTOPT="remount,$1"
157 echo "remount '$1' lustre on ${MOUNTPATH}....."
158 zconf_mount `hostname` $MOUNTPATH || return 96
159 MOUNTOPT=$SAVEMOUNTOPT
164 echo "umount lustre on ${MOUNTPATH}....."
165 zconf_umount `hostname` $MOUNTPATH || return 97
168 manual_umount_client(){
171 echo "manual umount lustre on ${MOUNT}...."
172 do_facet client "umount -d ${FORCE} $MOUNT"
178 start_mds || error "MDT start failed"
179 start_ost || error "OST start failed"
180 mount_client $MOUNT || error "client start failed"
184 if ! combined_mgs_mds ; then
194 stop_ost || return 202
195 stop_mds || return 201
196 unload_modules || return 203
200 umount_client $MOUNT || return 200
201 cleanup_nocli || return $?
205 do_facet client "cp /etc/passwd $DIR/a" || return 71
206 do_facet client "rm $DIR/a" || return 72
207 # make sure lustre is actually mounted (touch will block,
208 # but grep won't, so do it after)
209 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
210 echo "setup single mount lustre success"
214 do_facet client "touch $DIR/a" || return 71
215 do_facet client "rm $DIR/a" || return 72
216 do_facet client "touch $DIR2/a" || return 73
217 do_facet client "rm $DIR2/a" || return 74
218 echo "setup double mount lustre success"
223 if [ "$ONLY" == "setup" ]; then
228 if [ "$ONLY" == "cleanup" ]; then
235 #create single point mountpoint
241 check_mount || return 41
244 run_test 0 "single mount setup"
247 start_mds || error "MDT start failed"
249 echo "start ost second time..."
250 start_ost && error "2nd OST start should fail"
251 mount_client $MOUNT || error "client start failed"
252 check_mount || return 42
255 run_test 1 "start up ost twice (should return errors)"
259 echo "start mds second time.."
260 start_mds && error "2nd MDT start should fail"
263 check_mount || return 43
266 run_test 2 "start up mds twice (should return err)"
270 #mount.lustre returns an error if already in mtab
271 mount_client $MOUNT && error "2nd client mount should fail"
272 check_mount || return 44
275 run_test 3 "mount client twice (should return err)"
279 touch $DIR/$tfile || return 85
283 # ok for ost to fail shutdown
284 if [ 202 -ne $eno ]; then
289 run_test 4 "force cleanup ost, then cleanup"
291 test_5a() { # was test_5
293 touch $DIR/$tfile || return 1
294 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
296 stop_mds -f || return 2
298 # cleanup may return an error from the failed
299 # disconnects; for now I'll consider this successful
300 # if all the modules have unloaded.
304 echo "killing umount"
305 kill -TERM $UMOUNT_PID
306 echo "waiting for umount to finish"
308 if grep " $MOUNT " /proc/mounts; then
309 echo "test 5: /proc/mounts after failed umount"
313 echo "killing umount"
314 kill -TERM $UMOUNT_PID
315 echo "waiting for umount to finish"
317 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
321 # stop_mds is a no-op here, and should not fail
322 cleanup_nocli || return $?
323 # df may have lingering entry
325 # mtab may have lingering entry
329 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
331 grep -q $MOUNT" " /etc/mtab || break
332 echo "Waiting /etc/mtab updated ... "
333 WAIT=$(( WAIT + sleep))
335 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
336 echo "/etc/mtab updated in $WAIT secs"
338 run_test 5a "force cleanup mds, then cleanup"
342 [ -d $MOUNT ] || mkdir -p $MOUNT
343 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
344 mount_client $MOUNT && return 1
345 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
347 # stop_mds is a no-op here, and should not fail
348 cleanup_nocli || return $?
351 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
356 [ -d $MOUNT ] || mkdir -p $MOUNT
357 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
358 local oldfs="${FSNAME}"
359 FSNAME="wrong.${FSNAME}"
360 mount_client $MOUNT || :
362 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
364 cleanup_nocli || return $?
366 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
372 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
373 mount_client $MOUNT || return 1
375 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
378 run_test 5d "mount with ost down"
384 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
385 do_facet client "lctl set_param fail_loc=0x80000506"
386 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
387 mount_client $MOUNT || echo "mount failed (not fatal)"
389 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
392 run_test 5e "delayed connect, don't crash (bug 10268)"
397 mount_client ${MOUNT} || return 87
398 touch $DIR/a || return 86
401 run_test 6 "manual umount, then mount again"
406 cleanup_nocli || return $?
408 run_test 7 "manual umount, then cleanup"
413 check_mount2 || return 45
414 umount_client $MOUNT2
417 run_test 8 "double mount setup"
422 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
423 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
425 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
426 if [ "$CHECK_PTLDEBUG" ] && { \
427 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
428 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
429 echo "lnet.debug success"
431 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
434 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
435 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
436 echo "lnet.subsystem_debug success"
438 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
441 stop_ost || return $?
443 run_test 9 "test ptldebug and subsystem for mkfs"
446 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
447 # But with new MDS stack we don't care about the mode of local objects
448 # anymore, so this test is removed. See bug 22944 for more details.
452 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
454 if [ ! -e "$MDSDEV" ]; then
455 echo "no $MDSDEV existing, so mount Lustre to create one"
457 check_mount || return 41
461 echo "Remove mds config log"
462 do_facet $SINGLEMDS "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
465 start_mds && return 42
468 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
471 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
473 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
478 # check if current MDSSIZE is large enough
479 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
480 log "use MDSSIZE=$MDSSIZE"
482 # check if the global config has a large enough MDSSIZE
483 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
484 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
485 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
487 # check if the block device is large enough
488 [ -z "$OK" -a -b $MDSDEV ] && \
489 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
490 awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
491 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
493 # check if a loopback device has enough space for fs metadata (5%)
494 [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
495 SPACE=$(df -P $(dirname $MDSDEV) |
496 awk '($1 != "Filesystem") {print $4}') &&
497 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
498 log "use file $MDSDEV with MIN=$MIN"
500 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
503 echo "mount mds with large journal..."
504 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
506 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
509 echo "mount lustre system..."
511 check_mount || return 41
513 echo "check journal size..."
514 local FOUNDSIZE=`do_facet mds "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
515 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
516 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
518 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
523 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
526 run_test 18 "check mkfs creates large journals"
529 start_mds || return 1
530 stop_mds -f || return 2
532 run_test 19a "start/stop MDS without OSTs"
535 start_ost || return 1
536 stop_ost -f || return 2
538 run_test 19b "start/stop OSTs without MDS"
541 # first format the ost/mdt
545 check_mount || return 43
547 remount_client ro $MOUNT || return 44
548 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
549 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
550 remount_client rw $MOUNT || return 47
552 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
553 MCNT=`grep -c $MOUNT /etc/mtab`
554 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
559 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
564 wait_osc_import_state mds ost FULL
568 run_test 21a "start mds before ost, stop ost first"
573 wait_osc_import_state mds ost FULL
577 run_test 21b "start ost before mds, stop mds first"
583 wait_osc_import_state mds ost2 FULL
587 #writeconf to remove all ost2 traces for subsequent tests
590 run_test 21c "start mds between two osts, stop mds last"
595 echo Client mount with ost in logs, but none running
597 # wait until mds connected to ost and open client connection
598 wait_osc_import_state mds ost FULL
601 # check_mount will block trying to contact ost
602 mcreate $DIR/$tfile || return 40
603 rm -f $DIR/$tfile || return 42
607 echo Client mount with a running ost
610 # if gss enabled, wait full time to let connection from
611 # mds to ost be established, due to the mismatch between
612 # initial connect timeout and gss context negotiation timeout.
613 # This perhaps could be remove after AT landed.
614 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
615 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
618 check_mount || return 41
623 run_test 22 "start a client before osts (should return errs)"
625 test_23a() { # was test_23
629 # force down client so that recovering mds waits for reconnect
630 local running=$(grep -c $MOUNT /proc/mounts) || true
631 if [ $running -ne 0 ]; then
632 echo "Stopping client $MOUNT (opts: -f)"
636 # enter recovery on mds
638 # try to start a new client
639 mount_client $MOUNT &
641 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
642 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
643 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
645 ps --ppid $MOUNT_LUSTRE_PID
646 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
647 kill -TERM $MOUNT_LUSTRE_PID
648 echo "waiting for mount to finish"
650 # we can not wait $MOUNT_PID because it is not a child of this shell
656 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
658 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
659 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
662 [ -z "$PID1" -a -z "$PID2" ] && break
663 echo "waiting for mount to finish ... "
664 WAIT=$(( WAIT + sleep))
666 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
667 error "MOUNT_PID $MOUNT_PID and "\
668 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
674 run_test 23a "interrupt client during recovery mount delay"
679 test_23b() { # was test_23
682 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
683 lctl set_param fail_loc=0x80000313
687 run_test 23b "Simulate -EINTR during mount"
689 fs2mds_HOST=$mds_HOST
690 fs2ost_HOST=$ost_HOST
694 echo "umount $MOUNT2 ..."
695 umount $MOUNT2 || true
696 echo "stopping fs2mds ..."
697 stop fs2mds -f || true
698 echo "stopping fs2ost ..."
699 stop fs2ost -f || true
707 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
709 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
710 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
711 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
712 skip_env "mixed loopback and real device not working" && return
715 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
716 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
718 # test 8-char fsname as well
719 local FSNAME2=test1234
720 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
722 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
725 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
726 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
728 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
730 check_mount || return 2
731 # files written on 1 should not show up on 2
732 cp /etc/passwd $DIR/$tfile
734 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
737 cp /etc/passwd $MOUNT2/b || return 3
738 rm $MOUNT2/b || return 4
739 # 2 is actually mounted
740 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
742 facet_failover fs2mds
743 facet_failover fs2ost
746 # the MDS must remain up until last MDT
748 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
749 [ -z "$MDS" ] && error "No MDT" && return 8
751 cleanup_nocli || return 6
753 run_test 24a "Multiple MDTs on a single node"
756 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
758 if [ -z "$fs2mds_DEV" ]; then
759 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
760 skip_env "mixed loopback and real device not working" && return
763 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
765 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
767 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
770 run_test 24b "Multiple MGSs on a single node (should return err)"
774 check_mount || return 2
775 local MODULES=$($LCTL modules | awk '{ print $2 }')
776 rmmod $MODULES 2>/dev/null || true
779 run_test 25 "Verify modules are referenced"
783 # we need modules before mount for sysctl, so make sure...
784 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
785 #define OBD_FAIL_MDS_FS_SETUP 0x135
786 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
787 start_mds && echo MDS started && return 1
788 lctl get_param -n devices
789 DEVS=$(lctl get_param -n devices | wc -l)
790 [ $DEVS -gt 0 ] && return 2
791 unload_modules || return 203
793 run_test 26 "MDT startup failure cleans LOV (should return errs)"
799 local ORIG=$(do_facet $myfacet "$TEST")
800 if [ $# -gt 3 ]; then
806 echo "Setting $PARAM from $ORIG to $FINAL"
807 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
809 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
813 start_ost || return 1
814 start_mds || return 2
815 echo "Requeue thread should have started: "
816 ps -e | grep ll_cfg_requeue
817 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
820 run_test 27a "Reacquire MGS lock if OST started first"
825 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
827 facet_failover $SINGLEMDS
828 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
829 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
833 run_test 27b "Reacquire MGS lock after failover"
837 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
838 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
841 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
842 FINAL=$(($FINAL + 1))
843 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
844 umount_client $MOUNT || return 200
847 if [ $RESULT -ne $FINAL ]; then
848 echo "New config not seen: wanted $FINAL got $RESULT"
851 echo "New config success: got $RESULT"
853 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
856 run_test 28 "permanent parameter setting"
859 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
860 setup > /dev/null 2>&1
864 local PARAM="$FSNAME-OST0001.osc.active"
865 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
866 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
868 ACTV=$(lctl get_param -n $PROC_ACT)
870 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
871 # also check ost_server_uuid status
872 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
873 if [ -z "$RESULT" ]; then
874 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
877 echo "Live client success: got $RESULT"
881 local MPROC="osc.$FSNAME-OST0001-osc-[M]*.active"
886 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
887 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
888 if [ $RESULT -eq $DEAC ]; then
889 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
893 if [ $WAIT -eq $MAX ]; then
894 echo "MDT not deactivated: wanted $DEAC got $RESULT"
897 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
900 # test new client starts deactivated
901 umount_client $MOUNT || return 200
903 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
904 if [ -z "$RESULT" ]; then
905 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
908 echo "New client success: got $RESULT"
911 # make sure it reactivates
912 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
917 #writeconf to remove all ost2 traces for subsequent tests
920 run_test 29 "permanently remove an OST"
926 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
928 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
929 for i in ${LIST[@]}; do
930 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
932 # make sure client restart still works
934 mount_client $MOUNT || return 4
935 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
938 echo Erase parameter setting
939 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
941 mount_client $MOUNT || return 6
943 echo "deleted (default) value=$FINAL, orig=$ORIG"
944 # assumes this parameter started at the default value
945 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
949 run_test 30a "Big config llog and conf_param deletion"
954 # Make a fake nid. Use the OST nid, and add 20 to the least significant
955 # numerical part of it. Hopefully that's not already a failover address for
957 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
958 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
959 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
960 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
961 echo "Using fake nid $NEW"
963 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
964 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
965 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
967 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
968 echo "should have 2 failover nids: $NIDCOUNT"
969 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
970 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
972 mount_client $MOUNT || return 3
974 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
976 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
977 echo "only 1 final nid should remain: $NIDCOUNT"
978 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
982 run_test 30b "Remove failover nids"
984 test_31() { # bug 10734
985 # ipaddr must not exist
986 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
989 run_test 31 "Connect to non-existent node (shouldn't crash)"
991 # Use these start32/stop32 fn instead of t-f start/stop fn,
992 # for local devices, to skip global facet vars init
996 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
997 umount -d $@ ${MOUNT%/*}/${facet}
1006 mkdir -p ${MOUNT%/*}/${facet}
1008 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1009 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1011 if [ $RC -ne 0 ]; then
1012 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1013 echo "Start of ${device} of local ${facet} failed ${RC}"
1019 cleanup_nocli32 () {
1027 echo "Cleanup test_32 umount $MOUNT ..."
1028 umount -f $MOUNT || true
1029 echo "Cleanup local mds ost1 ..."
1035 client_only && skip "client only testing" && return 0
1036 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1037 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1039 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1040 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1041 local tmpdir=$TMP/conf32a
1043 tar xjvf $DISK1_8 -C $tmpdir || \
1044 { skip_env "Cannot untar $DISK1_8" && return 0; }
1047 $LCTL set_param debug=$PTLDEBUG
1049 $TUNEFS $tmpdir/mds || error "tunefs failed"
1051 # nids are wrong, so client wont work, but server should start
1052 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1053 trap cleanup_32 EXIT INT || return 3
1055 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1057 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1059 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1060 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1061 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1063 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1065 local NID=$($LCTL list_nids | head -1)
1067 echo "OSC changes should succeed:"
1068 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1069 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1072 echo "MDC changes should succeed:"
1073 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1074 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1077 echo "LOV changes should succeed:"
1078 $LCTL pool_new lustre.interop || return 11
1079 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1084 # mount a second time to make sure we didnt leave upgrade flag on
1086 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1087 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1088 trap cleanup_32 EXIT INT || return 12
1092 rm -rf $tmpdir || true # true is only for TMP on NFS
1094 run_test 32a "Upgrade from 1.8 (not live)"
1097 client_only && skip "client only testing" && return 0
1098 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1099 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1101 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1102 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1103 local tmpdir=$TMP/conf32b
1105 tar xjvf $DISK1_8 -C $tmpdir || \
1106 { skip_env "Cannot untar $DISK1_8" && return ; }
1109 $LCTL set_param debug="config"
1110 local NEWNAME=lustre
1112 # writeconf will cause servers to register with their current nids
1113 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1114 start32 mds1 $tmpdir/mds "-o loop" && \
1115 trap cleanup_32 EXIT INT || return 3
1117 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1119 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1121 $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 ||\
1122 error "tunefs failed"
1123 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1124 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1126 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1128 local NID=$($LCTL list_nids | head -1)
1130 echo "OSC changes should succeed:"
1131 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1132 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1135 echo "MDC changes should succeed:"
1136 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1137 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1140 echo "LOV changes should succeed:"
1141 $LCTL pool_new ${NEWNAME}.interop || return 11
1142 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1145 # MDT and OST should have registered with new nids, so we should have
1146 # a fully-functioning client
1147 echo "Check client and old fs contents"
1149 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1150 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1151 mount -t lustre $device $MOUNT || return 1
1153 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1154 local new=$((old + 5))
1155 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1156 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1158 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1163 rm -rf $tmpdir || true # true is only for TMP on NFS
1165 run_test 32b "Upgrade from 1.8 with writeconf"
1167 test_33a() { # bug 12333, was test_33
1169 local FSNAME2=test-123
1170 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1172 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1174 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1175 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1176 skip_env "mixed loopback and real device not working" && return
1179 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1180 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1181 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1182 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1184 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1185 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1186 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1188 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1191 cp /etc/hosts $MOUNT2/ || rc=3
1192 $LFS getstripe $MOUNT2/hosts
1197 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1198 cleanup_nocli || rc=6
1201 run_test 33a "Mount ost with a large index number"
1203 test_33b() { # was test_34
1206 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1207 # Drop lock cancelation reply during umount
1208 #define OBD_FAIL_LDLM_CANCEL 0x304
1209 do_facet client lctl set_param fail_loc=0x80000304
1210 #lctl set_param debug=-1
1211 umount_client $MOUNT
1214 run_test 33b "Drop cancel during umount"
1218 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1219 manual_umount_client
1221 do_facet client killall -USR1 multiop
1222 if [ $rc -eq 0 ]; then
1223 error "umount not fail!"
1228 run_test 34a "umount with opened file should be fail"
1233 touch $DIR/$tfile || return 1
1234 stop_mds --force || return 2
1236 manual_umount_client --force
1238 if [ $rc -ne 0 ]; then
1239 error "mtab after failed umount - rc $rc"
1245 run_test 34b "force umount with failed mds should be normal"
1249 touch $DIR/$tfile || return 1
1250 stop_ost --force || return 2
1252 manual_umount_client --force
1254 if [ $rc -ne 0 ]; then
1255 error "mtab after failed umount - rc $rc"
1261 run_test 34c "force umount with failed ost should be normal"
1263 test_35a() { # bug 12459
1266 DBG_SAVE="`lctl get_param -n debug`"
1267 lctl set_param debug="ha"
1269 log "Set up a fake failnode for the MDS"
1271 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1272 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1274 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1277 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1280 log "Stopping the MDT:"
1281 stop_mds || return 5
1283 df $MOUNT > /dev/null 2>&1 &
1285 log "Restarting the MDT:"
1286 start_mds || return 6
1287 log "Wait for df ($DFPID) ... "
1290 lctl set_param debug="$DBG_SAVE"
1292 # retrieve from the log the first server that the client tried to
1293 # contact after the connection loss
1294 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1295 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1296 /import_select_connection.*$device-mdc.* using connection/ {
1298 if (\\\$NF ~ /$FAKENID/)
1304 }" $TMP/lustre-log-$TESTNAME.log`
1305 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1307 # remove nid settings
1310 run_test 35a "Reconnect to the last active server first"
1312 test_35b() { # bug 18674
1313 remote_mds || { skip "local MDS" && return 0; }
1317 $LCTL set_param debug="ha"
1319 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1322 log "Set up a fake failnode for the MDS"
1324 local device=$(do_facet mds "$LCTL get_param -n devices" | \
1325 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1326 do_facet mds "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1329 local at_max_saved=0
1330 # adaptive timeouts may prevent seeing the issue
1331 if at_is_enabled; then
1332 at_max_saved=$(at_max_get mds)
1333 at_max_set 0 mds client
1336 mkdir -p $MOUNT/testdir
1337 touch $MOUNT/testdir/test
1339 log "Injecting EBUSY on MDS"
1340 # Setting OBD_FAIL_MDS_RESEND=0x136
1341 do_facet mds "$LCTL set_param fail_loc=0x80000136" || return 2
1343 log "Stat on a test file"
1344 stat $MOUNT/testdir/test
1346 log "Stop injecting EBUSY on MDS"
1347 do_facet mds "$LCTL set_param fail_loc=0" || return 3
1348 rm -f $MOUNT/testdir/test
1351 # restore adaptive timeout
1352 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1354 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1356 # retrieve from the log if the client has ever tried to
1357 # contact the fake server after the loss of connection
1358 FAILCONN=`awk "BEGIN {ret = 0;}
1359 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1361 if (\\\$NF ~ /$FAKENID/) {
1366 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1368 [ "$FAILCONN" == "0" ] && \
1369 log "ERROR: The client reconnection has not been triggered" && \
1371 [ "$FAILCONN" == "2" ] && \
1372 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1376 # remove nid settings
1379 run_test 35b "Continue reconnection retries, if the active server is busy"
1383 local FSNAME2=test1234
1384 local fs3ost_HOST=$ost_HOST
1385 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1387 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1390 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1391 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1392 skip_env "mixed loopback and real device not working" && return
1394 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1396 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1397 { skip "remote OST" && return 0; }
1399 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1400 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1401 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1402 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1403 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1405 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1406 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1408 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1409 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1410 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1412 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1414 sleep 5 # until 11778 fixed
1416 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1418 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1419 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1420 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1421 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1422 DFTOTAL=`echo $STRING | cut -d, -f1`
1423 DFUSED=`echo $STRING | cut -d, -f2`
1424 DFAVAIL=`echo $STRING | cut -d, -f3`
1425 DFFREE=$(($DFTOTAL - $DFUSED))
1427 ALLOWANCE=$((64 * $OSTCOUNT))
1429 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1430 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1431 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1434 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1435 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1436 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1439 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1440 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1441 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1446 stop fs3ost -f || return 200
1447 stop fs2ost -f || return 201
1448 stop fs2mds -f || return 202
1449 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1450 unload_modules || return 203
1453 run_test 36 "df report consistency on OSTs with different block size"
1456 client_only && skip "client only testing" && return 0
1457 LOCAL_MDSDEV="$TMP/mdt.img"
1458 SYM_MDSDEV="$TMP/sym_mdt.img"
1460 echo "MDS : $LOCAL_MDSDEV"
1461 echo "SYMLINK : $SYM_MDSDEV"
1465 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1466 error "mkfs.lustre $LOCAL_MDSDEV failed"
1467 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1469 echo "mount symlink device - $SYM_MDSDEV"
1471 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1472 umount -d ${MOUNT%/*}/mds
1473 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1475 if [ -n "$mount_op" ]; then
1476 error "**** FAIL: set tunables failed for symlink device"
1480 run_test 37 "verify set tunables works for symlink device"
1482 test_38() { # bug 14222
1487 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1488 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1490 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1491 error "copying $SRC to $DIR/$tdir"
1493 umount_client $MOUNT
1495 log "rename lov_objid file on MDS"
1496 rm -f $TMP/lov_objid.orig
1498 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1499 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1500 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1502 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1503 # check create in mds_lov_connect
1507 [ $V ] && log "verifying $DIR/$tdir/$f"
1508 diff -q $f $DIR/$tdir/$f || ERROR=y
1510 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1511 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1512 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1514 # check it's updates in sync
1515 umount_client $MOUNT
1518 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1519 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1520 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1525 [ $V ] && log "verifying $DIR/$tdir/$f"
1526 diff -q $f $DIR/$tdir/$f || ERROR=y
1528 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1529 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1530 umount_client $MOUNT
1532 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1534 log "files compared the same"
1537 run_test 38 "MDS recreates missing lov_objid file from OST data"
1543 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1544 error "memory leak detected" || true
1546 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1548 test_40() { # bug 15759
1550 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1551 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1555 run_test 40 "race during service thread startup"
1557 test_41() { #bug 14134
1559 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1561 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1562 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1563 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1565 mount_client $MOUNT || return 1
1568 echo "blah blah" > $MOUNT/$tfile
1571 umount_client $MOUNT
1572 stop ost1 -f || return 201
1573 stop_mds -f || return 202
1574 stop_mds -f || return 203
1575 unload_modules || return 204
1578 run_test 41 "mount mds with --nosvc and --nomgs"
1580 test_42() { #bug 14693
1582 check_mount || return 2
1583 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1584 umount_client $MOUNT
1585 mount_client $MOUNT || return 1
1589 run_test 42 "invalid config param should not prevent client from mounting"
1592 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1594 chmod ugo+x $DIR || error "chmod 0 failed"
1596 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1597 "$FSNAME.mdt.root_squash" \
1600 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1601 "$FSNAME.mdt.nosquash_nids" \
1605 # create set of test files
1607 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1608 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1609 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1611 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1612 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1614 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1615 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1616 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1619 # check root_squash:
1620 # set root squash UID:GID to RUNAS_ID
1621 # root should be able to access only files owned by RUNAS_ID
1624 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1625 "$FSNAME.mdt.root_squash" \
1626 "$RUNAS_ID:$RUNAS_ID"
1628 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1629 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1630 error "$ST: root read permission is denied"
1631 echo "$ST: root read permission is granted - ok"
1634 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1635 error "$ST: root write permission is denied"
1636 echo "$ST: root write permission is granted - ok"
1638 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1639 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1640 error "$ST: root read permission is granted"
1641 echo "$ST: root read permission is denied - ok"
1644 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1645 error "$ST: root write permission is granted"
1646 echo "$ST: root write permission is denied - ok"
1648 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1649 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1650 error "$ST: root unlink permission is granted"
1651 echo "$ST: root unlink permission is denied - ok"
1653 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1654 error "$ST: root create permission is granted"
1655 echo "$ST: root create permission is denied - ok"
1658 # check nosquash_nids:
1659 # put client's NID into nosquash_nids list,
1660 # root should be able to access root file after that
1662 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1663 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1664 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1666 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1667 "$FSNAME-MDTall.mdt.nosquash_nids" \
1670 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1671 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1672 error "$ST: root read permission is denied"
1673 echo "$ST: root read permission is granted - ok"
1676 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1677 error "$ST: root write permission is denied"
1678 echo "$ST: root write permission is granted - ok"
1680 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1681 rm $DIR/$tdir-rootdir/tfile-1 || \
1682 error "$ST: root unlink permission is denied"
1683 echo "$ST: root unlink permission is granted - ok"
1684 touch $DIR/$tdir-rootdir/tfile-2 || \
1685 error "$ST: root create permission is denied"
1686 echo "$ST: root create permission is granted - ok"
1690 run_test 43 "check root_squash and nosquash_nids"
1692 umount_client $MOUNT
1697 check_mount || return 2
1698 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1700 UUIDS=$(do_facet mds "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1701 for VAL in $UUIDS; do
1702 NID=$(echo $VAL | cut -d= -f1)
1703 CLUUID=$(echo $VAL | cut -d= -f2)
1704 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1706 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1710 run_test 44 "mounted client proc entry exists"
1714 check_mount || return 2
1719 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1720 do_facet client "lctl set_param fail_loc=0x50f"
1723 manual_umount_client --force || return 3
1724 do_facet client "lctl set_param fail_loc=0x0"
1726 mount_client $MOUNT || return 4
1730 run_test 45 "long unlink handling in ptlrpcd"
1737 umount_client $MOUNT2 || rc=$?
1738 umount_client $MOUNT || rc=$?
1739 while [ $count -gt 0 ]; do
1740 stop ost${count} -f || rc=$?
1744 cleanup_nocli || rc=$?
1745 #writeconf to remove all ost2 traces for subsequent tests
1751 echo "Testing with $OSTCOUNT OSTs"
1753 start_mds || return 1
1754 #first client should see only one ost
1755 start_ost || return 2
1756 wait_osc_import_state mds ost FULL
1758 mount_client $MOUNT || return 3
1759 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1762 for (( i=2; i<=$OSTCOUNT; i++ )); do
1763 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1766 # wait until osts in sync
1767 for (( i=2; i<=$OSTCOUNT; i++ )); do
1768 wait_osc_import_state mds ost$i FULL
1772 #second client see all ost's
1774 mount_client $MOUNT2 || return 8
1775 $LFS setstripe $MOUNT2 -c -1 || return 9
1776 $LFS getstripe $MOUNT2 || return 10
1778 echo "ok" > $MOUNT2/widestripe
1779 $LFS getstripe $MOUNT2/widestripe || return 11
1780 # fill acl buffer for avoid expand lsm to them
1781 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1782 setfacl -m $acl $MOUNT2/widestripe
1786 stat $MOUNT/widestripe || return 12
1788 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1791 run_test 46a "handle ost additional - wide striped file"
1796 check_mount || return 2
1797 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1801 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1802 if echo $ns | grep "MDT[[:digit:]]*"; then
1805 lrs=$(echo $ns | sed 's/.*lru_size=//')
1806 lru_size[count]=$lrs
1811 facet_failover $SINGLEMDS
1812 client_up || return 3
1815 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1816 if echo $ns | grep "MDT[[:digit:]]*"; then
1819 lrs=$(echo $ns | sed 's/.*lru_size=//')
1820 if ! test "$lrs" -eq "${lru_size[count]}"; then
1821 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1822 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1830 run_test 47 "server restart does not make client loss lru_resize settings"
1835 # reformat after this test is needed - if test will failed
1836 # we will have unkillable file at FS
1840 test_48() { # bug 17636
1843 check_mount || return 2
1845 $LFS setstripe $MOUNT -c -1 || return 9
1846 $LFS getstripe $MOUNT || return 10
1848 echo "ok" > $MOUNT/widestripe
1849 $LFS getstripe $MOUNT/widestripe || return 11
1851 trap cleanup_48 EXIT ERR
1853 # fill acl buffer for avoid expand lsm to them
1854 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1855 setfacl -m $acl $MOUNT/widestripe
1858 stat $MOUNT/widestripe || return 12
1863 run_test 48 "too many acls on file"
1865 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1866 test_49() { # bug 17710
1867 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1868 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1869 local LOCAL_TIMEOUT=20
1872 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1876 check_mount || return 1
1878 echo "check ldlm_timout..."
1879 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1880 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1881 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1883 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1884 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1887 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1888 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1891 umount_client $MOUNT
1892 stop_ost || return 2
1893 stop_mds || return 3
1895 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"
1899 check_mount || return 7
1901 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1902 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1903 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1905 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1906 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1909 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1910 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1913 cleanup || return $?
1915 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1916 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1918 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1921 # Test both statfs and lfs df and fail if either one fails
1922 multiop_bg_pause $1 f_
1925 killall -USR1 multiop
1926 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
1927 wait $PID || { RC1=$?; log "multiop return error "; }
1934 if [ $RC2 -eq 0 ]; then
1936 log "lazystatfs df failed"
1940 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
1946 lctl set_param llite.$FSNAME-*.lazystatfs=1
1949 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
1951 cleanup || return $?
1953 run_test 50a "lazystatfs all servers available =========================="
1957 lctl set_param llite.$FSNAME-*.lazystatfs=1
1960 # Wait for client to detect down OST
1961 stop_ost || error "Unable to stop OST1"
1962 wait_osc_import_state mds ost DISCONN
1964 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
1966 umount_client $MOUNT || error "Unable to unmount client"
1967 stop_mds || error "Unable to stop MDS"
1969 run_test 50b "lazystatfs all servers down =========================="
1972 start_mds || error "Unable to start MDS"
1973 start_ost || error "Unable to start OST1"
1974 start_ost2 || error "Unable to start OST2"
1975 mount_client $MOUNT || error "Unable to mount client"
1976 lctl set_param llite.$FSNAME-*.lazystatfs=1
1979 # Wait for client to detect down OST
1980 stop_ost || error "Unable to stop OST1"
1981 wait_osc_import_state mds ost DISCONN
1982 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1984 umount_client $MOUNT || error "Unable to unmount client"
1985 stop_ost2 || error "Unable to stop OST2"
1986 stop_mds || error "Unable to stop MDS"
1988 run_test 50c "lazystatfs one server down =========================="
1991 start_mds || error "Unable to start MDS"
1992 start_ost || error "Unable to start OST1"
1993 start_ost2 || error "Unable to start OST2"
1994 mount_client $MOUNT || error "Unable to mount client"
1995 lctl set_param llite.$FSNAME-*.lazystatfs=1
1998 # Issue the statfs during the window where the client still
1999 # belives the OST to be available but it is in fact down.
2000 # No failure just a statfs which hangs for a timeout interval.
2001 stop_ost || error "Unable to stop OST1"
2002 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2004 umount_client $MOUNT || error "Unable to unmount client"
2005 stop_ost2 || error "Unable to stop OST2"
2006 stop_mds || error "Unable to stop MDS"
2008 run_test 50d "lazystatfs client/server conn race =========================="
2015 start_mds || return 1
2016 #first client should see only one ost
2017 start_ost || return 2
2018 wait_osc_import_state mds ost FULL
2020 # Wait for client to detect down OST
2021 stop_ost || error "Unable to stop OST1"
2022 wait_osc_import_state mds ost DISCONN
2024 mount_client $MOUNT || error "Unable to mount client"
2025 lctl set_param llite.$FSNAME-*.lazystatfs=0
2027 multiop_bg_pause $MOUNT _f
2031 if [ $RC1 -ne 0 ]; then
2032 log "multiop failed $RC1"
2035 sleep $(( $TIMEOUT+1 ))
2037 [ $? -ne 0 ] && error "process isn't sleep"
2038 start_ost || error "Unable to start OST1"
2039 wait $pid || error "statfs failed"
2042 umount_client $MOUNT || error "Unable to unmount client"
2043 stop_ost || error "Unable to stop OST1"
2044 stop_mds || error "Unable to stop MDS"
2046 run_test 50e "normal statfs all servers down =========================="
2051 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2053 start_mds || error "Unable to start mds"
2054 #first client should see only one ost
2055 start_ost || error "Unable to start OST1"
2056 wait_osc_import_state mds ost FULL
2058 start_ost2 || error "Unable to start OST2"
2059 wait_osc_import_state mds ost2 FULL
2061 # Wait for client to detect down OST
2062 stop_ost2 || error "Unable to stop OST2"
2064 wait_osc_import_state mds ost2 DISCONN
2065 mount_client $MOUNT || error "Unable to mount client"
2066 lctl set_param llite.$FSNAME-*.lazystatfs=0
2068 multiop_bg_pause $MOUNT _f
2072 if [ $RC1 -ne 0 ]; then
2073 log "lazystatfs multiop failed $RC1"
2076 sleep $(( $TIMEOUT+1 ))
2078 [ $? -ne 0 ] && error "process isn't sleep"
2079 start_ost2 || error "Unable to start OST2"
2080 wait $pid || error "statfs failed"
2081 stop_ost2 || error "Unable to stop OST2"
2084 umount_client $MOUNT || error "Unable to unmount client"
2085 stop_ost || error "Unable to stop OST1"
2086 stop_mds || error "Unable to stop MDS"
2087 #writeconf to remove all ost2 traces for subsequent tests
2090 run_test 50f "normal statfs one server in down =========================="
2093 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2095 start_ost2 || error "Unable to start OST2"
2097 local PARAM="${FSNAME}-OST0001.osc.active"
2099 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2100 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2102 umount_client $MOUNT || error "Unable to unmount client"
2103 mount_client $MOUNT || error "Unable to mount client"
2104 # This df should not cause a panic
2107 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2109 umount_client $MOUNT || error "Unable to unmount client"
2110 stop_ost2 || error "Unable to stop OST2"
2111 stop_ost || error "Unable to stop OST1"
2112 stop_mds || error "Unable to stop MDS"
2113 #writeconf to remove all ost2 traces for subsequent tests
2116 run_test 50g "deactivated OST should not cause panic====================="
2119 local LOCAL_TIMEOUT=20
2123 check_mount || return 1
2126 $LFS setstripe -c -1 $MOUNT/d1
2127 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2128 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2129 touch $MOUNT/d1/f1 &
2132 start_ost2 || return 2
2134 stop_ost2 || return 3
2137 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2146 do_node $node mkdir -p $dest
2147 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2149 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2150 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2151 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2153 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2154 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2164 local backup2=${TMP}/backup2
2166 do_node $node mkdir -p $backup2
2167 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2169 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2170 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2171 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2173 do_node $node "diff -rq $backup $backup2"
2174 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2176 local xattrs2=${TMP}/xattrs2
2177 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2178 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2180 do_node $node "diff $xattrs $xattrs2"
2181 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2183 do_node $node "rm -rf $backup2 $xattrs2"
2184 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2189 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2191 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2193 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2196 local ost1mnt=${MOUNT%/*}/ost1
2197 local ost1node=$(facet_active_host ost1)
2198 local ost1tmp=$TMP/conf52
2201 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2202 touch $TMP/modified_first
2203 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2204 do_node $ost1node "mkdir -p $ost1tmp && touch $ost1tmp/modified_first"
2205 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2208 $LFS setstripe $DIR/$tdir -c -1 -s 1M
2209 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2211 for (( i=0; i < nrfiles; i++ )); do
2212 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2213 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2219 echo backup files to $TMP/files
2220 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2221 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2222 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2224 umount_client $MOUNT
2225 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2227 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2229 echo mount ost1 as ldiskfs
2230 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2231 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2234 echo backup objects to $ost1tmp/objects
2235 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2236 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2237 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2238 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2240 # move objects to lost+found
2241 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2242 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2245 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2246 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2248 # compare restored objects against saved ones
2249 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2250 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2252 do_node $ost1node "umount $ost1_dev"
2253 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2256 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2258 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2261 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2262 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2264 rm -rf $TMP/files $TMP/file_xattrs
2265 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2266 do_node $ost1node "rm -rf $ost1tmp"
2267 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2270 run_test 52 "check recovering objects from lost+found"
2272 # Checks threads_min/max/started for some service
2274 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2275 # parameter pattern prefix like 'ost.*.ost'.
2287 local msg="Insane $modname thread counts"
2291 check_mount || return 41
2293 # We need to expand $parampat, but it may match multiple parameters, so
2294 # we'll pick the first one
2295 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2296 error "Couldn't expand ${parampat}.threads_min parameter name"
2300 # Remove the .threads_min part
2301 paramp=${paramp%.threads_min}
2303 # Check for sanity in defaults
2304 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2305 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2306 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2307 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2308 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= tmax ))' || return $?
2310 # Check that we can lower min/max
2311 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin - 1))"
2312 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 10))"
2313 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2314 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2315 lassert 25 "$msg" '(($tmin2 == ($tmin - 1) && $tmax2 == ($tmax -10)))' || return $?
2317 # Check that we can set min/max to the same value
2318 do_facet $facet "lctl set_param ${paramp}.threads_min=$tmin"
2319 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2320 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2321 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2322 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2324 # Check that we can't set max < min
2325 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2326 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2327 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2328 lassert 27 "$msg" '(($tmin <= $tmax2))' || return $?
2330 # We need to ensure that we get the module options desired; to do this
2331 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2332 LOAD_MODULES_REMOTE=true
2335 setmodopts -a $modname "$opts" oldvalue
2339 check_mount || return 41
2341 # Restore previous setting of MODOPTS_*
2342 setmodopts $modname "$oldvalue"
2344 # Check that $opts took
2345 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2346 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2347 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2348 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2351 # Workaround a YALA bug where YALA expects that modules will remain
2352 # loaded on the servers
2353 LOAD_MODULES_REMOTE=false
2360 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2362 run_test 53a "check OSS thread count params"
2365 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2367 run_test 53b "check MDT thread count params"
2369 if ! combined_mgs_mds ; then
2376 local partial_arg=""
2377 local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
2379 # Run in partial (fast) mode if the size
2380 # of a partition > 10 GB
2381 [ $size -gt 10 ] && partial_arg="-p"
2383 llverfs $partial_arg $dir
2387 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
2388 [ $? -eq 0 ] || error "llverdev failed!"
2391 run_test 54a "llverdev"
2396 [ $? -eq 0 ] || error "llverfs failed!"
2399 run_test 54b "llverfs"
2403 local max_ost_index=$1
2404 echo -n $(((max_ost_index + 1) * 8))
2408 local mdsdev=$(mdsdevname 1)
2409 local ostdev=$(ostdevname 1)
2410 local saved_opts=$OST_MKFS_OPTS
2412 for i in 0 1023 2048
2414 OST_MKFS_OPTS="$saved_opts --index $i"
2422 echo checking size of lov_objid for ost index $i
2423 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2424 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2425 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2427 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2432 OST_MKFS_OPTS=$saved_opts
2435 run_test 55 "check lov_objid size"
2438 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2439 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2440 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2444 start_ost2 || error "Unable to start second ost"
2445 mount_client $MOUNT || error "Unable to mount client"
2451 run_test 56 "check big indexes"
2454 do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
2458 start_mgsmds >> /dev/null
2459 local C1=$(count_osts)
2460 if [ $C1 -eq 0 ]; then
2461 start_ost >> /dev/null
2465 echo "original ost count: $C1 (expect > 0)"
2466 [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
2467 start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
2468 local C2=$(count_osts)
2469 echo "after mdt writeconf count: $C2 (expect 0)"
2470 [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
2471 echo "OST start without writeconf should fail:"
2472 start_ost >> /dev/null && error "OST start without writeconf didn't fail"
2473 echo "OST start with writeconf should succeed:"
2474 start_ost -o writeconf >> /dev/null || error "OST1 start failed"
2475 local C3=$(count_osts)
2476 echo "after ost writeconf count: $C3 (expect 1)"
2477 [ $C3 -eq 1 ] || error "new OST writeconf should add:"
2478 start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
2479 local C4=$(count_osts)
2480 echo "after ost2 writeconf count: $C4 (expect 2)"
2481 [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
2482 stop_ost2 >> /dev/null
2483 cleanup_nocli >> /dev/null
2485 run_test 59 "writeconf mount option"
2488 equals_msg `basename $0`: test complete
2489 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true