+__u32 mdt_lmm_dom_entry_check(struct lov_mds_md *lmm, int *is_dom_only)
+{
+ struct lov_comp_md_v1 *comp_v1;
+ struct lov_mds_md *v1;
+ __u32 off;
+ __u32 dom_stripesize = 0;
+ int i;
+ bool has_ost_stripes = false;
+
+ ENTRY;
+
+ if (is_dom_only)
+ *is_dom_only = 0;
+
+ if (le32_to_cpu(lmm->lmm_magic) != LOV_MAGIC_COMP_V1)
+ RETURN(0);
+
+ comp_v1 = (struct lov_comp_md_v1 *)lmm;
+ off = le32_to_cpu(comp_v1->lcm_entries[0].lcme_offset);
+ v1 = (struct lov_mds_md *)((char *)comp_v1 + off);
+
+ /* Fast check for DoM entry with no mirroring, should be the first */
+ if (le16_to_cpu(comp_v1->lcm_mirror_count) == 0 &&
+ lov_pattern(le32_to_cpu(v1->lmm_pattern)) != LOV_PATTERN_MDT)
+ RETURN(0);
+
+ /* check all entries otherwise */
+ for (i = 0; i < le16_to_cpu(comp_v1->lcm_entry_count); i++) {
+ struct lov_comp_md_entry_v1 *lcme;
+
+ lcme = &comp_v1->lcm_entries[i];
+ if (!(le32_to_cpu(lcme->lcme_flags) & LCME_FL_INIT))
+ continue;
+
+ off = le32_to_cpu(lcme->lcme_offset);
+ v1 = (struct lov_mds_md *)((char *)comp_v1 + off);
+
+ if (lov_pattern(le32_to_cpu(v1->lmm_pattern)) ==
+ LOV_PATTERN_MDT)
+ dom_stripesize = le32_to_cpu(v1->lmm_stripe_size);
+ else
+ has_ost_stripes = true;
+
+ if (dom_stripesize && has_ost_stripes)
+ RETURN(dom_stripesize);
+ }
+ /* DoM-only case exits here */
+ if (is_dom_only && dom_stripesize)
+ *is_dom_only = 1;
+ RETURN(dom_stripesize);
+}
+