Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
f24e9980 SW |
2 | #ifndef _FS_CEPH_OSD_CLIENT_H |
3 | #define _FS_CEPH_OSD_CLIENT_H | |
4 | ||
a02a946d | 5 | #include <linux/bitrev.h> |
f24e9980 | 6 | #include <linux/completion.h> |
415e49a9 | 7 | #include <linux/kref.h> |
f24e9980 SW |
8 | #include <linux/mempool.h> |
9 | #include <linux/rbtree.h> | |
02113a0f | 10 | #include <linux/refcount.h> |
97e27aaa | 11 | #include <linux/ktime.h> |
f24e9980 | 12 | |
6c4a1915 AE |
13 | #include <linux/ceph/types.h> |
14 | #include <linux/ceph/osdmap.h> | |
15 | #include <linux/ceph/messenger.h> | |
b2aa5d0b | 16 | #include <linux/ceph/msgpool.h> |
6c4a1915 | 17 | #include <linux/ceph/auth.h> |
c885837f | 18 | #include <linux/ceph/pagelist.h> |
f24e9980 SW |
19 | |
20 | struct ceph_msg; | |
21 | struct ceph_snap_context; | |
22 | struct ceph_osd_request; | |
23 | struct ceph_osd_client; | |
24 | ||
25 | /* | |
26 | * completion callback for async writepages | |
27 | */ | |
85e084fe | 28 | typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *); |
f24e9980 | 29 | |
63244fa1 ID |
30 | #define CEPH_HOMELESS_OSD -1 |
31 | ||
a679e50f JL |
32 | /* |
33 | * A single extent in a SPARSE_READ reply. | |
34 | * | |
35 | * Note that these come from the OSD as little-endian values. On BE arches, | |
36 | * we convert them in-place after receipt. | |
37 | */ | |
38 | struct ceph_sparse_extent { | |
39 | u64 off; | |
40 | u64 len; | |
41 | } __packed; | |
42 | ||
f628d799 JL |
43 | /* Sparse read state machine state values */ |
44 | enum ceph_sparse_read_state { | |
45 | CEPH_SPARSE_READ_HDR = 0, | |
46 | CEPH_SPARSE_READ_EXTENTS, | |
47 | CEPH_SPARSE_READ_DATA_LEN, | |
cd7d469c | 48 | CEPH_SPARSE_READ_DATA_PRE, |
f628d799 JL |
49 | CEPH_SPARSE_READ_DATA, |
50 | }; | |
51 | ||
52 | /* | |
53 | * A SPARSE_READ reply is a 32-bit count of extents, followed by an array of | |
54 | * 64-bit offset/length pairs, and then all of the actual file data | |
55 | * concatenated after it (sans holes). | |
56 | * | |
57 | * Unfortunately, we don't know how long the extent array is until we've | |
58 | * started reading the data section of the reply. The caller should send down | |
59 | * a destination buffer for the array, but we'll alloc one if it's too small | |
60 | * or if the caller doesn't. | |
61 | */ | |
62 | struct ceph_sparse_read { | |
63 | enum ceph_sparse_read_state sr_state; /* state machine state */ | |
64 | u64 sr_req_off; /* orig request offset */ | |
65 | u64 sr_req_len; /* orig request length */ | |
66 | u64 sr_pos; /* current pos in buffer */ | |
67 | int sr_index; /* current extent index */ | |
cd7d469c | 68 | u32 sr_datalen; /* length of actual data */ |
f628d799 JL |
69 | u32 sr_count; /* extent count in reply */ |
70 | int sr_ext_len; /* length of extent array */ | |
71 | struct ceph_sparse_extent *sr_extent; /* extent array */ | |
72 | }; | |
73 | ||
08b8a044 JL |
74 | /* |
75 | * A given osd we're communicating with. | |
76 | * | |
77 | * Note that the o_requests tree can be searched while holding the "lock" mutex | |
78 | * or the "o_requests_lock" spinlock. Insertion or removal requires both! | |
79 | */ | |
f24e9980 | 80 | struct ceph_osd { |
02113a0f | 81 | refcount_t o_ref; |
f628d799 | 82 | int o_sparse_op_idx; |
f24e9980 SW |
83 | struct ceph_osd_client *o_osdc; |
84 | int o_osd; | |
85 | int o_incarnation; | |
86 | struct rb_node o_node; | |
87 | struct ceph_connection o_con; | |
08b8a044 | 88 | spinlock_t o_requests_lock; |
5aea3dcd | 89 | struct rb_root o_requests; |
922dab61 | 90 | struct rb_root o_linger_requests; |
a02a946d ID |
91 | struct rb_root o_backoff_mappings; |
92 | struct rb_root o_backoffs_by_id; | |
f5a2041b | 93 | struct list_head o_osd_lru; |
6c4a1915 | 94 | struct ceph_auth_handshake o_auth; |
f5a2041b | 95 | unsigned long lru_ttl; |
422d2cb8 | 96 | struct list_head o_keepalive_item; |
5aea3dcd | 97 | struct mutex lock; |
f628d799 | 98 | struct ceph_sparse_read o_sparse_read; |
f24e9980 SW |
99 | }; |
100 | ||
3f1af42a ID |
101 | #define CEPH_OSD_SLAB_OPS 2 |
102 | #define CEPH_OSD_MAX_OPS 16 | |
1b83bef2 | 103 | |
2ac2b7a6 | 104 | enum ceph_osd_data_type { |
ec9123c5 | 105 | CEPH_OSD_DATA_TYPE_NONE = 0, |
2ac2b7a6 | 106 | CEPH_OSD_DATA_TYPE_PAGES, |
9a5e6d09 | 107 | CEPH_OSD_DATA_TYPE_PAGELIST, |
2ac2b7a6 AE |
108 | #ifdef CONFIG_BLOCK |
109 | CEPH_OSD_DATA_TYPE_BIO, | |
110 | #endif /* CONFIG_BLOCK */ | |
b9e281c2 | 111 | CEPH_OSD_DATA_TYPE_BVECS, |
dee0c5f8 | 112 | CEPH_OSD_DATA_TYPE_ITER, |
2ac2b7a6 AE |
113 | }; |
114 | ||
2794a82a | 115 | struct ceph_osd_data { |
2ac2b7a6 AE |
116 | enum ceph_osd_data_type type; |
117 | union { | |
2794a82a AE |
118 | struct { |
119 | struct page **pages; | |
e0c59487 | 120 | u64 length; |
2794a82a AE |
121 | u32 alignment; |
122 | bool pages_from_pool; | |
123 | bool own_pages; | |
124 | }; | |
9a5e6d09 | 125 | struct ceph_pagelist *pagelist; |
2794a82a | 126 | #ifdef CONFIG_BLOCK |
fdce58cc | 127 | struct { |
5359a17d ID |
128 | struct ceph_bio_iter bio_pos; |
129 | u32 bio_length; | |
fdce58cc | 130 | }; |
2794a82a | 131 | #endif /* CONFIG_BLOCK */ |
0010f705 ID |
132 | struct { |
133 | struct ceph_bvec_iter bvec_pos; | |
134 | u32 num_bvecs; | |
135 | }; | |
dee0c5f8 | 136 | struct iov_iter iter; |
2794a82a AE |
137 | }; |
138 | }; | |
139 | ||
79528734 AE |
140 | struct ceph_osd_req_op { |
141 | u16 op; /* CEPH_OSD_OP_* */ | |
7b25bf5f | 142 | u32 flags; /* CEPH_OSD_OP_FLAG_* */ |
de2aa102 | 143 | u32 indata_len; /* request */ |
7665d85b YZ |
144 | u32 outdata_len; /* reply */ |
145 | s32 rval; | |
146 | ||
79528734 | 147 | union { |
49719778 | 148 | struct ceph_osd_data raw_data_in; |
79528734 AE |
149 | struct { |
150 | u64 offset, length; | |
151 | u64 truncate_size; | |
152 | u32 truncate_seq; | |
a679e50f JL |
153 | int sparse_ext_cnt; |
154 | struct ceph_sparse_extent *sparse_ext; | |
5476492f | 155 | struct ceph_osd_data osd_data; |
79528734 | 156 | } extent; |
d74b50be | 157 | struct { |
d7d5a007 ID |
158 | u32 name_len; |
159 | u32 value_len; | |
d74b50be YZ |
160 | __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */ |
161 | __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */ | |
162 | struct ceph_osd_data osd_data; | |
163 | } xattr; | |
79528734 AE |
164 | struct { |
165 | const char *class_name; | |
166 | const char *method_name; | |
5476492f | 167 | struct ceph_osd_data request_info; |
04017e29 | 168 | struct ceph_osd_data request_data; |
5476492f | 169 | struct ceph_osd_data response_data; |
79528734 AE |
170 | __u8 class_len; |
171 | __u8 method_len; | |
bb873b53 | 172 | u32 indata_len; |
79528734 AE |
173 | } cls; |
174 | struct { | |
175 | u64 cookie; | |
922dab61 ID |
176 | __u8 op; /* CEPH_OSD_WATCH_OP_ */ |
177 | u32 gen; | |
79528734 | 178 | } watch; |
922dab61 ID |
179 | struct { |
180 | struct ceph_osd_data request_data; | |
181 | } notify_ack; | |
19079203 ID |
182 | struct { |
183 | u64 cookie; | |
184 | struct ceph_osd_data request_data; | |
185 | struct ceph_osd_data response_data; | |
186 | } notify; | |
a4ed38d7 DF |
187 | struct { |
188 | struct ceph_osd_data response_data; | |
189 | } list_watchers; | |
c647b8a8 ID |
190 | struct { |
191 | u64 expected_object_size; | |
192 | u64 expected_write_size; | |
d3798acc | 193 | u32 flags; /* CEPH_OSD_OP_ALLOC_HINT_FLAG_* */ |
c647b8a8 | 194 | } alloc_hint; |
23ddf9be LH |
195 | struct { |
196 | u64 snapid; | |
197 | u64 src_version; | |
198 | u8 flags; | |
199 | u32 src_fadvise_flags; | |
200 | struct ceph_osd_data osd_data; | |
201 | } copy_from; | |
69dd3b39 JL |
202 | struct { |
203 | u64 ver; | |
204 | } assert_ver; | |
79528734 AE |
205 | }; |
206 | }; | |
207 | ||
63244fa1 ID |
208 | struct ceph_osd_request_target { |
209 | struct ceph_object_id base_oid; | |
210 | struct ceph_object_locator base_oloc; | |
211 | struct ceph_object_id target_oid; | |
212 | struct ceph_object_locator target_oloc; | |
213 | ||
dc98ff72 ID |
214 | struct ceph_pg pgid; /* last raw pg we mapped to */ |
215 | struct ceph_spg spgid; /* last actual spg we mapped to */ | |
63244fa1 ID |
216 | u32 pg_num; |
217 | u32 pg_num_mask; | |
218 | struct ceph_osds acting; | |
219 | struct ceph_osds up; | |
220 | int size; | |
221 | int min_size; | |
222 | bool sort_bitwise; | |
ae78dd81 | 223 | bool recovery_deletes; |
63244fa1 ID |
224 | |
225 | unsigned int flags; /* CEPH_OSD_FLAG_* */ | |
117d96a0 | 226 | bool used_replica; |
63244fa1 ID |
227 | bool paused; |
228 | ||
04c7d789 | 229 | u32 epoch; |
dc93e0e2 ID |
230 | u32 last_force_resend; |
231 | ||
63244fa1 ID |
232 | int osd; |
233 | }; | |
234 | ||
f24e9980 SW |
235 | /* an in-flight request */ |
236 | struct ceph_osd_request { | |
237 | u64 r_tid; /* unique for this client */ | |
238 | struct rb_node r_node; | |
4609245e | 239 | struct rb_node r_mc_node; /* map check */ |
88bc1922 | 240 | struct work_struct r_complete_work; |
f24e9980 | 241 | struct ceph_osd *r_osd; |
a66dd383 ID |
242 | |
243 | struct ceph_osd_request_target r_t; | |
244 | #define r_base_oid r_t.base_oid | |
245 | #define r_base_oloc r_t.base_oloc | |
246 | #define r_flags r_t.flags | |
f24e9980 SW |
247 | |
248 | struct ceph_msg *r_request, *r_reply; | |
f24e9980 | 249 | u32 r_sent; /* >0 if r_request is sending/sent */ |
1b83bef2 | 250 | |
79528734 AE |
251 | /* request osd ops array */ |
252 | unsigned int r_num_ops; | |
79528734 | 253 | |
1b83bef2 | 254 | int r_result; |
f24e9980 SW |
255 | |
256 | struct ceph_osd_client *r_osdc; | |
415e49a9 | 257 | struct kref r_kref; |
f24e9980 | 258 | bool r_mempool; |
69dd3b39 | 259 | bool r_linger; /* don't resend on failure */ |
b18b9550 | 260 | struct completion r_completion; /* private to osd_client.c */ |
26be8808 | 261 | ceph_osdc_callback_t r_callback; |
f24e9980 SW |
262 | |
263 | struct inode *r_inode; /* for use by callbacks */ | |
94e85771 | 264 | struct list_head r_private_item; /* ditto */ |
3d14c5d2 | 265 | void *r_priv; /* ditto */ |
f24e9980 | 266 | |
bb873b53 ID |
267 | /* set by submitter */ |
268 | u64 r_snapid; /* for reads, CEPH_NOSNAP o/w */ | |
269 | struct ceph_snap_context *r_snapc; /* for writes */ | |
fac02ddf | 270 | struct timespec64 r_mtime; /* ditto */ |
bb873b53 | 271 | u64 r_data_offset; /* ditto */ |
f24e9980 | 272 | |
bb873b53 | 273 | /* internal */ |
69dd3b39 | 274 | u64 r_version; /* data version sent in reply */ |
bb873b53 | 275 | unsigned long r_stamp; /* jiffies, send or check time */ |
7cc5e38f | 276 | unsigned long r_start_stamp; /* jiffies */ |
97e27aaa XL |
277 | ktime_t r_start_latency; /* ktime_t */ |
278 | ktime_t r_end_latency; /* ktime_t */ | |
bb873b53 | 279 | int r_attempts; |
4609245e | 280 | u32 r_map_dne_bound; |
3f1af42a | 281 | |
5234193e | 282 | struct ceph_osd_req_op r_ops[] __counted_by(r_num_ops); |
f24e9980 SW |
283 | }; |
284 | ||
205ee118 ID |
285 | struct ceph_request_redirect { |
286 | struct ceph_object_locator oloc; | |
287 | }; | |
288 | ||
8cb441c0 ID |
289 | /* |
290 | * osd request identifier | |
291 | * | |
292 | * caller name + incarnation# + tid to unique identify this request | |
293 | */ | |
294 | struct ceph_osd_reqid { | |
295 | struct ceph_entity_name name; | |
296 | __le64 tid; | |
297 | __le32 inc; | |
298 | } __packed; | |
299 | ||
300 | struct ceph_blkin_trace_info { | |
301 | __le64 trace_id; | |
302 | __le64 span_id; | |
303 | __le64 parent_span_id; | |
304 | } __packed; | |
305 | ||
922dab61 ID |
306 | typedef void (*rados_watchcb2_t)(void *arg, u64 notify_id, u64 cookie, |
307 | u64 notifier_id, void *data, size_t data_len); | |
308 | typedef void (*rados_watcherrcb_t)(void *arg, u64 cookie, int err); | |
309 | ||
310 | struct ceph_osd_linger_request { | |
a40c4f10 | 311 | struct ceph_osd_client *osdc; |
922dab61 ID |
312 | u64 linger_id; |
313 | bool committed; | |
19079203 | 314 | bool is_watch; /* watch or notify */ |
922dab61 ID |
315 | |
316 | struct ceph_osd *osd; | |
317 | struct ceph_osd_request *reg_req; | |
318 | struct ceph_osd_request *ping_req; | |
319 | unsigned long ping_sent; | |
b07d3c4b ID |
320 | unsigned long watch_valid_thru; |
321 | struct list_head pending_lworks; | |
922dab61 ID |
322 | |
323 | struct ceph_osd_request_target t; | |
4609245e | 324 | u32 map_dne_bound; |
922dab61 | 325 | |
fac02ddf | 326 | struct timespec64 mtime; |
922dab61 | 327 | |
a40c4f10 | 328 | struct kref kref; |
922dab61 ID |
329 | struct mutex lock; |
330 | struct rb_node node; /* osd */ | |
331 | struct rb_node osdc_node; /* osdc */ | |
4609245e | 332 | struct rb_node mc_node; /* map check */ |
922dab61 ID |
333 | struct list_head scan_item; |
334 | ||
335 | struct completion reg_commit_wait; | |
19079203 | 336 | struct completion notify_finish_wait; |
922dab61 | 337 | int reg_commit_error; |
19079203 | 338 | int notify_finish_error; |
922dab61 ID |
339 | int last_error; |
340 | ||
341 | u32 register_gen; | |
19079203 | 342 | u64 notify_id; |
a40c4f10 | 343 | |
922dab61 ID |
344 | rados_watchcb2_t wcb; |
345 | rados_watcherrcb_t errcb; | |
346 | void *data; | |
19079203 | 347 | |
75dbb685 ID |
348 | struct ceph_pagelist *request_pl; |
349 | struct page **notify_id_pages; | |
350 | ||
19079203 ID |
351 | struct page ***preply_pages; |
352 | size_t *preply_len; | |
a40c4f10 YS |
353 | }; |
354 | ||
a4ed38d7 DF |
355 | struct ceph_watch_item { |
356 | struct ceph_entity_name name; | |
357 | u64 cookie; | |
358 | struct ceph_entity_addr addr; | |
359 | }; | |
360 | ||
a02a946d ID |
361 | struct ceph_spg_mapping { |
362 | struct rb_node node; | |
363 | struct ceph_spg spgid; | |
364 | ||
365 | struct rb_root backoffs; | |
366 | }; | |
367 | ||
368 | struct ceph_hobject_id { | |
369 | void *key; | |
370 | size_t key_len; | |
371 | void *oid; | |
372 | size_t oid_len; | |
373 | u64 snapid; | |
374 | u32 hash; | |
375 | u8 is_max; | |
376 | void *nspace; | |
377 | size_t nspace_len; | |
378 | s64 pool; | |
379 | ||
380 | /* cache */ | |
381 | u32 hash_reverse_bits; | |
382 | }; | |
383 | ||
384 | static inline void ceph_hoid_build_hash_cache(struct ceph_hobject_id *hoid) | |
385 | { | |
386 | hoid->hash_reverse_bits = bitrev32(hoid->hash); | |
387 | } | |
388 | ||
389 | /* | |
390 | * PG-wide backoff: [begin, end) | |
391 | * per-object backoff: begin == end | |
392 | */ | |
393 | struct ceph_osd_backoff { | |
394 | struct rb_node spg_node; | |
395 | struct rb_node id_node; | |
396 | ||
397 | struct ceph_spg spgid; | |
398 | u64 id; | |
399 | struct ceph_hobject_id *begin; | |
400 | struct ceph_hobject_id *end; | |
401 | }; | |
402 | ||
264048af ID |
403 | #define CEPH_LINGER_ID_START 0xffff000000000000ULL |
404 | ||
f24e9980 SW |
405 | struct ceph_osd_client { |
406 | struct ceph_client *client; | |
407 | ||
408 | struct ceph_osdmap *osdmap; /* current map */ | |
5aea3dcd | 409 | struct rw_semaphore lock; |
f24e9980 | 410 | |
f24e9980 | 411 | struct rb_root osds; /* osds */ |
f5a2041b | 412 | struct list_head osd_lru; /* idle osds */ |
9dd2845c | 413 | spinlock_t osd_lru_lock; |
58eb7932 | 414 | u32 epoch_barrier; |
5aea3dcd ID |
415 | struct ceph_osd homeless_osd; |
416 | atomic64_t last_tid; /* tid of last request */ | |
922dab61 ID |
417 | u64 last_linger_id; |
418 | struct rb_root linger_requests; /* lingering requests */ | |
4609245e ID |
419 | struct rb_root map_checks; |
420 | struct rb_root linger_map_checks; | |
5aea3dcd ID |
421 | atomic_t num_requests; |
422 | atomic_t num_homeless; | |
66850df5 | 423 | int abort_err; |
f24e9980 | 424 | struct delayed_work timeout_work; |
f5a2041b | 425 | struct delayed_work osds_timeout_work; |
039934b8 | 426 | #ifdef CONFIG_DEBUG_FS |
f24e9980 | 427 | struct dentry *debugfs_file; |
039934b8 | 428 | #endif |
f24e9980 SW |
429 | |
430 | mempool_t *req_mempool; | |
431 | ||
0d59ab81 | 432 | struct ceph_msgpool msgpool_op; |
c16e7869 | 433 | struct ceph_msgpool msgpool_op_reply; |
a40c4f10 | 434 | |
a40c4f10 | 435 | struct workqueue_struct *notify_wq; |
88bc1922 | 436 | struct workqueue_struct *completion_wq; |
f24e9980 SW |
437 | }; |
438 | ||
b7ec35b3 ID |
439 | static inline bool ceph_osdmap_flag(struct ceph_osd_client *osdc, int flag) |
440 | { | |
441 | return osdc->osdmap->flags & flag; | |
442 | } | |
443 | ||
5522ae0b AE |
444 | extern int ceph_osdc_setup(void); |
445 | extern void ceph_osdc_cleanup(void); | |
446 | ||
f24e9980 SW |
447 | extern int ceph_osdc_init(struct ceph_osd_client *osdc, |
448 | struct ceph_client *client); | |
449 | extern void ceph_osdc_stop(struct ceph_osd_client *osdc); | |
120a75ea | 450 | extern void ceph_osdc_reopen_osds(struct ceph_osd_client *osdc); |
f24e9980 SW |
451 | |
452 | extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc, | |
453 | struct ceph_msg *msg); | |
454 | extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc, | |
455 | struct ceph_msg *msg); | |
58eb7932 | 456 | void ceph_osdc_update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb); |
66850df5 | 457 | void ceph_osdc_abort_requests(struct ceph_osd_client *osdc, int err); |
2cef0ba8 | 458 | void ceph_osdc_clear_abort_err(struct ceph_osd_client *osdc); |
f24e9980 | 459 | |
4cf3e6df ID |
460 | #define osd_req_op_data(oreq, whch, typ, fld) \ |
461 | ({ \ | |
462 | struct ceph_osd_request *__oreq = (oreq); \ | |
463 | unsigned int __whch = (whch); \ | |
464 | BUG_ON(__whch >= __oreq->r_num_ops); \ | |
465 | &__oreq->r_ops[__whch].typ.fld; \ | |
466 | }) | |
467 | ||
042f6498 | 468 | struct ceph_osd_req_op *osd_req_op_init(struct ceph_osd_request *osd_req, |
144cba14 | 469 | unsigned int which, u16 opcode, u32 flags); |
49719778 AE |
470 | |
471 | extern void osd_req_op_raw_data_in_pages(struct ceph_osd_request *, | |
472 | unsigned int which, | |
473 | struct page **pages, u64 length, | |
474 | u32 alignment, bool pages_from_pool, | |
475 | bool own_pages); | |
476 | ||
c99d2d4a AE |
477 | extern void osd_req_op_extent_init(struct ceph_osd_request *osd_req, |
478 | unsigned int which, u16 opcode, | |
33803f33 AE |
479 | u64 offset, u64 length, |
480 | u64 truncate_size, u32 truncate_seq); | |
c99d2d4a AE |
481 | extern void osd_req_op_extent_update(struct ceph_osd_request *osd_req, |
482 | unsigned int which, u64 length); | |
2c63f49a YZ |
483 | extern void osd_req_op_extent_dup_last(struct ceph_osd_request *osd_req, |
484 | unsigned int which, u64 offset_inc); | |
a4ce40a9 AE |
485 | |
486 | extern struct ceph_osd_data *osd_req_op_extent_osd_data( | |
487 | struct ceph_osd_request *osd_req, | |
406e2c9f | 488 | unsigned int which); |
a4ce40a9 AE |
489 | |
490 | extern void osd_req_op_extent_osd_data_pages(struct ceph_osd_request *, | |
406e2c9f | 491 | unsigned int which, |
a4ce40a9 AE |
492 | struct page **pages, u64 length, |
493 | u32 alignment, bool pages_from_pool, | |
494 | bool own_pages); | |
495 | extern void osd_req_op_extent_osd_data_pagelist(struct ceph_osd_request *, | |
406e2c9f | 496 | unsigned int which, |
a4ce40a9 AE |
497 | struct ceph_pagelist *pagelist); |
498 | #ifdef CONFIG_BLOCK | |
5359a17d ID |
499 | void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *osd_req, |
500 | unsigned int which, | |
501 | struct ceph_bio_iter *bio_pos, | |
502 | u32 bio_length); | |
a4ce40a9 | 503 | #endif /* CONFIG_BLOCK */ |
0010f705 ID |
504 | void osd_req_op_extent_osd_data_bvecs(struct ceph_osd_request *osd_req, |
505 | unsigned int which, | |
506 | struct bio_vec *bvecs, u32 num_bvecs, | |
507 | u32 bytes); | |
b9e281c2 ID |
508 | void osd_req_op_extent_osd_data_bvec_pos(struct ceph_osd_request *osd_req, |
509 | unsigned int which, | |
510 | struct ceph_bvec_iter *bvec_pos); | |
dee0c5f8 JL |
511 | void osd_req_op_extent_osd_iter(struct ceph_osd_request *osd_req, |
512 | unsigned int which, struct iov_iter *iter); | |
a4ce40a9 | 513 | |
04017e29 AE |
514 | extern void osd_req_op_cls_request_data_pagelist(struct ceph_osd_request *, |
515 | unsigned int which, | |
516 | struct ceph_pagelist *pagelist); | |
6c57b554 AE |
517 | extern void osd_req_op_cls_request_data_pages(struct ceph_osd_request *, |
518 | unsigned int which, | |
519 | struct page **pages, u64 length, | |
520 | u32 alignment, bool pages_from_pool, | |
521 | bool own_pages); | |
b9e281c2 ID |
522 | void osd_req_op_cls_request_data_bvecs(struct ceph_osd_request *osd_req, |
523 | unsigned int which, | |
0010f705 ID |
524 | struct bio_vec *bvecs, u32 num_bvecs, |
525 | u32 bytes); | |
a4ce40a9 | 526 | extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *, |
c99d2d4a | 527 | unsigned int which, |
a4ce40a9 AE |
528 | struct page **pages, u64 length, |
529 | u32 alignment, bool pages_from_pool, | |
530 | bool own_pages); | |
24639ce5 ID |
531 | int osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which, |
532 | const char *class, const char *method); | |
d74b50be YZ |
533 | extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which, |
534 | u16 opcode, const char *name, const void *value, | |
535 | size_t size, u8 cmp_op, u8 cmp_mode); | |
c647b8a8 ID |
536 | extern void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req, |
537 | unsigned int which, | |
538 | u64 expected_object_size, | |
d3798acc ID |
539 | u64 expected_write_size, |
540 | u32 flags); | |
aca39d9e LH |
541 | extern int osd_req_op_copy_from_init(struct ceph_osd_request *req, |
542 | u64 src_snapid, u64 src_version, | |
543 | struct ceph_object_id *src_oid, | |
544 | struct ceph_object_locator *src_oloc, | |
545 | u32 src_fadvise_flags, | |
546 | u32 dst_fadvise_flags, | |
547 | u32 truncate_seq, u64 truncate_size, | |
548 | u8 copy_from_flags); | |
33803f33 | 549 | |
3499e8a5 | 550 | extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, |
3499e8a5 | 551 | struct ceph_snap_context *snapc, |
acead002 | 552 | unsigned int num_ops, |
3499e8a5 | 553 | bool use_mempool, |
54a54007 | 554 | gfp_t gfp_flags); |
13d1ad16 | 555 | int ceph_osdc_alloc_messages(struct ceph_osd_request *req, gfp_t gfp); |
3499e8a5 | 556 | |
f24e9980 SW |
557 | extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *, |
558 | struct ceph_file_layout *layout, | |
559 | struct ceph_vino vino, | |
acead002 | 560 | u64 offset, u64 *len, |
715e4cd4 YZ |
561 | unsigned int which, int num_ops, |
562 | int opcode, int flags, | |
f24e9980 | 563 | struct ceph_snap_context *snapc, |
acead002 | 564 | u32 truncate_seq, u64 truncate_size, |
153e5167 | 565 | bool use_mempool); |
f24e9980 | 566 | |
a679e50f JL |
567 | int __ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op, int cnt); |
568 | ||
569 | /* | |
570 | * How big an extent array should we preallocate for a sparse read? This is | |
571 | * just a starting value. If we get more than this back from the OSD, the | |
572 | * receiver will reallocate. | |
573 | */ | |
574 | #define CEPH_SPARSE_EXT_ARRAY_INITIAL 16 | |
575 | ||
aaefabc4 | 576 | static inline int ceph_alloc_sparse_ext_map(struct ceph_osd_req_op *op, int cnt) |
a679e50f | 577 | { |
aaefabc4 XL |
578 | if (!cnt) |
579 | cnt = CEPH_SPARSE_EXT_ARRAY_INITIAL; | |
580 | ||
581 | return __ceph_alloc_sparse_ext_map(op, cnt); | |
a679e50f JL |
582 | } |
583 | ||
9e94af20 ID |
584 | extern void ceph_osdc_get_request(struct ceph_osd_request *req); |
585 | extern void ceph_osdc_put_request(struct ceph_osd_request *req); | |
f24e9980 | 586 | |
a8af0d68 JL |
587 | void ceph_osdc_start_request(struct ceph_osd_client *osdc, |
588 | struct ceph_osd_request *req); | |
c9f9b93d | 589 | extern void ceph_osdc_cancel_request(struct ceph_osd_request *req); |
f24e9980 SW |
590 | extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc, |
591 | struct ceph_osd_request *req); | |
592 | extern void ceph_osdc_sync(struct ceph_osd_client *osdc); | |
593 | ||
dd935f44 | 594 | extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc); |
7cca78c9 | 595 | void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc); |
dd935f44 | 596 | |
428a7158 DF |
597 | int ceph_osdc_call(struct ceph_osd_client *osdc, |
598 | struct ceph_object_id *oid, | |
599 | struct ceph_object_locator *oloc, | |
600 | const char *class, const char *method, | |
601 | unsigned int flags, | |
602 | struct page *req_page, size_t req_len, | |
68ada915 | 603 | struct page **resp_pages, size_t *resp_len); |
428a7158 | 604 | |
922dab61 ID |
605 | /* watch/notify */ |
606 | struct ceph_osd_linger_request * | |
607 | ceph_osdc_watch(struct ceph_osd_client *osdc, | |
608 | struct ceph_object_id *oid, | |
609 | struct ceph_object_locator *oloc, | |
610 | rados_watchcb2_t wcb, | |
611 | rados_watcherrcb_t errcb, | |
612 | void *data); | |
613 | int ceph_osdc_unwatch(struct ceph_osd_client *osdc, | |
614 | struct ceph_osd_linger_request *lreq); | |
615 | ||
616 | int ceph_osdc_notify_ack(struct ceph_osd_client *osdc, | |
617 | struct ceph_object_id *oid, | |
618 | struct ceph_object_locator *oloc, | |
619 | u64 notify_id, | |
620 | u64 cookie, | |
621 | void *payload, | |
6d54228f | 622 | u32 payload_len); |
19079203 ID |
623 | int ceph_osdc_notify(struct ceph_osd_client *osdc, |
624 | struct ceph_object_id *oid, | |
625 | struct ceph_object_locator *oloc, | |
626 | void *payload, | |
6d54228f | 627 | u32 payload_len, |
19079203 ID |
628 | u32 timeout, |
629 | struct page ***preply_pages, | |
630 | size_t *preply_len); | |
b07d3c4b ID |
631 | int ceph_osdc_watch_check(struct ceph_osd_client *osdc, |
632 | struct ceph_osd_linger_request *lreq); | |
a4ed38d7 DF |
633 | int ceph_osdc_list_watchers(struct ceph_osd_client *osdc, |
634 | struct ceph_object_id *oid, | |
635 | struct ceph_object_locator *oloc, | |
636 | struct ceph_watch_item **watchers, | |
637 | u32 *num_watchers); | |
f24e9980 | 638 | |
a679e50f JL |
639 | /* Find offset into the buffer of the end of the extent map */ |
640 | static inline u64 ceph_sparse_ext_map_end(struct ceph_osd_req_op *op) | |
641 | { | |
642 | struct ceph_sparse_extent *ext; | |
643 | ||
644 | /* No extents? No data */ | |
645 | if (op->extent.sparse_ext_cnt == 0) | |
646 | return 0; | |
647 | ||
648 | ext = &op->extent.sparse_ext[op->extent.sparse_ext_cnt - 1]; | |
649 | ||
650 | return ext->off + ext->len - op->extent.offset; | |
651 | } | |
652 | ||
653 | #endif |