Whamcloud - gitweb
EX-8569 lipe: trigger lpcc_purge scan by SIGUSR2
authorLei Feng <flei@whamcloud.com>
Wed, 8 Nov 2023 04:46:45 +0000 (12:46 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 9 Nov 2023 08:47:27 +0000 (08:47 +0000)
send SIGUSR2 to lpcc_purge to trigger a scanning
immediately.

Signed-off-by: Lei Feng <flei@whamcloud.com>
Test-Parameters: trivial
Change-Id: I2811c90ac75c93167e8104e90b424ac31c8cc50c
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53034
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lipe/man/lpcc.conf.5
lipe/src/lpcc_purge.c

index 7aace93..0582b5c 100644 (file)
@@ -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
index a80f249..2e5ba05 100644 (file)
@@ -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);