le16_to_cpu(lmm->lmm_stripe_count));
}
-void lov_dump_lmm_v3(int level, struct lov_mds_md_v3 *lmm)
-{
- lov_dump_lmm_common(level, lmm);
- CDEBUG_LIMIT(level, "pool_name "LOV_POOLNAMEF"\n", lmm->lmm_pool_name);
- lov_dump_lmm_objects(level, lmm->lmm_objects,
- le16_to_cpu(lmm->lmm_stripe_count));
-}
-
-void lov_dump_lmm(int level, void *lmm)
-{
- int magic;
-
- magic = le32_to_cpu(((struct lov_mds_md *)lmm)->lmm_magic);
- switch (magic) {
- case LOV_MAGIC_V1:
- lov_dump_lmm_v1(level, (struct lov_mds_md_v1 *)lmm);
- break;
- case LOV_MAGIC_V3:
- lov_dump_lmm_v3(level, (struct lov_mds_md_v3 *)lmm);
- break;
- default:
- CDEBUG_LIMIT(level, "unrecognized lmm_magic %x, assuming %x\n",
- magic, LOV_MAGIC_V1);
- lov_dump_lmm_common(level, lmm);
- break;
- }
-}
-
/**
* Pack LOV striping metadata for disk storage format (in little
* endian byte order).
* then return the size needed. If \a buf_size is too small then
* return -ERANGE. Otherwise return the size of the result.
*/
-ssize_t lov_lsm_pack_v1v3(const struct lov_stripe_md *lsm, void *buf,
- size_t buf_size)
+static ssize_t lov_lsm_pack_v1v3(const struct lov_stripe_md *lsm, void *buf,
+ size_t buf_size)
{
struct lov_mds_md_v1 *lmmv1 = buf;
struct lov_mds_md_v3 *lmmv3 = buf;
lmmv1->lmm_layout_gen = cpu_to_le16(lsm->lsm_layout_gen);
if (lsm->lsm_magic == LOV_MAGIC_V3) {
- CLASSERT(sizeof(lsm->lsm_entries[0]->lsme_pool_name) ==
- sizeof(lmmv3->lmm_pool_name));
+ BUILD_BUG_ON(sizeof(lsm->lsm_entries[0]->lsme_pool_name) !=
+ sizeof(lmmv3->lmm_pool_name));
strlcpy(lmmv3->lmm_pool_name,
lsm->lsm_entries[0]->lsme_pool_name,
sizeof(lmmv3->lmm_pool_name));
RETURN(lmm_size);
}
-ssize_t lov_lsm_pack_foreign(const struct lov_stripe_md *lsm, void *buf,
- size_t buf_size)
+static ssize_t lov_lsm_pack_foreign(const struct lov_stripe_md *lsm, void *buf,
+ size_t buf_size)
{
struct lov_foreign_md *lfm = buf;
size_t lfm_size;
struct lov_mds_md *lmmk, *lmm;
struct lov_foreign_md *lfm;
struct lov_user_md_v1 lum;
- size_t lmmk_size;
- ssize_t lmm_size, lum_size = 0;
+ size_t lmmk_size, lum_size = 0;
+ ssize_t lmm_size;
static bool printed;
int rc = 0;
i--;
comp_md = (struct lov_mds_md *)((char *)comp_v1 +
comp_v1->lcm_entries[i].lcme_offset);
+ lum_size = comp_v1->lcm_entries[i].lcme_size;
}
lmm = comp_md;
- lmm_size = lum_size;
+ lmm_size = min(lum_size, lmmk_size);
} else {
lmm = lmmk;
lmm_size = lmmk_size;
}
+
+ /**
+ * Return stripe_count=1 instead of 0 for DoM files to avoid
+ * divide-by-zero for older userspace that calls this ioctl,
+ * e.g. lustre ADIO driver.
+ */
+ if ((lum.lmm_stripe_count == 0) && (lum.lmm_pattern & LOV_PATTERN_MDT))
+ lum.lmm_stripe_count = 1;
/**
* User specified limited buffer size, usually the buffer is
* from ll_lov_setstripe(), and the buffer can only hold basic