Whamcloud - gitweb
LU-18114 snapshot: split "lctl snapshot_*" group into subcommands 20/56120/4
authorEmoly Liu <emoly@whamcloud.com>
Tue, 27 Aug 2024 11:22:02 +0000 (19:22 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 9 Dec 2024 06:07:56 +0000 (06:07 +0000)
Split "lctl snapshot_*" command group into subcommands, e.g.
"lctl snapshot_create" to "lctl snapshot create".
Also, lsnapshot in test-framework.sh is modified to verify
this patch.

Test-Parameters: trivial fstype=zfs testlist=sanity-lsnapshot
Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Change-Id: I30bf6f8a853f57bd1a14d5acb2b5aa4b3d49be71
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56120
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/test-framework.sh
lustre/utils/lctl.c

index 4599e51..afb0c63 100755 (executable)
@@ -10670,34 +10670,45 @@ killall_process () {
        do_nodes $clients "killall $signal $name"
 }
 
+lsnapshot () {
+       local cmd=$1
+       shift
+
+       if (( $MDS1_VERSION >= $(version_code 2.15.65) )); then
+               do_facet mgs "$LCTL snapshot $cmd -F $FSNAME $*"
+       else
+               do_facet mgs "$LCTL snapshot_$cmd -F $FSNAME $*"
+       fi
+}
+
 lsnapshot_create()
 {
-       do_facet mgs "$LCTL snapshot_create -F $FSNAME $*"
+       lsnapshot create $*
 }
 
 lsnapshot_destroy()
 {
-       do_facet mgs "$LCTL snapshot_destroy -F $FSNAME $*"
+       lsnapshot destroy $*
 }
 
 lsnapshot_modify()
 {
-       do_facet mgs "$LCTL snapshot_modify -F $FSNAME $*"
+       lsnapshot modify $*
 }
 
 lsnapshot_list()
 {
-       do_facet mgs "$LCTL snapshot_list -F $FSNAME $*"
+       lsnapshot list $*
 }
 
 lsnapshot_mount()
 {
-       do_facet mgs "$LCTL snapshot_mount -F $FSNAME $*"
+       lsnapshot mount $*
 }
 
 lsnapshot_umount()
 {
-       do_facet mgs "$LCTL snapshot_umount -F $FSNAME $*"
+       lsnapshot umount $*
 }
 
 lss_err()
index a3a0839..5331d11 100644 (file)
@@ -109,6 +109,49 @@ command_t barrier_cmdlist[] = {
 JT_SUBCMD(barrier);
 
 /**
+ * command_t snaptshot_cmdlist - lctl snapshot commands.
+ */
+command_t snapshot_cmdlist[] = {
+       { .pc_name = "create", .pc_func = jt_snapshot_create,
+         .pc_help = "create the snapshot\n"
+        "usage: snapshot create [-b | --barrier [on | off]]\n"
+        "                       [-c | --comment COMMENT]\n"
+        "                       {-F | --fsname FSNAME}\n"
+        "                       [-h | --help] {-n | --name SSNAME}\n"
+        "                       [-r | --rsh REMOTE_SHELL]\n"
+        "                       [-t | --timeout TIMEOUT]"},
+       {.pc_name = "destroy", .pc_func = jt_snapshot_destroy,
+        .pc_help = "destroy the snapshot\n"
+        "usage: snapshot destroy [-f | --force]\n"
+        "                        {-F | --fsname FSNAME} [-h | --help]\n"
+        "                        {-n | --name SSNAME}\n"
+        "                        [-r | --rsh REMOTE_SHELL]"},
+       {.pc_name = "modify", .pc_func = jt_snapshot_modify,
+        .pc_help = "modify the snapshot\n"
+        "usage: snapshot modify [-c | --comment COMMENT]\n"
+        "                       {-F | --fsname FSNAME} [-h | --help]\n"
+        "                       {-n | --name SSNAME} [-N | --new NEW_SSNAME]\n"
+        "                       [-r | --rsh REMOTE_SHELL]"},
+       {.pc_name = "list", .pc_func = jt_snapshot_list,
+        .pc_help = "query the snapshot(s)\n"
+        "usage: snapshot list [-d | --detail]\n"
+        "                     {-F | --fsname FSNAME} [-h | --help]\n"
+        "                     [-n | --name SSNAME] [-r | --rsh REMOTE_SHELL]"},
+       {.pc_name = "mount", .pc_func = jt_snapshot_mount,
+        .pc_help = "mount the snapshot\n"
+        "usage: snapshot mount {-F | --fsname FSNAME} [-h | --help]\n"
+        "                      {-n | --name SSNAME}\n"
+        "                      [-r | --rsh REMOTE_SHELL]"},
+       {.pc_name = "umount", .pc_func = jt_snapshot_umount,
+        .pc_help = "umount the snapshot\n"
+        "usage: snapshot umount {-F | --fsname FSNAME} [-h | --help]\n"
+        "                       {-n | --name SSNAME}\n"
+        "                       [-r | --rsh REMOTE_SHELL]"},
+       {.pc_help = NULL }
+};
+JT_SUBCMD(snapshot);
+
+/**
  * command_t lfsck_cmdlist - lctl lfsck commands.
  */
 command_t lfsck_cmdlist[] = {
@@ -349,38 +392,39 @@ command_t cmdlist[] = {
        {"snapshot_create", jt_snapshot_create, 0,
         "create the snapshot\n"
         "usage: snapshot_create [-b | --barrier [on | off]]\n"
-        "                       [-c | --comment comment]\n"
-        "                       <-F | --fsname fsname>\n"
-        "                       [-h | --help] <-n | --name ssname>\n"
-        "                       [-r | --rsh remote_shell]\n"
-        "                       [-t | --timeout timeout]"},
+        "                       [-c | --comment COMMENT]\n"
+        "                       {-F | --fsname FSNAME}\n"
+        "                       [-h | --help] {-n | --name SSNAME}\n"
+        "                       [-r | --rsh REMOTE_SHELL]\n"
+        "                       [-t | --timeout TIMEOUT]"},
        {"snapshot_destroy", jt_snapshot_destroy, 0,
         "destroy the snapshot\n"
         "usage: snapshot_destroy [-f | --force]\n"
-        "                        <-F | --fsname fsname> [-h | --help]\n"
-        "                        <-n | --name ssname>\n"
-        "                        [-r | --rsh remote_shell]"},
+        "                        {-F | --fsname FSNAME} [-h | --help]\n"
+        "                        {-n | --name SSNAME}\n"
+        "                        [-r | --rsh REMOTE_SHELL]"},
        {"snapshot_modify", jt_snapshot_modify, 0,
         "modify the snapshot\n"
-        "usage: snapshot_modify [-c | --comment comment]\n"
-        "                       <-F | --fsname fsname> [-h | --help]\n"
-        "                       <-n | --name ssname> [-N | --new new_ssname]\n"
-        "                       [-r | --rsh remote_shell]"},
+        "usage: snapshot_modify [-c | --comment COMMENT]\n"
+        "                       {-F | --fsname FSNAME} [-h | --help]\n"
+        "                       {-n | --name SSNAME} [-N | --new NEW_SSNAME]\n"
+        "                       [-r | --rsh REMOTE_SHELL]"},
        {"snapshot_list", jt_snapshot_list, 0,
         "query the snapshot(s)\n"
         "usage: snapshot_list [-d | --detail]\n"
-        "                     <-F | --fsname fsname> [-h | --help]\n"
-        "                     [-n | --name ssname] [-r | --rsh remote_shell]"},
+        "                     {-F | --fsname FSNAME} [-h | --help]\n"
+        "                     [-n | --name SSNAME] [-r | --rsh REMOTE_SHELL]"},
        {"snapshot_mount", jt_snapshot_mount, 0,
         "mount the snapshot\n"
-        "usage: snapshot_mount <-F | --fsname fsname> [-h | --help]\n"
-        "                      <-n | --name ssname>\n"
-        "                      [-r | --rsh remote_shell]"},
+        "usage: snapshot_mount {-F | --fsname FSNAME} [-h | --help]\n"
+        "                      {-n | --name SSNAME}\n"
+        "                      [-r | --rsh REMOTE_SHELL]"},
        {"snapshot_umount", jt_snapshot_umount, 0,
         "umount the snapshot\n"
-        "usage: snapshot_umount <-F | --fsname fsname> [-h | --help]\n"
-        "                       <-n | --name ssname>\n"
-        "                       [-r | --rsh remote_shell]"},
+        "usage: snapshot_umount {-F | --fsname FSNAME} [-h | --help]\n"
+        "                       {-n | --name SSNAME}\n"
+        "                       [-r | --rsh REMOTE_SHELL]"},
+       {"snapshot", jt_snapshot, snapshot_cmdlist, ""},
 #endif /* HAVE_SERVER_SUPPORT */
        /* Nodemap commands */
        {"=== Nodemap ===", NULL, 0, "nodemap management"},