From: Nathan Rutman Date: Fri, 13 Aug 2010 20:29:51 +0000 (+0400) Subject: b=22656 Prevent failover nids from registering with MGS first. X-Git-Tag: 2.0.51.0~75 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=255417f0d095d276a5a33b75f989eeb13d83800e b=22656 Prevent failover nids from registering with MGS first. Make the check in mgs_handle_target_reg() o=Joseph Herring i=nathan.rutman i=andreas.dilger --- diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 274b6fb..35d8da9 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -59,7 +59,7 @@ #include #include #include "mgs_internal.h" - +#include /* Establish a connection to the MGS.*/ static int mgs_connect(const struct lu_env *env, @@ -401,6 +401,30 @@ static int mgs_check_target(struct obd_device *obd, struct mgs_target_info *mti) RETURN(rc); } +/* Ensure this is not a failover node that is connecting first*/ +static int mgs_check_failover_reg(struct mgs_target_info *mti) +{ + lnet_nid_t nid; + char *ptr; + int i; + + ptr = mti->mti_params; + while (class_find_param(ptr, PARAM_FAILNODE, &ptr) == 0) { + while (class_parse_nid(ptr, &nid, &ptr) == 0) { + for (i = 0; i < mti->mti_nid_count; i++) { + if (nid == mti->mti_nids[i]) { + LCONSOLE_WARN("Denying initial registra" + "tion attempt from nid %s" + ", specified as failover" + "\n",libcfs_nid2str(nid)); + return -EADDRNOTAVAIL; + } + } + } + } + return 0; +} + /* Called whenever a target starts up. Flags indicate first connect, etc. */ static int mgs_handle_target_reg(struct ptlrpc_request *req) { @@ -427,6 +451,9 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) if (rc <= 0) /* Nothing wrong, or fatal error */ GOTO(out_nolock, rc); + } else { + if ((rc = mgs_check_failover_reg(mti))) + GOTO(out_nolock, rc); } OBD_FAIL_TIMEOUT(OBD_FAIL_MGS_PAUSE_TARGET_REG, 10); diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 05b73c7..721cee6 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -2363,10 +2363,6 @@ test_53b() { } run_test 53b "check MDT thread count params" -if ! combined_mgs_mds ; then - stop mgs -fi - run_llverfs() { local dir=$1 @@ -2447,6 +2443,20 @@ test_56() { } run_test 56 "check big indexes" +test_57() { # bug 22656 + local NID=$($LCTL list_nids | head -1) + writeconf + do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed" + if ! combined_mgs_mds ; then + start_mgs + fi + start_mds + start_ost && error "OST registration from failnode should fail" + stop_mds + reformat +} +run_test 57 "initial registration from failnode should fail (should return errs)" + count_osts() { do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l } @@ -2481,6 +2491,10 @@ test_59() { } run_test 59 "writeconf mount option" + +if ! combined_mgs_mds ; then + stop mgs +fi cleanup_gss equals_msg `basename $0`: test complete [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true