From: Fan Yong Date: Tue, 4 Nov 2014 09:32:15 +0000 (+0800) Subject: LU-6086 obdclass: check peer's version for MDT-MDT connection X-Git-Tag: 2.7.50~18 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=0030ed640284e4ed5afa9187c5a907141132b083 LU-6086 obdclass: check peer's version for MDT-MDT connection Because new DNE/LFSCK changed some wire protocol, we cannot support the interoperations between different version MDTs. The basic rules for the permitted connection are: 1) The @major in the connection version should be the same; 2) The @minor in the connection version should be the same; 3) The difference of the @patch in the connection version should NOT more than 3. Signed-off-by: Fan Yong Change-Id: I9e77f305c7552ad01e92c97f1eda0756f1291d30 Reviewed-on: http://review.whamcloud.com/13285 Tested-by: Jenkins Reviewed-by: Lai Siyao Tested-by: Maloo Reviewed-by: Andreas Dilger --- diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index d8825bb..5e1f170 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -900,6 +900,34 @@ int target_handle_connect(struct ptlrpc_request *req) mds_conn = (data->ocd_connect_flags & OBD_CONNECT_MDS) != 0; lw_client = (data->ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT) != 0; + + /* OBD_CONNECT_MNE_SWAB is defined as OBD_CONNECT_MDS_MDS + * for Imperative Recovery connection from MGC to MGS. */ + if (!lw_client && + (data->ocd_connect_flags & OBD_CONNECT_MDS_MDS) && + !(data->ocd_connect_flags & OBD_CONNECT_IMP_RECOV) && + (data->ocd_connect_flags & OBD_CONNECT_VERSION)) { + __u32 major = OBD_OCD_VERSION_MAJOR(data->ocd_version); + __u32 minor = OBD_OCD_VERSION_MINOR(data->ocd_version); + __u32 patch = OBD_OCD_VERSION_PATCH(data->ocd_version); + + /* We do not support the MDT-MDT interoperations with + * different version MDT because of protocol changes. */ + if (unlikely(major != LUSTRE_MAJOR || + minor != LUSTRE_MINOR || + abs(patch - LUSTRE_PATCH) > 3)) { + LCONSOLE_WARN("%s (%u.%u.%u.%u) refused the " + "connection from different version MDT " + "(%d.%d.%d.%d) %s %s\n", + target->obd_name, LUSTRE_MAJOR, + LUSTRE_MINOR, LUSTRE_PATCH, LUSTRE_FIX, + major, minor, patch, + OBD_OCD_VERSION_FIX(data->ocd_version), + libcfs_nid2str(req->rq_peer.nid), str); + + GOTO(out, rc = -EPROTO); + } + } } /* lctl gets a backstage, all-access pass. */ diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 7b3a373..47eefff 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -278,9 +278,6 @@ int lod_add_device(const struct lu_env *env, struct lod_device *lod, OBD_CONNECT_AT | OBD_CONNECT_FULL20 | OBD_CONNECT_LFSCK; - /* XXX set MDS-MDS flags, remove this when running this - * on client*/ - data->ocd_connect_flags |= OBD_CONNECT_MDS_MDS; spin_lock(&imp->imp_lock); imp->imp_server_timeout = 1; spin_unlock(&imp->imp_lock); diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 224cad4..5d1e6b8 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -1014,6 +1014,32 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, GOTO(out, rc = -EPROTO); } + if (!(imp->imp_connect_flags_orig & OBD_CONNECT_LIGHTWEIGHT) && + (imp->imp_connect_flags_orig & OBD_CONNECT_MDS_MDS) && + !(imp->imp_connect_flags_orig & OBD_CONNECT_IMP_RECOV) && + (ocd->ocd_connect_flags & OBD_CONNECT_VERSION)) { + __u32 major = OBD_OCD_VERSION_MAJOR(ocd->ocd_version); + __u32 minor = OBD_OCD_VERSION_MINOR(ocd->ocd_version); + __u32 patch = OBD_OCD_VERSION_PATCH(ocd->ocd_version); + + /* We do not support the MDT-MDT interoperations with + * different version MDT because of protocol changes. */ + if (unlikely(major != LUSTRE_MAJOR || + minor != LUSTRE_MINOR || + abs(patch - LUSTRE_PATCH) > 3)) { + LCONSOLE_WARN("%s: import %p (%u.%u.%u.%u) tried the " + "connection to different version MDT " + "(%d.%d.%d.%d) %s\n", + imp->imp_obd->obd_name, imp, LUSTRE_MAJOR, + LUSTRE_MINOR, LUSTRE_PATCH, LUSTRE_FIX, + major, minor, patch, + OBD_OCD_VERSION_FIX(ocd->ocd_version), + imp->imp_connection->c_remote_uuid.uuid); + + GOTO(out, rc = -EPROTO); + } + } + if (!exp) { /* This could happen if export is cleaned during the connect attempt */