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-06-2008, 07:29 PM
 
Default Cluster Project branch, master, updated. cluster-2.99.00-19-g4f3e5ee

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=4f3e5eeb33 3dc74fb81470131d8d0e8b3d383ed4

The branch, master has been updated
via 4f3e5eeb333dc74fb81470131d8d0e8b3d383ed4 (commit)
from f47515ef985da41de67f7f5c4158371bb13d44c9 (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 4f3e5eeb333dc74fb81470131d8d0e8b3d383ed4
Author: David Teigland <teigland@redhat.com>
Date: Tue May 6 14:28:03 2008 -0500

dlm_controld: code for info/debug queries

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

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

Summary of changes:
dlm/libdlmcontrol/libdlmcontrol.h | 64 ++++++++-
dlm/libdlmcontrol/main.c | 59 ++++++++-
group/dlm_controld/cpg.c | 259 ++++++++++++++++++++++++++++++++++---
group/dlm_controld/dlm_controld.h | 15 +-
group/dlm_controld/dlm_daemon.h | 7 +-
group/dlm_controld/group.c | 17 ++-
group/dlm_controld/main.c | 72 +++++++---
7 files changed, 431 insertions(+), 62 deletions(-)

diff --git a/dlm/libdlmcontrol/libdlmcontrol.h b/dlm/libdlmcontrol/libdlmcontrol.h
index 117e20e..bcc86ed 100644
--- a/dlm/libdlmcontrol/libdlmcontrol.h
+++ b/dlm/libdlmcontrol/libdlmcontrol.h
@@ -25,25 +25,74 @@

#define DLMC_DUMP_SIZE (1024 * 1024)

+#define DLMC_NF_MEMBER 0x00000001 /* node is member in cg */
+#define DLMC_NF_START 0x00000002 /* start message recvd for cg */
+#define DLMC_NF_DISALLOWED 0x00000004 /* node disallowed in cg */
+#define DLMC_NF_CHECK_FENCING 0x00000008
+#define DLMC_NF_CHECK_QUORUM 0x00000010
+#define DLMC_NF_CHECK_FS 0x00000020
+#define DLMC_NF_FS_NOTIFIED 0x00000040
+
struct dlmc_node {
int nodeid;
- int member;
+ uint32_t flags;
+ uint32_t added_seq;
+ uint32_t removed_seq;
+ int failed_reason;
};

-struct dlmc_lockspace {
+struct dlmc_change {
int member_count;
- int state;
+ int joined_count;
+ int remove_count;
+ int failed_count;
+ int wait_condition; /* 0 no, 1 fencing, 2 quorum, 3 fs */
+ int wait_messages; /* 0 no, 1 yes */
+ uint32_t seq;
+ uint32_t combined_seq;
+};
+
+#define DLMC_LF_JOINING 0x00000001
+#define DLMC_LF_LEAVING 0x00000002
+#define DLMC_LF_KERNEL_STOPPED 0x00000004
+#define DLMC_LF_FS_REGISTERED 0x00000008
+#define DLMC_LF_NEED_PLOCKS 0x00000010
+#define DLMC_LF_SAVE_PLOCKS 0x00000020
+
+struct dlmc_lockspace {
+ struct dlmc_change cg_prev; /* completed change (started_change) */
+ struct dlmc_change cg_next; /* in-progress change (changes list) */
+ uint32_t flags;
+ uint32_t global_id;
+ char name[DLM_LOCKSPACE_LEN+1];
};

-/* dlmc_lockspace_nodes() types */
+/* dlmc_lockspace_nodes() types
+
+ MEMBERS: members in completed (prev) change,
+ zero if there's no completed (prev) change
+ NEXT: members in in-progress (next) change,
+ zero if there's no in-progress (next) change
+ ALL: NEXT + nonmembers if there's an in-progress (next) change,
+ MEMBERS + nonmembers if there's no in-progress (next) change, but
+ there is a completed (prev) change
+ nonmembers if there's no in-progress (next) or completed (prev)
+ change (possible?)
+
+ dlmc_node_info() returns info for in-progress (next) change, if one exists,
+ otherwise it returns info for completed (prev) change.
+*/
+
#define DLMC_NODES_ALL 1
#define DLMC_NODES_MEMBERS 2
+#define DLMC_NODES_NEXT 3

int dlmc_dump_debug(char *buf);
int dlmc_dump_plocks(char *name, char *buf);
-int dlmc_node_info(char *name, int nodeid, struct dlmc_node *node);
-int dlmc_lockspace_info(char *name, struct dlmc_lockspace *ls);
-int dlmc_lockspace_nodes(char *name, int type, int max, int *count,
+int dlmc_lockspace_info(char *lsname, struct dlmc_lockspace *ls);
+int dlmc_node_info(char *lsname, int nodeid, struct dlmc_node *node);
+int dlmc_lockspaces(int max, int *count, struct dlmc_lockspace *lss);
+int dlmc_lockspace_nodes(char *lsname, int type, int max, int *count,
struct dlmc_node *nodes);

int dlmc_fs_connect(void);
@@ -56,3 +105,4 @@ int dlmc_fs_result(int fd, char *name, int *type, int *nodeid, int *result);
int dlmc_deadlock_check(char *name);

#endif
+
diff --git a/dlm/libdlmcontrol/main.c b/dlm/libdlmcontrol/main.c
index 3714a54..88b2d4a 100644
--- a/dlm/libdlmcontrol/main.c
+++ b/dlm/libdlmcontrol/main.c
@@ -226,6 +226,62 @@ int dlmc_lockspace_info(char *name, struct dlmc_lockspace *lockspace)
return rv;
}

+int dlmc_lockspaces(int max, int *count, struct dlmc_lockspace *lss)
+{
+ struct dlmc_header h, *rh;
+ char *reply;
+ int reply_len;
+ int fd, rv, result, ls_count;
+
+ init_header(&h, DLMC_CMD_LOCKSPACES, NULL, 0);
+ h.data = max;
+
+ reply_len = sizeof(struct dlmc_header) +
+ (max * sizeof(struct dlmc_lockspace));
+ reply = malloc(reply_len);
+ if (!reply) {
+ rv = -1;
+ goto out;
+ }
+ memset(reply, 0, reply_len);
+
+ fd = do_connect(DLMC_QUERY_SOCK_PATH);
+ if (fd < 0) {
+ rv = fd;
+ goto out;
+ }
+
+ rv = do_write(fd, &h, sizeof(h));
+ if (rv < 0)
+ goto out_close;
+
+ /* won't usually get back the full reply_len */
+ do_read(fd, reply, reply_len);
+
+ rh = (struct dlmc_header *)reply;
+ result = rh->data;
+ if (result < 0 && result != -E2BIG) {
+ rv = result;
+ goto out_close;
+ }
+
+ if (result == -E2BIG) {
+ *count = -E2BIG;
+ ls_count = max;
+ } else {
+ *count = result;
+ ls_count = result;
+ }
+ rv = 0;
+
+ memcpy(lss, (char *)reply + sizeof(struct dlmc_header),
+ ls_count * sizeof(struct dlmc_lockspace));
+ out_close:
+ close(fd);
+ out:
+ return rv;
+}
+
int dlmc_lockspace_nodes(char *name, int type, int max, int *count,
struct dlmc_node *nodes)
{
@@ -238,7 +294,8 @@ int dlmc_lockspace_nodes(char *name, int type, int max, int *count,
h.option = type;
h.data = max;

- reply_len = sizeof(struct dlmc_header) + (max * sizeof(struct dlmc_node));
+ reply_len = sizeof(struct dlmc_header) +
+ (max * sizeof(struct dlmc_node));
reply = malloc(reply_len);
if (!reply) {
rv = -1;
diff --git a/group/dlm_controld/cpg.c b/group/dlm_controld/cpg.c
index b9c9dee..e49a377 100644
--- a/group/dlm_controld/cpg.c
+++ b/group/dlm_controld/cpg.c
@@ -38,6 +38,9 @@ struct node {
int check_fs;
int fs_notified;
uint64_t add_time;
+ uint32_t added_seq; /* for queries */
+ uint32_t removed_seq; /* for queries */
+ int failed_reason; /* for queries */
};

/* One of these change structs is created for every confchg a cpg gets. */
@@ -55,7 +58,8 @@ struct change {
int failed_count;
int state;
int we_joined;
- uint32_t seq; /* just used as a reference when debugging */
+ uint32_t seq; /* used as a reference for debugging, and for queries */
+ uint32_t combined_seq; /* for queries */
};

char *msg_name(int type)
@@ -289,7 +293,8 @@ static struct node *get_node_history(struct lockspace *ls, int nodeid)
return NULL;
}

-static void node_history_init(struct lockspace *ls, int nodeid)
+static void node_history_init(struct lockspace *ls, int nodeid,
+ struct change *cg)
{
struct node *node;

@@ -305,6 +310,7 @@ static void node_history_init(struct lockspace *ls, int nodeid)
node->nodeid = nodeid;
node->add_time = 0;
list_add_tail(&node->list, &ls->node_history);
+ node->added_seq = cg->seq; /* for queries */
}

static void node_history_start(struct lockspace *ls, int nodeid)
@@ -320,7 +326,8 @@ static void node_history_start(struct lockspace *ls, int nodeid)
node->add_time = time(NULL);
}

-static void node_history_left(struct lockspace *ls, int nodeid)
+static void node_history_left(struct lockspace *ls, int nodeid,
+ struct change *cg)
{
struct node *node;

@@ -331,9 +338,12 @@ static void node_history_left(struct lockspace *ls, int nodeid)
}

node->add_time = 0;
+ node->check_quorum = 1;
+ node->removed_seq = cg->seq; /* for queries */
}

-static void node_history_fail(struct lockspace *ls, int nodeid)
+static void node_history_fail(struct lockspace *ls, int nodeid,
+ struct change *cg, int reason)
{
struct node *node;

@@ -348,6 +358,8 @@ static void node_history_fail(struct lockspace *ls, int nodeid)

node->check_quorum = 1;
node->check_fs = 1;
+ node->removed_seq = cg->seq; /* for queries */
+ node->failed_reason = reason; /* for queries */
}

static int check_fencing_done(struct lockspace *ls)
@@ -399,6 +411,8 @@ static int check_fencing_done(struct lockspace *ls)
return 1;
}

+/* wait for cman to see all the same nodes removed, and to say there's quorum */
+
static int check_quorum_done(struct lockspace *ls)
{
struct node *node;
@@ -429,6 +443,8 @@ static int check_quorum_done(struct lockspace *ls)
return 1;
}

+/* wait for local fs_controld to ack each failed node */
+
static int check_fs_done(struct lockspace *ls)
{
struct node *node;
@@ -605,6 +621,7 @@ static void cleanup_changes(struct lockspace *ls)
ls->started_change = cg;

list_for_each_entry_safe(cg, safe, &ls->changes, list) {
+ ls->started_change->combined_seq = cg->seq; /* for queries */
list_del(&cg->list);
free_cg(cg);
}
@@ -836,12 +853,28 @@ static struct change *find_change(struct lockspace *ls, struct dlm_header *hd,
return NULL;
}

+static int is_added(struct lockspace *ls, int nodeid)
+{
+ struct change *cg;
+ struct member *memb;
+
+ list_for_each_entry(cg, &ls->changes, list) {
+ memb = find_memb(cg, nodeid);
+ if (memb && memb->added)
+ return 1;
+ }
+ return 0;
+}
+
/* We require new members (memb->added) to be joining the lockspace
(memb->joining). New members that are not joining the lockspace can happen
when the cpg partitions and is then merged back together (shouldn't happen
in general, but is possible). We label these new members that are not
joining as "disallowed", and ignore their start message. */

+/* The added/joining checks to detect disallowed nodes need to consider
+ the whole set of changes that are being started. */
+
/* Handle spurious joins by ignoring this start message if the node says it's
not joining (i.e. it's already a member), but we see it being added (i.e.
it's not already a member) */
@@ -850,7 +883,7 @@ static void receive_start(struct lockspace *ls, struct dlm_header *hd, int len)
{
struct change *cg;
struct member *memb;
- int joining = 0;
+ int joining, added;
uint32_t seq = hd->msgdata;

log_group(ls, "receive_start %d:%u flags %x len %d", hd->nodeid, seq,
@@ -869,12 +902,12 @@ static void receive_start(struct lockspace *ls, struct dlm_header *hd, int len)

memb->start_flags = hd->flags;

- if (memb->start_flags & DLM_MFLG_JOINING)
- joining = 1;
+ joining = (memb->start_flags & DLM_MFLG_JOINING) ? 1 : 0;
+ added = is_added(ls, hd->nodeid);

- if ((memb->added && !joining) || (!memb->added && joining)) {
+ if ((added && !joining) || (!added && joining)) {
log_error("receive_start %d:%u disallowed added %d joining %d",
- hd->nodeid, seq, memb->added, joining);
+ hd->nodeid, seq, added, joining);
memb->disallowed = 1;
} else {
node_history_start(ls, hd->nodeid);
@@ -882,6 +915,17 @@ static void receive_start(struct lockspace *ls, struct dlm_header *hd, int len)
}
}

+static int we_joined(struct lockspace *ls)
+{
+ struct change *cg;
+
+ list_for_each_entry(cg, &ls->changes, list) {
+ if (cg->we_joined)
+ return 1;
+ }
+ return 0;
+}
+
static void send_start(struct lockspace *ls)
{
struct change *cg = list_first_entry(&ls->changes, struct change, list);
@@ -903,7 +947,7 @@ static void send_start(struct lockspace *ls)
hd->type = DLM_MSG_START;
hd->msgdata = cg->seq;

- if (cg->we_joined)
+ if (we_joined(ls))
hd->flags |= DLM_MFLG_JOINING;

if (!ls->need_plocks)
@@ -1059,8 +1103,10 @@ static int add_change(struct lockspace *ls,
memset(cg, 0, sizeof(struct change));
INIT_LIST_HEAD(&cg->members);
INIT_LIST_HEAD(&cg->removed);
- cg->seq = ++ls->change_seq;
cg->state = CGST_WAIT_CONDITIONS;
+ cg->seq = ++ls->change_seq;
+ if (!cg->seq)
+ cg->seq = ++ls->change_seq;

cg->member_count = member_list_entries;
cg->joined_count = joined_list_entries;
@@ -1089,9 +1135,10 @@ static int add_change(struct lockspace *ls,
list_add_tail(&memb->list, &cg->removed);

if (memb->failed)
- node_history_fail(ls, memb->nodeid);
+ node_history_fail(ls, memb->nodeid, cg,
+ left_list[i].reason);
else
- node_history_left(ls, memb->nodeid);
+ node_history_left(ls, memb->nodeid, cg);

log_group(ls, "add_change %u nodeid %d remove reason %d",
cg->seq, memb->nodeid, left_list[i].reason);
@@ -1109,15 +1156,17 @@ static int add_change(struct lockspace *ls,
if (memb->nodeid == our_nodeid)
cg->we_joined = 1;
else
- node_history_init(ls, memb->nodeid);
+ node_history_init(ls, memb->nodeid, cg);

log_group(ls, "add_change %u nodeid %d joined", cg->seq,
memb->nodeid);
}

- if (cg->we_joined)
+ if (cg->we_joined) {
+ log_group(ls, "add_change %u we joined", cg->seq);
list_for_each_entry(memb, &cg->members, list)
- node_history_init(ls, memb->nodeid);
+ node_history_init(ls, memb->nodeid, cg);
+ }

log_group(ls, "add_change %u member %d joined %d remove %d failed %d",
cg->seq, cg->member_count, cg->joined_count, cg->remove_count,
@@ -1460,19 +1509,191 @@ int set_fs_notified(struct lockspace *ls, int nodeid)
return 0;
}

-int set_node_info(struct lockspace *ls, int nodeid, struct dlmc_node *node)
+int set_lockspace_info(struct lockspace *ls, struct dlmc_lockspace *lockspace)
{
+ struct change *cg, *last = NULL;
+
+ strncpy(lockspace->name, ls->name, DLM_LOCKSPACE_LEN);
+ lockspace->global_id = ls->global_id;
+
+ if (ls->joining)
+ lockspace->flags |= DLMC_LF_JOINING;
+ if (ls->leaving)
+ lockspace->flags |= DLMC_LF_LEAVING;
+ if (ls->kernel_stopped)
+ lockspace->flags |= DLMC_LF_KERNEL_STOPPED;
+ if (ls->fs_registered)
+ lockspace->flags |= DLMC_LF_FS_REGISTERED;
+ if (ls->need_plocks)
+ lockspace->flags |= DLMC_LF_NEED_PLOCKS;
+ if (ls->save_plocks)
+ lockspace->flags |= DLMC_LF_SAVE_PLOCKS;
+
+ if (!ls->started_change)
+ goto next;
+
+ cg = ls->started_change;
+
+ lockspace->cg_prev.member_count = cg->member_count;
+ lockspace->cg_prev.joined_count = cg->joined_count;
+ lockspace->cg_prev.remove_count = cg->remove_count;
+ lockspace->cg_prev.failed_count = cg->failed_count;
+ lockspace->cg_prev.combined_seq = cg->combined_seq;
+ lockspace->cg_prev.seq = cg->seq;
+
+ next:
+ if (list_empty(&ls->changes))
+ goto out;
+
+ list_for_each_entry(cg, &ls->changes, list)
+ last = cg;
+
+ cg = list_first_entry(&ls->changes, struct change, list);
+
+ lockspace->cg_next.member_count = cg->member_count;
+ lockspace->cg_next.joined_count = cg->joined_count;
+ lockspace->cg_next.remove_count = cg->remove_count;
+ lockspace->cg_next.failed_count = cg->failed_count;
+ lockspace->cg_next.combined_seq = last->seq;
+ lockspace->cg_next.seq = cg->seq;
+
+ if (cg->state == CGST_WAIT_CONDITIONS)
+ lockspace->cg_next.wait_condition = 4;
+ if (poll_fencing)
+ lockspace->cg_next.wait_condition = 1;
+ else if (poll_quorum)
+ lockspace->cg_next.wait_condition = 2;
+ else if (poll_fs)
+ lockspace->cg_next.wait_condition = 3;
+
+ if (cg->state == CGST_WAIT_MESSAGES)
+ lockspace->cg_next.wait_messages = 1;
+ out:
return 0;
}

-int set_lockspace_info(struct lockspace *ls, struct dlmc_lockspace *lockspace)
+static int _set_node_info(struct lockspace *ls, struct change *cg, int nodeid,
+ struct dlmc_node *node)
{
+ struct member *m = NULL;
+ struct node *n;
+
+ if (cg)
+ m = find_memb(cg, nodeid);
+ if (!m)
+ goto history;
+
+ node->flags |= DLMC_NF_MEMBER;
+
+ if (m->start)
+ node->flags |= DLMC_NF_START;
+ if (m->disallowed)
+ node->flags |= DLMC_NF_DISALLOWED;
+
+ history:
+ n = get_node_history(ls, nodeid);
+ if (!n)
+ goto out;
+
+ if (n->check_fencing)
+ node->flags |= DLMC_NF_CHECK_FENCING;
+ if (n->check_quorum)
+ node->flags |= DLMC_NF_CHECK_QUORUM;
+ if (n->check_fs)
+ node->flags |= DLMC_NF_CHECK_FS;
+ if (n->fs_notified)
+ node->flags |= DLMC_NF_FS_NOTIFIED;
+
+ node->added_seq = n->added_seq;
+ node->removed_seq = n->removed_seq;
+ node->failed_reason = n->failed_reason;
+ out:
+ return 0;
+}
+
+int set_node_info(struct lockspace *ls, int nodeid, struct dlmc_node *node)
+{
+ struct change *cg;
+
+ if (!list_empty(&ls->changes)) {
+ cg = list_first_entry(&ls->changes, struct change, list);
+ return _set_node_info(ls, cg, nodeid, node);
+ }
+
+ return _set_node_info(ls, ls->started_change, nodeid, node);
+}
+
+int set_lockspaces(int *count, struct dlmc_lockspace **lss_out)
+{
+ struct lockspace *ls;
+ struct dlmc_lockspace *lss, *lsp;
+ int ls_count = 0;
+
+ list_for_each_entry(ls, &lockspaces, list)
+ ls_count++;
+
+ lss = malloc(ls_count * sizeof(struct dlmc_lockspace));
+ if (!lss)
+ return -ENOMEM;
+
+ lsp = lss;
+ list_for_each_entry(ls, &lockspaces, list) {
+ set_lockspace_info(ls, lsp++);
+ }
+
+ *count = ls_count;
+ *lss_out = lss;
return 0;
}

int set_lockspace_nodes(struct lockspace *ls, int option, int *node_count,
- struct dlmc_node **nodes)
+ struct dlmc_node **nodes_out)
{
+ struct change *cg;
+ struct node *n;
+ struct dlmc_node *nodes = NULL, *nodep;
+ struct member *memb;
+ int count = 0;
+
+ if (option == DLMC_NODES_ALL) {
+ if (!list_empty(&ls->changes))
+ cg = list_first_entry(&ls->changes, struct change,list);
+ else
+ cg = ls->started_change;
+
+ list_for_each_entry(n, &ls->node_history, list)
+ count++;
+
+ } else if (option == DLMC_NODES_MEMBERS) {
+ if (!ls->started_change)
+ goto out;
+ cg = ls->started_change;
+ count = cg->member_count;
+
+ } else if (option == DLMC_NODES_NEXT) {
+ if (list_empty(&ls->changes))
+ goto out;
+ cg = list_first_entry(&ls->changes, struct change, list);
+ count = cg->member_count;
+ } else
+ goto out;
+
+ nodes = malloc(count * sizeof(struct dlmc_node));
+ if (!nodes)
+ return -ENOMEM;
+ nodep = nodes;
+
+ if (option == DLMC_NODES_ALL) {
+ list_for_each_entry(n, &ls->node_history, list)
+ _set_node_info(ls, cg, n->nodeid, nodep++);
+ } else {
+ list_for_each_entry(memb, &cg->members, list)
+ _set_node_info(ls, cg, memb->nodeid, nodep++);
+ }
+
+ out:
+ *node_count = count;
+ *nodes_out = nodes;
return 0;
}

diff --git a/group/dlm_controld/dlm_controld.h b/group/dlm_controld/dlm_controld.h
index 079a8bc..655c2ef 100644
--- a/group/dlm_controld/dlm_controld.h
+++ b/group/dlm_controld/dlm_controld.h
@@ -24,13 +24,14 @@

#define DLMC_CMD_DUMP_DEBUG 1
#define DLMC_CMD_DUMP_PLOCKS 2
-#define DLMC_CMD_NODE_INFO 3
-#define DLMC_CMD_LOCKSPACE_INFO 4
-#define DLMC_CMD_LOCKSPACE_NODES 5
-#define DLMC_CMD_FS_REGISTER 6
-#define DLMC_CMD_FS_UNREGISTER 7
-#define DLMC_CMD_FS_NOTIFIED 8
-#define DLMC_CMD_DEADLOCK_CHECK 9
+#define DLMC_CMD_LOCKSPACE_INFO 3
+#define DLMC_CMD_NODE_INFO 4
+#define DLMC_CMD_LOCKSPACES 5
+#define DLMC_CMD_LOCKSPACE_NODES 6
+#define DLMC_CMD_FS_REGISTER 7
+#define DLMC_CMD_FS_UNREGISTER 8
+#define DLMC_CMD_FS_NOTIFIED 9
+#define DLMC_CMD_DEADLOCK_CHECK 10

struct dlmc_header {
unsigned int magic;
diff --git a/group/dlm_controld/dlm_daemon.h b/group/dlm_controld/dlm_daemon.h
index 370989a..b35f655 100644
--- a/group/dlm_controld/dlm_daemon.h
+++ b/group/dlm_controld/dlm_daemon.h
@@ -222,8 +222,9 @@ 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_lockspaces(int *count, struct dlmc_lockspace **lss_out);
int set_lockspace_nodes(struct lockspace *ls, int option, int *node_count,
- struct dlmc_node **nodes);
+ struct dlmc_node **nodes_out);
int set_fs_notified(struct lockspace *ls, int nodeid);

/* deadlock.c */
@@ -278,9 +279,11 @@ 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_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_lockspaces_group(int *count, struct dlmc_lockspace **lss_out);
int set_lockspace_nodes_group(struct lockspace *ls, int option, int *node_count,
struct dlmc_node **nodes);

diff --git a/group/dlm_controld/group.c b/group/dlm_controld/group.c
index 7f31f69..023fadd 100644
--- a/group/dlm_controld/group.c
+++ b/group/dlm_controld/group.c
@@ -240,19 +240,28 @@ int setup_groupd(void)
return rv;
}

-int set_node_info_group(struct lockspace *ls, int nodeid, struct dlmc_node *node)
+/* FIXME: most of the query info doesn't apply in the LIBGROUP mode,
+ but we can emulate some basic parts of it */
+
+int set_lockspace_info_group(struct lockspace *ls,
+ struct dlmc_lockspace *lockspace)
{
return 0;
}

-int set_lockspace_info_group(struct lockspace *ls,
- struct dlmc_lockspace *lockspace)
+int set_node_info_group(struct lockspace *ls, int nodeid,
+ struct dlmc_node *node)
+{
+ return 0;
+}
+
+int set_lockspaces_group(int *count, struct dlmc_lockspace **lss_out)
{
return 0;
}

int set_lockspace_nodes_group(struct lockspace *ls, int option, int *node_count,
- struct dlmc_node **nodes)
+ struct dlmc_node **nodes_out)
{
return 0;
}
diff --git a/group/dlm_controld/main.c b/group/dlm_controld/main.c
index 39bbdba..46d3fe8 100644
--- a/group/dlm_controld/main.c
+++ b/group/dlm_controld/main.c
@@ -436,7 +436,8 @@ static void query_dump_plocks(int fd, char *name)
/* 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)
+static void do_reply(int fd, int cmd, char *name, int result, char *buf,
+ int buflen)
{
char *reply;
int reply_len;
@@ -457,10 +458,10 @@ static void do_reply(int fd, int cmd, char *name, int result, char *buf, int buf
free(reply);
}

-static void query_node_info(int fd, char *name, int nodeid)
+static void query_lockspace_info(int fd, char *name)
{
struct lockspace *ls;
- struct dlmc_node node;
+ struct dlmc_lockspace lockspace;
int rv;

ls = find_ls(name);
@@ -470,18 +471,18 @@ static void query_node_info(int fd, char *name, int nodeid)
}

if (group_mode == GROUP_LIBGROUP)
- rv = set_node_info_group(ls, nodeid, &node);
+ rv = set_lockspace_info_group(ls, &lockspace);
else
- rv = set_node_info(ls, nodeid, &node);
+ rv = set_lockspace_info(ls, &lockspace);
out:
- do_reply(fd, DLMC_CMD_NODE_INFO, name, rv,
- (char *)&node, sizeof(node));
+ do_reply(fd, DLMC_CMD_LOCKSPACE_INFO, name, rv,
+ (char *)&lockspace, sizeof(lockspace));
}

-static void query_lockspace_info(int fd, char *name)
+static void query_node_info(int fd, char *name, int nodeid)
{
struct lockspace *ls;
- struct dlmc_lockspace lockspace;
+ struct dlmc_node node;
int rv;

ls = find_ls(name);
@@ -491,12 +492,43 @@ static void query_lockspace_info(int fd, char *name)
}

if (group_mode == GROUP_LIBGROUP)
- rv = set_lockspace_info_group(ls, &lockspace);
+ rv = set_node_info_group(ls, nodeid, &node);
else
- rv = set_lockspace_info(ls, &lockspace);
+ rv = set_node_info(ls, nodeid, &node);
out:
- do_reply(fd, DLMC_CMD_LOCKSPACE_INFO, name, rv,
- (char *)&lockspace, sizeof(lockspace));
+ do_reply(fd, DLMC_CMD_NODE_INFO, name, rv,
+ (char *)&node, sizeof(node));
+}
+
+static void query_lockspaces(int fd, int max)
+{
+ int ls_count = 0;
+ struct dlmc_lockspace *lss = NULL;
+ int rv, result;
+
+ if (group_mode == GROUP_LIBGROUP)
+ rv = set_lockspaces_group(&ls_count, &lss);
+ else
+ rv = set_lockspaces(&ls_count, &lss);
+
+ if (rv < 0) {
+ result = rv;
+ ls_count = 0;
+ goto out;
+ }
+
+ if (ls_count > max) {
+ result = -E2BIG;
+ ls_count = max;
+ } else {
+ result = ls_count;
+ }
+ out:
+ do_reply(fd, DLMC_CMD_LOCKSPACES, NULL, result,
+ (char *)lss, ls_count * sizeof(struct dlmc_lockspace));
+
+ if (lss)
+ free(lss);
}

static void query_lockspace_nodes(int fd, char *name, int option, int max)
@@ -618,13 +650,6 @@ static void process_connection(int ci)
send_cycle_start(ls);
break;

- case DLMC_CMD_DUMP_DEBUG:
- case DLMC_CMD_DUMP_PLOCKS:
- case DLMC_CMD_NODE_INFO:
- case DLMC_CMD_LOCKSPACE_INFO:
- case DLMC_CMD_LOCKSPACE_NODES:
- log_error("process_connection query on wrong socket");
- break;
default:
log_error("process_connection %d unknown command %d",
ci, h.command);
@@ -731,11 +756,14 @@ static void *process_queries(void *arg)
case DLMC_CMD_DUMP_PLOCKS:
query_dump_plocks(f, h.name);
break;
+ case DLMC_CMD_LOCKSPACE_INFO:
+ query_lockspace_info(f, h.name);
+ break;
case DLMC_CMD_NODE_INFO:
query_node_info(f, h.name, h.data);
break;
- case DLMC_CMD_LOCKSPACE_INFO:
- query_lockspace_info(f, h.name);
+ case DLMC_CMD_LOCKSPACES:
+ query_lockspaces(f, h.data);
break;
case DLMC_CMD_LOCKSPACE_NODES:
query_lockspace_nodes(f, h.name, h.option, h.data);


hooks/post-receive
--
Cluster Project
 

Thread Tools




All times are GMT. The time now is 09:59 PM.

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