master - dlm_controld: allow early fs_register

David Teigland teigland@fedoraproject.org
Wed Aug 6 21:05:00 GMT 2008


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=0e44be6d98d7691c5bcadf49ba11b668774bfebc
Commit:        0e44be6d98d7691c5bcadf49ba11b668774bfebc
Parent:        84a2ed735117e161897b50f4f4abab40390d4f66
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Wed Aug 6 15:27:24 2008 -0500
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Wed Aug 6 15:27:24 2008 -0500

dlm_controld: allow early fs_register

fs_controld daemons need to register their interest in a lockspace
during startup before they've actually joined the lockspace, which
means we need to record the registration before the lockspace exists
and then set the registered flag when it's created.

Signed-off-by: David Teigland <teigland@redhat.com>
---
 group/dlm_controld/main.c |   55 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/group/dlm_controld/main.c b/group/dlm_controld/main.c
index e30e711..6b866c2 100644
--- a/group/dlm_controld/main.c
+++ b/group/dlm_controld/main.c
@@ -17,6 +17,7 @@ static struct client *client = NULL;
 static struct pollfd *pollfd = NULL;
 static pthread_t query_thread;
 static pthread_mutex_t query_mutex;
+static struct list_head fs_register_list;
 
 struct client {
 	int fd;
@@ -192,6 +193,44 @@ struct lockspace *find_ls_id(uint32_t id)
 	return NULL;
 }
 
+struct fs_reg {
+	struct list_head list;
+	char name[DLM_LOCKSPACE_LEN+1];
+};
+
+static int fs_register_add(char *name)
+{
+	struct fs_reg *fs;
+	fs = malloc(sizeof(struct fs_reg));
+	if (!fs)
+		return -ENOMEM;
+	strncpy(fs->name, name, DLM_LOCKSPACE_LEN);
+	list_add(&fs->list, &fs_register_list);
+	return 0;
+}
+
+static void fs_register_del(char *name)
+{
+	struct fs_reg *fs;
+	list_for_each_entry(fs, &fs_register_list, list) {
+		if (!strcmp(name, fs->name)) {
+			list_del(&fs->list);
+			free(fs);
+			return;
+		}
+	}
+}
+
+static int fs_register_check(char *name)
+{
+	struct fs_reg *fs;
+	list_for_each_entry(fs, &fs_register_list, list) {
+		if (!strcmp(name, fs->name))
+			return 1;
+	}
+	return 0;
+}
+
 #define MAXARGS 8
 
 static char *get_args(char *buf, int *argc, char **argv, char sep, int want)
@@ -300,6 +339,9 @@ static void process_uevent(int ci)
 			goto out;
 		}
 
+		if (fs_register_check(ls->name))
+			ls->fs_registered = 1;
+
 		if (group_mode == GROUP_LIBGROUP)
 			rv = dlm_join_lockspace_group(ls);
 		else
@@ -602,20 +644,24 @@ static void process_connection(int ci)
 
 	switch (h.command) {
 	case DLMC_CMD_FS_REGISTER:
-		ls = find_ls(h.name);
 		if (group_mode == GROUP_LIBGROUP) {
 			rv = -EINVAL;
-		} else if (!ls) {
-			rv = -ENOENT;
 		} else {
-			ls->fs_registered = 1;
 			rv = 0;
+			ls = find_ls(h.name);
+			if (ls)
+				ls->fs_registered = 1;
+			else
+				rv = fs_register_add(h.name);
 		}
 		do_reply(client[ci].fd, DLMC_CMD_FS_REGISTER, h.name, rv,
 			 NULL, 0);
 		break;
 
 	case DLMC_CMD_FS_UNREGISTER:
+		if (group_mode == GROUP_LIBGROUP)
+			break;
+		fs_register_del(h.name);
 		ls = find_ls(h.name);
 		if (ls)
 			ls->fs_registered = 0;
@@ -1161,6 +1207,7 @@ static void set_scheduler(void)
 int main(int argc, char **argv)
 {
 	INIT_LIST_HEAD(&lockspaces);
+	INIT_LIST_HEAD(&fs_register_list);
 
 	init_logging();
 



More information about the Cluster-cvs mailing list