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