From mboxrd@z Thu Jan 1 00:00:00 1970 From: lhh@sourceware.org Date: 12 Jul 2006 14:04:08 -0000 Subject: [Cluster-devel] cluster/rgmanager/include lock.h members.h mes ... Message-ID: <20060712140408.4197.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Changes by: lhh at sourceware.org 2006-07-12 14:04:07 Modified files: rgmanager/include: lock.h members.h message.h resgroup.h rg_types.h vf.h Added files: rgmanager/include: cman-private.h Log message: Fix missing/non-updated #includes Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/cman-private.h.diff?cvsroot=cluster&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/lock.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/members.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/message.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/resgroup.h.diff?cvsroot=cluster&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/rg_types.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/vf.h.diff?cvsroot=cluster&r1=1.4&r2=1.5 /cvs/cluster/cluster/rgmanager/include/cman-private.h,v --> standard output revision 1.1 --- cluster/rgmanager/include/cman-private.h +++ - 2006-07-12 14:04:07.502035000 +0000 @@ -0,0 +1,14 @@ +#ifndef _CMAN_PRIVATE_H +#define _CMAN_PRIVATE_H + +#include + +int cman_init_subsys(cman_handle_t *ch); +cman_handle_t *cman_lock(int block, int sig); +cman_handle_t *cman_lock_preemptible(int block, int *fd); +int cman_cleanup_subsys(void); +int cman_unlock(cman_handle_t *ch); +int cman_send_data_unlocked(void *buf, int len, int flags, + uint8_t port, int nodeid); + +#endif --- cluster/rgmanager/include/lock.h 2006/06/02 17:37:10 1.1 +++ cluster/rgmanager/include/lock.h 2006/07/12 14:04:06 1.2 @@ -2,12 +2,21 @@ #define _LOCK_H #include +#include +#include #include -int clu_lock(dlm_lshandle_t ls, int mode, struct dlm_lksb *lksb, +int clu_ls_lock(dlm_lshandle_t ls, int mode, struct dlm_lksb *lksb, + int options, char *resource); +dlm_lshandle_t clu_open_lockspace(const char *lsname); +int clu_ls_unlock(dlm_lshandle_t ls, struct dlm_lksb *lksb); +int clu_close_lockspace(dlm_lshandle_t ls, const char *lsname); + +/* Default lockspace wrappers */ +int clu_lock_init(const char *default_lsname); +int clu_lock(int mode, struct dlm_lksb *lksb, int options, char *resource); -dlm_lshandle_t clu_acquire_lockspace(const char *lsname); -int clu_unlock(dlm_lshandle_t ls, struct dlm_lksb *lksb); -int clu_release_lockspace(dlm_lshandle_t ls, char *lsname); +int clu_unlock(struct dlm_lksb *lksb); +void clu_lock_finished(const char *default_lsname); #endif --- cluster/rgmanager/include/members.h 2006/06/02 17:37:10 1.1 +++ cluster/rgmanager/include/members.h 2006/07/12 14:04:06 1.2 @@ -21,11 +21,4 @@ cluster_member_list_t *member_list_dup(cluster_member_list_t *old); -#define cml_size(c) \ - (sizeof(cluster_member_list_t) + \ - sizeof(cman_node_t) * c) - -#define cml_alloc(size) malloc(cml_size(size)) - - #endif --- cluster/rgmanager/include/message.h 2006/06/02 17:37:10 1.1 +++ cluster/rgmanager/include/message.h 2006/07/12 14:04:06 1.2 @@ -64,13 +64,17 @@ swab32((ptr)->src_nodeid);\ } -typedef struct { + +typedef struct _msgctx { + struct _msg_ops *ops; msgctx_type_t type; + int flags; + /* XXX todo make this opaque */ union { struct { + msg_q_t *queue; pthread_mutex_t mutex; pthread_cond_t cond; - msg_q_t *queue; cman_handle_t cman_handle; int nodeid; int port; @@ -80,21 +84,59 @@ } cluster_info; struct { int sockfd; - int flags; + int pad; } local_info; } u; } msgctx_t; +typedef int (*msg_open_t)(int type, int nodeid, int port, msgctx_t *ctx, + int timeout); +typedef int (*msg_close_t)(msgctx_t *); +typedef int (*msg_listen_t)(int me, void *, msgctx_t **); +typedef int (*msg_accept_t)(msgctx_t *, msgctx_t *); +typedef int (*msg_shutdown_t)(void); +typedef int (*msg_send_t)(msgctx_t *, void *, size_t); +typedef int (*msg_receive_t)(msgctx_t *, void *, size_t, int); +typedef int (*msg_wait_t)(msgctx_t *, int); +typedef int (*msg_fd_set_t)(msgctx_t *, fd_set *, int *); +typedef int (*msg_fd_isset_t)(msgctx_t *, fd_set *); +typedef int (*msg_fd_clr_t)(msgctx_t *, fd_set *); +typedef void (*msg_print_t)(msgctx_t *); +typedef int (*msg_init_t)(msgctx_t *); + +typedef struct _msg_ops { + msg_open_t mo_open; + msg_close_t mo_close; + msg_listen_t mo_listen; + msg_accept_t mo_accept; + msg_shutdown_t mo_shutdown; + msg_wait_t mo_wait; + msg_send_t mo_send; + msg_receive_t mo_receive; + msg_fd_set_t mo_fd_set; + msg_fd_isset_t mo_fd_isset; + msg_fd_clr_t mo_fd_clr; + msg_print_t mo_print; + msg_init_t mo_init; +} msg_ops_t; + + /* Ripped from ccsd's setup_local_socket */ -#define RGMGR_SOCK "/var/run/cluster/rgmanager.sk" #define MAX_CONTEXTS 32 /* Testing; production should be 1024-ish */ #define SKF_LISTEN (1<<0) +#define SKF_READ (1<<1) +#define SKF_WRITE (1<<2) +#define SKF_MCAST (1<<3) -int msg_open(int nodeid, int port, msgctx_t *ctx, int timeout); -int msg_init(chandle_t *ch); +/* Call once for MSG_CLUSTER, once for MSG_SOCKET */ +/* Private is should be a null-terminated char string for MSG_SOCKET, + and a pointer to int type for MSG_CLUSTER */ +int msg_listen(int type, void *port, int me, msgctx_t **new_ctx); +int msg_open(int type, int nodeid, int port, msgctx_t *ctx, int timeout); +int msg_init(msgctx_t *ctx); int msg_accept(msgctx_t *listenctx, msgctx_t *acceptctx); int msg_get_nodeid(msgctx_t *ctx); int msg_close(msgctx_t *ctx); @@ -106,5 +148,7 @@ int msg_fd_set(msgctx_t *ctx, fd_set *fds, int *max); int msg_fd_isset(msgctx_t *ctx, fd_set *fds); int msg_fd_clr(msgctx_t *ctx, fd_set *fds); +void msg_print(msgctx_t *ctx); +int msg_shutdown(void); #endif --- cluster/rgmanager/include/resgroup.h 2006/06/02 17:37:10 1.10 +++ cluster/rgmanager/include/resgroup.h 2006/07/12 14:04:06 1.11 @@ -54,6 +54,7 @@ #define RG_SERVICE_GROUP "usrm::manager" #define RG_ACTION_REQUEST /* Message header */ 0x138582 +#define RG_EVENT 0x138583 #define RG_SUCCESS 0 #define RG_FAIL 1 @@ -138,15 +139,15 @@ char *rg_name, int lock); #ifdef DEBUG -int _rg_lock_dbg(char *, void **, char *, int); +int _rg_lock_dbg(char *, struct dlm_lksb *, char *, int); #define rg_lock(name, p) _rg_lock_dbg(name, p, __FILE__, __LINE__) -int _rg_unlock_dbg(char *, void *, char *, int); +int _rg_unlock_dbg(struct dlm_lksb *, char *, int); #define rg_unlock(name, p) _rg_unlock_dbg(name, p, __FILE__, __LINE__) #else -int rg_lock(char *name, void **p); -int rg_unlock(char *name, void *p); +int rg_lock(char *name, struct dlm_lksb *p); +int rg_unlock(struct dlm_lksb *p); #endif @@ -157,6 +158,7 @@ cluster_member_list_t *member_list(void); int my_id(void); +#define RG_EDEPEND -7 #define RG_EAGAIN -6 #define RG_EDEADLCK -5 #define RG_ENOSERVICE -4 --- cluster/rgmanager/include/rg_types.h 2006/06/02 17:37:10 1.1 +++ cluster/rgmanager/include/rg_types.h 2006/07/12 14:04:06 1.2 @@ -12,15 +12,7 @@ cman_node_t *cml_members; } cluster_member_list_t; - -typedef struct _cluster_stuff { - pthread_mutex_t c_lock; - cman_handle_t c_cluster; - dlm_lshandle_t c_lockspace; - int c_nodeid; - void *local_ctx; - void *cluster_ctx; -} chandle_t; - +#define RG_PORT 177 +#define RGMGR_SOCK "/var/run/cluster/rgmanager.sk" #endif --- cluster/rgmanager/include/vf.h 2006/06/02 17:37:10 1.4 +++ cluster/rgmanager/include/vf.h 2006/07/12 14:04:06 1.5 @@ -31,7 +31,7 @@ */ typedef struct __attribute__ ((packed)) _vf_msg_info { uint32_t vf_command; - uint32_t vf_pad; + uint32_t vf_transaction; char vf_keyid[64]; uint32_t vf_coordinator; /* Node ID of who coordinates */ uint32_t vf_datalen; @@ -42,6 +42,7 @@ #define swab_vf_msg_info_t(ptr) \ {\ swab32((ptr)->vf_command);\ + swab32((ptr)->vf_transaction);\ swab32((ptr)->vf_coordinator);\ swab64((ptr)->vf_view);\ swab32((ptr)->vf_datalen);\ @@ -77,7 +78,7 @@ typedef struct _view_node { struct _view_node * vn_next; /**< Next pointer. */ - msgctx_t *vn_ctx; /**< Associated file descriptor. */ + uint32_t vn_transaction; /**< Transaction ID */ uint32_t vn_nodeid; /**< Node ID of coordinator. */ struct timeval vn_timeout; /**< Expiration time. */ uint64_t vn_viewno; /**< View Number. */ @@ -94,7 +95,7 @@ typedef struct _commit_node { struct _commit_node * vc_next; /**< Next pointer. */ - int vc_fd; /**< File descriptor. */ + uint32_t vc_transaction; /**< Transaction ID */ } commit_node_t; @@ -127,6 +128,7 @@ /* Main programs handle this */ #define VF_MESSAGE 0x3000 +/* Subtypes */ #define VF_JOIN_VIEW 0x3001 #define VF_VOTE 0x3002 #define VF_ABORT 0x3004 @@ -135,10 +137,14 @@ #define VF_ACK 0x3007 #define VF_NACK 0x3008 +#define vf_command(x) (x&0x0000ffff) +#define vf_flags(x) (x&0xffff0000) + +#define VFMF_AFFIRM 0x00010000 + #define VF_COORD_TIMEOUT 60 /* 60 seconds MAX timeout */ #define VF_COMMIT_TIMEOUT_MIN (2 * VF_COORD_TIMEOUT) -#define MAX_FDS 1024 /* Return codes for vf_handle_msg... */ #define VFR_ERROR 100 @@ -179,6 +185,7 @@ int vf_key_init(char *keyid, int timeout, vf_vote_cb_t vote_cb, vf_commit_cb_t commit_cb); int getuptime(struct timeval *tv); +int vf_process_msg(msgctx_t *ctx, int nodeid, generic_msg_hdr *msgp, int nbytes); #define MSGP_VFS 0x18dcf1 #define MSGP_VFC 0x0103fab