From 5ed2090176ab0f3ce807fa47d96402d2418eb9b5 Mon Sep 17 00:00:00 2001 From: Frederick Dilger Date: Tue, 9 Jul 2024 22:02:18 -0600 Subject: [PATCH] LU-14442 utils: --tunable opt for list/get_param Added new [--tunable|-t] option for 'lctl {list|get}_param' that will only print tunable parameters. Specifically it excludes all params that contain any of the following strings: console|debug_|fail_|force|import|nis|panic_|sepol|stats|target_obd This is used for debugging system performance as it creates an easy way to collect all of the Lustre tuning parameters for each run. This can be combined with --no-links and --readable to remove a great deal of unwanted information being printed. LIST_PATHNAME was removed as it only added more to maintain while the purpose of that option can be achieved in a single line. Test-Parameters:trivial Signed-off-by: Frederick Dilger Change-Id: I847884af2fc16611f34e3e44a3f3990d39d7f39b Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55723 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Olaf Faaland Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- lustre/doc/lctl-get_param.8 | 7 +++++ lustre/doc/lctl-list_param.8 | 7 +++++ lustre/utils/lctl.c | 4 +-- lustre/utils/lctl_thread.h | 1 + lustre/utils/lustre_param.c | 67 +++++++++++++++++++++++++++++--------------- 5 files changed, 61 insertions(+), 25 deletions(-) diff --git a/lustre/doc/lctl-get_param.8 b/lustre/doc/lctl-get_param.8 index 6358bc1..bf00f84 100644 --- a/lustre/doc/lctl-get_param.8 +++ b/lustre/doc/lctl-get_param.8 @@ -11,6 +11,7 @@ lctl-get_param \- retrieve configuration parameters .RB [ --only-name | -N ] .RB [ --readable | -r ] .RB [ --recursive | -R ] +.RB [ --tunable | -t ] .RB [ --writable | -w ] .RB [ --yaml | -y ] .IR PARAM_PATH1 " [" PARAM_PATH2 " ...]" @@ -77,6 +78,12 @@ to print parameters that are both readable and writable. .BR -R ", " --recursive Recursively show all of the parameter names below the specified name. .TP +.BR -t ", " --tunable +Print only tunable parameters. This avoids all parameters containing any of the +following: +.br +.BR console | debug_ | fail_ | force | import | nis | panic_ | srpc_sepol | stats | target_obd +.TP .BR -w ", " --writable Print only parameters that are have write permission. Can be used with .RB [ -r | --readable ] diff --git a/lustre/doc/lctl-list_param.8 b/lustre/doc/lctl-list_param.8 index bc55ffe..7031526 100644 --- a/lustre/doc/lctl-list_param.8 +++ b/lustre/doc/lctl-list_param.8 @@ -10,6 +10,7 @@ lctl-list_param \- list configuration parameter names .RB [ --path | -p ] .RB [ --readable | -r ] .RB [ --recursive | -R ] +.RB [ --tunable | -t ] .RB [ --writeable | -w ] .IR PARAM_PATH1 " [" PARAM_PATH2 " ...]" .YS @@ -49,6 +50,12 @@ Recursively list all parameters under the specified parameter search string. If .I param_search is unspecified, all the parameters will be shown. .TP +.BR -t ", " --tunable +Print only tunable parameters. This avoids all parameters containing any of the +following: +.br +.BR console | debug_ | fail_ | force | import | nis | panic_ | srpc_sepol | stats | target_obd +.TP .BR -w ", " --writable Print only parameters that have write permission. Can be used with .RB [ -r | --readable ] diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index 0fd8956..b389a91 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -366,7 +366,7 @@ command_t cmdlist[] = { "usage: get_param [--classify|-F] [--header|-H] [--links|-l]\n" " [--no-links|-L] [--no-name|-n] [--only-name|-N]\n" " [--readable|-r] [--recursive|-R]\n" - " [--writable|-w] [--yaml|-y]\n" + " [--tunable|-t] [--writable|-w] [--yaml|-y]\n" " \n" "Get the value of Lustre or LNET parameter from the specified path.\n" "The path can contain shell-style filename patterns.\n"}, @@ -386,7 +386,7 @@ command_t cmdlist[] = { "list the Lustre or LNET parameter name\n" "usage: list_param [--dir-only|-D] [--classify|-F] [--links|-l]\n" " [--no-links|-L] [--path|-p] [--readable|-r]\n" - " [--recursive|-R] [--writable|-w]\n" + " [--recursive|-R] [--tunable|-t] [--writable|-w]\n" " \n" "List the name of Lustre or LNet parameter from the specified path.\n"}, {"del_ost", jt_del_ost, 0, "permanently delete OST records\n" diff --git a/lustre/utils/lctl_thread.h b/lustre/utils/lctl_thread.h index 6a19634..8890ff5 100644 --- a/lustre/utils/lctl_thread.h +++ b/lustre/utils/lctl_thread.h @@ -49,6 +49,7 @@ struct param_opts { unsigned int po_detail:1; unsigned int po_header:1; unsigned int po_follow_symlinks:1; + unsigned int po_tunable:1; unsigned int po_parallel_threads; unsigned int po_permissions; }; diff --git a/lustre/utils/lustre_param.c b/lustre/utils/lustre_param.c index 6356c27..5143d69 100644 --- a/lustre/utils/lustre_param.c +++ b/lustre/utils/lustre_param.c @@ -67,6 +67,7 @@ #include #include #include +#include #include "obdctl.h" #include @@ -264,25 +265,22 @@ static int clean_path(struct param_opts *popt, char *path) /** * The application lctl can perform three operations for lustre - * tunables. This enum defines those four operations which are + * tunables. This enum defines those three operations which are * * 1) LIST_PARAM - list available tunables * 2) GET_PARAM - report the current setting of a tunable * 3) SET_PARAM - set the tunable to a new value - * 4) LIST_PATHNAME - list paths of available tunables */ enum parameter_operation { LIST_PARAM, GET_PARAM, SET_PARAM, - LIST_PATHNAME, }; char *parameter_opname[] = { [LIST_PARAM] = "list_param", [GET_PARAM] = "get_param", [SET_PARAM] = "set_param", - [LIST_PATHNAME] = "list_pathname", }; /** @@ -395,6 +393,32 @@ int write_param(const char *path, const char *param_name, return rc; } +bool stats_param(const char *pattern) +{ + char * const flag_v[] = { + "console", + "debug_", + "fail_", + "force", + "import", + "panic_", + "peers", + "srpc_sepol", + "stats", + "target_obd", + }; + int i; + + for (i = 0; i < ARRAY_SIZE(flag_v); i++) + if (strstr(pattern, flag_v[i])) + return true; + + if (strncmp(pattern, "nis", strlen(pattern)) == 0) + return true; + + return false; +} + /** * Perform a read, write or just a listing of a parameter * @@ -472,6 +496,8 @@ static int do_param_op(struct param_opts *popt, char *pattern, char *value, if (popt->po_permissions && (st.st_mode & popt->po_permissions) != popt->po_permissions) continue; + if (popt->po_tunable && stats_param(paths.gl_pathv[i])) + continue; param_name = display_name(paths.gl_pathv[i], &st, popt); if (!param_name) { @@ -536,21 +562,8 @@ static int do_param_op(struct param_opts *popt, char *pattern, char *value, dup_cache[dup_count++] = strdup(param_name); if (popt->po_show_name) - printf("%s\n", param_name); - break; - case LIST_PATHNAME: - for (j = 0; j < dup_count; j++) { - if (!strcmp(dup_cache[j], param_name)) - break; - } - if (j != dup_count) { - free(param_name); - param_name = NULL; - continue; - } - dup_cache[dup_count++] = strdup(param_name); - if (popt->po_show_name) - printf("%s\n", paths.gl_pathv[i]); + printf("%s\n", popt->po_only_pathname ? + paths.gl_pathv[i] : param_name); break; } @@ -636,6 +649,7 @@ static int listparam_cmdline(int argc, char **argv, struct param_opts *popt) { .val = 'L', .name = "no-links", .has_arg = no_argument}, { .val = 'r', .name = "readable", .has_arg = no_argument}, { .val = 'R', .name = "recursive", .has_arg = no_argument}, + { .val = 't', .name = "tunable", .has_arg = no_argument}, { .val = 'w', .name = "writable", .has_arg = no_argument}, }; @@ -647,7 +661,7 @@ static int listparam_cmdline(int argc, char **argv, struct param_opts *popt) /* reset optind for each getopt_long() in case of multiple calls */ optind = 0; - while ((ch = getopt_long(argc, argv, "DFlLprRw", + while ((ch = getopt_long(argc, argv, "DFlLprRtw", long_opts, NULL)) != -1) { switch (ch) { case 'D': @@ -671,6 +685,9 @@ static int listparam_cmdline(int argc, char **argv, struct param_opts *popt) case 'R': popt->po_recursive = 1; break; + case 't': + popt->po_tunable = 1; + break; case 'w': popt->po_recursive |= S_IWRITE; break; @@ -707,8 +724,7 @@ int jt_lcfg_listparam(int argc, char **argv) continue; } - rc2 = do_param_op(&popt, path, NULL, popt.po_only_pathname ? - LIST_PATHNAME : LIST_PARAM, NULL); + rc2 = do_param_op(&popt, path, NULL, LIST_PARAM, NULL); if (rc2 < 0) { if (rc == 0) rc = rc2; @@ -738,8 +754,10 @@ static int getparam_cmdline(int argc, char **argv, struct param_opts *popt) { .val = 'L', .name = "no-links", .has_arg = no_argument}, { .val = 'n', .name = "no-name", .has_arg = no_argument}, { .val = 'N', .name = "only-name", .has_arg = no_argument}, + { .val = 'N', .name = "name-only", .has_arg = no_argument}, { .val = 'r', .name = "readable", .has_arg = no_argument}, { .val = 'R', .name = "recursive", .has_arg = no_argument}, + { .val = 't', .name = "tunable", .has_arg = no_argument}, { .val = 'w', .name = "writable", .has_arg = no_argument}, { .val = 'y', .name = "yaml", .has_arg = no_argument}, }; @@ -751,7 +769,7 @@ static int getparam_cmdline(int argc, char **argv, struct param_opts *popt) /* reset optind for each getopt_long() in case of multiple calls */ optind = 0; - while ((ch = getopt_long(argc, argv, "FHlLnNrRwy", + while ((ch = getopt_long(argc, argv, "FHlLnNrRtwy", long_opts, NULL)) != -1) { switch (ch) { case 'F': @@ -778,6 +796,9 @@ static int getparam_cmdline(int argc, char **argv, struct param_opts *popt) case 'R': popt->po_recursive = 1; break; + case 't': + popt->po_tunable = 1; + break; case 'w': popt->po_permissions |= S_IWRITE; break; -- 1.8.3.1