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