From fe4b49635d85fead1efbb4f06ac2c9e68ba76dfc Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Wed, 11 Dec 2024 17:23:38 +0800 Subject: [PATCH] LU-18114 llog: split "lctl llog_*" group into subcommands Split "lctl llog_*" command group into subcommands, e.g. "lctl llog_info" to "lctl llog info". Also, conf-sanity.sh test_123ad is modified to verify this patch. Signed-off-by: Emoly Liu Change-Id: Iea1cbfac61ff807d793a7a48dafa73915b06639d Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56040 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Zhenyu Xu Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger --- lustre/doc/lctl-llog-cancel.8 | 1 + lustre/doc/lctl-llog-catlist.8 | 1 + lustre/doc/lctl-llog-info.8 | 1 + lustre/doc/lctl-llog-print.8 | 1 + lustre/tests/conf-sanity.sh | 15 +++++++++++---- lustre/utils/lctl.c | 36 +++++++++++++++++++++++++++++++++--- 6 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 lustre/doc/lctl-llog-cancel.8 create mode 100644 lustre/doc/lctl-llog-catlist.8 create mode 100644 lustre/doc/lctl-llog-info.8 create mode 100644 lustre/doc/lctl-llog-print.8 diff --git a/lustre/doc/lctl-llog-cancel.8 b/lustre/doc/lctl-llog-cancel.8 new file mode 100644 index 0000000..12682db --- /dev/null +++ b/lustre/doc/lctl-llog-cancel.8 @@ -0,0 +1 @@ +.so man8/lctl-llog-cancel.8 \ No newline at end of file diff --git a/lustre/doc/lctl-llog-catlist.8 b/lustre/doc/lctl-llog-catlist.8 new file mode 100644 index 0000000..07ec8f9 --- /dev/null +++ b/lustre/doc/lctl-llog-catlist.8 @@ -0,0 +1 @@ +.so man8/lctl-llog-catlist.8 \ No newline at end of file diff --git a/lustre/doc/lctl-llog-info.8 b/lustre/doc/lctl-llog-info.8 new file mode 100644 index 0000000..044e38d --- /dev/null +++ b/lustre/doc/lctl-llog-info.8 @@ -0,0 +1 @@ +.so man8/lctl-llog-info.8 \ No newline at end of file diff --git a/lustre/doc/lctl-llog-print.8 b/lustre/doc/lctl-llog-print.8 new file mode 100644 index 0000000..d13928d --- /dev/null +++ b/lustre/doc/lctl-llog-print.8 @@ -0,0 +1 @@ +.so man8/lctl-llog_print.8 \ No newline at end of file diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 769dce7..eaa5837 100755 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -10552,6 +10552,13 @@ run_test 123ac "llog_print with --start and --end" test_123ad() { # LU-11566 remote_mgs_nodsh && skip "remote MGS with nodsh" + if (( $MDS1_VERSION >= $(version_code 2.16.50) )); then + llog_info="llog info" + llog_print="llog print" + else + llog_info="llog_info" + llog_print="llog_print" + fi # older versions of lctl may not print all records properly (( MGS_VERSION >= $(version_code 2.15.90) )) || skip "Need MGS version at least 2.15.90" @@ -10567,17 +10574,17 @@ test_123ad() { # LU-11566 # flags: 4 (plain) # records_count: 72 # last_index: 72 - local num=$(do_facet mgs $LCTL --device MGS llog_info $FSNAME-client | + local num=$(do_facet mgs $LCTL --device MGS $llog_info $FSNAME-client | awk '/last_index:/ { print $2 }') - do_facet mgs $LCTL --device MGS llog_print $FSNAME-client | + do_facet mgs $LCTL --device MGS $llog_print $FSNAME-client | grep -q "$FSNAME-OST0000.*osc\.max_dirty_mb=$old" || error "ocs.max_dirty_mb=$old not found in $FSNAME-client" # - { index: 72, event: marker, flags: 0x06, ... } - local last=$(do_facet mgs $LCTL --device MGS llog_print -r $FSNAME-client | + local last=$(do_facet mgs $LCTL --device MGS $llog_print -r $FSNAME-client | tail -1 | awk '{ print $4 }' | tr -d , ) - (( last == num )) || error "llog_print only showed $last/$num records" + (( last == num )) || error "$llog_print only showed $last/$num records" } run_test 123ad "llog_print shows all records" diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index c30fd8b..cffbada 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -280,6 +280,34 @@ command_t snapshot_cmdlist[] = { JT_SUBCMD(snapshot); /** + * command_t llog_cmdlist - lctl llog commands. + */ +command_t llog_cmdlist[] = { + { .pc_name = "catlist", .pc_func = jt_llog_catlist, + .pc_help = "list Lustre configuration log files\n" + "usage: llog catlist"}, + { .pc_name = "info", .pc_func = jt_llog_info, + .pc_help = "print log header information\n" + "usage: llog info {LOGNAME|FID}"}, + { .pc_name = "print", .pc_func = jt_llog_print, + .pc_help = "print the content of a configuration log\n" + "usage: llog print {LOGNAME|FID} [--start INDEX] [--end INDEX]\n" + " [--raw]"}, + { .pc_name = "cancel", .pc_func = jt_llog_cancel, + .pc_help = "cancel one record in specified log.\n" + "usage:llog cancel {LOGNAME|FID} --log_idx INDEX"}, + { .pc_name = "check", .pc_func = jt_llog_check, + .pc_help = "verify that log content is valid.\n" + "usage: llog_check {LOGNAME|FID} [--start INDEX] [--end INDEX]\n" + " check all records from index 1 by default."}, + { .pc_name = "remove", .pc_func = jt_llog_check, + .pc_help = "remove one log and erase it from disk.\n" + "usage: llog remove {LOGNAME|FID} [--log_id ID]"}, + { .pc_help = NULL } +}; +JT_SUBCMD(llog); + +/** * command_t lfsck_cmdlist - lctl lfsck commands. */ command_t lfsck_cmdlist[] = { @@ -674,15 +702,15 @@ command_t cmdlist[] = { "usage: llog_catlist"}, {"llog_info", jt_llog_info, 0, "print log header information.\n" - "usage: llog_info {LOGNAME|FID}\n"}, + "usage: llog_info {LOGNAME|FID}"}, {"llog_print", jt_llog_print, 0, "print all effective log records by default, or within given range.\n" "With --raw option skipped records are printed as well.\n" "usage: llog_print {LOGNAME|FID} [--start INDEX] [--end INDEX]\n" - " [--raw]\n"}, + " [--raw]"}, {"llog_cancel", jt_llog_cancel, 0, "cancel one record in specified log.\n" - "usage:llog_cancel {LOGNAME|FID} --log_idx INDEX\n"}, + "usage:llog_cancel {LOGNAME|FID} --log_idx INDEX"}, {"llog_check", jt_llog_check, 0, "verify that log content is valid.\n" "usage: llog_check {LOGNAME|FID} [--start INDEX] [--end INDEX]\n" @@ -690,6 +718,8 @@ command_t cmdlist[] = { {"llog_remove", jt_llog_remove, 0, "remove one log from catalog or plain log, erase it from disk.\n" "usage: llog_remove {LOGNAME|FID} [--log_id ID]"}, + {"llog", jt_llog, llog_cmdlist, ""}, + {"lcfg_clear", jt_lcfg_clear, 0, "drop unused config llog records for a device or filesystem.\n" "clients and servers must be unmounted during this operation.\n" -- 1.8.3.1