/* copied from lov/lov_ea.c, just for debugging, will be removed later */ void mdt_dump_lmm(int level, const struct lov_mds_md *lmm, __u64 valid) { const struct lov_ost_data_v1 *lod; int i; __u16 count; if (likely(!cfs_cdebug_show(level, DEBUG_SUBSYSTEM))) return; count = le16_to_cpu(((struct lov_user_md *)lmm)->lmm_stripe_count); CDEBUG(level, "objid "DOSTID", magic 0x%08X, pattern %#X\n", POSTID(&lmm->lmm_oi), le32_to_cpu(lmm->lmm_magic), le32_to_cpu(lmm->lmm_pattern)); CDEBUG(level, "stripe_size=0x%x, stripe_count=0x%x\n", le32_to_cpu(lmm->lmm_stripe_size), count); /* If it's a directory or a released file, then there are * no actual objects to print, so bail out. */ if (valid & OBD_MD_FLDIREA || le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED) return; LASSERT(count <= LOV_MAX_STRIPE_COUNT); for (i = 0, lod = lmm->lmm_objects; i < count; i++, lod++) { struct ost_id oi; ostid_le_to_cpu(&lod->l_ost_oi, &oi); CDEBUG(level, "stripe %u idx %u subobj "DOSTID"\n", i, le32_to_cpu(lod->l_ost_idx), POSTID(&oi)); } }
int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, struct lov_mds_md_v1 *lmm) { struct lov_oinfo *loi; int i; __u64 stripe_maxbytes = OBD_OBJECT_EOF; lsm_unpackmd_common(lsm, lmm); for (i = 0; i < lsm->lsm_stripe_count; i++) { /* XXX LOV STACKING call down to osc_unpackmd() */ loi = lsm->lsm_oinfo[i]; ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi); loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx); loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen); if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) { CERROR("OST index %d more than OST count %d\n", loi->loi_ost_idx, lov->desc.ld_tgt_count); lov_dump_lmm_v1(D_WARNING, lmm); return -EINVAL; } if (!lov->lov_tgts[loi->loi_ost_idx]) { CERROR("OST index %d missing\n", loi->loi_ost_idx); lov_dump_lmm_v1(D_WARNING, lmm); return -EINVAL; } /* calculate the minimum stripe max bytes */ lov_tgt_maxbytes(lov->lov_tgts[loi->loi_ost_idx], &stripe_maxbytes); } lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; return 0; }
static int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm, struct lov_mds_md *lmmv1) { struct lov_mds_md_v3 *lmm; struct lov_oinfo *loi; int i; int stripe_count; __u64 stripe_maxbytes = OBD_OBJECT_EOF; int cplen = 0; lmm = (struct lov_mds_md_v3 *)lmmv1; lsm_unpackmd_common(lsm, (struct lov_mds_md_v1 *)lmm); stripe_count = lsm_is_released(lsm) ? 0 : lsm->lsm_stripe_count; cplen = strlcpy(lsm->lsm_pool_name, lmm->lmm_pool_name, sizeof(lsm->lsm_pool_name)); if (cplen >= sizeof(lsm->lsm_pool_name)) return -E2BIG; for (i = 0; i < stripe_count; i++) { /* XXX LOV STACKING call down to osc_unpackmd() */ loi = lsm->lsm_oinfo[i]; ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi); loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx); loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen); if (lov_oinfo_is_dummy(loi)) continue; if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) { CERROR("OST index %d more than OST count %d\n", loi->loi_ost_idx, lov->desc.ld_tgt_count); lov_dump_lmm_v3(D_WARNING, lmm); return -EINVAL; } if (!lov->lov_tgts[loi->loi_ost_idx]) { CERROR("OST index %d missing\n", loi->loi_ost_idx); lov_dump_lmm_v3(D_WARNING, lmm); return -EINVAL; } /* calculate the minimum stripe max bytes */ lov_tgt_maxbytes(lov->lov_tgts[loi->loi_ost_idx], &stripe_maxbytes); } lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; if (lsm->lsm_stripe_count == 0) lsm->lsm_maxbytes = stripe_maxbytes * lov->desc.ld_tgt_count; return 0; }
static void lov_dump_lmm_objects(int level, struct lov_ost_data *lod, int stripe_count) { int i; if (stripe_count > LOV_V1_INSANE_STRIPE_COUNT) { CDEBUG(level, "bad stripe_count %u > max_stripe_count %u\n", stripe_count, LOV_V1_INSANE_STRIPE_COUNT); return; } for (i = 0; i < stripe_count; ++i, ++lod) { struct ost_id oi; ostid_le_to_cpu(&lod->l_ost_oi, &oi); CDEBUG(level, "stripe %u idx %u subobj "DOSTID"\n", i, le32_to_cpu(lod->l_ost_idx), POSTID(&oi)); } }
/* copied from lov/lov_ea.c, just for debugging, will be removed later */ void mdt_dump_lmm(int level, const struct lov_mds_md *lmm) { const struct lov_ost_data_v1 *lod; int i; __u16 count; count = le16_to_cpu(((struct lov_user_md*)lmm)->lmm_stripe_count); CDEBUG(level, "objid "DOSTID", magic 0x%08X, pattern %#X\n", POSTID(&lmm->lmm_oi), le32_to_cpu(lmm->lmm_magic), le32_to_cpu(lmm->lmm_pattern)); CDEBUG(level,"stripe_size=0x%x, stripe_count=0x%x\n", le32_to_cpu(lmm->lmm_stripe_size), count); if (count == LOV_ALL_STRIPES) return; LASSERT(count <= LOV_MAX_STRIPE_COUNT); for (i = 0, lod = lmm->lmm_objects; i < count; i++, lod++) { struct ost_id oi; ostid_le_to_cpu((struct ost_id *)&lod->l_ost_oi, &oi); CDEBUG(level, "stripe %u idx %u subobj "DOSTID"\n", i, le32_to_cpu(lod->l_ost_idx), POSTID(&oi)); } }
static int lsm_unpackmd_common(struct lov_obd *lov, struct lov_stripe_md *lsm, struct lov_mds_md *lmm, struct lov_ost_data_v1 *objects) { struct lov_oinfo *loi; loff_t stripe_maxbytes = LLONG_MAX; unsigned int stripe_count; unsigned int i; /* * This supposes lov_mds_md_v1/v3 first fields are * are the same */ lmm_oi_le_to_cpu(&lsm->lsm_oi, &lmm->lmm_oi); lsm->lsm_stripe_size = le32_to_cpu(lmm->lmm_stripe_size); lsm->lsm_pattern = le32_to_cpu(lmm->lmm_pattern); lsm->lsm_layout_gen = le16_to_cpu(lmm->lmm_layout_gen); lsm->lsm_pool_name[0] = '\0'; stripe_count = lsm_is_released(lsm) ? 0 : lsm->lsm_stripe_count; for (i = 0; i < stripe_count; i++) { loi = lsm->lsm_oinfo[i]; ostid_le_to_cpu(&objects[i].l_ost_oi, &loi->loi_oi); loi->loi_ost_idx = le32_to_cpu(objects[i].l_ost_idx); loi->loi_ost_gen = le32_to_cpu(objects[i].l_ost_gen); if (lov_oinfo_is_dummy(loi)) continue; if (loi->loi_ost_idx >= lov->desc.ld_tgt_count && !lov2obd(lov)->obd_process_conf) { CERROR("%s: OST index %d more than OST count %d\n", (char*)lov->desc.ld_uuid.uuid, loi->loi_ost_idx, lov->desc.ld_tgt_count); lov_dump_lmm_v1(D_WARNING, lmm); return -EINVAL; } if (lov->lov_tgts[loi->loi_ost_idx] == NULL) { CERROR("%s: OST index %d missing\n", (char*)lov->desc.ld_uuid.uuid, loi->loi_ost_idx); lov_dump_lmm_v1(D_WARNING, lmm); continue; } stripe_maxbytes = min_t(loff_t, stripe_maxbytes, lov_tgt_maxbytes( lov->lov_tgts[loi->loi_ost_idx])); } if (stripe_maxbytes == LLONG_MAX) stripe_maxbytes = LUSTRE_EXT3_STRIPE_MAXBYTES; if (lsm->lsm_stripe_count == 0) lsm->lsm_maxbytes = stripe_maxbytes * lov->desc.ld_tgt_count; else lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; return 0; }