* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-10-26 20:57 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-10-26 20:57 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: teigland at sourceware.org 2007-10-26 20:57:55
Modified files:
dlm/tool : main.c
Log message:
sync with HEAD, except deadlock stuff within #if DEADLOCK
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.7&r2=1.2.2.8
--- cluster/dlm/tool/main.c 2007/10/17 19:07:51 1.2.2.7
+++ cluster/dlm/tool/main.c 2007/10/26 20:57:55 1.2.2.8
@@ -24,7 +24,10 @@
#include <netinet/in.h>
#include "libdlm.h"
-/* #include "dlm_controld.h" */
+
+#if DEADLOCK
+#include "dlm_controld.h"
+#endif
#define OPTION_STRING "MhVvd:m:"
@@ -74,7 +77,7 @@
switch (optchar) {
case 'm':
memset(modebuf, 0, sizeof(modebuf));
- snprintf(modebuf, 8, optarg);
+ snprintf(modebuf, 8, "%s", optarg);
sscanf(modebuf, "%o", &create_mode);
break;
@@ -145,15 +148,15 @@
operation = OP_LOCKDEBUG;
opt_ind = optind + 1;
break;
- }
-#if 0
} else if (!strncmp(argv[optind], "spaces", 9) &&
(strlen(argv[optind]) == 6)) {
operation = OP_SPACES;
opt_ind = optind + 1;
need_lsname = 0;
break;
- } else if (!strncmp(argv[optind], "deadlock_check", 14) &&
+ }
+#if DEADLOCK
+ else if (!strncmp(argv[optind], "deadlock_check", 14) &&
(strlen(argv[optind]) == 14)) {
operation = OP_DEADLOCK_CHECK;
opt_ind = optind + 1;
@@ -176,7 +179,6 @@
}
}
-#if 0
static int do_write(int fd, void *buf, size_t count)
{
int rv, off = 0;
@@ -195,7 +197,6 @@
}
return 0;
}
-#endif
void do_join(char *name)
{
@@ -389,7 +390,6 @@
fclose(file);
}
-#if 0
void do_spaces(void)
{
/* TODO: get info from /sys/kernel/config/ */
@@ -419,6 +419,7 @@
return fd;
}
+#if DEADLOCK
static void do_deadlock_check(char *name)
{
char buf[DLM_CONTROLD_MSGLEN];
@@ -470,16 +471,16 @@
case OP_LOCKDEBUG:
do_lockdebug(lsname);
break;
-#if 0
+
case OP_SPACES:
do_spaces();
break;
-
+#if DEADLOCK
case OP_DEADLOCK_CHECK:
do_deadlock_check(lsname);
break;
-#endif
}
+#endif
return 0;
}
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-10-26 21:23 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-10-26 21:23 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: teigland at sourceware.org 2007-10-26 21:23:50
Modified files:
dlm/tool : main.c
Log message:
xid needs to be unsigned long long
#endif on wrong line from last commit
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.8&r2=1.2.2.9
--- cluster/dlm/tool/main.c 2007/10/26 20:57:55 1.2.2.8
+++ cluster/dlm/tool/main.c 2007/10/26 21:23:49 1.2.2.9
@@ -316,7 +316,7 @@
int r_len;
int rv;
unsigned int time;
- uint64_t xid;
+ unsigned long long xid;
uint32_t id;
int nodeid;
uint32_t remid;
@@ -479,8 +479,8 @@
case OP_DEADLOCK_CHECK:
do_deadlock_check(lsname);
break;
- }
#endif
+ }
return 0;
}
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-10-26 21:23 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-10-26 21:23 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-10-26 21:23:08
Modified files:
dlm/tool : main.c
Log message:
xid needs to be unsigned long long
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=1.11&r2=1.12
--- cluster/dlm/tool/main.c 2007/10/26 18:51:31 1.11
+++ cluster/dlm/tool/main.c 2007/10/26 21:23:08 1.12
@@ -310,7 +310,7 @@
int r_len;
int rv;
unsigned int time;
- uint64_t xid;
+ unsigned long long xid;
uint32_t id;
int nodeid;
uint32_t remid;
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-10-26 18:51 rmccabe
0 siblings, 0 replies; 21+ messages in thread
From: rmccabe @ 2007-10-26 18:51 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rmccabe at sourceware.org 2007-10-26 18:51:31
Modified files:
dlm/tool : main.c
Log message:
Fix format string bug
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=1.10&r2=1.11
--- cluster/dlm/tool/main.c 2007/10/17 19:11:30 1.10
+++ cluster/dlm/tool/main.c 2007/10/26 18:51:31 1.11
@@ -74,7 +74,7 @@
switch (optchar) {
case 'm':
memset(modebuf, 0, sizeof(modebuf));
- snprintf(modebuf, 8, optarg);
+ snprintf(modebuf, 8, "%s", optarg);
sscanf(modebuf, "%o", &create_mode);
break;
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-10-17 19:11 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-10-17 19:11 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-10-17 19:11:30
Modified files:
dlm/tool : main.c
Log message:
used wrong define, DLM_LOCK_ instead of LKM_
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=1.9&r2=1.10
--- cluster/dlm/tool/main.c 2007/10/17 18:08:47 1.9
+++ cluster/dlm/tool/main.c 2007/10/17 19:11:30 1.10
@@ -374,7 +374,7 @@
e.g. G,C,W?) */
if (status == DLM_LKSTS_GRANTED)
- rqmode = DLM_LOCK_NL;
+ rqmode = LKM_NLMODE;
printf("id %08x gr %s rq %s pid %u master %d \"%s\"\n",
id, mode_str(grmode), mode_str(rqmode),
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-10-17 19:07 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-10-17 19:07 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: teigland at sourceware.org 2007-10-17 19:07:52
Modified files:
dlm/tool : main.c
Log message:
used wrong define, DLM_LOCK_ instead of LKM_
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.6&r2=1.2.2.7
--- cluster/dlm/tool/main.c 2007/10/17 18:10:56 1.2.2.6
+++ cluster/dlm/tool/main.c 2007/10/17 19:07:51 1.2.2.7
@@ -379,7 +379,7 @@
e.g. G,C,W?) */
if (status == DLM_LKSTS_GRANTED)
- rqmode = DLM_LOCK_NL;
+ rqmode = LKM_NLMODE;
printf("id %08x gr %s rq %s pid %u master %d \"%s\"\n",
id, mode_str(grmode), mode_str(rqmode),
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-10-17 18:10 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-10-17 18:10 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: teigland at sourceware.org 2007-10-17 18:10:56
Modified files:
dlm/tool : main.c
Log message:
The output of 'dlm_tool lockdump' could make it appear that a granted
lock was still converting because the rqmode reported by the kernel
is not reset to IV when a NOQUEUE convert fails.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.5&r2=1.2.2.6
--- cluster/dlm/tool/main.c 2007/08/20 20:48:05 1.2.2.5
+++ cluster/dlm/tool/main.c 2007/10/17 18:10:56 1.2.2.6
@@ -372,6 +372,15 @@
continue;
}
+ /* A hack because dlm-kernel doesn't set rqmode back to NL when
+ a NOQUEUE convert fails, which means in a lockdump it looks
+ like a granted lock is still converting since rqmode is not
+ NL. (does it make sense to include status in the output,
+ e.g. G,C,W?) */
+
+ if (status == DLM_LKSTS_GRANTED)
+ rqmode = DLM_LOCK_NL;
+
printf("id %08x gr %s rq %s pid %u master %d \"%s\"\n",
id, mode_str(grmode), mode_str(rqmode),
ownpid, nodeid, r_name);
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-10-17 18:08 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-10-17 18:08 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-10-17 18:08:47
Modified files:
dlm/tool : main.c
Log message:
The output of 'dlm_tool lockdump' could make it appear that a granted
lock was still converting because the rqmode reported by the kernel
is not reset to IV when a NOQUEUE convert fails.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=1.8&r2=1.9
--- cluster/dlm/tool/main.c 2007/08/20 20:48:16 1.8
+++ cluster/dlm/tool/main.c 2007/10/17 18:08:47 1.9
@@ -367,6 +367,15 @@
continue;
}
+ /* A hack because dlm-kernel doesn't set rqmode back to NL when
+ a NOQUEUE convert fails, which means in a lockdump it looks
+ like a granted lock is still converting since rqmode is not
+ NL. (does it make sense to include status in the output,
+ e.g. G,C,W?) */
+
+ if (status == DLM_LKSTS_GRANTED)
+ rqmode = DLM_LOCK_NL;
+
printf("id %08x gr %s rq %s pid %u master %d \"%s\"\n",
id, mode_str(grmode), mode_str(rqmode),
ownpid, nodeid, r_name);
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-08-20 20:48 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-08-20 20:48 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-08-20 20:48:16
Modified files:
dlm/tool : main.c
Log message:
proper help output for -m option
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=1.7&r2=1.8
--- cluster/dlm/tool/main.c 2007/08/20 20:36:53 1.7
+++ cluster/dlm/tool/main.c 2007/08/20 20:48:16 1.8
@@ -54,7 +54,7 @@
printf("Options:\n");
printf(" -v Verbose output\n");
printf(" -d <n> Resource directory off/on (0/1), default 0\n");
- printf(" -m Permission mode for lockspace device (octal)\n");
+ printf(" -m <mode> Permission mode for lockspace device (octal), default 0600\n");
printf(" -M Print MSTCPY locks in lockdump (remote locks, locally mastered)\n");
printf(" -h Print this help, then exit\n");
printf(" -V Print program version information, then exit\n");
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-08-20 20:48 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-08-20 20:48 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: teigland at sourceware.org 2007-08-20 20:48:05
Modified files:
dlm/tool : main.c
Log message:
proper help output for -m option
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.4&r2=1.2.2.5
--- cluster/dlm/tool/main.c 2007/08/20 20:38:37 1.2.2.4
+++ cluster/dlm/tool/main.c 2007/08/20 20:48:05 1.2.2.5
@@ -54,7 +54,7 @@
printf("Options:\n");
printf(" -v Verbose output\n");
printf(" -d <n> Resource directory off/on (0/1), default 0\n");
- printf(" -m Permission mode for lockspace device (octal)\n");
+ printf(" -m <mode> Permission mode for lockspace device (octal), default 0600\n");
printf(" -M Print MSTCPY locks in lockdump (remote locks, locally mastered)\n");
printf(" -h Print this help, then exit\n");
printf(" -V Print program version information, then exit\n");
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-08-20 20:38 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-08-20 20:38 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: teigland at sourceware.org 2007-08-20 20:38:37
Modified files:
dlm/tool : main.c
Log message:
the mode (-m) and directory (-d) options were being set but not
used in the call to dlm_new_lockspace()
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.3&r2=1.2.2.4
--- cluster/dlm/tool/main.c 2007/07/19 20:43:24 1.2.2.3
+++ cluster/dlm/tool/main.c 2007/08/20 20:38:37 1.2.2.4
@@ -200,11 +200,15 @@
void do_join(char *name)
{
dlm_lshandle_t *dh;
+ uint32_t flags = 0;
printf("Joining lockspace \"%s\", permission %o\n", name, create_mode);
fflush(stdout);
- dh = dlm_new_lockspace(name, 0600, DLM_LSFL_NODIR);
+ if (!opt_dir)
+ flags = DLM_LSFL_NODIR;
+
+ dh = dlm_new_lockspace(name, create_mode, flags);
if (!dh) {
fprintf(stderr, "dlm_new_lockspace %s error %p %d\n",
name, dh, errno);
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-08-20 20:36 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-08-20 20:36 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-08-20 20:36:53
Modified files:
dlm/tool : main.c
Log message:
the -m mode option was being ignored and 0600 always used
(this change must have been lost at the same time as the -d option)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=1.6&r2=1.7
--- cluster/dlm/tool/main.c 2007/08/20 20:31:01 1.6
+++ cluster/dlm/tool/main.c 2007/08/20 20:36:53 1.7
@@ -203,7 +203,7 @@
if (!opt_dir)
flags = DLM_LSFL_NODIR;
- dh = dlm_new_lockspace(name, 0600, flags);
+ dh = dlm_new_lockspace(name, create_mode, flags);
if (!dh) {
fprintf(stderr, "dlm_new_lockspace %s error %p %d\n",
name, dh, errno);
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-08-20 20:31 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-08-20 20:31 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-08-20 20:31:02
Modified files:
dlm/tool : main.c
Log message:
the NODIR new_lockspace flag was always being used, even if the -d
was used to deselect it
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=1.5&r2=1.6
--- cluster/dlm/tool/main.c 2007/07/24 18:17:31 1.5
+++ cluster/dlm/tool/main.c 2007/08/20 20:31:01 1.6
@@ -195,11 +195,15 @@
void do_join(char *name)
{
dlm_lshandle_t *dh;
+ uint32_t flags = 0;
printf("Joining lockspace \"%s\", permission %o\n", name, create_mode);
fflush(stdout);
- dh = dlm_new_lockspace(name, 0600, DLM_LSFL_NODIR);
+ if (!opt_dir)
+ flags = DLM_LSFL_NODIR;
+
+ dh = dlm_new_lockspace(name, 0600, flags);
if (!dh) {
fprintf(stderr, "dlm_new_lockspace %s error %p %d\n",
name, dh, errno);
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-07-24 18:17 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-07-24 18:17 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-07-24 18:17:32
Modified files:
dlm/tool : main.c
Log message:
dlm_tool deadlock_check <name> is a way to manually kick off a deadlock
detection cycle for the named lockspace
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=1.4&r2=1.5
--- cluster/dlm/tool/main.c 2007/07/13 18:29:50 1.4
+++ cluster/dlm/tool/main.c 2007/07/24 18:17:31 1.5
@@ -24,7 +24,7 @@
#include <netinet/in.h>
#include "libdlm.h"
-/* #include "dlm_controld.h" */
+#include "dlm_controld.h"
#define OPTION_STRING "MhVvd:m:"
@@ -49,7 +49,7 @@
{
printf("Usage:\n");
printf("\n");
- printf("%s [options] [join|leave|lockdump|lockdebug]\n", prog_name);
+ printf("%s [options] [join|leave|lockdump|lockdebug|deadlock_check]\n", prog_name);
printf("\n");
printf("Options:\n");
printf(" -v Verbose output\n");
@@ -145,8 +145,6 @@
operation = OP_LOCKDEBUG;
opt_ind = optind + 1;
break;
- }
-#if 0
} else if (!strncmp(argv[optind], "spaces", 9) &&
(strlen(argv[optind]) == 6)) {
operation = OP_SPACES;
@@ -159,7 +157,6 @@
opt_ind = optind + 1;
break;
}
-#endif
optind++;
}
@@ -176,7 +173,6 @@
}
}
-#if 0
static int do_write(int fd, void *buf, size_t count)
{
int rv, off = 0;
@@ -195,7 +191,6 @@
}
return 0;
}
-#endif
void do_join(char *name)
{
@@ -376,7 +371,6 @@
fclose(file);
}
-#if 0
void do_spaces(void)
{
/* TODO: get info from /sys/kernel/config/ */
@@ -428,7 +422,6 @@
strerror(errno));
close(fd);
}
-#endif
int main(int argc, char **argv)
{
@@ -457,7 +450,7 @@
case OP_LOCKDEBUG:
do_lockdebug(lsname);
break;
-#if 0
+
case OP_SPACES:
do_spaces();
break;
@@ -465,7 +458,6 @@
case OP_DEADLOCK_CHECK:
do_deadlock_check(lsname);
break;
-#endif
}
return 0;
}
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-07-19 20:43 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-07-19 20:43 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: teigland at sourceware.org 2007-07-19 20:43:24
Modified files:
dlm/tool : main.c
Log message:
add lockdump and -m to set mode of dlm device (sync with HEAD)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.2&r2=1.2.2.3
--- cluster/dlm/tool/main.c 2007/06/25 20:36:33 1.2.2.2
+++ cluster/dlm/tool/main.c 2007/07/19 20:43:24 1.2.2.3
@@ -24,12 +24,17 @@
#include <netinet/in.h>
#include "libdlm.h"
+/* #include "dlm_controld.h" */
-#define OPTION_STRING "hVvd:"
+#define OPTION_STRING "MhVvd:m:"
#define OP_JOIN 1
#define OP_LEAVE 2
#define OP_JOINLEAVE 3
+#define OP_SPACES 4
+#define OP_LOCKDUMP 5
+#define OP_LOCKDEBUG 6
+#define OP_DEADLOCK_CHECK 7
static char *prog_name;
static char *lsname;
@@ -37,18 +42,22 @@
static int opt_ind;
static int verbose;
static int opt_dir = 0;
+static int dump_mstcpy = 0;
+static mode_t create_mode = 0600;
static void print_usage(void)
{
printf("Usage:\n");
printf("\n");
- printf("%s [options] [join|leave]\n", prog_name);
+ printf("%s [options] [join|leave|lockdump|lockdebug]\n", prog_name);
printf("\n");
printf("Options:\n");
- printf(" -v Verbose output, extra event information\n");
+ printf(" -v Verbose output\n");
+ printf(" -d <n> Resource directory off/on (0/1), default 0\n");
+ printf(" -m Permission mode for lockspace device (octal)\n");
+ printf(" -M Print MSTCPY locks in lockdump (remote locks, locally mastered)\n");
printf(" -h Print this help, then exit\n");
printf(" -V Print program version information, then exit\n");
- printf(" -d <n> Resource directory off/on (0/1), default 0\n");
printf("\n");
}
@@ -56,11 +65,23 @@
{
int cont = 1;
int optchar;
+ int need_lsname = 1;
+ char modebuf[8];
while (cont) {
optchar = getopt(argc, argv, OPTION_STRING);
switch (optchar) {
+ case 'm':
+ memset(modebuf, 0, sizeof(modebuf));
+ snprintf(modebuf, 8, optarg);
+ sscanf(modebuf, "%o", &create_mode);
+ break;
+
+ case 'M':
+ dump_mstcpy = 1;
+ break;
+
case 'v':
verbose = 1;
break;
@@ -114,7 +135,31 @@
operation = OP_JOINLEAVE;
opt_ind = optind + 1;
break;
+ } else if (!strncmp(argv[optind], "lockdump", 8) &&
+ (strlen(argv[optind]) == 8)) {
+ operation = OP_LOCKDUMP;
+ opt_ind = optind + 1;
+ break;
+ } else if (!strncmp(argv[optind], "lockdebug", 9) &&
+ (strlen(argv[optind]) == 9)) {
+ operation = OP_LOCKDEBUG;
+ opt_ind = optind + 1;
+ break;
}
+#if 0
+ } else if (!strncmp(argv[optind], "spaces", 9) &&
+ (strlen(argv[optind]) == 6)) {
+ operation = OP_SPACES;
+ opt_ind = optind + 1;
+ need_lsname = 0;
+ break;
+ } else if (!strncmp(argv[optind], "deadlock_check", 14) &&
+ (strlen(argv[optind]) == 14)) {
+ operation = OP_DEADLOCK_CHECK;
+ opt_ind = optind + 1;
+ break;
+ }
+#endif
optind++;
}
@@ -125,23 +170,44 @@
if (optind < argc - 1)
lsname = argv[opt_ind];
- else {
+ else if (need_lsname) {
fprintf(stderr, "lockspace name required\n");
exit(EXIT_FAILURE);
}
}
+#if 0
+static int do_write(int fd, void *buf, size_t count)
+{
+ int rv, off = 0;
+
+ retry:
+ rv = write(fd, buf + off, count);
+ if (rv == -1 && errno == EINTR)
+ goto retry;
+ if (rv < 0)
+ return rv;
+
+ if (rv != count) {
+ count -= rv;
+ off += rv;
+ goto retry;
+ }
+ return 0;
+}
+#endif
+
void do_join(char *name)
{
dlm_lshandle_t *dh;
- printf("Joining lockspace \"%s\"\n", name);
+ printf("Joining lockspace \"%s\", permission %o\n", name, create_mode);
fflush(stdout);
dh = dlm_new_lockspace(name, 0600, DLM_LSFL_NODIR);
if (!dh) {
- fprintf(stderr, "dlm_create_lockspace %s error %llu %d\n",
- name, (unsigned long long) dh, errno);
+ fprintf(stderr, "dlm_new_lockspace %s error %p %d\n",
+ name, dh, errno);
exit(-1);
}
@@ -159,8 +225,8 @@
dh = dlm_open_lockspace(name);
if (!dh) {
- fprintf(stderr, "dlm_open_lockspace %s error %llu %d\n",
- name, (unsigned long long) dh, errno);
+ fprintf(stderr, "dlm_open_lockspace %s error %p %d\n",
+ name, dh, errno);
exit(-1);
}
@@ -168,6 +234,202 @@
printf("done\n");
}
+#define LOCK_LINE_MAX 1024
+
+void do_lockdebug(char *name)
+{
+ FILE *file;
+ char path[PATH_MAX];
+ char line[LOCK_LINE_MAX];
+
+ snprintf(path, PATH_MAX, "/sys/kernel/debug/dlm/%s", name);
+
+ file = fopen(path, "r");
+ if (!file) {
+ fprintf(stderr, "can't open %s: %s\n", path, strerror(errno));
+ return;
+ }
+
+ while (fgets(line, LOCK_LINE_MAX, file)) {
+ printf("%s", line);
+ }
+
+ fclose(file);
+}
+
+char *mode_str(int mode)
+{
+ switch (mode) {
+ case -1:
+ return "IV";
+ case LKM_NLMODE:
+ return "NL";
+ case LKM_CRMODE:
+ return "CR";
+ case LKM_CWMODE:
+ return "CW";
+ case LKM_PRMODE:
+ return "PR";
+ case LKM_PWMODE:
+ return "PW";
+ case LKM_EXMODE:
+ return "EX";
+ }
+ return "??";
+}
+
+/* from linux/fs/dlm/dlm_internal.h */
+#define DLM_LKSTS_WAITING 1
+#define DLM_LKSTS_GRANTED 2
+#define DLM_LKSTS_CONVERT 3
+
+void parse_r_name(char *line, char *name)
+{
+ char *p;
+ int i = 0;
+ int begin = 0;
+
+ for (p = line; ; p++) {
+ if (*p == '"') {
+ if (begin)
+ break;
+ begin = 1;
+ continue;
+ }
+ if (begin)
+ name[i++] = *p;
+ }
+}
+
+void do_lockdump(char *name)
+{
+ FILE *file;
+ char path[PATH_MAX];
+ char line[LOCK_LINE_MAX];
+ char r_name[65];
+ int r_nodeid;
+ int r_len;
+ int rv;
+ unsigned int time;
+ uint64_t xid;
+ uint32_t id;
+ int nodeid;
+ uint32_t remid;
+ int ownpid;
+ uint32_t exflags;
+ uint32_t flags;
+ int8_t status;
+ int8_t grmode;
+ int8_t rqmode;
+
+ snprintf(path, PATH_MAX, "/sys/kernel/debug/dlm/%s_locks", name);
+
+ file = fopen(path, "r");
+ if (!file) {
+ fprintf(stderr, "can't open %s: %s\n", path, strerror(errno));
+ return;
+ }
+
+ /* skip the header on the first line */
+ fgets(line, LOCK_LINE_MAX, file);
+
+ while (fgets(line, LOCK_LINE_MAX, file)) {
+ rv = sscanf(line, "%x %d %x %u %llu %x %x %hhd %hhd %hhd %u %d %d",
+ &id,
+ &nodeid,
+ &remid,
+ &ownpid,
+ &xid,
+ &exflags,
+ &flags,
+ &status,
+ &grmode,
+ &rqmode,
+ &time,
+ &r_nodeid,
+ &r_len);
+
+ if (rv != 13) {
+ fprintf(stderr, "invalid debugfs line %d: %s\n",
+ rv, line);
+ return;
+ }
+
+ memset(r_name, 0, sizeof(r_name));
+ parse_r_name(line, r_name);
+
+ /* don't print MSTCPY locks without -M */
+ if (!r_nodeid && nodeid) {
+ if (!dump_mstcpy)
+ continue;
+ printf("id %08x gr %s rq %s pid %u MSTCPY %d \"%s\"\n",
+ id, mode_str(grmode), mode_str(rqmode),
+ ownpid, nodeid, r_name);
+ continue;
+ }
+
+ printf("id %08x gr %s rq %s pid %u master %d \"%s\"\n",
+ id, mode_str(grmode), mode_str(rqmode),
+ ownpid, nodeid, r_name);
+ }
+
+ fclose(file);
+}
+
+#if 0
+void do_spaces(void)
+{
+ /* TODO: get info from /sys/kernel/config/ */
+}
+
+static int connect_daemon(char *path)
+{
+ struct sockaddr_un sun;
+ socklen_t addrlen;
+ int rv, fd;
+
+ fd = socket(PF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0)
+ goto out;
+
+ memset(&sun, 0, sizeof(sun));
+ sun.sun_family = AF_UNIX;
+ strcpy(&sun.sun_path[1], path);
+ addrlen = sizeof(sa_family_t) + strlen(sun.sun_path+1) + 1;
+
+ rv = connect(fd, (struct sockaddr *) &sun, addrlen);
+ if (rv < 0) {
+ close(fd);
+ fd = rv;
+ }
+ out:
+ return fd;
+}
+
+static void do_deadlock_check(char *name)
+{
+ char buf[DLM_CONTROLD_MSGLEN];
+ int fd;
+ int rv;
+
+ fd = connect_daemon(DLM_CONTROLD_SOCK_PATH);
+ if (fd < 0) {
+ fprintf(stderr, "can't connect to dlm_controld: %s\n",
+ strerror(errno));
+ return;
+ }
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), "deadlock_check %s", name);
+
+ rv = do_write(fd, buf, DLM_CONTROLD_MSGLEN);
+ if (rv < 0)
+ fprintf(stderr, "bad write to dlm_controld: %s\n",
+ strerror(errno));
+ close(fd);
+}
+#endif
+
int main(int argc, char **argv)
{
prog_name = argv[0];
@@ -187,8 +449,24 @@
do_join(lsname);
do_leave(lsname);
break;
- }
+ case OP_LOCKDUMP:
+ do_lockdump(lsname);
+ break;
+
+ case OP_LOCKDEBUG:
+ do_lockdebug(lsname);
+ break;
+#if 0
+ case OP_SPACES:
+ do_spaces();
+ break;
+
+ case OP_DEADLOCK_CHECK:
+ do_deadlock_check(lsname);
+ break;
+#endif
+ }
return 0;
}
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-07-03 17:46 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-07-03 17:46 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL4
Changes by: teigland at sourceware.org 2007-07-03 17:46:55
Modified files:
dlm/tool : main.c
Log message:
The previous change resulted in double quotes around the name; change the
name parsing routine to not put quotes in the name string.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.2.3&r2=1.3.2.4
--- cluster/dlm/tool/main.c 2007/07/03 15:59:27 1.3.2.3
+++ cluster/dlm/tool/main.c 2007/07/03 17:46:55 1.3.2.4
@@ -222,11 +222,10 @@
for (p = line; ; p++) {
if (*p == '"') {
- if (begin) {
- name[i++] = *p;
+ if (begin)
break;
- }
begin = 1;
+ continue;
}
if (begin)
name[i++] = *p;
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-07-03 15:59 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-07-03 15:59 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL4
Changes by: teigland at sourceware.org 2007-07-03 15:59:28
Modified files:
dlm/tool : main.c
Log message:
quote the resource name when printing
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.2.2&r2=1.3.2.3
--- cluster/dlm/tool/main.c 2007/07/02 20:07:17 1.3.2.2
+++ cluster/dlm/tool/main.c 2007/07/03 15:59:27 1.3.2.3
@@ -250,16 +250,16 @@
sscanf(line, "%s %s %u Remote: %d %s\n", &lkid, &grmode,
&pid, &remote_nodeid, remote_lkid);
- printf("id %s gr %s rq %s pid %u MSTCPY %d %s\n", lkid, grmode, "IV",
- pid, remote_nodeid, name);
+ printf("id %s gr %s rq %s pid %u MSTCPY %d \"%s\"\n",
+ lkid, grmode, "IV", pid, remote_nodeid, name);
return;
}
sscanf(line, "%s %s %u\n", &lkid, &grmode, &pid);
- printf("id %s gr %s rq %s pid %u master %d %s\n", lkid, grmode, "IV",
- pid, master, name);
+ printf("id %s gr %s rq %s pid %u master %d \"%s\"\n",
+ lkid, grmode, "IV", pid, master, name);
}
void print_convert(char *line, char *name, int master)
@@ -278,16 +278,16 @@
sscanf(line, "%s %s (%s) %u Remote: %d %s\n", &lkid, &grmode,
&rqmode, &pid, &remote_nodeid, remote_lkid);
- printf("id %s gr %s rq %s pid %u MSTCPY %d %s\n", lkid, grmode,
- rqmode, pid, remote_nodeid, name);
+ printf("id %s gr %s rq %s pid %u MSTCPY %d \"%s\"\n",
+ lkid, grmode, rqmode, pid, remote_nodeid, name);
return;
}
sscanf(line, "%s %s (%s) %u\n", &lkid, &grmode, &rqmode, &pid);
- printf("id %s gr %s rq %s pid %u master %d %s\n", lkid, grmode, rqmode,
- pid, master, name);
+ printf("id %s gr %s rq %s pid %u master %d \"%s\"\n",
+ lkid, grmode, rqmode, pid, master, name);
}
void print_waiting(char *line, char *name, int master)
@@ -306,16 +306,16 @@
sscanf(line, "%s %s (%s) %u Remote: %d %s\n", &lkid, &grmode,
&rqmode, &pid, &remote_nodeid, remote_lkid);
- printf("id %s gr %s rq %s pid %u MSTCPY %d %s\n", lkid, "IV",
- rqmode, pid, remote_nodeid, name);
+ printf("id %s gr %s rq %s pid %u MSTCPY %d \"%s\"\n",
+ lkid, "IV", rqmode, pid, remote_nodeid, name);
return;
}
sscanf(line, "%s %s (%s) %u\n", &lkid, &grmode, &rqmode, &pid);
- printf("id %s gr %s rq %s pid %u master %d %s\n", lkid, "IV", rqmode,
- pid, master, name);
+ printf("id %s gr %s rq %s pid %u master %d \"%s\"\n",
+ lkid, "IV", rqmode, pid, master, name);
}
int parse_master_nodeid(char *line)
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-07-02 20:07 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-07-02 20:07 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL4
Changes by: teigland at sourceware.org 2007-07-02 20:07:17
Modified files:
dlm/tool : main.c
Log message:
Separate lockdump (compact, one lock per line) from lockdebug (verbose
output as seen from proc).
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.2.1&r2=1.3.2.2
--- cluster/dlm/tool/main.c 2007/07/02 15:08:47 1.3.2.1
+++ cluster/dlm/tool/main.c 2007/07/02 20:07:17 1.3.2.2
@@ -31,6 +31,7 @@
#define OP_LEAVE 2
#define OP_SPACES 3
#define OP_LOCKDUMP 4
+#define OP_LOCKDEBUG 5
static char *prog_name;
static char *lsname;
@@ -44,7 +45,7 @@
{
printf("Usage:\n");
printf("\n");
- printf("%s [options] [join|leave|spaces|lockdump]\n", prog_name);
+ printf("%s [options] [join|leave|spaces|lockdump|lockdebug]\n", prog_name);
printf("\n");
printf("Options:\n");
printf(" -v Verbose output, extra event information\n");
@@ -131,6 +132,11 @@
operation = OP_LOCKDUMP;
opt_ind = optind + 1;
break;
+ } else if (!strncmp(argv[optind], "lockdebug", 9) &&
+ (strlen(argv[optind]) == 9)) {
+ operation = OP_LOCKDEBUG;
+ opt_ind = optind + 1;
+ break;
}
optind++;
}
@@ -343,7 +349,7 @@
file = fopen(path, "r");
while (fgets(line, PROC_LINE_MAX, file)) {
- if (verbose) {
+ if (operation == OP_LOCKDEBUG) {
printf("%s", line);
continue;
}
@@ -411,6 +417,7 @@
break;
case OP_LOCKDUMP:
+ case OP_LOCKDEBUG:
do_lockdump(lsname);
break;
}
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-06-25 20:37 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-06-25 20:37 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-06-25 20:37:22
Modified files:
dlm/tool : main.c
Log message:
s/unsigned long/unsigned long long/
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=1.2&r2=1.3
--- cluster/dlm/tool/main.c 2007/06/05 18:25:32 1.2
+++ cluster/dlm/tool/main.c 2007/06/25 20:37:22 1.3
@@ -140,8 +140,8 @@
dh = dlm_new_lockspace(name, 0600, DLM_LSFL_NODIR);
if (!dh) {
- fprintf(stderr, "dlm_create_lockspace %s error %lu %d\n",
- name, (unsigned long) dh, errno);
+ fprintf(stderr, "dlm_create_lockspace %s error %llu %d\n",
+ name, (unsigned long long) dh, errno);
exit(-1);
}
@@ -159,8 +159,8 @@
dh = dlm_open_lockspace(name);
if (!dh) {
- fprintf(stderr, "dlm_open_lockspace %s error %lu %d\n",
- name, (unsigned long) dh, errno);
+ fprintf(stderr, "dlm_open_lockspace %s error %llu %d\n",
+ name, (unsigned long long) dh, errno);
exit(-1);
}
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-06-25 20:36 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-06-25 20:36 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: teigland at sourceware.org 2007-06-25 20:36:33
Modified files:
dlm/tool : main.c
Log message:
s/unsigned long/unsigned long long/
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.1&r2=1.2.2.2
--- cluster/dlm/tool/main.c 2007/06/05 18:27:27 1.2.2.1
+++ cluster/dlm/tool/main.c 2007/06/25 20:36:33 1.2.2.2
@@ -140,8 +140,8 @@
dh = dlm_new_lockspace(name, 0600, DLM_LSFL_NODIR);
if (!dh) {
- fprintf(stderr, "dlm_create_lockspace %s error %lu %d\n",
- name, (unsigned long) dh, errno);
+ fprintf(stderr, "dlm_create_lockspace %s error %llu %d\n",
+ name, (unsigned long long) dh, errno);
exit(-1);
}
@@ -159,8 +159,8 @@
dh = dlm_open_lockspace(name);
if (!dh) {
- fprintf(stderr, "dlm_open_lockspace %s error %lu %d\n",
- name, (unsigned long) dh, errno);
+ fprintf(stderr, "dlm_open_lockspace %s error %llu %d\n",
+ name, (unsigned long long) dh, errno);
exit(-1);
}
^ permalink raw reply [flat|nested] 21+ messages in thread* [Cluster-devel] cluster/dlm/tool main.c
@ 2007-06-05 18:25 teigland
0 siblings, 0 replies; 21+ messages in thread
From: teigland @ 2007-06-05 18:25 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-06-05 18:25:32
Modified files:
dlm/tool : main.c
Log message:
report an error if no lockspace name is provided
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=1.1&r2=1.2
--- cluster/dlm/tool/main.c 2007/05/18 16:39:51 1.1
+++ cluster/dlm/tool/main.c 2007/06/05 18:25:32 1.2
@@ -123,7 +123,12 @@
exit(EXIT_FAILURE);
}
- lsname = argv[opt_ind];
+ if (optind < argc - 1)
+ lsname = argv[opt_ind];
+ else {
+ fprintf(stderr, "lockspace name required\n");
+ exit(EXIT_FAILURE);
+ }
}
void do_join(char *name)
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2007-10-26 21:23 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-26 20:57 [Cluster-devel] cluster/dlm/tool main.c teigland
-- strict thread matches above, loose matches on Subject: below --
2007-10-26 21:23 teigland
2007-10-26 21:23 teigland
2007-10-26 18:51 rmccabe
2007-10-17 19:11 teigland
2007-10-17 19:07 teigland
2007-10-17 18:10 teigland
2007-10-17 18:08 teigland
2007-08-20 20:48 teigland
2007-08-20 20:48 teigland
2007-08-20 20:38 teigland
2007-08-20 20:36 teigland
2007-08-20 20:31 teigland
2007-07-24 18:17 teigland
2007-07-19 20:43 teigland
2007-07-03 17:46 teigland
2007-07-03 15:59 teigland
2007-07-02 20:07 teigland
2007-06-25 20:37 teigland
2007-06-25 20:36 teigland
2007-06-05 18:25 teigland
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).