xref: /openbmc/linux/include/linux/ceph/rados.h (revision 69dd3b39)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef CEPH_RADOS_H
3 #define CEPH_RADOS_H
4 
5 /*
6  * Data types for the Ceph distributed object storage layer RADOS
7  * (Reliable Autonomic Distributed Object Store).
8  */
9 
10 #include <linux/ceph/msgr.h>
11 
12 /*
13  * fs id
14  */
15 struct ceph_fsid {
16 	unsigned char fsid[16];
17 };
18 
ceph_fsid_compare(const struct ceph_fsid * a,const struct ceph_fsid * b)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      32  /* max # osds in a single pg */
55 
56 /*
57  * placement group.
58  * we encode this into one __le64.
59  */
60 struct ceph_pg_v1 {
61 	__le16 preferred; /* preferred primary osd */
62 	__le16 ps;        /* placement seed */
63 	__le32 pool;      /* object pool */
64 } __attribute__ ((packed));
65 
66 /*
67  * pg_pool is a set of pgs storing a pool of objects
68  *
69  *  pg_num -- base number of pseudorandomly placed pgs
70  *
71  *  pgp_num -- effective number when calculating pg placement.  this
72  * is used for pg_num increases.  new pgs result in data being "split"
73  * into new pgs.  for this to proceed smoothly, new pgs are intiially
74  * colocated with their parents; that is, pgp_num doesn't increase
75  * until the new pgs have successfully split.  only _then_ are the new
76  * pgs placed independently.
77  *
78  *  lpg_num -- localized pg count (per device).  replicas are randomly
79  * selected.
80  *
81  *  lpgp_num -- as above.
82  */
83 #define CEPH_NOPOOL  ((__u64) (-1))  /* pool id not defined */
84 
85 #define CEPH_POOL_TYPE_REP     1
86 #define CEPH_POOL_TYPE_RAID4   2 /* never implemented */
87 #define CEPH_POOL_TYPE_EC      3
88 
89 /*
90  * stable_mod func is used to control number of placement groups.
91  * similar to straight-up modulo, but produces a stable mapping as b
92  * increases over time.  b is the number of bins, and bmask is the
93  * containing power of 2 minus 1.
94  *
95  * b <= bmask and bmask=(2**n)-1
96  * e.g., b=12 -> bmask=15, b=123 -> bmask=127
97  */
ceph_stable_mod(int x,int b,int bmask)98 static inline int ceph_stable_mod(int x, int b, int bmask)
99 {
100 	if ((x & bmask) < b)
101 		return x & bmask;
102 	else
103 		return x & (bmask >> 1);
104 }
105 
106 /*
107  * object layout - how a given object should be stored.
108  */
109 struct ceph_object_layout {
110 	struct ceph_pg_v1 ol_pgid;   /* raw pg, with _full_ ps precision. */
111 	__le32 ol_stripe_unit;    /* for per-object parity, if any */
112 } __attribute__ ((packed));
113 
114 /*
115  * compound epoch+version, used by storage layer to serialize mutations
116  */
117 struct ceph_eversion {
118 	__le64 version;
119 	__le32 epoch;
120 } __attribute__ ((packed));
121 
122 /*
123  * osd map bits
124  */
125 
126 /* status bits */
127 #define CEPH_OSD_EXISTS  (1<<0)
128 #define CEPH_OSD_UP      (1<<1)
129 #define CEPH_OSD_AUTOOUT (1<<2)  /* osd was automatically marked out */
130 #define CEPH_OSD_NEW     (1<<3)  /* osd is new, never marked in */
131 
132 extern const char *ceph_osd_state_name(int s);
133 
134 /* osd weights.  fixed point value: 0x10000 == 1.0 ("in"), 0 == "out" */
135 #define CEPH_OSD_IN  0x10000
136 #define CEPH_OSD_OUT 0
137 
138 /* osd primary-affinity.  fixed point value: 0x10000 == baseline */
139 #define CEPH_OSD_MAX_PRIMARY_AFFINITY 0x10000
140 #define CEPH_OSD_DEFAULT_PRIMARY_AFFINITY 0x10000
141 
142 
143 /*
144  * osd map flag bits
145  */
146 #define CEPH_OSDMAP_NEARFULL (1<<0)  /* sync writes (near ENOSPC),
147 					not set since ~luminous */
148 #define CEPH_OSDMAP_FULL     (1<<1)  /* no data writes (ENOSPC),
149 					not set since ~luminous */
150 #define CEPH_OSDMAP_PAUSERD  (1<<2)  /* pause all reads */
151 #define CEPH_OSDMAP_PAUSEWR  (1<<3)  /* pause all writes */
152 #define CEPH_OSDMAP_PAUSEREC (1<<4)  /* pause recovery */
153 #define CEPH_OSDMAP_NOUP     (1<<5)  /* block osd boot */
154 #define CEPH_OSDMAP_NODOWN   (1<<6)  /* block osd mark-down/failure */
155 #define CEPH_OSDMAP_NOOUT    (1<<7)  /* block osd auto mark-out */
156 #define CEPH_OSDMAP_NOIN     (1<<8)  /* block osd auto mark-in */
157 #define CEPH_OSDMAP_NOBACKFILL (1<<9) /* block osd backfill */
158 #define CEPH_OSDMAP_NORECOVER (1<<10) /* block osd recovery and backfill */
159 #define CEPH_OSDMAP_NOSCRUB  (1<<11) /* block periodic scrub */
160 #define CEPH_OSDMAP_NODEEP_SCRUB (1<<12) /* block periodic deep-scrub */
161 #define CEPH_OSDMAP_NOTIERAGENT (1<<13) /* disable tiering agent */
162 #define CEPH_OSDMAP_NOREBALANCE (1<<14) /* block osd backfill unless pg is degraded */
163 #define CEPH_OSDMAP_SORTBITWISE (1<<15) /* use bitwise hobject_t sort */
164 #define CEPH_OSDMAP_REQUIRE_JEWEL    (1<<16) /* require jewel for booting osds */
165 #define CEPH_OSDMAP_REQUIRE_KRAKEN   (1<<17) /* require kraken for booting osds */
166 #define CEPH_OSDMAP_REQUIRE_LUMINOUS (1<<18) /* require l for booting osds */
167 #define CEPH_OSDMAP_RECOVERY_DELETES (1<<19) /* deletes performed during recovery instead of peering */
168 
169 /*
170  * The error code to return when an OSD can't handle a write
171  * because it is too large.
172  */
173 #define OSD_WRITETOOBIG EMSGSIZE
174 
175 /*
176  * osd ops
177  *
178  * WARNING: do not use these op codes directly.  Use the helpers
179  * defined below instead.  In certain cases, op code behavior was
180  * redefined, resulting in special-cases in the helpers.
181  */
182 #define CEPH_OSD_OP_MODE       0xf000
183 #define CEPH_OSD_OP_MODE_RD    0x1000
184 #define CEPH_OSD_OP_MODE_WR    0x2000
185 #define CEPH_OSD_OP_MODE_RMW   0x3000
186 #define CEPH_OSD_OP_MODE_SUB   0x4000
187 #define CEPH_OSD_OP_MODE_CACHE 0x8000
188 
189 #define CEPH_OSD_OP_TYPE       0x0f00
190 #define CEPH_OSD_OP_TYPE_LOCK  0x0100
191 #define CEPH_OSD_OP_TYPE_DATA  0x0200
192 #define CEPH_OSD_OP_TYPE_ATTR  0x0300
193 #define CEPH_OSD_OP_TYPE_EXEC  0x0400
194 #define CEPH_OSD_OP_TYPE_PG    0x0500
195 #define CEPH_OSD_OP_TYPE_MULTI 0x0600 /* multiobject */
196 
197 #define __CEPH_OSD_OP1(mode, nr) \
198 	(CEPH_OSD_OP_MODE_##mode | (nr))
199 
200 #define __CEPH_OSD_OP(mode, type, nr) \
201 	(CEPH_OSD_OP_MODE_##mode | CEPH_OSD_OP_TYPE_##type | (nr))
202 
203 #define __CEPH_FORALL_OSD_OPS(f)					    \
204 	/** data **/							    \
205 	/* read */							    \
206 	f(READ,		__CEPH_OSD_OP(RD, DATA, 1),	"read")		    \
207 	f(STAT,		__CEPH_OSD_OP(RD, DATA, 2),	"stat")		    \
208 	f(MAPEXT,	__CEPH_OSD_OP(RD, DATA, 3),	"mapext")	    \
209 									    \
210 	/* fancy read */						    \
211 	f(MASKTRUNC,	__CEPH_OSD_OP(RD, DATA, 4),	"masktrunc")	    \
212 	f(SPARSE_READ,	__CEPH_OSD_OP(RD, DATA, 5),	"sparse-read")	    \
213 									    \
214 	f(NOTIFY,	__CEPH_OSD_OP(RD, DATA, 6),	"notify")	    \
215 	f(NOTIFY_ACK,	__CEPH_OSD_OP(RD, DATA, 7),	"notify-ack")	    \
216 									    \
217 	/* versioning */						    \
218 	f(ASSERT_VER,	__CEPH_OSD_OP(RD, DATA, 8),	"assert-version")   \
219 									    \
220 	f(LIST_WATCHERS, __CEPH_OSD_OP(RD, DATA, 9),	"list-watchers")    \
221 									    \
222 	f(LIST_SNAPS,	__CEPH_OSD_OP(RD, DATA, 10),	"list-snaps")	    \
223 									    \
224 	/* sync */							    \
225 	f(SYNC_READ,	__CEPH_OSD_OP(RD, DATA, 11),	"sync_read")	    \
226 									    \
227 	/* write */							    \
228 	f(WRITE,	__CEPH_OSD_OP(WR, DATA, 1),	"write")	    \
229 	f(WRITEFULL,	__CEPH_OSD_OP(WR, DATA, 2),	"writefull")	    \
230 	f(TRUNCATE,	__CEPH_OSD_OP(WR, DATA, 3),	"truncate")	    \
231 	f(ZERO,		__CEPH_OSD_OP(WR, DATA, 4),	"zero")		    \
232 	f(DELETE,	__CEPH_OSD_OP(WR, DATA, 5),	"delete")	    \
233 									    \
234 	/* fancy write */						    \
235 	f(APPEND,	__CEPH_OSD_OP(WR, DATA, 6),	"append")	    \
236 	f(SETTRUNC,	__CEPH_OSD_OP(WR, DATA, 8),	"settrunc")	    \
237 	f(TRIMTRUNC,	__CEPH_OSD_OP(WR, DATA, 9),	"trimtrunc")	    \
238 									    \
239 	f(TMAPUP,	__CEPH_OSD_OP(RMW, DATA, 10),	"tmapup")	    \
240 	f(TMAPPUT,	__CEPH_OSD_OP(WR, DATA, 11),	"tmapput")	    \
241 	f(TMAPGET,	__CEPH_OSD_OP(RD, DATA, 12),	"tmapget")	    \
242 									    \
243 	f(CREATE,	__CEPH_OSD_OP(WR, DATA, 13),	"create")	    \
244 	f(ROLLBACK,	__CEPH_OSD_OP(WR, DATA, 14),	"rollback")	    \
245 									    \
246 	f(WATCH,	__CEPH_OSD_OP(WR, DATA, 15),	"watch")	    \
247 									    \
248 	/* omap */							    \
249 	f(OMAPGETKEYS,	__CEPH_OSD_OP(RD, DATA, 17),	"omap-get-keys")    \
250 	f(OMAPGETVALS,	__CEPH_OSD_OP(RD, DATA, 18),	"omap-get-vals")    \
251 	f(OMAPGETHEADER, __CEPH_OSD_OP(RD, DATA, 19),	"omap-get-header")  \
252 	f(OMAPGETVALSBYKEYS, __CEPH_OSD_OP(RD, DATA, 20), "omap-get-vals-by-keys") \
253 	f(OMAPSETVALS,	__CEPH_OSD_OP(WR, DATA, 21),	"omap-set-vals")    \
254 	f(OMAPSETHEADER, __CEPH_OSD_OP(WR, DATA, 22),	"omap-set-header")  \
255 	f(OMAPCLEAR,	__CEPH_OSD_OP(WR, DATA, 23),	"omap-clear")	    \
256 	f(OMAPRMKEYS,	__CEPH_OSD_OP(WR, DATA, 24),	"omap-rm-keys")	    \
257 	f(OMAP_CMP,	__CEPH_OSD_OP(RD, DATA, 25),	"omap-cmp")	    \
258 									    \
259 	/* tiering */							    \
260 	f(COPY_FROM,	__CEPH_OSD_OP(WR, DATA, 26),	"copy-from")	    \
261 	f(COPY_FROM2,	__CEPH_OSD_OP(WR, DATA, 45),	"copy-from2")	    \
262 	f(COPY_GET_CLASSIC, __CEPH_OSD_OP(RD, DATA, 27), "copy-get-classic") \
263 	f(UNDIRTY,	__CEPH_OSD_OP(WR, DATA, 28),	"undirty")	    \
264 	f(ISDIRTY,	__CEPH_OSD_OP(RD, DATA, 29),	"isdirty")	    \
265 	f(COPY_GET,	__CEPH_OSD_OP(RD, DATA, 30),	"copy-get")	    \
266 	f(CACHE_FLUSH,	__CEPH_OSD_OP(CACHE, DATA, 31),	"cache-flush")	    \
267 	f(CACHE_EVICT,	__CEPH_OSD_OP(CACHE, DATA, 32),	"cache-evict")	    \
268 	f(CACHE_TRY_FLUSH, __CEPH_OSD_OP(CACHE, DATA, 33), "cache-try-flush") \
269 									    \
270 	/* convert tmap to omap */					    \
271 	f(TMAP2OMAP,	__CEPH_OSD_OP(RMW, DATA, 34),	"tmap2omap")	    \
272 									    \
273 	/* hints */							    \
274 	f(SETALLOCHINT,	__CEPH_OSD_OP(WR, DATA, 35),	"set-alloc-hint")   \
275 									    \
276 	/** multi **/							    \
277 	f(CLONERANGE,	__CEPH_OSD_OP(WR, MULTI, 1),	"clonerange")	    \
278 	f(ASSERT_SRC_VERSION, __CEPH_OSD_OP(RD, MULTI, 2), "assert-src-version") \
279 	f(SRC_CMPXATTR,	__CEPH_OSD_OP(RD, MULTI, 3),	"src-cmpxattr")	    \
280 									    \
281 	/** attrs **/							    \
282 	/* read */							    \
283 	f(GETXATTR,	__CEPH_OSD_OP(RD, ATTR, 1),	"getxattr")	    \
284 	f(GETXATTRS,	__CEPH_OSD_OP(RD, ATTR, 2),	"getxattrs")	    \
285 	f(CMPXATTR,	__CEPH_OSD_OP(RD, ATTR, 3),	"cmpxattr")	    \
286 									    \
287 	/* write */							    \
288 	f(SETXATTR,	__CEPH_OSD_OP(WR, ATTR, 1),	"setxattr")	    \
289 	f(SETXATTRS,	__CEPH_OSD_OP(WR, ATTR, 2),	"setxattrs")	    \
290 	f(RESETXATTRS,	__CEPH_OSD_OP(WR, ATTR, 3),	"resetxattrs")	    \
291 	f(RMXATTR,	__CEPH_OSD_OP(WR, ATTR, 4),	"rmxattr")	    \
292 									    \
293 	/** subop **/							    \
294 	f(PULL,		__CEPH_OSD_OP1(SUB, 1),		"pull")		    \
295 	f(PUSH,		__CEPH_OSD_OP1(SUB, 2),		"push")		    \
296 	f(BALANCEREADS,	__CEPH_OSD_OP1(SUB, 3),		"balance-reads")    \
297 	f(UNBALANCEREADS, __CEPH_OSD_OP1(SUB, 4),	"unbalance-reads")  \
298 	f(SCRUB,	__CEPH_OSD_OP1(SUB, 5),		"scrub")	    \
299 	f(SCRUB_RESERVE, __CEPH_OSD_OP1(SUB, 6),	"scrub-reserve")    \
300 	f(SCRUB_UNRESERVE, __CEPH_OSD_OP1(SUB, 7),	"scrub-unreserve")  \
301 	f(SCRUB_STOP,	__CEPH_OSD_OP1(SUB, 8),		"scrub-stop")	    \
302 	f(SCRUB_MAP,	__CEPH_OSD_OP1(SUB, 9),		"scrub-map")	    \
303 									    \
304 	/** lock **/							    \
305 	f(WRLOCK,	__CEPH_OSD_OP(WR, LOCK, 1),	"wrlock")	    \
306 	f(WRUNLOCK,	__CEPH_OSD_OP(WR, LOCK, 2),	"wrunlock")	    \
307 	f(RDLOCK,	__CEPH_OSD_OP(WR, LOCK, 3),	"rdlock")	    \
308 	f(RDUNLOCK,	__CEPH_OSD_OP(WR, LOCK, 4),	"rdunlock")	    \
309 	f(UPLOCK,	__CEPH_OSD_OP(WR, LOCK, 5),	"uplock")	    \
310 	f(DNLOCK,	__CEPH_OSD_OP(WR, LOCK, 6),	"dnlock")	    \
311 									    \
312 	/** exec **/							    \
313 	/* note: the RD bit here is wrong; see special-case below in helper */ \
314 	f(CALL,		__CEPH_OSD_OP(RD, EXEC, 1),	"call")		    \
315 									    \
316 	/** pg **/							    \
317 	f(PGLS,		__CEPH_OSD_OP(RD, PG, 1),	"pgls")		    \
318 	f(PGLS_FILTER,	__CEPH_OSD_OP(RD, PG, 2),	"pgls-filter")	    \
319 	f(PG_HITSET_LS,	__CEPH_OSD_OP(RD, PG, 3),	"pg-hitset-ls")	    \
320 	f(PG_HITSET_GET, __CEPH_OSD_OP(RD, PG, 4),	"pg-hitset-get")
321 
322 enum {
323 #define GENERATE_ENUM_ENTRY(op, opcode, str)	CEPH_OSD_OP_##op = (opcode),
324 __CEPH_FORALL_OSD_OPS(GENERATE_ENUM_ENTRY)
325 #undef GENERATE_ENUM_ENTRY
326 };
327 
ceph_osd_op_type_lock(int op)328 static inline int ceph_osd_op_type_lock(int op)
329 {
330 	return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_LOCK;
331 }
ceph_osd_op_type_data(int op)332 static inline int ceph_osd_op_type_data(int op)
333 {
334 	return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_DATA;
335 }
ceph_osd_op_type_attr(int op)336 static inline int ceph_osd_op_type_attr(int op)
337 {
338 	return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_ATTR;
339 }
ceph_osd_op_type_exec(int op)340 static inline int ceph_osd_op_type_exec(int op)
341 {
342 	return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_EXEC;
343 }
ceph_osd_op_type_pg(int op)344 static inline int ceph_osd_op_type_pg(int op)
345 {
346 	return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_PG;
347 }
ceph_osd_op_type_multi(int op)348 static inline int ceph_osd_op_type_multi(int op)
349 {
350 	return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_MULTI;
351 }
352 
ceph_osd_op_mode_subop(int op)353 static inline int ceph_osd_op_mode_subop(int op)
354 {
355 	return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_SUB;
356 }
ceph_osd_op_mode_read(int op)357 static inline int ceph_osd_op_mode_read(int op)
358 {
359 	return (op & CEPH_OSD_OP_MODE_RD) &&
360 		op != CEPH_OSD_OP_CALL;
361 }
ceph_osd_op_mode_modify(int op)362 static inline int ceph_osd_op_mode_modify(int op)
363 {
364 	return op & CEPH_OSD_OP_MODE_WR;
365 }
366 
367 /*
368  * note that the following tmap stuff is also defined in the ceph librados.h
369  * any modification here needs to be updated there
370  */
371 #define CEPH_OSD_TMAP_HDR 'h'
372 #define CEPH_OSD_TMAP_SET 's'
373 #define CEPH_OSD_TMAP_CREATE 'c' /* create key */
374 #define CEPH_OSD_TMAP_RM  'r'
375 #define CEPH_OSD_TMAP_RMSLOPPY 'R'
376 
377 extern const char *ceph_osd_op_name(int op);
378 
379 /*
380  * osd op flags
381  *
382  * An op may be READ, WRITE, or READ|WRITE.
383  */
384 enum {
385 	CEPH_OSD_FLAG_ACK =            0x0001,  /* want (or is) "ack" ack */
386 	CEPH_OSD_FLAG_ONNVRAM =        0x0002,  /* want (or is) "onnvram" ack */
387 	CEPH_OSD_FLAG_ONDISK =         0x0004,  /* want (or is) "ondisk" ack */
388 	CEPH_OSD_FLAG_RETRY =          0x0008,  /* resend attempt */
389 	CEPH_OSD_FLAG_READ =           0x0010,  /* op may read */
390 	CEPH_OSD_FLAG_WRITE =          0x0020,  /* op may write */
391 	CEPH_OSD_FLAG_ORDERSNAP =      0x0040,  /* EOLDSNAP if snapc is out of order */
392 	CEPH_OSD_FLAG_PEERSTAT_OLD =   0x0080,  /* DEPRECATED msg includes osd_peer_stat */
393 	CEPH_OSD_FLAG_BALANCE_READS =  0x0100,
394 	CEPH_OSD_FLAG_PARALLELEXEC =   0x0200,  /* execute op in parallel */
395 	CEPH_OSD_FLAG_PGOP =           0x0400,  /* pg op, no object */
396 	CEPH_OSD_FLAG_EXEC =           0x0800,  /* op may exec */
397 	CEPH_OSD_FLAG_EXEC_PUBLIC =    0x1000,  /* DEPRECATED op may exec (public) */
398 	CEPH_OSD_FLAG_LOCALIZE_READS = 0x2000,  /* read from nearby replica, if any */
399 	CEPH_OSD_FLAG_RWORDERED =      0x4000,  /* order wrt concurrent reads */
400 	CEPH_OSD_FLAG_IGNORE_CACHE =   0x8000,  /* ignore cache logic */
401 	CEPH_OSD_FLAG_SKIPRWLOCKS =   0x10000,  /* skip rw locks */
402 	CEPH_OSD_FLAG_IGNORE_OVERLAY = 0x20000, /* ignore pool overlay */
403 	CEPH_OSD_FLAG_FLUSH =         0x40000,  /* this is part of flush */
404 	CEPH_OSD_FLAG_MAP_SNAP_CLONE = 0x80000,  /* map snap direct to clone id */
405 	CEPH_OSD_FLAG_ENFORCE_SNAPC   = 0x100000,  /* use snapc provided even if
406 						      pool uses pool snaps */
407 	CEPH_OSD_FLAG_REDIRECTED   = 0x200000,  /* op has been redirected */
408 	CEPH_OSD_FLAG_KNOWN_REDIR = 0x400000,  /* redirect bit is authoritative */
409 	CEPH_OSD_FLAG_FULL_TRY =    0x800000,  /* try op despite full flag */
410 	CEPH_OSD_FLAG_FULL_FORCE = 0x1000000,  /* force op despite full flag */
411 };
412 
413 enum {
414 	CEPH_OSD_OP_FLAG_EXCL = 1,      /* EXCL object create */
415 	CEPH_OSD_OP_FLAG_FAILOK = 2,    /* continue despite failure */
416 	CEPH_OSD_OP_FLAG_FADVISE_RANDOM	    = 0x4, /* the op is random */
417 	CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL = 0x8, /* the op is sequential */
418 	CEPH_OSD_OP_FLAG_FADVISE_WILLNEED   = 0x10,/* data will be accessed in
419 						      the near future */
420 	CEPH_OSD_OP_FLAG_FADVISE_DONTNEED   = 0x20,/* data will not be accessed
421 						      in the near future */
422 	CEPH_OSD_OP_FLAG_FADVISE_NOCACHE    = 0x40,/* data will be accessed only
423 						      once by this client */
424 };
425 
426 #define EOLDSNAPC    ERESTART  /* ORDERSNAP flag set; writer has old snapc*/
427 #define EBLOCKLISTED ESHUTDOWN /* blocklisted */
428 
429 /* xattr comparison */
430 enum {
431 	CEPH_OSD_CMPXATTR_OP_NOP = 0,
432 	CEPH_OSD_CMPXATTR_OP_EQ  = 1,
433 	CEPH_OSD_CMPXATTR_OP_NE  = 2,
434 	CEPH_OSD_CMPXATTR_OP_GT  = 3,
435 	CEPH_OSD_CMPXATTR_OP_GTE = 4,
436 	CEPH_OSD_CMPXATTR_OP_LT  = 5,
437 	CEPH_OSD_CMPXATTR_OP_LTE = 6
438 };
439 
440 enum {
441 	CEPH_OSD_CMPXATTR_MODE_STRING = 1,
442 	CEPH_OSD_CMPXATTR_MODE_U64    = 2
443 };
444 
445 enum {
446 	CEPH_OSD_COPY_FROM_FLAG_FLUSH = 1,       /* part of a flush operation */
447 	CEPH_OSD_COPY_FROM_FLAG_IGNORE_OVERLAY = 2, /* ignore pool overlay */
448 	CEPH_OSD_COPY_FROM_FLAG_IGNORE_CACHE = 4,   /* ignore osd cache logic */
449 	CEPH_OSD_COPY_FROM_FLAG_MAP_SNAP_CLONE = 8, /* map snap direct to
450 						     * cloneid */
451 	CEPH_OSD_COPY_FROM_FLAG_RWORDERED = 16,     /* order with write */
452 	CEPH_OSD_COPY_FROM_FLAG_TRUNCATE_SEQ = 32,  /* send truncate_{seq,size} */
453 };
454 
455 enum {
456 	CEPH_OSD_WATCH_OP_UNWATCH = 0,
457 	CEPH_OSD_WATCH_OP_LEGACY_WATCH = 1,
458 	/* note: use only ODD ids to prevent pre-giant code from
459 	   interpreting the op as UNWATCH */
460 	CEPH_OSD_WATCH_OP_WATCH = 3,
461 	CEPH_OSD_WATCH_OP_RECONNECT = 5,
462 	CEPH_OSD_WATCH_OP_PING = 7,
463 };
464 
465 const char *ceph_osd_watch_op_name(int o);
466 
467 enum {
468 	CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_WRITE = 1,
469 	CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_WRITE = 2,
470 	CEPH_OSD_ALLOC_HINT_FLAG_SEQUENTIAL_READ = 4,
471 	CEPH_OSD_ALLOC_HINT_FLAG_RANDOM_READ = 8,
472 	CEPH_OSD_ALLOC_HINT_FLAG_APPEND_ONLY = 16,
473 	CEPH_OSD_ALLOC_HINT_FLAG_IMMUTABLE = 32,
474 	CEPH_OSD_ALLOC_HINT_FLAG_SHORTLIVED = 64,
475 	CEPH_OSD_ALLOC_HINT_FLAG_LONGLIVED = 128,
476 	CEPH_OSD_ALLOC_HINT_FLAG_COMPRESSIBLE = 256,
477 	CEPH_OSD_ALLOC_HINT_FLAG_INCOMPRESSIBLE = 512,
478 };
479 
480 enum {
481 	CEPH_OSD_BACKOFF_OP_BLOCK = 1,
482 	CEPH_OSD_BACKOFF_OP_ACK_BLOCK = 2,
483 	CEPH_OSD_BACKOFF_OP_UNBLOCK = 3,
484 };
485 
486 /*
487  * an individual object operation.  each may be accompanied by some data
488  * payload
489  */
490 struct ceph_osd_op {
491 	__le16 op;           /* CEPH_OSD_OP_* */
492 	__le32 flags;        /* CEPH_OSD_OP_FLAG_* */
493 	union {
494 		struct {
495 			__le64 offset, length;
496 			__le64 truncate_size;
497 			__le32 truncate_seq;
498 		} __attribute__ ((packed)) extent;
499 		struct {
500 			__le32 name_len;
501 			__le32 value_len;
502 			__u8 cmp_op;       /* CEPH_OSD_CMPXATTR_OP_* */
503 			__u8 cmp_mode;     /* CEPH_OSD_CMPXATTR_MODE_* */
504 		} __attribute__ ((packed)) xattr;
505 		struct {
506 			__u8 class_len;
507 			__u8 method_len;
508 			__u8 argc;
509 			__le32 indata_len;
510 		} __attribute__ ((packed)) cls;
511 		struct {
512 			__le64 cookie, count;
513 		} __attribute__ ((packed)) pgls;
514 	        struct {
515 		        __le64 snapid;
516 	        } __attribute__ ((packed)) snap;
517 		struct {
518 			__le64 cookie;
519 			__le64 ver;     /* no longer used */
520 			__u8 op;	/* CEPH_OSD_WATCH_OP_* */
521 			__le32 gen;     /* registration generation */
522 		} __attribute__ ((packed)) watch;
523 		struct {
524 			__le64 cookie;
525 		} __attribute__ ((packed)) notify;
526 		struct {
527 			__le64 unused;
528 			__le64 ver;
529 		} __attribute__ ((packed)) assert_ver;
530 		struct {
531 			__le64 offset, length;
532 			__le64 src_offset;
533 		} __attribute__ ((packed)) clonerange;
534 		struct {
535 			__le64 expected_object_size;
536 			__le64 expected_write_size;
537 			__le32 flags;  /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */
538 		} __attribute__ ((packed)) alloc_hint;
539 		struct {
540 			__le64 snapid;
541 			__le64 src_version;
542 			__u8 flags; /* CEPH_OSD_COPY_FROM_FLAG_* */
543 			/*
544 			 * CEPH_OSD_OP_FLAG_FADVISE_*: fadvise flags
545 			 * for src object, flags for dest object are in
546 			 * ceph_osd_op::flags.
547 			 */
548 			__le32 src_fadvise_flags;
549 		} __attribute__ ((packed)) copy_from;
550 	};
551 	__le32 payload_len;
552 } __attribute__ ((packed));
553 
554 
555 #endif
556