Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / vol / fssync.h
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 *
9 * Portions Copyright (c) 2006-2010 Sine Nomine Associates
10 */
11
12 /*
13 System: VICE-TWO
14 Module: fssync.h
15 Institution: The Information Technology Center, Carnegie-Mellon University
16
17 */
18
19 #ifndef __fssync_h_
20 #define __fssync_h_
21
22 #define FSYNC_PROTO_VERSION 3
23
24 #include "voldefs.h"
25
26 /**
27 * FSYNC command codes.
28 *
29 * If you add more command codes here, be sure to add some documentation
30 * in doc/arch/fssync.txt.
31 */
32 enum FSYNCOpCode {
33 FSYNC_VOL_ON = SYNC_COM_CODE_DECL(0), /**< bring Volume online */
34 FSYNC_VOL_OFF = SYNC_COM_CODE_DECL(1), /**< take Volume offline */
35 FSYNC_VOL_LISTVOLUMES = SYNC_COM_CODE_DECL(2), /**< Update local volume list */
36 FSYNC_VOL_NEEDVOLUME = SYNC_COM_CODE_DECL(3), /**< Put volume in whatever mode (offline, or whatever)
37 * best fits the attachment mode provided in reason */
38 FSYNC_VOL_MOVE = SYNC_COM_CODE_DECL(4), /**< Generate temporary relocation information
39 * for this volume to another site, to be used
40 * if this volume disappears */
41 FSYNC_VOL_BREAKCBKS = SYNC_COM_CODE_DECL(5), /**< Break all the callbacks on this volume */
42 FSYNC_VOL_DONE = SYNC_COM_CODE_DECL(6), /**< Done with this volume (used after a delete).
43 * Don't put online, but remove from list */
44 FSYNC_VOL_QUERY = SYNC_COM_CODE_DECL(7), /**< query the volume state */
45 FSYNC_VOL_QUERY_HDR = SYNC_COM_CODE_DECL(8), /**< query the volume disk data structure */
46 FSYNC_VOL_QUERY_VOP = SYNC_COM_CODE_DECL(9), /**< query the volume for pending vol op info */
47 FSYNC_VOL_STATS_GENERAL = SYNC_COM_CODE_DECL(10), /**< query the general volume package statistics */
48 FSYNC_VOL_STATS_VICEP = SYNC_COM_CODE_DECL(11), /**< query the per-partition volume package stats */
49 FSYNC_VOL_STATS_HASH = SYNC_COM_CODE_DECL(12), /**< query the per hash-chain volume package stats */
50 FSYNC_VOL_STATS_HDR = SYNC_COM_CODE_DECL(13), /**< query the volume header cache statistics */
51 FSYNC_VOL_STATS_VLRU = SYNC_COM_CODE_DECL(14), /**< query the VLRU statistics */
52 FSYNC_VOL_ATTACH = SYNC_COM_CODE_DECL(15), /**< Force volume online */
53 FSYNC_VOL_FORCE_ERROR = SYNC_COM_CODE_DECL(16), /**< force volume into error state */
54 FSYNC_VOL_LEAVE_OFF = SYNC_COM_CODE_DECL(17), /**< end vol op, but leave volume offline */
55 FSYNC_VOL_QUERY_VNODE = SYNC_COM_CODE_DECL(18), /**< query vnode state */
56 FSYNC_VG_QUERY = SYNC_COM_CODE_DECL(19), /**< Query volume group membership for a given volume id */
57 FSYNC_VG_ADD = SYNC_COM_CODE_DECL(20), /**< add a volume id to a vg */
58 FSYNC_VG_DEL = SYNC_COM_CODE_DECL(21), /**< delete a volume id from a vg */
59 FSYNC_VG_SCAN = SYNC_COM_CODE_DECL(22), /**< force a re-scan of a given partition */
60 FSYNC_VG_SCAN_ALL = SYNC_COM_CODE_DECL(23), /**< force a re-scan of all vice partitions */
61 FSYNC_OP_CODE_END
62 };
63
64 /**
65 * FSYNC reason codes.
66 */
67 enum FSYNCReasonCode {
68 FSYNC_WHATEVER = SYNC_REASON_CODE_DECL(0), /**< XXXX */
69 FSYNC_SALVAGE = SYNC_REASON_CODE_DECL(1), /**< volume is being salvaged */
70 FSYNC_MOVE = SYNC_REASON_CODE_DECL(2), /**< volume is being moved */
71 FSYNC_OPERATOR = SYNC_REASON_CODE_DECL(3), /**< operator forced volume offline */
72 FSYNC_EXCLUSIVE = SYNC_REASON_CODE_DECL(4), /**< somebody else has the volume offline */
73 FSYNC_UNKNOWN_VOLID = SYNC_REASON_CODE_DECL(5), /**< volume id not known by fileserver */
74 FSYNC_HDR_NOT_ATTACHED = SYNC_REASON_CODE_DECL(6), /**< volume header not currently attached */
75 FSYNC_NO_PENDING_VOL_OP = SYNC_REASON_CODE_DECL(7), /**< no volume operation pending */
76 FSYNC_VOL_PKG_ERROR = SYNC_REASON_CODE_DECL(8), /**< error in the volume package */
77 FSYNC_UNKNOWN_VNID = SYNC_REASON_CODE_DECL(9), /**< vnode id not known by fileserver */
78 FSYNC_WRONG_PART = SYNC_REASON_CODE_DECL(10),/**< volume attached on different partition */
79 FSYNC_BAD_STATE = SYNC_REASON_CODE_DECL(11),/**< current volume state does not allow this operation */
80 FSYNC_BAD_PART = SYNC_REASON_CODE_DECL(12),/**< invalid disk partition */
81 FSYNC_PART_SCANNING = SYNC_REASON_CODE_DECL(13),/**< partition is busy scanning VGs */
82 FSYNC_REASON_CODE_END
83 };
84
85 /* FSYNC response codes */
86
87 /* FSYNC flag codes */
88
89 struct offlineInfo {
90 VolumeId volumeID;
91 char partName[16];
92 };
93
94 /**
95 * fssync protocol volume operation request message.
96 */
97 typedef struct FSSYNC_VolOp_hdr {
98 VolumeId volume; /**< volume id associated with request */
99 char partName[16]; /**< partition name, e.g. /vicepa */
100 } FSSYNC_VolOp_hdr;
101
102 typedef struct FSSYNC_VolOp_command {
103 SYNC_command_hdr * hdr;
104 FSSYNC_VolOp_hdr * vop;
105 SYNC_command * com;
106 struct offlineInfo * v;
107 struct offlineInfo * volumes;
108 } FSSYNC_VolOp_command;
109
110
111 /**
112 * volume operation processing state.
113 */
114 enum FSSYNC_VolOpState {
115 FSSYNC_VolOpPending = 0, /**< volume operation request received */
116 FSSYNC_VolOpDenied = 1, /**< volume operation request denied */
117 FSSYNC_VolOpRunningOnline = 2, /**< volume operation is running while volume is online */
118 FSSYNC_VolOpRunningOffline = 3, /**< volume operation is running while volume is offline */
119 FSSYNC_VolOpRunningUnknown = 4 /**< volume operation is running; VVolOpLeaveOnline_r resolution unknown */
120 };
121
122 /**
123 * volume operation information node.
124 *
125 * @note this structure is attached to a struct Volume to signify that
126 * a volume operation is in-progress.
127 *
128 * @see Volume
129 * @see VRegisterVolOp_r
130 * @see VDeregisterVolOp_r
131 */
132 typedef struct FSSYNC_VolOp_info {
133 SYNC_command_hdr com;
134 FSSYNC_VolOp_hdr vop;
135 enum FSSYNC_VolOpState vol_op_state;
136 } FSSYNC_VolOp_info;
137
138
139 /**
140 * fssync protocol volume package statistics request node.
141 */
142 typedef struct FSSYNC_StatsOp_hdr {
143 union {
144 afs_uint32 vlru_generation; /**< vlru generation id */
145 afs_uint32 hash_bucket; /**< volume hash bucket */
146 char partName[16]; /**< partition name */
147 } args;
148 } FSSYNC_StatsOp_hdr;
149
150 typedef struct FSSYNC_StatsOp_command {
151 SYNC_command_hdr * hdr;
152 FSSYNC_StatsOp_hdr * sop;
153 SYNC_command * com;
154 } FSSYNC_StatsOp_command;
155
156 /**
157 * fssync protocol vnode query request message.
158 */
159 typedef struct FSSYNC_VnQry_hdr {
160 VolumeId volume; /**< volume id */
161 afs_uint32 vnode; /**< vnode id */
162 afs_uint32 unique; /**< uniqifier */
163 afs_uint32 spare; /**< reserved for future use */
164 char partName[16]; /**< partition name */
165 } FSSYNC_VnQry_hdr;
166
167 /**
168 * fssync protocol volume group query response message.
169 */
170 typedef struct FSSYNC_VGQry_response {
171 afs_uint32 rw; /**< rw volume id */
172 afs_uint32 children[VOL_VG_MAX_VOLS]; /**< vector of children */
173 } FSSYNC_VGQry_response_t;
174
175 /**
176 * fssync protocol volume group update command message.
177 */
178 typedef struct FSSYNC_VGUpdate_command {
179 afs_uint32 parent; /**< rw volume id */
180 afs_uint32 child; /**< volume id to associate with parent
181 * (can legally be the parent itself) */
182 char partName[16]; /**< name of vice partition on which this
183 * volume group resides */
184 } FSSYNC_VGUpdate_command_t;
185
186 #define FSSYNC_IN_PORT 2040
187 #define FSSYNC_UN_PATH "fssync.sock"
188 #define FSSYNC_ENDPOINT_DECL SYNC_ENDPOINT_DECL(FSSYNC_IN_PORT, FSSYNC_UN_PATH)
189
190 /*
191 * common interfaces
192 */
193 extern void FSYNC_Init(void);
194
195 /*
196 * fsync client interfaces
197 */
198 extern void FSYNC_clientFinis(void);
199 extern int FSYNC_clientInit(void);
200 extern int FSYNC_clientChildProcReconnect(void);
201
202 /* generic low-level interface */
203 extern afs_int32 FSYNC_askfs(SYNC_command * com, SYNC_response * res);
204
205 /* generic higher-level interface */
206 extern afs_int32 FSYNC_GenericOp(void * ext_hdr, size_t ext_len,
207 int command, int reason,
208 SYNC_response * res);
209
210 /*
211 * volume operations control interface
212 *
213 * FSYNC_VolOp must be called with the partition name and not the partition path.
214 */
215 extern afs_int32 FSYNC_VolOp(VolumeId volume, char *partName, int com, int reason,
216 SYNC_response * res);
217
218 /* statistics query interface */
219 extern afs_int32 FSYNC_StatsOp(FSSYNC_StatsOp_hdr * scom, int command, int reason,
220 SYNC_response * res_in);
221
222 extern void FSYNC_fsInit(void);
223
224 /* volume group cache coherence interfaces */
225 extern afs_int32 FSYNC_VGCQuery(char * part, VolumeId parent,
226 FSSYNC_VGQry_response_t *, SYNC_response *res);
227 extern afs_int32 FSYNC_VGCAdd(char *part, VolumeId parent, VolumeId child,
228 int reason, SYNC_response *res);
229 extern afs_int32 FSYNC_VGCDel(char *part, VolumeId parent, VolumeId child,
230 int reason, SYNC_response *res);
231 extern afs_int32 FSYNC_VGCScan(char *part, int reason);
232
233 extern afs_int32 FSYNC_VerifyCheckout(VolumeId volume, char *partition,
234 afs_int32 command, afs_int32 reason);
235
236 #endif /* __fssync_h_ */