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