From ac1fd0707babaa68487e81ca7b3e1cb174ac8bfd Mon Sep 17 00:00:00 2001
From: johann <johann>
Date: Thu, 11 Dec 2008 14:51:58 +0000
Subject: [PATCH] Branch b1_6 b=16522 i=adilger i=wangdi

enable OBD_CONNECT_MDT flag when connecting from the MDS so that
the OSTs know that the MDS "UUID" can be reused for the same export
from a different NID, so we do not need to wait for the export to be
evicted.
---
 lustre/ChangeLog                   |  8 ++++++++
 lustre/include/lustre/lustre_idl.h |  3 ++-
 lustre/ldlm/ldlm_lib.c             | 27 +++++++++++++++++++--------
 lustre/mds/mds_lov.c               |  2 +-
 4 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index 1545f5054a..1ec37aba48 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -256,6 +256,14 @@ Details    : With AT enabled, the recovery window can be excessively long
 	     INITIAL_CONNECT_TIMEOUT now) and clients report the old service
 	     time via pb_service_time.
 
+Severity   : normal
+Bugzilla   : 16522
+Description: Watchdog triggered on MDS failover
+Details    : enable OBD_CONNECT_MDT flag when connecting from the MDS so that
+	     the OSTs know that the MDS "UUID" can be reused for the same export
+	     from a different NID, so we do not need to wait for the export to be
+	     evicted
+
 --------------------------------------------------------------------------
 
 2008-08-31 Sun Microsystems, Inc.
diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h
index 843b43e6d5..5fc920612c 100644
--- a/lustre/include/lustre/lustre_idl.h
+++ b/lustre/include/lustre/lustre_idl.h
@@ -303,6 +303,7 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 /* Connect flags */
 #define OBD_CONNECT_RDONLY            0x1ULL /*client allowed read-only access*/
 #define OBD_CONNECT_INDEX             0x2ULL /*connect to specific LOV idx */
+#define OBD_CONNECT_MDS               0x4ULL /*connect from MDT to OST */
 #define OBD_CONNECT_GRANT             0x8ULL /*OSC acquires grant at connect */
 #define OBD_CONNECT_SRVLOCK          0x10ULL /*server takes locks for client */
 #define OBD_CONNECT_VERSION          0x20ULL /*Lustre versions in ocd */
@@ -354,7 +355,7 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
                                 OBD_CONNECT_BRW_SIZE | OBD_CONNECT_QUOTA64 | \
                                 OBD_CONNECT_CANCELSET | OBD_CONNECT_AT | \
                                 LRU_RESIZE_CONNECT_FLAG | OBD_CONNECT_CKSUM | \
-                                OBD_CONNECT_CHANGE_QS)
+                                OBD_CONNECT_CHANGE_QS | OBD_CONNECT_MDS)
 #define ECHO_CONNECT_SUPPORTED (0)
 #define MGS_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION | OBD_CONNECT_AT)
 
diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c
index 5bc07a2812..2bbb7f05f7 100644
--- a/lustre/ldlm/ldlm_lib.c
+++ b/lustre/ldlm/ldlm_lib.c
@@ -733,14 +733,25 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
                    req->rq_peer.nid != export->exp_connection->c_peer.nid) {
                 /* make darn sure this is coming from the same peer
                  * if the UUIDs matched */
-                  CWARN("%s: cookie %s seen on new NID %s when "
-                          "existing NID %s is already connected\n",
-                        target->obd_name, cluuid.uuid,
-                  libcfs_nid2str(req->rq_peer.nid),
-                  libcfs_nid2str(export->exp_connection->c_peer.nid));
-                  class_export_put(export);
-                  export = NULL;
-                  rc = -EALREADY;
+                if (data && data->ocd_connect_flags & OBD_CONNECT_MDS) {
+                        /* the MDS UUID can be reused, don't need to wait
+                         * for the export to be evicted */
+                        CWARN("%s: received MDS connection from a new NID %s,"
+                              " removing former export from NID %s\n",
+                            target->obd_name,
+                            libcfs_nid2str(req->rq_peer.nid),
+                            libcfs_nid2str(export->exp_connection->c_peer.nid));
+                        class_fail_export(export);
+                } else {
+                        CWARN("%s: cookie %s seen on new NID %s when "
+                              "existing NID %s is already connected\n",
+                            target->obd_name, cluuid.uuid,
+                            libcfs_nid2str(req->rq_peer.nid),
+                            libcfs_nid2str(export->exp_connection->c_peer.nid));
+                        rc = -EALREADY;
+                }
+                class_export_put(export);
+                export = NULL;
         } else if (export != NULL && export->exp_failed) { /* bug 11327 */
                 CDEBUG(D_HA, "%s: exp %p evict in progress - new cookie needed "
                       "for connect\n", export->exp_obd->obd_name, export);
diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c
index f03fa742f1..c3911d9092 100644
--- a/lustre/mds/mds_lov.c
+++ b/lustre/mds/mds_lov.c
@@ -613,7 +613,7 @@ int mds_lov_connect(struct obd_device *obd, char * lov_name)
                 RETURN(-ENOMEM);
         data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_INDEX |
                 OBD_CONNECT_REQPORTAL | OBD_CONNECT_QUOTA64 | OBD_CONNECT_AT |
-                OBD_CONNECT_CHANGE_QS;
+                OBD_CONNECT_CHANGE_QS | OBD_CONNECT_MDS;
 #ifdef HAVE_LRU_RESIZE_SUPPORT
         data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
 #endif
-- 
GitLab