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.
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_LOST_AND_FOUND 4 /* reserved ino for use in recovery */
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_MIN_STRIPE_UNIT 65536
58 struct ceph_dir_layout
{
59 __u8 dl_dir_hash
; /* see ceph_hash.h for ids */
63 } __attribute__ ((packed
));
65 /* crypto algorithms */
66 #define CEPH_CRYPTO_NONE 0x0
67 #define CEPH_CRYPTO_AES 0x1
69 #define CEPH_AES_IV "cephsageyudagreg"
71 /* security/authentication protocols */
72 #define CEPH_AUTH_UNKNOWN 0x0
73 #define CEPH_AUTH_NONE 0x1
74 #define CEPH_AUTH_CEPHX 0x2
76 #define CEPH_AUTH_UID_DEFAULT ((__u64) -1)
79 /*********************************************
88 #define CEPH_MSG_SHUTDOWN 1
89 #define CEPH_MSG_PING 2
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
106 #define CEPH_MSG_MDS_MAP 21
108 #define CEPH_MSG_CLIENT_SESSION 22
109 #define CEPH_MSG_CLIENT_RECONNECT 23
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
121 #define CEPH_MSG_POOLOP_REPLY 48
122 #define CEPH_MSG_POOLOP 49
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
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
137 /* watch-notify operations */
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 */
144 const char *ceph_watch_event_name(int o
);
146 /* pool operations */
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,
157 struct ceph_mon_request_header
{
160 __le64 session_mon_tid
;
161 } __attribute__ ((packed
));
163 struct ceph_mon_statfs
{
164 struct ceph_mon_request_header monhdr
;
165 struct ceph_fsid fsid
;
166 } __attribute__ ((packed
));
169 __le64 kb
, kb_used
, kb_avail
;
171 } __attribute__ ((packed
));
173 struct ceph_mon_statfs_reply
{
174 struct ceph_fsid fsid
;
176 struct ceph_statfs st
;
177 } __attribute__ ((packed
));
179 const char *ceph_pool_op_name(int op
);
181 struct ceph_mon_poolop
{
182 struct ceph_mon_request_header monhdr
;
183 struct ceph_fsid fsid
;
189 } __attribute__ ((packed
));
191 struct ceph_mon_poolop_reply
{
192 struct ceph_mon_request_header monhdr
;
193 struct ceph_fsid fsid
;
198 } __attribute__ ((packed
));
200 struct ceph_mon_unmanaged_snap
{
202 } __attribute__ ((packed
));
204 struct ceph_osd_getmap
{
205 struct ceph_mon_request_header monhdr
;
206 struct ceph_fsid fsid
;
208 } __attribute__ ((packed
));
210 struct ceph_mds_getmap
{
211 struct ceph_mon_request_header monhdr
;
212 struct ceph_fsid fsid
;
213 } __attribute__ ((packed
));
215 struct ceph_client_mount
{
216 struct ceph_mon_request_header monhdr
;
217 } __attribute__ ((packed
));
219 #define CEPH_SUBSCRIBE_ONETIME 1 /* i want only 1 update after have */
221 struct ceph_mon_subscribe_item
{
224 } __attribute__ ((packed
));
226 struct ceph_mon_subscribe_ack
{
227 __le32 duration
; /* seconds */
228 struct ceph_fsid fsid
;
229 } __attribute__ ((packed
));
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 */
239 #define CEPH_MDSMAP_ALLOW_CLASSICS (CEPH_MDSMAP_ALLOW_SNAPS | CEPH_MDSMAP_ALLOW_MULTIMDS | \
240 CEPH_MDSMAP_ALLOW_DIRFRAGS)
242 #define CEPH_MDSMAP_DEFAULTS CEPH_MDSMAP_ALLOW_DIRFRAGS | CEPH_MDSMAP_ALLOW_MULTIMDS
249 #define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */
250 #define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees.
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
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 */
270 extern const char *ceph_mds_state_name(int s
);
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
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 */
293 /* client_session ops */
295 CEPH_SESSION_REQUEST_OPEN
,
297 CEPH_SESSION_REQUEST_CLOSE
,
299 CEPH_SESSION_REQUEST_RENEWCAPS
,
300 CEPH_SESSION_RENEWCAPS
,
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
309 CEPH_SESSION_REQUEST_FLUSH_MDLOG
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,
335 CEPH_MDS_OP_LOOKUPNAME
= 0x00105,
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,
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,
353 CEPH_MDS_OP_CREATE
= 0x01301,
354 CEPH_MDS_OP_OPEN
= 0x00302,
355 CEPH_MDS_OP_READDIR
= 0x00305,
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,
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
372 extern const char *ceph_mds_op_name(int op
);
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)
384 #define CEPH_SETATTR_MTIME_NOW (1 << 7)
385 #define CEPH_SETATTR_ATIME_NOW (1 << 8)
386 #define CEPH_SETATTR_KILL_SGUID (1 << 10)
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
400 int ceph_flags_sys2wire(int flags
);
403 * Ceph setxattr request flags.
405 #define CEPH_XATTR_CREATE (1 << 0)
406 #define CEPH_XATTR_REPLACE (1 << 1)
407 #define CEPH_XATTR_REMOVE (1 << 31)
410 * readdir request flags;
412 #define CEPH_READDIR_REPLY_BITFLAGS (1<<0)
415 * readdir reply flags.
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)
422 /* Note that this is embedded wthin ceph_mds_request_head_legacy. */
423 union ceph_mds_request_args_legacy
{
425 __le32 mask
; /* CEPH_CAP_* */
426 } __attribute__ ((packed
)) getattr
;
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
;
437 __le32 frag
; /* which dir fragment */
438 __le32 max_entries
; /* how many dentries to grab */
442 } __attribute__ ((packed
)) readdir
;
446 } __attribute__ ((packed
)) mknod
;
449 } __attribute__ ((packed
)) mkdir
;
453 __le32 stripe_unit
; /* layout for newly created file */
454 __le32 stripe_count
; /* ... */
456 __le32 pool
; /* if >= 0 and CREATEPOOLID feature */
457 __le32 mask
; /* CEPH_CAP_* */
458 __le64 old_size
; /* if O_TRUNC */
459 } __attribute__ ((packed
)) open
;
462 __le32 osdmap_epoch
; /* use for set file/dir layout */
463 } __attribute__ ((packed
)) setxattr
;
465 struct ceph_file_layout layout
;
466 } __attribute__ ((packed
)) setlayout
;
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
));
478 #define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */
479 #define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */
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
));
495 * Note that this is embedded wthin ceph_mds_request_head. Also, compatability
496 * with the ceph_mds_request_args_legacy must be maintained!
498 union ceph_mds_request_args
{
500 __le32 mask
; /* CEPH_CAP_* */
501 } __attribute__ ((packed
)) getattr
;
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
;
513 __le32 frag
; /* which dir fragment */
514 __le32 max_entries
; /* how many dentries to grab */
518 } __attribute__ ((packed
)) readdir
;
522 } __attribute__ ((packed
)) mknod
;
525 } __attribute__ ((packed
)) mkdir
;
529 __le32 stripe_unit
; /* layout for newly created file */
530 __le32 stripe_count
; /* ... */
532 __le32 pool
; /* if >= 0 and CREATEPOOLID feature */
533 __le32 mask
; /* CEPH_CAP_* */
534 __le64 old_size
; /* if O_TRUNC */
535 } __attribute__ ((packed
)) open
;
538 __le32 osdmap_epoch
; /* use for set file/dir layout */
539 } __attribute__ ((packed
)) setxattr
;
541 struct ceph_file_layout layout
;
542 } __attribute__ ((packed
)) setlayout
;
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
));
554 #define CEPH_MDS_REQUEST_HEAD_VERSION 1
557 * Note that any change to this structure must ensure that it is compatible
558 * with ceph_mds_request_head_legacy.
560 struct ceph_mds_request_head
{
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
));
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
));
584 copy_from_legacy_head(struct ceph_mds_request_head
*head
,
585 struct ceph_mds_request_head_legacy
*legacy
)
587 memcpy(&(head
->oldest_client_tid
), legacy
, sizeof(*legacy
));
591 copy_to_legacy_head(struct ceph_mds_request_head_legacy
*legacy
,
592 struct ceph_mds_request_head
*head
)
594 memcpy(legacy
, &(head
->oldest_client_tid
), sizeof(*legacy
));
598 struct ceph_mds_reply_head
{
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
));
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
));
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
));
618 /* capability issue, for bundling with mds reply */
619 struct ceph_mds_reply_cap
{
620 __le32 caps
, wanted
; /* caps issued, wanted */
623 __le64 realm
; /* snap realm */
624 __u8 flags
; /* CEPH_CAP_FLAG_* */
625 } __attribute__ ((packed
));
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 */
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 */
635 } __attribute__ ((packed
));
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 */
642 } __attribute__ ((packed
));
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
649 #define CEPH_LOCK_SHARED 1
650 #define CEPH_LOCK_EXCL 2
651 #define CEPH_LOCK_UNLOCK 4
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
));
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 */
671 int ceph_flags_to_mode(int flags
);
673 /* inline data state */
674 #define CEPH_INLINE_NONE ((__u64)-1)
675 #define CEPH_INLINE_MAX_SIZE CEPH_MIN_STRIPE_UNIT
677 /* capability bits */
678 #define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */
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 */
690 #define CEPH_CAP_SIMPLE_BITS 2
691 #define CEPH_CAP_FILE_BITS 8
694 #define CEPH_CAP_SAUTH 2
695 #define CEPH_CAP_SLINK 4
696 #define CEPH_CAP_SXATTR 6
697 #define CEPH_CAP_SFILE 8
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)
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 | \
737 #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \
738 CEPH_CAP_LINK_SHARED | \
739 CEPH_CAP_XATTR_SHARED | \
740 CEPH_CAP_FILE_SHARED)
741 #define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \
744 #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \
745 CEPH_CAP_LINK_EXCL | \
746 CEPH_CAP_XATTR_EXCL | \
748 #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \
750 #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
751 #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
752 CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \
755 #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
758 int ceph_caps_for_mode(int mode
);
761 CEPH_CAP_OP_GRANT
, /* mds->client grant */
762 CEPH_CAP_OP_REVOKE
, /* mds->client revoke */
763 CEPH_CAP_OP_TRUNC
, /* mds->client trunc notify */
764 CEPH_CAP_OP_EXPORT
, /* mds has exported the cap */
765 CEPH_CAP_OP_IMPORT
, /* mds has imported the cap */
766 CEPH_CAP_OP_UPDATE
, /* client->mds update */
767 CEPH_CAP_OP_DROP
, /* client->mds drop cap bits */
768 CEPH_CAP_OP_FLUSH
, /* client->mds cap writeback */
769 CEPH_CAP_OP_FLUSH_ACK
, /* mds->client flushed */
770 CEPH_CAP_OP_FLUSHSNAP
, /* client->mds flush snapped metadata */
771 CEPH_CAP_OP_FLUSHSNAP_ACK
, /* mds->client flushed snapped metadata */
772 CEPH_CAP_OP_RELEASE
, /* client->mds release (clean) cap */
773 CEPH_CAP_OP_RENEW
, /* client->mds renewal request */
776 extern const char *ceph_cap_op_name(int op
);
778 /* extra info for cap import/export */
779 struct ceph_mds_cap_peer
{
785 } __attribute__ ((packed
));
788 * caps message, used for capability callbacks, acks, requests, etc.
790 struct ceph_mds_caps_head
{
791 __le32 op
; /* CEPH_CAP_OP_* */
794 __le32 seq
, issue_seq
;
795 __le32 caps
, wanted
, dirty
; /* latest issued/wanted/dirty */
798 __le32 snap_trace_len
;
801 __le32 uid
, gid
, mode
;
808 __le64 xattr_version
;
809 } __attribute__ ((packed
));
811 struct ceph_mds_caps_body_legacy
{
813 /* all except export */
816 __le64 size
, max_size
, truncate_size
;
818 struct ceph_timespec mtime
, atime
, ctime
;
819 struct ceph_file_layout layout
;
820 __le32 time_warp_seq
;
823 struct ceph_mds_cap_peer peer
;
825 } __attribute__ ((packed
));
827 /* cap release msg head */
828 struct ceph_mds_cap_release
{
829 __le32 num
; /* number of cap_items that follow */
830 } __attribute__ ((packed
));
832 struct ceph_mds_cap_item
{
835 __le32 migrate_seq
, seq
;
836 } __attribute__ ((packed
));
838 #define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */
839 #define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */
840 #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */
841 #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */
843 extern const char *ceph_lease_op_name(int o
);
845 /* lease msg header */
846 struct ceph_mds_lease
{
847 __u8 action
; /* CEPH_MDS_LEASE_* */
848 __le16 mask
; /* which lease */
850 __le64 first
, last
; /* snap range */
852 __le32 duration_ms
; /* duration of renewal */
853 } __attribute__ ((packed
));
854 /* followed by a __le32+string for dname */
856 /* client reconnect */
857 struct ceph_mds_cap_reconnect
{
862 __le64 pathbase
; /* base ino for our path to this ino */
863 __le32 flock_len
; /* size of flock state blob, if any */
864 } __attribute__ ((packed
));
865 /* followed by flock blob */
867 struct ceph_mds_cap_reconnect_v1
{
872 struct ceph_timespec mtime
, atime
;
874 __le64 pathbase
; /* base ino for our path to this ino */
875 } __attribute__ ((packed
));
877 struct ceph_mds_snaprealm_reconnect
{
878 __le64 ino
; /* snap realm base */
879 __le64 seq
; /* snap seq for this snap realm */
880 __le64 parent
; /* parent realm */
881 } __attribute__ ((packed
));
887 CEPH_SNAP_OP_UPDATE
, /* CREATE or DESTROY */
889 CEPH_SNAP_OP_DESTROY
,
893 extern const char *ceph_snap_op_name(int o
);
895 /* snap msg header */
896 struct ceph_mds_snap_head
{
897 __le32 op
; /* CEPH_SNAP_OP_* */
898 __le64 split
; /* ino to split off, if any */
899 __le32 num_split_inos
; /* # inos belonging to new child realm */
900 __le32 num_split_realms
; /* # child realms udner new child realm */
901 __le32 trace_len
; /* size of snap trace blob */
902 } __attribute__ ((packed
));
903 /* followed by split ino list, then split realms, then the trace blob */
906 * encode info about a snaprealm, as viewed by a client
908 struct ceph_mds_snap_realm
{
909 __le64 ino
; /* ino */
910 __le64 created
; /* snap: when created */
911 __le64 parent
; /* ino: parent realm */
912 __le64 parent_since
; /* snap: same parent since */
913 __le64 seq
; /* snap: version */
915 __le32 num_prior_parent_snaps
;
916 } __attribute__ ((packed
));
917 /* followed by my snap list, then prior parent snap list */