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 * The data structures defined here are shared between Linux kernel and
20 * user space. Also, those data structures are maintained always in
21 * little-endian byte order, even on big-endian systems. This is handled
22 * differently in kernel vs. user space. For use as kernel headers, the
23 * little-endian fields need to use the __le16/__le32/__le64 types. These
24 * are markers that indicate endian conversion routines must be used
25 * whenever such fields are accessed, which can be verified by checker
26 * tools like "sparse". For use as user-space headers, the little-endian
27 * fields instead use types ceph_le16/ceph_le32/ceph_le64, which are C++
28 * classes that implement automatic endian conversion on every access.
29 * To still allow for header sharing, this file uses the __le types, but
30 * redefines those to the ceph_ types when compiled in user space.
33 #include "byteorder.h"
34 #define __le16 ceph_le16
35 #define __le32 ceph_le32
36 #define __le64 ceph_le64
40 * subprotocol versions. when specific messages types or high-level
41 * protocols change, bump the affected components. we keep rev
42 * internal cluster protocols separately from the public,
43 * client-facing protocol.
45 #define CEPH_OSDC_PROTOCOL 24 /* server/client */
46 #define CEPH_MDSC_PROTOCOL 32 /* server/client */
47 #define CEPH_MONC_PROTOCOL 15 /* server/client */
50 #define CEPH_INO_ROOT 1
51 #define CEPH_INO_CEPH 2 /* hidden .ceph dir */
52 #define CEPH_INO_LOST_AND_FOUND 4 /* reserved ino for use in recovery */
54 /* arbitrary limit on max # of monitors (cluster of 3 is typical) */
55 #define CEPH_MAX_MON 31
58 * ceph_file_layout - describe data layout for a file/inode
60 struct ceph_file_layout
{
61 /* file -> object mapping */
62 __le32 fl_stripe_unit
; /* stripe unit, in bytes. must be multiple
64 __le32 fl_stripe_count
; /* over this many objects */
65 __le32 fl_object_size
; /* until objects are this big, then move to
67 __le32 fl_cas_hash
; /* UNUSED. 0 = none; 1 = sha256 */
69 /* pg -> disk layout */
70 __le32 fl_object_stripe_unit
; /* UNUSED. for per-object parity, if any */
72 /* object -> pg layout */
73 __le32 fl_unused
; /* unused; used to be preferred primary for pg (-1 for none) */
74 __le32 fl_pg_pool
; /* namespace, crush ruleset, rep level */
75 } __attribute__ ((packed
));
77 #define CEPH_MIN_STRIPE_UNIT 65536
79 struct ceph_dir_layout
{
80 __u8 dl_dir_hash
; /* see ceph_hash.h for ids */
84 } __attribute__ ((packed
));
86 /* crypto algorithms */
87 #define CEPH_CRYPTO_NONE 0x0
88 #define CEPH_CRYPTO_AES 0x1
90 #define CEPH_AES_IV "cephsageyudagreg"
92 /* security/authentication protocols */
93 #define CEPH_AUTH_UNKNOWN 0x0
94 #define CEPH_AUTH_NONE 0x1
95 #define CEPH_AUTH_CEPHX 0x2
97 /* msgr2 protocol modes */
98 #define CEPH_CON_MODE_UNKNOWN 0x0
99 #define CEPH_CON_MODE_CRC 0x1
100 #define CEPH_CON_MODE_SECURE 0x2
102 extern const char *ceph_con_mode_name(int con_mode
);
104 /* For options with "_", like: GSS_GSS
105 which means: Mode/Protocol to validate "authentication_authorization",
107 - Authentication: Verifying the identity of an entity.
108 - Authorization: Verifying that an authenticated entity has
109 the right to access a particular resource.
111 #define CEPH_AUTH_GSS 0x4
112 #define CEPH_AUTH_GSS_GSS CEPH_AUTH_GSS
114 #define CEPH_AUTH_UID_DEFAULT ((__u64) -1)
117 /*********************************************
126 #define CEPH_MSG_SHUTDOWN 1
127 #define CEPH_MSG_PING 2
129 /* client <-> monitor */
130 #define CEPH_MSG_MON_MAP 4
131 #define CEPH_MSG_MON_GET_MAP 5
132 #define CEPH_MSG_MON_GET_OSDMAP 6
133 #define CEPH_MSG_MON_METADATA 7
134 #define CEPH_MSG_STATFS 13
135 #define CEPH_MSG_STATFS_REPLY 14
136 #define CEPH_MSG_MON_SUBSCRIBE 15
137 #define CEPH_MSG_MON_SUBSCRIBE_ACK 16
138 #define CEPH_MSG_AUTH 17
139 #define CEPH_MSG_AUTH_REPLY 18
140 #define CEPH_MSG_MON_GET_VERSION 19
141 #define CEPH_MSG_MON_GET_VERSION_REPLY 20
144 #define CEPH_MSG_MDS_MAP 21
146 #define CEPH_MSG_CLIENT_SESSION 22
147 #define CEPH_MSG_CLIENT_RECONNECT 23
149 #define CEPH_MSG_CLIENT_REQUEST 24
150 #define CEPH_MSG_CLIENT_REQUEST_FORWARD 25
151 #define CEPH_MSG_CLIENT_REPLY 26
152 #define CEPH_MSG_CLIENT_RECLAIM 27
153 #define CEPH_MSG_CLIENT_RECLAIM_REPLY 28
154 #define CEPH_MSG_CLIENT_METRICS 29
155 #define CEPH_MSG_CLIENT_CAPS 0x310
156 #define CEPH_MSG_CLIENT_LEASE 0x311
157 #define CEPH_MSG_CLIENT_SNAP 0x312
158 #define CEPH_MSG_CLIENT_CAPRELEASE 0x313
159 #define CEPH_MSG_CLIENT_QUOTA 0x314
162 #define CEPH_MSG_POOLOP_REPLY 48
163 #define CEPH_MSG_POOLOP 49
167 #define CEPH_MSG_OSD_MAP 41
168 #define CEPH_MSG_OSD_OP 42
169 #define CEPH_MSG_OSD_OPREPLY 43
170 #define CEPH_MSG_WATCH_NOTIFY 44
171 #define CEPH_MSG_OSD_BACKOFF 61
173 /* FSMap subscribers (see all MDS clusters at once) */
174 #define CEPH_MSG_FS_MAP 45
175 /* FSMapUser subscribers (get MDS clusters name->ID mapping) */
176 #define CEPH_MSG_FS_MAP_USER 103
178 /* watch-notify operations */
180 CEPH_WATCH_EVENT_NOTIFY
= 1, /* notifying watcher */
181 CEPH_WATCH_EVENT_NOTIFY_COMPLETE
= 2, /* notifier notified when done */
182 CEPH_WATCH_EVENT_DISCONNECT
= 3, /* we were disconnected */
185 const char *ceph_watch_event_name(int o
);
187 /* pool operations */
189 POOL_OP_CREATE
= 0x01,
190 POOL_OP_DELETE
= 0x02,
191 POOL_OP_AUID_CHANGE
= 0x03,
192 POOL_OP_CREATE_SNAP
= 0x11,
193 POOL_OP_DELETE_SNAP
= 0x12,
194 POOL_OP_CREATE_UNMANAGED_SNAP
= 0x21,
195 POOL_OP_DELETE_UNMANAGED_SNAP
= 0x22,
198 struct ceph_mon_request_header
{
201 __le64 session_mon_tid
;
202 } __attribute__ ((packed
));
204 struct ceph_mon_statfs
{
205 struct ceph_mon_request_header monhdr
;
206 struct ceph_fsid fsid
;
207 } __attribute__ ((packed
));
210 __le64 kb
, kb_used
, kb_avail
;
212 } __attribute__ ((packed
));
214 struct ceph_mon_statfs_reply
{
215 struct ceph_fsid fsid
;
217 struct ceph_statfs st
;
218 } __attribute__ ((packed
));
220 const char *ceph_pool_op_name(int op
);
222 struct ceph_mon_poolop
{
223 struct ceph_mon_request_header monhdr
;
224 struct ceph_fsid fsid
;
227 __le64 __old_auid
; // obsolete
230 } __attribute__ ((packed
));
232 struct ceph_mon_poolop_reply
{
233 struct ceph_mon_request_header monhdr
;
234 struct ceph_fsid fsid
;
239 } __attribute__ ((packed
));
241 struct ceph_mon_unmanaged_snap
{
243 } __attribute__ ((packed
));
245 struct ceph_osd_getmap
{
246 struct ceph_mon_request_header monhdr
;
247 struct ceph_fsid fsid
;
249 } __attribute__ ((packed
));
251 struct ceph_mds_getmap
{
252 struct ceph_mon_request_header monhdr
;
253 struct ceph_fsid fsid
;
254 } __attribute__ ((packed
));
256 struct ceph_client_mount
{
257 struct ceph_mon_request_header monhdr
;
258 } __attribute__ ((packed
));
260 #define CEPH_SUBSCRIBE_ONETIME 1 /* i want only 1 update after have */
262 struct ceph_mon_subscribe_item
{
265 } __attribute__ ((packed
));
267 struct ceph_mon_subscribe_ack
{
268 __le32 duration
; /* seconds */
269 struct ceph_fsid fsid
;
270 } __attribute__ ((packed
));
275 #define CEPH_MDSMAP_NOT_JOINABLE (1<<0) /* standbys cannot join */
276 #define CEPH_MDSMAP_DOWN (CEPH_MDSMAP_NOT_JOINABLE) /* backwards compat */
277 #define CEPH_MDSMAP_ALLOW_SNAPS (1<<1) /* cluster allowed to create snapshots */
278 /* deprecated #define CEPH_MDSMAP_ALLOW_MULTIMDS (1<<2) cluster allowed to have >1 active MDS */
279 /* deprecated #define CEPH_MDSMAP_ALLOW_DIRFRAGS (1<<3) cluster allowed to fragment directories */
280 #define CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS (1<<4) /* cluster alllowed to enable MULTIMDS
281 and SNAPS at the same time */
282 #define CEPH_MDSMAP_ALLOW_STANDBY_REPLAY (1<<5) /* cluster alllowed to enable MULTIMDS */
284 #define CEPH_MDSMAP_DEFAULTS (CEPH_MDSMAP_ALLOW_SNAPS | \
285 CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS)
292 #define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */
293 #define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees.
295 #define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */
296 #define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */
297 #define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */
298 #define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */
299 #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */
300 #define CEPH_MDS_STATE_REPLAYONCE -9 /* Legacy, unused */
301 #define CEPH_MDS_STATE_NULL -10
303 #define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */
304 #define CEPH_MDS_STATE_RESOLVE 9 /* up, disambiguating distributed
305 operations (import, rename, etc.) */
306 #define CEPH_MDS_STATE_RECONNECT 10 /* up, reconnect to clients */
307 #define CEPH_MDS_STATE_REJOIN 11 /* up, rejoining distributed cache */
308 #define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */
309 #define CEPH_MDS_STATE_ACTIVE 13 /* up, active */
310 #define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */
311 #define CEPH_MDS_STATE_DAMAGED 15 /* rank not replayable, need repair */
313 extern const char *ceph_mds_state_name(int s
);
317 * metadata lock types.
318 * - these are bitmasks.. we can compose them
319 * - they also define the lock ordering by the MDS
320 * - a few of these are internal to the mds
322 #define CEPH_LOCK_DN (1 << 0)
323 #define CEPH_LOCK_DVERSION (1 << 1)
324 #define CEPH_LOCK_ISNAP (1 << 4) /* snapshot lock. MDS internal */
325 #define CEPH_LOCK_IPOLICY (1 << 5) /* policy lock on dirs. MDS internal */
326 #define CEPH_LOCK_IFILE (1 << 6)
327 #define CEPH_LOCK_INEST (1 << 7) /* mds internal */
328 #define CEPH_LOCK_IDFT (1 << 8) /* dir frag tree */
329 #define CEPH_LOCK_IAUTH (1 << 9)
330 #define CEPH_LOCK_ILINK (1 << 10)
331 #define CEPH_LOCK_IXATTR (1 << 11)
332 #define CEPH_LOCK_IFLOCK (1 << 12) /* advisory file locks */
333 #define CEPH_LOCK_IVERSION (1 << 13) /* mds internal */
335 #define CEPH_LOCK_IFIRST CEPH_LOCK_ISNAP
338 /* client_session ops */
340 CEPH_SESSION_REQUEST_OPEN
,
342 CEPH_SESSION_REQUEST_CLOSE
,
344 CEPH_SESSION_REQUEST_RENEWCAPS
,
345 CEPH_SESSION_RENEWCAPS
,
347 CEPH_SESSION_RECALL_STATE
,
348 CEPH_SESSION_FLUSHMSG
,
349 CEPH_SESSION_FLUSHMSG_ACK
,
350 CEPH_SESSION_FORCE_RO
,
351 // A response to REQUEST_OPEN indicating that the client should
352 // permanently desist from contacting the MDS
354 CEPH_SESSION_REQUEST_FLUSH_MDLOG
357 // flags for state reclaim
358 #define CEPH_RECLAIM_RESET 1
360 extern const char *ceph_session_op_name(int op
);
362 struct ceph_mds_session_head
{
365 struct ceph_timespec stamp
;
366 __le32 max_caps
, max_leases
;
367 } __attribute__ ((packed
));
372 * & 0x001000 -> write op
373 * & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
374 & & 0x100000 -> use weird ino/path trace
376 #define CEPH_MDS_OP_WRITE 0x001000
378 CEPH_MDS_OP_LOOKUP
= 0x00100,
379 CEPH_MDS_OP_GETATTR
= 0x00101,
380 CEPH_MDS_OP_LOOKUPHASH
= 0x00102,
381 CEPH_MDS_OP_LOOKUPPARENT
= 0x00103,
382 CEPH_MDS_OP_LOOKUPINO
= 0x00104,
383 CEPH_MDS_OP_LOOKUPNAME
= 0x00105,
385 CEPH_MDS_OP_SETXATTR
= 0x01105,
386 CEPH_MDS_OP_RMXATTR
= 0x01106,
387 CEPH_MDS_OP_SETLAYOUT
= 0x01107,
388 CEPH_MDS_OP_SETATTR
= 0x01108,
389 CEPH_MDS_OP_SETFILELOCK
= 0x01109,
390 CEPH_MDS_OP_GETFILELOCK
= 0x00110,
391 CEPH_MDS_OP_SETDIRLAYOUT
=0x0110a,
393 CEPH_MDS_OP_MKNOD
= 0x01201,
394 CEPH_MDS_OP_LINK
= 0x01202,
395 CEPH_MDS_OP_UNLINK
= 0x01203,
396 CEPH_MDS_OP_RENAME
= 0x01204,
397 CEPH_MDS_OP_MKDIR
= 0x01220,
398 CEPH_MDS_OP_RMDIR
= 0x01221,
399 CEPH_MDS_OP_SYMLINK
= 0x01222,
401 CEPH_MDS_OP_CREATE
= 0x01301,
402 CEPH_MDS_OP_OPEN
= 0x00302,
403 CEPH_MDS_OP_READDIR
= 0x00305,
405 CEPH_MDS_OP_LOOKUPSNAP
= 0x00400,
406 CEPH_MDS_OP_MKSNAP
= 0x01400,
407 CEPH_MDS_OP_RMSNAP
= 0x01401,
408 CEPH_MDS_OP_LSSNAP
= 0x00402,
409 CEPH_MDS_OP_RENAMESNAP
= 0x01403,
412 CEPH_MDS_OP_FRAGMENTDIR
= 0x01500,
413 CEPH_MDS_OP_EXPORTDIR
= 0x01501,
414 CEPH_MDS_OP_FLUSH
= 0x01502,
415 CEPH_MDS_OP_ENQUEUE_SCRUB
= 0x01503,
416 CEPH_MDS_OP_REPAIR_FRAGSTATS
= 0x01504,
417 CEPH_MDS_OP_REPAIR_INODESTATS
= 0x01505,
418 CEPH_MDS_OP_RDLOCK_FRAGSSTATS
= 0x01507
421 extern const char *ceph_mds_op_name(int op
);
423 #ifndef CEPH_SETATTR_MODE
424 #define CEPH_SETATTR_MODE (1 << 0)
425 #define CEPH_SETATTR_UID (1 << 1)
426 #define CEPH_SETATTR_GID (1 << 2)
427 #define CEPH_SETATTR_MTIME (1 << 3)
428 #define CEPH_SETATTR_ATIME (1 << 4)
429 #define CEPH_SETATTR_SIZE (1 << 5)
430 #define CEPH_SETATTR_CTIME (1 << 6)
431 #define CEPH_SETATTR_MTIME_NOW (1 << 7)
432 #define CEPH_SETATTR_ATIME_NOW (1 << 8)
433 #define CEPH_SETATTR_BTIME (1 << 9)
435 #define CEPH_SETATTR_KILL_SGUID (1 << 10)
440 #define CEPH_O_RDONLY 00000000
441 #define CEPH_O_WRONLY 00000001
442 #define CEPH_O_RDWR 00000002
443 #define CEPH_O_CREAT 00000100
444 #define CEPH_O_EXCL 00000200
445 #define CEPH_O_TRUNC 00001000
446 #define CEPH_O_LAZY 00020000
447 #define CEPH_O_DIRECTORY 00200000
448 #define CEPH_O_NOFOLLOW 00400000
450 int ceph_flags_sys2wire(int flags
);
453 * Ceph setxattr request flags.
455 #define CEPH_XATTR_CREATE (1 << 0)
456 #define CEPH_XATTR_REPLACE (1 << 1)
457 #define CEPH_XATTR_REMOVE (1 << 31)
460 * readdir request flags;
462 #define CEPH_READDIR_REPLY_BITFLAGS (1<<0)
465 * readdir reply flags.
467 #define CEPH_READDIR_FRAG_END (1<<0)
468 #define CEPH_READDIR_FRAG_COMPLETE (1<<8)
469 #define CEPH_READDIR_HASH_ORDER (1<<9)
470 #define CEPH_READDIR_OFFSET_HASH (1<<10)
472 /* Note that this is embedded wthin ceph_mds_request_head_legacy. */
473 union ceph_mds_request_args_legacy
{
475 __le32 mask
; /* CEPH_CAP_* */
476 } __attribute__ ((packed
)) getattr
;
481 struct ceph_timespec mtime
;
482 struct ceph_timespec atime
;
483 __le64 size
, old_size
; /* old_size needed by truncate */
484 __le32 mask
; /* CEPH_SETATTR_* */
485 } __attribute__ ((packed
)) setattr
;
487 __le32 frag
; /* which dir fragment */
488 __le32 max_entries
; /* how many dentries to grab */
492 } __attribute__ ((packed
)) readdir
;
496 } __attribute__ ((packed
)) mknod
;
499 } __attribute__ ((packed
)) mkdir
;
503 __le32 stripe_unit
; /* layout for newly created file */
504 __le32 stripe_count
; /* ... */
506 __le32 pool
; /* if >= 0 and CREATEPOOLID feature */
507 __le32 mask
; /* CEPH_CAP_* */
508 __le64 old_size
; /* if O_TRUNC */
509 } __attribute__ ((packed
)) open
;
512 __le32 osdmap_epoch
; /* use for set file/dir layout */
513 } __attribute__ ((packed
)) setxattr
;
515 struct ceph_file_layout layout
;
516 } __attribute__ ((packed
)) setlayout
;
518 __u8 rule
; /* currently fcntl or flock */
519 __u8 type
; /* shared, exclusive, remove*/
520 __le64 owner
; /* who requests/holds the lock */
521 __le64 pid
; /* process id requesting the lock */
522 __le64 start
; /* initial location to lock */
523 __le64 length
; /* num bytes to lock from start */
524 __u8 wait
; /* will caller wait for lock to become available? */
525 } __attribute__ ((packed
)) filelock_change
;
526 } __attribute__ ((packed
));
528 #define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */
529 #define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */
530 #define CEPH_MDS_FLAG_ASYNC 4 /* request is async */
532 struct ceph_mds_request_head_legacy
{
533 __le64 oldest_client_tid
;
534 __le32 mdsmap_epoch
; /* on client */
535 __le32 flags
; /* CEPH_MDS_FLAG_* */
536 __u8 num_retry
, num_fwd
; /* count retry, fwd attempts */
537 __le16 num_releases
; /* # include cap/lease release records */
538 __le32 op
; /* mds op code */
539 __le32 caller_uid
, caller_gid
;
540 __le64 ino
; /* use this ino for openc, mkdir, mknod,
541 etc. (if replaying) */
542 union ceph_mds_request_args_legacy args
;
543 } __attribute__ ((packed
));
546 * Note that this is embedded wthin ceph_mds_request_head. Also, compatibility
547 * with the ceph_mds_request_args_legacy must be maintained!
549 union ceph_mds_request_args
{
551 __le32 mask
; /* CEPH_CAP_* */
552 } __attribute__ ((packed
)) getattr
;
557 struct ceph_timespec mtime
;
558 struct ceph_timespec atime
;
559 __le64 size
, old_size
; /* old_size needed by truncate */
560 __le32 mask
; /* CEPH_SETATTR_* */
561 struct ceph_timespec btime
;
562 } __attribute__ ((packed
)) setattr
;
564 __le32 frag
; /* which dir fragment */
565 __le32 max_entries
; /* how many dentries to grab */
569 } __attribute__ ((packed
)) readdir
;
573 } __attribute__ ((packed
)) mknod
;
576 } __attribute__ ((packed
)) mkdir
;
580 __le32 stripe_unit
; /* layout for newly created file */
581 __le32 stripe_count
; /* ... */
583 __le32 pool
; /* if >= 0 and CREATEPOOLID feature */
584 __le32 mask
; /* CEPH_CAP_* */
585 __le64 old_size
; /* if O_TRUNC */
586 } __attribute__ ((packed
)) open
;
589 __le32 osdmap_epoch
; /* use for set file/dir layout */
590 } __attribute__ ((packed
)) setxattr
;
592 struct ceph_file_layout layout
;
593 } __attribute__ ((packed
)) setlayout
;
595 __u8 rule
; /* currently fcntl or flock */
596 __u8 type
; /* shared, exclusive, remove*/
597 __le64 owner
; /* who requests/holds the lock */
598 __le64 pid
; /* process id requesting the lock */
599 __le64 start
; /* initial location to lock */
600 __le64 length
; /* num bytes to lock from start */
601 __u8 wait
; /* will caller wait for lock to become available? */
602 } __attribute__ ((packed
)) filelock_change
;
604 __le32 mask
; /* CEPH_CAP_* */
608 } __attribute__ ((packed
)) lookupino
;
609 } __attribute__ ((packed
));
611 #define CEPH_MDS_REQUEST_HEAD_VERSION 1
614 * Note that any change to this structure must ensure that it is compatible
615 * with ceph_mds_request_head_legacy.
617 struct ceph_mds_request_head
{
619 __le64 oldest_client_tid
;
620 __le32 mdsmap_epoch
; /* on client */
621 __le32 flags
; /* CEPH_MDS_FLAG_* */
622 __u8 num_retry
, num_fwd
; /* count retry, fwd attempts */
623 __le16 num_releases
; /* # include cap/lease release records */
624 __le32 op
; /* mds op code */
625 __le32 caller_uid
, caller_gid
;
626 __le64 ino
; /* use this ino for openc, mkdir, mknod,
627 etc. (if replaying) */
628 union ceph_mds_request_args args
;
629 } __attribute__ ((packed
));
631 /* cap/lease release record */
632 struct ceph_mds_request_release
{
633 __le64 ino
, cap_id
; /* ino and unique cap id */
634 __le32 caps
, wanted
; /* new issued, wanted */
635 __le32 seq
, issue_seq
, mseq
;
636 __le32 dname_seq
; /* if releasing a dentry lease, a */
637 __le32 dname_len
; /* string follows. */
638 } __attribute__ ((packed
));
641 copy_from_legacy_head(struct ceph_mds_request_head
*head
,
642 struct ceph_mds_request_head_legacy
*legacy
)
644 struct ceph_mds_request_head_legacy
*embedded_legacy
=
645 (struct ceph_mds_request_head_legacy
*)&head
->oldest_client_tid
;
646 *embedded_legacy
= *legacy
;
650 copy_to_legacy_head(struct ceph_mds_request_head_legacy
*legacy
,
651 struct ceph_mds_request_head
*head
)
653 struct ceph_mds_request_head_legacy
*embedded_legacy
=
654 (struct ceph_mds_request_head_legacy
*)&head
->oldest_client_tid
;
655 *legacy
= *embedded_legacy
;
659 struct ceph_mds_reply_head
{
663 __u8 safe
; /* true if committed to disk */
664 __u8 is_dentry
, is_target
; /* true if dentry, target inode records
665 are included with reply */
666 } __attribute__ ((packed
));
668 /* one for each node split */
669 struct ceph_frag_tree_split
{
670 __le32 frag
; /* this frag splits... */
671 __le32 by
; /* ...by this many bits */
672 } __attribute__ ((packed
));
674 struct ceph_frag_tree_head
{
675 __le32 nsplits
; /* num ceph_frag_tree_split records */
676 struct ceph_frag_tree_split splits
[];
677 } __attribute__ ((packed
));
679 /* capability issue, for bundling with mds reply */
680 struct ceph_mds_reply_cap
{
681 __le32 caps
, wanted
; /* caps issued, wanted */
684 __le64 realm
; /* snap realm */
685 __u8 flags
; /* CEPH_CAP_FLAG_* */
686 } __attribute__ ((packed
));
688 #define CEPH_CAP_FLAG_AUTH (1 << 0) /* cap is issued by auth mds */
689 #define CEPH_CAP_FLAG_RELEASE (1 << 1) /* ask client to release the cap */
691 /* reply_lease follows dname, and reply_inode */
692 struct ceph_mds_reply_lease
{
693 __le16 mask
; /* lease type(s) */
694 __le32 duration_ms
; /* lease duration */
696 } __attribute__ ((packed
));
698 #define CEPH_LEASE_VALID (1 | 2) /* old and new bit values */
699 #define CEPH_LEASE_PRIMARY_LINK 4 /* primary linkage */
701 struct ceph_mds_reply_dirfrag
{
702 __le32 frag
; /* fragment */
703 __le32 auth
; /* auth mds, if this is a delegation point */
704 __le32 ndist
; /* number of mds' this is replicated on */
706 } __attribute__ ((packed
));
708 #define CEPH_LOCK_FCNTL 1
709 #define CEPH_LOCK_FLOCK 2
710 #define CEPH_LOCK_FCNTL_INTR 3
711 #define CEPH_LOCK_FLOCK_INTR 4
713 #define CEPH_LOCK_SHARED 1
714 #define CEPH_LOCK_EXCL 2
715 #define CEPH_LOCK_UNLOCK 4
717 struct ceph_filelock
{
718 __le64 start
;/* file offset to start lock at */
719 __le64 length
; /* num bytes to lock; 0 for all following start */
720 __le64 client
; /* which client holds the lock */
721 __le64 owner
; /* who requests/holds the lock */
722 __le64 pid
; /* process id holding the lock on the client */
723 __u8 type
; /* shared lock, exclusive lock, or unlock */
724 } __attribute__ ((packed
));
727 /* file access modes */
728 #define CEPH_FILE_MODE_PIN 0
729 #define CEPH_FILE_MODE_RD 1
730 #define CEPH_FILE_MODE_WR 2
731 #define CEPH_FILE_MODE_RDWR 3 /* RD | WR */
732 #define CEPH_FILE_MODE_LAZY 4 /* lazy io */
733 #define CEPH_FILE_MODE_NUM 8 /* bc these are bit fields.. mostly */
735 int ceph_flags_to_mode(int flags
);
737 /* inline data state */
738 #define CEPH_INLINE_NONE ((__u64)-1)
739 #define CEPH_INLINE_MAX_SIZE CEPH_MIN_STRIPE_UNIT
741 /* capability bits */
742 #define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */
744 /* generic cap bits */
745 /* note: these definitions are duplicated in mds/locks.c */
746 #define CEPH_CAP_GSHARED 1 /* client can reads */
747 #define CEPH_CAP_GEXCL 2 /* client can read and update */
748 #define CEPH_CAP_GCACHE 4 /* (file) client can cache reads */
749 #define CEPH_CAP_GRD 8 /* (file) client can read */
750 #define CEPH_CAP_GWR 16 /* (file) client can write */
751 #define CEPH_CAP_GBUFFER 32 /* (file) client can buffer writes */
752 #define CEPH_CAP_GWREXTEND 64 /* (file) client can extend EOF */
753 #define CEPH_CAP_GLAZYIO 128 /* (file) client can perform lazy io */
755 #define CEPH_CAP_SIMPLE_BITS 2
756 #define CEPH_CAP_FILE_BITS 8
759 #define CEPH_CAP_SAUTH 2
760 #define CEPH_CAP_SLINK 4
761 #define CEPH_CAP_SXATTR 6
762 #define CEPH_CAP_SFILE 8
764 /* composed values */
765 #define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH)
766 #define CEPH_CAP_AUTH_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SAUTH)
767 #define CEPH_CAP_LINK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SLINK)
768 #define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK)
769 #define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SXATTR)
770 #define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR)
771 #define CEPH_CAP_FILE(x) ((x) << CEPH_CAP_SFILE)
772 #define CEPH_CAP_FILE_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFILE)
773 #define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE)
774 #define CEPH_CAP_FILE_CACHE (CEPH_CAP_GCACHE << CEPH_CAP_SFILE)
775 #define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE)
776 #define CEPH_CAP_FILE_WR (CEPH_CAP_GWR << CEPH_CAP_SFILE)
777 #define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE)
778 #define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
779 #define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE)
781 /* cap masks (for getattr) */
782 #define CEPH_STAT_CAP_INODE CEPH_CAP_PIN
783 #define CEPH_STAT_CAP_TYPE CEPH_CAP_PIN /* mode >> 12 */
784 #define CEPH_STAT_CAP_SYMLINK CEPH_CAP_PIN
785 #define CEPH_STAT_CAP_UID CEPH_CAP_AUTH_SHARED
786 #define CEPH_STAT_CAP_GID CEPH_CAP_AUTH_SHARED
787 #define CEPH_STAT_CAP_MODE CEPH_CAP_AUTH_SHARED
788 #define CEPH_STAT_CAP_NLINK CEPH_CAP_LINK_SHARED
789 #define CEPH_STAT_CAP_LAYOUT CEPH_CAP_FILE_SHARED
790 #define CEPH_STAT_CAP_MTIME CEPH_CAP_FILE_SHARED
791 #define CEPH_STAT_CAP_SIZE CEPH_CAP_FILE_SHARED
792 #define CEPH_STAT_CAP_ATIME CEPH_CAP_FILE_SHARED /* fixme */
793 #define CEPH_STAT_CAP_XATTR CEPH_CAP_XATTR_SHARED
794 #define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN | \
795 CEPH_CAP_AUTH_SHARED | \
796 CEPH_CAP_LINK_SHARED | \
797 CEPH_CAP_FILE_SHARED | \
798 CEPH_CAP_XATTR_SHARED)
799 #define CEPH_STAT_CAP_INLINE_DATA (CEPH_CAP_FILE_SHARED | \
801 #define CEPH_STAT_RSTAT CEPH_CAP_FILE_WREXTEND
803 #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \
804 CEPH_CAP_LINK_SHARED | \
805 CEPH_CAP_XATTR_SHARED | \
806 CEPH_CAP_FILE_SHARED)
807 #define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \
810 #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \
811 CEPH_CAP_LINK_EXCL | \
812 CEPH_CAP_XATTR_EXCL | \
814 #define CEPH_CAP_ANY_FILE_RD (CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE | \
815 CEPH_CAP_FILE_SHARED)
816 #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \
818 #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
819 #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
820 CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \
823 #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
826 /* cap masks async dir operations */
827 #define CEPH_CAP_DIR_CREATE CEPH_CAP_FILE_CACHE
828 #define CEPH_CAP_DIR_UNLINK CEPH_CAP_FILE_RD
829 #define CEPH_CAP_ANY_DIR_OPS (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_RD | \
830 CEPH_CAP_FILE_WREXTEND | CEPH_CAP_FILE_LAZYIO)
833 int ceph_caps_for_mode(int mode
);
836 CEPH_CAP_OP_GRANT
, /* mds->client grant */
837 CEPH_CAP_OP_REVOKE
, /* mds->client revoke */
838 CEPH_CAP_OP_TRUNC
, /* mds->client trunc notify */
839 CEPH_CAP_OP_EXPORT
, /* mds has exported the cap */
840 CEPH_CAP_OP_IMPORT
, /* mds has imported the cap */
841 CEPH_CAP_OP_UPDATE
, /* client->mds update */
842 CEPH_CAP_OP_DROP
, /* client->mds drop cap bits */
843 CEPH_CAP_OP_FLUSH
, /* client->mds cap writeback */
844 CEPH_CAP_OP_FLUSH_ACK
, /* mds->client flushed */
845 CEPH_CAP_OP_FLUSHSNAP
, /* client->mds flush snapped metadata */
846 CEPH_CAP_OP_FLUSHSNAP_ACK
, /* mds->client flushed snapped metadata */
847 CEPH_CAP_OP_RELEASE
, /* client->mds release (clean) cap */
848 CEPH_CAP_OP_RENEW
, /* client->mds renewal request */
851 extern const char *ceph_cap_op_name(int op
);
853 /* extra info for cap import/export */
854 struct ceph_mds_cap_peer
{
860 } __attribute__ ((packed
));
863 * caps message, used for capability callbacks, acks, requests, etc.
865 struct ceph_mds_caps_head
{
866 __le32 op
; /* CEPH_CAP_OP_* */
869 __le32 seq
, issue_seq
;
870 __le32 caps
, wanted
, dirty
; /* latest issued/wanted/dirty */
873 __le32 snap_trace_len
;
876 __le32 uid
, gid
, mode
;
883 __le64 xattr_version
;
884 } __attribute__ ((packed
));
886 struct ceph_mds_caps_non_export_body
{
887 /* all except export */
889 __le64 size
, max_size
, truncate_size
;
891 struct ceph_timespec mtime
, atime
, ctime
;
892 struct ceph_file_layout layout
;
893 __le32 time_warp_seq
;
894 } __attribute__ ((packed
));
896 struct ceph_mds_caps_export_body
{
898 struct ceph_mds_cap_peer peer
;
899 } __attribute__ ((packed
));
901 /* cap release msg head */
902 struct ceph_mds_cap_release
{
903 __le32 num
; /* number of cap_items that follow */
904 } __attribute__ ((packed
));
906 struct ceph_mds_cap_item
{
909 __le32 migrate_seq
, seq
;
910 } __attribute__ ((packed
));
912 #define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */
913 #define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */
914 #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */
915 #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */
917 extern const char *ceph_lease_op_name(int o
);
919 /* lease msg header */
920 struct ceph_mds_lease
{
921 __u8 action
; /* CEPH_MDS_LEASE_* */
922 __le16 mask
; /* which lease */
924 __le64 first
, last
; /* snap range */
926 __le32 duration_ms
; /* duration of renewal */
927 } __attribute__ ((packed
));
928 /* followed by a __le32+string for dname */
930 /* client reconnect */
931 struct ceph_mds_cap_reconnect
{
936 __le64 pathbase
; /* base ino for our path to this ino */
937 __le32 flock_len
; /* size of flock state blob, if any */
938 } __attribute__ ((packed
));
939 /* followed by flock blob */
941 struct ceph_mds_cap_reconnect_v1
{
946 struct ceph_timespec mtime
, atime
;
948 __le64 pathbase
; /* base ino for our path to this ino */
949 } __attribute__ ((packed
));
951 struct ceph_mds_snaprealm_reconnect
{
952 __le64 ino
; /* snap realm base */
953 __le64 seq
; /* snap seq for this snap realm */
954 __le64 parent
; /* parent realm */
955 } __attribute__ ((packed
));
961 CEPH_SNAP_OP_UPDATE
, /* CREATE or DESTROY */
963 CEPH_SNAP_OP_DESTROY
,
967 extern const char *ceph_snap_op_name(int o
);
969 /* snap msg header */
970 struct ceph_mds_snap_head
{
971 __le32 op
; /* CEPH_SNAP_OP_* */
972 __le64 split
; /* ino to split off, if any */
973 __le32 num_split_inos
; /* # inos belonging to new child realm */
974 __le32 num_split_realms
; /* # child realms udner new child realm */
975 __le32 trace_len
; /* size of snap trace blob */
976 } __attribute__ ((packed
));
977 /* followed by split ino list, then split realms, then the trace blob */
980 * encode info about a snaprealm, as viewed by a client
982 struct ceph_mds_snap_realm
{
983 __le64 ino
; /* ino */
984 __le64 created
; /* snap: when created */
985 __le64 parent
; /* ino: parent realm */
986 __le64 parent_since
; /* snap: same parent since */
987 __le64 seq
; /* snap: version */
989 __le32 num_prior_parent_snaps
;
990 } __attribute__ ((packed
));
991 /* followed by my snap list, then prior parent snap list */