1 /* SPDX-License-Identifier: GPL-2.0 */
3 * ceph_fs.h - Ceph constants and data types to share between kernel and
6 * Most types in this file are defined as little-endian, and are
7 * primarily intended to describe data structures that pass over the
8 * wire or that are stored on disk.
16 #include <linux/ceph/msgr.h>
17 #include <linux/ceph/rados.h>
20 * subprotocol versions. when specific messages types or high-level
21 * protocols change, bump the affected components. we keep rev
22 * internal cluster protocols separately from the public,
23 * client-facing protocol.
25 #define CEPH_OSDC_PROTOCOL 24 /* server/client */
26 #define CEPH_MDSC_PROTOCOL 32 /* server/client */
27 #define CEPH_MONC_PROTOCOL 15 /* server/client */
30 #define CEPH_INO_ROOT 1
31 #define CEPH_INO_CEPH 2 /* hidden .ceph dir */
32 #define CEPH_INO_DOTDOT 3 /* used by ceph fuse for parent (..) */
34 /* arbitrary limit on max # of monitors (cluster of 3 is typical) */
35 #define CEPH_MAX_MON 31
38 * legacy ceph_file_layoute
40 struct ceph_file_layout_legacy {
41 /* file -> object mapping */
42 __le32 fl_stripe_unit; /* stripe unit, in bytes. must be multiple
44 __le32 fl_stripe_count; /* over this many objects */
45 __le32 fl_object_size; /* until objects are this big, then move to
47 __le32 fl_cas_hash; /* UNUSED. 0 = none; 1 = sha256 */
49 /* pg -> disk layout */
50 __le32 fl_object_stripe_unit; /* UNUSED. for per-object parity, if any */
52 /* object -> pg layout */
53 __le32 fl_unused; /* unused; used to be preferred primary for pg (-1 for none) */
54 __le32 fl_pg_pool; /* namespace, crush ruleset, rep level */
55 } __attribute__ ((packed));
59 * ceph_file_layout - describe data layout for a file/inode
61 struct ceph_file_layout {
62 /* file -> object mapping */
63 u32 stripe_unit; /* stripe unit, in bytes */
64 u32 stripe_count; /* over this many objects */
65 u32 object_size; /* until objects are this big */
66 s64 pool_id; /* rados pool id */
67 struct ceph_string __rcu *pool_ns; /* rados pool namespace */
70 extern int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);
71 extern void ceph_file_layout_from_legacy(struct ceph_file_layout *fl,
72 struct ceph_file_layout_legacy *legacy);
73 extern void ceph_file_layout_to_legacy(struct ceph_file_layout *fl,
74 struct ceph_file_layout_legacy *legacy);
76 #define CEPH_MIN_STRIPE_UNIT 65536
78 struct ceph_dir_layout {
79 __u8 dl_dir_hash; /* see ceph_hash.h for ids */
83 } __attribute__ ((packed));
85 /* crypto algorithms */
86 #define CEPH_CRYPTO_NONE 0x0
87 #define CEPH_CRYPTO_AES 0x1
89 #define CEPH_AES_IV "cephsageyudagreg"
91 /* security/authentication protocols */
92 #define CEPH_AUTH_UNKNOWN 0x0
93 #define CEPH_AUTH_NONE 0x1
94 #define CEPH_AUTH_CEPHX 0x2
96 #define CEPH_AUTH_UID_DEFAULT ((__u64) -1)
99 /*********************************************
108 #define CEPH_MSG_SHUTDOWN 1
109 #define CEPH_MSG_PING 2
111 /* client <-> monitor */
112 #define CEPH_MSG_MON_MAP 4
113 #define CEPH_MSG_MON_GET_MAP 5
114 #define CEPH_MSG_STATFS 13
115 #define CEPH_MSG_STATFS_REPLY 14
116 #define CEPH_MSG_MON_SUBSCRIBE 15
117 #define CEPH_MSG_MON_SUBSCRIBE_ACK 16
118 #define CEPH_MSG_AUTH 17
119 #define CEPH_MSG_AUTH_REPLY 18
120 #define CEPH_MSG_MON_GET_VERSION 19
121 #define CEPH_MSG_MON_GET_VERSION_REPLY 20
124 #define CEPH_MSG_MDS_MAP 21
125 #define CEPH_MSG_FS_MAP_USER 103
127 #define CEPH_MSG_CLIENT_SESSION 22
128 #define CEPH_MSG_CLIENT_RECONNECT 23
130 #define CEPH_MSG_CLIENT_REQUEST 24
131 #define CEPH_MSG_CLIENT_REQUEST_FORWARD 25
132 #define CEPH_MSG_CLIENT_REPLY 26
133 #define CEPH_MSG_CLIENT_METRICS 29
134 #define CEPH_MSG_CLIENT_CAPS 0x310
135 #define CEPH_MSG_CLIENT_LEASE 0x311
136 #define CEPH_MSG_CLIENT_SNAP 0x312
137 #define CEPH_MSG_CLIENT_CAPRELEASE 0x313
138 #define CEPH_MSG_CLIENT_QUOTA 0x314
141 #define CEPH_MSG_POOLOP_REPLY 48
142 #define CEPH_MSG_POOLOP 49
145 #define CEPH_MSG_MON_COMMAND 50
146 #define CEPH_MSG_MON_COMMAND_ACK 51
149 #define CEPH_MSG_OSD_MAP 41
150 #define CEPH_MSG_OSD_OP 42
151 #define CEPH_MSG_OSD_OPREPLY 43
152 #define CEPH_MSG_WATCH_NOTIFY 44
153 #define CEPH_MSG_OSD_BACKOFF 61
156 /* watch-notify operations */
158 CEPH_WATCH_EVENT_NOTIFY = 1, /* notifying watcher */
159 CEPH_WATCH_EVENT_NOTIFY_COMPLETE = 2, /* notifier notified when done */
160 CEPH_WATCH_EVENT_DISCONNECT = 3, /* we were disconnected */
164 struct ceph_mon_request_header {
167 __le64 session_mon_tid;
168 } __attribute__ ((packed));
170 struct ceph_mon_statfs {
171 struct ceph_mon_request_header monhdr;
172 struct ceph_fsid fsid;
173 __u8 contains_data_pool;
175 } __attribute__ ((packed));
178 __le64 kb, kb_used, kb_avail;
180 } __attribute__ ((packed));
182 struct ceph_mon_statfs_reply {
183 struct ceph_fsid fsid;
185 struct ceph_statfs st;
186 } __attribute__ ((packed));
188 struct ceph_mon_command {
189 struct ceph_mon_request_header monhdr;
190 struct ceph_fsid fsid;
191 __le32 num_strs; /* always 1 */
194 } __attribute__ ((packed));
196 struct ceph_osd_getmap {
197 struct ceph_mon_request_header monhdr;
198 struct ceph_fsid fsid;
200 } __attribute__ ((packed));
202 struct ceph_mds_getmap {
203 struct ceph_mon_request_header monhdr;
204 struct ceph_fsid fsid;
205 } __attribute__ ((packed));
207 struct ceph_client_mount {
208 struct ceph_mon_request_header monhdr;
209 } __attribute__ ((packed));
211 #define CEPH_SUBSCRIBE_ONETIME 1 /* i want only 1 update after have */
213 struct ceph_mon_subscribe_item {
216 } __attribute__ ((packed));
218 struct ceph_mon_subscribe_ack {
219 __le32 duration; /* seconds */
220 struct ceph_fsid fsid;
221 } __attribute__ ((packed));
223 #define CEPH_FS_CLUSTER_ID_NONE -1
228 #define CEPH_MDSMAP_DOWN (1<<0) /* cluster deliberately down */
235 #define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */
236 #define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees.
238 #define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */
239 #define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */
240 #define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */
241 #define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */
242 #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */
243 #define CEPH_MDS_STATE_REPLAYONCE -9 /* up, replaying an active node's journal */
245 #define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */
246 #define CEPH_MDS_STATE_RESOLVE 9 /* up, disambiguating distributed
247 operations (import, rename, etc.) */
248 #define CEPH_MDS_STATE_RECONNECT 10 /* up, reconnect to clients */
249 #define CEPH_MDS_STATE_REJOIN 11 /* up, rejoining distributed cache */
250 #define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */
251 #define CEPH_MDS_STATE_ACTIVE 13 /* up, active */
252 #define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */
254 extern const char *ceph_mds_state_name(int s);
258 * metadata lock types.
259 * - these are bitmasks.. we can compose them
260 * - they also define the lock ordering by the MDS
261 * - a few of these are internal to the mds
263 #define CEPH_LOCK_DVERSION 1
264 #define CEPH_LOCK_DN 2
265 #define CEPH_LOCK_ISNAP 16
266 #define CEPH_LOCK_IVERSION 32 /* mds internal */
267 #define CEPH_LOCK_IFILE 64
268 #define CEPH_LOCK_IAUTH 128
269 #define CEPH_LOCK_ILINK 256
270 #define CEPH_LOCK_IDFT 512 /* dir frag tree */
271 #define CEPH_LOCK_INEST 1024 /* mds internal */
272 #define CEPH_LOCK_IXATTR 2048
273 #define CEPH_LOCK_IFLOCK 4096 /* advisory file locks */
274 #define CEPH_LOCK_INO 8192 /* immutable inode bits; not a lock */
275 #define CEPH_LOCK_IPOLICY 16384 /* policy lock on dirs. MDS internal */
277 /* client_session ops */
279 CEPH_SESSION_REQUEST_OPEN,
281 CEPH_SESSION_REQUEST_CLOSE,
283 CEPH_SESSION_REQUEST_RENEWCAPS,
284 CEPH_SESSION_RENEWCAPS,
286 CEPH_SESSION_RECALL_STATE,
287 CEPH_SESSION_FLUSHMSG,
288 CEPH_SESSION_FLUSHMSG_ACK,
289 CEPH_SESSION_FORCE_RO,
291 CEPH_SESSION_REQUEST_FLUSH_MDLOG,
294 extern const char *ceph_session_op_name(int op);
296 struct ceph_mds_session_head {
299 struct ceph_timespec stamp;
300 __le32 max_caps, max_leases;
301 } __attribute__ ((packed));
306 * & 0x001000 -> write op
307 * & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
308 & & 0x100000 -> use weird ino/path trace
310 #define CEPH_MDS_OP_WRITE 0x001000
312 CEPH_MDS_OP_LOOKUP = 0x00100,
313 CEPH_MDS_OP_GETATTR = 0x00101,
314 CEPH_MDS_OP_LOOKUPHASH = 0x00102,
315 CEPH_MDS_OP_LOOKUPPARENT = 0x00103,
316 CEPH_MDS_OP_LOOKUPINO = 0x00104,
317 CEPH_MDS_OP_LOOKUPNAME = 0x00105,
319 CEPH_MDS_OP_SETXATTR = 0x01105,
320 CEPH_MDS_OP_RMXATTR = 0x01106,
321 CEPH_MDS_OP_SETLAYOUT = 0x01107,
322 CEPH_MDS_OP_SETATTR = 0x01108,
323 CEPH_MDS_OP_SETFILELOCK= 0x01109,
324 CEPH_MDS_OP_GETFILELOCK= 0x00110,
325 CEPH_MDS_OP_SETDIRLAYOUT=0x0110a,
327 CEPH_MDS_OP_MKNOD = 0x01201,
328 CEPH_MDS_OP_LINK = 0x01202,
329 CEPH_MDS_OP_UNLINK = 0x01203,
330 CEPH_MDS_OP_RENAME = 0x01204,
331 CEPH_MDS_OP_MKDIR = 0x01220,
332 CEPH_MDS_OP_RMDIR = 0x01221,
333 CEPH_MDS_OP_SYMLINK = 0x01222,
335 CEPH_MDS_OP_CREATE = 0x01301,
336 CEPH_MDS_OP_OPEN = 0x00302,
337 CEPH_MDS_OP_READDIR = 0x00305,
339 CEPH_MDS_OP_LOOKUPSNAP = 0x00400,
340 CEPH_MDS_OP_MKSNAP = 0x01400,
341 CEPH_MDS_OP_RMSNAP = 0x01401,
342 CEPH_MDS_OP_LSSNAP = 0x00402,
343 CEPH_MDS_OP_RENAMESNAP = 0x01403,
346 extern const char *ceph_mds_op_name(int op);
349 #define CEPH_SETATTR_MODE 1
350 #define CEPH_SETATTR_UID 2
351 #define CEPH_SETATTR_GID 4
352 #define CEPH_SETATTR_MTIME 8
353 #define CEPH_SETATTR_ATIME 16
354 #define CEPH_SETATTR_SIZE 32
355 #define CEPH_SETATTR_CTIME 64
358 * Ceph setxattr request flags.
360 #define CEPH_XATTR_CREATE (1 << 0)
361 #define CEPH_XATTR_REPLACE (1 << 1)
362 #define CEPH_XATTR_REMOVE (1 << 31)
365 * readdir request flags;
367 #define CEPH_READDIR_REPLY_BITFLAGS (1<<0)
370 * readdir reply flags.
372 #define CEPH_READDIR_FRAG_END (1<<0)
373 #define CEPH_READDIR_FRAG_COMPLETE (1<<8)
374 #define CEPH_READDIR_HASH_ORDER (1<<9)
375 #define CEPH_READDIR_OFFSET_HASH (1<<10)
380 #define CEPH_O_RDONLY 00000000
381 #define CEPH_O_WRONLY 00000001
382 #define CEPH_O_RDWR 00000002
383 #define CEPH_O_CREAT 00000100
384 #define CEPH_O_EXCL 00000200
385 #define CEPH_O_TRUNC 00001000
386 #define CEPH_O_DIRECTORY 00200000
387 #define CEPH_O_NOFOLLOW 00400000
389 union ceph_mds_request_args {
391 __le32 mask; /* CEPH_CAP_* */
392 } __attribute__ ((packed)) getattr;
397 struct ceph_timespec mtime;
398 struct ceph_timespec atime;
399 __le64 size, old_size; /* old_size needed by truncate */
400 __le32 mask; /* CEPH_SETATTR_* */
401 } __attribute__ ((packed)) setattr;
403 __le32 frag; /* which dir fragment */
404 __le32 max_entries; /* how many dentries to grab */
408 } __attribute__ ((packed)) readdir;
412 } __attribute__ ((packed)) mknod;
415 } __attribute__ ((packed)) mkdir;
419 __le32 stripe_unit; /* layout for newly created file */
420 __le32 stripe_count; /* ... */
422 __le32 file_replication;
423 __le32 mask; /* CEPH_CAP_* */
425 } __attribute__ ((packed)) open;
428 } __attribute__ ((packed)) setxattr;
430 struct ceph_file_layout_legacy layout;
431 } __attribute__ ((packed)) setlayout;
433 __u8 rule; /* currently fcntl or flock */
434 __u8 type; /* shared, exclusive, remove*/
435 __le64 owner; /* owner of the lock */
436 __le64 pid; /* process id requesting the lock */
437 __le64 start; /* initial location to lock */
438 __le64 length; /* num bytes to lock from start */
439 __u8 wait; /* will caller wait for lock to become available? */
440 } __attribute__ ((packed)) filelock_change;
442 __le32 mask; /* CEPH_CAP_* */
446 } __attribute__ ((packed)) lookupino;
447 } __attribute__ ((packed));
449 #define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */
450 #define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */
451 #define CEPH_MDS_FLAG_ASYNC 4 /* request is asynchronous */
453 struct ceph_mds_request_head {
454 __le64 oldest_client_tid;
455 __le32 mdsmap_epoch; /* on client */
456 __le32 flags; /* CEPH_MDS_FLAG_* */
457 __u8 num_retry, num_fwd; /* count retry, fwd attempts */
458 __le16 num_releases; /* # include cap/lease release records */
459 __le32 op; /* mds op code */
460 __le32 caller_uid, caller_gid;
461 __le64 ino; /* use this ino for openc, mkdir, mknod,
462 etc. (if replaying) */
463 union ceph_mds_request_args args;
464 } __attribute__ ((packed));
466 /* cap/lease release record */
467 struct ceph_mds_request_release {
468 __le64 ino, cap_id; /* ino and unique cap id */
469 __le32 caps, wanted; /* new issued, wanted */
470 __le32 seq, issue_seq, mseq;
471 __le32 dname_seq; /* if releasing a dentry lease, a */
472 __le32 dname_len; /* string follows. */
473 } __attribute__ ((packed));
476 struct ceph_mds_reply_head {
480 __u8 safe; /* true if committed to disk */
481 __u8 is_dentry, is_target; /* true if dentry, target inode records
482 are included with reply */
483 } __attribute__ ((packed));
485 /* one for each node split */
486 struct ceph_frag_tree_split {
487 __le32 frag; /* this frag splits... */
488 __le32 by; /* ...by this many bits */
489 } __attribute__ ((packed));
491 struct ceph_frag_tree_head {
492 __le32 nsplits; /* num ceph_frag_tree_split records */
493 struct ceph_frag_tree_split splits[];
494 } __attribute__ ((packed));
496 /* capability issue, for bundling with mds reply */
497 struct ceph_mds_reply_cap {
498 __le32 caps, wanted; /* caps issued, wanted */
501 __le64 realm; /* snap realm */
502 __u8 flags; /* CEPH_CAP_FLAG_* */
503 } __attribute__ ((packed));
505 #define CEPH_CAP_FLAG_AUTH (1 << 0) /* cap is issued by auth mds */
506 #define CEPH_CAP_FLAG_RELEASE (1 << 1) /* release the cap */
508 /* inode record, for bundling with mds reply */
509 struct ceph_mds_reply_inode {
513 __le64 version; /* inode version */
514 __le64 xattr_version; /* version for xattr blob */
515 struct ceph_mds_reply_cap cap; /* caps issued for this inode */
516 struct ceph_file_layout_legacy layout;
517 struct ceph_timespec ctime, mtime, atime;
518 __le32 time_warp_seq;
519 __le64 size, max_size, truncate_size;
521 __le32 mode, uid, gid;
523 __le64 files, subdirs, rbytes, rfiles, rsubdirs; /* dir stats */
524 struct ceph_timespec rctime;
525 struct ceph_frag_tree_head fragtree; /* (must be at end of struct) */
526 } __attribute__ ((packed));
527 /* followed by frag array, symlink string, dir layout, xattr blob */
529 /* reply_lease follows dname, and reply_inode */
530 struct ceph_mds_reply_lease {
531 __le16 mask; /* lease type(s) */
532 __le32 duration_ms; /* lease duration */
534 } __attribute__ ((packed));
536 #define CEPH_LEASE_VALID (1 | 2) /* old and new bit values */
537 #define CEPH_LEASE_PRIMARY_LINK 4 /* primary linkage */
539 struct ceph_mds_reply_dirfrag {
540 __le32 frag; /* fragment */
541 __le32 auth; /* auth mds, if this is a delegation point */
542 __le32 ndist; /* number of mds' this is replicated on */
544 } __attribute__ ((packed));
546 #define CEPH_LOCK_FCNTL 1
547 #define CEPH_LOCK_FLOCK 2
548 #define CEPH_LOCK_FCNTL_INTR 3
549 #define CEPH_LOCK_FLOCK_INTR 4
552 #define CEPH_LOCK_SHARED 1
553 #define CEPH_LOCK_EXCL 2
554 #define CEPH_LOCK_UNLOCK 4
556 struct ceph_filelock {
557 __le64 start;/* file offset to start lock at */
558 __le64 length; /* num bytes to lock; 0 for all following start */
559 __le64 client; /* which client holds the lock */
560 __le64 owner; /* owner the lock */
561 __le64 pid; /* process id holding the lock on the client */
562 __u8 type; /* shared lock, exclusive lock, or unlock */
563 } __attribute__ ((packed));
566 /* file access modes */
567 #define CEPH_FILE_MODE_PIN 0
568 #define CEPH_FILE_MODE_RD 1
569 #define CEPH_FILE_MODE_WR 2
570 #define CEPH_FILE_MODE_RDWR 3 /* RD | WR */
571 #define CEPH_FILE_MODE_LAZY 4 /* lazy io */
572 #define CEPH_FILE_MODE_BITS 4
573 #define CEPH_FILE_MODE_MASK ((1 << CEPH_FILE_MODE_BITS) - 1)
575 int ceph_flags_to_mode(int flags);
577 #define CEPH_INLINE_NONE ((__u64)-1)
579 /* capability bits */
580 #define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */
582 /* generic cap bits */
583 #define CEPH_CAP_GSHARED 1 /* client can reads */
584 #define CEPH_CAP_GEXCL 2 /* client can read and update */
585 #define CEPH_CAP_GCACHE 4 /* (file) client can cache reads */
586 #define CEPH_CAP_GRD 8 /* (file) client can read */
587 #define CEPH_CAP_GWR 16 /* (file) client can write */
588 #define CEPH_CAP_GBUFFER 32 /* (file) client can buffer writes */
589 #define CEPH_CAP_GWREXTEND 64 /* (file) client can extend EOF */
590 #define CEPH_CAP_GLAZYIO 128 /* (file) client can perform lazy io */
592 #define CEPH_CAP_SIMPLE_BITS 2
593 #define CEPH_CAP_FILE_BITS 8
596 #define CEPH_CAP_SAUTH 2
597 #define CEPH_CAP_SLINK 4
598 #define CEPH_CAP_SXATTR 6
599 #define CEPH_CAP_SFILE 8
600 #define CEPH_CAP_SFLOCK 20
602 #define CEPH_CAP_BITS 22
604 /* composed values */
605 #define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH)
606 #define CEPH_CAP_AUTH_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SAUTH)
607 #define CEPH_CAP_LINK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SLINK)
608 #define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK)
609 #define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SXATTR)
610 #define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR)
611 #define CEPH_CAP_FILE(x) (x << CEPH_CAP_SFILE)
612 #define CEPH_CAP_FILE_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFILE)
613 #define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE)
614 #define CEPH_CAP_FILE_CACHE (CEPH_CAP_GCACHE << CEPH_CAP_SFILE)
615 #define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE)
616 #define CEPH_CAP_FILE_WR (CEPH_CAP_GWR << CEPH_CAP_SFILE)
617 #define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE)
618 #define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
619 #define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE)
620 #define CEPH_CAP_FLOCK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFLOCK)
621 #define CEPH_CAP_FLOCK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFLOCK)
624 /* cap masks (for getattr) */
625 #define CEPH_STAT_CAP_INODE CEPH_CAP_PIN
626 #define CEPH_STAT_CAP_TYPE CEPH_CAP_PIN /* mode >> 12 */
627 #define CEPH_STAT_CAP_SYMLINK CEPH_CAP_PIN
628 #define CEPH_STAT_CAP_UID CEPH_CAP_AUTH_SHARED
629 #define CEPH_STAT_CAP_GID CEPH_CAP_AUTH_SHARED
630 #define CEPH_STAT_CAP_MODE CEPH_CAP_AUTH_SHARED
631 #define CEPH_STAT_CAP_NLINK CEPH_CAP_LINK_SHARED
632 #define CEPH_STAT_CAP_LAYOUT CEPH_CAP_FILE_SHARED
633 #define CEPH_STAT_CAP_MTIME CEPH_CAP_FILE_SHARED
634 #define CEPH_STAT_CAP_SIZE CEPH_CAP_FILE_SHARED
635 #define CEPH_STAT_CAP_ATIME CEPH_CAP_FILE_SHARED /* fixme */
636 #define CEPH_STAT_CAP_XATTR CEPH_CAP_XATTR_SHARED
637 #define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN | \
638 CEPH_CAP_AUTH_SHARED | \
639 CEPH_CAP_LINK_SHARED | \
640 CEPH_CAP_FILE_SHARED | \
641 CEPH_CAP_XATTR_SHARED)
642 #define CEPH_STAT_CAP_INLINE_DATA (CEPH_CAP_FILE_SHARED | \
644 #define CEPH_STAT_RSTAT CEPH_CAP_FILE_WREXTEND
646 #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \
647 CEPH_CAP_LINK_SHARED | \
648 CEPH_CAP_XATTR_SHARED | \
649 CEPH_CAP_FILE_SHARED)
650 #define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \
653 #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \
654 CEPH_CAP_LINK_EXCL | \
655 CEPH_CAP_XATTR_EXCL | \
657 #define CEPH_CAP_ANY_FILE_RD (CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE | \
658 CEPH_CAP_FILE_SHARED)
659 #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \
661 #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
662 #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
663 CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \
665 #define CEPH_CAP_ALL_FILE (CEPH_CAP_PIN | CEPH_CAP_ANY_SHARED | \
666 CEPH_CAP_AUTH_EXCL | CEPH_CAP_XATTR_EXCL | \
667 CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)
669 #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
672 /* cap masks async dir operations */
673 #define CEPH_CAP_DIR_CREATE CEPH_CAP_FILE_CACHE
674 #define CEPH_CAP_DIR_UNLINK CEPH_CAP_FILE_RD
675 #define CEPH_CAP_ANY_DIR_OPS (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_RD | \
676 CEPH_CAP_FILE_WREXTEND | CEPH_CAP_FILE_LAZYIO)
678 int ceph_caps_for_mode(int mode);
681 CEPH_CAP_OP_GRANT, /* mds->client grant */
682 CEPH_CAP_OP_REVOKE, /* mds->client revoke */
683 CEPH_CAP_OP_TRUNC, /* mds->client trunc notify */
684 CEPH_CAP_OP_EXPORT, /* mds has exported the cap */
685 CEPH_CAP_OP_IMPORT, /* mds has imported the cap */
686 CEPH_CAP_OP_UPDATE, /* client->mds update */
687 CEPH_CAP_OP_DROP, /* client->mds drop cap bits */
688 CEPH_CAP_OP_FLUSH, /* client->mds cap writeback */
689 CEPH_CAP_OP_FLUSH_ACK, /* mds->client flushed */
690 CEPH_CAP_OP_FLUSHSNAP, /* client->mds flush snapped metadata */
691 CEPH_CAP_OP_FLUSHSNAP_ACK, /* mds->client flushed snapped metadata */
692 CEPH_CAP_OP_RELEASE, /* client->mds release (clean) cap */
693 CEPH_CAP_OP_RENEW, /* client->mds renewal request */
696 extern const char *ceph_cap_op_name(int op);
698 /* flags field in client cap messages (version >= 10) */
699 #define CEPH_CLIENT_CAPS_SYNC (1<<0)
700 #define CEPH_CLIENT_CAPS_NO_CAPSNAP (1<<1)
701 #define CEPH_CLIENT_CAPS_PENDING_CAPSNAP (1<<2)
704 * caps message, used for capability callbacks, acks, requests, etc.
706 struct ceph_mds_caps {
707 __le32 op; /* CEPH_CAP_OP_* */
710 __le32 seq, issue_seq;
711 __le32 caps, wanted, dirty; /* latest issued/wanted/dirty */
714 __le32 snap_trace_len;
717 __le32 uid, gid, mode;
724 __le64 xattr_version;
727 __le64 size, max_size, truncate_size;
729 struct ceph_timespec mtime, atime, ctime;
730 struct ceph_file_layout_legacy layout;
731 __le32 time_warp_seq;
732 } __attribute__ ((packed));
734 struct ceph_mds_cap_peer {
740 } __attribute__ ((packed));
742 /* cap release msg head */
743 struct ceph_mds_cap_release {
744 __le32 num; /* number of cap_items that follow */
745 } __attribute__ ((packed));
747 struct ceph_mds_cap_item {
750 __le32 migrate_seq, seq;
751 } __attribute__ ((packed));
753 #define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */
754 #define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */
755 #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */
756 #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */
758 extern const char *ceph_lease_op_name(int o);
760 /* lease msg header */
761 struct ceph_mds_lease {
762 __u8 action; /* CEPH_MDS_LEASE_* */
763 __le16 mask; /* which lease */
765 __le64 first, last; /* snap range */
767 __le32 duration_ms; /* duration of renewal */
768 } __attribute__ ((packed));
769 /* followed by a __le32+string for dname */
771 /* client reconnect */
772 struct ceph_mds_cap_reconnect {
777 __le64 pathbase; /* base ino for our path to this ino */
778 __le32 flock_len; /* size of flock state blob, if any */
779 } __attribute__ ((packed));
780 /* followed by flock blob */
782 struct ceph_mds_cap_reconnect_v1 {
787 struct ceph_timespec mtime, atime;
789 __le64 pathbase; /* base ino for our path to this ino */
790 } __attribute__ ((packed));
792 struct ceph_mds_snaprealm_reconnect {
793 __le64 ino; /* snap realm base */
794 __le64 seq; /* snap seq for this snap realm */
795 __le64 parent; /* parent realm */
796 } __attribute__ ((packed));
802 CEPH_SNAP_OP_UPDATE, /* CREATE or DESTROY */
804 CEPH_SNAP_OP_DESTROY,
808 extern const char *ceph_snap_op_name(int o);
810 /* snap msg header */
811 struct ceph_mds_snap_head {
812 __le32 op; /* CEPH_SNAP_OP_* */
813 __le64 split; /* ino to split off, if any */
814 __le32 num_split_inos; /* # inos belonging to new child realm */
815 __le32 num_split_realms; /* # child realms udner new child realm */
816 __le32 trace_len; /* size of snap trace blob */
817 } __attribute__ ((packed));
818 /* followed by split ino list, then split realms, then the trace blob */
821 * encode info about a snaprealm, as viewed by a client
823 struct ceph_mds_snap_realm {
824 __le64 ino; /* ino */
825 __le64 created; /* snap: when created */
826 __le64 parent; /* ino: parent realm */
827 __le64 parent_since; /* snap: same parent since */
828 __le64 seq; /* snap: version */
830 __le32 num_prior_parent_snaps;
831 } __attribute__ ((packed));
832 /* followed by my snap list, then prior parent snap list */
837 struct ceph_mds_quota {
838 __le64 ino; /* ino */
839 struct ceph_timespec rctime;
840 __le64 rbytes; /* dir stats */
843 __u8 struct_v; /* compat */
846 __le64 max_bytes; /* quota max. bytes */
847 __le64 max_files; /* quota max. files */
848 } __attribute__ ((packed));