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