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