-static int lov_verify_lmm_v0(struct lov_mds_md_v0 *lmm, int lmm_bytes,
- int *stripe_count)
-{
- if (lmm_bytes < sizeof(*lmm)) {
- CERROR("lov_mds_md too small: %d, need at least %d\n",
- lmm_bytes, (int)sizeof(*lmm));
- return -EINVAL;
- }
-
- *stripe_count = le16_to_cpu(lmm->lmm_stripe_count);
-
- if (*stripe_count == 0 ||
- *stripe_count > le32_to_cpu(lmm->lmm_ost_count)) {
- CERROR("bad stripe count %d\n", *stripe_count);
- lov_dump_lmm_v0(D_WARNING, lmm);
- return -EINVAL;
- }
-
- if (lmm_bytes < lov_mds_md_v0_size(*stripe_count)) {
- CERROR("LOV EA too small: %d, need %d\n",
- lmm_bytes, lov_mds_md_size(*stripe_count));
- lov_dump_lmm_v0(D_WARNING, lmm);
- return -EINVAL;
- }
-
- if (lmm->lmm_object_id == 0) {
- CERROR("zero object id\n");
- lov_dump_lmm_v0(D_WARNING, lmm);
- return -EINVAL;
- }
-
- if (le32_to_cpu(lmm->lmm_stripe_offset) >
- le32_to_cpu(lmm->lmm_ost_count)) {
- CERROR("stripe offset %d more than number of OSTs %d\n",
- le32_to_cpu(lmm->lmm_stripe_offset),
- le32_to_cpu(lmm->lmm_ost_count));
- lov_dump_lmm_v0(D_WARNING, lmm);
- return -EINVAL;
- }
-
- if (lmm->lmm_stripe_size == 0) {
- CERROR("zero stripe size\n");
- lov_dump_lmm_v0(D_WARNING, lmm);
- return -EINVAL;
- }