This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / fs / intermezzo / intermezzo_idl.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001, 2002 Cluster File Systems, Inc.
5  *  Copyright (C) 2001 Tacit Networks, Inc.
6  *
7  *   This file is part of InterMezzo, http://www.inter-mezzo.org.
8  *
9  *   InterMezzo is free software; you can redistribute it and/or
10  *   modify it under the terms of version 2 of the GNU General Public
11  *   License as published by the Free Software Foundation.
12  *
13  *   InterMezzo is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with InterMezzo; if not, write to the Free Software
20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #ifndef __INTERMEZZO_IDL_H__
24 #define __INTERMEZZO_IDL_H__
25
26 #include <linux/ioctl.h>
27 #include <linux/types.h>
28
29 /* this file contains all data structures used in InterMezzo's interfaces:
30  * - upcalls
31  * - ioctl's
32  * - KML records
33  * - RCVD records
34  * - rpc's
35  */ 
36
37 /* UPCALL */
38 #define INTERMEZZO_MINOR 248   
39
40
41 #define IZO_UPC_VERSION 0x00010002
42 #define IZO_UPC_PERMIT        1
43 #define IZO_UPC_CONNECT       2
44 #define IZO_UPC_GO_FETCH_KML  3
45 #define IZO_UPC_OPEN          4
46 #define IZO_UPC_REVOKE_PERMIT 5
47 #define IZO_UPC_KML           6
48 #define IZO_UPC_BACKFETCH     7
49 #define IZO_UPC_KML_TRUNC     8
50 #define IZO_UPC_SET_KMLSIZE   9
51 #define IZO_UPC_BRANCH_UNDO   10
52 #define IZO_UPC_BRANCH_REDO   11
53 #define IZO_UPC_GET_FILEID    12
54 #define IZO_UPC_CLIENT_MAKE_BRANCH    13
55 #define IZO_UPC_SERVER_MAKE_BRANCH    14
56 #define IZO_UPC_REPSTATUS    15
57
58 #define IZO_UPC_LARGEST_OPCODE 15
59
60 struct izo_upcall_hdr {
61         __u32 u_len;
62         __u32 u_version;
63         __u32 u_opc;
64         __u32 u_uniq;
65         __u32 u_pid;
66         __u32 u_uid;
67         __u32 u_pathlen;
68         __u32 u_fsetlen;
69         __u64 u_offset;
70         __u64 u_length;
71         __u32 u_first_recno;
72         __u32 u_last_recno;
73         __u32 u_async;
74         __u32 u_reclen;
75         __u8  u_uuid[16];
76 };
77
78 /* This structure _must_ sit at the beginning of the buffer */
79 struct izo_upcall_resp {
80         __u32 opcode;
81         __u32 unique;    
82         __u32 result;
83 };
84
85
86 /* IOCTL */
87
88 #define IZO_IOCTL_VERSION 0x00010003
89
90 /* maximum size supported for ioc_pbuf1 */
91 #define KML_MAX_BUF (64*1024)
92
93 struct izo_ioctl_hdr { 
94         __u32  ioc_len;
95         __u32  ioc_version;
96 };
97
98 struct izo_ioctl_data {
99         __u32 ioc_len;
100         __u32 ioc_version;
101         __u32 ioc_izodev;
102         __u32 ioc_kmlrecno;
103         __u64 ioc_kmlsize;
104         __u32 ioc_flags;
105         __s32 ioc_inofd;
106         __u64 ioc_ino;
107         __u64 ioc_generation;
108         __u32 ioc_mark_what;
109         __u32 ioc_and_flag;
110         __u32 ioc_or_flag;
111         __u32 ioc_dev;
112         __u32 ioc_offset;
113         __u32 ioc_slot;
114         __u64 ioc_uid;
115         __u8  ioc_uuid[16];
116
117         __u32 ioc_inllen1;   /* path */
118         char *ioc_inlbuf1;
119         __u32 ioc_inllen2;   /* fileset */
120         char *ioc_inlbuf2;
121
122         __u32 ioc_plen1;     /* buffers in user space (KML) */
123         char *ioc_pbuf1;
124         __u32 ioc_plen2;     /* buffers in user space (KML) */
125         char *ioc_pbuf2;
126
127         char  ioc_bulk[0];
128 };
129
130 #define IZO_IOC_DEVICE          _IOW ('p',0x50, void *)
131 #define IZO_IOC_REINTKML        _IOW ('p',0x51, void *)
132 #define IZO_IOC_GET_RCVD        _IOW ('p',0x52, void *)
133 #define IZO_IOC_SET_IOCTL_UID   _IOW ('p',0x53, void *)
134 #define IZO_IOC_GET_KML_SIZE    _IOW ('p',0x54, void *)
135 #define IZO_IOC_PURGE_FILE_DATA _IOW ('p',0x55, void *)
136 #define IZO_IOC_CONNECT         _IOW ('p',0x56, void *)
137 #define IZO_IOC_GO_FETCH_KML    _IOW ('p',0x57, void *)
138 #define IZO_IOC_MARK            _IOW ('p',0x58, void *)
139 #define IZO_IOC_CLEAR_FSET      _IOW ('p',0x59, void *)
140 #define IZO_IOC_CLEAR_ALL_FSETS _IOW ('p',0x60, void *)
141 #define IZO_IOC_SET_FSET        _IOW ('p',0x61, void *)
142 #define IZO_IOC_REVOKE_PERMIT   _IOW ('p',0x62, void *)
143 #define IZO_IOC_SET_KMLSIZE     _IOW ('p',0x63, void *)
144 #define IZO_IOC_CLIENT_MAKE_BRANCH _IOW ('p',0x64, void *)
145 #define IZO_IOC_SERVER_MAKE_BRANCH _IOW ('p',0x65, void *)
146 #define IZO_IOC_BRANCH_UNDO    _IOW ('p',0x66, void *)
147 #define IZO_IOC_BRANCH_REDO    _IOW ('p',0x67, void *)
148 #define IZO_IOC_SET_PID        _IOW ('p',0x68, void *)
149 #define IZO_IOC_SET_CHANNEL    _IOW ('p',0x69, void *)
150 #define IZO_IOC_GET_CHANNEL    _IOW ('p',0x70, void *)
151 #define IZO_IOC_GET_FILEID    _IOW ('p',0x71, void *)
152 #define IZO_IOC_ADJUST_LML    _IOW ('p',0x72, void *)
153 #define IZO_IOC_SET_FILEID    _IOW ('p',0x73, void *)
154 #define IZO_IOC_REPSTATUS    _IOW ('p',0x74, void *)
155
156 /* marking flags for fsets */
157 #define FSET_CLIENT_RO        0x00000001
158 #define FSET_LENTO_RO         0x00000002
159 #define FSET_HASPERMIT        0x00000004 /* we have a permit to WB */
160 #define FSET_INSYNC           0x00000008 /* this fileset is in sync */
161 #define FSET_PERMIT_WAITING   0x00000010 /* Lento is waiting for permit */
162 #define FSET_STEAL_PERMIT     0x00000020 /* take permit if Lento is dead */
163 #define FSET_JCLOSE_ON_WRITE  0x00000040 /* Journal closes on writes */
164 #define FSET_DATA_ON_DEMAND   0x00000080 /* update data on file_open() */
165 #define FSET_PERMIT_EXCLUSIVE 0x00000100 /* only one permitholder allowed */
166 #define FSET_HAS_BRANCHES     0x00000200 /* this fileset contains branches */
167 #define FSET_IS_BRANCH        0x00000400 /* this fileset is a branch */
168 #define FSET_FLAT_BRANCH      0x00000800 /* this fileset is ROOT with branches */
169
170 /* what to mark indicator (ioctl parameter) */
171 #define MARK_DENTRY   101
172 #define MARK_FSET     102
173 #define MARK_CACHE    103
174 #define MARK_GETFL    104
175
176 /* KML */
177
178 #define KML_MAJOR_VERSION 0x00010000
179 #define KML_MINOR_VERSION 0x00000002
180 #define KML_OPCODE_NOOP          0
181 #define KML_OPCODE_CREATE        1
182 #define KML_OPCODE_MKDIR         2
183 #define KML_OPCODE_UNLINK        3
184 #define KML_OPCODE_RMDIR         4
185 #define KML_OPCODE_CLOSE         5
186 #define KML_OPCODE_SYMLINK       6
187 #define KML_OPCODE_RENAME        7
188 #define KML_OPCODE_SETATTR       8
189 #define KML_OPCODE_LINK          9
190 #define KML_OPCODE_OPEN          10
191 #define KML_OPCODE_MKNOD         11
192 #define KML_OPCODE_WRITE         12
193 #define KML_OPCODE_RELEASE       13
194 #define KML_OPCODE_TRUNC         14
195 #define KML_OPCODE_SETEXTATTR    15
196 #define KML_OPCODE_DELEXTATTR    16
197 #define KML_OPCODE_KML_TRUNC     17
198 #define KML_OPCODE_GET_FILEID    18
199 #define KML_OPCODE_NUM           19
200 /* new stuff */
201 struct presto_version {
202         __u32 pv_mtime_sec;
203         __u32 pv_mtime_nsec;
204         __u32 pv_ctime_sec;
205         __u32 pv_ctime_nsec;
206         __u64 pv_size;
207 };
208
209 struct kml_prefix_hdr {
210         __u32                    len;
211         __u32                    version;
212         __u32                    pid;
213         __u32                    auid;
214         __u32                    fsuid;
215         __u32                    fsgid;
216         __u32                    opcode;
217         __u32                    ngroups;
218 };
219
220 struct kml_prefix { 
221         struct kml_prefix_hdr    *hdr;
222         __u32                    *groups;
223 };
224
225 struct kml_suffix { 
226         __u32                    prevrec;
227         __u32                    recno;
228         __u32                    time;
229         __u32                    len;
230 };
231
232 struct kml_rec {
233         char                   *buf;
234         struct kml_prefix       prefix;
235         __u64                   offset;
236         char                   *path;
237         int                     pathlen;
238         char                   *name;
239         int                     namelen;
240         char                   *target;
241         int                     targetlen;
242         struct presto_version  *old_objectv;
243         struct presto_version  *new_objectv;
244         struct presto_version  *old_parentv;
245         struct presto_version  *new_parentv;
246         struct presto_version  *old_targetv;
247         struct presto_version  *new_targetv;
248         __u32                   valid;
249         __u32                   mode;
250         __u32                   uid;
251         __u32                   gid;
252         __u64                   size;
253         __u32                   mtime_sec;
254         __u32                   mtime_nsec;
255         __u32                   ctime_sec;
256         __u32                   ctime_nsec;
257         __u32                   flags;
258         __u32                   ino;
259         __u32                   rdev;
260         __u32                   major;
261         __u32                   minor;
262         __u32                   generation;
263         __u32                   old_mode;
264         __u32                   old_rdev;
265         __u64                   old_uid;
266         __u64                   old_gid;
267         char                   *old_target;
268         int                     old_targetlen;
269         struct kml_suffix      *suffix;
270 };
271
272
273 /* RCVD */ 
274
275 /* izo_rcvd_rec fills the .intermezzo/fset/last_rcvd file and provides data about
276  * our view of reintegration offsets for a given peer.
277  *
278  * The only exception is the last_rcvd record which has a UUID consisting of all
279  * zeroes; this record's lr_local_offset field is the logical byte offset of our
280  * KML, which is updated when KML truncation takes place.  All other fields are
281  * reserved. */
282
283 /* XXX - document how clean shutdowns are recorded */
284
285 struct izo_rcvd_rec { 
286         __u8    lr_uuid[16];       /* which peer? */
287         __u64   lr_remote_recno;   /* last confirmed remote recno  */
288         __u64   lr_remote_offset;  /* last confirmed remote offset */
289         __u64   lr_local_recno;    /* last locally reinted recno   */
290         __u64   lr_local_offset;   /* last locally reinted offset  */
291         __u64   lr_last_ctime;     /* the largest ctime that has reintegrated */
292 };
293
294 /* Cache purge database
295  *
296  * Each DB entry is this structure followed by the path name, no trailing NUL. */
297 struct izo_purge_entry {
298         __u64 p_atime;
299         __u32 p_pathlen;
300 };
301
302 /* RPC */
303
304 #endif