static int mdd_is_dead_obj(struct mdd_object *obj)
{
- if (obj && obj->mod_flags & DEAD_OBJ)
- return 1;
- return 0;
+ return obj && obj->mod_flags & DEAD_OBJ;
}
-/*Check whether it may create the cobj under the pobj*/
-static int mdd_may_create(const struct lu_context *ctxt,
+/*Check whether it may create the cobj under the pobj*/
+static int mdd_may_create(const struct lu_context *ctxt,
struct mdd_object *pobj, struct mdd_object *cobj)
{
ENTRY;
struct mdd_device *mdd = mdo2mdd(&pobj->mod_obj);
int rc = 0;
ENTRY;
-
+
LASSERT(cobj && pobj);
if (!lu_object_exists(ctxt, &cobj->mod_obj.mo_lu))
RETURN(-ENOENT);
-
+
/*TODO:check append flags*/
if (is_dir) {
if (!S_ISDIR(mdd_object_type(cobj)))
if (lu_fid_eq(mdo2fid(cobj), &mdd->mdd_root_fid))
RETURN(-EBUSY);
-
+
} else if (S_ISDIR(mdd_object_type(cobj)))
RETURN(-EISDIR);
-
+
if (mdd_is_dead_obj(pobj))
RETURN(-ENOENT);
-
+
RETURN(rc);
}
/* get only inode attributes */
-static int __mdd_iattr_get (const struct lu_context *ctxt,
- struct mdd_object *mdd_obj,
- struct md_attr *ma)
+static int __mdd_iattr_get(const struct lu_context *ctxt,
+ struct mdd_object *mdd_obj, struct md_attr *ma)
{
struct dt_object *next = mdd_object_child(mdd_obj);
int rc = 0;
}
static int mdd_attr_get_internal(const struct lu_context *ctxt,
- struct mdd_object *mdd_obj,
+ struct mdd_object *mdd_obj,
struct md_attr *ma)
{
int rc = 0;
if (ma->ma_need & MA_INODE)
rc = __mdd_iattr_get(ctxt, mdd_obj, ma);
-
+
if (rc == 0 && ma->ma_need & MA_LOV) {
if (S_ISREG(lu_object_attr(mdd2lu_obj(mdd_obj))) ||
S_ISDIR(lu_object_attr(mdd2lu_obj(mdd_obj)))) {
}
static inline int mdd_attr_get_internal_locked (const struct lu_context *ctxt,
- struct mdd_object *mdd_obj,
+ struct mdd_object *mdd_obj,
struct md_attr *ma)
{
int rc;
char *dev = lustre_cfg_string(cfg, 0);
int rc;
- switch(cfg->lcfg_command) {
+ switch (cfg->lcfg_command) {
case LCFG_SETUP:
rc = next->ld_ops->ldo_process_config(ctxt, next, cfg);
if (rc)
.loo_object_exists = mdd_object_exists,
};
-void mdd_lock(const struct lu_context *ctxt, struct mdd_object *obj,
+void mdd_lock(const struct lu_context *ctxt, struct mdd_object *obj,
enum dt_lock_mode mode)
{
struct dt_object *next = mdd_object_child(obj);
next->do_ops->do_lock(ctxt, next, mode);
}
-void mdd_unlock(const struct lu_context *ctxt, struct mdd_object *obj,
+void mdd_unlock(const struct lu_context *ctxt, struct mdd_object *obj,
enum dt_lock_mode mode)
{
struct dt_object *next = mdd_object_child(obj);
struct dt_object *next;
int rc = 0;
ENTRY;
-
+
LASSERT(lu_object_exists(ctxt, mdd2lu_obj(o)));
next = mdd_object_child(o);
if (buf && buf_len > 0) {
- rc = next->do_ops->do_xattr_set(ctxt, next, buf, buf_len, name,
+ rc = next->do_ops->do_xattr_set(ctxt, next, buf, buf_len, name,
0, handle);
}else if (buf == NULL && buf_len == 0) {
rc = next->do_ops->do_xattr_del(ctxt, next, name, handle);
* chown_common and inode_setattr
* utimes and inode_setattr
* This API is ported from mds_fix_attr but remove some unnecesssary stuff.
- * and port to
+ * and port to
*/
int mdd_fix_attr(const struct lu_context *ctxt, struct mdd_object *obj,
const struct md_attr *ma, struct lu_attr *la)
/* set attr and LOV EA at once, return updated attr */
static int mdd_attr_set(const struct lu_context *ctxt,
- struct md_object *obj,
+ struct md_object *obj,
const struct md_attr *ma)
{
struct mdd_object *mdd_obj = md2mdd_obj(obj);
OBD_ALLOC(lmm, max_size);
if (lmm == NULL)
GOTO(cleanup, rc = -ENOMEM);
-
+
rc = mdd_get_md(ctxt, mdd_obj, lmm, &lmm_size, 1);
-
+
if (rc < 0)
GOTO(cleanup, rc);
}
if (ma->ma_attr.la_valid & (ATTR_MTIME | ATTR_CTIME))
CDEBUG(D_INODE, "setting mtime "LPU64", ctime "LPU64"\n",
ma->ma_attr.la_mtime, ma->ma_attr.la_ctime);
-
+
*la_copy = ma->ma_attr;
rc = mdd_fix_attr(ctxt, mdd_obj, ma, la_copy);
if (rc)
}
if (rc == 0 && ma->ma_valid & MA_LOV) {
- if ((S_ISREG(mdd_object_type(mdd_obj)) ||
+ if ((S_ISREG(mdd_object_type(mdd_obj)) ||
S_ISDIR(mdd_object_type(mdd_obj)))) {
/*TODO check permission*/
rc = mdd_lov_set_md(ctxt, NULL, mdd_obj, ma->ma_lmm,
ma->ma_lmm_size, handle, 1);
}
-
+
}
cleanup:
mdd_trans_stop(ctxt, mdd, handle);
if (lmm != NULL) {
OBD_FREE(lmm, max_size);
}
-
+
RETURN(rc);
}
if (IS_ERR(handle))
RETURN(PTR_ERR(handle));
- rc = mdd_xattr_set_txn(ctxt, md2mdd_obj(obj), buf, buf_len, name,
+ rc = mdd_xattr_set_txn(ctxt, md2mdd_obj(obj), buf, buf_len, name,
fl, handle);
mdd_trans_stop(ctxt, mdd, handle);
RETURN(rc);
}
-static int mdd_link_sanity_check(const struct lu_context *ctxt,
+static int mdd_link_sanity_check(const struct lu_context *ctxt,
struct mdd_object *tgt_obj,
struct mdd_object *src_obj)
{
int rc;
-
+
rc = mdd_may_create(ctxt, tgt_obj, NULL);
if (rc)
RETURN(rc);
rc = mdd_link_sanity_check(ctxt, mdd_tobj, mdd_sobj);
if (rc)
GOTO(out, rc);
-
+
rc = __mdd_index_insert(ctxt, mdd_tobj, lu_object_fid(&src_obj->mo_lu),
name, handle);
if (rc == 0)
{
int rc;
ENTRY;
-
+
rc = __mdd_iattr_get(ctxt, obj, ma);
if (rc == 0) {
if (atomic_read(&obj->mod_count) == 0 &&
if (rc == 0 && ma->ma_valid & MA_LOV)
rc = mdd_unlink_log(ctxt,
mdo2mdd(&obj->mod_obj),
- obj, ma);
+ obj, ma);
}
}
RETURN(rc);
if (rc)
RETURN(rc);
- if (S_ISDIR(mdd_object_type(cobj)) &&
+ if (S_ISDIR(mdd_object_type(cobj)) &&
dt_try_as_dir(ctxt, dt_cobj)) {
rc = mdd_dir_is_empty(ctxt, cobj);
if (rc != 0)
RETURN(rc);
}
-
+
RETURN(rc);
}
}
mdd_lock2(ctxt, src_pobj, tgt_pobj);
-
+
RETURN(0);
}
mdd_unlock(ctxt, tgt_pobj, DT_WRITE_LOCK);
}
-static int mdd_rename_sanity_check (const struct lu_context *ctxt,
- struct mdd_object *src_pobj,
- struct mdd_object *tgt_pobj,
- struct mdd_object *sobj,
- struct mdd_object *tobj)
+static int mdd_rename_sanity_check(const struct lu_context *ctxt,
+ struct mdd_object *src_pobj,
+ struct mdd_object *tgt_pobj,
+ struct mdd_object *sobj,
+ struct mdd_object *tobj)
{
struct mdd_device *mdd =mdo2mdd(&src_pobj->mod_obj);
int rc = 0, src_is_dir, tgt_is_dir;
GOTO(out, rc = -EINVAL);
GOTO(out, rc);
}
-
+
/* source should not be ancestor of target */
if (!mdd_is_parent(ctxt, mdd, tobj, sobj))
GOTO(out, rc = -EINVAL);
-
+
rc = mdd_may_delete(ctxt, tgt_pobj, tobj, src_is_dir);
if (rc)
GOTO(out, rc);
GOTO(cleanup, rc);
/*if sobj is dir, its parent object nlink should be dec too*/
- if (S_ISDIR(mdd_object_type(mdd_sobj)))
+ if (S_ISDIR(mdd_object_type(mdd_sobj)))
__mdd_ref_del(ctxt, mdd_spobj, handle);
if (tobj) {
* (1) the valid bits should be converted between Lustre and Linux;
* (2) maybe, the child attributes should be set in OSD when creation.
*/
-
- rc = mdd_attr_set_internal(ctxt, child, &ma->ma_attr, handle);
+
+ rc = mdd_attr_set_internal(ctxt, child, &ma->ma_attr, handle);
if (rc != 0)
RETURN(rc);
/*XXX: setting the lov ea is not locked but setting the attr is locked? */
if (rc == 0) {
- rc = mdd_lov_set_md(ctxt, mdd_pobj, son, lmm, lmm_size,
+ rc = mdd_lov_set_md(ctxt, mdd_pobj, son, lmm, lmm_size,
handle, 0);
if (rc == 0)
rc = mdd_attr_get_internal_locked(ctxt, son, ma);
RETURN(-ENOMEM);
mdd_lock(ctxt, mdd_obj, DT_WRITE_LOCK);
-
+
/* rmdir checks */
- if (S_ISDIR(lu_object_attr(&obj->mo_lu)) &&
+ if (S_ISDIR(lu_object_attr(&obj->mo_lu)) &&
dt_try_as_dir(ctxt, mdd_object_child(mdd_obj))) {
rc = mdd_dir_is_empty(ctxt, mdd_obj);
if (rc != 0)
/* unlink dot */
__mdd_ref_del(ctxt, mdd_obj, handle);
}
-
+
rc = __mdd_finish_unlink(ctxt, mdd_obj, ma);
-cleanup:
+cleanup:
mdd_unlock(ctxt, mdd_obj, DT_WRITE_LOCK);
mdd_trans_stop(ctxt, mdd, handle);
RETURN(rc);
if (atomic_dec_and_test(&md2mdd_obj(obj)->mod_count)) {
/*TODO: Remove it from orphan list */
}
-
+
return __mdd_finish_unlink(ctxt, md2mdd_obj(obj), ma);
}
*/
if (islnk || (!isreg && !isdir &&
(req->rq_export->exp_connect_flags & OBD_CONNECT_NODEVOH))) {
- info->mti_trans_flags |= MDT_NONEED_TANSNO;
+ info->mti_trans_flags |= MDT_NONEED_TANSNO;
RETURN(0);
}
/* This can't be done earlier, we need to return reply body */
} else if (flags & MDS_OPEN_DIRECTORY)
RETURN(-ENOTDIR);
- if ((isreg) && !(ma->ma_valid & MA_LOV)) {
+ if (isreg && !(ma->ma_valid & MA_LOV)) {
/*No EA, check whether it is will set regEA and dirEA
*since in above attr get, these size might be zero,
*so reset it, to retrieve the MD after create obj*/
if (rc)
RETURN(rc);
}
- CDEBUG(D_INODE, "after open, ma_valid bit = "LPX64" lmm_size = %d\n",
+ CDEBUG(D_INODE, "after open, ma_valid bit = "LPX64" lmm_size = %d\n",
ma->ma_valid, ma->ma_lmm_size);
repbody->eadatasize = 0;
repbody->aclsize = 0;
else
repbody->valid |= OBD_MD_FLEASIZE;
}
- /*FIXME: should determine the offset dynamicly,
+ /*FIXME: should determine the offset dynamicly,
*did not get ACL before shrink*/
lustre_shrink_reply(req, 2, repbody->eadatasize, 1);
lustre_shrink_reply(req, repbody->eadatasize ? 3 : 2, repbody->aclsize,
mdt_object_get(info->mti_ctxt, o);
/* open hanling */
mo_open(info->mti_ctxt, mdt_object_child(o));
-
+
mfd->mfd_mode = flags;
mfd->mfd_object = o;
mfd->mfd_xid = mdt_info_req(info)->rq_xid;
CDEBUG(D_INODE, "I am going to create "DFID"/("DFID":%s) "
"cr_flag=%x mode=%06o\n",
- PFID(rr->rr_fid1), PFID(rr->rr_fid2),
+ PFID(rr->rr_fid1), PFID(rr->rr_fid2),
rr->rr_name, create_flags, la->la_mode);
ldlm_rep = req_capsule_server_get(&info->mti_pill, &RMF_DLM_REP);
intent_set_disposition(ldlm_rep, DISP_LOOKUP_EXECD);
-
+
lh = &info->mti_lh[MDT_LH_PARENT];
if (!(create_flags & MDS_OPEN_CREAT))
lh->mlh_mode = LCK_CR;
intent_set_disposition(ldlm_rep, DISP_LOOKUP_NEG);
if (result == -ESTALE) {
/*ESTALE means the parent is a dead(unlinked) dir,
- *so it should return -ENOENT to in accordance
+ *so it should return -ENOENT to in accordance
*with the original mds implemantaion.*/
GOTO(out_parent, result = -ENOENT);
}
&info->mti_attr);
if (rc2 != 0)
CERROR("error in cleanup of open");
- }
+ }
out_child:
mdt_object_put(info->mti_ctxt, child);
out_parent:
} else if (mfd->mfd_mode & MDS_FMODE_EXEC) {
mdt_allow_write_access(o);
}
-
+
mdt_mfd_free(mfd);
mo_close(ctxt, mdt_object_child(o), ma);
class_handle_unhash(&mfd->mfd_handle);
list_del_init(&mfd->mfd_list);
spin_unlock(&med->med_open_lock);
-
+
ma->ma_lmm = req_capsule_server_get(&info->mti_pill,
&RMF_MDT_MD);
ma->ma_lmm_size = req_capsule_get_size(&info->mti_pill,
&RMF_MDT_MD,
RCL_SERVER);
-
+
ma->ma_cookie = req_capsule_server_get(&info->mti_pill,
&RMF_LOGCOOKIES);
ma->ma_cookie_size = req_capsule_get_size(&info->mti_pill,