if (rc)
return rc;
- return mdd_declare_object_kill(env, obj, ma, handle);
+ return mdo_declare_destroy(env, obj, handle);
}
/* caller should take a lock before calling */
struct thandle *th)
{
int rc = 0;
- int reset = 1;
int is_dir = S_ISDIR(ma->ma_attr.la_mode);
ENTRY;
PFID(mdd_object_fid(obj)),
obj->mod_count);
} else {
- rc = mdd_object_kill(env, obj, ma, th);
- if (rc == 0)
- reset = 0;
+ rc = mdo_destroy(env, obj, th);
}
}
- if (reset)
- ma->ma_valid &= ~(MA_LOV | MA_COOKIE);
RETURN(rc);
}
stop:
mdd_trans_stop(env, mdd, rc, handle);
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 3, 55, 0)
- if (rc == 0 && ma->ma_valid & MA_COOKIE && ma->ma_valid & MA_LOV &&
- ma->ma_valid & MA_FLAGS && ma->ma_attr_flags & MDS_UNLINK_DESTROY)
- /* Since echo client is incapable of destorying ost object,
- * it will destory the object here. */
- rc = mdd_lovobj_unlink(env, mdd, mdd_cobj, la, ma, 1);
-#else
-#warning "please remove this after 2.4 (LOD/OSP)."
-#endif
return rc;
}
}
-static int mdd_declare_create_data(const struct lu_env *env,
- struct mdd_device *mdd,
- struct mdd_object *obj,
- int lmm_size,
- struct thandle *handle)
-{
- struct lu_buf *buf = &mdd_env_info(env)->mti_buf;
- int rc;
-
- buf->lb_buf = NULL;
- buf->lb_len = lmm_size;
- rc = mdo_declare_xattr_set(env, obj, buf, XATTR_NAME_LOV,
- 0, handle);
- if (rc)
- return rc;
-
- rc = mdd_declare_lov_objid_update(env, mdd, handle);
-
- return rc;
-}
-
static int mdd_create_data(const struct lu_env *env, struct md_object *pobj,
struct md_object *cobj, const struct md_op_spec *spec,
struct md_attr *ma)
struct mdd_device *mdd = mdo2mdd(cobj);
struct mdd_object *mdd_pobj = md2mdd_obj(pobj);
struct mdd_object *son = md2mdd_obj(cobj);
- struct lov_mds_md *lmm = NULL;
- int lmm_size = 0;
struct thandle *handle;
- struct lu_attr *attr = &mdd_env_info(env)->mti_la_for_fix;
+ const struct lu_buf *buf;
+ struct lu_attr *attr = &mdd_env_info(env)->mti_cattr;
int rc;
ENTRY;
+ /* do not let users to create stripes via .lustre/
+ * mdd_obf_setup() sets IMMUTE_OBJ on this directory */
+ if (pobj && mdd_pobj->mod_flags & IMMUTE_OBJ)
+ RETURN(-ENOENT);
+
rc = mdd_cd_sanity_check(env, son);
if (rc)
RETURN(rc);
if (!md_should_create(spec->sp_cr_flags))
RETURN(0);
- lmm_size = ma->ma_lmm_size;
-
- rc = mdd_lov_create(env, mdd, mdd_pobj, son, &lmm, &lmm_size, spec, ma);
- if (rc)
- RETURN(rc);
+ /*
+ * there are following use cases for this function:
+ * 1) late striping - file was created with MDS_OPEN_DELAY_CREATE
+ * striping can be specified or not
+ * 2) CMD?
+ */
rc = mdd_la_get(env, son, attr, mdd_object_capa(env, son));
if (rc)
RETURN(rc);
if (IS_ERR(handle))
GOTO(out_free, rc = PTR_ERR(handle));
- rc = mdd_declare_create_data(env, mdd, son, lmm_size, handle);
- if (rc)
- GOTO(stop, rc);
-
- rc = mdd_trans_start(env, mdd, handle);
- if (rc)
- GOTO(stop, rc);
-
/*
* XXX: Setting the lov ea is not locked but setting the attr is locked?
* Should this be fixed?
*/
+ CDEBUG(D_OTHER, "ea %p/%u, cr_flags %Lo, no_create %u\n",
+ spec->u.sp_ea.eadata, spec->u.sp_ea.eadatalen,
+ spec->sp_cr_flags, spec->no_create);
+
+ if (spec->no_create) {
+ /* replay case */
+ buf = mdd_buf_get_const(env, spec->u.sp_ea.eadata,
+ spec->u.sp_ea.eadatalen);
+ } else if (!(spec->sp_cr_flags & MDS_OPEN_HAS_OBJS)) {
+ if (spec->sp_cr_flags & MDS_OPEN_HAS_EA) {
+ /* lfs setstripe */
+ buf = mdd_buf_get_const(env, spec->u.sp_ea.eadata,
+ spec->u.sp_ea.eadatalen);
+ } else {
+ buf = &LU_BUF_NULL;
+ }
+ } else {
+ /* MDS_OPEN_HAS_OBJS is not used anymore ? */
+ LBUG();
+ }
- /* Replay creates has objects already */
-#if 0
- if (spec->no_create) {
- CDEBUG(D_INFO, "we already have lov ea\n");
- rc = mdd_lov_set_md(env, mdd_pobj, son,
- (struct lov_mds_md *)spec->u.sp_ea.eadata,
- spec->u.sp_ea.eadatalen, handle, 0);
- } else
-#endif
- /* No need mdd_lsm_sanity_check here */
- rc = mdd_lov_set_md(env, mdd_pobj, son, lmm,
- lmm_size, handle, 0);
+ rc = dt_declare_xattr_set(env, mdd_object_child(son), buf,
+ XATTR_NAME_LOV, 0, handle);
+ if (rc)
+ GOTO(stop, rc);
- /* update lov_objid data, must be before transaction stop! */
- if (rc == 0)
- mdd_lov_objid_update(mdd, lmm);
+ rc = mdd_trans_start(env, mdd, handle);
+ if (rc)
+ GOTO(stop, rc);
+ rc = dt_xattr_set(env, mdd_object_child(son), buf, XATTR_NAME_LOV,
+ 0, handle, mdd_object_capa(env, son));
stop:
- mdd_trans_stop(env, mdd, rc, handle);
+ mdd_trans_stop(env, mdd, rc, handle);
out_free:
- /* Finish mdd_lov_create() stuff. */
- /* if no_create == 0 (not replay), we free lmm allocated by
- * mdd_lov_create() */
- mdd_lov_create_finish(env, mdd, lmm, lmm_size, spec);
- RETURN(rc);
+ RETURN(rc);
}
/* Get fid from name and parent */
static int mdd_declare_create(const struct lu_env *env, struct mdd_device *mdd,
struct mdd_object *p, struct mdd_object *c,
const struct lu_name *name,
- struct lu_attr *attr, int lmm_size,
+ struct lu_attr *attr,
int got_def_acl,
struct thandle *handle,
const struct md_op_spec *spec)
{
struct mdd_thread_info *info = mdd_env_info(env);
- struct lu_buf *buf = &mdd_env_info(env)->mti_buf;
int rc = 0;
rc = mdd_declare_object_create_internal(env, p, c, attr, handle, spec);
if (rc)
GOTO(out, rc);
- rc = mdo_declare_xattr_set(env, c, buf, XATTR_NAME_LOV,
- 0, handle);
- if (rc)
- GOTO(out, rc);
+ /* replay case, create LOV EA from client data */
+ if (spec->no_create || (spec->sp_cr_flags & MDS_OPEN_HAS_EA)) {
+ const struct lu_buf *buf;
+
+ buf = mdd_buf_get_const(env, spec->u.sp_ea.eadata,
+ spec->u.sp_ea.eadatalen);
+ rc = mdo_declare_xattr_set(env, c, buf, XATTR_NAME_LOV,
+ 0, handle);
+ if (rc)
+ GOTO(out, rc);
+ }
if (S_ISLNK(attr->la_mode)) {
rc = dt_declare_record_write(env, mdd_object_child(c),
if (rc)
return rc;
- rc = mdd_declare_lov_objid_update(env, mdd, handle);
-
out:
return rc;
}
struct mdd_object *son = md2mdd_obj(child);
struct mdd_device *mdd = mdo2mdd(pobj);
struct lu_attr *attr = &ma->ma_attr;
- struct lov_mds_md *lmm = NULL;
struct thandle *handle;
struct lu_attr *pattr = &info->mti_pattr;
struct dynlock_handle *dlh;
const char *name = lname->ln_name;
- int rc, created = 0, initialized = 0, inserted = 0, lmm_size = 0;
+ int rc, created = 0, initialized = 0, inserted = 0;
int got_def_acl = 0;
ENTRY;
RETURN(rc);
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_DQACQ_NET))
- GOTO(out_pending, rc = -EINPROGRESS);
-
- /*
- * No RPC inside the transaction, so OST objects should be created at
- * first.
- */
- if (S_ISREG(attr->la_mode)) {
- lmm_size = ma->ma_lmm_size;
- rc = mdd_lov_create(env, mdd, mdd_pobj, son, &lmm, &lmm_size,
- spec, ma);
- if (rc)
- GOTO(out_pending, rc);
- }
+ GOTO(out_free, rc = -EINPROGRESS);
if (!S_ISLNK(attr->la_mode)) {
struct lu_buf *acl_buf;
GOTO(out_free, rc = PTR_ERR(handle));
rc = mdd_declare_create(env, mdd, mdd_pobj, son, lname, attr,
- got_def_acl, lmm_size, handle, spec);
+ got_def_acl, handle, spec);
if (rc)
GOTO(out_stop, rc);
rc = mdd_object_initialize(env, mdo2fid(mdd_pobj), lname,
son, attr, handle, spec);
+
+ /*
+ * 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.
+ */
+ if (rc == 0 &&
+ (spec->no_create || (spec->sp_cr_flags & MDS_OPEN_HAS_EA))) {
+ 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, XATTR_NAME_LOV, 0, handle,
+ BYPASS_CAPA);
+ }
mdd_write_unlock(env, son);
if (rc)
/*
inserted = 1;
- /* No need mdd_lsm_sanity_check here */
- rc = mdd_lov_set_md(env, mdd_pobj, son, lmm, lmm_size, handle, 0);
- if (rc) {
- CERROR("error on stripe info copy %d \n", rc);
- GOTO(cleanup, rc);
- }
-
if (S_ISLNK(attr->la_mode)) {
struct md_ucred *uc = md_ucred(env);
struct dt_object *dt = mdd_object_child(son);
mdd_write_unlock(env, son);
}
- /* update lov_objid data, must be before transaction stop! */
- if (rc == 0)
- mdd_lov_objid_update(mdd, lmm);
-
mdd_pdo_write_unlock(env, mdd_pobj, dlh);
out_trans:
if (rc == 0)
out_stop:
mdd_trans_stop(env, mdd, rc, handle);
out_free:
- /* finish lov_create stuff, free all temporary data */
- mdd_lov_create_finish(env, mdd, lmm, lmm_size, spec);
-out_pending:
/* The child object shouldn't be cached anymore */
if (rc)
cfs_set_bit(LU_OBJECT_HEARD_BANSHEE,