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