diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index de4c8dc7b39aac7267f95bcb5c653da43c9109b5..8a390abdbf36b1e13c12c8d6b72a67ed70936e39 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -901,11 +901,19 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler) revimp->imp_remote_handle = conn; revimp->imp_dlm_fake = 1; revimp->imp_state = LUSTRE_IMP_FULL; + set_flags: - if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_NEXT_VER) { - /* Client wants v2 */ + if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V1 && + lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_NEXT_VER) { revimp->imp_msg_magic = LUSTRE_MSG_MAGIC_V2; lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_NEXT_VER); + } else { + /* unknown versions will be caught in + * ptlrpc_handle_server_req_in->lustre_unpack_msg() */ + revimp->imp_msg_magic = req->rq_reqmsg->lm_magic; + } + + if (revimp->imp_msg_magic != LUSTRE_MSG_MAGIC_V1) { if (export->exp_connect_flags & OBD_CONNECT_AT) revimp->imp_msghdr_flags |= MSGHDR_AT_SUPPORT; } diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 472088bf2b00787574e34b96f32915a00118fe24..8bacf405abe0e4b3e8d15e568b9af315c620880c 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -830,9 +830,9 @@ struct obd_import *class_new_import(struct obd_device *obd) class_handle_hash(&imp->imp_handle, import_handle_addref); init_imp_at(&imp->imp_at); - /* the default magic is V1, will be used in connect RPC, and + /* the default magic is V2, will be used in connect RPC, and * then adjusted according to the flags in request/reply. */ - imp->imp_msg_magic = LUSTRE_MSG_MAGIC_V1; + imp->imp_msg_magic = LUSTRE_MSG_MAGIC_V2; return imp; } diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 98a2c45b39f41706097de86b6a9841a3c4fba1f5..4b96594cc3a7716227d7404eadceef2bfddc7331 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -516,7 +516,9 @@ int ptlrpc_connect_import(struct obd_import *imp, char *new_uuid) #ifndef __KERNEL__ lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_LIBCLIENT); #endif - lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_NEXT_VER); + if (imp->imp_msg_magic == LUSTRE_MSG_MAGIC_V1) + lustre_msg_add_op_flags(request->rq_reqmsg, + MSG_CONNECT_NEXT_VER); request->rq_send_state = LUSTRE_IMP_CONNECTING; /* Allow a slightly larger reply for future growth compatibility */ @@ -635,7 +637,9 @@ static int ptlrpc_connect_interpret(struct ptlrpc_request *request, spin_unlock(&imp->imp_lock); } - if (msg_flags & MSG_CONNECT_NEXT_VER) { + if ((request->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V1 && + msg_flags & MSG_CONNECT_NEXT_VER) || + request->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2) { imp->imp_msg_magic = LUSTRE_MSG_MAGIC_V2; CDEBUG(D_RPCTRACE, "connect to %s with lustre_msg_v2\n", obd2cli_tgt(imp->imp_obd));