Whamcloud - gitweb
LU-2007 ldlm: reconnect can be racy
authorAlex Zhuravlev <bzzz@whamcloud.com>
Sat, 4 Aug 2012 08:14:31 +0000 (12:14 +0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 26 Sep 2012 14:54:25 +0000 (10:54 -0400)
exp_connecting should be checked under spinlock

Signed-off-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Change-Id: I271bc349ae1ad63a4acd1042f30ac7aa7176f105
Reviewed-on: http://review.whamcloud.com/4075
Tested-by: Hudson
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Mike Pershin <tappro@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/ldlm/ldlm_lib.c

index d058a45..5ed98b8 100644 (file)
@@ -884,7 +884,11 @@ int target_handle_connect(struct ptlrpc_request *req)
                 goto no_export;
 
         /* we've found an export in the hash */
                 goto no_export;
 
         /* we've found an export in the hash */
+
+       cfs_spin_lock(&export->exp_lock);
+
         if (export->exp_connecting) { /* bug 9635, et. al. */
         if (export->exp_connecting) { /* bug 9635, et. al. */
+               cfs_spin_unlock(&export->exp_lock);
                 LCONSOLE_WARN("%s: Export %p already connecting from %s\n",
                               export->exp_obd->obd_name, export,
                               libcfs_nid2str(req->rq_peer.nid));
                 LCONSOLE_WARN("%s: Export %p already connecting from %s\n",
                               export->exp_obd->obd_name, export,
                               libcfs_nid2str(req->rq_peer.nid));
@@ -892,6 +896,7 @@ int target_handle_connect(struct ptlrpc_request *req)
                 export = NULL;
                 rc = -EALREADY;
         } else if (mds_conn && export->exp_connection) {
                 export = NULL;
                 rc = -EALREADY;
         } else if (mds_conn && export->exp_connection) {
+               cfs_spin_unlock(&export->exp_lock);
                 if (req->rq_peer.nid != export->exp_connection->c_peer.nid)
                         /* mds reconnected after failover */
                         LCONSOLE_WARN("%s: Received MDS connection from "
                 if (req->rq_peer.nid != export->exp_connection->c_peer.nid)
                         /* mds reconnected after failover */
                         LCONSOLE_WARN("%s: Received MDS connection from "
@@ -911,6 +916,7 @@ int target_handle_connect(struct ptlrpc_request *req)
                    req->rq_peer.nid != export->exp_connection->c_peer.nid &&
                    (lustre_msg_get_op_flags(req->rq_reqmsg) &
                     MSG_CONNECT_INITIAL)) {
                    req->rq_peer.nid != export->exp_connection->c_peer.nid &&
                    (lustre_msg_get_op_flags(req->rq_reqmsg) &
                     MSG_CONNECT_INITIAL)) {
+               cfs_spin_unlock(&export->exp_lock);
                 /* in mds failover we have static uuid but nid can be
                  * changed*/
                 LCONSOLE_WARN("%s: Client %s seen on new nid %s when "
                 /* in mds failover we have static uuid but nid can be
                  * changed*/
                 LCONSOLE_WARN("%s: Client %s seen on new nid %s when "
@@ -923,13 +929,12 @@ int target_handle_connect(struct ptlrpc_request *req)
                 class_export_put(export);
                 export = NULL;
         } else {
                 class_export_put(export);
                 export = NULL;
         } else {
-                cfs_spin_lock(&export->exp_lock);
-                export->exp_connecting = 1;
-                cfs_spin_unlock(&export->exp_lock);
-                LASSERT(export->exp_obd == target);
+               export->exp_connecting = 1;
+               cfs_spin_unlock(&export->exp_lock);
+               LASSERT(export->exp_obd == target);
 
 
-                rc = target_handle_reconnect(&conn, export, &cluuid);
-        }
+               rc = target_handle_reconnect(&conn, export, &cluuid);
+       }
 
         /* If we found an export, we already unlocked. */
         if (!export) {
 
         /* If we found an export, we already unlocked. */
         if (!export) {