From: nikita Date: Wed, 12 Apr 2006 13:48:42 +0000 (+0000) Subject: split struct md_device_operations into struct md_device_operations and struct md_obje... X-Git-Tag: v1_8_0_110~486^2~2033 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7007a1c8d36599f7072229e725895e935f33bc92;p=fs%2Flustre-release.git split struct md_device_operations into struct md_device_operations and struct md_object_operations --- diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index 24d3f71..3a9c8e6 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -58,16 +58,7 @@ static inline int lu_device_is_cmm(struct lu_device *d) static struct md_device_operations cmm_md_ops = { .mdo_root_get = cmm_root_get, .mdo_config = cmm_config, - .mdo_statfs = cmm_statfs, - .mdo_mkdir = cmm_mkdir, - .mdo_attr_get = cmm_attr_get, -// .mdo_rename = cmm_rename, -// .mdo_link = cmm_link, -// .mdo_attr_get = cmm_attr_get, -// .mdo_attr_set = cmm_attr_set, -// .mdo_index_insert = cmm_index_insert, -// .mdo_index_delete = cmm_index_delete, -// .mdo_object_create = cmm_object_create, + .mdo_statfs = cmm_statfs }; static int cmm_device_init(struct lu_device *d, const char *top) diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 3fceb2d..e6d0496 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -34,6 +34,8 @@ #include "cmm_internal.h" +static struct md_object_operations cmm_mo_ops; + struct cmm_object *cmm_object_find(struct cmm_device *d, struct lu_fid *f) { struct lu_object *o; @@ -54,12 +56,14 @@ struct lu_object *cmm_object_alloc(struct lu_device *d) { struct cmm_object *mo; ENTRY; - + OBD_ALLOC_PTR(mo); if (mo != NULL) { struct lu_object *o; + o = &mo->cmo_obj.mo_lu; lu_object_init(o, NULL, d); + mo->cmo_obj.mo_ops = &cmm_mo_ops; RETURN(o); } else RETURN(NULL); @@ -102,7 +106,7 @@ static void cmm_lock(struct md_object *obj, __u32 mode) { struct cmm_object *cmm_obj = md2cmm_obj(obj); struct cmm_device *cmm_dev = cmm_obj2dev(cmm_obj); - + CMM_DO_CHILD(cmm_dev)->ldo_lock_obj(cmm2child_obj(cmm_obj), mode); return; } @@ -111,7 +115,7 @@ static void cmm_unlock(struct md_object *obj, __u32 mode) { struct cmm_object *cmm_obj = md2cmm_obj(obj); struct cmm_device *cmm_dev = cmm_obj2dev(cmm_obj); - + CMM_DO_CHILD(cmm_dev)->ldo_unlock_obj(cmm2child_obj(cmm_obj), mode); return; } @@ -121,74 +125,57 @@ static void cmm_unlock(struct md_object *obj, __u32 mode) /* Metadata API */ int cmm_root_get(struct md_device *md, struct lu_fid *fid) { struct cmm_device *cmm_dev = md2cmm_dev(md); - int result = -EOPNOTSUPP; - - if (cmm_child_ops(cmm_dev)->mdo_root_get) { - result = cmm_child_ops(cmm_dev)->mdo_root_get( - cmm_dev->cmm_child, fid); - } - - return result; + + return cmm_child_ops(cmm_dev)->mdo_root_get(cmm_dev->cmm_child, fid); } int cmm_config(struct md_device *md, const char *name, void *buf, int size, int mode) { struct cmm_device *cmm_dev = md2cmm_dev(md); - int result = -EOPNOTSUPP; + int result; ENTRY; - - if (cmm_child_ops(cmm_dev)->mdo_config) - result = cmm_child_ops(cmm_dev)->mdo_config(cmm_dev->cmm_child, - name, buf, size, mode); - + result = cmm_child_ops(cmm_dev)->mdo_config(cmm_dev->cmm_child, + name, buf, size, mode); RETURN(result); } int cmm_statfs(struct md_device *md, struct kstatfs *sfs) { struct cmm_device *cmm_dev = md2cmm_dev(md); - int result = -EOPNOTSUPP; - + int result; + ENTRY; - - if (cmm_child_ops(cmm_dev)->mdo_statfs) { - result = cmm_child_ops(cmm_dev)->mdo_statfs( - cmm_dev->cmm_child, sfs); - } - + result = cmm_child_ops(cmm_dev)->mdo_statfs(cmm_dev->cmm_child, sfs); RETURN (result); } -int cmm_mkdir(struct md_object *md_parent, const char *name, - struct md_object *md_child) +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 cmm_device *cmm_dev = cmm_obj2dev(cmm_parent); - int result = -EOPNOTSUPP; - - if (cmm_child_ops(cmm_dev)->mdo_mkdir) { - result = cmm_child_ops(cmm_dev)->mdo_mkdir( - cmm2child_obj(cmm_parent), - name, md_child); - } - - return result; + + return md_parent->mo_ops->moo_mkdir(cmm2child_obj(cmm_parent), + name, md_child); } +static struct md_object_operations cmm_mo_ops = { + .moo_mkdir = cmm_mkdir, + .moo_mkdir = cmm_mkdir, + .moo_attr_get = cmm_attr_get, +// .moo_rename = cmm_rename, +// .moo_link = cmm_link, +// .moo_attr_set = cmm_attr_set, +// .moo_index_insert = cmm_index_insert, +// .moo_index_delete = cmm_index_delete, +// .moo_object_create = cmm_object_create, +}; + int cmm_attr_get(struct md_object *obj, void *buf, int size, const char *name, struct context *ctxt) { - struct cmm_object *co = md2cmm_obj(obj); - struct cmm_device *dev = cmm_obj2dev(co); - struct md_object *next = cmm2child_obj(co); - int result = -EOPNOTSUPP; - - LASSERT(cmm_child_ops(dev)>0x100); - if (cmm_child_ops(dev)->mdo_attr_get) { - result = cmm_child_ops(dev)->mdo_attr_get(next, buf, size, - name, ctxt); - } - - return result; + 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); } diff --git a/lustre/include/linux/md_object.h b/lustre/include/linux/md_object.h index b786b1f..37be54a 100644 --- a/lustre/include/linux/md_object.h +++ b/lustre/include/linux/md_object.h @@ -37,48 +37,52 @@ struct context { int flags; }; -struct md_device_operations { - - /* method for getting/setting device wide back stored config data, like - * last used meta-sequence, etc. */ - int (*mdo_config) (struct md_device *m, const char *name, - void *buf, int size, int mode); - - /* meta-data device related handlers. */ - int (*mdo_root_get)(struct md_device *m, struct lu_fid *f); - int (*mdo_statfs)(struct md_device *m, struct kstatfs *sfs); +struct md_object_operations { /* meta-data object operations related handlers */ - int (*mdo_mkdir)(struct md_object *obj, const char *name, + int (*moo_mkdir)(struct md_object *obj, const char *name, struct md_object *child); - int (*mdo_rename)(struct md_object *spobj, struct md_object *tpobj, + int (*moo_rename)(struct md_object *spobj, struct md_object *tpobj, struct md_object *sobj, const char *sname, struct md_object *tobj, const char *tname, struct context *uctxt); - int (*mdo_link)(struct md_object *tobj, struct md_object *sobj, + int (*moo_link)(struct md_object *tobj, struct md_object *sobj, const char *name, struct context *uctxt); - int (*mdo_attr_get)(struct md_object *obj, void *buf, int buf_len, + int (*moo_attr_get)(struct md_object *obj, void *buf, int buf_len, const char *name, struct context *uctxt); - int (*mdo_attr_set)(struct md_object *obj, void *buf, int buf_len, + int (*moo_attr_set)(struct md_object *obj, void *buf, int buf_len, const char *name, struct context *uctxt); /* FLD maintanence related handlers */ - int (*mdo_index_insert)(struct md_object *pobj, struct md_object *obj, + int (*moo_index_insert)(struct md_object *pobj, struct md_object *obj, const char *name, struct context *uctxt); - int (*mdo_index_delete)(struct md_object *pobj, struct md_object *obj, + int (*moo_index_delete)(struct md_object *pobj, struct md_object *obj, const char *name, struct context *uctxt); - int (*mdo_object_create)(struct md_object *pobj, struct md_object *child, + int (*moo_object_create)(struct md_object *pobj, + struct md_object *child, struct context *uctxt); }; +struct md_device_operations { + /* method for getting/setting device wide back stored config data, like + * last used meta-sequence, etc. */ + int (*mdo_config) (struct md_device *m, const char *name, + void *buf, int size, int mode); + + /* meta-data device related handlers. */ + int (*mdo_root_get)(struct md_device *m, struct lu_fid *f); + int (*mdo_statfs)(struct md_device *m, struct kstatfs *sfs); +}; + struct md_device { struct lu_device md_lu_dev; struct md_device_operations *md_ops; }; struct md_object { - struct lu_object mo_lu; + struct lu_object mo_lu; + struct md_object_operations *mo_ops; }; static inline int lu_device_is_md(struct lu_device *d) diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 1488ae1..9ec8645 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -52,6 +52,8 @@ static struct lu_device_operations mdd_lu_ops; static void mdd_lock(struct mdd_object *obj, enum dt_lock_mode mode); static void mdd_unlock(struct mdd_object *obj, enum dt_lock_mode mode); +static struct md_object_operations mdd_obj_ops; + static int lu_device_is_mdd(struct lu_device *d) { /* @@ -103,6 +105,7 @@ static struct lu_object *mdd_object_alloc(struct lu_device *d) o = &mdo->mod_obj.mo_lu; lu_object_init(o, NULL, d); + mdo->mod_obj.mo_ops = &mdd_obj_ops; return (&mdo->mod_obj.mo_lu); } else return(NULL); @@ -643,18 +646,21 @@ static int mdd_statfs(struct md_device *m, struct kstatfs *sfs) { RETURN(rc); } -struct md_device_operations mdd_ops = { +static struct md_device_operations mdd_ops = { .mdo_root_get = mdd_root_get, .mdo_config = mdd_config, - .mdo_statfs = mdd_statfs, - .mdo_mkdir = mdd_mkdir, - .mdo_rename = mdd_rename, - .mdo_link = mdd_link, - .mdo_attr_get = mdd_attr_get, - .mdo_attr_set = mdd_attr_set, - .mdo_index_insert = mdd_index_insert, - .mdo_index_delete = mdd_index_delete, - .mdo_object_create = mdd_object_create, + .mdo_statfs = mdd_statfs +}; + +static struct md_object_operations mdd_obj_ops = { + .moo_mkdir = mdd_mkdir, + .moo_rename = mdd_rename, + .moo_link = mdd_link, + .moo_attr_get = mdd_attr_get, + .moo_attr_set = mdd_attr_set, + .moo_index_insert = mdd_index_insert, + .moo_index_delete = mdd_index_delete, + .moo_object_create = mdd_object_create, }; static struct obd_ops mdd_obd_device_ops = { diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index b033b16..40dde0d 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -81,8 +81,8 @@ static int mdt_mkdir(struct mdt_thread_info *info, struct mdt_device *d, child = mdt_object_find(d, cfid); if (!IS_ERR(child)) { - result = mdt_child_ops(d)->mdo_mkdir(mdt_object_child(o), name, - mdt_object_child(child)); + result = o->mot_obj.mo_ops->moo_mkdir(mdt_object_child(o), name, + mdt_object_child(child)); mdt_object_put(child); } else result = PTR_ERR(child); @@ -103,9 +103,9 @@ static int mdt_md_getattr(struct mdt_thread_info *info, struct lu_fid *fid, if (IS_ERR(o)) return PTR_ERR(o); - result = mdt_child_ops(d)->mdo_attr_get(mdt_object_child(o), name, - mdt_object_child(child)); - mdt_object_put(child); + result = o->mot_obj.mo_ops->moo_attr_get(mdt_object_child(o), name, + mdt_object_child(child)); + mdt_object_put(child); } else result = PTR_ERR(child); mdt_object_unlock(d->mdt_namespace, o, lh);