Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / daemons / clvmd / clvmd.h
blobfb820090ffdb3e8f12d0b2226cb3e0bd1097607b
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
7 * This file is part of LVM2.
9 * This copyrighted material is made available to anyone wishing to use,
10 * modify, copy, or redistribute it subject to the terms and conditions
11 * of the GNU General Public License v.2.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #ifndef _CLVMD_H
19 #define _CLVMD_H
21 #define CLVMD_MAJOR_VERSION 0
22 #define CLVMD_MINOR_VERSION 2
23 #define CLVMD_PATCH_VERSION 1
25 /* Name of the cluster LVM admin lock */
26 #define ADMIN_LOCK_NAME "CLVMD_ADMIN"
28 /* Default time (in seconds) we will wait for all remote commands to execute
29 before declaring them dead */
30 #define DEFAULT_CMD_TIMEOUT 60
32 /* One of these for each reply we get from command execution on a node */
33 struct node_reply {
34 char node[MAX_CLUSTER_MEMBER_NAME_LEN];
35 char *replymsg;
36 int status;
37 struct node_reply *next;
40 typedef enum {DEBUG_OFF, DEBUG_STDERR, DEBUG_SYSLOG} debug_t;
43 * These exist for the use of local sockets only when we are
44 * collecting responses from all cluster nodes
46 struct localsock_bits {
47 struct node_reply *replies;
48 int num_replies;
49 int expected_replies;
50 time_t sent_time; /* So we can check for timeouts */
51 int in_progress; /* Only execute one cmd at a time per client */
52 int sent_out; /* Flag to indicate that a command was sent
53 to remote nodes */
54 void *private; /* Private area for command processor use */
55 void *cmd; /* Whole command as passed down local socket */
56 int cmd_len; /* Length of above */
57 int pipe; /* Pipe to send PRE completion status down */
58 int finished; /* Flag to tell subthread to exit */
59 int all_success; /* Set to 0 if any node (or the pre_command)
60 failed */
61 struct local_client *pipe_client;
62 pthread_t threadid;
63 enum { PRE_COMMAND, POST_COMMAND, QUIT } state;
64 pthread_mutex_t mutex; /* Main thread and worker synchronisation */
65 pthread_cond_t cond;
67 pthread_mutex_t reply_mutex; /* Protect reply structure */
70 /* Entries for PIPE clients */
71 struct pipe_bits {
72 struct local_client *client; /* Actual (localsock) client */
73 pthread_t threadid; /* Our own copy of the thread id */
76 /* Entries for Network socket clients */
77 struct netsock_bits {
78 void *private;
79 int flags;
82 typedef int (*fd_callback_t) (struct local_client * fd, char *buf, int len,
83 const char *csid,
84 struct local_client ** new_client);
86 /* One of these for each fd we are listening on */
87 struct local_client {
88 int fd;
89 enum { CLUSTER_MAIN_SOCK, CLUSTER_DATA_SOCK, LOCAL_RENDEZVOUS,
90 LOCAL_SOCK, THREAD_PIPE, CLUSTER_INTERNAL } type;
91 struct local_client *next;
92 unsigned short xid;
93 fd_callback_t callback;
94 uint8_t removeme;
96 union {
97 struct localsock_bits localsock;
98 struct pipe_bits pipe;
99 struct netsock_bits net;
100 } bits;
103 #define DEBUGLOG(fmt, args...) debuglog(fmt, ## args);
105 #ifndef max
106 #define max(a,b) ((a)>(b)?(a):(b))
107 #endif
109 /* The real command processor is in clvmd-command.c */
110 extern int do_command(struct local_client *client, struct clvm_header *msg,
111 int msglen, char **buf, int buflen, int *retlen);
113 /* Pre and post command routines are called only on the local node */
114 extern int do_pre_command(struct local_client *client);
115 extern int do_post_command(struct local_client *client);
116 extern void cmd_client_cleanup(struct local_client *client);
117 extern int add_client(struct local_client *new_client);
119 extern void clvmd_cluster_init_completed(void);
120 extern void process_message(struct local_client *client, const char *buf,
121 int len, const char *csid);
122 extern void debuglog(const char *fmt, ... )
123 __attribute__ ((format(printf, 1, 2)));
125 int sync_lock(const char *resource, int mode, int flags, int *lockid);
126 int sync_unlock(const char *resource, int lockid);
128 #endif