2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:autoindent:shiftwidth=4:tabstop=4:
5 # FIXME - there is no reason to use all of these different
6 # return codes, espcially when most of them are mapped to something
7 # else anyway. The combination of test number and return code
8 # figure out what failed.
14 # bug number for skipped test:
16 ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
17 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
20 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
22 PTLDEBUG=${PTLDEBUG:--1}
24 LUSTRE=${LUSTRE:-`dirname $0`/..}
25 RLUSTRE=${RLUSTRE:-$LUSTRE}
27 . $LUSTRE/tests/test-framework.sh
30 # use small MDS + OST size to speed formatting time
31 # do not use too small MDSSIZE/OSTSIZE, which affect the default jouranl size
34 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
36 # STORED_MDSSIZE is used in test_18
37 if [ -n "$MDSSIZE" ]; then
38 STORED_MDSSIZE=$MDSSIZE
44 require_dsh_mds || exit 0
45 require_dsh_ost || exit 0
47 [ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
62 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
63 do_facet ${facet} "$TUNEFS --writeconf $dev" ||
64 { echo "tunefs failed, reformatting instead" && reformat_and_config && return 1; }
69 # if writeconf failed, we reformatted
70 writeconf1 mds $MDSDEV || return 0
71 writeconf1 ost1 `ostdevname 1` || return 0
72 writeconf1 ost2 `ostdevname 2` || return 0
76 # The MGS must be started before the OSTs for a new fs, so start
77 # and stop to generate the startup logs.
80 wait_osc_import_state mds ost FULL
85 reformat_and_config() {
87 if ! combined_mgs_mds ; then
95 start mgs $MGSDEV $mgs_MOUNT_OPTS
99 local facet=$SINGLEMDS
100 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
101 local num=$(echo $facet | tr -d "mds")
102 local dev=$(mdsdevname $num)
103 echo "start mds service on `facet_active_host $facet`"
104 start $facet ${dev} $MDS_MOUNT_OPTS || return 94
108 echo "stop mds service on `facet_active_host $SINGLEMDS`"
109 # These tests all use non-failover stop
110 stop $SINGLEMDS -f || return 97
114 echo "start ost1 service on `facet_active_host ost1`"
115 start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95
119 echo "stop ost1 service on `facet_active_host ost1`"
120 # These tests all use non-failover stop
121 stop ost1 -f || return 98
125 echo "start ost2 service on `facet_active_host ost2`"
126 start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92
130 echo "stop ost2 service on `facet_active_host ost2`"
131 # These tests all use non-failover stop
132 stop ost2 -f || return 93
137 echo "mount $FSNAME on ${MOUNTPATH}....."
138 zconf_mount `hostname` $MOUNTPATH || return 96
142 local SAVEMOUNTOPT=$MOUNTOPT
143 MOUNTOPT="remount,$1"
145 echo "remount '$1' lustre on ${MOUNTPATH}....."
146 zconf_mount `hostname` $MOUNTPATH || return 96
147 MOUNTOPT=$SAVEMOUNTOPT
152 echo "umount lustre on ${MOUNTPATH}....."
153 zconf_umount `hostname` $MOUNTPATH || return 97
156 manual_umount_client(){
159 echo "manual umount lustre on ${MOUNT}...."
160 do_facet client "umount -d ${FORCE} $MOUNT"
166 start_mds || error "MDT start failed"
167 start_ost || error "OST start failed"
168 mount_client $MOUNT || error "client start failed"
172 if ! combined_mgs_mds ; then
182 stop_ost || return 202
183 stop_mds || return 201
184 unload_modules || return 203
188 umount_client $MOUNT || return 200
189 cleanup_nocli || return $?
193 do_facet client "cp /etc/passwd $DIR/a" || return 71
194 do_facet client "rm $DIR/a" || return 72
195 # make sure lustre is actually mounted (touch will block,
196 # but grep won't, so do it after)
197 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
198 echo "setup single mount lustre success"
202 do_facet client "touch $DIR/a" || return 71
203 do_facet client "rm $DIR/a" || return 72
204 do_facet client "touch $DIR2/a" || return 73
205 do_facet client "rm $DIR2/a" || return 74
206 echo "setup double mount lustre success"
211 if [ "$ONLY" == "setup" ]; then
216 if [ "$ONLY" == "cleanup" ]; then
223 #create single point mountpoint
229 check_mount || return 41
232 run_test 0 "single mount setup"
235 start_mds || error "MDT start failed"
237 echo "start ost second time..."
238 start_ost && error "2nd OST start should fail"
239 mount_client $MOUNT || error "client start failed"
240 check_mount || return 42
243 run_test 1 "start up ost twice (should return errors)"
247 echo "start mds second time.."
248 start_mds && error "2nd MDT start should fail"
251 check_mount || return 43
254 run_test 2 "start up mds twice (should return err)"
258 #mount.lustre returns an error if already in mtab
259 mount_client $MOUNT && error "2nd client mount should fail"
260 check_mount || return 44
263 run_test 3 "mount client twice (should return err)"
267 touch $DIR/$tfile || return 85
271 # ok for ost to fail shutdown
272 if [ 202 -ne $eno ]; then
277 run_test 4 "force cleanup ost, then cleanup"
279 test_5a() { # was test_5
281 touch $DIR/$tfile || return 1
282 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
284 stop_mds -f || return 2
286 # cleanup may return an error from the failed
287 # disconnects; for now I'll consider this successful
288 # if all the modules have unloaded.
292 echo "killing umount"
293 kill -TERM $UMOUNT_PID
294 echo "waiting for umount to finish"
296 if grep " $MOUNT " /proc/mounts; then
297 echo "test 5: /proc/mounts after failed umount"
301 echo "killing umount"
302 kill -TERM $UMOUNT_PID
303 echo "waiting for umount to finish"
305 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
309 # stop_mds is a no-op here, and should not fail
310 cleanup_nocli || return $?
311 # df may have lingering entry
313 # mtab may have lingering entry
317 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
319 grep -q $MOUNT" " /etc/mtab || break
320 echo "Waiting /etc/mtab updated ... "
321 WAIT=$(( WAIT + sleep))
323 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
324 echo "/etc/mtab updated in $WAIT secs"
326 run_test 5a "force cleanup mds, then cleanup"
330 [ -d $MOUNT ] || mkdir -p $MOUNT
331 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
332 mount_client $MOUNT && return 1
333 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
335 # stop_mds is a no-op here, and should not fail
336 cleanup_nocli || return $?
339 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
344 [ -d $MOUNT ] || mkdir -p $MOUNT
345 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
346 local oldfs="${FSNAME}"
347 FSNAME="wrong.${FSNAME}"
348 mount_client $MOUNT || :
350 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
352 cleanup_nocli || return $?
354 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
360 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
361 mount_client $MOUNT || return 1
363 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
366 run_test 5d "mount with ost down"
372 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
373 do_facet client "lctl set_param fail_loc=0x80000506"
374 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
375 mount_client $MOUNT || echo "mount failed (not fatal)"
377 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
380 run_test 5e "delayed connect, don't crash (bug 10268)"
385 mount_client ${MOUNT} || return 87
386 touch $DIR/a || return 86
389 run_test 6 "manual umount, then mount again"
394 cleanup_nocli || return $?
396 run_test 7 "manual umount, then cleanup"
401 check_mount2 || return 45
402 umount_client $MOUNT2
405 run_test 8 "double mount setup"
410 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
411 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
413 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
414 if [ "$CHECK_PTLDEBUG" ] && { \
415 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
416 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
417 echo "lnet.debug success"
419 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
422 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
423 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
424 echo "lnet.subsystem_debug success"
426 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
429 stop_ost || return $?
431 run_test 9 "test ptldebug and subsystem for mkfs"
433 # LOGS/PENDING do not exist anymore since CMD3
435 local TMPMTPT="${TMP}/conf16"
436 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
438 if [ ! -e "$MDSDEV" ]; then
439 log "no $MDSDEV existing, so mount Lustre to create one"
441 check_mount || return 41
445 [ -f "$MDSDEV" ] && LOOPOPT="-o loop"
447 log "change the mode of $MDSDEV/OBJECTS to 555"
448 do_facet $SINGLEMDS "mkdir -p $TMPMTPT &&
449 mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
450 chmod 555 $TMPMTPT/OBJECTS &&
451 umount $TMPMTPT" || return $?
453 log "mount Lustre to change the mode of OBJECTS, then umount Lustre"
455 check_mount || return 41
458 log "read the mode of OBJECTS and check if they has been changed properly"
459 EXPECTEDOBJECTSMODE=`do_facet $SINGLEMDS "$DEBUGFS -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
461 if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
462 log "Success:Lustre change the mode of OBJECTS correctly"
464 error "Lustre does not change mode of OBJECTS properly"
467 run_test 16 "verify that lustre will correct the mode of OBJECTS"
470 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
472 if [ ! -e "$MDSDEV" ]; then
473 echo "no $MDSDEV existing, so mount Lustre to create one"
475 check_mount || return 41
479 echo "Remove mds config log"
480 do_facet $SINGLEMDS "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
483 start_mds && return 42
486 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
489 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
491 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
496 # check if current MDSSIZE is large enough
497 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
498 log "use MDSSIZE=$MDSSIZE"
500 # check if the global config has a large enough MDSSIZE
501 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
502 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
503 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
505 # check if the block device is large enough
506 [ -z "$OK" -a -b $MDSDEV ] && \
507 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
508 awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
509 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
511 # check if a loopback device has enough space for fs metadata (5%)
512 [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
513 SPACE=$(df -P $(dirname $MDSDEV) |
514 awk '($1 != "Filesystem") {print $4}') &&
515 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
516 log "use file $MDSDEV with MIN=$MIN"
518 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
521 echo "mount mds with large journal..."
522 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
524 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
527 echo "mount lustre system..."
529 check_mount || return 41
531 echo "check journal size..."
532 local FOUNDSIZE=`do_facet mds "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
533 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
534 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
536 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
541 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
544 run_test 18 "check mkfs creates large journals"
547 start_mds || return 1
548 stop_mds -f || return 2
550 run_test 19a "start/stop MDS without OSTs"
553 start_ost || return 1
554 stop_ost -f || return 2
556 run_test 19b "start/stop OSTs without MDS"
559 # first format the ost/mdt
563 check_mount || return 43
565 remount_client ro $MOUNT || return 44
566 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
567 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
568 remount_client rw $MOUNT || return 47
570 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
571 MCNT=`grep -c $MOUNT /etc/mtab`
572 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
577 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
582 wait_osc_import_state mds ost FULL
586 run_test 21a "start mds before ost, stop ost first"
591 wait_osc_import_state mds ost FULL
595 run_test 21b "start ost before mds, stop mds first"
601 wait_osc_import_state mds ost2 FULL
605 #writeconf to remove all ost2 traces for subsequent tests
608 run_test 21c "start mds between two osts, stop mds last"
613 echo Client mount with ost in logs, but none running
615 # wait until mds connected to ost and open client connection
616 wait_osc_import_state mds ost FULL
619 # check_mount will block trying to contact ost
620 mcreate $DIR/$tfile || return 40
621 rm -f $DIR/$tfile || return 42
625 echo Client mount with a running ost
628 # if gss enabled, wait full time to let connection from
629 # mds to ost be established, due to the mismatch between
630 # initial connect timeout and gss context negotiation timeout.
631 # This perhaps could be remove after AT landed.
632 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
633 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
636 check_mount || return 41
641 run_test 22 "start a client before osts (should return errs)"
643 test_23a() { # was test_23
647 # force down client so that recovering mds waits for reconnect
648 local running=$(grep -c $MOUNT /proc/mounts) || true
649 if [ $running -ne 0 ]; then
650 echo "Stopping client $MOUNT (opts: -f)"
654 # enter recovery on mds
656 # try to start a new client
657 mount_client $MOUNT &
659 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
660 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
661 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
663 ps --ppid $MOUNT_LUSTRE_PID
664 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
665 kill -TERM $MOUNT_LUSTRE_PID
666 echo "waiting for mount to finish"
668 # we can not wait $MOUNT_PID because it is not a child of this shell
674 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
676 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
677 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
680 [ -z "$PID1" -a -z "$PID2" ] && break
681 echo "waiting for mount to finish ... "
682 WAIT=$(( WAIT + sleep))
684 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
685 error "MOUNT_PID $MOUNT_PID and "\
686 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
692 run_test 23a "interrupt client during recovery mount delay"
697 test_23b() { # was test_23
700 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
701 lctl set_param fail_loc=0x80000313
705 run_test 23b "Simulate -EINTR during mount"
707 fs2mds_HOST=$mds_HOST
708 fs2ost_HOST=$ost_HOST
712 echo "umount $MOUNT2 ..."
713 umount $MOUNT2 || true
714 echo "stopping fs2mds ..."
715 stop fs2mds -f || true
716 echo "stopping fs2ost ..."
717 stop fs2ost -f || true
725 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
727 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
728 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
729 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
730 skip_env "mixed loopback and real device not working" && return
733 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
734 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
736 # test 8-char fsname as well
737 local FSNAME2=test1234
738 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
740 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
743 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
744 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
746 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
748 check_mount || return 2
749 # files written on 1 should not show up on 2
750 cp /etc/passwd $DIR/$tfile
752 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
755 cp /etc/passwd $MOUNT2/b || return 3
756 rm $MOUNT2/b || return 4
757 # 2 is actually mounted
758 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
760 facet_failover fs2mds
761 facet_failover fs2ost
764 # the MDS must remain up until last MDT
766 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
767 [ -z "$MDS" ] && error "No MDT" && return 8
769 cleanup_nocli || return 6
771 run_test 24a "Multiple MDTs on a single node"
774 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
776 if [ -z "$fs2mds_DEV" ]; then
777 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
778 skip_env "mixed loopback and real device not working" && return
781 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
783 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
785 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
788 run_test 24b "Multiple MGSs on a single node (should return err)"
792 check_mount || return 2
793 local MODULES=$($LCTL modules | awk '{ print $2 }')
794 rmmod $MODULES 2>/dev/null || true
797 run_test 25 "Verify modules are referenced"
801 # we need modules before mount for sysctl, so make sure...
802 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
803 #define OBD_FAIL_MDS_FS_SETUP 0x135
804 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
805 start_mds && echo MDS started && return 1
806 lctl get_param -n devices
807 DEVS=$(lctl get_param -n devices | wc -l)
808 [ $DEVS -gt 0 ] && return 2
809 unload_modules || return 203
811 run_test 26 "MDT startup failure cleans LOV (should return errs)"
817 local ORIG=$(do_facet $myfacet "$TEST")
818 if [ $# -gt 3 ]; then
824 echo "Setting $PARAM from $ORIG to $FINAL"
825 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
827 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
831 start_ost || return 1
832 start_mds || return 2
833 echo "Requeue thread should have started: "
834 ps -e | grep ll_cfg_requeue
835 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
838 run_test 27a "Reacquire MGS lock if OST started first"
843 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
845 facet_failover $SINGLEMDS
846 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
847 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
851 run_test 27b "Reacquire MGS lock after failover"
855 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
856 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
859 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
860 FINAL=$(($FINAL + 1))
861 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
862 umount_client $MOUNT || return 200
865 if [ $RESULT -ne $FINAL ]; then
866 echo "New config not seen: wanted $FINAL got $RESULT"
869 echo "New config success: got $RESULT"
871 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
874 run_test 28 "permanent parameter setting"
877 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
878 setup > /dev/null 2>&1
882 local PARAM="$FSNAME-OST0001.osc.active"
883 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
884 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
886 ACTV=$(lctl get_param -n $PROC_ACT)
888 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
889 # also check ost_server_uuid status
890 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
891 if [ -z "$RESULT" ]; then
892 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
895 echo "Live client success: got $RESULT"
899 local MPROC="osc.$FSNAME-OST0001-osc-[M]*.active"
904 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
905 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
906 if [ $RESULT -eq $DEAC ]; then
907 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
911 if [ $WAIT -eq $MAX ]; then
912 echo "MDT not deactivated: wanted $DEAC got $RESULT"
915 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
918 # test new client starts deactivated
919 umount_client $MOUNT || return 200
921 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
922 if [ -z "$RESULT" ]; then
923 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
926 echo "New client success: got $RESULT"
929 # make sure it reactivates
930 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
935 #writeconf to remove all ost2 traces for subsequent tests
938 run_test 29 "permanently remove an OST"
944 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
946 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
947 for i in ${LIST[@]}; do
948 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
950 # make sure client restart still works
952 mount_client $MOUNT || return 4
953 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
956 echo Erase parameter setting
957 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
959 mount_client $MOUNT || return 6
961 echo "deleted (default) value=$FINAL, orig=$ORIG"
962 # assumes this parameter started at the default value
963 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
967 run_test 30a "Big config llog and conf_param deletion"
972 # Make a fake nid. Use the OST nid, and add 20 to the least significant
973 # numerical part of it. Hopefully that's not already a failover address for
975 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
976 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
977 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
978 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
979 echo "Using fake nid $NEW"
981 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
982 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
983 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
985 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
986 echo "should have 2 failover nids: $NIDCOUNT"
987 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
988 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
990 mount_client $MOUNT || return 3
992 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
994 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
995 echo "only 1 final nid should remain: $NIDCOUNT"
996 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
1000 run_test 30b "Remove failover nids"
1002 test_31() { # bug 10734
1003 # ipaddr must not exist
1004 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
1007 run_test 31 "Connect to non-existent node (shouldn't crash)"
1009 # Use these start32/stop32 fn instead of t-f start/stop fn,
1010 # for local devices, to skip global facet vars init
1014 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
1015 umount -d $@ ${MOUNT%/*}/${facet}
1024 mkdir -p ${MOUNT%/*}/${facet}
1026 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
1027 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
1029 if [ $RC -ne 0 ]; then
1030 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1031 echo "Start of ${device} of local ${facet} failed ${RC}"
1037 cleanup_nocli32 () {
1045 echo "Cleanup test_32 umount $MOUNT ..."
1046 umount -f $MOUNT || true
1047 echo "Cleanup local mds ost1 ..."
1053 client_only && skip "client only testing" && return 0
1054 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1055 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1057 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1058 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1059 local tmpdir=$TMP/conf32a
1061 tar xjvf $DISK1_8 -C $tmpdir || \
1062 { skip_env "Cannot untar $DISK1_8" && return 0; }
1065 $LCTL set_param debug=$PTLDEBUG
1067 $TUNEFS $tmpdir/mds || error "tunefs failed"
1069 # nids are wrong, so client wont work, but server should start
1070 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1071 trap cleanup_32 EXIT INT || return 3
1073 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1075 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1077 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1078 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1079 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1081 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1083 local NID=$($LCTL list_nids | head -1)
1085 echo "OSC changes should succeed:"
1086 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1087 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1090 echo "MDC changes should succeed:"
1091 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1092 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1095 echo "LOV changes should succeed:"
1096 $LCTL pool_new lustre.interop || return 11
1097 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1102 # mount a second time to make sure we didnt leave upgrade flag on
1104 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1105 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1106 trap cleanup_32 EXIT INT || return 12
1110 rm -rf $tmpdir || true # true is only for TMP on NFS
1112 run_test 32a "Upgrade from 1.8 (not live)"
1115 client_only && skip "client only testing" && return 0
1116 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1117 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1119 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1120 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1121 local tmpdir=$TMP/conf32b
1123 tar xjvf $DISK1_8 -C $tmpdir || \
1124 { skip_env "Cannot untar $DISK1_8" && return ; }
1127 $LCTL set_param debug="config"
1128 local NEWNAME=lustre
1130 # writeconf will cause servers to register with their current nids
1131 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1132 start32 mds1 $tmpdir/mds "-o loop" && \
1133 trap cleanup_32 EXIT INT || return 3
1135 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1137 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1139 $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 ||\
1140 error "tunefs failed"
1141 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1142 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1144 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1146 local NID=$($LCTL list_nids | head -1)
1148 echo "OSC changes should succeed:"
1149 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1150 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1153 echo "MDC changes should succeed:"
1154 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1155 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1158 echo "LOV changes should succeed:"
1159 $LCTL pool_new ${NEWNAME}.interop || return 11
1160 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1163 # MDT and OST should have registered with new nids, so we should have
1164 # a fully-functioning client
1165 echo "Check client and old fs contents"
1167 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1168 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1169 mount -t lustre $device $MOUNT || return 1
1171 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1172 local new=$((old + 5))
1173 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1174 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1176 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1181 rm -rf $tmpdir || true # true is only for TMP on NFS
1183 run_test 32b "Upgrade from 1.8 with writeconf"
1185 test_33a() { # bug 12333, was test_33
1187 local FSNAME2=test-123
1188 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1190 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1192 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1193 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1194 skip_env "mixed loopback and real device not working" && return
1197 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1198 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1199 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1200 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1202 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1203 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1204 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1206 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1209 cp /etc/hosts $MOUNT2/ || rc=3
1210 $LFS getstripe $MOUNT2/hosts
1215 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1216 cleanup_nocli || rc=6
1219 run_test 33a "Mount ost with a large index number"
1221 test_33b() { # was test_34
1224 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1225 # Drop lock cancelation reply during umount
1226 #define OBD_FAIL_LDLM_CANCEL 0x304
1227 do_facet client lctl set_param fail_loc=0x80000304
1228 #lctl set_param debug=-1
1229 umount_client $MOUNT
1232 run_test 33b "Drop cancel during umount"
1236 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1237 manual_umount_client
1239 do_facet client killall -USR1 multiop
1240 if [ $rc -eq 0 ]; then
1241 error "umount not fail!"
1246 run_test 34a "umount with opened file should be fail"
1251 touch $DIR/$tfile || return 1
1252 stop_mds --force || return 2
1254 manual_umount_client --force
1256 if [ $rc -ne 0 ]; then
1257 error "mtab after failed umount - rc $rc"
1263 run_test 34b "force umount with failed mds should be normal"
1267 touch $DIR/$tfile || return 1
1268 stop_ost --force || return 2
1270 manual_umount_client --force
1272 if [ $rc -ne 0 ]; then
1273 error "mtab after failed umount - rc $rc"
1279 run_test 34c "force umount with failed ost should be normal"
1281 test_35a() { # bug 12459
1284 DBG_SAVE="`lctl get_param -n debug`"
1285 lctl set_param debug="ha"
1287 log "Set up a fake failnode for the MDS"
1289 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1290 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1292 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1295 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1298 log "Stopping the MDT:"
1299 stop_mds || return 5
1301 df $MOUNT > /dev/null 2>&1 &
1303 log "Restarting the MDT:"
1304 start_mds || return 6
1305 log "Wait for df ($DFPID) ... "
1308 lctl set_param debug="$DBG_SAVE"
1310 # retrieve from the log the first server that the client tried to
1311 # contact after the connection loss
1312 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1313 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1314 /import_select_connection.*$device-mdc.* using connection/ {
1316 if (\\\$NF ~ /$FAKENID/)
1322 }" $TMP/lustre-log-$TESTNAME.log`
1323 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1325 # remove nid settings
1328 run_test 35a "Reconnect to the last active server first"
1330 test_35b() { # bug 18674
1331 remote_mds || { skip "local MDS" && return 0; }
1335 $LCTL set_param debug="ha"
1337 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1340 log "Set up a fake failnode for the MDS"
1342 local device=$(do_facet mds "$LCTL get_param -n devices" | \
1343 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1344 do_facet mds "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1347 local at_max_saved=0
1348 # adaptive timeouts may prevent seeing the issue
1349 if at_is_enabled; then
1350 at_max_saved=$(at_max_get mds)
1351 at_max_set 0 mds client
1354 mkdir -p $MOUNT/testdir
1355 touch $MOUNT/testdir/test
1357 log "Injecting EBUSY on MDS"
1358 # Setting OBD_FAIL_MDS_RESEND=0x136
1359 do_facet mds "$LCTL set_param fail_loc=0x80000136" || return 2
1361 log "Stat on a test file"
1362 stat $MOUNT/testdir/test
1364 log "Stop injecting EBUSY on MDS"
1365 do_facet mds "$LCTL set_param fail_loc=0" || return 3
1366 rm -f $MOUNT/testdir/test
1369 # restore adaptive timeout
1370 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1372 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1374 # retrieve from the log if the client has ever tried to
1375 # contact the fake server after the loss of connection
1376 FAILCONN=`awk "BEGIN {ret = 0;}
1377 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1379 if (\\\$NF ~ /$FAKENID/) {
1384 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1386 [ "$FAILCONN" == "0" ] && \
1387 log "ERROR: The client reconnection has not been triggered" && \
1389 [ "$FAILCONN" == "2" ] && \
1390 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1394 # remove nid settings
1397 run_test 35b "Continue reconnection retries, if the active server is busy"
1401 local FSNAME2=test1234
1402 local fs3ost_HOST=$ost_HOST
1403 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1405 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1408 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1409 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1410 skip_env "mixed loopback and real device not working" && return
1412 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1414 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1415 { skip "remote OST" && return 0; }
1417 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1418 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1419 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1420 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1421 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1423 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1424 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1426 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1427 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1428 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1430 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1432 sleep 5 # until 11778 fixed
1434 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1436 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1437 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1438 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1439 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1440 DFTOTAL=`echo $STRING | cut -d, -f1`
1441 DFUSED=`echo $STRING | cut -d, -f2`
1442 DFAVAIL=`echo $STRING | cut -d, -f3`
1443 DFFREE=$(($DFTOTAL - $DFUSED))
1445 ALLOWANCE=$((64 * $OSTCOUNT))
1447 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1448 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1449 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1452 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1453 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1454 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1457 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1458 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1459 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1464 stop fs3ost -f || return 200
1465 stop fs2ost -f || return 201
1466 stop fs2mds -f || return 202
1467 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1468 unload_modules || return 203
1471 run_test 36 "df report consistency on OSTs with different block size"
1474 client_only && skip "client only testing" && return 0
1475 LOCAL_MDSDEV="$TMP/mdt.img"
1476 SYM_MDSDEV="$TMP/sym_mdt.img"
1478 echo "MDS : $LOCAL_MDSDEV"
1479 echo "SYMLINK : $SYM_MDSDEV"
1483 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1484 error "mkfs.lustre $LOCAL_MDSDEV failed"
1485 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1487 echo "mount symlink device - $SYM_MDSDEV"
1489 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1490 umount -d ${MOUNT%/*}/mds
1491 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1493 if [ -n "$mount_op" ]; then
1494 error "**** FAIL: set tunables failed for symlink device"
1498 run_test 37 "verify set tunables works for symlink device"
1500 test_38() { # bug 14222
1505 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1506 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1508 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1509 error "copying $SRC to $DIR/$tdir"
1511 umount_client $MOUNT
1513 log "rename lov_objid file on MDS"
1514 rm -f $TMP/lov_objid.orig
1516 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1517 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1518 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1520 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1521 # check create in mds_lov_connect
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.new\\\" $MDSDEV"
1529 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1530 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1532 # check it's updates in sync
1533 umount_client $MOUNT
1536 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1537 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1538 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1543 [ $V ] && log "verifying $DIR/$tdir/$f"
1544 diff -q $f $DIR/$tdir/$f || ERROR=y
1546 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1547 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1548 umount_client $MOUNT
1550 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1552 log "files compared the same"
1555 run_test 38 "MDS recreates missing lov_objid file from OST data"
1561 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1562 error "memory leak detected" || true
1564 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1566 test_40() { # bug 15759
1568 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1569 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1573 run_test 40 "race during service thread startup"
1575 test_41() { #bug 14134
1577 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1579 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1580 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1581 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1583 mount_client $MOUNT || return 1
1586 echo "blah blah" > $MOUNT/$tfile
1589 umount_client $MOUNT
1590 stop ost1 -f || return 201
1591 stop_mds -f || return 202
1592 stop_mds -f || return 203
1593 unload_modules || return 204
1596 run_test 41 "mount mds with --nosvc and --nomgs"
1598 test_42() { #bug 14693
1600 check_mount || return 2
1601 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1602 umount_client $MOUNT
1603 mount_client $MOUNT || return 1
1607 run_test 42 "invalid config param should not prevent client from mounting"
1610 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1612 chmod ugo+x $DIR || error "chmod 0 failed"
1614 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1615 "$FSNAME.mdt.root_squash" \
1618 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1619 "$FSNAME.mdt.nosquash_nids" \
1623 # create set of test files
1625 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1626 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1627 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1629 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1630 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1632 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1633 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1634 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1637 # check root_squash:
1638 # set root squash UID:GID to RUNAS_ID
1639 # root should be able to access only files owned by RUNAS_ID
1642 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1643 "$FSNAME.mdt.root_squash" \
1644 "$RUNAS_ID:$RUNAS_ID"
1646 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1647 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1648 error "$ST: root read permission is denied"
1649 echo "$ST: root read permission is granted - ok"
1652 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1653 error "$ST: root write permission is denied"
1654 echo "$ST: root write permission is granted - ok"
1656 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1657 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1658 error "$ST: root read permission is granted"
1659 echo "$ST: root read permission is denied - ok"
1662 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1663 error "$ST: root write permission is granted"
1664 echo "$ST: root write permission is denied - ok"
1666 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1667 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1668 error "$ST: root unlink permission is granted"
1669 echo "$ST: root unlink permission is denied - ok"
1671 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1672 error "$ST: root create permission is granted"
1673 echo "$ST: root create permission is denied - ok"
1676 # check nosquash_nids:
1677 # put client's NID into nosquash_nids list,
1678 # root should be able to access root file after that
1680 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1681 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1682 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1684 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1685 "$FSNAME-MDTall.mdt.nosquash_nids" \
1688 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1689 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1690 error "$ST: root read permission is denied"
1691 echo "$ST: root read permission is granted - ok"
1694 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1695 error "$ST: root write permission is denied"
1696 echo "$ST: root write permission is granted - ok"
1698 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1699 rm $DIR/$tdir-rootdir/tfile-1 || \
1700 error "$ST: root unlink permission is denied"
1701 echo "$ST: root unlink permission is granted - ok"
1702 touch $DIR/$tdir-rootdir/tfile-2 || \
1703 error "$ST: root create permission is denied"
1704 echo "$ST: root create permission is granted - ok"
1708 run_test 43 "check root_squash and nosquash_nids"
1710 umount_client $MOUNT
1715 check_mount || return 2
1716 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1718 UUIDS=$(do_facet mds "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1719 for VAL in $UUIDS; do
1720 NID=$(echo $VAL | cut -d= -f1)
1721 CLUUID=$(echo $VAL | cut -d= -f2)
1722 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1724 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1728 run_test 44 "mounted client proc entry exists"
1732 check_mount || return 2
1737 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1738 do_facet client "lctl set_param fail_loc=0x50f"
1741 manual_umount_client --force || return 3
1742 do_facet client "lctl set_param fail_loc=0x0"
1744 mount_client $MOUNT || return 4
1748 run_test 45 "long unlink handling in ptlrpcd"
1755 umount_client $MOUNT2 || rc=$?
1756 umount_client $MOUNT || rc=$?
1757 while [ $count -gt 0 ]; do
1758 stop ost${count} -f || rc=$?
1762 cleanup_nocli || rc=$?
1763 #writeconf to remove all ost2 traces for subsequent tests
1769 echo "Testing with $OSTCOUNT OSTs"
1771 start_mds || return 1
1772 #first client should see only one ost
1773 start_ost || return 2
1774 wait_osc_import_state mds ost FULL
1776 mount_client $MOUNT || return 3
1777 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1780 for (( i=2; i<=$OSTCOUNT; i++ )); do
1781 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1784 # wait until osts in sync
1785 for (( i=2; i<=$OSTCOUNT; i++ )); do
1786 wait_osc_import_state mds ost$i FULL
1790 #second client see all ost's
1792 mount_client $MOUNT2 || return 8
1793 $LFS setstripe $MOUNT2 -c -1 || return 9
1794 $LFS getstripe $MOUNT2 || return 10
1796 echo "ok" > $MOUNT2/widestripe
1797 $LFS getstripe $MOUNT2/widestripe || return 11
1798 # fill acl buffer for avoid expand lsm to them
1799 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1800 setfacl -m $acl $MOUNT2/widestripe
1804 stat $MOUNT/widestripe || return 12
1806 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1809 run_test 46a "handle ost additional - wide striped file"
1814 check_mount || return 2
1815 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1819 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1820 if echo $ns | grep "MDT[[:digit:]]*"; then
1823 lrs=$(echo $ns | sed 's/.*lru_size=//')
1824 lru_size[count]=$lrs
1829 facet_failover $SINGLEMDS
1830 client_up || return 3
1833 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1834 if echo $ns | grep "MDT[[:digit:]]*"; then
1837 lrs=$(echo $ns | sed 's/.*lru_size=//')
1838 if ! test "$lrs" -eq "${lru_size[count]}"; then
1839 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1840 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1848 run_test 47 "server restart does not make client loss lru_resize settings"
1853 # reformat after this test is needed - if test will failed
1854 # we will have unkillable file at FS
1858 test_48() { # bug 17636
1861 check_mount || return 2
1863 $LFS setstripe $MOUNT -c -1 || return 9
1864 $LFS getstripe $MOUNT || return 10
1866 echo "ok" > $MOUNT/widestripe
1867 $LFS getstripe $MOUNT/widestripe || return 11
1869 trap cleanup_48 EXIT ERR
1871 # fill acl buffer for avoid expand lsm to them
1872 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1873 setfacl -m $acl $MOUNT/widestripe
1876 stat $MOUNT/widestripe || return 12
1881 run_test 48 "too many acls on file"
1883 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1884 test_49() { # bug 17710
1885 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1886 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1887 local LOCAL_TIMEOUT=20
1890 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1894 check_mount || return 1
1896 echo "check ldlm_timout..."
1897 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1898 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1899 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1901 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1902 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1905 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1906 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1909 umount_client $MOUNT
1910 stop_ost || return 2
1911 stop_mds || return 3
1913 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"
1917 check_mount || return 7
1919 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1920 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1921 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1923 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1924 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1927 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1928 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1931 cleanup || return $?
1933 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1934 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1936 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1939 # Test both statfs and lfs df and fail if either one fails
1940 multiop_bg_pause $1 f_
1943 killall -USR1 multiop
1944 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
1945 wait $PID || { RC1=$?; log "multiop return error "; }
1952 if [ $RC2 -eq 0 ]; then
1954 log "lazystatfs df failed"
1958 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
1964 lctl set_param llite.$FSNAME-*.lazystatfs=1
1967 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
1969 cleanup || return $?
1971 run_test 50a "lazystatfs all servers available =========================="
1975 lctl set_param llite.$FSNAME-*.lazystatfs=1
1978 # Wait for client to detect down OST
1979 stop_ost || error "Unable to stop OST1"
1980 wait_osc_import_state mds ost DISCONN
1982 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
1984 umount_client $MOUNT || error "Unable to unmount client"
1985 stop_mds || error "Unable to stop MDS"
1987 run_test 50b "lazystatfs all servers down =========================="
1990 start_mds || error "Unable to start MDS"
1991 start_ost || error "Unable to start OST1"
1992 start_ost2 || error "Unable to start OST2"
1993 mount_client $MOUNT || error "Unable to mount client"
1994 lctl set_param llite.$FSNAME-*.lazystatfs=1
1997 # Wait for client to detect down OST
1998 stop_ost || error "Unable to stop OST1"
1999 wait_osc_import_state mds ost DISCONN
2000 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2002 umount_client $MOUNT || error "Unable to unmount client"
2003 stop_ost2 || error "Unable to stop OST2"
2004 stop_mds || error "Unable to stop MDS"
2006 run_test 50c "lazystatfs one server down =========================="
2009 start_mds || error "Unable to start MDS"
2010 start_ost || error "Unable to start OST1"
2011 start_ost2 || error "Unable to start OST2"
2012 mount_client $MOUNT || error "Unable to mount client"
2013 lctl set_param llite.$FSNAME-*.lazystatfs=1
2016 # Issue the statfs during the window where the client still
2017 # belives the OST to be available but it is in fact down.
2018 # No failure just a statfs which hangs for a timeout interval.
2019 stop_ost || error "Unable to stop OST1"
2020 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
2022 umount_client $MOUNT || error "Unable to unmount client"
2023 stop_ost2 || error "Unable to stop OST2"
2024 stop_mds || error "Unable to stop MDS"
2026 run_test 50d "lazystatfs client/server conn race =========================="
2033 start_mds || return 1
2034 #first client should see only one ost
2035 start_ost || return 2
2036 wait_osc_import_state mds ost FULL
2038 # Wait for client to detect down OST
2039 stop_ost || error "Unable to stop OST1"
2040 wait_osc_import_state mds ost DISCONN
2042 mount_client $MOUNT || error "Unable to mount client"
2043 lctl set_param llite.$FSNAME-*.lazystatfs=0
2045 multiop_bg_pause $MOUNT _f
2049 if [ $RC1 -ne 0 ]; then
2050 log "multiop failed $RC1"
2053 sleep $(( $TIMEOUT+1 ))
2055 [ $? -ne 0 ] && error "process isn't sleep"
2056 start_ost || error "Unable to start OST1"
2057 wait $pid || error "statfs failed"
2060 umount_client $MOUNT || error "Unable to unmount client"
2061 stop_ost || error "Unable to stop OST1"
2062 stop_mds || error "Unable to stop MDS"
2064 run_test 50e "normal statfs all servers down =========================="
2069 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2071 start_mds || error "Unable to start mds"
2072 #first client should see only one ost
2073 start_ost || error "Unable to start OST1"
2074 wait_osc_import_state mds ost FULL
2076 start_ost2 || error "Unable to start OST2"
2077 wait_osc_import_state mds ost2 FULL
2079 # Wait for client to detect down OST
2080 stop_ost2 || error "Unable to stop OST2"
2082 wait_osc_import_state mds ost2 DISCONN
2083 mount_client $MOUNT || error "Unable to mount client"
2084 lctl set_param llite.$FSNAME-*.lazystatfs=0
2086 multiop_bg_pause $MOUNT _f
2090 if [ $RC1 -ne 0 ]; then
2091 log "lazystatfs multiop failed $RC1"
2094 sleep $(( $TIMEOUT+1 ))
2096 [ $? -ne 0 ] && error "process isn't sleep"
2097 start_ost2 || error "Unable to start OST2"
2098 wait $pid || error "statfs failed"
2099 stop_ost2 || error "Unable to stop OST2"
2102 umount_client $MOUNT || error "Unable to unmount client"
2103 stop_ost || error "Unable to stop OST1"
2104 stop_mds || error "Unable to stop MDS"
2105 #writeconf to remove all ost2 traces for subsequent tests
2108 run_test 50f "normal statfs one server in down =========================="
2111 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2113 start_ost2 || error "Unable to start OST2"
2115 local PARAM="${FSNAME}-OST0001.osc.active"
2117 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2118 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2120 umount_client $MOUNT || error "Unable to unmount client"
2121 mount_client $MOUNT || error "Unable to mount client"
2122 # This df should not cause a panic
2125 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2127 umount_client $MOUNT || error "Unable to unmount client"
2128 stop_ost2 || error "Unable to stop OST2"
2129 stop_ost || error "Unable to stop OST1"
2130 stop_mds || error "Unable to stop MDS"
2131 #writeconf to remove all ost2 traces for subsequent tests
2134 run_test 50g "deactivated OST should not cause panic====================="
2137 local LOCAL_TIMEOUT=20
2141 check_mount || return 1
2144 $LFS setstripe -c -1 $MOUNT/d1
2145 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2146 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2147 touch $MOUNT/d1/f1 &
2150 start_ost2 || return 2
2152 stop_ost2 || return 3
2155 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2164 do_node $node mkdir -p $dest
2165 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2167 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2168 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2169 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2171 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2172 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2182 local backup2=${TMP}/backup2
2184 do_node $node mkdir -p $backup2
2185 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2187 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2188 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2189 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2191 do_node $node "diff -rq $backup $backup2"
2192 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2194 local xattrs2=${TMP}/xattrs2
2195 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2196 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2198 do_node $node "diff $xattrs $xattrs2"
2199 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2201 do_node $node "rm -rf $backup2 $xattrs2"
2202 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2207 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2209 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2211 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2214 local ost1mnt=${MOUNT%/*}/ost1
2215 local ost1node=$(facet_active_host ost1)
2216 local ost1tmp=$TMP/conf52
2219 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2220 touch $TMP/modified_first
2221 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2222 do_node $ost1node "mkdir -p $ost1tmp && touch $ost1tmp/modified_first"
2223 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2226 $LFS setstripe $DIR/$tdir -c -1 -s 1M
2227 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2229 for (( i=0; i < nrfiles; i++ )); do
2230 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2231 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2237 echo backup files to $TMP/files
2238 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2239 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2240 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2242 umount_client $MOUNT
2243 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2245 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2247 echo mount ost1 as ldiskfs
2248 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2249 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2252 echo backup objects to $ost1tmp/objects
2253 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2254 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2255 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2256 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2258 # move objects to lost+found
2259 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2260 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2263 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2264 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2266 # compare restored objects against saved ones
2267 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2268 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2270 do_node $ost1node "umount $ost1_dev"
2271 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2274 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2276 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2279 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2280 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2282 rm -rf $TMP/files $TMP/file_xattrs
2283 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2284 do_node $ost1node "rm -rf $ost1tmp"
2285 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2288 run_test 52 "check recovering objects from lost+found"
2290 # Checks threads_min/max/started for some service
2292 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2293 # parameter pattern prefix like 'ost.*.ost'.
2305 local msg="Insane $modname thread counts"
2309 check_mount || return 41
2311 # We need to expand $parampat, but it may match multiple parameters, so
2312 # we'll pick the first one
2313 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2314 error "Couldn't expand ${parampat}.threads_min parameter name"
2318 # Remove the .threads_min part
2319 paramp=${paramp%.threads_min}
2321 # Check for sanity in defaults
2322 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2323 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2324 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2325 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2326 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= tmax ))' || return $?
2328 # Check that we can lower min/max
2329 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin - 1))"
2330 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 10))"
2331 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2332 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2333 lassert 25 "$msg" '(($tmin2 == ($tmin - 1) && $tmax2 == ($tmax -10)))' || return $?
2335 # Check that we can set min/max to the same value
2336 do_facet $facet "lctl set_param ${paramp}.threads_min=$tmin"
2337 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2338 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2339 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2340 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2342 # Check that we can't set max < min
2343 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2344 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2345 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2346 lassert 27 "$msg" '(($tmin <= $tmax2))' || return $?
2348 # We need to ensure that we get the module options desired; to do this
2349 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2350 LOAD_MODULES_REMOTE=true
2353 setmodopts -a $modname "$opts" oldvalue
2357 check_mount || return 41
2359 # Restore previous setting of MODOPTS_*
2360 setmodopts $modname "$oldvalue"
2362 # Check that $opts took
2363 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2364 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2365 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2366 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2369 # Workaround a YALA bug where YALA expects that modules will remain
2370 # loaded on the servers
2371 LOAD_MODULES_REMOTE=false
2378 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2380 run_test 53a "check OSS thread count params"
2383 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2385 run_test 53b "check MDT thread count params"
2387 if ! combined_mgs_mds ; then
2394 local partial_arg=""
2395 local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
2397 # Run in partial (fast) mode if the size
2398 # of a partition > 10 GB
2399 [ $size -gt 10 ] && partial_arg="-p"
2401 llverfs $partial_arg $dir
2405 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
2406 [ $? -eq 0 ] || error "llverdev failed!"
2409 run_test 54a "llverdev"
2414 [ $? -eq 0 ] || error "llverfs failed!"
2417 run_test 54b "llverfs"
2421 local max_ost_index=$1
2422 echo -n $(((max_ost_index + 1) * 8))
2426 local mdsdev=$(mdsdevname 1)
2427 local ostdev=$(ostdevname 1)
2428 local saved_opts=$OST_MKFS_OPTS
2430 for i in 0 1023 2048
2432 OST_MKFS_OPTS="$saved_opts --index $i"
2440 echo checking size of lov_objid for ost index $i
2441 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2442 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2443 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2445 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2450 OST_MKFS_OPTS=$saved_opts
2453 run_test 55 "check lov_objid size"
2456 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2457 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2458 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2462 start_ost2 || error "Unable to start second ost"
2463 mount_client $MOUNT || error "Unable to mount client"
2469 run_test 56 "check big indexes"
2472 equals_msg `basename $0`: test complete
2473 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true