From a37b7315ad15a1012c22277a0f7c7b7c9a989b59 Mon Sep 17 00:00:00 2001 From: Di Wang Date: Fri, 4 Mar 2016 13:01:48 -0500 Subject: [PATCH] LU-7848 target: Do not fail MDT-MDT connection When one MDT restarts, and try to connect to another MDT with the new cookie, let's do not fail it, otherwise it might cause eviction between MDT. Signed-off-by: Di Wang Change-Id: I3d2e0712ee0ed05bdf46c7781e190206a6dcfb1c Reviewed-on: http://review.whamcloud.com/18800 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/ldlm/ldlm_lib.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 2a92a17..3aea6a2 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -1117,25 +1117,43 @@ int target_handle_connect(struct ptlrpc_request *req) class_export_put(export); export = NULL; rc = -EALREADY; - } else if ((mds_conn || lw_client) && export->exp_connection != NULL) { + } else if ((mds_conn || lw_client || + data->ocd_connect_flags & OBD_CONNECT_MDS_MDS) && + export->exp_connection != NULL) { spin_unlock(&export->exp_lock); - if (req->rq_peer.nid != export->exp_connection->c_peer.nid) + if (req->rq_peer.nid != export->exp_connection->c_peer.nid) { /* MDS or LWP reconnected after failover. */ LCONSOLE_WARN("%s: Received %s connection from " "%s, removing former export from %s\n", target->obd_name, mds_conn ? "MDS" : "LWP", libcfs_nid2str(req->rq_peer.nid), libcfs_nid2str(export->exp_connection->c_peer.nid)); - else + } else { /* New MDS connection from the same NID. */ LCONSOLE_WARN("%s: Received new %s connection from " "%s, removing former export from same NID\n", target->obd_name, mds_conn ? "MDS" : "LWP", libcfs_nid2str(req->rq_peer.nid)); - class_fail_export(export); - class_export_put(export); - export = NULL; - rc = 0; + } + + if (req->rq_peer.nid == export->exp_connection->c_peer.nid && + data->ocd_connect_flags & OBD_CONNECT_MDS_MDS) { + /* Because exports between MDTs will always be + * kept, let's do not fail such export if they + * come from the same NID, otherwise it might + * cause eviction between MDTs, which might + * cause namespace inconsistency */ + spin_lock(&export->exp_lock); + export->exp_connecting = 1; + spin_unlock(&export->exp_lock); + conn.cookie = export->exp_handle.h_cookie; + rc = EALREADY; + } else { + class_fail_export(export); + class_export_put(export); + export = NULL; + rc = 0; + } } else if (export->exp_connection != NULL && req->rq_peer.nid != export->exp_connection->c_peer.nid && (lustre_msg_get_op_flags(req->rq_reqmsg) & -- 1.8.3.1