This is the mail archive of the
cluster-cvs@sourceware.org
mailing list for the cluster.
master - gfs_controld: queries in libgroup mode
- From: David Teigland <teigland at fedoraproject dot org>
- To: cluster-cvs-relay at redhat dot com
- Date: Tue, 12 Aug 2008 14:12:50 +0000 (UTC)
- Subject: master - gfs_controld: queries in libgroup mode
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=816a6ee09dcd7de0f264f375fd83cd5ce5c11bc4
Commit: 816a6ee09dcd7de0f264f375fd83cd5ce5c11bc4
Parent: 116708143fb9492c1f9b99e3837bacc590317173
Author: David Teigland <teigland@redhat.com>
AuthorDate: Fri Aug 8 16:42:00 2008 -0500
Committer: David Teigland <teigland@redhat.com>
CommitterDate: Tue Aug 12 09:03:45 2008 -0500
gfs_controld: queries in libgroup mode
Most of the query info doesn't apply when running in LIBGROUP mode,
but some of the basic info can be provided.
Signed-off-by: David Teigland <teigland@redhat.com>
---
group/dlm_controld/group.c | 2 +-
group/gfs_controld/cpg-old.c | 31 ++-------
group/gfs_controld/cpg-old.h | 25 +++++++
group/gfs_controld/group.c | 123 +++++++++++++++++++++++++++++++++-
group/gfs_controld/main.c | 3 +
group/libgfscontrol/libgfscontrol.h | 1 +
6 files changed, 154 insertions(+), 31 deletions(-)
diff --git a/group/dlm_controld/group.c b/group/dlm_controld/group.c
index cd2743b..ac6c354 100644
--- a/group/dlm_controld/group.c
+++ b/group/dlm_controld/group.c
@@ -311,7 +311,7 @@ int set_lockspace_nodes_group(struct lockspace *ls, int option, int *node_count,
memset(nodes, 0, sizeof(*nodes));
nodep = nodes;
- for (i = 0; i < cb_member_count; i++) {
+ for (i = 0; i < ls->cb_member_count; i++) {
set_node_info_group(ls, ls->cb_members[i], nodep++);
}
out:
diff --git a/group/gfs_controld/cpg-old.c b/group/gfs_controld/cpg-old.c
index 8808957..56e4f08 100644
--- a/group/gfs_controld/cpg-old.c
+++ b/group/gfs_controld/cpg-old.c
@@ -32,31 +32,6 @@ enum {
RS_READONLY,
};
-struct mg_member {
- struct list_head list;
- int nodeid;
- int jid;
-
- int spectator;
- int readonly;
- int rw;
- uint32_t opts;
-
- int tell_gfs_to_recover;
- int wait_gfs_recover_done;
- int gone_event;
- int gone_type;
- int finished;
- int local_recovery_status;
- int recovery_status;
- int withdrawing;
- int needs_journals;
-
- int ms_kernel_mount_done;
- int ms_first_mounter;
- int ms_kernel_mount_error;
-};
-
extern group_handle_t gh;
/* cpg message protocol
@@ -632,6 +607,7 @@ static void receive_recovery_done(struct mountgroup *mg, char *buf, int len,
}
mg->needs_recovery = 0;
+ mg->kernel_stopped = 0; /* for queries */
set_sysfs(mg, "block", 0);
}
@@ -1891,8 +1867,10 @@ int do_stop(struct mountgroup *mg)
for (;;) {
rv = set_sysfs(mg, "block", 1);
- if (!rv)
+ if (!rv) {
+ mg->kernel_stopped = 1; /* for queries */
break;
+ }
/* We get an error trying to block gfs, this could be due
to a number of things:
@@ -2001,6 +1979,7 @@ int do_finish(struct mountgroup *mg)
}
if (!mg->needs_recovery) {
+ mg->kernel_stopped = 0; /* for queries */
set_sysfs(mg, "block", 0);
/* we may have been holding back our local mount due to
diff --git a/group/gfs_controld/cpg-old.h b/group/gfs_controld/cpg-old.h
index e343faf..0458338 100644
--- a/group/gfs_controld/cpg-old.h
+++ b/group/gfs_controld/cpg-old.h
@@ -44,5 +44,30 @@ struct save_msg {
char buf[0];
};
+struct mg_member {
+ struct list_head list;
+ int nodeid;
+ int jid;
+
+ int spectator;
+ int readonly;
+ int rw;
+ uint32_t opts;
+
+ int tell_gfs_to_recover;
+ int wait_gfs_recover_done;
+ int gone_event;
+ int gone_type;
+ int finished;
+ int local_recovery_status;
+ int recovery_status;
+ int withdrawing;
+ int needs_journals;
+
+ int ms_kernel_mount_done;
+ int ms_first_mounter;
+ int ms_kernel_mount_error;
+};
+
#endif
diff --git a/group/gfs_controld/group.c b/group/gfs_controld/group.c
index ca2e376..e349853 100644
--- a/group/gfs_controld/group.c
+++ b/group/gfs_controld/group.c
@@ -181,24 +181,139 @@ void close_groupd(void)
group_exit(gh);
}
-int set_mountgroup_info_group(struct mountgroup *mg, struct gfsc_mountgroup *out)
+/* most of the query info doesn't apply in the LIBGROUP mode, but we can
+ emulate some basic parts of it */
+
+int set_mountgroup_info_group(struct mountgroup *mg,
+ struct gfsc_mountgroup *out)
{
+ strncpy(out->name, mg->name, GFS_MOUNTGROUP_LEN);
+ out->global_id = mg->id;
+
+ if (mg->joining)
+ out->flags |= GFSC_MF_JOINING;
+ if (mg->leaving)
+ out->flags |= GFSC_MF_LEAVING;
+ if (mg->kernel_stopped)
+ out->flags |= GFSC_MF_KERNEL_STOPPED;
+
+ out->cg_prev.member_count = mg->memb_count;
+
return 0;
}
-int set_node_info_group(struct mountgroup *mg, int nodeid, struct gfsc_node *node)
+static int _set_node_info(struct mountgroup *mg, int nodeid,
+ struct gfsc_node *node)
{
+ struct mg_member *memb;
+ int is_member = 0, is_gone = 0;
+
+ list_for_each_entry(memb, &mg->members, list) {
+ if (memb->nodeid != nodeid)
+ continue;
+ is_member = 1;
+ goto found;
+ }
+ list_for_each_entry(memb, &mg->members_gone, list) {
+ if (memb->nodeid != nodeid)
+ continue;
+ is_gone = 1;
+ break;
+ }
+ if (!is_member && !is_gone)
+ goto out;
+ found:
+ node->nodeid = nodeid;
+
+ if (is_member)
+ node->flags |= GFSC_NF_MEMBER;
+ if (memb->spectator)
+ node->flags |= GFSC_NF_SPECTATOR;
+ if (memb->readonly)
+ node->flags |= GFSC_NF_READONLY;
+ if (memb->ms_kernel_mount_done)
+ node->flags |= GFSC_NF_KERNEL_MOUNT_DONE;
+ if (memb->ms_kernel_mount_error)
+ node->flags |= GFSC_NF_KERNEL_MOUNT_ERROR;
+
+ node->jid = memb->jid;
+
+ if (is_gone && memb->gone_type == GROUP_NODE_FAILED)
+ node->failed_reason = 1;
+ out:
return 0;
}
+int set_node_info_group(struct mountgroup *mg, int nodeid,
+ struct gfsc_node *node)
+{
+ return _set_node_info(mg, nodeid, node);
+}
+
int set_mountgroups_group(int *count, struct gfsc_mountgroup **mgs_out)
{
+ struct mountgroup *mg;
+ struct gfsc_mountgroup *mgs, *mgp;
+ int mg_count = 0;
+
+ list_for_each_entry(mg, &mountgroups, list)
+ mg_count++;
+
+ mgs = malloc(mg_count * sizeof(struct gfsc_mountgroup));
+ if (!mgs)
+ return -ENOMEM;
+ memset(mgs, 0, mg_count * sizeof(struct gfsc_mountgroup));
+
+ mgp = mgs;
+ list_for_each_entry(mg, &mountgroups, list) {
+ set_mountgroup_info(mg, mgp++);
+ }
+
+ *count = mg_count;
+ *mgs_out = mgs;
return 0;
}
-int set_mountgroup_nodes_group(struct mountgroup *mg, int option, int *node_count,
- struct gfsc_node **nodes_out)
+int list_count(struct list_head *head)
+{
+ struct list_head *tmp;
+ int count = 0;
+
+ list_for_each(tmp, head)
+ count++;
+ return count;
+}
+
+int set_mountgroup_nodes_group(struct mountgroup *mg, int option,
+ int *node_count, struct gfsc_node **nodes_out)
{
+ struct gfsc_node *nodes = NULL, *nodep;
+ struct mg_member *memb;
+ int count = 0;
+
+ if (option == GFSC_NODES_ALL) {
+ count = mg->memb_count + list_count(&mg->members_gone);
+ } else if (option == GFSC_NODES_MEMBERS) {
+ count = mg->memb_count;
+ } else
+ goto out;
+
+ nodes = malloc(count * sizeof(struct gfsc_node));
+ if (!nodes)
+ return -ENOMEM;
+ memset(nodes, 0, count * sizeof(struct gfsc_node));
+ nodep = nodes;
+
+ list_for_each_entry(memb, &mg->members, list)
+ _set_node_info(mg, memb->nodeid, nodep++);
+
+ if (option == GFSC_NODES_ALL) {
+ list_for_each_entry(memb, &mg->members_gone, list)
+ _set_node_info(mg, memb->nodeid, nodep++);
+ }
+ out:
+ *node_count = count;
+ *nodes_out = nodes;
return 0;
}
diff --git a/group/gfs_controld/main.c b/group/gfs_controld/main.c
index 00e227d..01de429 100644
--- a/group/gfs_controld/main.c
+++ b/group/gfs_controld/main.c
@@ -454,6 +454,9 @@ static void query_mountgroup_info(int fd, char *name)
goto out;
}
+ memset(&mountgroup, 0, sizeof(mountgroup));
+ mountgroup.group_mode = group_mode;
+
if (group_mode == GROUP_LIBGROUP)
rv = set_mountgroup_info_group(mg, &mountgroup);
else
diff --git a/group/libgfscontrol/libgfscontrol.h b/group/libgfscontrol/libgfscontrol.h
index 28b20e5..e5bb969 100644
--- a/group/libgfscontrol/libgfscontrol.h
+++ b/group/libgfscontrol/libgfscontrol.h
@@ -49,6 +49,7 @@ struct gfsc_change {
#define GFSC_MF_LOCAL_RECOVERY_BUSY 0x00000080
struct gfsc_mountgroup {
+ int group_mode;
struct gfsc_change cg_prev; /* completed change (started_change) */
struct gfsc_change cg_next; /* in-progress change (changes list) */
int journals_need_recovery; /* count of jounals need_recovery */