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