From 9d6ad4d409e029babb9762a602643bd5a93a3c2f Mon Sep 17 00:00:00 2001 From: nikita Date: Wed, 12 Apr 2006 12:41:14 +0000 Subject: [PATCH] add const qualifiers --- lustre/include/linux/obd_class.h | 33 ++++++++++++++++++--------------- lustre/include/lustre/lustre_user.h | 4 ++-- lustre/obdclass/genops.c | 27 +++++++++++++++++---------- lustre/obdclass/lustre_peer.c | 8 ++++---- lustre/obdclass/obd_config.c | 4 ++-- 5 files changed, 43 insertions(+), 33 deletions(-) diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index ab0eaf2..af9a055 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -53,21 +53,24 @@ extern spinlock_t obd_dev_lock; extern struct obd_device *class_conn2obd(struct lustre_handle *); extern struct obd_device *class_exp2obd(struct obd_export *); +struct lu_device_type; + /* genops.c */ struct obd_export *class_conn2export(struct lustre_handle *); -int class_register_type(struct obd_ops *ops, struct lprocfs_vars *, char *nm); -int class_unregister_type(char *nm); +int class_register_type(struct obd_ops *ops, struct lprocfs_vars *, + const char *nm, struct lu_device_type *ldt); +int class_unregister_type(const char *nm); struct obd_device *class_newdev(struct obd_type *type, char *name); void class_release_dev(struct obd_device *obd); -int class_name2dev(char *name); -struct obd_device *class_name2obd(char *name); +int class_name2dev(const char *name); +struct obd_device *class_name2obd(const char *name); int class_uuid2dev(struct obd_uuid *uuid); struct obd_device *class_uuid2obd(struct obd_uuid *uuid); void class_obd_list(void); struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid, - char * typ_name, + const char * typ_name, struct obd_uuid *grp_uuid); struct obd_device * class_find_client_notype(struct obd_uuid *tgt_uuid, struct obd_uuid *grp_uuid); @@ -93,8 +96,8 @@ void ping_evictor_stop(void); char *obd_export_nid2str(struct obd_export *exp); -int obd_export_evict_by_nid(struct obd_device *obd, char *nid); -int obd_export_evict_by_uuid(struct obd_device *obd, char *uuid); +int obd_export_evict_by_nid(struct obd_device *obd, const char *nid); +int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid); /* config.c */ int class_process_config(struct lustre_cfg *lcfg); @@ -141,8 +144,8 @@ struct lustre_profile { char * lp_mdc; }; -struct lustre_profile *class_get_profile(char * prof); -void class_del_profile(char *prof); +struct lustre_profile *class_get_profile(const char * prof); +void class_del_profile(const char *prof); /* genops.c */ #define class_export_get(exp) \ @@ -173,8 +176,8 @@ void class_import_put(struct obd_import *); struct obd_import *class_new_import(void); void class_destroy_import(struct obd_import *exp); -struct obd_type *class_search_type(char *name); -struct obd_type *class_get_type(char *name); +struct obd_type *class_search_type(const char *name); +struct obd_type *class_get_type(const char *name); void class_put_type(struct obd_type *type); int class_connect(struct lustre_handle *conn, struct obd_device *obd, struct obd_uuid *cluuid); @@ -1067,7 +1070,7 @@ static inline int obd_san_preprw(int cmd, struct obd_export *exp, return(rc); } -static inline int obd_pin(struct obd_export *exp, struct lu_fid *fid, +static inline int obd_pin(struct obd_export *exp, struct lu_fid *fid, struct obd_client_handle *handle, int flag) { int rc; @@ -1264,9 +1267,9 @@ void class_generate_random_uuid(class_uuid_t uuid); void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out); /* lustre_peer.c */ -int lustre_uuid_to_peer(char *uuid, lnet_nid_t *peer_nid, int index); -int class_add_uuid(char *uuid, __u64 nid); -int class_del_uuid (char *uuid); +int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index); +int class_add_uuid(const char *uuid, __u64 nid); +int class_del_uuid (const char *uuid); void class_init_uuidlist(void); void class_exit_uuidlist(void); diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h index f2b349f..2f1c6df 100644 --- a/lustre/include/lustre/lustre_user.h +++ b/lustre/include/lustre/lustre_user.h @@ -173,13 +173,13 @@ static inline int obd_uuid_empty(struct obd_uuid *uuid) return uuid->uuid[0] == '\0'; } -static inline void obd_str2uuid(struct obd_uuid *uuid, char *tmp) +static inline void obd_str2uuid(struct obd_uuid *uuid, const char *tmp) { strncpy((char *)uuid->uuid, tmp, sizeof(*uuid)); uuid->uuid[sizeof(*uuid) - 1] = '\0'; } -static inline char *obd_uuid2str(struct obd_uuid *uuid) +static inline char *obd_uuid2str(struct obd_uuid *uuid) { if (uuid->uuid[sizeof(*uuid) - 1] != '\0') { /* Obviously not safe, but for printfs, no real harm done...*/ diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 0384e71..89363a7 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -36,6 +36,7 @@ #include #include #include +#include extern struct list_head obd_types; static spinlock_t obd_types_lock = SPIN_LOCK_UNLOCKED; @@ -51,7 +52,7 @@ void (*ptlrpc_abort_inflight_superhack)(struct obd_import *imp); * support functions: we could use inter-module communication, but this * is more portable to other OS's */ -struct obd_type *class_search_type(char *name) +struct obd_type *class_search_type(const char *name) { struct list_head *tmp; struct obd_type *type; @@ -68,13 +69,13 @@ struct obd_type *class_search_type(char *name) return NULL; } -struct obd_type *class_get_type(char *name) +struct obd_type *class_get_type(const char *name) { struct obd_type *type = class_search_type(name); #ifdef CONFIG_KMOD if (!type) { - char *modname = name; + const char *modname = name; if (strcmp(modname, LUSTRE_MDT_NAME) == 0) modname = LUSTRE_MDS_NAME; if (!request_module(modname)) { @@ -97,7 +98,7 @@ void class_put_type(struct obd_type *type) } int class_register_type(struct obd_ops *ops, struct lprocfs_vars *vars, - char *name) + const char *name, struct lu_device_type *ldt) { struct obd_type *type; int rc = 0; @@ -132,6 +133,12 @@ int class_register_type(struct obd_ops *ops, struct lprocfs_vars *vars, GOTO (failed, rc); } #endif + if (ldt != NULL) { + type->typ_lu = ldt; + rc = ldt->ldt_ops->ldto_init(ldt); + if (rc != 0) + GOTO (failed, rc); + } spin_lock(&obd_types_lock); list_add(&type->typ_chain, &obd_types); @@ -148,7 +155,7 @@ int class_register_type(struct obd_ops *ops, struct lprocfs_vars *vars, RETURN(rc); } -int class_unregister_type(char *name) +int class_unregister_type(const char *name) { struct obd_type *type = class_search_type(name); ENTRY; @@ -228,7 +235,7 @@ void class_release_dev(struct obd_device *obd) spin_unlock(&obd_dev_lock); } -int class_name2dev(char *name) +int class_name2dev(const char *name) { int i; @@ -253,7 +260,7 @@ int class_name2dev(char *name) return -1; } -struct obd_device *class_name2obd(char *name) +struct obd_device *class_name2obd(const char *name) { int dev = class_name2dev(name); if (dev < 0) @@ -317,7 +324,7 @@ void class_obd_list(void) specified, then only the client with that uuid is returned, otherwise any client connected to the tgt is returned. */ struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid, - char * typ_name, + const char * typ_name, struct obd_uuid *grp_uuid) { int i; @@ -1239,7 +1246,7 @@ void class_update_export_timer(struct obd_export *exp, time_t extra_delay) EXPORT_SYMBOL(class_update_export_timer); #define EVICT_BATCH 32 -int obd_export_evict_by_nid(struct obd_device *obd, char *nid) +int obd_export_evict_by_nid(struct obd_device *obd, const char *nid) { struct obd_export *doomed_exp[EVICT_BATCH] = { NULL }; struct list_head *p; @@ -1279,7 +1286,7 @@ search_again: } EXPORT_SYMBOL(obd_export_evict_by_nid); -int obd_export_evict_by_uuid(struct obd_device *obd, char *uuid) +int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid) { struct obd_export *doomed_exp = NULL; struct list_head *p; diff --git a/lustre/obdclass/lustre_peer.c b/lustre/obdclass/lustre_peer.c index 40af90a..8a601c1 100644 --- a/lustre/obdclass/lustre_peer.c +++ b/lustre/obdclass/lustre_peer.c @@ -62,7 +62,7 @@ void class_exit_uuidlist(void) class_del_uuid(NULL); } -int lustre_uuid_to_peer(char *uuid, lnet_nid_t *peer_nid, int index) +int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index) { struct list_head *tmp; @@ -85,9 +85,9 @@ int lustre_uuid_to_peer(char *uuid, lnet_nid_t *peer_nid, int index) return -ENOENT; } -/* Add a nid to a niduuid. Multiple nids can be added to a single uuid; +/* Add a nid to a niduuid. Multiple nids can be added to a single uuid; LNET will choose the best one. */ -int class_add_uuid(char *uuid, __u64 nid) +int class_add_uuid(const char *uuid, __u64 nid) { struct uuid_nid_data *data; int nob = strnlen (uuid, PAGE_SIZE) + 1; @@ -121,7 +121,7 @@ int class_add_uuid(char *uuid, __u64 nid) } /* Delete the nids for one uuid if specified, otherwise delete all */ -int class_del_uuid (char *uuid) +int class_del_uuid(const char *uuid) { struct list_head deathrow; struct list_head *tmp; diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 6d564a2..b5ed43c 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -511,7 +511,7 @@ int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg) static LIST_HEAD(lustre_profile_list); -struct lustre_profile *class_get_profile(char * prof) +struct lustre_profile *class_get_profile(const char * prof) { struct lustre_profile *lprof; @@ -568,7 +568,7 @@ out: RETURN(err); } -void class_del_profile(char *prof) +void class_del_profile(const char *prof) { struct lustre_profile *lprof; -- 1.8.3.1