From 9c6d90191a7d7685d98aee7fb49ff6c23e3956ff Mon Sep 17 00:00:00 2001 From: Frank Zago Date: Mon, 29 Sep 2014 21:39:31 -0500 Subject: [PATCH] LU-5396 lov: (and ldlm) make some functions static Some functions and variables are only used in their C file, so reduce their scope. This reduces the code size, and fixes sparse warnings such as: warning: symbol 'proc_lnet_routes' was not declared. Should it be static? warning: symbol 'proc_lnet_routers' was not declared. Should it be static? Some prototypes were removed from C files and added to the proper header. Signed-off-by: Frank Zago Change-Id: I86b7ada5c768f4b875fce55745f7492faabd4617 Reviewed-on: http://review.whamcloud.com/12221 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- lustre/include/lprocfs_status.h | 2 +- lustre/ldlm/ldlm_internal.h | 8 ++++++-- lustre/ldlm/ldlm_lib.c | 3 ++- lustre/ldlm/ldlm_lock.c | 15 ++++++++------- lustre/ldlm/ldlm_lockd.c | 6 ++---- lustre/ldlm/ldlm_pool.c | 4 ++-- lustre/ldlm/ldlm_resource.c | 22 ++++++++++------------ lustre/lov/lov_cl_internal.h | 1 - lustre/lov/lov_dev.c | 2 +- lustre/lov/lov_ea.c | 8 ++++---- lustre/lov/lov_internal.h | 3 ++- lustre/lov/lov_obd.c | 25 ++++++++++++------------- lustre/lov/lov_object.c | 3 ++- lustre/lov/lov_pool.c | 4 ++-- lustre/lov/lproc_lov.c | 2 +- 15 files changed, 55 insertions(+), 53 deletions(-) diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 5b62f8f..afd48bd 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -821,7 +821,7 @@ static const struct file_operations name##_fops = { \ { \ return single_open(file, NULL, PDE_DATA(inode)); \ } \ - struct file_operations name##_##type##_fops = { \ + static const struct file_operations name##_##type##_fops = { \ .open = name##_##type##_open, \ .write = name##_##type##_write, \ .release = lprocfs_single_release, \ diff --git a/lustre/ldlm/ldlm_internal.h b/lustre/ldlm/ldlm_internal.h index 6d2fc61..f6b7757 100644 --- a/lustre/ldlm/ldlm_internal.h +++ b/lustre/ldlm/ldlm_internal.h @@ -43,6 +43,7 @@ extern struct list_head ldlm_srv_namespace_list; extern struct mutex ldlm_cli_namespace_lock; extern struct list_head ldlm_cli_active_namespace_list; extern struct list_head ldlm_cli_inactive_namespace_list; +extern unsigned int ldlm_cancel_unused_locks_before_replay; static inline int ldlm_namespace_nr_read(ldlm_side_t client) { @@ -112,12 +113,16 @@ int ldlm_cancel_lru_local(struct ldlm_namespace *ns, ldlm_cancel_flags_t cancel_flags, int flags); extern unsigned int ldlm_enqueue_min; /* ldlm_resource.c */ +extern struct kmem_cache *ldlm_resource_slab; +extern struct kmem_cache *ldlm_lock_slab; + int ldlm_resource_putref_locked(struct ldlm_resource *res); void ldlm_resource_insert_lock_after(struct ldlm_lock *original, struct ldlm_lock *new); void ldlm_namespace_free_prior(struct ldlm_namespace *ns, struct obd_import *imp, int force); void ldlm_namespace_free_post(struct ldlm_namespace *ns); + /* ldlm_lock.c */ struct ldlm_cb_set_arg { @@ -211,7 +216,6 @@ void l_check_ns_lock(struct ldlm_namespace *ns); void l_check_no_ns_lock(struct ldlm_namespace *ns); extern struct proc_dir_entry *ldlm_svc_proc_dir; -extern struct proc_dir_entry *ldlm_type_proc_dir; struct ldlm_state { struct ptlrpc_service *ldlm_cb_service; @@ -265,7 +269,7 @@ typedef enum ldlm_policy_res ldlm_policy_res_t; struct __##var##__dummy_read {;} /* semicolon catcher */ #define LDLM_POOL_PROC_WRITER(var, type) \ - int lprocfs_wr_##var(struct file *file, \ + static int lprocfs_wr_##var(struct file *file, \ const char __user *buffer, \ unsigned long count, void *data) \ { \ diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 4731969..fc75178 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -2378,7 +2378,8 @@ int target_pack_pool_reply(struct ptlrpc_request *req) } EXPORT_SYMBOL(target_pack_pool_reply); -int target_send_reply_msg(struct ptlrpc_request *req, int rc, int fail_id) +static int target_send_reply_msg(struct ptlrpc_request *req, + int rc, int fail_id) { if (OBD_FAIL_CHECK_ORSET(fail_id & ~OBD_FAIL_ONCE, OBD_FAIL_ONCE)) { DEBUG_REQ(D_ERROR, req, "dropping reply"); diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 72141c8..b5aa5a0 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -350,7 +350,7 @@ void ldlm_lock_touch_in_lru(struct ldlm_lock *lock) * ldlm_lock_destroy, you can never drop your final references on this lock. * Because it's not in the hash table anymore. -phil */ -int ldlm_lock_destroy_internal(struct ldlm_lock *lock) +static int ldlm_lock_destroy_internal(struct ldlm_lock *lock) { ENTRY; @@ -445,7 +445,7 @@ static void lock_handle_free(void *lock, int size) OBD_SLAB_FREE(lock, ldlm_lock_slab, size); } -struct portals_handle_ops lock_handle_ops = { +static struct portals_handle_ops lock_handle_ops = { .hop_addref = lock_handle_addref, .hop_free = lock_handle_free, }; @@ -661,8 +661,8 @@ EXPORT_SYMBOL(ldlm_lock2desc); * * Only add if we have not sent a blocking AST to the lock yet. */ -void ldlm_add_bl_work_item(struct ldlm_lock *lock, struct ldlm_lock *new, - struct list_head *work_list) +static void ldlm_add_bl_work_item(struct ldlm_lock *lock, struct ldlm_lock *new, + struct list_head *work_list) { if (!ldlm_is_ast_sent(lock)) { LDLM_DEBUG(lock, "lock incompatible; sending blocking AST."); @@ -682,7 +682,8 @@ void ldlm_add_bl_work_item(struct ldlm_lock *lock, struct ldlm_lock *new, /** * Add a lock to list of just granted locks to send completion AST to. */ -void ldlm_add_cp_work_item(struct ldlm_lock *lock, struct list_head *work_list) +static void ldlm_add_cp_work_item(struct ldlm_lock *lock, + struct list_head *work_list) { if (!ldlm_is_cp_reqd(lock)) { ldlm_set_cp_reqd(lock); @@ -2192,8 +2193,8 @@ struct export_cl_data { * Iterator function for ldlm_cancel_locks_for_export. * Cancels passed locks. */ -int ldlm_cancel_locks_for_export_cb(cfs_hash_t *hs, cfs_hash_bd_t *bd, - struct hlist_node *hnode, void *data) +static int ldlm_cancel_locks_for_export_cb(cfs_hash_t *hs, cfs_hash_bd_t *bd, + struct hlist_node *hnode, void *data) { struct export_cl_data *ecl = (struct export_cl_data *)data; diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 3a569c9..4244798 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -55,8 +55,6 @@ static char *ldlm_cpts; CFS_MODULE_PARM(ldlm_cpts, "s", charp, 0444, "CPU partitions ldlm threads should run on"); -extern struct kmem_cache *ldlm_resource_slab; -extern struct kmem_cache *ldlm_lock_slab; static struct mutex ldlm_ref_mutex; static int ldlm_refcount; @@ -2478,8 +2476,8 @@ static int ldlm_hpreq_handler(struct ptlrpc_request *req) RETURN(0); } -int ldlm_revoke_lock_cb(cfs_hash_t *hs, cfs_hash_bd_t *bd, - struct hlist_node *hnode, void *data) +static int ldlm_revoke_lock_cb(cfs_hash_t *hs, cfs_hash_bd_t *bd, + struct hlist_node *hnode, void *data) { struct list_head *rpc_list = data; diff --git a/lustre/ldlm/ldlm_pool.c b/lustre/ldlm/ldlm_pool.c index a526f08..cecb2e2 100644 --- a/lustre/ldlm/ldlm_pool.c +++ b/lustre/ldlm/ldlm_pool.c @@ -562,13 +562,13 @@ static int ldlm_cli_pool_shrink(struct ldlm_pool *pl, return ldlm_cancel_lru(ns, nr, LCF_ASYNC, LDLM_CANCEL_SHRINK); } -struct ldlm_pool_ops ldlm_srv_pool_ops = { +static struct ldlm_pool_ops ldlm_srv_pool_ops = { .po_recalc = ldlm_srv_pool_recalc, .po_shrink = ldlm_srv_pool_shrink, .po_setup = ldlm_srv_pool_setup }; -struct ldlm_pool_ops ldlm_cli_pool_ops = { +static struct ldlm_pool_ops ldlm_cli_pool_ops = { .po_recalc = ldlm_cli_pool_recalc, .po_shrink = ldlm_cli_pool_shrink }; diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index bed49ee..4c9b81a 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -61,15 +61,13 @@ struct list_head ldlm_cli_active_namespace_list; /* Client namespaces that don't have any locks in them */ struct list_head ldlm_cli_inactive_namespace_list; -struct proc_dir_entry *ldlm_type_proc_dir = NULL; -struct proc_dir_entry *ldlm_ns_proc_dir = NULL; -struct proc_dir_entry *ldlm_svc_proc_dir = NULL; - -extern unsigned int ldlm_cancel_unused_locks_before_replay; +static struct proc_dir_entry *ldlm_type_proc_dir; +static struct proc_dir_entry *ldlm_ns_proc_dir; +struct proc_dir_entry *ldlm_svc_proc_dir; /* during debug dump certain amount of granted locks for one resource to avoid * DDOS. */ -unsigned int ldlm_dump_granted_max = 256; +static unsigned int ldlm_dump_granted_max = 256; #ifdef LPROCFS static ssize_t @@ -312,7 +310,7 @@ static ssize_t lprocfs_elc_seq_write(struct file *file, } LPROC_SEQ_FOPS(lprocfs_elc); -void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) +static void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) { if (ns->ns_proc_dir_entry == NULL) CERROR("dlm namespace %s has no procfs dir?\n", @@ -324,7 +322,7 @@ void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) lprocfs_free_stats(&ns->ns_stats); } -int ldlm_namespace_proc_register(struct ldlm_namespace *ns) +static int ldlm_namespace_proc_register(struct ldlm_namespace *ns) { struct lprocfs_seq_vars lock_vars[2]; char lock_name[MAX_STRING_SIZE + 1]; @@ -481,7 +479,7 @@ static void ldlm_res_hop_put(cfs_hash_t *hs, struct hlist_node *hnode) ldlm_resource_putref(res); } -cfs_hash_ops_t ldlm_ns_hash_ops = { +static cfs_hash_ops_t ldlm_ns_hash_ops = { .hs_hash = ldlm_res_hop_hash, .hs_key = ldlm_res_hop_key, .hs_keycmp = ldlm_res_hop_keycmp, @@ -492,7 +490,7 @@ cfs_hash_ops_t ldlm_ns_hash_ops = { .hs_put = ldlm_res_hop_put }; -cfs_hash_ops_t ldlm_ns_fid_hash_ops = { +static cfs_hash_ops_t ldlm_ns_fid_hash_ops = { .hs_hash = ldlm_res_hop_fid_hash, .hs_key = ldlm_res_hop_key, .hs_keycmp = ldlm_res_hop_keycmp, @@ -513,7 +511,7 @@ typedef struct { cfs_hash_ops_t *nsd_hops; } ldlm_ns_hash_def_t; -ldlm_ns_hash_def_t ldlm_ns_hash_defs[] = +static ldlm_ns_hash_def_t ldlm_ns_hash_defs[] = { { .nsd_type = LDLM_NS_TYPE_MDC, @@ -962,7 +960,7 @@ void ldlm_namespace_get(struct ldlm_namespace *ns) EXPORT_SYMBOL(ldlm_namespace_get); /* This is only for callers that care about refcount */ -int ldlm_namespace_get_return(struct ldlm_namespace *ns) +static int ldlm_namespace_get_return(struct ldlm_namespace *ns) { return atomic_inc_return(&ns->ns_bref); } diff --git a/lustre/lov/lov_cl_internal.h b/lustre/lov/lov_cl_internal.h index 787e7eb..93bec95 100644 --- a/lustre/lov/lov_cl_internal.h +++ b/lustre/lov/lov_cl_internal.h @@ -770,4 +770,3 @@ static inline struct lov_layout_raid0 *lov_r0(struct lov_object *lov) /** @} lov */ #endif - diff --git a/lustre/lov/lov_dev.c b/lustre/lov/lov_dev.c index 8ea9185..e874a7d 100644 --- a/lustre/lov/lov_dev.c +++ b/lustre/lov/lov_dev.c @@ -58,7 +58,7 @@ struct kmem_cache *lovsub_req_kmem; struct kmem_cache *lov_lock_link_kmem; /** Lock class of lov_device::ld_mutex. */ -struct lock_class_key cl_lov_device_mutex_class; +static struct lock_class_key cl_lov_device_mutex_class; struct lu_kmem_descr lov_caches[] = { { diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c index 075c491..55d71a2 100644 --- a/lustre/lov/lov_ea.c +++ b/lustre/lov/lov_ea.c @@ -198,8 +198,8 @@ static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes, return lsm_lmm_verify_common(lmm, lmm_bytes, *stripe_count); } -int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, - struct lov_mds_md_v1 *lmm) +static int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, + struct lov_mds_md_v1 *lmm) { struct lov_oinfo *loi; int i; @@ -278,8 +278,8 @@ static int lsm_lmm_verify_v3(struct lov_mds_md *lmmv1, int lmm_bytes, *stripe_count); } -int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm, - struct lov_mds_md *lmmv1) +static int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm, + struct lov_mds_md *lmmv1) { struct lov_mds_md_v3 *lmm; struct lov_oinfo *loi; diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 9509ef6..5d5b793 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -114,6 +114,8 @@ struct lov_request_set { extern struct kmem_cache *lov_oinfo_slab; +extern struct lu_kmem_descr lov_caches[]; + void lov_finish_set(struct lov_request_set *set); static inline void lov_put_reqset(struct lov_request_set *set) @@ -233,7 +235,6 @@ int lov_pool_del(struct obd_device *obd, char *poolname); int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname); int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname); void lov_dump_pool(int level, struct pool_desc *pool); -void lov_pool_putref(struct pool_desc *pool); static inline struct lov_stripe_md *lsm_addref(struct lov_stripe_md *lsm) { diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 1d9fe20..7f3cd20 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1544,9 +1544,10 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, * \param fm_end logical end of mapping * \param start_stripe starting stripe will be returned in this */ -obd_size fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap, - struct lov_stripe_md *lsm, obd_size fm_start, - obd_size fm_end, int *start_stripe) +static obd_size fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap, + struct lov_stripe_md *lsm, + obd_size fm_start, + obd_size fm_end, int *start_stripe) { obd_size local_end = fiemap->fm_extents[0].fe_logical; obd_off lun_start, lun_end; @@ -1606,9 +1607,9 @@ obd_size fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap, * * \retval last_stripe return the last stripe of the mapping */ -int fiemap_calc_last_stripe(struct lov_stripe_md *lsm, obd_size fm_start, - obd_size fm_end, int start_stripe, - int *stripe_count) +static int fiemap_calc_last_stripe(struct lov_stripe_md *lsm, obd_size fm_start, + obd_size fm_end, int start_stripe, + int *stripe_count) { int last_stripe; obd_off obd_start, obd_end; @@ -1642,10 +1643,10 @@ int fiemap_calc_last_stripe(struct lov_stripe_md *lsm, obd_size fm_start, * \param ext_count number of extents to be copied * \param current_extent where to start copying in main extent array */ -void fiemap_prepare_and_copy_exts(struct ll_user_fiemap *fiemap, - struct ll_fiemap_extent *lcl_fm_ext, - int ost_index, unsigned int ext_count, - int current_extent) +static void fiemap_prepare_and_copy_exts(struct ll_user_fiemap *fiemap, + struct ll_fiemap_extent *lcl_fm_ext, + int ost_index, unsigned int ext_count, + int current_extent) { char *to; int ext; @@ -2168,9 +2169,7 @@ static struct obd_ops lov_obd_ops = { struct kmem_cache *lov_oinfo_slab; -extern struct lu_kmem_descr lov_caches[]; - -int __init lov_init(void) +static int __init lov_init(void) { bool enable_proc = true; struct obd_type *type; diff --git a/lustre/lov/lov_object.c b/lustre/lov/lov_object.c index 61b5a9f..f7ef365 100644 --- a/lustre/lov/lov_object.c +++ b/lustre/lov/lov_object.c @@ -42,6 +42,7 @@ #define DEBUG_SUBSYSTEM S_LOV #include "lov_cl_internal.h" +#include "lclient.h" /** \addtogroup lov * @{ @@ -604,7 +605,7 @@ const static struct lov_layout_operations lov_dispatch[] = { /** * Return lov_layout_type associated with a given lsm */ -enum lov_layout_type lov_type(struct lov_stripe_md *lsm) +static enum lov_layout_type lov_type(struct lov_stripe_md *lsm) { if (lsm == NULL) return LLT_EMPTY; diff --git a/lustre/lov/lov_pool.c b/lustre/lov/lov_pool.c index 37be01e..564d13d 100644 --- a/lustre/lov/lov_pool.c +++ b/lustre/lov/lov_pool.c @@ -58,7 +58,7 @@ static void lov_pool_getref(struct pool_desc *pool) atomic_inc(&pool->pool_refcount); } -void lov_pool_putref(struct pool_desc *pool) +static void lov_pool_putref(struct pool_desc *pool) { CDEBUG(D_INFO, "pool %p\n", pool); if (atomic_dec_and_test(&pool->pool_refcount)) { @@ -71,7 +71,7 @@ void lov_pool_putref(struct pool_desc *pool) } } -void lov_pool_putref_locked(struct pool_desc *pool) +static void lov_pool_putref_locked(struct pool_desc *pool) { CDEBUG(D_INFO, "pool %p\n", pool); LASSERT(atomic_read(&pool->pool_refcount) > 1); diff --git a/lustre/lov/lproc_lov.c b/lustre/lov/lproc_lov.c index e8f9abb..77a429e 100644 --- a/lustre/lov/lproc_lov.c +++ b/lustre/lov/lproc_lov.c @@ -236,7 +236,7 @@ static int lov_tgt_seq_show(struct seq_file *p, void *v) tgt->ltd_active ? "" : "IN"); } -struct seq_operations lov_tgt_sops = { +static const struct seq_operations lov_tgt_sops = { .start = lov_tgt_seq_start, .stop = lov_tgt_seq_stop, .next = lov_tgt_seq_next, -- 1.8.3.1