3 # add uml1 uml2 uml3 in your /etc/hosts
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: 13739 19280
15 HEAD_EXCEPT=" 32a 50e 50f"
17 # bug number for skipped test:
18 ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT $HEAD_EXCEPT"
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
22 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
24 PTLDEBUG=${PTLDEBUG:--1}
26 LUSTRE=${LUSTRE:-`dirname $0`/..}
27 RLUSTRE=${RLUSTRE:-$LUSTRE}
29 . $LUSTRE/tests/test-framework.sh
31 # STORED_MDSSIZE is used in test_18
32 if [ -n "$MDSSIZE" ]; then
33 STORED_MDSSIZE=$MDSSIZE
35 # use small MDS + OST size to speed formatting time
38 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
40 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
41 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
44 [ "$SLOW" = "no" ] && EXCEPT_SLOW="0 1 2 3 6 7 15 18 24b 25 30 31 32 33 34a 45"
53 local facet=$SINGLEMDS
54 local dev=${facet}_dev
58 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
59 do_facet ${facet} "$TUNEFS --writeconf ${!dev}" || echo "tunefs failed, reformatting instead" && reformat
65 # The MGS must be started before the OSTs for a new fs, so start
66 # and stop to generate the startup logs.
69 wait_osc_import_state mds ost FULL
74 reformat_and_config() {
80 local facet=$SINGLEMDS
81 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
82 local num=$(echo $facet | tr -d "mds")
83 local dev=$(mdsdevname $num)
84 echo "start mds service on `facet_active_host $facet`"
85 start $facet ${dev} $MDS_MOUNT_OPTS || return 94
89 echo "stop mds service on `facet_active_host $SINGLEMDS`"
90 # These tests all use non-failover stop
91 stop $SINGLEMDS -f || return 97
95 echo "start ost1 service on `facet_active_host ost1`"
96 start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95
100 echo "stop ost1 service on `facet_active_host ost1`"
101 # These tests all use non-failover stop
102 stop ost1 -f || return 98
106 echo "start ost2 service on `facet_active_host ost2`"
107 start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92
111 echo "stop ost2 service on `facet_active_host ost2`"
112 # These tests all use non-failover stop
113 stop ost2 -f || return 93
118 echo "mount $FSNAME on ${MOUNTPATH}....."
119 zconf_mount `hostname` $MOUNTPATH || return 96
123 local SAVEMOUNTOPT=$MOUNTOPT
124 MOUNTOPT="remount,$1"
126 echo "remount '$1' lustre on ${MOUNTPATH}....."
127 zconf_mount `hostname` $MOUNTPATH || return 96
128 MOUNTOPT=$SAVEMOUNTOPT
133 echo "umount lustre on ${MOUNTPATH}....."
134 zconf_umount `hostname` $MOUNTPATH || return 97
137 manual_umount_client(){
140 echo "manual umount lustre on ${MOUNT}...."
141 do_facet client "umount -d ${FORCE} $MOUNT"
159 stop_mds || return 201
160 stop_ost || return 202
161 unload_modules || return 203
165 umount_client $MOUNT || return 200
166 cleanup_nocli || return $?
170 do_facet client "cp /etc/passwd $DIR/a" || return 71
171 do_facet client "rm $DIR/a" || return 72
172 # make sure lustre is actually mounted (touch will block,
173 # but grep won't, so do it after)
174 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
175 echo "setup single mount lustre success"
179 do_facet client "touch $DIR/a" || return 71
180 do_facet client "rm $DIR/a" || return 72
181 do_facet client "touch $DIR2/a" || return 73
182 do_facet client "rm $DIR2/a" || return 74
183 echo "setup double mount lustre success"
188 if [ "$ONLY" == "setup" ]; then
193 if [ "$ONLY" == "cleanup" ]; then
200 #create single point mountpoint
206 check_mount || return 41
209 run_test 0 "single mount setup"
213 echo "start ost second time..."
215 check_mount || return 42
218 run_test 1 "start up ost twice (should return errors)"
223 echo "start mds second time.."
226 check_mount || return 43
229 run_test 2 "start up mds twice (should return err)"
233 #mount.lustre returns an error if already in mtab
234 mount_client $MOUNT && return $?
235 check_mount || return 44
238 run_test 3 "mount client twice (should return err)"
242 touch $DIR/$tfile || return 85
246 # ok for ost to fail shutdown
247 if [ 202 -ne $eno ]; then
252 run_test 4 "force cleanup ost, then cleanup"
254 test_5a() { # was test_5
256 touch $DIR/$tfile || return 1
257 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
259 stop_mds -f || return 2
261 # cleanup may return an error from the failed
262 # disconnects; for now I'll consider this successful
263 # if all the modules have unloaded.
267 echo "killing umount"
268 kill -TERM $UMOUNT_PID
269 echo "waiting for umount to finish"
271 if grep " $MOUNT " /proc/mounts; then
272 echo "test 5: /proc/mounts after failed umount"
276 echo "killing umount"
277 kill -TERM $UMOUNT_PID
278 echo "waiting for umount to finish"
280 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
284 # stop_mds is a no-op here, and should not fail
285 cleanup_nocli || return $?
286 # df may have lingering entry
288 # mtab may have lingering entry
292 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
294 grep -q $MOUNT" " /etc/mtab || break
295 echo "Waiting /etc/mtab updated ... "
296 WAIT=$(( WAIT + sleep))
298 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
299 echo "/etc/mtab updated in $WAIT secs"
301 run_test 5a "force cleanup mds, then cleanup"
305 [ -d $MOUNT ] || mkdir -p $MOUNT
306 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
307 mount_client $MOUNT && return 1
308 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
310 # stop_mds is a no-op here, and should not fail
311 cleanup_nocli || return $?
314 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
319 [ -d $MOUNT ] || mkdir -p $MOUNT
320 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
321 local oldfs="${FSNAME}"
322 FSNAME="wrong.${FSNAME}"
323 mount_client $MOUNT || :
325 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
327 cleanup_nocli || return $?
329 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
335 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
336 mount_client $MOUNT || return 1
338 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
341 run_test 5d "mount with ost down"
347 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
348 do_facet client "lctl set_param fail_loc=0x80000506"
349 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
350 mount_client $MOUNT || echo "mount failed (not fatal)"
352 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
355 run_test 5e "delayed connect, don't crash (bug 10268)"
360 mount_client ${MOUNT} || return 87
361 touch $DIR/a || return 86
364 run_test 6 "manual umount, then mount again"
369 cleanup_nocli || return $?
371 run_test 7 "manual umount, then cleanup"
376 check_mount2 || return 45
377 umount_client $MOUNT2
380 run_test 8 "double mount setup"
385 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
386 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
388 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
389 if [ "$CHECK_PTLDEBUG" ] && { \
390 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
391 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
392 echo "lnet.debug success"
394 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
397 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
398 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
399 echo "lnet.subsystem_debug success"
401 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
404 stop_ost || return $?
407 run_test 9 "test ptldebug and subsystem for mkfs"
409 # LOGS/PENDING do not exist anymore since CMD3
411 local TMPMTPT="${TMP}/conf16"
412 local dev=${SINGLEMDS}_dev
414 if [ ! -e "$MDSDEV" ]; then
415 log "no $MDSDEV existing, so mount Lustre to create one"
417 check_mount || return 41
421 [ -f "$MDSDEV" ] && LOOPOPT="-o loop"
423 log "change the mode of $MDSDEV/OBJECTS to 555"
424 do_facet $SINGLEMDS "mkdir -p $TMPMTPT &&
425 mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
426 chmod 555 $TMPMTPT/OBJECTS &&
427 umount $TMPMTPT" || return $?
429 log "mount Lustre to change the mode of OBJECTS, then umount Lustre"
431 check_mount || return 41
434 log "read the mode of OBJECTS and check if they has been changed properly"
435 EXPECTEDOBJECTSMODE=`do_facet $SINGLEMDS "$DEBUGFS -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
437 if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
438 log "Success:Lustre change the mode of OBJECTS correctly"
440 error "Lustre does not change mode of OBJECTS properly"
443 run_test 16 "verify that lustre will correct the mode of OBJECTS"
446 local dev=${SINGLEMDS}_dev
449 if [ ! -e "$MDSDEV" ]; then
450 echo "no $MDSDEV existing, so mount Lustre to create one"
452 check_mount || return 41
456 echo "Remove mds config log"
457 do_facet $SINGLEMDS "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
460 start_mds && return 42
463 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
466 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
468 local dev=${SINGLEMDS}_dev
474 # check if current MDSSIZE is large enough
475 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
476 log "use MDSSIZE=$MDSSIZE"
478 # check if the global config has a large enough MDSSIZE
479 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
480 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
481 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
483 # check if the block device is large enough
484 [ -z "$OK" -a -b $MDSDEV ] && \
485 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
486 awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
487 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
489 # check if a loopback device has enough space for fs metadata (5%)
490 [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
491 SPACE=$(df -P $(dirname $MDSDEV) |
492 awk '($1 != "Filesystem") {print $4}') &&
493 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
494 log "use file $MDSDEV with MIN=$MIN"
496 [ -z "$OK" ] && skip "$MDSDEV too small for ${MIN}kB MDS" && return
499 echo "mount mds with large journal..."
500 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
502 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
505 echo "mount lustre system..."
507 check_mount || return 41
509 echo "check journal size..."
510 local FOUNDSIZE=`do_facet mds "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
511 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
512 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
514 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
519 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
522 run_test 18 "check mkfs creates large journals"
525 start_mds || return 1
526 stop_mds -f || return 2
528 run_test 19a "start/stop MDS without OSTs"
531 start_ost || return 1
532 stop_ost -f || return 2
534 run_test 19b "start/stop OSTs without MDS"
537 # first format the ost/mdt
541 check_mount || return 43
543 remount_client ro $MOUNT || return 44
544 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
545 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
546 remount_client rw $MOUNT || return 47
548 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
549 MCNT=`grep -c $MOUNT /etc/mtab`
550 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
555 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
560 wait_osc_import_state mds ost FULL
564 run_test 21a "start mds before ost, stop ost first"
569 wait_osc_import_state mds ost FULL
573 run_test 21b "start ost before mds, stop mds first"
579 wait_osc_import_state mds ost2 FULL
583 #writeconf to remove all ost2 traces for subsequent tests
586 run_test 21c "start mds between two osts, stop mds last"
591 echo Client mount with ost in logs, but none running
593 # wait until mds connected to ost and open client connection
594 wait_osc_import_state mds ost FULL
597 # check_mount will block trying to contact ost
601 echo Client mount with a running ost
604 # if gss enabled, wait full time to let connection from
605 # mds to ost be established, due to the mismatch between
606 # initial connect timeout and gss context negotiation timeout.
607 # This perhaps could be remove after AT landed.
608 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
609 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
612 check_mount || return 41
617 run_test 22 "start a client before osts (should return errs)"
619 test_23a() { # was test_23
623 # force down client so that recovering mds waits for reconnect
624 local running=$(grep -c $MOUNT /proc/mounts) || true
625 if [ $running -ne 0 ]; then
626 echo "Stopping client $MOUNT (opts: -f)"
630 # enter recovery on mds
632 # try to start a new client
633 mount_client $MOUNT &
635 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
636 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
637 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
639 ps --ppid $MOUNT_LUSTRE_PID
640 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
641 kill -TERM $MOUNT_LUSTRE_PID
642 echo "waiting for mount to finish"
644 # we can not wait $MOUNT_PID because it is not a child of this shell
650 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
652 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
653 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
656 [ -z "$PID1" -a -z "$PID2" ] && break
657 echo "waiting for mount to finish ... "
658 WAIT=$(( WAIT + sleep))
660 [ "$WAIT" -eq "$MAX_WAIT" ] && error "MOUNT_PID $MOUNT_PID and \
661 MOUNT__LUSTRE_PID $MOUNT__LUSTRE_PID still not killed in $WAIT secs"
666 run_test 23a "interrupt client during recovery mount delay"
671 test_23b() { # was test_23
674 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
675 lctl set_param fail_loc=0x80000313
679 run_test 23b "Simulate -EINTR during mount"
681 fs2mds_HOST=$mds_HOST
682 fs2ost_HOST=$ost_HOST
686 echo "umount $MOUNT2 ..."
687 umount $MOUNT2 || true
688 echo "stopping fs2mds ..."
689 stop fs2mds -f || true
690 echo "stopping fs2ost ..."
691 stop fs2ost -f || true
698 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
699 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
700 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
701 skip "mixed loopback and real device not working" && return
704 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
705 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
707 # test 8-char fsname as well
708 local FSNAME2=test1234
709 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
711 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
714 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
715 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
717 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
719 check_mount || return 2
720 # files written on 1 should not show up on 2
721 cp /etc/passwd $DIR/$tfile
723 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
726 cp /etc/passwd $MOUNT2/b || return 3
727 rm $MOUNT2/b || return 4
728 # 2 is actually mounted
729 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
731 facet_failover fs2mds
732 facet_failover fs2ost
735 # the MDS must remain up until last MDT
737 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
738 [ -z "$MDS" ] && error "No MDT" && return 8
740 cleanup_nocli || return 6
742 run_test 24a "Multiple MDTs on a single node"
745 if [ -z "$fs2mds_DEV" ]; then
746 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
747 skip "mixed loopback and real device not working" && return
750 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
752 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
754 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
757 run_test 24b "Multiple MGSs on a single node (should return err)"
761 check_mount || return 2
762 local MODULES=$($LCTL modules | awk '{ print $2 }')
763 rmmod $MODULES 2>/dev/null || true
766 run_test 25 "Verify modules are referenced"
770 # we need modules before mount for sysctl, so make sure...
771 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
772 #define OBD_FAIL_MDS_FS_SETUP 0x135
773 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
774 start_mds && echo MDS started && return 1
775 lctl get_param -n devices
776 DEVS=$(lctl get_param -n devices | wc -l)
777 [ $DEVS -gt 0 ] && return 2
778 unload_modules || return 203
780 run_test 26 "MDT startup failure cleans LOV (should return errs)"
786 local ORIG=$(do_facet $myfacet "$TEST")
787 if [ $# -gt 3 ]; then
793 echo "Setting $PARAM from $ORIG to $FINAL"
794 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
796 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
800 start_ost || return 1
801 start_mds || return 2
802 echo "Requeue thread should have started: "
803 ps -e | grep ll_cfg_requeue
804 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
807 run_test 27a "Reacquire MGS lock if OST started first"
812 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
814 facet_failover $SINGLEMDS
815 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
816 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
820 run_test 27b "Reacquire MGS lock after failover"
824 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
825 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
828 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
829 FINAL=$(($FINAL + 1))
830 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
831 umount_client $MOUNT || return 200
834 if [ $RESULT -ne $FINAL ]; then
835 echo "New config not seen: wanted $FINAL got $RESULT"
838 echo "New config success: got $RESULT"
840 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
843 run_test 28 "permanent parameter setting"
846 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2, skipping" && return
847 setup > /dev/null 2>&1
851 local PARAM="$FSNAME-OST0001.osc.active"
852 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
853 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
855 ACTV=$(lctl get_param -n $PROC_ACT)
857 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
858 # also check ost_server_uuid status
859 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
860 if [ -z "$RESULT" ]; then
861 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
864 echo "Live client success: got $RESULT"
868 local MPROC="osc.$FSNAME-OST0001-osc-[M]*.active"
873 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
874 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
875 if [ $RESULT -eq $DEAC ]; then
876 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
880 if [ $WAIT -eq $MAX ]; then
881 echo "MDT not deactivated: wanted $DEAC got $RESULT"
884 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
887 # test new client starts deactivated
888 umount_client $MOUNT || return 200
890 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
891 if [ -z "$RESULT" ]; then
892 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
895 echo "New client success: got $RESULT"
898 # make sure it reactivates
899 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
904 #writeconf to remove all ost2 traces for subsequent tests
907 run_test 29 "permanently remove an OST"
912 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
914 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
915 for i in ${LIST[@]}; do
916 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
918 # make sure client restart still works
920 mount_client $MOUNT || return 4
921 [ "$($TEST)" -ne "$i" ] && return 5
922 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
925 run_test 30 "Big config llog"
927 test_31() { # bug 10734
928 # ipaddr must not exist
929 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
932 run_test 31 "Connect to non-existent node (shouldn't crash)"
934 # Use these start32/stop32 fn instead of t-f start/stop fn,
935 # for local devices, to skip global facet vars init
939 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
940 umount -d $@ ${MOUNT%/*}/${facet}
949 mkdir -p ${MOUNT%/*}/${facet}
951 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
952 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
954 if [ $RC -ne 0 ]; then
955 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
956 echo "Start of ${device} of local ${facet} failed ${RC}"
970 echo "Cleanup test_32 umount $MOUNT ..."
971 umount -f $MOUNT || true
972 echo "Cleanup local mds ost1 ..."
978 # this test is totally useless on a client-only system
979 [ -n "$CLIENTONLY" -o -n "$CLIENTMODSONLY" ] && skip "client only testing" && return 0
980 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
981 [ -z "$TUNEFS" ] && skip "No tunefs" && return 0
982 local DISK1_8=$LUSTRE/tests/disk1_8.tgz
983 [ ! -r $DISK1_8 ] && skip "Cannot find $DISK1_8" && return 0
986 tar xjvf $DISK1_8 -C $TMP/$tdir || \
987 { skip "Cannot untar $DISK1_8" && return 0; }
990 lctl set_param debug=$PTLDEBUG
992 $TUNEFS $tmpdir/mds || error "tunefs failed"
994 # nids are wrong, so client wont work, but server should start
995 start32 mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
996 trap cleanup_32 EXIT INT || return 3
998 local UUID=$(lctl get_param -n mds.lustre-MDT0000.uuid)
1000 [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
1002 $TUNEFS --mgsnode=`hostname` $tmpdir/ost1 || error "tunefs failed"
1003 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1004 UUID=$(lctl get_param -n obdfilter.lustre-OST0000.uuid)
1006 [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
1008 local NID=$($LCTL list_nids | head -1)
1010 echo "OSC changes should return err:"
1011 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 && return 7
1012 $LCTL conf_param lustre-OST0000.failover.node=$NID && return 8
1014 echo "MDC changes should succeed:"
1015 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1016 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1019 # With a new good MDT failover nid, we should be able to mount a client
1020 # (but it cant talk to OST)
1021 local mountopt="-o exclude=lustre-OST0000"
1023 local device=`h2$NETTYPE $HOSTNAME`:/lustre
1024 echo "Starting local client: $HOSTNAME: $mountopt $device $MOUNT"
1025 mount -t lustre $mountopt $device $MOUNT || return 1
1027 local old=$(lctl get_param -n mdc.*.max_rpcs_in_flight)
1028 local new=$((old + 5))
1029 lctl conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=$new
1030 wait_update $HOSTNAME "lctl get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1034 # mount a second time to make sure we didnt leave upgrade flag on
1036 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1037 start32 mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1038 trap cleanup_32 EXIT INT || return 12
1042 rm -rf $tmpdir || true # true is only for TMP on NFS
1044 run_test 32a "Upgrade from 1.8 (not live)"
1047 # this test is totally useless on a client-only system
1048 [ -n "$CLIENTONLY" -o -n "$CLIENTMODSONLY" ] && skip "client only testing" && return 0
1049 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1050 [ -z "$TUNEFS" ] && skip "No tunefs" && return
1052 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1053 [ ! -r $DISK1_8 ] && skip "Cannot find $DISK1_8" && return 0
1054 local tmpdir=$TMP/$tdir
1056 tar xjvf $DISK1_8 -C $tmpdir || \
1057 { skip "Cannot untar $DISK1_8" && return ; }
1060 lctl set_param debug=$PTLDEBUG
1061 local NEWNAME=lustre
1063 # writeconf will cause servers to register with their current nids
1064 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1065 start32 mds1 $tmpdir/mds "-o loop" && \
1066 trap cleanup_32 EXIT INT || return 3
1068 local UUID=$(lctl get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1070 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1072 $TUNEFS --mgsnode=`hostname` --writeconf --fsname=$NEWNAME $tmpdir/ost1 || error "tunefs failed"
1073 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1074 UUID=$(lctl get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1076 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1078 echo "OSC changes should succeed:"
1079 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1080 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1082 echo "MDC changes should succeed:"
1083 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1086 # MDT and OST should have registered with new nids, so we should have
1087 # a fully-functioning client
1088 echo "Check client and old fs contents"
1090 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1091 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1092 mount -t lustre $device $MOUNT || return 1
1094 local old=$(lctl get_param -n mdc.*.max_rpcs_in_flight)
1095 local new=$((old + 5))
1096 lctl conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1097 wait_update $HOSTNAME "lctl get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1099 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1104 rm -rf $tmpdir || true # true is only for TMP on NFS
1106 run_test 32b "Upgrade from 1.8 with writeconf"
1108 test_33a() { # bug 12333, was test_33
1110 local FSNAME2=test-123
1111 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1113 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1114 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1115 skip "mixed loopback and real device not working" && return
1118 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1119 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1120 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1121 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1123 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1124 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1125 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1127 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1130 cp /etc/hosts $MOUNT2/ || rc=3
1131 $LFS getstripe $MOUNT2/hosts
1136 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1137 cleanup_nocli || rc=6
1140 run_test 33a "Mount ost with a large index number"
1142 test_33b() { # was test_34
1145 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1146 # Drop lock cancelation reply during umount
1147 #define OBD_FAIL_LDLM_CANCEL 0x304
1148 do_facet client lctl set_param fail_loc=0x80000304
1149 #lctl set_param debug=-1
1150 umount_client $MOUNT
1153 run_test 33b "Drop cancel during umount"
1157 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1158 manual_umount_client
1160 do_facet client killall -USR1 multiop
1161 if [ $rc -eq 0 ]; then
1162 error "umount not fail!"
1167 run_test 34a "umount with opened file should be fail"
1172 touch $DIR/$tfile || return 1
1173 stop_mds --force || return 2
1175 manual_umount_client --force
1177 if [ $rc -ne 0 ]; then
1178 error "mtab after failed umount - rc $rc"
1184 run_test 34b "force umount with failed mds should be normal"
1188 touch $DIR/$tfile || return 1
1189 stop_ost --force || return 2
1191 manual_umount_client --force
1193 if [ $rc -ne 0 ]; then
1194 error "mtab after failed umount - rc $rc"
1200 run_test 34c "force umount with failed ost should be normal"
1202 test_35() { # bug 12459
1205 DBG_SAVE="`lctl get_param -n debug`"
1206 lctl set_param debug="ha"
1208 log "Set up a fake failnode for the MDS"
1210 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1211 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1213 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1216 MSG="conf-sanity.sh test_35 `date +%F%kh%Mm%Ss`"
1219 log "Stopping the MDT:"
1220 stop_mds || return 5
1222 df $MOUNT > /dev/null 2>&1 &
1224 log "Restarting the MDT:"
1225 start_mds || return 6
1226 log "Wait for df ($DFPID) ... "
1229 lctl set_param debug="$DBG_SAVE"
1231 # retrieve from the log the first server that the client tried to
1232 # contact after the connection loss
1233 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1234 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1235 /import_select_connection.*$device-mdc.* using connection/ {
1237 if (\\\$NF ~ /$FAKENID/)
1243 }" $TMP/lustre-log-$TESTNAME.log`
1244 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1247 run_test 35 "Reconnect to the last active server first"
1251 local FSNAME2=test1234
1252 local fs3ost_HOST=$ost_HOST
1254 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1257 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1258 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1259 skip "mixed loopback and real device not working" && return
1261 [ $OSTCOUNT -lt 2 ] && skip "skipping test for single OST" && return
1263 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1264 { skip "remote OST" && return 0; }
1266 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1267 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1268 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1269 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1270 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1272 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1273 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1275 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1276 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1277 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1279 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1281 sleep 5 # until 11778 fixed
1283 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1285 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1286 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1287 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1288 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1289 DFTOTAL=`echo $STRING | cut -d, -f1`
1290 DFUSED=`echo $STRING | cut -d, -f2`
1291 DFAVAIL=`echo $STRING | cut -d, -f3`
1292 DFFREE=$(($DFTOTAL - $DFUSED))
1294 ALLOWANCE=$((64 * $OSTCOUNT))
1296 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1297 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1298 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1301 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1302 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1303 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1306 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1307 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1308 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1313 stop fs3ost -f || return 200
1314 stop fs2ost -f || return 201
1315 stop fs2mds -f || return 202
1316 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1317 unload_modules || return 203
1320 run_test 36 "df report consistency on OSTs with different block size"
1323 [ -n "$CLIENTONLY" -o -n "$CLIENTMODSONLY" ] && skip "client only testing" && return 0
1324 LOCAL_MDSDEV="$TMP/mdt.img"
1325 SYM_MDSDEV="$TMP/sym_mdt.img"
1327 echo "MDS : $LOCAL_MDSDEV"
1328 echo "SYMLINK : $SYM_MDSDEV"
1332 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1333 error "mkfs.lustre $LOCAL_MDSDEV failed"
1334 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1336 echo "mount symlink device - $SYM_MDSDEV"
1338 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1339 umount -d ${MOUNT%/*}/mds
1340 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1342 if [ -n "$mount_op" ]; then
1343 error "**** FAIL: set tunables failed for symlink device"
1347 run_test 37 "verify set tunables works for symlink device"
1349 test_38() { # bug 14222
1354 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1355 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1357 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1358 error "copying $SRC to $DIR/$tdir"
1360 umount_client $MOUNT
1362 log "rename lov_objid file on MDS"
1363 rm -f $TMP/lov_objid.orig
1365 local dev=${SINGLEMDS}_dev
1366 local MDSDEV=${!dev}
1367 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1368 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1370 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1371 # check create in mds_lov_connect
1375 [ $V ] && log "verifying $DIR/$tdir/$f"
1376 diff -q $f $DIR/$tdir/$f || ERROR=y
1378 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1379 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1380 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1382 # check it's updates in sync
1383 umount_client $MOUNT
1386 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1387 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1388 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1393 [ $V ] && log "verifying $DIR/$tdir/$f"
1394 diff -q $f $DIR/$tdir/$f || ERROR=y
1396 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1397 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1398 umount_client $MOUNT
1400 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1402 log "files compared the same"
1405 run_test 38 "MDS recreates missing lov_objid file from OST data"
1411 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1412 error "memory leak detected" || true
1414 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1416 test_40() { # bug 15759
1418 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1419 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1423 run_test 40 "race during service thread startup"
1425 test_41() { #bug 14134
1427 local dev=${SINGLEMDS}_dev
1428 local MDSDEV=${!dev}
1430 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1431 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1432 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs
1434 mount_client $MOUNT || return 1
1437 echo "blah blah" > $MOUNT/$tfile
1440 umount_client $MOUNT
1441 stop ost1 -f || return 201
1442 stop_mds -f || return 202
1443 stop_mds -f || return 203
1444 unload_modules || return 204
1447 run_test 41 "mount mds with --nosvc and --nomgs"
1449 test_42() { #bug 14693
1451 check_mount || return 2
1452 do_facet client lctl conf_param lustre.llite.some_wrong_param=10
1453 umount_client $MOUNT
1454 mount_client $MOUNT || return 1
1458 run_test 42 "invalid config param should not prevent client from mounting"
1461 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip "run as root"
1463 chmod ugo+x $DIR || error "chmod 0 failed"
1465 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1466 "$FSNAME.mdt.root_squash" \
1469 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1470 "$FSNAME.mdt.nosquash_nids" \
1474 # create set of test files
1476 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1477 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1478 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1480 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1481 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1483 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1484 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1485 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1488 # check root_squash:
1489 # set root squash UID:GID to RUNAS_ID
1490 # root should be able to access only files owned by RUNAS_ID
1493 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1494 "$FSNAME.mdt.root_squash" \
1495 "$RUNAS_ID:$RUNAS_ID"
1497 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1498 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1499 error "$ST: root read permission is denied"
1500 echo "$ST: root read permission is granted - ok"
1503 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1504 error "$ST: root write permission is denied"
1505 echo "$ST: root write permission is granted - ok"
1507 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1508 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1509 error "$ST: root read permission is granted"
1510 echo "$ST: root read permission is denied - ok"
1513 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1514 error "$ST: root write permission is granted"
1515 echo "$ST: root write permission is denied - ok"
1517 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1518 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1519 error "$ST: root unlink permission is granted"
1520 echo "$ST: root unlink permission is denied - ok"
1522 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1523 error "$ST: root create permission is granted"
1524 echo "$ST: root create permission is denied - ok"
1527 # check nosquash_nids:
1528 # put client's NID into nosquash_nids list,
1529 # root should be able to access root file after that
1531 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1532 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1533 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1535 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1536 "$FSNAME-MDTall.mdt.nosquash_nids" \
1539 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1540 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1541 error "$ST: root read permission is denied"
1542 echo "$ST: root read permission is granted - ok"
1545 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1546 error "$ST: root write permission is denied"
1547 echo "$ST: root write permission is granted - ok"
1549 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1550 rm $DIR/$tdir-rootdir/tfile-1 || \
1551 error "$ST: root unlink permission is denied"
1552 echo "$ST: root unlink permission is granted - ok"
1553 touch $DIR/$tdir-rootdir/tfile-2 || \
1554 error "$ST: root create permission is denied"
1555 echo "$ST: root create permission is granted - ok"
1559 run_test 43 "check root_squash and nosquash_nids"
1561 umount_client $MOUNT
1566 check_mount || return 2
1571 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1572 do_facet client "lctl set_param fail_loc=0x50f"
1575 manual_umount_client --force || return 3
1576 do_facet client "lctl set_param fail_loc=0x0"
1578 mount_client $MOUNT || return 4
1582 run_test 45 "long unlink handling in ptlrpcd"
1587 start_mds || return 1
1588 #first client should see only one ost
1589 start_ost || return 2
1590 wait_osc_import_state mds ost FULL
1592 mount_client $MOUNT || return 3
1594 start_ost2 || return 4
1595 start ost3 `ostdevname 3` $OST_MOUNT_OPTS || return 5
1596 start ost4 `ostdevname 4` $OST_MOUNT_OPTS || return 6
1597 start ost5 `ostdevname 5` $OST_MOUNT_OPTS || return 7
1598 # wait until ost2-5 is sync
1600 wait_osc_import_state mds ost2 FULL
1601 wait_osc_import_state mds ost3 FULL
1602 wait_osc_import_state mds ost4 FULL
1603 wait_osc_import_state mds ost5 FULL
1604 #second client see all ost's
1606 mount_client $MOUNT2 || return 8
1607 $LFS setstripe $MOUNT2 -c -1 || return 9
1608 $LFS getstripe $MOUNT2 || return 10
1610 echo "ok" > $MOUNT2/widestripe
1611 $LFS getstripe $MOUNT2/widestripe || return 11
1612 # fill acl buffer for avoid expand lsm to them
1613 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1614 setfacl -m $acl $MOUNT2/widestripe
1618 stat $MOUNT/widestripe || return 12
1620 umount_client $MOUNT2 || return 13
1621 umount_client $MOUNT || return 14
1622 stop ost5 -f || return 20
1623 stop ost4 -f || return 21
1624 stop ost3 -f || return 22
1625 stop_ost2 || return 23
1626 stop_ost || return 24
1627 stop_mds || return 25
1629 run_test 46a "handle ost additional - wide striped file"
1634 check_mount || return 2
1635 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1639 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1640 if echo $ns | grep "MDT[[:digit:]]*"; then
1643 lrs=$(echo $ns | sed 's/.*lru_size=//')
1644 lru_size[count]=$lrs
1649 facet_failover $SINGLEMDS
1650 df -h $MOUNT || return 3
1653 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1654 if echo $ns | grep "MDT[[:digit:]]*"; then
1657 lrs=$(echo $ns | sed 's/.*lru_size=//')
1658 if ! test "$lrs" -eq "${lru_size[count]}"; then
1659 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1660 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1668 run_test 47 "server restart does not make client loss lru_resize settings"
1673 # reformat after this test is needed - if test will failed
1674 # we will have unkillable file at FS
1678 test_48() { # bug 17636
1681 check_mount || return 2
1683 $LFS setstripe $MOUNT -c -1 || return 9
1684 $LFS getstripe $MOUNT || return 10
1686 echo "ok" > $MOUNT/widestripe
1687 $LFS getstripe $MOUNT/widestripe || return 11
1689 trap cleanup_48 EXIT ERR
1691 # fill acl buffer for avoid expand lsm to them
1692 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1693 setfacl -m $acl $MOUNT/widestripe
1696 stat $MOUNT/widestripe || return 12
1701 run_test 48 "too many acls on file"
1703 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1704 test_49() { # bug 17710
1705 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1706 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1707 local LOCAL_TIMEOUT=20
1710 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1716 check_mount || return 1
1718 echo "check ldlm_timout..."
1719 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1720 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1721 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1723 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1724 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1727 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1728 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1731 umount_client $MOUNT
1732 stop_ost || return 2
1733 stop_mds || return 3
1735 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"
1738 start_mds || return 4
1739 start_ost || return 5
1740 mount_client $MOUNT || return 6
1741 check_mount || return 7
1743 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1744 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1745 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1747 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1748 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1751 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1752 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1755 cleanup || return $?
1757 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1758 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1760 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1763 # Test both statfs and lfs df and fail if either one fails
1764 multiop_bg_pause $1 f_
1767 killall -USR1 multiop
1768 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
1769 wait $PID || { RC1=$?; log "multiop return error "; }
1776 if [ $RC2 -eq 0 ]; then
1778 log "lazystatfs df failed"
1782 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
1788 lctl set_param llite.$FSNAME-*.lazystatfs=1
1791 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
1793 cleanup || return $?
1795 run_test 50a "lazystatfs all servers available =========================="
1799 lctl set_param llite.$FSNAME-*.lazystatfs=1
1802 # Wait for client to detect down OST
1803 stop_ost || error "Unable to stop OST1"
1804 wait_osc_import_state mds ost DISCONN
1806 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
1808 umount_client $MOUNT || error "Unable to unmount client"
1809 stop_mds || error "Unable to stop MDS"
1811 run_test 50b "lazystatfs all servers down =========================="
1814 start_mds || error "Unable to start MDS"
1815 start_ost || error "Unable to start OST1"
1816 start_ost2 || error "Unable to start OST2"
1817 mount_client $MOUNT || error "Unable to mount client"
1818 lctl set_param llite.$FSNAME-*.lazystatfs=1
1821 # Wait for client to detect down OST
1822 stop_ost || error "Unable to stop OST1"
1823 wait_osc_import_state mds ost DISCONN
1824 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1826 umount_client $MOUNT || error "Unable to unmount client"
1827 stop_ost2 || error "Unable to stop OST2"
1828 stop_mds || error "Unable to stop MDS"
1830 run_test 50c "lazystatfs one server down =========================="
1833 start_mds || error "Unable to start MDS"
1834 start_ost || error "Unable to start OST1"
1835 start_ost2 || error "Unable to start OST2"
1836 mount_client $MOUNT || error "Unable to mount client"
1837 lctl set_param llite.$FSNAME-*.lazystatfs=1
1840 # Issue the statfs during the window where the client still
1841 # belives the OST to be available but it is in fact down.
1842 # No failure just a statfs which hangs for a timeout interval.
1843 stop_ost || error "Unable to stop OST1"
1844 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1846 umount_client $MOUNT || error "Unable to unmount client"
1847 stop_ost2 || error "Unable to stop OST2"
1848 stop_mds || error "Unable to stop MDS"
1850 run_test 50d "lazystatfs client/server conn race =========================="
1857 start_mds || return 1
1858 #first client should see only one ost
1859 start_ost || return 2
1860 wait_osc_import_state mds ost FULL
1862 # Wait for client to detect down OST
1863 stop_ost || error "Unable to stop OST1"
1864 wait_osc_import_state mds ost DISCONN
1866 mount_client $MOUNT || error "Unable to mount client"
1867 lctl set_param llite.$FSNAME-*.lazystatfs=0
1869 multiop_bg_pause $MOUNT _f
1873 if [ $RC1 -ne 0 ]; then
1874 log "multiop failed $RC1"
1877 sleep $(( $TIMEOUT+1 ))
1879 [ $? -ne 0 ] && error "process isn't sleep"
1880 start_ost || error "Unable to start OST1"
1881 wait $pid || error "statfs failed"
1884 umount_client $MOUNT || error "Unable to unmount client"
1885 stop_ost || error "Unable to stop OST1"
1886 stop_mds || error "Unable to stop MDS"
1888 run_test 50e "normal statfs all servers down =========================="
1893 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
1895 start_mds || error "Unable to start mds"
1896 #first client should see only one ost
1897 start_ost || error "Unable to start OST1"
1898 wait_osc_import_state mds ost FULL
1900 start_ost2 || error "Unable to start OST2"
1901 wait_osc_import_state mds ost2 FULL
1903 # Wait for client to detect down OST
1904 stop_ost2 || error "Unable to stop OST2"
1906 wait_osc_import_state mds ost2 DISCONN
1907 mount_client $MOUNT || error "Unable to mount client"
1908 lctl set_param llite.$FSNAME-*.lazystatfs=0
1910 multiop_bg_pause $MOUNT _f
1914 if [ $RC1 -ne 0 ]; then
1915 log "lazystatfs multiop failed $RC1"
1918 sleep $(( $TIMEOUT+1 ))
1920 [ $? -ne 0 ] && error "process isn't sleep"
1921 start_ost2 || error "Unable to start OST1"
1922 wait $pid || error "statfs failed"
1925 umount_client $MOUNT || error "Unable to unmount client"
1926 stop_ost || error "Unable to stop OST1"
1927 stop_mds || error "Unable to stop MDS"
1930 run_test 50f "normal statfs one server in down =========================="
1933 local LOCAL_TIMEOUT=20
1939 check_mount || return 1
1942 $LFS setstripe -c -1 $MOUNT/d1
1943 #define OBD_FAIL_MDS_REINT_DELAY 0x142
1944 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
1945 touch $MOUNT/d1/f1 &
1948 start_ost2 || return 2
1950 stop_ost2 || return 3
1953 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
1956 equals_msg `basename $0`: test complete
1957 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true