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