Whamcloud - gitweb
LU-8049 obdclass: use __BIG_ENDIAN to detect local endianness 12/19812/3
authorFan Yong <fan.yong@intel.com>
Fri, 8 Apr 2016 13:12:33 +0000 (21:12 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 27 May 2016 00:58:37 +0000 (00:58 +0000)
Originally, we used LUSTRE_MSG_MAGIC to detect the local endianness
as "if (LUSTRE_MSG_MAGIC != cpu_to_le32(LUSTRE_MSG_MAGIC))". But it
is not a good way. It is gratuitously confusing for no reason not
only because it has nothing specific to do with LUSTRE_MSG_MAGIC,
but also because this is a compile-time check but looks like runtime
check. This patch fixes it by checking "__BIG_ENDIAN".

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I7fc15890119b15c178da22b6dc6eebe102403734
Reviewed-on: http://review.whamcloud.com/19812
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/obdclass/md_attrs.c

index d83b5bb..190524a 100644 (file)
@@ -63,12 +63,11 @@ EXPORT_SYMBOL(lustre_lma_init);
  */
 void lustre_lma_swab(struct lustre_mdt_attrs *lma)
 {
-       /* Use LUSTRE_MSG_MAGIC to detect local endianess. */
-       if (LUSTRE_MSG_MAGIC != cpu_to_le32(LUSTRE_MSG_MAGIC)) {
-               __swab32s(&lma->lma_compat);
-               __swab32s(&lma->lma_incompat);
-               lustre_swab_lu_fid(&lma->lma_self_fid);
-       }
+#ifdef __BIG_ENDIAN
+       __swab32s(&lma->lma_compat);
+       __swab32s(&lma->lma_incompat);
+       lustre_swab_lu_fid(&lma->lma_self_fid);
+#endif
 };
 EXPORT_SYMBOL(lustre_lma_swab);
 
@@ -80,13 +79,12 @@ EXPORT_SYMBOL(lustre_lma_swab);
  */
 void lustre_hsm_swab(struct hsm_attrs *attrs)
 {
-       /* Use LUSTRE_MSG_MAGIC to detect local endianess. */
-       if (LUSTRE_MSG_MAGIC != cpu_to_le32(LUSTRE_MSG_MAGIC)) {
-               __swab32s(&attrs->hsm_compat);
-               __swab32s(&attrs->hsm_flags);
-               __swab64s(&attrs->hsm_arch_id);
-               __swab64s(&attrs->hsm_arch_ver);
-       }
+#ifdef __BIG_ENDIAN
+       __swab32s(&attrs->hsm_compat);
+       __swab32s(&attrs->hsm_flags);
+       __swab64s(&attrs->hsm_arch_id);
+       __swab64s(&attrs->hsm_arch_ver);
+#endif
 };
 
 /*