Whamcloud - gitweb
EX-3002 lipe: rename lpurge free{lo,hi} to {max,min}-used
authorJohn L. Hammond <jhammond@whamcloud.com>
Thu, 28 Oct 2021 01:24:40 +0000 (20:24 -0500)
committerJohn L. Hammond <jhammond@whamcloud.com>
Tue, 5 Apr 2022 21:00:22 +0000 (21:00 +0000)
Expressing things in terms of used rather than free is much easier to
understand.

Signed-off-by: John L. Hammond <jhammond@whamcloud.com>
Test-Parameters: trivial testlist=hot-pools
Change-Id: I31ff88db97c0dd1b2ddbaa67aa27e8bec520c7d3
Reviewed-on: https://review.whamcloud.com/46903
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alexandre Ioffe <aioffe@ddn.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
lipe/src/lpurge.c

index bbf49b8..af02d7f 100644 (file)
@@ -149,6 +149,8 @@ static struct options opt = {
        .o_scan_threads = DEF_SCAN_THREADS,
        .o_slot_size = DEF_SLOT_SIZE,
        .o_scan_rate = DEF_SCAN_RATE,
+       .o_max_used = -1,
+       .o_min_used = -1,
 };
 
 enum llapi_message_level lx_log_level = LLAPI_MSG_INFO;
@@ -253,11 +255,14 @@ static void usage(void)
        printf("Usage: %s [options]\n"
               "\t-b, --debug, enable debugging output\n"
               "\t-D, --device, OST device\n"
-              "\t-h, --freehi, high watermark, %% of space (default: %u)\n"
+              /* -h, --freehi, high watermark, %% of space (default: %u) */
               "\t--help, print this help message\n"
               "\t-i, --interval, seconds to next check (default: %u)\n"
               "\t-j, --max_jobs, max.jobs to release replicas (default: %u)\n"
-              "\t-l, --freelo, low watermark, %% of space (default: %u)\n"
+              "\t--min-used=MIN, start slow purge when %% space used reaches MIN (default %u)\n"
+              "\t--max-used=MAX, start fast purge when %% space used reaches MAX (default %u)\n"
+              "\t--used=USED, equivalent to --min-used=USED --max-used=(USED + 5)\n"
+              /* -l, --freelo, low watermark, %% of space (default: %u) */
               "\t-m, --mds, MDS idx:host:mountpoint (can specify multiple)\n"
               "\t-M, --mount, local Lustre client's mountpoint\n"
               "\t-p, --pool, pool to remove replicas from (default: %s)\n"
@@ -269,9 +274,9 @@ static void usage(void)
               "\t--version, print version information and exit\n",
               program_invocation_short_name,
               DEF_INTERVAL,
-              100 - DEF_MIN_USED,
               DEF_MAX_JOBS,
-              100 - DEF_MAX_USED,
+              DEF_MIN_USED,
+              DEF_MAX_USED,
               DEF_POOL,
               DEF_SCAN_RATE,
               DEF_SLOT_SIZE,
@@ -284,8 +289,8 @@ static void usage(void)
        printf("  config example:\n"
               "\tdevice=lustre-OST0000\n"
               "\tmount=/mnt/lustre\n"
-              "\tfreelo=20\n"
-              "\tfreehi=30\n"
+              "\tmax-used=80\n"
+              "\tmin-used=70\n"
               "\tmax_jobs=8\n"
               "\tpool=<pool>\n"
               "\tmds=0:mds1host:/mnt/lustre\n"
@@ -1371,9 +1376,14 @@ static void parse_mountpoint(char *name)
                LX_FATAL("cannot open '%s/.lustre/fid': %s\n", name, strerror(errno));
 }
 
-#define LPURGE_INTERNAL_DUMP_FIDS 1
-#define LPURGE_OPT_VERSION 2
-#define LPURGE_OPT_LOG_TIMESTAMPS 3
+enum {
+       LPURGE_INTERNAL_DUMP_FIDS = 1,
+       LPURGE_OPT_LOG_TIMESTAMPS,
+       LPURGE_OPT_MAX_USED,
+       LPURGE_OPT_MIN_USED,
+       LPURGE_OPT_USED,
+       LPURGE_OPT_VERSION,
+};
 
 static struct option options[] = {
        { "device", required_argument, NULL, 'D'},
@@ -1385,7 +1395,9 @@ static struct option options[] = {
        { "freelo", required_argument, NULL, 'l'},
        { "help", no_argument, NULL, 'H' },
        { "interval", required_argument, NULL, 'i'},
+       { "max-used", required_argument, NULL, LPURGE_OPT_MAX_USED },
        { "max_jobs", required_argument, NULL, 'j'},
+       { "min-used", required_argument, NULL, LPURGE_OPT_MIN_USED },
        { "mds", required_argument, NULL, 'm'},
        { "mount", required_argument, NULL, 'M'},
        { "pool", required_argument, NULL, 'p'},
@@ -1393,6 +1405,7 @@ static struct option options[] = {
        { "scan_threads", required_argument, NULL, 't'},
        { "slot_size", required_argument, NULL, 'S'},
        { "timestamps", no_argument, NULL, LPURGE_OPT_LOG_TIMESTAMPS},
+       { "used", required_argument, NULL, LPURGE_OPT_USED },
        { "version", no_argument, NULL, LPURGE_OPT_VERSION},
        { NULL }
 };
@@ -1418,6 +1431,28 @@ static void lpurge_process_opt(int c, char *optarg)
        case LPURGE_INTERNAL_DUMP_FIDS:
                opt.o_fids_dumpfile = xstrdup(optarg);
                break;
+       case LPURGE_OPT_MAX_USED:
+               value = strtol(optarg, &endptr, 10);
+               if (*endptr != '\0' || !(1 <= value && value <= 100))
+                       LX_FATAL("invalid argument ('%s') to --max-used\n", optarg);
+
+               opt.o_max_used = value;
+               break;
+       case LPURGE_OPT_MIN_USED:
+               value = strtol(optarg, &endptr, 10);
+               if (*endptr != '\0' || !(0 <= value && value <= 99))
+                       LX_FATAL("invalid argument ('%s') to --min-used\n", optarg);
+
+               opt.o_min_used = value;
+               break;
+       case LPURGE_OPT_USED:
+               value = strtol(optarg, &endptr, 10);
+               if (*endptr != '\0' || !(0 <= value && value <= 95))
+                       LX_FATAL("invalid argument ('%s') to --used\n", optarg);
+
+               opt.o_min_used = value;
+               opt.o_max_used = value + 5;
+               break;
        case LPURGE_OPT_VERSION:
                lipe_version();
                exit(0);
@@ -1433,6 +1468,7 @@ static void lpurge_process_opt(int c, char *optarg)
                load_config(optarg);
                break;
        case 'h':
+               LX_WARN("options '-h' and '--freehi' are deprecated, please use '--min-used' or '--used' instead\n");
                value = strtol(optarg, &endptr, 10);
                if (*endptr != '\0' || value < 0)
                        LX_FATAL("invalid high watermark: '%s'\n", optarg);
@@ -1457,6 +1493,7 @@ static void lpurge_process_opt(int c, char *optarg)
                opt.o_max_jobs = value;
                break;
        case 'l':
+               LX_WARN("options '-l' and '--freelo' are deprecated, please use '--max-used' or '--used' instead\n");
                value = strtol(optarg, &endptr, 10);
                if (*endptr != '\0' || value < 0)
                        LX_FATAL("invalid low watermark: '%s'\n", optarg);
@@ -1571,20 +1608,26 @@ static void lpurge_verify_opts(void)
                opt.o_pool = DEF_POOL;
                LX_INFO("source pool isn't defined, use '%s'\n", opt.o_pool);
        }
-       if (opt.o_max_used == 0) {
+
+       if (opt.o_max_used == -1) {
                opt.o_max_used = DEF_MAX_USED;
                LX_INFO("max_used is not defined, using %u\n", opt.o_max_used);
        }
-       if (opt.o_max_used < 1 || opt.o_max_used > 99)
+
+       if (!(0 <= opt.o_max_used && opt.o_max_used <= 100))
                LX_FATAL("invalid max_used value %u\n", opt.o_max_used);
 
-       if (opt.o_min_used == 0) {
+       if (opt.o_min_used == -1) {
                opt.o_min_used = DEF_MIN_USED;
-               LX_INFO("min_used is not defined, useing %u\n", opt.o_min_used);
+               LX_INFO("min_used is not defined, using %u\n", opt.o_min_used);
        }
-       if (opt.o_min_used < 1 || opt.o_min_used > 99)
+
+       if (!(0 <= opt.o_min_used && opt.o_min_used <= 100))
                LX_FATAL("invalid min_used value %u\n", opt.o_min_used);
 
+       if (!(opt.o_min_used < opt.o_max_used))
+               LX_FATAL("min_used (%u) must be less than max_used (%u)\n", opt.o_min_used, opt.o_max_used);
+
        if (!ostprefix)
                LX_FATAL("OST device is not defined\n");