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