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