/* Unpack LOV object metadata from disk storage. It is packed in LE byte * order and is opaque to the networking layer. */ struct lov_stripe_md *lov_unpackmd(struct lov_obd *lov, struct lov_mds_md *lmm, size_t lmm_size) { struct lov_stripe_md *lsm; u16 stripe_count; u32 pattern; u32 magic; int rc; rc = lov_verify_lmm(lmm, lmm_size, &stripe_count); if (rc) return ERR_PTR(rc); magic = le32_to_cpu(lmm->lmm_magic); pattern = le32_to_cpu(lmm->lmm_pattern); lsm = lov_lsm_alloc(stripe_count, pattern, magic); if (IS_ERR(lsm)) return lsm; LASSERT(lsm_op_find(magic)); rc = lsm_op_find(magic)->lsm_unpackmd(lov, lsm, lmm); if (rc) { lov_free_memmd(&lsm); return ERR_PTR(rc); } return lsm; }
/* Unpack LOV object metadata from disk storage. It is packed in LE byte * order and is opaque to the networking layer. */ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, struct lov_mds_md *lmm, int lmm_bytes) { struct obd_device *obd = class_exp2obd(exp); struct lov_obd *lov = &obd->u.lov; int rc = 0, lsm_size; __u16 stripe_count; __u32 magic; __u32 pattern; ENTRY; /* If passed an MDS struct use values from there, otherwise defaults */ if (lmm) { rc = lov_verify_lmm(lmm, lmm_bytes, &stripe_count); if (rc) RETURN(rc); magic = le32_to_cpu(lmm->lmm_magic); pattern = le32_to_cpu(lmm->lmm_pattern); } else { magic = LOV_MAGIC; stripe_count = lov_get_stripecnt(lov, magic, 0); pattern = LOV_PATTERN_RAID0; } /* If we aren't passed an lsmp struct, we just want the size */ if (!lsmp) { /* XXX LOV STACKING call into osc for sizes */ LBUG(); RETURN(lov_stripe_md_size(stripe_count)); } /* If we are passed an allocated struct but nothing to unpack, free */ if (*lsmp && !lmm) { lov_free_memmd(lsmp); RETURN(0); } lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic); if (lsm_size < 0) RETURN(lsm_size); /* If we are passed a pointer but nothing to unpack, we only alloc */ if (!lmm) RETURN(lsm_size); LASSERT(lsm_op_find(magic) != NULL); rc = lsm_op_find(magic)->lsm_unpackmd(lov, *lsmp, lmm); if (rc) { lov_free_memmd(lsmp); RETURN(rc); } RETURN(lsm_size); }