Whamcloud - gitweb
LU-1644 mgs: swab nidtbl entries for 2.2 clients
[fs/lustre-release.git] / lustre / ldlm / ldlm_lib.c
index f1d7877..c8c0697 100644 (file)
@@ -747,7 +747,8 @@ int target_handle_connect(struct ptlrpc_request *req)
         struct obd_connect_data *data, *tmpdata;
         int size, tmpsize;
         lnet_nid_t *client_nid = NULL;
-        ENTRY;
+       bool mne_swab_client_ver;
+       ENTRY;
 
         OBD_RACE(OBD_FAIL_TGT_CONN_RACE);
 
@@ -838,6 +839,15 @@ int target_handle_connect(struct ptlrpc_request *req)
         if (rc)
                 GOTO(out, rc);
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 6, 50, 0)
+       /* Check if the client might be missing the LU-1252 fix to swab
+        * the IR mne_length entries. Do this as early as possible in case
+        * the version code is modified. See LU-1644 for details. */
+       mne_swab_client_ver = OBD_OCD_VERSION_MAJOR(data->ocd_version) == 2 &&
+                             OBD_OCD_VERSION_MINOR(data->ocd_version) == 2 &&
+                             OBD_OCD_VERSION_PATCH(data->ocd_version) < 55;
+#endif
+
         if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_LIBCLIENT) {
                 if (!data) {
                         DEBUG_REQ(D_WARNING, req, "Refusing old (unversioned) "
@@ -1032,6 +1042,21 @@ dont_check_exports:
         if (rc)
                 GOTO(out, rc);
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 6, 50, 0)
+       /* 2.2.0 clients always swab nidtbl entries due to a bug, so server
+        * will do the swabbing for if the client is using the same endianness.
+        *
+        * 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 clients.  For newer clients, servers
+        * will never do MNE swabbing, let the client handle that.  LU-1644 */
+       export->exp_need_mne_swab =
+               !(data->ocd_connect_flags & OBD_CONNECT_MNE_SWAB) &&
+               mne_swab_client_ver && !ptlrpc_req_need_swab(req);
+#else
+#warning "LU-1644: Remove old OBD_CONNECT_MNE_SWAB fixup and exp_need_mne_swab"
+#endif
+
         LASSERT(target->u.obt.obt_magic == OBT_MAGIC);
         data->ocd_instance = target->u.obt.obt_instance;