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"
434 # Test 16 was to "verify that lustre will correct the mode of OBJECTS".
435 # But with new MDS stack we don't care about the mode of local objects
436 # anymore, so this test is removed. See bug 22944 for more details.
440 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
442 if [ ! -e "$MDSDEV" ]; then
443 echo "no $MDSDEV existing, so mount Lustre to create one"
445 check_mount || return 41
449 echo "Remove mds config log"
450 do_facet $SINGLEMDS "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
453 start_mds && return 42
456 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
459 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
461 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
466 # check if current MDSSIZE is large enough
467 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
468 log "use MDSSIZE=$MDSSIZE"
470 # check if the global config has a large enough MDSSIZE
471 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
472 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
473 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
475 # check if the block device is large enough
476 [ -z "$OK" -a -b $MDSDEV ] && \
477 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
478 awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
479 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
481 # check if a loopback device has enough space for fs metadata (5%)
482 [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
483 SPACE=$(df -P $(dirname $MDSDEV) |
484 awk '($1 != "Filesystem") {print $4}') &&
485 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
486 log "use file $MDSDEV with MIN=$MIN"
488 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
491 echo "mount mds with large journal..."
492 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
494 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
497 echo "mount lustre system..."
499 check_mount || return 41
501 echo "check journal size..."
502 local FOUNDSIZE=`do_facet mds "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
503 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
504 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
506 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
511 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
514 run_test 18 "check mkfs creates large journals"
517 start_mds || return 1
518 stop_mds -f || return 2
520 run_test 19a "start/stop MDS without OSTs"
523 start_ost || return 1
524 stop_ost -f || return 2
526 run_test 19b "start/stop OSTs without MDS"
529 # first format the ost/mdt
533 check_mount || return 43
535 remount_client ro $MOUNT || return 44
536 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
537 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
538 remount_client rw $MOUNT || return 47
540 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
541 MCNT=`grep -c $MOUNT /etc/mtab`
542 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
547 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
552 wait_osc_import_state mds ost FULL
556 run_test 21a "start mds before ost, stop ost first"
561 wait_osc_import_state mds ost FULL
565 run_test 21b "start ost before mds, stop mds first"
571 wait_osc_import_state mds ost2 FULL
575 #writeconf to remove all ost2 traces for subsequent tests
578 run_test 21c "start mds between two osts, stop mds last"
583 echo Client mount with ost in logs, but none running
585 # wait until mds connected to ost and open client connection
586 wait_osc_import_state mds ost FULL
589 # check_mount will block trying to contact ost
590 mcreate $DIR/$tfile || return 40
591 rm -f $DIR/$tfile || return 42
595 echo Client mount with a running ost
598 # if gss enabled, wait full time to let connection from
599 # mds to ost be established, due to the mismatch between
600 # initial connect timeout and gss context negotiation timeout.
601 # This perhaps could be remove after AT landed.
602 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
603 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
606 check_mount || return 41
611 run_test 22 "start a client before osts (should return errs)"
613 test_23a() { # was test_23
617 # force down client so that recovering mds waits for reconnect
618 local running=$(grep -c $MOUNT /proc/mounts) || true
619 if [ $running -ne 0 ]; then
620 echo "Stopping client $MOUNT (opts: -f)"
624 # enter recovery on mds
626 # try to start a new client
627 mount_client $MOUNT &
629 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
630 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
631 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
633 ps --ppid $MOUNT_LUSTRE_PID
634 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
635 kill -TERM $MOUNT_LUSTRE_PID
636 echo "waiting for mount to finish"
638 # we can not wait $MOUNT_PID because it is not a child of this shell
644 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
646 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
647 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
650 [ -z "$PID1" -a -z "$PID2" ] && break
651 echo "waiting for mount to finish ... "
652 WAIT=$(( WAIT + sleep))
654 if [ "$WAIT" -eq "$MAX_WAIT" ]; then
655 error "MOUNT_PID $MOUNT_PID and "\
656 "MOUNT_LUSTRE_PID $MOUNT_LUSTRE_PID still not killed in $WAIT secs"
662 run_test 23a "interrupt client during recovery mount delay"
667 test_23b() { # was test_23
670 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
671 lctl set_param fail_loc=0x80000313
675 run_test 23b "Simulate -EINTR during mount"
677 fs2mds_HOST=$mds_HOST
678 fs2ost_HOST=$ost_HOST
682 echo "umount $MOUNT2 ..."
683 umount $MOUNT2 || true
684 echo "stopping fs2mds ..."
685 stop fs2mds -f || true
686 echo "stopping fs2ost ..."
687 stop fs2ost -f || true
695 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
697 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
698 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
699 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
700 skip_env "mixed loopback and real device not working" && return
703 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
704 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
706 # test 8-char fsname as well
707 local FSNAME2=test1234
708 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
710 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
713 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
714 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
716 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
718 check_mount || return 2
719 # files written on 1 should not show up on 2
720 cp /etc/passwd $DIR/$tfile
722 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
725 cp /etc/passwd $MOUNT2/b || return 3
726 rm $MOUNT2/b || return 4
727 # 2 is actually mounted
728 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
730 facet_failover fs2mds
731 facet_failover fs2ost
734 # the MDS must remain up until last MDT
736 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
737 [ -z "$MDS" ] && error "No MDT" && return 8
739 cleanup_nocli || return 6
741 run_test 24a "Multiple MDTs on a single node"
744 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
746 if [ -z "$fs2mds_DEV" ]; then
747 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
748 skip_env "mixed loopback and real device not working" && return
751 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
753 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
755 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
758 run_test 24b "Multiple MGSs on a single node (should return err)"
762 check_mount || return 2
763 local MODULES=$($LCTL modules | awk '{ print $2 }')
764 rmmod $MODULES 2>/dev/null || true
767 run_test 25 "Verify modules are referenced"
771 # we need modules before mount for sysctl, so make sure...
772 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
773 #define OBD_FAIL_MDS_FS_SETUP 0x135
774 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
775 start_mds && echo MDS started && return 1
776 lctl get_param -n devices
777 DEVS=$(lctl get_param -n devices | wc -l)
778 [ $DEVS -gt 0 ] && return 2
779 unload_modules || return 203
781 run_test 26 "MDT startup failure cleans LOV (should return errs)"
787 local ORIG=$(do_facet $myfacet "$TEST")
788 if [ $# -gt 3 ]; then
794 echo "Setting $PARAM from $ORIG to $FINAL"
795 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
797 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
801 start_ost || return 1
802 start_mds || return 2
803 echo "Requeue thread should have started: "
804 ps -e | grep ll_cfg_requeue
805 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
808 run_test 27a "Reacquire MGS lock if OST started first"
813 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
815 facet_failover $SINGLEMDS
816 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
817 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
821 run_test 27b "Reacquire MGS lock after failover"
825 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
826 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
829 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
830 FINAL=$(($FINAL + 1))
831 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
832 umount_client $MOUNT || return 200
835 if [ $RESULT -ne $FINAL ]; then
836 echo "New config not seen: wanted $FINAL got $RESULT"
839 echo "New config success: got $RESULT"
841 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
844 run_test 28 "permanent parameter setting"
847 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
848 setup > /dev/null 2>&1
852 local PARAM="$FSNAME-OST0001.osc.active"
853 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
854 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
856 ACTV=$(lctl get_param -n $PROC_ACT)
858 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
859 # also check ost_server_uuid status
860 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
861 if [ -z "$RESULT" ]; then
862 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
865 echo "Live client success: got $RESULT"
869 local MPROC="osc.$FSNAME-OST0001-osc-[M]*.active"
874 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
875 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
876 if [ $RESULT -eq $DEAC ]; then
877 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
881 if [ $WAIT -eq $MAX ]; then
882 echo "MDT not deactivated: wanted $DEAC got $RESULT"
885 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
888 # test new client starts deactivated
889 umount_client $MOUNT || return 200
891 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
892 if [ -z "$RESULT" ]; then
893 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
896 echo "New client success: got $RESULT"
899 # make sure it reactivates
900 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
905 #writeconf to remove all ost2 traces for subsequent tests
908 run_test 29 "permanently remove an OST"
914 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
916 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
917 for i in ${LIST[@]}; do
918 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
920 # make sure client restart still works
922 mount_client $MOUNT || return 4
923 [ "$($TEST)" -ne "$i" ] && error "Param didn't stick across restart $($TEST) != $i"
926 echo Erase parameter setting
927 do_facet mgs "$LCTL conf_param -d $FSNAME.llite.max_read_ahead_whole_mb" || return 6
929 mount_client $MOUNT || return 6
931 echo "deleted (default) value=$FINAL, orig=$ORIG"
932 # assumes this parameter started at the default value
933 [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
937 run_test 30a "Big config llog and conf_param deletion"
942 # Make a fake nid. Use the OST nid, and add 20 to the least significant
943 # numerical part of it. Hopefully that's not already a failover address for
945 OSTNID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
946 ORIGVAL=$(echo $OSTNID | egrep -oi "[0-9]*@")
947 NEWVAL=$((($(echo $ORIGVAL | egrep -oi "[0-9]*") + 20) % 256))
948 NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
949 echo "Using fake nid $NEW"
951 TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
952 set_and_check client "$TEST" "$FSNAME-OST0000.failover.node" $NEW || error "didn't add failover nid $NEW"
953 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
955 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
956 echo "should have 2 failover nids: $NIDCOUNT"
957 [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
958 do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
960 mount_client $MOUNT || return 3
962 NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
964 NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
965 echo "only 1 final nid should remain: $NIDCOUNT"
966 [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
970 run_test 30b "Remove failover nids"
972 test_31() { # bug 10734
973 # ipaddr must not exist
974 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
977 run_test 31 "Connect to non-existent node (shouldn't crash)"
979 # Use these start32/stop32 fn instead of t-f start/stop fn,
980 # for local devices, to skip global facet vars init
984 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
985 umount -d $@ ${MOUNT%/*}/${facet}
994 mkdir -p ${MOUNT%/*}/${facet}
996 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
997 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
999 if [ $RC -ne 0 ]; then
1000 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
1001 echo "Start of ${device} of local ${facet} failed ${RC}"
1007 cleanup_nocli32 () {
1015 echo "Cleanup test_32 umount $MOUNT ..."
1016 umount -f $MOUNT || true
1017 echo "Cleanup local mds ost1 ..."
1023 client_only && skip "client only testing" && return 0
1024 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1025 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
1027 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1028 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1029 local tmpdir=$TMP/conf32a
1031 tar xjvf $DISK1_8 -C $tmpdir || \
1032 { skip_env "Cannot untar $DISK1_8" && return 0; }
1035 $LCTL set_param debug=$PTLDEBUG
1037 $TUNEFS $tmpdir/mds || error "tunefs failed"
1039 # nids are wrong, so client wont work, but server should start
1040 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1041 trap cleanup_32 EXIT INT || return 3
1043 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
1045 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1047 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1048 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1049 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1051 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1053 local NID=$($LCTL list_nids | head -1)
1055 echo "OSC changes should succeed:"
1056 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1057 $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
1060 echo "MDC changes should succeed:"
1061 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1062 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1065 echo "LOV changes should succeed:"
1066 $LCTL pool_new lustre.interop || return 11
1067 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1072 # mount a second time to make sure we didnt leave upgrade flag on
1074 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1075 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1076 trap cleanup_32 EXIT INT || return 12
1080 rm -rf $tmpdir || true # true is only for TMP on NFS
1082 run_test 32a "Upgrade from 1.8 (not live)"
1085 client_only && skip "client only testing" && return 0
1086 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1087 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1089 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1090 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1091 local tmpdir=$TMP/conf32b
1093 tar xjvf $DISK1_8 -C $tmpdir || \
1094 { skip_env "Cannot untar $DISK1_8" && return ; }
1097 $LCTL set_param debug="config"
1098 local NEWNAME=lustre
1100 # writeconf will cause servers to register with their current nids
1101 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1102 start32 mds1 $tmpdir/mds "-o loop" && \
1103 trap cleanup_32 EXIT INT || return 3
1105 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1107 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1109 $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 ||\
1110 error "tunefs failed"
1111 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1112 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1114 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1116 local NID=$($LCTL list_nids | head -1)
1118 echo "OSC changes should succeed:"
1119 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1120 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1123 echo "MDC changes should succeed:"
1124 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1125 $LCTL conf_param ${NEWNAME}-MDT0000.failover.node=$NID || return 10
1128 echo "LOV changes should succeed:"
1129 $LCTL pool_new ${NEWNAME}.interop || return 11
1130 $LCTL conf_param ${NEWNAME}-MDT0000.lov.stripesize=4M || return 12
1133 # MDT and OST should have registered with new nids, so we should have
1134 # a fully-functioning client
1135 echo "Check client and old fs contents"
1137 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1138 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1139 mount -t lustre $device $MOUNT || return 1
1141 local old=$($LCTL get_param -n mdc.*.max_rpcs_in_flight)
1142 local new=$((old + 5))
1143 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1144 wait_update $HOSTNAME "$LCTL get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1146 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1151 rm -rf $tmpdir || true # true is only for TMP on NFS
1153 run_test 32b "Upgrade from 1.8 with writeconf"
1155 test_33a() { # bug 12333, was test_33
1157 local FSNAME2=test-123
1158 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1160 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1162 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1163 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1164 skip_env "mixed loopback and real device not working" && return
1167 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1168 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1169 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1170 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1172 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1173 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1174 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1176 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1179 cp /etc/hosts $MOUNT2/ || rc=3
1180 $LFS getstripe $MOUNT2/hosts
1185 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1186 cleanup_nocli || rc=6
1189 run_test 33a "Mount ost with a large index number"
1191 test_33b() { # was test_34
1194 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1195 # Drop lock cancelation reply during umount
1196 #define OBD_FAIL_LDLM_CANCEL 0x304
1197 do_facet client lctl set_param fail_loc=0x80000304
1198 #lctl set_param debug=-1
1199 umount_client $MOUNT
1202 run_test 33b "Drop cancel during umount"
1206 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1207 manual_umount_client
1209 do_facet client killall -USR1 multiop
1210 if [ $rc -eq 0 ]; then
1211 error "umount not fail!"
1216 run_test 34a "umount with opened file should be fail"
1221 touch $DIR/$tfile || return 1
1222 stop_mds --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 34b "force umount with failed mds should be normal"
1237 touch $DIR/$tfile || return 1
1238 stop_ost --force || return 2
1240 manual_umount_client --force
1242 if [ $rc -ne 0 ]; then
1243 error "mtab after failed umount - rc $rc"
1249 run_test 34c "force umount with failed ost should be normal"
1251 test_35a() { # bug 12459
1254 DBG_SAVE="`lctl get_param -n debug`"
1255 lctl set_param debug="ha"
1257 log "Set up a fake failnode for the MDS"
1259 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1260 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1262 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1265 MSG="conf-sanity.sh test_35a `date +%F%kh%Mm%Ss`"
1268 log "Stopping the MDT:"
1269 stop_mds || return 5
1271 df $MOUNT > /dev/null 2>&1 &
1273 log "Restarting the MDT:"
1274 start_mds || return 6
1275 log "Wait for df ($DFPID) ... "
1278 lctl set_param debug="$DBG_SAVE"
1280 # retrieve from the log the first server that the client tried to
1281 # contact after the connection loss
1282 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1283 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1284 /import_select_connection.*$device-mdc.* using connection/ {
1286 if (\\\$NF ~ /$FAKENID/)
1292 }" $TMP/lustre-log-$TESTNAME.log`
1293 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1295 # remove nid settings
1298 run_test 35a "Reconnect to the last active server first"
1300 test_35b() { # bug 18674
1301 remote_mds || { skip "local MDS" && return 0; }
1305 $LCTL set_param debug="ha"
1307 MSG="conf-sanity.sh test_35b `date +%F%kh%Mm%Ss`"
1310 log "Set up a fake failnode for the MDS"
1312 local device=$(do_facet mds "$LCTL get_param -n devices" | \
1313 awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1314 do_facet mds "$LCTL conf_param ${device}.failover.node=$FAKENID" || \
1317 local at_max_saved=0
1318 # adaptive timeouts may prevent seeing the issue
1319 if at_is_enabled; then
1320 at_max_saved=$(at_max_get mds)
1321 at_max_set 0 mds client
1324 mkdir -p $MOUNT/testdir
1325 touch $MOUNT/testdir/test
1327 log "Injecting EBUSY on MDS"
1328 # Setting OBD_FAIL_MDS_RESEND=0x136
1329 do_facet mds "$LCTL set_param fail_loc=0x80000136" || return 2
1331 log "Stat on a test file"
1332 stat $MOUNT/testdir/test
1334 log "Stop injecting EBUSY on MDS"
1335 do_facet mds "$LCTL set_param fail_loc=0" || return 3
1336 rm -f $MOUNT/testdir/test
1339 # restore adaptive timeout
1340 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds client
1342 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1344 # retrieve from the log if the client has ever tried to
1345 # contact the fake server after the loss of connection
1346 FAILCONN=`awk "BEGIN {ret = 0;}
1347 /import_select_connection.*${FSNAME}-MDT0000-mdc.* using connection/ {
1349 if (\\\$NF ~ /$FAKENID/) {
1354 END {print ret}" $TMP/lustre-log-$TESTNAME.log`
1356 [ "$FAILCONN" == "0" ] && \
1357 log "ERROR: The client reconnection has not been triggered" && \
1359 [ "$FAILCONN" == "2" ] && \
1360 log "ERROR: The client tried to reconnect to the failover server while the primary was busy" && \
1364 # remove nid settings
1367 run_test 35b "Continue reconnection retries, if the active server is busy"
1371 local FSNAME2=test1234
1372 local fs3ost_HOST=$ost_HOST
1373 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1375 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1378 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1379 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1380 skip_env "mixed loopback and real device not working" && return
1382 [ $OSTCOUNT -lt 2 ] && skip_env "skipping test for single OST" && return
1384 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1385 { skip "remote OST" && return 0; }
1387 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1388 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1389 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1390 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1391 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1393 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1394 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1396 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1397 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1398 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1400 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1402 sleep 5 # until 11778 fixed
1404 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1406 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1407 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1408 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1409 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1410 DFTOTAL=`echo $STRING | cut -d, -f1`
1411 DFUSED=`echo $STRING | cut -d, -f2`
1412 DFAVAIL=`echo $STRING | cut -d, -f3`
1413 DFFREE=$(($DFTOTAL - $DFUSED))
1415 ALLOWANCE=$((64 * $OSTCOUNT))
1417 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1418 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1419 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1422 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1423 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1424 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1427 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1428 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1429 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1434 stop fs3ost -f || return 200
1435 stop fs2ost -f || return 201
1436 stop fs2mds -f || return 202
1437 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1438 unload_modules || return 203
1441 run_test 36 "df report consistency on OSTs with different block size"
1444 client_only && skip "client only testing" && return 0
1445 LOCAL_MDSDEV="$TMP/mdt.img"
1446 SYM_MDSDEV="$TMP/sym_mdt.img"
1448 echo "MDS : $LOCAL_MDSDEV"
1449 echo "SYMLINK : $SYM_MDSDEV"
1453 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1454 error "mkfs.lustre $LOCAL_MDSDEV failed"
1455 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1457 echo "mount symlink device - $SYM_MDSDEV"
1459 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1460 umount -d ${MOUNT%/*}/mds
1461 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1463 if [ -n "$mount_op" ]; then
1464 error "**** FAIL: set tunables failed for symlink device"
1468 run_test 37 "verify set tunables works for symlink device"
1470 test_38() { # bug 14222
1475 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1476 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1478 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1479 error "copying $SRC to $DIR/$tdir"
1481 umount_client $MOUNT
1483 log "rename lov_objid file on MDS"
1484 rm -f $TMP/lov_objid.orig
1486 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1487 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1488 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1490 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1491 # check create in mds_lov_connect
1495 [ $V ] && log "verifying $DIR/$tdir/$f"
1496 diff -q $f $DIR/$tdir/$f || ERROR=y
1498 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1499 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1500 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1502 # check it's updates in sync
1503 umount_client $MOUNT
1506 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1507 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1508 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1513 [ $V ] && log "verifying $DIR/$tdir/$f"
1514 diff -q $f $DIR/$tdir/$f || ERROR=y
1516 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1517 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1518 umount_client $MOUNT
1520 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1522 log "files compared the same"
1525 run_test 38 "MDS recreates missing lov_objid file from OST data"
1531 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1532 error "memory leak detected" || true
1534 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1536 test_40() { # bug 15759
1538 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1539 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1543 run_test 40 "race during service thread startup"
1545 test_41() { #bug 14134
1547 local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
1549 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1550 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1551 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
1553 mount_client $MOUNT || return 1
1556 echo "blah blah" > $MOUNT/$tfile
1559 umount_client $MOUNT
1560 stop ost1 -f || return 201
1561 stop_mds -f || return 202
1562 stop_mds -f || return 203
1563 unload_modules || return 204
1566 run_test 41 "mount mds with --nosvc and --nomgs"
1568 test_42() { #bug 14693
1570 check_mount || return 2
1571 do_facet mgs $LCTL conf_param lustre.llite.some_wrong_param=10
1572 umount_client $MOUNT
1573 mount_client $MOUNT || return 1
1577 run_test 42 "invalid config param should not prevent client from mounting"
1580 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
1582 chmod ugo+x $DIR || error "chmod 0 failed"
1584 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1585 "$FSNAME.mdt.root_squash" \
1588 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1589 "$FSNAME.mdt.nosquash_nids" \
1593 # create set of test files
1595 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1596 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1597 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1599 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1600 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1602 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1603 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1604 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1607 # check root_squash:
1608 # set root squash UID:GID to RUNAS_ID
1609 # root should be able to access only files owned by RUNAS_ID
1612 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1613 "$FSNAME.mdt.root_squash" \
1614 "$RUNAS_ID:$RUNAS_ID"
1616 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1617 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1618 error "$ST: root read permission is denied"
1619 echo "$ST: root read permission is granted - ok"
1622 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1623 error "$ST: root write permission is denied"
1624 echo "$ST: root write permission is granted - ok"
1626 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1627 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1628 error "$ST: root read permission is granted"
1629 echo "$ST: root read permission is denied - ok"
1632 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1633 error "$ST: root write permission is granted"
1634 echo "$ST: root write permission is denied - ok"
1636 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1637 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1638 error "$ST: root unlink permission is granted"
1639 echo "$ST: root unlink permission is denied - ok"
1641 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1642 error "$ST: root create permission is granted"
1643 echo "$ST: root create permission is denied - ok"
1646 # check nosquash_nids:
1647 # put client's NID into nosquash_nids list,
1648 # root should be able to access root file after that
1650 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1651 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1652 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1654 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1655 "$FSNAME-MDTall.mdt.nosquash_nids" \
1658 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1659 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1660 error "$ST: root read permission is denied"
1661 echo "$ST: root read permission is granted - ok"
1664 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1665 error "$ST: root write permission is denied"
1666 echo "$ST: root write permission is granted - ok"
1668 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1669 rm $DIR/$tdir-rootdir/tfile-1 || \
1670 error "$ST: root unlink permission is denied"
1671 echo "$ST: root unlink permission is granted - ok"
1672 touch $DIR/$tdir-rootdir/tfile-2 || \
1673 error "$ST: root create permission is denied"
1674 echo "$ST: root create permission is granted - ok"
1678 run_test 43 "check root_squash and nosquash_nids"
1680 umount_client $MOUNT
1685 check_mount || return 2
1686 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1688 UUIDS=$(do_facet mds "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1689 for VAL in $UUIDS; do
1690 NID=$(echo $VAL | cut -d= -f1)
1691 CLUUID=$(echo $VAL | cut -d= -f2)
1692 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1694 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1698 run_test 44 "mounted client proc entry exists"
1702 check_mount || return 2
1707 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1708 do_facet client "lctl set_param fail_loc=0x50f"
1711 manual_umount_client --force || return 3
1712 do_facet client "lctl set_param fail_loc=0x0"
1714 mount_client $MOUNT || return 4
1718 run_test 45 "long unlink handling in ptlrpcd"
1725 umount_client $MOUNT2 || rc=$?
1726 umount_client $MOUNT || rc=$?
1727 while [ $count -gt 0 ]; do
1728 stop ost${count} -f || rc=$?
1732 cleanup_nocli || rc=$?
1733 #writeconf to remove all ost2 traces for subsequent tests
1739 echo "Testing with $OSTCOUNT OSTs"
1741 start_mds || return 1
1742 #first client should see only one ost
1743 start_ost || return 2
1744 wait_osc_import_state mds ost FULL
1746 mount_client $MOUNT || return 3
1747 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1750 for (( i=2; i<=$OSTCOUNT; i++ )); do
1751 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1754 # wait until osts in sync
1755 for (( i=2; i<=$OSTCOUNT; i++ )); do
1756 wait_osc_import_state mds ost$i FULL
1760 #second client see all ost's
1762 mount_client $MOUNT2 || return 8
1763 $LFS setstripe $MOUNT2 -c -1 || return 9
1764 $LFS getstripe $MOUNT2 || return 10
1766 echo "ok" > $MOUNT2/widestripe
1767 $LFS getstripe $MOUNT2/widestripe || return 11
1768 # fill acl buffer for avoid expand lsm to them
1769 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1770 setfacl -m $acl $MOUNT2/widestripe
1774 stat $MOUNT/widestripe || return 12
1776 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1779 run_test 46a "handle ost additional - wide striped file"
1784 check_mount || return 2
1785 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1789 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1790 if echo $ns | grep "MDT[[:digit:]]*"; then
1793 lrs=$(echo $ns | sed 's/.*lru_size=//')
1794 lru_size[count]=$lrs
1799 facet_failover $SINGLEMDS
1800 client_up || return 3
1803 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1804 if echo $ns | grep "MDT[[:digit:]]*"; then
1807 lrs=$(echo $ns | sed 's/.*lru_size=//')
1808 if ! test "$lrs" -eq "${lru_size[count]}"; then
1809 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1810 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1818 run_test 47 "server restart does not make client loss lru_resize settings"
1823 # reformat after this test is needed - if test will failed
1824 # we will have unkillable file at FS
1828 test_48() { # bug 17636
1831 check_mount || return 2
1833 $LFS setstripe $MOUNT -c -1 || return 9
1834 $LFS getstripe $MOUNT || return 10
1836 echo "ok" > $MOUNT/widestripe
1837 $LFS getstripe $MOUNT/widestripe || return 11
1839 trap cleanup_48 EXIT ERR
1841 # fill acl buffer for avoid expand lsm to them
1842 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1843 setfacl -m $acl $MOUNT/widestripe
1846 stat $MOUNT/widestripe || return 12
1851 run_test 48 "too many acls on file"
1853 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1854 test_49() { # bug 17710
1855 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1856 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1857 local LOCAL_TIMEOUT=20
1860 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1864 check_mount || return 1
1866 echo "check ldlm_timout..."
1867 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1868 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1869 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1871 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1872 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1875 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1876 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1879 umount_client $MOUNT
1880 stop_ost || return 2
1881 stop_mds || return 3
1883 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"
1887 check_mount || return 7
1889 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1890 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1891 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1893 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1894 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1897 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1898 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1901 cleanup || return $?
1903 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1904 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1906 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1909 # Test both statfs and lfs df and fail if either one fails
1910 multiop_bg_pause $1 f_
1913 killall -USR1 multiop
1914 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
1915 wait $PID || { RC1=$?; log "multiop return error "; }
1922 if [ $RC2 -eq 0 ]; then
1924 log "lazystatfs df failed"
1928 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
1934 lctl set_param llite.$FSNAME-*.lazystatfs=1
1937 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
1939 cleanup || return $?
1941 run_test 50a "lazystatfs all servers available =========================="
1945 lctl set_param llite.$FSNAME-*.lazystatfs=1
1948 # Wait for client to detect down OST
1949 stop_ost || error "Unable to stop OST1"
1950 wait_osc_import_state mds ost DISCONN
1952 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
1954 umount_client $MOUNT || error "Unable to unmount client"
1955 stop_mds || error "Unable to stop MDS"
1957 run_test 50b "lazystatfs all servers down =========================="
1960 start_mds || error "Unable to start MDS"
1961 start_ost || error "Unable to start OST1"
1962 start_ost2 || error "Unable to start OST2"
1963 mount_client $MOUNT || error "Unable to mount client"
1964 lctl set_param llite.$FSNAME-*.lazystatfs=1
1967 # Wait for client to detect down OST
1968 stop_ost || error "Unable to stop OST1"
1969 wait_osc_import_state mds ost DISCONN
1970 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1972 umount_client $MOUNT || error "Unable to unmount client"
1973 stop_ost2 || error "Unable to stop OST2"
1974 stop_mds || error "Unable to stop MDS"
1976 run_test 50c "lazystatfs one server down =========================="
1979 start_mds || error "Unable to start MDS"
1980 start_ost || error "Unable to start OST1"
1981 start_ost2 || error "Unable to start OST2"
1982 mount_client $MOUNT || error "Unable to mount client"
1983 lctl set_param llite.$FSNAME-*.lazystatfs=1
1986 # Issue the statfs during the window where the client still
1987 # belives the OST to be available but it is in fact down.
1988 # No failure just a statfs which hangs for a timeout interval.
1989 stop_ost || error "Unable to stop OST1"
1990 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1992 umount_client $MOUNT || error "Unable to unmount client"
1993 stop_ost2 || error "Unable to stop OST2"
1994 stop_mds || error "Unable to stop MDS"
1996 run_test 50d "lazystatfs client/server conn race =========================="
2003 start_mds || return 1
2004 #first client should see only one ost
2005 start_ost || return 2
2006 wait_osc_import_state mds ost FULL
2008 # Wait for client to detect down OST
2009 stop_ost || error "Unable to stop OST1"
2010 wait_osc_import_state mds ost DISCONN
2012 mount_client $MOUNT || error "Unable to mount client"
2013 lctl set_param llite.$FSNAME-*.lazystatfs=0
2015 multiop_bg_pause $MOUNT _f
2019 if [ $RC1 -ne 0 ]; then
2020 log "multiop failed $RC1"
2023 sleep $(( $TIMEOUT+1 ))
2025 [ $? -ne 0 ] && error "process isn't sleep"
2026 start_ost || error "Unable to start OST1"
2027 wait $pid || error "statfs failed"
2030 umount_client $MOUNT || error "Unable to unmount client"
2031 stop_ost || error "Unable to stop OST1"
2032 stop_mds || error "Unable to stop MDS"
2034 run_test 50e "normal statfs all servers down =========================="
2039 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
2041 start_mds || error "Unable to start mds"
2042 #first client should see only one ost
2043 start_ost || error "Unable to start OST1"
2044 wait_osc_import_state mds ost FULL
2046 start_ost2 || error "Unable to start OST2"
2047 wait_osc_import_state mds ost2 FULL
2049 # Wait for client to detect down OST
2050 stop_ost2 || error "Unable to stop OST2"
2052 wait_osc_import_state mds ost2 DISCONN
2053 mount_client $MOUNT || error "Unable to mount client"
2054 lctl set_param llite.$FSNAME-*.lazystatfs=0
2056 multiop_bg_pause $MOUNT _f
2060 if [ $RC1 -ne 0 ]; then
2061 log "lazystatfs multiop failed $RC1"
2064 sleep $(( $TIMEOUT+1 ))
2066 [ $? -ne 0 ] && error "process isn't sleep"
2067 start_ost2 || error "Unable to start OST2"
2068 wait $pid || error "statfs failed"
2069 stop_ost2 || error "Unable to stop OST2"
2072 umount_client $MOUNT || error "Unable to unmount client"
2073 stop_ost || error "Unable to stop OST1"
2074 stop_mds || error "Unable to stop MDS"
2075 #writeconf to remove all ost2 traces for subsequent tests
2078 run_test 50f "normal statfs one server in down =========================="
2081 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
2083 start_ost2 || error "Unable to start OST2"
2085 local PARAM="${FSNAME}-OST0001.osc.active"
2087 $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
2088 do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
2090 umount_client $MOUNT || error "Unable to unmount client"
2091 mount_client $MOUNT || error "Unable to mount client"
2092 # This df should not cause a panic
2095 do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
2097 umount_client $MOUNT || error "Unable to unmount client"
2098 stop_ost2 || error "Unable to stop OST2"
2099 stop_ost || error "Unable to stop OST1"
2100 stop_mds || error "Unable to stop MDS"
2101 #writeconf to remove all ost2 traces for subsequent tests
2104 run_test 50g "deactivated OST should not cause panic====================="
2107 local LOCAL_TIMEOUT=20
2111 check_mount || return 1
2114 $LFS setstripe -c -1 $MOUNT/d1
2115 #define OBD_FAIL_MDS_REINT_DELAY 0x142
2116 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
2117 touch $MOUNT/d1/f1 &
2120 start_ost2 || return 2
2122 stop_ost2 || return 3
2125 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
2134 do_node $node mkdir -p $dest
2135 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2137 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
2138 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2139 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2141 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2142 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2152 local backup2=${TMP}/backup2
2154 do_node $node mkdir -p $backup2
2155 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2157 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2158 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2159 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2161 do_node $node "diff -rq $backup $backup2"
2162 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2164 local xattrs2=${TMP}/xattrs2
2165 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2166 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2168 do_node $node "diff $xattrs $xattrs2"
2169 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2171 do_node $node "rm -rf $backup2 $xattrs2"
2172 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2177 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2179 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2181 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2184 local ost1mnt=${MOUNT%/*}/ost1
2185 local ost1node=$(facet_active_host ost1)
2186 local ost1tmp=$TMP/conf52
2189 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2190 touch $TMP/modified_first
2191 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2192 do_node $ost1node "mkdir -p $ost1tmp && touch $ost1tmp/modified_first"
2193 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2196 $LFS setstripe $DIR/$tdir -c -1 -s 1M
2197 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2199 for (( i=0; i < nrfiles; i++ )); do
2200 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2201 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2207 echo backup files to $TMP/files
2208 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2209 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2210 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2212 umount_client $MOUNT
2213 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2215 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2217 echo mount ost1 as ldiskfs
2218 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2219 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2222 echo backup objects to $ost1tmp/objects
2223 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2224 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2225 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2226 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2228 # move objects to lost+found
2229 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2230 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2233 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2234 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2236 # compare restored objects against saved ones
2237 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2238 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2240 do_node $ost1node "umount $ost1_dev"
2241 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2244 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2246 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2249 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2250 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2252 rm -rf $TMP/files $TMP/file_xattrs
2253 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2254 do_node $ost1node "rm -rf $ost1tmp"
2255 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2258 run_test 52 "check recovering objects from lost+found"
2260 # Checks threads_min/max/started for some service
2262 # Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
2263 # parameter pattern prefix like 'ost.*.ost'.
2275 local msg="Insane $modname thread counts"
2279 check_mount || return 41
2281 # We need to expand $parampat, but it may match multiple parameters, so
2282 # we'll pick the first one
2283 if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
2284 error "Couldn't expand ${parampat}.threads_min parameter name"
2288 # Remove the .threads_min part
2289 paramp=${paramp%.threads_min}
2291 # Check for sanity in defaults
2292 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2293 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2294 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
2295 lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
2296 lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= tmax ))' || return $?
2298 # Check that we can lower min/max
2299 do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin - 1))"
2300 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 10))"
2301 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2302 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2303 lassert 25 "$msg" '(($tmin2 == ($tmin - 1) && $tmax2 == ($tmax -10)))' || return $?
2305 # Check that we can set min/max to the same value
2306 do_facet $facet "lctl set_param ${paramp}.threads_min=$tmin"
2307 do_facet $facet "lctl set_param ${paramp}.threads_max=$tmin"
2308 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2309 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2310 lassert 26 "$msg" '(($tmin2 == $tmin && $tmax2 == $tmin))' || return $?
2312 # Check that we can't set max < min
2313 do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
2314 tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
2315 tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
2316 lassert 27 "$msg" '(($tmin <= $tmax2))' || return $?
2318 # We need to ensure that we get the module options desired; to do this
2319 # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
2320 LOAD_MODULES_REMOTE=true
2323 setmodopts -a $modname "$opts" oldvalue
2327 check_mount || return 41
2329 # Restore previous setting of MODOPTS_*
2330 setmodopts $modname "$oldvalue"
2332 # Check that $opts took
2333 tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
2334 tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
2335 tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
2336 lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
2339 # Workaround a YALA bug where YALA expects that modules will remain
2340 # loaded on the servers
2341 LOAD_MODULES_REMOTE=false
2348 thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
2350 run_test 53a "check OSS thread count params"
2353 thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
2355 run_test 53b "check MDT thread count params"
2357 if ! combined_mgs_mds ; then
2364 local partial_arg=""
2365 local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
2367 # Run in partial (fast) mode if the size
2368 # of a partition > 10 GB
2369 [ $size -gt 10 ] && partial_arg="-p"
2371 llverfs $partial_arg $dir
2375 do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
2376 [ $? -eq 0 ] || error "llverdev failed!"
2379 run_test 54a "llverdev"
2384 [ $? -eq 0 ] || error "llverfs failed!"
2387 run_test 54b "llverfs"
2391 local max_ost_index=$1
2392 echo -n $(((max_ost_index + 1) * 8))
2396 local mdsdev=$(mdsdevname 1)
2397 local ostdev=$(ostdevname 1)
2398 local saved_opts=$OST_MKFS_OPTS
2400 for i in 0 1023 2048
2402 OST_MKFS_OPTS="$saved_opts --index $i"
2410 echo checking size of lov_objid for ost index $i
2411 LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
2412 if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
2413 error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
2415 echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
2420 OST_MKFS_OPTS=$saved_opts
2423 run_test 55 "check lov_objid size"
2426 add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
2427 add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
2428 add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
2432 start_ost2 || error "Unable to start second ost"
2433 mount_client $MOUNT || error "Unable to mount client"
2439 run_test 56 "check big indexes"
2442 equals_msg `basename $0`: test complete
2443 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true