2 * ceph_fs.h - Ceph constants and data types to share between kernel and
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.
15 #include <linux/ceph/msgr.h>
16 #include <linux/ceph/rados.h>
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.
24 #define CEPH_OSDC_PROTOCOL 24 /* server/client */
25 #define CEPH_MDSC_PROTOCOL 32 /* server/client */
26 #define CEPH_MONC_PROTOCOL 15 /* server/client */
29 #define CEPH_INO_ROOT 1
30 #define CEPH_INO_CEPH 2 /* hidden .ceph dir */
31 #define CEPH_INO_DOTDOT 3 /* used by ceph fuse for parent (..) */
33 /* arbitrary limit on max # of monitors (cluster of 3 is typical) */
34 #define CEPH_MAX_MON 31
37 * ceph_file_layout - describe data layout for a file/inode
39 struct ceph_file_layout
{
40 /* file -> object mapping */
41 __le32 fl_stripe_unit
; /* stripe unit, in bytes. must be multiple
43 __le32 fl_stripe_count
; /* over this many objects */
44 __le32 fl_object_size
; /* until objects are this big, then move to
46 __le32 fl_cas_hash
; /* UNUSED. 0 = none; 1 = sha256 */
48 /* pg -> disk layout */
49 __le32 fl_object_stripe_unit
; /* UNUSED. for per-object parity, if any */
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
));
56 #define ceph_file_layout_su(l) ((__s32)le32_to_cpu((l).fl_stripe_unit))
57 #define ceph_file_layout_stripe_count(l) \
58 ((__s32)le32_to_cpu((l).fl_stripe_count))
59 #define ceph_file_layout_object_size(l) ((__s32)le32_to_cpu((l).fl_object_size))
60 #define ceph_file_layout_cas_hash(l) ((__s32)le32_to_cpu((l).fl_cas_hash))
61 #define ceph_file_layout_object_su(l) \
62 ((__s32)le32_to_cpu((l).fl_object_stripe_unit))
63 #define ceph_file_layout_pg_pool(l) \
64 ((__s32)le32_to_cpu((l).fl_pg_pool))
66 static inline unsigned ceph_file_layout_stripe_width(struct ceph_file_layout
*l
)
68 return le32_to_cpu(l
->fl_stripe_unit
) *
69 le32_to_cpu(l
->fl_stripe_count
);
72 /* "period" == bytes before i start on a new set of objects */
73 static inline unsigned ceph_file_layout_period(struct ceph_file_layout
*l
)
75 return le32_to_cpu(l
->fl_object_size
) *
76 le32_to_cpu(l
->fl_stripe_count
);
79 #define CEPH_MIN_STRIPE_UNIT 65536
81 int ceph_file_layout_is_valid(const struct ceph_file_layout
*layout
);
83 struct ceph_dir_layout
{
84 __u8 dl_dir_hash
; /* see ceph_hash.h for ids */
88 } __attribute__ ((packed
));
90 /* crypto algorithms */
91 #define CEPH_CRYPTO_NONE 0x0
92 #define CEPH_CRYPTO_AES 0x1
94 #define CEPH_AES_IV "cephsageyudagreg"
96 /* security/authentication protocols */
97 #define CEPH_AUTH_UNKNOWN 0x0
98 #define CEPH_AUTH_NONE 0x1
99 #define CEPH_AUTH_CEPHX 0x2
101 #define CEPH_AUTH_UID_DEFAULT ((__u64) -1)
104 /*********************************************
113 #define CEPH_MSG_SHUTDOWN 1
114 #define CEPH_MSG_PING 2
116 /* client <-> monitor */
117 #define CEPH_MSG_MON_MAP 4
118 #define CEPH_MSG_MON_GET_MAP 5
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
123 #define CEPH_MSG_AUTH 17
124 #define CEPH_MSG_AUTH_REPLY 18
125 #define CEPH_MSG_MON_GET_VERSION 19
126 #define CEPH_MSG_MON_GET_VERSION_REPLY 20
129 #define CEPH_MSG_MDS_MAP 21
131 #define CEPH_MSG_CLIENT_SESSION 22
132 #define CEPH_MSG_CLIENT_RECONNECT 23
134 #define CEPH_MSG_CLIENT_REQUEST 24
135 #define CEPH_MSG_CLIENT_REQUEST_FORWARD 25
136 #define CEPH_MSG_CLIENT_REPLY 26
137 #define CEPH_MSG_CLIENT_CAPS 0x310
138 #define CEPH_MSG_CLIENT_LEASE 0x311
139 #define CEPH_MSG_CLIENT_SNAP 0x312
140 #define CEPH_MSG_CLIENT_CAPRELEASE 0x313
143 #define CEPH_MSG_POOLOP_REPLY 48
144 #define CEPH_MSG_POOLOP 49
148 #define CEPH_MSG_OSD_MAP 41
149 #define CEPH_MSG_OSD_OP 42
150 #define CEPH_MSG_OSD_OPREPLY 43
151 #define CEPH_MSG_WATCH_NOTIFY 44
154 /* watch-notify operations */
156 WATCH_NOTIFY
= 1, /* notifying watcher */
157 WATCH_NOTIFY_COMPLETE
= 2, /* notifier notified when done */
161 /* pool operations */
163 POOL_OP_CREATE
= 0x01,
164 POOL_OP_DELETE
= 0x02,
165 POOL_OP_AUID_CHANGE
= 0x03,
166 POOL_OP_CREATE_SNAP
= 0x11,
167 POOL_OP_DELETE_SNAP
= 0x12,
168 POOL_OP_CREATE_UNMANAGED_SNAP
= 0x21,
169 POOL_OP_DELETE_UNMANAGED_SNAP
= 0x22,
172 struct ceph_mon_request_header
{
175 __le64 session_mon_tid
;
176 } __attribute__ ((packed
));
178 struct ceph_mon_statfs
{
179 struct ceph_mon_request_header monhdr
;
180 struct ceph_fsid fsid
;
181 } __attribute__ ((packed
));
184 __le64 kb
, kb_used
, kb_avail
;
186 } __attribute__ ((packed
));
188 struct ceph_mon_statfs_reply
{
189 struct ceph_fsid fsid
;
191 struct ceph_statfs st
;
192 } __attribute__ ((packed
));
194 const char *ceph_pool_op_name(int op
);
196 struct ceph_mon_poolop
{
197 struct ceph_mon_request_header monhdr
;
198 struct ceph_fsid fsid
;
204 } __attribute__ ((packed
));
206 struct ceph_mon_poolop_reply
{
207 struct ceph_mon_request_header monhdr
;
208 struct ceph_fsid fsid
;
213 } __attribute__ ((packed
));
215 struct ceph_mon_unmanaged_snap
{
217 } __attribute__ ((packed
));
219 struct ceph_osd_getmap
{
220 struct ceph_mon_request_header monhdr
;
221 struct ceph_fsid fsid
;
223 } __attribute__ ((packed
));
225 struct ceph_mds_getmap
{
226 struct ceph_mon_request_header monhdr
;
227 struct ceph_fsid fsid
;
228 } __attribute__ ((packed
));
230 struct ceph_client_mount
{
231 struct ceph_mon_request_header monhdr
;
232 } __attribute__ ((packed
));
234 #define CEPH_SUBSCRIBE_ONETIME 1 /* i want only 1 update after have */
236 struct ceph_mon_subscribe_item
{
237 __le64 have_version
; __le64 have
;
239 } __attribute__ ((packed
));
241 struct ceph_mon_subscribe_ack
{
242 __le32 duration
; /* seconds */
243 struct ceph_fsid fsid
;
244 } __attribute__ ((packed
));
249 #define CEPH_MDSMAP_DOWN (1<<0) /* cluster deliberately down */
256 #define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */
257 #define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees.
259 #define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */
260 #define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */
261 #define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */
262 #define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */
263 #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */
264 #define CEPH_MDS_STATE_REPLAYONCE -9 /* up, replaying an active node's journal */
266 #define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */
267 #define CEPH_MDS_STATE_RESOLVE 9 /* up, disambiguating distributed
268 operations (import, rename, etc.) */
269 #define CEPH_MDS_STATE_RECONNECT 10 /* up, reconnect to clients */
270 #define CEPH_MDS_STATE_REJOIN 11 /* up, rejoining distributed cache */
271 #define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */
272 #define CEPH_MDS_STATE_ACTIVE 13 /* up, active */
273 #define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */
275 extern const char *ceph_mds_state_name(int s
);
279 * metadata lock types.
280 * - these are bitmasks.. we can compose them
281 * - they also define the lock ordering by the MDS
282 * - a few of these are internal to the mds
284 #define CEPH_LOCK_DVERSION 1
285 #define CEPH_LOCK_DN 2
286 #define CEPH_LOCK_ISNAP 16
287 #define CEPH_LOCK_IVERSION 32 /* mds internal */
288 #define CEPH_LOCK_IFILE 64
289 #define CEPH_LOCK_IAUTH 128
290 #define CEPH_LOCK_ILINK 256
291 #define CEPH_LOCK_IDFT 512 /* dir frag tree */
292 #define CEPH_LOCK_INEST 1024 /* mds internal */
293 #define CEPH_LOCK_IXATTR 2048
294 #define CEPH_LOCK_IFLOCK 4096 /* advisory file locks */
295 #define CEPH_LOCK_INO 8192 /* immutable inode bits; not a lock */
296 #define CEPH_LOCK_IPOLICY 16384 /* policy lock on dirs. MDS internal */
298 /* client_session ops */
300 CEPH_SESSION_REQUEST_OPEN
,
302 CEPH_SESSION_REQUEST_CLOSE
,
304 CEPH_SESSION_REQUEST_RENEWCAPS
,
305 CEPH_SESSION_RENEWCAPS
,
307 CEPH_SESSION_RECALL_STATE
,
308 CEPH_SESSION_FLUSHMSG
,
309 CEPH_SESSION_FLUSHMSG_ACK
,
312 extern const char *ceph_session_op_name(int op
);
314 struct ceph_mds_session_head
{
317 struct ceph_timespec stamp
;
318 __le32 max_caps
, max_leases
;
319 } __attribute__ ((packed
));
324 * & 0x001000 -> write op
325 * & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
326 & & 0x100000 -> use weird ino/path trace
328 #define CEPH_MDS_OP_WRITE 0x001000
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,
336 CEPH_MDS_OP_SETXATTR
= 0x01105,
337 CEPH_MDS_OP_RMXATTR
= 0x01106,
338 CEPH_MDS_OP_SETLAYOUT
= 0x01107,
339 CEPH_MDS_OP_SETATTR
= 0x01108,
340 CEPH_MDS_OP_SETFILELOCK
= 0x01109,
341 CEPH_MDS_OP_GETFILELOCK
= 0x00110,
342 CEPH_MDS_OP_SETDIRLAYOUT
=0x0110a,
344 CEPH_MDS_OP_MKNOD
= 0x01201,
345 CEPH_MDS_OP_LINK
= 0x01202,
346 CEPH_MDS_OP_UNLINK
= 0x01203,
347 CEPH_MDS_OP_RENAME
= 0x01204,
348 CEPH_MDS_OP_MKDIR
= 0x01220,
349 CEPH_MDS_OP_RMDIR
= 0x01221,
350 CEPH_MDS_OP_SYMLINK
= 0x01222,
352 CEPH_MDS_OP_CREATE
= 0x01301,
353 CEPH_MDS_OP_OPEN
= 0x00302,
354 CEPH_MDS_OP_READDIR
= 0x00305,
356 CEPH_MDS_OP_LOOKUPSNAP
= 0x00400,
357 CEPH_MDS_OP_MKSNAP
= 0x01400,
358 CEPH_MDS_OP_RMSNAP
= 0x01401,
359 CEPH_MDS_OP_LSSNAP
= 0x00402,
362 extern const char *ceph_mds_op_name(int op
);
365 #define CEPH_SETATTR_MODE 1
366 #define CEPH_SETATTR_UID 2
367 #define CEPH_SETATTR_GID 4
368 #define CEPH_SETATTR_MTIME 8
369 #define CEPH_SETATTR_ATIME 16
370 #define CEPH_SETATTR_SIZE 32
371 #define CEPH_SETATTR_CTIME 64
374 * Ceph setxattr request flags.
376 #define CEPH_XATTR_CREATE 1
377 #define CEPH_XATTR_REPLACE 2
379 union ceph_mds_request_args
{
381 __le32 mask
; /* CEPH_CAP_* */
382 } __attribute__ ((packed
)) getattr
;
387 struct ceph_timespec mtime
;
388 struct ceph_timespec atime
;
389 __le64 size
, old_size
; /* old_size needed by truncate */
390 __le32 mask
; /* CEPH_SETATTR_* */
391 } __attribute__ ((packed
)) setattr
;
393 __le32 frag
; /* which dir fragment */
394 __le32 max_entries
; /* how many dentries to grab */
396 } __attribute__ ((packed
)) readdir
;
400 } __attribute__ ((packed
)) mknod
;
403 } __attribute__ ((packed
)) mkdir
;
407 __le32 stripe_unit
; /* layout for newly created file */
408 __le32 stripe_count
; /* ... */
410 __le32 file_replication
;
411 __le32 unused
; /* used to be preferred osd */
412 } __attribute__ ((packed
)) open
;
415 } __attribute__ ((packed
)) setxattr
;
417 struct ceph_file_layout layout
;
418 } __attribute__ ((packed
)) setlayout
;
420 __u8 rule
; /* currently fcntl or flock */
421 __u8 type
; /* shared, exclusive, remove*/
422 __le64 pid
; /* process id requesting the lock */
423 __le64 pid_namespace
;
424 __le64 start
; /* initial location to lock */
425 __le64 length
; /* num bytes to lock from start */
426 __u8 wait
; /* will caller wait for lock to become available? */
427 } __attribute__ ((packed
)) filelock_change
;
428 } __attribute__ ((packed
));
430 #define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */
431 #define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */
433 struct ceph_mds_request_head
{
434 __le64 oldest_client_tid
;
435 __le32 mdsmap_epoch
; /* on client */
436 __le32 flags
; /* CEPH_MDS_FLAG_* */
437 __u8 num_retry
, num_fwd
; /* count retry, fwd attempts */
438 __le16 num_releases
; /* # include cap/lease release records */
439 __le32 op
; /* mds op code */
440 __le32 caller_uid
, caller_gid
;
441 __le64 ino
; /* use this ino for openc, mkdir, mknod,
442 etc. (if replaying) */
443 union ceph_mds_request_args args
;
444 } __attribute__ ((packed
));
446 /* cap/lease release record */
447 struct ceph_mds_request_release
{
448 __le64 ino
, cap_id
; /* ino and unique cap id */
449 __le32 caps
, wanted
; /* new issued, wanted */
450 __le32 seq
, issue_seq
, mseq
;
451 __le32 dname_seq
; /* if releasing a dentry lease, a */
452 __le32 dname_len
; /* string follows. */
453 } __attribute__ ((packed
));
456 struct ceph_mds_reply_head
{
460 __u8 safe
; /* true if committed to disk */
461 __u8 is_dentry
, is_target
; /* true if dentry, target inode records
462 are included with reply */
463 } __attribute__ ((packed
));
465 /* one for each node split */
466 struct ceph_frag_tree_split
{
467 __le32 frag
; /* this frag splits... */
468 __le32 by
; /* ...by this many bits */
469 } __attribute__ ((packed
));
471 struct ceph_frag_tree_head
{
472 __le32 nsplits
; /* num ceph_frag_tree_split records */
473 struct ceph_frag_tree_split splits
[];
474 } __attribute__ ((packed
));
476 /* capability issue, for bundling with mds reply */
477 struct ceph_mds_reply_cap
{
478 __le32 caps
, wanted
; /* caps issued, wanted */
481 __le64 realm
; /* snap realm */
482 __u8 flags
; /* CEPH_CAP_FLAG_* */
483 } __attribute__ ((packed
));
485 #define CEPH_CAP_FLAG_AUTH (1 << 0) /* cap is issued by auth mds */
486 #define CEPH_CAP_FLAG_RELEASE (1 << 1) /* release the cap */
488 /* inode record, for bundling with mds reply */
489 struct ceph_mds_reply_inode
{
493 __le64 version
; /* inode version */
494 __le64 xattr_version
; /* version for xattr blob */
495 struct ceph_mds_reply_cap cap
; /* caps issued for this inode */
496 struct ceph_file_layout layout
;
497 struct ceph_timespec ctime
, mtime
, atime
;
498 __le32 time_warp_seq
;
499 __le64 size
, max_size
, truncate_size
;
501 __le32 mode
, uid
, gid
;
503 __le64 files
, subdirs
, rbytes
, rfiles
, rsubdirs
; /* dir stats */
504 struct ceph_timespec rctime
;
505 struct ceph_frag_tree_head fragtree
; /* (must be at end of struct) */
506 } __attribute__ ((packed
));
507 /* followed by frag array, symlink string, dir layout, xattr blob */
509 /* reply_lease follows dname, and reply_inode */
510 struct ceph_mds_reply_lease
{
511 __le16 mask
; /* lease type(s) */
512 __le32 duration_ms
; /* lease duration */
514 } __attribute__ ((packed
));
516 struct ceph_mds_reply_dirfrag
{
517 __le32 frag
; /* fragment */
518 __le32 auth
; /* auth mds, if this is a delegation point */
519 __le32 ndist
; /* number of mds' this is replicated on */
521 } __attribute__ ((packed
));
523 #define CEPH_LOCK_FCNTL 1
524 #define CEPH_LOCK_FLOCK 2
526 #define CEPH_LOCK_SHARED 1
527 #define CEPH_LOCK_EXCL 2
528 #define CEPH_LOCK_UNLOCK 4
530 struct ceph_filelock
{
531 __le64 start
;/* file offset to start lock at */
532 __le64 length
; /* num bytes to lock; 0 for all following start */
533 __le64 client
; /* which client holds the lock */
534 __le64 pid
; /* process id holding the lock on the client */
535 __le64 pid_namespace
;
536 __u8 type
; /* shared lock, exclusive lock, or unlock */
537 } __attribute__ ((packed
));
540 /* file access modes */
541 #define CEPH_FILE_MODE_PIN 0
542 #define CEPH_FILE_MODE_RD 1
543 #define CEPH_FILE_MODE_WR 2
544 #define CEPH_FILE_MODE_RDWR 3 /* RD | WR */
545 #define CEPH_FILE_MODE_LAZY 4 /* lazy io */
546 #define CEPH_FILE_MODE_NUM 8 /* bc these are bit fields.. mostly */
548 int ceph_flags_to_mode(int flags
);
551 /* capability bits */
552 #define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */
554 /* generic cap bits */
555 #define CEPH_CAP_GSHARED 1 /* client can reads */
556 #define CEPH_CAP_GEXCL 2 /* client can read and update */
557 #define CEPH_CAP_GCACHE 4 /* (file) client can cache reads */
558 #define CEPH_CAP_GRD 8 /* (file) client can read */
559 #define CEPH_CAP_GWR 16 /* (file) client can write */
560 #define CEPH_CAP_GBUFFER 32 /* (file) client can buffer writes */
561 #define CEPH_CAP_GWREXTEND 64 /* (file) client can extend EOF */
562 #define CEPH_CAP_GLAZYIO 128 /* (file) client can perform lazy io */
564 #define CEPH_CAP_SIMPLE_BITS 2
565 #define CEPH_CAP_FILE_BITS 8
568 #define CEPH_CAP_SAUTH 2
569 #define CEPH_CAP_SLINK 4
570 #define CEPH_CAP_SXATTR 6
571 #define CEPH_CAP_SFILE 8
572 #define CEPH_CAP_SFLOCK 20
574 #define CEPH_CAP_BITS 22
576 /* composed values */
577 #define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH)
578 #define CEPH_CAP_AUTH_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SAUTH)
579 #define CEPH_CAP_LINK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SLINK)
580 #define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK)
581 #define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SXATTR)
582 #define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR)
583 #define CEPH_CAP_FILE(x) (x << CEPH_CAP_SFILE)
584 #define CEPH_CAP_FILE_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFILE)
585 #define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE)
586 #define CEPH_CAP_FILE_CACHE (CEPH_CAP_GCACHE << CEPH_CAP_SFILE)
587 #define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE)
588 #define CEPH_CAP_FILE_WR (CEPH_CAP_GWR << CEPH_CAP_SFILE)
589 #define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE)
590 #define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
591 #define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE)
592 #define CEPH_CAP_FLOCK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFLOCK)
593 #define CEPH_CAP_FLOCK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFLOCK)
596 /* cap masks (for getattr) */
597 #define CEPH_STAT_CAP_INODE CEPH_CAP_PIN
598 #define CEPH_STAT_CAP_TYPE CEPH_CAP_PIN /* mode >> 12 */
599 #define CEPH_STAT_CAP_SYMLINK CEPH_CAP_PIN
600 #define CEPH_STAT_CAP_UID CEPH_CAP_AUTH_SHARED
601 #define CEPH_STAT_CAP_GID CEPH_CAP_AUTH_SHARED
602 #define CEPH_STAT_CAP_MODE CEPH_CAP_AUTH_SHARED
603 #define CEPH_STAT_CAP_NLINK CEPH_CAP_LINK_SHARED
604 #define CEPH_STAT_CAP_LAYOUT CEPH_CAP_FILE_SHARED
605 #define CEPH_STAT_CAP_MTIME CEPH_CAP_FILE_SHARED
606 #define CEPH_STAT_CAP_SIZE CEPH_CAP_FILE_SHARED
607 #define CEPH_STAT_CAP_ATIME CEPH_CAP_FILE_SHARED /* fixme */
608 #define CEPH_STAT_CAP_XATTR CEPH_CAP_XATTR_SHARED
609 #define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN | \
610 CEPH_CAP_AUTH_SHARED | \
611 CEPH_CAP_LINK_SHARED | \
612 CEPH_CAP_FILE_SHARED | \
613 CEPH_CAP_XATTR_SHARED)
615 #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \
616 CEPH_CAP_LINK_SHARED | \
617 CEPH_CAP_XATTR_SHARED | \
618 CEPH_CAP_FILE_SHARED)
619 #define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \
622 #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \
623 CEPH_CAP_LINK_EXCL | \
624 CEPH_CAP_XATTR_EXCL | \
626 #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \
628 #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
629 #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
630 CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \
633 #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
636 int ceph_caps_for_mode(int mode
);
639 CEPH_CAP_OP_GRANT
, /* mds->client grant */
640 CEPH_CAP_OP_REVOKE
, /* mds->client revoke */
641 CEPH_CAP_OP_TRUNC
, /* mds->client trunc notify */
642 CEPH_CAP_OP_EXPORT
, /* mds has exported the cap */
643 CEPH_CAP_OP_IMPORT
, /* mds has imported the cap */
644 CEPH_CAP_OP_UPDATE
, /* client->mds update */
645 CEPH_CAP_OP_DROP
, /* client->mds drop cap bits */
646 CEPH_CAP_OP_FLUSH
, /* client->mds cap writeback */
647 CEPH_CAP_OP_FLUSH_ACK
, /* mds->client flushed */
648 CEPH_CAP_OP_FLUSHSNAP
, /* client->mds flush snapped metadata */
649 CEPH_CAP_OP_FLUSHSNAP_ACK
, /* mds->client flushed snapped metadata */
650 CEPH_CAP_OP_RELEASE
, /* client->mds release (clean) cap */
651 CEPH_CAP_OP_RENEW
, /* client->mds renewal request */
654 extern const char *ceph_cap_op_name(int op
);
657 * caps message, used for capability callbacks, acks, requests, etc.
659 struct ceph_mds_caps
{
660 __le32 op
; /* CEPH_CAP_OP_* */
663 __le32 seq
, issue_seq
;
664 __le32 caps
, wanted
, dirty
; /* latest issued/wanted/dirty */
667 __le32 snap_trace_len
;
670 __le32 uid
, gid
, mode
;
677 __le64 xattr_version
;
680 __le64 size
, max_size
, truncate_size
;
682 struct ceph_timespec mtime
, atime
, ctime
;
683 struct ceph_file_layout layout
;
684 __le32 time_warp_seq
;
685 } __attribute__ ((packed
));
687 struct ceph_mds_cap_peer
{
693 } __attribute__ ((packed
));
695 /* cap release msg head */
696 struct ceph_mds_cap_release
{
697 __le32 num
; /* number of cap_items that follow */
698 } __attribute__ ((packed
));
700 struct ceph_mds_cap_item
{
703 __le32 migrate_seq
, seq
;
704 } __attribute__ ((packed
));
706 #define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */
707 #define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */
708 #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */
709 #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */
711 extern const char *ceph_lease_op_name(int o
);
713 /* lease msg header */
714 struct ceph_mds_lease
{
715 __u8 action
; /* CEPH_MDS_LEASE_* */
716 __le16 mask
; /* which lease */
718 __le64 first
, last
; /* snap range */
720 __le32 duration_ms
; /* duration of renewal */
721 } __attribute__ ((packed
));
722 /* followed by a __le32+string for dname */
724 /* client reconnect */
725 struct ceph_mds_cap_reconnect
{
730 __le64 pathbase
; /* base ino for our path to this ino */
731 __le32 flock_len
; /* size of flock state blob, if any */
732 } __attribute__ ((packed
));
733 /* followed by flock blob */
735 struct ceph_mds_cap_reconnect_v1
{
740 struct ceph_timespec mtime
, atime
;
742 __le64 pathbase
; /* base ino for our path to this ino */
743 } __attribute__ ((packed
));
745 struct ceph_mds_snaprealm_reconnect
{
746 __le64 ino
; /* snap realm base */
747 __le64 seq
; /* snap seq for this snap realm */
748 __le64 parent
; /* parent realm */
749 } __attribute__ ((packed
));
755 CEPH_SNAP_OP_UPDATE
, /* CREATE or DESTROY */
757 CEPH_SNAP_OP_DESTROY
,
761 extern const char *ceph_snap_op_name(int o
);
763 /* snap msg header */
764 struct ceph_mds_snap_head
{
765 __le32 op
; /* CEPH_SNAP_OP_* */
766 __le64 split
; /* ino to split off, if any */
767 __le32 num_split_inos
; /* # inos belonging to new child realm */
768 __le32 num_split_realms
; /* # child realms udner new child realm */
769 __le32 trace_len
; /* size of snap trace blob */
770 } __attribute__ ((packed
));
771 /* followed by split ino list, then split realms, then the trace blob */
774 * encode info about a snaprealm, as viewed by a client
776 struct ceph_mds_snap_realm
{
777 __le64 ino
; /* ino */
778 __le64 created
; /* snap: when created */
779 __le64 parent
; /* ino: parent realm */
780 __le64 parent_since
; /* snap: same parent since */
781 __le64 seq
; /* snap: version */
783 __le32 num_prior_parent_snaps
;
784 } __attribute__ ((packed
));
785 /* followed by my snap list, then prior parent snap list */