Whamcloud - gitweb
LU-1644 mgc: remove obsolete IR swabbing workaround
[fs/lustre-release.git] / lustre / ptlrpc / import.c
index d1777b5..2e7ac0e 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2016, Intel Corporation.
+ * Copyright (c) 2011, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -175,16 +175,15 @@ int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt)
                                "lost; in progress operations using this "
                                "service will wait for recovery to complete\n",
                                imp->imp_obd->obd_name, target_len, target_start,
-                               libcfs_nid2str(imp->imp_connection->c_peer.nid));
-                } else {
-                        LCONSOLE_ERROR_MSG(0x166, "%s: Connection to "
-                               "%.*s (at %s) was lost; in progress "
-                               "operations using this service will fail\n",
-                               imp->imp_obd->obd_name,
-                               target_len, target_start,
-                               libcfs_nid2str(imp->imp_connection->c_peer.nid));
-                }
-                IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON);
+                              obd_import_nid2str(imp));
+               } else {
+                       LCONSOLE_ERROR_MSG(0x166, "%s: Connection to "
+                              "%.*s (at %s) was lost; in progress "
+                              "operations using this service will fail\n",
+                              imp->imp_obd->obd_name, target_len, target_start,
+                              obd_import_nid2str(imp));
+               }
+               IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON);
                spin_unlock(&imp->imp_lock);
 
                if (obd_dump_on_timeout)
@@ -518,7 +517,7 @@ static int import_select_connection(struct obd_import *imp)
        }
 
        list_for_each_entry(conn, &imp->imp_conn_list, oic_item) {
-               CDEBUG(D_HA, "%s: connect to NID %s last attempt %llu\n",
+               CDEBUG(D_HA, "%s: connect to NID %s last attempt %lld\n",
                        imp->imp_obd->obd_name,
                        libcfs_nid2str(conn->oic_conn->c_peer.nid),
                        conn->oic_last_attempt);
@@ -526,8 +525,7 @@ static int import_select_connection(struct obd_import *imp)
                 /* If we have not tried this connection since
                    the last successful attempt, go with this one */
                 if ((conn->oic_last_attempt == 0) ||
-                    cfs_time_beforeq_64(conn->oic_last_attempt,
-                                       imp->imp_last_success_conn)) {
+                   conn->oic_last_attempt <= imp->imp_last_success_conn) {
                         imp_conn = conn;
                         tried_all = 0;
                         break;
@@ -538,8 +536,7 @@ static int import_select_connection(struct obd_import *imp)
                    least recently used */
                 if (!imp_conn)
                         imp_conn = conn;
-                else if (cfs_time_before_64(conn->oic_last_attempt,
-                                            imp_conn->oic_last_attempt))
+               else if (imp_conn->oic_last_attempt > conn->oic_last_attempt)
                         imp_conn = conn;
         }
 
@@ -568,7 +565,7 @@ static int import_select_connection(struct obd_import *imp)
                        "to %ds\n", imp->imp_obd->obd_name, at_get(at));
        }
 
-        imp_conn->oic_last_attempt = cfs_time_current_64();
+       imp_conn->oic_last_attempt = ktime_get_seconds();
 
         /* switch connection, don't mind if it's same as the current one */
         if (imp->imp_connection)
@@ -764,7 +761,7 @@ int ptlrpc_connect_import(struct obd_import *imp)
                lustre_msg_add_op_flags(request->rq_reqmsg,
                                        MSG_CONNECT_TRANSNO);
 
-       DEBUG_REQ(D_RPCTRACE, request, "(re)connect request (timeout %d)",
+       DEBUG_REQ(D_RPCTRACE, request, "(re)connect request (timeout %ld)",
                  request->rq_timeout);
        ptlrpcd_add_req(request);
        rc = 0;
@@ -801,18 +798,6 @@ static int ptlrpc_connect_set_flags(struct obd_import *imp,
        static bool warned;
        struct client_obd *cli = &imp->imp_obd->u.cli;
 
-       if ((imp->imp_connect_flags_orig & OBD_CONNECT_IBITS) &&
-           !(ocd->ocd_connect_flags & OBD_CONNECT_IBITS)) {
-               LCONSOLE_WARN("%s: MDS %s does not support ibits "
-                             "lock, either very old or invalid: "
-                             "requested %#llx, replied %#llx\n",
-                             imp->imp_obd->obd_name,
-                             imp->imp_connection->c_remote_uuid.uuid,
-                             imp->imp_connect_flags_orig,
-                             ocd->ocd_connect_flags);
-               return -EPROTO;
-       }
-
        spin_lock(&imp->imp_lock);
        list_del(&imp->imp_conn_current->oic_item);
        list_add(&imp->imp_conn_current->oic_item,
@@ -822,7 +807,6 @@ static int ptlrpc_connect_set_flags(struct obd_import *imp,
 
        spin_unlock(&imp->imp_lock);
 
-
        if (!warned && (ocd->ocd_connect_flags & OBD_CONNECT_VERSION) &&
            (ocd->ocd_version > LUSTRE_VERSION_CODE +
                                LUSTRE_VERSION_OFFSET_WARN ||
@@ -833,7 +817,7 @@ static int ptlrpc_connect_set_flags(struct obd_import *imp,
                const char *older = "older than client. "
                                    "Consider upgrading server";
                const char *newer = "newer than client. "
-                                   "Consider recompiling application";
+                                   "Consider upgrading client";
 
                LCONSOLE_WARN("Server %s version (%d.%d.%d.%d) "
                              "is much %s (%s)\n",
@@ -847,25 +831,6 @@ static int ptlrpc_connect_set_flags(struct obd_import *imp,
                warned = true;
        }
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
-       /* Check if server has LU-1252 fix applied to not always swab
-        * the IR MNE entries. Do this only once per connection.  This
-        * fixup is version-limited, because we don't want to carry the
-        * OBD_CONNECT_MNE_SWAB flag around forever, just so long as we
-        * need interop with unpatched 2.2 servers.  For newer servers,
-        * the client will do MNE swabbing only as needed.  LU-1644 */
-       if (unlikely((ocd->ocd_connect_flags & OBD_CONNECT_VERSION) &&
-                    !(ocd->ocd_connect_flags & OBD_CONNECT_MNE_SWAB) &&
-                    OBD_OCD_VERSION_MAJOR(ocd->ocd_version) == 2 &&
-                    OBD_OCD_VERSION_MINOR(ocd->ocd_version) == 2 &&
-                    OBD_OCD_VERSION_PATCH(ocd->ocd_version) < 55 &&
-                    strcmp(imp->imp_obd->obd_type->typ_name,
-                           LUSTRE_MGC_NAME) == 0))
-               imp->imp_need_mne_swab = 1;
-       else /* clear if server was upgraded since last connect */
-               imp->imp_need_mne_swab = 0;
-#endif
-
        if (ocd->ocd_connect_flags & OBD_CONNECT_CKSUM) {
                /* We sent to the server ocd_cksum_types with bits set
                 * for algorithms we understand. The server masked off
@@ -990,7 +955,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
         __u64 old_connect_flags;
         int msg_flags;
        struct obd_connect_data *ocd;
-       struct obd_export *exp;
+       struct obd_export *exp = NULL;
        int ret;
        ENTRY;
 
@@ -1115,6 +1080,8 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
        rc = ptlrpc_connect_set_flags(imp, ocd, old_connect_flags, exp,
                                      aa->pcaa_initial_connect);
        class_export_put(exp);
+       exp = NULL;
+
        if (rc != 0)
                GOTO(out, rc);
 
@@ -1286,6 +1253,9 @@ out:
        imp->imp_connect_tried = 1;
        spin_unlock(&imp->imp_lock);
 
+       if (exp != NULL)
+               class_export_put(exp);
+
         if (rc != 0) {
                 IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON);
                 if (rc == -EACCES) {
@@ -1304,14 +1274,15 @@ out:
                         if (request->rq_repmsg == NULL)
                                 RETURN(-EPROTO);
 
-                        ocd = req_capsule_server_get(&request->rq_pill,
-                                                     &RMF_CONNECT_DATA);
-                        if (ocd &&
-                            (ocd->ocd_connect_flags & OBD_CONNECT_VERSION) &&
-                            (ocd->ocd_version != LUSTRE_VERSION_CODE)) {
-                           /* Actually servers are only supposed to refuse
-                              connection from liblustre clients, so we should
-                              never see this from VFS context */
+                       ocd = req_capsule_server_get(&request->rq_pill,
+                                                    &RMF_CONNECT_DATA);
+                       /* Servers are not supposed to refuse connections from
+                        * clients based on version, only connection feature
+                        * flags.  We should never see this from llite, but it
+                        * may be useful for debugging in the future. */
+                       if (ocd &&
+                           (ocd->ocd_connect_flags & OBD_CONNECT_VERSION) &&
+                           (ocd->ocd_version != LUSTRE_VERSION_CODE)) {
                                 LCONSOLE_ERROR_MSG(0x16a, "Server %s version "
                                         "(%d.%d.%d.%d)"
                                         " refused connection from this client "
@@ -1544,7 +1515,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
                LCONSOLE_INFO("%s: Connection restored to %s (at %s)\n",
                              imp->imp_obd->obd_name,
                              obd_uuid2str(&conn->c_remote_uuid),
-                             libcfs_nid2str(imp->imp_connection->c_peer.nid));
+                             obd_import_nid2str(imp));
         }
 
        if (imp->imp_state == LUSTRE_IMP_FULL) {