From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31704 invoked by alias); 30 Apr 2008 17:07:30 -0000 Received: (qmail 31432 invoked by uid 9453); 30 Apr 2008 17:07:28 -0000 Date: Wed, 30 Apr 2008 17:07:00 -0000 Message-ID: <20080430170728.31376.qmail@sourceware.org> From: teigland@sourceware.org To: cluster-cvs@sources.redhat.com, cluster-devel@redhat.com Subject: Cluster Project branch, master, updated. cluster-2.99.00-10-gf0cc81b X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: af2b1a3e3430a1e11b29a0ef6c34332c4176797e X-Git-Newrev: f0cc81be7ea17b3d53916c150bb8d4231511b2fa Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2008-q2/txt/msg00237.txt.bz2 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=f0cc81be7ea17b3d53916c150bb8d4231511b2fa The branch, master has been updated via f0cc81be7ea17b3d53916c150bb8d4231511b2fa (commit) from af2b1a3e3430a1e11b29a0ef6c34332c4176797e (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 f0cc81be7ea17b3d53916c150bb8d4231511b2fa Author: David Teigland Date: Wed Apr 30 11:59:44 2008 -0500 libdlmcontrol: filling out code Signed-off-by: David Teigland ----------------------------------------------------------------------- Summary of changes: dlm/libdlmcontrol/libdlmcontrol.h | 13 +------ dlm/libdlmcontrol/main.c | 74 +++++++++++++++++++++++++++++++++++++ dlm/tool/main.c | 2 +- group/dlm_controld/dlm_controld.h | 2 +- group/dlm_controld/main.c | 15 ++++--- 5 files changed, 86 insertions(+), 20 deletions(-) diff --git a/dlm/libdlmcontrol/libdlmcontrol.h b/dlm/libdlmcontrol/libdlmcontrol.h index 69eee26..117e20e 100644 --- a/dlm/libdlmcontrol/libdlmcontrol.h +++ b/dlm/libdlmcontrol/libdlmcontrol.h @@ -46,24 +46,13 @@ int dlmc_lockspace_info(char *name, struct dlmc_lockspace *ls); int dlmc_lockspace_nodes(char *name, int type, int max, int *count, struct dlmc_node *nodes); -/* returns a local unix socket connected to dlm_controld */ int dlmc_fs_connect(void); - -/* closes the unix socket */ void dlmc_fs_disconnect(int fd); - -/* writes to fd: REGISTER + name */ int dlmc_fs_register(int fd, char *name); - -/* writes to fd: UNREGISTER + name */ int dlmc_fs_unregister(int fd, char *name); - -/* writes to fd: NOTIFIED + name + nodeid */ int dlmc_fs_notified(int fd, char *name, int nodeid); - -/* reads from fd: gets name, REGISTER/NOTIFIED, nodeid, result */ int dlmc_fs_result(int fd, char *name, int *type, int *nodeid, int *result); -int dlmc_deadlk_check(char *name); +int dlmc_deadlock_check(char *name); #endif diff --git a/dlm/libdlmcontrol/main.c b/dlm/libdlmcontrol/main.c index f52bce2..2bd001d 100644 --- a/dlm/libdlmcontrol/main.c +++ b/dlm/libdlmcontrol/main.c @@ -281,3 +281,77 @@ int dlmc_lockspace_nodes(char *name, int type, int max, int *count, struct dlmc_ return rv; } +int dlmc_fs_connect(void) +{ + return do_connect(DLMC_SOCK_PATH); +} + +void dlmc_fs_disconnect(int fd) +{ + close(fd); +} + +int dlmc_fs_register(int fd, char *name) +{ + struct dlmc_header h; + + init_header(&h, name, DLMC_CMD_FS_REGISTER, sizeof(h)); + + return do_write(fd, &h, sizeof(h)); +} + +int dlmc_fs_unregister(int fd, char *name) +{ + struct dlmc_header h; + + init_header(&h, name, DLMC_CMD_FS_UNREGISTER, sizeof(h)); + + return do_write(fd, &h, sizeof(h)); +} + +int dlmc_fs_notified(int fd, char *name, int nodeid) +{ + struct dlmc_header h; + + init_header(&h, name, DLMC_CMD_FS_NOTIFIED, sizeof(h)); + h.data = nodeid; + + return do_write(fd, &h, sizeof(h)); +} + +int dlmc_fs_result(int fd, char *name, int *type, int *nodeid, int *result) +{ + struct dlmc_header h; + int rv; + + rv = do_read(fd, &h, sizeof(h)); + if (rv < 0) + goto out; + + strncpy(name, h.name, DLM_LOCKSPACE_LEN); + *type = h.command; + *nodeid = h.option; + *result = h.data; + out: + return rv; +} + +int dlmc_deadlock_check(char *name) +{ + struct dlmc_header h; + int fd, rv; + + init_header(&h, name, DLMC_CMD_DEADLOCK_CHECK, sizeof(h)); + + fd = do_connect(DLMC_SOCK_PATH); + if (fd < 0) { + rv = fd; + goto out; + } + + rv = do_write(fd, &h, sizeof(h)); + close(fd); + out: + return rv; +} + diff --git a/dlm/tool/main.c b/dlm/tool/main.c index fcd6b35..ed1b21d 100644 --- a/dlm/tool/main.c +++ b/dlm/tool/main.c @@ -395,7 +395,7 @@ void do_spaces(void) static void do_deadlock_check(char *name) { - /* dlmc_deadlk_check(name); */ + dlmc_deadlock_check(name); } int main(int argc, char **argv) diff --git a/group/dlm_controld/dlm_controld.h b/group/dlm_controld/dlm_controld.h index 8b18983..079a8bc 100644 --- a/group/dlm_controld/dlm_controld.h +++ b/group/dlm_controld/dlm_controld.h @@ -30,7 +30,7 @@ #define DLMC_CMD_FS_REGISTER 6 #define DLMC_CMD_FS_UNREGISTER 7 #define DLMC_CMD_FS_NOTIFIED 8 -#define DLMC_CMD_DEADLK_CHECK 9 +#define DLMC_CMD_DEADLOCK_CHECK 9 struct dlmc_header { unsigned int magic; diff --git a/group/dlm_controld/main.c b/group/dlm_controld/main.c index 5646df1..30c2c14 100644 --- a/group/dlm_controld/main.c +++ b/group/dlm_controld/main.c @@ -388,6 +388,7 @@ static void process_connection(int ci) struct dlmc_header h; char *extra = NULL; int rv, extra_len; + struct lockspace *ls; rv = do_read(client[ci].fd, &h, sizeof(h)); if (rv < 0) { @@ -423,20 +424,21 @@ static void process_connection(int ci) switch (h.command) { case DLMC_CMD_FS_REGISTER: + /* TODO */ break; case DLMC_CMD_FS_UNREGISTER: + /* TODO */ break; case DLMC_CMD_FS_NOTIFIED: + /* TODO */ break; - case DLMC_CMD_DEADLK_CHECK: -#if 0 - ls = find_ls(hd.name); + case DLMC_CMD_DEADLOCK_CHECK: + ls = find_ls(h.name); if (ls) send_cycle_start(ls); -#endif break; case DLMC_CMD_DUMP_DEBUG: @@ -543,7 +545,7 @@ static void *process_queries(void *arg) goto out; } - pthread_mutex_lock(&query_mutex); + query_lock(); switch (h.command) { case DLMC_CMD_DUMP_DEBUG: @@ -564,7 +566,7 @@ static void *process_queries(void *arg) default: break; } - pthread_mutex_unlock(&query_mutex); + query_unlock(); out: close(f); @@ -697,6 +699,7 @@ static int loop(void) goto out; } + /* FIXME: lock/unlock around operations that take a while */ query_lock(); for (i = 0; i <= client_maxi; i++) { hooks/post-receive -- Cluster Project