From f7d32fa1161c2759e914e52bbafdcfff2b381075 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Wed, 27 Oct 2021 09:48:58 -0500 Subject: [PATCH] EX-3002 lipe: use static in lpurge In lpurge, declare functions and variables static when possible. Remove any unused functions or variables. Signed-off-by: John L. Hammond Test-Parameters: trivial testlist=hot-pools Change-Id: I902894741c62136eda34327204f9299cd23c9e27 Reviewed-on: https://review.whamcloud.com/45385 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alexandre Ioffe Reviewed-by: Jian Yu Reviewed-on: https://review.whamcloud.com/46123 --- lipe/src/lpurge.c | 86 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/lipe/src/lpurge.c b/lipe/src/lpurge.c index 6403e4f..e2832eb 100644 --- a/lipe/src/lpurge.c +++ b/lipe/src/lpurge.c @@ -105,7 +105,7 @@ struct lpurge_slot { }; #define LPURGE_HIST_MAX 16 -struct lpurge_slot lpurge_hist[LPURGE_HIST_MAX]; +static struct lpurge_slot lpurge_hist[LPURGE_HIST_MAX]; struct stats { unsigned long long s_scan_time; @@ -118,7 +118,7 @@ struct stats { unsigned long s_failed; /* # files we failed to purge */ /* TODO count mirrors we tried to purge but found last non stale */ }; -struct stats stats; +static struct stats stats; #define DEF_FREEHI 90 #define DEF_FREELO 75 @@ -143,7 +143,9 @@ struct options { unsigned int o_slot_size; unsigned int o_freelo; unsigned int o_freehi; -} opt = { +}; + +static struct options opt = { .o_interval = DEF_INTERVAL, .o_max_jobs = DEF_MAX_JOBS, .o_scan_threads = DEF_SCAN_THREADS, @@ -154,30 +156,29 @@ struct options { enum llapi_message_level lx_log_level = LLAPI_MSG_INFO; char *lx_log_prefix; /* To print device name in log messages */ -struct lipe_instance instance; -unsigned long long freelo; /* low free space when to scan quickly and remove */ -unsigned long long freehi; /* high free space when stop to scan */ -unsigned long long kbfree; -char *ostname; -char *ostprefix; -char ost_mntdev[PATH_MAX]; -char *ost_mntpt; -bool is_mdt = false; -int lustre_fd = -1; -int open_by_fid_fd = -1; -unsigned long oldest; -time_t scan_started_time; -time_t scan_finished_time; -unsigned int lpurge_scan_rate; -unsigned int lpurge_scanned_since; +static struct lipe_instance instance; +static unsigned long long freelo; /* low free space when to scan quickly and remove */ +static unsigned long long freehi; /* high free space when stop to scan */ +static unsigned long long kbfree; +static char *ostname; +static char *ostprefix; +static char ost_mntdev[PATH_MAX]; +static char *ost_mntpt; +static bool is_mdt = false; +static int lustre_fd = -1; +static int open_by_fid_fd = -1; +static unsigned long oldest; +static time_t scan_started_time; +static time_t scan_finished_time; +static unsigned int lpurge_scan_rate; +static unsigned int lpurge_scanned_since; /* how soon the scan result expires, in seconds */ -unsigned long lpurge_expire_time = DEF_EXPIRE_TIME; +static unsigned long lpurge_expire_time = DEF_EXPIRE_TIME; /* how long to wait before next urgent scan, in seconds */ /* calculated using previous scans, see lpurge_scan() */ -time_t lpurge_suspend_time; -char *prog; +static time_t lpurge_suspend_time; -void load_config(char *name); +static void load_config(char *name); #define LPURGE_FLIST_SIZE (1024 * 1024) @@ -194,7 +195,7 @@ static void lpurge_null_handler(int signal) int cfs_get_param_paths(glob_t *paths, const char *pattern, ...); -void lpurge_init_result(void) +static void lpurge_init_result(void) { int age = 3600; /* hour or less */ int i; @@ -217,7 +218,7 @@ void lpurge_init_result(void) } } -void lpurge_reset_result(void) +static void lpurge_reset_result(void) { struct lpurge_object *s, *t; int i; @@ -243,7 +244,7 @@ void lpurge_reset_result(void) } } -void usage(void) +static void usage(void) { printf("Usage: %s [options]\n" "\t-b, --debug, enable debugging output\n" @@ -402,7 +403,7 @@ static int lpurge_kbtotal(unsigned long long *kbtotalsize) static unsigned long long lpurge_last_kbtotal; -void lpurge_configure_thresholds(void) +static void lpurge_configure_thresholds(void) { int rc; unsigned long long fresh; @@ -660,9 +661,9 @@ static int lpurge_check_ost_object(struct lpurge_slot *ls, * this OST if you have a good replica" ? preferrable in * batches */ -int lpurge_lipe_callback(struct lipe_instance *instance, - struct lipe_object *object, - struct lipe_object_attrs *attrs) +static int lpurge_lipe_callback(struct lipe_instance *instance, + struct lipe_object *object, + struct lipe_object_attrs *attrs) { struct lpurge_slot *ls = NULL; struct lpurge_object *lo = NULL; @@ -1078,8 +1079,8 @@ out: return rc; } -/* Unused. */ -void lpurge_work_submit(struct lpurge_object *lo) +#if 0 /* Unused. */ +static void lpurge_work_submit(struct lpurge_object *lo) { pthread_mutex_lock(&lpurge_work_lock); assert(lpurge_work_should_run); @@ -1088,8 +1089,9 @@ void lpurge_work_submit(struct lpurge_object *lo) pthread_cond_signal(&lpurge_work_cond); pthread_mutex_unlock(&lpurge_work_lock); } +#endif -void lpurge_purge_slot(struct lpurge_slot *ls, long long target) +static void lpurge_purge_slot(struct lpurge_slot *ls, long long target) { struct lpurge_object *lo; __u64 total, was, kbfree; @@ -1211,7 +1213,7 @@ again: */ } -void lpurge_free_space(void) +static void lpurge_free_space(void) { unsigned long long kbfree; int i, rc; @@ -1244,7 +1246,7 @@ void lpurge_free_space(void) LX_INFO("%lluM space free\n", kbfree >> 10); } -void lpurge_scan(void) +static void lpurge_scan(void) { time_t now = time(NULL); time_t scan_time; @@ -1324,7 +1326,7 @@ void lpurge_scan(void) } } -void parse_mountpoint(const char *name) +static void parse_mountpoint(char *name) { struct lu_fid fid; int rc, idx; @@ -1381,7 +1383,7 @@ static struct option *lpurge_keyword_lookup(const char *keyword) return NULL; } -void lpurge_process_opt(int c, char *optarg) +static void lpurge_process_opt(int c, char *optarg) { long value; char *endptr; @@ -1479,7 +1481,7 @@ void lpurge_process_opt(int c, char *optarg) } } -void load_config(char *name) +static void load_config(char *name) { char buf[PATH_MAX]; FILE *f; @@ -1532,7 +1534,7 @@ void load_config(char *name) fclose(f); } -void lpurge_verify_opts(void) +static void lpurge_verify_opts(void) { char buf[1024]; @@ -1600,7 +1602,7 @@ void lpurge_verify_opts(void) LX_FATAL("invalid max_jobs: %d\n", opt.o_max_jobs); } -void lpurge_parse_opts(int argc, char **argv) +static void lpurge_parse_opts(int argc, char **argv) { int c; @@ -1626,7 +1628,7 @@ void lpurge_parse_opts(int argc, char **argv) * 3rd part: space info * 4th part: hlist states (status of each scanned slots) */ -void lpurge_usr1_handle(int sig) +static void lpurge_usr1_handle(int sig) { unsigned long long kbfree; FILE *f; @@ -1702,7 +1704,7 @@ void lpurge_usr1_handle(int sig) fclose(f); } -void lpurge_usr2_handle(int sig) +static void lpurge_usr2_handle(int sig) { int i, rc; unsigned long dumped = 0; -- 1.8.3.1