Whamcloud - gitweb
LU-18959 misc: Mark symbols static to prevent namespace pollution 81/59081/3
authorOleg Drokin <green@whamcloud.com>
Sun, 4 May 2025 20:19:30 +0000 (16:19 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 7 May 2025 21:15:24 +0000 (21:15 +0000)
Sparse highlighted a number of symbols as not used outside
the file they are defined in. And a couple where they were used,
but the proper header was not included, fix these issues:

libcfs/libcfs/tracefile.c:37 sparse warning: symbol 'cfs_trace_data' was not declared. Should it be static?
libcfs/libcfs/tracefile.c:49 sparse warning: symbol 'tctl_task' was not declared. Should it be static?
lnet/lnet/lnet_rdma.c:24 sparse warning: symbol 'nvfs_shutdown' was not declared. Should it be static?
lnet/lnet/lnet_rdma.c:25 sparse warning: symbol 'nvfs_ops' was not declared. Should it be static?
lnet/lnet/lnet_rdma.c:26 sparse warning: symbol 'nvfs_n_ops' was not declared. Should it be static?
lustre/ldlm/ldlm_lockd.c:44 sparse warning: symbol 'ldlm_kobj' was not declared. Should it be static?
lustre/lfsck/lfsck_namespace.c:6916 sparse warning: symbol 'lfsck_namespace_assistant_ops' was not declared. Should it be static?
lustre/lmv/lproc_lmv.c:409 sparse warning: symbol 'lprocfs_lmv_obd_vars' was not declared. Should it be static?
lustre/lod/lod_dev.c:160 sparse warning: symbol 'lod_txn_callback_kmem' was not declared. Should it be static?
lustre/mdc/lproc_mdc.c:572 sparse warning: symbol 'ldebugfs_mdc_obd_vars' was not declared. Should it be static?
lustre/mdc/mdc_batch.c:189 sparse warning: symbol 'mdc_update_interpreters' was not declared. Should it be static?
lustre/mdc/mdc_dev.c:1672 sparse warning: symbol 'mdc_lu_ops' was not declared. Should it be static?
lustre/mdt/mdt_mds.c:63 sparse warning: symbol 'mds_max_io_threads' was not declared. Should it be static?
lustre/mgc/lproc_mgc.c:39 sparse warning: symbol 'ldebugfs_mgc_obd_vars' was not declared. Should it be static?
lustre/obdclass/hash.c:98 sparse warning: symbol 'cfs_rehash_wq' was not declared. Should it be static?
lustre/obdclass/jobid.c:33 sparse warning: symbol 'jobid_hash_lock' was not declared. Should it be static?
lustre/obdclass/kernelcomm.c:273 sparse warning: symbol 'stats_params' was not declared. Should it be static?
lustre/obdclass/lprocfs_status.c:2610 sparse warning: symbol 'cksum_name' was not declared. Should it be static?
lustre/obdclass/lprocfs_status_server.c:540 sparse warning: symbol 'ldebugfs_obd_exports_vars' was not declared. Should it be static?
lustre/obdclass/lu_object.c:1883 sparse warning: symbol 'lu_env_rhash' was not declared. Should it be static?
lustre/obdclass/scrub.c:464 sparse warning: symbol 'scrub_status_names' was not declared. Should it be static?
lustre/obdclass/scrub.c:475 sparse warning: symbol 'scrub_flags_names' was not declared. Should it be static?
lustre/obdclass/scrub.c:483 sparse warning: symbol 'scrub_param_names' was not declared. Should it be static?
lustre/ofd/ofd_oss.c:28 sparse warning: symbol 'oss_max_threads' was not declared. Should it be static?
lustre/osc/lproc_osc.c:664 sparse warning: symbol 'ldebugfs_osc_obd_vars' was not declared. Should it be static?
lustre/osd-ldiskfs/osd_handler.c:81 sparse warning: symbol 'ldiskfs_flush_descriptors_seconds' was not declared. Should it be static?
lustre/osd-ldiskfs/osd_handler.c:84 sparse warning: symbol 'ldiskfs_delayed_unlink_blocks' was not declared. Should it be static?
lustre/osd-ldiskfs/osd_handler.c:90 sparse warning: symbol 'osd_itea_cachep' was not declared. Should it be static?
lustre/osd-ldiskfs/osd_lproc.c:810 sparse warning: symbol 'ldebugfs_osd_obd_vars' was not declared. Should it be static?
lustre/osd-zfs/osd_lproc.c:384 sparse warning: symbol 'ldebugfs_osd_obd_vars' was not declared. Should it be static?
lustre/ptlrpc/nodemap_lproc.c:23 sparse warning: symbol 'nodemap_root' was not declared. Should it be static?
lustre/ptlrpc/nrs_tbf.c:2284 sparse warning: symbol 'nrs_tbf_opcode_ops' was not declared. Should it be static?
lustre/ptlrpc/nrs_tbf.c:2598 sparse warning: symbol 'nrs_tbf_uid_ops' was not declared. Should it be static?
lustre/ptlrpc/nrs_tbf.c:2611 sparse warning: symbol 'nrs_tbf_gid_ops' was not declared. Should it be static?
lustre/quota/lquota_lib.c:23 sparse warning: symbol 'lquota_caches' was not declared. Should it be static?
lustre/quota/qsd_lib.c:39 sparse warning: symbol 'qsd_caches' was not declared. Should it be static?
lustre/target/tgt_grant.c:61 sparse warning: symbol 'lbug_on_grant_miscount' was not declared. Should it be static?
lustre/target/tgt_handler.c:1576 sparse warning: symbol 'tgt_lfsck_in_notify' was not declared. Should it be static?
lustre/target/tgt_main.c:39 sparse warning: symbol 'sync_lock_cancel_show' was not declared. Should it be static?
lustre/target/tgt_main.c:72 sparse warning: symbol 'sync_lock_cancel_store' was not declared. Should it be static?

Change-Id: Ibdf617161fe481ddd6a2905e60890cb23ed59733
Test-Parameters: trivial
Signed-off-by: Oleg Drokin <green@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59081
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Timothy Day <timday@amazon.com>
29 files changed:
libcfs/libcfs/tracefile.c
lnet/lnet/lnet_rdma.c
lustre/ldlm/ldlm_lockd.c
lustre/lfsck/lfsck_namespace.c
lustre/lmv/lproc_lmv.c
lustre/lod/lod_dev.c
lustre/mdc/lproc_mdc.c
lustre/mdc/mdc_batch.c
lustre/mdc/mdc_dev.c
lustre/mdt/mdt_mds.c
lustre/mgc/lproc_mgc.c
lustre/obdclass/hash.c
lustre/obdclass/jobid.c
lustre/obdclass/kernelcomm.c
lustre/obdclass/lprocfs_status.c
lustre/obdclass/lprocfs_status_server.c
lustre/obdclass/lu_object.c
lustre/obdclass/scrub.c
lustre/ofd/ofd_oss.c
lustre/osc/lproc_osc.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_lproc.c
lustre/osd-zfs/osd_lproc.c
lustre/ptlrpc/nodemap_lproc.c
lustre/ptlrpc/nrs_tbf.c
lustre/quota/lquota_lib.c
lustre/target/tgt_grant.c
lustre/target/tgt_handler.c
lustre/target/tgt_main.c

index 4084da9..c967598 100644 (file)
@@ -34,7 +34,7 @@ enum cfs_trace_buf_type {
        CFS_TCD_TYPE_CNT
 };
 
-union cfs_trace_data_union (*cfs_trace_data[CFS_TCD_TYPE_CNT])[NR_CPUS] __cacheline_aligned;
+static union cfs_trace_data_union (*cfs_trace_data[CFS_TCD_TYPE_CNT])[NR_CPUS] __cacheline_aligned;
 
 /* Pages containing records already processed by daemon.
  * Link via ->lru, use size in ->private
@@ -46,7 +46,7 @@ static long daemon_pages_max;
 char cfs_tracefile[TRACEFILE_NAME_SIZE];
 long long cfs_tracefile_size = CFS_TRACEFILE_SIZE;
 
-struct task_struct *tctl_task;
+static struct task_struct *tctl_task;
 
 static atomic_t cfs_tage_allocated = ATOMIC_INIT(0);
 static DECLARE_RWSEM(cfs_tracefile_sem);
index af5176c..b0eaad4 100644 (file)
@@ -21,9 +21,9 @@
 
 #define ERROR_PRINT_DEADLINE 3600
 
-atomic_t nvfs_shutdown = ATOMIC_INIT(1);
-struct nvfs_dma_rw_ops *nvfs_ops = NULL;
-struct percpu_counter nvfs_n_ops;
+static atomic_t nvfs_shutdown = ATOMIC_INIT(1);
+static struct nvfs_dma_rw_ops *nvfs_ops;
+static struct percpu_counter nvfs_n_ops;
 
 static inline long nvfs_count_ops(void)
 {
index eacd59d..786aedf 100644 (file)
@@ -41,7 +41,7 @@ MODULE_PARM_DESC(ldlm_cpts, "CPU partitions ldlm threads should run on");
 static DEFINE_MUTEX(ldlm_ref_mutex);
 static int ldlm_refcount;
 
-struct kobject *ldlm_kobj;
+static struct kobject *ldlm_kobj;
 struct kset *ldlm_ns_kset;
 struct kset *ldlm_svc_kset;
 
index eef586b..49e60c2 100644 (file)
@@ -6913,7 +6913,7 @@ out:
        EXIT;
 }
 
-const struct lfsck_assistant_operations lfsck_namespace_assistant_ops = {
+static const struct lfsck_assistant_operations lfsck_namespace_assistant_ops = {
        .la_handler_p1          = lfsck_namespace_assistant_handler_p1,
        .la_handler_p2          = lfsck_namespace_assistant_handler_p2,
        .la_fill_pos            = lfsck_namespace_assistant_fill_pos,
index 85acd1f..013ce6f 100644 (file)
@@ -406,7 +406,7 @@ static const struct proc_ops lmv_proc_target_fops = {
        .proc_release   = seq_release,
 };
 
-struct lprocfs_vars lprocfs_lmv_obd_vars[] = {
+static struct lprocfs_vars lprocfs_lmv_obd_vars[] = {
        { .name =       "qos_exclude_prefixes",
          .fops =       &qos_exclude_prefixes_fops },
        { .name =       "target_obd",
index 07bd014..4d0cf09 100644 (file)
@@ -157,7 +157,7 @@ int lod_fld_lookup(const struct lu_env *env, struct lod_device *lod,
 struct kmem_cache *lod_object_kmem;
 
 /* Slab for dt_txn_callback */
-struct kmem_cache *lod_txn_callback_kmem;
+static struct kmem_cache *lod_txn_callback_kmem;
 static struct lu_kmem_descr lod_caches[] = {
        {
                .ckd_cache = &lod_object_kmem,
index a471de7..f191749 100644 (file)
@@ -569,7 +569,7 @@ LDEBUGFS_SEQ_FOPS_RO_TYPE(mdc, timeouts);
 LDEBUGFS_SEQ_FOPS_RO_TYPE(mdc, state);
 LDEBUGFS_SEQ_FOPS_RW_TYPE(mdc, import);
 
-struct ldebugfs_vars ldebugfs_mdc_obd_vars[] = {
+static struct ldebugfs_vars ldebugfs_mdc_obd_vars[] = {
        { .name =       "connect_flags",
          .fops =       &mdc_connect_flags_fops },
        { .name =       "mds_server_uuid",
index 1daa6fb..a10f5a1 100644 (file)
@@ -186,7 +186,7 @@ out:
        return item->mop_cb(item, rc);
 }
 
-object_update_interpret_t mdc_update_interpreters[MD_OP_MAX] = {
+static object_update_interpret_t mdc_update_interpreters[MD_OP_MAX] = {
        [MD_OP_GETATTR] = mdc_batch_getattr_interpret,
 };
 
index 5990487..d064b6b 100644 (file)
@@ -1669,7 +1669,7 @@ static int mdc_process_config(const struct lu_env *env, struct lu_device *d,
        return count > 0 ? 0 : count;
 }
 
-const 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,
        .ldo_recovery_complete = NULL,
index 3529d49..cbfaad0 100644 (file)
@@ -60,7 +60,7 @@ module_param(mds_cpu_bind, uint, 0444);
 MODULE_PARM_DESC(mds_cpu_bind,
                 "bind MDS threads to particular CPU partitions");
 
-int mds_max_io_threads = 512;
+static int mds_max_io_threads = 512;
 module_param(mds_max_io_threads, int, 0444);
 MODULE_PARM_DESC(mds_max_io_threads,
                 "maximum number of MDS IO service threads");
index 3490c64..bd6a3ee 100644 (file)
@@ -36,7 +36,7 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v)
 
 LDEBUGFS_SEQ_FOPS_RO(mgc_ir_state);
 
-struct ldebugfs_vars ldebugfs_mgc_obd_vars[] = {
+static struct ldebugfs_vars ldebugfs_mgc_obd_vars[] = {
        { .name =       "connect_flags",
          .fops =       &mgc_connect_flags_fops },
        { .name =       "mgs_server_uuid",
index 24cc517..7c2a6cb 100644 (file)
@@ -95,7 +95,7 @@ module_param(warn_on_depth, uint, 0644);
 MODULE_PARM_DESC(warn_on_depth, "warning when hash depth is high.");
 #endif
 
-struct workqueue_struct *cfs_rehash_wq;
+static struct workqueue_struct *cfs_rehash_wq;
 
 int cfs_hash_init(void)
 {
index 38d5fef..faf218f 100644 (file)
@@ -30,7 +30,7 @@
 
 static struct cfs_hash *jobid_hash;
 static struct cfs_hash_ops jobid_hash_ops;
-spinlock_t jobid_hash_lock;
+static spinlock_t jobid_hash_lock;
 
 #define RESCAN_INTERVAL 30
 #define DELETE_INTERVAL 300
index 06f7733..bdb2d4d 100644 (file)
@@ -270,7 +270,7 @@ static int lustre_device_done(struct netlink_callback *cb)
        return 0;
 }
 
-struct ln_key_list stats_params = {
+static struct ln_key_list stats_params = {
        .lkl_maxattr    = LUSTRE_PARAM_ATTR_MAX,
        .lkl_list       = {
                [LUSTRE_PARAM_ATTR_HDR] = {
index 1a00a5e..259c1fc 100644 (file)
@@ -19,6 +19,7 @@
 #include <obd_class.h>
 #include <lprocfs_status.h>
 #include <lustre_kernelcomm.h>
+#include <obd_cksum.h>
 
 #ifdef CONFIG_PROC_FS
 
index 683d0ab..07141fb 100644 (file)
@@ -537,7 +537,7 @@ ldebugfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
 }
 EXPORT_SYMBOL(ldebugfs_nid_stats_clear_seq_write);
 
-struct ldebugfs_vars ldebugfs_obd_exports_vars[] = {
+static struct ldebugfs_vars ldebugfs_obd_exports_vars[] = {
        { .name =       "nodemap",
          .fops =       &ldebugfs_exp_nodemap_fops      },
        { .name =       "uuid",
index ef88dd0..b4cf710 100644 (file)
@@ -1878,7 +1878,7 @@ static const struct rhashtable_params lu_env_rhash_params = {
        .head_offset = offsetof(struct lu_env_item, lei_linkage),
 };
 
-struct rhashtable lu_env_rhash;
+static struct rhashtable lu_env_rhash;
 
 struct lu_env_percpu {
        struct task_struct *lep_task;
index e417c7b..28488f2 100644 (file)
@@ -461,7 +461,7 @@ void scrub_stop(struct lustre_scrub *scrub)
 }
 EXPORT_SYMBOL(scrub_stop);
 
-const char *const scrub_status_names[] = {
+static const char *const scrub_status_names[] = {
        "init",
        "scanning",
        "completed",
@@ -472,7 +472,7 @@ const char *const scrub_status_names[] = {
        NULL
 };
 
-const char *const scrub_flags_names[] = {
+static const char *const scrub_flags_names[] = {
        "recreated",
        "inconsistent",
        "auto",
@@ -480,7 +480,7 @@ const char *const scrub_flags_names[] = {
        NULL
 };
 
-const char *const scrub_param_names[] = {
+static const char *const scrub_param_names[] = {
        "failout",
        "dryrun",
        NULL
index 218b51b..8ec8287 100644 (file)
@@ -25,7 +25,7 @@
 
 #define OSS_SERVICE_WATCHDOG_FACTOR 2
 
-int oss_max_threads = 512;
+static int oss_max_threads = 512;
 module_param(oss_max_threads, int, 0444);
 MODULE_PARM_DESC(oss_max_threads, "maximum number of OSS service threads");
 
index 6e7b4dc..29977a2 100644 (file)
@@ -661,7 +661,7 @@ LDEBUGFS_SEQ_FOPS_RO_TYPE(osc, timeouts);
 LDEBUGFS_SEQ_FOPS_RO_TYPE(osc, state);
 LDEBUGFS_SEQ_FOPS_RW_TYPE(osc, import);
 
-struct ldebugfs_vars ldebugfs_osc_obd_vars[] = {
+static struct ldebugfs_vars ldebugfs_osc_obd_vars[] = {
        { .name =       "connect_flags",
          .fops =       &osc_connect_flags_fops         },
        { .name =       "ost_server_uuid",
index 06f82ad..4049cdd 100644 (file)
@@ -80,13 +80,13 @@ atomic_t descriptors_cnt;
 unsigned int ldiskfs_flush_descriptors_cnt = 5000;
 
 /* 1 GiB in 512-byte sectors */
-int ldiskfs_delayed_unlink_blocks = (1 << (30 - 9));
+static int ldiskfs_delayed_unlink_blocks = (1 << (30 - 9));
 
 /* Slab to allocate dynlocks */
 struct kmem_cache *dynlock_cachep;
 
 /* Slab to allocate osd_it_ea */
-struct kmem_cache *osd_itea_cachep;
+static struct kmem_cache *osd_itea_cachep;
 
 static struct lu_kmem_descr ldiskfs_caches[] = {
        {
index 618b3a5..f959100 100644 (file)
@@ -807,7 +807,7 @@ static ssize_t extents_dense_store(struct kobject *kobj, struct attribute *attr,
 LUSTRE_RW_ATTR(extents_dense);
 #endif
 
-struct ldebugfs_vars ldebugfs_osd_obd_vars[] = {
+static struct ldebugfs_vars ldebugfs_osd_obd_vars[] = {
        { .name =       "oi_scrub",
          .fops =       &ldiskfs_osd_oi_scrub_fops      },
        { NULL }
index 79d031d..0e8703a 100644 (file)
@@ -381,7 +381,7 @@ static struct attribute *zfs_attrs[] = {
        NULL,
 };
 
-struct ldebugfs_vars ldebugfs_osd_obd_vars[] = {
+static struct ldebugfs_vars ldebugfs_osd_obd_vars[] = {
        { .name =       "oi_scrub",
          .fops =       &zfs_osd_oi_scrub_fops          },
        { 0 }
index eda3a3e..026c5b3 100644 (file)
@@ -20,7 +20,7 @@
 static LIST_HEAD(nodemap_pde_list);
 
 /* nodemap debugfs root directory under lustre */
-struct dentry *nodemap_root;
+static struct dentry *nodemap_root;
 
 /**
  * Reads and prints the idmap for the given nodemap.
index 5b4112f..0f2316f 100644 (file)
@@ -2281,7 +2281,7 @@ nrs_tbf_opcode_rule_dump(struct nrs_tbf_rule *rule, struct seq_file *m)
 }
 
 
-struct nrs_tbf_ops nrs_tbf_opcode_ops = {
+static struct nrs_tbf_ops nrs_tbf_opcode_ops = {
        .o_name = NRS_TBF_TYPE_OPCODE,
        .o_startup = nrs_tbf_opcode_startup,
        .o_cli_find = nrs_tbf_opcode_cli_find,
@@ -2595,7 +2595,7 @@ static void nrs_tbf_id_rule_fini(struct nrs_tbf_rule *rule)
        OBD_FREE_STR(rule->tr_ids_str);
 }
 
-struct nrs_tbf_ops nrs_tbf_uid_ops = {
+static struct nrs_tbf_ops nrs_tbf_uid_ops = {
        .o_name = NRS_TBF_TYPE_UID,
        .o_startup = nrs_tbf_id_startup,
        .o_cli_find = nrs_tbf_id_cli_find,
@@ -2608,7 +2608,7 @@ struct nrs_tbf_ops nrs_tbf_uid_ops = {
        .o_rule_fini = nrs_tbf_id_rule_fini,
 };
 
-struct nrs_tbf_ops nrs_tbf_gid_ops = {
+static struct nrs_tbf_ops nrs_tbf_gid_ops = {
        .o_name = NRS_TBF_TYPE_GID,
        .o_startup = nrs_tbf_id_startup,
        .o_cli_find = nrs_tbf_id_cli_find,
index 7dfe5eb..ad5ca57 100644 (file)
@@ -20,7 +20,7 @@
 
 struct kmem_cache *lqe_kmem;
 
-struct lu_kmem_descr lquota_caches[] = {
+static struct lu_kmem_descr lquota_caches[] = {
        {
                .ckd_cache = &lqe_kmem,
                .ckd_name  = "lqe_kmem",
index 0254c0a..c4e6587 100644 (file)
@@ -58,7 +58,7 @@
 
 #include "tgt_internal.h"
 
-int lbug_on_grant_miscount;
+static int lbug_on_grant_miscount;
 module_param(lbug_on_grant_miscount, int, 0644);
 MODULE_PARM_DESC(lbug_on_grant_miscount, "LBUG on grant miscount");
 
index 39e36b3..747dbd1 100644 (file)
@@ -1573,9 +1573,9 @@ void tgt_register_lfsck_in_notify_local(int (*notify)(const struct lu_env *,
 }
 EXPORT_SYMBOL(tgt_register_lfsck_in_notify_local);
 
-int (*tgt_lfsck_in_notify)(const struct lu_env *env,
-                          struct dt_device *key,
-                          struct lfsck_request *lr) = NULL;
+static int (*tgt_lfsck_in_notify)(const struct lu_env *env,
+                                 struct dt_device *key,
+                                 struct lfsck_request *lr) = NULL;
 
 void tgt_register_lfsck_in_notify(int (*notify)(const struct lu_env *,
                                                struct dt_device *,
index 66071df..1665f2b 100644 (file)
@@ -16,6 +16,7 @@
 #include <obd_target.h>
 #include <obd_cksum.h>
 #include "tgt_internal.h"
+#include "lu_target.h"
 #include "../ptlrpc/ptlrpc_internal.h"
 
 /* This must be longer than the longest string below */