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.
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"
563 run_test 21a "start mds before ost, stop ost first"
571 run_test 21b "start ost before mds, stop mds first"
580 #writeconf to remove all ost2 traces for subsequent tests
583 run_test 21c "start mds between two osts, stop mds last"
588 echo Client mount with ost in logs, but none running
590 # wait until mds connected to ost and open client connection
592 sleep $((TIMEOUT / 4 + 1))
595 # check_mount will block trying to contact ost
599 echo Client mount with a running ost
602 # if gss enabled, wait full time to let connection from
603 # mds to ost be established, due to the mismatch between
604 # initial connect timeout and gss context negotiation timeout.
605 # This perhaps could be remove after AT landed.
606 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
607 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
610 check_mount || return 41
615 run_test 22 "start a client before osts (should return errs)"
617 test_23a() { # was test_23
621 # force down client so that recovering mds waits for reconnect
622 local running=$(grep -c $MOUNT /proc/mounts) || true
623 if [ $running -ne 0 ]; then
624 echo "Stopping client $MOUNT (opts: -f)"
628 # enter recovery on mds
630 # try to start a new client
631 mount_client $MOUNT &
633 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
634 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
635 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
637 ps --ppid $MOUNT_LUSTRE_PID
638 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
639 kill -TERM $MOUNT_LUSTRE_PID
640 echo "waiting for mount to finish"
642 # we can not wait $MOUNT_PID because it is not a child of this shell
648 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
650 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
651 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
654 [ -z "$PID1" -a -z "$PID2" ] && break
655 echo "waiting for mount to finish ... "
656 WAIT=$(( WAIT + sleep))
658 [ "$WAIT" -eq "$MAX_WAIT" ] && error "MOUNT_PID $MOUNT_PID and \
659 MOUNT__LUSTRE_PID $MOUNT__LUSTRE_PID still not killed in $WAIT secs"
664 run_test 23a "interrupt client during recovery mount delay"
669 test_23b() { # was test_23
672 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
673 lctl set_param fail_loc=0x80000313
677 run_test 23b "Simulate -EINTR during mount"
679 fs2mds_HOST=$mds_HOST
680 fs2ost_HOST=$ost_HOST
684 echo "umount $MOUNT2 ..."
685 umount $MOUNT2 || true
686 echo "stopping fs2mds ..."
687 stop fs2mds -f || true
688 echo "stopping fs2ost ..."
689 stop fs2ost -f || true
696 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
697 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
698 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
699 skip "mixed loopback and real device not working" && return
702 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
703 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
705 # test 8-char fsname as well
706 local FSNAME2=test1234
707 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
709 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
712 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
713 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
715 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
717 check_mount || return 2
718 # files written on 1 should not show up on 2
719 cp /etc/passwd $DIR/$tfile
721 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
724 cp /etc/passwd $MOUNT2/b || return 3
725 rm $MOUNT2/b || return 4
726 # 2 is actually mounted
727 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
729 facet_failover fs2mds
730 facet_failover fs2ost
733 # the MDS must remain up until last MDT
735 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
736 [ -z "$MDS" ] && error "No MDT" && return 8
738 cleanup_nocli || return 6
740 run_test 24a "Multiple MDTs on a single node"
743 if [ -z "$fs2mds_DEV" ]; then
744 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
745 skip "mixed loopback and real device not working" && return
748 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
750 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
752 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
755 run_test 24b "Multiple MGSs on a single node (should return err)"
759 check_mount || return 2
760 local MODULES=$($LCTL modules | awk '{ print $2 }')
761 rmmod $MODULES 2>/dev/null || true
764 run_test 25 "Verify modules are referenced"
768 # we need modules before mount for sysctl, so make sure...
769 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
770 #define OBD_FAIL_MDS_FS_SETUP 0x135
771 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
772 start_mds && echo MDS started && return 1
773 lctl get_param -n devices
774 DEVS=$(lctl get_param -n devices | wc -l)
775 [ $DEVS -gt 0 ] && return 2
776 unload_modules || return 203
778 run_test 26 "MDT startup failure cleans LOV (should return errs)"
784 local ORIG=$(do_facet $myfacet "$TEST")
785 if [ $# -gt 3 ]; then
791 echo "Setting $PARAM from $ORIG to $FINAL"
792 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
794 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
798 start_ost || return 1
799 start_mds || return 2
800 echo "Requeue thread should have started: "
801 ps -e | grep ll_cfg_requeue
802 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
805 run_test 27a "Reacquire MGS lock if OST started first"
810 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
812 facet_failover $SINGLEMDS
813 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
814 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
818 run_test 27b "Reacquire MGS lock after failover"
822 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
823 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
826 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
827 FINAL=$(($FINAL + 1))
828 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
829 umount_client $MOUNT || return 200
832 if [ $RESULT -ne $FINAL ]; then
833 echo "New config not seen: wanted $FINAL got $RESULT"
836 echo "New config success: got $RESULT"
838 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
841 run_test 28 "permanent parameter setting"
844 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2, skipping" && return
845 setup > /dev/null 2>&1
849 local PARAM="$FSNAME-OST0001.osc.active"
850 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
851 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
853 ACTV=$(lctl get_param -n $PROC_ACT)
855 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
856 # also check ost_server_uuid status
857 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
858 if [ -z "$RESULT" ]; then
859 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
862 echo "Live client success: got $RESULT"
866 local MPROC="osc.$FSNAME-OST0001-osc-[M]*.active"
871 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
872 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
873 if [ $RESULT -eq $DEAC ]; then
874 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
878 if [ $WAIT -eq $MAX ]; then
879 echo "MDT not deactivated: wanted $DEAC got $RESULT"
882 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
885 # test new client starts deactivated
886 umount_client $MOUNT || return 200
888 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
889 if [ -z "$RESULT" ]; then
890 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
893 echo "New client success: got $RESULT"
896 # make sure it reactivates
897 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
902 #writeconf to remove all ost2 traces for subsequent tests
905 run_test 29 "permanently remove an OST"
910 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
912 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
913 for i in ${LIST[@]}; do
914 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
916 # make sure client restart still works
918 mount_client $MOUNT || return 4
919 [ "$($TEST)" -ne "$i" ] && return 5
920 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
923 run_test 30 "Big config llog"
925 test_31() { # bug 10734
926 # ipaddr must not exist
927 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
930 run_test 31 "Connect to non-existent node (shouldn't crash)"
932 # Use these start32/stop32 fn instead of t-f start/stop fn,
933 # for local devices, to skip global facet vars init
937 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
938 umount -d $@ ${MOUNT%/*}/${facet}
947 mkdir -p ${MOUNT%/*}/${facet}
949 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
950 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
952 if [ $RC -ne 0 ]; then
953 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
954 echo "Start of ${device} of local ${facet} failed ${RC}"
968 echo "Cleanup test_32 umount $MOUNT ..."
969 umount -f $MOUNT || true
970 echo "Cleanup local mds ost1 ..."
976 # this test is totally useless on a client-only system
977 [ -n "$CLIENTONLY" -o -n "$CLIENTMODSONLY" ] && skip "client only testing" && return 0
978 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
979 [ -z "$TUNEFS" ] && skip "No tunefs" && return 0
980 local DISK1_8=$LUSTRE/tests/disk1_8.tgz
981 [ ! -r $DISK1_8 ] && skip "Cannot find $DISK1_8" && return 0
984 tar xjvf $DISK1_8 -C $TMP/$tdir || \
985 { skip "Cannot untar $DISK1_8" && return 0; }
988 lctl set_param debug=$PTLDEBUG
990 $TUNEFS $tmpdir/mds || error "tunefs failed"
992 # nids are wrong, so client wont work, but server should start
993 start32 mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
994 trap cleanup_32 EXIT INT || return 3
996 local UUID=$(lctl get_param -n mds.lustre-MDT0000.uuid)
998 [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
1000 $TUNEFS --mgsnode=`hostname` $tmpdir/ost1 || error "tunefs failed"
1001 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1002 UUID=$(lctl get_param -n obdfilter.lustre-OST0000.uuid)
1004 [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
1006 local NID=$($LCTL list_nids | head -1)
1008 echo "OSC changes should return err:"
1009 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 && return 7
1010 $LCTL conf_param lustre-OST0000.failover.node=$NID && return 8
1012 echo "MDC changes should succeed:"
1013 $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1014 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1017 # With a new good MDT failover nid, we should be able to mount a client
1018 # (but it cant talk to OST)
1019 local mountopt="-o exclude=lustre-OST0000"
1021 local device=`h2$NETTYPE $HOSTNAME`:/lustre
1022 echo "Starting local client: $HOSTNAME: $mountopt $device $MOUNT"
1023 mount -t lustre $mountopt $device $MOUNT || return 1
1025 local old=$(lctl get_param -n mdc.*.max_rpcs_in_flight)
1026 local new=$((old + 5))
1027 lctl conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=$new
1028 wait_update $HOSTNAME "lctl get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1032 # mount a second time to make sure we didnt leave upgrade flag on
1034 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1035 start32 mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1036 trap cleanup_32 EXIT INT || return 12
1040 rm -rf $tmpdir || true # true is only for TMP on NFS
1042 run_test 32a "Upgrade from 1.8 (not live)"
1045 # this test is totally useless on a client-only system
1046 [ -n "$CLIENTONLY" -o -n "$CLIENTMODSONLY" ] && skip "client only testing" && return 0
1047 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1048 [ -z "$TUNEFS" ] && skip "No tunefs" && return
1050 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1051 [ ! -r $DISK1_8 ] && skip "Cannot find $DISK1_8" && return 0
1052 local tmpdir=$TMP/$tdir
1054 tar xjvf $DISK1_8 -C $tmpdir || \
1055 { skip "Cannot untar $DISK1_8" && return ; }
1058 lctl set_param debug=$PTLDEBUG
1059 local NEWNAME=lustre
1061 # writeconf will cause servers to register with their current nids
1062 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1063 start32 mds1 $tmpdir/mds "-o loop" && \
1064 trap cleanup_32 EXIT INT || return 3
1066 local UUID=$(lctl get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1068 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1070 $TUNEFS --mgsnode=`hostname` --writeconf --fsname=$NEWNAME $tmpdir/ost1 || error "tunefs failed"
1071 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1072 UUID=$(lctl get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1074 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1076 echo "OSC changes should succeed:"
1077 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1078 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1080 echo "MDC changes should succeed:"
1081 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1084 # MDT and OST should have registered with new nids, so we should have
1085 # a fully-functioning client
1086 echo "Check client and old fs contents"
1088 local device=`h2$NETTYPE $HOSTNAME`:/$NEWNAME
1089 echo "Starting local client: $HOSTNAME: $device $MOUNT"
1090 mount -t lustre $device $MOUNT || return 1
1092 local old=$(lctl get_param -n mdc.*.max_rpcs_in_flight)
1093 local new=$((old + 5))
1094 lctl conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
1095 wait_update $HOSTNAME "lctl get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
1097 [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
1102 rm -rf $tmpdir || true # true is only for TMP on NFS
1104 run_test 32b "Upgrade from 1.8 with writeconf"
1106 test_33a() { # bug 12333, was test_33
1108 local FSNAME2=test-123
1109 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
1111 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
1112 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1113 skip "mixed loopback and real device not working" && return
1116 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1117 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1118 add fs2mds $MDS_MKFS_OPTS --mkfsoptions='\"-J size=8\"' --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1119 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --index=8191 --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1121 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
1122 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1123 do_facet $SINGLEMDS "$LCTL conf_param $FSNAME2.sys.timeout=200" || rc=1
1125 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || rc=2
1128 cp /etc/hosts $MOUNT2/ || rc=3
1129 $LFS getstripe $MOUNT2/hosts
1134 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev
1135 cleanup_nocli || rc=6
1138 run_test 33a "Mount ost with a large index number"
1140 test_33b() { # was test_34
1143 do_facet client dd if=/dev/zero of=$MOUNT/24 bs=1024k count=1
1144 # Drop lock cancelation reply during umount
1145 #define OBD_FAIL_LDLM_CANCEL 0x304
1146 do_facet client lctl set_param fail_loc=0x80000304
1147 #lctl set_param debug=-1
1148 umount_client $MOUNT
1151 run_test 33b "Drop cancel during umount"
1155 do_facet client "sh runmultiop_bg_pause $DIR/file O_c"
1156 manual_umount_client
1158 do_facet client killall -USR1 multiop
1159 if [ $rc -eq 0 ]; then
1160 error "umount not fail!"
1165 run_test 34a "umount with opened file should be fail"
1170 touch $DIR/$tfile || return 1
1171 stop_mds --force || return 2
1173 manual_umount_client --force
1175 if [ $rc -ne 0 ]; then
1176 error "mtab after failed umount - rc $rc"
1182 run_test 34b "force umount with failed mds should be normal"
1186 touch $DIR/$tfile || return 1
1187 stop_ost --force || return 2
1189 manual_umount_client --force
1191 if [ $rc -ne 0 ]; then
1192 error "mtab after failed umount - rc $rc"
1198 run_test 34c "force umount with failed ost should be normal"
1200 test_35() { # bug 12459
1203 DBG_SAVE="`lctl get_param -n debug`"
1204 lctl set_param debug="ha"
1206 log "Set up a fake failnode for the MDS"
1208 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
1209 do_facet $SINGLEMDS $LCTL conf_param ${device}.failover.node=$FAKENID || return 4
1211 log "Wait for RECONNECT_INTERVAL seconds (10s)"
1214 MSG="conf-sanity.sh test_35 `date +%F%kh%Mm%Ss`"
1217 log "Stopping the MDT:"
1218 stop_mds || return 5
1220 df $MOUNT > /dev/null 2>&1 &
1222 log "Restarting the MDT:"
1223 start_mds || return 6
1224 log "Wait for df ($DFPID) ... "
1227 lctl set_param debug="$DBG_SAVE"
1229 # retrieve from the log the first server that the client tried to
1230 # contact after the connection loss
1231 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1232 NEXTCONN=`awk "/${MSG}/ {start = 1;}
1233 /import_select_connection.*$device-mdc.* using connection/ {
1235 if (\\\$NF ~ /$FAKENID/)
1241 }" $TMP/lustre-log-$TESTNAME.log`
1242 [ "$NEXTCONN" != "0" ] && log "The client didn't try to reconnect to the last active server (tried ${NEXTCONN} instead)" && return 7
1245 run_test 35 "Reconnect to the last active server first"
1249 local FSNAME2=test1234
1250 local fs3ost_HOST=$ost_HOST
1252 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST && fs3ost_HOST=$ost1_HOST
1255 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
1256 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
1257 skip "mixed loopback and real device not working" && return
1259 [ $OSTCOUNT -lt 2 ] && skip "skipping test for single OST" && return
1261 [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
1262 { skip "remote OST" && return 0; }
1264 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
1265 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
1266 local fs3ostdev=${fs3ost_DEV:-$(ostdevname 2)_2}
1267 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2mdsdev || exit 10
1268 # XXX after we support non 4K disk blocksize, change following --mkfsoptions with
1270 add fs2ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs2ostdev || exit 10
1271 add fs3ost $OST_MKFS_OPTS --mkfsoptions='-b4096' --fsname=${FSNAME2} --mgsnode=$MGSNID --reformat $fs3ostdev || exit 10
1273 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS
1274 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
1275 start fs3ost $fs3ostdev $OST_MOUNT_OPTS
1277 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
1279 sleep 5 # until 11778 fixed
1281 dd if=/dev/zero of=$MOUNT2/$tfile bs=1M count=7 || return 2
1283 BKTOTAL=`lctl get_param -n obdfilter.*.kbytestotal | awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1284 BKFREE=`lctl get_param -n obdfilter.*.kbytesfree | awk 'BEGIN{free=0}; {free+=$1}; END{print free}'`
1285 BKAVAIL=`lctl get_param -n obdfilter.*.kbytesavail | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}'`
1286 STRING=`df -P $MOUNT2 | tail -n 1 | awk '{print $2","$3","$4}'`
1287 DFTOTAL=`echo $STRING | cut -d, -f1`
1288 DFUSED=`echo $STRING | cut -d, -f2`
1289 DFAVAIL=`echo $STRING | cut -d, -f3`
1290 DFFREE=$(($DFTOTAL - $DFUSED))
1292 ALLOWANCE=$((64 * $OSTCOUNT))
1294 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
1295 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
1296 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
1299 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
1300 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
1301 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
1304 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
1305 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
1306 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
1311 stop fs3ost -f || return 200
1312 stop fs2ost -f || return 201
1313 stop fs2mds -f || return 202
1314 rm -rf $MOUNT2 $fs2mdsdev $fs2ostdev $fs3ostdev
1315 unload_modules || return 203
1318 run_test 36 "df report consistency on OSTs with different block size"
1321 [ -n "$CLIENTONLY" -o -n "$CLIENTMODSONLY" ] && skip "client only testing" && return 0
1322 LOCAL_MDSDEV="$TMP/mdt.img"
1323 SYM_MDSDEV="$TMP/sym_mdt.img"
1325 echo "MDS : $LOCAL_MDSDEV"
1326 echo "SYMLINK : $SYM_MDSDEV"
1330 mkfs.lustre --reformat --fsname=lustre --mdt --mgs --device-size=9000 $LOCAL_MDSDEV ||
1331 error "mkfs.lustre $LOCAL_MDSDEV failed"
1332 ln -s $LOCAL_MDSDEV $SYM_MDSDEV
1334 echo "mount symlink device - $SYM_MDSDEV"
1336 mount_op=`mount -v -t lustre -o loop $SYM_MDSDEV ${MOUNT%/*}/mds 2>&1 | grep "unable to set tunable"`
1337 umount -d ${MOUNT%/*}/mds
1338 rm -f $LOCAL_MDSDEV $SYM_MDSDEV
1340 if [ -n "$mount_op" ]; then
1341 error "**** FAIL: set tunables failed for symlink device"
1345 run_test 37 "verify set tunables works for symlink device"
1347 test_38() { # bug 14222
1352 FILES=`find $SRC -type f -mtime +1 | head -n $COUNT`
1353 log "copying $(echo $FILES | wc -w) files to $DIR/$tdir"
1355 tar cf - $FILES | tar xf - -C $DIR/$tdir || \
1356 error "copying $SRC to $DIR/$tdir"
1358 umount_client $MOUNT
1360 log "rename lov_objid file on MDS"
1361 rm -f $TMP/lov_objid.orig
1363 local dev=${SINGLEMDS}_dev
1364 local MDSDEV=${!dev}
1365 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
1366 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1368 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.orig"
1369 # check create in mds_lov_connect
1373 [ $V ] && log "verifying $DIR/$tdir/$f"
1374 diff -q $f $DIR/$tdir/$f || ERROR=y
1376 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\" $MDSDEV"
1377 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new"
1378 [ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
1380 # check it's updates in sync
1381 umount_client $MOUNT
1384 do_facet $SINGLEMDS dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
1385 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
1386 do_facet $SINGLEMDS "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
1391 [ $V ] && log "verifying $DIR/$tdir/$f"
1392 diff -q $f $DIR/$tdir/$f || ERROR=y
1394 do_facet $SINGLEMDS "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
1395 do_facet $SINGLEMDS "od -Ax -td8 $TMP/lov_objid.new1"
1396 umount_client $MOUNT
1398 [ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
1400 log "files compared the same"
1403 run_test 38 "MDS recreates missing lov_objid file from OST data"
1409 perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
1410 error "memory leak detected" || true
1412 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
1414 test_40() { # bug 15759
1416 #define OBD_FAIL_TGT_TOOMANY_THREADS 0x706
1417 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000706"
1421 run_test 40 "race during service thread startup"
1423 test_41() { #bug 14134
1425 local dev=${SINGLEMDS}_dev
1426 local MDSDEV=${!dev}
1428 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
1429 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
1430 start $SINGLEMDS $MDSDEV $MDS_MOUNT_OPTS -o nomgs
1432 mount_client $MOUNT || return 1
1435 echo "blah blah" > $MOUNT/$tfile
1438 umount_client $MOUNT
1439 stop ost1 -f || return 201
1440 stop_mds -f || return 202
1441 stop_mds -f || return 203
1442 unload_modules || return 204
1445 run_test 41 "mount mds with --nosvc and --nomgs"
1447 test_42() { #bug 14693
1449 check_mount || return 2
1450 do_facet client lctl conf_param lustre.llite.some_wrong_param=10
1451 umount_client $MOUNT
1452 mount_client $MOUNT || return 1
1456 run_test 42 "invalid config param should not prevent client from mounting"
1459 [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip "run as root"
1461 chmod ugo+x $DIR || error "chmod 0 failed"
1463 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1464 "$FSNAME.mdt.root_squash" \
1467 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1468 "$FSNAME.mdt.nosquash_nids" \
1472 # create set of test files
1474 echo "111" > $DIR/$tfile-userfile || error "write 1 failed"
1475 chmod go-rw $DIR/$tfile-userfile || error "chmod 1 failed"
1476 chown $RUNAS_ID.$RUNAS_ID $DIR/$tfile-userfile || error "chown failed"
1478 echo "222" > $DIR/$tfile-rootfile || error "write 2 failed"
1479 chmod go-rw $DIR/$tfile-rootfile || error "chmod 2 faield"
1481 mkdir $DIR/$tdir-rootdir -p || error "mkdir failed"
1482 chmod go-rwx $DIR/$tdir-rootdir || error "chmod 3 failed"
1483 touch $DIR/$tdir-rootdir/tfile-1 || error "touch failed"
1486 # check root_squash:
1487 # set root squash UID:GID to RUNAS_ID
1488 # root should be able to access only files owned by RUNAS_ID
1491 "lctl get_param -n mdt.$FSNAME-MDT0000.root_squash" \
1492 "$FSNAME.mdt.root_squash" \
1493 "$RUNAS_ID:$RUNAS_ID"
1495 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-userfile)
1496 dd if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1497 error "$ST: root read permission is denied"
1498 echo "$ST: root read permission is granted - ok"
1501 dd conv=notrunc if=$DIR/$tfile-userfile 1>/dev/null 2>/dev/null || \
1502 error "$ST: root write permission is denied"
1503 echo "$ST: root write permission is granted - ok"
1505 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1506 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1507 error "$ST: root read permission is granted"
1508 echo "$ST: root read permission is denied - ok"
1511 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null && \
1512 error "$ST: root write permission is granted"
1513 echo "$ST: root write permission is denied - ok"
1515 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1516 rm $DIR/$tdir-rootdir/tfile-1 1>/dev/null 2>/dev/null && \
1517 error "$ST: root unlink permission is granted"
1518 echo "$ST: root unlink permission is denied - ok"
1520 touch $DIR/tdir-rootdir/tfile-2 1>/dev/null 2>/dev/null && \
1521 error "$ST: root create permission is granted"
1522 echo "$ST: root create permission is denied - ok"
1525 # check nosquash_nids:
1526 # put client's NID into nosquash_nids list,
1527 # root should be able to access root file after that
1529 local NIDLIST=$(lctl list_nids all | tr '\n' ' ')
1530 NIDLIST="2@elan $NIDLIST 192.168.0.[2,10]@tcp"
1531 NIDLIST=$(echo $NIDLIST | tr -s ' ' ' ')
1533 "lctl get_param -n mdt.$FSNAME-MDT0000.nosquash_nids" \
1534 "$FSNAME-MDTall.mdt.nosquash_nids" \
1537 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tfile-rootfile)
1538 dd if=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1539 error "$ST: root read permission is denied"
1540 echo "$ST: root read permission is granted - ok"
1543 dd conv=notrunc of=$DIR/$tfile-rootfile 1>/dev/null 2>/dev/null || \
1544 error "$ST: root write permission is denied"
1545 echo "$ST: root write permission is granted - ok"
1547 ST=$(stat -c "%n: owner uid %u (%A)" $DIR/$tdir-rootdir)
1548 rm $DIR/$tdir-rootdir/tfile-1 || \
1549 error "$ST: root unlink permission is denied"
1550 echo "$ST: root unlink permission is granted - ok"
1551 touch $DIR/$tdir-rootdir/tfile-2 || \
1552 error "$ST: root create permission is denied"
1553 echo "$ST: root create permission is granted - ok"
1557 run_test 43 "check root_squash and nosquash_nids"
1559 umount_client $MOUNT
1564 check_mount || return 2
1569 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1570 do_facet client "lctl set_param fail_loc=0x50f"
1573 manual_umount_client --force || return 3
1574 do_facet client "lctl set_param fail_loc=0x0"
1576 mount_client $MOUNT || return 4
1580 run_test 45 "long unlink handling in ptlrpcd"
1585 start_mds || return 1
1586 #first client should see only one ost
1587 start_ost || return 2
1589 mount_client $MOUNT || return 3
1591 start_ost2 || return 4
1592 start ost3 `ostdevname 3` $OST_MOUNT_OPTS || return 5
1593 start ost4 `ostdevname 4` $OST_MOUNT_OPTS || return 6
1594 start ost5 `ostdevname 5` $OST_MOUNT_OPTS || return 7
1595 # wait until ost2-5 is sync
1597 sleep $((TIMEOUT / 4 + 1))
1598 #second client see both ost's
1600 mount_client $MOUNT2 || return 8
1601 $LFS setstripe $MOUNT2 -c -1 || return 9
1602 $LFS getstripe $MOUNT2 || return 10
1604 echo "ok" > $MOUNT2/widestripe
1605 $LFS getstripe $MOUNT2/widestripe || return 11
1606 # fill acl buffer for avoid expand lsm to them
1607 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1608 setfacl -m $acl $MOUNT2/widestripe
1612 stat $MOUNT/widestripe || return 12
1614 umount_client $MOUNT2 || return 13
1615 umount_client $MOUNT || return 14
1616 stop ost5 -f || return 20
1617 stop ost4 -f || return 21
1618 stop ost3 -f || return 22
1619 stop_ost2 || return 23
1620 stop_ost || return 24
1621 stop_mds || return 25
1623 run_test 46a "handle ost additional - wide striped file"
1628 check_mount || return 2
1629 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1633 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1634 if echo $ns | grep "MDT[[:digit:]]*"; then
1637 lrs=$(echo $ns | sed 's/.*lru_size=//')
1638 lru_size[count]=$lrs
1643 facet_failover $SINGLEMDS
1644 df -h $MOUNT || return 3
1647 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1648 if echo $ns | grep "MDT[[:digit:]]*"; then
1651 lrs=$(echo $ns | sed 's/.*lru_size=//')
1652 if ! test "$lrs" -eq "${lru_size[count]}"; then
1653 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1654 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1662 run_test 47 "server restart does not make client loss lru_resize settings"
1667 # reformat after this test is needed - if test will failed
1668 # we will have unkillable file at FS
1672 test_48() { # bug 17636
1675 check_mount || return 2
1677 $LFS setstripe $MOUNT -c -1 || return 9
1678 $LFS getstripe $MOUNT || return 10
1680 echo "ok" > $MOUNT/widestripe
1681 $LFS getstripe $MOUNT/widestripe || return 11
1683 trap cleanup_48 EXIT ERR
1685 # fill acl buffer for avoid expand lsm to them
1686 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1687 setfacl -m $acl $MOUNT/widestripe
1690 stat $MOUNT/widestripe || return 12
1695 run_test 48 "too many acls on file"
1697 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1698 test_49() { # bug 17710
1699 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1700 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1701 local LOCAL_TIMEOUT=20
1704 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1710 check_mount || return 1
1712 echo "check ldlm_timout..."
1713 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1714 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1715 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1717 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1718 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1721 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1722 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1725 umount_client $MOUNT
1726 stop_ost || return 2
1727 stop_mds || return 3
1729 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"
1732 start_mds || return 4
1733 start_ost || return 5
1734 mount_client $MOUNT || return 6
1735 check_mount || return 7
1737 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1738 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1739 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1741 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1742 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1745 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1746 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1749 cleanup || return $?
1751 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1752 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1754 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1757 # Test both statfs and lfs df and fail if either one fails
1758 multiop_bg_pause $1 f_
1761 killall -USR1 multiop
1762 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
1763 wait $PID || { RC1=$?; log "multiop return error "; }
1770 if [ $RC2 -eq 0 ]; then
1772 log "lazystatfs df failed"
1776 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
1782 lctl set_param llite.$FSNAME-*.lazystatfs=1
1785 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
1787 cleanup || return $?
1789 run_test 50a "lazystatfs all servers available =========================="
1793 lctl set_param llite.$FSNAME-*.lazystatfs=1
1796 # Wait for client to detect down OST
1797 stop_ost || error "Unable to stop OST1"
1798 CONN_PROC="osc.$FSNAME-OST0000-osc-[M]*.ost_server_uuid"
1799 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1800 while [ "${CONN_STATE}" = "FULL" ]; do
1802 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1804 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
1806 umount_client $MOUNT || error "Unable to unmount client"
1807 stop_mds || error "Unable to stop MDS"
1809 run_test 50b "lazystatfs all servers down =========================="
1812 start_mds || error "Unable to start MDS"
1813 start_ost || error "Unable to start OST1"
1814 start_ost2 || error "Unable to start OST2"
1815 mount_client $MOUNT || error "Unable to mount client"
1816 lctl set_param llite.$FSNAME-*.lazystatfs=1
1819 # Wait for client to detect down OST
1820 stop_ost || error "Unable to stop OST1"
1821 CONN_PROC="osc.$FSNAME-OST0000-osc-[M]*.ost_server_uuid"
1822 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1823 while [ ${CONN_STATE} = "FULL" ]; do
1825 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1827 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1829 umount_client $MOUNT || error "Unable to unmount client"
1830 stop_ost2 || error "Unable to stop OST2"
1831 stop_mds || error "Unable to stop MDS"
1833 run_test 50c "lazystatfs one server down =========================="
1836 start_mds || error "Unable to start MDS"
1837 start_ost || error "Unable to start OST1"
1838 start_ost2 || error "Unable to start OST2"
1839 mount_client $MOUNT || error "Unable to mount client"
1840 lctl set_param llite.$FSNAME-*.lazystatfs=1
1843 # Issue the statfs during the window where the client still
1844 # belives the OST to be available but it is in fact down.
1845 # No failure just a statfs which hangs for a timeout interval.
1846 stop_ost || error "Unable to stop OST1"
1847 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1849 umount_client $MOUNT || error "Unable to unmount client"
1850 stop_ost2 || error "Unable to stop OST2"
1851 stop_mds || error "Unable to stop MDS"
1853 run_test 50d "lazystatfs client/server conn race =========================="
1858 CONN_PROC="osc.$FSNAME-OST0000-osc-[M]*.ost_server_uuid"
1861 start_mds || return 1
1862 #first client should see only one ost
1863 start_ost || return 2
1864 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1865 while [ "${CONN_STATE}" != "FULL" ]; do
1867 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1870 lctl set_param llite.$FSNAME-*.lazystatfs=0
1872 # Wait for client to detect down OST
1873 stop_ost || error "Unable to stop OST1"
1875 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1876 while [ "${CONN_STATE}" = "FULL" ]; do
1878 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1881 mount_client $MOUNT || error "Unable to mount client"
1883 multiop_bg_pause $MOUNT _f
1887 if [ $RC1 -ne 0 ]; then
1888 log "multiop failed $RC1"
1891 sleep $(( $TIMEOUT+1 ))
1893 [ $? -ne 0 ] && error "process isn't sleep"
1894 start_ost || error "Unable to start OST1"
1895 wait $pid || error "statfs failed"
1898 umount_client $MOUNT || error "Unable to unmount client"
1899 stop_ost || error "Unable to stop OST1"
1900 stop_mds || error "Unable to stop MDS"
1902 run_test 50e "normal statfs all servers down =========================="
1907 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
1909 start_mds || error "Unable to start mds"
1910 #first client should see only one ost
1911 start_ost || error "Unable to start OST1"
1912 start_ost2 || error "Unable to start OST2"
1913 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1914 while [ "${CONN_STATE}" != "FULL" ]; do
1916 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1919 lctl set_param llite.$FSNAME-*.lazystatfs=0
1921 # Wait for client to detect down OST
1922 stop_ost2 || error "Unable to stop OST2"
1924 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1925 while [ "${CONN_STATE}" = "FULL" ]; do
1927 CONN_STATE=`lctl get_param -n $CONN_PROC | cut -f2`
1930 mount_client $MOUNT || error "Unable to mount client"
1932 multiop_bg_pause $MOUNT _f
1936 if [ $RC1 -ne 0 ]; then
1937 log "lazystatfs multiop failed $RC1"
1940 sleep $(( $TIMEOUT+1 ))
1942 [ $? -ne 0 ] && error "process isn't sleep"
1943 start_ost2 || error "Unable to start OST1"
1944 wait $pid || error "statfs failed"
1947 umount_client $MOUNT || error "Unable to unmount client"
1948 stop_ost || error "Unable to stop OST1"
1949 stop_mds || error "Unable to stop MDS"
1952 run_test 50f "normal statfs one server in down =========================="
1956 equals_msg `basename $0`: test complete
1957 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true