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