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