From: Heming Zhao <heming.zhao@suse.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 02/10] dlm_tool: add run_(check|cancel) all feature
Date: Sun, 19 Sep 2021 14:43:14 +0800 [thread overview]
Message-ID: <20210919064322.1670-3-heming.zhao@suse.com> (raw)
In-Reply-To: <20210919064322.1670-1-heming.zhao@suse.com>
Current run_check and run_cancel require uuid for executing.
If users want to check/cancel all commands, they must input every
command uuid, which is a boring action.
This commit add a new option "-A", which makes one time travel
all the command without uuid.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
dlm_tool/dlm_tool.8 | 5 ++-
dlm_tool/main.c | 80 ++++++++++++++++++++++++++++++++-------------
2 files changed, 62 insertions(+), 23 deletions(-)
diff --git a/dlm_tool/dlm_tool.8 b/dlm_tool/dlm_tool.8
index 056c4af0213c..086596c67dbf 100644
--- a/dlm_tool/dlm_tool.8
+++ b/dlm_tool/dlm_tool.8
@@ -110,6 +110,9 @@ Wide lockdebug output
.B \-M
Include MSTCPY locks in lockdump output
+.B \-A
+Include all uuid in run_check and run_cancel
+
.B \-h
Print help, then exit
@@ -177,7 +180,7 @@ dlm_tool run|run_start [-n] \fIcommand\fP
-
-dlm_tool run_check|run_cancel [-i "sec"] \fIuuid\fP
+dlm_tool run_check|run_cancel [-A] [-i "sec"] \fIuuid\fP
-
diff --git a/dlm_tool/main.c b/dlm_tool/main.c
index 53d9336d59c6..37f381f6d980 100644
--- a/dlm_tool/main.c
+++ b/dlm_tool/main.c
@@ -53,6 +53,7 @@ static char *lsname;
static int operation;
static int opt_ind;
static int ls_all_nodes = 0;
+static int opt_all_uuid = 0;
static int opt_excl = 0;
static int opt_fs = 0;
static int dump_mstcpy = 0;
@@ -215,7 +216,7 @@ static void print_usage(void)
printf("\n");
}
-#define OPTION_STRING "MhVnm:e:f:vwsi:"
+#define OPTION_STRING "MhVAnm:e:f:vwsi:"
static void decode_arguments(int argc, char **argv)
{
@@ -254,6 +255,10 @@ static void decode_arguments(int argc, char **argv)
ls_all_nodes = 1;
break;
+ case 'A':
+ opt_all_uuid = 1;
+ break;
+
case 's':
summarize = 1;
break;
@@ -456,8 +461,10 @@ static void decode_arguments(int argc, char **argv)
fprintf(stderr, "command required\n");
exit(EXIT_FAILURE);
} else if (need_uuid) {
- fprintf(stderr, "uuid required\n");
- exit(EXIT_FAILURE);
+ if (!opt_all_uuid) {
+ fprintf(stderr, "uuid required\n");
+ exit(EXIT_FAILURE);
+ }
} else {
fprintf(stderr, "missing arg\n");
exit(EXIT_FAILURE);
@@ -1486,14 +1493,42 @@ static void do_log_plock(void)
printf("\n");
}
+static int check_or_cancel(int do_cancel)
+{
+ uint32_t flags = 0;
+ uint32_t check_status = 0;
+ int rv = 0;
+
+ if (do_cancel)
+ flags = DLMC_FLAG_RUN_CHECK_CANCEL;
+ else
+ flags = DLMC_FLAG_RUN_CHECK_CLEAR;
+
+ rv = dlmc_run_check(run_uuid, strlen(run_uuid), wait_sec, flags,
+ &check_status);
+
+ printf("check_status: ");
+
+ if (check_status & DLMC_RUN_STATUS_WAITING)
+ printf("waiting ");
+ if (check_status & DLMC_RUN_STATUS_DONE)
+ printf("done ");
+ if (check_status & DLMC_RUN_STATUS_FAILED)
+ printf("failed ");
+ printf("\n");
+ return rv;
+}
+
static int do_run(int op)
{
int do_start = (op == OP_RUN) || (op == OP_RUN_START);
int do_check = (op == OP_RUN) || (op == OP_RUN_CHECK);
int do_cancel = (op == OP_RUN_CANCEL);
uint32_t flags = 0;
- uint32_t check_status = 0;
- int rv = 0;
+ int rv = 0, pos = 0;
+ char buf[DLMC_DUMP_SIZE];
+ char *p;
+
if (do_start) {
/* FIXME: use proper option to specify */
@@ -1508,23 +1543,24 @@ static int do_run(int op)
}
if (do_check || do_cancel) {
- if (do_cancel)
- flags = DLMC_FLAG_RUN_CHECK_CANCEL;
- else
- flags = DLMC_FLAG_RUN_CHECK_CLEAR;
-
- rv = dlmc_run_check(run_uuid, strlen(run_uuid), wait_sec, flags,
- &check_status);
-
- printf("check_status: ");
-
- if (check_status & DLMC_RUN_STATUS_WAITING)
- printf("waiting ");
- if (check_status & DLMC_RUN_STATUS_DONE)
- printf("done ");
- if (check_status & DLMC_RUN_STATUS_FAILED)
- printf("failed ");
- printf("\n");
+ if (opt_all_uuid) {
+ memset(buf, 0, sizeof(buf));
+ dlmc_dump_run(buf);
+ buf[DLMC_DUMP_SIZE-1] = '\0';
+ while (1) {
+ p = strstr(buf + pos, "run_uuid ");
+ if (!p)
+ break;
+ pos = p - buf;
+ sscanf(buf + pos, "run_uuid %s start_nodeid", run_uuid);
+ pos += 10 + strlen(run_uuid); /* 10: "run_uuid" + 2 spaces */
+ printf("uuid: %s\n", run_uuid);
+ rv += check_or_cancel(do_cancel);
+ }
+ return rv;
+ } else {
+ rv = check_or_cancel(do_cancel);
+ }
}
return rv;
--
2.32.0
next prev parent reply other threads:[~2021-09-19 6:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-19 6:43 [Cluster-devel] [RFC PATCH dlm 00/10] dlm_controld config settings can be Heming Zhao
2021-09-19 6:43 ` [Cluster-devel] [PATCH 01/10] dlm_tool man: add command "joinleave", add "USAGE" section Heming Zhao
2021-09-19 6:43 ` Heming Zhao [this message]
2021-09-19 6:43 ` [Cluster-devel] [PATCH 03/10] dlm_tool man: add dynamic setting and examples Heming Zhao
2021-09-19 6:43 ` [Cluster-devel] [PATCH 04/10] dlm_controld: put MAX_LINE in header file Heming Zhao
2021-09-19 6:43 ` [Cluster-devel] [PATCH 05/10] dlm_controld: add dynamic setting items in "struct dlm_option" Heming Zhao
2021-09-19 6:43 ` [Cluster-devel] [PATCH 06/10] dlm_controld: change dlm_options[] to shared memory type Heming Zhao
2021-09-19 6:43 ` [Cluster-devel] [PATCH 07/10] dlm_controld: make few APIs public Heming Zhao
2021-09-19 6:43 ` [Cluster-devel] [PATCH 08/10] dlm_controld: support "dlm_tool dump_config" to show dynamic setting Heming Zhao
2021-09-19 6:43 ` [Cluster-devel] [PATCH 09/10] dlm_controld: add new API set_opt_online() Heming Zhao
2021-09-19 6:43 ` [Cluster-devel] [PATCH 10/10] dlm_controld: enable "dlm_tool run|run_start" dynamic setting feature Heming Zhao
2021-09-20 17:57 ` [Cluster-devel] [RFC PATCH dlm 00/10] dlm_controld config settings can be David Teigland
2021-09-21 6:38 ` heming.zhao
2021-09-21 13:54 ` David Teigland
2021-09-22 9:32 ` heming.zhao
2021-09-22 13:46 ` David Teigland
2021-09-22 14:35 ` heming.zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210919064322.1670-3-heming.zhao@suse.com \
--to=heming.zhao@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).