This source file includes following definitions.
- ceph_fsid_compare
- ceph_stable_mod
- __CEPH_FORALL_OSD_OPS
- ceph_osd_op_type_lock
- ceph_osd_op_type_data
- ceph_osd_op_type_attr
- ceph_osd_op_type_exec
- ceph_osd_op_type_pg
- ceph_osd_op_type_multi
- ceph_osd_op_mode_subop
- ceph_osd_op_mode_read
- ceph_osd_op_mode_modify
1
2 #ifndef CEPH_RADOS_H
3 #define CEPH_RADOS_H
4
5
6
7
8
9
10 #include <linux/ceph/msgr.h>
11
12
13
14
15 struct ceph_fsid {
16 unsigned char fsid[16];
17 };
18
19 static inline int ceph_fsid_compare(const struct ceph_fsid *a,
20 const struct ceph_fsid *b)
21 {
22 return memcmp(a, b, sizeof(*a));
23 }
24
25
26
27
28 typedef __le64 ceph_snapid_t;
29 #define CEPH_SNAPDIR ((__u64)(-1))
30 #define CEPH_NOSNAP ((__u64)(-2))
31 #define CEPH_MAXSNAP ((__u64)(-3))
32
33 struct ceph_timespec {
34 __le32 tv_sec;
35 __le32 tv_nsec;
36 } __attribute__ ((packed));
37
38
39
40
41
42 #define CEPH_OBJECT_LAYOUT_HASH 1
43 #define CEPH_OBJECT_LAYOUT_LINEAR 2
44 #define CEPH_OBJECT_LAYOUT_HASHINO 3
45
46
47
48
49 #define CEPH_PG_LAYOUT_CRUSH 0
50 #define CEPH_PG_LAYOUT_HASH 1
51 #define CEPH_PG_LAYOUT_LINEAR 2
52 #define CEPH_PG_LAYOUT_HYBRID 3
53
54 #define CEPH_PG_MAX_SIZE 32
55
56
57
58
59
60 struct ceph_pg_v1 {
61 __le16 preferred;
62 __le16 ps;
63 __le32 pool;
64 } __attribute__ ((packed));
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 #define CEPH_NOPOOL ((__u64) (-1))
84
85 #define CEPH_POOL_TYPE_REP 1
86 #define CEPH_POOL_TYPE_RAID4 2
87 #define CEPH_POOL_TYPE_EC 3
88
89
90
91
92
93
94
95
96
97
98 static inline int ceph_stable_mod(int x, int b, int bmask)
99 {
100 if ((x & bmask) < b)
101 return x & bmask;
102 else
103 return x & (bmask >> 1);
104 }
105
106
107
108
109 struct ceph_object_layout {
110 struct ceph_pg_v1 ol_pgid;
111 __le32 ol_stripe_unit;
112 } __attribute__ ((packed));
113
114
115
116
117 struct ceph_eversion {
118 __le64 version;
119 __le32 epoch;
120 } __attribute__ ((packed));
121
122
123
124
125
126
127 #define CEPH_OSD_EXISTS (1<<0)
128 #define CEPH_OSD_UP (1<<1)
129 #define CEPH_OSD_AUTOOUT (1<<2)
130 #define CEPH_OSD_NEW (1<<3)
131
132 extern const char *ceph_osd_state_name(int s);
133
134
135 #define CEPH_OSD_IN 0x10000
136 #define CEPH_OSD_OUT 0
137
138
139 #define CEPH_OSD_MAX_PRIMARY_AFFINITY 0x10000
140 #define CEPH_OSD_DEFAULT_PRIMARY_AFFINITY 0x10000
141
142
143
144
145
146 #define CEPH_OSDMAP_NEARFULL (1<<0)
147
148 #define CEPH_OSDMAP_FULL (1<<1)
149
150 #define CEPH_OSDMAP_PAUSERD (1<<2)
151 #define CEPH_OSDMAP_PAUSEWR (1<<3)
152 #define CEPH_OSDMAP_PAUSEREC (1<<4)
153 #define CEPH_OSDMAP_NOUP (1<<5)
154 #define CEPH_OSDMAP_NODOWN (1<<6)
155 #define CEPH_OSDMAP_NOOUT (1<<7)
156 #define CEPH_OSDMAP_NOIN (1<<8)
157 #define CEPH_OSDMAP_NOBACKFILL (1<<9)
158 #define CEPH_OSDMAP_NORECOVER (1<<10)
159 #define CEPH_OSDMAP_NOSCRUB (1<<11)
160 #define CEPH_OSDMAP_NODEEP_SCRUB (1<<12)
161 #define CEPH_OSDMAP_NOTIERAGENT (1<<13)
162 #define CEPH_OSDMAP_NOREBALANCE (1<<14)
163 #define CEPH_OSDMAP_SORTBITWISE (1<<15)
164 #define CEPH_OSDMAP_REQUIRE_JEWEL (1<<16)
165 #define CEPH_OSDMAP_REQUIRE_KRAKEN (1<<17)
166 #define CEPH_OSDMAP_REQUIRE_LUMINOUS (1<<18)
167 #define CEPH_OSDMAP_RECOVERY_DELETES (1<<19)
168
169
170
171
172
173 #define OSD_WRITETOOBIG EMSGSIZE
174
175
176
177
178
179
180
181
182 #define CEPH_OSD_OP_MODE 0xf000
183 #define CEPH_OSD_OP_MODE_RD 0x1000
184 #define CEPH_OSD_OP_MODE_WR 0x2000
185 #define CEPH_OSD_OP_MODE_RMW 0x3000
186 #define CEPH_OSD_OP_MODE_SUB 0x4000
187 #define CEPH_OSD_OP_MODE_CACHE 0x8000
188
189 #define CEPH_OSD_OP_TYPE 0x0f00
190 #define CEPH_OSD_OP_TYPE_LOCK 0x0100
191 #define CEPH_OSD_OP_TYPE_DATA 0x0200
192 #define CEPH_OSD_OP_TYPE_ATTR 0x0300
193 #define CEPH_OSD_OP_TYPE_EXEC 0x0400
194 #define CEPH_OSD_OP_TYPE_PG 0x0500
195 #define CEPH_OSD_OP_TYPE_MULTI 0x0600
196
197 #define __CEPH_OSD_OP1(mode, nr) \
198 (CEPH_OSD_OP_MODE_##mode | (nr))
199
200 #define __CEPH_OSD_OP(mode, type, nr) \
201 (CEPH_OSD_OP_MODE_##mode | CEPH_OSD_OP_TYPE_##type | (nr))
202
203 #define __CEPH_FORALL_OSD_OPS(f) \
204 \
205 \
206 f(READ, __CEPH_OSD_OP(RD, DATA, 1), "read") \
207 f(STAT, __CEPH_OSD_OP(RD, DATA, 2), "stat") \
208 f(MAPEXT, __CEPH_OSD_OP(RD, DATA, 3), "mapext") \
209 \
210 \
211 f(MASKTRUNC, __CEPH_OSD_OP(RD, DATA, 4), "masktrunc") \
212 f(SPARSE_READ, __CEPH_OSD_OP(RD, DATA, 5), "sparse-read") \
213 \
214 f(NOTIFY, __CEPH_OSD_OP(RD, DATA, 6), "notify") \
215 f(NOTIFY_ACK, __CEPH_OSD_OP(RD, DATA, 7), "notify-ack") \
216 \
217 \
218 f(ASSERT_VER, __CEPH_OSD_OP(RD, DATA, 8), "assert-version") \
219 \
220 f(LIST_WATCHERS, __CEPH_OSD_OP(RD, DATA, 9), "list-watchers") \
221 \
222 f(LIST_SNAPS, __CEPH_OSD_OP(RD, DATA, 10), "list-snaps") \
223 \
224 \
225 f(SYNC_READ, __CEPH_OSD_OP(RD, DATA, 11), "sync_read") \
226 \
227 \
228 f(WRITE, __CEPH_OSD_OP(WR, DATA, 1), "write") \
229 f(WRITEFULL, __CEPH_OSD_OP(WR, DATA, 2), "writefull") \
230 f(TRUNCATE, __CEPH_OSD_OP(WR, DATA, 3), "truncate") \
231 f(ZERO, __CEPH_OSD_OP(WR, DATA, 4), "zero") \
232 f(DELETE, __CEPH_OSD_OP(WR, DATA, 5), "delete") \
233 \
234 \
235 f(APPEND, __CEPH_OSD_OP(WR, DATA, 6), "append") \
236 f(SETTRUNC, __CEPH_OSD_OP(WR, DATA, 8), "settrunc") \
237 f(TRIMTRUNC, __CEPH_OSD_OP(WR, DATA, 9), "trimtrunc") \
238 \
239 f(TMAPUP, __CEPH_OSD_OP(RMW, DATA, 10), "tmapup") \
240 f(TMAPPUT, __CEPH_OSD_OP(WR, DATA, 11), "tmapput") \
241 f(TMAPGET, __CEPH_OSD_OP(RD, DATA, 12), "tmapget") \
242 \
243 f(CREATE, __CEPH_OSD_OP(WR, DATA, 13), "create") \
244 f(ROLLBACK, __CEPH_OSD_OP(WR, DATA, 14), "rollback") \
245 \
246 f(WATCH, __CEPH_OSD_OP(WR, DATA, 15), "watch") \
247 \
248 \
249 f(OMAPGETKEYS, __CEPH_OSD_OP(RD, DATA, 17), "omap-get-keys") \
250 f(OMAPGETVALS, __CEPH_OSD_OP(RD, DATA, 18), "omap-get-vals") \
251 f(OMAPGETHEADER, __CEPH_OSD_OP(RD, DATA, 19), "omap-get-header") \
252 f(OMAPGETVALSBYKEYS, __CEPH_OSD_OP(RD, DATA, 20), "omap-get-vals-by-keys") \
253 f(OMAPSETVALS, __CEPH_OSD_OP(WR, DATA, 21), "omap-set-vals") \
254 f(OMAPSETHEADER, __CEPH_OSD_OP(WR, DATA, 22), "omap-set-header") \
255 f(OMAPCLEAR, __CEPH_OSD_OP(WR, DATA, 23), "omap-clear") \
256 f(OMAPRMKEYS, __CEPH_OSD_OP(WR, DATA, 24), "omap-rm-keys") \
257 f(OMAP_CMP, __CEPH_OSD_OP(RD, DATA, 25), "omap-cmp") \
258 \
259 \
260 f(COPY_FROM, __CEPH_OSD_OP(WR, DATA, 26), "copy-from") \
261 f(COPY_GET_CLASSIC, __CEPH_OSD_OP(RD, DATA, 27), "copy-get-classic") \
262 f(UNDIRTY, __CEPH_OSD_OP(WR, DATA, 28), "undirty") \
263 f(ISDIRTY, __CEPH_OSD_OP(RD, DATA, 29), "isdirty") \
264 f(COPY_GET, __CEPH_OSD_OP(RD, DATA, 30), "copy-get") \
265 f(CACHE_FLUSH, __CEPH_OSD_OP(CACHE, DATA, 31), "cache-flush") \
266 f(CACHE_EVICT, __CEPH_OSD_OP(CACHE, DATA, 32), "cache-evict") \
267 f(CACHE_TRY_FLUSH, __CEPH_OSD_OP(CACHE, DATA, 33), "cache-try-flush") \
268 \
269 \
270 f(TMAP2OMAP, __CEPH_OSD_OP(RMW, DATA, 34), "tmap2omap") \
271 \
272 \
273 f(SETALLOCHINT, __CEPH_OSD_OP(WR, DATA, 35), "set-alloc-hint") \
274 \
275 \
276 f(CLONERANGE, __CEPH_OSD_OP(WR, MULTI, 1), "clonerange") \
277 f(ASSERT_SRC_VERSION, __CEPH_OSD_OP(RD, MULTI, 2), "assert-src-version") \
278 f(SRC_CMPXATTR, __CEPH_OSD_OP(RD, MULTI, 3), "src-cmpxattr") \
279 \
280 \
281 \
282 f(GETXATTR, __CEPH_OSD_OP(RD, ATTR, 1), "getxattr") \
283 f(GETXATTRS, __CEPH_OSD_OP(RD, ATTR, 2), "getxattrs") \
284 f(CMPXATTR, __CEPH_OSD_OP(RD, ATTR, 3), "cmpxattr") \
285 \
286 \
287 f(SETXATTR, __CEPH_OSD_OP(WR, ATTR, 1), "setxattr") \
288 f(SETXATTRS, __CEPH_OSD_OP(WR, ATTR, 2), "setxattrs") \
289 f(RESETXATTRS, __CEPH_OSD_OP(WR, ATTR, 3), "resetxattrs") \
290 f(RMXATTR, __CEPH_OSD_OP(WR, ATTR, 4), "rmxattr") \
291 \
292 \
293 f(PULL, __CEPH_OSD_OP1(SUB, 1), "pull") \
294 f(PUSH, __CEPH_OSD_OP1(SUB, 2), "push") \
295 f(BALANCEREADS, __CEPH_OSD_OP1(SUB, 3), "balance-reads") \
296 f(UNBALANCEREADS, __CEPH_OSD_OP1(SUB, 4), "unbalance-reads") \
297 f(SCRUB, __CEPH_OSD_OP1(SUB, 5), "scrub") \
298 f(SCRUB_RESERVE, __CEPH_OSD_OP1(SUB, 6), "scrub-reserve") \
299 f(SCRUB_UNRESERVE, __CEPH_OSD_OP1(SUB, 7), "scrub-unreserve") \
300 f(SCRUB_STOP, __CEPH_OSD_OP1(SUB, 8), "scrub-stop") \
301 f(SCRUB_MAP, __CEPH_OSD_OP1(SUB, 9), "scrub-map") \
302 \
303 \
304 f(WRLOCK, __CEPH_OSD_OP(WR, LOCK, 1), "wrlock") \
305 f(WRUNLOCK, __CEPH_OSD_OP(WR, LOCK, 2), "wrunlock") \
306 f(RDLOCK, __CEPH_OSD_OP(WR, LOCK, 3), "rdlock") \
307 f(RDUNLOCK, __CEPH_OSD_OP(WR, LOCK, 4), "rdunlock") \
308 f(UPLOCK, __CEPH_OSD_OP(WR, LOCK, 5), "uplock") \
309 f(DNLOCK, __CEPH_OSD_OP(WR, LOCK, 6), "dnlock") \
310 \
311 \
312 \
313 f(CALL, __CEPH_OSD_OP(RD, EXEC, 1), "call") \
314 \
315 \
316 f(PGLS, __CEPH_OSD_OP(RD, PG, 1), "pgls") \
317 f(PGLS_FILTER, __CEPH_OSD_OP(RD, PG, 2), "pgls-filter") \
318 f(PG_HITSET_LS, __CEPH_OSD_OP(RD, PG, 3), "pg-hitset-ls") \
319 f(PG_HITSET_GET, __CEPH_OSD_OP(RD, PG, 4), "pg-hitset-get")
320
321 enum {
322 #define GENERATE_ENUM_ENTRY(op, opcode, str) CEPH_OSD_OP_##op = (opcode),
323 __CEPH_FORALL_OSD_OPS(GENERATE_ENUM_ENTRY)
324 #undef GENERATE_ENUM_ENTRY
325 };
326
327 static inline int ceph_osd_op_type_lock(int op)
328 {
329 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_LOCK;
330 }
331 static inline int ceph_osd_op_type_data(int op)
332 {
333 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_DATA;
334 }
335 static inline int ceph_osd_op_type_attr(int op)
336 {
337 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_ATTR;
338 }
339 static inline int ceph_osd_op_type_exec(int op)
340 {
341 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_EXEC;
342 }
343 static inline int ceph_osd_op_type_pg(int op)
344 {
345 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_PG;
346 }
347 static inline int ceph_osd_op_type_multi(int op)
348 {
349 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_MULTI;
350 }
351
352 static inline int ceph_osd_op_mode_subop(int op)
353 {
354 return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_SUB;
355 }
356 static inline int ceph_osd_op_mode_read(int op)
357 {
358 return (op & CEPH_OSD_OP_MODE_RD) &&
359 op != CEPH_OSD_OP_CALL;
360 }
361 static inline int ceph_osd_op_mode_modify(int op)
362 {
363 return op & CEPH_OSD_OP_MODE_WR;
364 }
365
366
367
368
369
370 #define CEPH_OSD_TMAP_HDR 'h'
371 #define CEPH_OSD_TMAP_SET 's'
372 #define CEPH_OSD_TMAP_CREATE 'c'
373 #define CEPH_OSD_TMAP_RM 'r'
374 #define CEPH_OSD_TMAP_RMSLOPPY 'R'
375
376 extern const char *ceph_osd_op_name(int op);
377
378
379
380
381
382
383 enum {
384 CEPH_OSD_FLAG_ACK = 0x0001,
385 CEPH_OSD_FLAG_ONNVRAM = 0x0002,
386 CEPH_OSD_FLAG_ONDISK = 0x0004,
387 CEPH_OSD_FLAG_RETRY = 0x0008,
388 CEPH_OSD_FLAG_READ = 0x0010,
389 CEPH_OSD_FLAG_WRITE = 0x0020,
390 CEPH_OSD_FLAG_ORDERSNAP = 0x0040,
391 CEPH_OSD_FLAG_PEERSTAT_OLD = 0x0080,
392 CEPH_OSD_FLAG_BALANCE_READS = 0x0100,
393 CEPH_OSD_FLAG_PARALLELEXEC = 0x0200,
394 CEPH_OSD_FLAG_PGOP = 0x0400,
395 CEPH_OSD_FLAG_EXEC = 0x0800,
396 CEPH_OSD_FLAG_EXEC_PUBLIC = 0x1000,
397 CEPH_OSD_FLAG_LOCALIZE_READS = 0x2000,
398 CEPH_OSD_FLAG_RWORDERED = 0x4000,
399 CEPH_OSD_FLAG_IGNORE_CACHE = 0x8000,
400 CEPH_OSD_FLAG_SKIPRWLOCKS = 0x10000,
401 CEPH_OSD_FLAG_IGNORE_OVERLAY = 0x20000,
402 CEPH_OSD_FLAG_FLUSH = 0x40000,
403 CEPH_OSD_FLAG_MAP_SNAP_CLONE = 0x80000,
404 CEPH_OSD_FLAG_ENFORCE_SNAPC = 0x100000,
405
406 CEPH_OSD_FLAG_REDIRECTED = 0x200000,
407 CEPH_OSD_FLAG_KNOWN_REDIR = 0x400000,
408 CEPH_OSD_FLAG_FULL_TRY = 0x800000,
409 CEPH_OSD_FLAG_FULL_FORCE = 0x1000000,
410 };
411
412 enum {
413 CEPH_OSD_OP_FLAG_EXCL = 1,
414 CEPH_OSD_OP_FLAG_FAILOK = 2,
415 CEPH_OSD_OP_FLAG_FADVISE_RANDOM = 0x4,
416 CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL = 0x8,
417 CEPH_OSD_OP_FLAG_FADVISE_WILLNEED = 0x10,
418
419 CEPH_OSD_OP_FLAG_FADVISE_DONTNEED = 0x20,
420
421 CEPH_OSD_OP_FLAG_FADVISE_NOCACHE = 0x40,
422
423 };
424
425 #define EOLDSNAPC ERESTART
426 #define EBLACKLISTED ESHUTDOWN
427
428
429 enum {
430 CEPH_OSD_CMPXATTR_OP_NOP = 0,
431 CEPH_OSD_CMPXATTR_OP_EQ = 1,
432 CEPH_OSD_CMPXATTR_OP_NE = 2,
433 CEPH_OSD_CMPXATTR_OP_GT = 3,
434 CEPH_OSD_CMPXATTR_OP_GTE = 4,
435 CEPH_OSD_CMPXATTR_OP_LT = 5,
436 CEPH_OSD_CMPXATTR_OP_LTE = 6
437 };
438
439 enum {
440 CEPH_OSD_CMPXATTR_MODE_STRING = 1,
441 CEPH_OSD_CMPXATTR_MODE_U64 = 2
442 };
443
444 enum {
445 CEPH_OSD_COPY_FROM_FLAG_FLUSH = 1,
446 CEPH_OSD_COPY_FROM_FLAG_IGNORE_OVERLAY = 2,
447 CEPH_OSD_COPY_FROM_FLAG_IGNORE_CACHE = 4,
448 CEPH_OSD_COPY_FROM_FLAG_MAP_SNAP_CLONE = 8,
449
450 CEPH_OSD_COPY_FROM_FLAG_RWORDERED = 16,
451 };
452
453 enum {
454 CEPH_OSD_WATCH_OP_UNWATCH = 0,
455 CEPH_OSD_WATCH_OP_LEGACY_WATCH = 1,
456
457
458 CEPH_OSD_WATCH_OP_WATCH = 3,
459 CEPH_OSD_WATCH_OP_RECONNECT = 5,
460 CEPH_OSD_WATCH_OP_PING = 7,
461 };
462
463 const char *ceph_osd_watch_op_name(int o);
464
465 enum {
466 CEPH_OSD_BACKOFF_OP_BLOCK = 1,
467 CEPH_OSD_BACKOFF_OP_ACK_BLOCK = 2,
468 CEPH_OSD_BACKOFF_OP_UNBLOCK = 3,
469 };
470
471
472
473
474
475 struct ceph_osd_op {
476 __le16 op;
477 __le32 flags;
478 union {
479 struct {
480 __le64 offset, length;
481 __le64 truncate_size;
482 __le32 truncate_seq;
483 } __attribute__ ((packed)) extent;
484 struct {
485 __le32 name_len;
486 __le32 value_len;
487 __u8 cmp_op;
488 __u8 cmp_mode;
489 } __attribute__ ((packed)) xattr;
490 struct {
491 __u8 class_len;
492 __u8 method_len;
493 __u8 argc;
494 __le32 indata_len;
495 } __attribute__ ((packed)) cls;
496 struct {
497 __le64 cookie, count;
498 } __attribute__ ((packed)) pgls;
499 struct {
500 __le64 snapid;
501 } __attribute__ ((packed)) snap;
502 struct {
503 __le64 cookie;
504 __le64 ver;
505 __u8 op;
506 __le32 gen;
507 } __attribute__ ((packed)) watch;
508 struct {
509 __le64 cookie;
510 } __attribute__ ((packed)) notify;
511 struct {
512 __le64 offset, length;
513 __le64 src_offset;
514 } __attribute__ ((packed)) clonerange;
515 struct {
516 __le64 expected_object_size;
517 __le64 expected_write_size;
518 } __attribute__ ((packed)) alloc_hint;
519 struct {
520 __le64 snapid;
521 __le64 src_version;
522 __u8 flags;
523
524
525
526
527
528 __le32 src_fadvise_flags;
529 } __attribute__ ((packed)) copy_from;
530 };
531 __le32 payload_len;
532 } __attribute__ ((packed));
533
534
535 #endif