From 87b67d5ff5e242feca26ef961514d3b738ca4192 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Wed, 27 Oct 2021 09:47:05 -0500 Subject: [PATCH] EX-3002 lipe: use static in lamigo In lamigo, declare functions and variables static when possible. Remove any unused functions. Signed-off-by: John L. Hammond Test-Parameters: trivial testlist=hot-pools Change-Id: Iad16f31304ed9d9d70aa4ecb54f2a9acbbfdead5 Reviewed-on: https://review.whamcloud.com/45384 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alexandre Ioffe Reviewed-by: Jian Yu Reviewed-on: https://review.whamcloud.com/46122 --- lipe/src/lamigo.c | 101 +++++++++++++++++--------------------------------- lipe/src/lamigo.h | 2 - lipe/src/lamigo_alr.c | 14 +++---- 3 files changed, 41 insertions(+), 76 deletions(-) diff --git a/lipe/src/lamigo.c b/lipe/src/lamigo.c index 49011af..fa67491 100644 --- a/lipe/src/lamigo.c +++ b/lipe/src/lamigo.c @@ -99,7 +99,7 @@ char *lx_log_prefix = "NONE"; static char *lamigo_changelog_user; static LIPE_LIST_HEAD(lamigo_rule_list); -__u64 lamigo_rule_attrs; /* attributes needed to evalute the rules */ +static __u64 lamigo_rule_attrs; /* attributes needed to evalute the rules */ static void usage(void) { @@ -269,7 +269,7 @@ struct stats { int s_hist_cur; }; -struct stats stats = { 0 }; +static struct stats stats = { 0 }; static void lamigo_hist_add(struct lu_fid *fid, enum amigo_resync_type result) { @@ -296,7 +296,9 @@ struct lamigo_head { struct fid_hash_head lh_hash; struct lipe_list_head lh_list; /* ordered list by record index */ unsigned long lh_cached_count; -} head = { +}; + +static struct lamigo_head head = { .lh_list = LIPE_LIST_HEAD_INIT(head.lh_list), }; @@ -306,27 +308,28 @@ struct mirror_opts { struct pool_list *mo_src_pool; }; -__u64 lamigo_last_processed_idx; /* changelog index */ +static __u64 lamigo_last_processed_idx; /* changelog index */ static time_t lamigo_last_cleared; static __u64 lamigo_last_cleared_index; static LIPE_LIST_HEAD(lamigo_agent_list); static int lamigo_agent_count; -int lamigo_max_jobs; /* max jobs for all agents */ -int lamigo_jobs_running; /* jobs running at the moment */ -char fsname[MAX_OBD_NAME + 1]; - -void *chglog_hdlr; -struct lipe_instance instance; -char mdt_mntdev[PATH_MAX]; -int open_by_fid_fd = -1; +static int lamigo_max_jobs; /* max jobs for all agents */ +static int lamigo_jobs_running; /* jobs running at the moment */ +static char fsname[MAX_OBD_NAME + 1]; + +static void *chglog_hdlr; +static struct lipe_instance instance; +static char mdt_mntdev[PATH_MAX]; +static int open_by_fid_fd = -1; int enable_heat = 1; /* track and use heat by default */ -int lamigo_sigpipe[2]; +static int lamigo_sigpipe[2]; int cfs_get_param_paths(glob_t *paths, const char *pattern, ...); static int lamigo_read_file(const char *param, char *val, const int vallen); static void lamigo_check_hot(void); -void lamigo_alr_mirror_cb(struct resync_job *rj, void *cbdata, int rc); +static void lamigo_alr_mirror_cb(struct resync_job *rj, void *cbdata, int rc); +static void lamigo_parse_rules(const char *rule_str, const char *filename); struct pool_list *fast_pools; /* fast pools */ struct pool_list *slow_pools; /* slow pool */ @@ -642,7 +645,7 @@ static int lamigo_exec_cmd(struct resync_agent *a, const char *cmd, int *pstatus return rc; } -void *lamigo_replicate_one(void *args) +static void *lamigo_replicate_one(void *args) { struct resync_job *rj = (struct resync_job *)args; struct resync_agent *agent = rj->rj_agent; @@ -775,22 +778,6 @@ static bool lamigo_entry_needs_resync(struct lov_comp_md_entry_v1 *entry) return false; } -char *lmm_magic_to_str(__u32 magic) -{ - static char unknown[16]; - - if (magic == LOV_USER_MAGIC_V1) - return "V1"; - else if (magic == LOV_USER_MAGIC_V3) - return "V3"; - else if (magic == LOV_USER_MAGIC_COMP_V1) - return "C1"; - snprintf(unknown, sizeof(unknown), "%04x", magic); - - return unknown; -} - - static int lamigo_get_objects(struct lov_user_md_v3 *v3, struct lov_user_ost_data_v1 **objects, int *stripes) @@ -1239,7 +1226,7 @@ out: return resync; } -void *lamigo_check_agent_func(void *args) +static void *lamigo_check_agent_func(void *args) { char cmd[PATH_MAX]; struct resync_agent *a = (struct resync_agent *)args; @@ -1317,7 +1304,7 @@ static int lamigo_submit_job(struct resync_job *rj) return 0; } -void lamigo_schedule_setprefer(struct resync_job *rj, void *cbdata, int rc) +static void lamigo_schedule_setprefer(struct resync_job *rj, void *cbdata, int rc) { struct resync_job *srj; @@ -1864,7 +1851,7 @@ bool lamigo_lookup_ost(struct pool_list *pl, int ost) return false; } -struct pool_list *lamigo_alloc_pool(char *pool) +static struct pool_list *lamigo_alloc_pool(char *pool) { struct pool_list *pl; @@ -1877,7 +1864,7 @@ struct pool_list *lamigo_alloc_pool(char *pool) return pl; } -void lamigo_parse_pool(char *pool) +static void lamigo_parse_pool(char *pool) { struct pool_list *pl; @@ -1896,7 +1883,7 @@ void lamigo_parse_pool(char *pool) fast_pools = pl; } -void lamigo_refresh_osts_from_pool(struct pool_list *pl) +static void lamigo_refresh_osts_from_pool(struct pool_list *pl) { glob_t paths; char **list, *buffer = NULL; @@ -1967,7 +1954,7 @@ out: free(buffer); } -void lamigo_refresh_pools(void) +static void lamigo_refresh_pools(void) { static unsigned long last_time; unsigned long now = time(NULL); @@ -1994,7 +1981,7 @@ void lamigo_refresh_pools(void) } } -void lamigo_process_opt(int c, char *optarg) +static void lamigo_process_opt(int c, char *optarg) { int rc; char *endptr; @@ -2217,26 +2204,6 @@ static void count_bracket_recursion(const char *str, int *counter) } } -char *stracat(char *src, char *dst) -{ - int len = 0; - char *n; - - if (src) - len += strlen(src); - if (dst) - len += strlen(dst); - n = xmalloc(len + 1); - if (src) - strcpy(n, src); - if (dst) - strcat(n, dst); - if (src) - free(src); - - return n; -} - static void load_rules(FILE *f, const char *filename, char *start) { char buf[PATH_MAX]; @@ -2340,7 +2307,7 @@ static void load_config(char *name) fclose(f); } -void lamigo_parse_opts(int argc, char **argv) +static void lamigo_parse_opts(int argc, char **argv) { char buf[PATH_MAX]; int rc, c, opt_index = 0; @@ -2459,9 +2426,9 @@ static int lamigo_create_job(struct lu_fid *fid, return lamigo_submit_job(rj); } -int lamigo_lipe_callback(struct lipe_instance *instance, - struct lipe_object *object, - struct lipe_object_attrs *attrs) +static int lamigo_lipe_callback(struct lipe_instance *instance, + struct lipe_object *object, + struct lipe_object_attrs *attrs) { struct lipe_rule rule; struct lipe_policy_sysattrs sysattrs; @@ -2542,7 +2509,7 @@ out: return 0; } -char *mdtprefix; +static char *mdtprefix; static int lamigo_find_device(const char *devname) { @@ -2622,7 +2589,7 @@ static int lamigo_read_param(const char *param, char *val, const int vallen) /** * Scan the whole MDT and replicate matched files. */ -int lamigo_rescan(void) +static int lamigo_rescan(void) { struct lipe_policy policy; struct scan_result result; @@ -2896,7 +2863,7 @@ static void lamigo_changelog_user_register(void) static unsigned long progress_timestamp; static unsigned long progress_last_processed; -void lamigo_show_progress(void) +static void lamigo_show_progress(void) { unsigned long now = time(NULL); @@ -3019,7 +2986,7 @@ again: } } -void lamigo_parse_rules(const char *rule_str, const char *filename) +static void lamigo_parse_rules(const char *rule_str, const char *filename) { struct json_object *obj_top; struct json_object *obj_rules; @@ -3255,7 +3222,7 @@ int main(int argc, char **argv) } } -void lamigo_alr_mirror_cb(struct resync_job *rj, void *cbdata, int rc) +static void lamigo_alr_mirror_cb(struct resync_job *rj, void *cbdata, int rc) { lamigo_alr_mark(&rj->rj_fid, rc == 0 ? ALR_TAG_REPLICATED : ALR_TAG_FAILED, diff --git a/lipe/src/lamigo.h b/lipe/src/lamigo.h index c5e75d6..f83cfe9 100644 --- a/lipe/src/lamigo.h +++ b/lipe/src/lamigo.h @@ -115,6 +115,4 @@ int lamigo_alr_get_hot_files(int period, struct alr_heat *ht, int nr, void lamigo_alr_mark(struct lu_fid *fid, __u8 set, __u8 clear); void lamigo_alr_dump_heat_table(FILE *file); -void lamigo_parse_rules(const char *rule_str, const char *filename); - #endif diff --git a/lipe/src/lamigo_alr.c b/lipe/src/lamigo_alr.c index 81c2007..4ce1dae 100644 --- a/lipe/src/lamigo_alr.c +++ b/lipe/src/lamigo_alr.c @@ -160,7 +160,7 @@ static void lamigo_alr_update_one(struct lu_fid *fid, enum alr_rw rw, pthread_mutex_unlock(&art_mutex); } -void lamigo_alr_parse_one(const char *line) +static void lamigo_alr_parse_one(const char *line) { unsigned long long timestamp, begin, end, iosize, segments, count; char *ostidx, *strend; @@ -203,7 +203,7 @@ void lamigo_alr_parse_one(const char *line) count, iosize, end, pool); } -int lamigo_alr_parse(char *buf, int size, int *received) +static int lamigo_alr_parse(char *buf, int size, int *received) { int len, offset = 0; char *p; @@ -340,12 +340,12 @@ static void lamigo_clean_oldest_list(void) typedef __u64 (*alr_heat_fn_t)(struct alr_rec *f, enum alr_rw rw); -__u64 alr_heat_abs_iops_fn(struct alr_rec *f, enum alr_rw rw) +static __u64 alr_heat_abs_iops_fn(struct alr_rec *f, enum alr_rw rw) { return f->ar_ops[rw]; } -__u64 alr_heat_iops_density_fn(struct alr_rec *f, enum alr_rw rw) +static __u64 alr_heat_iops_density_fn(struct alr_rec *f, enum alr_rw rw) { __u64 mb; @@ -355,7 +355,7 @@ __u64 alr_heat_iops_density_fn(struct alr_rec *f, enum alr_rw rw) return f->ar_ops[rw] / mb; } -alr_heat_fn_t alr_heat_fn[] = { +static alr_heat_fn_t alr_heat_fn[] = { alr_heat_abs_iops_fn, alr_heat_iops_density_fn, }; @@ -562,8 +562,8 @@ out: pthread_mutex_unlock(&p->alp_mutex); } -void lamigo_alr_process_temp_one(struct lu_fid *fid, int rw, __u64 ops, - __u64 iosize, __u64 maxoff, enum alr_pool pool) +static void lamigo_alr_process_temp_one(struct lu_fid *fid, int rw, __u64 ops, + __u64 iosize, __u64 maxoff, enum alr_pool pool) { struct alr_rec *f = NULL; struct fid_hash *fh; -- 1.8.3.1