+ /* Note: In DNE phase I, for striped dir, though sub-stripes will be
+ * created in declare phase, they also needs to be added to master
+ * object as sub-directory entry. So it has to initialize the master
+ * object, then set dir striped EA.(in mdo_xattr_set) */
+ rc = mdd_object_initialize(env, mdo2fid(pobj), son, attr, handle,
+ spec);
+ if (rc != 0)
+ GOTO(err_destroy, rc);
+
+ /*
+ * in case of replay we just set LOVEA provided by the client
+ * XXX: I think it would be interesting to try "old" way where
+ * MDT calls this xattr_set(LOV) in a different transaction.
+ * probably this way we code can be made better.
+ */
+
+ /* During creation, there are only a few cases we need do xattr_set to
+ * create stripes.
+ * 1. regular file: see comments above.
+ * 2. create striped directory with provided stripeEA.
+ * 3. create striped directory because inherit default layout from the
+ * parent. */
+ if (spec->no_create ||
+ (S_ISREG(attr->la_mode) && spec->sp_cr_flags & MDS_OPEN_HAS_EA) ||
+ S_ISDIR(attr->la_mode)) {
+ const struct lu_buf *buf;
+
+ buf = mdd_buf_get_const(env, spec->u.sp_ea.eadata,
+ spec->u.sp_ea.eadatalen);
+ rc = mdo_xattr_set(env, son, buf,
+ S_ISDIR(attr->la_mode) ? XATTR_NAME_LMV :
+ XATTR_NAME_LOV, 0,
+ handle, BYPASS_CAPA);
+ if (rc != 0)
+ GOTO(err_destroy, rc);
+ }
+