From 79a76faa48484cac10344137154ae93c16048d68 Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Tue, 27 Aug 2024 19:30:32 +0800 Subject: [PATCH] LU-18114 lctl: split "lctl net_drop_*" group into subcommands Split "lctl net_drop_*" command group into subcommands, e.g. "lctl net_drop_add" to "lctl net_drop add". Also, sanity-lnet.sh is modified to verify this patch. Test-Parameters: trivial testlist=sanity-lnet Signed-off-by: Emoly Liu Change-Id: I5094328435e5b93a8a7311f26ec77275211e0517 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56154 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin --- lustre/tests/sanity-lnet.sh | 14 ++++++++++++-- lustre/utils/lctl.c | 47 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/lustre/tests/sanity-lnet.sh b/lustre/tests/sanity-lnet.sh index 70b31fc..231a1c6 100755 --- a/lustre/tests/sanity-lnet.sh +++ b/lustre/tests/sanity-lnet.sh @@ -2148,10 +2148,15 @@ cleanup_health_test() { add_health_test_drop_rules() { local args="-m GET -r 1 -e ${1}" local src dst + if (( $MDS1_VERSION >= $(version_code 2.15.65) )); then + net_drop_add="net_drop add" + else + net_drop_add="net_drop_add" + fi for src in "${LNIDS[@]}"; do for dst in "${RNIDS[@]}" "${LNIDS[@]}"; do - $LCTL net_drop_add -s $src -d $dst ${args} || + $LCTL $net_drop_add -s $src -d $dst ${args} || error "Failed to add drop rule $src $dst $args" done done @@ -2159,6 +2164,11 @@ add_health_test_drop_rules() { do_lnet_health_ping_test() { local hstatus="$1" + if (( $MDS1_VERSION >= $(version_code 2.15.65) )); then + net_drop_del="net_drop del" + else + net_drop_del="net_drop_del" + fi echo "Simulate $hstatus" @@ -2170,7 +2180,7 @@ do_lnet_health_ping_test() { lnet_health_post - $LCTL net_drop_del -a + $LCTL $net_drop_del -a return 0 } diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index 23d7482..0f6545c 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -105,6 +105,32 @@ command_t changelog_cmdlist[] = { }; JT_SUBCMD(changelog); +/** + * command_t net_drop_cmdlist - lctl net_drop commands. + */ +command_t net_drop_cmdlist[] = { + {.pc_name = "add", .pc_func = jt_ptl_drop_add, + .pc_help = "Add LNet drop rule\n" + "usage: net_drop add {-s | --source NID}\n" + " {-d | --dest NID}\n" + " {{-r | --rate DROP_RATE} | {-i | --interval SECONDS}}\n" + " [-p | --portal PORTAL...]\n" + " [-m | --message {PUT|ACK|GET|REPLY...}]\n" + " [-e | --health_error]"}, + {.pc_name = "del", .pc_func = jt_ptl_drop_del, + .pc_help = "remove LNet drop rule\n" + "usage: net_drop del {-a | --all} |\n" + " {{-s | --source NID} {-d | --dest NID}}"}, + {.pc_name = "reset", .pc_func = jt_ptl_drop_reset, + .pc_help = "reset drop rule stats\n" + "usage: net_drop reset"}, + {.pc_name = "list", .pc_func = jt_ptl_drop_list, + .pc_help = "list LNet drop rules\n" + "usage: net_drop list"}, + { .pc_help = NULL } +}; +JT_SUBCMD(net_drop); + #ifdef HAVE_SERVER_SUPPORT /** * command_t barrier_cmdlist - lctl barrier commands. @@ -245,22 +271,23 @@ command_t cmdlist[] = { "usage: show_route"}, {"ping", jt_ptl_ping, 0, "Check LNET connectivity\n" "usage: ping nid [timeout [pid]]"}, + {"net_drop_add", jt_ptl_drop_add, 0, "Add LNet drop rule\n" - "usage: net_drop_add <-s | --source NID>\n" - " <-d | --dest NID>\n" - " <<-r | --rate DROP_RATE> |\n" - " <-i | --interval SECONDS>>\n" - " [<-p | --portal> PORTAL...]\n" - " [<-m | --message> ...]\n" - " [< -e | --health_error]\n"}, + "usage: net_drop_add {-s | --source NID}\n" + " {-d | --dest NID}\n" + " {{-r | --rate DROP_RATE} | {-i | --interval SECONDS}}\n" + " [-p | --portal PORTAL...]\n" + " [-m | --message {PUT|ACK|GET|REPLY...}]\n" + " [-e | --health_error]"}, {"net_drop_del", jt_ptl_drop_del, 0, "remove LNet drop rule\n" - "usage: net_drop_del <[-a | --all] |\n" - " <-s | --source NID>\n" - " <-d | --dest NID>>\n"}, + "usage: net_drop_del {-a | --all} |\n" + " {{-s | --source NID} {-d | --dest NID}}"}, {"net_drop_reset", jt_ptl_drop_reset, 0, "reset drop rule stats\n" "usage: net_drop_reset"}, {"net_drop_list", jt_ptl_drop_list, 0, "list LNet drop rules\n" "usage: net_drop_list"}, + {"net_drop", jt_net_drop, net_drop_cmdlist, ""}, + {"net_delay_add", jt_ptl_delay_add, 0, "Add LNet delay rule\n" "usage: net_delay_add <-s | --source NID>\n" " <-d | --dest NID>\n" -- 1.8.3.1