File Index
Files and directories
Sign in
FILE

ceph_fs.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/ceph/ceph_fs.h C
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * ceph_fs.h - Ceph constants and data types to share between kernel and
  4 * user space.
  5 *
  6 * Most types in this file are defined as little-endian, and are
  7 * primarily intended to describe data structures that pass over the
  8 * wire or that are stored on disk.
  9 *
 10 * LGPL2
 11 */
 12
 13#ifndef CEPH_FS_H
 14#define CEPH_FS_H
 15
 16#include <linux/ceph/msgr.h>
 17#include <linux/ceph/rados.h>
 18
 19/*
 20 * subprotocol versions.  when specific messages types or high-level
 21 * protocols change, bump the affected components.  we keep rev
 22 * internal cluster protocols separately from the public,
 23 * client-facing protocol.
 24 */
 25#define CEPH_OSDC_PROTOCOL   24 /* server/client */
 26#define CEPH_MDSC_PROTOCOL   32 /* server/client */
 27#define CEPH_MONC_PROTOCOL   15 /* server/client */
 28
 29
 30#define CEPH_INO_ROOT   1
 31#define CEPH_INO_CEPH   2            /* hidden .ceph dir */
 32#define CEPH_INO_GLOBAL_SNAPREALM  3 /* global dummy snaprealm */
 33
 34/*
 35 * name for "old" CephFS file systems,
 36 * see ceph.git e2b151d009640114b2565c901d6f41f6cd5ec652
 37 */
 38#define CEPH_OLD_FS_NAME	"cephfs"
 39
 40/* arbitrary limit on max # of monitors (cluster of 3 is typical) */
 41#define CEPH_MAX_MON   31
 42
 43/*
 44 * legacy ceph_file_layoute
 45 */
 46struct ceph_file_layout_legacy {
 47	/* file -> object mapping */
 48	__le32 fl_stripe_unit;     /* stripe unit, in bytes.  must be multiple
 49				      of page size. */
 50	__le32 fl_stripe_count;    /* over this many objects */
 51	__le32 fl_object_size;     /* until objects are this big, then move to
 52				      new objects */
 53	__le32 fl_cas_hash;        /* UNUSED.  0 = none; 1 = sha256 */
 54
 55	/* pg -> disk layout */
 56	__le32 fl_object_stripe_unit;  /* UNUSED.  for per-object parity, if any */
 57
 58	/* object -> pg layout */
 59	__le32 fl_unused;       /* unused; used to be preferred primary for pg (-1 for none) */
 60	__le32 fl_pg_pool;      /* namespace, crush ruleset, rep level */
 61} __attribute__ ((packed));
 62
 63struct ceph_string;
 64/*
 65 * ceph_file_layout - describe data layout for a file/inode
 66 */
 67struct ceph_file_layout {
 68	/* file -> object mapping */
 69	u32 stripe_unit;   /* stripe unit, in bytes */
 70	u32 stripe_count;  /* over this many objects */
 71	u32 object_size;   /* until objects are this big */
 72	s64 pool_id;        /* rados pool id */
 73	struct ceph_string __rcu *pool_ns; /* rados pool namespace */
 74};
 75
 76extern int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);
 77extern void ceph_file_layout_from_legacy(struct ceph_file_layout *fl,
 78				struct ceph_file_layout_legacy *legacy);
 79extern void ceph_file_layout_to_legacy(struct ceph_file_layout *fl,
 80				struct ceph_file_layout_legacy *legacy);
 81
 82#define CEPH_MIN_STRIPE_UNIT 65536
 83
 84struct ceph_dir_layout {
 85	__u8   dl_dir_hash;   /* see ceph_hash.h for ids */
 86	__u8   dl_unused1;
 87	__u16  dl_unused2;
 88	__u32  dl_unused3;
 89} __attribute__ ((packed));
 90
 91/* crypto algorithms */
 92#define CEPH_CRYPTO_NONE 0x0
 93#define CEPH_CRYPTO_AES  0x1
 94
 95#define CEPH_AES_IV "cephsageyudagreg"
 96
 97/* security/authentication protocols */
 98#define CEPH_AUTH_UNKNOWN	0x0
 99#define CEPH_AUTH_NONE	 	0x1
100#define CEPH_AUTH_CEPHX	 	0x2
101
102#define CEPH_AUTH_MODE_NONE		0
103#define CEPH_AUTH_MODE_AUTHORIZER	1
104#define CEPH_AUTH_MODE_MON		10
105
106/* msgr2 protocol modes */
107#define CEPH_CON_MODE_UNKNOWN	0x0
108#define CEPH_CON_MODE_CRC	0x1
109#define CEPH_CON_MODE_SECURE	0x2
110
111#define CEPH_AUTH_UID_DEFAULT ((__u64) -1)
112
113const char *ceph_auth_proto_name(int proto);
114const char *ceph_con_mode_name(int mode);
115
116/*********************************************
117 * message layer
118 */
119
120/*
121 * message types
122 */
123
124/* misc */
125#define CEPH_MSG_SHUTDOWN               1
126#define CEPH_MSG_PING                   2
127
128/* client <-> monitor */
129#define CEPH_MSG_MON_MAP                4
130#define CEPH_MSG_MON_GET_MAP            5
131#define CEPH_MSG_STATFS                 13
132#define CEPH_MSG_STATFS_REPLY           14
133#define CEPH_MSG_MON_SUBSCRIBE          15
134#define CEPH_MSG_MON_SUBSCRIBE_ACK      16
135#define CEPH_MSG_AUTH			17
136#define CEPH_MSG_AUTH_REPLY		18
137#define CEPH_MSG_MON_GET_VERSION        19
138#define CEPH_MSG_MON_GET_VERSION_REPLY  20
139
140/* client <-> mds */
141#define CEPH_MSG_MDS_MAP                21
142#define CEPH_MSG_FS_MAP_USER            103
143
144#define CEPH_MSG_CLIENT_SESSION         22
145#define CEPH_MSG_CLIENT_RECONNECT       23
146
147#define CEPH_MSG_CLIENT_REQUEST         24
148#define CEPH_MSG_CLIENT_REQUEST_FORWARD 25
149#define CEPH_MSG_CLIENT_REPLY           26
150#define CEPH_MSG_CLIENT_METRICS         29
151#define CEPH_MSG_CLIENT_CAPS            0x310
152#define CEPH_MSG_CLIENT_LEASE           0x311
153#define CEPH_MSG_CLIENT_SNAP            0x312
154#define CEPH_MSG_CLIENT_CAPRELEASE      0x313
155#define CEPH_MSG_CLIENT_QUOTA           0x314
156
157/* pool ops */
158#define CEPH_MSG_POOLOP_REPLY           48
159#define CEPH_MSG_POOLOP                 49
160
161/* mon commands */
162#define CEPH_MSG_MON_COMMAND            50
163#define CEPH_MSG_MON_COMMAND_ACK        51
164
165/* osd */
166#define CEPH_MSG_OSD_MAP                41
167#define CEPH_MSG_OSD_OP                 42
168#define CEPH_MSG_OSD_OPREPLY            43
169#define CEPH_MSG_WATCH_NOTIFY           44
170#define CEPH_MSG_OSD_BACKOFF            61
171
172
173/* watch-notify operations */
174enum {
175	CEPH_WATCH_EVENT_NOTIFY		  = 1, /* notifying watcher */
176	CEPH_WATCH_EVENT_NOTIFY_COMPLETE  = 2, /* notifier notified when done */
177	CEPH_WATCH_EVENT_DISCONNECT       = 3, /* we were disconnected */
178};
179
180
181struct ceph_mon_request_header {
182	__le64 have_version;
183	__le16 session_mon;
184	__le64 session_mon_tid;
185} __attribute__ ((packed));
186
187struct ceph_mon_statfs {
188	struct ceph_mon_request_header monhdr;
189	struct ceph_fsid fsid;
190	__u8 contains_data_pool;
191	__le64 data_pool;
192} __attribute__ ((packed));
193
194struct ceph_statfs {
195	__le64 kb, kb_used, kb_avail;
196	__le64 num_objects;
197} __attribute__ ((packed));
198
199struct ceph_mon_statfs_reply {
200	struct ceph_fsid fsid;
201	__le64 version;
202	struct ceph_statfs st;
203} __attribute__ ((packed));
204
205struct ceph_mon_command {
206	struct ceph_mon_request_header monhdr;
207	struct ceph_fsid fsid;
208	__le32 num_strs;         /* always 1 */
209	__le32 str_len;
210	char str[];
211} __attribute__ ((packed));
212
213struct ceph_osd_getmap {
214	struct ceph_mon_request_header monhdr;
215	struct ceph_fsid fsid;
216	__le32 start;
217} __attribute__ ((packed));
218
219struct ceph_mds_getmap {
220	struct ceph_mon_request_header monhdr;
221	struct ceph_fsid fsid;
222} __attribute__ ((packed));
223
224struct ceph_client_mount {
225	struct ceph_mon_request_header monhdr;
226} __attribute__ ((packed));
227
228#define CEPH_SUBSCRIBE_ONETIME    1  /* i want only 1 update after have */
229
230struct ceph_mon_subscribe_item {
231	__le64 start;
232	__u8 flags;
233} __attribute__ ((packed));
234
235struct ceph_mon_subscribe_ack {
236	__le32 duration;         /* seconds */
237	struct ceph_fsid fsid;
238} __attribute__ ((packed));
239
240#define CEPH_FS_CLUSTER_ID_NONE  -1
241
242/*
243 * mdsmap flags
244 */
245#define CEPH_MDSMAP_DOWN    (1<<0)  /* cluster deliberately down */
246
247/*
248 * mds states
249 *   > 0 -> in
250 *  <= 0 -> out
251 */
252#define CEPH_MDS_STATE_DNE          0  /* down, does not exist. */
253#define CEPH_MDS_STATE_STOPPED     -1  /* down, once existed, but no subtrees.
254					  empty log. */
255#define CEPH_MDS_STATE_BOOT        -4  /* up, boot announcement. */
256#define CEPH_MDS_STATE_STANDBY     -5  /* up, idle.  waiting for assignment. */
257#define CEPH_MDS_STATE_CREATING    -6  /* up, creating MDS instance. */
258#define CEPH_MDS_STATE_STARTING    -7  /* up, starting previously stopped mds */
259#define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */
260#define CEPH_MDS_STATE_REPLAYONCE   -9 /* up, replaying an active node's journal */
261
262#define CEPH_MDS_STATE_REPLAY       8  /* up, replaying journal. */
263#define CEPH_MDS_STATE_RESOLVE      9  /* up, disambiguating distributed
264					  operations (import, rename, etc.) */
265#define CEPH_MDS_STATE_RECONNECT    10 /* up, reconnect to clients */
266#define CEPH_MDS_STATE_REJOIN       11 /* up, rejoining distributed cache */
267#define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */
268#define CEPH_MDS_STATE_ACTIVE       13 /* up, active */
269#define CEPH_MDS_STATE_STOPPING     14 /* up, but exporting metadata */
270
271extern const char *ceph_mds_state_name(int s);
272
273
274/*
275 * metadata lock types.
276 *  - these are bitmasks.. we can compose them
277 *  - they also define the lock ordering by the MDS
278 *  - a few of these are internal to the mds
279 */
280#define CEPH_LOCK_DVERSION    1
281#define CEPH_LOCK_DN          2
282#define CEPH_LOCK_ISNAP       16
283#define CEPH_LOCK_IVERSION    32    /* mds internal */
284#define CEPH_LOCK_IFILE       64
285#define CEPH_LOCK_IAUTH       128
286#define CEPH_LOCK_ILINK       256
287#define CEPH_LOCK_IDFT        512   /* dir frag tree */
288#define CEPH_LOCK_INEST       1024  /* mds internal */
289#define CEPH_LOCK_IXATTR      2048
290#define CEPH_LOCK_IFLOCK      4096  /* advisory file locks */
291#define CEPH_LOCK_INO         8192  /* immutable inode bits; not a lock */
292#define CEPH_LOCK_IPOLICY     16384 /* policy lock on dirs. MDS internal */
293
294/* client_session ops */
295enum {
296	CEPH_SESSION_REQUEST_OPEN,
297	CEPH_SESSION_OPEN,
298	CEPH_SESSION_REQUEST_CLOSE,
299	CEPH_SESSION_CLOSE,
300	CEPH_SESSION_REQUEST_RENEWCAPS,
301	CEPH_SESSION_RENEWCAPS,
302	CEPH_SESSION_STALE,
303	CEPH_SESSION_RECALL_STATE,
304	CEPH_SESSION_FLUSHMSG,
305	CEPH_SESSION_FLUSHMSG_ACK,
306	CEPH_SESSION_FORCE_RO,
307	CEPH_SESSION_REJECT,
308	CEPH_SESSION_REQUEST_FLUSH_MDLOG,
309};
310
311#define CEPH_SESSION_BLOCKLISTED	(1 << 0)  /* session blocklisted */
312
313extern const char *ceph_session_op_name(int op);
314
315struct ceph_mds_session_head {
316	__le32 op;
317	__le64 seq;
318	struct ceph_timespec stamp;
319	__le32 max_caps, max_leases;
320} __attribute__ ((packed));
321
322/* client_request */
323/*
324 * metadata ops.
325 *  & 0x001000 -> write op
326 *  & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
327 &  & 0x100000 -> use weird ino/path trace
328 */
329#define CEPH_MDS_OP_WRITE        0x001000
330enum {
331	CEPH_MDS_OP_LOOKUP     = 0x00100,
332	CEPH_MDS_OP_GETATTR    = 0x00101,
333	CEPH_MDS_OP_LOOKUPHASH = 0x00102,
334	CEPH_MDS_OP_LOOKUPPARENT = 0x00103,
335	CEPH_MDS_OP_LOOKUPINO  = 0x00104,
336	CEPH_MDS_OP_LOOKUPNAME = 0x00105,
337	CEPH_MDS_OP_GETVXATTR  = 0x00106,
338
339	CEPH_MDS_OP_SETXATTR   = 0x01105,
340	CEPH_MDS_OP_RMXATTR    = 0x01106,
341	CEPH_MDS_OP_SETLAYOUT  = 0x01107,
342	CEPH_MDS_OP_SETATTR    = 0x01108,
343	CEPH_MDS_OP_SETFILELOCK= 0x01109,
344	CEPH_MDS_OP_GETFILELOCK= 0x00110,
345	CEPH_MDS_OP_SETDIRLAYOUT=0x0110a,
346
347	CEPH_MDS_OP_MKNOD      = 0x01201,
348	CEPH_MDS_OP_LINK       = 0x01202,
349	CEPH_MDS_OP_UNLINK     = 0x01203,
350	CEPH_MDS_OP_RENAME     = 0x01204,
351	CEPH_MDS_OP_MKDIR      = 0x01220,
352	CEPH_MDS_OP_RMDIR      = 0x01221,
353	CEPH_MDS_OP_SYMLINK    = 0x01222,
354
355	CEPH_MDS_OP_CREATE     = 0x01301,
356	CEPH_MDS_OP_OPEN       = 0x00302,
357	CEPH_MDS_OP_READDIR    = 0x00305,
358
359	CEPH_MDS_OP_LOOKUPSNAP = 0x00400,
360	CEPH_MDS_OP_MKSNAP     = 0x01400,
361	CEPH_MDS_OP_RMSNAP     = 0x01401,
362	CEPH_MDS_OP_LSSNAP     = 0x00402,
363	CEPH_MDS_OP_RENAMESNAP = 0x01403,
364};
365
366#define IS_CEPH_MDS_OP_NEWINODE(op) (op == CEPH_MDS_OP_CREATE     || \
367				     op == CEPH_MDS_OP_MKNOD      || \
368				     op == CEPH_MDS_OP_MKDIR      || \
369				     op == CEPH_MDS_OP_SYMLINK)
370
371extern const char *ceph_mds_op_name(int op);
372
373#define CEPH_SETATTR_MODE              (1 << 0)
374#define CEPH_SETATTR_UID               (1 << 1)
375#define CEPH_SETATTR_GID               (1 << 2)
376#define CEPH_SETATTR_MTIME             (1 << 3)
377#define CEPH_SETATTR_ATIME             (1 << 4)
378#define CEPH_SETATTR_SIZE              (1 << 5)
379#define CEPH_SETATTR_CTIME             (1 << 6)
380#define CEPH_SETATTR_MTIME_NOW         (1 << 7)
381#define CEPH_SETATTR_ATIME_NOW         (1 << 8)
382#define CEPH_SETATTR_BTIME             (1 << 9)
383#define CEPH_SETATTR_KILL_SGUID        (1 << 10)
384#define CEPH_SETATTR_FSCRYPT_AUTH      (1 << 11)
385#define CEPH_SETATTR_FSCRYPT_FILE      (1 << 12)
386
387/*
388 * Ceph setxattr request flags.
389 */
390#define CEPH_XATTR_CREATE  (1 << 0)
391#define CEPH_XATTR_REPLACE (1 << 1)
392#define CEPH_XATTR_REMOVE  (1 << 31)
393
394/*
395 * readdir request flags;
396 */
397#define CEPH_READDIR_REPLY_BITFLAGS	(1<<0)
398
399/*
400 * readdir reply flags.
401 */
402#define CEPH_READDIR_FRAG_END		(1<<0)
403#define CEPH_READDIR_FRAG_COMPLETE	(1<<8)
404#define CEPH_READDIR_HASH_ORDER		(1<<9)
405#define CEPH_READDIR_OFFSET_HASH	(1<<10)
406
407/*
408 * open request flags
409 */
410#define CEPH_O_RDONLY		00000000
411#define CEPH_O_WRONLY		00000001
412#define CEPH_O_RDWR		00000002
413#define CEPH_O_CREAT		00000100
414#define CEPH_O_EXCL		00000200
415#define CEPH_O_TRUNC		00001000
416#define CEPH_O_DIRECTORY	00200000
417#define CEPH_O_NOFOLLOW		00400000
418
419union ceph_mds_request_args {
420	struct {
421		__le32 mask;                 /* CEPH_CAP_* */
422	} __attribute__ ((packed)) getattr;
423	struct {
424		__le32 mode;
425		__le32 uid;
426		__le32 gid;
427		struct ceph_timespec mtime;
428		struct ceph_timespec atime;
429		__le64 size, old_size;       /* old_size needed by truncate */
430		__le32 mask;                 /* CEPH_SETATTR_* */
431	} __attribute__ ((packed)) setattr;
432	struct {
433		__le32 frag;                 /* which dir fragment */
434		__le32 max_entries;          /* how many dentries to grab */
435		__le32 max_bytes;
436		__le16 flags;
437		__le32 offset_hash;
438	} __attribute__ ((packed)) readdir;
439	struct {
440		__le32 mode;
441		__le32 rdev;
442	} __attribute__ ((packed)) mknod;
443	struct {
444		__le32 mode;
445	} __attribute__ ((packed)) mkdir;
446	struct {
447		__le32 flags;
448		__le32 mode;
449		__le32 stripe_unit;          /* layout for newly created file */
450		__le32 stripe_count;         /* ... */
451		__le32 object_size;
452		__le32 pool;
453		__le32 mask;                 /* CEPH_CAP_* */
454		__le64 old_size;
455	} __attribute__ ((packed)) open;
456	struct {
457		__le32 flags;
458		__le32 osdmap_epoch; /* used for setting file/dir layouts */
459	} __attribute__ ((packed)) setxattr;
460	struct {
461		struct ceph_file_layout_legacy layout;
462	} __attribute__ ((packed)) setlayout;
463	struct {
464		__u8 rule; /* currently fcntl or flock */
465		__u8 type; /* shared, exclusive, remove*/
466		__le64 owner; /* owner of the lock */
467		__le64 pid; /* process id requesting the lock */
468		__le64 start; /* initial location to lock */
469		__le64 length; /* num bytes to lock from start */
470		__u8 wait; /* will caller wait for lock to become available? */
471	} __attribute__ ((packed)) filelock_change;
472	struct {
473		__le32 mask;                 /* CEPH_CAP_* */
474		__le64 snapid;
475		__le64 parent;
476		__le32 hash;
477	} __attribute__ ((packed)) lookupino;
478} __attribute__ ((packed));
479
480union ceph_mds_request_args_ext {
481	union ceph_mds_request_args old;
482	struct {
483		__le32 mode;
484		__le32 uid;
485		__le32 gid;
486		struct ceph_timespec mtime;
487		struct ceph_timespec atime;
488		__le64 size, old_size;       /* old_size needed by truncate */
489		__le32 mask;                 /* CEPH_SETATTR_* */
490		struct ceph_timespec btime;
491	} __attribute__ ((packed)) setattr_ext;
492};
493
494#define CEPH_MDS_FLAG_REPLAY		1 /* this is a replayed op */
495#define CEPH_MDS_FLAG_WANT_DENTRY	2 /* want dentry in reply */
496#define CEPH_MDS_FLAG_ASYNC		4 /* request is asynchronous */
497
498struct ceph_mds_request_head_legacy {
499	__le64 oldest_client_tid;
500	__le32 mdsmap_epoch;           /* on client */
501	__le32 flags;                  /* CEPH_MDS_FLAG_* */
502	__u8 num_retry, num_fwd;       /* count retry, fwd attempts */
503	__le16 num_releases;           /* # include cap/lease release records */
504	__le32 op;                     /* mds op code */
505	__le32 caller_uid, caller_gid;
506	__le64 ino;                    /* use this ino for openc, mkdir, mknod,
507					  etc. (if replaying) */
508	union ceph_mds_request_args args;
509} __attribute__ ((packed));
510
511#define CEPH_MDS_REQUEST_HEAD_VERSION  3
512
513struct ceph_mds_request_head {
514	__le16 version;                /* struct version */
515	__le64 oldest_client_tid;
516	__le32 mdsmap_epoch;           /* on client */
517	__le32 flags;                  /* CEPH_MDS_FLAG_* */
518	__u8 num_retry, num_fwd;       /* legacy count retry and fwd attempts */
519	__le16 num_releases;           /* # include cap/lease release records */
520	__le32 op;                     /* mds op code */
521	__le32 caller_uid, caller_gid;
522	__le64 ino;                    /* use this ino for openc, mkdir, mknod,
523					  etc. (if replaying) */
524	union ceph_mds_request_args_ext args;
525
526	__le32 ext_num_retry;          /* new count retry attempts */
527	__le32 ext_num_fwd;            /* new count fwd attempts */
528
529	__le32 struct_len;             /* to store size of struct ceph_mds_request_head */
530	__le32 owner_uid, owner_gid;   /* used for OPs which create inodes */
531} __attribute__ ((packed));
532
533/* cap/lease release record */
534struct ceph_mds_request_release {
535	__le64 ino, cap_id;            /* ino and unique cap id */
536	__le32 caps, wanted;           /* new issued, wanted */
537	__le32 seq, issue_seq, mseq;
538	__le32 dname_seq;              /* if releasing a dentry lease, a */
539	__le32 dname_len;              /* string follows. */
540} __attribute__ ((packed));
541
542/* client reply */
543struct ceph_mds_reply_head {
544	__le32 op;
545	__le32 result;
546	__le32 mdsmap_epoch;
547	__u8 safe;                     /* true if committed to disk */
548	__u8 is_dentry, is_target;     /* true if dentry, target inode records
549					  are included with reply */
550} __attribute__ ((packed));
551
552/* one for each node split */
553struct ceph_frag_tree_split {
554	__le32 frag;                   /* this frag splits... */
555	__le32 by;                     /* ...by this many bits */
556} __attribute__ ((packed));
557
558struct ceph_frag_tree_head {
559	__le32 nsplits;                /* num ceph_frag_tree_split records */
560	struct ceph_frag_tree_split splits[];
561} __attribute__ ((packed));
562
563/* capability issue, for bundling with mds reply */
564struct ceph_mds_reply_cap {
565	__le32 caps, wanted;           /* caps issued, wanted */
566	__le64 cap_id;
567	__le32 seq, mseq;
568	__le64 realm;                  /* snap realm */
569	__u8 flags;                    /* CEPH_CAP_FLAG_* */
570} __attribute__ ((packed));
571
572#define CEPH_CAP_FLAG_AUTH	(1 << 0)  /* cap is issued by auth mds */
573#define CEPH_CAP_FLAG_RELEASE	(1 << 1)  /* release the cap */
574
575/* inode record, for bundling with mds reply */
576struct ceph_mds_reply_inode {
577	__le64 ino;
578	__le64 snapid;
579	__le32 rdev;
580	__le64 version;                /* inode version */
581	__le64 xattr_version;          /* version for xattr blob */
582	struct ceph_mds_reply_cap cap; /* caps issued for this inode */
583	struct ceph_file_layout_legacy layout;
584	struct ceph_timespec ctime, mtime, atime;
585	__le32 time_warp_seq;
586	__le64 size, max_size, truncate_size;
587	__le32 truncate_seq;
588	__le32 mode, uid, gid;
589	__le32 nlink;
590	__le64 files, subdirs, rbytes, rfiles, rsubdirs;  /* dir stats */
591	struct ceph_timespec rctime;
592	struct ceph_frag_tree_head fragtree;  /* (must be at end of struct) */
593} __attribute__ ((packed));
594/* followed by frag array, symlink string, dir layout, xattr blob */
595
596/* reply_lease follows dname, and reply_inode */
597struct ceph_mds_reply_lease {
598	__le16 mask;            /* lease type(s) */
599	__le32 duration_ms;     /* lease duration */
600	__le32 seq;
601} __attribute__ ((packed));
602
603#define CEPH_LEASE_VALID        (1 | 2) /* old and new bit values */
604#define CEPH_LEASE_PRIMARY_LINK 4       /* primary linkage */
605
606struct ceph_mds_reply_dirfrag {
607	__le32 frag;            /* fragment */
608	__le32 auth;            /* auth mds, if this is a delegation point */
609	__le32 ndist;           /* number of mds' this is replicated on */
610	__le32 dist[];
611} __attribute__ ((packed));
612
613#define CEPH_LOCK_FCNTL		1
614#define CEPH_LOCK_FLOCK		2
615#define CEPH_LOCK_FCNTL_INTR    3
616#define CEPH_LOCK_FLOCK_INTR    4
617
618
619#define CEPH_LOCK_SHARED   1
620#define CEPH_LOCK_EXCL     2
621#define CEPH_LOCK_UNLOCK   4
622
623struct ceph_filelock {
624	__le64 start;/* file offset to start lock at */
625	__le64 length; /* num bytes to lock; 0 for all following start */
626	__le64 client; /* which client holds the lock */
627	__le64 owner; /* owner the lock */
628	__le64 pid; /* process id holding the lock on the client */
629	__u8 type; /* shared lock, exclusive lock, or unlock */
630} __attribute__ ((packed));
631
632
633/* file access modes */
634#define CEPH_FILE_MODE_PIN        0
635#define CEPH_FILE_MODE_RD         1
636#define CEPH_FILE_MODE_WR         2
637#define CEPH_FILE_MODE_RDWR       3  /* RD | WR */
638#define CEPH_FILE_MODE_LAZY       4  /* lazy io */
639#define CEPH_FILE_MODE_BITS       4
640#define CEPH_FILE_MODE_MASK       ((1 << CEPH_FILE_MODE_BITS) - 1)
641
642int ceph_flags_to_mode(int flags);
643
644#define CEPH_INLINE_NONE	((__u64)-1)
645
646/* capability bits */
647#define CEPH_CAP_PIN         1  /* no specific capabilities beyond the pin */
648
649/* generic cap bits */
650#define CEPH_CAP_GSHARED     1  /* client can reads */
651#define CEPH_CAP_GEXCL       2  /* client can read and update */
652#define CEPH_CAP_GCACHE      4  /* (file) client can cache reads */
653#define CEPH_CAP_GRD         8  /* (file) client can read */
654#define CEPH_CAP_GWR        16  /* (file) client can write */
655#define CEPH_CAP_GBUFFER    32  /* (file) client can buffer writes */
656#define CEPH_CAP_GWREXTEND  64  /* (file) client can extend EOF */
657#define CEPH_CAP_GLAZYIO   128  /* (file) client can perform lazy io */
658
659#define CEPH_CAP_SIMPLE_BITS  2
660#define CEPH_CAP_FILE_BITS    8
661
662/* per-lock shift */
663#define CEPH_CAP_SAUTH      2
664#define CEPH_CAP_SLINK      4
665#define CEPH_CAP_SXATTR     6
666#define CEPH_CAP_SFILE      8
667#define CEPH_CAP_SFLOCK    20
668
669#define CEPH_CAP_BITS      22
670
671/* composed values */
672#define CEPH_CAP_AUTH_SHARED  (CEPH_CAP_GSHARED  << CEPH_CAP_SAUTH)
673#define CEPH_CAP_AUTH_EXCL     (CEPH_CAP_GEXCL     << CEPH_CAP_SAUTH)
674#define CEPH_CAP_LINK_SHARED  (CEPH_CAP_GSHARED  << CEPH_CAP_SLINK)
675#define CEPH_CAP_LINK_EXCL     (CEPH_CAP_GEXCL     << CEPH_CAP_SLINK)
676#define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED  << CEPH_CAP_SXATTR)
677#define CEPH_CAP_XATTR_EXCL    (CEPH_CAP_GEXCL     << CEPH_CAP_SXATTR)
678#define CEPH_CAP_FILE(x)    (x << CEPH_CAP_SFILE)
679#define CEPH_CAP_FILE_SHARED   (CEPH_CAP_GSHARED   << CEPH_CAP_SFILE)
680#define CEPH_CAP_FILE_EXCL     (CEPH_CAP_GEXCL     << CEPH_CAP_SFILE)
681#define CEPH_CAP_FILE_CACHE    (CEPH_CAP_GCACHE    << CEPH_CAP_SFILE)
682#define CEPH_CAP_FILE_RD       (CEPH_CAP_GRD       << CEPH_CAP_SFILE)
683#define CEPH_CAP_FILE_WR       (CEPH_CAP_GWR       << CEPH_CAP_SFILE)
684#define CEPH_CAP_FILE_BUFFER   (CEPH_CAP_GBUFFER   << CEPH_CAP_SFILE)
685#define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
686#define CEPH_CAP_FILE_LAZYIO   (CEPH_CAP_GLAZYIO   << CEPH_CAP_SFILE)
687#define CEPH_CAP_FLOCK_SHARED  (CEPH_CAP_GSHARED   << CEPH_CAP_SFLOCK)
688#define CEPH_CAP_FLOCK_EXCL    (CEPH_CAP_GEXCL     << CEPH_CAP_SFLOCK)
689
690
691/* cap masks (for getattr) */
692#define CEPH_STAT_CAP_INODE    CEPH_CAP_PIN
693#define CEPH_STAT_CAP_TYPE     CEPH_CAP_PIN  /* mode >> 12 */
694#define CEPH_STAT_CAP_SYMLINK  CEPH_CAP_PIN
695#define CEPH_STAT_CAP_UID      CEPH_CAP_AUTH_SHARED
696#define CEPH_STAT_CAP_GID      CEPH_CAP_AUTH_SHARED
697#define CEPH_STAT_CAP_MODE     CEPH_CAP_AUTH_SHARED
698#define CEPH_STAT_CAP_NLINK    CEPH_CAP_LINK_SHARED
699#define CEPH_STAT_CAP_LAYOUT   CEPH_CAP_FILE_SHARED
700#define CEPH_STAT_CAP_MTIME    CEPH_CAP_FILE_SHARED
701#define CEPH_STAT_CAP_SIZE     CEPH_CAP_FILE_SHARED
702#define CEPH_STAT_CAP_ATIME    CEPH_CAP_FILE_SHARED  /* fixme */
703#define CEPH_STAT_CAP_XATTR    CEPH_CAP_XATTR_SHARED
704#define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN |			\
705				 CEPH_CAP_AUTH_SHARED |	\
706				 CEPH_CAP_LINK_SHARED |	\
707				 CEPH_CAP_FILE_SHARED |	\
708				 CEPH_CAP_XATTR_SHARED)
709#define CEPH_STAT_CAP_INLINE_DATA (CEPH_CAP_FILE_SHARED | \
710				   CEPH_CAP_FILE_RD)
711#define CEPH_STAT_RSTAT CEPH_CAP_FILE_WREXTEND
712
713#define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED |			\
714			      CEPH_CAP_LINK_SHARED |			\
715			      CEPH_CAP_XATTR_SHARED |			\
716			      CEPH_CAP_FILE_SHARED)
717#define CEPH_CAP_ANY_RD   (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD |	\
718			   CEPH_CAP_FILE_CACHE)
719
720#define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL |		\
721			   CEPH_CAP_LINK_EXCL |		\
722			   CEPH_CAP_XATTR_EXCL |	\
723			   CEPH_CAP_FILE_EXCL)
724#define CEPH_CAP_ANY_FILE_RD (CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE | \
725			      CEPH_CAP_FILE_SHARED)
726#define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER |	\
727			      CEPH_CAP_FILE_EXCL)
728#define CEPH_CAP_ANY_WR   (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
729#define CEPH_CAP_ANY      (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
730			   CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \
731			   CEPH_CAP_PIN)
732#define CEPH_CAP_ALL_FILE (CEPH_CAP_PIN | CEPH_CAP_ANY_SHARED | \
733			   CEPH_CAP_AUTH_EXCL | CEPH_CAP_XATTR_EXCL | \
734			   CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)
735
736#define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
737			CEPH_LOCK_IXATTR)
738
739/* cap masks async dir operations */
740#define CEPH_CAP_DIR_CREATE	CEPH_CAP_FILE_CACHE
741#define CEPH_CAP_DIR_UNLINK	CEPH_CAP_FILE_RD
742#define CEPH_CAP_ANY_DIR_OPS	(CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_RD | \
743				 CEPH_CAP_FILE_WREXTEND | CEPH_CAP_FILE_LAZYIO)
744
745int ceph_caps_for_mode(int mode);
746
747enum {
748	CEPH_CAP_OP_GRANT,         /* mds->client grant */
749	CEPH_CAP_OP_REVOKE,        /* mds->client revoke */
750	CEPH_CAP_OP_TRUNC,         /* mds->client trunc notify */
751	CEPH_CAP_OP_EXPORT,        /* mds has exported the cap */
752	CEPH_CAP_OP_IMPORT,        /* mds has imported the cap */
753	CEPH_CAP_OP_UPDATE,        /* client->mds update */
754	CEPH_CAP_OP_DROP,          /* client->mds drop cap bits */
755	CEPH_CAP_OP_FLUSH,         /* client->mds cap writeback */
756	CEPH_CAP_OP_FLUSH_ACK,     /* mds->client flushed */
757	CEPH_CAP_OP_FLUSHSNAP,     /* client->mds flush snapped metadata */
758	CEPH_CAP_OP_FLUSHSNAP_ACK, /* mds->client flushed snapped metadata */
759	CEPH_CAP_OP_RELEASE,       /* client->mds release (clean) cap */
760	CEPH_CAP_OP_RENEW,         /* client->mds renewal request */
761};
762
763extern const char *ceph_cap_op_name(int op);
764
765/* flags field in client cap messages (version >= 10) */
766#define CEPH_CLIENT_CAPS_SYNC			(1<<0)
767#define CEPH_CLIENT_CAPS_NO_CAPSNAP		(1<<1)
768#define CEPH_CLIENT_CAPS_PENDING_CAPSNAP	(1<<2)
769
770/*
771 * caps message, used for capability callbacks, acks, requests, etc.
772 */
773struct ceph_mds_caps {
774	__le32 op;                  /* CEPH_CAP_OP_* */
775	__le64 ino, realm;
776	__le64 cap_id;
777	__le32 seq, issue_seq;
778	__le32 caps, wanted, dirty; /* latest issued/wanted/dirty */
779	__le32 migrate_seq;
780	__le64 snap_follows;
781	__le32 snap_trace_len;
782
783	/* authlock */
784	__le32 uid, gid, mode;
785
786	/* linklock */
787	__le32 nlink;
788
789	/* xattrlock */
790	__le32 xattr_len;
791	__le64 xattr_version;
792
793	/* a union of non-export and export bodies. */
794	__le64 size, max_size, truncate_size;
795	__le32 truncate_seq;
796	struct ceph_timespec mtime, atime, ctime;
797	struct ceph_file_layout_legacy layout;
798	__le32 time_warp_seq;
799} __attribute__ ((packed));
800
801struct ceph_mds_cap_peer {
802	__le64 cap_id;
803	__le32 issue_seq;
804	__le32 mseq;
805	__le32 mds;
806	__u8   flags;
807} __attribute__ ((packed));
808
809/* cap release msg head */
810struct ceph_mds_cap_release {
811	__le32 num;                /* number of cap_items that follow */
812} __attribute__ ((packed));
813
814struct ceph_mds_cap_item {
815	__le64 ino;
816	__le64 cap_id;
817	__le32 migrate_seq, issue_seq;
818} __attribute__ ((packed));
819
820#define CEPH_MDS_LEASE_REVOKE           1  /*    mds  -> client */
821#define CEPH_MDS_LEASE_RELEASE          2  /* client  -> mds    */
822#define CEPH_MDS_LEASE_RENEW            3  /* client <-> mds    */
823#define CEPH_MDS_LEASE_REVOKE_ACK       4  /* client  -> mds    */
824
825extern const char *ceph_lease_op_name(int o);
826
827/* lease msg header */
828struct ceph_mds_lease {
829	__u8 action;            /* CEPH_MDS_LEASE_* */
830	__le16 mask;            /* which lease */
831	__le64 ino;
832	__le64 first, last;     /* snap range */
833	__le32 seq;
834	__le32 duration_ms;     /* duration of renewal */
835} __attribute__ ((packed));
836/* followed by a __le32+string for dname */
837
838/* client reconnect */
839struct ceph_mds_cap_reconnect {
840	__le64 cap_id;
841	__le32 wanted;
842	__le32 issued;
843	__le64 snaprealm;
844	__le64 pathbase;        /* base ino for our path to this ino */
845	__le32 flock_len;       /* size of flock state blob, if any */
846} __attribute__ ((packed));
847/* followed by flock blob */
848
849struct ceph_mds_cap_reconnect_v1 {
850	__le64 cap_id;
851	__le32 wanted;
852	__le32 issued;
853	__le64 size;
854	struct ceph_timespec mtime, atime;
855	__le64 snaprealm;
856	__le64 pathbase;        /* base ino for our path to this ino */
857} __attribute__ ((packed));
858
859struct ceph_mds_snaprealm_reconnect {
860	__le64 ino;     /* snap realm base */
861	__le64 seq;     /* snap seq for this snap realm */
862	__le64 parent;  /* parent realm */
863} __attribute__ ((packed));
864
865/*
866 * snaps
867 */
868enum {
869	CEPH_SNAP_OP_UPDATE,  /* CREATE or DESTROY */
870	CEPH_SNAP_OP_CREATE,
871	CEPH_SNAP_OP_DESTROY,
872	CEPH_SNAP_OP_SPLIT,
873};
874
875extern const char *ceph_snap_op_name(int o);
876
877/* snap msg header */
878struct ceph_mds_snap_head {
879	__le32 op;                /* CEPH_SNAP_OP_* */
880	__le64 split;             /* ino to split off, if any */
881	__le32 num_split_inos;    /* # inos belonging to new child realm */
882	__le32 num_split_realms;  /* # child realms udner new child realm */
883	__le32 trace_len;         /* size of snap trace blob */
884} __attribute__ ((packed));
885/* followed by split ino list, then split realms, then the trace blob */
886
887/*
888 * encode info about a snaprealm, as viewed by a client
889 */
890struct ceph_mds_snap_realm {
891	__le64 ino;           /* ino */
892	__le64 created;       /* snap: when created */
893	__le64 parent;        /* ino: parent realm */
894	__le64 parent_since;  /* snap: same parent since */
895	__le64 seq;           /* snap: version */
896	__le32 num_snaps;
897	__le32 num_prior_parent_snaps;
898} __attribute__ ((packed));
899/* followed by my snap list, then prior parent snap list */
900
901/*
902 * quotas
903 */
904struct ceph_mds_quota {
905	__le64 ino;		/* ino */
906	struct ceph_timespec rctime;
907	__le64 rbytes;		/* dir stats */
908	__le64 rfiles;
909	__le64 rsubdirs;
910	__u8 struct_v;		/* compat */
911	__u8 struct_compat;
912	__le32 struct_len;
913	__le64 max_bytes;	/* quota max. bytes */
914	__le64 max_files;	/* quota max. files */
915} __attribute__ ((packed));
916
917#endif
~/ Read-only file preview.