]> git.proxmox.com Git - ceph.git/blob - ceph/src/include/ceph_fs.h
update sources to 12.2.7
[ceph.git] / ceph / src / include / ceph_fs.h
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 CEPH_FS_H
13 #define CEPH_FS_H
14
15 #include "msgr.h"
16 #include "rados.h"
17
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 */
24 #define CEPH_OSDC_PROTOCOL 24 /* server/client */
25 #define CEPH_MDSC_PROTOCOL 32 /* server/client */
26 #define CEPH_MONC_PROTOCOL 15 /* server/client */
27
28
29 #define CEPH_INO_ROOT 1
30 #define CEPH_INO_CEPH 2 /* hidden .ceph dir */
31 #define CEPH_INO_LOST_AND_FOUND 4 /* reserved ino for use in recovery */
32
33 /* arbitrary limit on max # of monitors (cluster of 3 is typical) */
34 #define CEPH_MAX_MON 31
35
36 /*
37 * ceph_file_layout - describe data layout for a file/inode
38 */
39 struct ceph_file_layout {
40 /* file -> object mapping */
41 __le32 fl_stripe_unit; /* stripe unit, in bytes. must be multiple
42 of page size. */
43 __le32 fl_stripe_count; /* over this many objects */
44 __le32 fl_object_size; /* until objects are this big, then move to
45 new objects */
46 __le32 fl_cas_hash; /* UNUSED. 0 = none; 1 = sha256 */
47
48 /* pg -> disk layout */
49 __le32 fl_object_stripe_unit; /* UNUSED. for per-object parity, if any */
50
51 /* object -> pg layout */
52 __le32 fl_unused; /* unused; used to be preferred primary for pg (-1 for none) */
53 __le32 fl_pg_pool; /* namespace, crush ruleset, rep level */
54 } __attribute__ ((packed));
55
56 #define CEPH_MIN_STRIPE_UNIT 65536
57
58 struct ceph_dir_layout {
59 __u8 dl_dir_hash; /* see ceph_hash.h for ids */
60 __u8 dl_unused1;
61 __u16 dl_unused2;
62 __u32 dl_unused3;
63 } __attribute__ ((packed));
64
65 /* crypto algorithms */
66 #define CEPH_CRYPTO_NONE 0x0
67 #define CEPH_CRYPTO_AES 0x1
68
69 #define CEPH_AES_IV "cephsageyudagreg"
70
71 /* security/authentication protocols */
72 #define CEPH_AUTH_UNKNOWN 0x0
73 #define CEPH_AUTH_NONE 0x1
74 #define CEPH_AUTH_CEPHX 0x2
75
76 #define CEPH_AUTH_UID_DEFAULT ((__u64) -1)
77
78
79 /*********************************************
80 * message layer
81 */
82
83 /*
84 * message types
85 */
86
87 /* misc */
88 #define CEPH_MSG_SHUTDOWN 1
89 #define CEPH_MSG_PING 2
90
91 /* client <-> monitor */
92 #define CEPH_MSG_MON_MAP 4
93 #define CEPH_MSG_MON_GET_MAP 5
94 #define CEPH_MSG_MON_GET_OSDMAP 6
95 #define CEPH_MSG_MON_METADATA 7
96 #define CEPH_MSG_STATFS 13
97 #define CEPH_MSG_STATFS_REPLY 14
98 #define CEPH_MSG_MON_SUBSCRIBE 15
99 #define CEPH_MSG_MON_SUBSCRIBE_ACK 16
100 #define CEPH_MSG_AUTH 17
101 #define CEPH_MSG_AUTH_REPLY 18
102 #define CEPH_MSG_MON_GET_VERSION 19
103 #define CEPH_MSG_MON_GET_VERSION_REPLY 20
104
105 /* client <-> mds */
106 #define CEPH_MSG_MDS_MAP 21
107
108 #define CEPH_MSG_CLIENT_SESSION 22
109 #define CEPH_MSG_CLIENT_RECONNECT 23
110
111 #define CEPH_MSG_CLIENT_REQUEST 24
112 #define CEPH_MSG_CLIENT_REQUEST_FORWARD 25
113 #define CEPH_MSG_CLIENT_REPLY 26
114 #define CEPH_MSG_CLIENT_CAPS 0x310
115 #define CEPH_MSG_CLIENT_LEASE 0x311
116 #define CEPH_MSG_CLIENT_SNAP 0x312
117 #define CEPH_MSG_CLIENT_CAPRELEASE 0x313
118 #define CEPH_MSG_CLIENT_QUOTA 0x314
119
120 /* pool ops */
121 #define CEPH_MSG_POOLOP_REPLY 48
122 #define CEPH_MSG_POOLOP 49
123
124
125 /* osd */
126 #define CEPH_MSG_OSD_MAP 41
127 #define CEPH_MSG_OSD_OP 42
128 #define CEPH_MSG_OSD_OPREPLY 43
129 #define CEPH_MSG_WATCH_NOTIFY 44
130 #define CEPH_MSG_OSD_BACKOFF 61
131
132 /* FSMap subscribers (see all MDS clusters at once) */
133 #define CEPH_MSG_FS_MAP 45
134 /* FSMapUser subscribers (get MDS clusters name->ID mapping) */
135 #define CEPH_MSG_FS_MAP_USER 103
136
137 /* watch-notify operations */
138 enum {
139 CEPH_WATCH_EVENT_NOTIFY = 1, /* notifying watcher */
140 CEPH_WATCH_EVENT_NOTIFY_COMPLETE = 2, /* notifier notified when done */
141 CEPH_WATCH_EVENT_DISCONNECT = 3, /* we were disconnected */
142 };
143
144 const char *ceph_watch_event_name(int o);
145
146 /* pool operations */
147 enum {
148 POOL_OP_CREATE = 0x01,
149 POOL_OP_DELETE = 0x02,
150 POOL_OP_AUID_CHANGE = 0x03,
151 POOL_OP_CREATE_SNAP = 0x11,
152 POOL_OP_DELETE_SNAP = 0x12,
153 POOL_OP_CREATE_UNMANAGED_SNAP = 0x21,
154 POOL_OP_DELETE_UNMANAGED_SNAP = 0x22,
155 };
156
157 struct ceph_mon_request_header {
158 __le64 have_version;
159 __le16 session_mon;
160 __le64 session_mon_tid;
161 } __attribute__ ((packed));
162
163 struct ceph_mon_statfs {
164 struct ceph_mon_request_header monhdr;
165 struct ceph_fsid fsid;
166 } __attribute__ ((packed));
167
168 struct ceph_statfs {
169 __le64 kb, kb_used, kb_avail;
170 __le64 num_objects;
171 } __attribute__ ((packed));
172
173 struct ceph_mon_statfs_reply {
174 struct ceph_fsid fsid;
175 __le64 version;
176 struct ceph_statfs st;
177 } __attribute__ ((packed));
178
179 const char *ceph_pool_op_name(int op);
180
181 struct ceph_mon_poolop {
182 struct ceph_mon_request_header monhdr;
183 struct ceph_fsid fsid;
184 __le32 pool;
185 __le32 op;
186 __le64 auid;
187 __le64 snapid;
188 __le32 name_len;
189 } __attribute__ ((packed));
190
191 struct ceph_mon_poolop_reply {
192 struct ceph_mon_request_header monhdr;
193 struct ceph_fsid fsid;
194 __le32 reply_code;
195 __le32 epoch;
196 char has_data;
197 char data[0];
198 } __attribute__ ((packed));
199
200 struct ceph_mon_unmanaged_snap {
201 __le64 snapid;
202 } __attribute__ ((packed));
203
204 struct ceph_osd_getmap {
205 struct ceph_mon_request_header monhdr;
206 struct ceph_fsid fsid;
207 __le32 start;
208 } __attribute__ ((packed));
209
210 struct ceph_mds_getmap {
211 struct ceph_mon_request_header monhdr;
212 struct ceph_fsid fsid;
213 } __attribute__ ((packed));
214
215 struct ceph_client_mount {
216 struct ceph_mon_request_header monhdr;
217 } __attribute__ ((packed));
218
219 #define CEPH_SUBSCRIBE_ONETIME 1 /* i want only 1 update after have */
220
221 struct ceph_mon_subscribe_item {
222 __le64 start;
223 __u8 flags;
224 } __attribute__ ((packed));
225
226 struct ceph_mon_subscribe_ack {
227 __le32 duration; /* seconds */
228 struct ceph_fsid fsid;
229 } __attribute__ ((packed));
230
231 /*
232 * mdsmap flags
233 */
234 #define CEPH_MDSMAP_DOWN (1<<0) /* cluster deliberately down */
235 #define CEPH_MDSMAP_ALLOW_SNAPS (1<<1) /* cluster allowed to create snapshots */
236 #define CEPH_MDSMAP_ALLOW_MULTIMDS (1<<2) /* cluster allowed to have >1 active MDS */
237 #define CEPH_MDSMAP_ALLOW_DIRFRAGS (1<<3) /* cluster allowed to fragment directories */
238
239 #define CEPH_MDSMAP_ALLOW_CLASSICS (CEPH_MDSMAP_ALLOW_SNAPS | CEPH_MDSMAP_ALLOW_MULTIMDS | \
240 CEPH_MDSMAP_ALLOW_DIRFRAGS)
241
242 #define CEPH_MDSMAP_DEFAULTS CEPH_MDSMAP_ALLOW_DIRFRAGS | CEPH_MDSMAP_ALLOW_MULTIMDS
243
244 /*
245 * mds states
246 * > 0 -> in
247 * <= 0 -> out
248 */
249 #define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */
250 #define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees.
251 empty log. */
252 #define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */
253 #define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */
254 #define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */
255 #define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */
256 #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */
257 #define CEPH_MDS_STATE_REPLAYONCE -9 /* Legacy, unused */
258 #define CEPH_MDS_STATE_NULL -10
259
260 #define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */
261 #define CEPH_MDS_STATE_RESOLVE 9 /* up, disambiguating distributed
262 operations (import, rename, etc.) */
263 #define CEPH_MDS_STATE_RECONNECT 10 /* up, reconnect to clients */
264 #define CEPH_MDS_STATE_REJOIN 11 /* up, rejoining distributed cache */
265 #define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */
266 #define CEPH_MDS_STATE_ACTIVE 13 /* up, active */
267 #define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */
268 #define CEPH_MDS_STATE_DAMAGED 15 /* rank not replayable, need repair */
269
270 extern const char *ceph_mds_state_name(int s);
271
272
273 /*
274 * metadata lock types.
275 * - these are bitmasks.. we can compose them
276 * - they also define the lock ordering by the MDS
277 * - a few of these are internal to the mds
278 */
279 #define CEPH_LOCK_DVERSION 1
280 #define CEPH_LOCK_DN 2
281 #define CEPH_LOCK_ISNAP 16
282 #define CEPH_LOCK_IVERSION 32 /* mds internal */
283 #define CEPH_LOCK_IFILE 64
284 #define CEPH_LOCK_IAUTH 128
285 #define CEPH_LOCK_ILINK 256
286 #define CEPH_LOCK_IDFT 512 /* dir frag tree */
287 #define CEPH_LOCK_INEST 1024 /* mds internal */
288 #define CEPH_LOCK_IXATTR 2048
289 #define CEPH_LOCK_IFLOCK 4096 /* advisory file locks */
290 #define CEPH_LOCK_INO 8192 /* immutable inode bits; not a lock */
291 #define CEPH_LOCK_IPOLICY 16384 /* policy lock on dirs. MDS internal */
292
293 /* client_session ops */
294 enum {
295 CEPH_SESSION_REQUEST_OPEN,
296 CEPH_SESSION_OPEN,
297 CEPH_SESSION_REQUEST_CLOSE,
298 CEPH_SESSION_CLOSE,
299 CEPH_SESSION_REQUEST_RENEWCAPS,
300 CEPH_SESSION_RENEWCAPS,
301 CEPH_SESSION_STALE,
302 CEPH_SESSION_RECALL_STATE,
303 CEPH_SESSION_FLUSHMSG,
304 CEPH_SESSION_FLUSHMSG_ACK,
305 CEPH_SESSION_FORCE_RO,
306 // A response to REQUEST_OPEN indicating that the client should
307 // permanently desist from contacting the MDS
308 CEPH_SESSION_REJECT,
309 CEPH_SESSION_REQUEST_FLUSH_MDLOG
310 };
311
312 extern const char *ceph_session_op_name(int op);
313
314 struct ceph_mds_session_head {
315 __le32 op;
316 __le64 seq;
317 struct ceph_timespec stamp;
318 __le32 max_caps, max_leases;
319 } __attribute__ ((packed));
320
321 /* client_request */
322 /*
323 * metadata ops.
324 * & 0x001000 -> write op
325 * & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
326 & & 0x100000 -> use weird ino/path trace
327 */
328 #define CEPH_MDS_OP_WRITE 0x001000
329 enum {
330 CEPH_MDS_OP_LOOKUP = 0x00100,
331 CEPH_MDS_OP_GETATTR = 0x00101,
332 CEPH_MDS_OP_LOOKUPHASH = 0x00102,
333 CEPH_MDS_OP_LOOKUPPARENT = 0x00103,
334 CEPH_MDS_OP_LOOKUPINO = 0x00104,
335 CEPH_MDS_OP_LOOKUPNAME = 0x00105,
336
337 CEPH_MDS_OP_SETXATTR = 0x01105,
338 CEPH_MDS_OP_RMXATTR = 0x01106,
339 CEPH_MDS_OP_SETLAYOUT = 0x01107,
340 CEPH_MDS_OP_SETATTR = 0x01108,
341 CEPH_MDS_OP_SETFILELOCK= 0x01109,
342 CEPH_MDS_OP_GETFILELOCK= 0x00110,
343 CEPH_MDS_OP_SETDIRLAYOUT=0x0110a,
344
345 CEPH_MDS_OP_MKNOD = 0x01201,
346 CEPH_MDS_OP_LINK = 0x01202,
347 CEPH_MDS_OP_UNLINK = 0x01203,
348 CEPH_MDS_OP_RENAME = 0x01204,
349 CEPH_MDS_OP_MKDIR = 0x01220,
350 CEPH_MDS_OP_RMDIR = 0x01221,
351 CEPH_MDS_OP_SYMLINK = 0x01222,
352
353 CEPH_MDS_OP_CREATE = 0x01301,
354 CEPH_MDS_OP_OPEN = 0x00302,
355 CEPH_MDS_OP_READDIR = 0x00305,
356
357 CEPH_MDS_OP_LOOKUPSNAP = 0x00400,
358 CEPH_MDS_OP_MKSNAP = 0x01400,
359 CEPH_MDS_OP_RMSNAP = 0x01401,
360 CEPH_MDS_OP_LSSNAP = 0x00402,
361 CEPH_MDS_OP_RENAMESNAP = 0x01403,
362
363 // internal op
364 CEPH_MDS_OP_FRAGMENTDIR= 0x01500,
365 CEPH_MDS_OP_EXPORTDIR = 0x01501,
366 CEPH_MDS_OP_FLUSH = 0x01502,
367 CEPH_MDS_OP_ENQUEUE_SCRUB = 0x01503,
368 CEPH_MDS_OP_REPAIR_FRAGSTATS = 0x01504,
369 CEPH_MDS_OP_REPAIR_INODESTATS = 0x01505
370 };
371
372 extern const char *ceph_mds_op_name(int op);
373
374 #ifndef CEPH_SETATTR_MODE
375 #define CEPH_SETATTR_MODE (1 << 0)
376 #define CEPH_SETATTR_UID (1 << 1)
377 #define CEPH_SETATTR_GID (1 << 2)
378 #define CEPH_SETATTR_MTIME (1 << 3)
379 #define CEPH_SETATTR_ATIME (1 << 4)
380 #define CEPH_SETATTR_SIZE (1 << 5)
381 #define CEPH_SETATTR_CTIME (1 << 6)
382 #define CEPH_SETATTR_BTIME (1 << 9)
383 #endif
384 #define CEPH_SETATTR_MTIME_NOW (1 << 7)
385 #define CEPH_SETATTR_ATIME_NOW (1 << 8)
386 #define CEPH_SETATTR_KILL_SGUID (1 << 10)
387
388 /*
389 * open request flags
390 */
391 #define CEPH_O_RDONLY 00000000
392 #define CEPH_O_WRONLY 00000001
393 #define CEPH_O_RDWR 00000002
394 #define CEPH_O_CREAT 00000100
395 #define CEPH_O_EXCL 00000200
396 #define CEPH_O_TRUNC 00001000
397 #define CEPH_O_DIRECTORY 00200000
398 #define CEPH_O_NOFOLLOW 00400000
399
400 int ceph_flags_sys2wire(int flags);
401
402 /*
403 * Ceph setxattr request flags.
404 */
405 #define CEPH_XATTR_CREATE (1 << 0)
406 #define CEPH_XATTR_REPLACE (1 << 1)
407 #define CEPH_XATTR_REMOVE (1 << 31)
408
409 /*
410 * readdir request flags;
411 */
412 #define CEPH_READDIR_REPLY_BITFLAGS (1<<0)
413
414 /*
415 * readdir reply flags.
416 */
417 #define CEPH_READDIR_FRAG_END (1<<0)
418 #define CEPH_READDIR_FRAG_COMPLETE (1<<8)
419 #define CEPH_READDIR_HASH_ORDER (1<<9)
420 #define CEPH_READDIR_OFFSET_HASH (1<<10)
421
422 /* Note that this is embedded wthin ceph_mds_request_head_legacy. */
423 union ceph_mds_request_args_legacy {
424 struct {
425 __le32 mask; /* CEPH_CAP_* */
426 } __attribute__ ((packed)) getattr;
427 struct {
428 __le32 mode;
429 __le32 uid;
430 __le32 gid;
431 struct ceph_timespec mtime;
432 struct ceph_timespec atime;
433 __le64 size, old_size; /* old_size needed by truncate */
434 __le32 mask; /* CEPH_SETATTR_* */
435 } __attribute__ ((packed)) setattr;
436 struct {
437 __le32 frag; /* which dir fragment */
438 __le32 max_entries; /* how many dentries to grab */
439 __le32 max_bytes;
440 __le16 flags;
441 __le32 offset_hash;
442 } __attribute__ ((packed)) readdir;
443 struct {
444 __le32 mode;
445 __le32 rdev;
446 } __attribute__ ((packed)) mknod;
447 struct {
448 __le32 mode;
449 } __attribute__ ((packed)) mkdir;
450 struct {
451 __le32 flags;
452 __le32 mode;
453 __le32 stripe_unit; /* layout for newly created file */
454 __le32 stripe_count; /* ... */
455 __le32 object_size;
456 __le32 pool; /* if >= 0 and CREATEPOOLID feature */
457 __le32 mask; /* CEPH_CAP_* */
458 __le64 old_size; /* if O_TRUNC */
459 } __attribute__ ((packed)) open;
460 struct {
461 __le32 flags;
462 __le32 osdmap_epoch; /* use for set file/dir layout */
463 } __attribute__ ((packed)) setxattr;
464 struct {
465 struct ceph_file_layout layout;
466 } __attribute__ ((packed)) setlayout;
467 struct {
468 __u8 rule; /* currently fcntl or flock */
469 __u8 type; /* shared, exclusive, remove*/
470 __le64 owner; /* who requests/holds the lock */
471 __le64 pid; /* process id requesting the lock */
472 __le64 start; /* initial location to lock */
473 __le64 length; /* num bytes to lock from start */
474 __u8 wait; /* will caller wait for lock to become available? */
475 } __attribute__ ((packed)) filelock_change;
476 } __attribute__ ((packed));
477
478 #define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */
479 #define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */
480
481 struct ceph_mds_request_head_legacy {
482 __le64 oldest_client_tid;
483 __le32 mdsmap_epoch; /* on client */
484 __le32 flags; /* CEPH_MDS_FLAG_* */
485 __u8 num_retry, num_fwd; /* count retry, fwd attempts */
486 __le16 num_releases; /* # include cap/lease release records */
487 __le32 op; /* mds op code */
488 __le32 caller_uid, caller_gid;
489 __le64 ino; /* use this ino for openc, mkdir, mknod,
490 etc. (if replaying) */
491 union ceph_mds_request_args_legacy args;
492 } __attribute__ ((packed));
493
494 /*
495 * Note that this is embedded wthin ceph_mds_request_head. Also, compatability
496 * with the ceph_mds_request_args_legacy must be maintained!
497 */
498 union ceph_mds_request_args {
499 struct {
500 __le32 mask; /* CEPH_CAP_* */
501 } __attribute__ ((packed)) getattr;
502 struct {
503 __le32 mode;
504 __le32 uid;
505 __le32 gid;
506 struct ceph_timespec mtime;
507 struct ceph_timespec atime;
508 __le64 size, old_size; /* old_size needed by truncate */
509 __le32 mask; /* CEPH_SETATTR_* */
510 struct ceph_timespec btime;
511 } __attribute__ ((packed)) setattr;
512 struct {
513 __le32 frag; /* which dir fragment */
514 __le32 max_entries; /* how many dentries to grab */
515 __le32 max_bytes;
516 __le16 flags;
517 __le32 offset_hash;
518 } __attribute__ ((packed)) readdir;
519 struct {
520 __le32 mode;
521 __le32 rdev;
522 } __attribute__ ((packed)) mknod;
523 struct {
524 __le32 mode;
525 } __attribute__ ((packed)) mkdir;
526 struct {
527 __le32 flags;
528 __le32 mode;
529 __le32 stripe_unit; /* layout for newly created file */
530 __le32 stripe_count; /* ... */
531 __le32 object_size;
532 __le32 pool; /* if >= 0 and CREATEPOOLID feature */
533 __le32 mask; /* CEPH_CAP_* */
534 __le64 old_size; /* if O_TRUNC */
535 } __attribute__ ((packed)) open;
536 struct {
537 __le32 flags;
538 __le32 osdmap_epoch; /* use for set file/dir layout */
539 } __attribute__ ((packed)) setxattr;
540 struct {
541 struct ceph_file_layout layout;
542 } __attribute__ ((packed)) setlayout;
543 struct {
544 __u8 rule; /* currently fcntl or flock */
545 __u8 type; /* shared, exclusive, remove*/
546 __le64 owner; /* who requests/holds the lock */
547 __le64 pid; /* process id requesting the lock */
548 __le64 start; /* initial location to lock */
549 __le64 length; /* num bytes to lock from start */
550 __u8 wait; /* will caller wait for lock to become available? */
551 } __attribute__ ((packed)) filelock_change;
552 } __attribute__ ((packed));
553
554 #define CEPH_MDS_REQUEST_HEAD_VERSION 1
555
556 /*
557 * Note that any change to this structure must ensure that it is compatible
558 * with ceph_mds_request_head_legacy.
559 */
560 struct ceph_mds_request_head {
561 __le16 version;
562 __le64 oldest_client_tid;
563 __le32 mdsmap_epoch; /* on client */
564 __le32 flags; /* CEPH_MDS_FLAG_* */
565 __u8 num_retry, num_fwd; /* count retry, fwd attempts */
566 __le16 num_releases; /* # include cap/lease release records */
567 __le32 op; /* mds op code */
568 __le32 caller_uid, caller_gid;
569 __le64 ino; /* use this ino for openc, mkdir, mknod,
570 etc. (if replaying) */
571 union ceph_mds_request_args args;
572 } __attribute__ ((packed));
573
574 /* cap/lease release record */
575 struct ceph_mds_request_release {
576 __le64 ino, cap_id; /* ino and unique cap id */
577 __le32 caps, wanted; /* new issued, wanted */
578 __le32 seq, issue_seq, mseq;
579 __le32 dname_seq; /* if releasing a dentry lease, a */
580 __le32 dname_len; /* string follows. */
581 } __attribute__ ((packed));
582
583 static inline void
584 copy_from_legacy_head(struct ceph_mds_request_head *head,
585 struct ceph_mds_request_head_legacy *legacy)
586 {
587 memcpy(&(head->oldest_client_tid), legacy, sizeof(*legacy));
588 }
589
590 static inline void
591 copy_to_legacy_head(struct ceph_mds_request_head_legacy *legacy,
592 struct ceph_mds_request_head *head)
593 {
594 memcpy(legacy, &(head->oldest_client_tid), sizeof(*legacy));
595 }
596
597 /* client reply */
598 struct ceph_mds_reply_head {
599 __le32 op;
600 __le32 result;
601 __le32 mdsmap_epoch;
602 __u8 safe; /* true if committed to disk */
603 __u8 is_dentry, is_target; /* true if dentry, target inode records
604 are included with reply */
605 } __attribute__ ((packed));
606
607 /* one for each node split */
608 struct ceph_frag_tree_split {
609 __le32 frag; /* this frag splits... */
610 __le32 by; /* ...by this many bits */
611 } __attribute__ ((packed));
612
613 struct ceph_frag_tree_head {
614 __le32 nsplits; /* num ceph_frag_tree_split records */
615 struct ceph_frag_tree_split splits[];
616 } __attribute__ ((packed));
617
618 /* capability issue, for bundling with mds reply */
619 struct ceph_mds_reply_cap {
620 __le32 caps, wanted; /* caps issued, wanted */
621 __le64 cap_id;
622 __le32 seq, mseq;
623 __le64 realm; /* snap realm */
624 __u8 flags; /* CEPH_CAP_FLAG_* */
625 } __attribute__ ((packed));
626
627 #define CEPH_CAP_FLAG_AUTH (1 << 0) /* cap is issued by auth mds */
628 #define CEPH_CAP_FLAG_RELEASE (1 << 1) /* ask client to release the cap */
629
630 /* reply_lease follows dname, and reply_inode */
631 struct ceph_mds_reply_lease {
632 __le16 mask; /* lease type(s) */
633 __le32 duration_ms; /* lease duration */
634 __le32 seq;
635 } __attribute__ ((packed));
636
637 struct ceph_mds_reply_dirfrag {
638 __le32 frag; /* fragment */
639 __le32 auth; /* auth mds, if this is a delegation point */
640 __le32 ndist; /* number of mds' this is replicated on */
641 __le32 dist[];
642 } __attribute__ ((packed));
643
644 #define CEPH_LOCK_FCNTL 1
645 #define CEPH_LOCK_FLOCK 2
646 #define CEPH_LOCK_FCNTL_INTR 3
647 #define CEPH_LOCK_FLOCK_INTR 4
648
649 #define CEPH_LOCK_SHARED 1
650 #define CEPH_LOCK_EXCL 2
651 #define CEPH_LOCK_UNLOCK 4
652
653 struct ceph_filelock {
654 __le64 start;/* file offset to start lock at */
655 __le64 length; /* num bytes to lock; 0 for all following start */
656 __le64 client; /* which client holds the lock */
657 __le64 owner; /* who requests/holds the lock */
658 __le64 pid; /* process id holding the lock on the client */
659 __u8 type; /* shared lock, exclusive lock, or unlock */
660 } __attribute__ ((packed));
661
662
663 /* file access modes */
664 #define CEPH_FILE_MODE_PIN 0
665 #define CEPH_FILE_MODE_RD 1
666 #define CEPH_FILE_MODE_WR 2
667 #define CEPH_FILE_MODE_RDWR 3 /* RD | WR */
668 #define CEPH_FILE_MODE_LAZY 4 /* lazy io */
669 #define CEPH_FILE_MODE_NUM 8 /* bc these are bit fields.. mostly */
670
671 int ceph_flags_to_mode(int flags);
672
673 /* inline data state */
674 #define CEPH_INLINE_NONE ((__u64)-1)
675 #define CEPH_INLINE_MAX_SIZE CEPH_MIN_STRIPE_UNIT
676
677 /* capability bits */
678 #define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */
679
680 /* generic cap bits */
681 #define CEPH_CAP_GSHARED 1 /* client can reads */
682 #define CEPH_CAP_GEXCL 2 /* client can read and update */
683 #define CEPH_CAP_GCACHE 4 /* (file) client can cache reads */
684 #define CEPH_CAP_GRD 8 /* (file) client can read */
685 #define CEPH_CAP_GWR 16 /* (file) client can write */
686 #define CEPH_CAP_GBUFFER 32 /* (file) client can buffer writes */
687 #define CEPH_CAP_GWREXTEND 64 /* (file) client can extend EOF */
688 #define CEPH_CAP_GLAZYIO 128 /* (file) client can perform lazy io */
689
690 #define CEPH_CAP_SIMPLE_BITS 2
691 #define CEPH_CAP_FILE_BITS 8
692
693 /* per-lock shift */
694 #define CEPH_CAP_SAUTH 2
695 #define CEPH_CAP_SLINK 4
696 #define CEPH_CAP_SXATTR 6
697 #define CEPH_CAP_SFILE 8
698
699 /* composed values */
700 #define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH)
701 #define CEPH_CAP_AUTH_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SAUTH)
702 #define CEPH_CAP_LINK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SLINK)
703 #define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK)
704 #define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SXATTR)
705 #define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR)
706 #define CEPH_CAP_FILE(x) (x << CEPH_CAP_SFILE)
707 #define CEPH_CAP_FILE_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFILE)
708 #define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE)
709 #define CEPH_CAP_FILE_CACHE (CEPH_CAP_GCACHE << CEPH_CAP_SFILE)
710 #define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE)
711 #define CEPH_CAP_FILE_WR (CEPH_CAP_GWR << CEPH_CAP_SFILE)
712 #define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE)
713 #define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
714 #define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE)
715
716 /* cap masks (for getattr) */
717 #define CEPH_STAT_CAP_INODE CEPH_CAP_PIN
718 #define CEPH_STAT_CAP_TYPE CEPH_CAP_PIN /* mode >> 12 */
719 #define CEPH_STAT_CAP_SYMLINK CEPH_CAP_PIN
720 #define CEPH_STAT_CAP_UID CEPH_CAP_AUTH_SHARED
721 #define CEPH_STAT_CAP_GID CEPH_CAP_AUTH_SHARED
722 #define CEPH_STAT_CAP_MODE CEPH_CAP_AUTH_SHARED
723 #define CEPH_STAT_CAP_NLINK CEPH_CAP_LINK_SHARED
724 #define CEPH_STAT_CAP_LAYOUT CEPH_CAP_FILE_SHARED
725 #define CEPH_STAT_CAP_MTIME CEPH_CAP_FILE_SHARED
726 #define CEPH_STAT_CAP_SIZE CEPH_CAP_FILE_SHARED
727 #define CEPH_STAT_CAP_ATIME CEPH_CAP_FILE_SHARED /* fixme */
728 #define CEPH_STAT_CAP_XATTR CEPH_CAP_XATTR_SHARED
729 #define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN | \
730 CEPH_CAP_AUTH_SHARED | \
731 CEPH_CAP_LINK_SHARED | \
732 CEPH_CAP_FILE_SHARED | \
733 CEPH_CAP_XATTR_SHARED)
734 #define CEPH_STAT_CAP_INLINE_DATA (CEPH_CAP_FILE_SHARED | \
735 CEPH_CAP_FILE_RD)
736 #define CEPH_STAT_RSTAT CEPH_CAP_FILE_WREXTEND
737
738 #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \
739 CEPH_CAP_LINK_SHARED | \
740 CEPH_CAP_XATTR_SHARED | \
741 CEPH_CAP_FILE_SHARED)
742 #define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \
743 CEPH_CAP_FILE_CACHE)
744
745 #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \
746 CEPH_CAP_LINK_EXCL | \
747 CEPH_CAP_XATTR_EXCL | \
748 CEPH_CAP_FILE_EXCL)
749 #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \
750 CEPH_CAP_FILE_EXCL)
751 #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
752 #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
753 CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \
754 CEPH_CAP_PIN)
755
756 #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
757 CEPH_LOCK_IXATTR)
758
759 int ceph_caps_for_mode(int mode);
760
761 enum {
762 CEPH_CAP_OP_GRANT, /* mds->client grant */
763 CEPH_CAP_OP_REVOKE, /* mds->client revoke */
764 CEPH_CAP_OP_TRUNC, /* mds->client trunc notify */
765 CEPH_CAP_OP_EXPORT, /* mds has exported the cap */
766 CEPH_CAP_OP_IMPORT, /* mds has imported the cap */
767 CEPH_CAP_OP_UPDATE, /* client->mds update */
768 CEPH_CAP_OP_DROP, /* client->mds drop cap bits */
769 CEPH_CAP_OP_FLUSH, /* client->mds cap writeback */
770 CEPH_CAP_OP_FLUSH_ACK, /* mds->client flushed */
771 CEPH_CAP_OP_FLUSHSNAP, /* client->mds flush snapped metadata */
772 CEPH_CAP_OP_FLUSHSNAP_ACK, /* mds->client flushed snapped metadata */
773 CEPH_CAP_OP_RELEASE, /* client->mds release (clean) cap */
774 CEPH_CAP_OP_RENEW, /* client->mds renewal request */
775 };
776
777 extern const char *ceph_cap_op_name(int op);
778
779 /* extra info for cap import/export */
780 struct ceph_mds_cap_peer {
781 __le64 cap_id;
782 __le32 seq;
783 __le32 mseq;
784 __le32 mds;
785 __u8 flags;
786 } __attribute__ ((packed));
787
788 /*
789 * caps message, used for capability callbacks, acks, requests, etc.
790 */
791 struct ceph_mds_caps_head {
792 __le32 op; /* CEPH_CAP_OP_* */
793 __le64 ino, realm;
794 __le64 cap_id;
795 __le32 seq, issue_seq;
796 __le32 caps, wanted, dirty; /* latest issued/wanted/dirty */
797 __le32 migrate_seq;
798 __le64 snap_follows;
799 __le32 snap_trace_len;
800
801 /* authlock */
802 __le32 uid, gid, mode;
803
804 /* linklock */
805 __le32 nlink;
806
807 /* xattrlock */
808 __le32 xattr_len;
809 __le64 xattr_version;
810 } __attribute__ ((packed));
811
812 struct ceph_mds_caps_body_legacy {
813 union {
814 /* all except export */
815 struct {
816 /* filelock */
817 __le64 size, max_size, truncate_size;
818 __le32 truncate_seq;
819 struct ceph_timespec mtime, atime, ctime;
820 struct ceph_file_layout layout;
821 __le32 time_warp_seq;
822 };
823 /* export message */
824 struct ceph_mds_cap_peer peer;
825 };
826 } __attribute__ ((packed));
827
828 /* cap release msg head */
829 struct ceph_mds_cap_release {
830 __le32 num; /* number of cap_items that follow */
831 } __attribute__ ((packed));
832
833 struct ceph_mds_cap_item {
834 __le64 ino;
835 __le64 cap_id;
836 __le32 migrate_seq, seq;
837 } __attribute__ ((packed));
838
839 #define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */
840 #define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */
841 #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */
842 #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */
843
844 extern const char *ceph_lease_op_name(int o);
845
846 /* lease msg header */
847 struct ceph_mds_lease {
848 __u8 action; /* CEPH_MDS_LEASE_* */
849 __le16 mask; /* which lease */
850 __le64 ino;
851 __le64 first, last; /* snap range */
852 __le32 seq;
853 __le32 duration_ms; /* duration of renewal */
854 } __attribute__ ((packed));
855 /* followed by a __le32+string for dname */
856
857 /* client reconnect */
858 struct ceph_mds_cap_reconnect {
859 __le64 cap_id;
860 __le32 wanted;
861 __le32 issued;
862 __le64 snaprealm;
863 __le64 pathbase; /* base ino for our path to this ino */
864 __le32 flock_len; /* size of flock state blob, if any */
865 } __attribute__ ((packed));
866 /* followed by flock blob */
867
868 struct ceph_mds_cap_reconnect_v1 {
869 __le64 cap_id;
870 __le32 wanted;
871 __le32 issued;
872 __le64 size;
873 struct ceph_timespec mtime, atime;
874 __le64 snaprealm;
875 __le64 pathbase; /* base ino for our path to this ino */
876 } __attribute__ ((packed));
877
878 struct ceph_mds_snaprealm_reconnect {
879 __le64 ino; /* snap realm base */
880 __le64 seq; /* snap seq for this snap realm */
881 __le64 parent; /* parent realm */
882 } __attribute__ ((packed));
883
884 /*
885 * snaps
886 */
887 enum {
888 CEPH_SNAP_OP_UPDATE, /* CREATE or DESTROY */
889 CEPH_SNAP_OP_CREATE,
890 CEPH_SNAP_OP_DESTROY,
891 CEPH_SNAP_OP_SPLIT,
892 };
893
894 extern const char *ceph_snap_op_name(int o);
895
896 /* snap msg header */
897 struct ceph_mds_snap_head {
898 __le32 op; /* CEPH_SNAP_OP_* */
899 __le64 split; /* ino to split off, if any */
900 __le32 num_split_inos; /* # inos belonging to new child realm */
901 __le32 num_split_realms; /* # child realms udner new child realm */
902 __le32 trace_len; /* size of snap trace blob */
903 } __attribute__ ((packed));
904 /* followed by split ino list, then split realms, then the trace blob */
905
906 /*
907 * encode info about a snaprealm, as viewed by a client
908 */
909 struct ceph_mds_snap_realm {
910 __le64 ino; /* ino */
911 __le64 created; /* snap: when created */
912 __le64 parent; /* ino: parent realm */
913 __le64 parent_since; /* snap: same parent since */
914 __le64 seq; /* snap: version */
915 __le32 num_snaps;
916 __le32 num_prior_parent_snaps;
917 } __attribute__ ((packed));
918 /* followed by my snap list, then prior parent snap list */
919
920 #endif