From 2a9b61b976dc1925bad5a1cee56f945065a44aec Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Thu, 6 Sep 2012 17:28:00 -0700 Subject: [PATCH] LU-1644 recovery: to not check client version for mne swap data->ocd_version in obd_connect_data can be overwritten by server so that it'll be wrong if client is reconnected after server recovery. Wrong clienv version caused wrong exp_need_mne_swab was set and then has interop issue between 2.2 clients and 2.3 server. In this patch, the following fixes are made: 1. do not check the client version on the MGS; 2. reset client version on each import connect; 3. client side fix will be removed after lustre 3.2 Signed-off-by: Jinshan Xiong Change-Id: Ia2899d1b8385fd4799ca6fe260fc4c84444247cb Reviewed-on: http://review.whamcloud.com/3897 Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Maloo Tested-by: Yu Jian Reviewed-by: Oleg Drokin --- lustre/ldlm/ldlm_lib.c | 15 ++------------- lustre/mgc/mgc_request.c | 4 ++-- lustre/mgs/mgs_nids.c | 1 - lustre/obdclass/obd_mount.c | 10 ++++++++-- lustre/ptlrpc/import.c | 6 ++++-- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 06473f8..c49e887 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -748,7 +748,6 @@ int target_handle_connect(struct ptlrpc_request *req) struct obd_connect_data *data, *tmpdata; int size, tmpsize; lnet_nid_t *client_nid = NULL; - bool mne_swab_client_ver; ENTRY; OBD_RACE(OBD_FAIL_TGT_CONN_RACE); @@ -840,15 +839,6 @@ int target_handle_connect(struct ptlrpc_request *req) if (rc) GOTO(out, rc); -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 6, 50, 0) - /* Check if the client might be missing the LU-1252 fix to swab - * the IR mne_length entries. Do this as early as possible in case - * the version code is modified. See LU-1644 for details. */ - mne_swab_client_ver = OBD_OCD_VERSION_MAJOR(data->ocd_version) == 2 && - OBD_OCD_VERSION_MINOR(data->ocd_version) == 2 && - OBD_OCD_VERSION_PATCH(data->ocd_version) < 55; -#endif - if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_LIBCLIENT) { if (!data) { DEBUG_REQ(D_WARNING, req, "Refusing old (unversioned) " @@ -1051,9 +1041,8 @@ dont_check_exports: * OBD_CONNECT_MNE_SWAB flag around forever, just so long as we need * interop with unpatched 2.2 clients. For newer clients, servers * will never do MNE swabbing, let the client handle that. LU-1644 */ - export->exp_need_mne_swab = - !(data->ocd_connect_flags & OBD_CONNECT_MNE_SWAB) && - mne_swab_client_ver && !ptlrpc_req_need_swab(req); + export->exp_need_mne_swab = !ptlrpc_req_need_swab(req) && + !(data->ocd_connect_flags & OBD_CONNECT_MNE_SWAB); #else #warning "LU-1644: Remove old OBD_CONNECT_MNE_SWAB fixup and exp_need_mne_swab" #endif diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 94fe3bd..e4bc00a 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -1514,13 +1514,13 @@ again: } mne_swab = !!ptlrpc_rep_need_swab(req); -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 6, 50, 0) +#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 2, 50, 0) /* This import flag means the server did an extra swab of IR MNE * records (fixed in LU-1252), reverse it here if needed. LU-1644 */ if (unlikely(req->rq_import->imp_need_mne_swab)) mne_swab = !mne_swab; #else -#warning "LU-1644: Remove old OBD_CONNECT_MNE_SWAB fixup and exp_need_mne_swab" +#warning "LU-1644: Remove old OBD_CONNECT_MNE_SWAB fixup and imp_need_mne_swab" #endif for (i = 0; i < nrpages && ealen > 0; i++) { diff --git a/lustre/mgs/mgs_nids.c b/lustre/mgs/mgs_nids.c index 0c9c13d..0f0c83a 100644 --- a/lustre/mgs/mgs_nids.c +++ b/lustre/mgs/mgs_nids.c @@ -146,7 +146,6 @@ static int mgs_nidtbl_read(struct obd_export *exp, struct mgs_nidtbl *tbl, /* check if we need to consume remaining bytes. */ if (last_in_unit != NULL && bytes_in_unit) { -# #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 6, 50, 0) /* May need to swab back to update the length.*/ if (exp->exp_need_mne_swab) diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 33ef09d..b2ec636 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -691,8 +691,14 @@ static int lustre_start_mgc(struct super_block *sb) /* We connect to the MGS at setup, and don't disconnect until cleanup */ data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_AT | - OBD_CONNECT_FULL20 | OBD_CONNECT_IMP_RECOV | - OBD_CONNECT_MNE_SWAB; + OBD_CONNECT_FULL20 | OBD_CONNECT_IMP_RECOV; + +#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 2, 50, 0) + data->ocd_connect_flags |= OBD_CONNECT_MNE_SWAB; +#else +#warning "LU-1644: Remove old OBD_CONNECT_MNE_SWAB fixup and imp_need_mne_swab" +#endif + if (lmd_is_client(lsi->lsi_lmd) && lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR) data->ocd_connect_flags &= ~OBD_CONNECT_IMP_RECOV; diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 43dda40..b7e7c84 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -647,6 +647,8 @@ int ptlrpc_connect_import(struct obd_import *imp) /* Reset connect flags to the originally requested flags, in case * the server is updated on-the-fly we will get the new features. */ imp->imp_connect_data.ocd_connect_flags = imp->imp_connect_flags_orig; + /* Reset ocd_version each time so the server knows the exact versions */ + imp->imp_connect_data.ocd_version = LUSTRE_VERSION_CODE; imp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT; imp->imp_msghdr_flags &= ~MSGHDR_CKSUM_INCOMPAT18; @@ -1038,7 +1040,7 @@ finish: newer : older, LUSTRE_VERSION_STRING); } -#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 6, 50, 0) +#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 2, 50, 0) /* Check if server has LU-1252 fix applied to not always swab * the IR MNE entries. Do this only once per connection. This * fixup is version-limited, because we don't want to carry the @@ -1056,7 +1058,7 @@ finish: else /* clear if server was upgraded since last connect */ imp->imp_need_mne_swab = 0; #else -#warning "LU-1644: Remove old OBD_CONNECT_MNE_SWAB fixup and exp_need_mne_swab" +#warning "LU-1644: Remove old OBD_CONNECT_MNE_SWAB fixup and imp_need_mne_swab" #endif if (ocd->ocd_connect_flags & OBD_CONNECT_CKSUM) { -- 1.8.3.1