From: nikita Date: Tue, 18 Jul 2006 11:58:08 +0000 (+0000) Subject: rename dt_is_dir() to dt_try_as_dir() to reflect the fact that this function performs... X-Git-Tag: v1_8_0_110~486^2~1393 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=c8b349dc3e7bed6b0fa87e9190ae2bf9e229557d;p=fs%2Flustre-release.git rename dt_is_dir() to dt_try_as_dir() to reflect the fact that this function performs some initialization --- diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index d50f3b2..e6d4a7b 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -337,7 +337,7 @@ int dt_txn_hook_stop(const struct lu_context *ctx, int dt_txn_hook_commit(const struct lu_context *ctx, struct dt_device *dev, struct thandle *txn); -int dt_is_dir(const struct lu_context *ctx, struct dt_object *obj); +int dt_try_as_dir(const struct lu_context *ctx, struct dt_object *obj); struct dt_object *dt_store_open(const struct lu_context *ctx, struct dt_device *dt, const char *name, struct lu_fid *fid); diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index f59ee72..a97f943 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -262,7 +262,7 @@ static int mdd_device_init(const struct lu_context *ctx, struct mdd_device *mdd = lu2mdd_dev(d); int rc; ENTRY; - + mdd->mdd_child = lu2dt_dev(next); rc = mdd_fs_setup(ctx, mdd); @@ -384,7 +384,7 @@ static int __mdd_object_create(const struct lu_context *ctxt, 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); @@ -482,7 +482,7 @@ static int __mdd_index_insert(const struct lu_context *ctxt, 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); @@ -492,14 +492,14 @@ static int __mdd_index_insert(const struct lu_context *ctxt, } 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 @@ -544,7 +544,7 @@ static int mdd_unlink(const struct lu_context *ctxt, struct md_object *pobj, 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; @@ -563,7 +563,7 @@ static int mdd_unlink(const struct lu_context *ctxt, struct md_object *pobj, 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); @@ -574,15 +574,15 @@ cleanup: 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; } @@ -592,18 +592,18 @@ static int mdd_is_parent(const struct lu_context *ctxt, 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); } @@ -622,7 +622,7 @@ static int mdd_rename_lock(const struct lu_context *ctxt, 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); } @@ -669,10 +669,10 @@ static int mdd_rename(const struct lu_context *ctxt, struct md_object *src_pobj, /*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); @@ -698,7 +698,7 @@ static int mdd_rename(const struct lu_context *ctxt, struct md_object *src_pobj, 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); @@ -721,7 +721,7 @@ static int mdd_lookup(const struct lu_context *ctxt, struct md_object *pobj, 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; @@ -731,14 +731,14 @@ static int mdd_lookup(const struct lu_context *ctxt, struct md_object *pobj, /* * 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; @@ -752,7 +752,7 @@ static int mdd_create(const struct lu_context *ctxt, struct md_object *pobj, if (rc) RETURN(rc); } - + mdd_txn_param_build(ctxt, &MDD_TXN_MKDIR); handle = mdd_trans_start(ctxt, mdd); if (IS_ERR(handle)) @@ -803,12 +803,12 @@ static int mdd_create(const struct lu_context *ctxt, struct md_object *pobj, 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); @@ -823,11 +823,11 @@ cleanup: 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); } @@ -860,7 +860,7 @@ static int mdd_mkname(const struct lu_context *ctxt, struct md_object *pobj, 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) { @@ -877,8 +877,8 @@ static int mdd_name_remove(const struct lu_context *ctxt, 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); diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index 85516aa..86de339 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -50,7 +50,7 @@ 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; @@ -98,7 +98,7 @@ out: 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; @@ -137,12 +137,12 @@ int mdd_lov_fini(const struct lu_context *ctxt, struct mdd_device *mdd) 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; } @@ -191,8 +191,8 @@ out: 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); @@ -206,10 +206,10 @@ int mdd_notify(const struct lu_context *ctxt, struct md_device *md, rc = 0; RETURN(rc); } - + rc = md_lov_start_synchronize(obd, &mdd->mdd_lov_info, watched, data, !(ev == OBD_NOTIFY_SYNC), ctxt); - + RETURN(rc); } @@ -245,12 +245,12 @@ int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj, 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", @@ -258,7 +258,7 @@ int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj, } } 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", @@ -268,7 +268,7 @@ int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj, } 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; diff --git a/lustre/obdclass/dt_object.c b/lustre/obdclass/dt_object.c index 30201d3..de7f070 100644 --- a/lustre/obdclass/dt_object.c +++ b/lustre/obdclass/dt_object.c @@ -129,14 +129,14 @@ void dt_object_fini(struct dt_object *obj) } EXPORT_SYMBOL(dt_object_fini); -int dt_is_dir(const struct lu_context *ctx, struct dt_object *obj) +int dt_try_as_dir(const struct lu_context *ctx, struct dt_object *obj) { if (obj->do_index_ops == NULL) obj->do_ops->do_object_index_try(ctx, obj, &dt_directory_features); return obj->do_index_ops != NULL; } -EXPORT_SYMBOL(dt_is_dir); +EXPORT_SYMBOL(dt_try_as_dir); static int dt_lookup(const struct lu_context *ctx, struct dt_object *dir, const char *name, struct lu_fid *fid) @@ -145,7 +145,7 @@ static int dt_lookup(const struct lu_context *ctx, struct dt_object *dir, const struct dt_key *key = (const struct dt_key *)name; int result; - if (dt_is_dir(ctx, dir)) + if (dt_try_as_dir(ctx, dir)) result = dir->do_index_ops->dio_lookup(ctx, dir, rec, key); else result = -ENOTDIR;