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:
15 ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT"
16 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
19 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
21 PTLDEBUG=${PTLDEBUG:--1}
23 LUSTRE=${LUSTRE:-`dirname $0`/..}
24 RLUSTRE=${RLUSTRE:-$LUSTRE}
26 . $LUSTRE/tests/test-framework.sh
28 # STORED_MDSSIZE is used in test_18
29 if [ -n "$MDSSIZE" ]; then
30 STORED_MDSSIZE=$MDSSIZE
32 # use small MDS + OST size to speed formatting time
35 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
37 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
38 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
41 [ "$SLOW" = "no" ] && EXCEPT_SLOW="0 1 2 3 6 7 15 18 24b 25 30 31 32 33 34a 45"
50 local facet=$SINGLEMDS
51 local dev=${facet}_dev
55 # who knows if/where $TUNEFS is installed? Better reformat if it fails...
56 do_facet ${facet} "$TUNEFS --writeconf ${!dev}" || echo "tunefs failed, reformatting instead" && reformat
62 # The MGS must be started before the OSTs for a new fs, so start
63 # and stop to generate the startup logs.
66 wait_osc_import_state mds ost FULL
71 reformat_and_config() {
77 local facet=$SINGLEMDS
78 # we can not use MDSDEV1 here because SINGLEMDS could be set not to mds1 only
79 local num=$(echo $facet | tr -d "mds")
80 local dev=$(mdsdevname $num)
81 echo "start mds service on `facet_active_host $facet`"
82 start $facet ${dev} $MDS_MOUNT_OPTS || return 94
86 echo "stop mds service on `facet_active_host $SINGLEMDS`"
87 # These tests all use non-failover stop
88 stop $SINGLEMDS -f || return 97
92 echo "start ost1 service on `facet_active_host ost1`"
93 start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95
97 echo "stop ost1 service on `facet_active_host ost1`"
98 # These tests all use non-failover stop
99 stop ost1 -f || return 98
103 echo "start ost2 service on `facet_active_host ost2`"
104 start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92
108 echo "stop ost2 service on `facet_active_host ost2`"
109 # These tests all use non-failover stop
110 stop ost2 -f || return 93
115 echo "mount $FSNAME on ${MOUNTPATH}....."
116 zconf_mount `hostname` $MOUNTPATH || return 96
120 local SAVEMOUNTOPT=$MOUNTOPT
121 MOUNTOPT="remount,$1"
123 echo "remount '$1' lustre on ${MOUNTPATH}....."
124 zconf_mount `hostname` $MOUNTPATH || return 96
125 MOUNTOPT=$SAVEMOUNTOPT
130 echo "umount lustre on ${MOUNTPATH}....."
131 zconf_umount `hostname` $MOUNTPATH || return 97
134 manual_umount_client(){
137 echo "manual umount lustre on ${MOUNT}...."
138 do_facet client "umount -d ${FORCE} $MOUNT"
156 stop_mds || return 201
157 stop_ost || return 202
158 unload_modules || return 203
162 umount_client $MOUNT || return 200
163 cleanup_nocli || return $?
167 do_facet client "cp /etc/passwd $DIR/a" || return 71
168 do_facet client "rm $DIR/a" || return 72
169 # make sure lustre is actually mounted (touch will block,
170 # but grep won't, so do it after)
171 do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
172 echo "setup single mount lustre success"
176 do_facet client "touch $DIR/a" || return 71
177 do_facet client "rm $DIR/a" || return 72
178 do_facet client "touch $DIR2/a" || return 73
179 do_facet client "rm $DIR2/a" || return 74
180 echo "setup double mount lustre success"
185 if [ "$ONLY" == "setup" ]; then
190 if [ "$ONLY" == "cleanup" ]; then
197 #create single point mountpoint
203 check_mount || return 41
206 run_test 0 "single mount setup"
210 echo "start ost second time..."
212 check_mount || return 42
215 run_test 1 "start up ost twice (should return errors)"
220 echo "start mds second time.."
223 check_mount || return 43
226 run_test 2 "start up mds twice (should return err)"
230 #mount.lustre returns an error if already in mtab
231 mount_client $MOUNT && return $?
232 check_mount || return 44
235 run_test 3 "mount client twice (should return err)"
239 touch $DIR/$tfile || return 85
243 # ok for ost to fail shutdown
244 if [ 202 -ne $eno ]; then
249 run_test 4 "force cleanup ost, then cleanup"
251 test_5a() { # was test_5
253 touch $DIR/$tfile || return 1
254 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process."
256 stop_mds -f || return 2
258 # cleanup may return an error from the failed
259 # disconnects; for now I'll consider this successful
260 # if all the modules have unloaded.
264 echo "killing umount"
265 kill -TERM $UMOUNT_PID
266 echo "waiting for umount to finish"
268 if grep " $MOUNT " /proc/mounts; then
269 echo "test 5: /proc/mounts after failed umount"
273 echo "killing umount"
274 kill -TERM $UMOUNT_PID
275 echo "waiting for umount to finish"
277 grep " $MOUNT " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11
281 # stop_mds is a no-op here, and should not fail
282 cleanup_nocli || return $?
283 # df may have lingering entry
285 # mtab may have lingering entry
289 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
291 grep -q $MOUNT" " /etc/mtab || break
292 echo "Waiting /etc/mtab updated ... "
293 WAIT=$(( WAIT + sleep))
295 [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs"
296 echo "/etc/mtab updated in $WAIT secs"
298 run_test 5a "force cleanup mds, then cleanup"
302 [ -d $MOUNT ] || mkdir -p $MOUNT
303 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
304 mount_client $MOUNT && return 1
305 grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
307 # stop_mds is a no-op here, and should not fail
308 cleanup_nocli || return $?
311 run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)"
316 [ -d $MOUNT ] || mkdir -p $MOUNT
317 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10
318 local oldfs="${FSNAME}"
319 FSNAME="wrong.${FSNAME}"
320 mount_client $MOUNT || :
322 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11
324 cleanup_nocli || return $?
326 run_test 5c "cleanup after failed mount (bug 2712) (should return errs)"
332 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10
333 mount_client $MOUNT || return 1
335 grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11
338 run_test 5d "mount with ost down"
344 #define OBD_FAIL_PTLRPC_DELAY_SEND 0x506
345 do_facet client "lctl set_param fail_loc=0x80000506"
346 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10
347 mount_client $MOUNT || echo "mount failed (not fatal)"
349 grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11
352 run_test 5e "delayed connect, don't crash (bug 10268)"
357 mount_client ${MOUNT} || return 87
358 touch $DIR/a || return 86
361 run_test 6 "manual umount, then mount again"
366 cleanup_nocli || return $?
368 run_test 7 "manual umount, then cleanup"
373 check_mount2 || return 45
374 umount_client $MOUNT2
377 run_test 8 "double mount setup"
382 do_facet ost1 lctl set_param debug=\'inode trace\' || return 1
383 do_facet ost1 lctl set_param subsystem_debug=\'mds ost\' || return 1
385 CHECK_PTLDEBUG="`do_facet ost1 lctl get_param -n debug`"
386 if [ "$CHECK_PTLDEBUG" ] && { \
387 [ "$CHECK_PTLDEBUG" = "trace inode warning error emerg console" ] ||
388 [ "$CHECK_PTLDEBUG" = "trace inode" ]; }; then
389 echo "lnet.debug success"
391 echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'"
394 CHECK_SUBSYS="`do_facet ost1 lctl get_param -n subsystem_debug`"
395 if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then
396 echo "lnet.subsystem_debug success"
398 echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'"
401 stop_ost || return $?
404 run_test 9 "test ptldebug and subsystem for mkfs"
406 # LOGS/PENDING do not exist anymore since CMD3
408 local TMPMTPT="${TMP}/conf16"
409 local dev=${SINGLEMDS}_dev
411 if [ ! -e "$MDSDEV" ]; then
412 log "no $MDSDEV existing, so mount Lustre to create one"
414 check_mount || return 41
418 [ -f "$MDSDEV" ] && LOOPOPT="-o loop"
420 log "change the mode of $MDSDEV/OBJECTS to 555"
421 do_facet $SINGLEMDS "mkdir -p $TMPMTPT &&
422 mount $LOOPOPT -t $FSTYPE $MDSDEV $TMPMTPT &&
423 chmod 555 $TMPMTPT/OBJECTS &&
424 umount $TMPMTPT" || return $?
426 log "mount Lustre to change the mode of OBJECTS, then umount Lustre"
428 check_mount || return 41
431 log "read the mode of OBJECTS and check if they has been changed properly"
432 EXPECTEDOBJECTSMODE=`do_facet $SINGLEMDS "$DEBUGFS -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
434 if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
435 log "Success:Lustre change the mode of OBJECTS correctly"
437 error "Lustre does not change mode of OBJECTS properly"
440 run_test 16 "verify that lustre will correct the mode of OBJECTS"
443 local dev=${SINGLEMDS}_dev
446 if [ ! -e "$MDSDEV" ]; then
447 echo "no $MDSDEV existing, so mount Lustre to create one"
449 check_mount || return 41
453 echo "Remove mds config log"
454 do_facet $SINGLEMDS "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
457 start_mds && return 42
460 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
463 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return
465 local dev=${SINGLEMDS}_dev
471 # check if current MDSSIZE is large enough
472 [ $MDSSIZE -ge $MIN ] && OK=1 && myMDSSIZE=$MDSSIZE && \
473 log "use MDSSIZE=$MDSSIZE"
475 # check if the global config has a large enough MDSSIZE
476 [ -z "$OK" -a ! -z "$STORED_MDSSIZE" ] && [ $STORED_MDSSIZE -ge $MIN ] && \
477 OK=1 && myMDSSIZE=$STORED_MDSSIZE && \
478 log "use STORED_MDSSIZE=$STORED_MDSSIZE"
480 # check if the block device is large enough
481 [ -z "$OK" -a -b $MDSDEV ] && \
482 [ "$(dd if=$MDSDEV of=/dev/null bs=1k count=1 skip=$MIN 2>&1 |
483 awk '($3 == "in") { print $1 }')" = "1+0" ] && OK=1 && \
484 myMDSSIZE=$MIN && log "use device $MDSDEV with MIN=$MIN"
486 # check if a loopback device has enough space for fs metadata (5%)
487 [ -z "$OK" ] && [ -f $MDSDEV -o ! -e $MDSDEV ] &&
488 SPACE=$(df -P $(dirname $MDSDEV) |
489 awk '($1 != "Filesystem") {print $4}') &&
490 [ $SPACE -gt $((MIN / 20)) ] && OK=1 && myMDSSIZE=$MIN && \
491 log "use file $MDSDEV with MIN=$MIN"
493 [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
496 echo "mount mds with large journal..."
497 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
499 MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
502 echo "mount lustre system..."
504 check_mount || return 41
506 echo "check journal size..."
507 local FOUNDSIZE=`do_facet mds "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
508 if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
509 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
511 error "expected journal size > 32M, found $((FOUNDSIZE >> 20))M"
516 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
519 run_test 18 "check mkfs creates large journals"
522 start_mds || return 1
523 stop_mds -f || return 2
525 run_test 19a "start/stop MDS without OSTs"
528 start_ost || return 1
529 stop_ost -f || return 2
531 run_test 19b "start/stop OSTs without MDS"
534 # first format the ost/mdt
538 check_mount || return 43
540 remount_client ro $MOUNT || return 44
541 touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
542 [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
543 remount_client rw $MOUNT || return 47
545 [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
546 MCNT=`grep -c $MOUNT /etc/mtab`
547 [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
552 run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
557 wait_osc_import_state mds ost FULL
561 run_test 21a "start mds before ost, stop ost first"
566 wait_osc_import_state mds ost FULL
570 run_test 21b "start ost before mds, stop mds first"
576 wait_osc_import_state mds ost2 FULL
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
591 wait_osc_import_state mds ost FULL
594 # check_mount will block trying to contact ost
598 echo Client mount with a running ost
601 # if gss enabled, wait full time to let connection from
602 # mds to ost be established, due to the mismatch between
603 # initial connect timeout and gss context negotiation timeout.
604 # This perhaps could be remove after AT landed.
605 echo "sleep $((TIMEOUT + TIMEOUT + TIMEOUT))s"
606 sleep $((TIMEOUT + TIMEOUT + TIMEOUT))
609 check_mount || return 41
614 run_test 22 "start a client before osts (should return errs)"
616 test_23a() { # was test_23
620 # force down client so that recovering mds waits for reconnect
621 local running=$(grep -c $MOUNT /proc/mounts) || true
622 if [ $running -ne 0 ]; then
623 echo "Stopping client $MOUNT (opts: -f)"
627 # enter recovery on mds
629 # try to start a new client
630 mount_client $MOUNT &
632 MOUNT_PID=$(ps -ef | grep "t lustre" | grep -v grep | awk '{print $2}')
633 MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
634 echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
636 ps --ppid $MOUNT_LUSTRE_PID
637 # FIXME why o why can't I kill these? Manual "ctrl-c" works...
638 kill -TERM $MOUNT_LUSTRE_PID
639 echo "waiting for mount to finish"
641 # we can not wait $MOUNT_PID because it is not a child of this shell
647 while [ "$WAIT" -lt "$MAX_WAIT" ]; do
649 PID1=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_PID)
650 PID2=$(ps -ef | awk '{print $2}' | grep -w $MOUNT_LUSTRE_PID)
653 [ -z "$PID1" -a -z "$PID2" ] && break
654 echo "waiting for mount to finish ... "
655 WAIT=$(( WAIT + sleep))
657 [ "$WAIT" -eq "$MAX_WAIT" ] && error "MOUNT_PID $MOUNT_PID and \
658 MOUNT__LUSTRE_PID $MOUNT__LUSTRE_PID still not killed in $WAIT secs"
663 run_test 23a "interrupt client during recovery mount delay"
668 test_23b() { # was test_23
671 # Simulate -EINTR during mount OBD_FAIL_LDLM_CLOSE_THREAD
672 lctl set_param fail_loc=0x80000313
676 run_test 23b "Simulate -EINTR during mount"
678 fs2mds_HOST=$mds_HOST
679 fs2ost_HOST=$ost_HOST
683 echo "umount $MOUNT2 ..."
684 umount $MOUNT2 || true
685 echo "stopping fs2mds ..."
686 stop fs2mds -f || true
687 echo "stopping fs2ost ..."
688 stop fs2ost -f || true
695 [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
696 if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
697 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
698 skip_env "mixed loopback and real device not working" && return
701 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
702 local fs2ostdev=${fs2ost_DEV:-$(ostdevname 1)_2}
704 # test 8-char fsname as well
705 local FSNAME2=test1234
706 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat $fs2mdsdev || exit 10
708 add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
711 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_24a EXIT INT
712 start fs2ost $fs2ostdev $OST_MOUNT_OPTS
714 mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
716 check_mount || return 2
717 # files written on 1 should not show up on 2
718 cp /etc/passwd $DIR/$tfile
720 [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
723 cp /etc/passwd $MOUNT2/b || return 3
724 rm $MOUNT2/b || return 4
725 # 2 is actually mounted
726 grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
728 facet_failover fs2mds
729 facet_failover fs2ost
732 # the MDS must remain up until last MDT
734 MDS=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
735 [ -z "$MDS" ] && error "No MDT" && return 8
737 cleanup_nocli || return 6
739 run_test 24a "Multiple MDTs on a single node"
742 if [ -z "$fs2mds_DEV" ]; then
743 do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
744 skip_env "mixed loopback and real device not working" && return
747 local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
749 add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
751 start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
754 run_test 24b "Multiple MGSs on a single node (should return err)"
758 check_mount || return 2
759 local MODULES=$($LCTL modules | awk '{ print $2 }')
760 rmmod $MODULES 2>/dev/null || true
763 run_test 25 "Verify modules are referenced"
767 # we need modules before mount for sysctl, so make sure...
768 do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
769 #define OBD_FAIL_MDS_FS_SETUP 0x135
770 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
771 start_mds && echo MDS started && return 1
772 lctl get_param -n devices
773 DEVS=$(lctl get_param -n devices | wc -l)
774 [ $DEVS -gt 0 ] && return 2
775 unload_modules || return 203
777 run_test 26 "MDT startup failure cleans LOV (should return errs)"
783 local ORIG=$(do_facet $myfacet "$TEST")
784 if [ $# -gt 3 ]; then
790 echo "Setting $PARAM from $ORIG to $FINAL"
791 do_facet $SINGLEMDS "$LCTL conf_param $PARAM='$FINAL'" || error conf_param failed
793 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" || error check failed!
797 start_ost || return 1
798 start_mds || return 2
799 echo "Requeue thread should have started: "
800 ps -e | grep ll_cfg_requeue
801 set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
804 run_test 27a "Reacquire MGS lock if OST started first"
809 local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
811 facet_failover $SINGLEMDS
812 set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
813 set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
817 run_test 27b "Reacquire MGS lock after failover"
821 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
822 PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
825 set_and_check client "$TEST" "$PARAM" $FINAL || return 3
826 FINAL=$(($FINAL + 1))
827 set_and_check client "$TEST" "$PARAM" $FINAL || return 4
828 umount_client $MOUNT || return 200
831 if [ $RESULT -ne $FINAL ]; then
832 echo "New config not seen: wanted $FINAL got $RESULT"
835 echo "New config success: got $RESULT"
837 set_and_check client "$TEST" "$PARAM" $ORIG || return 5
840 run_test 28 "permanent parameter setting"
843 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
844 setup > /dev/null 2>&1
848 local PARAM="$FSNAME-OST0001.osc.active"
849 local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
850 local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
852 ACTV=$(lctl get_param -n $PROC_ACT)
854 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
855 # also check ost_server_uuid status
856 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
857 if [ -z "$RESULT" ]; then
858 echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
861 echo "Live client success: got $RESULT"
865 local MPROC="osc.$FSNAME-OST0001-osc-[M]*.active"
870 RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
871 [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
872 if [ $RESULT -eq $DEAC ]; then
873 echo "MDT deactivated also after $WAIT sec (got $RESULT)"
877 if [ $WAIT -eq $MAX ]; then
878 echo "MDT not deactivated: wanted $DEAC got $RESULT"
881 echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
884 # test new client starts deactivated
885 umount_client $MOUNT || return 200
887 RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
888 if [ -z "$RESULT" ]; then
889 echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
892 echo "New client success: got $RESULT"
895 # make sure it reactivates
896 set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
901 #writeconf to remove all ost2 traces for subsequent tests
904 run_test 29 "permanently remove an OST"
909 TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
911 LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
912 for i in ${LIST[@]}; do
913 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
915 # make sure client restart still works
917 mount_client $MOUNT || return 4
918 [ "$($TEST)" -ne "$i" ] && return 5
919 set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
922 run_test 30 "Big config llog"
924 test_31() { # bug 10734
925 # ipaddr must not exist
926 mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
929 run_test 31 "Connect to non-existent node (shouldn't crash)"
931 # Use these start32/stop32 fn instead of t-f start/stop fn,
932 # for local devices, to skip global facet vars init
936 echo "Stopping local ${MOUNT%/*}/${facet} (opts:$@)"
937 umount -d $@ ${MOUNT%/*}/${facet}
946 mkdir -p ${MOUNT%/*}/${facet}
948 echo "Starting local ${facet}: $@ $device ${MOUNT%/*}/${facet}"
949 mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
951 if [ $RC -ne 0 ]; then
952 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
953 echo "Start of ${device} of local ${facet} failed ${RC}"
967 echo "Cleanup test_32 umount $MOUNT ..."
968 umount -f $MOUNT || true
969 echo "Cleanup local mds ost1 ..."
975 client_only && skip "client only testing" && return 0
976 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
977 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return 0
979 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
980 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
981 local tmpdir=$TMP/conf32a
983 tar xjvf $DISK1_8 -C $tmpdir || \
984 { skip_env "Cannot untar $DISK1_8" && return 0; }
987 $LCTL set_param debug=$PTLDEBUG
989 $TUNEFS $tmpdir/mds || error "tunefs failed"
991 # nids are wrong, so client wont work, but server should start
992 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
993 trap cleanup_32 EXIT INT || return 3
995 local UUID=$($LCTL get_param -n mdt.lustre-MDT0000.uuid)
997 [ "$UUID" == "lustre-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
999 $TUNEFS --mgsnode=$HOSTNAME $tmpdir/ost1 || error "tunefs failed"
1000 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1001 UUID=$($LCTL get_param -n obdfilter.lustre-OST0000.uuid)
1003 [ "$UUID" == "lustre-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1005 local NID=$($LCTL list_nids | head -1)
1007 echo "OSC changes should succeed:"
1008 $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
1009 $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 echo "LOV changes should succeed:"
1018 $LCTL pool_new lustre.interop || return 11
1019 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
1024 # mount a second time to make sure we didnt leave upgrade flag on
1026 $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
1027 start32 mds1 $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
1028 trap cleanup_32 EXIT INT || return 12
1032 rm -rf $tmpdir || true # true is only for TMP on NFS
1034 run_test 32a "Upgrade from 1.8 (not live)"
1037 client_only && skip "client only testing" && return 0
1038 [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
1039 [ -z "$TUNEFS" ] && skip_env "No tunefs" && return
1041 local DISK1_8=$LUSTRE/tests/disk1_8.tar.bz2
1042 [ ! -r $DISK1_8 ] && skip_env "Cannot find $DISK1_8" && return 0
1043 local tmpdir=$TMP/conf32b
1045 tar xjvf $DISK1_8 -C $tmpdir || \
1046 { skip_env "Cannot untar $DISK1_8" && return ; }
1049 $LCTL set_param debug=$PTLDEBUG
1050 local NEWNAME=lustre
1052 # writeconf will cause servers to register with their current nids
1053 $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
1054 start32 mds1 $tmpdir/mds "-o loop" && \
1055 trap cleanup_32 EXIT INT || return 3
1057 local UUID=$($LCTL get_param -n mdt.${NEWNAME}-MDT0000.uuid)
1059 [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
1061 $TUNEFS --mgsnode=$HOSTNAME --writeconf --fsname=$NEWNAME $tmpdir/ost1 || error "tunefs failed"
1062 start32 ost1 $tmpdir/ost1 "-o loop" || return 5
1063 UUID=$($LCTL get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
1065 [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
1067 local NID=$($LCTL list_nids | head -1)
1069 echo "OSC changes should succeed:"
1070 $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
1071 $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
1074 echo "MDC changes should succeed:"
1075 $LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
1076 $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
1079 echo "LOV changes should succeed:"
1080 $LCTL pool_new lustre.interop || return 11
1081 $LCTL conf_param lustre-MDT0000.lov.stripesize=4M || return 12
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_env "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_env "mixed loopback and real device not working" && return
1259 [ $OSTCOUNT -lt 2 ] && skip_env "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 client_only && 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,force
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_env "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
1565 UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
1567 UUIDS=$(do_facet mds "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
1568 for VAL in $UUIDS; do
1569 NID=$(echo $VAL | cut -d= -f1)
1570 CLUUID=$(echo $VAL | cut -d= -f2)
1571 [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
1573 [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
1577 run_test 44 "mounted client proc entry exists"
1581 check_mount || return 2
1586 #define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
1587 do_facet client "lctl set_param fail_loc=0x50f"
1590 manual_umount_client --force || return 3
1591 do_facet client "lctl set_param fail_loc=0x0"
1593 mount_client $MOUNT || return 4
1597 run_test 45 "long unlink handling in ptlrpcd"
1604 umount_client $MOUNT2 || rc=$?
1605 umount_client $MOUNT || rc=$?
1606 while [ $count -gt 0 ]; do
1607 stop ost${count} -f || rc=$?
1611 # writeconf is needed after the test, otherwise,
1612 # we might end up with extra OSTs
1614 cleanup_nocli || rc=$?
1619 echo "Testing with $OSTCOUNT OSTs"
1621 start_mds || return 1
1622 #first client should see only one ost
1623 start_ost || return 2
1624 wait_osc_import_state mds ost FULL
1626 mount_client $MOUNT || return 3
1627 trap "cleanup_46a $OSTCOUNT" EXIT ERR
1630 for (( i=2; i<=$OSTCOUNT; i++ )); do
1631 start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
1634 # wait until osts in sync
1635 for (( i=2; i<=$OSTCOUNT; i++ )); do
1636 wait_osc_import_state mds ost$i FULL
1640 #second client see all ost's
1642 mount_client $MOUNT2 || return 8
1643 $LFS setstripe $MOUNT2 -c -1 || return 9
1644 $LFS getstripe $MOUNT2 || return 10
1646 echo "ok" > $MOUNT2/widestripe
1647 $LFS getstripe $MOUNT2/widestripe || return 11
1648 # fill acl buffer for avoid expand lsm to them
1649 awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
1650 setfacl -m $acl $MOUNT2/widestripe
1654 stat $MOUNT/widestripe || return 12
1656 cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
1659 run_test 46a "handle ost additional - wide striped file"
1664 check_mount || return 2
1665 $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
1669 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1670 if echo $ns | grep "MDT[[:digit:]]*"; then
1673 lrs=$(echo $ns | sed 's/.*lru_size=//')
1674 lru_size[count]=$lrs
1679 facet_failover $SINGLEMDS
1680 df -h $MOUNT || return 3
1683 for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
1684 if echo $ns | grep "MDT[[:digit:]]*"; then
1687 lrs=$(echo $ns | sed 's/.*lru_size=//')
1688 if ! test "$lrs" -eq "${lru_size[count]}"; then
1689 n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
1690 error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
1698 run_test 47 "server restart does not make client loss lru_resize settings"
1703 # reformat after this test is needed - if test will failed
1704 # we will have unkillable file at FS
1708 test_48() { # bug 17636
1711 check_mount || return 2
1713 $LFS setstripe $MOUNT -c -1 || return 9
1714 $LFS getstripe $MOUNT || return 10
1716 echo "ok" > $MOUNT/widestripe
1717 $LFS getstripe $MOUNT/widestripe || return 11
1719 trap cleanup_48 EXIT ERR
1721 # fill acl buffer for avoid expand lsm to them
1722 getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
1723 setfacl -m $acl $MOUNT/widestripe
1726 stat $MOUNT/widestripe || return 12
1731 run_test 48 "too many acls on file"
1733 # check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
1734 test_49() { # bug 17710
1735 local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
1736 local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
1737 local LOCAL_TIMEOUT=20
1740 OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
1746 check_mount || return 1
1748 echo "check ldlm_timout..."
1749 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1750 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1751 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1753 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1754 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1757 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
1758 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1761 umount_client $MOUNT
1762 stop_ost || return 2
1763 stop_mds || return 3
1765 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"
1768 start_mds || return 4
1769 start_ost || return 5
1770 mount_client $MOUNT || return 6
1771 check_mount || return 7
1773 LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
1774 LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
1775 LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
1777 if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
1778 error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
1781 if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
1782 error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
1785 cleanup || return $?
1787 MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
1788 OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
1790 run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
1793 # Test both statfs and lfs df and fail if either one fails
1794 multiop_bg_pause $1 f_
1797 killall -USR1 multiop
1798 [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
1799 wait $PID || { RC1=$?; log "multiop return error "; }
1806 if [ $RC2 -eq 0 ]; then
1808 log "lazystatfs df failed"
1812 [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
1818 lctl set_param llite.$FSNAME-*.lazystatfs=1
1821 lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
1823 cleanup || return $?
1825 run_test 50a "lazystatfs all servers available =========================="
1829 lctl set_param llite.$FSNAME-*.lazystatfs=1
1832 # Wait for client to detect down OST
1833 stop_ost || error "Unable to stop OST1"
1834 wait_osc_import_state mds ost DISCONN
1836 lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
1838 umount_client $MOUNT || error "Unable to unmount client"
1839 stop_mds || error "Unable to stop MDS"
1841 run_test 50b "lazystatfs all servers down =========================="
1844 start_mds || error "Unable to start MDS"
1845 start_ost || error "Unable to start OST1"
1846 start_ost2 || error "Unable to start OST2"
1847 mount_client $MOUNT || error "Unable to mount client"
1848 lctl set_param llite.$FSNAME-*.lazystatfs=1
1851 # Wait for client to detect down OST
1852 stop_ost || error "Unable to stop OST1"
1853 wait_osc_import_state mds ost DISCONN
1854 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1856 umount_client $MOUNT || error "Unable to unmount client"
1857 stop_ost2 || error "Unable to stop OST2"
1858 stop_mds || error "Unable to stop MDS"
1860 run_test 50c "lazystatfs one server down =========================="
1863 start_mds || error "Unable to start MDS"
1864 start_ost || error "Unable to start OST1"
1865 start_ost2 || error "Unable to start OST2"
1866 mount_client $MOUNT || error "Unable to mount client"
1867 lctl set_param llite.$FSNAME-*.lazystatfs=1
1870 # Issue the statfs during the window where the client still
1871 # belives the OST to be available but it is in fact down.
1872 # No failure just a statfs which hangs for a timeout interval.
1873 stop_ost || error "Unable to stop OST1"
1874 lazystatfs $MOUNT || error "lazystatfs failed with one down server"
1876 umount_client $MOUNT || error "Unable to unmount client"
1877 stop_ost2 || error "Unable to stop OST2"
1878 stop_mds || error "Unable to stop MDS"
1880 run_test 50d "lazystatfs client/server conn race =========================="
1887 start_mds || return 1
1888 #first client should see only one ost
1889 start_ost || return 2
1890 wait_osc_import_state mds ost FULL
1892 # Wait for client to detect down OST
1893 stop_ost || error "Unable to stop OST1"
1894 wait_osc_import_state mds ost DISCONN
1896 mount_client $MOUNT || error "Unable to mount client"
1897 lctl set_param llite.$FSNAME-*.lazystatfs=0
1899 multiop_bg_pause $MOUNT _f
1903 if [ $RC1 -ne 0 ]; then
1904 log "multiop failed $RC1"
1907 sleep $(( $TIMEOUT+1 ))
1909 [ $? -ne 0 ] && error "process isn't sleep"
1910 start_ost || error "Unable to start OST1"
1911 wait $pid || error "statfs failed"
1914 umount_client $MOUNT || error "Unable to unmount client"
1915 stop_ost || error "Unable to stop OST1"
1916 stop_mds || error "Unable to stop MDS"
1918 run_test 50e "normal statfs all servers down =========================="
1923 CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
1925 start_mds || error "Unable to start mds"
1926 #first client should see only one ost
1927 start_ost || error "Unable to start OST1"
1928 wait_osc_import_state mds ost FULL
1930 start_ost2 || error "Unable to start OST2"
1931 wait_osc_import_state mds ost2 FULL
1933 # Wait for client to detect down OST
1934 stop_ost2 || error "Unable to stop OST2"
1936 wait_osc_import_state mds ost2 DISCONN
1937 mount_client $MOUNT || error "Unable to mount client"
1938 lctl set_param llite.$FSNAME-*.lazystatfs=0
1940 multiop_bg_pause $MOUNT _f
1944 if [ $RC1 -ne 0 ]; then
1945 log "lazystatfs multiop failed $RC1"
1948 sleep $(( $TIMEOUT+1 ))
1950 [ $? -ne 0 ] && error "process isn't sleep"
1951 start_ost2 || error "Unable to start OST2"
1952 wait $pid || error "statfs failed"
1953 stop_ost2 || error "Unable to stop OST2"
1956 umount_client $MOUNT || error "Unable to unmount client"
1957 stop_ost || error "Unable to stop OST1"
1958 stop_mds || error "Unable to stop MDS"
1961 run_test 50f "normal statfs one server in down =========================="
1964 local LOCAL_TIMEOUT=20
1970 check_mount || return 1
1973 $LFS setstripe -c -1 $MOUNT/d1
1974 #define OBD_FAIL_MDS_REINT_DELAY 0x142
1975 do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
1976 touch $MOUNT/d1/f1 &
1979 start_ost2 || return 2
1981 stop_ost2 || return 3
1984 run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
1993 do_node $node mkdir -p $dest
1994 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
1996 do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
1997 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
1998 [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
2000 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
2001 [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
2011 local backup2=${TMP}/backup2
2013 do_node $node mkdir -p $backup2
2014 [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
2016 do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
2017 [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
2018 [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
2020 do_node $node "diff -rq $backup $backup2"
2021 [ $? -eq 0 ] || { error "contents differ"; return 3; }
2023 local xattrs2=${TMP}/xattrs2
2024 do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
2025 [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
2027 do_node $node "diff $xattrs $xattrs2"
2028 [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
2030 do_node $node "rm -rf $backup2 $xattrs2"
2031 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
2036 [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
2038 [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
2040 [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
2043 local ost1mnt=${MOUNT%/*}/ost1
2044 local ost1node=$(facet_active_host ost1)
2045 local ost1tmp=$TMP/conf52
2048 [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
2049 touch $TMP/modified_first
2050 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
2051 do_node $ost1node "mkdir -p $ost1tmp && touch $ost1tmp/modified_first"
2052 [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
2055 $LFS setstripe $DIR/$tdir -c -1 -s 1M
2056 [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
2058 for (( i=0; i < nrfiles; i++ )); do
2059 multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
2060 [ $? -eq 0 ] || { error "multiop failed"; return 8; }
2066 echo backup files to $TMP/files
2067 local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
2068 copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2069 [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
2071 umount_client $MOUNT
2072 [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
2074 [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
2076 echo mount ost1 as ldiskfs
2077 do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
2078 [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
2081 echo backup objects to $ost1tmp/objects
2082 local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
2083 '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
2084 copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2085 [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
2087 # move objects to lost+found
2088 do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
2089 [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
2092 do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
2093 [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
2095 # compare restored objects against saved ones
2096 diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
2097 [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
2099 do_node $ost1node "umount $ost1_dev"
2100 [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
2103 [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
2105 [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
2108 diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
2109 [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
2111 rm -rf $TMP/files $TMP/file_xattrs
2112 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
2113 do_node $ost1node "rm -rf $ost1tmp"
2114 [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
2117 run_test 52 "check recovering objects from lost+found"
2120 equals_msg `basename $0`: test complete
2121 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true