Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-8049

Do not use LUSTRE_MSG_MAGIC to check local endianness

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • Lustre 2.9.0
    • None
    • None
    • 3
    • 9223372036854775807

    Description

      There are some code using LUSTRE_MSG_MAGIC to check local endianness, such as:

      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);
              }
      };
      

      It is not a good way of determining the CPU endianness, 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 that looks like a runtime check. Instead, we can fix it with checking "__BIG_ENDIAN".

      Attachments

        Activity

          People

            yong.fan nasf (Inactive)
            yong.fan nasf (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: