From: nikita Date: Wed, 26 Apr 2006 20:11:51 +0000 (+0000) Subject: move some method into per-object operation vectors. Add comments. X-Git-Tag: v1_8_0_110~486^2~1921 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=3a28db04420df29daf93de658f94141270909777;p=fs%2Flustre-release.git move some method into per-object operation vectors. Add comments. --- diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index 5eef9ef..ad17b5a 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -102,9 +102,7 @@ static int cmm_process_config(struct lu_device *d, struct lustre_cfg *cfg) static struct lu_device_operations cmm_lu_ops = { .ldo_object_alloc = cmm_object_alloc, - .ldo_object_init = cmm_object_init, .ldo_object_free = cmm_object_free, - .ldo_object_release = cmm_object_release, .ldo_process_config = cmm_process_config }; diff --git a/lustre/cmm/cmm_internal.h b/lustre/cmm/cmm_internal.h index b1b330d..791ded4 100644 --- a/lustre/cmm/cmm_internal.h +++ b/lustre/cmm/cmm_internal.h @@ -96,10 +96,8 @@ static inline struct md_object *cmm2child_obj(struct cmm_object *o) int cmm_add_mdc(struct cmm_device *, struct lustre_cfg *); /* cmm_object.c */ -int cmm_object_init(struct lu_context *ctxt, struct lu_object*); struct lu_object *cmm_object_alloc(struct lu_context *ctx, struct lu_device *); void cmm_object_free(struct lu_context *ctx, struct lu_object *o); -void cmm_object_release(struct lu_context *ctxt, struct lu_object *o); //int cmm_getattr(struct lu_object *o, struct lu_attr *a); //int cmm_setattr(struct lu_object *o, struct lu_attr *a); diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 4517ebe..fa73d89 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -37,7 +37,7 @@ static struct md_object_operations cmm_mo_ops; static struct lu_object_operations cmm_obj_ops; -static int cmm_fld_lookup(struct lu_fid *fid) +static int cmm_fld_lookup(struct lu_fid *fid) { /* return master MDS for now */ return 0; @@ -205,6 +205,8 @@ static struct md_object_operations cmm_mo_ops = { }; static struct lu_object_operations cmm_obj_ops = { + .loo_object_init = cmm_object_init, + .loo_object_release = cmm_object_release, .loo_object_print = cmm_object_print, .loo_object_exists = cmm_object_exists }; diff --git a/lustre/include/linux/dt_object.h b/lustre/include/linux/dt_object.h index c172562..bcd6f87 100644 --- a/lustre/include/linux/dt_object.h +++ b/lustre/include/linux/dt_object.h @@ -109,7 +109,6 @@ struct dt_device_operations { */ int (*dt_object_destroy)(struct lu_context *ctxt, struct dt_object *dt, struct thandle *th); - }; /* diff --git a/lustre/include/linux/lu_object.h b/lustre/include/linux/lu_object.h index 452b451..c92a367 100644 --- a/lustre/include/linux/lu_object.h +++ b/lustre/include/linux/lu_object.h @@ -112,17 +112,46 @@ struct lu_device_operations { * - then lu_object_alloc() sets fid in the header of newly created * object. * - * - then ->ldo_object_init() is called. It has to allocate - * lower-layer object(s). To do this, ->ldo_object_init() calls + * - then ->loo_object_init() (a method from struct + * lu_object_operations) is called. It has to allocate lower-layer + * object(s). To do this, ->loo_object_init() calls * ldo_object_alloc() of the lower-layer device(s). * - * - for all new objects allocated by ->ldo_object_init() (and - * inserted into object stack), ->ldo_object_init() is called again + * - for all new objects allocated by ->loo_object_init() (and + * inserted into object stack), ->loo_object_init() is called again * repeatedly, until no new objects are created. * */ /* + * Allocate object for the given device (without lower-layer + * parts). This is called by ->loo_object_init() from the parent + * layer, and should setup at least ->lo_dev and ->lo_ops fields of + * resulting lu_object. + * + * postcondition: ergo(!IS_ERR(result), result->lo_dev == d && + * result->lo_ops != NULL); + */ + struct lu_object *(*ldo_object_alloc)(struct lu_context *ctx, + struct lu_device *d); + /* + * Dual to ->ldo_object_alloc(). Called when object is removed from + * memory. + */ + void (*ldo_object_free)(struct lu_context *ctx, struct lu_object *o); + + /* + * process config specific for device + */ + int (*ldo_process_config)(struct lu_device *, struct lustre_cfg *); +}; + +/* + * Operations specific for particular lu_object. + */ +struct lu_object_operations { + + /* * Allocate lower-layer parts of the object by calling * ->ldo_object_alloc() of the corresponding underlying device. * @@ -130,43 +159,20 @@ struct lu_device_operations { * stack. It's responsibility of this method to insert lower-layer * object(s) it create into appropriate places of object stack. */ - int (*ldo_object_init)(struct lu_context *, struct lu_object *); - - /* - * Allocate object for the given device (without lower-layer - * parts). This is called by ->ldo_object_init() from the parent - * layer. - */ - struct lu_object *(*ldo_object_alloc)(struct lu_context *, - struct lu_device *); - + int (*loo_object_init)(struct lu_context *ctx, struct lu_object *o); /* * Called before ->ldo_object_free() to signal that object is being - * destroyed. + * destroyed. Dual to ->loo_object_init(). */ - void (*ldo_object_delete)(struct lu_context *ctx, struct lu_object *o); - - /* - * Dual to ->ldo_object_alloc(). Called when object is removed from - * memory. - */ - void (*ldo_object_free)(struct lu_context *ctx, struct lu_object *o); + void (*loo_object_delete)(struct lu_context *ctx, struct lu_object *o); /* * Called when last active reference to the object is released (and * object returns to the cache). */ - void (*ldo_object_release)(struct lu_context *ctx, struct lu_object *o); + void (*loo_object_release)(struct lu_context *ctx, struct lu_object *o); /* - * process config specific for device - */ - int (*ldo_process_config)(struct lu_device *, struct lustre_cfg *); - -}; - -struct lu_object_operations { - /* * Return true off object @o exists on a storage. */ int (*loo_object_exists)(struct lu_context *ctx, struct lu_object *o); @@ -286,7 +292,7 @@ struct lu_device_type_operations { */ enum lu_object_flags { /* - * this flags is set if ->ldo_object_init() has been called for this + * this flags is set if ->loo_object_init() has been called for this * layer. Used by lu_object_alloc(). */ LU_OBJECT_ALLOCATED = (1 << 0) diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 471713c..90bdde1 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -58,7 +58,7 @@ struct lu_device_type; /* genops.c */ struct obd_export *class_conn2export(struct lustre_handle *); int class_register_type(struct obd_ops *, struct md_ops *, - struct lprocfs_vars *, const char *nm, + struct lprocfs_vars *, const char *nm, struct lu_device_type *ldt); int class_unregister_type(const char *nm); @@ -417,11 +417,12 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) ENTRY; OBD_CHECK_DEV(obd); - + ldt = obd->obd_type->typ_lu; d = obd->obd_lu_dev; if (ldt != NULL && d != NULL) { - rc = d->ld_ops->ldo_process_config(d, (struct lustre_cfg *)data); + rc = d->ld_ops->ldo_process_config(d, + (struct lustre_cfg *)data); } else { OBD_CHECK_DT_OP(obd, process_config, -EOPNOTSUPP); rc = OBP(obd, process_config)(obd, datalen, data); @@ -1294,7 +1295,7 @@ static inline int md_delete(struct obd_export *exp, if (MDP(exp->exp_obd, delete) == NULL) RETURN(0); - + MD_COUNTER_INCREMENT(exp->exp_obd, delete); rc = MDP(exp->exp_obd, delete)(exp, fid); RETURN(rc); @@ -1308,7 +1309,7 @@ static inline int md_getattr(struct obd_export *exp, struct lu_fid *fid, ENTRY; EXP_CHECK_MD_OP(exp, getattr); MD_COUNTER_INCREMENT(exp->exp_obd, getattr); - rc = MDP(exp->exp_obd, getattr)(exp, fid, valid, + rc = MDP(exp->exp_obd, getattr)(exp, fid, valid, ea_size, request); RETURN(rc); } @@ -1351,7 +1352,7 @@ static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, RETURN(rc); } -static inline int md_done_writing(struct obd_export *exp, +static inline int md_done_writing(struct obd_export *exp, struct md_op_data *op_data) { int rc; @@ -1396,7 +1397,7 @@ static inline int md_getattr_name(struct obd_export *exp, struct lu_fid *fid, RETURN(rc); } -static inline int md_intent_lock(struct obd_export *exp, +static inline int md_intent_lock(struct obd_export *exp, struct md_op_data *op_data, void *lmm, int lmmsize, struct lookup_intent *it, @@ -1409,12 +1410,12 @@ static inline int md_intent_lock(struct obd_export *exp, EXP_CHECK_MD_OP(exp, intent_lock); MD_COUNTER_INCREMENT(exp->exp_obd, intent_lock); rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, lmm, lmmsize, - it, flags, reqp, cb_blocking, + it, flags, reqp, cb_blocking, extra_lock_flags); RETURN(rc); } -static inline int md_link(struct obd_export *exp, +static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { @@ -1426,7 +1427,7 @@ static inline int md_link(struct obd_export *exp, RETURN(rc); } -static inline int md_rename(struct obd_export *exp, +static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, const char *old, int oldlen, const char *new, int newlen, @@ -1496,7 +1497,7 @@ static inline int md_get_lustre_md(struct obd_export *exp, ENTRY; EXP_CHECK_MD_OP(exp, get_lustre_md); MD_COUNTER_INCREMENT(exp->exp_obd, get_lustre_md); - RETURN(MDP(exp->exp_obd, get_lustre_md)(exp, req, offset, + RETURN(MDP(exp->exp_obd, get_lustre_md)(exp, req, offset, dt_exp, md)); } diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index df4f780..61702cf 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -322,13 +322,13 @@ static int mdd_process_config(struct lu_device *d, struct lustre_cfg *cfg) static struct lu_device_operations mdd_lu_ops = { .ldo_object_alloc = mdd_object_alloc, - .ldo_object_init = mdd_object_init, .ldo_object_free = mdd_object_free, - .ldo_object_release = mdd_object_release, .ldo_process_config = mdd_process_config }; static struct lu_object_operations mdd_lu_obj_ops = { + .loo_object_init = mdd_object_init, + .loo_object_release = mdd_object_release, .loo_object_print = mdd_object_print, .loo_object_exists = mdd_object_exists }; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index e891f88..d563b36 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -252,7 +252,6 @@ static int mdt_connect(struct mdt_thread_info *info, static int mdt_disconnect(struct mdt_thread_info *info, struct ptlrpc_request *req, int offset) { - //return -EOPNOTSUPP; return target_handle_disconnect(req); } @@ -522,7 +521,7 @@ enum mdt_handler_flags { * struct ldlm_request is passed in MDS_REQ_INTENT_LOCKREQ_OFF-th * incoming buffer. */ - HABEO_CLAVIS = (1 << 1) + HABEO_CLAVIS = (1 << 1) }; struct mdt_opc_slice { @@ -972,8 +971,7 @@ static int mdt_seq_mgr_hpr(struct lu_context *ctx, void *opaque, __u64 *seq, ENTRY; rc = mdt_config(ctx, m, LUSTRE_CONFIG_METASEQ, - seq, sizeof(*seq), - mode); + seq, sizeof(*seq), mode); RETURN(rc); } @@ -1394,13 +1392,13 @@ static int mdt_object_print(struct lu_context *ctxt, static struct lu_device_operations mdt_lu_ops = { .ldo_object_alloc = mdt_object_alloc, - .ldo_object_init = mdt_object_init, .ldo_object_free = mdt_object_free, - .ldo_object_release = mdt_object_release, .ldo_process_config = mdt_process_config }; static struct lu_object_operations mdt_obj_ops = { + .loo_object_init = mdt_object_init, + .loo_object_release = mdt_object_release, .loo_object_print = mdt_object_print, .loo_object_exists = mdt_object_exists }; diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 17d9f92..6a8cfbf 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -52,8 +52,8 @@ void lu_object_put(struct lu_context *ctxt, struct lu_object *o) spin_lock(&site->ls_guard); if (-- top->loh_ref == 0) { list_for_each_entry(o, &top->loh_layers, lo_linkage) { - if (lu_object_ops(o)->ldo_object_release != NULL) - lu_object_ops(o)->ldo_object_release(ctxt, o); + if (o->lo_ops->ldo_object_release != NULL) + o->lo_ops->ldo_object_release(ctxt, o); } -- site->ls_busy; if (lu_object_is_dying(top)) { @@ -91,8 +91,7 @@ struct lu_object *lu_object_alloc(struct lu_context *ctxt, continue; clean = 0; scan->lo_header = top->lo_header; - result = lu_object_ops(scan)->ldo_object_init(ctxt, - scan); + result = scan->lo_ops->loo_object_init(ctxt, scan); if (result != 0) { lu_object_free(ctxt, top); RETURN(ERR_PTR(result)); @@ -111,8 +110,8 @@ static void lu_object_free(struct lu_context *ctx, struct lu_object *o) list_for_each_entry_reverse(scan, &o->lo_header->loh_layers, lo_linkage) { - if (lu_object_ops(scan)->ldo_object_delete != NULL) - lu_object_ops(scan)->ldo_object_delete(ctx, scan); + if (scan->lo_ops->ldo_object_delete != NULL) + scan->lo_ops->ldo_object_delete(ctx, scan); } -- o->lo_dev->ld_site->ls_total; INIT_LIST_HEAD(&splice); diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index a823482..7bf9be2 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -549,16 +549,16 @@ static struct super_block *osd_sb(const struct osd_device *dev) } static struct lu_object_operations osd_lu_obj_ops = { + .loo_object_init = osd_object_init, + .loo_object_delete = osd_object_delete, + .loo_object_release = osd_object_release, .loo_object_print = osd_object_print, .loo_object_exists = osd_object_exists }; static struct lu_device_operations osd_lu_ops = { .ldo_object_alloc = osd_object_alloc, - .ldo_object_init = osd_object_init, .ldo_object_free = osd_object_free, - .ldo_object_release = osd_object_release, - .ldo_object_delete = osd_object_delete, .ldo_process_config = osd_process_config };