From f817369b48be1cc3f36c9b91ca522138937935c1 Mon Sep 17 00:00:00 2001 From: Lei Feng Date: Wed, 8 Nov 2023 10:07:32 +0800 Subject: [PATCH] EX-8568 lipe: lpcc_purge can disable force scanning when force_scan_interval is set to -1, lpcc_purge will never start force scanning. Signed-off-by: Lei Feng Test-Parameters: trivial Change-Id: I21bcadb97f09622eae08af73082196e816b2c9ae Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53032 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lipe/man/lpcc.conf.5 | 3 ++- lipe/src/lpcc_purge.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lipe/man/lpcc.conf.5 b/lipe/man/lpcc.conf.5 index 1e1a976..7aace93 100644 --- a/lipe/man/lpcc.conf.5 +++ b/lipe/man/lpcc.conf.5 @@ -45,7 +45,8 @@ seconds by default. .BR purge.force_scan_interval 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. +It is 1800 seconds by default. This function can be disabled by setting the +value to -1. .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 00a38b7..a80f249 100644 --- a/lipe/src/lpcc_purge.c +++ b/lipe/src/lpcc_purge.c @@ -38,6 +38,7 @@ #define DEF_FORCE_SCAN_INTERVAL (30 * 60) #define MIN_FORCE_SCAN_INTERVAL (60) #define MAX_FORCE_SCAN_INTERVAL (24 * 60 * 60) +#define DISABLED_FORCE_SCAN_INTERVAL (-1) #define OPT_DRY_RUN 1 #define OPT_CANDIDATE_NUM 2 @@ -417,7 +418,7 @@ static void usage(void) "\t-t, --scan-threads=NUM, scanning threads (default: %u)\n" "\t --candidate-num=NUM, candidate number of approximate LRU (default: %d, min: %d, max: %d)\n" "\t --max-scan-secs=NUM, max seconds to scan continously before purging (default: %d, min: %d, max: %d)\n" - "\t --force-scan-interval=NUM, seconds to next forceful scanning (default: %d, min: %d, max: %d)\n" + "\t --force-scan-interval=NUM, seconds to next forceful scanning (default: %d, min: %d, max: %d, disabled: %d)\n" "\t-w, --dump=FILE, dump stats to FILE when signal USR1 is recieved (default: /var/run/lpcc_purge-RWID.stats)\n" "\t --pidfile=FILE, the pidfile name (default: /var/run/lpcc_purge-RWID.pid)\n" "\t --clear-hashdir, clear empty hash dir after detaching file\n" @@ -433,7 +434,7 @@ static void usage(void) DEF_CANDIDATE_NUM, MIN_CANDIDATE_NUM, MAX_CANDIDATE_NUM, DEF_MAX_SCAN_SECS, MIN_MAX_SCAN_SECS, MAX_MAX_SCAN_SECS, DEF_FORCE_SCAN_INTERVAL, MIN_FORCE_SCAN_INTERVAL, - MAX_FORCE_SCAN_INTERVAL + MAX_FORCE_SCAN_INTERVAL, DISABLED_FORCE_SCAN_INTERVAL ); } @@ -721,8 +722,9 @@ static void lpcc_purge_process_opt(int c, char *optarg) break; case OPT_FORCE_SCAN_INTERVAL: value = strtol(optarg, &endptr, 10); - if (*endptr != '\0' || value < MIN_FORCE_SCAN_INTERVAL || - value > MAX_FORCE_SCAN_INTERVAL) { + if (*endptr != '\0' || (value != DISABLED_FORCE_SCAN_INTERVAL && + (value < MIN_FORCE_SCAN_INTERVAL || + value > MAX_FORCE_SCAN_INTERVAL))) { llapi_error(LLAPI_MSG_FATAL, -EINVAL, "invalid force-scan-interval: '%s'\n", optarg); @@ -897,8 +899,9 @@ static void lpcc_purge_wait_for_scan(void) double usage = lpcc_purge_get_fs_usage(opt.o_cache); LPCC_PURGE_LOG(LLAPI_MSG_DEBUG, "usage: %.1f\n", usage); if (usage >= opt.o_high_usage || opt.o_dry_run || + (opt.o_force_scan_interval != DISABLED_FORCE_SCAN_INTERVAL && (now - xstats[1].xs_last_scan_time) > - opt.o_force_scan_interval) { + opt.o_force_scan_interval)) { stats.s_start_usage = usage; xstats[1].xs_last_scan_time = now; break; -- 1.8.3.1