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