From: nikita Date: Tue, 11 Apr 2006 18:33:01 +0000 (+0000) Subject: move device_{init,fini}() into lu_device_type_operations, and add "const" to second... X-Git-Tag: v1_8_0_110~486^2~2050 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=46e9242c2a70b3d694eb725c916b3f7ccd74aeac;p=fs%2Flustre-release.git move device_{init,fini}() into lu_device_type_operations, and add "const" to second argument of ->ldto_device_init() --- diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index 2a38723..c3b2300 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -69,21 +69,20 @@ static struct md_device_operations cmm_md_ops = { // .mdo_object_create = cmm_object_create, }; -static int cmm_device_init(struct lu_device *d, char *top) +static int cmm_device_init(struct lu_device *d, const char *top) { struct cmm_device *m = lu2cmm_dev(d); struct lu_device *next; - int err = -EFAULT; - + int err; + ENTRY; - + LASSERT(m->cmm_child); next = md2lu_dev(m->cmm_child); - if (next->ld_ops->ldo_device_init) { - err = next->ld_ops->ldo_device_init(next, top); - } - return err; + LASSERT(next->ld_type->ldt_ops->ldto_device_init != NULL); + err = next->ld_type->ldt_ops->ldto_device_init(next, top); + RETURN(err); } static void cmm_device_fini(struct lu_device *d) @@ -93,14 +92,12 @@ static void cmm_device_fini(struct lu_device *d) LASSERT(m->cmm_child); next = md2lu_dev(m->cmm_child); - - if (next->ld_ops->ldo_device_fini) - next->ld_ops->ldo_device_fini(next); + + LASSERT(next->ld_type->ldt_ops->ldto_device_fini != NULL); + next->ld_type->ldt_ops->ldto_device_fini(next); } static struct lu_device_operations cmm_lu_ops = { - .ldo_device_init = cmm_device_init, - .ldo_device_fini = cmm_device_fini, .ldo_object_alloc = cmm_object_alloc, .ldo_object_init = cmm_object_init, .ldo_object_free = cmm_object_free, @@ -115,9 +112,9 @@ struct lu_device *cmm_device_alloc(struct lu_device_type *t, struct cmm_device *m; struct obd_device * obd = NULL; char * child = lustre_cfg_string(cfg, 1); - + ENTRY; - + OBD_ALLOC_PTR(m); if (m == NULL) { l = ERR_PTR(-ENOMEM); @@ -126,7 +123,7 @@ struct lu_device *cmm_device_alloc(struct lu_device_type *t, m->cmm_md_dev.md_ops = &cmm_md_ops; l = cmm2lu_dev(m); l->ld_ops = &cmm_lu_ops; - + /* get next layer */ obd = class_name2obd(child); if (obd && obd->obd_lu_dev) { @@ -145,7 +142,7 @@ struct lu_device *cmm_device_alloc(struct lu_device_type *t, void cmm_device_free(struct lu_device *d) { struct cmm_device *m = lu2cmm_dev(d); - + LASSERT(atomic_read(&d->ld_ref) == 0); md_device_fini(&m->cmm_md_dev); //cmm_fini(m); @@ -167,7 +164,10 @@ static struct lu_device_type_operations cmm_device_type_ops = { .ldto_fini = cmm_type_fini, .ldto_device_alloc = cmm_device_alloc, - .ldto_device_free = cmm_device_free + .ldto_device_free = cmm_device_free, + + .ldto_device_init = cmm_device_init, + .ldto_device_fini = cmm_device_fini }; static struct lu_device_type cmm_device_type = { diff --git a/lustre/include/linux/lu_object.h b/lustre/include/linux/lu_object.h index 9edbe57..36b50d1 100644 --- a/lustre/include/linux/lu_object.h +++ b/lustre/include/linux/lu_object.h @@ -128,11 +128,6 @@ struct lu_device_operations { * */ - /* Initialize the devices after allocation - * called from top device, when all layers are linked */ - int (*ldo_device_init)(struct lu_device *, char *); - void (*ldo_device_fini)(struct lu_device *); - /* * Allocate lower-layer parts of the object by calling * ->ldo_object_alloc() of the corresponding underlying device. @@ -219,6 +214,13 @@ struct lu_device_type_operations { struct lustre_cfg *lcfg); void (*ldto_device_free)(struct lu_device *d); + /* + * Initialize the devices after allocation + * called from top device, when all layers are linked + */ + int (*ldto_device_init)(struct lu_device *, const char *); + void (*ldto_device_fini)(struct lu_device *); + int (*ldto_init)(struct lu_device_type *t); void (*ldto_fini)(struct lu_device_type *t); }; @@ -463,7 +465,7 @@ struct dt_device_operations { * 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); @@ -484,6 +486,7 @@ struct dt_device_operations { int (*dt_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 { diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 6953f2f..45b526e 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -247,9 +247,6 @@ static int mdd_object_print(struct seq_file *f, const struct lu_object *o) static int mdd_fs_setup(struct mdd_device *mdd) { - mdd->mdd_rootfid.f_seq = LUSTRE_ROOT_FID_SEQ; - mdd->mdd_rootfid.f_oid = LUSTRE_ROOT_FID_OID; - mdd->mdd_rootfid.f_ver = 0; return 0; } @@ -258,23 +255,22 @@ static int mdd_fs_cleanup(struct mdd_device *mdd) return 0; } -static int mdd_device_init(struct lu_device *d, char *top) +static int mdd_device_init(struct lu_device *d, const char *top) { struct mdd_device *mdd = lu2mdd_dev(d); struct lu_device *next; int rc = -EFAULT; - + ENTRY; LASSERT(mdd->mdd_child); next = &mdd->mdd_child->dd_lu_dev; - if (next->ld_ops->ldo_device_init) - rc = next->ld_ops->ldo_device_init(next, top); - + LASSERT(next->ld_type->ldt_ops->ldto_device_init != NULL); + rc = next->ld_type->ldt_ops->ldto_device_init(next, top); if (rc) GOTO(err, rc); - + rc = mdd_fs_setup(mdd); if (rc) GOTO(err, rc); @@ -289,17 +285,15 @@ static void mdd_device_fini(struct lu_device *d) { struct mdd_device *m = lu2mdd_dev(d); struct lu_device *next; - + LASSERT(m->mdd_child); next = &m->mdd_child->dd_lu_dev; - - if (next->ld_ops->ldo_device_fini) - next->ld_ops->ldo_device_fini(next); + + LASSERT(next->ld_type->ldt_ops->ldto_device_fini != NULL); + next->ld_type->ldt_ops->ldto_device_fini(next); } static struct lu_device_operations mdd_lu_ops = { - .ldo_device_init = mdd_device_init, - .ldo_device_fini = mdd_device_fini, .ldo_object_alloc = mdd_object_alloc, .ldo_object_init = mdd_object_init, .ldo_object_free = mdd_object_free, @@ -621,36 +615,31 @@ cleanup: static int mdd_root_get(struct md_device *m, struct lu_fid *f) { struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev); + ENTRY; - *f = mdd->mdd_rootfid; - RETURN(0); + RETURN(mdd_child_ops(mdd)->dt_root_get(mdd->mdd_child, f)); } static int mdd_config(struct md_device *m, const char *name, void *buf, int size, int mode) { struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev); - int rc = -EOPNOTSUPP; + int rc; ENTRY; - if (mdd_child_ops(mdd)->dt_config) { - rc = mdd_child_ops(mdd)->dt_config(mdd->mdd_child, - name, buf, size, - mode); - } - + rc = mdd_child_ops(mdd)->dt_config(mdd->mdd_child, + name, buf, size, mode); RETURN(rc); } static int mdd_statfs(struct md_device *m, struct kstatfs *sfs) { struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev); - int rc = -EOPNOTSUPP; - + int rc; + ENTRY; - if (mdd_child_ops(mdd) && mdd_child_ops(mdd)->dt_statfs) - rc = mdd_child_ops(mdd)->dt_statfs(mdd->mdd_child, sfs); - + rc = mdd_child_ops(mdd)->dt_statfs(mdd->mdd_child, sfs); + RETURN(rc); } @@ -690,7 +679,7 @@ struct lu_device *mdd_device_alloc(struct lu_device_type *t, l = mdd2lu_dev(m); l->ld_ops = &mdd_lu_ops; m->mdd_md_dev.md_ops = &mdd_ops; - + /* get next layer */ obd = class_name2obd(child); if (obd && obd->obd_lu_dev) { @@ -709,7 +698,7 @@ struct lu_device *mdd_device_alloc(struct lu_device_type *t, void mdd_device_free(struct lu_device *lu) { struct mdd_device *m = lu2mdd_dev(lu); - + LASSERT(atomic_read(&lu->ld_ref) == 0); md_device_fini(&m->mdd_md_dev); @@ -730,7 +719,10 @@ static struct lu_device_type_operations mdd_device_type_ops = { .ldto_fini = mdd_type_fini, .ldto_device_alloc = mdd_device_alloc, - .ldto_device_free = mdd_device_free + .ldto_device_free = mdd_device_free, + + .ldto_device_init = mdd_device_init, + .ldto_device_fini = mdd_device_fini }; static struct lu_device_type mdd_device_type = { diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 236bd1e..96e1aaa 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -15,7 +15,6 @@ struct mdd_device { __u64 mdd_mount_count; __u64 mdd_io_epoch; unsigned long mdd_atime_diff; - struct lu_fid mdd_rootfid; struct lr_server_data *mdd_server_data; struct dentry *mdd_pending_dir; struct dentry *mdd_logs_dir;