Whamcloud - gitweb
b=22560 introduce "OBD_CONNECT_FULL20" to distinguish 1.8 client from 2.0 one for...
[fs/lustre-release.git] / lustre / ptlrpc / pack_generic.c
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);