From f4b93dff9a8f4a59976ea864c4e3c2c42faa5770 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Sat, 7 Mar 2015 04:34:56 -0700 Subject: [PATCH] LU-6349 ptlrpc: remove old protocol compatibility Some old protocol compatibility workarounds are still present in master that should have been removed when LUSTRE_MSG_MAGIC_V1 was. In particular, the process for upgrading LUSTRE_MSG_MAGIC_V1 to LUSTRE_MSG_MAGIC_V2 had the client to connect to the server with the V1 protocol with op_flag=MSG_CONNECT_NEXT_VER set, and if the server supported the V2 protocol it would reply with LUSTRE_MSG_MAGIC_V2. This ensured that if the new client connected to an old server the connection would be allowed. However, even with V1 protocol support removed, the 2.x clients are still connecting with NEXT_VER set. In b1_8 this flag was contingent on LUSTRE_MSG_MAGIC_V1 being used, which is how it should have been in 2.x as well. A few other cleanups are be done at the same time: - disallow 1.8 clients (or at least those that don't understand OBD_CONNECT_FULL20) so we can remove workarounds for 1.8 clients - remove support for pre-2.1 DLM flock lock handling - don't workaround the lack of MDS_ATTR_xTIME_SET flags in setattr - always set MSGHDR_CKSUM_INCOMPAT18 (it can eventually be removed) Signed-off-by: Andreas Dilger Change-Id: Id0a7a5724f2f84decaa3444fe278d0fc05500c1e Reviewed-on: http://review.whamcloud.com/14006 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Dmitry Eremin Reviewed-by: John L. Hammond Reviewed-by: Liang Zhen Reviewed-by: Oleg Drokin --- lustre/ldlm/ldlm_flock.c | 28 +++++++--------------------- lustre/ldlm/ldlm_internal.h | 4 +--- lustre/ldlm/ldlm_lib.c | 23 ++++++++++++++++------- lustre/ldlm/ldlm_lock.c | 21 ++++----------------- lustre/mdt/mdt_lib.c | 14 -------------- lustre/ptlrpc/import.c | 11 ++--------- 6 files changed, 30 insertions(+), 71 deletions(-) diff --git a/lustre/ldlm/ldlm_flock.c b/lustre/ldlm/ldlm_flock.c index f2a0859..ac17c1a4 100644 --- a/lustre/ldlm/ldlm_flock.c +++ b/lustre/ldlm/ldlm_flock.c @@ -840,28 +840,14 @@ int ldlm_flock_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, RETURN(0); } -void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy, - ldlm_policy_data_t *lpolicy) +void ldlm_flock_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy, + ldlm_policy_data_t *lpolicy) { - memset(lpolicy, 0, sizeof(*lpolicy)); - lpolicy->l_flock.start = wpolicy->l_flock.lfw_start; - lpolicy->l_flock.end = wpolicy->l_flock.lfw_end; - lpolicy->l_flock.pid = wpolicy->l_flock.lfw_pid; - /* Compat code, old clients had no idea about owner field and - * relied solely on pid for ownership. Introduced in LU-104, 2.1, - * April 2011 */ - lpolicy->l_flock.owner = wpolicy->l_flock.lfw_pid; -} - - -void ldlm_flock_policy_wire21_to_local(const ldlm_wire_policy_data_t *wpolicy, - ldlm_policy_data_t *lpolicy) -{ - memset(lpolicy, 0, sizeof(*lpolicy)); - lpolicy->l_flock.start = wpolicy->l_flock.lfw_start; - lpolicy->l_flock.end = wpolicy->l_flock.lfw_end; - lpolicy->l_flock.pid = wpolicy->l_flock.lfw_pid; - lpolicy->l_flock.owner = wpolicy->l_flock.lfw_owner; + memset(lpolicy, 0, sizeof(*lpolicy)); + lpolicy->l_flock.start = wpolicy->l_flock.lfw_start; + lpolicy->l_flock.end = wpolicy->l_flock.lfw_end; + lpolicy->l_flock.pid = wpolicy->l_flock.lfw_pid; + lpolicy->l_flock.owner = wpolicy->l_flock.lfw_owner; } void ldlm_flock_policy_local_to_wire(const ldlm_policy_data_t *lpolicy, diff --git a/lustre/ldlm/ldlm_internal.h b/lustre/ldlm/ldlm_internal.h index 51681d7..ad2ea44 100644 --- a/lustre/ldlm/ldlm_internal.h +++ b/lustre/ldlm/ldlm_internal.h @@ -334,9 +334,7 @@ void ldlm_extent_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy, ldlm_policy_data_t *lpolicy); void ldlm_extent_policy_local_to_wire(const ldlm_policy_data_t *lpolicy, ldlm_wire_policy_data_t *wpolicy); -void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy, - ldlm_policy_data_t *lpolicy); -void ldlm_flock_policy_wire21_to_local(const ldlm_wire_policy_data_t *wpolicy, +void ldlm_flock_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy, ldlm_policy_data_t *lpolicy); void ldlm_flock_policy_local_to_wire(const ldlm_policy_data_t *lpolicy, diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index b92c1de..69f35c1 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -871,6 +871,20 @@ int target_handle_connect(struct ptlrpc_request *req) if (rc) GOTO(out, rc); +#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0) + /* Don't allow clients to connect that are using old 1.8 format + * protocol conventions (LUSTRE_MSG_MAGIC_v1, !MSGHDR_CKSUM_INCOMPAT18, + * ldlm_flock_policy_wire format, MDT_ATTR_xTIME_SET, etc). The + * FULL20 flag should be set on all connections since 2.0, but no + * longer affects behaviour. + * + * Later this check will be disabled and the flag can be retired + * completely once interop with 3.0 is no longer needed. + */ + if (!(data->ocd_connect_flags & OBD_CONNECT_FULL20)) + GOTO(out, rc = -EPROTO); +#endif + if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_LIBCLIENT) { if (data->ocd_version < LUSTRE_VERSION_CODE - LUSTRE_VERSION_ALLOWED_OFFSET || @@ -1237,17 +1251,12 @@ dont_check_exports: * ptlrpc_handle_server_req_in->lustre_unpack_msg(). */ revimp->imp_msg_magic = req->rq_reqmsg->lm_magic; - if ((data->ocd_connect_flags & OBD_CONNECT_AT) && - (revimp->imp_msg_magic != LUSTRE_MSG_MAGIC_V1)) + if (data->ocd_connect_flags & OBD_CONNECT_AT) revimp->imp_msghdr_flags |= MSGHDR_AT_SUPPORT; else revimp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT; - if ((data->ocd_connect_flags & OBD_CONNECT_FULL20) && - (revimp->imp_msg_magic != LUSTRE_MSG_MAGIC_V1)) - revimp->imp_msghdr_flags |= MSGHDR_CKSUM_INCOMPAT18; - else - revimp->imp_msghdr_flags &= ~MSGHDR_CKSUM_INCOMPAT18; + revimp->imp_msghdr_flags |= MSGHDR_CKSUM_INCOMPAT18; rc = sptlrpc_import_sec_adapt(revimp, req->rq_svc_ctx, &req->rq_flvr); if (rc) { diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 44049c1..302c965 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -66,17 +66,10 @@ char *ldlm_typename[] = { [LDLM_IBITS] = "IBT", }; -static ldlm_policy_wire_to_local_t ldlm_policy_wire18_to_local[] = { +static ldlm_policy_wire_to_local_t ldlm_policy_wire_to_local[] = { [LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_wire_to_local, [LDLM_EXTENT - LDLM_MIN_TYPE] = ldlm_extent_policy_wire_to_local, - [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_wire18_to_local, - [LDLM_IBITS - LDLM_MIN_TYPE] = ldlm_ibits_policy_wire_to_local, -}; - -static ldlm_policy_wire_to_local_t ldlm_policy_wire21_to_local[] = { - [LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_wire_to_local, - [LDLM_EXTENT - LDLM_MIN_TYPE] = ldlm_extent_policy_wire_to_local, - [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_wire21_to_local, + [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_wire_to_local, [LDLM_IBITS - LDLM_MIN_TYPE] = ldlm_ibits_policy_wire_to_local, }; @@ -109,14 +102,8 @@ void ldlm_convert_policy_to_local(struct obd_export *exp, ldlm_type_t type, ldlm_policy_data_t *lpolicy) { ldlm_policy_wire_to_local_t convert; - int new_client; - - /** some badness for 2.0.0 clients, but 2.0.0 isn't supported */ - new_client = (exp_connect_flags(exp) & OBD_CONNECT_FULL20) != 0; - if (new_client) - convert = ldlm_policy_wire21_to_local[type - LDLM_MIN_TYPE]; - else - convert = ldlm_policy_wire18_to_local[type - LDLM_MIN_TYPE]; + + convert = ldlm_policy_wire_to_local[type - LDLM_MIN_TYPE]; convert(wpolicy, lpolicy); } diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index 42854bb..d212c56 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -923,20 +923,6 @@ static int mdt_setattr_unpack_rec(struct mdt_thread_info *info) rr->rr_fid1 = &rec->sa_fid; la->la_valid = mdt_attr_valid_xlate(rec->sa_valid, rr, ma); - /* If MDS_ATTR_xTIME is set without MDS_ATTR_xTIME_SET and - * the client does not have OBD_CONNECT_FULL20, convert it - * to LA_xTIME. LU-3036 */ - if (!(exp_connect_flags(info->mti_exp) & OBD_CONNECT_FULL20)) { - if (!(rec->sa_valid & MDS_ATTR_ATIME_SET) && - (rec->sa_valid & MDS_ATTR_ATIME)) - la->la_valid |= LA_ATIME; - if (!(rec->sa_valid & MDS_ATTR_MTIME_SET) && - (rec->sa_valid & MDS_ATTR_MTIME)) - la->la_valid |= LA_MTIME; - if (!(rec->sa_valid & MDS_ATTR_CTIME_SET) && - (rec->sa_valid & MDS_ATTR_CTIME)) - la->la_valid |= LA_CTIME; - } la->la_mode = rec->sa_mode; la->la_flags = rec->sa_attr_flags; la->la_uid = nodemap_map_id(nodemap, NODEMAP_UID, diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 007f737..e96396a 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -728,8 +728,6 @@ int ptlrpc_connect_import(struct obd_import *imp) request->rq_timeout = INITIAL_CONNECT_TIMEOUT; lustre_msg_set_timeout(request->rq_reqmsg, request->rq_timeout); - lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_NEXT_VER); - request->rq_no_resend = request->rq_no_delay = 1; request->rq_send_state = LUSTRE_IMP_CONNECTING; /* Allow a slightly larger reply for future growth compatibility */ @@ -913,8 +911,7 @@ static int ptlrpc_connect_set_flags(struct obd_import *imp, ocd->ocd_connect_flags; } - if ((ocd->ocd_connect_flags & OBD_CONNECT_AT) && - (imp->imp_msg_magic == LUSTRE_MSG_MAGIC_V2)) + if (ocd->ocd_connect_flags & OBD_CONNECT_AT) /* We need a per-message support flag, because * a. we don't know if the incoming connect reply * supports AT or not (in reply_in_callback) @@ -927,11 +924,7 @@ static int ptlrpc_connect_set_flags(struct obd_import *imp, else imp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT; - if ((ocd->ocd_connect_flags & OBD_CONNECT_FULL20) && - (imp->imp_msg_magic == LUSTRE_MSG_MAGIC_V2)) - imp->imp_msghdr_flags |= MSGHDR_CKSUM_INCOMPAT18; - else - imp->imp_msghdr_flags &= ~MSGHDR_CKSUM_INCOMPAT18; + imp->imp_msghdr_flags |= MSGHDR_CKSUM_INCOMPAT18; return 0; } -- 1.8.3.1