+ lov_pool_putref(pool);
+ }
+ }
+
+ rc = lov_alloc_memmd(lsmp, stripe_count, lumv1->lmm_pattern, lmm_magic);
+
+ if (rc >= 0) {
+ (*lsmp)->lsm_oinfo[0]->loi_ost_idx = lumv1->lmm_stripe_offset;
+ (*lsmp)->lsm_stripe_size = lumv1->lmm_stripe_size;
+ if (lmm_magic == LOV_USER_MAGIC_V3)
+ strncpy((*lsmp)->lsm_pool_name, lumv3->lmm_pool_name,
+ LOV_MAXPOOLNAME);
+ rc = 0;
+ }
+
+ RETURN(rc);
+}
+
+/* Configure object striping information on a new file.
+ *
+ * @lmmu is a pointer to a user struct with one or more of the fields set to
+ * indicate the application preference: lmm_stripe_count, lmm_stripe_size,
+ * lmm_stripe_offset, and lmm_stripe_pattern. lmm_magic must be LOV_MAGIC.
+ * @lsmp is a pointer to an in-core stripe MD that needs to be filled in.
+ */
+int lov_setstripe(struct obd_export *exp, int max_lmm_size,
+ struct lov_stripe_md **lsmp, struct lov_user_md *lump)
+{
+ int rc;
+ mm_segment_t seg;
+
+ seg = get_fs();
+ set_fs(KERNEL_DS);
+
+ rc = __lov_setstripe(exp, max_lmm_size, lsmp, lump);
+ set_fs(seg);
+ RETURN(rc);
+}
+
+int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp,
+ struct lov_user_md *lump)
+{
+ int i;
+ int rc;
+ struct obd_export *oexp;
+ struct lov_obd *lov = &exp->exp_obd->u.lov;
+ obd_id last_id = 0;
+ struct lov_user_ost_data_v1 *lmm_objects;
+
+ ENTRY;
+
+ if (lump->lmm_magic == LOV_USER_MAGIC_V3)
+ lmm_objects = ((struct lov_user_md_v3 *)lump)->lmm_objects;
+ else
+ lmm_objects = lump->lmm_objects;
+
+ for (i = 0; i < lump->lmm_stripe_count; i++) {
+ __u32 len = sizeof(last_id);
+ oexp = lov->lov_tgts[lmm_objects[i].l_ost_idx]->ltd_exp;
+ rc = obd_get_info(oexp, sizeof(KEY_LAST_ID), KEY_LAST_ID,
+ &len, &last_id, NULL);
+ if (rc)
+ RETURN(rc);
+ if (lmm_objects[i].l_object_id > last_id) {
+ CERROR("Setting EA for object > than last id on "
+ "ost idx %d "LPD64" > "LPD64" \n",
+ lmm_objects[i].l_ost_idx,
+ lmm_objects[i].l_object_id, last_id);
+ RETURN(-EINVAL);
+ }
+ }
+
+ rc = lov_setstripe(exp, 0, lsmp, lump);
+ if (rc)
+ RETURN(rc);
+
+ for (i = 0; i < lump->lmm_stripe_count; i++) {
+ (*lsmp)->lsm_oinfo[i]->loi_ost_idx =
+ lmm_objects[i].l_ost_idx;
+ (*lsmp)->lsm_oinfo[i]->loi_id = lmm_objects[i].l_object_id;
+ (*lsmp)->lsm_oinfo[i]->loi_seq = lmm_objects[i].l_object_seq;
+ }