Commit | Line | Data |
---|---|---|
0dee3c28 SW |
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 | * | |
9 | * LGPL2 | |
10 | */ | |
11 | ||
12 | #ifndef _FS_CEPH_CEPH_FS_H | |
13 | #define _FS_CEPH_CEPH_FS_H | |
14 | ||
15 | #include "msgr.h" | |
16 | #include "rados.h" | |
17 | ||
18 | /* | |
19 | * Ceph release version | |
20 | */ | |
21 | #define CEPH_VERSION_MAJOR 0 | |
bb097ffa SW |
22 | #define CEPH_VERSION_MINOR 17 |
23 | #define CEPH_VERSION_PATCH 0 | |
0dee3c28 SW |
24 | |
25 | #define _CEPH_STRINGIFY(x) #x | |
26 | #define CEPH_STRINGIFY(x) _CEPH_STRINGIFY(x) | |
27 | #define CEPH_MAKE_VERSION(x, y, z) CEPH_STRINGIFY(x) "." CEPH_STRINGIFY(y) \ | |
28 | "." CEPH_STRINGIFY(z) | |
29 | #define CEPH_VERSION CEPH_MAKE_VERSION(CEPH_VERSION_MAJOR, \ | |
30 | CEPH_VERSION_MINOR, CEPH_VERSION_PATCH) | |
31 | ||
32 | /* | |
33 | * subprotocol versions. when specific messages types or high-level | |
34 | * protocols change, bump the affected components. we keep rev | |
35 | * internal cluster protocols separately from the public, | |
36 | * client-facing protocol. | |
37 | */ | |
38 | #define CEPH_OSD_PROTOCOL 7 /* cluster internal */ | |
39 | #define CEPH_MDS_PROTOCOL 9 /* cluster internal */ | |
13e38c8a | 40 | #define CEPH_MON_PROTOCOL 5 /* cluster internal */ |
cfbbcd24 | 41 | #define CEPH_OSDC_PROTOCOL 22 /* server/client */ |
94045e11 | 42 | #define CEPH_MDSC_PROTOCOL 30 /* server/client */ |
13e38c8a | 43 | #define CEPH_MONC_PROTOCOL 15 /* server/client */ |
0dee3c28 SW |
44 | |
45 | ||
46 | #define CEPH_INO_ROOT 1 | |
47 | ||
48 | /* arbitrary limit on max # of monitors (cluster of 3 is typical) */ | |
49 | #define CEPH_MAX_MON 31 | |
50 | ||
51 | ||
0dee3c28 SW |
52 | |
53 | /* | |
54 | * ceph_file_layout - describe data layout for a file/inode | |
55 | */ | |
56 | struct ceph_file_layout { | |
57 | /* file -> object mapping */ | |
58 | __le32 fl_stripe_unit; /* stripe unit, in bytes. must be multiple | |
59 | of page size. */ | |
60 | __le32 fl_stripe_count; /* over this many objects */ | |
61 | __le32 fl_object_size; /* until objects are this big, then move to | |
62 | new objects */ | |
63 | __le32 fl_cas_hash; /* 0 = none; 1 = sha256 */ | |
64 | ||
65 | /* pg -> disk layout */ | |
66 | __le32 fl_object_stripe_unit; /* for per-object parity, if any */ | |
67 | ||
68 | /* object -> pg layout */ | |
69 | __le32 fl_pg_preferred; /* preferred primary for pg (-1 for none) */ | |
70 | __le32 fl_pg_pool; /* namespace, crush ruleset, rep level */ | |
71 | } __attribute__ ((packed)); | |
72 | ||
752727a1 | 73 | #define CEPH_MIN_STRIPE_UNIT 65536 |
0dee3c28 | 74 | |
752727a1 | 75 | int ceph_file_layout_is_valid(const struct ceph_file_layout *layout); |
0dee3c28 SW |
76 | |
77 | ||
4e7a5dcd SW |
78 | /* crypto algorithms */ |
79 | #define CEPH_CRYPTO_NONE 0x0 | |
80 | #define CEPH_CRYPTO_AES 0x1 | |
81 | ||
82 | /* security/authentication protocols */ | |
83 | #define CEPH_AUTH_UNKNOWN 0x0 | |
84 | #define CEPH_AUTH_NONE 0x1 | |
85 | #define CEPH_AUTH_CEPHX 0x2 | |
86 | ||
87 | ||
0dee3c28 SW |
88 | /********************************************* |
89 | * message layer | |
90 | */ | |
91 | ||
92 | /* | |
93 | * message types | |
94 | */ | |
95 | ||
96 | /* misc */ | |
97 | #define CEPH_MSG_SHUTDOWN 1 | |
98 | #define CEPH_MSG_PING 2 | |
99 | ||
100 | /* client <-> monitor */ | |
101 | #define CEPH_MSG_MON_MAP 4 | |
102 | #define CEPH_MSG_MON_GET_MAP 5 | |
0dee3c28 SW |
103 | #define CEPH_MSG_STATFS 13 |
104 | #define CEPH_MSG_STATFS_REPLY 14 | |
105 | #define CEPH_MSG_MON_SUBSCRIBE 15 | |
106 | #define CEPH_MSG_MON_SUBSCRIBE_ACK 16 | |
4e7a5dcd SW |
107 | #define CEPH_MSG_AUTH 17 |
108 | #define CEPH_MSG_AUTH_REPLY 18 | |
0dee3c28 SW |
109 | |
110 | /* client <-> mds */ | |
0dee3c28 SW |
111 | #define CEPH_MSG_MDS_MAP 21 |
112 | ||
113 | #define CEPH_MSG_CLIENT_SESSION 22 | |
114 | #define CEPH_MSG_CLIENT_RECONNECT 23 | |
115 | ||
116 | #define CEPH_MSG_CLIENT_REQUEST 24 | |
117 | #define CEPH_MSG_CLIENT_REQUEST_FORWARD 25 | |
118 | #define CEPH_MSG_CLIENT_REPLY 26 | |
119 | #define CEPH_MSG_CLIENT_CAPS 0x310 | |
120 | #define CEPH_MSG_CLIENT_LEASE 0x311 | |
121 | #define CEPH_MSG_CLIENT_SNAP 0x312 | |
122 | #define CEPH_MSG_CLIENT_CAPRELEASE 0x313 | |
123 | ||
124 | /* osd */ | |
0dee3c28 SW |
125 | #define CEPH_MSG_OSD_MAP 41 |
126 | #define CEPH_MSG_OSD_OP 42 | |
127 | #define CEPH_MSG_OSD_OPREPLY 43 | |
128 | ||
13e38c8a SW |
129 | struct ceph_mon_request_header { |
130 | __le64 have_version; | |
131 | __le16 session_mon; | |
132 | __le64 session_mon_tid; | |
133 | } __attribute__ ((packed)); | |
0dee3c28 SW |
134 | |
135 | struct ceph_mon_statfs { | |
13e38c8a | 136 | struct ceph_mon_request_header monhdr; |
0dee3c28 SW |
137 | struct ceph_fsid fsid; |
138 | __le64 tid; | |
139 | } __attribute__ ((packed)); | |
140 | ||
141 | struct ceph_statfs { | |
142 | __le64 kb, kb_used, kb_avail; | |
143 | __le64 num_objects; | |
144 | } __attribute__ ((packed)); | |
145 | ||
146 | struct ceph_mon_statfs_reply { | |
147 | struct ceph_fsid fsid; | |
148 | __le64 tid; | |
149 | __le64 version; | |
150 | struct ceph_statfs st; | |
151 | } __attribute__ ((packed)); | |
152 | ||
153 | struct ceph_osd_getmap { | |
13e38c8a | 154 | struct ceph_mon_request_header monhdr; |
0dee3c28 SW |
155 | struct ceph_fsid fsid; |
156 | __le32 start; | |
157 | } __attribute__ ((packed)); | |
158 | ||
159 | struct ceph_mds_getmap { | |
13e38c8a | 160 | struct ceph_mon_request_header monhdr; |
0dee3c28 SW |
161 | struct ceph_fsid fsid; |
162 | } __attribute__ ((packed)); | |
163 | ||
164 | struct ceph_client_mount { | |
13e38c8a | 165 | struct ceph_mon_request_header monhdr; |
0dee3c28 SW |
166 | } __attribute__ ((packed)); |
167 | ||
168 | struct ceph_mon_subscribe_item { | |
13e38c8a | 169 | __le64 have_version; __le64 have; |
0dee3c28 SW |
170 | __u8 onetime; |
171 | } __attribute__ ((packed)); | |
172 | ||
07bd10fb SW |
173 | struct ceph_mon_subscribe_ack { |
174 | __le32 duration; /* seconds */ | |
175 | struct ceph_fsid fsid; | |
176 | } __attribute__ ((packed)); | |
177 | ||
0dee3c28 SW |
178 | /* |
179 | * mds states | |
180 | * > 0 -> in | |
181 | * <= 0 -> out | |
182 | */ | |
183 | #define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */ | |
184 | #define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees. | |
185 | empty log. */ | |
186 | #define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */ | |
187 | #define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */ | |
188 | #define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */ | |
189 | #define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */ | |
190 | #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */ | |
191 | ||
192 | #define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */ | |
193 | #define CEPH_MDS_STATE_RESOLVE 9 /* up, disambiguating distributed | |
194 | operations (import, rename, etc.) */ | |
195 | #define CEPH_MDS_STATE_RECONNECT 10 /* up, reconnect to clients */ | |
196 | #define CEPH_MDS_STATE_REJOIN 11 /* up, rejoining distributed cache */ | |
197 | #define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */ | |
198 | #define CEPH_MDS_STATE_ACTIVE 13 /* up, active */ | |
199 | #define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */ | |
200 | ||
201 | extern const char *ceph_mds_state_name(int s); | |
202 | ||
203 | ||
204 | /* | |
205 | * metadata lock types. | |
206 | * - these are bitmasks.. we can compose them | |
207 | * - they also define the lock ordering by the MDS | |
208 | * - a few of these are internal to the mds | |
209 | */ | |
210 | #define CEPH_LOCK_DN 1 | |
211 | #define CEPH_LOCK_ISNAP 2 | |
212 | #define CEPH_LOCK_IVERSION 4 /* mds internal */ | |
213 | #define CEPH_LOCK_IFILE 8 /* mds internal */ | |
214 | #define CEPH_LOCK_IAUTH 32 | |
215 | #define CEPH_LOCK_ILINK 64 | |
216 | #define CEPH_LOCK_IDFT 128 /* dir frag tree */ | |
217 | #define CEPH_LOCK_INEST 256 /* mds internal */ | |
218 | #define CEPH_LOCK_IXATTR 512 | |
219 | #define CEPH_LOCK_INO 2048 /* immutable inode bits; not a lock */ | |
220 | ||
221 | /* client_session ops */ | |
222 | enum { | |
223 | CEPH_SESSION_REQUEST_OPEN, | |
224 | CEPH_SESSION_OPEN, | |
225 | CEPH_SESSION_REQUEST_CLOSE, | |
226 | CEPH_SESSION_CLOSE, | |
227 | CEPH_SESSION_REQUEST_RENEWCAPS, | |
228 | CEPH_SESSION_RENEWCAPS, | |
229 | CEPH_SESSION_STALE, | |
230 | CEPH_SESSION_RECALL_STATE, | |
231 | }; | |
232 | ||
233 | extern const char *ceph_session_op_name(int op); | |
234 | ||
235 | struct ceph_mds_session_head { | |
236 | __le32 op; | |
237 | __le64 seq; | |
238 | struct ceph_timespec stamp; | |
239 | __le32 max_caps, max_leases; | |
240 | } __attribute__ ((packed)); | |
241 | ||
242 | /* client_request */ | |
243 | /* | |
244 | * metadata ops. | |
245 | * & 0x001000 -> write op | |
246 | * & 0x010000 -> follow symlink (e.g. stat(), not lstat()). | |
247 | & & 0x100000 -> use weird ino/path trace | |
248 | */ | |
249 | #define CEPH_MDS_OP_WRITE 0x001000 | |
250 | enum { | |
251 | CEPH_MDS_OP_LOOKUP = 0x00100, | |
252 | CEPH_MDS_OP_GETATTR = 0x00101, | |
253 | CEPH_MDS_OP_LOOKUPHASH = 0x00102, | |
254 | CEPH_MDS_OP_LOOKUPPARENT = 0x00103, | |
255 | ||
256 | CEPH_MDS_OP_SETXATTR = 0x01105, | |
257 | CEPH_MDS_OP_RMXATTR = 0x01106, | |
258 | CEPH_MDS_OP_SETLAYOUT = 0x01107, | |
259 | CEPH_MDS_OP_SETATTR = 0x01108, | |
260 | ||
261 | CEPH_MDS_OP_MKNOD = 0x01201, | |
262 | CEPH_MDS_OP_LINK = 0x01202, | |
263 | CEPH_MDS_OP_UNLINK = 0x01203, | |
264 | CEPH_MDS_OP_RENAME = 0x01204, | |
265 | CEPH_MDS_OP_MKDIR = 0x01220, | |
266 | CEPH_MDS_OP_RMDIR = 0x01221, | |
267 | CEPH_MDS_OP_SYMLINK = 0x01222, | |
268 | ||
269 | CEPH_MDS_OP_CREATE = 0x00301, | |
270 | CEPH_MDS_OP_OPEN = 0x00302, | |
271 | CEPH_MDS_OP_READDIR = 0x00305, | |
272 | ||
273 | CEPH_MDS_OP_LOOKUPSNAP = 0x00400, | |
274 | CEPH_MDS_OP_MKSNAP = 0x01400, | |
275 | CEPH_MDS_OP_RMSNAP = 0x01401, | |
276 | CEPH_MDS_OP_LSSNAP = 0x00402, | |
277 | }; | |
278 | ||
279 | extern const char *ceph_mds_op_name(int op); | |
280 | ||
281 | ||
282 | #define CEPH_SETATTR_MODE 1 | |
283 | #define CEPH_SETATTR_UID 2 | |
284 | #define CEPH_SETATTR_GID 4 | |
285 | #define CEPH_SETATTR_MTIME 8 | |
286 | #define CEPH_SETATTR_ATIME 16 | |
287 | #define CEPH_SETATTR_SIZE 32 | |
288 | #define CEPH_SETATTR_CTIME 64 | |
289 | ||
290 | union ceph_mds_request_args { | |
291 | struct { | |
292 | __le32 mask; /* CEPH_CAP_* */ | |
293 | } __attribute__ ((packed)) getattr; | |
294 | struct { | |
295 | __le32 mode; | |
296 | __le32 uid; | |
297 | __le32 gid; | |
298 | struct ceph_timespec mtime; | |
299 | struct ceph_timespec atime; | |
300 | __le64 size, old_size; /* old_size needed by truncate */ | |
301 | __le32 mask; /* CEPH_SETATTR_* */ | |
302 | } __attribute__ ((packed)) setattr; | |
303 | struct { | |
304 | __le32 frag; /* which dir fragment */ | |
305 | __le32 max_entries; /* how many dentries to grab */ | |
306 | } __attribute__ ((packed)) readdir; | |
307 | struct { | |
308 | __le32 mode; | |
309 | __le32 rdev; | |
310 | } __attribute__ ((packed)) mknod; | |
311 | struct { | |
312 | __le32 mode; | |
313 | } __attribute__ ((packed)) mkdir; | |
314 | struct { | |
315 | __le32 flags; | |
316 | __le32 mode; | |
317 | __le32 stripe_unit; /* layout for newly created file */ | |
318 | __le32 stripe_count; /* ... */ | |
319 | __le32 object_size; | |
320 | __le32 file_replication; | |
321 | __le32 preferred; | |
322 | } __attribute__ ((packed)) open; | |
323 | struct { | |
324 | __le32 flags; | |
325 | } __attribute__ ((packed)) setxattr; | |
326 | struct { | |
327 | struct ceph_file_layout layout; | |
328 | } __attribute__ ((packed)) setlayout; | |
329 | } __attribute__ ((packed)); | |
330 | ||
331 | #define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */ | |
332 | #define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */ | |
333 | ||
334 | struct ceph_mds_request_head { | |
335 | __le64 tid, oldest_client_tid; | |
336 | __le32 mdsmap_epoch; /* on client */ | |
337 | __le32 flags; /* CEPH_MDS_FLAG_* */ | |
338 | __u8 num_retry, num_fwd; /* count retry, fwd attempts */ | |
339 | __le16 num_releases; /* # include cap/lease release records */ | |
340 | __le32 op; /* mds op code */ | |
341 | __le32 caller_uid, caller_gid; | |
342 | __le64 ino; /* use this ino for openc, mkdir, mknod, | |
343 | etc. (if replaying) */ | |
344 | union ceph_mds_request_args args; | |
345 | } __attribute__ ((packed)); | |
346 | ||
347 | /* cap/lease release record */ | |
348 | struct ceph_mds_request_release { | |
349 | __le64 ino, cap_id; /* ino and unique cap id */ | |
350 | __le32 caps, wanted; /* new issued, wanted */ | |
351 | __le32 seq, issue_seq, mseq; | |
352 | __le32 dname_seq; /* if releasing a dentry lease, a */ | |
353 | __le32 dname_len; /* string follows. */ | |
354 | } __attribute__ ((packed)); | |
355 | ||
356 | /* client reply */ | |
357 | struct ceph_mds_reply_head { | |
358 | __le64 tid; | |
359 | __le32 op; | |
360 | __le32 result; | |
361 | __le32 mdsmap_epoch; | |
362 | __u8 safe; /* true if committed to disk */ | |
363 | __u8 is_dentry, is_target; /* true if dentry, target inode records | |
364 | are included with reply */ | |
365 | } __attribute__ ((packed)); | |
366 | ||
367 | /* one for each node split */ | |
368 | struct ceph_frag_tree_split { | |
369 | __le32 frag; /* this frag splits... */ | |
370 | __le32 by; /* ...by this many bits */ | |
371 | } __attribute__ ((packed)); | |
372 | ||
373 | struct ceph_frag_tree_head { | |
374 | __le32 nsplits; /* num ceph_frag_tree_split records */ | |
375 | struct ceph_frag_tree_split splits[]; | |
376 | } __attribute__ ((packed)); | |
377 | ||
378 | /* capability issue, for bundling with mds reply */ | |
379 | struct ceph_mds_reply_cap { | |
380 | __le32 caps, wanted; /* caps issued, wanted */ | |
381 | __le64 cap_id; | |
382 | __le32 seq, mseq; | |
383 | __le64 realm; /* snap realm */ | |
384 | __u8 flags; /* CEPH_CAP_FLAG_* */ | |
385 | } __attribute__ ((packed)); | |
386 | ||
387 | #define CEPH_CAP_FLAG_AUTH 1 /* cap is issued by auth mds */ | |
388 | ||
389 | /* inode record, for bundling with mds reply */ | |
390 | struct ceph_mds_reply_inode { | |
391 | __le64 ino; | |
392 | __le64 snapid; | |
393 | __le32 rdev; | |
394 | __le64 version; /* inode version */ | |
395 | __le64 xattr_version; /* version for xattr blob */ | |
396 | struct ceph_mds_reply_cap cap; /* caps issued for this inode */ | |
397 | struct ceph_file_layout layout; | |
398 | struct ceph_timespec ctime, mtime, atime; | |
399 | __le32 time_warp_seq; | |
400 | __le64 size, max_size, truncate_size; | |
401 | __le32 truncate_seq; | |
402 | __le32 mode, uid, gid; | |
403 | __le32 nlink; | |
404 | __le64 files, subdirs, rbytes, rfiles, rsubdirs; /* dir stats */ | |
405 | struct ceph_timespec rctime; | |
406 | struct ceph_frag_tree_head fragtree; /* (must be at end of struct) */ | |
407 | } __attribute__ ((packed)); | |
408 | /* followed by frag array, then symlink string, then xattr blob */ | |
409 | ||
410 | /* reply_lease follows dname, and reply_inode */ | |
411 | struct ceph_mds_reply_lease { | |
412 | __le16 mask; /* lease type(s) */ | |
413 | __le32 duration_ms; /* lease duration */ | |
414 | __le32 seq; | |
415 | } __attribute__ ((packed)); | |
416 | ||
417 | struct ceph_mds_reply_dirfrag { | |
418 | __le32 frag; /* fragment */ | |
419 | __le32 auth; /* auth mds, if this is a delegation point */ | |
420 | __le32 ndist; /* number of mds' this is replicated on */ | |
421 | __le32 dist[]; | |
422 | } __attribute__ ((packed)); | |
423 | ||
424 | /* file access modes */ | |
425 | #define CEPH_FILE_MODE_PIN 0 | |
426 | #define CEPH_FILE_MODE_RD 1 | |
427 | #define CEPH_FILE_MODE_WR 2 | |
428 | #define CEPH_FILE_MODE_RDWR 3 /* RD | WR */ | |
429 | #define CEPH_FILE_MODE_LAZY 4 /* lazy io */ | |
430 | #define CEPH_FILE_MODE_NUM 8 /* bc these are bit fields.. mostly */ | |
431 | ||
432 | int ceph_flags_to_mode(int flags); | |
433 | ||
434 | ||
435 | /* capability bits */ | |
436 | #define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */ | |
437 | ||
438 | /* generic cap bits */ | |
439 | #define CEPH_CAP_GSHARED 1 /* client can reads */ | |
440 | #define CEPH_CAP_GEXCL 2 /* client can read and update */ | |
441 | #define CEPH_CAP_GCACHE 4 /* (file) client can cache reads */ | |
442 | #define CEPH_CAP_GRD 8 /* (file) client can read */ | |
443 | #define CEPH_CAP_GWR 16 /* (file) client can write */ | |
444 | #define CEPH_CAP_GBUFFER 32 /* (file) client can buffer writes */ | |
445 | #define CEPH_CAP_GWREXTEND 64 /* (file) client can extend EOF */ | |
446 | #define CEPH_CAP_GLAZYIO 128 /* (file) client can perform lazy io */ | |
447 | ||
448 | /* per-lock shift */ | |
449 | #define CEPH_CAP_SAUTH 2 | |
450 | #define CEPH_CAP_SLINK 4 | |
451 | #define CEPH_CAP_SXATTR 6 | |
452 | #define CEPH_CAP_SFILE 8 /* goes at the end (uses >2 cap bits) */ | |
453 | ||
454 | #define CEPH_CAP_BITS 16 | |
455 | ||
456 | /* composed values */ | |
457 | #define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH) | |
458 | #define CEPH_CAP_AUTH_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SAUTH) | |
459 | #define CEPH_CAP_LINK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SLINK) | |
460 | #define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK) | |
461 | #define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SXATTR) | |
462 | #define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR) | |
463 | #define CEPH_CAP_FILE(x) (x << CEPH_CAP_SFILE) | |
464 | #define CEPH_CAP_FILE_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFILE) | |
465 | #define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE) | |
466 | #define CEPH_CAP_FILE_CACHE (CEPH_CAP_GCACHE << CEPH_CAP_SFILE) | |
467 | #define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE) | |
468 | #define CEPH_CAP_FILE_WR (CEPH_CAP_GWR << CEPH_CAP_SFILE) | |
469 | #define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE) | |
470 | #define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE) | |
471 | #define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE) | |
472 | ||
473 | /* cap masks (for getattr) */ | |
474 | #define CEPH_STAT_CAP_INODE CEPH_CAP_PIN | |
475 | #define CEPH_STAT_CAP_TYPE CEPH_CAP_PIN /* mode >> 12 */ | |
476 | #define CEPH_STAT_CAP_SYMLINK CEPH_CAP_PIN | |
477 | #define CEPH_STAT_CAP_UID CEPH_CAP_AUTH_SHARED | |
478 | #define CEPH_STAT_CAP_GID CEPH_CAP_AUTH_SHARED | |
479 | #define CEPH_STAT_CAP_MODE CEPH_CAP_AUTH_SHARED | |
480 | #define CEPH_STAT_CAP_NLINK CEPH_CAP_LINK_SHARED | |
481 | #define CEPH_STAT_CAP_LAYOUT CEPH_CAP_FILE_SHARED | |
482 | #define CEPH_STAT_CAP_MTIME CEPH_CAP_FILE_SHARED | |
483 | #define CEPH_STAT_CAP_SIZE CEPH_CAP_FILE_SHARED | |
484 | #define CEPH_STAT_CAP_ATIME CEPH_CAP_FILE_SHARED /* fixme */ | |
485 | #define CEPH_STAT_CAP_XATTR CEPH_CAP_XATTR_SHARED | |
486 | #define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN | \ | |
487 | CEPH_CAP_AUTH_SHARED | \ | |
488 | CEPH_CAP_LINK_SHARED | \ | |
489 | CEPH_CAP_FILE_SHARED | \ | |
490 | CEPH_CAP_XATTR_SHARED) | |
491 | ||
492 | #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \ | |
493 | CEPH_CAP_LINK_SHARED | \ | |
494 | CEPH_CAP_XATTR_SHARED | \ | |
495 | CEPH_CAP_FILE_SHARED) | |
496 | #define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \ | |
497 | CEPH_CAP_FILE_CACHE) | |
498 | ||
499 | #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \ | |
500 | CEPH_CAP_LINK_EXCL | \ | |
501 | CEPH_CAP_XATTR_EXCL | \ | |
502 | CEPH_CAP_FILE_EXCL) | |
503 | #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \ | |
504 | CEPH_CAP_FILE_EXCL) | |
505 | #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR) | |
506 | #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \ | |
507 | CEPH_CAP_ANY_FILE_WR | CEPH_CAP_PIN) | |
508 | ||
509 | #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \ | |
510 | CEPH_LOCK_IXATTR) | |
511 | ||
512 | int ceph_caps_for_mode(int mode); | |
513 | ||
514 | enum { | |
515 | CEPH_CAP_OP_GRANT, /* mds->client grant */ | |
516 | CEPH_CAP_OP_REVOKE, /* mds->client revoke */ | |
517 | CEPH_CAP_OP_TRUNC, /* mds->client trunc notify */ | |
518 | CEPH_CAP_OP_EXPORT, /* mds has exported the cap */ | |
519 | CEPH_CAP_OP_IMPORT, /* mds has imported the cap */ | |
520 | CEPH_CAP_OP_UPDATE, /* client->mds update */ | |
521 | CEPH_CAP_OP_DROP, /* client->mds drop cap bits */ | |
522 | CEPH_CAP_OP_FLUSH, /* client->mds cap writeback */ | |
523 | CEPH_CAP_OP_FLUSH_ACK, /* mds->client flushed */ | |
524 | CEPH_CAP_OP_FLUSHSNAP, /* client->mds flush snapped metadata */ | |
525 | CEPH_CAP_OP_FLUSHSNAP_ACK, /* mds->client flushed snapped metadata */ | |
526 | CEPH_CAP_OP_RELEASE, /* client->mds release (clean) cap */ | |
527 | CEPH_CAP_OP_RENEW, /* client->mds renewal request */ | |
528 | }; | |
529 | ||
530 | extern const char *ceph_cap_op_name(int op); | |
531 | ||
532 | /* | |
533 | * caps message, used for capability callbacks, acks, requests, etc. | |
534 | */ | |
535 | struct ceph_mds_caps { | |
536 | __le32 op; /* CEPH_CAP_OP_* */ | |
537 | __le64 ino, realm; | |
538 | __le64 cap_id; | |
539 | __le32 seq, issue_seq; | |
540 | __le32 caps, wanted, dirty; /* latest issued/wanted/dirty */ | |
541 | __le32 migrate_seq; | |
542 | __le64 snap_follows; | |
543 | __le32 snap_trace_len; | |
544 | __le64 client_tid; /* for FLUSH(SNAP) -> FLUSH(SNAP)_ACK */ | |
545 | ||
546 | /* authlock */ | |
547 | __le32 uid, gid, mode; | |
548 | ||
549 | /* linklock */ | |
550 | __le32 nlink; | |
551 | ||
552 | /* xattrlock */ | |
553 | __le32 xattr_len; | |
554 | __le64 xattr_version; | |
555 | ||
556 | /* filelock */ | |
557 | __le64 size, max_size, truncate_size; | |
558 | __le32 truncate_seq; | |
559 | struct ceph_timespec mtime, atime, ctime; | |
560 | struct ceph_file_layout layout; | |
561 | __le32 time_warp_seq; | |
562 | } __attribute__ ((packed)); | |
563 | ||
564 | /* cap release msg head */ | |
565 | struct ceph_mds_cap_release { | |
566 | __le32 num; /* number of cap_items that follow */ | |
567 | } __attribute__ ((packed)); | |
568 | ||
569 | struct ceph_mds_cap_item { | |
570 | __le64 ino; | |
571 | __le64 cap_id; | |
572 | __le32 migrate_seq, seq; | |
573 | } __attribute__ ((packed)); | |
574 | ||
575 | #define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */ | |
576 | #define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */ | |
577 | #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */ | |
578 | #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */ | |
579 | ||
580 | extern const char *ceph_lease_op_name(int o); | |
581 | ||
582 | /* lease msg header */ | |
583 | struct ceph_mds_lease { | |
584 | __u8 action; /* CEPH_MDS_LEASE_* */ | |
585 | __le16 mask; /* which lease */ | |
586 | __le64 ino; | |
587 | __le64 first, last; /* snap range */ | |
588 | __le32 seq; | |
589 | __le32 duration_ms; /* duration of renewal */ | |
590 | } __attribute__ ((packed)); | |
591 | /* followed by a __le32+string for dname */ | |
592 | ||
593 | /* client reconnect */ | |
594 | struct ceph_mds_cap_reconnect { | |
595 | __le64 cap_id; | |
596 | __le32 wanted; | |
597 | __le32 issued; | |
598 | __le64 size; | |
599 | struct ceph_timespec mtime, atime; | |
600 | __le64 snaprealm; | |
601 | __le64 pathbase; /* base ino for our path to this ino */ | |
602 | } __attribute__ ((packed)); | |
603 | /* followed by encoded string */ | |
604 | ||
605 | struct ceph_mds_snaprealm_reconnect { | |
606 | __le64 ino; /* snap realm base */ | |
607 | __le64 seq; /* snap seq for this snap realm */ | |
608 | __le64 parent; /* parent realm */ | |
609 | } __attribute__ ((packed)); | |
610 | ||
611 | /* | |
612 | * snaps | |
613 | */ | |
614 | enum { | |
615 | CEPH_SNAP_OP_UPDATE, /* CREATE or DESTROY */ | |
616 | CEPH_SNAP_OP_CREATE, | |
617 | CEPH_SNAP_OP_DESTROY, | |
618 | CEPH_SNAP_OP_SPLIT, | |
619 | }; | |
620 | ||
621 | extern const char *ceph_snap_op_name(int o); | |
622 | ||
623 | /* snap msg header */ | |
624 | struct ceph_mds_snap_head { | |
625 | __le32 op; /* CEPH_SNAP_OP_* */ | |
626 | __le64 split; /* ino to split off, if any */ | |
627 | __le32 num_split_inos; /* # inos belonging to new child realm */ | |
628 | __le32 num_split_realms; /* # child realms udner new child realm */ | |
629 | __le32 trace_len; /* size of snap trace blob */ | |
630 | } __attribute__ ((packed)); | |
631 | /* followed by split ino list, then split realms, then the trace blob */ | |
632 | ||
633 | /* | |
634 | * encode info about a snaprealm, as viewed by a client | |
635 | */ | |
636 | struct ceph_mds_snap_realm { | |
637 | __le64 ino; /* ino */ | |
638 | __le64 created; /* snap: when created */ | |
639 | __le64 parent; /* ino: parent realm */ | |
640 | __le64 parent_since; /* snap: same parent since */ | |
641 | __le64 seq; /* snap: version */ | |
642 | __le32 num_snaps; | |
643 | __le32 num_prior_parent_snaps; | |
644 | } __attribute__ ((packed)); | |
645 | /* followed by my snap list, then prior parent snap list */ | |
646 | ||
647 | #endif |