From 82fcdd9b16aad0b1cd840383c6f3b18c40be00bd Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Fri, 8 Apr 2016 21:12:33 +0800 Subject: [PATCH] LU-8049 obdclass: use __BIG_ENDIAN to detect local endianness 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 Change-Id: I7fc15890119b15c178da22b6dc6eebe102403734 Reviewed-on: http://review.whamcloud.com/19812 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Niu Yawei Reviewed-by: Andreas Dilger --- lustre/obdclass/md_attrs.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lustre/obdclass/md_attrs.c b/lustre/obdclass/md_attrs.c index d83b5bb..190524a 100644 --- a/lustre/obdclass/md_attrs.c +++ b/lustre/obdclass/md_attrs.c @@ -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 }; /* -- 1.8.3.1