Whamcloud - gitweb
LU-5409 mdd: use DT wrappers 64/11264/4
authorJohn L. Hammond <john.hammond@intel.com>
Tue, 29 Jul 2014 15:02:27 +0000 (10:02 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 12 Aug 2014 16:08:16 +0000 (16:08 +0000)
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 <john.hammond@intel.com>
Change-Id: Iaf21970e582f30f903e07615c59c306f413d16dc
Reviewed-on: http://review.whamcloud.com/11264
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdd/mdd_dir.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lock.c
lustre/mdd/mdd_orphans.c

index 81b7e01..55aec66 100644 (file)
@@ -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)) &&
                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);
                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,
 }
 
 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,
 }
 
 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;
                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;
        }
        } 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;
 
                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;
                }
                        if (unlikely(rc == 0))
                                target_exist = true;
                }
index 9183bba..153d083 100644 (file)
@@ -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,
 
 /* 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,
 }
 
 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,
 }
 
 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,
 }
 
 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,
 }
 
 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,
 }
 
 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,
 }
 
 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,
 }
 
 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
 }
 
 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,
 }
 
 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,
 }
 
 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,
 }
 
 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
 }
 
 static inline
@@ -746,18 +734,16 @@ int mdo_destroy(const struct lu_env *env, struct mdd_object *o,
         return dt_destroy(env, next, handle);
 }
 
         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
 }
 
 #endif
index 60bf87d..2220ff8 100644 (file)
 #include "mdd_internal.h"
 
 void mdd_write_lock(const struct lu_env *env, struct mdd_object *obj,
 #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,
 }
 
 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)
 {
 }
 
 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)
 {
 }
 
 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)
 {
 }
 
 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);
 }
 }
index 442452c..ee398cf 100644 (file)
@@ -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,
 }
 
 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,
 }
 
 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,
 }
 
 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);
 
        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,
 }
 
 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_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);
          * 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;
 
        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)
 
 out:
         if (rc == 0)