public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: David Teigland <teigland@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: master - dlm_controld: allow early fs_register
Date: Wed, 06 Aug 2008 21:05:00 -0000	[thread overview]
Message-ID: <20080806203713.6A5B812003F@lists.fedorahosted.org> (raw)

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();
 


                 reply	other threads:[~2008-08-06 20:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080806203713.6A5B812003F@lists.fedorahosted.org \
    --to=teigland@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).