]> git.proxmox.com Git - ceph.git/blob - ceph/src/include/rados.h
53320d65410c619ac75152159737e2803a40ed7e
[ceph.git] / ceph / src / include / rados.h
1 #ifndef CEPH_RADOS_H
2 #define CEPH_RADOS_H
3
4 /*
5 * Data types for the Ceph distributed object storage layer RADOS
6 * (Reliable Autonomic Distributed Object Store).
7 */
8
9 #include <string.h>
10 #include "msgr.h"
11
12 /*
13 * fs id
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 * ino, object, etc.
27 */
28 typedef __le64 ceph_snapid_t;
29 #define CEPH_SNAPDIR ((__u64)(-1)) /* reserved for hidden .snap dir */
30 #define CEPH_NOSNAP ((__u64)(-2)) /* "head", "live" revision */
31 #define CEPH_MAXSNAP ((__u64)(-3)) /* largest valid snapid */
32
33 struct ceph_timespec {
34 __le32 tv_sec;
35 __le32 tv_nsec;
36 } __attribute__ ((packed));
37
38
39 /*
40 * object layout - how objects are mapped into PGs
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 * pg layout -- how PGs are mapped onto (sets of) OSDs
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 16 /* max # osds in a single pg */
55
56 /*
57 * placement group.
58 * we encode this into one __le64.
59 */
60 struct ceph_pg {
61 __le16 preferred; /* preferred primary osd */
62 __le16 ps; /* placement seed */
63 __le32 pool; /* object pool */
64 } __attribute__ ((packed));
65
66 /*
67 * pg pool types
68 *
69 * NOTE: These map 1:1 on to the pg_pool_t::TYPE_* values. They are
70 * duplicated here only for CrushCompiler's benefit.
71 */
72 #define CEPH_PG_TYPE_REPLICATED 1
73 /* #define CEPH_PG_TYPE_RAID4 2 never implemented */
74 #define CEPH_PG_TYPE_ERASURE 3
75
76 /*
77 * stable_mod func is used to control number of placement groups.
78 * similar to straight-up modulo, but produces a stable mapping as b
79 * increases over time. b is the number of bins, and bmask is the
80 * containing power of 2 minus 1.
81 *
82 * b <= bmask and bmask=(2**n)-1
83 * e.g., b=12 -> bmask=15, b=123 -> bmask=127
84 */
85 static inline int ceph_stable_mod(int x, int b, int bmask)
86 {
87 if ((x & bmask) < b)
88 return x & bmask;
89 else
90 return x & (bmask >> 1);
91 }
92
93 /*
94 * object layout - how a given object should be stored.
95 */
96 struct ceph_object_layout {
97 struct ceph_pg ol_pgid; /* raw pg, with _full_ ps precision. */
98 __le32 ol_stripe_unit; /* for per-object parity, if any */
99 } __attribute__ ((packed));
100
101 /*
102 * compound epoch+version, used by storage layer to serialize mutations
103 */
104 struct ceph_eversion {
105 __le32 epoch;
106 __le64 version;
107 } __attribute__ ((packed));
108
109 /*
110 * osd map bits
111 */
112
113 /* status bits */
114 #define CEPH_OSD_EXISTS (1<<0)
115 #define CEPH_OSD_UP (1<<1)
116 #define CEPH_OSD_AUTOOUT (1<<2) /* osd was automatically marked out */
117 #define CEPH_OSD_NEW (1<<3) /* osd is new, never marked in */
118 #define CEPH_OSD_FULL (1<<4) /* osd is at or above full threshold */
119 #define CEPH_OSD_NEARFULL (1<<5) /* osd is at or above nearfull threshold */
120 #define CEPH_OSD_BACKFILLFULL (1<<6) /* osd is at or above backfillfull threshold */
121 #define CEPH_OSD_DESTROYED (1<<7) /* osd has been destroyed */
122 #define CEPH_OSD_NOUP (1<<8) /* osd can not be marked up */
123 #define CEPH_OSD_NODOWN (1<<9) /* osd can not be marked down */
124 #define CEPH_OSD_NOIN (1<<10) /* osd can not be marked in */
125 #define CEPH_OSD_NOOUT (1<<11) /* osd can not be marked out */
126
127 extern const char *ceph_osd_state_name(int s);
128
129 /* osd weights. fixed point value: 0x10000 == 1.0 ("in"), 0 == "out" */
130 #define CEPH_OSD_IN 0x10000
131 #define CEPH_OSD_OUT 0
132
133 #define CEPH_OSD_MAX_PRIMARY_AFFINITY 0x10000
134 #define CEPH_OSD_DEFAULT_PRIMARY_AFFINITY 0x10000
135
136
137 /*
138 * osd map flag bits
139 */
140 #define CEPH_OSDMAP_NEARFULL (1<<0) /* sync writes (near ENOSPC) */
141 #define CEPH_OSDMAP_FULL (1<<1) /* no data writes (ENOSPC) */
142 #define CEPH_OSDMAP_PAUSERD (1<<2) /* pause all reads */
143 #define CEPH_OSDMAP_PAUSEWR (1<<3) /* pause all writes */
144 #define CEPH_OSDMAP_PAUSEREC (1<<4) /* pause recovery */
145 #define CEPH_OSDMAP_NOUP (1<<5) /* block osd boot */
146 #define CEPH_OSDMAP_NODOWN (1<<6) /* block osd mark-down/failure */
147 #define CEPH_OSDMAP_NOOUT (1<<7) /* block osd auto mark-out */
148 #define CEPH_OSDMAP_NOIN (1<<8) /* block osd auto mark-in */
149 #define CEPH_OSDMAP_NOBACKFILL (1<<9) /* block osd backfill */
150 #define CEPH_OSDMAP_NORECOVER (1<<10) /* block osd recovery and backfill */
151 #define CEPH_OSDMAP_NOSCRUB (1<<11) /* block periodic scrub */
152 #define CEPH_OSDMAP_NODEEP_SCRUB (1<<12) /* block periodic deep-scrub */
153 #define CEPH_OSDMAP_NOTIERAGENT (1<<13) /* disable tiering agent */
154 #define CEPH_OSDMAP_NOREBALANCE (1<<14) /* block osd backfill unless pg is degraded */
155 #define CEPH_OSDMAP_SORTBITWISE (1<<15) /* use bitwise hobject_t sort */
156 #define CEPH_OSDMAP_REQUIRE_JEWEL (1<<16) /* require jewel for booting osds */
157 #define CEPH_OSDMAP_REQUIRE_KRAKEN (1<<17) /* require kraken for booting osds */
158 #define CEPH_OSDMAP_REQUIRE_LUMINOUS (1<<18) /* require l for booting osds */
159 #define CEPH_OSDMAP_RECOVERY_DELETES (1<<19) /* deletes performed during recovery instead of peering */
160 #define CEPH_OSDMAP_PURGED_SNAPDIRS (1<<20) /* osds have converted snapsets */
161 #define CEPH_OSDMAP_NOSNAPTRIM (1<<21) /* disable snap trimming */
162 #define CEPH_OSDMAP_PGLOG_HARDLIMIT (1<<22) /* put a hard limit on pg log length */
163
164 /* these are hidden in 'ceph status' view */
165 #define CEPH_OSDMAP_SEMIHIDDEN_FLAGS (CEPH_OSDMAP_REQUIRE_JEWEL| \
166 CEPH_OSDMAP_REQUIRE_KRAKEN | \
167 CEPH_OSDMAP_REQUIRE_LUMINOUS | \
168 CEPH_OSDMAP_RECOVERY_DELETES | \
169 CEPH_OSDMAP_SORTBITWISE | \
170 CEPH_OSDMAP_PURGED_SNAPDIRS | \
171 CEPH_OSDMAP_PGLOG_HARDLIMIT)
172 #define CEPH_OSDMAP_LEGACY_REQUIRE_FLAGS (CEPH_OSDMAP_REQUIRE_JEWEL | \
173 CEPH_OSDMAP_REQUIRE_KRAKEN | \
174 CEPH_OSDMAP_REQUIRE_LUMINOUS)
175
176 /*
177 * major ceph release numbers
178 */
179 #define CEPH_RELEASE_ARGONAUT 1
180 #define CEPH_RELEASE_BOBTAIL 2
181 #define CEPH_RELEASE_CUTTLEFISH 3
182 #define CEPH_RELEASE_DUMPLING 4
183 #define CEPH_RELEASE_EMPEROR 5
184 #define CEPH_RELEASE_FIREFLY 6
185 #define CEPH_RELEASE_GIANT 7
186 #define CEPH_RELEASE_HAMMER 8
187 #define CEPH_RELEASE_INFERNALIS 9
188 #define CEPH_RELEASE_JEWEL 10
189 #define CEPH_RELEASE_KRAKEN 11
190 #define CEPH_RELEASE_LUMINOUS 12
191 #define CEPH_RELEASE_MIMIC 13
192 #define CEPH_RELEASE_NAUTILUS 14
193 #define CEPH_RELEASE_MAX 15 /* highest + 1 */
194
195 extern const char *ceph_release_name(int r);
196 extern int ceph_release_from_name(const char *s);
197 extern uint64_t ceph_release_features(int r);
198 extern int ceph_release_from_features(uint64_t features);
199
200 /*
201 * The error code to return when an OSD can't handle a write
202 * because it is too large.
203 */
204 #define OSD_WRITETOOBIG EMSGSIZE
205
206 /*
207 * osd ops
208 *
209 * WARNING: do not use these op codes directly. Use the helpers
210 * defined below instead. In certain cases, op code behavior was
211 * redefined, resulting in special-cases in the helpers.
212 */
213 #define CEPH_OSD_OP_MODE 0xf000
214 #define CEPH_OSD_OP_MODE_RD 0x1000
215 #define CEPH_OSD_OP_MODE_WR 0x2000
216 #define CEPH_OSD_OP_MODE_RMW 0x3000
217 #define CEPH_OSD_OP_MODE_SUB 0x4000
218 #define CEPH_OSD_OP_MODE_CACHE 0x8000
219
220 #define CEPH_OSD_OP_TYPE 0x0f00
221 #define CEPH_OSD_OP_TYPE_DATA 0x0200
222 #define CEPH_OSD_OP_TYPE_ATTR 0x0300
223 #define CEPH_OSD_OP_TYPE_EXEC 0x0400
224 #define CEPH_OSD_OP_TYPE_PG 0x0500
225 // LEAVE UNUSED 0x0600 used to be multiobject ops
226
227 #define __CEPH_OSD_OP1(mode, nr) \
228 (CEPH_OSD_OP_MODE_##mode | (nr))
229
230 #define __CEPH_OSD_OP(mode, type, nr) \
231 (CEPH_OSD_OP_MODE_##mode | CEPH_OSD_OP_TYPE_##type | (nr))
232
233 #define __CEPH_FORALL_OSD_OPS(f) \
234 /** data **/ \
235 /* read */ \
236 f(READ, __CEPH_OSD_OP(RD, DATA, 1), "read") \
237 f(STAT, __CEPH_OSD_OP(RD, DATA, 2), "stat") \
238 f(MAPEXT, __CEPH_OSD_OP(RD, DATA, 3), "mapext") \
239 f(CHECKSUM, __CEPH_OSD_OP(RD, DATA, 31), "checksum") \
240 \
241 /* fancy read */ \
242 f(MASKTRUNC, __CEPH_OSD_OP(RD, DATA, 4), "masktrunc") \
243 f(SPARSE_READ, __CEPH_OSD_OP(RD, DATA, 5), "sparse-read") \
244 \
245 f(NOTIFY, __CEPH_OSD_OP(RD, DATA, 6), "notify") \
246 f(NOTIFY_ACK, __CEPH_OSD_OP(RD, DATA, 7), "notify-ack") \
247 \
248 /* versioning */ \
249 f(ASSERT_VER, __CEPH_OSD_OP(RD, DATA, 8), "assert-version") \
250 \
251 f(LIST_WATCHERS, __CEPH_OSD_OP(RD, DATA, 9), "list-watchers") \
252 \
253 f(LIST_SNAPS, __CEPH_OSD_OP(RD, DATA, 10), "list-snaps") \
254 \
255 /* sync */ \
256 f(SYNC_READ, __CEPH_OSD_OP(RD, DATA, 11), "sync_read") \
257 \
258 /* write */ \
259 f(WRITE, __CEPH_OSD_OP(WR, DATA, 1), "write") \
260 f(WRITEFULL, __CEPH_OSD_OP(WR, DATA, 2), "writefull") \
261 f(TRUNCATE, __CEPH_OSD_OP(WR, DATA, 3), "truncate") \
262 f(ZERO, __CEPH_OSD_OP(WR, DATA, 4), "zero") \
263 f(DELETE, __CEPH_OSD_OP(WR, DATA, 5), "delete") \
264 \
265 /* fancy write */ \
266 f(APPEND, __CEPH_OSD_OP(WR, DATA, 6), "append") \
267 f(STARTSYNC, __CEPH_OSD_OP(WR, DATA, 7), "startsync") \
268 f(SETTRUNC, __CEPH_OSD_OP(WR, DATA, 8), "settrunc") \
269 f(TRIMTRUNC, __CEPH_OSD_OP(WR, DATA, 9), "trimtrunc") \
270 \
271 f(TMAPUP, __CEPH_OSD_OP(RMW, DATA, 10), "tmapup") \
272 f(TMAPPUT, __CEPH_OSD_OP(WR, DATA, 11), "tmapput") \
273 f(TMAPGET, __CEPH_OSD_OP(RD, DATA, 12), "tmapget") \
274 \
275 f(CREATE, __CEPH_OSD_OP(WR, DATA, 13), "create") \
276 f(ROLLBACK, __CEPH_OSD_OP(WR, DATA, 14), "rollback") \
277 \
278 f(WATCH, __CEPH_OSD_OP(WR, DATA, 15), "watch") \
279 \
280 /* omap */ \
281 f(OMAPGETKEYS, __CEPH_OSD_OP(RD, DATA, 17), "omap-get-keys") \
282 f(OMAPGETVALS, __CEPH_OSD_OP(RD, DATA, 18), "omap-get-vals") \
283 f(OMAPGETHEADER, __CEPH_OSD_OP(RD, DATA, 19), "omap-get-header") \
284 f(OMAPGETVALSBYKEYS, __CEPH_OSD_OP(RD, DATA, 20), "omap-get-vals-by-keys") \
285 f(OMAPSETVALS, __CEPH_OSD_OP(WR, DATA, 21), "omap-set-vals") \
286 f(OMAPSETHEADER, __CEPH_OSD_OP(WR, DATA, 22), "omap-set-header") \
287 f(OMAPCLEAR, __CEPH_OSD_OP(WR, DATA, 23), "omap-clear") \
288 f(OMAPRMKEYS, __CEPH_OSD_OP(WR, DATA, 24), "omap-rm-keys") \
289 f(OMAP_CMP, __CEPH_OSD_OP(RD, DATA, 25), "omap-cmp") \
290 \
291 /* tiering */ \
292 f(COPY_FROM, __CEPH_OSD_OP(WR, DATA, 26), "copy-from") \
293 /* was copy-get-classic */ \
294 f(UNDIRTY, __CEPH_OSD_OP(WR, DATA, 28), "undirty") \
295 f(ISDIRTY, __CEPH_OSD_OP(RD, DATA, 29), "isdirty") \
296 f(COPY_GET, __CEPH_OSD_OP(RD, DATA, 30), "copy-get") \
297 f(CACHE_FLUSH, __CEPH_OSD_OP(CACHE, DATA, 31), "cache-flush") \
298 f(CACHE_EVICT, __CEPH_OSD_OP(CACHE, DATA, 32), "cache-evict") \
299 f(CACHE_TRY_FLUSH, __CEPH_OSD_OP(CACHE, DATA, 33), "cache-try-flush") \
300 \
301 /* convert tmap to omap */ \
302 f(TMAP2OMAP, __CEPH_OSD_OP(RMW, DATA, 34), "tmap2omap") \
303 \
304 /* hints */ \
305 f(SETALLOCHINT, __CEPH_OSD_OP(WR, DATA, 35), "set-alloc-hint") \
306 \
307 /* cache pin/unpin */ \
308 f(CACHE_PIN, __CEPH_OSD_OP(WR, DATA, 36), "cache-pin") \
309 f(CACHE_UNPIN, __CEPH_OSD_OP(WR, DATA, 37), "cache-unpin") \
310 \
311 /* ESX/SCSI */ \
312 f(WRITESAME, __CEPH_OSD_OP(WR, DATA, 38), "write-same") \
313 f(CMPEXT, __CEPH_OSD_OP(RD, DATA, 32), "cmpext") \
314 \
315 /* Extensible */ \
316 f(SET_REDIRECT, __CEPH_OSD_OP(WR, DATA, 39), "set-redirect") \
317 f(SET_CHUNK, __CEPH_OSD_OP(WR, DATA, 40), "set-chunk") \
318 f(TIER_PROMOTE, __CEPH_OSD_OP(WR, DATA, 41), "tier-promote") \
319 f(UNSET_MANIFEST, __CEPH_OSD_OP(WR, DATA, 42), "unset-manifest") \
320 \
321 /** attrs **/ \
322 /* read */ \
323 f(GETXATTR, __CEPH_OSD_OP(RD, ATTR, 1), "getxattr") \
324 f(GETXATTRS, __CEPH_OSD_OP(RD, ATTR, 2), "getxattrs") \
325 f(CMPXATTR, __CEPH_OSD_OP(RD, ATTR, 3), "cmpxattr") \
326 \
327 /* write */ \
328 f(SETXATTR, __CEPH_OSD_OP(WR, ATTR, 1), "setxattr") \
329 f(SETXATTRS, __CEPH_OSD_OP(WR, ATTR, 2), "setxattrs") \
330 f(RESETXATTRS, __CEPH_OSD_OP(WR, ATTR, 3), "resetxattrs") \
331 f(RMXATTR, __CEPH_OSD_OP(WR, ATTR, 4), "rmxattr") \
332 \
333 /** subop **/ \
334 f(PULL, __CEPH_OSD_OP1(SUB, 1), "pull") \
335 f(PUSH, __CEPH_OSD_OP1(SUB, 2), "push") \
336 f(BALANCEREADS, __CEPH_OSD_OP1(SUB, 3), "balance-reads") \
337 f(UNBALANCEREADS, __CEPH_OSD_OP1(SUB, 4), "unbalance-reads") \
338 f(SCRUB, __CEPH_OSD_OP1(SUB, 5), "scrub") \
339 f(SCRUB_RESERVE, __CEPH_OSD_OP1(SUB, 6), "scrub-reserve") \
340 f(SCRUB_UNRESERVE, __CEPH_OSD_OP1(SUB, 7), "scrub-unreserve") \
341 /* 8 used to be scrub-stop */ \
342 f(SCRUB_MAP, __CEPH_OSD_OP1(SUB, 9), "scrub-map") \
343 \
344 /** exec **/ \
345 /* note: the RD bit here is wrong; see special-case below in helper */ \
346 f(CALL, __CEPH_OSD_OP(RD, EXEC, 1), "call") \
347 \
348 /** pg **/ \
349 f(PGLS, __CEPH_OSD_OP(RD, PG, 1), "pgls") \
350 f(PGLS_FILTER, __CEPH_OSD_OP(RD, PG, 2), "pgls-filter") \
351 f(PG_HITSET_LS, __CEPH_OSD_OP(RD, PG, 3), "pg-hitset-ls") \
352 f(PG_HITSET_GET, __CEPH_OSD_OP(RD, PG, 4), "pg-hitset-get") \
353 f(PGNLS, __CEPH_OSD_OP(RD, PG, 5), "pgnls") \
354 f(PGNLS_FILTER, __CEPH_OSD_OP(RD, PG, 6), "pgnls-filter") \
355 f(SCRUBLS, __CEPH_OSD_OP(RD, PG, 7), "scrubls")
356
357 enum {
358 #define GENERATE_ENUM_ENTRY(op, opcode, str) CEPH_OSD_OP_##op = (opcode),
359 __CEPH_FORALL_OSD_OPS(GENERATE_ENUM_ENTRY)
360 #undef GENERATE_ENUM_ENTRY
361 };
362
363 static inline int ceph_osd_op_type_data(int op)
364 {
365 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_DATA;
366 }
367 static inline int ceph_osd_op_type_attr(int op)
368 {
369 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_ATTR;
370 }
371 static inline int ceph_osd_op_type_exec(int op)
372 {
373 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_EXEC;
374 }
375 static inline int ceph_osd_op_type_pg(int op)
376 {
377 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_PG;
378 }
379
380 static inline int ceph_osd_op_mode_subop(int op)
381 {
382 return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_SUB;
383 }
384 static inline int ceph_osd_op_mode_read(int op)
385 {
386 return (op & CEPH_OSD_OP_MODE_RD) &&
387 op != CEPH_OSD_OP_CALL;
388 }
389 static inline int ceph_osd_op_mode_modify(int op)
390 {
391 return op & CEPH_OSD_OP_MODE_WR;
392 }
393 static inline int ceph_osd_op_mode_cache(int op)
394 {
395 return op & CEPH_OSD_OP_MODE_CACHE;
396 }
397 static inline int ceph_osd_op_uses_extent(int op)
398 {
399 switch(op) {
400 case CEPH_OSD_OP_READ:
401 case CEPH_OSD_OP_MAPEXT:
402 case CEPH_OSD_OP_MASKTRUNC:
403 case CEPH_OSD_OP_SPARSE_READ:
404 case CEPH_OSD_OP_SYNC_READ:
405 case CEPH_OSD_OP_WRITE:
406 case CEPH_OSD_OP_WRITEFULL:
407 case CEPH_OSD_OP_TRUNCATE:
408 case CEPH_OSD_OP_ZERO:
409 case CEPH_OSD_OP_APPEND:
410 case CEPH_OSD_OP_TRIMTRUNC:
411 case CEPH_OSD_OP_CMPEXT:
412 return true;
413 default:
414 return false;
415 }
416 }
417
418 /*
419 * note that the following tmap stuff is also defined in the ceph librados.h
420 * and objclass.h. Any modification here needs to be updated there
421 */
422 #define CEPH_OSD_TMAP_HDR 'h'
423 #define CEPH_OSD_TMAP_SET 's'
424 #define CEPH_OSD_TMAP_CREATE 'c' /* create key */
425 #define CEPH_OSD_TMAP_RM 'r'
426 #define CEPH_OSD_TMAP_RMSLOPPY 'R'
427
428 extern const char *ceph_osd_op_name(int op);
429
430 /*
431 * osd op flags
432 *
433 * An op may be READ, WRITE, or READ|WRITE.
434 */
435 enum {
436 CEPH_OSD_FLAG_ACK = 0x0001, /* want (or is) "ack" ack */
437 CEPH_OSD_FLAG_ONNVRAM = 0x0002, /* want (or is) "onnvram" ack */
438 CEPH_OSD_FLAG_ONDISK = 0x0004, /* want (or is) "ondisk" ack */
439 CEPH_OSD_FLAG_RETRY = 0x0008, /* resend attempt */
440 CEPH_OSD_FLAG_READ = 0x0010, /* op may read */
441 CEPH_OSD_FLAG_WRITE = 0x0020, /* op may write */
442 CEPH_OSD_FLAG_ORDERSNAP = 0x0040, /* EOLDSNAP if snapc is out of order */
443 CEPH_OSD_FLAG_PEERSTAT_OLD = 0x0080, /* DEPRECATED msg includes osd_peer_stat */
444 CEPH_OSD_FLAG_BALANCE_READS = 0x0100,
445 CEPH_OSD_FLAG_PARALLELEXEC = 0x0200, /* execute op in parallel */
446 CEPH_OSD_FLAG_PGOP = 0x0400, /* pg op, no object */
447 CEPH_OSD_FLAG_EXEC = 0x0800, /* op may exec */
448 CEPH_OSD_FLAG_EXEC_PUBLIC = 0x1000, /* DEPRECATED op may exec (public) */
449 CEPH_OSD_FLAG_LOCALIZE_READS = 0x2000, /* read from nearby replica, if any */
450 CEPH_OSD_FLAG_RWORDERED = 0x4000, /* order wrt concurrent reads */
451 CEPH_OSD_FLAG_IGNORE_CACHE = 0x8000, /* ignore cache logic */
452 CEPH_OSD_FLAG_SKIPRWLOCKS = 0x10000, /* skip rw locks */
453 CEPH_OSD_FLAG_IGNORE_OVERLAY =0x20000, /* ignore pool overlay */
454 CEPH_OSD_FLAG_FLUSH = 0x40000, /* this is part of flush */
455 CEPH_OSD_FLAG_MAP_SNAP_CLONE =0x80000, /* map snap direct to clone id
456 */
457 CEPH_OSD_FLAG_ENFORCE_SNAPC =0x100000, /* use snapc provided even if
458 pool uses pool snaps */
459 CEPH_OSD_FLAG_REDIRECTED = 0x200000, /* op has been redirected */
460 CEPH_OSD_FLAG_KNOWN_REDIR = 0x400000, /* redirect bit is authoritative */
461 CEPH_OSD_FLAG_FULL_TRY = 0x800000, /* try op despite full flag */
462 CEPH_OSD_FLAG_FULL_FORCE = 0x1000000, /* force op despite full flag */
463 CEPH_OSD_FLAG_IGNORE_REDIRECT = 0x2000000, /* ignore redirection */
464 };
465
466 enum {
467 CEPH_OSD_OP_FLAG_EXCL = 0x1, /* EXCL object create */
468 CEPH_OSD_OP_FLAG_FAILOK = 0x2, /* continue despite failure */
469 CEPH_OSD_OP_FLAG_FADVISE_RANDOM = 0x4, /* the op is random */
470 CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL = 0x8, /* the op is sequential */
471 CEPH_OSD_OP_FLAG_FADVISE_WILLNEED = 0x10,/* data will be accessed in the near future */
472 CEPH_OSD_OP_FLAG_FADVISE_DONTNEED = 0x20,/* data will not be accessed in the near future */
473 CEPH_OSD_OP_FLAG_FADVISE_NOCACHE = 0x40, /* data will be accessed only once by this client */
474 CEPH_OSD_OP_FLAG_WITH_REFERENCE = 0x80, /* need reference couting */
475 CEPH_OSD_OP_FLAG_BYPASS_CLEAN_CACHE = 0x100, /* bypass ObjectStore cache, mainly for deep-scrub */
476 };
477
478 #define EOLDSNAPC 85 /* ORDERSNAP flag set; writer has old snapc*/
479 #define EBLACKLISTED 108 /* blacklisted */
480
481 /* xattr comparison */
482 enum {
483 CEPH_OSD_CMPXATTR_OP_EQ = 1,
484 CEPH_OSD_CMPXATTR_OP_NE = 2,
485 CEPH_OSD_CMPXATTR_OP_GT = 3,
486 CEPH_OSD_CMPXATTR_OP_GTE = 4,
487 CEPH_OSD_CMPXATTR_OP_LT = 5,
488 CEPH_OSD_CMPXATTR_OP_LTE = 6
489 };
490
491 enum {
492 CEPH_OSD_CMPXATTR_MODE_STRING = 1,
493 CEPH_OSD_CMPXATTR_MODE_U64 = 2
494 };
495
496 enum {
497 CEPH_OSD_COPY_FROM_FLAG_FLUSH = 1, /* part of a flush operation */
498 CEPH_OSD_COPY_FROM_FLAG_IGNORE_OVERLAY = 2, /* ignore pool overlay */
499 CEPH_OSD_COPY_FROM_FLAG_IGNORE_CACHE = 4, /* ignore osd cache logic */
500 CEPH_OSD_COPY_FROM_FLAG_MAP_SNAP_CLONE = 8, /* map snap direct to
501 * cloneid */
502 CEPH_OSD_COPY_FROM_FLAG_RWORDERED = 16, /* order with write */
503 };
504
505 enum {
506 CEPH_OSD_TMAP2OMAP_NULLOK = 1,
507 };
508
509 enum {
510 CEPH_OSD_WATCH_OP_UNWATCH = 0,
511 CEPH_OSD_WATCH_OP_LEGACY_WATCH = 1,
512 /* note: use only ODD ids to prevent pre-giant code from
513 interpreting the op as UNWATCH */
514 CEPH_OSD_WATCH_OP_WATCH = 3,
515 CEPH_OSD_WATCH_OP_RECONNECT = 5,
516 CEPH_OSD_WATCH_OP_PING = 7,
517 };
518
519 enum {
520 CEPH_OSD_CHECKSUM_OP_TYPE_XXHASH32 = 0,
521 CEPH_OSD_CHECKSUM_OP_TYPE_XXHASH64 = 1,
522 CEPH_OSD_CHECKSUM_OP_TYPE_CRC32C = 2
523 };
524
525 const char *ceph_osd_watch_op_name(int o);
526
527 enum {
528 CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_WRITE = 1,
529 CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_WRITE = 2,
530 CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_READ = 4,
531 CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_READ = 8,
532 CEPH_OSD_ALLOC_HINT_FLAG_APPEND_ONLY = 16,
533 CEPH_OSD_ALLOC_HINT_FLAG_IMMUTABLE = 32,
534 CEPH_OSD_ALLOC_HINT_FLAG_SHORTLIVED = 64,
535 CEPH_OSD_ALLOC_HINT_FLAG_LONGLIVED = 128,
536 CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE = 256,
537 CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE = 512,
538 };
539
540 const char *ceph_osd_alloc_hint_flag_name(int f);
541
542 enum {
543 CEPH_OSD_BACKOFF_OP_BLOCK = 1,
544 CEPH_OSD_BACKOFF_OP_ACK_BLOCK = 2,
545 CEPH_OSD_BACKOFF_OP_UNBLOCK = 3,
546 };
547
548 const char *ceph_osd_backoff_op_name(int op);
549
550 /*
551 * an individual object operation. each may be accompanied by some data
552 * payload
553 */
554 struct ceph_osd_op {
555 __le16 op; /* CEPH_OSD_OP_* */
556 __le32 flags; /* CEPH_OSD_OP_FLAG_* */
557 union {
558 struct {
559 __le64 offset, length;
560 __le64 truncate_size;
561 __le32 truncate_seq;
562 } __attribute__ ((packed)) extent;
563 struct {
564 __le32 name_len;
565 __le32 value_len;
566 __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */
567 __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */
568 } __attribute__ ((packed)) xattr;
569 struct {
570 __u8 class_len;
571 __u8 method_len;
572 __u8 argc;
573 __le32 indata_len;
574 } __attribute__ ((packed)) cls;
575 struct {
576 __le64 count;
577 __le32 start_epoch; /* for the pgls sequence */
578 } __attribute__ ((packed)) pgls;
579 struct {
580 __le64 snapid;
581 } __attribute__ ((packed)) snap;
582 struct {
583 __le64 cookie;
584 __le64 ver; /* no longer used */
585 __u8 op; /* CEPH_OSD_WATCH_OP_* */
586 __u32 gen; /* registration generation */
587 __u32 timeout; /* connection timeout */
588 } __attribute__ ((packed)) watch;
589 struct {
590 __le64 cookie;
591 } __attribute__ ((packed)) notify;
592 struct {
593 __le64 unused;
594 __le64 ver;
595 } __attribute__ ((packed)) assert_ver;
596 struct {
597 __le64 offset, length;
598 __le64 src_offset;
599 } __attribute__ ((packed)) clonerange;
600 struct {
601 __le64 max; /* max data in reply */
602 } __attribute__ ((packed)) copy_get;
603 struct {
604 __le64 snapid;
605 __le64 src_version;
606 __u8 flags; /* CEPH_OSD_COPY_FROM_FLAG_* */
607 /*
608 * CEPH_OSD_OP_FLAG_FADVISE_*: fadvise flags
609 * for src object, flags for dest object are in
610 * ceph_osd_op::flags.
611 */
612 __le32 src_fadvise_flags;
613 } __attribute__ ((packed)) copy_from;
614 struct {
615 struct ceph_timespec stamp;
616 } __attribute__ ((packed)) hit_set_get;
617 struct {
618 __u8 flags;
619 } __attribute__ ((packed)) tmap2omap;
620 struct {
621 __le64 expected_object_size;
622 __le64 expected_write_size;
623 __le32 flags; /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
624 } __attribute__ ((packed)) alloc_hint;
625 struct {
626 __le64 offset;
627 __le64 length;
628 __le64 data_length;
629 } __attribute__ ((packed)) writesame;
630 struct {
631 __le64 offset;
632 __le64 length;
633 __le32 chunk_size;
634 __u8 type; /* CEPH_OSD_CHECKSUM_OP_TYPE_* */
635 } __attribute__ ((packed)) checksum;
636 };
637 __le32 payload_len;
638 } __attribute__ ((packed));
639
640 /*
641 * Check the compatibility of struct ceph_osd_op
642 * (2+4+(2*8+8+4)+4) = (sizeof(ceph_osd_op::op) +
643 * sizeof(ceph_osd_op::flags) +
644 * sizeof(ceph_osd_op::extent) +
645 * sizeof(ceph_osd_op::payload_len))
646 */
647 #ifdef __cplusplus
648 static_assert(sizeof(ceph_osd_op) == (2+4+(2*8+8+4)+4),
649 "sizeof(ceph_osd_op) breaks the compatibility");
650 #endif
651
652 struct ceph_osd_reply_head {
653 __le32 client_inc; /* client incarnation */
654 __le32 flags;
655 struct ceph_object_layout layout;
656 __le32 osdmap_epoch;
657 struct ceph_eversion reassert_version; /* for replaying uncommitted */
658
659 __le32 result; /* result code */
660
661 __le32 object_len; /* length of object name */
662 __le32 num_ops;
663 struct ceph_osd_op ops[0]; /* ops[], object */
664 } __attribute__ ((packed));
665
666
667 #endif