From: nikita Date: Wed, 17 May 2006 13:13:49 +0000 (+0000) Subject: add lu_context to ->ldto_device_{alloc,free}() methods X-Git-Tag: v1_8_0_110~486^2~1816 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=2a16ace563fa2cbc08f6cef3c6d3f620e076e97e;p=fs%2Flustre-release.git add lu_context to ->ldto_device_{alloc,free}() methods --- diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index f0c1bcc..1630ecf 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -106,13 +106,13 @@ static int cmm_add_mdc(struct lu_context *ctx, /*TODO check this MDC exists already */ - ld = ldt->ldt_ops->ldto_device_alloc(ldt, cfg); + ld = ldt->ldt_ops->ldto_device_alloc(ctx, ldt, cfg); ld->ld_site = cmm2lu_dev(cm)->ld_site; rc = ldt->ldt_ops->ldto_device_init(ctx, ld, NULL); if (rc) - ldt->ldt_ops->ldto_device_free(ld); + ldt->ldt_ops->ldto_device_free(ctx, ld); /* pass config to the just created MDC */ rc = ld->ld_ops->ldo_process_config(ctx, ld, cfg); @@ -158,7 +158,8 @@ static struct lu_device_operations cmm_lu_ops = { /* --- lu_device_type operations --- */ -struct lu_device *cmm_device_alloc(struct lu_device_type *t, +struct lu_device *cmm_device_alloc(struct lu_context *ctx, + struct lu_device_type *t, struct lustre_cfg *cfg) { struct lu_device *l; @@ -180,7 +181,7 @@ struct lu_device *cmm_device_alloc(struct lu_device_type *t, return l; } -void cmm_device_free(struct lu_device *d) +void cmm_device_free(struct lu_context *ctx, struct lu_device *d) { struct cmm_device *m = lu2cmm_dev(d); @@ -228,7 +229,7 @@ static struct lu_device *cmm_device_fini(struct lu_context *ctx, list_del(&mc->mc_linkage); lu_device_put(cmm2lu_dev(cm)); ld->ld_type->ldt_ops->ldto_device_fini(ctx, ld_m); - ld->ld_type->ldt_ops->ldto_device_free(ld_m); + ld->ld_type->ldt_ops->ldto_device_free(ctx, ld_m); } EXIT; diff --git a/lustre/cmm/mdc_device.c b/lustre/cmm/mdc_device.c index 7558a6a..8e6b364 100644 --- a/lustre/cmm/mdc_device.c +++ b/lustre/cmm/mdc_device.c @@ -265,7 +265,8 @@ static struct lu_device *mdc_device_fini(struct lu_context *ctx, RETURN (NULL); } -struct lu_device *mdc_device_alloc(struct lu_device_type *ldt, +struct lu_device *mdc_device_alloc(struct lu_context *ctx, + struct lu_device_type *ldt, struct lustre_cfg *cfg) { struct lu_device *ld; @@ -316,7 +317,8 @@ static struct lu_device *mdc_device_fini(struct lu_context *ctx, RETURN (NULL); } -struct lu_device *mdc_device_alloc(struct lu_device_type *ldt, +struct lu_device *mdc_device_alloc(struct lu_context *ctx, + struct lu_device_type *ldt, struct lustre_cfg *cfg) { struct lu_device *ld; @@ -336,7 +338,7 @@ struct lu_device *mdc_device_alloc(struct lu_device_type *ldt, RETURN (ld); } -void mdc_device_free(struct lu_device *ld) +void mdc_device_free(struct lu_context *ctx, struct lu_device *ld) { struct mdc_device *mc = lu2mdc_dev(ld); diff --git a/lustre/include/linux/lu_object.h b/lustre/include/linux/lu_object.h index bee960c..a691224 100644 --- a/lustre/include/linux/lu_object.h +++ b/lustre/include/linux/lu_object.h @@ -260,12 +260,13 @@ struct lu_device_type_operations { /* * Allocate new device. */ - struct lu_device *(*ldto_device_alloc)(struct lu_device_type *t, + struct lu_device *(*ldto_device_alloc)(struct lu_context *ctx, + struct lu_device_type *t, struct lustre_cfg *lcfg); /* * Free device. Dual to ->ldto_device_alloc(). */ - void (*ldto_device_free)(struct lu_device *d); + void (*ldto_device_free)(struct lu_context *ctx, struct lu_device *d); /* * Initialize the devices after allocation diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index b87e467..b614bb6 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -355,15 +355,23 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) ldt = obd->obd_type->typ_lu; if (ldt != NULL) { +#ifdef __KERNEL__ + struct lu_context ctx; struct lu_device *d; - d = ldt->ldt_ops->ldto_device_alloc(ldt, cfg); - if (!IS_ERR(d)) { - obd->obd_lu_dev = d; - d->ld_obd = obd; - rc = 0; - } else - rc = PTR_ERR(d); + rc = lu_context_init(&ctx); + if (rc == 0) { + lu_context_enter(&ctx); + + d = ldt->ldt_ops->ldto_device_alloc(&ctx, ldt, cfg); + if (!IS_ERR(d)) { + obd->obd_lu_dev = d; + d->ld_obd = obd; + rc = 0; + } else + rc = PTR_ERR(d); + } +#endif } else { OBD_CHECK_DT_OP(obd, setup, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, setup); @@ -397,9 +405,19 @@ static inline int obd_cleanup(struct obd_device *obd) ldt = obd->obd_type->typ_lu; d = obd->obd_lu_dev; if (ldt != NULL && d != NULL) { - ldt->ldt_ops->ldto_device_free(d); - obd->obd_lu_dev = NULL; - rc = 0; +#ifdef __KERNEL__ + struct lu_context ctx; + + rc = lu_context_init(&ctx); + if (rc == 0) { + lu_context_enter(&ctx); + ldt->ldt_ops->ldto_device_free(&ctx, d); + lu_context_exit(&ctx); + lu_context_fini(&ctx); + obd->obd_lu_dev = NULL; + rc = 0; + } +#endif } else { OBD_CHECK_DT_OP(obd, cleanup, 0); rc = OBP(obd, cleanup)(obd); diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 13a6292..b69901a 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -766,7 +766,8 @@ static struct obd_ops mdd_obd_device_ops = { .o_owner = THIS_MODULE }; -struct lu_device *mdd_device_alloc(struct lu_device_type *t, +struct lu_device *mdd_device_alloc(struct lu_context *ctx, + struct lu_device_type *t, struct lustre_cfg *lcfg) { struct lu_device *l; @@ -785,7 +786,7 @@ struct lu_device *mdd_device_alloc(struct lu_device_type *t, return l; } -static void mdd_device_free(struct lu_device *lu) +static void mdd_device_free(struct lu_context *ctx, struct lu_device *lu) { struct mdd_device *m = lu2mdd_dev(lu); diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 71502b6..8cc953d 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -492,7 +492,7 @@ static int mds_getstatus(struct ptlrpc_request *req) /* get the LOV EA from @inode and store it into @md. It can be at most * @size bytes, and @size is updated with the actual EA size. - * The EA size is also returned on success, and -ve errno on failure. + * The EA size is also returned on success, and -ve errno on failure. * If there is no EA then 0 is returned. */ int mds_get_md(struct obd_device *obd, struct inode *inode, void *md, int *size, int lock) @@ -2629,7 +2629,7 @@ static struct obd_ops mdt_obd_ops = { quota_interface_t *quota_interface; quota_interface_t mds_quota_interface; -static int __init mds_init(void) +static __attribute__((unused)) int __init mds_init(void) { int rc; struct lprocfs_static_vars lvars; @@ -2653,7 +2653,7 @@ static int __init mds_init(void) return 0; } -static void /*__exit*/ mds_exit(void) +static __attribute__((unused)) void /*__exit*/ mds_exit(void) { lquota_exit(quota_interface); if (quota_interface) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 6daa44f..1289d4a 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1211,7 +1211,7 @@ static void mdt_stack_fini(struct lu_context *ctx, /* each fini() returns next device in stack of layers * * so we can avoid the recursion */ n = ldt->ldt_ops->ldto_device_fini(ctx, d); - ldt->ldt_ops->ldto_device_free(d); + ldt->ldt_ops->ldto_device_free(ctx, d); type = ldt->ldt_obd_type; type->typ_refcnt--; @@ -1246,7 +1246,7 @@ static struct lu_device *mdt_layer_setup(struct lu_context *ctx, GOTO(out_type, rc = -EINVAL); } - d = ldt->ldt_ops->ldto_device_alloc(ldt, cfg); + d = ldt->ldt_ops->ldto_device_alloc(ctx, ldt, cfg); if (IS_ERR(d)) { CERROR("Cannot allocate device: '%s'\n", typename); GOTO(out_type, rc = -ENODEV); @@ -1265,7 +1265,7 @@ static struct lu_device *mdt_layer_setup(struct lu_context *ctx, RETURN(d); out_alloc: - ldt->ldt_ops->ldto_device_free(d); + ldt->ldt_ops->ldto_device_free(ctx, d); type->typ_refcnt--; out_type: class_put_type(type); @@ -1666,7 +1666,7 @@ static struct obd_ops mdt_obd_device_ops = { .o_disconnect = mdt_obd_disconnect, }; -static void mdt_device_free(struct lu_device *d) +static void mdt_device_free(struct lu_context *ctx, struct lu_device *d) { struct mdt_device *m = mdt_dev(d); @@ -1674,7 +1674,8 @@ static void mdt_device_free(struct lu_device *d) OBD_FREE_PTR(m); } -static struct lu_device *mdt_device_alloc(struct lu_device_type *t, +static struct lu_device *mdt_device_alloc(struct lu_context *ctx, + struct lu_device_type *t, struct lustre_cfg *cfg) { struct lu_device *l; @@ -1687,7 +1688,7 @@ static struct lu_device *mdt_device_alloc(struct lu_device_type *t, l = &m->mdt_md_dev.md_lu_dev; result = mdt_init0(m, t, cfg); if (result != 0) { - mdt_device_free(l); + mdt_device_free(ctx, l); return ERR_PTR(result); } diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 069c3ee..936785e 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -80,7 +80,7 @@ static void osd_object_release(struct lu_context *ctxt, struct lu_object *l); static int osd_object_exists (struct lu_context *ctx, struct lu_object *o); static int osd_object_print (struct lu_context *ctx, struct seq_file *f, const struct lu_object *o); -static void osd_device_free (struct lu_device *m); +static void osd_device_free (struct lu_context *ctx, struct lu_device *m); static void *osd_key_init (struct lu_context *ctx); static void osd_key_fini (struct lu_context *ctx, void *data); static int osd_has_index (struct osd_object *obj); @@ -112,7 +112,8 @@ static struct osd_device *osd_obj2dev (struct osd_object *o); static struct lu_device *osd2lu_dev (struct osd_device * osd); static struct lu_device *osd_device_fini (struct lu_context *ctx, struct lu_device *d); -static struct lu_device *osd_device_alloc (struct lu_device_type *t, +static struct lu_device *osd_device_alloc (struct lu_context *ctx, + struct lu_device_type *t, struct lustre_cfg *cfg); static struct lu_object *osd_object_alloc (struct lu_context *ctx, struct lu_device *d); @@ -757,7 +758,8 @@ static struct lu_device *osd_device_fini(struct lu_context *ctx, RETURN(NULL); } -static struct lu_device *osd_device_alloc(struct lu_device_type *t, +static struct lu_device *osd_device_alloc(struct lu_context *ctx, + struct lu_device_type *t, struct lustre_cfg *cfg) { struct lu_device *l; @@ -779,7 +781,7 @@ static struct lu_device *osd_device_alloc(struct lu_device_type *t, return l; } -static void osd_device_free(struct lu_device *d) +static void osd_device_free(struct lu_context *ctx, struct lu_device *d) { struct osd_device *o = osd_dev(d);