FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 05-01-2008, 09:08 PM
 
Default Cluster Project branch, master, updated. cluster-2.99.00-12-g41f2735

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=41f2735e80 acff590c08161e76ce0d25ca5e9c66

The branch, master has been updated
via 41f2735e80acff590c08161e76ce0d25ca5e9c66 (commit)
from 4e449d4110b416a7c1da8eb2cca3e81338085db5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 41f2735e80acff590c08161e76ce0d25ca5e9c66
Author: David Teigland <teigland@redhat.com>
Date: Thu May 1 16:02:37 2008 -0500

dlm_controld: filling out code

Filling in various unfinished bits, fixing up wrong/inconsistent
header length (also in fenced).

Signed-off-by: David Teigland <teigland@redhat.com>

-----------------------------------------------------------------------

Summary of changes:
dlm/libdlmcontrol/main.c | 28 +++---
fence/fenced/main.c | 46 +++++---
fence/libfenced/main.c | 19 ++--
group/dlm_controld/cpg.c | 41 +++++++-
group/dlm_controld/dlm_daemon.h | 18 +++-
group/dlm_controld/group.c | 17 +++
group/dlm_controld/main.c | 227 ++++++++++++++++++++++++++++++++++----
group/dlm_controld/plock.c | 35 ++++---
8 files changed, 346 insertions(+), 85 deletions(-)

diff --git a/dlm/libdlmcontrol/main.c b/dlm/libdlmcontrol/main.c
index 2bd001d..3714a54 100644
--- a/dlm/libdlmcontrol/main.c
+++ b/dlm/libdlmcontrol/main.c
@@ -84,27 +84,28 @@ static int do_connect(char *sock_path)
return fd;
}

-static void init_header(struct dlmc_header *h, char *name, int cmd, int len)
+static void init_header(struct dlmc_header *h, int cmd, char *name,
+ int extra_len)
{
memset(h, 0, sizeof(struct dlmc_header));

h->magic = DLMC_MAGIC;
h->version = DLMC_VERSION;
- h->len = len;
+ h->len = sizeof(struct dlmc_header) + extra_len;
h->command = cmd;

if (name)
- strncpy(h->name, name, DLM_LOCKSPACE_LEN); /* no term null in header */
+ strncpy(h->name, name, DLM_LOCKSPACE_LEN);
}

-int do_dump(int type, char *name, char *buf)
+int do_dump(int cmd, char *name, char *buf)
{
struct dlmc_header h, *rh;
char *reply;
int reply_len;
int fd, rv;

- init_header(&h, name, type, sizeof(h));
+ init_header(&h, cmd, name, 0);

reply_len = sizeof(struct dlmc_header) + DLMC_DUMP_SIZE;
reply = malloc(reply_len);
@@ -156,7 +157,7 @@ int dlmc_node_info(char *name, int nodeid, struct dlmc_node *node)
char reply[sizeof(struct dlmc_header) + sizeof(struct dlmc_node)];
int fd, rv;

- init_header(&h, name, DLMC_CMD_NODE_INFO, sizeof(h));
+ init_header(&h, DLMC_CMD_NODE_INFO, name, 0);
h.data = nodeid;

memset(reply, 0, sizeof(reply));
@@ -194,7 +195,7 @@ int dlmc_lockspace_info(char *name, struct dlmc_lockspace *lockspace)
char reply[sizeof(struct dlmc_header) + sizeof(struct dlmc_lockspace)];
int fd, rv;

- init_header(&h, name, DLMC_CMD_LOCKSPACE_INFO, sizeof(h));
+ init_header(&h, DLMC_CMD_LOCKSPACE_INFO, name, 0);

memset(reply, 0, sizeof(reply));

@@ -225,14 +226,15 @@ int dlmc_lockspace_info(char *name, struct dlmc_lockspace *lockspace)
return rv;
}

-int dlmc_lockspace_nodes(char *name, int type, int max, int *count, struct dlmc_node *nodes)
+int dlmc_lockspace_nodes(char *name, int type, int max, int *count,
+ struct dlmc_node *nodes)
{
struct dlmc_header h, *rh;
char *reply;
int reply_len;
int fd, rv, result, node_count;

- init_header(&h, name, DLMC_CMD_LOCKSPACE_NODES, sizeof(h));
+ init_header(&h, DLMC_CMD_LOCKSPACE_NODES, name, 0);
h.option = type;
h.data = max;

@@ -295,7 +297,7 @@ int dlmc_fs_register(int fd, char *name)
{
struct dlmc_header h;

- init_header(&h, name, DLMC_CMD_FS_REGISTER, sizeof(h));
+ init_header(&h, DLMC_CMD_FS_REGISTER, name, 0);

return do_write(fd, &h, sizeof(h));
}
@@ -304,7 +306,7 @@ int dlmc_fs_unregister(int fd, char *name)
{
struct dlmc_header h;

- init_header(&h, name, DLMC_CMD_FS_UNREGISTER, sizeof(h));
+ init_header(&h, DLMC_CMD_FS_UNREGISTER, name, 0);

return do_write(fd, &h, sizeof(h));
}
@@ -313,7 +315,7 @@ int dlmc_fs_notified(int fd, char *name, int nodeid)
{
struct dlmc_header h;

- init_header(&h, name, DLMC_CMD_FS_NOTIFIED, sizeof(h));
+ init_header(&h, DLMC_CMD_FS_NOTIFIED, name, 0);
h.data = nodeid;

return do_write(fd, &h, sizeof(h));
@@ -341,7 +343,7 @@ int dlmc_deadlock_check(char *name)
struct dlmc_header h;
int fd, rv;

- init_header(&h, name, DLMC_CMD_DEADLOCK_CHECK, sizeof(h));
+ init_header(&h, DLMC_CMD_DEADLOCK_CHECK, name, 0);

fd = do_connect(DLMC_SOCK_PATH);
if (fd < 0) {
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index aec8f2c..a94bb85 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -263,47 +263,57 @@ static int do_external(char *name, char *extra, int extra_len)
return rv;
}

+static void init_header(struct fenced_header *h, int cmd, int result,
+ int extra_len)
+{
+ memset(h, 0, sizeof(struct fenced_header));
+
+ h->magic = FENCED_MAGIC;
+ h->version = FENCED_VERSION;
+ h->len = sizeof(struct fenced_header) + extra_len;
+ h->command = cmd;
+ h->data = result;
+}
+
/* combines a header and the data and sends it back to the client in
a single do_write() call */

-static void do_reply(int f, int cmd, int result, char *buf, int len)
+static void do_reply(int f, int cmd, int result, char *buf, int buflen)
{
- struct fenced_header *rh;
char *reply;
int reply_len;

- reply_len = sizeof(struct fenced_header) + len;
+ reply_len = sizeof(struct fenced_header) + buflen;
reply = malloc(reply_len);
if (!reply)
return;
memset(reply, 0, reply_len);

- rh = (struct fenced_header *)reply;
-
- rh->magic = FENCED_MAGIC;
- rh->version = FENCED_VERSION;
- rh->len = reply_len;
- rh->command = cmd;
- rh->data = result;
+ init_header((struct fenced_header *)reply, cmd, result, buflen);

- if (buf)
- memcpy(reply + sizeof(struct fenced_header), buf, len);
+ if (buf && buflen)
+ memcpy(reply + sizeof(struct fenced_header), buf, buflen);

do_write(f, reply, reply_len);

free(reply);
}

-/* dump can do 1, 2, or 3 separate writes:
- first write is the header,
- second write is the tail of log,
- third is the head of the log */
-
static void query_dump_debug(int f)
{
+ struct fenced_header h;
+ int extra_len;
int len;

- do_reply(f, FENCED_CMD_DUMP_DEBUG, 0, NULL, 0);
+ /* in the case of dump_wrap, extra_len will go in two writes,
+ first the log tail, then the log head */
+ if (dump_wrap)
+ extra_len = FENCED_DUMP_SIZE;
+ else
+ extra_len = dump_point;
+
+ init_header(&h, FENCED_CMD_DUMP_DEBUG, 0, extra_len);
+ do_write(f, &h, sizeof(h));

if (dump_wrap) {
len = FENCED_DUMP_SIZE - dump_point;
diff --git a/fence/libfenced/main.c b/fence/libfenced/main.c
index 4f2a310..89d81d5 100644
--- a/fence/libfenced/main.c
+++ b/fence/libfenced/main.c
@@ -83,13 +83,13 @@ static int do_connect(char *sock_path)
return fd;
}

-static void init_header(struct fenced_header *h, int cmd, int len)
+static void init_header(struct fenced_header *h, int cmd, int extra_len)
{
memset(h, 0, sizeof(struct fenced_header));

h->magic = FENCED_MAGIC;
h->version = FENCED_VERSION;
- h->len = len;
+ h->len = sizeof(struct fenced_header) + extra_len;
h->command = cmd;
}

@@ -98,7 +98,7 @@ int fenced_join(void)
struct fenced_header h;
int fd, rv;

- init_header(&h, FENCED_CMD_JOIN, sizeof(h));
+ init_header(&h, FENCED_CMD_JOIN, 0);

fd = do_connect(FENCED_SOCK_PATH);
if (fd < 0) {
@@ -117,7 +117,7 @@ int fenced_leave(void)
struct fenced_header h;
int fd, rv;

- init_header(&h, FENCED_CMD_LEAVE, sizeof(h));
+ init_header(&h, FENCED_CMD_LEAVE, 0);

fd = do_connect(FENCED_SOCK_PATH);
if (fd < 0) {
@@ -139,7 +139,8 @@ int fenced_external(char *name)
int namelen;

memset(&msg, 0, sizeof(msg));
- init_header(hd, FENCED_CMD_EXTERNAL, sizeof(msg));
+
+ init_header(hd, FENCED_CMD_EXTERNAL, MAX_NODENAME_LEN + 1);

namelen = strlen(name);
if (namelen > MAX_NODENAME_LEN)
@@ -165,7 +166,7 @@ int fenced_dump_debug(char *buf)
int reply_len;
int fd, rv;

- init_header(&h, FENCED_CMD_DUMP_DEBUG, sizeof(h));
+ init_header(&h, FENCED_CMD_DUMP_DEBUG, 0);

reply_len = sizeof(struct fenced_header) + FENCED_DUMP_SIZE;
reply = malloc(reply_len);
@@ -207,7 +208,7 @@ int fenced_node_info(int nodeid, struct fenced_node *node)
char reply[sizeof(struct fenced_header) + sizeof(struct fenced_node)];
int fd, rv;

- init_header(&h, FENCED_CMD_NODE_INFO, sizeof(h));
+ init_header(&h, FENCED_CMD_NODE_INFO, 0);
h.data = nodeid;

memset(reply, 0, sizeof(reply));
@@ -245,7 +246,7 @@ int fenced_domain_info(struct fenced_domain *domain)
char reply[sizeof(struct fenced_header) + sizeof(struct fenced_domain)];
int fd, rv;

- init_header(&h, FENCED_CMD_DOMAIN_INFO, sizeof(h));
+ init_header(&h, FENCED_CMD_DOMAIN_INFO, 0);

memset(reply, 0, sizeof(reply));

@@ -283,7 +284,7 @@ int fenced_domain_nodes(int type, int max, int *count, struct fenced_node *nodes
int reply_len;
int fd, rv, result, node_count;

- init_header(&h, FENCED_CMD_DOMAIN_NODES, sizeof(h));
+ init_header(&h, FENCED_CMD_DOMAIN_NODES, 0);
h.option = type;
h.data = max;

diff --git a/group/dlm_controld/cpg.c b/group/dlm_controld/cpg.c
index 59872d7..b9c9dee 100644
--- a/group/dlm_controld/cpg.c
+++ b/group/dlm_controld/cpg.c
@@ -36,7 +36,7 @@ struct node {
int check_fencing;
int check_quorum;
int check_fs;
- int fs_notify;
+ int fs_notified;
uint64_t add_time;
};

@@ -442,7 +442,7 @@ static int check_fs_done(struct lockspace *ls)
if (!node->check_fs)
continue;

- if (node->fs_notify) {
+ if (node->fs_notified) {
node->check_fs = 0;
} else {
log_group(ls, "check_fs %d needs fs notify",
@@ -1439,3 +1439,40 @@ int setup_cpg(void)
return 0;
}

+/* fs_controld has seen nodedown for nodeid; it's now ok for dlm to do
+ recovery for the failed node */
+
+int set_fs_notified(struct lockspace *ls, int nodeid)
+{
+ struct node *node;
+
+ /* this shouldn't happen */
+ node = get_node_history(ls, nodeid);
+ if (!node)
+ return -ESRCH;
+
+ /* this can happen, we haven't seen a nodedown for this node yet,
+ but we should soon */
+ if (!node->check_fs)
+ return -EAGAIN;
+
+ node->fs_notified = 1;
+ return 0;
+}
+
+int set_node_info(struct lockspace *ls, int nodeid, struct dlmc_node *node)
+{
+ return 0;
+}
+
+int set_lockspace_info(struct lockspace *ls, struct dlmc_lockspace *lockspace)
+{
+ return 0;
+}
+
+int set_lockspace_nodes(struct lockspace *ls, int option, int *node_count,
+ struct dlmc_node **nodes)
+{
+ return 0;
+}
+
diff --git a/group/dlm_controld/dlm_daemon.h b/group/dlm_controld/dlm_daemon.h
index e1930b8..370989a 100644
--- a/group/dlm_controld/dlm_daemon.h
+++ b/group/dlm_controld/dlm_daemon.h
@@ -86,6 +86,8 @@ extern char daemon_debug_buf[256];
extern char dump_buf[DLMC_DUMP_SIZE];
extern int dump_point;
extern int dump_wrap;
+extern char plock_dump_buf[DLMC_DUMP_SIZE];
+extern int plock_dump_len;

void daemon_dump_save(void);

@@ -202,7 +204,7 @@ int set_sysfs_control(char *name, int val);
int set_sysfs_event_done(char *name, int val);
int set_sysfs_id(char *name, uint32_t id);
int set_configfs_members(char *name, int new_count, int *new_members,
- int renew_count, int *renew_members);
+ int renew_count, int *renew_members);
void clear_configfs(void);
int add_configfs_node(int nodeid, char *addr, int addrlen, int local);
void del_configfs_node(int nodeid);
@@ -218,12 +220,17 @@ int dlm_join_lockspace(struct lockspace *ls);
int dlm_leave_lockspace(struct lockspace *ls);
char *msg_name(int type);
void update_flow_control_status(void);
+int set_node_info(struct lockspace *ls, int nodeid, struct dlmc_node *node);
+int set_lockspace_info(struct lockspace *ls, struct dlmc_lockspace *lockspace);
+int set_lockspace_nodes(struct lockspace *ls, int option, int *node_count,
+ struct dlmc_node **nodes);
+int set_fs_notified(struct lockspace *ls, int nodeid);

/* deadlock.c */
void setup_deadlock(void);
void send_cycle_start(struct lockspace *ls);
void receive_checkpoint_ready(struct lockspace *ls, struct dlm_header *hd,
- int len);
+ int len);
void receive_cycle_start(struct lockspace *ls, struct dlm_header *hd, int len);
void receive_cycle_end(struct lockspace *ls, struct dlm_header *hd, int len);
void receive_cancel_lock(struct lockspace *ls, struct dlm_header *hd, int len);
@@ -264,13 +271,18 @@ void close_plock_checkpoint(struct lockspace *ls);
void store_plocks(struct lockspace *ls);
void retrieve_plocks(struct lockspace *ls);
void purge_plocks(struct lockspace *ls, int nodeid, int unmount);
-int dump_plocks(char *name, int fd);
+int fill_plock_dump_buf(struct lockspace *ls);

/* group.c */
int setup_groupd(void);
void process_groupd(int ci);
int dlm_join_lockspace_group(struct lockspace *ls);
int dlm_leave_lockspace_group(struct lockspace *ls);
+int set_node_info_group(struct lockspace *ls, int nodeid, struct dlmc_node *node);
+int set_lockspace_info_group(struct lockspace *ls,
+ struct dlmc_lockspace *lockspace);
+int set_lockspace_nodes_group(struct lockspace *ls, int option, int *node_count,
+ struct dlmc_node **nodes);

#endif

diff --git a/group/dlm_controld/group.c b/group/dlm_controld/group.c
index 8cfdd26..7f31f69 100644
--- a/group/dlm_controld/group.c
+++ b/group/dlm_controld/group.c
@@ -240,3 +240,20 @@ int setup_groupd(void)
return rv;
}

+int set_node_info_group(struct lockspace *ls, int nodeid, struct dlmc_node *node)
+{
+ return 0;
+}
+
+int set_lockspace_info_group(struct lockspace *ls,
+ struct dlmc_lockspace *lockspace)
+{
+ return 0;
+}
+
+int set_lockspace_nodes_group(struct lockspace *ls, int option, int *node_count,
+ struct dlmc_node **nodes)
+{
+ return 0;
+}
+
diff --git a/group/dlm_controld/main.c b/group/dlm_controld/main.c
index 30c2c14..39bbdba 100644
--- a/group/dlm_controld/main.c
+++ b/group/dlm_controld/main.c
@@ -76,23 +76,6 @@ int do_write(int fd, void *buf, size_t count)
return 0;
}

-static void query_dump_debug(int fd)
-{
- int len;
-
- if (dump_wrap) {
- len = DLMC_DUMP_SIZE - dump_point;
- do_write(fd, dump_buf + dump_point, len);
- len = dump_point;
- } else
- len = dump_point;
-
- /* NUL terminate the debug string */
- dump_buf[dump_point] = '';
-
- do_write(fd, dump_buf, len);
-}
-
static void client_alloc(void)
{
int i;
@@ -383,6 +366,182 @@ static int setup_uevent(void)
return s;
}

+static void init_header(struct dlmc_header *h, int cmd, char *name, int result,
+ int extra_len)
+{
+ memset(h, 0, sizeof(struct dlmc_header));
+
+ h->magic = DLMC_MAGIC;
+ h->version = DLMC_VERSION;
+ h->len = sizeof(struct dlmc_header) + extra_len;
+ h->command = cmd;
+ h->data = result;
+
+ if (name)
+ strncpy(h->name, name, DLM_LOCKSPACE_LEN);
+}
+
+static void query_dump_debug(int fd)
+{
+ struct dlmc_header h;
+ int extra_len;
+ int len;
+
+ /* in the case of dump_wrap, extra_len will go in two writes,
+ first the log tail, then the log head */
+ if (dump_wrap)
+ extra_len = DLMC_DUMP_SIZE;
+ else
+ extra_len = dump_point;
+
+ init_header(&h, DLMC_CMD_DUMP_DEBUG, NULL, 0, extra_len);
+ do_write(fd, &h, sizeof(h));
+
+ if (dump_wrap) {
+ len = DLMC_DUMP_SIZE - dump_point;
+ do_write(fd, dump_buf + dump_point, len);
+ len = dump_point;
+ } else
+ len = dump_point;
+
+ /* NUL terminate the debug string */
+ dump_buf[dump_point] = '';
+
+ do_write(fd, dump_buf, len);
+}
+
+static void query_dump_plocks(int fd, char *name)
+{
+ struct lockspace *ls;
+ struct dlmc_header h;
+ int rv;
+
+ ls = find_ls(name);
+ if (!ls) {
+ plock_dump_len = 0;
+ rv = -ENOENT;
+ } else {
+ /* writes to plock_dump_buf and sets plock_dump_len */
+ rv = fill_plock_dump_buf(ls);
+ }
+
+ init_header(&h, DLMC_CMD_DUMP_PLOCKS, name, rv, plock_dump_len);
+
+ do_write(fd, &h, sizeof(h));
+
+ if (plock_dump_len)
+ do_write(fd, plock_dump_buf, plock_dump_len);
+}
+
+/* combines a header and the data and sends it back to the client in
+ a single do_write() call */
+
+static void do_reply(int fd, int cmd, char *name, int result, char *buf, int buflen)
+{
+ char *reply;
+ int reply_len;
+
+ reply_len = sizeof(struct dlmc_header) + buflen;
+ reply = malloc(reply_len);
+ if (!reply)
+ return;
+ memset(reply, 0, reply_len);
+
+ init_header((struct dlmc_header *)reply, cmd, name, result, buflen);
+
+ if (buf && buflen)
+ memcpy(reply + sizeof(struct dlmc_header), buf, buflen);
+
+ do_write(fd, reply, reply_len);
+
+ free(reply);
+}
+
+static void query_node_info(int fd, char *name, int nodeid)
+{
+ struct lockspace *ls;
+ struct dlmc_node node;
+ int rv;
+
+ ls = find_ls(name);
+ if (!ls) {
+ rv = -ENOENT;
+ goto out;
+ }
+
+ if (group_mode == GROUP_LIBGROUP)
+ rv = set_node_info_group(ls, nodeid, &node);
+ else
+ rv = set_node_info(ls, nodeid, &node);
+ out:
+ do_reply(fd, DLMC_CMD_NODE_INFO, name, rv,
+ (char *)&node, sizeof(node));
+}
+
+static void query_lockspace_info(int fd, char *name)
+{
+ struct lockspace *ls;
+ struct dlmc_lockspace lockspace;
+ int rv;
+
+ ls = find_ls(name);
+ if (!ls) {
+ rv = -ENOENT;
+ goto out;
+ }
+
+ if (group_mode == GROUP_LIBGROUP)
+ rv = set_lockspace_info_group(ls, &lockspace);
+ else
+ rv = set_lockspace_info(ls, &lockspace);
+ out:
+ do_reply(fd, DLMC_CMD_LOCKSPACE_INFO, name, rv,
+ (char *)&lockspace, sizeof(lockspace));
+}
+
+static void query_lockspace_nodes(int fd, char *name, int option, int max)
+{
+ struct lockspace *ls;
+ int node_count = 0;
+ struct dlmc_node *nodes = NULL;
+ int rv, result;
+
+ ls = find_ls(name);
+ if (!ls) {
+ result = -ENOENT;
+ node_count = 0;
+ goto out;
+ }
+
+ if (group_mode == GROUP_LIBGROUP)
+ rv = set_lockspace_nodes_group(ls, option, &node_count, &nodes);
+ else
+ rv = set_lockspace_nodes(ls, option, &node_count, &nodes);
+
+ if (rv < 0) {
+ result = rv;
+ node_count = 0;
+ goto out;
+ }
+
+ /* node_count is the number of structs copied/returned; the caller's
+ max may be less than that, in which case we copy as many as they
+ asked for and return -E2BIG */
+
+ if (node_count > max) {
+ result = -E2BIG;
+ node_count = max;
+ } else {
+ result = node_count;
+ }
+ out:
+ do_reply(fd, DLMC_CMD_LOCKSPACE_NODES, name, result,
+ (char *)nodes, node_count * sizeof(struct dlmc_node));
+
+ if (nodes)
+ free(nodes);
+}
+
static void process_connection(int ci)
{
struct dlmc_header h;
@@ -424,15 +583,33 @@ static void process_connection(int ci)

switch (h.command) {
case DLMC_CMD_FS_REGISTER:
- /* TODO */
+ ls = find_ls(h.name);
+ if (group_mode == GROUP_LIBGROUP) {
+ rv = -EINVAL;
+ } else if (!ls) {
+ rv = -ENOENT;
+ } else {
+ ls->fs_registered = 1;
+ rv = 0;
+ }
+ do_reply(client[ci].fd, DLMC_CMD_FS_REGISTER, h.name, rv,
+ NULL, 0);
break;

case DLMC_CMD_FS_UNREGISTER:
- /* TODO */
+ ls = find_ls(h.name);
+ if (ls)
+ ls->fs_registered = 0;
break;

case DLMC_CMD_FS_NOTIFIED:
- /* TODO */
+ ls = find_ls(h.name);
+ if (ls)
+ rv = set_fs_notified(ls, h.data);
+ else
+ rv = -ENOENT;
+ do_reply(client[ci].fd, DLMC_CMD_FS_NOTIFIED, h.name, rv,
+ NULL, 0);
break;

case DLMC_CMD_DEADLOCK_CHECK:
@@ -552,16 +729,16 @@ static void *process_queries(void *arg)
query_dump_debug(f);
break;
case DLMC_CMD_DUMP_PLOCKS:
- /* query_dump_plocks(f); */
+ query_dump_plocks(f, h.name);
break;
case DLMC_CMD_NODE_INFO:
- /* query_node_info(f, h.data); */
+ query_node_info(f, h.name, h.data);
break;
case DLMC_CMD_LOCKSPACE_INFO:
- /* query_lockspace_info(f); */
+ query_lockspace_info(f, h.name);
break;
case DLMC_CMD_LOCKSPACE_NODES:
- /* query_lockspace_nodes(f, h.option, h.data); */
+ query_lockspace_nodes(f, h.name, h.option, h.data);
break;
default:
break;
@@ -1023,4 +1200,6 @@ char daemon_debug_buf[256];
char dump_buf[DLMC_DUMP_SIZE];
int dump_point;
int dump_wrap;
+char plock_dump_buf[DLMC_DUMP_SIZE];
+int plock_dump_len;

diff --git a/group/dlm_controld/plock.c b/group/dlm_controld/plock.c
index 648e9ec..033b7b7 100644
--- a/group/dlm_controld/plock.c
+++ b/group/dlm_controld/plock.c
@@ -2247,25 +2247,20 @@ void purge_plocks(struct lockspace *ls, int nodeid, int unmount)
log_group(ls, "purged %d plocks for %d", purged, nodeid);
}

-int dump_plocks(char *name, int fd)
+int fill_plock_dump_buf(struct lockspace *ls)
{
- struct lockspace *ls;
struct posix_lock *po;
struct lock_waiter *w;
struct resource *r;
- char line[MAXLINE];
- int rv;
-
- if (!name)
- return -1;
+ int rv = 0;
+ int len = DLMC_DUMP_SIZE, pos = 0, ret;

- ls = find_ls(name);
- if (!ls)
- return -1;
+ memset(plock_dump_buf, 0, sizeof(plock_dump_buf));
+ plock_dump_len = 0;

list_for_each_entry(r, &ls->plock_resources, list) {
list_for_each_entry(po, &r->locks, list) {
- snprintf(line, MAXLINE,
+ ret = snprintf(plock_dump_buf + pos, len - pos,
"%llu %s %llu-%llu nodeid %d pid %u owner %llx
",
(unsigned long long)r->number,
po->ex ? "WR" : "RD",
@@ -2274,11 +2269,15 @@ int dump_plocks(char *name, int fd)
po->nodeid, po->pid,
(unsigned long long)po->owner);

- rv = do_write(fd, line, strlen(line));
+ if (ret >= len - pos) {
+ rv = -ENOSPC;
+ goto out;
+ }
+ pos += ret;
}

list_for_each_entry(w, &r->waiters, list) {
- snprintf(line, MAXLINE,
+ ret = snprintf(plock_dump_buf + pos, len - pos,
"%llu WAITING %s %llu-%llu nodeid %d pid %u owner %llx
",
(unsigned long long)r->number,
w->info.ex ? "WR" : "RD",
@@ -2287,11 +2286,15 @@ int dump_plocks(char *name, int fd)
w->info.nodeid, w->info.pid,
(unsigned long long)w->info.owner);

- rv = do_write(fd, line, strlen(line));
+ if (ret >= len - pos) {
+ rv = -ENOSPC;
+ goto out;
+ }
+ pos += ret;
}
}
-
- return 0;
+ out:
+ return rv;
}

#if 0


hooks/post-receive
--
Cluster Project
 

Thread Tools




All times are GMT. The time now is 02:12 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org