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