Whamcloud - gitweb
LU-5396 lov: (and ldlm) make some functions static 21/12221/10
authorFrank Zago <fzago@cray.com>
Tue, 30 Sep 2014 02:39:31 +0000 (21:39 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 Dec 2014 08:11:43 +0000 (08:11 +0000)
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 <fzago@cray.com>
Change-Id: I86b7ada5c768f4b875fce55745f7492faabd4617
Reviewed-on: http://review.whamcloud.com/12221
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
15 files changed:
lustre/include/lprocfs_status.h
lustre/ldlm/ldlm_internal.h
lustre/ldlm/ldlm_lib.c
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_pool.c
lustre/ldlm/ldlm_resource.c
lustre/lov/lov_cl_internal.h
lustre/lov/lov_dev.c
lustre/lov/lov_ea.c
lustre/lov/lov_internal.h
lustre/lov/lov_obd.c
lustre/lov/lov_object.c
lustre/lov/lov_pool.c
lustre/lov/lproc_lov.c

index 5b62f8f..afd48bd 100644 (file)
@@ -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,                      \
index 6d2fc61..f6b7757 100644 (file)
@@ -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)           \
        {                                                               \
index 4731969..fc75178 100644 (file)
@@ -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");
index 72141c8..b5aa5a0 100644 (file)
@@ -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;
index 3a569c9..4244798 100644 (file)
@@ -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;
index a526f08..cecb2e2 100644 (file)
@@ -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
 };
index bed49ee..4c9b81a 100644 (file)
@@ -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);
 }
index 787e7eb..93bec95 100644 (file)
@@ -770,4 +770,3 @@ static inline struct lov_layout_raid0 *lov_r0(struct lov_object *lov)
 /** @} lov */
 
 #endif
-
index 8ea9185..e874a7d 100644 (file)
@@ -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[] = {
         {
index 075c491..55d71a2 100644 (file)
@@ -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;
index 9509ef6..5d5b793 100644 (file)
@@ -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)
 {
index 1d9fe20..7f3cd20 100644 (file)
@@ -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;
index 61b5a9f..f7ef365 100644 (file)
@@ -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;
index 37be01e..564d13d 100644 (file)
@@ -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);
index e8f9abb..77a429e 100644 (file)
@@ -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,