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
43 require_dsh_mds || exit 0
44 require_dsh_ost || exit 0
46 [ "$SLOW" = "no" ] && EXCEPT_SLOW="0 1 2 3 6 7 15 18 24b 25 30 31 32 33 34a 45"
55 local facet=$SINGLEMDS
56 local dev=${facet}_dev
60 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
61 do_facet ${facet} "$TUNEFS --writeconf ${!dev}" ||
62 echo "tunefs failed, reformatting instead" && reformat_and_config
67 # The MGS must be started before the OSTs for a new fs, so start
68 # and stop to generate the startup logs.
71 wait_osc_import_state mds ost FULL
76 reformat_and_config() {
78 if ! combined_mgs_mds ; then
86 start mgs $MGSDEV $mgs_MOUNT_OPTS
90 local facet=$SINGLEMDS
91 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
92 local num=$(echo $facet | tr -d "mds")
93 local dev=$(mdsdevname $num)
94 echo "start mds service on `facet_active_host $facet`"
95 start $facet ${dev} $MDS_MOUNT_OPTS || return 94
99 echo "stop mds service on `facet_active_host $SINGLEMDS`"
100 # These tests all use non-failover stop
101 stop $SINGLEMDS -f || return 97
105 echo "start ost1 service on `facet_active_host ost1`"
106 start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95
110 echo "stop ost1 service on `facet_active_host ost1`"
111 # These tests all use non-failover stop
112 stop ost1 -f || return 98
116 echo "start ost2 service on `facet_active_host ost2`"
117 start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92
121 echo "stop ost2 service on `facet_active_host ost2`"
122 # These tests all use non-failover stop
123 stop ost2 -f || return 93
128 echo "mount $FSNAME on ${MOUNTPATH}....."
129 zconf_mount `hostname` $MOUNTPATH || return 96
133 local SAVEMOUNTOPT=$MOUNTOPT
134 MOUNTOPT="remount,$1"
136 echo "remount '$1' lustre on ${MOUNTPATH}....."
137 zconf_mount `hostname` $MOUNTPATH || return 96
138 MOUNTOPT=$SAVEMOUNTOPT
143 echo "umount lustre on ${MOUNTPATH}....."
144 zconf_umount `hostname` $MOUNTPATH || return 97
147 manual_umount_client(){
150 echo "manual umount lustre on ${MOUNT}...."
151 do_facet client "umount -d ${FORCE} $MOUNT"
157 start_ost || error "OST start failed"
158 start_mds || error "MDT start failed"
159 mount_client $MOUNT || error "client start failed"
163 if ! combined_mgs_mds ; then
173 stop_mds || return 201
174 stop_ost || return 202
175 unload_modules || return 203
179 umount_client $MOUNT || return 200
180 cleanup_nocli || return $?
184 do_facet client "cp /etc/passwd $DIR/a" || return 71
185 do_facet client "rm $DIR/a" || return 72
186 # make sure lustre is actually mounted (touch will block,
187 # but grep won't, so do it after)
188 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
189 echo "setup single mount lustre success"
193 do_facet client "touch $DIR/a" || return 71
194 do_facet client "rm $DIR/a" || return 72
195 do_facet client "touch $DIR2/a" || return 73
196 do_facet client "rm $DIR2/a" || return 74
197 echo "setup double mount lustre success"
202 if [ "$ONLY" == "setup" ]; then
207 if [ "$ONLY" == "cleanup" ]; then
214 #create single point mountpoint
220 check_mount || return 41
223 run_test 0 "single mount setup"
227 echo "start ost second time..."
228 start_ost && error "2nd OST start should fail"
229 start_mds || error "MDT start failed"
230 mount_client $MOUNT || error "client start failed"
231 check_mount || return 42
234 run_test 1 "start up ost twice (should return errors)"
239 echo "start mds second time.."
240 start_mds && error "2nd MDT start should fail"
242 check_mount || return 43
245 run_test 2 "start up mds twice (should return err)"
249 #mount.lustre returns an error if already in mtab
250 mount_client $MOUNT && error "2nd client mount should fail"
251 check_mount || return 44
254 run_test 3 "mount client twice (should return err)"
258 touch $DIR/$tfile || return 85
262 # ok for ost to fail shutdown
263 if [ 202 -ne $eno ]; then
268 run_test 4 "force cleanup ost, then cleanup"
270 test_5a() { # was test_5
272 touch $DIR/$tfile || return 1
273 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
275 stop_mds -f || return 2
277 # cleanup may return an error from the failed
278 # disconnects; for now I'll consider this successful
279 # if all the modules have unloaded.
283 echo "killing umount"
284 kill -TERM $UMOUNT_PID
285 echo "waiting for umount to finish"
287 if grep " $MOUNT " /proc/mounts; then
288 echo "test 5: /proc/mounts after failed umount"
292 echo "killing umount"
293 kill -TERM $UMOUNT_PID
294 echo "waiting for umount to finish"
296 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
300 # stop_mds is a no-op here, and should not fail
301 cleanup_nocli || return $?
302 # df may have lingering entry
304 # mtab may have lingering entry
308 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
310 grep -q $MOUNT" " /etc/mtab || break
311 echo "Waiting /etc/mtab updated ... "
312 WAIT=$(( WAIT + sleep))
314 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
315 echo "/etc/mtab updated in $WAIT secs"
317 run_test 5a "force cleanup mds, then cleanup"
321 [ -d $MOUNT ] || mkdir -p $MOUNT
322 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
323 mount_client $MOUNT && return 1
324 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
326 # stop_mds is a no-op here, and should not fail
327 cleanup_nocli || return $?
330 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
335 [ -d $MOUNT ] || mkdir -p $MOUNT
336 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
337 local oldfs="${FSNAME}"
338 FSNAME="wrong.${FSNAME}"
339 mount_client $MOUNT || :
341 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
343 cleanup_nocli || return $?
345 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
351 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
352 mount_client $MOUNT || return 1
354 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
357 run_test 5d "mount with ost down"
363 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
364 do_facet client "lctl set_param fail_loc=0x80000506"
365 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
366 mount_client $MOUNT || echo "mount failed (not fatal)"
368 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
371 run_test 5e "delayed connect, don't crash (bug 10268)"
376 mount_client ${MOUNT} || return 87
377 touch $DIR/a || return 86
380 run_test 6 "manual umount, then mount again"
385 cleanup_nocli || return $?
387 run_test 7 "manual umount, then cleanup"
392 check_mount2 || return 45
393 umount_client $MOUNT2
396 run_test 8 "double mount setup"
401 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
402 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
404 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
405 if [ "$CHECK_PTLDEBUG" ] && { \
406 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
407 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
408 echo "lnet.debug success"
410 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
413 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
414 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
415 echo "lnet.subsystem_debug success"
417 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
420 stop_ost || return $?
423 run_test 9 "test ptldebug and subsystem for mkfs"
425 # LOGS/PENDING do not exist anymore since CMD3
427 local TMPMTPT="${TMP}/conf16"
428 local dev=${SINGLEMDS}_dev
430 if [ ! -e "$MDSDEV" ]; then
431 log "no $MDSDEV existing, so mount Lustre to create one"
433 check_mount || return 41
437 [ -f "$MDSDEV" ] && LOOPOPT="-o loop"
439 log "change the mode of $MDSDEV/OBJECTS to 555"
440 do_facet $SINGLEMDS "mkdir -p $TMPMTPT &&
441 mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
442 chmod 555 $TMPMTPT/OBJECTS &&
443 umount $TMPMTPT" || return $?
445 log "mount Lustre to change the mode of OBJECTS, then umount Lustre"
447 check_mount || return 41
450 log "read the mode of OBJECTS and check if they has been changed properly"
451 EXPECTEDOBJECTSMODE=`do_facet $SINGLEMDS "$DEBUGFS -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
453 if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
454 log "Success:Lustre change the mode of OBJECTS correctly"
456 error "Lustre does not change mode of OBJECTS properly"
459 run_test 16 "verify that lustre will correct the mode of OBJECTS"
462 local dev=${SINGLEMDS}_dev
465 if [ ! -e "$MDSDEV" ]; then
466 echo "no $MDSDEV existing, so mount Lustre to create one"
468 check_mount || return 41
472 echo "Remove mds config log"
473 do_facet $SINGLEMDS "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
476 start_mds && return 42
479 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
482 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
484 local dev=${SINGLEMDS}_dev
490 # check if current MDSSIZE is large enough
491 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
492 log "use MDSSIZE=$MDSSIZE"
494 # check if the global config has a large enough MDSSIZE
495 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
496 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
497 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
499 # check if the block device is large enough
500 [ -z "$OK" -a -b $MDSDEV ] && \
501 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
502 awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
503 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
505 # check if a loopback device has enough space for fs metadata (5%)
506 [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
507 SPACE=$(df -P $(dirname $MDSDEV) |
508 awk '($1 != "Filesystem") {print $4}') &&
509 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
510 log "use file $MDSDEV with MIN=$MIN"
512 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
515 echo "mount mds with large journal..."
516 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
518 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
521 echo "mount lustre system..."
523 check_mount || return 41
525 echo "check journal size..."
526 local FOUNDSIZE=`do_facet mds "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
527 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
528 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
530 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
535 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
538 run_test 18 "check mkfs creates large journals"
541 start_mds || return 1
542 stop_mds -f || return 2
544 run_test 19a "start/stop MDS without OSTs"
547 start_ost || return 1
548 stop_ost -f || return 2
550 run_test 19b "start/stop OSTs without MDS"
553 # first format the ost/mdt
557 check_mount || return 43
559 remount_client ro $MOUNT || return 44
560 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
561 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
562 remount_client rw $MOUNT || return 47
564 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
565 MCNT=`grep -c $MOUNT /etc/mtab`
566 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
571 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
576 wait_osc_import_state mds ost FULL
580 run_test 21a "start mds before ost, stop ost first"
585 wait_osc_import_state mds ost FULL
589 run_test 21b "start ost before mds, stop mds first"
595 wait_osc_import_state mds ost2 FULL
599 #writeconf to remove all ost2 traces for subsequent tests
602 run_test 21c "start mds between two osts, stop mds last"
607 echo Client mount with ost in logs, but none running
609 # wait until mds connected to ost and open client connection
610 wait_osc_import_state mds ost FULL
613 # check_mount will block trying to contact ost
614 mcreate $DIR/$tfile || return 40
615 rm -f $DIR/$tfile || return 42
619 echo Client mount with a running ost
622 # if gss enabled, wait full time to let connection from
623 # mds to ost be established, due to the mismatch between
624 # initial connect timeout and gss context negotiation timeout.
625 # This perhaps could be remove after AT landed.
626 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
627 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
630 check_mount || return 41
635 run_test 22 "start a client before osts (should return errs)"
637 test_23a() { # was test_23
641 # force down client so that recovering mds waits for reconnect
642 local running=$(grep -c $MOUNT /proc/mounts) || true
643 if [ $running -ne 0 ]; then
644 echo "Stopping client $MOUNT (opts: -f)"
648 # enter recovery on mds
650 # try to start a new client
651 mount_client $MOUNT &
653 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
654 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
655 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
657 ps --ppid $MOUNT_LUSTRE_PID
658 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
659 kill -TERM $MOUNT_LUSTRE_PID
660 echo "waiting for mount to finish"
662 # we can not wait $MOUNT_PID because it is not a child of this shell
668 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
670 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
671 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
674 [ -z "$PID1" -a -z "$PID2" ] && break
675 echo "waiting for mount to finish ... "
676 WAIT=$(( WAIT + sleep))
678 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
679 error "MOUNT_PID $MOUNT_PID and "\
680 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
686 run_test 23a "interrupt client during recovery mount delay"
691 test_23b() { # was test_23
694 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
695 lctl set_param fail_loc=0x80000313
699 run_test 23b "Simulate -EINTR during mount"
701 fs2mds_HOST=$mds_HOST
702 fs2ost_HOST=$ost_HOST
706 echo "umount $MOUNT2 ..."
707 umount $MOUNT2 || true
708 echo "stopping fs2mds ..."
709 stop fs2mds -f || true
710 echo "stopping fs2ost ..."
711 stop fs2ost -f || true
718 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
719 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
720 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
721 skip_env "mixed loopback and real device not working" && return
724 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
725 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
727 # test 8-char fsname as well
728 local FSNAME2=test1234
729 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
731 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
734 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
735 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
737 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
739 check_mount || return 2
740 # files written on 1 should not show up on 2
741 cp /etc/passwd $DIR/$tfile
743 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
746 cp /etc/passwd $MOUNT2/b || return 3
747 rm $MOUNT2/b || return 4
748 # 2 is actually mounted
749 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
751 facet_failover fs2mds
752 facet_failover fs2ost
755 # the MDS must remain up until last MDT
757 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
758 [ -z "$MDS" ] && error "No MDT" && return 8
760 cleanup_nocli || return 6
762 run_test 24a "Multiple MDTs on a single node"
765 if [ -z "$fs2mds_DEV" ]; then
766 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
767 skip_env "mixed loopback and real device not working" && return
770 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
772 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
774 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
777 run_test 24b "Multiple MGSs on a single node (should return err)"
781 check_mount || return 2
782 local MODULES=$($LCTL modules | awk '{ print $2 }')
783 rmmod $MODULES 2>/dev/null || true
786 run_test 25 "Verify modules are referenced"
790 # we need modules before mount for sysctl, so make sure...
791 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
792 #define OBD_FAIL_MDS_FS_SETUP 0x135
793 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
794 start_mds && echo MDS started && return 1
795 lctl get_param -n devices
796 DEVS=$(lctl get_param -n devices | wc -l)
797 [ $DEVS -gt 0 ] && return 2
798 unload_modules || return 203
800 run_test 26 "MDT startup failure cleans LOV (should return errs)"
806 local ORIG=$(do_facet $myfacet "$TEST")
807 if [ $# -gt 3 ]; then
813 echo "Setting $PARAM from $ORIG to $FINAL"
814 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
816 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
820 start_ost || return 1
821 start_mds || return 2
822 echo "Requeue thread should have started: "
823 ps -e | grep ll_cfg_requeue
824 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
827 run_test 27a "Reacquire MGS lock if OST started first"
832 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
834 facet_failover $SINGLEMDS
835 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
836 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
840 run_test 27b "Reacquire MGS lock after failover"
844 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
845 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
848 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
849 FINAL=$(($FINAL + 1))
850 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
851 umount_client $MOUNT || return 200
854 if [ $RESULT -ne $FINAL ]; then
855 echo "New config not seen: wanted $FINAL got $RESULT"
858 echo "New config success: got $RESULT"
860 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
863 run_test 28 "permanent parameter setting"
866 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
867 setup > /dev/null 2>&1
871 local PARAM="$FSNAME-OST0001.osc.active"
872 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
873 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
875 ACTV=$(lctl get_param -n $PROC_ACT)
877 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
878 # also check ost_server_uuid status
879 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
880 if [ -z "$RESULT" ]; then
881 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
884 echo "Live client success: got $RESULT"
888 local MPROC="osc.$FSNAME-OST0001-osc-[M]*.active"
893 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
894 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
895 if [ $RESULT -eq $DEAC ]; then
896 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
900 if [ $WAIT -eq $MAX ]; then
901 echo "MDT not deactivated: wanted $DEAC got $RESULT"
904 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
907 # test new client starts deactivated
908 umount_client $MOUNT || return 200
910 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
911 if [ -z "$RESULT" ]; then
912 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
915 echo "New client success: got $RESULT"
918 # make sure it reactivates
919 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
924 #writeconf to remove all ost2 traces for subsequent tests
927 run_test 29 "permanently remove an OST"
933 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
935 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
936 for i in ${LIST[@]}; do
937 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
939 # make sure client restart still works
941 mount_client $MOUNT || return 4
942 [ "$($TEST)" -ne "$i" ] && return 5
945 echo Erase parameter setting
946 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
948 mount_client $MOUNT || return 6
950 echo "deleted (default) value=$FINAL, orig=$ORIG"
951 # assumes this parameter started at the default value
952 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
956 run_test 30 "Big config llog and conf_param deletion"
958 test_31() { # bug 10734
959 # ipaddr must not exist
960 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
963 run_test 31 "Connect to non-existent node (shouldn't crash)"
965 # Use these start32/stop32 fn instead of t-f start/stop fn,
966 # for local devices, to skip global facet vars init
970 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
971 umount -d $@ ${MOUNT%/*}/${facet}
980 mkdir -p ${MOUNT%/*}/${facet}
982 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
983 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
985 if [ $RC -ne 0 ]; then
986 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
987 echo "Start of ${device} of local ${facet} failed ${RC}"
1001 echo "Cleanup test_32 umount $MOUNT ..."
1002 umount -f $MOUNT || true
1003 echo "Cleanup local mds ost1 ..."
1009 client_only && skip "client only testing" && return 0
1010 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1011 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1013 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1014 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1015 local tmpdir=$TMP/conf32a
1017 tar xjvf $DISK1_8 -C $tmpdir || \
1018 { skip_env "Cannot untar $DISK1_8" && return 0; }
1021 $LCTL set_param debug=$PTLDEBUG
1023 $TUNEFS $tmpdir/mds || error "tunefs failed"
1025 # nids are wrong, so client wont work, but server should start
1026 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1027 trap cleanup_32 EXIT INT || return 3
1029 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1031 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1033 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1034 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1035 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1037 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1039 local NID=$($LCTL list_nids | head -1)
1041 echo "OSC changes should succeed:"
1042 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1043 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1046 echo "MDC changes should succeed:"
1047 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1048 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1051 echo "LOV changes should succeed:"
1052 $LCTL pool_new lustre.interop || return 11
1053 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1058 # mount a second time to make sure we didnt leave upgrade flag on
1060 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1061 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1062 trap cleanup_32 EXIT INT || return 12
1066 rm -rf $tmpdir || true # true is only for TMP on NFS
1068 run_test 32a "Upgrade from 1.8 (not live)"
1071 client_only && skip "client only testing" && return 0
1072 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1073 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1075 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1076 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1077 local tmpdir=$TMP/conf32b
1079 tar xjvf $DISK1_8 -C $tmpdir || \
1080 { skip_env "Cannot untar $DISK1_8" && return ; }
1083 $LCTL set_param debug="config"
1084 local NEWNAME=lustre
1086 # writeconf will cause servers to register with their current nids
1087 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1088 start32 mds1 $tmpdir/mds "-o loop" && \
1089 trap cleanup_32 EXIT INT || return 3
1091 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1093 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1095 $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 ||\
1096 error "tunefs failed"
1097 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1098 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1100 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1102 local NID=$($LCTL list_nids | head -1)
1104 echo "OSC changes should succeed:"
1105 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1106 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1109 echo "MDC changes should succeed:"
1110 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1111 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1114 echo "LOV changes should succeed:"
1115 $LCTL pool_new ${NEWNAME}.interop || return 11
1116 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1119 # MDT and OST should have registered with new nids, so we should have
1120 # a fully-functioning client
1121 echo "Check client and old fs contents"
1123 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1124 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1125 mount -t lustre $device $MOUNT || return 1
1127 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1128 local new=$((old + 5))
1129 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1130 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1132 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1137 rm -rf $tmpdir || true # true is only for TMP on NFS
1139 run_test 32b "Upgrade from 1.8 with writeconf"
1141 test_33a() { # bug 12333, was test_33
1143 local FSNAME2=test-123
1144 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1146 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1147 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1148 skip_env "mixed loopback and real device not working" && return
1151 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1152 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1153 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1154 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1156 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1157 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1158 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1160 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1163 cp /etc/hosts $MOUNT2/ || rc=3
1164 $LFS getstripe $MOUNT2/hosts
1169 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1170 cleanup_nocli || rc=6
1173 run_test 33a "Mount ost with a large index number"
1175 test_33b() { # was test_34
1178 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1179 # Drop lock cancelation reply during umount
1180 #define OBD_FAIL_LDLM_CANCEL 0x304
1181 do_facet client lctl set_param fail_loc=0x80000304
1182 #lctl set_param debug=-1
1183 umount_client $MOUNT
1186 run_test 33b "Drop cancel during umount"
1190 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1191 manual_umount_client
1193 do_facet client killall -USR1 multiop
1194 if [ $rc -eq 0 ]; then
1195 error "umount not fail!"
1200 run_test 34a "umount with opened file should be fail"
1205 touch $DIR/$tfile || return 1
1206 stop_mds --force || return 2
1208 manual_umount_client --force
1210 if [ $rc -ne 0 ]; then
1211 error "mtab after failed umount - rc $rc"
1217 run_test 34b "force umount with failed mds should be normal"
1221 touch $DIR/$tfile || return 1
1222 stop_ost --force || return 2
1224 manual_umount_client --force
1226 if [ $rc -ne 0 ]; then
1227 error "mtab after failed umount - rc $rc"
1233 run_test 34c "force umount with failed ost should be normal"
1235 test_35a() { # bug 12459
1238 DBG_SAVE="`lctl get_param -n debug`"
1239 lctl set_param debug="ha"
1241 log "Set up a fake failnode for the MDS"
1243 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1244 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1246 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1249 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1252 log "Stopping the MDT:"
1253 stop_mds || return 5
1255 df $MOUNT > /dev/null 2>&1 &
1257 log "Restarting the MDT:"
1258 start_mds || return 6
1259 log "Wait for df ($DFPID) ... "
1262 lctl set_param debug="$DBG_SAVE"
1264 # retrieve from the log the first server that the client tried to
1265 # contact after the connection loss
1266 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1267 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1268 /import_select_connection.*$device-mdc.* using connection/ {
1270 if (\\\$NF ~ /$FAKENID/)
1276 }" $TMP/lustre-log-$TESTNAME.log`
1277 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1280 run_test 35a "Reconnect to the last active server first"
1282 test_35b() { # bug 18674
1283 remote_mds || { skip "local MDS" && return 0; }
1287 $LCTL set_param debug="ha"
1289 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1292 log "Set up a fake failnode for the MDS"
1294 local device=$(do_facet mds "$LCTL get_param -n devices" | \
1295 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1296 do_facet mds "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1299 local at_max_saved=0
1300 # adaptive timeouts may prevent seeing the issue
1301 if at_is_enabled; then
1302 at_max_saved=$(at_max_get mds)
1303 at_max_set 0 mds client
1306 mkdir -p $MOUNT/testdir
1307 touch $MOUNT/testdir/test
1309 log "Injecting EBUSY on MDS"
1310 # Setting OBD_FAIL_MDS_RESEND=0x136
1311 do_facet mds "$LCTL set_param fail_loc=0x80000136" || return 2
1313 log "Stat on a test file"
1314 stat $MOUNT/testdir/test
1316 log "Stop injecting EBUSY on MDS"
1317 do_facet mds "$LCTL set_param fail_loc=0" || return 3
1318 rm -f $MOUNT/testdir/test
1321 # restore adaptive timeout
1322 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1324 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1326 # retrieve from the log if the client has ever tried to
1327 # contact the fake server after the loss of connection
1328 FAILCONN=`awk "BEGIN {ret = 0;}
1329 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1331 if (\\\$NF ~ /$FAKENID/) {
1336 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1338 [ "$FAILCONN" == "0" ] && \
1339 log "ERROR: The client reconnection has not been triggered" && \
1341 [ "$FAILCONN" == "2" ] && \
1342 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1347 run_test 35b "Continue reconnection retries, if the active server is busy"
1351 local FSNAME2=test1234
1352 local fs3ost_HOST=$ost_HOST
1354 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1357 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1358 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1359 skip_env "mixed loopback and real device not working" && return
1361 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1363 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1364 { skip "remote OST" && return 0; }
1366 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1367 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1368 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1369 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1370 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1372 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1373 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1375 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1376 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1377 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1379 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1381 sleep 5 # until 11778 fixed
1383 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1385 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1386 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1387 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1388 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1389 DFTOTAL=`echo $STRING | cut -d, -f1`
1390 DFUSED=`echo $STRING | cut -d, -f2`
1391 DFAVAIL=`echo $STRING | cut -d, -f3`
1392 DFFREE=$(($DFTOTAL - $DFUSED))
1394 ALLOWANCE=$((64 * $OSTCOUNT))
1396 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1397 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1398 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1401 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1402 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1403 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1406 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1407 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1408 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1413 stop fs3ost -f || return 200
1414 stop fs2ost -f || return 201
1415 stop fs2mds -f || return 202
1416 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1417 unload_modules || return 203
1420 run_test 36 "df report consistency on OSTs with different block size"
1423 client_only && skip "client only testing" && return 0
1424 LOCAL_MDSDEV="$TMP/mdt.img"
1425 SYM_MDSDEV="$TMP/sym_mdt.img"
1427 echo "MDS : $LOCAL_MDSDEV"
1428 echo "SYMLINK : $SYM_MDSDEV"
1432 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1433 error "mkfs.lustre $LOCAL_MDSDEV failed"
1434 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1436 echo "mount symlink device - $SYM_MDSDEV"
1438 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1439 umount -d ${MOUNT%/*}/mds
1440 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1442 if [ -n "$mount_op" ]; then
1443 error "**** FAIL: set tunables failed for symlink device"
1447 run_test 37 "verify set tunables works for symlink device"
1449 test_38() { # bug 14222
1454 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1455 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1457 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1458 error "copying $SRC to $DIR/$tdir"
1460 umount_client $MOUNT
1462 log "rename lov_objid file on MDS"
1463 rm -f $TMP/lov_objid.orig
1465 local dev=${SINGLEMDS}_dev
1466 local MDSDEV=${!dev}
1467 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1468 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1470 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1471 # check create in mds_lov_connect
1475 [ $V ] && log "verifying $DIR/$tdir/$f"
1476 diff -q $f $DIR/$tdir/$f || ERROR=y
1478 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1479 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1480 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1482 # check it's updates in sync
1483 umount_client $MOUNT
1486 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1487 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1488 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1493 [ $V ] && log "verifying $DIR/$tdir/$f"
1494 diff -q $f $DIR/$tdir/$f || ERROR=y
1496 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1497 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1498 umount_client $MOUNT
1500 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1502 log "files compared the same"
1505 run_test 38 "MDS recreates missing lov_objid file from OST data"
1511 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1512 error "memory leak detected" || true
1514 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1516 test_40() { # bug 15759
1518 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1519 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1523 run_test 40 "race during service thread startup"
1525 test_41() { #bug 14134
1527 local dev=${SINGLEMDS}_dev
1528 local MDSDEV=${!dev}
1530 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1531 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1532 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1534 mount_client $MOUNT || return 1
1537 echo "blah blah" > $MOUNT/$tfile
1540 umount_client $MOUNT
1541 stop ost1 -f || return 201
1542 stop_mds -f || return 202
1543 stop_mds -f || return 203
1544 unload_modules || return 204
1547 run_test 41 "mount mds with --nosvc and --nomgs"
1549 test_42() { #bug 14693
1551 check_mount || return 2
1552 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1553 umount_client $MOUNT
1554 mount_client $MOUNT || return 1
1558 run_test 42 "invalid config param should not prevent client from mounting"
1561 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1563 chmod ugo+x $DIR || error "chmod 0 failed"
1565 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1566 "$FSNAME.mdt.root_squash" \
1569 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1570 "$FSNAME.mdt.nosquash_nids" \
1574 # create set of test files
1576 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1577 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1578 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1580 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1581 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1583 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1584 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1585 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1588 # check root_squash:
1589 # set root squash UID:GID to RUNAS_ID
1590 # root should be able to access only files owned by RUNAS_ID
1593 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1594 "$FSNAME.mdt.root_squash" \
1595 "$RUNAS_ID:$RUNAS_ID"
1597 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1598 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1599 error "$ST: root read permission is denied"
1600 echo "$ST: root read permission is granted - ok"
1603 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1604 error "$ST: root write permission is denied"
1605 echo "$ST: root write permission is granted - ok"
1607 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1608 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1609 error "$ST: root read permission is granted"
1610 echo "$ST: root read permission is denied - ok"
1613 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1614 error "$ST: root write permission is granted"
1615 echo "$ST: root write permission is denied - ok"
1617 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1618 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1619 error "$ST: root unlink permission is granted"
1620 echo "$ST: root unlink permission is denied - ok"
1622 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1623 error "$ST: root create permission is granted"
1624 echo "$ST: root create permission is denied - ok"
1627 # check nosquash_nids:
1628 # put client's NID into nosquash_nids list,
1629 # root should be able to access root file after that
1631 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1632 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1633 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1635 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1636 "$FSNAME-MDTall.mdt.nosquash_nids" \
1639 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1640 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1641 error "$ST: root read permission is denied"
1642 echo "$ST: root read permission is granted - ok"
1645 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1646 error "$ST: root write permission is denied"
1647 echo "$ST: root write permission is granted - ok"
1649 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1650 rm $DIR/$tdir-rootdir/tfile-1 || \
1651 error "$ST: root unlink permission is denied"
1652 echo "$ST: root unlink permission is granted - ok"
1653 touch $DIR/$tdir-rootdir/tfile-2 || \
1654 error "$ST: root create permission is denied"
1655 echo "$ST: root create permission is granted - ok"
1659 run_test 43 "check root_squash and nosquash_nids"
1661 umount_client $MOUNT
1666 check_mount || return 2
1667 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1669 UUIDS=$(do_facet mds "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1670 for VAL in $UUIDS; do
1671 NID=$(echo $VAL | cut -d= -f1)
1672 CLUUID=$(echo $VAL | cut -d= -f2)
1673 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1675 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1679 run_test 44 "mounted client proc entry exists"
1683 check_mount || return 2
1688 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1689 do_facet client "lctl set_param fail_loc=0x50f"
1692 manual_umount_client --force || return 3
1693 do_facet client "lctl set_param fail_loc=0x0"
1695 mount_client $MOUNT || return 4
1699 run_test 45 "long unlink handling in ptlrpcd"
1706 umount_client $MOUNT2 || rc=$?
1707 umount_client $MOUNT || rc=$?
1708 while [ $count -gt 0 ]; do
1709 stop ost${count} -f || rc=$?
1713 # writeconf is needed after the test, otherwise,
1714 # we might end up with extra OSTs
1716 cleanup_nocli || rc=$?
1721 echo "Testing with $OSTCOUNT OSTs"
1723 start_mds || return 1
1724 #first client should see only one ost
1725 start_ost || return 2
1726 wait_osc_import_state mds ost FULL
1728 mount_client $MOUNT || return 3
1729 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1732 for (( i=2; i<=$OSTCOUNT; i++ )); do
1733 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1736 # wait until osts in sync
1737 for (( i=2; i<=$OSTCOUNT; i++ )); do
1738 wait_osc_import_state mds ost$i FULL
1742 #second client see all ost's
1744 mount_client $MOUNT2 || return 8
1745 $LFS setstripe $MOUNT2 -c -1 || return 9
1746 $LFS getstripe $MOUNT2 || return 10
1748 echo "ok" > $MOUNT2/widestripe
1749 $LFS getstripe $MOUNT2/widestripe || return 11
1750 # fill acl buffer for avoid expand lsm to them
1751 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1752 setfacl -m $acl $MOUNT2/widestripe
1756 stat $MOUNT/widestripe || return 12
1758 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1761 run_test 46a "handle ost additional - wide striped file"
1766 check_mount || return 2
1767 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1771 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1772 if echo $ns | grep "MDT[[:digit:]]*"; then
1775 lrs=$(echo $ns | sed 's/.*lru_size=//')
1776 lru_size[count]=$lrs
1781 facet_failover $SINGLEMDS
1782 client_up || return 3
1785 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1786 if echo $ns | grep "MDT[[:digit:]]*"; then
1789 lrs=$(echo $ns | sed 's/.*lru_size=//')
1790 if ! test "$lrs" -eq "${lru_size[count]}"; then
1791 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1792 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1800 run_test 47 "server restart does not make client loss lru_resize settings"
1805 # reformat after this test is needed - if test will failed
1806 # we will have unkillable file at FS
1810 test_48() { # bug 17636
1813 check_mount || return 2
1815 $LFS setstripe $MOUNT -c -1 || return 9
1816 $LFS getstripe $MOUNT || return 10
1818 echo "ok" > $MOUNT/widestripe
1819 $LFS getstripe $MOUNT/widestripe || return 11
1821 trap cleanup_48 EXIT ERR
1823 # fill acl buffer for avoid expand lsm to them
1824 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1825 setfacl -m $acl $MOUNT/widestripe
1828 stat $MOUNT/widestripe || return 12
1833 run_test 48 "too many acls on file"
1835 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1836 test_49() { # bug 17710
1837 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1838 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1839 local LOCAL_TIMEOUT=20
1842 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1846 check_mount || return 1
1848 echo "check ldlm_timout..."
1849 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1850 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1851 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1853 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1854 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1857 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1858 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1861 umount_client $MOUNT
1862 stop_ost || return 2
1863 stop_mds || return 3
1865 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"
1869 check_mount || return 7
1871 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1872 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1873 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1875 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1876 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1879 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1880 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1883 cleanup || return $?
1885 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1886 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1888 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1891 # Test both statfs and lfs df and fail if either one fails
1892 multiop_bg_pause $1 f_
1895 killall -USR1 multiop
1896 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
1897 wait $PID || { RC1=$?; log "multiop return error "; }
1904 if [ $RC2 -eq 0 ]; then
1906 log "lazystatfs df failed"
1910 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
1916 lctl set_param llite.$FSNAME-*.lazystatfs=1
1919 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
1921 cleanup || return $?
1923 run_test 50a "lazystatfs all servers available =========================="
1927 lctl set_param llite.$FSNAME-*.lazystatfs=1
1930 # Wait for client to detect down OST
1931 stop_ost || error "Unable to stop OST1"
1932 wait_osc_import_state mds ost DISCONN
1934 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
1936 umount_client $MOUNT || error "Unable to unmount client"
1937 stop_mds || error "Unable to stop MDS"
1939 run_test 50b "lazystatfs all servers down =========================="
1942 start_mds || error "Unable to start MDS"
1943 start_ost || error "Unable to start OST1"
1944 start_ost2 || error "Unable to start OST2"
1945 mount_client $MOUNT || error "Unable to mount client"
1946 lctl set_param llite.$FSNAME-*.lazystatfs=1
1949 # Wait for client to detect down OST
1950 stop_ost || error "Unable to stop OST1"
1951 wait_osc_import_state mds ost DISCONN
1952 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1954 umount_client $MOUNT || error "Unable to unmount client"
1955 stop_ost2 || error "Unable to stop OST2"
1956 stop_mds || error "Unable to stop MDS"
1958 run_test 50c "lazystatfs one server down =========================="
1961 start_mds || error "Unable to start MDS"
1962 start_ost || error "Unable to start OST1"
1963 start_ost2 || error "Unable to start OST2"
1964 mount_client $MOUNT || error "Unable to mount client"
1965 lctl set_param llite.$FSNAME-*.lazystatfs=1
1968 # Issue the statfs during the window where the client still
1969 # belives the OST to be available but it is in fact down.
1970 # No failure just a statfs which hangs for a timeout interval.
1971 stop_ost || error "Unable to stop OST1"
1972 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1974 umount_client $MOUNT || error "Unable to unmount client"
1975 stop_ost2 || error "Unable to stop OST2"
1976 stop_mds || error "Unable to stop MDS"
1978 run_test 50d "lazystatfs client/server conn race =========================="
1985 start_mds || return 1
1986 #first client should see only one ost
1987 start_ost || return 2
1988 wait_osc_import_state mds ost FULL
1990 # Wait for client to detect down OST
1991 stop_ost || error "Unable to stop OST1"
1992 wait_osc_import_state mds ost DISCONN
1994 mount_client $MOUNT || error "Unable to mount client"
1995 lctl set_param llite.$FSNAME-*.lazystatfs=0
1997 multiop_bg_pause $MOUNT _f
2001 if [ $RC1 -ne 0 ]; then
2002 log "multiop failed $RC1"
2005 sleep $(( $TIMEOUT+1 ))
2007 [ $? -ne 0 ] && error "process isn't sleep"
2008 start_ost || error "Unable to start OST1"
2009 wait $pid || error "statfs failed"
2012 umount_client $MOUNT || error "Unable to unmount client"
2013 stop_ost || error "Unable to stop OST1"
2014 stop_mds || error "Unable to stop MDS"
2016 run_test 50e "normal statfs all servers down =========================="
2021 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2023 start_mds || error "Unable to start mds"
2024 #first client should see only one ost
2025 start_ost || error "Unable to start OST1"
2026 wait_osc_import_state mds ost FULL
2028 start_ost2 || error "Unable to start OST2"
2029 wait_osc_import_state mds ost2 FULL
2031 # Wait for client to detect down OST
2032 stop_ost2 || error "Unable to stop OST2"
2034 wait_osc_import_state mds ost2 DISCONN
2035 mount_client $MOUNT || error "Unable to mount client"
2036 lctl set_param llite.$FSNAME-*.lazystatfs=0
2038 multiop_bg_pause $MOUNT _f
2042 if [ $RC1 -ne 0 ]; then
2043 log "lazystatfs multiop failed $RC1"
2046 sleep $(( $TIMEOUT+1 ))
2048 [ $? -ne 0 ] && error "process isn't sleep"
2049 start_ost2 || error "Unable to start OST2"
2050 wait $pid || error "statfs failed"
2051 stop_ost2 || error "Unable to stop OST2"
2054 umount_client $MOUNT || error "Unable to unmount client"
2055 stop_ost || error "Unable to stop OST1"
2056 stop_mds || error "Unable to stop MDS"
2059 run_test 50f "normal statfs one server in down =========================="
2062 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2064 start_ost2 || error "Unable to start OST2"
2066 local PARAM="${FSNAME}-OST0001.osc.active"
2068 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2069 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2071 umount_client $MOUNT || error "Unable to unmount client"
2072 mount_client $MOUNT || error "Unable to mount client"
2073 # This df should not cause a panic
2076 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2078 umount_client $MOUNT || error "Unable to unmount client"
2079 stop_ost2 || error "Unable to stop OST2"
2080 stop_ost || error "Unable to stop OST1"
2081 stop_mds || error "Unable to stop MDS"
2084 run_test 50g "deactivated OST should not cause panic====================="
2087 local LOCAL_TIMEOUT=20
2091 check_mount || return 1
2094 $LFS setstripe -c -1 $MOUNT/d1
2095 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2096 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2097 touch $MOUNT/d1/f1 &
2100 start_ost2 || return 2
2102 stop_ost2 || return 3
2105 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2114 do_node $node mkdir -p $dest
2115 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2117 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2118 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2119 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2121 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2122 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2132 local backup2=${TMP}/backup2
2134 do_node $node mkdir -p $backup2
2135 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2137 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2138 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2139 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2141 do_node $node "diff -rq $backup $backup2"
2142 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2144 local xattrs2=${TMP}/xattrs2
2145 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2146 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2148 do_node $node "diff $xattrs $xattrs2"
2149 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2151 do_node $node "rm -rf $backup2 $xattrs2"
2152 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2157 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2159 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2161 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2164 local ost1mnt=${MOUNT%/*}/ost1
2165 local ost1node=$(facet_active_host ost1)
2166 local ost1tmp=$TMP/conf52
2169 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2170 touch $TMP/modified_first
2171 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2172 do_node $ost1node "mkdir -p $ost1tmp && touch $ost1tmp/modified_first"
2173 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2176 $LFS setstripe $DIR/$tdir -c -1 -s 1M
2177 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2179 for (( i=0; i < nrfiles; i++ )); do
2180 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2181 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2187 echo backup files to $TMP/files
2188 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2189 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2190 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2192 umount_client $MOUNT
2193 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2195 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2197 echo mount ost1 as ldiskfs
2198 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2199 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2202 echo backup objects to $ost1tmp/objects
2203 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2204 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2205 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2206 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2208 # move objects to lost+found
2209 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2210 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2213 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2214 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2216 # compare restored objects against saved ones
2217 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2218 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2220 do_node $ost1node "umount $ost1_dev"
2221 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2224 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2226 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2229 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2230 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2232 rm -rf $TMP/files $TMP/file_xattrs
2233 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2234 do_node $ost1node "rm -rf $ost1tmp"
2235 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2238 run_test 52 "check recovering objects from lost+found"
2240 # Checks threads_min/max/started for some service
2242 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2243 # parameter pattern prefix like 'ost.*.ost'.
2255 local msg="Insane $modname thread counts"
2259 check_mount || return 41
2261 # We need to expand $parampat, but it may match multiple parameters, so
2262 # we'll pick the first one
2263 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2264 error "Couldn't expand ${parampat}.threads_min parameter name"
2268 # Remove the .threads_min part
2269 paramp=${paramp%.threads_min}
2271 # Check for sanity in defaults
2272 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2273 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2274 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2275 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2276 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= tmax ))' || return $?
2278 # Check that we can lower min/max
2279 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin - 1))"
2280 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 10))"
2281 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2282 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2283 lassert 25 "$msg" '(($tmin2 == ($tmin - 1) && $tmax2 == ($tmax -10)))' || return $?
2285 # Check that we can set min/max to the same value
2286 do_facet $facet "lctl set_param ${paramp}.threads_min=$tmin"
2287 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2288 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2289 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2290 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2292 # Check that we can't set max < min
2293 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2294 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2295 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2296 lassert 27 "$msg" '(($tmin <= $tmax2))' || return $?
2298 # We need to ensure that we get the module options desired; to do this
2299 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2300 LOAD_MODULES_REMOTE=true
2303 setmodopts -a $modname "$opts" oldvalue
2307 check_mount || return 41
2309 # Restore previous setting of MODOPTS_*
2310 setmodopts $modname "$oldvalue"
2312 # Check that $opts took
2313 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2314 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2315 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2316 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2319 # Workaround a YALA bug where YALA expects that modules will remain
2320 # loaded on the servers
2321 LOAD_MODULES_REMOTE=false
2328 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2330 run_test 53a "check OSS thread count params"
2333 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2335 run_test 53b "check MDT thread count params"
2337 if ! combined_mgs_mds ; then
2344 local partial_arg=""
2345 local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
2347 # Run in partial (fast) mode if the size
2348 # of a partition > 10 GB
2349 [ $size -gt 10 ] && partial_arg="-p"
2351 llverfs $partial_arg $dir
2355 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
2356 [ $? -eq 0 ] || error "llverdev failed!"
2359 run_test 54a "llverdev"
2364 [ $? -eq 0 ] || error "llverfs failed!"
2367 run_test 54b "llverfs"
2371 local max_ost_index=$1
2372 echo -n $(((max_ost_index + 1) * 8))
2376 local mdsdev=$(mdsdevname 1)
2377 local ostdev=$(ostdevname 1)
2378 local saved_opts=$OST_MKFS_OPTS
2380 for i in 0 1023 2048
2382 OST_MKFS_OPTS="$saved_opts --index $i"
2390 echo checking size of lov_objid for ost index $i
2391 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2392 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2393 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2395 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2400 OST_MKFS_OPTS=$saved_opts
2403 run_test 55 "check lov_objid size"
2406 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2407 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2408 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2412 start_ost2 || error "Unable to start second ost"
2413 mount_client $MOUNT || error "Unable to mount client"
2419 run_test 56 "check big indexes"
2422 equals_msg `basename $0`: test complete
2423 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true