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