Whamcloud - gitweb
LU-6086 obdclass: check peer's version for MDT-MDT connection 85/13285/5
authorFan Yong <fan.yong@intel.com>
Tue, 4 Nov 2014 09:32:15 +0000 (17:32 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 10 Feb 2015 18:04:09 +0000 (18:04 +0000)
Because new DNE/LFSCK changed some wire protocol, we cannot support
the interoperations between different version MDTs. The basic rules
for the permitted connection are:
1) The @major in the connection version should be the same;
2) The @minor in the connection version should be the same;
3) The difference of the @patch in the connection version should NOT
   more than 3.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I9e77f305c7552ad01e92c97f1eda0756f1291d30
Reviewed-on: http://review.whamcloud.com/13285
Tested-by: Jenkins
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/ldlm/ldlm_lib.c
lustre/lod/lod_lov.c
lustre/ptlrpc/import.c

index d8825bb..5e1f170 100644 (file)
@@ -900,6 +900,34 @@ int target_handle_connect(struct ptlrpc_request *req)
                mds_conn = (data->ocd_connect_flags & OBD_CONNECT_MDS) != 0;
                lw_client = (data->ocd_connect_flags &
                             OBD_CONNECT_LIGHTWEIGHT) != 0;
                mds_conn = (data->ocd_connect_flags & OBD_CONNECT_MDS) != 0;
                lw_client = (data->ocd_connect_flags &
                             OBD_CONNECT_LIGHTWEIGHT) != 0;
+
+               /* OBD_CONNECT_MNE_SWAB is defined as OBD_CONNECT_MDS_MDS
+                * for Imperative Recovery connection from MGC to MGS. */
+               if (!lw_client &&
+                   (data->ocd_connect_flags & OBD_CONNECT_MDS_MDS) &&
+                   !(data->ocd_connect_flags & OBD_CONNECT_IMP_RECOV) &&
+                   (data->ocd_connect_flags & OBD_CONNECT_VERSION)) {
+                       __u32 major = OBD_OCD_VERSION_MAJOR(data->ocd_version);
+                       __u32 minor = OBD_OCD_VERSION_MINOR(data->ocd_version);
+                       __u32 patch = OBD_OCD_VERSION_PATCH(data->ocd_version);
+
+                       /* We do not support the MDT-MDT interoperations with
+                        * different version MDT because of protocol changes. */
+                       if (unlikely(major != LUSTRE_MAJOR ||
+                                    minor != LUSTRE_MINOR ||
+                                    abs(patch - LUSTRE_PATCH) > 3)) {
+                               LCONSOLE_WARN("%s (%u.%u.%u.%u) refused the "
+                                       "connection from different version MDT "
+                                       "(%d.%d.%d.%d) %s %s\n",
+                                       target->obd_name, LUSTRE_MAJOR,
+                                       LUSTRE_MINOR, LUSTRE_PATCH, LUSTRE_FIX,
+                                       major, minor, patch,
+                                       OBD_OCD_VERSION_FIX(data->ocd_version),
+                                       libcfs_nid2str(req->rq_peer.nid), str);
+
+                               GOTO(out, rc = -EPROTO);
+                       }
+               }
        }
 
         /* lctl gets a backstage, all-access pass. */
        }
 
         /* lctl gets a backstage, all-access pass. */
index 7b3a373..47eefff 100644 (file)
@@ -278,9 +278,6 @@ int lod_add_device(const struct lu_env *env, struct lod_device *lod,
                                           OBD_CONNECT_AT |
                                           OBD_CONNECT_FULL20 |
                                           OBD_CONNECT_LFSCK;
                                           OBD_CONNECT_AT |
                                           OBD_CONNECT_FULL20 |
                                           OBD_CONNECT_LFSCK;
-               /* XXX set MDS-MDS flags, remove this when running this
-                * on client*/
-               data->ocd_connect_flags |= OBD_CONNECT_MDS_MDS;
                spin_lock(&imp->imp_lock);
                imp->imp_server_timeout = 1;
                spin_unlock(&imp->imp_lock);
                spin_lock(&imp->imp_lock);
                imp->imp_server_timeout = 1;
                spin_unlock(&imp->imp_lock);
index 224cad4..5d1e6b8 100644 (file)
@@ -1014,6 +1014,32 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
                GOTO(out, rc = -EPROTO);
        }
 
                GOTO(out, rc = -EPROTO);
        }
 
+       if (!(imp->imp_connect_flags_orig & OBD_CONNECT_LIGHTWEIGHT) &&
+           (imp->imp_connect_flags_orig & OBD_CONNECT_MDS_MDS) &&
+           !(imp->imp_connect_flags_orig & OBD_CONNECT_IMP_RECOV) &&
+           (ocd->ocd_connect_flags & OBD_CONNECT_VERSION)) {
+               __u32 major = OBD_OCD_VERSION_MAJOR(ocd->ocd_version);
+               __u32 minor = OBD_OCD_VERSION_MINOR(ocd->ocd_version);
+               __u32 patch = OBD_OCD_VERSION_PATCH(ocd->ocd_version);
+
+               /* We do not support the MDT-MDT interoperations with
+                * different version MDT because of protocol changes. */
+               if (unlikely(major != LUSTRE_MAJOR ||
+                            minor != LUSTRE_MINOR ||
+                            abs(patch - LUSTRE_PATCH) > 3)) {
+                       LCONSOLE_WARN("%s: import %p (%u.%u.%u.%u) tried the "
+                                     "connection to different version MDT "
+                                     "(%d.%d.%d.%d) %s\n",
+                                     imp->imp_obd->obd_name, imp, LUSTRE_MAJOR,
+                                     LUSTRE_MINOR, LUSTRE_PATCH, LUSTRE_FIX,
+                                     major, minor, patch,
+                                     OBD_OCD_VERSION_FIX(ocd->ocd_version),
+                                     imp->imp_connection->c_remote_uuid.uuid);
+
+                       GOTO(out, rc = -EPROTO);
+               }
+       }
+
        if (!exp) {
                /* This could happen if export is cleaned during the
                   connect attempt */
        if (!exp) {
                /* This could happen if export is cleaned during the
                   connect attempt */