- } else if (export != NULL && export->exp_connection != NULL &&
- 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;
- } else if (export != NULL) {
- spin_lock(&export->exp_lock);
+ } else if (mds_conn && export->exp_connection) {
+ if (req->rq_peer.nid != export->exp_connection->c_peer.nid)
+ /* mds reconnected after failover */
+ CWARN("%s: received MDS connection from 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));
+ else
+ /* new mds connection from the same nid */
+ CWARN("%s: received new MDS connection from NID %s,"
+ " removing former export from same NID\n",
+ target->obd_name, libcfs_nid2str(req->rq_peer.nid));
+ 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) &
+ MSG_CONNECT_INITIAL)) {
+ /* in mds failover we have static uuid but nid can be
+ * changed*/
+ 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 {
+ cfs_spin_lock(&export->exp_lock);