Whamcloud - gitweb
LU-18114 lfsck: split "lctl lfsck_*" group into subcommands 97/55997/7
authorEmoly Liu <emoly@whamcloud.com>
Thu, 15 Aug 2024 08:00:55 +0000 (16:00 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 30 Aug 2024 06:00:41 +0000 (06:00 +0000)
Split "lctl lfsck_*" command group into subcommands, e.g.
"lctl lfsck_start" to "lctl lfsck start".
Also, sanity-lfsck.sh test_12a is modified a little to verify
this patch.

Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Change-Id: I039f8942b45a16a26386b579919018163e0d8c7c
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55997
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Frederick Dilger <fdilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-lfsck.sh
lustre/utils/lctl.c

index b9fb321..971fdbe 100755 (executable)
@@ -1492,6 +1492,13 @@ test_12a() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
        (( $MDS1_VERSION > $(version_code 2.5.55) )) ||
                skip "MDS older than 2.5.55, LU-3950"
+       if (( $MDS1_VERSION >= $(version_code 2.15.65) )); then
+               lfsck_start="lfsck start"
+               lfsck_stop="lfsck stop"
+       else
+               lfsck_start="lfsck_start"
+               lfsck_stop="lfsck_stop"
+       fi
 
        check_mount_and_prep
        for k in $(seq $MDSCOUNT); do
@@ -1501,21 +1508,21 @@ test_12a() {
        done
 
        echo "Start namespace LFSCK on all targets by single command (-s 1)."
-       do_facet mds1 $LCTL lfsck_start -M ${FSNAME}-MDT0000 -t namespace -A \
+       do_facet mds1 $LCTL $lfsck_start -M ${FSNAME}-MDT0000 -t namespace -A \
                -s 1 -r || error "(2) Fail to start LFSCK on all devices!"
 
        echo "All the LFSCK targets should be in 'scanning-phase1' status."
        wait_all_targets namespace scanning-phase1 3
 
        echo "Stop namespace LFSCK on all targets by single lctl command."
-       do_facet mds1 $LCTL lfsck_stop -M ${FSNAME}-MDT0000 -A ||
+       do_facet mds1 $LCTL $lfsck_stop -M ${FSNAME}-MDT0000 -A ||
                error "(4) Fail to stop LFSCK on all devices!"
 
        echo "All the LFSCK targets should be in 'stopped' status."
        wait_all_targets_blocked namespace stopped 5
 
        echo "Re-start namespace LFSCK on all targets by single command (-s 0)."
-       do_facet mds1 $LCTL lfsck_start -M ${FSNAME}-MDT0000 -t namespace -A \
+       do_facet mds1 $LCTL $lfsck_start -M ${FSNAME}-MDT0000 -t namespace -A \
                -s 0 -r || error "(6) Fail to start LFSCK on all devices!"
 
        echo "All the LFSCK targets should be in 'completed' status."
@@ -1524,14 +1531,14 @@ test_12a() {
        start_full_debug_logging
 
        echo "Start layout LFSCK on all targets by single command (-s 1)."
-       do_facet mds1 $LCTL lfsck_start -M ${FSNAME}-MDT0000 -t layout -A \
+       do_facet mds1 $LCTL $lfsck_start -M ${FSNAME}-MDT0000 -t layout -A \
                -s 1 -r || error "(8) Fail to start LFSCK on all devices!"
 
        echo "All the LFSCK targets should be in 'scanning-phase1' status."
        wait_all_targets layout scanning-phase1 9
 
        echo "Stop layout LFSCK on all targets by single lctl command."
-       do_facet mds1 $LCTL lfsck_stop -M ${FSNAME}-MDT0000 -A ||
+       do_facet mds1 $LCTL $lfsck_stop -M ${FSNAME}-MDT0000 -A ||
                error "(10) Fail to stop LFSCK on all devices!"
 
        echo "All the LFSCK targets should be in 'stopped' status."
@@ -1546,7 +1553,7 @@ test_12a() {
        done
 
        echo "Re-start layout LFSCK on all targets by single command (-s 0)."
-       do_facet mds1 $LCTL lfsck_start -M ${FSNAME}-MDT0000 -t layout -A \
+       do_facet mds1 $LCTL $lfsck_start -M ${FSNAME}-MDT0000 -t layout -A \
                -s 0 -r || error "(13) Fail to start LFSCK on all devices!"
 
        echo "All the LFSCK targets should be in 'completed' status."
index 564acfd..6cc06eb 100644 (file)
 #include <lustre/lustreapi.h>
 #include "lctl_thread.h"
 
-static int jt_pcc(int argc, char **argv);
+#define JT_SUBCMD(name)                                                \
+static int jt_##name(int argc, char **argv)                    \
+{                                                              \
+       char cmd[PATH_MAX];                                     \
+       int rc = 0;                                             \
+                                                               \
+       setlinebuf(stdout);                                     \
+                                                               \
+       snprintf(cmd, sizeof(cmd), "%s %s",                     \
+                program_invocation_short_name, argv[0]);       \
+       program_invocation_short_name = cmd;                    \
+       rc = cfs_parser(argc, argv, name##_cmdlist);            \
+                                                               \
+       return rc < 0 ? -rc : rc;                               \
+}
 
 /**
  * command_t pccdev_cmdlist - lctl pcc commands.
  */
-command_t pccdev_cmdlist[] = {
+command_t pcc_cmdlist[] = {
        { .pc_name = "add", .pc_func = jt_pcc_add,
          .pc_help = "Add a PCC backend to a client.\n"
                "usage: lctl pcc add <mntpath> <pccpath> [--param|-p <param>]\n"
@@ -61,7 +75,7 @@ command_t pccdev_cmdlist[] = {
                "\tparam:   Setting parameters for PCC backend.\n" },
        { .pc_name = "del", .pc_func = jt_pcc_del,
          .pc_help = "Delete the specified PCC backend on a client.\n"
-               "usage: clt pcc del <mntpath> <pccpath>\n" },
+               "usage: lctl pcc del <mntpath> <pccpath>\n" },
        { .pc_name = "clear", .pc_func = jt_pcc_clear,
          .pc_help = "Remove all PCC backend on a client.\n"
                "usage: lctl pcc clear <mntpath>\n" },
@@ -70,6 +84,37 @@ command_t pccdev_cmdlist[] = {
                "usage: lctl pcc list <mntpath>\n" },
        { .pc_help = NULL }
 };
+JT_SUBCMD(pcc);
+
+#ifdef HAVE_SERVER_SUPPORT
+/**
+ * command_t lfsck_cmdlist - lctl lfsck commands.
+ */
+command_t lfsck_cmdlist[] = {
+       { .pc_name = "start", .pc_func = jt_lfsck_start,
+         .pc_help = "Start online Lustre File System Check.\n"
+        "usage: lfsck start [--device|-M {MDT,OST}_DEVICE]\n"
+        "                   [--all|-A] [--create-ostobj|-c [on | off]]\n"
+        "                   [--create-mdtobj|-C [on | off]]\n"
+        "                   [--delay-create-ostobj|-d [on | off]]\n"
+        "                   [--error|-e {continue | abort}] [--help|-h]\n"
+        "                   [--dryrun|-n [on | off]] [--orphan|-o]\n"
+        "                   [--reset|-r] [--speed|-s SPEED_LIMIT]\n"
+        "                   [--type|-t {all|default|scrub|layout|namespace}]\n"
+        "                   [--window-size|-w SIZE]"},
+       { .pc_name = "stop", .pc_func = jt_lfsck_stop,
+         .pc_help = "Stop online Lustre File System Check.\n"
+        "usage: lfsck stop [--device|-M {MDT,OST}_DEVICE]\n"
+        "                  [--all|-A] [--help|-h]"},
+       { .pc_name = "query", .pc_func = jt_lfsck_query,
+         .pc_help = "Get Lustre File System Check global status.\n"
+        "usage: lfsck query [--device|-M MDT_DEVICE] [--help|-h]\n"
+        "                   [--type|-t {all|default|scrub|layout|namespace}]\n"
+        "                   [--wait|-w]"},
+       { .pc_help = NULL }
+};
+JT_SUBCMD(lfsck);
+#endif
 
 command_t cmdlist[] = {
        /* Metacommands */
@@ -366,7 +411,7 @@ command_t cmdlist[] = {
 
        /* Persistent Client Cache (PCC) commands */
        {"=== Persistent Client Cache ===", NULL, 0, "PCC user management"},
-       {"pcc", jt_pcc, pccdev_cmdlist,
+       {"pcc", jt_pcc, pcc_cmdlist,
         "lctl commands used to interact with PCC features:\n"
         "lctl pcc add    - add a PCC backend to a client\n"
         "lctl pcc del    - delete a PCC backend on a client\n"
@@ -408,6 +453,7 @@ command_t cmdlist[] = {
         "usage: lfsck_query [--device|-M MDT_device] [--help|-h]\n"
         "                   [--type|-t lfsck_type[,lfsck_type...]]\n"
         "                   [--wait|-w]"},
+       {"lfsck", jt_lfsck, lfsck_cmdlist, ""},
 
        /* Llog operations */
        {"==== LLOG ====", NULL, 0, "LLOG"},
@@ -558,31 +604,6 @@ command_t cmdlist[] = {
        { 0, 0, 0, NULL }
 };
 
-/**
- * jt_pcc() - Parse and execute lctl pcc commands.
- * @argc: The count of lctl pcc command line arguments.
- * @argv: Array of strings for lctl pcc command line arguments.
- *
- * This function parses lfs pcc commands and performs the
- * corresponding functions specified in pccdev_cmdlist[].
- *
- * Return: 0 on success or an error code on failure.
- */
-static int jt_pcc(int argc, char **argv)
-{
-       char cmd[PATH_MAX];
-       int rc = 0;
-
-       setlinebuf(stdout);
-
-       snprintf(cmd, sizeof(cmd), "%s %s", program_invocation_short_name,
-                argv[0]);
-       program_invocation_short_name = cmd;
-       rc = cfs_parser(argc, argv, pccdev_cmdlist);
-
-       return rc < 0 ? -rc : rc;
-}
-
 static int lctl_main(int argc, char **argv)
 {
        int rc;