static void __mdd_ref_add(const struct lu_context *ctxt, struct mdd_object *obj,
struct thandle *handle);
static void __mdd_ref_del(const struct lu_context *ctxt, struct mdd_object *obj,
- struct thandle *handle, struct md_attr *);
+ struct thandle *handle);
static int mdd_lookup(const struct lu_context *ctxt, struct md_object *pobj,
const char *name, struct lu_fid* fid);
static struct md_object_operations mdd_obj_ops;
LASSERT((ma->ma_attr.la_mode & S_IFMT) ==
(obj->mo_lu.lo_header->loh_attr & S_IFMT));
ma->ma_valid |= MA_INODE;
+ /* get LOV EA also */
if ((S_ISREG(ma->ma_attr.la_mode)
|| S_ISDIR(ma->ma_attr.la_mode))
&& ma->ma_lmm != 0 && ma->ma_lmm_size > 0) {
rc = 0;
}
}
- /*TODO: get DIREA for directory */
}
CDEBUG(D_INODE, "after getattr rc = %d, ma_valid = "LPX64"\n",
rc, ma->ma_valid);
RETURN(rc);
}
-static int mdd_object_create(const struct lu_context *ctxt,
- struct md_object *obj, struct md_attr *attr)
-{
-
- struct mdd_device *mdd = mdo2mdd(obj);
- struct thandle *handle;
- int rc;
- ENTRY;
-
- mdd_txn_param_build(ctxt, &MDD_TXN_OBJECT_CREATE);
- handle = mdd_trans_start(ctxt, mdd);
- if (IS_ERR(handle))
- RETURN(PTR_ERR(handle));
-
- rc = __mdd_object_create(ctxt, md2mdd_obj(obj), attr, handle);
-
- mdd_trans_stop(ctxt, mdd, handle);
-
- RETURN(rc);
-}
-
static int __mdd_attr_set(const struct lu_context *ctxt, struct md_object *obj,
const struct lu_attr *attr, struct thandle *handle)
{
int rc;
ENTRY;
- if (S_ISDIR(cobj->mo_lu.lo_header->loh_attr)) {
+ if (S_ISDIR(lu_object_attr(&cobj->mo_lu))) {
if (!S_ISDIR(ma->ma_attr.la_mode))
RETURN(-EISDIR);
} else if (S_ISDIR(ma->ma_attr.la_mode))
mdd_lock2(ctxt, mdd_pobj, mdd_cobj);
/* rmdir checks */
- if (S_ISDIR(cobj->mo_lu.lo_header->loh_attr)) {
+ if (S_ISDIR(lu_object_attr(&cobj->mo_lu))) {
rc = mdd_dir_is_empty(ctxt, mdd_cobj);
if (rc != 0)
GOTO(cleanup, rc);
if (rc)
GOTO(cleanup, rc);
- __mdd_ref_del(ctxt, mdd_cobj, handle, ma);
- mdd_attr_get(ctxt, cobj, ma);
-
+ __mdd_ref_del(ctxt, mdd_cobj, handle);
if (S_ISDIR(ma->ma_attr.la_mode)) {
/* unlink dot */
- __mdd_ref_del(ctxt, mdd_cobj, handle, ma);
+ __mdd_ref_del(ctxt, mdd_cobj, handle);
/* unlink dotdot */
- __mdd_ref_del(ctxt, mdd_pobj, handle, NULL);
+ __mdd_ref_del(ctxt, mdd_pobj, handle);
}
+ mdd_attr_get(ctxt, cobj, ma);
+
#if 0
/*This should be moved to handle last unlink. wait open
* orphan prototype finished*/
if (tobj && lu_object_exists(ctxt, &tobj->mo_lu)) {
- __mdd_ref_del(ctxt, mdd_tobj, handle, NULL);
+ __mdd_ref_del(ctxt, mdd_tobj, handle);
if (S_ISDIR(mdd_object_type(mdd_tobj)))
- __mdd_ref_del(ctxt, mdd_tpobj, handle, NULL);
+ __mdd_ref_del(ctxt, mdd_tpobj, handle);
+ /* XXX: mdd_attr_get(ctxt, tobj, ma); needed here */
}
+
cleanup:
/*FIXME: should we do error handling here?*/
if (locked)
CERROR("Failure to cleanup after dotdot"
" creation: %d (%d)\n", rc2, rc);
else
- __mdd_ref_del(ctxt, child, handle, 0);
+ __mdd_ref_del(ctxt, child, handle);
}
}
}
else
rc = -EFAULT;
}
- rc = mdd_attr_get(ctxt, child, ma);
+ mdd_attr_get(ctxt, child, ma);
cleanup:
if (rc && created) {
int rc2 = 0;
rc2);
}
if (rc2 == 0)
- __mdd_ref_del(ctxt, son, handle, NULL);
+ __mdd_ref_del(ctxt, son, handle);
}
if (lmm)
OBD_FREE(lmm, lmm_size);
mdd_trans_stop(ctxt, mdd, handle);
RETURN(rc);
}
+/* partial operation */
+static int mdd_object_create(const struct lu_context *ctxt,
+ struct md_object *obj, struct md_attr *ma)
+{
+
+ struct mdd_device *mdd = mdo2mdd(obj);
+ struct thandle *handle;
+ int rc;
+ ENTRY;
+
+ mdd_txn_param_build(ctxt, &MDD_TXN_OBJECT_CREATE);
+ handle = mdd_trans_start(ctxt, mdd);
+ if (IS_ERR(handle))
+ RETURN(PTR_ERR(handle));
+
+ rc = __mdd_object_create(ctxt, md2mdd_obj(obj), ma, handle);
+/* XXX: parent fid is needed here
+ rc = __mdd_object_initialize(ctxt, mdo, son, ma, handle);
+*/
+ mdd_attr_get(ctxt, md2mdd_obj(obj), ma);
-static int mdd_mkname(const struct lu_context *ctxt, struct md_object *pobj,
- const char *name, const struct lu_fid *fid)
+ mdd_trans_stop(ctxt, mdd, handle);
+
+ RETURN(rc);
+}
+/* partial operation */
+static int mdd_name_insert(const struct lu_context *ctxt,
+ struct md_object *pobj,
+ const char *name, const struct lu_fid *fid)
{
struct mdd_device *mdd = mdo2mdd(pobj);
struct mdd_object *mdo = md2mdd_obj(pobj);
GOTO(cleanup, rc);
if (tobj && lu_object_exists(ctxt, &tobj->mo_lu))
- __mdd_ref_del(ctxt, mdd_tobj, handle, NULL);
+ __mdd_ref_del(ctxt, mdd_tobj, handle);
cleanup:
/*FIXME: should we do error handling here?*/
mdd_unlock2(ctxt, mdd_tpobj, mdd_tobj);
static void
__mdd_ref_del(const struct lu_context *ctxt, struct mdd_object *obj,
- struct thandle *handle, struct md_attr *ma)
+ struct thandle *handle)
{
struct dt_object *next = mdd_object_child(obj);
RETURN(-ENOMEM);
mdd_lock(ctxt, mdd_obj, DT_WRITE_LOCK);
- __mdd_ref_del(ctxt, mdd_obj, handle, ma);
+ __mdd_ref_del(ctxt, mdd_obj, handle);
mdd_attr_get(ctxt, obj, ma);
mdd_unlock(ctxt, mdd_obj, DT_WRITE_LOCK);
.mdo_rename = mdd_rename,
.mdo_link = mdd_link,
.mdo_unlink = mdd_unlink,
- .mdo_name_insert = mdd_mkname,
+ .mdo_name_insert = mdd_name_insert,
.mdo_name_remove = mdd_name_remove,
.mdo_rename_tgt = mdd_rename_tgt,
.mdo_create_data = mdd_create_data