X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fobdclass%2Fmd_attrs.c;h=d0ca4f17b1cb3b327a23e7fecd4526d97b4f666c;hp=f996438327518c2b7a092f1ed615b48d0c41c8a2;hb=3cce65712d94cffe8f1626545845b95b88aef672;hpb=1294081248bbd3e9dc23eb1ffb275dc59a4278db diff --git a/lustre/obdclass/md_attrs.c b/lustre/obdclass/md_attrs.c index f996438..d0ca4f1 100644 --- a/lustre/obdclass/md_attrs.c +++ b/lustre/obdclass/md_attrs.c @@ -21,13 +21,13 @@ * GPL HEADER END */ /* - * Copyright (c) 2012, 2013, Intel Corporation. + * Copyright (c) 2012, 2017, Intel Corporation. * Use is subject to license terms. * * Author: Johann Lombardi */ - -#include +#include +#include #include #include @@ -47,10 +47,10 @@ void lustre_lma_init(struct lustre_mdt_attrs *lma, const struct lu_fid *fid, /* If a field is added in struct lustre_mdt_attrs, zero it explicitly * and change the test below. */ - LASSERT(sizeof(*lma) == - (offsetof(struct lustre_mdt_attrs, lma_self_fid) + - sizeof(lma->lma_self_fid))); -}; + CLASSERT(sizeof(*lma) == + (offsetof(struct lustre_mdt_attrs, lma_self_fid) + + sizeof(lma->lma_self_fid))); +} EXPORT_SYMBOL(lustre_lma_init); /** @@ -60,73 +60,72 @@ 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); +void lustre_loa_init(struct lustre_ost_attrs *loa, const struct lu_fid *fid, + __u32 compat, __u32 incompat) +{ + CLASSERT(sizeof(*loa) == LMA_OLD_SIZE); + + memset(&loa->loa_parent_fid, 0, + sizeof(*loa) - offsetof(typeof(*loa), loa_parent_fid)); + lustre_lma_init(&loa->loa_lma, fid, compat, incompat); +} +EXPORT_SYMBOL(lustre_loa_init); + /** - * Swab, if needed, SOM structure which is stored on-disk in little-endian - * order. + * Swab, if needed, LOA (for OST-object only) structure with LMA EA and PFID EA + * combined together are stored on-disk in little-endian order. * - * \param attrs - is a pointer to the SOM structure to be swabbed. + * \param[in] loa - the pointer to the LOA structure to be swabbed. + * \param[in] to_cpu - to indicate swab for CPU order or not. */ -void lustre_som_swab(struct som_attrs *attrs) +void lustre_loa_swab(struct lustre_ost_attrs *loa, bool to_cpu) { - /* Use LUSTRE_MSG_MAGIC to detect local endianess. */ - if (LUSTRE_MSG_MAGIC != cpu_to_le32(LUSTRE_MSG_MAGIC)) { - __swab32s(&attrs->som_compat); - __swab32s(&attrs->som_incompat); - __swab64s(&attrs->som_ioepoch); - __swab64s(&attrs->som_size); - __swab64s(&attrs->som_blocks); - __swab64s(&attrs->som_mountid); + struct lustre_mdt_attrs *lma = &loa->loa_lma; +#ifdef __BIG_ENDIAN + __u32 compat = lma->lma_compat; +#endif + + lustre_lma_swab(lma); +#ifdef __BIG_ENDIAN + if (to_cpu) + compat = lma->lma_compat; + + if (compat & LMAC_STRIPE_INFO) { + lustre_swab_lu_fid(&loa->loa_parent_fid); + __swab32s(&loa->loa_stripe_size); } -}; -EXPORT_SYMBOL(lustre_som_swab); + if (compat & LMAC_COMP_INFO) { + __swab32s(&loa->loa_comp_id); + __swab64s(&loa->loa_comp_start); + __swab64s(&loa->loa_comp_end); + } +#endif +} +EXPORT_SYMBOL(lustre_loa_swab); -/* - * Swab and extract SOM attributes from on-disk xattr. +/** + * Swab, if needed, SOM structure which is stored on-disk in little-endian + * order. * - * \param buf - is a buffer containing the on-disk SOM extended attribute. - * \param rc - is the SOM xattr stored in \a buf - * \param msd - is the md_som_data structure where to extract SOM attributes. + * \param attrs - is a pointer to the SOM structure to be swabbed. */ -int lustre_buf2som(void *buf, int rc, struct md_som_data *msd) +void lustre_som_swab(struct lustre_som_attrs *attrs) { - struct som_attrs *attrs = (struct som_attrs *)buf; - ENTRY; - - if (rc == 0 || rc == -ENODATA) - /* no SOM attributes */ - RETURN(-ENODATA); - - if (rc < 0) - /* error hit while fetching xattr */ - RETURN(rc); - - /* check SOM compatibility */ - if (attrs->som_incompat & ~cpu_to_le32(SOM_INCOMPAT_SUPP)) - RETURN(-ENODATA); - - /* unpack SOM attributes */ - lustre_som_swab(attrs); - - /* fill in-memory msd structure */ - msd->msd_compat = attrs->som_compat; - msd->msd_incompat = attrs->som_incompat; - msd->msd_ioepoch = attrs->som_ioepoch; - msd->msd_size = attrs->som_size; - msd->msd_blocks = attrs->som_blocks; - msd->msd_mountid = attrs->som_mountid; - - RETURN(0); +#ifdef __BIG_ENDIAN + __swab16s(&attrs->lsa_valid); + __swab64s(&attrs->lsa_size); + __swab64s(&attrs->lsa_blocks); +#endif } -EXPORT_SYMBOL(lustre_buf2som); +EXPORT_SYMBOL(lustre_som_swab); /** * Swab, if needed, HSM structure which is stored on-disk in little-endian @@ -136,15 +135,13 @@ EXPORT_SYMBOL(lustre_buf2som); */ 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); - } -}; -EXPORT_SYMBOL(lustre_hsm_swab); +#ifdef __BIG_ENDIAN + __swab32s(&attrs->hsm_compat); + __swab32s(&attrs->hsm_flags); + __swab64s(&attrs->hsm_arch_id); + __swab64s(&attrs->hsm_arch_ver); +#endif +} /* * Swab and extract HSM attributes from on-disk xattr.