+test_19a() {
+ start_mds || return 1
+ stop_mds -f || return 2
+}
+run_test 19a "start/stop MDS without OSTs"
+
+test_19b() {
+ start_ost || return 1
+ stop_ost -f || return 2
+}
+run_test 19b "start/stop OSTs without MDS"
+
+test_20() {
+ # first format the ost/mdt
+ start_ost
+ start_mds
+ mount_client $MOUNT
+ check_mount || return 43
+ rm -f $DIR/$tfile
+ remount_client ro $MOUNT || return 44
+ touch $DIR/$tfile && echo "$DIR/$tfile created incorrectly" && return 45
+ [ -e $DIR/$tfile ] && echo "$DIR/$tfile exists incorrectly" && return 46
+ remount_client rw $MOUNT || return 47
+ touch $DIR/$tfile
+ [ ! -f $DIR/$tfile ] && echo "$DIR/$tfile missing" && return 48
+ MCNT=`grep -c $MOUNT /etc/mtab`
+ [ "$MCNT" -ne 1 ] && echo "$MOUNT in /etc/mtab $MCNT times" && return 49
+ umount_client $MOUNT
+ stop_mds
+ stop_ost
+}
+run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
+
+test_21a() {
+ start_mds
+ start_ost
+ stop_ost
+ stop_mds
+}
+run_test 21a "start mds before ost, stop ost first"
+
+test_21b() {
+ start_ost
+ start_mds
+ stop_mds
+ stop_ost
+}
+run_test 21b "start ost before mds, stop mds first"
+
+test_21c() {
+ start_ost
+ start_mds
+ start_ost2
+ stop_ost
+ stop_ost2
+ stop_mds
+}
+run_test 21c "start mds between two osts, stop mds last"
+
+test_22() {
+ #reformat to remove all logs
+ reformat
+ start_mds
+ echo Client mount before any osts are in the logs
+ mount_client $MOUNT
+ check_mount && return 41
+ pass
+
+ echo Client mount with ost in logs, but none running
+ start_ost
+ stop_ost
+ mount_client $MOUNT
+ # check_mount will block trying to contact ost
+ umount_client $MOUNT
+ pass
+
+ echo Client mount with a running ost
+ start_ost
+ mount_client $MOUNT
+ sleep 5 #bz10476
+ check_mount || return 41
+ pass
+
+ cleanup
+}
+run_test 22 "start a client before osts (should return errs)"
+
+test_23() {
+ setup
+ # fail mds
+ stop mds
+ # force down client so that recovering mds waits for reconnect
+ zconf_umount `hostname` $MOUNT -f
+ # enter recovery on mds
+ start_mds
+ # try to start a new client
+ mount_client $MOUNT &
+ MOUNT_PID=$!
+ sleep 5
+ MOUNT_LUSTRE_PID=`ps -ef | grep mount.lustre | grep -v grep | awk '{print $2}'`
+ echo mount pid is ${MOUNT_PID}, mount.lustre pid is ${MOUNT_LUSTRE_PID}
+ ps --ppid $MOUNT_PID
+ ps --ppid $MOUNT_LUSTRE_PID
+ # FIXME why o why can't I kill these? Manual "ctrl-c" works...
+ kill -TERM $MOUNT_PID
+ echo "waiting for mount to finish"
+ ps -ef | grep mount
+ wait $MOUNT_PID
+
+ stop_mds
+ stop_ost
+}
+#this test isn't working yet
+#run_test 23 "interrupt client during recovery mount delay"
+
+test_24a() {
+ local fs2mds_HOST=$mds_HOST
+ # test 8-char fsname as well
+ local FSNAME2=test1234
+ add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME2} --nomgs --mgsnode=$MGSNID --reformat ${MDSDEV}_2 || exit 10
+
+ local fs2ost_HOST=$ost_HOST
+ local fs2ostdev=$(ostdevname 1)_2
+ add fs2ost $OST_MKFS_OPTS --fsname=${FSNAME2} --reformat $fs2ostdev || exit 10
+
+ setup
+ start fs2mds ${MDSDEV}_2 $MDS_MOUNT_OPTS
+ start fs2ost $fs2ostdev $OST_MOUNT_OPTS
+ mkdir -p $MOUNT2
+ mount -t lustre $MGSNID:/${FSNAME2} $MOUNT2 || return 1
+ # 1 still works
+ check_mount || return 2
+ # files written on 1 should not show up on 2
+ cp /etc/passwd $DIR/$tfile
+ sleep 10
+ [ -e $MOUNT2/$tfile ] && error "File bleed" && return 7
+ # 2 should work
+ cp /etc/passwd $MOUNT2/b || return 3
+ rm $MOUNT2/b || return 4
+ # 2 is actually mounted
+ grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
+ # failover
+ facet_failover fs2mds
+ facet_failover fs2ost
+ df
+ umount_client $MOUNT
+ # the MDS must remain up until last MDT
+ stop_mds
+ MDS=$(awk '($3 ~ "mdt" && $4 ~ "MDS") { print $4 }' $LPROC/devices)
+ [ -z "$MDS" ] && error "No MDS" && return 8
+ umount $MOUNT2
+ stop fs2mds -f
+ stop fs2ost -f
+ cleanup_nocli || return 6
+}
+run_test 24a "Multiple MDTs on a single node"
+
+test_24b() {
+ local fs2mds_HOST=$mds_HOST
+ add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat ${MDSDEV}_2 || exit 10
+ setup
+ start fs2mds ${MDSDEV}_2 $MDS_MOUNT_OPTS && return 2
+ cleanup || return 6
+}
+run_test 24b "Multiple MGSs on a single node (should return err)"
+
+test_25() {
+ setup
+ check_mount || return 2
+ local MODULES=$($LCTL modules | awk '{ print $2 }')
+ rmmod $MODULES 2>/dev/null || true
+ cleanup || return 6
+}
+run_test 25 "Verify modules are referenced"
+
+test_26() {
+ load_modules
+ # we need modules before mount for sysctl, so make sure...
+ [ -z "$(lsmod | grep lustre)" ] && modprobe lustre
+#define OBD_FAIL_MDS_FS_SETUP 0x135
+ sysctl -w lustre.fail_loc=0x80000135
+ start_mds && echo MDS started && return 1
+ cat $LPROC/devices
+ DEVS=$(cat $LPROC/devices | wc -l)
+ [ $DEVS -gt 0 ] && return 2
+ unload_modules || return 203
+}
+run_test 26 "MDT startup failure cleans LOV (should return errs)"
+
+set_and_check() {
+ local TEST=$1
+ local PARAM=$2
+ local ORIG=$($TEST)
+ if [ $# -gt 2 ]; then
+ local FINAL=$3
+ else
+ local -i FINAL
+ FINAL=$(($ORIG + 5))
+ fi
+ echo "Setting $PARAM from $ORIG to $FINAL"
+ $LCTL conf_param $PARAM=$FINAL
+ local RESULT
+ local MAX=20
+ local WAIT=0
+ while [ 1 ]; do
+ sleep 5
+ RESULT=$($TEST)
+ if [ $RESULT -eq $FINAL ]; then
+ echo "Updated config after $WAIT sec (got $RESULT)"
+ break
+ fi
+ WAIT=$((WAIT + 5))
+ if [ $WAIT -eq $MAX ]; then
+ echo "Config update not seen: wanted $FINAL got $RESULT"
+ return 3
+ fi
+ echo "Waiting $(($MAX - $WAIT)) secs for config update"
+ done
+}
+
+test_27a() {
+ start_ost || return 1
+ start_mds || return 2
+ echo "Requeue thread should have started: "
+ ps -e | grep ll_cfg_requeue
+ set_and_check "cat $LPROC/obdfilter/$FSNAME-OST0000/client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
+ cleanup_nocli
+}
+run_test 27a "Reacquire MGS lock if OST started first"
+
+test_27b() {
+ setup
+ facet_failover mds
+ set_and_check "cat $LPROC/mds/$FSNAME-MDT0000/group_acquire_expire" "$FSNAME-MDT0000.mdt.group_acquire_expire" || return 3
+ set_and_check "cat $LPROC/mdc/$FSNAME-MDT0000-mdc-*/max_rpcs_in_flight" "$FSNAME-MDT0000.mdc.max_rpcs_in_flight" || return 4
+ cleanup
+}
+run_test 27b "Reacquire MGS lock after failover"
+
+test_28() {
+ setup
+ TEST="cat $LPROC/llite/$FSNAME-*/max_read_ahead_whole_mb"
+ ORIG=$($TEST)
+ declare -i FINAL
+ FINAL=$(($ORIG + 10))
+ set_and_check "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
+ set_and_check "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" || return 3
+ umount_client $MOUNT || return 200
+ mount_client $MOUNT
+ RESULT=$($TEST)
+ if [ $RESULT -ne $FINAL ]; then
+ echo "New config not seen: wanted $FINAL got $RESULT"
+ return 4
+ else
+ echo "New config success: got $RESULT"
+ fi
+ cleanup
+}
+run_test 28 "permanent parameter setting"
+
+test_29() {
+ [ "$OSTCOUNT" -lt "2" ] && echo "skipping deactivate test" && return
+ setup > /dev/null 2>&1
+ start_ost2
+ sleep 10
+
+ local PARAM="$FSNAME-OST0001.osc.active"
+ local PROC_ACT="$LPROC/osc/$FSNAME-OST0001-osc-*/active"
+ local PROC_UUID="$LPROC/osc/$FSNAME-OST0001-osc-*/ost_server_uuid"
+ if [ ! -r $PROC_ACT ]; then
+ echo "Can't read $PROC_ACT"
+ ls $LPROC/osc/$FSNAME-*
+ return 1
+ fi
+ ACTV=$(cat $PROC_ACT)
+ DEAC=$((1 - $ACTV))
+ set_and_check "cat $PROC_ACT" "$PARAM" $DEAC || return 2
+ # also check ost_server_uuid status
+ RESULT=$(grep DEACTIV $PROC_UUID)
+ if [ -z "$RESULT" ]; then
+ echo "Live client not deactivated: $(cat $PROC_UUID)"
+ return 3
+ else
+ echo "Live client success: got $RESULT"
+ fi
+
+ # check MDT too
+ local MPROC="$LPROC/osc/$FSNAME-OST0001-osc/active"
+ if [ -r $MPROC ]; then
+ RESULT=$(cat $MPROC)
+ if [ $RESULT -ne $DEAC ]; then
+ echo "MDT not deactivated: $(cat $MPROC)"
+ return 4
+ fi
+ echo "MDT deactivated also"
+ fi
+
+ # test new client starts deactivated
+ umount_client $MOUNT || return 200
+ mount_client $MOUNT
+ RESULT=$(grep DEACTIV $PROC_UUID | grep NEW)
+ if [ -z "$RESULT" ]; then
+ echo "New client not deactivated from start: $(cat $PROC_UUID)"
+ return 5
+ else
+ echo "New client success: got $RESULT"
+ fi
+
+ # make sure it reactivates
+ set_and_check "cat $PROC_ACT" "$PARAM" $ACTV || return 6
+
+ umount_client $MOUNT
+ stop_ost2
+ cleanup_nocli
+ #writeconf to remove all ost2 traces for subsequent tests
+ writeconf
+}
+run_test 29 "permanently remove an OST"
+
+test_30() {
+ # start mds first after writeconf
+ start_mds
+ start_ost
+ mount_client $MOUNT
+ TEST="cat $LPROC/llite/$FSNAME-*/max_read_ahead_whole_mb"
+ ORIG=$($TEST)
+ for i in $(seq 1 20); do
+ set_and_check "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
+ done
+ # make sure client restart still works
+ umount_client $MOUNT
+ mount_client $MOUNT || return 4
+ [ "$($TEST)" -ne "$i" ] && return 5
+ set_and_check "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
+ cleanup
+}
+run_test 30 "Big config llog"
+
+test_31() { # bug 10734
+ # ipaddr must not exist
+ mount -t lustre 4.3.2.1@tcp:/lustre $MOUNT || true
+ cleanup
+}
+run_test 31 "Connect to non-existent node (shouldn't crash)"
+
+test_32a() {
+ [ -z "$TUNEFS" ] && echo "No tunefs" && return
+ [ ! -r disk1_4.zip ] && echo "Cant find disk1_4.zip, skipping" && return
+ unzip -o -j -d $TMP/$tdir disk1_4.zip || { echo "Cant unzip disk1_4, skipping" && return ; }
+ load_modules
+ sysctl lnet.debug=$PTLDEBUG
+
+ $TUNEFS $TMP/$tdir/mds || error "tunefs failed"
+ # nids are wrong, so client wont work, but server should start
+ start mds $TMP/$tdir/mds "-o loop,exclude=lustre-OST0000" || return 3
+ local UUID=$(cat $LPROC/mds/lustre-MDT0000/uuid)
+ echo MDS uuid $UUID
+ [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
+
+ $TUNEFS --mgsnode=`hostname` $TMP/$tdir/ost1 || error "tunefs failed"
+ start ost1 $TMP/$tdir/ost1 "-o loop" || return 5
+ UUID=$(cat $LPROC/obdfilter/lustre-OST0000/uuid)
+ echo OST uuid $UUID
+ [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
+
+ local NID=$($LCTL list_nids | head -1)
+
+ echo "OSC changes should return err:"
+ $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 && return 7
+ $LCTL conf_param lustre-OST0000.failover.node=$NID && return 8
+ echo "ok."
+ echo "MDC changes should succeed:"
+ $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
+ $LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
+ echo "ok."
+
+ # With a new good MDT failover nid, we should be able to mount a client
+ # (but it cant talk to OST)
+ local OLDMOUNTOPT=$MOUNTOPT
+ MOUNTOPT="exclude=lustre-OST0000"
+ mount_client $MOUNT
+ MOUNTOPT=$OLDMOUNTOPT
+ set_and_check "cat $LPROC/mdc/*/max_rpcs_in_flight" "lustre-MDT0000.mdc.max_rpcs_in_flight" || return 11
+
+ zconf_umount `hostname` $MOUNT -f
+ cleanup_nocli
+
+ # mount a second time to make sure we didnt leave upgrade flag on
+ $TUNEFS --dryrun $TMP/$tdir/mds || error "tunefs failed"
+ start mds $TMP/$tdir/mds "-o loop,exclude=lustre-OST0000" || return 12
+ cleanup_nocli
+
+ [ -d $TMP/$tdir ] && rm -rf $TMP/$tdir
+}
+run_test 32a "Upgrade from 1.4 (not live)"
+
+test_32b() {
+ [ -z "$TUNEFS" ] && echo "No tunefs" && return
+ [ ! -r disk1_4.zip ] && echo "Cant find disk1_4.zip, skipping" && return
+ unzip -o -j -d $TMP/$tdir disk1_4.zip || { echo "Cant unzip disk1_4, skipping" && return ; }
+ load_modules
+ sysctl lnet.debug=$PTLDEBUG
+
+ # writeconf will cause servers to register with their current nids
+ $TUNEFS --writeconf $TMP/$tdir/mds || error "tunefs failed"
+ start mds $TMP/$tdir/mds "-o loop" || return 3
+ local UUID=$(cat $LPROC/mds/lustre-MDT0000/uuid)
+ echo MDS uuid $UUID
+ [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
+
+ $TUNEFS --mgsnode=`hostname` $TMP/$tdir/ost1 || error "tunefs failed"
+ start ost1 $TMP/$tdir/ost1 "-o loop" || return 5
+ UUID=$(cat $LPROC/obdfilter/lustre-OST0000/uuid)
+ echo OST uuid $UUID
+ [ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
+
+ echo "OSC changes should succeed:"
+ $LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 || return 7
+ $LCTL conf_param lustre-OST0000.failover.node=$NID || return 8
+ echo "ok."
+ echo "MDC changes should succeed:"
+ $LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
+ echo "ok."
+
+ # MDT and OST should have registered with new nids, so we should have
+ # a fully-functioning client
+ echo "Check client and old fs contents"
+ mount_client $MOUNT
+ set_and_check "cat $LPROC/mdc/*/max_rpcs_in_flight" "lustre-MDT0000.mdc.max_rpcs_in_flight" || return 11
+ [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "2479747619 779" ] || return 12
+ echo "ok."
+
+ cleanup
+ [ -d $TMP/$tdir ] && rm -rf $TMP/$tdir
+}
+run_test 32b "Upgrade from 1.4 with writeconf"
+
+umount_client $MOUNT
+cleanup_nocli
+