blob: 5c0da61cb763124c651e3287f4ecaf69f8cdfbc8 [file] [log] [blame]
Sage Weil5cd068c2010-07-07 08:38:17 -07001#ifndef CEPH_RADOS_H
2#define CEPH_RADOS_H
Sage Weil0dee3c22009-10-06 11:31:06 -07003
4/*
5 * Data types for the Ceph distributed object storage layer RADOS
6 * (Reliable Autonomic Distributed Object Store).
7 */
8
David Howellsa1ce3922012-10-02 18:01:25 +01009#include <linux/ceph/msgr.h>
Sage Weil0dee3c22009-10-06 11:31:06 -070010
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
Sage Weild85b7052010-05-10 10:24:48 -070053#define CEPH_PG_MAX_SIZE 16 /* max # osds in a single pg */
Sage Weil0dee3c22009-10-06 11:31:06 -070054
55/*
56 * placement group.
57 * we encode this into one __le64.
58 */
Sage Weil129793542013-01-08 09:15:10 -080059struct ceph_pg_v1 {
Sage Weil51042122009-11-04 11:39:12 -080060 __le16 preferred; /* preferred primary osd */
61 __le16 ps; /* placement seed */
62 __le32 pool; /* object pool */
Sage Weil0dee3c22009-10-06 11:31:06 -070063} __attribute__ ((packed));
64
65/*
66 * pg_pool is a set of pgs storing a pool of objects
67 *
68 * pg_num -- base number of pseudorandomly placed pgs
69 *
70 * pgp_num -- effective number when calculating pg placement. this
71 * is used for pg_num increases. new pgs result in data being "split"
72 * into new pgs. for this to proceed smoothly, new pgs are intiially
73 * colocated with their parents; that is, pgp_num doesn't increase
74 * until the new pgs have successfully split. only _then_ are the new
75 * pgs placed independently.
76 *
77 * lpg_num -- localized pg count (per device). replicas are randomly
78 * selected.
79 *
80 * lpgp_num -- as above.
81 */
Alex Elder86b00e02012-10-25 23:34:42 -050082#define CEPH_NOPOOL ((__u64) (-1)) /* pool id not defined */
83
Ilya Dryomov2abebdb2014-03-24 17:12:47 +020084#define CEPH_POOL_TYPE_REP 1
85#define CEPH_POOL_TYPE_RAID4 2 /* never implemented */
86#define CEPH_POOL_TYPE_EC 3
Sage Weil0dee3c22009-10-06 11:31:06 -070087
88/*
89 * stable_mod func is used to control number of placement groups.
90 * similar to straight-up modulo, but produces a stable mapping as b
91 * increases over time. b is the number of bins, and bmask is the
92 * containing power of 2 minus 1.
93 *
94 * b <= bmask and bmask=(2**n)-1
95 * e.g., b=12 -> bmask=15, b=123 -> bmask=127
96 */
97static inline int ceph_stable_mod(int x, int b, int bmask)
98{
99 if ((x & bmask) < b)
100 return x & bmask;
101 else
102 return x & (bmask >> 1);
103}
104
105/*
106 * object layout - how a given object should be stored.
107 */
108struct ceph_object_layout {
Sage Weil129793542013-01-08 09:15:10 -0800109 struct ceph_pg_v1 ol_pgid; /* raw pg, with _full_ ps precision. */
Sage Weil0dee3c22009-10-06 11:31:06 -0700110 __le32 ol_stripe_unit; /* for per-object parity, if any */
111} __attribute__ ((packed));
112
113/*
114 * compound epoch+version, used by storage layer to serialize mutations
115 */
116struct ceph_eversion {
Sage Weil0dee3c22009-10-06 11:31:06 -0700117 __le64 version;
Ilya Dryomov985c1672016-04-28 16:07:22 +0200118 __le32 epoch;
Sage Weil0dee3c22009-10-06 11:31:06 -0700119} __attribute__ ((packed));
120
121/*
122 * osd map bits
123 */
124
125/* status bits */
Alex Elder0315a772013-02-15 11:42:30 -0600126#define CEPH_OSD_EXISTS (1<<0)
127#define CEPH_OSD_UP (1<<1)
128#define CEPH_OSD_AUTOOUT (1<<2) /* osd was automatically marked out */
129#define CEPH_OSD_NEW (1<<3) /* osd is new, never marked in */
Sage Weil0dee3c22009-10-06 11:31:06 -0700130
Alex Elder4b568b12013-02-15 11:42:30 -0600131extern const char *ceph_osd_state_name(int s);
132
Sage Weil0dee3c22009-10-06 11:31:06 -0700133/* osd weights. fixed point value: 0x10000 == 1.0 ("in"), 0 == "out" */
134#define CEPH_OSD_IN 0x10000
135#define CEPH_OSD_OUT 0
136
Ilya Dryomov2cfa34f2014-03-21 19:05:30 +0200137/* osd primary-affinity. fixed point value: 0x10000 == baseline */
138#define CEPH_OSD_MAX_PRIMARY_AFFINITY 0x10000
139#define CEPH_OSD_DEFAULT_PRIMARY_AFFINITY 0x10000
140
Sage Weil0dee3c22009-10-06 11:31:06 -0700141
142/*
143 * osd map flag bits
144 */
145#define CEPH_OSDMAP_NEARFULL (1<<0) /* sync writes (near ENOSPC) */
146#define CEPH_OSDMAP_FULL (1<<1) /* no data writes (ENOSPC) */
147#define CEPH_OSDMAP_PAUSERD (1<<2) /* pause all reads */
148#define CEPH_OSDMAP_PAUSEWR (1<<3) /* pause all writes */
149#define CEPH_OSDMAP_PAUSEREC (1<<4) /* pause recovery */
Alex Elder0315a772013-02-15 11:42:30 -0600150#define CEPH_OSDMAP_NOUP (1<<5) /* block osd boot */
151#define CEPH_OSDMAP_NODOWN (1<<6) /* block osd mark-down/failure */
152#define CEPH_OSDMAP_NOOUT (1<<7) /* block osd auto mark-out */
153#define CEPH_OSDMAP_NOIN (1<<8) /* block osd auto mark-in */
154#define CEPH_OSDMAP_NOBACKFILL (1<<9) /* block osd backfill */
155#define CEPH_OSDMAP_NORECOVER (1<<10) /* block osd recovery and backfill */
Ilya Dryomov63244fa2016-04-28 16:07:23 +0200156#define CEPH_OSDMAP_NOSCRUB (1<<11) /* block periodic scrub */
157#define CEPH_OSDMAP_NODEEP_SCRUB (1<<12) /* block periodic deep-scrub */
158#define CEPH_OSDMAP_NOTIERAGENT (1<<13) /* disable tiering agent */
159#define CEPH_OSDMAP_NOREBALANCE (1<<14) /* block osd backfill unless pg is degraded */
160#define CEPH_OSDMAP_SORTBITWISE (1<<15) /* use bitwise hobject_t sort */
Alex Elder0315a772013-02-15 11:42:30 -0600161
162/*
163 * The error code to return when an OSD can't handle a write
164 * because it is too large.
165 */
166#define OSD_WRITETOOBIG EMSGSIZE
Sage Weil0dee3c22009-10-06 11:31:06 -0700167
168/*
169 * osd ops
Alex Elder0315a772013-02-15 11:42:30 -0600170 *
171 * WARNING: do not use these op codes directly. Use the helpers
172 * defined below instead. In certain cases, op code behavior was
173 * redefined, resulting in special-cases in the helpers.
Sage Weil0dee3c22009-10-06 11:31:06 -0700174 */
175#define CEPH_OSD_OP_MODE 0xf000
176#define CEPH_OSD_OP_MODE_RD 0x1000
177#define CEPH_OSD_OP_MODE_WR 0x2000
178#define CEPH_OSD_OP_MODE_RMW 0x3000
179#define CEPH_OSD_OP_MODE_SUB 0x4000
Ilya Dryomov70b5bfa2014-10-02 17:22:29 +0400180#define CEPH_OSD_OP_MODE_CACHE 0x8000
Sage Weil0dee3c22009-10-06 11:31:06 -0700181
182#define CEPH_OSD_OP_TYPE 0x0f00
183#define CEPH_OSD_OP_TYPE_LOCK 0x0100
184#define CEPH_OSD_OP_TYPE_DATA 0x0200
185#define CEPH_OSD_OP_TYPE_ATTR 0x0300
186#define CEPH_OSD_OP_TYPE_EXEC 0x0400
187#define CEPH_OSD_OP_TYPE_PG 0x0500
Alex Elder0315a772013-02-15 11:42:30 -0600188#define CEPH_OSD_OP_TYPE_MULTI 0x0600 /* multiobject */
Sage Weil0dee3c22009-10-06 11:31:06 -0700189
Ilya Dryomov70b5bfa2014-10-02 17:22:29 +0400190#define __CEPH_OSD_OP1(mode, nr) \
191 (CEPH_OSD_OP_MODE_##mode | (nr))
192
193#define __CEPH_OSD_OP(mode, type, nr) \
194 (CEPH_OSD_OP_MODE_##mode | CEPH_OSD_OP_TYPE_##type | (nr))
195
196#define __CEPH_FORALL_OSD_OPS(f) \
197 /** data **/ \
198 /* read */ \
199 f(READ, __CEPH_OSD_OP(RD, DATA, 1), "read") \
200 f(STAT, __CEPH_OSD_OP(RD, DATA, 2), "stat") \
201 f(MAPEXT, __CEPH_OSD_OP(RD, DATA, 3), "mapext") \
202 \
203 /* fancy read */ \
204 f(MASKTRUNC, __CEPH_OSD_OP(RD, DATA, 4), "masktrunc") \
205 f(SPARSE_READ, __CEPH_OSD_OP(RD, DATA, 5), "sparse-read") \
206 \
207 f(NOTIFY, __CEPH_OSD_OP(RD, DATA, 6), "notify") \
208 f(NOTIFY_ACK, __CEPH_OSD_OP(RD, DATA, 7), "notify-ack") \
209 \
210 /* versioning */ \
211 f(ASSERT_VER, __CEPH_OSD_OP(RD, DATA, 8), "assert-version") \
212 \
213 f(LIST_WATCHERS, __CEPH_OSD_OP(RD, DATA, 9), "list-watchers") \
214 \
215 f(LIST_SNAPS, __CEPH_OSD_OP(RD, DATA, 10), "list-snaps") \
216 \
217 /* sync */ \
218 f(SYNC_READ, __CEPH_OSD_OP(RD, DATA, 11), "sync_read") \
219 \
220 /* write */ \
221 f(WRITE, __CEPH_OSD_OP(WR, DATA, 1), "write") \
222 f(WRITEFULL, __CEPH_OSD_OP(WR, DATA, 2), "writefull") \
223 f(TRUNCATE, __CEPH_OSD_OP(WR, DATA, 3), "truncate") \
224 f(ZERO, __CEPH_OSD_OP(WR, DATA, 4), "zero") \
225 f(DELETE, __CEPH_OSD_OP(WR, DATA, 5), "delete") \
226 \
227 /* fancy write */ \
228 f(APPEND, __CEPH_OSD_OP(WR, DATA, 6), "append") \
229 f(STARTSYNC, __CEPH_OSD_OP(WR, DATA, 7), "startsync") \
230 f(SETTRUNC, __CEPH_OSD_OP(WR, DATA, 8), "settrunc") \
231 f(TRIMTRUNC, __CEPH_OSD_OP(WR, DATA, 9), "trimtrunc") \
232 \
233 f(TMAPUP, __CEPH_OSD_OP(RMW, DATA, 10), "tmapup") \
234 f(TMAPPUT, __CEPH_OSD_OP(WR, DATA, 11), "tmapput") \
235 f(TMAPGET, __CEPH_OSD_OP(RD, DATA, 12), "tmapget") \
236 \
237 f(CREATE, __CEPH_OSD_OP(WR, DATA, 13), "create") \
238 f(ROLLBACK, __CEPH_OSD_OP(WR, DATA, 14), "rollback") \
239 \
240 f(WATCH, __CEPH_OSD_OP(WR, DATA, 15), "watch") \
241 \
242 /* omap */ \
243 f(OMAPGETKEYS, __CEPH_OSD_OP(RD, DATA, 17), "omap-get-keys") \
244 f(OMAPGETVALS, __CEPH_OSD_OP(RD, DATA, 18), "omap-get-vals") \
245 f(OMAPGETHEADER, __CEPH_OSD_OP(RD, DATA, 19), "omap-get-header") \
246 f(OMAPGETVALSBYKEYS, __CEPH_OSD_OP(RD, DATA, 20), "omap-get-vals-by-keys") \
247 f(OMAPSETVALS, __CEPH_OSD_OP(WR, DATA, 21), "omap-set-vals") \
248 f(OMAPSETHEADER, __CEPH_OSD_OP(WR, DATA, 22), "omap-set-header") \
249 f(OMAPCLEAR, __CEPH_OSD_OP(WR, DATA, 23), "omap-clear") \
250 f(OMAPRMKEYS, __CEPH_OSD_OP(WR, DATA, 24), "omap-rm-keys") \
251 f(OMAP_CMP, __CEPH_OSD_OP(RD, DATA, 25), "omap-cmp") \
252 \
253 /* tiering */ \
254 f(COPY_FROM, __CEPH_OSD_OP(WR, DATA, 26), "copy-from") \
255 f(COPY_GET_CLASSIC, __CEPH_OSD_OP(RD, DATA, 27), "copy-get-classic") \
256 f(UNDIRTY, __CEPH_OSD_OP(WR, DATA, 28), "undirty") \
257 f(ISDIRTY, __CEPH_OSD_OP(RD, DATA, 29), "isdirty") \
258 f(COPY_GET, __CEPH_OSD_OP(RD, DATA, 30), "copy-get") \
259 f(CACHE_FLUSH, __CEPH_OSD_OP(CACHE, DATA, 31), "cache-flush") \
260 f(CACHE_EVICT, __CEPH_OSD_OP(CACHE, DATA, 32), "cache-evict") \
261 f(CACHE_TRY_FLUSH, __CEPH_OSD_OP(CACHE, DATA, 33), "cache-try-flush") \
262 \
263 /* convert tmap to omap */ \
264 f(TMAP2OMAP, __CEPH_OSD_OP(RMW, DATA, 34), "tmap2omap") \
265 \
266 /* hints */ \
267 f(SETALLOCHINT, __CEPH_OSD_OP(WR, DATA, 35), "set-alloc-hint") \
268 \
269 /** multi **/ \
270 f(CLONERANGE, __CEPH_OSD_OP(WR, MULTI, 1), "clonerange") \
271 f(ASSERT_SRC_VERSION, __CEPH_OSD_OP(RD, MULTI, 2), "assert-src-version") \
272 f(SRC_CMPXATTR, __CEPH_OSD_OP(RD, MULTI, 3), "src-cmpxattr") \
273 \
274 /** attrs **/ \
275 /* read */ \
276 f(GETXATTR, __CEPH_OSD_OP(RD, ATTR, 1), "getxattr") \
277 f(GETXATTRS, __CEPH_OSD_OP(RD, ATTR, 2), "getxattrs") \
278 f(CMPXATTR, __CEPH_OSD_OP(RD, ATTR, 3), "cmpxattr") \
279 \
280 /* write */ \
281 f(SETXATTR, __CEPH_OSD_OP(WR, ATTR, 1), "setxattr") \
282 f(SETXATTRS, __CEPH_OSD_OP(WR, ATTR, 2), "setxattrs") \
283 f(RESETXATTRS, __CEPH_OSD_OP(WR, ATTR, 3), "resetxattrs") \
284 f(RMXATTR, __CEPH_OSD_OP(WR, ATTR, 4), "rmxattr") \
285 \
286 /** subop **/ \
287 f(PULL, __CEPH_OSD_OP1(SUB, 1), "pull") \
288 f(PUSH, __CEPH_OSD_OP1(SUB, 2), "push") \
289 f(BALANCEREADS, __CEPH_OSD_OP1(SUB, 3), "balance-reads") \
290 f(UNBALANCEREADS, __CEPH_OSD_OP1(SUB, 4), "unbalance-reads") \
291 f(SCRUB, __CEPH_OSD_OP1(SUB, 5), "scrub") \
292 f(SCRUB_RESERVE, __CEPH_OSD_OP1(SUB, 6), "scrub-reserve") \
293 f(SCRUB_UNRESERVE, __CEPH_OSD_OP1(SUB, 7), "scrub-unreserve") \
294 f(SCRUB_STOP, __CEPH_OSD_OP1(SUB, 8), "scrub-stop") \
295 f(SCRUB_MAP, __CEPH_OSD_OP1(SUB, 9), "scrub-map") \
296 \
297 /** lock **/ \
298 f(WRLOCK, __CEPH_OSD_OP(WR, LOCK, 1), "wrlock") \
299 f(WRUNLOCK, __CEPH_OSD_OP(WR, LOCK, 2), "wrunlock") \
300 f(RDLOCK, __CEPH_OSD_OP(WR, LOCK, 3), "rdlock") \
301 f(RDUNLOCK, __CEPH_OSD_OP(WR, LOCK, 4), "rdunlock") \
302 f(UPLOCK, __CEPH_OSD_OP(WR, LOCK, 5), "uplock") \
303 f(DNLOCK, __CEPH_OSD_OP(WR, LOCK, 6), "dnlock") \
304 \
305 /** exec **/ \
306 /* note: the RD bit here is wrong; see special-case below in helper */ \
307 f(CALL, __CEPH_OSD_OP(RD, EXEC, 1), "call") \
308 \
309 /** pg **/ \
310 f(PGLS, __CEPH_OSD_OP(RD, PG, 1), "pgls") \
311 f(PGLS_FILTER, __CEPH_OSD_OP(RD, PG, 2), "pgls-filter") \
312 f(PG_HITSET_LS, __CEPH_OSD_OP(RD, PG, 3), "pg-hitset-ls") \
313 f(PG_HITSET_GET, __CEPH_OSD_OP(RD, PG, 4), "pg-hitset-get")
314
Sage Weil0dee3c22009-10-06 11:31:06 -0700315enum {
Ilya Dryomov70b5bfa2014-10-02 17:22:29 +0400316#define GENERATE_ENUM_ENTRY(op, opcode, str) CEPH_OSD_OP_##op = (opcode),
317__CEPH_FORALL_OSD_OPS(GENERATE_ENUM_ENTRY)
318#undef GENERATE_ENUM_ENTRY
Sage Weil0dee3c22009-10-06 11:31:06 -0700319};
320
321static inline int ceph_osd_op_type_lock(int op)
322{
323 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_LOCK;
324}
325static inline int ceph_osd_op_type_data(int op)
326{
327 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_DATA;
328}
329static inline int ceph_osd_op_type_attr(int op)
330{
331 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_ATTR;
332}
333static inline int ceph_osd_op_type_exec(int op)
334{
335 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_EXEC;
336}
337static inline int ceph_osd_op_type_pg(int op)
338{
339 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_PG;
340}
Alex Elder0315a772013-02-15 11:42:30 -0600341static inline int ceph_osd_op_type_multi(int op)
342{
343 return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_MULTI;
344}
Sage Weil0dee3c22009-10-06 11:31:06 -0700345
346static inline int ceph_osd_op_mode_subop(int op)
347{
348 return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_SUB;
349}
350static inline int ceph_osd_op_mode_read(int op)
351{
Alex Elder0315a772013-02-15 11:42:30 -0600352 return (op & CEPH_OSD_OP_MODE_RD) &&
353 op != CEPH_OSD_OP_CALL;
Sage Weil0dee3c22009-10-06 11:31:06 -0700354}
355static inline int ceph_osd_op_mode_modify(int op)
356{
Alex Elder0315a772013-02-15 11:42:30 -0600357 return op & CEPH_OSD_OP_MODE_WR;
Sage Weil0dee3c22009-10-06 11:31:06 -0700358}
359
Sage Weilf0b18d92010-07-07 08:39:03 -0700360/*
361 * note that the following tmap stuff is also defined in the ceph librados.h
362 * any modification here needs to be updated there
363 */
Sage Weil0dee3c22009-10-06 11:31:06 -0700364#define CEPH_OSD_TMAP_HDR 'h'
365#define CEPH_OSD_TMAP_SET 's'
Alex Elder0315a772013-02-15 11:42:30 -0600366#define CEPH_OSD_TMAP_CREATE 'c' /* create key */
Sage Weil0dee3c22009-10-06 11:31:06 -0700367#define CEPH_OSD_TMAP_RM 'r'
Alex Elder0315a772013-02-15 11:42:30 -0600368#define CEPH_OSD_TMAP_RMSLOPPY 'R'
Sage Weil0dee3c22009-10-06 11:31:06 -0700369
370extern const char *ceph_osd_op_name(int op);
371
Sage Weil0dee3c22009-10-06 11:31:06 -0700372/*
373 * osd op flags
374 *
375 * An op may be READ, WRITE, or READ|WRITE.
376 */
377enum {
Alex Elder0315a772013-02-15 11:42:30 -0600378 CEPH_OSD_FLAG_ACK = 0x0001, /* want (or is) "ack" ack */
379 CEPH_OSD_FLAG_ONNVRAM = 0x0002, /* want (or is) "onnvram" ack */
380 CEPH_OSD_FLAG_ONDISK = 0x0004, /* want (or is) "ondisk" ack */
381 CEPH_OSD_FLAG_RETRY = 0x0008, /* resend attempt */
382 CEPH_OSD_FLAG_READ = 0x0010, /* op may read */
383 CEPH_OSD_FLAG_WRITE = 0x0020, /* op may write */
384 CEPH_OSD_FLAG_ORDERSNAP = 0x0040, /* EOLDSNAP if snapc is out of order */
385 CEPH_OSD_FLAG_PEERSTAT_OLD = 0x0080, /* DEPRECATED msg includes osd_peer_stat */
386 CEPH_OSD_FLAG_BALANCE_READS = 0x0100,
387 CEPH_OSD_FLAG_PARALLELEXEC = 0x0200, /* execute op in parallel */
388 CEPH_OSD_FLAG_PGOP = 0x0400, /* pg op, no object */
389 CEPH_OSD_FLAG_EXEC = 0x0800, /* op may exec */
390 CEPH_OSD_FLAG_EXEC_PUBLIC = 0x1000, /* DEPRECATED op may exec (public) */
391 CEPH_OSD_FLAG_LOCALIZE_READS = 0x2000, /* read from nearby replica, if any */
392 CEPH_OSD_FLAG_RWORDERED = 0x4000, /* order wrt concurrent reads */
Ilya Dryomov1b3f2ab2014-01-27 17:40:19 +0200393 CEPH_OSD_FLAG_IGNORE_CACHE = 0x8000, /* ignore cache logic */
394 CEPH_OSD_FLAG_SKIPRWLOCKS = 0x10000, /* skip rw locks */
395 CEPH_OSD_FLAG_IGNORE_OVERLAY = 0x20000, /* ignore pool overlay */
396 CEPH_OSD_FLAG_FLUSH = 0x40000, /* this is part of flush */
Ilya Dryomovbb873b52016-05-26 00:29:52 +0200397 CEPH_OSD_FLAG_MAP_SNAP_CLONE = 0x80000, /* map snap direct to clone id */
398 CEPH_OSD_FLAG_ENFORCE_SNAPC = 0x100000, /* use snapc provided even if
399 pool uses pool snaps */
400 CEPH_OSD_FLAG_REDIRECTED = 0x200000, /* op has been redirected */
401 CEPH_OSD_FLAG_KNOWN_REDIR = 0x400000, /* redirect bit is authoritative */
402 CEPH_OSD_FLAG_FULL_TRY = 0x800000, /* try op despite full flag */
403 CEPH_OSD_FLAG_FULL_FORCE = 0x1000000, /* force op despite full flag */
Sage Weil0dee3c22009-10-06 11:31:06 -0700404};
405
406enum {
407 CEPH_OSD_OP_FLAG_EXCL = 1, /* EXCL object create */
Alex Elder0315a772013-02-15 11:42:30 -0600408 CEPH_OSD_OP_FLAG_FAILOK = 2, /* continue despite failure */
Sage Weil0dee3c22009-10-06 11:31:06 -0700409};
410
411#define EOLDSNAPC ERESTART /* ORDERSNAP flag set; writer has old snapc*/
412#define EBLACKLISTED ESHUTDOWN /* blacklisted */
413
Sage Weilca9d93a2010-05-12 14:48:20 -0700414/* xattr comparison */
415enum {
416 CEPH_OSD_CMPXATTR_OP_NOP = 0,
417 CEPH_OSD_CMPXATTR_OP_EQ = 1,
418 CEPH_OSD_CMPXATTR_OP_NE = 2,
419 CEPH_OSD_CMPXATTR_OP_GT = 3,
420 CEPH_OSD_CMPXATTR_OP_GTE = 4,
421 CEPH_OSD_CMPXATTR_OP_LT = 5,
422 CEPH_OSD_CMPXATTR_OP_LTE = 6
423};
424
425enum {
426 CEPH_OSD_CMPXATTR_MODE_STRING = 1,
427 CEPH_OSD_CMPXATTR_MODE_U64 = 2
428};
429
Ilya Dryomov922dab62016-05-26 01:15:02 +0200430enum {
431 CEPH_OSD_WATCH_OP_UNWATCH = 0,
432 CEPH_OSD_WATCH_OP_LEGACY_WATCH = 1,
433 /* note: use only ODD ids to prevent pre-giant code from
434 interpreting the op as UNWATCH */
435 CEPH_OSD_WATCH_OP_WATCH = 3,
436 CEPH_OSD_WATCH_OP_RECONNECT = 5,
437 CEPH_OSD_WATCH_OP_PING = 7,
438};
439
440const char *ceph_osd_watch_op_name(int o);
Yehuda Sadeh483fac72011-01-20 16:36:06 -0800441
Sage Weil0dee3c22009-10-06 11:31:06 -0700442/*
443 * an individual object operation. each may be accompanied by some data
444 * payload
445 */
446struct ceph_osd_op {
447 __le16 op; /* CEPH_OSD_OP_* */
Ilya Dryomov7b25bf52014-02-25 16:22:26 +0200448 __le32 flags; /* CEPH_OSD_OP_FLAG_* */
Sage Weil0dee3c22009-10-06 11:31:06 -0700449 union {
450 struct {
451 __le64 offset, length;
Yehuda Sadeh0c948992010-02-01 16:10:45 -0800452 __le64 truncate_size;
453 __le32 truncate_seq;
Sage Weil0dee3c22009-10-06 11:31:06 -0700454 } __attribute__ ((packed)) extent;
455 struct {
456 __le32 name_len;
457 __le32 value_len;
Sage Weilca9d93a2010-05-12 14:48:20 -0700458 __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */
459 __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */
Sage Weil0dee3c22009-10-06 11:31:06 -0700460 } __attribute__ ((packed)) xattr;
461 struct {
Sage Weil0dee3c22009-10-06 11:31:06 -0700462 __u8 class_len;
463 __u8 method_len;
464 __u8 argc;
465 __le32 indata_len;
466 } __attribute__ ((packed)) cls;
467 struct {
468 __le64 cookie, count;
469 } __attribute__ ((packed)) pgls;
Sage Weilf0b18d92010-07-07 08:39:03 -0700470 struct {
471 __le64 snapid;
472 } __attribute__ ((packed)) snap;
Yehuda Sadeh483fac72011-01-20 16:36:06 -0800473 struct {
474 __le64 cookie;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200475 __le64 ver; /* no longer used */
476 __u8 op; /* CEPH_OSD_WATCH_OP_* */
477 __le32 gen; /* registration generation */
Yehuda Sadeh483fac72011-01-20 16:36:06 -0800478 } __attribute__ ((packed)) watch;
Alex Elder0315a772013-02-15 11:42:30 -0600479 struct {
Ilya Dryomov19079202016-04-28 16:07:27 +0200480 __le64 cookie;
481 } __attribute__ ((packed)) notify;
482 struct {
Alex Elder0315a772013-02-15 11:42:30 -0600483 __le64 offset, length;
484 __le64 src_offset;
485 } __attribute__ ((packed)) clonerange;
Ilya Dryomovc647b8a2014-02-25 16:22:27 +0200486 struct {
487 __le64 expected_object_size;
488 __le64 expected_write_size;
489 } __attribute__ ((packed)) alloc_hint;
Alex Elder0315a772013-02-15 11:42:30 -0600490 };
Sage Weil0dee3c22009-10-06 11:31:06 -0700491 __le32 payload_len;
492} __attribute__ ((packed));
493
Sage Weil0dee3c22009-10-06 11:31:06 -0700494
Sage Weil0dee3c22009-10-06 11:31:06 -0700495#endif