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.
17 #include "include/encoding.h"
18 #include "include/denc.h"
21 * The data structures defined here are shared between Linux kernel and
22 * user space. Also, those data structures are maintained always in
23 * little-endian byte order, even on big-endian systems. This is handled
24 * differently in kernel vs. user space. For use as kernel headers, the
25 * little-endian fields need to use the __le16/__le32/__le64 types. These
26 * are markers that indicate endian conversion routines must be used
27 * whenever such fields are accessed, which can be verified by checker
28 * tools like "sparse". For use as user-space headers, the little-endian
29 * fields instead use types ceph_le16/ceph_le32/ceph_le64, which are C++
30 * classes that implement automatic endian conversion on every access.
31 * To still allow for header sharing, this file uses the __le types, but
32 * redefines those to the ceph_ types when compiled in user space.
35 #include "byteorder.h"
36 #define __le16 ceph_le16
37 #define __le32 ceph_le32
38 #define __le64 ceph_le64
42 * subprotocol versions. when specific messages types or high-level
43 * protocols change, bump the affected components. we keep rev
44 * internal cluster protocols separately from the public,
45 * client-facing protocol.
47 #define CEPH_OSDC_PROTOCOL 24 /* server/client */
48 #define CEPH_MDSC_PROTOCOL 32 /* server/client */
49 #define CEPH_MONC_PROTOCOL 15 /* server/client */
52 #define CEPH_INO_ROOT 1
54 * hidden .ceph dir, which is no longer created but
55 * recognised in existing filesystems so that we
56 * don't try to fragment it.
58 #define CEPH_INO_CEPH 2
59 #define CEPH_INO_GLOBAL_SNAPREALM 3
60 #define CEPH_INO_LOST_AND_FOUND 4 /* reserved ino for use in recovery */
62 /* arbitrary limit on max # of monitors (cluster of 3 is typical) */
63 #define CEPH_MAX_MON 31
66 * ceph_file_layout - describe data layout for a file/inode
68 struct ceph_file_layout
{
69 /* file -> object mapping */
70 __le32 fl_stripe_unit
; /* stripe unit, in bytes. must be multiple
72 __le32 fl_stripe_count
; /* over this many objects */
73 __le32 fl_object_size
; /* until objects are this big, then move to
75 __le32 fl_cas_hash
; /* UNUSED. 0 = none; 1 = sha256 */
77 /* pg -> disk layout */
78 __le32 fl_object_stripe_unit
; /* UNUSED. for per-object parity, if any */
80 /* object -> pg layout */
81 __le32 fl_unused
; /* unused; used to be preferred primary for pg (-1 for none) */
82 __le32 fl_pg_pool
; /* namespace, crush rule, rep level */
83 } __attribute__ ((packed
));
85 #define CEPH_MIN_STRIPE_UNIT 65536
87 struct ceph_dir_layout
{
88 __u8 dl_dir_hash
; /* see ceph_hash.h for ids */
92 } __attribute__ ((packed
));
94 /* crypto algorithms */
95 #define CEPH_CRYPTO_NONE 0x0
96 #define CEPH_CRYPTO_AES 0x1
98 #define CEPH_AES_IV "cephsageyudagreg"
100 /* security/authentication protocols */
101 #define CEPH_AUTH_UNKNOWN 0x0
102 #define CEPH_AUTH_NONE 0x1
103 #define CEPH_AUTH_CEPHX 0x2
105 /* msgr2 protocol modes */
106 #define CEPH_CON_MODE_UNKNOWN 0x0
107 #define CEPH_CON_MODE_CRC 0x1
108 #define CEPH_CON_MODE_SECURE 0x2
110 extern const char *ceph_con_mode_name(int con_mode
);
112 /* For options with "_", like: GSS_GSS
113 which means: Mode/Protocol to validate "authentication_authorization",
115 - Authentication: Verifying the identity of an entity.
116 - Authorization: Verifying that an authenticated entity has
117 the right to access a particular resource.
119 #define CEPH_AUTH_GSS 0x4
120 #define CEPH_AUTH_GSS_GSS CEPH_AUTH_GSS
122 #define CEPH_AUTH_UID_DEFAULT ((__u64) -1)
125 /*********************************************
134 #define CEPH_MSG_SHUTDOWN 1
135 #define CEPH_MSG_PING 2
137 /* client <-> monitor */
138 #define CEPH_MSG_MON_MAP 4
139 #define CEPH_MSG_MON_GET_MAP 5
140 #define CEPH_MSG_MON_GET_OSDMAP 6
141 #define CEPH_MSG_MON_METADATA 7
142 #define CEPH_MSG_STATFS 13
143 #define CEPH_MSG_STATFS_REPLY 14
144 #define CEPH_MSG_MON_SUBSCRIBE 15
145 #define CEPH_MSG_MON_SUBSCRIBE_ACK 16
146 #define CEPH_MSG_AUTH 17
147 #define CEPH_MSG_AUTH_REPLY 18
148 #define CEPH_MSG_MON_GET_VERSION 19
149 #define CEPH_MSG_MON_GET_VERSION_REPLY 20
152 #define CEPH_MSG_MDS_MAP 21
154 #define CEPH_MSG_CLIENT_SESSION 22
155 #define CEPH_MSG_CLIENT_RECONNECT 23
157 #define CEPH_MSG_CLIENT_REQUEST 24
158 #define CEPH_MSG_CLIENT_REQUEST_FORWARD 25
159 #define CEPH_MSG_CLIENT_REPLY 26
160 #define CEPH_MSG_CLIENT_RECLAIM 27
161 #define CEPH_MSG_CLIENT_RECLAIM_REPLY 28
162 #define CEPH_MSG_CLIENT_METRICS 29
163 #define CEPH_MSG_CLIENT_CAPS 0x310
164 #define CEPH_MSG_CLIENT_LEASE 0x311
165 #define CEPH_MSG_CLIENT_SNAP 0x312
166 #define CEPH_MSG_CLIENT_CAPRELEASE 0x313
167 #define CEPH_MSG_CLIENT_QUOTA 0x314
170 #define CEPH_MSG_POOLOP_REPLY 48
171 #define CEPH_MSG_POOLOP 49
175 #define CEPH_MSG_OSD_MAP 41
176 #define CEPH_MSG_OSD_OP 42
177 #define CEPH_MSG_OSD_OPREPLY 43
178 #define CEPH_MSG_WATCH_NOTIFY 44
179 #define CEPH_MSG_OSD_BACKOFF 61
181 /* FSMap subscribers (see all MDS clusters at once) */
182 #define CEPH_MSG_FS_MAP 45
183 /* FSMapUser subscribers (get MDS clusters name->ID mapping) */
184 #define CEPH_MSG_FS_MAP_USER 103
186 /* watch-notify operations */
188 CEPH_WATCH_EVENT_NOTIFY
= 1, /* notifying watcher */
189 CEPH_WATCH_EVENT_NOTIFY_COMPLETE
= 2, /* notifier notified when done */
190 CEPH_WATCH_EVENT_DISCONNECT
= 3, /* we were disconnected */
193 const char *ceph_watch_event_name(int o
);
195 /* pool operations */
197 POOL_OP_CREATE
= 0x01,
198 POOL_OP_DELETE
= 0x02,
199 POOL_OP_AUID_CHANGE
= 0x03,
200 POOL_OP_CREATE_SNAP
= 0x11,
201 POOL_OP_DELETE_SNAP
= 0x12,
202 POOL_OP_CREATE_UNMANAGED_SNAP
= 0x21,
203 POOL_OP_DELETE_UNMANAGED_SNAP
= 0x22,
206 struct ceph_mon_request_header
{
209 __le64 session_mon_tid
;
210 } __attribute__ ((packed
));
212 struct ceph_mon_statfs
{
213 struct ceph_mon_request_header monhdr
;
214 struct ceph_fsid fsid
;
215 } __attribute__ ((packed
));
218 __le64 kb
, kb_used
, kb_avail
;
220 } __attribute__ ((packed
));
222 struct ceph_mon_statfs_reply
{
223 struct ceph_fsid fsid
;
225 struct ceph_statfs st
;
226 } __attribute__ ((packed
));
228 const char *ceph_pool_op_name(int op
);
230 struct ceph_mon_poolop
{
231 struct ceph_mon_request_header monhdr
;
232 struct ceph_fsid fsid
;
235 __le64 __old_auid
; // obsolete
238 } __attribute__ ((packed
));
240 struct ceph_mon_poolop_reply
{
241 struct ceph_mon_request_header monhdr
;
242 struct ceph_fsid fsid
;
247 } __attribute__ ((packed
));
249 struct ceph_mon_unmanaged_snap
{
251 } __attribute__ ((packed
));
253 struct ceph_osd_getmap
{
254 struct ceph_mon_request_header monhdr
;
255 struct ceph_fsid fsid
;
257 } __attribute__ ((packed
));
259 struct ceph_mds_getmap
{
260 struct ceph_mon_request_header monhdr
;
261 struct ceph_fsid fsid
;
262 } __attribute__ ((packed
));
264 struct ceph_client_mount
{
265 struct ceph_mon_request_header monhdr
;
266 } __attribute__ ((packed
));
268 #define CEPH_SUBSCRIBE_ONETIME 1 /* i want only 1 update after have */
270 struct ceph_mon_subscribe_item
{
273 } __attribute__ ((packed
));
275 struct ceph_mon_subscribe_ack
{
276 __le32 duration
; /* seconds */
277 struct ceph_fsid fsid
;
278 } __attribute__ ((packed
));
283 #define CEPH_MDSMAP_NOT_JOINABLE (1<<0) /* standbys cannot join */
284 #define CEPH_MDSMAP_DOWN (CEPH_MDSMAP_NOT_JOINABLE) /* backwards compat */
285 #define CEPH_MDSMAP_ALLOW_SNAPS (1<<1) /* cluster allowed to create snapshots */
286 /* deprecated #define CEPH_MDSMAP_ALLOW_MULTIMDS (1<<2) cluster allowed to have >1 active MDS */
287 /* deprecated #define CEPH_MDSMAP_ALLOW_DIRFRAGS (1<<3) cluster allowed to fragment directories */
288 #define CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS (1<<4) /* cluster alllowed to enable MULTIMDS
289 and SNAPS at the same time */
290 #define CEPH_MDSMAP_ALLOW_STANDBY_REPLAY (1<<5) /* cluster alllowed to enable MULTIMDS */
291 #define CEPH_MDSMAP_REFUSE_CLIENT_SESSION (1<<6) /* cluster allowed to refuse client session
293 #define CEPH_MDSMAP_DEFAULTS (CEPH_MDSMAP_ALLOW_SNAPS | \
294 CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS)
301 #define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */
302 #define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees.
304 #define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */
305 #define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */
306 #define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */
307 #define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */
308 #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */
309 #define CEPH_MDS_STATE_REPLAYONCE -9 /* Legacy, unused */
310 #define CEPH_MDS_STATE_NULL -10
312 #define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */
313 #define CEPH_MDS_STATE_RESOLVE 9 /* up, disambiguating distributed
314 operations (import, rename, etc.) */
315 #define CEPH_MDS_STATE_RECONNECT 10 /* up, reconnect to clients */
316 #define CEPH_MDS_STATE_REJOIN 11 /* up, rejoining distributed cache */
317 #define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */
318 #define CEPH_MDS_STATE_ACTIVE 13 /* up, active */
319 #define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */
320 #define CEPH_MDS_STATE_DAMAGED 15 /* rank not replayable, need repair */
322 extern const char *ceph_mds_state_name(int s
);
326 * metadata lock types.
327 * - these are bitmasks.. we can compose them
328 * - they also define the lock ordering by the MDS
329 * - a few of these are internal to the mds
331 #define CEPH_LOCK_DN (1 << 0)
332 #define CEPH_LOCK_DVERSION (1 << 1)
333 #define CEPH_LOCK_ISNAP (1 << 4) /* snapshot lock. MDS internal */
334 #define CEPH_LOCK_IPOLICY (1 << 5) /* policy lock on dirs. MDS internal */
335 #define CEPH_LOCK_IFILE (1 << 6)
336 #define CEPH_LOCK_INEST (1 << 7) /* mds internal */
337 #define CEPH_LOCK_IDFT (1 << 8) /* dir frag tree */
338 #define CEPH_LOCK_IAUTH (1 << 9)
339 #define CEPH_LOCK_ILINK (1 << 10)
340 #define CEPH_LOCK_IXATTR (1 << 11)
341 #define CEPH_LOCK_IFLOCK (1 << 12) /* advisory file locks */
342 #define CEPH_LOCK_IVERSION (1 << 13) /* mds internal */
344 #define CEPH_LOCK_IFIRST CEPH_LOCK_ISNAP
347 /* client_session ops */
349 CEPH_SESSION_REQUEST_OPEN
,
351 CEPH_SESSION_REQUEST_CLOSE
,
353 CEPH_SESSION_REQUEST_RENEWCAPS
,
354 CEPH_SESSION_RENEWCAPS
,
356 CEPH_SESSION_RECALL_STATE
,
357 CEPH_SESSION_FLUSHMSG
,
358 CEPH_SESSION_FLUSHMSG_ACK
,
359 CEPH_SESSION_FORCE_RO
,
360 // A response to REQUEST_OPEN indicating that the client should
361 // permanently desist from contacting the MDS
363 CEPH_SESSION_REQUEST_FLUSH_MDLOG
366 // flags for state reclaim
367 #define CEPH_RECLAIM_RESET 1
369 extern const char *ceph_session_op_name(int op
);
371 struct ceph_mds_session_head
{
374 struct ceph_timespec stamp
;
375 __le32 max_caps
, max_leases
;
376 } __attribute__ ((packed
));
381 * & 0x001000 -> write op
382 * & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
383 & & 0x100000 -> use weird ino/path trace
385 #define CEPH_MDS_OP_WRITE 0x001000
387 CEPH_MDS_OP_LOOKUP
= 0x00100,
388 CEPH_MDS_OP_GETATTR
= 0x00101,
389 CEPH_MDS_OP_LOOKUPHASH
= 0x00102,
390 CEPH_MDS_OP_LOOKUPPARENT
= 0x00103,
391 CEPH_MDS_OP_LOOKUPINO
= 0x00104,
392 CEPH_MDS_OP_LOOKUPNAME
= 0x00105,
393 CEPH_MDS_OP_GETVXATTR
= 0x00106,
394 CEPH_MDS_OP_DUMMY
= 0x00107,
396 CEPH_MDS_OP_SETXATTR
= 0x01105,
397 CEPH_MDS_OP_RMXATTR
= 0x01106,
398 CEPH_MDS_OP_SETLAYOUT
= 0x01107,
399 CEPH_MDS_OP_SETATTR
= 0x01108,
400 CEPH_MDS_OP_SETFILELOCK
= 0x01109,
401 CEPH_MDS_OP_GETFILELOCK
= 0x00110,
402 CEPH_MDS_OP_SETDIRLAYOUT
=0x0110a,
404 CEPH_MDS_OP_MKNOD
= 0x01201,
405 CEPH_MDS_OP_LINK
= 0x01202,
406 CEPH_MDS_OP_UNLINK
= 0x01203,
407 CEPH_MDS_OP_RENAME
= 0x01204,
408 CEPH_MDS_OP_MKDIR
= 0x01220,
409 CEPH_MDS_OP_RMDIR
= 0x01221,
410 CEPH_MDS_OP_SYMLINK
= 0x01222,
412 CEPH_MDS_OP_CREATE
= 0x01301,
413 CEPH_MDS_OP_OPEN
= 0x00302,
414 CEPH_MDS_OP_READDIR
= 0x00305,
416 CEPH_MDS_OP_LOOKUPSNAP
= 0x00400,
417 CEPH_MDS_OP_MKSNAP
= 0x01400,
418 CEPH_MDS_OP_RMSNAP
= 0x01401,
419 CEPH_MDS_OP_LSSNAP
= 0x00402,
420 CEPH_MDS_OP_RENAMESNAP
= 0x01403,
423 CEPH_MDS_OP_FRAGMENTDIR
= 0x01500,
424 CEPH_MDS_OP_EXPORTDIR
= 0x01501,
425 CEPH_MDS_OP_FLUSH
= 0x01502,
426 CEPH_MDS_OP_ENQUEUE_SCRUB
= 0x01503,
427 CEPH_MDS_OP_REPAIR_FRAGSTATS
= 0x01504,
428 CEPH_MDS_OP_REPAIR_INODESTATS
= 0x01505,
429 CEPH_MDS_OP_RDLOCK_FRAGSSTATS
= 0x01507
432 extern const char *ceph_mds_op_name(int op
);
434 // setattr mask is an int
435 #ifndef CEPH_SETATTR_MODE
436 #define CEPH_SETATTR_MODE (1 << 0)
437 #define CEPH_SETATTR_UID (1 << 1)
438 #define CEPH_SETATTR_GID (1 << 2)
439 #define CEPH_SETATTR_MTIME (1 << 3)
440 #define CEPH_SETATTR_ATIME (1 << 4)
441 #define CEPH_SETATTR_SIZE (1 << 5)
442 #define CEPH_SETATTR_CTIME (1 << 6)
443 #define CEPH_SETATTR_MTIME_NOW (1 << 7)
444 #define CEPH_SETATTR_ATIME_NOW (1 << 8)
445 #define CEPH_SETATTR_BTIME (1 << 9)
446 #define CEPH_SETATTR_KILL_SGUID (1 << 10)
447 #define CEPH_SETATTR_FSCRYPT_AUTH (1 << 11)
448 #define CEPH_SETATTR_FSCRYPT_FILE (1 << 12)
449 #define CEPH_SETATTR_KILL_SUID (1 << 13)
450 #define CEPH_SETATTR_KILL_SGID (1 << 14)
456 #define CEPH_O_RDONLY 00000000
457 #define CEPH_O_WRONLY 00000001
458 #define CEPH_O_RDWR 00000002
459 #define CEPH_O_CREAT 00000100
460 #define CEPH_O_EXCL 00000200
461 #define CEPH_O_TRUNC 00001000
462 #define CEPH_O_LAZY 00020000
463 #define CEPH_O_DIRECTORY 00200000
464 #define CEPH_O_NOFOLLOW 00400000
466 int ceph_flags_sys2wire(int flags
);
469 * Ceph setxattr request flags.
471 #define CEPH_XATTR_CREATE (1 << 0)
472 #define CEPH_XATTR_REPLACE (1 << 1)
473 #define CEPH_XATTR_REMOVE (1 << 31)
476 * readdir request flags;
478 #define CEPH_READDIR_REPLY_BITFLAGS (1<<0)
481 * readdir reply flags.
483 #define CEPH_READDIR_FRAG_END (1<<0)
484 #define CEPH_READDIR_FRAG_COMPLETE (1<<8)
485 #define CEPH_READDIR_HASH_ORDER (1<<9)
486 #define CEPH_READDIR_OFFSET_HASH (1<<10)
488 /* Note that this is embedded wthin ceph_mds_request_head_legacy. */
489 union ceph_mds_request_args_legacy
{
491 __le32 mask
; /* CEPH_CAP_* */
492 } __attribute__ ((packed
)) getattr
;
497 struct ceph_timespec mtime
;
498 struct ceph_timespec atime
;
499 __le64 size
, old_size
; /* old_size needed by truncate */
500 __le32 mask
; /* CEPH_SETATTR_* */
501 } __attribute__ ((packed
)) setattr
;
503 __le32 frag
; /* which dir fragment */
504 __le32 max_entries
; /* how many dentries to grab */
508 } __attribute__ ((packed
)) readdir
;
512 } __attribute__ ((packed
)) mknod
;
515 } __attribute__ ((packed
)) mkdir
;
519 __le32 stripe_unit
; /* layout for newly created file */
520 __le32 stripe_count
; /* ... */
522 __le32 pool
; /* if >= 0 and CREATEPOOLID feature */
523 __le32 mask
; /* CEPH_CAP_* */
524 __le64 old_size
; /* if O_TRUNC */
525 } __attribute__ ((packed
)) open
;
528 __le32 osdmap_epoch
; /* use for set file/dir layout */
529 } __attribute__ ((packed
)) setxattr
;
531 struct ceph_file_layout layout
;
532 } __attribute__ ((packed
)) setlayout
;
534 __u8 rule
; /* currently fcntl or flock */
535 __u8 type
; /* shared, exclusive, remove*/
536 __le64 owner
; /* who requests/holds the lock */
537 __le64 pid
; /* process id requesting the lock */
538 __le64 start
; /* initial location to lock */
539 __le64 length
; /* num bytes to lock from start */
540 __u8 wait
; /* will caller wait for lock to become available? */
541 } __attribute__ ((packed
)) filelock_change
;
542 } __attribute__ ((packed
));
544 #define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */
545 #define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */
546 #define CEPH_MDS_FLAG_ASYNC 4 /* request is async */
548 struct ceph_mds_request_head_legacy
{
549 __le64 oldest_client_tid
;
550 __le32 mdsmap_epoch
; /* on client */
551 __le32 flags
; /* CEPH_MDS_FLAG_* */
552 __u8 num_retry
, num_fwd
; /* count retry, fwd attempts */
553 __le16 num_releases
; /* # include cap/lease release records */
554 __le32 op
; /* mds op code */
555 __le32 caller_uid
, caller_gid
;
556 __le64 ino
; /* use this ino for openc, mkdir, mknod,
557 etc. (if replaying) */
558 union ceph_mds_request_args_legacy args
;
559 } __attribute__ ((packed
));
562 * Note that this is embedded wthin ceph_mds_request_head. Also, compatibility
563 * with the ceph_mds_request_args_legacy must be maintained!
565 union ceph_mds_request_args
{
567 __le32 mask
; /* CEPH_CAP_* */
568 } __attribute__ ((packed
)) getattr
;
573 struct ceph_timespec mtime
;
574 struct ceph_timespec atime
;
575 __le64 size
, old_size
; /* old_size needed by truncate */
576 __le32 mask
; /* CEPH_SETATTR_* */
577 struct ceph_timespec btime
;
578 } __attribute__ ((packed
)) setattr
;
580 __le32 frag
; /* which dir fragment */
581 __le32 max_entries
; /* how many dentries to grab */
585 } __attribute__ ((packed
)) readdir
;
589 } __attribute__ ((packed
)) mknod
;
592 } __attribute__ ((packed
)) mkdir
;
596 __le32 stripe_unit
; /* layout for newly created file */
597 __le32 stripe_count
; /* ... */
599 __le32 pool
; /* if >= 0 and CREATEPOOLID feature */
600 __le32 mask
; /* CEPH_CAP_* */
601 __le64 old_size
; /* if O_TRUNC */
602 } __attribute__ ((packed
)) open
;
605 __le32 osdmap_epoch
; /* use for set file/dir layout */
606 } __attribute__ ((packed
)) setxattr
;
608 struct ceph_file_layout layout
;
609 } __attribute__ ((packed
)) setlayout
;
611 __u8 rule
; /* currently fcntl or flock */
612 __u8 type
; /* shared, exclusive, remove*/
613 __le64 owner
; /* who requests/holds the lock */
614 __le64 pid
; /* process id requesting the lock */
615 __le64 start
; /* initial location to lock */
616 __le64 length
; /* num bytes to lock from start */
617 __u8 wait
; /* will caller wait for lock to become available? */
618 } __attribute__ ((packed
)) filelock_change
;
620 __le32 mask
; /* CEPH_CAP_* */
624 } __attribute__ ((packed
)) lookupino
;
625 } __attribute__ ((packed
));
627 #define CEPH_MDS_REQUEST_HEAD_VERSION 2
630 * Note that any change to this structure must ensure that it is compatible
631 * with ceph_mds_request_head_legacy.
633 struct ceph_mds_request_head
{
635 __le64 oldest_client_tid
;
636 __le32 mdsmap_epoch
; /* on client */
637 __le32 flags
; /* CEPH_MDS_FLAG_* */
638 __u8 num_retry
, num_fwd
; /* legacy count retry and fwd attempts */
639 __le16 num_releases
; /* # include cap/lease release records */
640 __le32 op
; /* mds op code */
641 __le32 caller_uid
, caller_gid
;
642 __le64 ino
; /* use this ino for openc, mkdir, mknod,
643 etc. (if replaying) */
644 union ceph_mds_request_args args
;
646 __le32 ext_num_retry
; /* new count retry attempts */
647 __le32 ext_num_fwd
; /* new count fwd attempts */
648 } __attribute__ ((packed
));
650 void inline encode(const struct ceph_mds_request_head
& h
, ceph::buffer::list
& bl
, bool old_version
) {
652 encode(h
.version
, bl
);
653 encode(h
.oldest_client_tid
, bl
);
654 encode(h
.mdsmap_epoch
, bl
);
657 // For old MDS daemons
658 __u8 num_retry
= __u32(h
.ext_num_retry
);
659 __u8 num_fwd
= __u32(h
.ext_num_fwd
);
660 encode(num_retry
, bl
);
663 encode(h
.num_releases
, bl
);
665 encode(h
.caller_uid
, bl
);
666 encode(h
.caller_gid
, bl
);
668 bl
.append((char*)&h
.args
, sizeof(h
.args
));
671 encode(h
.ext_num_retry
, bl
);
672 encode(h
.ext_num_fwd
, bl
);
676 void inline decode(struct ceph_mds_request_head
& h
, ceph::buffer::list::const_iterator
& bl
) {
678 decode(h
.version
, bl
);
679 decode(h
.oldest_client_tid
, bl
);
680 decode(h
.mdsmap_epoch
, bl
);
682 decode(h
.num_retry
, bl
);
683 decode(h
.num_fwd
, bl
);
684 decode(h
.num_releases
, bl
);
686 decode(h
.caller_uid
, bl
);
687 decode(h
.caller_gid
, bl
);
689 bl
.copy(sizeof(h
.args
), (char*)&(h
.args
));
691 if (h
.version
>= 2) {
692 decode(h
.ext_num_retry
, bl
);
693 decode(h
.ext_num_fwd
, bl
);
695 h
.ext_num_retry
= h
.num_retry
;
696 h
.ext_num_fwd
= h
.num_fwd
;
700 /* cap/lease release record */
701 struct ceph_mds_request_release
{
702 __le64 ino
, cap_id
; /* ino and unique cap id */
703 __le32 caps
, wanted
; /* new issued, wanted */
704 __le32 seq
, issue_seq
, mseq
;
705 __le32 dname_seq
; /* if releasing a dentry lease, a */
706 __le32 dname_len
; /* string follows. */
707 } __attribute__ ((packed
));
710 copy_from_legacy_head(struct ceph_mds_request_head
*head
,
711 struct ceph_mds_request_head_legacy
*legacy
)
713 struct ceph_mds_request_head_legacy
*embedded_legacy
=
714 (struct ceph_mds_request_head_legacy
*)&head
->oldest_client_tid
;
715 *embedded_legacy
= *legacy
;
719 copy_to_legacy_head(struct ceph_mds_request_head_legacy
*legacy
,
720 struct ceph_mds_request_head
*head
)
722 struct ceph_mds_request_head_legacy
*embedded_legacy
=
723 (struct ceph_mds_request_head_legacy
*)&head
->oldest_client_tid
;
724 *legacy
= *embedded_legacy
;
728 struct ceph_mds_reply_head
{
732 __u8 safe
; /* true if committed to disk */
733 __u8 is_dentry
, is_target
; /* true if dentry, target inode records
734 are included with reply */
735 } __attribute__ ((packed
));
737 /* one for each node split */
738 struct ceph_frag_tree_split
{
739 __le32 frag
; /* this frag splits... */
740 __le32 by
; /* ...by this many bits */
741 } __attribute__ ((packed
));
743 struct ceph_frag_tree_head
{
744 __le32 nsplits
; /* num ceph_frag_tree_split records */
745 struct ceph_frag_tree_split splits
[];
746 } __attribute__ ((packed
));
748 /* capability issue, for bundling with mds reply */
749 struct ceph_mds_reply_cap
{
750 __le32 caps
, wanted
; /* caps issued, wanted */
753 __le64 realm
; /* snap realm */
754 __u8 flags
; /* CEPH_CAP_FLAG_* */
755 } __attribute__ ((packed
));
757 #define CEPH_CAP_FLAG_AUTH (1 << 0) /* cap is issued by auth mds */
758 #define CEPH_CAP_FLAG_RELEASE (1 << 1) /* ask client to release the cap */
760 /* reply_lease follows dname, and reply_inode */
761 struct ceph_mds_reply_lease
{
762 __le16 mask
; /* lease type(s) */
763 __le32 duration_ms
; /* lease duration */
765 } __attribute__ ((packed
));
767 #define CEPH_LEASE_VALID (1 | 2) /* old and new bit values */
768 #define CEPH_LEASE_PRIMARY_LINK 4 /* primary linkage */
770 struct ceph_mds_reply_dirfrag
{
771 __le32 frag
; /* fragment */
772 __le32 auth
; /* auth mds, if this is a delegation point */
773 __le32 ndist
; /* number of mds' this is replicated on */
775 } __attribute__ ((packed
));
777 #define CEPH_LOCK_FCNTL 1
778 #define CEPH_LOCK_FLOCK 2
779 #define CEPH_LOCK_FCNTL_INTR 3
780 #define CEPH_LOCK_FLOCK_INTR 4
782 #define CEPH_LOCK_SHARED 1
783 #define CEPH_LOCK_EXCL 2
784 #define CEPH_LOCK_UNLOCK 4
786 struct ceph_filelock
{
787 __le64 start
;/* file offset to start lock at */
788 __le64 length
; /* num bytes to lock; 0 for all following start */
789 __le64 client
; /* which client holds the lock */
790 __le64 owner
; /* who requests/holds the lock */
791 __le64 pid
; /* process id holding the lock on the client */
792 __u8 type
; /* shared lock, exclusive lock, or unlock */
793 } __attribute__ ((packed
));
796 /* file access modes */
797 #define CEPH_FILE_MODE_PIN 0
798 #define CEPH_FILE_MODE_RD 1
799 #define CEPH_FILE_MODE_WR 2
800 #define CEPH_FILE_MODE_RDWR 3 /* RD | WR */
801 #define CEPH_FILE_MODE_LAZY 4 /* lazy io */
802 #define CEPH_FILE_MODE_NUM 8 /* bc these are bit fields.. mostly */
804 int ceph_flags_to_mode(int flags
);
806 /* inline data state */
807 #define CEPH_INLINE_NONE ((__u64)-1)
808 #define CEPH_INLINE_MAX_SIZE CEPH_MIN_STRIPE_UNIT
810 /* capability bits */
811 #define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */
813 /* generic cap bits */
814 /* note: these definitions are duplicated in mds/locks.c */
815 #define CEPH_CAP_GSHARED 1 /* client can reads */
816 #define CEPH_CAP_GEXCL 2 /* client can read and update */
817 #define CEPH_CAP_GCACHE 4 /* (file) client can cache reads */
818 #define CEPH_CAP_GRD 8 /* (file) client can read */
819 #define CEPH_CAP_GWR 16 /* (file) client can write */
820 #define CEPH_CAP_GBUFFER 32 /* (file) client can buffer writes */
821 #define CEPH_CAP_GWREXTEND 64 /* (file) client can extend EOF */
822 #define CEPH_CAP_GLAZYIO 128 /* (file) client can perform lazy io */
824 #define CEPH_CAP_SIMPLE_BITS 2
825 #define CEPH_CAP_FILE_BITS 8
828 #define CEPH_CAP_SAUTH 2
829 #define CEPH_CAP_SLINK 4
830 #define CEPH_CAP_SXATTR 6
831 #define CEPH_CAP_SFILE 8
833 /* composed values */
834 #define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH)
835 #define CEPH_CAP_AUTH_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SAUTH)
836 #define CEPH_CAP_LINK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SLINK)
837 #define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK)
838 #define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SXATTR)
839 #define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR)
840 #define CEPH_CAP_FILE(x) ((x) << CEPH_CAP_SFILE)
841 #define CEPH_CAP_FILE_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFILE)
842 #define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE)
843 #define CEPH_CAP_FILE_CACHE (CEPH_CAP_GCACHE << CEPH_CAP_SFILE)
844 #define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE)
845 #define CEPH_CAP_FILE_WR (CEPH_CAP_GWR << CEPH_CAP_SFILE)
846 #define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE)
847 #define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
848 #define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE)
850 /* cap masks (for getattr) */
851 #define CEPH_STAT_CAP_INODE CEPH_CAP_PIN
852 #define CEPH_STAT_CAP_TYPE CEPH_CAP_PIN /* mode >> 12 */
853 #define CEPH_STAT_CAP_SYMLINK CEPH_CAP_PIN
854 #define CEPH_STAT_CAP_UID CEPH_CAP_AUTH_SHARED
855 #define CEPH_STAT_CAP_GID CEPH_CAP_AUTH_SHARED
856 #define CEPH_STAT_CAP_MODE CEPH_CAP_AUTH_SHARED
857 #define CEPH_STAT_CAP_NLINK CEPH_CAP_LINK_SHARED
858 #define CEPH_STAT_CAP_LAYOUT CEPH_CAP_FILE_SHARED
859 #define CEPH_STAT_CAP_MTIME CEPH_CAP_FILE_SHARED
860 #define CEPH_STAT_CAP_SIZE CEPH_CAP_FILE_SHARED
861 #define CEPH_STAT_CAP_ATIME CEPH_CAP_FILE_SHARED /* fixme */
862 #define CEPH_STAT_CAP_XATTR CEPH_CAP_XATTR_SHARED
863 #define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN | \
864 CEPH_CAP_AUTH_SHARED | \
865 CEPH_CAP_LINK_SHARED | \
866 CEPH_CAP_FILE_SHARED | \
867 CEPH_CAP_XATTR_SHARED)
868 #define CEPH_STAT_CAP_INLINE_DATA (CEPH_CAP_FILE_SHARED | \
870 #define CEPH_STAT_RSTAT CEPH_CAP_FILE_WREXTEND
872 #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \
873 CEPH_CAP_LINK_SHARED | \
874 CEPH_CAP_XATTR_SHARED | \
875 CEPH_CAP_FILE_SHARED)
876 #define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \
879 #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \
880 CEPH_CAP_LINK_EXCL | \
881 CEPH_CAP_XATTR_EXCL | \
883 #define CEPH_CAP_ANY_FILE_RD (CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE | \
884 CEPH_CAP_FILE_SHARED)
885 #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \
887 #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
888 #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
889 CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \
892 #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
895 /* cap masks async dir operations */
896 #define CEPH_CAP_DIR_CREATE CEPH_CAP_FILE_CACHE
897 #define CEPH_CAP_DIR_UNLINK CEPH_CAP_FILE_RD
898 #define CEPH_CAP_ANY_DIR_OPS (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_RD | \
899 CEPH_CAP_FILE_WREXTEND | CEPH_CAP_FILE_LAZYIO)
902 int ceph_caps_for_mode(int mode
);
905 CEPH_CAP_OP_GRANT
, /* mds->client grant */
906 CEPH_CAP_OP_REVOKE
, /* mds->client revoke */
907 CEPH_CAP_OP_TRUNC
, /* mds->client trunc notify */
908 CEPH_CAP_OP_EXPORT
, /* mds has exported the cap */
909 CEPH_CAP_OP_IMPORT
, /* mds has imported the cap */
910 CEPH_CAP_OP_UPDATE
, /* client->mds update */
911 CEPH_CAP_OP_DROP
, /* client->mds drop cap bits */
912 CEPH_CAP_OP_FLUSH
, /* client->mds cap writeback */
913 CEPH_CAP_OP_FLUSH_ACK
, /* mds->client flushed */
914 CEPH_CAP_OP_FLUSHSNAP
, /* client->mds flush snapped metadata */
915 CEPH_CAP_OP_FLUSHSNAP_ACK
, /* mds->client flushed snapped metadata */
916 CEPH_CAP_OP_RELEASE
, /* client->mds release (clean) cap */
917 CEPH_CAP_OP_RENEW
, /* client->mds renewal request */
920 extern const char *ceph_cap_op_name(int op
);
922 /* extra info for cap import/export */
923 struct ceph_mds_cap_peer
{
929 } __attribute__ ((packed
));
932 * caps message, used for capability callbacks, acks, requests, etc.
934 struct ceph_mds_caps_head
{
935 __le32 op
; /* CEPH_CAP_OP_* */
938 __le32 seq
, issue_seq
;
939 __le32 caps
, wanted
, dirty
; /* latest issued/wanted/dirty */
942 __le32 snap_trace_len
;
945 __le32 uid
, gid
, mode
;
952 __le64 xattr_version
;
953 } __attribute__ ((packed
));
955 struct ceph_mds_caps_non_export_body
{
956 /* all except export */
958 __le64 size
, max_size
, truncate_size
;
960 struct ceph_timespec mtime
, atime
, ctime
;
961 struct ceph_file_layout layout
;
962 __le32 time_warp_seq
;
963 } __attribute__ ((packed
));
965 struct ceph_mds_caps_export_body
{
967 struct ceph_mds_cap_peer peer
;
968 } __attribute__ ((packed
));
970 /* cap release msg head */
971 struct ceph_mds_cap_release
{
972 __le32 num
; /* number of cap_items that follow */
973 } __attribute__ ((packed
));
975 struct ceph_mds_cap_item
{
978 __le32 migrate_seq
, seq
;
979 } __attribute__ ((packed
));
981 #define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */
982 #define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */
983 #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */
984 #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */
986 extern const char *ceph_lease_op_name(int o
);
988 /* lease msg header */
989 struct ceph_mds_lease
{
990 __u8 action
; /* CEPH_MDS_LEASE_* */
991 __le16 mask
; /* which lease */
993 __le64 first
, last
; /* snap range */
995 __le32 duration_ms
; /* duration of renewal */
996 } __attribute__ ((packed
));
997 /* followed by a __le32+string for dname */
999 /* client reconnect */
1000 struct ceph_mds_cap_reconnect
{
1005 __le64 pathbase
; /* base ino for our path to this ino */
1006 __le32 flock_len
; /* size of flock state blob, if any */
1007 } __attribute__ ((packed
));
1008 /* followed by flock blob */
1010 struct ceph_mds_cap_reconnect_v1
{
1015 struct ceph_timespec mtime
, atime
;
1017 __le64 pathbase
; /* base ino for our path to this ino */
1018 } __attribute__ ((packed
));
1020 struct ceph_mds_snaprealm_reconnect
{
1021 __le64 ino
; /* snap realm base */
1022 __le64 seq
; /* snap seq for this snap realm */
1023 __le64 parent
; /* parent realm */
1024 } __attribute__ ((packed
));
1030 CEPH_SNAP_OP_UPDATE
, /* CREATE or DESTROY */
1031 CEPH_SNAP_OP_CREATE
,
1032 CEPH_SNAP_OP_DESTROY
,
1036 extern const char *ceph_snap_op_name(int o
);
1038 /* snap msg header */
1039 struct ceph_mds_snap_head
{
1040 __le32 op
; /* CEPH_SNAP_OP_* */
1041 __le64 split
; /* ino to split off, if any */
1042 __le32 num_split_inos
; /* # inos belonging to new child realm */
1043 __le32 num_split_realms
; /* # child realms udner new child realm */
1044 __le32 trace_len
; /* size of snap trace blob */
1045 } __attribute__ ((packed
));
1046 /* followed by split ino list, then split realms, then the trace blob */
1049 * encode info about a snaprealm, as viewed by a client
1051 struct ceph_mds_snap_realm
{
1052 __le64 ino
; /* ino */
1053 __le64 created
; /* snap: when created */
1054 __le64 parent
; /* ino: parent realm */
1055 __le64 parent_since
; /* snap: same parent since */
1056 __le64 seq
; /* snap: version */
1058 __le32 num_prior_parent_snaps
;
1059 } __attribute__ ((packed
));
1060 /* followed by my snap list, then prior parent snap list */