Tizen 2.1 base
[external/device-mapper.git] / daemons / cmirrord / cluster.h
1 /*
2  * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
3  *
4  * This copyrighted material is made available to anyone wishing to use,
5  * modify, copy, or redistribute it subject to the terms and conditions
6  * of the GNU Lesser General Public License v.2.1.
7  *
8  * You should have received a copy of the GNU Lesser General Public License
9  * along with this program; if not, write to the Free Software Foundation,
10  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
11  */
12 #ifndef _LVM_CLOG_CLUSTER_H
13 #define _LVM_CLOG_CLUSTER_H
14
15 #include "dm-log-userspace.h"
16 #include "libdevmapper.h"
17
18 #define DM_ULOG_RESPONSE 0x1000U /* in last byte of 32-bit value */
19 #define DM_ULOG_CHECKPOINT_READY 21
20 #define DM_ULOG_MEMBER_JOIN      22
21
22 /*
23  * There is other information in addition to what can
24  * be found in the dm_ulog_request structure that we
25  * need for processing.  'clog_request' is the wrapping
26  * structure we use to make the additional fields
27  * available.
28  */
29 struct clog_request {
30         /*
31          * If we don't use a union, the structure size will
32          * vary between 32-bit and 64-bit machines.  So, we
33          * pack two 64-bit version numbers in there to force
34          * the size of the structure to be the same.
35          *
36          * The two version numbers also help us with endian
37          * issues.  The first is always little endian, while
38          * the second is in native format of the sending
39          * machine.  If the two are equal, there is no need
40          * to do endian conversions.
41          */
42         union {
43                 uint64_t version[2]; /* LE version and native version */
44                 struct dm_list list;
45         } u;
46
47         /*
48          * 'originator' is the machine from which the requests
49          * was made.
50          */
51         uint32_t originator;
52
53         /*
54          * 'pit_server' is the "point-in-time" server for the
55          * request.  (I.e.  The machine that was the server at
56          * the time the request was issued - only important during
57          * startup.
58          */
59         uint32_t pit_server;
60
61         /*
62          * The request from the kernel that is being processed
63          */
64         struct dm_ulog_request u_rq;
65 };
66
67 int init_cluster(void);
68 void cleanup_cluster(void);
69 void cluster_debug(void);
70
71 int create_cluster_cpg(char *uuid, uint64_t luid);
72 int destroy_cluster_cpg(char *uuid);
73
74 int cluster_send(struct clog_request *rq);
75
76 #endif /* _LVM_CLOG_CLUSTER_H */