From 6196d7cf76977a210f99581895593248fe87aa38 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Tue, 29 Jul 2014 10:02:27 -0500 Subject: [PATCH] LU-5409 mdd: use DT wrappers In lustre/mdd replace direct calls to members of dt_object_operations with calls to the equivalent static inline functions. Signed-off-by: John L. Hammond Change-Id: Iaf21970e582f30f903e07615c59c306f413d16dc Reviewed-on: http://review.whamcloud.com/11264 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- lustre/mdd/mdd_dir.c | 50 ++++++------- lustre/mdd/mdd_internal.h | 178 +++++++++++++++++++++------------------------- lustre/mdd/mdd_lock.c | 24 +++---- lustre/mdd/mdd_orphans.c | 55 +++++++------- 4 files changed, 138 insertions(+), 169 deletions(-) diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 81b7e01..55aec66 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -98,16 +98,10 @@ __mdd_lookup(const struct lu_env *env, struct md_object *pobj, RETURN(rc); if (likely(S_ISDIR(mdd_object_type(mdd_obj)) && - dt_try_as_dir(env, dir))) { - - rc = dir->do_index_ops->dio_lookup(env, dir, - (struct dt_rec *)fid, key, - mdd_object_capa(env, mdd_obj)); - if (rc > 0) - rc = 0; - else if (rc == 0) - rc = -ENOENT; - } else + dt_try_as_dir(env, dir))) + rc = dt_lookup(env, dir, (struct dt_rec *)fid, key, + mdd_object_capa(env, mdd_obj)); + else rc = -ENOTDIR; RETURN(rc); @@ -569,21 +563,19 @@ static int mdd_link_sanity_check(const struct lu_env *env, } static int __mdd_index_delete_only(const struct lu_env *env, struct mdd_object *pobj, - const char *name, struct thandle *handle, - struct lustre_capa *capa) + const char *name, struct thandle *handle, + struct lustre_capa *capa) { - struct dt_object *next = mdd_object_child(pobj); - int rc; - ENTRY; + struct dt_object *next = mdd_object_child(pobj); + int rc; + ENTRY; - if (dt_try_as_dir(env, next)) { - rc = next->do_index_ops->dio_delete(env, next, - (struct dt_key *)name, - handle, capa); - } else - rc = -ENOTDIR; + if (dt_try_as_dir(env, next)) + rc = dt_delete(env, next, (struct dt_key *)name, handle, capa); + else + rc = -ENOTDIR; - RETURN(rc); + RETURN(rc); } static int __mdd_index_insert_only(const struct lu_env *env, @@ -605,10 +597,9 @@ static int __mdd_index_insert_only(const struct lu_env *env, rec->rec_fid = lf; rec->rec_type = type; ignore_quota = uc ? uc->uc_cap & CFS_CAP_SYS_RESOURCE_MASK : 1; - rc = next->do_index_ops->dio_insert(env, next, - (const struct dt_rec *)rec, - (const struct dt_key *)name, - handle, capa, ignore_quota); + rc = dt_insert(env, next, (const struct dt_rec *)rec, + (const struct dt_key *)name, handle, capa, + ignore_quota); } else { rc = -ENOTDIR; } @@ -3546,10 +3537,9 @@ static int mdd_migrate_entries(const struct lu_env *env, if (dt_try_as_dir(env, dt_tobj)) { struct lu_fid *fid = &mdd_env_info(env)->mti_fid2; - rc = dt_tobj->do_index_ops->dio_lookup(env, dt_tobj, - (struct dt_rec *)fid, - (struct dt_key *)name, - mdd_object_capa(env, mdd_tobj)); + rc = dt_lookup(env, dt_tobj, (struct dt_rec *)fid, + (struct dt_key *)name, + mdd_object_capa(env, mdd_tobj)); if (unlikely(rc == 0)) target_exist = true; } diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 9183bba..153d083 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -515,10 +515,10 @@ static inline int mdd_permission_internal_locked(const struct lu_env *env, /* mdd inline func for calling osd_dt_object ops */ static inline int mdo_attr_get(const struct lu_env *env, struct mdd_object *obj, - struct lu_attr *la, struct lustre_capa *capa) + struct lu_attr *la, struct lustre_capa *capa) { - struct dt_object *next = mdd_object_child(obj); - return next->do_ops->do_attr_get(env, next, la, capa); + struct dt_object *next = mdd_object_child(obj); + return dt_attr_get(env, next, la, capa); } static inline int mdo_declare_attr_set(const struct lu_env *env, @@ -531,26 +531,25 @@ static inline int mdo_declare_attr_set(const struct lu_env *env, } static inline int mdo_attr_set(const struct lu_env *env, - struct mdd_object *obj, - const struct lu_attr *la, - struct thandle *handle, - struct lustre_capa *capa) + struct mdd_object *obj, + const struct lu_attr *la, + struct thandle *handle, + struct lustre_capa *capa) { - struct dt_object *next = mdd_object_child(obj); - if (mdd_object_exists(obj) == 0) { - CERROR("%s: object "DFID" not found: rc = -2\n", - mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj))); - return -ENOENT; - } - return next->do_ops->do_attr_set(env, next, la, handle, capa); + struct dt_object *next = mdd_object_child(obj); + + if (!mdd_object_exists(obj)) + return -ENOENT; + + return dt_attr_set(env, next, la, handle, capa); } static inline int mdo_xattr_get(const struct lu_env *env,struct mdd_object *obj, - struct lu_buf *buf, const char *name, - struct lustre_capa *capa) + struct lu_buf *buf, const char *name, + struct lustre_capa *capa) { - struct dt_object *next = mdd_object_child(obj); - return next->do_ops->do_xattr_get(env, next, buf, name, capa); + struct dt_object *next = mdd_object_child(obj); + return dt_xattr_get(env, next, buf, name, capa); } static inline int mdo_declare_xattr_set(const struct lu_env *env, @@ -564,18 +563,16 @@ static inline int mdo_declare_xattr_set(const struct lu_env *env, } static inline int mdo_xattr_set(const struct lu_env *env,struct mdd_object *obj, - const struct lu_buf *buf, const char *name, - int fl, struct thandle *handle, - struct lustre_capa *capa) + const struct lu_buf *buf, const char *name, + int fl, struct thandle *handle, + struct lustre_capa *capa) { - struct dt_object *next = mdd_object_child(obj); - if (mdd_object_exists(obj) == 0) { - CERROR("%s: object "DFID" not found: rc = -2\n", - mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj))); - return -ENOENT; - } - return next->do_ops->do_xattr_set(env, next, buf, name, fl, handle, - capa); + struct dt_object *next = mdd_object_child(obj); + + if (!mdd_object_exists(obj)) + return -ENOENT; + + return dt_xattr_set(env, next, buf, name, fl, handle, capa); } static inline int mdo_declare_xattr_del(const struct lu_env *env, @@ -588,29 +585,27 @@ static inline int mdo_declare_xattr_del(const struct lu_env *env, } static inline int mdo_xattr_del(const struct lu_env *env,struct mdd_object *obj, - const char *name, struct thandle *handle, - struct lustre_capa *capa) + const char *name, struct thandle *handle, + struct lustre_capa *capa) { - struct dt_object *next = mdd_object_child(obj); - if (mdd_object_exists(obj) == 0) { - CERROR("%s: object "DFID" not found: rc = -2\n", - mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj))); - return -ENOENT; - } - return next->do_ops->do_xattr_del(env, next, name, handle, capa); + struct dt_object *next = mdd_object_child(obj); + + if (!mdd_object_exists(obj)) + return -ENOENT; + + return dt_xattr_del(env, next, name, handle, capa); } -static inline -int mdo_xattr_list(const struct lu_env *env, struct mdd_object *obj, - struct lu_buf *buf, struct lustre_capa *capa) +static inline int +mdo_xattr_list(const struct lu_env *env, struct mdd_object *obj, + struct lu_buf *buf, struct lustre_capa *capa) { - struct dt_object *next = mdd_object_child(obj); - if (mdd_object_exists(obj) == 0) { - CERROR("%s: object "DFID" not found: rc = -2\n", - mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj))); - return -ENOENT; - } - return next->do_ops->do_xattr_list(env, next, buf, capa); + struct dt_object *next = mdd_object_child(obj); + + if (!mdd_object_exists(obj)) + return -ENOENT; + + return dt_xattr_list(env, next, buf, capa); } static inline @@ -672,15 +667,14 @@ static inline int mdo_declare_ref_add(const struct lu_env *env, } static inline int mdo_ref_add(const struct lu_env *env, struct mdd_object *obj, - struct thandle *handle) + struct thandle *handle) { - struct dt_object *next = mdd_object_child(obj); - if (mdd_object_exists(obj) == 0) { - CERROR("%s: object "DFID" not found: rc = -2\n", - mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj))); - return -ENOENT; - } - return next->do_ops->do_ref_add(env, next, handle); + struct dt_object *next = mdd_object_child(obj); + + if (!mdd_object_exists(obj)) + return -ENOENT; + + return dt_ref_add(env, next, handle); } static inline int mdo_declare_ref_del(const struct lu_env *env, @@ -692,42 +686,36 @@ static inline int mdo_declare_ref_del(const struct lu_env *env, } static inline int mdo_ref_del(const struct lu_env *env, struct mdd_object *obj, - struct thandle *handle) + struct thandle *handle) { - struct dt_object *next = mdd_object_child(obj); - if (mdd_object_exists(obj) == 0) { - CERROR("%s: object "DFID" not found: rc = -2\n", - mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj))); - return -ENOENT; - } - return next->do_ops->do_ref_del(env, next, handle); + struct dt_object *next = mdd_object_child(obj); + + if (!mdd_object_exists(obj)) + return -ENOENT; + + return dt_ref_del(env, next, handle); } -static inline -int mdo_declare_create_obj(const struct lu_env *env, struct mdd_object *o, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *handle) +static inline int +mdo_declare_create_obj(const struct lu_env *env, struct mdd_object *o, + struct lu_attr *attr, + struct dt_allocation_hint *hint, + struct dt_object_format *dof, + struct thandle *handle) { - struct dt_object *next = mdd_object_child(o); - return next->do_ops->do_declare_create(env, next, attr, hint, - dof, handle); + struct dt_object *next = mdd_object_child(o); + return dt_declare_create(env, next, attr, hint, dof, handle); } -static inline -int mdo_create_obj(const struct lu_env *env, struct mdd_object *o, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *handle) +static inline int +mdo_create_obj(const struct lu_env *env, struct mdd_object *o, + struct lu_attr *attr, + struct dt_allocation_hint *hint, + struct dt_object_format *dof, + struct thandle *handle) { - struct dt_object *next = mdd_object_child(o); - int rc; - - rc = next->do_ops->do_create(env, next, attr, hint, dof, handle); - - return rc; + struct dt_object *next = mdd_object_child(o); + return dt_create(env, next, attr, hint, dof, handle); } static inline @@ -746,18 +734,16 @@ int mdo_destroy(const struct lu_env *env, struct mdd_object *o, return dt_destroy(env, next, handle); } -static inline struct obd_capa *mdo_capa_get(const struct lu_env *env, - struct mdd_object *obj, - struct lustre_capa *old, - __u64 opc) +static inline struct obd_capa * +mdo_capa_get(const struct lu_env *env, struct mdd_object *obj, + struct lustre_capa *old, __u64 opc) { - struct dt_object *next = mdd_object_child(obj); - if (mdd_object_exists(obj) == 0) { - CERROR("%s: object "DFID" not found: rc = -2\n", - mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj))); - return ERR_PTR(-ENOENT); - } - return next->do_ops->do_capa_get(env, next, old, opc); + struct dt_object *next = mdd_object_child(obj); + + if (!mdd_object_exists(obj)) + return ERR_PTR(-ENOENT); + + return dt_capa_get(env, next, old, opc); } #endif diff --git a/lustre/mdd/mdd_lock.c b/lustre/mdd/mdd_lock.c index 60bf87d..2220ff8 100644 --- a/lustre/mdd/mdd_lock.c +++ b/lustre/mdd/mdd_lock.c @@ -47,38 +47,38 @@ #include "mdd_internal.h" void mdd_write_lock(const struct lu_env *env, struct mdd_object *obj, - enum mdd_object_role role) + enum mdd_object_role role) { - struct dt_object *next = mdd_object_child(obj); + struct dt_object *next = mdd_object_child(obj); - next->do_ops->do_write_lock(env, next, role); + dt_write_lock(env, next, role); } void mdd_read_lock(const struct lu_env *env, struct mdd_object *obj, - enum mdd_object_role role) + enum mdd_object_role role) { - struct dt_object *next = mdd_object_child(obj); + struct dt_object *next = mdd_object_child(obj); - next->do_ops->do_read_lock(env, next, role); + dt_read_lock(env, next, role); } void mdd_write_unlock(const struct lu_env *env, struct mdd_object *obj) { - struct dt_object *next = mdd_object_child(obj); + struct dt_object *next = mdd_object_child(obj); - next->do_ops->do_write_unlock(env, next); + dt_write_unlock(env, next); } void mdd_read_unlock(const struct lu_env *env, struct mdd_object *obj) { - struct dt_object *next = mdd_object_child(obj); + struct dt_object *next = mdd_object_child(obj); - next->do_ops->do_read_unlock(env, next); + dt_read_unlock(env, next); } int mdd_write_locked(const struct lu_env *env, struct mdd_object *obj) { - struct dt_object *next = mdd_object_child(obj); + struct dt_object *next = mdd_object_child(obj); - return next->do_ops->do_write_locked(env, next); + return dt_write_locked(env, next); } diff --git a/lustre/mdd/mdd_orphans.c b/lustre/mdd/mdd_orphans.c index 442452c..ee398cf 100644 --- a/lustre/mdd/mdd_orphans.c +++ b/lustre/mdd/mdd_orphans.c @@ -93,19 +93,17 @@ static struct dt_key* orph_key_fill_18(const struct lu_env *env, } static inline void mdd_orphan_write_lock(const struct lu_env *env, - struct mdd_device *mdd) + struct mdd_device *mdd) { - - struct dt_object *dor = mdd->mdd_orphans; - dor->do_ops->do_write_lock(env, dor, MOR_TGT_ORPHAN); + struct dt_object *dor = mdd->mdd_orphans; + dt_write_lock(env, dor, MOR_TGT_ORPHAN); } static inline void mdd_orphan_write_unlock(const struct lu_env *env, - struct mdd_device *mdd) + struct mdd_device *mdd) { - - struct dt_object *dor = mdd->mdd_orphans; - dor->do_ops->do_write_unlock(env, dor); + struct dt_object *dor = mdd->mdd_orphans; + dt_write_unlock(env, dor); } static inline int mdd_orphan_insert_obj(const struct lu_env *env, @@ -121,9 +119,8 @@ static inline int mdd_orphan_insert_obj(const struct lu_env *env, rec->rec_fid = lf; rec->rec_type = mdd_object_type(obj); - return dor->do_index_ops->dio_insert(env, dor, - (const struct dt_rec *)rec, - key, th, BYPASS_CAPA, 1); + return dt_insert(env, dor, (const struct dt_rec *)rec, key, th, + BYPASS_CAPA, 1); } static inline int mdd_orphan_delete_obj(const struct lu_env *env, @@ -131,27 +128,25 @@ static inline int mdd_orphan_delete_obj(const struct lu_env *env, struct dt_key *key, struct thandle *th) { - struct dt_object *dor = mdd->mdd_orphans; + struct dt_object *dor = mdd->mdd_orphans; - return dor->do_index_ops->dio_delete(env, dor, - key, th, - BYPASS_CAPA); + return dt_delete(env, dor, key, th, BYPASS_CAPA); } -static inline void mdd_orphan_ref_add(const struct lu_env *env, - struct mdd_device *mdd, - struct thandle *th) +static inline int mdd_orphan_ref_add(const struct lu_env *env, + struct mdd_device *mdd, + struct thandle *th) { - struct dt_object *dor = mdd->mdd_orphans; - dor->do_ops->do_ref_add(env, dor, th); + struct dt_object *dor = mdd->mdd_orphans; + return dt_ref_add(env, dor, th); } -static inline void mdd_orphan_ref_del(const struct lu_env *env, - struct mdd_device *mdd, - struct thandle *th) +static inline int mdd_orphan_ref_del(const struct lu_env *env, + struct mdd_device *mdd, + struct thandle *th) { - struct dt_object *dor = mdd->mdd_orphans; - dor->do_ops->do_ref_del(env, dor, th); + struct dt_object *dor = mdd->mdd_orphans; + return dt_ref_del(env, dor, th); } @@ -231,15 +226,13 @@ static int orph_index_insert(const struct lu_env *env, * from here */ if (!dt_try_as_dir(env, next)) GOTO(out, rc = 0); - next->do_index_ops->dio_delete(env, next, - (const struct dt_key *)dotdot, - th, BYPASS_CAPA); + + dt_delete(env, next, (const struct dt_key *)dotdot, th, BYPASS_CAPA); rec->rec_fid = lf_dor; rec->rec_type = S_IFDIR; - next->do_index_ops->dio_insert(env, next, (const struct dt_rec *)rec, - (const struct dt_key *)dotdot, - th, BYPASS_CAPA, 1); + dt_insert(env, next, (const struct dt_rec *)rec, + (const struct dt_key *)dotdot, th, BYPASS_CAPA, 1); out: if (rc == 0) -- 1.8.3.1