* [Cluster-devel] cluster/dlm/tool Makefile main.c
@ 2007-07-02 15:08 teigland
0 siblings, 0 replies; 2+ messages in thread
From: teigland @ 2007-07-02 15:08 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 15:08:47
Added files:
dlm/tool : Makefile main.c
Log message:
Add dlm_tool to RHEL4 branch to join/leave lockspaces and dump lock
listing. Not entirely certain what we'll do with yet, if anything.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.2.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.3.2.1
/cvs/cluster/cluster/dlm/tool/Makefile,v --> standard output
revision 1.2.4.1
--- cluster/dlm/tool/Makefile
+++ - 2007-07-02 15:08:47.585279000 +0000
@@ -0,0 +1,35 @@
+###############################################################################
+###############################################################################
+##
+## Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+##
+## This copyrighted material is made available to anyone wishing to use,
+## modify, copy, or redistribute it subject to the terms and conditions
+## of the GNU General Public License v.2.
+##
+###############################################################################
+###############################################################################
+top_srcdir = ../..
+UNINSTALL=${top_srcdir}/scripts/uninstall.pl
+
+BINARIES=dlm_tool
+
+all: $(BINARIES)
+
+CFLAGS+=-I${top_srcdir}/dlm/lib -L${top_srcdir}/dlm/lib -g
+
+ifneq (${KERNEL_SRC}, )
+CFLAGS += -I${KERNEL_SRC}/include/cluster
+else
+CFLAGS += -I/usr/include/linux/cluster
+endif
+
+
+dlm_tool: main.c
+ $(CC) $(CFLAGS) -o $@ $< -ldlm -lpthread
+
+clean:
+ rm -f *.o $(BINARIES) *~ core
+
+copytobin:
+
/cvs/cluster/cluster/dlm/tool/main.c,v --> standard output
revision 1.3.2.1
--- cluster/dlm/tool/main.c
+++ - 2007-07-02 15:08:47.680016000 +0000
@@ -0,0 +1,420 @@
+/******************************************************************************
+*******************************************************************************
+**
+** Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+**
+** This copyrighted material is made available to anyone wishing to use,
+** modify, copy, or redistribute it subject to the terms and conditions
+** of the GNU General Public License v.2.
+**
+*******************************************************************************
+******************************************************************************/
+
+#include <sys/types.h>
+#include <sys/un.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <netinet/in.h>
+
+#include "libdlm.h"
+
+#define OPTION_STRING "MhVvd:m:"
+
+#define OP_JOIN 1
+#define OP_LEAVE 2
+#define OP_SPACES 3
+#define OP_LOCKDUMP 4
+
+static char *prog_name;
+static char *lsname;
+static int operation;
+static int opt_ind;
+static int verbose;
+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|spaces|lockdump]\n", prog_name);
+ printf("\n");
+ printf("Options:\n");
+ printf(" -v Verbose output, extra event information\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("\n");
+}
+
+static void decode_arguments(int argc, char **argv)
+{
+ 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;
+
+ case 'h':
+ print_usage();
+ exit(EXIT_SUCCESS);
+ break;
+
+ case 'V':
+ printf("%s (built %s %s)\n",
+ prog_name, __DATE__, __TIME__);
+ /* printf("%s\n", REDHAT_COPYRIGHT); */
+ exit(EXIT_SUCCESS);
+ break;
+
+ case ':':
+ case '?':
+ fprintf(stderr, "Please use '-h' for usage.\n");
+ exit(EXIT_FAILURE);
+ break;
+
+ case EOF:
+ cont = 0;
+ break;
+
+ default:
+ fprintf(stderr, "unknown option: %c\n", optchar);
+ exit(EXIT_FAILURE);
+ break;
+ };
+ }
+
+ while (optind < argc) {
+ if (!strncmp(argv[optind], "join", 4) &&
+ (strlen(argv[optind]) == 4)) {
+ operation = OP_JOIN;
+ opt_ind = optind + 1;
+ break;
+ } else if (!strncmp(argv[optind], "leave", 5) &&
+ (strlen(argv[optind]) == 5)) {
+ operation = OP_LEAVE;
+ opt_ind = optind + 1;
+ break;
+ } else if (!strncmp(argv[optind], "spaces", 6) &&
+ (strlen(argv[optind]) == 6)) {
+ operation = OP_SPACES;
+ opt_ind = optind + 1;
+ need_lsname = 0;
+ break;
+ } else if (!strncmp(argv[optind], "lockdump", 8) &&
+ (strlen(argv[optind]) == 8)) {
+ operation = OP_LOCKDUMP;
+ opt_ind = optind + 1;
+ break;
+ }
+ optind++;
+ }
+
+ if (!operation || !opt_ind) {
+ print_usage();
+ exit(EXIT_FAILURE);
+ }
+
+ if (optind < argc - 1)
+ lsname = argv[opt_ind];
+ else if (need_lsname) {
+ fprintf(stderr, "lockspace name required\n");
+ exit(EXIT_FAILURE);
+ }
+}
+
+void do_join(char *name)
+{
+ dlm_lshandle_t *dh;
+
+ printf("Joining lockspace \"%s\", permission %o\n", name, create_mode);
+ fflush(stdout);
+
+ dh = dlm_create_lockspace(name, create_mode);
+ if (!dh) {
+ fprintf(stderr, "dlm_create_lockspace %s error %p %d\n",
+ name, dh, errno);
+ exit(-1);
+ }
+
+ printf("done\n");
+}
+
+void do_leave(char *name)
+{
+ dlm_lshandle_t *dh;
+
+ printf("Leaving lockspace \"%s\"\n", name);
+ fflush(stdout);
+
+ dh = dlm_open_lockspace(name);
+ if (!dh) {
+ fprintf(stderr, "dlm_open_lockspace %s error %p %d\n",
+ name, dh, errno);
+ exit(-1);
+ }
+
+ dlm_release_lockspace(name, dh, 1);
+ printf("done\n");
+}
+
+#define PROC_LINE_MAX 256
+
+void do_spaces(void)
+{
+ FILE *file;
+ char path[PATH_MAX];
+ char line[PROC_LINE_MAX];
+ int fd;
+ int error;
+
+ snprintf(path, PATH_MAX, "/proc/cluster/services");
+
+ file = fopen(path, "r");
+
+ while (fgets(line, PROC_LINE_MAX, file)) {
+ if (strstr(line, "DLM"))
+ printf("%s", line);
+ }
+
+ fclose(file);
+}
+
+char *parse_resource(char *line)
+{
+ static char name[65];
+ char *p;
+ int i = 0;
+ int begin = 0;
+
+ memset(name, 0, sizeof(name));
+
+ for (p = line; ; p++) {
+ if (*p == '"') {
+ if (begin) {
+ name[i++] = *p;
+ break;
+ }
+ begin = 1;
+ }
+ if (begin)
+ name[i++] = *p;
+ }
+
+ return name;
+}
+
+void print_granted(char *line, char *name, int master)
+{
+ char lkid[16];
+ char grmode[8];
+ char remote_lkid[16];
+ int remote_nodeid;
+ unsigned int pid;
+
+ if (strstr(line, "Remote:")) {
+ if (!dump_mstcpy)
+ return;
+
+ 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);
+
+ 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);
+}
+
+void print_convert(char *line, char *name, int master)
+{
+ char lkid[16];
+ char grmode[8];
+ char rqmode[8];
+ char remote_lkid[16];
+ int remote_nodeid;
+ unsigned int pid;
+
+ if (strstr(line, "Remote:")) {
+ if (!dump_mstcpy)
+ return;
+
+ 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);
+
+ 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);
+}
+
+void print_waiting(char *line, char *name, int master)
+{
+ char lkid[16];
+ char grmode[8];
+ char rqmode[8];
+ char remote_lkid[16];
+ int remote_nodeid;
+ unsigned int pid;
+
+ if (strstr(line, "Remote:")) {
+ if (!dump_mstcpy)
+ return;
+
+ 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);
+
+ 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);
+}
+
+int parse_master_nodeid(char *line)
+{
+ int nodeid;
+
+ sscanf(line, "Local Copy, Master is node %d", &nodeid);
+
+ return nodeid;
+}
+
+void do_lockdump(char *name)
+{
+ FILE *file;
+ char path[PATH_MAX];
+ char line[PROC_LINE_MAX];
+ char *rname;
+ int fd;
+ int error;
+ int master;
+ int next_is_granted, next_is_convert, next_is_waiting;
+
+ snprintf(path, PATH_MAX, "/proc/cluster/dlm_locks");
+
+ fd = open(path, O_WRONLY);
+
+ error = write(fd, name, strlen(name));
+
+ close(fd);
+
+ file = fopen(path, "r");
+
+ while (fgets(line, PROC_LINE_MAX, file)) {
+ if (verbose) {
+ printf("%s", line);
+ continue;
+ }
+
+ if (strlen(line) < 4) {
+ continue;
+ } else if (!strncmp(line, "LVB: ", 5)) {
+ continue;
+ } else if (!strncmp(line, " ", 5)) {
+ continue;
+ } else if (!strncmp(line, "Resource", 8)) {
+ rname = parse_resource(line);
+ continue;
+ } else if (strstr(line, "Master Copy")) {
+ master = 0;
+ continue;
+ } else if (strstr(line, "Local Copy")) {
+ master = parse_master_nodeid(line);
+ continue;
+ } else if (strstr(line, "Granted Queue")) {
+ next_is_granted = 1;
+ next_is_convert = 0;
+ next_is_waiting = 0;
+ continue;
+ } else if (strstr(line, "Conversion Queue")) {
+ next_is_granted = 0;
+ next_is_convert = 1;
+ next_is_waiting = 0;
+ continue;
+ } else if (strstr(line, "Waiting Queue")) {
+ next_is_granted = 0;
+ next_is_convert = 0;
+ next_is_waiting = 1;
+ continue;
+ } else {
+ if (next_is_granted)
+ print_granted(line, rname, master);
+ else if (next_is_convert)
+ print_convert(line, rname, master);
+ else if (next_is_waiting)
+ print_waiting(line, rname, master);
+ }
+ }
+
+ fclose(file);
+}
+
+int main(int argc, char **argv)
+{
+ prog_name = argv[0];
+ decode_arguments(argc, argv);
+ /* check_name(lsname); */
+
+ switch (operation) {
+ case OP_JOIN:
+ do_join(lsname);
+ break;
+
+ case OP_LEAVE:
+ do_leave(lsname);
+ break;
+
+ case OP_SPACES:
+ do_spaces();
+ break;
+
+ case OP_LOCKDUMP:
+ do_lockdump(lsname);
+ break;
+ }
+
+ return 0;
+}
+
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Cluster-devel] cluster/dlm/tool Makefile main.c
@ 2007-07-13 18:29 teigland
0 siblings, 0 replies; 2+ messages in thread
From: teigland @ 2007-07-13 18:29 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-07-13 18:29:50
Modified files:
dlm/tool : Makefile main.c
Log message:
add lockdump and option to set permission of dlm device when creating
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/Makefile.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=1.3&r2=1.4
--- cluster/dlm/tool/Makefile 2007/06/01 09:45:32 1.2
+++ cluster/dlm/tool/Makefile 2007/07/13 18:29:50 1.3
@@ -17,7 +17,7 @@
OBJS= main.o
CFLAGS += -g
-CFLAGS += -I. -I../lib/
+CFLAGS += -I. -I../lib/ -I../../group/dlm_controld/
CFLAGS += -I${incdir}
LDFLAGS += -L../lib -ldlm
--- cluster/dlm/tool/main.c 2007/06/25 20:37:22 1.3
+++ cluster/dlm/tool/main.c 2007/07/13 18:29:50 1.4
@@ -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] 2+ messages in thread
end of thread, other threads:[~2007-07-13 18:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-13 18:29 [Cluster-devel] cluster/dlm/tool Makefile main.c teigland
-- strict thread matches above, loose matches on Subject: below --
2007-07-02 15:08 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).