Whamcloud - gitweb
split struct dt_device_operations.
authornikita <nikita>
Wed, 12 Apr 2006 14:20:12 +0000 (14:20 +0000)
committernikita <nikita>
Wed, 12 Apr 2006 14:20:12 +0000 (14:20 +0000)
fix layering in cmm.

lustre/cmm/cmm_object.c
lustre/include/linux/lu_object.h
lustre/include/linux/md_object.h
lustre/mdd/mdd_handler.c
lustre/mdt/mdt_handler.c

index e6d0496..83f5cee 100644 (file)
@@ -153,9 +153,9 @@ int cmm_mkdir(struct md_object *md_parent, const char *name,
                      struct md_object *md_child)
 {
        struct cmm_object *cmm_parent = md2cmm_obj(md_parent);
+        struct md_object  *next       = cmm2child_obj(cmm_parent);
 
-        return md_parent->mo_ops->moo_mkdir(cmm2child_obj(cmm_parent),
-                                            name, md_child);
+        return next->mo_ops->moo_mkdir(next, name, md_child);
 }
 
 static struct md_object_operations cmm_mo_ops = {
@@ -176,6 +176,6 @@ int cmm_attr_get(struct md_object *obj, void *buf, int size,
         struct md_object *next = cmm2child_obj(md2cmm_obj(obj));
 
         LASSERT((void *)obj->mo_ops > (void *)0x100);
-        return obj->mo_ops->moo_attr_get(next, buf, size, name, ctxt);
+        return next->mo_ops->moo_attr_get(next, buf, size, name, ctxt);
 }
 
index 36b50d1..cbd31cf 100644 (file)
@@ -446,47 +446,46 @@ struct lu_object *lu_object_locate(struct lu_object_header *h,
  * DT device interface. XXX Probably should go elsewhere.
  */
 
-struct dt_object {
-        struct lu_object do_lu;
-};
+struct context;
+struct thandle;
+struct txn_param;
+struct dt_device;
+struct dt_object;
 
 enum dt_lock_mode {
         DT_WRITE_LOCK = 1,
         DT_READ_LOCK  = 2,
 };
 
-struct context;
-struct thandle;
-struct txn_param;
-struct dt_device;
-
 struct dt_device_operations {
         /* method for getting/setting device wide back stored config data, like
          * last used meta-sequence, etc. */
         int (*dt_config) (struct dt_device *dev, const char *name,
                           void *buf, int size, int mode);
-
         int   (*dt_statfs)(struct dt_device *dev, struct kstatfs *sfs);
-        void  (*dt_object_lock)(struct dt_object *dt, enum dt_lock_mode mode);
-        void  (*dt_object_unlock)(struct dt_object *dt, enum dt_lock_mode mode);
         struct thandle *(*dt_trans_start)(struct dt_device *dev,
                                           struct txn_param *param);
         void  (*dt_trans_stop)(struct thandle *th);
-        int   (*dt_object_create)(struct dt_object *dt, struct dt_object *child,
+        int   (*dt_root_get)(struct dt_device *dev, struct lu_fid *f);
+};
+
+struct dt_object_operations {
+        void  (*do_object_lock)(struct dt_object *dt, enum dt_lock_mode mode);
+        void  (*do_object_unlock)(struct dt_object *dt, enum dt_lock_mode mode);
+        int   (*do_object_create)(struct dt_object *dt, struct dt_object *child,
                                   struct context *context, struct thandle *th);
-        int   (*dt_object_destroy)(struct dt_object *dt, struct thandle *th);
-        int   (*dt_attr_get)(struct dt_object *dt, void *buf, int buf_len,
+        int   (*do_object_destroy)(struct dt_object *dt, struct thandle *th);
+        int   (*do_attr_get)(struct dt_object *dt, void *buf, int buf_len,
                              const char *name, struct context *context);
-        int   (*dt_attr_set)(struct dt_object *dt, void *buf, int buf_len,
+        int   (*do_attr_set)(struct dt_object *dt, void *buf, int buf_len,
                              const char *name, struct context *context,
                              struct thandle *handle);
-        int   (*dt_index_insert)(struct dt_object *dt, struct lu_fid *fid,
+        int   (*do_index_insert)(struct dt_object *dt, struct lu_fid *fid,
                                  const char *name, struct context *uctxt,
                                  void *handle);
-        int   (*dt_index_delete)(struct dt_object *dt, struct lu_fid *fid,
+        int   (*do_index_delete)(struct dt_object *dt, struct lu_fid *fid,
                                  const char *name, struct context *uctxt,
                                  struct thandle *handle);
-        int   (*dt_root_get)(struct dt_device *dev, struct lu_fid *f);
 };
 
 struct dt_device {
@@ -495,6 +494,11 @@ struct dt_device {
         struct lustre_mount_info    *dd_lmi;
 };
 
+struct dt_object {
+        struct lu_object             do_lu;
+       struct dt_object_operations *do_ops;
+};
+
 struct txn_param {
         unsigned int tp_credits;
 };
index 37be54a..80223f6 100644 (file)
@@ -85,12 +85,12 @@ struct md_object {
         struct md_object_operations *mo_ops;
 };
 
-static inline int lu_device_is_md(struct lu_device *d)
+static inline int lu_device_is_md(const struct lu_device *d)
 {
         return d->ld_type->ldt_tags & LU_DEVICE_MD;
 }
 
-static inline struct md_device *lu2md_dev(struct lu_device *d)
+static inline struct md_device *lu2md_dev(const struct lu_device *d)
 {
         LASSERT(lu_device_is_md(d));
         return container_of(d, struct md_device, md_lu_dev);
@@ -101,13 +101,18 @@ static inline struct lu_device *md2lu_dev(struct md_device *d)
         return &d->md_lu_dev;
 }
 
-static inline struct md_object *lu2md(struct lu_object *o)
+static inline struct md_object *lu2md(const struct lu_object *o)
 {
         LASSERT(lu_device_is_md(o->lo_dev));
         return container_of(o, struct md_object, mo_lu);
 }
 
-static inline struct md_device *md_device_get(struct md_object *o)
+static inline struct md_object *md_object_next(const struct md_object *obj)
+{
+        return lu2md(lu_object_next(&obj->mo_lu));
+}
+
+static inline struct md_device *md_device_get(const struct md_object *o)
 {
         LASSERT(lu_device_is_md(o->mo_lu.lo_dev));
         return container_of(o->mo_lu.lo_dev, struct md_device, md_lu_dev);
index 9ec8645..ddc81c2 100644 (file)
@@ -143,13 +143,12 @@ mdd_attr_get(struct md_object *obj, void *buf, int buf_len, const char *name,
              struct context *uctxt)
 {
         struct mdd_object *mdd_obj = mdo2mddo(obj);
-        struct mdd_device *mdd = mdo2mdd(obj);
+        struct dt_object  *next = mdd_object_child(mdd_obj);
         int rc;
 
         ENTRY;
 
-        rc = mdd_child_ops(mdd)->dt_attr_get(mdd_object_child(mdd_obj),
-                                             buf, buf_len, name, uctxt);
+        rc = next->do_ops->do_attr_get(next, buf, buf_len, name, uctxt);
         RETURN(rc);
 }
 
@@ -158,9 +157,9 @@ __mdd_object_destroy(struct mdd_device *mdd, struct mdd_object *obj,
                      struct thandle *handle)
 {
         int rc = 0;
+        struct dt_object *next = mdd_object_child(obj);
 
-        rc = mdd_child_ops(mdd)->dt_object_destroy(mdd_object_child(obj),
-                                                   handle);
+        rc = next->do_ops->do_object_destroy(next, handle);
         RETURN(rc);
 }
 
@@ -312,16 +311,16 @@ static struct dt_object* mdd_object_child(struct mdd_object *o)
 
 static void mdd_lock(struct mdd_object *obj, enum dt_lock_mode mode)
 {
-        struct mdd_device *dev = mdo2mdd(&obj->mod_obj);
+        struct dt_object  *next = mdd_object_child(obj);
 
-        mdd_child_ops(dev)->dt_object_lock(mdd_object_child(obj), mode);
+        next->do_ops->do_object_lock(next, mode);
 }
 
 static void mdd_unlock(struct mdd_object *obj, enum dt_lock_mode mode)
 {
-        struct mdd_device *dev = mdo2mdd(&obj->mod_obj);
+        struct dt_object  *next = mdd_object_child(obj);
 
-        mdd_child_ops(dev)->dt_object_unlock(mdd_object_child(obj), mode);
+        next->do_ops->do_object_unlock(next, mode);
 }
 
 static void mdd_lock2(struct mdd_object *o0, struct mdd_object *o1)
@@ -353,11 +352,11 @@ __mdd_object_create(struct mdd_device *mdd, struct mdd_object *pobj,
                     struct thandle *handle)
 {
         int rc;
+        struct dt_object *next = mdd_object_child(pobj);
         ENTRY;
 
-        rc = mdd_child_ops(mdd)->dt_object_create(mdd_object_child(pobj),
-                                                  mdd_object_child(child),
-                                                  uctxt, handle);
+        rc = next->do_ops->do_object_create(next, mdd_object_child(child),
+                                            uctxt, handle);
         /*XXX increase the refcount of the object or not?*/
         RETURN(rc);
 }
@@ -389,10 +388,9 @@ __mdd_attr_set(struct mdd_device *mdd, struct mdd_object *obj, void *buf,
                int buf_len, const char *name, struct context *uc_context,
                struct thandle *handle)
 {
-        return mdd_child_ops(mdd)->dt_attr_set(mdd_object_child(obj),
-                                                buf, buf_len,
-                                                name, uc_context,
-                                                handle);
+        struct dt_object *next = mdd_object_child(obj);
+        return next->do_ops->do_attr_set(next, buf, buf_len,
+                                         name, uc_context, handle);
 }
 
 static int
@@ -427,13 +425,13 @@ __mdd_index_insert(struct mdd_device *mdd, struct mdd_object *pobj,
                    struct context *uctxt, void *handle)
 {
         int rc;
+        struct dt_object *next = mdd_object_child(pobj);
         ENTRY;
 
         mdd_lock2(pobj, obj);
 
-        rc = mdd_child_ops(mdd)->dt_index_insert(mdd_object_child(pobj),
-                                             mdd_object_getfid(obj), name,
-                                             uctxt, handle);
+        rc = next->do_ops->do_index_insert(next, mdd_object_getfid(obj), name,
+                                           uctxt, handle);
         mdd_unlock2(pobj, obj);
 
         RETURN(rc);
@@ -465,13 +463,13 @@ __mdd_index_delete(struct mdd_device *mdd, struct mdd_object *pobj,
                    struct context *uctxt, struct thandle *handle)
 {
         int rc;
+        struct dt_object *next = mdd_object_child(pobj);
         ENTRY;
 
         mdd_lock2(pobj, obj);
 
-        rc = mdd_child_ops(mdd)->dt_index_delete(mdd_object_child(pobj),
-                                              mdd_object_getfid(obj), name,
-                                              uctxt, handle);
+        rc = next->do_ops->do_index_delete(next, mdd_object_getfid(obj), name,
+                                           uctxt, handle);
         mdd_unlock2(pobj, obj);
 
         RETURN(rc);
index 40dde0d..477af0f 100644 (file)
@@ -81,8 +81,10 @@ static int mdt_mkdir(struct mdt_thread_info *info, struct mdt_device *d,
 
         child = mdt_object_find(d, cfid);
         if (!IS_ERR(child)) {
-                result = o->mot_obj.mo_ops->moo_mkdir(mdt_object_child(o), name,
-                                                      mdt_object_child(child));
+                struct md_object *next = mdt_object_child(o);
+
+                result = next->mo_ops->moo_mkdir(next, name,
+                                                 mdt_object_child(child));
                 mdt_object_put(child);
         } else
                 result = PTR_ERR(child);
@@ -96,6 +98,7 @@ static int mdt_md_getattr(struct mdt_thread_info *info, struct lu_fid *fid,
 {
         struct mdt_device *d = info->mti_mdt;
         struct mdt_object *o;
+        struct md_object  *next;
         struct iattr
         int               result;
 
@@ -103,8 +106,9 @@ static int mdt_md_getattr(struct mdt_thread_info *info, struct lu_fid *fid,
         if (IS_ERR(o))
                 return PTR_ERR(o);
 
-        result = o->mot_obj.mo_ops->moo_attr_get(mdt_object_child(o), name,
-                                                 mdt_object_child(child));
+        next = mdt_object_child(o);
+        result = next->mo_ops->moo_attr_get(next, name,
+                                            mdt_object_child(child));
         mdt_object_put(child);
         } else
                 result = PTR_ERR(child);