Whamcloud - gitweb
b=22560 introduce "OBD_CONNECT_FULL20" to distinguish 1.8 client from 2.0 one for...
authorFan Yong <Yong.Fan@sun.com>
Tue, 18 May 2010 02:24:44 +0000 (10:24 +0800)
committerRobert Read <robert.read@oracle.com>
Wed, 19 May 2010 17:46:39 +0000 (10:46 -0700)
Introduce "OBD_CONNECT_FULL20" to distinguish 1.8 client from 2.0 one for different checksum policy:
1) for 1.8 client, use fixed first 88 bytes of ptlrpc_body
2) for 2.0 client, use lm_buflens

i=andreas.dilger
i=robert.read

16 files changed:
lustre/cmm/mdc_device.c
lustre/include/lustre/lustre_idl.h
lustre/include/lustre_net.h
lustre/ldlm/ldlm_lib.c
lustre/liblustre/llite_lib.c
lustre/liblustre/super.c
lustre/llite/llite_lib.c
lustre/mds/mds_lov.c
lustre/obdclass/obd_mount.c
lustre/ptlrpc/import.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/sec.c
lustre/ptlrpc/sec_null.c
lustre/ptlrpc/wiretest.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index fc77a67..3e7da7c 100644 (file)
@@ -151,7 +151,8 @@ static int mdc_obd_add(const struct lu_env *env,
                                          OBD_CONNECT_IBITS |
                                          OBD_CONNECT_MDS_MDS |
                                          OBD_CONNECT_FID |
-                                         OBD_CONNECT_AT;
+                                         OBD_CONNECT_AT |
+                                         OBD_CONNECT_FULL20;
                 rc = obd_connect(env, &desc->cl_exp, mdc, &mdc->obd_uuid, ocd, NULL);
                 OBD_FREE_PTR(ocd);
                 if (rc) {
index 3a1581f..c77fff7 100644 (file)
@@ -658,6 +658,7 @@ static inline void lustre_handle_copy(struct lustre_handle *tgt,
 
 /* flags for lm_flags */
 #define MSGHDR_AT_SUPPORT               0x1
+#define MSGHDR_CKSUM_INCOMPAT18         0x2
 
 #define lustre_msg lustre_msg_v2
 /* we depend on this structure to be 8-byte aligned */
@@ -796,6 +797,7 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 #define OBD_CONNECT_LOV_V3        0x100000000ULL /*client supports LOV v3 EA */
 #define OBD_CONNECT_GRANT_SHRINK  0x200000000ULL /* support grant shrink */
 #define OBD_CONNECT_SKIP_ORPHAN   0x400000000ULL /* don't reuse orphan objids */
+#define OBD_CONNECT_FULL20        0x800000000ULL /* it is 2.0 client */
 /* also update obd_connect_names[] for lprocfs_rd_connect_flags()
  * and lustre/utils/wirecheck.c */
 
@@ -815,7 +817,8 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
                                 OBD_CONNECT_MDS_CAPA | OBD_CONNECT_OSS_CAPA | \
                                 OBD_CONNECT_MDS_MDS | OBD_CONNECT_FID | \
                                 LRU_RESIZE_CONNECT_FLAG | OBD_CONNECT_VBR | \
-                                OBD_CONNECT_LOV_V3 | OBD_CONNECT_SOM)
+                                OBD_CONNECT_LOV_V3 | OBD_CONNECT_SOM | \
+                                OBD_CONNECT_FULL20)
 #define OST_CONNECT_SUPPORTED  (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \
                                 OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \
                                 OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_INDEX | \
@@ -826,9 +829,10 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
                                 OBD_CONNECT_OSS_CAPA  | OBD_CONNECT_RMT_CLIENT | \
                                 OBD_CONNECT_RMT_CLIENT_FORCE | OBD_CONNECT_VBR | \
                                 OBD_CONNECT_MDS | OBD_CONNECT_SKIP_ORPHAN | \
-                                OBD_CONNECT_GRANT_SHRINK)
+                                OBD_CONNECT_GRANT_SHRINK | OBD_CONNECT_FULL20)
 #define ECHO_CONNECT_SUPPORTED (0)
-#define MGS_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION | OBD_CONNECT_AT)
+#define MGS_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION | OBD_CONNECT_AT | \
+                                OBD_CONNECT_FULL20)
 
 #define OBD_OCD_VERSION(major,minor,patch,fix) (((major)<<24) + ((minor)<<16) +\
                                                 ((patch)<<8) + (fix))
index d507cb8..9bd4205 100644 (file)
@@ -64,6 +64,7 @@
 #include <lustre_req_layout.h>
 
 #include <obd_support.h>
+#include <lustre_ver.h>
 
 /* MD flags we _always_ use */
 #define PTLRPC_MD_OPTIONS  0
@@ -1174,7 +1175,12 @@ __u32 lustre_msg_get_magic(struct lustre_msg *msg);
 __u32 lustre_msg_get_timeout(struct lustre_msg *msg);
 __u32 lustre_msg_get_service_time(struct lustre_msg *msg);
 __u32 lustre_msg_get_cksum(struct lustre_msg *msg);
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 0, 0)
+__u32 lustre_msg_calc_cksum(struct lustre_msg *msg, int compat18);
+#else
+# warning "remove checksum compatibility support for b1_8"
 __u32 lustre_msg_calc_cksum(struct lustre_msg *msg);
+#endif
 void lustre_msg_set_handle(struct lustre_msg *msg,struct lustre_handle *handle);
 void lustre_msg_set_type(struct lustre_msg *msg, __u32 type);
 void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc);
index a19f2f3..5621bd5 100644 (file)
@@ -1053,6 +1053,12 @@ dont_check_exports:
         else
                 revimp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT;
 
+        if ((export->exp_connect_flags & OBD_CONNECT_FULL20) &&
+            (revimp->imp_msg_magic != LUSTRE_MSG_MAGIC_V1))
+                revimp->imp_msghdr_flags |= MSGHDR_CKSUM_INCOMPAT18;
+        else
+                revimp->imp_msghdr_flags &= ~MSGHDR_CKSUM_INCOMPAT18;
+
         rc = sptlrpc_import_sec_adapt(revimp, req->rq_svc_ctx, &req->rq_flvr);
         if (rc) {
                 CERROR("Failed to get sec for reverse import: %d\n", rc);
index 9003491..c12695b 100644 (file)
@@ -173,7 +173,8 @@ int liblustre_process_log(struct config_llog_instance *cfg,
                 GOTO(out_cleanup, rc = -ENOMEM);
 
         ocd->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_FID |
-                                 OBD_CONNECT_AT | OBD_CONNECT_VBR;
+                                 OBD_CONNECT_AT | OBD_CONNECT_VBR |
+                                 OBD_CONNECT_FULL20;
 #ifdef LIBLUSTRE_POSIX_ACL
         ocd->ocd_connect_flags |= OBD_CONNECT_ACL;
 #endif
index 7be70b9..969d633 100644 (file)
@@ -1999,7 +1999,8 @@ llu_fsswop_mount(const char *source,
 
         ocd.ocd_connect_flags = OBD_CONNECT_IBITS | OBD_CONNECT_VERSION |
                                 OBD_CONNECT_FID | OBD_CONNECT_AT |
-                                OBD_CONNECT_VBR | OBD_CONNECT_SOM;
+                                OBD_CONNECT_VBR | OBD_CONNECT_SOM |
+                                OBD_CONNECT_FULL20;
 #ifdef LIBLUSTRE_POSIX_ACL
         ocd.ocd_connect_flags |= OBD_CONNECT_ACL;
 #endif
@@ -2036,7 +2037,7 @@ llu_fsswop_mount(const char *source,
         ocd.ocd_connect_flags = OBD_CONNECT_SRVLOCK | OBD_CONNECT_REQPORTAL |
                                 OBD_CONNECT_VERSION | OBD_CONNECT_TRUNCLOCK |
                                 OBD_CONNECT_FID | OBD_CONNECT_AT |
-                                OBD_CONNECT_SOM;
+                                OBD_CONNECT_SOM | OBD_CONNECT_FULL20;
 
         ocd.ocd_version = LUSTRE_VERSION_CODE;
         err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, &ocd, NULL);
index 51aae73..8c0461f 100644 (file)
@@ -198,7 +198,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
                                   OBD_CONNECT_OSS_CAPA | OBD_CONNECT_CANCELSET|
                                   OBD_CONNECT_FID      | OBD_CONNECT_AT |
                                   OBD_CONNECT_LOV_V3 | OBD_CONNECT_RMT_CLIENT |
-                                  OBD_CONNECT_VBR      | OBD_CONNECT_SOM;
+                                  OBD_CONNECT_VBR      | OBD_CONNECT_SOM |
+                                  OBD_CONNECT_FULL20;
 
 #ifdef HAVE_LRU_RESIZE_SUPPORT
         if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
@@ -339,7 +340,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
                                   OBD_CONNECT_SRVLOCK   | OBD_CONNECT_TRUNCLOCK|
                                   OBD_CONNECT_AT | OBD_CONNECT_RMT_CLIENT |
                                   OBD_CONNECT_OSS_CAPA | OBD_CONNECT_VBR|
-                                  OBD_CONNECT_SOM;
+                                  OBD_CONNECT_SOM | OBD_CONNECT_FULL20;
 
         if (!OBD_FAIL_CHECK(OBD_FAIL_OSC_CONNECT_CKSUM)) {
                 /* OBD_CONNECT_CKSUM should always be set, even if checksums are
index d01c6fd..80490f4 100644 (file)
@@ -716,7 +716,7 @@ int mds_lov_connect(struct obd_device *obd, char * lov_name)
                                   OBD_CONNECT_BRW_SIZE  | OBD_CONNECT_CKSUM   |
                                   OBD_CONNECT_CHANGE_QS | OBD_CONNECT_AT      |
                                   OBD_CONNECT_MDS | OBD_CONNECT_SKIP_ORPHAN   |
-                                  OBD_CONNECT_SOM;
+                                  OBD_CONNECT_SOM | OBD_CONNECT_FULL20;
 #ifdef HAVE_LRU_RESIZE_SUPPORT
         data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
 #endif
index 3d211be..b2acd97 100644 (file)
@@ -766,7 +766,7 @@ static int lustre_start_mgc(struct super_block *sb)
         if (data == NULL)
                 GOTO(out, rc = -ENOMEM);
         data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_FID |
-                                  OBD_CONNECT_AT;
+                                  OBD_CONNECT_AT | OBD_CONNECT_FULL20;
         data->ocd_version = LUSTRE_VERSION_CODE;
         rc = obd_connect(NULL, &exp, obd, &(obd->obd_uuid), data, NULL);
         OBD_FREE_PTR(data);
index 95eb543..f04e56f 100644 (file)
@@ -667,6 +667,7 @@ int ptlrpc_connect_import(struct obd_import *imp, char *new_uuid)
          * the server is updated on-the-fly we will get the new features. */
         imp->imp_connect_data.ocd_connect_flags = imp->imp_connect_flags_orig;
         imp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT;
+        imp->imp_msghdr_flags &= ~MSGHDR_CKSUM_INCOMPAT18;
 
         rc = obd_reconnect(NULL, imp->imp_obd->obd_self_export, obd,
                            &obd->obd_uuid, &imp->imp_connect_data, NULL);
@@ -1112,6 +1113,12 @@ finish:
                 else
                         imp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT;
 
+                if ((ocd->ocd_connect_flags & OBD_CONNECT_FULL20) &&
+                    (imp->imp_msg_magic == LUSTRE_MSG_MAGIC_V2))
+                        imp->imp_msghdr_flags |= MSGHDR_CKSUM_INCOMPAT18;
+                else
+                        imp->imp_msghdr_flags &= ~MSGHDR_CKSUM_INCOMPAT18;
+
                 LASSERT((cli->cl_max_pages_per_rpc <= PTLRPC_MAX_BRW_PAGES) &&
                         (cli->cl_max_pages_per_rpc > 0));
         }
index 5af3db6..3939a6b 100644 (file)
@@ -1252,13 +1252,34 @@ __u32 lustre_msg_get_cksum(struct lustre_msg *msg)
         }
 }
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 0, 0)
+/*
+ * In 1.6 and 1.8 the checksum was computed only on struct ptlrpc_body as
+ * it was in 1.6 (88 bytes, smaller than the full size in 1.8).  It makes
+ * more sense to compute the checksum on the full ptlrpc_body, regardless
+ * of what size it is, but in order to keep interoperability with 1.8 we
+ * can optionally also checksum only the first 88 bytes (caller decides). */
+# define ptlrpc_body_cksum_size_compat18         88
+
+__u32 lustre_msg_calc_cksum(struct lustre_msg *msg, int compat18)
+#else
+# warning "remove checksum compatibility support for b1_8"
 __u32 lustre_msg_calc_cksum(struct lustre_msg *msg)
+#endif
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 0, 0)
+                __u32 len = compat18 ? ptlrpc_body_cksum_size_compat18 :
+                            lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
-                return crc32_le(~(__u32)0, (unsigned char *)pb, sizeof(*pb));
+                return crc32_le(~(__u32)0, (unsigned char *)pb, len);
+#else
+# warning "remove checksum compatibility support for b1_8"
+                return crc32_le(~(__u32)0, (unsigned char *)pb,
+                                lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF));
+#endif
         }
         default:
                 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
index fce57c7..1d64af4 100644 (file)
@@ -1115,6 +1115,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
         early_req->rq_repdata = (struct lustre_msg *) early_buf;
         early_req->rq_repdata_len = early_size;
         early_req->rq_early = 1;
+        early_req->rq_reqmsg = req->rq_reqmsg;
 
         rc = do_cli_unwrap_reply(early_req);
         if (rc) {
index 67dbcfb..52100ae 100644 (file)
@@ -107,7 +107,16 @@ int null_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
 
         if (req->rq_early) {
                 cksums = lustre_msg_get_cksum(req->rq_repdata);
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 0, 0)
+                if (lustre_msghdr_get_flags(req->rq_reqmsg) &
+                    MSGHDR_CKSUM_INCOMPAT18)
+                        cksumc = lustre_msg_calc_cksum(req->rq_repmsg, 0);
+                else
+                        cksumc = lustre_msg_calc_cksum(req->rq_repmsg, 1);
+#else
+# warning "remove checksum compatibility support for b1_8"
                 cksumc = lustre_msg_calc_cksum(req->rq_repmsg);
+#endif
                 if (cksumc != cksums) {
                         CWARN("early reply checksum mismatch: %08x != %08x\n",
                               cksumc, cksums);
@@ -358,8 +367,19 @@ int null_authorize(struct ptlrpc_request *req)
                 else
                         req->rq_reply_off = 0;
         } else {
-                lustre_msg_set_cksum(rs->rs_repbuf,
-                                     lustre_msg_calc_cksum(rs->rs_repbuf));
+                __u32 cksum;
+
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 0, 0)
+                if (lustre_msghdr_get_flags(req->rq_reqmsg) &
+                    MSGHDR_CKSUM_INCOMPAT18)
+                        cksum = lustre_msg_calc_cksum(rs->rs_repbuf, 0);
+                else
+                        cksum = lustre_msg_calc_cksum(rs->rs_repbuf, 1);
+#else
+# warning "remove checksum compatibility support for b1_8"
+                cksum = lustre_msg_calc_cksum(rs->rs_repbuf);
+#endif
+                lustre_msg_set_cksum(rs->rs_repbuf, cksum);
                 req->rq_reply_off = 0;
         }
 
index d186f71..f61dbab 100644 (file)
@@ -492,6 +492,7 @@ void lustre_assert_wire_constants(void)
         CLASSERT(OBD_CONNECT_LRU_RESIZE == 0x2000000ULL);
         CLASSERT(OBD_CONNECT_VBR == 0x80000000ULL);
         CLASSERT(OBD_CONNECT_SKIP_ORPHAN == 0x400000000ULL);
+        CLASSERT(OBD_CONNECT_FULL20 == 0x800000000ULL);
 
         /* Checks for struct obdo */
         LASSERTF((int)sizeof(struct obdo) == 208, " found %lld\n",
index 49092b1..2f91886 100644 (file)
@@ -221,6 +221,7 @@ static void check_obd_connect_data(void)
         CHECK_CDEFINE(OBD_CONNECT_LRU_RESIZE);
         CHECK_CDEFINE(OBD_CONNECT_VBR);
         CHECK_CDEFINE(OBD_CONNECT_SKIP_ORPHAN);
+        CHECK_CDEFINE(OBD_CONNECT_FULL20);
 }
 
 static void
index ada400e..38f13b4 100644 (file)
@@ -489,6 +489,7 @@ void lustre_assert_wire_constants(void)
         CLASSERT(OBD_CONNECT_LRU_RESIZE == 0x2000000ULL);
         CLASSERT(OBD_CONNECT_VBR == 0x80000000ULL);
         CLASSERT(OBD_CONNECT_SKIP_ORPHAN == 0x400000000ULL);
+        CLASSERT(OBD_CONNECT_FULL20 == 0x800000000ULL);
 
         /* Checks for struct obdo */
         LASSERTF((int)sizeof(struct obdo) == 208, " found %lld\n",