~ubuntu-branches/ubuntu/breezy/lvm2/breezy

« back to all changes in this revision

Viewing changes to daemons/clvmd/cnxman-socket.h

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Caulfield
  • Date: 2004-11-03 09:37:56 UTC
  • Revision ID: james.westby@ubuntu.com-20041103093756-jt0nj8z0v8k1lyiv
Tags: upstream-2.00.25
ImportĀ upstreamĀ versionĀ 2.00.25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
*******************************************************************************
 
3
**
 
4
**  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
 
5
**  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
 
6
**
 
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.
 
10
**
 
11
*******************************************************************************
 
12
******************************************************************************/
 
13
 
 
14
/* CMAN socket interface header,
 
15
   may be include by user or kernel code */
 
16
 
 
17
#ifndef __CNXMAN_SOCKET_H
 
18
#define __CNXMAN_SOCKET_H
 
19
 
 
20
/* A currently unused number. TIPC also uses this number and you're unlikely
 
21
   to be using both.
 
22
 */
 
23
#define AF_CLUSTER 30
 
24
#define PF_CLUSTER AF_CLUSTER
 
25
 
 
26
/* Protocol(socket) types */
 
27
#define CLPROTO_MASTER 2
 
28
#define CLPROTO_CLIENT 3
 
29
 
 
30
/* ioctls -- should register these properly */
 
31
#define SIOCCLUSTER_NOTIFY            _IOW('x', 0x01, int)
 
32
#define SIOCCLUSTER_REMOVENOTIFY      _IO( 'x', 0x02)
 
33
#define SIOCCLUSTER_GETMEMBERS        _IOR('x', 0x03, struct cl_cluster_nodelist)
 
34
#define SIOCCLUSTER_SETEXPECTED_VOTES _IOW('x', 0x04, int)
 
35
#define SIOCCLUSTER_ISQUORATE         _IO( 'x', 0x05)
 
36
#define SIOCCLUSTER_ISLISTENING       _IOW('x', 0x06, struct cl_listen_request)
 
37
#define SIOCCLUSTER_GETALLMEMBERS     _IOR('x', 0x07, struct cl_cluster_nodelist)
 
38
#define SIOCCLUSTER_SET_VOTES         _IOW('x', 0x08, int)
 
39
#define SIOCCLUSTER_GET_VERSION       _IOR('x', 0x09, struct cl_version)
 
40
#define SIOCCLUSTER_SET_VERSION       _IOW('x', 0x0a, struct cl_version)
 
41
#define SIOCCLUSTER_ISACTIVE          _IO( 'x', 0x0b)
 
42
#define SIOCCLUSTER_KILLNODE          _IOW('x', 0x0c, int)
 
43
#define SIOCCLUSTER_GET_JOINCOUNT     _IO( 'x', 0x0d)
 
44
#define SIOCCLUSTER_SERVICE_REGISTER  _IOW('x', 0x0e, char)
 
45
#define SIOCCLUSTER_SERVICE_UNREGISTER _IO('x', 0x0f)
 
46
#define SIOCCLUSTER_SERVICE_JOIN      _IO( 'x', 0x10)
 
47
#define SIOCCLUSTER_SERVICE_LEAVE     _IO( 'x', 0x20)
 
48
#define SIOCCLUSTER_SERVICE_SETSIGNAL _IOW('x', 0x30, int)
 
49
#define SIOCCLUSTER_SERVICE_STARTDONE _IOW('x', 0x40, unsigned int)
 
50
#define SIOCCLUSTER_SERVICE_GETEVENT  _IOR('x', 0x50, struct cl_service_event)
 
51
#define SIOCCLUSTER_SERVICE_GETMEMBERS _IOR('x', 0x60, struct cl_cluster_nodelist)
 
52
#define SIOCCLUSTER_SERVICE_GLOBALID  _IOR('x', 0x70, uint32_t)
 
53
#define SIOCCLUSTER_SERVICE_SETLEVEL  _IOR('x', 0x80, int)
 
54
#define SIOCCLUSTER_GETNODE           _IOWR('x', 0x90, struct cl_cluster_node)
 
55
#define SIOCCLUSTER_BARRIER           _IOW('x', 0x0a0, struct cl_barrier_info)
 
56
 
 
57
/* These were setsockopts */
 
58
#define SIOCCLUSTER_PASS_SOCKET       _IOW('x', 0x0b0, struct cl_passed_sock)
 
59
#define SIOCCLUSTER_SET_NODENAME      _IOW('x', 0x0b1, char *)
 
60
#define SIOCCLUSTER_SET_NODEID        _IOW('x', 0x0b2, int)
 
61
#define SIOCCLUSTER_JOIN_CLUSTER      _IOW('x', 0x0b3, struct cl_join_cluster_info)
 
62
#define SIOCCLUSTER_LEAVE_CLUSTER     _IOW('x', 0x0b4, int)
 
63
 
 
64
 
 
65
/* Maximum size of a cluster message */
 
66
#define MAX_CLUSTER_MESSAGE          1500
 
67
#define MAX_CLUSTER_MEMBER_NAME_LEN   255
 
68
#define MAX_BARRIER_NAME_LEN           33
 
69
#define MAX_SA_ADDR_LEN                12
 
70
#define MAX_CLUSTER_NAME_LEN           16
 
71
 
 
72
/* Well-known cluster port numbers */
 
73
#define CLUSTER_PORT_MEMBERSHIP  1      /* Mustn't block during cluster
 
74
                                         * transitions! */
 
75
#define CLUSTER_PORT_SERVICES    2
 
76
#define CLUSTER_PORT_SYSMAN      10     /* Remote execution daemon */
 
77
#define CLUSTER_PORT_CLVMD       11     /* Cluster LVM daemon */
 
78
#define CLUSTER_PORT_SLM         12     /* LVM SLM (simple lock manager) */
 
79
 
 
80
/* Port numbers above this will be blocked when the cluster is inquorate or in
 
81
 * transition */
 
82
#define HIGH_PROTECTED_PORT      9
 
83
 
 
84
/* Reasons for leaving the cluster */
 
85
#define CLUSTER_LEAVEFLAG_DOWN     0    /* Normal shutdown */
 
86
#define CLUSTER_LEAVEFLAG_KILLED   1
 
87
#define CLUSTER_LEAVEFLAG_PANIC    2
 
88
#define CLUSTER_LEAVEFLAG_REMOVED  3    /* This one can reduce quorum */
 
89
#define CLUSTER_LEAVEFLAG_REJECTED 4    /* Not allowed into the cluster in the
 
90
                                         * first place */
 
91
#define CLUSTER_LEAVEFLAG_INCONSISTENT 5        /* Our view of the cluster is
 
92
                                                 * in a minority */
 
93
#define CLUSTER_LEAVEFLAG_DEAD         6        /* Discovered to be dead */
 
94
#define CLUSTER_LEAVEFLAG_FORCE     0x10        /* Forced by command-line */
 
95
 
 
96
/* OOB messages sent to a local socket */
 
97
#define CLUSTER_OOB_MSG_PORTCLOSED  1
 
98
#define CLUSTER_OOB_MSG_STATECHANGE 2
 
99
#define CLUSTER_OOB_MSG_SERVICEEVENT 3
 
100
 
 
101
/* Sendmsg flags, these are above the normal sendmsg flags so they don't
 
102
 * interfere */
 
103
#define MSG_NOACK     0x010000  /* Don't need an ACK for this message */
 
104
#define MSG_QUEUE     0x020000  /* Queue the message for sending later */
 
105
#define MSG_MULTICAST 0x080000  /* Message was sent to all nodes in the cluster
 
106
                                 */
 
107
#define MSG_ALLINT    0x100000  /* Send out of all interfaces */
 
108
#define MSG_REPLYEXP  0x200000  /* Reply is expected */
 
109
 
 
110
typedef enum { NODESTATE_REMOTEMEMBER, NODESTATE_JOINING, NODESTATE_MEMBER,
 
111
               NODESTATE_DEAD } nodestate_t;
 
112
 
 
113
 
 
114
struct sockaddr_cl {
 
115
        unsigned short scl_family;
 
116
        unsigned char scl_flags;
 
117
        unsigned char scl_port;
 
118
        int           scl_nodeid;
 
119
};
 
120
 
 
121
/*
 
122
 * This is how we pass the multicast & receive sockets into kernel space.
 
123
 */
 
124
struct cl_passed_sock {
 
125
        int fd;                 /* FD of master socket to do multicast on */
 
126
        int number;             /* Socket number, to match up recvonly & bcast
 
127
                                 * sockets */
 
128
        int multicast;          /* Is it multicast or receive ? */
 
129
};
 
130
 
 
131
/* Cluster configuration info passed when we join the cluster */
 
132
struct cl_join_cluster_info {
 
133
        unsigned char votes;
 
134
        unsigned int expected_votes;
 
135
        unsigned int two_node;
 
136
        unsigned int config_version;
 
137
 
 
138
        char cluster_name[17];
 
139
};
 
140
 
 
141
 
 
142
/* This is the structure, per node, returned from the membership ioctl */
 
143
struct cl_cluster_node {
 
144
        unsigned int size;
 
145
        unsigned int node_id;
 
146
        unsigned int us;
 
147
        unsigned int leave_reason;
 
148
        unsigned int incarnation;
 
149
        nodestate_t state;
 
150
        char name[MAX_CLUSTER_MEMBER_NAME_LEN];
 
151
        unsigned char votes;
 
152
};
 
153
 
 
154
/* The struct passed to the membership ioctls */
 
155
struct cl_cluster_nodelist {
 
156
        uint32_t max_members;
 
157
        struct cl_cluster_node *nodes;
 
158
};
 
159
 
 
160
/* Structure passed to SIOCCLUSTER_ISLISTENING */
 
161
struct cl_listen_request {
 
162
        unsigned char port;
 
163
        int           nodeid;
 
164
};
 
165
 
 
166
/* A Cluster PORTCLOSED message - received by a local user as an OOB message */
 
167
struct cl_portclosed_oob {
 
168
        unsigned char cmd;      /* CLUSTER_OOB_MSG_PORTCLOSED */
 
169
        unsigned char port;
 
170
};
 
171
 
 
172
/* Get all version numbers or set the config version */
 
173
struct cl_version {
 
174
        unsigned int major;
 
175
        unsigned int minor;
 
176
        unsigned int patch;
 
177
        unsigned int config;
 
178
};
 
179
 
 
180
/* structure passed to barrier ioctls */
 
181
struct cl_barrier_info {
 
182
        char cmd;
 
183
        char name[MAX_BARRIER_NAME_LEN];
 
184
        unsigned int flags;
 
185
        unsigned long arg;
 
186
};
 
187
 
 
188
typedef enum { SERVICE_EVENT_STOP, SERVICE_EVENT_START, SERVICE_EVENT_FINISH,
 
189
                SERVICE_EVENT_LEAVEDONE } service_event_t;
 
190
 
 
191
typedef enum { SERVICE_START_FAILED, SERVICE_START_JOIN, SERVICE_START_LEAVE }
 
192
                service_start_t;
 
193
 
 
194
struct cl_service_event {
 
195
        service_event_t type;
 
196
        service_start_t start_type;
 
197
        unsigned int event_id;
 
198
        unsigned int last_stop;
 
199
        unsigned int last_start;
 
200
        unsigned int last_finish;
 
201
        unsigned int node_count;
 
202
};
 
203
 
 
204
 
 
205
/* Commands to the barrier ioctl */
 
206
#define BARRIER_IOCTL_REGISTER 1
 
207
#define BARRIER_IOCTL_CHANGE   2
 
208
#define BARRIER_IOCTL_DELETE   3
 
209
#define BARRIER_IOCTL_WAIT     4
 
210
 
 
211
/* Attributes of a barrier - bitmask */
 
212
#define BARRIER_ATTR_AUTODELETE 1
 
213
#define BARRIER_ATTR_MULTISTEP  2
 
214
#define BARRIER_ATTR_MANUAL     4
 
215
#define BARRIER_ATTR_ENABLED    8
 
216
#define BARRIER_ATTR_CALLBACK  16
 
217
 
 
218
/* Attribute setting commands */
 
219
#define BARRIER_SETATTR_AUTODELETE 1
 
220
#define BARRIER_SETATTR_MULTISTEP  2
 
221
#define BARRIER_SETATTR_ENABLED    3
 
222
#define BARRIER_SETATTR_NODES      4
 
223
#define BARRIER_SETATTR_CALLBACK   5
 
224
#define BARRIER_SETATTR_TIMEOUT    6
 
225
 
 
226
#endif