Whamcloud - gitweb
LU-9846 lod: Add overstriping support
[fs/lustre-release.git] / lustre / mdt / mdt_internal.h
index 546ad8a..f6a04f1 100644 (file)
@@ -709,6 +709,43 @@ static inline bool mdt_lmm_is_flr(struct lov_mds_md *lmm)
               le16_to_cpu(lcm->lcm_mirror_count) > 0;
 }
 
+static inline bool lmm_is_overstriping(struct lov_mds_md *lmm)
+{
+       if (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V1 ||
+           le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V3)
+               return le16_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_OVERSTRIPING;
+
+       return false;
+}
+
+static inline bool mdt_lmm_comp_overstriping(struct lov_mds_md *lmm)
+{
+       struct lov_comp_md_v1 *comp_v1;
+       struct lov_mds_md *v1;
+       __u32 off;
+       int i;
+
+       comp_v1 = (struct lov_comp_md_v1 *)lmm;
+
+       for (i = 1; i < le16_to_cpu(comp_v1->lcm_entry_count); i++) {
+               off = le32_to_cpu(comp_v1->lcm_entries[i].lcme_offset);
+               v1 = (struct lov_mds_md *)((char *)comp_v1 + off);
+
+               if (lmm_is_overstriping(v1))
+                       return true;
+       }
+
+       return false;
+}
+
+static inline bool mdt_lmm_is_overstriping(struct lov_mds_md *lmm)
+{
+       if (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_COMP_V1)
+               return mdt_lmm_comp_overstriping(lmm);
+
+       return lmm_is_overstriping(lmm);
+}
+
 static inline bool mdt_is_sum_statfs_client(struct obd_export *exp)
 {
        return exp_connect_flags(exp) & OBD_CONNECT_FLAGS2 &&