X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fobdclass%2Fmd_attrs.c;h=85003937e746676e4f591a8be886799e32af0b01;hp=979c52dc745d95fbfbf37e1d39625905faba6e1d;hb=db5661e8aad397317f4a0763655ffc0164956097;hpb=e61be5b3bc31178fe44e7eec447d3e18b3f3bda6 diff --git a/lustre/obdclass/md_attrs.c b/lustre/obdclass/md_attrs.c index 979c52d..8500393 100644 --- a/lustre/obdclass/md_attrs.c +++ b/lustre/obdclass/md_attrs.c @@ -53,7 +53,7 @@ void lustre_lma_init(struct lustre_mdt_attrs *lma, const struct lu_fid *fid, LASSERT(sizeof(*lma) == (offsetof(struct lustre_mdt_attrs, lma_self_fid) + sizeof(lma->lma_self_fid))); -}; +} EXPORT_SYMBOL(lustre_lma_init); /** @@ -68,9 +68,52 @@ void lustre_lma_swab(struct lustre_mdt_attrs *lma) __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, LOA (for OST-object only) structure with LMA EA and PFID EA + * combined together are stored on-disk in little-endian order. + * + * \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_loa_swab(struct lustre_ost_attrs *loa, bool to_cpu) +{ + 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); + } + 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, if needed, HSM structure which is stored on-disk in little-endian * order. @@ -85,7 +128,7 @@ void lustre_hsm_swab(struct hsm_attrs *attrs) __swab64s(&attrs->hsm_arch_id); __swab64s(&attrs->hsm_arch_ver); #endif -}; +} /* * Swab and extract HSM attributes from on-disk xattr.