2 * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
9 * of the GNU General Public License v.2.
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software Foundation,
13 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #define CLVMD_MAJOR_VERSION 0
20 #define CLVMD_MINOR_VERSION 2
21 #define CLVMD_PATCH_VERSION 1
23 /* Default time (in seconds) we will wait for all remote commands to execute
24 before declaring them dead */
25 #define DEFAULT_CMD_TIMEOUT 60
27 /* One of these for each reply we get from command execution on a node */
29 char node[MAX_CLUSTER_MEMBER_NAME_LEN];
32 struct node_reply *next;
35 typedef enum {DEBUG_OFF, DEBUG_STDERR, DEBUG_SYSLOG} debug_t;
38 * These exist for the use of local sockets only when we are
39 * collecting responses from all cluster nodes
41 struct localsock_bits {
42 struct node_reply *replies;
45 time_t sent_time; /* So we can check for timeouts */
46 int in_progress; /* Only execute one cmd at a time per client */
47 int sent_out; /* Flag to indicate that a command was sent
49 void *private; /* Private area for command processor use */
50 void *cmd; /* Whole command as passed down local socket */
51 int cmd_len; /* Length of above */
52 int pipe; /* Pipe to send PRE completion status down */
53 int finished; /* Flag to tell subthread to exit */
54 int all_success; /* Set to 0 if any node (or the pre_command)
56 struct local_client *pipe_client;
58 enum { PRE_COMMAND, POST_COMMAND, QUIT } state;
59 pthread_mutex_t mutex; /* Main thread and worker synchronisation */
62 pthread_mutex_t reply_mutex; /* Protect reply structure */
65 /* Entries for PIPE clients */
67 struct local_client *client; /* Actual (localsock) client */
68 pthread_t threadid; /* Our own copy of the thread id */
71 /* Entries for Network socket clients */
77 typedef int (*fd_callback_t) (struct local_client * fd, char *buf, int len,
79 struct local_client ** new_client);
81 /* One of these for each fd we are listening on */
84 enum { CLUSTER_MAIN_SOCK, CLUSTER_DATA_SOCK, LOCAL_RENDEZVOUS,
85 LOCAL_SOCK, THREAD_PIPE, CLUSTER_INTERNAL } type;
86 struct local_client *next;
88 fd_callback_t callback;
92 struct localsock_bits localsock;
93 struct pipe_bits pipe;
94 struct netsock_bits net;
98 #define DEBUGLOG(fmt, args...) debuglog(fmt, ## args);
101 #define max(a,b) ((a)>(b)?(a):(b))
104 /* The real command processor is in clvmd-command.c */
105 extern int do_command(struct local_client *client, struct clvm_header *msg,
106 int msglen, char **buf, int buflen, int *retlen);
108 /* Pre and post command routines are called only on the local node */
109 extern int do_pre_command(struct local_client *client);
110 extern int do_post_command(struct local_client *client);
111 extern void cmd_client_cleanup(struct local_client *client);
112 extern int add_client(struct local_client *new_client);
114 extern void clvmd_cluster_init_completed(void);
115 extern void process_message(struct local_client *client, const char *buf,
116 int len, const char *csid);
117 extern void debuglog(const char *fmt, ... )
118 __attribute__ ((format(printf, 1, 2)));
120 int sync_lock(const char *resource, int mode, int flags, int *lockid);
121 int sync_unlock(const char *resource, int lockid);