From: Lei Feng Date: Wed, 8 Nov 2023 04:46:45 +0000 (+0800) Subject: EX-8569 lipe: trigger lpcc_purge scan by SIGUSR2 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=e5ca52bd414de9bcb985962f2b2c284487657837;p=fs%2Flustre-release.git EX-8569 lipe: trigger lpcc_purge scan by SIGUSR2 send SIGUSR2 to lpcc_purge to trigger a scanning immediately. Signed-off-by: Lei Feng Test-Parameters: trivial Change-Id: I2811c90ac75c93167e8104e90b424ac31c8cc50c Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53034 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- diff --git a/lipe/man/lpcc.conf.5 b/lipe/man/lpcc.conf.5 index 7aace93..0582b5c 100644 --- a/lipe/man/lpcc.conf.5 +++ b/lipe/man/lpcc.conf.5 @@ -47,6 +47,9 @@ The interval for lpcc_purge to scan cache device forcefully even if its usage is not higher than \fBpurge.high_usage\fR to refresh some statistics data. It is 1800 seconds by default. This function can be disabled by setting the value to -1. + +The force scanning can also be triggered by sending signal SIGUSR2 to +lpcc_purge process at any time. .TP .BR purge.scan_threads How many threads are used to scan cache device in parallel. It is 1 thread by diff --git a/lipe/src/lpcc_purge.c b/lipe/src/lpcc_purge.c index a80f249..2e5ba05 100644 --- a/lipe/src/lpcc_purge.c +++ b/lipe/src/lpcc_purge.c @@ -231,10 +231,6 @@ void lpcc_purge_candidate_set_sort(void) sizeof(candidate_set.cs_arr[0]), &_compare_candidate); } -static void lpcc_purge_null_handler(int signal) -{ -} - static void lpcc_purge_sigint_handler(int signal) { LPCC_PURGE_LOG(LLAPI_MSG_FATAL, "Exit due to signal: %s\n", @@ -403,6 +399,12 @@ static void lpcc_purge_usr1_handler(int sig) fclose(f); } +static bool force_scan_flag = false; +static void lpcc_purge_usr2_handler(int sig) +{ + force_scan_flag = true; +} + static void usage(void) { printf("Usage: %s [options]\n" @@ -905,6 +907,13 @@ static void lpcc_purge_wait_for_scan(void) stats.s_start_usage = usage; xstats[1].xs_last_scan_time = now; break; + } else if (force_scan_flag) { + LPCC_PURGE_LOG(LLAPI_MSG_INFO, + "force scanning triggered by signal\n"); + stats.s_start_usage = usage; + xstats[1].xs_last_scan_time = now; + force_scan_flag = false; + break; } else { sleep(opt.o_interval); } @@ -1276,7 +1285,7 @@ int main(int argc, char *argv[]) llapi_msg_set_level(LLAPI_MSG_INFO); signal(SIGUSR1, &lpcc_purge_usr1_handler); - signal(SIGUSR2, &lpcc_purge_null_handler); + signal(SIGUSR2, &lpcc_purge_usr2_handler); signal(SIGINT, &lpcc_purge_sigint_handler); signal(SIGTERM, &lpcc_purge_sigint_handler);