From: nikita Date: Sat, 18 Oct 2008 17:26:37 +0000 (+0000) Subject: Constify instances of struct {lu,dt,md}_device_operations. X-Git-Tag: v1_9_90~56 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=6b6ae6fe7cc74816c42878630d73400a072598f3 Constify instances of struct {lu,dt,md}_device_operations. b=16450 --- diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 8af96c9..8a2ad27 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -1648,6 +1648,11 @@ Description: Factor lu_site procfs stats into a separate function. Details : Separate lu_site stats printing code into a separate function that can be reused on a client. +Severity : minor +Bugzilla : 16450 +Description: Constify instances of struct {lu,dt,md}_device_operations. +Details : Constify instances of struct {lu,dt,md}_device_operations. + -------------------------------------------------------------------------------- 2007-08-10 Cluster File Systems, Inc. diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index a526307..571a513 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -58,7 +58,7 @@ static struct obd_ops cmm_obd_device_ops = { .o_owner = THIS_MODULE }; -static struct lu_device_operations cmm_lu_ops; +static const struct lu_device_operations cmm_lu_ops; static inline int lu_device_is_cmm(struct lu_device *d) { @@ -127,7 +127,7 @@ static int cmm_update_capa_key(const struct lu_env *env, RETURN(rc); } -static struct md_device_operations cmm_md_ops = { +static const struct md_device_operations cmm_md_ops = { .mdo_statfs = cmm_statfs, .mdo_root_get = cmm_root_get, .mdo_maxsize_get = cmm_maxsize_get, @@ -336,7 +336,7 @@ static int cmm_recovery_complete(const struct lu_env *env, RETURN(rc); } -static struct lu_device_operations cmm_lu_ops = { +static const struct lu_device_operations cmm_lu_ops = { .ldo_object_alloc = cmm_object_alloc, .ldo_process_config = cmm_process_config, .ldo_recovery_complete = cmm_recovery_complete diff --git a/lustre/cmm/cmm_internal.h b/lustre/cmm/cmm_internal.h index e3b1da2..4dc359f 100644 --- a/lustre/cmm/cmm_internal.h +++ b/lustre/cmm/cmm_internal.h @@ -75,9 +75,10 @@ enum cmm_flags { CMM_INITIALIZED = 1 << 0 }; -static inline struct md_device_operations *cmm_child_ops(struct cmm_device *d) +static inline const struct md_device_operations * +cmm_child_ops(struct cmm_device *d) { - return (d->cmm_child->md_ops); + return d->cmm_child->md_ops; } static inline struct cmm_device *md2cmm_dev(struct md_device *m) diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 910e5c0..2289be3 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -77,13 +77,13 @@ int cmm_fld_lookup(struct cmm_device *cm, const struct lu_fid *fid, RETURN (rc); } -static struct md_object_operations cml_mo_ops; -static struct md_dir_operations cml_dir_ops; -static struct lu_object_operations cml_obj_ops; +static const struct md_object_operations cml_mo_ops; +static const struct md_dir_operations cml_dir_ops; +static const struct lu_object_operations cml_obj_ops; -static struct md_object_operations cmr_mo_ops; -static struct md_dir_operations cmr_dir_ops; -static struct lu_object_operations cmr_obj_ops; +static const struct md_object_operations cmr_mo_ops; +static const struct md_dir_operations cmr_dir_ops; +static const struct lu_object_operations cmr_obj_ops; struct lu_object *cmm_object_alloc(const struct lu_env *env, const struct lu_object_header *loh, @@ -195,10 +195,10 @@ static int cml_object_init(const struct lu_env *env, struct lu_object *lo, static int cml_object_print(const struct lu_env *env, void *cookie, lu_printer_t p, const struct lu_object *lo) { - return (*p)(env, cookie, LUSTRE_CMM_NAME"-local@%p", lo); + return (*p)(env, cookie, "[local]"); } -static struct lu_object_operations cml_obj_ops = { +static const struct lu_object_operations cml_obj_ops = { .loo_object_init = cml_object_init, .loo_object_free = cml_object_free, .loo_object_print = cml_object_print @@ -353,7 +353,7 @@ static int cml_object_sync(const struct lu_env *env, struct md_object *mo) RETURN(rc); } -static struct md_object_operations cml_mo_ops = { +static const struct md_object_operations cml_mo_ops = { .moo_permission = cml_permission, .moo_attr_get = cml_attr_get, .moo_attr_set = cml_attr_set, @@ -742,7 +742,7 @@ static int cmm_is_subdir(const struct lu_env *env, struct md_object *mo, RETURN(rc); } -static struct md_dir_operations cml_dir_ops = { +static const struct md_dir_operations cml_dir_ops = { .mdo_is_subdir = cmm_is_subdir, .mdo_lookup = cml_lookup, .mdo_lock_mode = cml_lock_mode, @@ -827,10 +827,10 @@ static int cmr_object_init(const struct lu_env *env, struct lu_object *lo, static int cmr_object_print(const struct lu_env *env, void *cookie, lu_printer_t p, const struct lu_object *lo) { - return (*p)(env, cookie, LUSTRE_CMM_NAME"-remote@%p", lo); + return (*p)(env, cookie, "[remote]"); } -static struct lu_object_operations cmr_obj_ops = { +static const struct lu_object_operations cmr_obj_ops = { .loo_object_init = cmr_object_init, .loo_object_free = cmr_object_free, .loo_object_print = cmr_object_print @@ -936,7 +936,7 @@ static int cmr_object_sync(const struct lu_env *env, struct md_object *mo) return -EFAULT; } -static struct md_object_operations cmr_mo_ops = { +static const struct md_object_operations cmr_mo_ops = { .moo_permission = cmr_permission, .moo_attr_get = cmr_attr_get, .moo_attr_set = cmr_attr_set, @@ -1266,7 +1266,7 @@ static int cmr_rename_tgt(const struct lu_env *env, RETURN(rc); } -static struct md_dir_operations cmr_dir_ops = { +static const struct md_dir_operations cmr_dir_ops = { .mdo_is_subdir = cmm_is_subdir, .mdo_lookup = cmr_lookup, .mdo_lock_mode = cmr_lock_mode, diff --git a/lustre/cmm/mdc_device.c b/lustre/cmm/mdc_device.c index 21dada3..8c75a6c 100644 --- a/lustre/cmm/mdc_device.c +++ b/lustre/cmm/mdc_device.c @@ -52,7 +52,7 @@ #include "cmm_internal.h" #include "mdc_internal.h" -static struct lu_device_operations mdc_lu_ops; +static const struct lu_device_operations mdc_lu_ops; static inline int lu_device_is_mdc(struct lu_device *ld) { @@ -60,7 +60,7 @@ static inline int lu_device_is_mdc(struct lu_device *ld) ld->ld_ops == &mdc_lu_ops); } -static struct md_device_operations mdc_md_ops = { 0 }; +static const struct md_device_operations mdc_md_ops = { 0 }; static int mdc_obd_update(struct obd_device *host, struct obd_device *watched, @@ -245,7 +245,7 @@ static int mdc_process_config(const struct lu_env *env, RETURN(rc); } -static struct lu_device_operations mdc_lu_ops = { +static const struct lu_device_operations mdc_lu_ops = { .ldo_object_alloc = mdc_object_alloc, .ldo_process_config = mdc_process_config }; diff --git a/lustre/cmm/mdc_object.c b/lustre/cmm/mdc_object.c index d58e47b..36c7678 100644 --- a/lustre/cmm/mdc_object.c +++ b/lustre/cmm/mdc_object.c @@ -52,9 +52,9 @@ #include "cmm_internal.h" #include "mdc_internal.h" -static struct md_object_operations mdc_mo_ops; -static struct md_dir_operations mdc_dir_ops; -static struct lu_object_operations mdc_obj_ops; +static const struct md_object_operations mdc_mo_ops; +static const struct md_dir_operations mdc_dir_ops; +static const struct lu_object_operations mdc_obj_ops; extern struct lu_context_key mdc_thread_key; @@ -511,7 +511,7 @@ int mdc_send_page(struct cmm_device *cm, const struct lu_env *env, } #endif -static struct md_object_operations mdc_mo_ops = { +static const struct md_object_operations mdc_mo_ops = { .moo_attr_get = mdc_attr_get, .moo_attr_set = mdc_attr_set, .moo_object_create = mdc_object_create, @@ -603,7 +603,7 @@ static int mdc_is_subdir(const struct lu_env *env, struct md_object *mo, RETURN(rc); } -static struct md_dir_operations mdc_dir_ops = { +static const struct md_dir_operations mdc_dir_ops = { .mdo_is_subdir = mdc_is_subdir, .mdo_rename_tgt = mdc_rename_tgt }; diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index f535c69..760cee5 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -405,9 +405,9 @@ struct dt_index_operations { struct dt_device { struct lu_device dd_lu_dev; - struct dt_device_operations *dd_ops; + const struct dt_device_operations *dd_ops; - /* + /** * List of dt_txn_callback (see below). This is not protected in any * way, because callbacks are supposed to be added/deleted only during * single-threaded start-up shut-down procedures. @@ -431,9 +431,9 @@ static inline struct dt_device * lu2dt_dev(struct lu_device *l) struct dt_object { struct lu_object do_lu; - struct dt_object_operations *do_ops; - struct dt_body_operations *do_body_ops; - struct dt_index_operations *do_index_ops; + const struct dt_object_operations *do_ops; + const struct dt_body_operations *do_body_ops; + const struct dt_index_operations *do_index_ops; }; int dt_object_init(struct dt_object *obj, diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index e848fac..d105001 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -452,7 +452,7 @@ struct lu_object { /* * Operations for this object. */ - struct lu_object_operations *lo_ops; + const struct lu_object_operations *lo_ops; /* * Linkage into list of all layers. */ @@ -781,21 +781,21 @@ static inline const struct lu_fid *lu_object_fid(const struct lu_object *o) return &o->lo_header->loh_fid; } -/* +/** * return device operations vector for this object */ -static inline struct lu_device_operations * +static const inline struct lu_device_operations * lu_object_ops(const struct lu_object *o) { return o->lo_dev->ld_ops; } -/* +/** * Given a compound object, find its slice, corresponding to the device type - * @dtype. + * \a dtype. */ struct lu_object *lu_object_locate(struct lu_object_header *h, - struct lu_device_type *dtype); + const struct lu_device_type *dtype); struct lu_cdebug_print_info { int lpi_subsys; diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index f6166e1..774e34b 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -336,7 +336,7 @@ struct md_upcall { struct md_device { struct lu_device md_lu_dev; - struct md_device_operations *md_ops; + const struct md_device_operations *md_ops; struct md_upcall md_upcall; }; diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 5e96765..92b1077 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -60,7 +60,7 @@ #include "mdd_internal.h" -struct md_device_operations mdd_ops; +const struct md_device_operations mdd_ops; static const char *mdd_root_dir_name = "root"; static int mdd_device_init(const struct lu_env *env, struct lu_device *d, @@ -243,7 +243,7 @@ static int mdd_recovery_complete(const struct lu_env *env, RETURN(rc); } -struct lu_device_operations mdd_lu_ops = { +const struct lu_device_operations mdd_lu_ops = { .ldo_object_alloc = mdd_object_alloc, .ldo_process_config = mdd_process_config, .ldo_recovery_complete = mdd_recovery_complete @@ -400,7 +400,7 @@ EXPORT_SYMBOL(md_capainfo); /* type constructor/destructor: mdd_type_init, mdd_type_fini */ LU_TYPE_INIT_FINI(mdd, &mdd_thread_key, &mdd_ucred_key, &mdd_capainfo_key); -struct md_device_operations mdd_ops = { +const struct md_device_operations mdd_ops = { .mdo_statfs = mdd_statfs, .mdo_root_get = mdd_root_get, .mdo_maxsize_get = mdd_maxsize_get, @@ -412,6 +412,9 @@ static struct lu_device_type_operations mdd_device_type_ops = { .ldto_init = mdd_type_init, .ldto_fini = mdd_type_fini, + .ldto_start = mdd_type_start, + .ldto_stop = mdd_type_stop, + .ldto_device_alloc = mdd_device_alloc, .ldto_device_free = mdd_device_free, diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 4625205..b67784a 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -1706,7 +1706,7 @@ cleanup_unlocked: return rc; } -struct md_dir_operations mdd_dir_ops = { +const struct md_dir_operations mdd_dir_ops = { .mdo_is_subdir = mdd_is_subdir, .mdo_lookup = mdd_lookup, .mdo_create = mdd_create, diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 896248a..d72d48c 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -289,8 +289,8 @@ void mdd_lprocfs_time_end(const struct lu_env *env, int mdd_get_flags(const struct lu_env *env, struct mdd_object *obj); -extern struct md_dir_operations mdd_dir_ops; -extern struct md_object_operations mdd_obj_ops; +extern const struct md_dir_operations mdd_dir_ops; +extern const struct md_object_operations mdd_obj_ops; /* mdd_trans.c */ void mdd_txn_param_build(const struct lu_env *env, struct mdd_device *mdd, @@ -326,7 +326,7 @@ struct lu_object *mdd_object_alloc(const struct lu_env *env, /* mdd_object.c */ int accmode(const struct lu_env *env, struct lu_attr *la, int flags); extern struct lu_context_key mdd_thread_key; -extern struct lu_device_operations mdd_lu_ops; +extern const struct lu_device_operations mdd_lu_ops; struct mdd_object *mdd_object_find(const struct lu_env *env, struct mdd_device *d, @@ -393,7 +393,8 @@ static inline struct mdd_object* md2mdd_obj(struct md_object *mdo) return container_of0(mdo, struct mdd_object, mod_obj); } -static inline struct dt_device_operations *mdd_child_ops(struct mdd_device *d) +static inline const struct dt_device_operations * +mdd_child_ops(struct mdd_device *d) { return d->mdd_child->dd_ops; } diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 4a50879..2503006 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -60,7 +60,7 @@ #include "mdd_internal.h" -static struct lu_object_operations mdd_lu_obj_ops; +static const struct lu_object_operations mdd_lu_obj_ops; int mdd_la_get(const struct lu_env *env, struct mdd_object *obj, struct lu_attr *la, struct lustre_capa *capa) @@ -236,11 +236,10 @@ static void mdd_object_delete(const struct lu_env *env, struct lu_object *o) } } -static struct lu_object_operations mdd_lu_obj_ops = { +static const struct lu_object_operations mdd_lu_obj_ops = { .loo_object_init = mdd_object_init, .loo_object_start = mdd_object_start, .loo_object_free = mdd_object_free, - .loo_object_print = mdd_object_print, .loo_object_delete = mdd_object_delete }; @@ -1379,7 +1378,7 @@ static int mdd_readpage_sanity_check(const struct lu_env *env, } static int mdd_dir_page_build(const struct lu_env *env, int first, - void *area, int nob, struct dt_it_ops *iops, + void *area, int nob, const struct dt_it_ops *iops, struct dt_it *it, __u64 *start, __u64 *end, struct lu_dirent **last) { @@ -1453,7 +1452,7 @@ static int __mdd_readpage(const struct lu_env *env, struct mdd_object *obj, { struct dt_it *it; struct dt_object *next = mdd_object_child(obj); - struct dt_it_ops *iops; + const struct dt_it_ops *iops; struct page *pg; struct lu_dirent *last = NULL; int i; @@ -1597,7 +1596,7 @@ static int mdd_object_sync(const struct lu_env *env, struct md_object *obj) return next->do_ops->do_object_sync(env, next); } -struct md_object_operations mdd_obj_ops = { +const struct md_object_operations mdd_obj_ops = { .moo_permission = mdd_permission, .moo_attr_get = mdd_attr_get, .moo_attr_set = mdd_attr_set, diff --git a/lustre/mdd/mdd_orphans.c b/lustre/mdd/mdd_orphans.c index 2ac658b..24a134e 100644 --- a/lustre/mdd/mdd_orphans.c +++ b/lustre/mdd/mdd_orphans.c @@ -150,7 +150,7 @@ static int orph_index_iterate(const struct lu_env *env, { struct dt_object *dt_obj = mdd->mdd_orphans; struct dt_it *it; - struct dt_it_ops *iops; + const struct dt_it_ops *iops; struct orph_key *key = orph_key_empty(env, 0); int result; ENTRY; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 6a3fad4..37bddb3 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -162,7 +162,7 @@ static struct mdt_device *mdt_dev(struct lu_device *d); static int mdt_regular_handle(struct ptlrpc_request *req); static int mdt_unpack_req_pack_rep(struct mdt_thread_info *info, __u32 flags); -static struct lu_object_operations mdt_obj_ops; +static const struct lu_object_operations mdt_obj_ops; int mdt_get_disposition(struct ldlm_reply *rep, int flag) { @@ -1056,7 +1056,7 @@ out_shrink: return rc; } -static struct lu_device_operations mdt_lu_ops; +static const struct lu_device_operations mdt_lu_ops; static int lu_device_is_mdt(struct lu_device *d) { @@ -4230,21 +4230,14 @@ static void mdt_object_free(const struct lu_env *env, struct lu_object *o) EXIT; } -static int mdt_object_print(const struct lu_env *env, void *cookie, - lu_printer_t p, const struct lu_object *o) -{ - return (*p)(env, cookie, LUSTRE_MDT_NAME"-object@%p", o); -} - -static struct lu_device_operations mdt_lu_ops = { +static const struct lu_device_operations mdt_lu_ops = { .ldo_object_alloc = mdt_object_alloc, .ldo_process_config = mdt_process_config }; -static struct lu_object_operations mdt_obj_ops = { +static const struct lu_object_operations mdt_obj_ops = { .loo_object_init = mdt_object_init, - .loo_object_free = mdt_object_free, - .loo_object_print = mdt_object_print + .loo_object_free = mdt_object_free }; /* mds_connect_internal */ diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index ead3bfb..4ddbf7c 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -402,7 +402,8 @@ static inline void mdt_trans_add_cb(const struct thandle *th, txi->txi_cb_count++; } -static inline struct md_device_operations *mdt_child_ops(struct mdt_device * m) +static inline const struct md_device_operations * +mdt_child_ops(struct mdt_device * m) { LASSERT(m->mdt_child); return m->mdt_child->md_ops; diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index ee58e92..5d9a155 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -216,16 +216,16 @@ static struct thandle *osd_trans_start (const struct lu_env *env, struct txn_param *p); static journal_t *osd_journal (const struct osd_device *dev); -static struct lu_device_type_operations osd_device_type_ops; +static const struct lu_device_type_operations osd_device_type_ops; static struct lu_device_type osd_device_type; -static struct lu_object_operations osd_lu_obj_ops; +static const struct lu_object_operations osd_lu_obj_ops; static struct obd_ops osd_obd_device_ops; -static struct lu_device_operations osd_lu_ops; +static const struct lu_device_operations osd_lu_ops; static struct lu_context_key osd_key; -static struct dt_object_operations osd_obj_ops; -static struct dt_body_operations osd_body_ops; -static struct dt_index_operations osd_index_ops; -static struct dt_index_operations osd_index_compat_ops; +static const struct dt_object_operations osd_obj_ops; +static const struct dt_body_operations osd_body_ops; +static const struct dt_index_operations osd_index_ops; +static const struct dt_index_operations osd_index_compat_ops; struct osd_thandle { struct thandle ot_super; @@ -778,7 +778,7 @@ static int osd_credit_get(const struct lu_env *env, struct dt_device *d, return osd_dto_credits[op]; } -static struct dt_device_operations osd_dt_ops = { +static const struct dt_device_operations osd_dt_ops = { .dt_root_get = osd_root_get, .dt_statfs = osd_statfs, .dt_trans_start = osd_trans_start, @@ -1511,7 +1511,7 @@ static int osd_object_sync(const struct lu_env *env, struct dt_object *dt) RETURN(rc); } -static struct dt_object_operations osd_obj_ops = { +static const struct dt_object_operations osd_obj_ops = { .do_read_lock = osd_object_read_lock, .do_write_lock = osd_object_write_lock, .do_read_unlock = osd_object_read_unlock, @@ -1584,7 +1584,7 @@ static ssize_t osd_write(const struct lu_env *env, struct dt_object *dt, return result; } -static struct dt_body_operations osd_body_ops = { +static const struct dt_body_operations osd_body_ops = { .dbo_read = osd_read, .dbo_write = osd_write }; @@ -1937,7 +1937,7 @@ static int osd_it_load(const struct lu_env *env, return iam_it_load(&it->oi_it, hash); } -static struct dt_index_operations osd_index_ops = { +static const struct dt_index_operations osd_index_ops = { .dio_lookup = osd_index_lookup, .dio_insert = osd_index_insert, .dio_delete = osd_index_delete, @@ -2538,7 +2538,7 @@ static int osd_object_invariant(const struct lu_object *l) return osd_invariant(osd_obj(l)); } -static struct lu_object_operations osd_lu_obj_ops = { +static const 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, @@ -2547,16 +2547,19 @@ static struct lu_object_operations osd_lu_obj_ops = { .loo_object_invariant = osd_object_invariant }; -static struct lu_device_operations osd_lu_ops = { +static const struct lu_device_operations osd_lu_ops = { .ldo_object_alloc = osd_object_alloc, .ldo_process_config = osd_process_config, .ldo_recovery_complete = osd_recovery_complete }; -static struct lu_device_type_operations osd_device_type_ops = { +static const struct lu_device_type_operations osd_device_type_ops = { .ldto_init = osd_type_init, .ldto_fini = osd_type_fini, + .ldto_start = osd_type_start, + .ldto_stop = osd_type_stop, + .ldto_device_alloc = osd_device_alloc, .ldto_device_free = osd_device_free,