struct mdd_device *mdd = lu2mdd_dev(d);
int rc;
ENTRY;
-
+
mdd->mdd_child = lu2dt_dev(next);
rc = mdd_fs_setup(ctx, mdd);
LASSERT(ergo(rc == 0, lu_object_exists(ctxt, &obj->mod_obj.mo_lu)));
/* increase the nlink for directory */
- if (rc == 0 && dt_is_dir(ctxt, mdd_object_child(obj)))
+ if (rc == 0 && dt_try_as_dir(ctxt, mdd_object_child(obj)))
rc = __mdd_ref_add(ctxt, obj, handle);
/*XXX increase the refcount of the object or not?*/
RETURN(rc);
struct dt_object *next = mdd_object_child(pobj);
ENTRY;
- if (dt_is_dir(ctxt, next))
+ if (dt_try_as_dir(ctxt, next))
rc = next->do_index_ops->dio_insert(ctxt, next,
(struct dt_rec *)lf,
(struct dt_key *)name, handle);
}
static int __mdd_index_delete(const struct lu_context *ctxt,
- struct mdd_object *pobj, const char *name,
+ struct mdd_object *pobj, const char *name,
struct thandle *handle)
{
int rc;
struct dt_object *next = mdd_object_child(pobj);
ENTRY;
- if (dt_is_dir(ctxt, next))
+ if (dt_try_as_dir(ctxt, next))
rc = next->do_index_ops->dio_delete(ctxt, next,
(struct dt_key *)name, handle);
else
struct mdd_device *mdd = mdo2mdd(pobj);
struct mdd_object *mdd_pobj = md2mdd_obj(pobj);
struct mdd_object *mdd_cobj = md2mdd_obj(cobj);
- struct dt_object *dt_cobj = mdd_object_child(mdd_cobj);
+ struct dt_object *dt_cobj = mdd_object_child(mdd_cobj);
struct thandle *handle;
int rc;
ENTRY;
rc = __mdd_ref_del(ctxt, mdd_cobj, handle);
if (rc)
GOTO(cleanup, rc);
- if (dt_is_dir(ctxt, dt_cobj)) {
+ if (dt_try_as_dir(ctxt, dt_cobj)) {
rc = __mdd_ref_del(ctxt, mdd_pobj, handle);
if (rc)
GOTO(cleanup, rc);
RETURN(rc);
}
-static int mdd_parent_fid(const struct lu_context *ctxt,
- struct mdd_object *obj,
+static int mdd_parent_fid(const struct lu_context *ctxt,
+ struct mdd_object *obj,
struct lu_fid *fid)
{
const char *name = "..";
int rc;
-
+
rc = mdd_lookup(ctxt, &obj->mod_obj, name, fid);
-
+
return rc;
}
struct mdd_object *p1,
struct mdd_object *p2)
{
- struct lu_fid pfid;
+ struct lu_fid pfid;
int rc;
do {
rc = mdd_parent_fid(ctxt, p1, &pfid);
- if (rc)
+ if (rc)
RETURN(rc);
if (lu_fid_eq(&pfid, mdo2fid(p2))) {
RETURN(1);
}
} while (!lu_fid_eq(&pfid, &mdd->mdd_root_fid));
-
+
RETURN(rc);
}
if (lu_fid_eq(&mdd->mdd_root_fid, mdo2fid(src_pobj))){
mdd_lock2(ctxt, src_pobj, tgt_pobj);
RETURN(0);
- } else if (lu_fid_eq(&mdd->mdd_root_fid, mdo2fid(tgt_pobj))) {
+ } else if (lu_fid_eq(&mdd->mdd_root_fid, mdo2fid(tgt_pobj))) {
mdd_lock2(ctxt, tgt_pobj, src_pobj);
RETURN(0);
}
/*FIXME: Should consider tobj and sobj too in rename_lock*/
rc = mdd_rename_lock(ctxt, mdd, mdd_spobj, mdd_tpobj);
- if (rc)
+ if (rc)
GOTO(cleanup, rc);
locked = 1;
- if (tobj)
+ if (tobj)
mdd_tobj = md2mdd_obj(tobj);
rc = __mdd_index_delete(ctxt, mdd_spobj, sname, handle);
rc = __mdd_ref_del(ctxt, mdd_tobj, handle);
if (rc)
GOTO(cleanup, rc);
- if (dt_is_dir(ctxt, dt_tobj)) {
+ if (dt_try_as_dir(ctxt, dt_tobj)) {
rc = __mdd_ref_add(ctxt, mdd_tpobj, handle);
if (rc)
GOTO(cleanup, rc);
int rc;
ENTRY;
- if (dt_is_dir(ctxt, dir))
+ if (dt_try_as_dir(ctxt, dir))
rc = dir->do_index_ops->dio_lookup(ctxt, dir, rec, key);
else
rc = -ENOTDIR;
/*
* Create object and insert it into namespace.
*/
-static int mdd_create(const struct lu_context *ctxt, struct md_object *pobj,
- const char *name, struct md_object *child,
+static int mdd_create(const struct lu_context *ctxt, struct md_object *pobj,
+ const char *name, struct md_object *child,
const char *target_name, struct lu_attr* attr)
{
struct mdd_device *mdd = mdo2mdd(pobj);
struct mdd_object *mdo = md2mdd_obj(pobj);
struct mdd_object *son = md2mdd_obj(child);
- struct dt_object *dt_son = mdd_object_child(son);
+ struct dt_object *dt_son = mdd_object_child(son);
struct lov_mds_md *lmm = NULL;
struct thandle *handle;
int rc, created = 0, inserted = 0, ref_add = 0, lmm_size;
if (rc)
RETURN(rc);
}
-
+
mdd_txn_param_build(ctxt, &MDD_TXN_MKDIR);
handle = mdd_trans_start(ctxt, mdd);
if (IS_ERR(handle))
GOTO(cleanup, rc);
created = 1;
-
+
rc = __mdd_index_insert(ctxt, mdo, lu_object_fid(&child->mo_lu),
name, handle);
-
+
inserted = 1;
- if (dt_is_dir(ctxt, dt_son)) {
+ if (dt_try_as_dir(ctxt, dt_son)) {
rc = __mdd_ref_add(ctxt, mdo, handle);
if (rc)
GOTO(cleanup, rc);
int rc1 = 0, rc2 = 0, rc3 = 0;
rc1 = __mdd_ref_del(ctxt, son, handle);
- if (inserted)
+ if (inserted)
rc2 = __mdd_index_delete(ctxt, mdo, name, handle);
if (ref_add)
rc3 = __mdd_ref_del(ctxt, mdo, handle);
- if (rc1 || rc2 || rc3)
+ if (rc1 || rc2 || rc3)
CERROR("error can not cleanup destory %d insert %d \n",
rc1, rc2);
}
RETURN(rc);
}
-static int mdd_name_remove(const struct lu_context *ctxt,
+static int mdd_name_remove(const struct lu_context *ctxt,
struct md_object *pobj,
const char *name)
{
mdd_lock(ctxt, mdo, DT_WRITE_LOCK);
- rc = __mdd_index_delete(ctxt, mdo, name, handle);
-
+ rc = __mdd_index_delete(ctxt, mdo, name, handle);
+
mdd_unlock(ctxt, mdo, DT_WRITE_LOCK);
mdd_trans_stop(ctxt, mdd, handle);
static const char mdd_lov_objid_name[] = "lov_objid";
-static int mdd_lov_read_objids(struct obd_device *obd, struct md_lov_info *mli,
+static int mdd_lov_read_objids(struct obd_device *obd, struct md_lov_info *mli,
const void *ctxt)
{
struct dt_object *obj_ids = mli->md_lov_objid_obj;
RETURN(0);
}
-int mdd_lov_write_objids(struct obd_device *obd, struct md_lov_info *mli,
+int mdd_lov_write_objids(struct obd_device *obd, struct md_lov_info *mli,
const void *ctxt)
{
int i, rc = 0, tgts;
struct md_lov_info *mli = &mdd->mdd_lov_info;
obd_register_observer(mli->md_lov_obd, NULL);
-
+
if (mli->md_lov_exp) {
obd_disconnect(mli->md_lov_exp);
mli->md_lov_exp = NULL;
}
-
+
dt_object_fini(mli->md_lov_objid_obj);
return 0;
}
RETURN(rc);
}
-int mdd_notify(const struct lu_context *ctxt, struct md_device *md,
- struct obd_device *watched,
+int mdd_notify(const struct lu_context *ctxt, struct md_device *md,
+ struct obd_device *watched,
enum obd_notify_event ev, void *data)
{
struct mdd_device *mdd = lu2mdd_dev(&md->md_lu_dev);
rc = 0;
RETURN(rc);
}
-
+
rc = md_lov_start_synchronize(obd, &mdd->mdd_lov_info, watched, data,
!(ev == OBD_NOTIFY_SYNC), ctxt);
-
+
RETURN(rc);
}
int rc = 0;
ENTRY;
- if (dt_is_dir(ctxt, next)) {
+ if (dt_try_as_dir(ctxt, next)) {
struct lov_mds_md *lmm = &mdd_ctx_info(ctxt)->mti_lmm;
int size = sizeof(lmm);
rc = mdd_get_md(ctxt, pobj, &lmm, &size, 1);
if (rc > 0) {
- rc = mdd_xattr_set(ctxt, child, lmm, size,
+ rc = mdd_xattr_set(ctxt, child, lmm, size,
MDS_LOV_MD_NAME);
if (rc)
CERROR("error on copy stripe info: rc = %d\n",
}
} else if (lmmp) {
LASSERT(lmm_size > 0);
- rc = mdd_xattr_set(ctxt, child, lmmp, lmm_size,
+ rc = mdd_xattr_set(ctxt, child, lmmp, lmm_size,
MDS_LOV_MD_NAME);
if (rc)
CERROR("error on copy stripe info: rc = %d\n",
}
int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd,
- struct mdd_object *child, struct lov_mds_md **lmm,
+ struct mdd_object *child, struct lov_mds_md **lmm,
int *lmm_size)
{
struct md_lov_info *mli = &mdd->mdd_lov_info;