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
52 * hidden .ceph dir, which is no longer created but
53 * recognised in existing filesystems so that we
54 * don't try to fragment it.
56 #define CEPH_INO_CEPH 2
57 #define CEPH_INO_GLOBAL_SNAPREALM 3
58 #define CEPH_INO_LOST_AND_FOUND 4 /* reserved ino for use in recovery */
60 /* arbitrary limit on max # of monitors (cluster of 3 is typical) */
61 #define CEPH_MAX_MON 31
64 * ceph_file_layout - describe data layout for a file/inode
66 struct ceph_file_layout
{
67 /* file -> object mapping */
68 __le32 fl_stripe_unit
; /* stripe unit, in bytes. must be multiple
70 __le32 fl_stripe_count
; /* over this many objects */
71 __le32 fl_object_size
; /* until objects are this big, then move to
73 __le32 fl_cas_hash
; /* UNUSED. 0 = none; 1 = sha256 */
75 /* pg -> disk layout */
76 __le32 fl_object_stripe_unit
; /* UNUSED. for per-object parity, if any */
78 /* object -> pg layout */
79 __le32 fl_unused
; /* unused; used to be preferred primary for pg (-1 for none) */
80 __le32 fl_pg_pool
; /* namespace, crush rule, rep level */
81 } __attribute__ ((packed
));
83 #define CEPH_MIN_STRIPE_UNIT 65536
85 struct ceph_dir_layout
{
86 __u8 dl_dir_hash
; /* see ceph_hash.h for ids */
90 } __attribute__ ((packed
));
92 /* crypto algorithms */
93 #define CEPH_CRYPTO_NONE 0x0
94 #define CEPH_CRYPTO_AES 0x1
96 #define CEPH_AES_IV "cephsageyudagreg"
98 /* security/authentication protocols */
99 #define CEPH_AUTH_UNKNOWN 0x0
100 #define CEPH_AUTH_NONE 0x1
101 #define CEPH_AUTH_CEPHX 0x2
103 /* msgr2 protocol modes */
104 #define CEPH_CON_MODE_UNKNOWN 0x0
105 #define CEPH_CON_MODE_CRC 0x1
106 #define CEPH_CON_MODE_SECURE 0x2
108 extern const char *ceph_con_mode_name(int con_mode
);
110 /* For options with "_", like: GSS_GSS
111 which means: Mode/Protocol to validate "authentication_authorization",
113 - Authentication: Verifying the identity of an entity.
114 - Authorization: Verifying that an authenticated entity has
115 the right to access a particular resource.
117 #define CEPH_AUTH_GSS 0x4
118 #define CEPH_AUTH_GSS_GSS CEPH_AUTH_GSS
120 #define CEPH_AUTH_UID_DEFAULT ((__u64) -1)
123 /*********************************************
132 #define CEPH_MSG_SHUTDOWN 1
133 #define CEPH_MSG_PING 2
135 /* client <-> monitor */
136 #define CEPH_MSG_MON_MAP 4
137 #define CEPH_MSG_MON_GET_MAP 5
138 #define CEPH_MSG_MON_GET_OSDMAP 6
139 #define CEPH_MSG_MON_METADATA 7
140 #define CEPH_MSG_STATFS 13
141 #define CEPH_MSG_STATFS_REPLY 14
142 #define CEPH_MSG_MON_SUBSCRIBE 15
143 #define CEPH_MSG_MON_SUBSCRIBE_ACK 16
144 #define CEPH_MSG_AUTH 17
145 #define CEPH_MSG_AUTH_REPLY 18
146 #define CEPH_MSG_MON_GET_VERSION 19
147 #define CEPH_MSG_MON_GET_VERSION_REPLY 20
150 #define CEPH_MSG_MDS_MAP 21
152 #define CEPH_MSG_CLIENT_SESSION 22
153 #define CEPH_MSG_CLIENT_RECONNECT 23
155 #define CEPH_MSG_CLIENT_REQUEST 24
156 #define CEPH_MSG_CLIENT_REQUEST_FORWARD 25
157 #define CEPH_MSG_CLIENT_REPLY 26
158 #define CEPH_MSG_CLIENT_RECLAIM 27
159 #define CEPH_MSG_CLIENT_RECLAIM_REPLY 28
160 #define CEPH_MSG_CLIENT_METRICS 29
161 #define CEPH_MSG_CLIENT_CAPS 0x310
162 #define CEPH_MSG_CLIENT_LEASE 0x311
163 #define CEPH_MSG_CLIENT_SNAP 0x312
164 #define CEPH_MSG_CLIENT_CAPRELEASE 0x313
165 #define CEPH_MSG_CLIENT_QUOTA 0x314
168 #define CEPH_MSG_POOLOP_REPLY 48
169 #define CEPH_MSG_POOLOP 49
173 #define CEPH_MSG_OSD_MAP 41
174 #define CEPH_MSG_OSD_OP 42
175 #define CEPH_MSG_OSD_OPREPLY 43
176 #define CEPH_MSG_WATCH_NOTIFY 44
177 #define CEPH_MSG_OSD_BACKOFF 61
179 /* FSMap subscribers (see all MDS clusters at once) */
180 #define CEPH_MSG_FS_MAP 45
181 /* FSMapUser subscribers (get MDS clusters name->ID mapping) */
182 #define CEPH_MSG_FS_MAP_USER 103
184 /* watch-notify operations */
186 CEPH_WATCH_EVENT_NOTIFY
= 1, /* notifying watcher */
187 CEPH_WATCH_EVENT_NOTIFY_COMPLETE
= 2, /* notifier notified when done */
188 CEPH_WATCH_EVENT_DISCONNECT
= 3, /* we were disconnected */
191 const char *ceph_watch_event_name(int o
);
193 /* pool operations */
195 POOL_OP_CREATE
= 0x01,
196 POOL_OP_DELETE
= 0x02,
197 POOL_OP_AUID_CHANGE
= 0x03,
198 POOL_OP_CREATE_SNAP
= 0x11,
199 POOL_OP_DELETE_SNAP
= 0x12,
200 POOL_OP_CREATE_UNMANAGED_SNAP
= 0x21,
201 POOL_OP_DELETE_UNMANAGED_SNAP
= 0x22,
204 struct ceph_mon_request_header
{
207 __le64 session_mon_tid
;
208 } __attribute__ ((packed
));
210 struct ceph_mon_statfs
{
211 struct ceph_mon_request_header monhdr
;
212 struct ceph_fsid fsid
;
213 } __attribute__ ((packed
));
216 __le64 kb
, kb_used
, kb_avail
;
218 } __attribute__ ((packed
));
220 struct ceph_mon_statfs_reply
{
221 struct ceph_fsid fsid
;
223 struct ceph_statfs st
;
224 } __attribute__ ((packed
));
226 const char *ceph_pool_op_name(int op
);
228 struct ceph_mon_poolop
{
229 struct ceph_mon_request_header monhdr
;
230 struct ceph_fsid fsid
;
233 __le64 __old_auid
; // obsolete
236 } __attribute__ ((packed
));
238 struct ceph_mon_poolop_reply
{
239 struct ceph_mon_request_header monhdr
;
240 struct ceph_fsid fsid
;
245 } __attribute__ ((packed
));
247 struct ceph_mon_unmanaged_snap
{
249 } __attribute__ ((packed
));
251 struct ceph_osd_getmap
{
252 struct ceph_mon_request_header monhdr
;
253 struct ceph_fsid fsid
;
255 } __attribute__ ((packed
));
257 struct ceph_mds_getmap
{
258 struct ceph_mon_request_header monhdr
;
259 struct ceph_fsid fsid
;
260 } __attribute__ ((packed
));
262 struct ceph_client_mount
{
263 struct ceph_mon_request_header monhdr
;
264 } __attribute__ ((packed
));
266 #define CEPH_SUBSCRIBE_ONETIME 1 /* i want only 1 update after have */
268 struct ceph_mon_subscribe_item
{
271 } __attribute__ ((packed
));
273 struct ceph_mon_subscribe_ack
{
274 __le32 duration
; /* seconds */
275 struct ceph_fsid fsid
;
276 } __attribute__ ((packed
));
281 #define CEPH_MDSMAP_NOT_JOINABLE (1<<0) /* standbys cannot join */
282 #define CEPH_MDSMAP_DOWN (CEPH_MDSMAP_NOT_JOINABLE) /* backwards compat */
283 #define CEPH_MDSMAP_ALLOW_SNAPS (1<<1) /* cluster allowed to create snapshots */
284 /* deprecated #define CEPH_MDSMAP_ALLOW_MULTIMDS (1<<2) cluster allowed to have >1 active MDS */
285 /* deprecated #define CEPH_MDSMAP_ALLOW_DIRFRAGS (1<<3) cluster allowed to fragment directories */
286 #define CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS (1<<4) /* cluster alllowed to enable MULTIMDS
287 and SNAPS at the same time */
288 #define CEPH_MDSMAP_ALLOW_STANDBY_REPLAY (1<<5) /* cluster alllowed to enable MULTIMDS */
290 #define CEPH_MDSMAP_DEFAULTS (CEPH_MDSMAP_ALLOW_SNAPS | \
291 CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS)
298 #define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */
299 #define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees.
301 #define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */
302 #define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */
303 #define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */
304 #define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */
305 #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */
306 #define CEPH_MDS_STATE_REPLAYONCE -9 /* Legacy, unused */
307 #define CEPH_MDS_STATE_NULL -10
309 #define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */
310 #define CEPH_MDS_STATE_RESOLVE 9 /* up, disambiguating distributed
311 operations (import, rename, etc.) */
312 #define CEPH_MDS_STATE_RECONNECT 10 /* up, reconnect to clients */
313 #define CEPH_MDS_STATE_REJOIN 11 /* up, rejoining distributed cache */
314 #define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */
315 #define CEPH_MDS_STATE_ACTIVE 13 /* up, active */
316 #define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */
317 #define CEPH_MDS_STATE_DAMAGED 15 /* rank not replayable, need repair */
319 extern const char *ceph_mds_state_name(int s
);
323 * metadata lock types.
324 * - these are bitmasks.. we can compose them
325 * - they also define the lock ordering by the MDS
326 * - a few of these are internal to the mds
328 #define CEPH_LOCK_DN (1 << 0)
329 #define CEPH_LOCK_DVERSION (1 << 1)
330 #define CEPH_LOCK_ISNAP (1 << 4) /* snapshot lock. MDS internal */
331 #define CEPH_LOCK_IPOLICY (1 << 5) /* policy lock on dirs. MDS internal */
332 #define CEPH_LOCK_IFILE (1 << 6)
333 #define CEPH_LOCK_INEST (1 << 7) /* mds internal */
334 #define CEPH_LOCK_IDFT (1 << 8) /* dir frag tree */
335 #define CEPH_LOCK_IAUTH (1 << 9)
336 #define CEPH_LOCK_ILINK (1 << 10)
337 #define CEPH_LOCK_IXATTR (1 << 11)
338 #define CEPH_LOCK_IFLOCK (1 << 12) /* advisory file locks */
339 #define CEPH_LOCK_IVERSION (1 << 13) /* mds internal */
341 #define CEPH_LOCK_IFIRST CEPH_LOCK_ISNAP
344 /* client_session ops */
346 CEPH_SESSION_REQUEST_OPEN
,
348 CEPH_SESSION_REQUEST_CLOSE
,
350 CEPH_SESSION_REQUEST_RENEWCAPS
,
351 CEPH_SESSION_RENEWCAPS
,
353 CEPH_SESSION_RECALL_STATE
,
354 CEPH_SESSION_FLUSHMSG
,
355 CEPH_SESSION_FLUSHMSG_ACK
,
356 CEPH_SESSION_FORCE_RO
,
357 // A response to REQUEST_OPEN indicating that the client should
358 // permanently desist from contacting the MDS
360 CEPH_SESSION_REQUEST_FLUSH_MDLOG
363 // flags for state reclaim
364 #define CEPH_RECLAIM_RESET 1
366 extern const char *ceph_session_op_name(int op
);
368 struct ceph_mds_session_head
{
371 struct ceph_timespec stamp
;
372 __le32 max_caps
, max_leases
;
373 } __attribute__ ((packed
));
378 * & 0x001000 -> write op
379 * & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
380 & & 0x100000 -> use weird ino/path trace
382 #define CEPH_MDS_OP_WRITE 0x001000
384 CEPH_MDS_OP_LOOKUP
= 0x00100,
385 CEPH_MDS_OP_GETATTR
= 0x00101,
386 CEPH_MDS_OP_LOOKUPHASH
= 0x00102,
387 CEPH_MDS_OP_LOOKUPPARENT
= 0x00103,
388 CEPH_MDS_OP_LOOKUPINO
= 0x00104,
389 CEPH_MDS_OP_LOOKUPNAME
= 0x00105,
390 CEPH_MDS_OP_GETVXATTR
= 0x00106,
392 CEPH_MDS_OP_SETXATTR
= 0x01105,
393 CEPH_MDS_OP_RMXATTR
= 0x01106,
394 CEPH_MDS_OP_SETLAYOUT
= 0x01107,
395 CEPH_MDS_OP_SETATTR
= 0x01108,
396 CEPH_MDS_OP_SETFILELOCK
= 0x01109,
397 CEPH_MDS_OP_GETFILELOCK
= 0x00110,
398 CEPH_MDS_OP_SETDIRLAYOUT
=0x0110a,
400 CEPH_MDS_OP_MKNOD
= 0x01201,
401 CEPH_MDS_OP_LINK
= 0x01202,
402 CEPH_MDS_OP_UNLINK
= 0x01203,
403 CEPH_MDS_OP_RENAME
= 0x01204,
404 CEPH_MDS_OP_MKDIR
= 0x01220,
405 CEPH_MDS_OP_RMDIR
= 0x01221,
406 CEPH_MDS_OP_SYMLINK
= 0x01222,
408 CEPH_MDS_OP_CREATE
= 0x01301,
409 CEPH_MDS_OP_OPEN
= 0x00302,
410 CEPH_MDS_OP_READDIR
= 0x00305,
412 CEPH_MDS_OP_LOOKUPSNAP
= 0x00400,
413 CEPH_MDS_OP_MKSNAP
= 0x01400,
414 CEPH_MDS_OP_RMSNAP
= 0x01401,
415 CEPH_MDS_OP_LSSNAP
= 0x00402,
416 CEPH_MDS_OP_RENAMESNAP
= 0x01403,
419 CEPH_MDS_OP_FRAGMENTDIR
= 0x01500,
420 CEPH_MDS_OP_EXPORTDIR
= 0x01501,
421 CEPH_MDS_OP_FLUSH
= 0x01502,
422 CEPH_MDS_OP_ENQUEUE_SCRUB
= 0x01503,
423 CEPH_MDS_OP_REPAIR_FRAGSTATS
= 0x01504,
424 CEPH_MDS_OP_REPAIR_INODESTATS
= 0x01505,
425 CEPH_MDS_OP_RDLOCK_FRAGSSTATS
= 0x01507
428 extern const char *ceph_mds_op_name(int op
);
430 #ifndef CEPH_SETATTR_MODE
431 #define CEPH_SETATTR_MODE (1 << 0)
432 #define CEPH_SETATTR_UID (1 << 1)
433 #define CEPH_SETATTR_GID (1 << 2)
434 #define CEPH_SETATTR_MTIME (1 << 3)
435 #define CEPH_SETATTR_ATIME (1 << 4)
436 #define CEPH_SETATTR_SIZE (1 << 5)
437 #define CEPH_SETATTR_CTIME (1 << 6)
438 #define CEPH_SETATTR_MTIME_NOW (1 << 7)
439 #define CEPH_SETATTR_ATIME_NOW (1 << 8)
440 #define CEPH_SETATTR_BTIME (1 << 9)
442 #define CEPH_SETATTR_KILL_SGUID (1 << 10)
447 #define CEPH_O_RDONLY 00000000
448 #define CEPH_O_WRONLY 00000001
449 #define CEPH_O_RDWR 00000002
450 #define CEPH_O_CREAT 00000100
451 #define CEPH_O_EXCL 00000200
452 #define CEPH_O_TRUNC 00001000
453 #define CEPH_O_LAZY 00020000
454 #define CEPH_O_DIRECTORY 00200000
455 #define CEPH_O_NOFOLLOW 00400000
457 int ceph_flags_sys2wire(int flags
);
460 * Ceph setxattr request flags.
462 #define CEPH_XATTR_CREATE (1 << 0)
463 #define CEPH_XATTR_REPLACE (1 << 1)
464 #define CEPH_XATTR_REMOVE (1 << 31)
467 * readdir request flags;
469 #define CEPH_READDIR_REPLY_BITFLAGS (1<<0)
472 * readdir reply flags.
474 #define CEPH_READDIR_FRAG_END (1<<0)
475 #define CEPH_READDIR_FRAG_COMPLETE (1<<8)
476 #define CEPH_READDIR_HASH_ORDER (1<<9)
477 #define CEPH_READDIR_OFFSET_HASH (1<<10)
479 /* Note that this is embedded wthin ceph_mds_request_head_legacy. */
480 union ceph_mds_request_args_legacy
{
482 __le32 mask
; /* CEPH_CAP_* */
483 } __attribute__ ((packed
)) getattr
;
488 struct ceph_timespec mtime
;
489 struct ceph_timespec atime
;
490 __le64 size
, old_size
; /* old_size needed by truncate */
491 __le32 mask
; /* CEPH_SETATTR_* */
492 } __attribute__ ((packed
)) setattr
;
494 __le32 frag
; /* which dir fragment */
495 __le32 max_entries
; /* how many dentries to grab */
499 } __attribute__ ((packed
)) readdir
;
503 } __attribute__ ((packed
)) mknod
;
506 } __attribute__ ((packed
)) mkdir
;
510 __le32 stripe_unit
; /* layout for newly created file */
511 __le32 stripe_count
; /* ... */
513 __le32 pool
; /* if >= 0 and CREATEPOOLID feature */
514 __le32 mask
; /* CEPH_CAP_* */
515 __le64 old_size
; /* if O_TRUNC */
516 } __attribute__ ((packed
)) open
;
519 __le32 osdmap_epoch
; /* use for set file/dir layout */
520 } __attribute__ ((packed
)) setxattr
;
522 struct ceph_file_layout layout
;
523 } __attribute__ ((packed
)) setlayout
;
525 __u8 rule
; /* currently fcntl or flock */
526 __u8 type
; /* shared, exclusive, remove*/
527 __le64 owner
; /* who requests/holds the lock */
528 __le64 pid
; /* process id requesting the lock */
529 __le64 start
; /* initial location to lock */
530 __le64 length
; /* num bytes to lock from start */
531 __u8 wait
; /* will caller wait for lock to become available? */
532 } __attribute__ ((packed
)) filelock_change
;
533 } __attribute__ ((packed
));
535 #define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */
536 #define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */
537 #define CEPH_MDS_FLAG_ASYNC 4 /* request is async */
539 struct ceph_mds_request_head_legacy
{
540 __le64 oldest_client_tid
;
541 __le32 mdsmap_epoch
; /* on client */
542 __le32 flags
; /* CEPH_MDS_FLAG_* */
543 __u8 num_retry
, num_fwd
; /* count retry, fwd attempts */
544 __le16 num_releases
; /* # include cap/lease release records */
545 __le32 op
; /* mds op code */
546 __le32 caller_uid
, caller_gid
;
547 __le64 ino
; /* use this ino for openc, mkdir, mknod,
548 etc. (if replaying) */
549 union ceph_mds_request_args_legacy args
;
550 } __attribute__ ((packed
));
553 * Note that this is embedded wthin ceph_mds_request_head. Also, compatibility
554 * with the ceph_mds_request_args_legacy must be maintained!
556 union ceph_mds_request_args
{
558 __le32 mask
; /* CEPH_CAP_* */
559 } __attribute__ ((packed
)) getattr
;
564 struct ceph_timespec mtime
;
565 struct ceph_timespec atime
;
566 __le64 size
, old_size
; /* old_size needed by truncate */
567 __le32 mask
; /* CEPH_SETATTR_* */
568 struct ceph_timespec btime
;
569 } __attribute__ ((packed
)) setattr
;
571 __le32 frag
; /* which dir fragment */
572 __le32 max_entries
; /* how many dentries to grab */
576 } __attribute__ ((packed
)) readdir
;
580 } __attribute__ ((packed
)) mknod
;
583 } __attribute__ ((packed
)) mkdir
;
587 __le32 stripe_unit
; /* layout for newly created file */
588 __le32 stripe_count
; /* ... */
590 __le32 pool
; /* if >= 0 and CREATEPOOLID feature */
591 __le32 mask
; /* CEPH_CAP_* */
592 __le64 old_size
; /* if O_TRUNC */
593 } __attribute__ ((packed
)) open
;
596 __le32 osdmap_epoch
; /* use for set file/dir layout */
597 } __attribute__ ((packed
)) setxattr
;
599 struct ceph_file_layout layout
;
600 } __attribute__ ((packed
)) setlayout
;
602 __u8 rule
; /* currently fcntl or flock */
603 __u8 type
; /* shared, exclusive, remove*/
604 __le64 owner
; /* who requests/holds the lock */
605 __le64 pid
; /* process id requesting the lock */
606 __le64 start
; /* initial location to lock */
607 __le64 length
; /* num bytes to lock from start */
608 __u8 wait
; /* will caller wait for lock to become available? */
609 } __attribute__ ((packed
)) filelock_change
;
611 __le32 mask
; /* CEPH_CAP_* */
615 } __attribute__ ((packed
)) lookupino
;
616 } __attribute__ ((packed
));
618 #define CEPH_MDS_REQUEST_HEAD_VERSION 1
621 * Note that any change to this structure must ensure that it is compatible
622 * with ceph_mds_request_head_legacy.
624 struct ceph_mds_request_head
{
626 __le64 oldest_client_tid
;
627 __le32 mdsmap_epoch
; /* on client */
628 __le32 flags
; /* CEPH_MDS_FLAG_* */
629 __u8 num_retry
, num_fwd
; /* count retry, fwd attempts */
630 __le16 num_releases
; /* # include cap/lease release records */
631 __le32 op
; /* mds op code */
632 __le32 caller_uid
, caller_gid
;
633 __le64 ino
; /* use this ino for openc, mkdir, mknod,
634 etc. (if replaying) */
635 union ceph_mds_request_args args
;
636 } __attribute__ ((packed
));
638 /* cap/lease release record */
639 struct ceph_mds_request_release
{
640 __le64 ino
, cap_id
; /* ino and unique cap id */
641 __le32 caps
, wanted
; /* new issued, wanted */
642 __le32 seq
, issue_seq
, mseq
;
643 __le32 dname_seq
; /* if releasing a dentry lease, a */
644 __le32 dname_len
; /* string follows. */
645 } __attribute__ ((packed
));
648 copy_from_legacy_head(struct ceph_mds_request_head
*head
,
649 struct ceph_mds_request_head_legacy
*legacy
)
651 struct ceph_mds_request_head_legacy
*embedded_legacy
=
652 (struct ceph_mds_request_head_legacy
*)&head
->oldest_client_tid
;
653 *embedded_legacy
= *legacy
;
657 copy_to_legacy_head(struct ceph_mds_request_head_legacy
*legacy
,
658 struct ceph_mds_request_head
*head
)
660 struct ceph_mds_request_head_legacy
*embedded_legacy
=
661 (struct ceph_mds_request_head_legacy
*)&head
->oldest_client_tid
;
662 *legacy
= *embedded_legacy
;
666 struct ceph_mds_reply_head
{
670 __u8 safe
; /* true if committed to disk */
671 __u8 is_dentry
, is_target
; /* true if dentry, target inode records
672 are included with reply */
673 } __attribute__ ((packed
));
675 /* one for each node split */
676 struct ceph_frag_tree_split
{
677 __le32 frag
; /* this frag splits... */
678 __le32 by
; /* ...by this many bits */
679 } __attribute__ ((packed
));
681 struct ceph_frag_tree_head
{
682 __le32 nsplits
; /* num ceph_frag_tree_split records */
683 struct ceph_frag_tree_split splits
[];
684 } __attribute__ ((packed
));
686 /* capability issue, for bundling with mds reply */
687 struct ceph_mds_reply_cap
{
688 __le32 caps
, wanted
; /* caps issued, wanted */
691 __le64 realm
; /* snap realm */
692 __u8 flags
; /* CEPH_CAP_FLAG_* */
693 } __attribute__ ((packed
));
695 #define CEPH_CAP_FLAG_AUTH (1 << 0) /* cap is issued by auth mds */
696 #define CEPH_CAP_FLAG_RELEASE (1 << 1) /* ask client to release the cap */
698 /* reply_lease follows dname, and reply_inode */
699 struct ceph_mds_reply_lease
{
700 __le16 mask
; /* lease type(s) */
701 __le32 duration_ms
; /* lease duration */
703 } __attribute__ ((packed
));
705 #define CEPH_LEASE_VALID (1 | 2) /* old and new bit values */
706 #define CEPH_LEASE_PRIMARY_LINK 4 /* primary linkage */
708 struct ceph_mds_reply_dirfrag
{
709 __le32 frag
; /* fragment */
710 __le32 auth
; /* auth mds, if this is a delegation point */
711 __le32 ndist
; /* number of mds' this is replicated on */
713 } __attribute__ ((packed
));
715 #define CEPH_LOCK_FCNTL 1
716 #define CEPH_LOCK_FLOCK 2
717 #define CEPH_LOCK_FCNTL_INTR 3
718 #define CEPH_LOCK_FLOCK_INTR 4
720 #define CEPH_LOCK_SHARED 1
721 #define CEPH_LOCK_EXCL 2
722 #define CEPH_LOCK_UNLOCK 4
724 struct ceph_filelock
{
725 __le64 start
;/* file offset to start lock at */
726 __le64 length
; /* num bytes to lock; 0 for all following start */
727 __le64 client
; /* which client holds the lock */
728 __le64 owner
; /* who requests/holds the lock */
729 __le64 pid
; /* process id holding the lock on the client */
730 __u8 type
; /* shared lock, exclusive lock, or unlock */
731 } __attribute__ ((packed
));
734 /* file access modes */
735 #define CEPH_FILE_MODE_PIN 0
736 #define CEPH_FILE_MODE_RD 1
737 #define CEPH_FILE_MODE_WR 2
738 #define CEPH_FILE_MODE_RDWR 3 /* RD | WR */
739 #define CEPH_FILE_MODE_LAZY 4 /* lazy io */
740 #define CEPH_FILE_MODE_NUM 8 /* bc these are bit fields.. mostly */
742 int ceph_flags_to_mode(int flags
);
744 /* inline data state */
745 #define CEPH_INLINE_NONE ((__u64)-1)
746 #define CEPH_INLINE_MAX_SIZE CEPH_MIN_STRIPE_UNIT
748 /* capability bits */
749 #define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */
751 /* generic cap bits */
752 /* note: these definitions are duplicated in mds/locks.c */
753 #define CEPH_CAP_GSHARED 1 /* client can reads */
754 #define CEPH_CAP_GEXCL 2 /* client can read and update */
755 #define CEPH_CAP_GCACHE 4 /* (file) client can cache reads */
756 #define CEPH_CAP_GRD 8 /* (file) client can read */
757 #define CEPH_CAP_GWR 16 /* (file) client can write */
758 #define CEPH_CAP_GBUFFER 32 /* (file) client can buffer writes */
759 #define CEPH_CAP_GWREXTEND 64 /* (file) client can extend EOF */
760 #define CEPH_CAP_GLAZYIO 128 /* (file) client can perform lazy io */
762 #define CEPH_CAP_SIMPLE_BITS 2
763 #define CEPH_CAP_FILE_BITS 8
766 #define CEPH_CAP_SAUTH 2
767 #define CEPH_CAP_SLINK 4
768 #define CEPH_CAP_SXATTR 6
769 #define CEPH_CAP_SFILE 8
771 /* composed values */
772 #define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH)
773 #define CEPH_CAP_AUTH_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SAUTH)
774 #define CEPH_CAP_LINK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SLINK)
775 #define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK)
776 #define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SXATTR)
777 #define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR)
778 #define CEPH_CAP_FILE(x) ((x) << CEPH_CAP_SFILE)
779 #define CEPH_CAP_FILE_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFILE)
780 #define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE)
781 #define CEPH_CAP_FILE_CACHE (CEPH_CAP_GCACHE << CEPH_CAP_SFILE)
782 #define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE)
783 #define CEPH_CAP_FILE_WR (CEPH_CAP_GWR << CEPH_CAP_SFILE)
784 #define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE)
785 #define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
786 #define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE)
788 /* cap masks (for getattr) */
789 #define CEPH_STAT_CAP_INODE CEPH_CAP_PIN
790 #define CEPH_STAT_CAP_TYPE CEPH_CAP_PIN /* mode >> 12 */
791 #define CEPH_STAT_CAP_SYMLINK CEPH_CAP_PIN
792 #define CEPH_STAT_CAP_UID CEPH_CAP_AUTH_SHARED
793 #define CEPH_STAT_CAP_GID CEPH_CAP_AUTH_SHARED
794 #define CEPH_STAT_CAP_MODE CEPH_CAP_AUTH_SHARED
795 #define CEPH_STAT_CAP_NLINK CEPH_CAP_LINK_SHARED
796 #define CEPH_STAT_CAP_LAYOUT CEPH_CAP_FILE_SHARED
797 #define CEPH_STAT_CAP_MTIME CEPH_CAP_FILE_SHARED
798 #define CEPH_STAT_CAP_SIZE CEPH_CAP_FILE_SHARED
799 #define CEPH_STAT_CAP_ATIME CEPH_CAP_FILE_SHARED /* fixme */
800 #define CEPH_STAT_CAP_XATTR CEPH_CAP_XATTR_SHARED
801 #define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN | \
802 CEPH_CAP_AUTH_SHARED | \
803 CEPH_CAP_LINK_SHARED | \
804 CEPH_CAP_FILE_SHARED | \
805 CEPH_CAP_XATTR_SHARED)
806 #define CEPH_STAT_CAP_INLINE_DATA (CEPH_CAP_FILE_SHARED | \
808 #define CEPH_STAT_RSTAT CEPH_CAP_FILE_WREXTEND
810 #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \
811 CEPH_CAP_LINK_SHARED | \
812 CEPH_CAP_XATTR_SHARED | \
813 CEPH_CAP_FILE_SHARED)
814 #define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \
817 #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \
818 CEPH_CAP_LINK_EXCL | \
819 CEPH_CAP_XATTR_EXCL | \
821 #define CEPH_CAP_ANY_FILE_RD (CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE | \
822 CEPH_CAP_FILE_SHARED)
823 #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \
825 #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
826 #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
827 CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \
830 #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
833 /* cap masks async dir operations */
834 #define CEPH_CAP_DIR_CREATE CEPH_CAP_FILE_CACHE
835 #define CEPH_CAP_DIR_UNLINK CEPH_CAP_FILE_RD
836 #define CEPH_CAP_ANY_DIR_OPS (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_RD | \
837 CEPH_CAP_FILE_WREXTEND | CEPH_CAP_FILE_LAZYIO)
840 int ceph_caps_for_mode(int mode
);
843 CEPH_CAP_OP_GRANT
, /* mds->client grant */
844 CEPH_CAP_OP_REVOKE
, /* mds->client revoke */
845 CEPH_CAP_OP_TRUNC
, /* mds->client trunc notify */
846 CEPH_CAP_OP_EXPORT
, /* mds has exported the cap */
847 CEPH_CAP_OP_IMPORT
, /* mds has imported the cap */
848 CEPH_CAP_OP_UPDATE
, /* client->mds update */
849 CEPH_CAP_OP_DROP
, /* client->mds drop cap bits */
850 CEPH_CAP_OP_FLUSH
, /* client->mds cap writeback */
851 CEPH_CAP_OP_FLUSH_ACK
, /* mds->client flushed */
852 CEPH_CAP_OP_FLUSHSNAP
, /* client->mds flush snapped metadata */
853 CEPH_CAP_OP_FLUSHSNAP_ACK
, /* mds->client flushed snapped metadata */
854 CEPH_CAP_OP_RELEASE
, /* client->mds release (clean) cap */
855 CEPH_CAP_OP_RENEW
, /* client->mds renewal request */
858 extern const char *ceph_cap_op_name(int op
);
860 /* extra info for cap import/export */
861 struct ceph_mds_cap_peer
{
867 } __attribute__ ((packed
));
870 * caps message, used for capability callbacks, acks, requests, etc.
872 struct ceph_mds_caps_head
{
873 __le32 op
; /* CEPH_CAP_OP_* */
876 __le32 seq
, issue_seq
;
877 __le32 caps
, wanted
, dirty
; /* latest issued/wanted/dirty */
880 __le32 snap_trace_len
;
883 __le32 uid
, gid
, mode
;
890 __le64 xattr_version
;
891 } __attribute__ ((packed
));
893 struct ceph_mds_caps_non_export_body
{
894 /* all except export */
896 __le64 size
, max_size
, truncate_size
;
898 struct ceph_timespec mtime
, atime
, ctime
;
899 struct ceph_file_layout layout
;
900 __le32 time_warp_seq
;
901 } __attribute__ ((packed
));
903 struct ceph_mds_caps_export_body
{
905 struct ceph_mds_cap_peer peer
;
906 } __attribute__ ((packed
));
908 /* cap release msg head */
909 struct ceph_mds_cap_release
{
910 __le32 num
; /* number of cap_items that follow */
911 } __attribute__ ((packed
));
913 struct ceph_mds_cap_item
{
916 __le32 migrate_seq
, seq
;
917 } __attribute__ ((packed
));
919 #define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */
920 #define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */
921 #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */
922 #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */
924 extern const char *ceph_lease_op_name(int o
);
926 /* lease msg header */
927 struct ceph_mds_lease
{
928 __u8 action
; /* CEPH_MDS_LEASE_* */
929 __le16 mask
; /* which lease */
931 __le64 first
, last
; /* snap range */
933 __le32 duration_ms
; /* duration of renewal */
934 } __attribute__ ((packed
));
935 /* followed by a __le32+string for dname */
937 /* client reconnect */
938 struct ceph_mds_cap_reconnect
{
943 __le64 pathbase
; /* base ino for our path to this ino */
944 __le32 flock_len
; /* size of flock state blob, if any */
945 } __attribute__ ((packed
));
946 /* followed by flock blob */
948 struct ceph_mds_cap_reconnect_v1
{
953 struct ceph_timespec mtime
, atime
;
955 __le64 pathbase
; /* base ino for our path to this ino */
956 } __attribute__ ((packed
));
958 struct ceph_mds_snaprealm_reconnect
{
959 __le64 ino
; /* snap realm base */
960 __le64 seq
; /* snap seq for this snap realm */
961 __le64 parent
; /* parent realm */
962 } __attribute__ ((packed
));
968 CEPH_SNAP_OP_UPDATE
, /* CREATE or DESTROY */
970 CEPH_SNAP_OP_DESTROY
,
974 extern const char *ceph_snap_op_name(int o
);
976 /* snap msg header */
977 struct ceph_mds_snap_head
{
978 __le32 op
; /* CEPH_SNAP_OP_* */
979 __le64 split
; /* ino to split off, if any */
980 __le32 num_split_inos
; /* # inos belonging to new child realm */
981 __le32 num_split_realms
; /* # child realms udner new child realm */
982 __le32 trace_len
; /* size of snap trace blob */
983 } __attribute__ ((packed
));
984 /* followed by split ino list, then split realms, then the trace blob */
987 * encode info about a snaprealm, as viewed by a client
989 struct ceph_mds_snap_realm
{
990 __le64 ino
; /* ino */
991 __le64 created
; /* snap: when created */
992 __le64 parent
; /* ino: parent realm */
993 __le64 parent_since
; /* snap: same parent since */
994 __le64 seq
; /* snap: version */
996 __le32 num_prior_parent_snaps
;
997 } __attribute__ ((packed
));
998 /* followed by my snap list, then prior parent snap list */