+test_24b() {
+ if [ -z "$fs2mds_DEV" ]; then
+ do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
+ skip "mixed loopback and real device not working" && return
+ fi
+
+ local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
+
+ add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
+ setup
+ start fs2mds $fs2mdsdev $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...
+ do_facet $SINGLEMDS "lsmod | grep -q lustre || modprobe lustre"
+#define OBD_FAIL_MDS_FS_SETUP 0x135
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000135"
+ start_mds && echo MDS started && return 1
+ lctl get_param -n devices
+ DEVS=$(lctl get_param -n 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 myfacet=$1
+ local TEST=$2
+ local PARAM=$3
+ local ORIG=$(do_facet $myfacet "$TEST")
+ if [ $# -gt 3 ]; then
+ local FINAL=$4
+ else
+ local -i FINAL
+ FINAL=$(($ORIG + 5))
+ fi
+ echo "Setting $PARAM from $ORIG to $FINAL"
+ do_facet $SINGLEMDS "$LCTL conf_param $PARAM=$FINAL" || error conf_param failed
+ local RESULT
+ local MAX=90
+ local WAIT=0
+ while [ 1 ]; do
+ sleep 5
+ RESULT=$(do_facet $myfacet "$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 ost1 "lctl get_param -n 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() {
+ # FIXME. ~grev
+ setup
+ local device=$(do_facet $SINGLEMDS "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
+
+ facet_failover $SINGLEMDS
+ set_and_check $SINGLEMDS "lctl get_param -n mdt.$device.identity_acquire_expire" "$device.mdt.identity_acquire_expire" || return 3
+ set_and_check client "lctl get_param -n mdc.$device-mdc-*.max_rpcs_in_flight" "$device.mdc.max_rpcs_in_flight" || return 4
+ check_mount
+ cleanup
+}
+run_test 27b "Reacquire MGS lock after failover"
+
+test_28() {
+ setup
+ TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
+ PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
+ ORIG=$($TEST)
+ FINAL=$(($ORIG + 1))
+ set_and_check client "$TEST" "$PARAM" $FINAL || return 3
+ FINAL=$(($FINAL + 1))
+ set_and_check client "$TEST" "$PARAM" $FINAL || return 4
+ 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
+ set_and_check client "$TEST" "$PARAM" $ORIG || return 5
+ cleanup
+}
+run_test 28 "permanent parameter setting"
+
+test_29() {
+ [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2, skipping" && return
+ setup > /dev/null 2>&1
+ start_ost2
+ sleep 10
+
+ local PARAM="$FSNAME-OST0001.osc.active"
+ local PROC_ACT="osc.$FSNAME-OST0001-osc-[^M]*.active"
+ local PROC_UUID="osc.$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
+
+ ACTV=$(lctl get_param -n $PROC_ACT)
+ DEAC=$((1 - $ACTV))
+ set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $DEAC || return 2
+ # also check ost_server_uuid status
+ RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV)
+ if [ -z "$RESULT" ]; then
+ echo "Live client not deactivated: $(lctl get_param -n $PROC_UUID)"
+ return 3
+ else
+ echo "Live client success: got $RESULT"
+ fi
+
+ # check MDT too
+ local MPROC="osc.$FSNAME-OST0001-osc-[M]*.active"
+ local MAX=30
+ local WAIT=0
+ while [ 1 ]; do
+ sleep 5
+ RESULT=`do_facet $SINGLEMDS " lctl get_param -n $MPROC"`
+ [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
+ if [ $RESULT -eq $DEAC ]; then
+ echo "MDT deactivated also after $WAIT sec (got $RESULT)"
+ break
+ fi
+ WAIT=$((WAIT + 5))
+ if [ $WAIT -eq $MAX ]; then
+ echo "MDT not deactivated: wanted $DEAC got $RESULT"
+ return 4
+ fi
+ echo "Waiting $(($MAX - $WAIT)) secs for MDT deactivated"
+ done
+
+ # test new client starts deactivated
+ umount_client $MOUNT || return 200
+ mount_client $MOUNT
+ RESULT=$(lctl get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
+ if [ -z "$RESULT" ]; then
+ echo "New client not deactivated from start: $(lctl get_param -n $PROC_UUID)"
+ return 5
+ else
+ echo "New client success: got $RESULT"
+ fi
+
+ # make sure it reactivates
+ set_and_check client "lctl get_param -n $PROC_ACT" "$PARAM" $ACTV || return 6
+
+ umount_client $MOUNT
+ stop_ost2
+ cleanup_nocli
+ #writeconf to remove all ost2 traces for subsequent tests
+ writeconf
+ start_mds
+ start_ost
+ cleanup
+}
+run_test 29 "permanently remove an OST"
+
+test_30() {
+ setup
+
+ TEST="lctl get_param -n llite.$FSNAME-*.max_read_ahead_whole_mb"
+ ORIG=$($TEST)
+ LIST=(1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5)
+ for i in ${LIST[@]}; do
+ set_and_check client "$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 client "$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() {
+ # XXX - make this test verify 1.8 -> 2.0 upgrade is working
+ # XXX - make this run on client-only systems with real hardware on
+ # the OST and MDT
+ # there appears to be a lot of assumption here about loopback
+ # devices
+ # or maybe this test is just totally useless on a client-only system
+ [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
+ [ "$mds_HOST" = "`hostname`" ] || { skip "remote MDS" && return 0; }
+ [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
+ { skip "remote OST" && return 0; }
+
+ [ -z "$TUNEFS" ] && skip "No tunefs" && return
+ local DISK1_8=$LUSTRE/tests/disk1_8.tgz
+ [ ! -r $DISK1_8 ] && skip "Cannot find $DISK1_8" && return 0
+
+ mkdir -p $TMP/$tdir
+ tar xjvf $DISK1_8 -C $TMP/$tdir || \
+ { skip "Cannot untar $DISK1_8" && return 0; }
+
+ load_modules
+ lctl set_param debug=$PTLDEBUG
+
+ $TUNEFS $tmpdir/mds || error "tunefs failed"
+ # nids are wrong, so client wont work, but server should start
+ start mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" || return 3
+ local UUID=$(lctl get_param -n mdt.lustre-MDT0000.uuid)
+ echo MDS uuid $UUID
+ [ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
+
+ $TUNEFS --mgsnode=`hostname` $tmpdir/ost1 || error "tunefs failed"
+ start ost1 $tmpdir/ost1 "-o loop" || return 5
+ UUID=$(lctl get_param -n 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 client "lctl get_param -n mdc.*.max_rpcs_in_flight" "lustre-MDT0000.mdc.max_rpcs_in_flight" ||
+ return 11
+
+ zconf_umount `hostname` $MOUNT -f
+ cleanup_nocli
+ load_modules
+
+ # mount a second time to make sure we didnt leave upgrade flag on
+ load_modules
+ $TUNEFS --dryrun $tmpdir/mds || error "tunefs failed"
+ load_modules
+ start mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" || return 12
+ cleanup_nocli
+
+ rm -rf $tmpdir || true # true is only for TMP on NFS
+}
+run_test 32a "Upgrade from 1.8 (not live)"
+
+test_32b() {
+ # XXX - make this test verify 1.8 -> 2.0 upgrade is working
+ # XXX - make this run on client-only systems with real hardware on
+ # the OST and MDT
+ # there appears to be a lot of assumption here about loopback
+ # devices
+ # or maybe this test is just totally useless on a client-only system
+ [ "$NETTYPE" = "tcp" ] || { skip "NETTYPE != tcp" && return 0; }
+ [ "$mds_HOST" = "`hostname`" ] || { skip "remote MDS" && return 0; }
+ [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] || \
+ { skip "remote OST" && return 0; }
+
+ [ -z "$TUNEFS" ] && skip "No tunefs" && return
+ local DISK1_8=$LUSTRE/tests/disk1_8.tgz
+ [ ! -r $DISK1_8 ] && skip "Cannot find $DISK1_8" && return 0
+ local tmpdir=$TMP/$tdir
+ mkdir -p $tmpdir
+ tar xjvf $DISK1_8 -C $tmpdir || \
+ { skip "Cannot untar $DISK1_8" && return ; }
+
+ load_modules
+ lctl set_param debug=$PTLDEBUG
+ NEWNAME=lustre
+
+ # writeconf will cause servers to register with their current nids
+ $TUNEFS --writeconf --fsname=$NEWNAME $tmpdir/mds || error "tunefs failed"
+ start mds1 $tmpdir/mds "-o loop" || return 3
+ local UUID=$(lctl get_param -n mdt.${NEWNAME}-MDT0000.uuid)
+ echo MDS uuid $UUID
+ [ "$UUID" == "${NEWNAME}-MDT0000_UUID" ] || error "UUID is wrong: $UUID"
+
+ $TUNEFS --mgsnode=`hostname` --writeconf --fsname=$NEWNAME $tmpdir/ost1 || error "tunefs failed"
+ start ost1 $tmpdir/ost1 "-o loop" || return 5
+ UUID=$(lctl get_param -n obdfilter.${NEWNAME}-OST0000.uuid)
+ echo OST uuid $UUID
+ [ "$UUID" == "${NEWNAME}-OST0000_UUID" ] || error "UUID is wrong: $UUID"
+
+ echo "OSC changes should succeed:"
+ $LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
+ $LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
+ echo "ok."
+ echo "MDC changes should succeed:"
+ $LCTL conf_param ${NEWNAME}-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"
+ OLDFS=$FSNAME
+ FSNAME=$NEWNAME
+ mount_client $MOUNT
+ FSNAME=$OLDFS
+ set_and_check client "lctl get_param -n mdc.*.max_rpcs_in_flight" "${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight" || return 11
+ [ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "94306271 1478" ] || return 12
+ echo "ok."
+
+ cleanup
+ rm -rf $tmpdir || true # true is only for TMP on NFS
+}
+run_test 32b "Upgrade from 1.8 with writeconf"
+
+test_33a() { # bug 12333, was test_33
+ local rc=0
+ local FSNAME2=test-123
+ [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
+
+ if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
+ do_facet $SINGLEMDS [ -b "$MDSDEV" ] && \
+ skip "mixed loopback and real device not working" && return