]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | * ceph_fs.h - Ceph constants and data types to share between kernel and | |
3 | * user space. | |
4 | * | |
5 | * Most types in this file are defined as little-endian, and are | |
6 | * primarily intended to describe data structures that pass over the | |
7 | * wire or that are stored on disk. | |
8 | * | |
9f95a23c | 9 | * LGPL-2.1 or LGPL-3.0 |
7c673cae FG |
10 | */ |
11 | ||
12 | #ifndef CEPH_FS_H | |
13 | #define CEPH_FS_H | |
14 | ||
15 | #include "msgr.h" | |
16 | #include "rados.h" | |
17 | ||
eafe8130 TL |
18 | /* |
19 | * The data structures defined here are shared between Linux kernel and | |
20 | * user space. Also, those data structures are maintained always in | |
21 | * little-endian byte order, even on big-endian systems. This is handled | |
22 | * differently in kernel vs. user space. For use as kernel headers, the | |
23 | * little-endian fields need to use the __le16/__le32/__le64 types. These | |
24 | * are markers that indicate endian conversion routines must be used | |
25 | * whenever such fields are accessed, which can be verified by checker | |
26 | * tools like "sparse". For use as user-space headers, the little-endian | |
27 | * fields instead use types ceph_le16/ceph_le32/ceph_le64, which are C++ | |
28 | * classes that implement automatic endian conversion on every access. | |
29 | * To still allow for header sharing, this file uses the __le types, but | |
30 | * redefines those to the ceph_ types when compiled in user space. | |
31 | */ | |
32 | #ifndef __KERNEL__ | |
33 | #include "byteorder.h" | |
34 | #define __le16 ceph_le16 | |
35 | #define __le32 ceph_le32 | |
36 | #define __le64 ceph_le64 | |
37 | #endif | |
38 | ||
7c673cae FG |
39 | /* |
40 | * subprotocol versions. when specific messages types or high-level | |
41 | * protocols change, bump the affected components. we keep rev | |
42 | * internal cluster protocols separately from the public, | |
43 | * client-facing protocol. | |
44 | */ | |
45 | #define CEPH_OSDC_PROTOCOL 24 /* server/client */ | |
46 | #define CEPH_MDSC_PROTOCOL 32 /* server/client */ | |
47 | #define CEPH_MONC_PROTOCOL 15 /* server/client */ | |
48 | ||
49 | ||
b3b6e05e TL |
50 | #define CEPH_INO_ROOT 1 |
51 | /* | |
52 | * hidden .ceph dir, which is no longer created but | |
53 | * recognised in existing filesystems so that we | |
54 | * don't try to fragment it. | |
55 | */ | |
56 | #define CEPH_INO_CEPH 2 | |
57 | #define CEPH_INO_GLOBAL_SNAPREALM 3 | |
58 | #define CEPH_INO_LOST_AND_FOUND 4 /* reserved ino for use in recovery */ | |
7c673cae FG |
59 | |
60 | /* arbitrary limit on max # of monitors (cluster of 3 is typical) */ | |
61 | #define CEPH_MAX_MON 31 | |
62 | ||
63 | /* | |
64 | * ceph_file_layout - describe data layout for a file/inode | |
65 | */ | |
66 | struct ceph_file_layout { | |
67 | /* file -> object mapping */ | |
68 | __le32 fl_stripe_unit; /* stripe unit, in bytes. must be multiple | |
69 | of page size. */ | |
70 | __le32 fl_stripe_count; /* over this many objects */ | |
71 | __le32 fl_object_size; /* until objects are this big, then move to | |
72 | new objects */ | |
73 | __le32 fl_cas_hash; /* UNUSED. 0 = none; 1 = sha256 */ | |
74 | ||
75 | /* pg -> disk layout */ | |
76 | __le32 fl_object_stripe_unit; /* UNUSED. for per-object parity, if any */ | |
77 | ||
78 | /* object -> pg layout */ | |
79 | __le32 fl_unused; /* unused; used to be preferred primary for pg (-1 for none) */ | |
20effc67 | 80 | __le32 fl_pg_pool; /* namespace, crush rule, rep level */ |
7c673cae FG |
81 | } __attribute__ ((packed)); |
82 | ||
83 | #define CEPH_MIN_STRIPE_UNIT 65536 | |
84 | ||
85 | struct ceph_dir_layout { | |
86 | __u8 dl_dir_hash; /* see ceph_hash.h for ids */ | |
87 | __u8 dl_unused1; | |
88 | __u16 dl_unused2; | |
89 | __u32 dl_unused3; | |
90 | } __attribute__ ((packed)); | |
91 | ||
92 | /* crypto algorithms */ | |
93 | #define CEPH_CRYPTO_NONE 0x0 | |
94 | #define CEPH_CRYPTO_AES 0x1 | |
95 | ||
96 | #define CEPH_AES_IV "cephsageyudagreg" | |
97 | ||
98 | /* security/authentication protocols */ | |
99 | #define CEPH_AUTH_UNKNOWN 0x0 | |
100 | #define CEPH_AUTH_NONE 0x1 | |
101 | #define CEPH_AUTH_CEPHX 0x2 | |
102 | ||
11fdf7f2 TL |
103 | /* msgr2 protocol modes */ |
104 | #define CEPH_CON_MODE_UNKNOWN 0x0 | |
105 | #define CEPH_CON_MODE_CRC 0x1 | |
106 | #define CEPH_CON_MODE_SECURE 0x2 | |
107 | ||
108 | extern const char *ceph_con_mode_name(int con_mode); | |
109 | ||
110 | /* For options with "_", like: GSS_GSS | |
111 | which means: Mode/Protocol to validate "authentication_authorization", | |
112 | where: | |
113 | - Authentication: Verifying the identity of an entity. | |
114 | - Authorization: Verifying that an authenticated entity has | |
115 | the right to access a particular resource. | |
116 | */ | |
117 | #define CEPH_AUTH_GSS 0x4 | |
118 | #define CEPH_AUTH_GSS_GSS CEPH_AUTH_GSS | |
119 | ||
7c673cae FG |
120 | #define CEPH_AUTH_UID_DEFAULT ((__u64) -1) |
121 | ||
122 | ||
123 | /********************************************* | |
124 | * message layer | |
125 | */ | |
126 | ||
127 | /* | |
128 | * message types | |
129 | */ | |
130 | ||
131 | /* misc */ | |
132 | #define CEPH_MSG_SHUTDOWN 1 | |
133 | #define CEPH_MSG_PING 2 | |
134 | ||
135 | /* client <-> monitor */ | |
136 | #define CEPH_MSG_MON_MAP 4 | |
137 | #define CEPH_MSG_MON_GET_MAP 5 | |
138 | #define CEPH_MSG_MON_GET_OSDMAP 6 | |
139 | #define CEPH_MSG_MON_METADATA 7 | |
140 | #define CEPH_MSG_STATFS 13 | |
141 | #define CEPH_MSG_STATFS_REPLY 14 | |
142 | #define CEPH_MSG_MON_SUBSCRIBE 15 | |
143 | #define CEPH_MSG_MON_SUBSCRIBE_ACK 16 | |
144 | #define CEPH_MSG_AUTH 17 | |
145 | #define CEPH_MSG_AUTH_REPLY 18 | |
146 | #define CEPH_MSG_MON_GET_VERSION 19 | |
147 | #define CEPH_MSG_MON_GET_VERSION_REPLY 20 | |
148 | ||
149 | /* client <-> mds */ | |
150 | #define CEPH_MSG_MDS_MAP 21 | |
151 | ||
152 | #define CEPH_MSG_CLIENT_SESSION 22 | |
153 | #define CEPH_MSG_CLIENT_RECONNECT 23 | |
154 | ||
155 | #define CEPH_MSG_CLIENT_REQUEST 24 | |
156 | #define CEPH_MSG_CLIENT_REQUEST_FORWARD 25 | |
157 | #define CEPH_MSG_CLIENT_REPLY 26 | |
11fdf7f2 TL |
158 | #define CEPH_MSG_CLIENT_RECLAIM 27 |
159 | #define CEPH_MSG_CLIENT_RECLAIM_REPLY 28 | |
f67539c2 | 160 | #define CEPH_MSG_CLIENT_METRICS 29 |
7c673cae FG |
161 | #define CEPH_MSG_CLIENT_CAPS 0x310 |
162 | #define CEPH_MSG_CLIENT_LEASE 0x311 | |
163 | #define CEPH_MSG_CLIENT_SNAP 0x312 | |
164 | #define CEPH_MSG_CLIENT_CAPRELEASE 0x313 | |
165 | #define CEPH_MSG_CLIENT_QUOTA 0x314 | |
166 | ||
167 | /* pool ops */ | |
168 | #define CEPH_MSG_POOLOP_REPLY 48 | |
169 | #define CEPH_MSG_POOLOP 49 | |
170 | ||
171 | ||
172 | /* osd */ | |
173 | #define CEPH_MSG_OSD_MAP 41 | |
174 | #define CEPH_MSG_OSD_OP 42 | |
175 | #define CEPH_MSG_OSD_OPREPLY 43 | |
176 | #define CEPH_MSG_WATCH_NOTIFY 44 | |
177 | #define CEPH_MSG_OSD_BACKOFF 61 | |
178 | ||
179 | /* FSMap subscribers (see all MDS clusters at once) */ | |
180 | #define CEPH_MSG_FS_MAP 45 | |
181 | /* FSMapUser subscribers (get MDS clusters name->ID mapping) */ | |
182 | #define CEPH_MSG_FS_MAP_USER 103 | |
183 | ||
184 | /* watch-notify operations */ | |
185 | enum { | |
186 | CEPH_WATCH_EVENT_NOTIFY = 1, /* notifying watcher */ | |
187 | CEPH_WATCH_EVENT_NOTIFY_COMPLETE = 2, /* notifier notified when done */ | |
188 | CEPH_WATCH_EVENT_DISCONNECT = 3, /* we were disconnected */ | |
189 | }; | |
190 | ||
191 | const char *ceph_watch_event_name(int o); | |
192 | ||
193 | /* pool operations */ | |
194 | enum { | |
195 | POOL_OP_CREATE = 0x01, | |
196 | POOL_OP_DELETE = 0x02, | |
197 | POOL_OP_AUID_CHANGE = 0x03, | |
198 | POOL_OP_CREATE_SNAP = 0x11, | |
199 | POOL_OP_DELETE_SNAP = 0x12, | |
200 | POOL_OP_CREATE_UNMANAGED_SNAP = 0x21, | |
201 | POOL_OP_DELETE_UNMANAGED_SNAP = 0x22, | |
202 | }; | |
203 | ||
204 | struct ceph_mon_request_header { | |
205 | __le64 have_version; | |
206 | __le16 session_mon; | |
207 | __le64 session_mon_tid; | |
208 | } __attribute__ ((packed)); | |
209 | ||
210 | struct ceph_mon_statfs { | |
211 | struct ceph_mon_request_header monhdr; | |
212 | struct ceph_fsid fsid; | |
213 | } __attribute__ ((packed)); | |
214 | ||
215 | struct ceph_statfs { | |
216 | __le64 kb, kb_used, kb_avail; | |
217 | __le64 num_objects; | |
218 | } __attribute__ ((packed)); | |
219 | ||
220 | struct ceph_mon_statfs_reply { | |
221 | struct ceph_fsid fsid; | |
222 | __le64 version; | |
223 | struct ceph_statfs st; | |
224 | } __attribute__ ((packed)); | |
225 | ||
226 | const char *ceph_pool_op_name(int op); | |
227 | ||
228 | struct ceph_mon_poolop { | |
229 | struct ceph_mon_request_header monhdr; | |
230 | struct ceph_fsid fsid; | |
231 | __le32 pool; | |
232 | __le32 op; | |
11fdf7f2 | 233 | __le64 __old_auid; // obsolete |
7c673cae FG |
234 | __le64 snapid; |
235 | __le32 name_len; | |
236 | } __attribute__ ((packed)); | |
237 | ||
238 | struct ceph_mon_poolop_reply { | |
239 | struct ceph_mon_request_header monhdr; | |
240 | struct ceph_fsid fsid; | |
241 | __le32 reply_code; | |
242 | __le32 epoch; | |
243 | char has_data; | |
244 | char data[0]; | |
245 | } __attribute__ ((packed)); | |
246 | ||
247 | struct ceph_mon_unmanaged_snap { | |
248 | __le64 snapid; | |
249 | } __attribute__ ((packed)); | |
250 | ||
251 | struct ceph_osd_getmap { | |
252 | struct ceph_mon_request_header monhdr; | |
253 | struct ceph_fsid fsid; | |
254 | __le32 start; | |
255 | } __attribute__ ((packed)); | |
256 | ||
257 | struct ceph_mds_getmap { | |
258 | struct ceph_mon_request_header monhdr; | |
259 | struct ceph_fsid fsid; | |
260 | } __attribute__ ((packed)); | |
261 | ||
262 | struct ceph_client_mount { | |
263 | struct ceph_mon_request_header monhdr; | |
264 | } __attribute__ ((packed)); | |
265 | ||
266 | #define CEPH_SUBSCRIBE_ONETIME 1 /* i want only 1 update after have */ | |
267 | ||
268 | struct ceph_mon_subscribe_item { | |
269 | __le64 start; | |
270 | __u8 flags; | |
271 | } __attribute__ ((packed)); | |
272 | ||
273 | struct ceph_mon_subscribe_ack { | |
274 | __le32 duration; /* seconds */ | |
275 | struct ceph_fsid fsid; | |
276 | } __attribute__ ((packed)); | |
277 | ||
278 | /* | |
279 | * mdsmap flags | |
280 | */ | |
11fdf7f2 TL |
281 | #define CEPH_MDSMAP_NOT_JOINABLE (1<<0) /* standbys cannot join */ |
282 | #define CEPH_MDSMAP_DOWN (CEPH_MDSMAP_NOT_JOINABLE) /* backwards compat */ | |
283 | #define CEPH_MDSMAP_ALLOW_SNAPS (1<<1) /* cluster allowed to create snapshots */ | |
284 | /* deprecated #define CEPH_MDSMAP_ALLOW_MULTIMDS (1<<2) cluster allowed to have >1 active MDS */ | |
285 | /* deprecated #define CEPH_MDSMAP_ALLOW_DIRFRAGS (1<<3) cluster allowed to fragment directories */ | |
286 | #define CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS (1<<4) /* cluster alllowed to enable MULTIMDS | |
287 | and SNAPS at the same time */ | |
288 | #define CEPH_MDSMAP_ALLOW_STANDBY_REPLAY (1<<5) /* cluster alllowed to enable MULTIMDS */ | |
289 | ||
290 | #define CEPH_MDSMAP_DEFAULTS (CEPH_MDSMAP_ALLOW_SNAPS | \ | |
291 | CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS) | |
7c673cae FG |
292 | |
293 | /* | |
294 | * mds states | |
295 | * > 0 -> in | |
296 | * <= 0 -> out | |
297 | */ | |
298 | #define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */ | |
299 | #define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees. | |
300 | empty log. */ | |
301 | #define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */ | |
302 | #define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */ | |
303 | #define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */ | |
304 | #define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */ | |
305 | #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */ | |
306 | #define CEPH_MDS_STATE_REPLAYONCE -9 /* Legacy, unused */ | |
307 | #define CEPH_MDS_STATE_NULL -10 | |
308 | ||
309 | #define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */ | |
310 | #define CEPH_MDS_STATE_RESOLVE 9 /* up, disambiguating distributed | |
311 | operations (import, rename, etc.) */ | |
312 | #define CEPH_MDS_STATE_RECONNECT 10 /* up, reconnect to clients */ | |
313 | #define CEPH_MDS_STATE_REJOIN 11 /* up, rejoining distributed cache */ | |
314 | #define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */ | |
315 | #define CEPH_MDS_STATE_ACTIVE 13 /* up, active */ | |
316 | #define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */ | |
317 | #define CEPH_MDS_STATE_DAMAGED 15 /* rank not replayable, need repair */ | |
318 | ||
319 | extern const char *ceph_mds_state_name(int s); | |
320 | ||
321 | ||
322 | /* | |
323 | * metadata lock types. | |
324 | * - these are bitmasks.. we can compose them | |
325 | * - they also define the lock ordering by the MDS | |
326 | * - a few of these are internal to the mds | |
327 | */ | |
9f95a23c TL |
328 | #define CEPH_LOCK_DN (1 << 0) |
329 | #define CEPH_LOCK_DVERSION (1 << 1) | |
330 | #define CEPH_LOCK_ISNAP (1 << 4) /* snapshot lock. MDS internal */ | |
331 | #define CEPH_LOCK_IPOLICY (1 << 5) /* policy lock on dirs. MDS internal */ | |
332 | #define CEPH_LOCK_IFILE (1 << 6) | |
333 | #define CEPH_LOCK_INEST (1 << 7) /* mds internal */ | |
334 | #define CEPH_LOCK_IDFT (1 << 8) /* dir frag tree */ | |
335 | #define CEPH_LOCK_IAUTH (1 << 9) | |
336 | #define CEPH_LOCK_ILINK (1 << 10) | |
337 | #define CEPH_LOCK_IXATTR (1 << 11) | |
338 | #define CEPH_LOCK_IFLOCK (1 << 12) /* advisory file locks */ | |
339 | #define CEPH_LOCK_IVERSION (1 << 13) /* mds internal */ | |
340 | ||
341 | #define CEPH_LOCK_IFIRST CEPH_LOCK_ISNAP | |
342 | ||
7c673cae FG |
343 | |
344 | /* client_session ops */ | |
345 | enum { | |
346 | CEPH_SESSION_REQUEST_OPEN, | |
347 | CEPH_SESSION_OPEN, | |
348 | CEPH_SESSION_REQUEST_CLOSE, | |
349 | CEPH_SESSION_CLOSE, | |
350 | CEPH_SESSION_REQUEST_RENEWCAPS, | |
351 | CEPH_SESSION_RENEWCAPS, | |
352 | CEPH_SESSION_STALE, | |
353 | CEPH_SESSION_RECALL_STATE, | |
354 | CEPH_SESSION_FLUSHMSG, | |
355 | CEPH_SESSION_FLUSHMSG_ACK, | |
356 | CEPH_SESSION_FORCE_RO, | |
357 | // A response to REQUEST_OPEN indicating that the client should | |
358 | // permanently desist from contacting the MDS | |
31f18b77 FG |
359 | CEPH_SESSION_REJECT, |
360 | CEPH_SESSION_REQUEST_FLUSH_MDLOG | |
7c673cae FG |
361 | }; |
362 | ||
11fdf7f2 TL |
363 | // flags for state reclaim |
364 | #define CEPH_RECLAIM_RESET 1 | |
365 | ||
7c673cae FG |
366 | extern const char *ceph_session_op_name(int op); |
367 | ||
368 | struct ceph_mds_session_head { | |
369 | __le32 op; | |
370 | __le64 seq; | |
371 | struct ceph_timespec stamp; | |
372 | __le32 max_caps, max_leases; | |
373 | } __attribute__ ((packed)); | |
374 | ||
375 | /* client_request */ | |
376 | /* | |
377 | * metadata ops. | |
378 | * & 0x001000 -> write op | |
379 | * & 0x010000 -> follow symlink (e.g. stat(), not lstat()). | |
380 | & & 0x100000 -> use weird ino/path trace | |
381 | */ | |
382 | #define CEPH_MDS_OP_WRITE 0x001000 | |
383 | enum { | |
384 | CEPH_MDS_OP_LOOKUP = 0x00100, | |
385 | CEPH_MDS_OP_GETATTR = 0x00101, | |
386 | CEPH_MDS_OP_LOOKUPHASH = 0x00102, | |
387 | CEPH_MDS_OP_LOOKUPPARENT = 0x00103, | |
388 | CEPH_MDS_OP_LOOKUPINO = 0x00104, | |
389 | CEPH_MDS_OP_LOOKUPNAME = 0x00105, | |
1d09f67e | 390 | CEPH_MDS_OP_GETVXATTR = 0x00106, |
7c673cae FG |
391 | |
392 | CEPH_MDS_OP_SETXATTR = 0x01105, | |
393 | CEPH_MDS_OP_RMXATTR = 0x01106, | |
394 | CEPH_MDS_OP_SETLAYOUT = 0x01107, | |
395 | CEPH_MDS_OP_SETATTR = 0x01108, | |
396 | CEPH_MDS_OP_SETFILELOCK= 0x01109, | |
397 | CEPH_MDS_OP_GETFILELOCK= 0x00110, | |
398 | CEPH_MDS_OP_SETDIRLAYOUT=0x0110a, | |
399 | ||
400 | CEPH_MDS_OP_MKNOD = 0x01201, | |
401 | CEPH_MDS_OP_LINK = 0x01202, | |
402 | CEPH_MDS_OP_UNLINK = 0x01203, | |
403 | CEPH_MDS_OP_RENAME = 0x01204, | |
404 | CEPH_MDS_OP_MKDIR = 0x01220, | |
405 | CEPH_MDS_OP_RMDIR = 0x01221, | |
406 | CEPH_MDS_OP_SYMLINK = 0x01222, | |
407 | ||
408 | CEPH_MDS_OP_CREATE = 0x01301, | |
409 | CEPH_MDS_OP_OPEN = 0x00302, | |
410 | CEPH_MDS_OP_READDIR = 0x00305, | |
411 | ||
412 | CEPH_MDS_OP_LOOKUPSNAP = 0x00400, | |
413 | CEPH_MDS_OP_MKSNAP = 0x01400, | |
414 | CEPH_MDS_OP_RMSNAP = 0x01401, | |
415 | CEPH_MDS_OP_LSSNAP = 0x00402, | |
416 | CEPH_MDS_OP_RENAMESNAP = 0x01403, | |
417 | ||
418 | // internal op | |
419 | CEPH_MDS_OP_FRAGMENTDIR= 0x01500, | |
420 | CEPH_MDS_OP_EXPORTDIR = 0x01501, | |
421 | CEPH_MDS_OP_FLUSH = 0x01502, | |
422 | CEPH_MDS_OP_ENQUEUE_SCRUB = 0x01503, | |
423 | CEPH_MDS_OP_REPAIR_FRAGSTATS = 0x01504, | |
11fdf7f2 | 424 | CEPH_MDS_OP_REPAIR_INODESTATS = 0x01505, |
f67539c2 | 425 | CEPH_MDS_OP_RDLOCK_FRAGSSTATS = 0x01507 |
7c673cae FG |
426 | }; |
427 | ||
428 | extern const char *ceph_mds_op_name(int op); | |
429 | ||
430 | #ifndef CEPH_SETATTR_MODE | |
431 | #define CEPH_SETATTR_MODE (1 << 0) | |
432 | #define CEPH_SETATTR_UID (1 << 1) | |
433 | #define CEPH_SETATTR_GID (1 << 2) | |
434 | #define CEPH_SETATTR_MTIME (1 << 3) | |
435 | #define CEPH_SETATTR_ATIME (1 << 4) | |
436 | #define CEPH_SETATTR_SIZE (1 << 5) | |
437 | #define CEPH_SETATTR_CTIME (1 << 6) | |
7c673cae FG |
438 | #define CEPH_SETATTR_MTIME_NOW (1 << 7) |
439 | #define CEPH_SETATTR_ATIME_NOW (1 << 8) | |
f64942e4 AA |
440 | #define CEPH_SETATTR_BTIME (1 << 9) |
441 | #endif | |
7c673cae FG |
442 | #define CEPH_SETATTR_KILL_SGUID (1 << 10) |
443 | ||
444 | /* | |
445 | * open request flags | |
446 | */ | |
447 | #define CEPH_O_RDONLY 00000000 | |
448 | #define CEPH_O_WRONLY 00000001 | |
449 | #define CEPH_O_RDWR 00000002 | |
450 | #define CEPH_O_CREAT 00000100 | |
451 | #define CEPH_O_EXCL 00000200 | |
452 | #define CEPH_O_TRUNC 00001000 | |
11fdf7f2 | 453 | #define CEPH_O_LAZY 00020000 |
7c673cae FG |
454 | #define CEPH_O_DIRECTORY 00200000 |
455 | #define CEPH_O_NOFOLLOW 00400000 | |
456 | ||
457 | int ceph_flags_sys2wire(int flags); | |
458 | ||
459 | /* | |
460 | * Ceph setxattr request flags. | |
461 | */ | |
462 | #define CEPH_XATTR_CREATE (1 << 0) | |
463 | #define CEPH_XATTR_REPLACE (1 << 1) | |
464 | #define CEPH_XATTR_REMOVE (1 << 31) | |
465 | ||
466 | /* | |
467 | * readdir request flags; | |
468 | */ | |
469 | #define CEPH_READDIR_REPLY_BITFLAGS (1<<0) | |
470 | ||
471 | /* | |
472 | * readdir reply flags. | |
473 | */ | |
474 | #define CEPH_READDIR_FRAG_END (1<<0) | |
475 | #define CEPH_READDIR_FRAG_COMPLETE (1<<8) | |
476 | #define CEPH_READDIR_HASH_ORDER (1<<9) | |
477 | #define CEPH_READDIR_OFFSET_HASH (1<<10) | |
478 | ||
479 | /* Note that this is embedded wthin ceph_mds_request_head_legacy. */ | |
480 | union ceph_mds_request_args_legacy { | |
481 | struct { | |
482 | __le32 mask; /* CEPH_CAP_* */ | |
483 | } __attribute__ ((packed)) getattr; | |
484 | struct { | |
485 | __le32 mode; | |
486 | __le32 uid; | |
487 | __le32 gid; | |
488 | struct ceph_timespec mtime; | |
489 | struct ceph_timespec atime; | |
490 | __le64 size, old_size; /* old_size needed by truncate */ | |
491 | __le32 mask; /* CEPH_SETATTR_* */ | |
492 | } __attribute__ ((packed)) setattr; | |
493 | struct { | |
494 | __le32 frag; /* which dir fragment */ | |
495 | __le32 max_entries; /* how many dentries to grab */ | |
496 | __le32 max_bytes; | |
497 | __le16 flags; | |
498 | __le32 offset_hash; | |
499 | } __attribute__ ((packed)) readdir; | |
500 | struct { | |
501 | __le32 mode; | |
502 | __le32 rdev; | |
503 | } __attribute__ ((packed)) mknod; | |
504 | struct { | |
505 | __le32 mode; | |
506 | } __attribute__ ((packed)) mkdir; | |
507 | struct { | |
508 | __le32 flags; | |
509 | __le32 mode; | |
510 | __le32 stripe_unit; /* layout for newly created file */ | |
511 | __le32 stripe_count; /* ... */ | |
512 | __le32 object_size; | |
513 | __le32 pool; /* if >= 0 and CREATEPOOLID feature */ | |
514 | __le32 mask; /* CEPH_CAP_* */ | |
515 | __le64 old_size; /* if O_TRUNC */ | |
516 | } __attribute__ ((packed)) open; | |
517 | struct { | |
518 | __le32 flags; | |
519 | __le32 osdmap_epoch; /* use for set file/dir layout */ | |
520 | } __attribute__ ((packed)) setxattr; | |
521 | struct { | |
522 | struct ceph_file_layout layout; | |
523 | } __attribute__ ((packed)) setlayout; | |
524 | struct { | |
525 | __u8 rule; /* currently fcntl or flock */ | |
526 | __u8 type; /* shared, exclusive, remove*/ | |
527 | __le64 owner; /* who requests/holds the lock */ | |
528 | __le64 pid; /* process id requesting the lock */ | |
529 | __le64 start; /* initial location to lock */ | |
530 | __le64 length; /* num bytes to lock from start */ | |
531 | __u8 wait; /* will caller wait for lock to become available? */ | |
532 | } __attribute__ ((packed)) filelock_change; | |
533 | } __attribute__ ((packed)); | |
534 | ||
535 | #define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */ | |
536 | #define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */ | |
9f95a23c | 537 | #define CEPH_MDS_FLAG_ASYNC 4 /* request is async */ |
7c673cae FG |
538 | |
539 | struct ceph_mds_request_head_legacy { | |
540 | __le64 oldest_client_tid; | |
541 | __le32 mdsmap_epoch; /* on client */ | |
542 | __le32 flags; /* CEPH_MDS_FLAG_* */ | |
543 | __u8 num_retry, num_fwd; /* count retry, fwd attempts */ | |
544 | __le16 num_releases; /* # include cap/lease release records */ | |
545 | __le32 op; /* mds op code */ | |
546 | __le32 caller_uid, caller_gid; | |
547 | __le64 ino; /* use this ino for openc, mkdir, mknod, | |
548 | etc. (if replaying) */ | |
549 | union ceph_mds_request_args_legacy args; | |
550 | } __attribute__ ((packed)); | |
551 | ||
552 | /* | |
11fdf7f2 | 553 | * Note that this is embedded wthin ceph_mds_request_head. Also, compatibility |
7c673cae FG |
554 | * with the ceph_mds_request_args_legacy must be maintained! |
555 | */ | |
556 | union ceph_mds_request_args { | |
557 | struct { | |
558 | __le32 mask; /* CEPH_CAP_* */ | |
559 | } __attribute__ ((packed)) getattr; | |
560 | struct { | |
561 | __le32 mode; | |
562 | __le32 uid; | |
563 | __le32 gid; | |
564 | struct ceph_timespec mtime; | |
565 | struct ceph_timespec atime; | |
566 | __le64 size, old_size; /* old_size needed by truncate */ | |
567 | __le32 mask; /* CEPH_SETATTR_* */ | |
568 | struct ceph_timespec btime; | |
569 | } __attribute__ ((packed)) setattr; | |
570 | struct { | |
571 | __le32 frag; /* which dir fragment */ | |
572 | __le32 max_entries; /* how many dentries to grab */ | |
573 | __le32 max_bytes; | |
574 | __le16 flags; | |
575 | __le32 offset_hash; | |
576 | } __attribute__ ((packed)) readdir; | |
577 | struct { | |
578 | __le32 mode; | |
579 | __le32 rdev; | |
580 | } __attribute__ ((packed)) mknod; | |
581 | struct { | |
582 | __le32 mode; | |
583 | } __attribute__ ((packed)) mkdir; | |
584 | struct { | |
585 | __le32 flags; | |
586 | __le32 mode; | |
587 | __le32 stripe_unit; /* layout for newly created file */ | |
588 | __le32 stripe_count; /* ... */ | |
589 | __le32 object_size; | |
590 | __le32 pool; /* if >= 0 and CREATEPOOLID feature */ | |
591 | __le32 mask; /* CEPH_CAP_* */ | |
592 | __le64 old_size; /* if O_TRUNC */ | |
593 | } __attribute__ ((packed)) open; | |
594 | struct { | |
595 | __le32 flags; | |
596 | __le32 osdmap_epoch; /* use for set file/dir layout */ | |
597 | } __attribute__ ((packed)) setxattr; | |
598 | struct { | |
599 | struct ceph_file_layout layout; | |
600 | } __attribute__ ((packed)) setlayout; | |
601 | struct { | |
602 | __u8 rule; /* currently fcntl or flock */ | |
603 | __u8 type; /* shared, exclusive, remove*/ | |
604 | __le64 owner; /* who requests/holds the lock */ | |
605 | __le64 pid; /* process id requesting the lock */ | |
606 | __le64 start; /* initial location to lock */ | |
607 | __le64 length; /* num bytes to lock from start */ | |
608 | __u8 wait; /* will caller wait for lock to become available? */ | |
609 | } __attribute__ ((packed)) filelock_change; | |
11fdf7f2 TL |
610 | struct { |
611 | __le32 mask; /* CEPH_CAP_* */ | |
612 | __le64 snapid; | |
613 | __le64 parent; | |
614 | __le32 hash; | |
615 | } __attribute__ ((packed)) lookupino; | |
7c673cae FG |
616 | } __attribute__ ((packed)); |
617 | ||
618 | #define CEPH_MDS_REQUEST_HEAD_VERSION 1 | |
619 | ||
620 | /* | |
621 | * Note that any change to this structure must ensure that it is compatible | |
622 | * with ceph_mds_request_head_legacy. | |
623 | */ | |
624 | struct ceph_mds_request_head { | |
625 | __le16 version; | |
626 | __le64 oldest_client_tid; | |
627 | __le32 mdsmap_epoch; /* on client */ | |
628 | __le32 flags; /* CEPH_MDS_FLAG_* */ | |
629 | __u8 num_retry, num_fwd; /* count retry, fwd attempts */ | |
630 | __le16 num_releases; /* # include cap/lease release records */ | |
631 | __le32 op; /* mds op code */ | |
632 | __le32 caller_uid, caller_gid; | |
633 | __le64 ino; /* use this ino for openc, mkdir, mknod, | |
634 | etc. (if replaying) */ | |
635 | union ceph_mds_request_args args; | |
636 | } __attribute__ ((packed)); | |
637 | ||
638 | /* cap/lease release record */ | |
639 | struct ceph_mds_request_release { | |
640 | __le64 ino, cap_id; /* ino and unique cap id */ | |
641 | __le32 caps, wanted; /* new issued, wanted */ | |
642 | __le32 seq, issue_seq, mseq; | |
643 | __le32 dname_seq; /* if releasing a dentry lease, a */ | |
644 | __le32 dname_len; /* string follows. */ | |
645 | } __attribute__ ((packed)); | |
646 | ||
647 | static inline void | |
648 | copy_from_legacy_head(struct ceph_mds_request_head *head, | |
649 | struct ceph_mds_request_head_legacy *legacy) | |
650 | { | |
9f95a23c TL |
651 | struct ceph_mds_request_head_legacy *embedded_legacy = |
652 | (struct ceph_mds_request_head_legacy *)&head->oldest_client_tid; | |
653 | *embedded_legacy = *legacy; | |
7c673cae FG |
654 | } |
655 | ||
656 | static inline void | |
657 | copy_to_legacy_head(struct ceph_mds_request_head_legacy *legacy, | |
658 | struct ceph_mds_request_head *head) | |
659 | { | |
9f95a23c TL |
660 | struct ceph_mds_request_head_legacy *embedded_legacy = |
661 | (struct ceph_mds_request_head_legacy *)&head->oldest_client_tid; | |
662 | *legacy = *embedded_legacy; | |
7c673cae FG |
663 | } |
664 | ||
665 | /* client reply */ | |
666 | struct ceph_mds_reply_head { | |
667 | __le32 op; | |
668 | __le32 result; | |
669 | __le32 mdsmap_epoch; | |
670 | __u8 safe; /* true if committed to disk */ | |
671 | __u8 is_dentry, is_target; /* true if dentry, target inode records | |
672 | are included with reply */ | |
673 | } __attribute__ ((packed)); | |
674 | ||
675 | /* one for each node split */ | |
676 | struct ceph_frag_tree_split { | |
677 | __le32 frag; /* this frag splits... */ | |
678 | __le32 by; /* ...by this many bits */ | |
679 | } __attribute__ ((packed)); | |
680 | ||
681 | struct ceph_frag_tree_head { | |
682 | __le32 nsplits; /* num ceph_frag_tree_split records */ | |
683 | struct ceph_frag_tree_split splits[]; | |
684 | } __attribute__ ((packed)); | |
685 | ||
686 | /* capability issue, for bundling with mds reply */ | |
687 | struct ceph_mds_reply_cap { | |
688 | __le32 caps, wanted; /* caps issued, wanted */ | |
689 | __le64 cap_id; | |
690 | __le32 seq, mseq; | |
691 | __le64 realm; /* snap realm */ | |
692 | __u8 flags; /* CEPH_CAP_FLAG_* */ | |
693 | } __attribute__ ((packed)); | |
694 | ||
695 | #define CEPH_CAP_FLAG_AUTH (1 << 0) /* cap is issued by auth mds */ | |
696 | #define CEPH_CAP_FLAG_RELEASE (1 << 1) /* ask client to release the cap */ | |
697 | ||
698 | /* reply_lease follows dname, and reply_inode */ | |
699 | struct ceph_mds_reply_lease { | |
700 | __le16 mask; /* lease type(s) */ | |
701 | __le32 duration_ms; /* lease duration */ | |
702 | __le32 seq; | |
703 | } __attribute__ ((packed)); | |
704 | ||
9f95a23c TL |
705 | #define CEPH_LEASE_VALID (1 | 2) /* old and new bit values */ |
706 | #define CEPH_LEASE_PRIMARY_LINK 4 /* primary linkage */ | |
707 | ||
7c673cae FG |
708 | struct ceph_mds_reply_dirfrag { |
709 | __le32 frag; /* fragment */ | |
710 | __le32 auth; /* auth mds, if this is a delegation point */ | |
711 | __le32 ndist; /* number of mds' this is replicated on */ | |
712 | __le32 dist[]; | |
713 | } __attribute__ ((packed)); | |
714 | ||
715 | #define CEPH_LOCK_FCNTL 1 | |
716 | #define CEPH_LOCK_FLOCK 2 | |
717 | #define CEPH_LOCK_FCNTL_INTR 3 | |
718 | #define CEPH_LOCK_FLOCK_INTR 4 | |
719 | ||
720 | #define CEPH_LOCK_SHARED 1 | |
721 | #define CEPH_LOCK_EXCL 2 | |
722 | #define CEPH_LOCK_UNLOCK 4 | |
723 | ||
724 | struct ceph_filelock { | |
725 | __le64 start;/* file offset to start lock at */ | |
726 | __le64 length; /* num bytes to lock; 0 for all following start */ | |
727 | __le64 client; /* which client holds the lock */ | |
728 | __le64 owner; /* who requests/holds the lock */ | |
729 | __le64 pid; /* process id holding the lock on the client */ | |
730 | __u8 type; /* shared lock, exclusive lock, or unlock */ | |
731 | } __attribute__ ((packed)); | |
732 | ||
733 | ||
734 | /* file access modes */ | |
735 | #define CEPH_FILE_MODE_PIN 0 | |
736 | #define CEPH_FILE_MODE_RD 1 | |
737 | #define CEPH_FILE_MODE_WR 2 | |
738 | #define CEPH_FILE_MODE_RDWR 3 /* RD | WR */ | |
739 | #define CEPH_FILE_MODE_LAZY 4 /* lazy io */ | |
740 | #define CEPH_FILE_MODE_NUM 8 /* bc these are bit fields.. mostly */ | |
741 | ||
742 | int ceph_flags_to_mode(int flags); | |
743 | ||
744 | /* inline data state */ | |
745 | #define CEPH_INLINE_NONE ((__u64)-1) | |
746 | #define CEPH_INLINE_MAX_SIZE CEPH_MIN_STRIPE_UNIT | |
747 | ||
748 | /* capability bits */ | |
749 | #define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */ | |
750 | ||
751 | /* generic cap bits */ | |
eafe8130 | 752 | /* note: these definitions are duplicated in mds/locks.c */ |
7c673cae FG |
753 | #define CEPH_CAP_GSHARED 1 /* client can reads */ |
754 | #define CEPH_CAP_GEXCL 2 /* client can read and update */ | |
755 | #define CEPH_CAP_GCACHE 4 /* (file) client can cache reads */ | |
756 | #define CEPH_CAP_GRD 8 /* (file) client can read */ | |
757 | #define CEPH_CAP_GWR 16 /* (file) client can write */ | |
758 | #define CEPH_CAP_GBUFFER 32 /* (file) client can buffer writes */ | |
759 | #define CEPH_CAP_GWREXTEND 64 /* (file) client can extend EOF */ | |
760 | #define CEPH_CAP_GLAZYIO 128 /* (file) client can perform lazy io */ | |
761 | ||
762 | #define CEPH_CAP_SIMPLE_BITS 2 | |
763 | #define CEPH_CAP_FILE_BITS 8 | |
764 | ||
765 | /* per-lock shift */ | |
766 | #define CEPH_CAP_SAUTH 2 | |
767 | #define CEPH_CAP_SLINK 4 | |
768 | #define CEPH_CAP_SXATTR 6 | |
769 | #define CEPH_CAP_SFILE 8 | |
770 | ||
771 | /* composed values */ | |
772 | #define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH) | |
773 | #define CEPH_CAP_AUTH_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SAUTH) | |
774 | #define CEPH_CAP_LINK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SLINK) | |
775 | #define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK) | |
776 | #define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SXATTR) | |
777 | #define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR) | |
9f95a23c | 778 | #define CEPH_CAP_FILE(x) ((x) << CEPH_CAP_SFILE) |
7c673cae FG |
779 | #define CEPH_CAP_FILE_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFILE) |
780 | #define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE) | |
781 | #define CEPH_CAP_FILE_CACHE (CEPH_CAP_GCACHE << CEPH_CAP_SFILE) | |
782 | #define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE) | |
783 | #define CEPH_CAP_FILE_WR (CEPH_CAP_GWR << CEPH_CAP_SFILE) | |
784 | #define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE) | |
785 | #define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE) | |
786 | #define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE) | |
787 | ||
788 | /* cap masks (for getattr) */ | |
789 | #define CEPH_STAT_CAP_INODE CEPH_CAP_PIN | |
790 | #define CEPH_STAT_CAP_TYPE CEPH_CAP_PIN /* mode >> 12 */ | |
791 | #define CEPH_STAT_CAP_SYMLINK CEPH_CAP_PIN | |
792 | #define CEPH_STAT_CAP_UID CEPH_CAP_AUTH_SHARED | |
793 | #define CEPH_STAT_CAP_GID CEPH_CAP_AUTH_SHARED | |
794 | #define CEPH_STAT_CAP_MODE CEPH_CAP_AUTH_SHARED | |
795 | #define CEPH_STAT_CAP_NLINK CEPH_CAP_LINK_SHARED | |
796 | #define CEPH_STAT_CAP_LAYOUT CEPH_CAP_FILE_SHARED | |
797 | #define CEPH_STAT_CAP_MTIME CEPH_CAP_FILE_SHARED | |
798 | #define CEPH_STAT_CAP_SIZE CEPH_CAP_FILE_SHARED | |
799 | #define CEPH_STAT_CAP_ATIME CEPH_CAP_FILE_SHARED /* fixme */ | |
800 | #define CEPH_STAT_CAP_XATTR CEPH_CAP_XATTR_SHARED | |
801 | #define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN | \ | |
802 | CEPH_CAP_AUTH_SHARED | \ | |
803 | CEPH_CAP_LINK_SHARED | \ | |
804 | CEPH_CAP_FILE_SHARED | \ | |
805 | CEPH_CAP_XATTR_SHARED) | |
806 | #define CEPH_STAT_CAP_INLINE_DATA (CEPH_CAP_FILE_SHARED | \ | |
807 | CEPH_CAP_FILE_RD) | |
28e407b8 | 808 | #define CEPH_STAT_RSTAT CEPH_CAP_FILE_WREXTEND |
7c673cae FG |
809 | |
810 | #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \ | |
811 | CEPH_CAP_LINK_SHARED | \ | |
812 | CEPH_CAP_XATTR_SHARED | \ | |
813 | CEPH_CAP_FILE_SHARED) | |
814 | #define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \ | |
815 | CEPH_CAP_FILE_CACHE) | |
816 | ||
817 | #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \ | |
818 | CEPH_CAP_LINK_EXCL | \ | |
819 | CEPH_CAP_XATTR_EXCL | \ | |
820 | CEPH_CAP_FILE_EXCL) | |
1adf2230 AA |
821 | #define CEPH_CAP_ANY_FILE_RD (CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE | \ |
822 | CEPH_CAP_FILE_SHARED) | |
7c673cae FG |
823 | #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \ |
824 | CEPH_CAP_FILE_EXCL) | |
825 | #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR) | |
826 | #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \ | |
827 | CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \ | |
828 | CEPH_CAP_PIN) | |
829 | ||
830 | #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \ | |
831 | CEPH_LOCK_IXATTR) | |
832 | ||
9f95a23c TL |
833 | /* cap masks async dir operations */ |
834 | #define CEPH_CAP_DIR_CREATE CEPH_CAP_FILE_CACHE | |
835 | #define CEPH_CAP_DIR_UNLINK CEPH_CAP_FILE_RD | |
836 | #define CEPH_CAP_ANY_DIR_OPS (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_RD | \ | |
837 | CEPH_CAP_FILE_WREXTEND | CEPH_CAP_FILE_LAZYIO) | |
838 | ||
839 | ||
7c673cae FG |
840 | int ceph_caps_for_mode(int mode); |
841 | ||
842 | enum { | |
843 | CEPH_CAP_OP_GRANT, /* mds->client grant */ | |
844 | CEPH_CAP_OP_REVOKE, /* mds->client revoke */ | |
845 | CEPH_CAP_OP_TRUNC, /* mds->client trunc notify */ | |
846 | CEPH_CAP_OP_EXPORT, /* mds has exported the cap */ | |
847 | CEPH_CAP_OP_IMPORT, /* mds has imported the cap */ | |
848 | CEPH_CAP_OP_UPDATE, /* client->mds update */ | |
849 | CEPH_CAP_OP_DROP, /* client->mds drop cap bits */ | |
850 | CEPH_CAP_OP_FLUSH, /* client->mds cap writeback */ | |
851 | CEPH_CAP_OP_FLUSH_ACK, /* mds->client flushed */ | |
852 | CEPH_CAP_OP_FLUSHSNAP, /* client->mds flush snapped metadata */ | |
853 | CEPH_CAP_OP_FLUSHSNAP_ACK, /* mds->client flushed snapped metadata */ | |
854 | CEPH_CAP_OP_RELEASE, /* client->mds release (clean) cap */ | |
855 | CEPH_CAP_OP_RENEW, /* client->mds renewal request */ | |
856 | }; | |
857 | ||
858 | extern const char *ceph_cap_op_name(int op); | |
859 | ||
860 | /* extra info for cap import/export */ | |
861 | struct ceph_mds_cap_peer { | |
862 | __le64 cap_id; | |
863 | __le32 seq; | |
864 | __le32 mseq; | |
865 | __le32 mds; | |
866 | __u8 flags; | |
867 | } __attribute__ ((packed)); | |
868 | ||
869 | /* | |
870 | * caps message, used for capability callbacks, acks, requests, etc. | |
871 | */ | |
872 | struct ceph_mds_caps_head { | |
873 | __le32 op; /* CEPH_CAP_OP_* */ | |
874 | __le64 ino, realm; | |
875 | __le64 cap_id; | |
876 | __le32 seq, issue_seq; | |
877 | __le32 caps, wanted, dirty; /* latest issued/wanted/dirty */ | |
878 | __le32 migrate_seq; | |
879 | __le64 snap_follows; | |
880 | __le32 snap_trace_len; | |
881 | ||
882 | /* authlock */ | |
883 | __le32 uid, gid, mode; | |
884 | ||
885 | /* linklock */ | |
886 | __le32 nlink; | |
887 | ||
888 | /* xattrlock */ | |
889 | __le32 xattr_len; | |
890 | __le64 xattr_version; | |
891 | } __attribute__ ((packed)); | |
892 | ||
f67539c2 TL |
893 | struct ceph_mds_caps_non_export_body { |
894 | /* all except export */ | |
895 | /* filelock */ | |
896 | __le64 size, max_size, truncate_size; | |
897 | __le32 truncate_seq; | |
898 | struct ceph_timespec mtime, atime, ctime; | |
899 | struct ceph_file_layout layout; | |
900 | __le32 time_warp_seq; | |
901 | } __attribute__ ((packed)); | |
902 | ||
903 | struct ceph_mds_caps_export_body { | |
904 | /* export message */ | |
905 | struct ceph_mds_cap_peer peer; | |
7c673cae FG |
906 | } __attribute__ ((packed)); |
907 | ||
908 | /* cap release msg head */ | |
909 | struct ceph_mds_cap_release { | |
910 | __le32 num; /* number of cap_items that follow */ | |
911 | } __attribute__ ((packed)); | |
912 | ||
913 | struct ceph_mds_cap_item { | |
914 | __le64 ino; | |
915 | __le64 cap_id; | |
916 | __le32 migrate_seq, seq; | |
917 | } __attribute__ ((packed)); | |
918 | ||
919 | #define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */ | |
920 | #define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */ | |
921 | #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */ | |
922 | #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */ | |
923 | ||
924 | extern const char *ceph_lease_op_name(int o); | |
925 | ||
926 | /* lease msg header */ | |
927 | struct ceph_mds_lease { | |
928 | __u8 action; /* CEPH_MDS_LEASE_* */ | |
929 | __le16 mask; /* which lease */ | |
930 | __le64 ino; | |
931 | __le64 first, last; /* snap range */ | |
932 | __le32 seq; | |
933 | __le32 duration_ms; /* duration of renewal */ | |
934 | } __attribute__ ((packed)); | |
935 | /* followed by a __le32+string for dname */ | |
936 | ||
937 | /* client reconnect */ | |
938 | struct ceph_mds_cap_reconnect { | |
939 | __le64 cap_id; | |
940 | __le32 wanted; | |
941 | __le32 issued; | |
942 | __le64 snaprealm; | |
943 | __le64 pathbase; /* base ino for our path to this ino */ | |
944 | __le32 flock_len; /* size of flock state blob, if any */ | |
945 | } __attribute__ ((packed)); | |
946 | /* followed by flock blob */ | |
947 | ||
948 | struct ceph_mds_cap_reconnect_v1 { | |
949 | __le64 cap_id; | |
950 | __le32 wanted; | |
951 | __le32 issued; | |
952 | __le64 size; | |
953 | struct ceph_timespec mtime, atime; | |
954 | __le64 snaprealm; | |
955 | __le64 pathbase; /* base ino for our path to this ino */ | |
956 | } __attribute__ ((packed)); | |
957 | ||
958 | struct ceph_mds_snaprealm_reconnect { | |
959 | __le64 ino; /* snap realm base */ | |
960 | __le64 seq; /* snap seq for this snap realm */ | |
961 | __le64 parent; /* parent realm */ | |
962 | } __attribute__ ((packed)); | |
963 | ||
964 | /* | |
965 | * snaps | |
966 | */ | |
967 | enum { | |
968 | CEPH_SNAP_OP_UPDATE, /* CREATE or DESTROY */ | |
969 | CEPH_SNAP_OP_CREATE, | |
970 | CEPH_SNAP_OP_DESTROY, | |
971 | CEPH_SNAP_OP_SPLIT, | |
972 | }; | |
973 | ||
974 | extern const char *ceph_snap_op_name(int o); | |
975 | ||
976 | /* snap msg header */ | |
977 | struct ceph_mds_snap_head { | |
978 | __le32 op; /* CEPH_SNAP_OP_* */ | |
979 | __le64 split; /* ino to split off, if any */ | |
980 | __le32 num_split_inos; /* # inos belonging to new child realm */ | |
981 | __le32 num_split_realms; /* # child realms udner new child realm */ | |
982 | __le32 trace_len; /* size of snap trace blob */ | |
983 | } __attribute__ ((packed)); | |
984 | /* followed by split ino list, then split realms, then the trace blob */ | |
985 | ||
986 | /* | |
987 | * encode info about a snaprealm, as viewed by a client | |
988 | */ | |
989 | struct ceph_mds_snap_realm { | |
990 | __le64 ino; /* ino */ | |
991 | __le64 created; /* snap: when created */ | |
992 | __le64 parent; /* ino: parent realm */ | |
993 | __le64 parent_since; /* snap: same parent since */ | |
994 | __le64 seq; /* snap: version */ | |
995 | __le32 num_snaps; | |
996 | __le32 num_prior_parent_snaps; | |
997 | } __attribute__ ((packed)); | |
998 | /* followed by my snap list, then prior parent snap list */ | |
999 | ||
eafe8130 TL |
1000 | #ifndef __KERNEL__ |
1001 | #undef __le16 | |
1002 | #undef __le32 | |
1003 | #undef __le64 | |
1004 | #endif | |
1005 | ||
7c673cae | 1006 | #endif |