blob: adf670ecaf94688449f92f240dd3f0bde3b87500 [file] [log] [blame]
Sage Weilf24e9982009-10-06 11:31:10 -07001#ifndef _FS_CEPH_OSD_CLIENT_H
2#define _FS_CEPH_OSD_CLIENT_H
3
Ilya Dryomova02a9462017-06-19 12:18:05 +02004#include <linux/bitrev.h>
Sage Weilf24e9982009-10-06 11:31:10 -07005#include <linux/completion.h>
Sage Weil415e49a2009-12-07 13:37:03 -08006#include <linux/kref.h>
Sage Weilf24e9982009-10-06 11:31:10 -07007#include <linux/mempool.h>
8#include <linux/rbtree.h>
Elena Reshetova02113a02017-03-17 14:10:28 +02009#include <linux/refcount.h>
Sage Weilf24e9982009-10-06 11:31:10 -070010
Alex Elder6c4a1912012-05-16 15:16:38 -050011#include <linux/ceph/types.h>
12#include <linux/ceph/osdmap.h>
13#include <linux/ceph/messenger.h>
Ilya Dryomovb2aa5d02016-06-07 21:57:15 +020014#include <linux/ceph/msgpool.h>
Alex Elder6c4a1912012-05-16 15:16:38 -050015#include <linux/ceph/auth.h>
Alex Elderc8858372012-11-13 21:11:15 -060016#include <linux/ceph/pagelist.h>
Sage Weilf24e9982009-10-06 11:31:10 -070017
18struct ceph_msg;
19struct ceph_snap_context;
20struct ceph_osd_request;
21struct ceph_osd_client;
22
23/*
24 * completion callback for async writepages
25 */
Ilya Dryomov85e084f2016-04-28 16:07:24 +020026typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *);
Sage Weilf24e9982009-10-06 11:31:10 -070027
Ilya Dryomov63244fa2016-04-28 16:07:23 +020028#define CEPH_HOMELESS_OSD -1
29
Sage Weilf24e9982009-10-06 11:31:10 -070030/* a given osd we're communicating with */
31struct ceph_osd {
Elena Reshetova02113a02017-03-17 14:10:28 +020032 refcount_t o_ref;
Sage Weilf24e9982009-10-06 11:31:10 -070033 struct ceph_osd_client *o_osdc;
34 int o_osd;
35 int o_incarnation;
36 struct rb_node o_node;
37 struct ceph_connection o_con;
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +020038 struct rb_root o_requests;
Ilya Dryomov922dab62016-05-26 01:15:02 +020039 struct rb_root o_linger_requests;
Ilya Dryomova02a9462017-06-19 12:18:05 +020040 struct rb_root o_backoff_mappings;
41 struct rb_root o_backoffs_by_id;
Yehuda Sadehf5a20412010-02-03 11:00:26 -080042 struct list_head o_osd_lru;
Alex Elder6c4a1912012-05-16 15:16:38 -050043 struct ceph_auth_handshake o_auth;
Yehuda Sadehf5a20412010-02-03 11:00:26 -080044 unsigned long lru_ttl;
Yehuda Sadeh422d2cb2010-02-26 15:32:31 -080045 struct list_head o_keepalive_item;
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +020046 struct mutex lock;
Sage Weilf24e9982009-10-06 11:31:10 -070047};
48
Ilya Dryomov3f1af422016-02-09 17:50:15 +010049#define CEPH_OSD_SLAB_OPS 2
50#define CEPH_OSD_MAX_OPS 16
Sage Weil1b83bef2013-02-25 16:11:12 -080051
Alex Elder2ac2b7a2013-02-14 12:16:43 -060052enum ceph_osd_data_type {
Alex Elderec9123c2013-04-05 01:27:12 -050053 CEPH_OSD_DATA_TYPE_NONE = 0,
Alex Elder2ac2b7a2013-02-14 12:16:43 -060054 CEPH_OSD_DATA_TYPE_PAGES,
Alex Elder9a5e6d02013-03-08 13:35:36 -060055 CEPH_OSD_DATA_TYPE_PAGELIST,
Alex Elder2ac2b7a2013-02-14 12:16:43 -060056#ifdef CONFIG_BLOCK
57 CEPH_OSD_DATA_TYPE_BIO,
58#endif /* CONFIG_BLOCK */
59};
60
Alex Elder2794a822013-02-14 12:16:43 -060061struct ceph_osd_data {
Alex Elder2ac2b7a2013-02-14 12:16:43 -060062 enum ceph_osd_data_type type;
63 union {
Alex Elder2794a822013-02-14 12:16:43 -060064 struct {
65 struct page **pages;
Alex Eldere0c59482013-03-07 15:38:25 -060066 u64 length;
Alex Elder2794a822013-02-14 12:16:43 -060067 u32 alignment;
68 bool pages_from_pool;
69 bool own_pages;
70 };
Alex Elder9a5e6d02013-03-08 13:35:36 -060071 struct ceph_pagelist *pagelist;
Alex Elder2794a822013-02-14 12:16:43 -060072#ifdef CONFIG_BLOCK
Alex Elderfdce58c2013-03-14 14:09:06 -050073 struct {
74 struct bio *bio; /* list of bios */
75 size_t bio_length; /* total in list */
76 };
Alex Elder2794a822013-02-14 12:16:43 -060077#endif /* CONFIG_BLOCK */
78 };
79};
80
Alex Elder79528732013-04-03 21:32:51 -050081struct ceph_osd_req_op {
82 u16 op; /* CEPH_OSD_OP_* */
Ilya Dryomov7b25bf52014-02-25 16:22:26 +020083 u32 flags; /* CEPH_OSD_OP_FLAG_* */
Ilya Dryomovde2aa102016-02-08 13:39:46 +010084 u32 indata_len; /* request */
Yan, Zheng7665d852016-01-07 16:48:57 +080085 u32 outdata_len; /* reply */
86 s32 rval;
87
Alex Elder79528732013-04-03 21:32:51 -050088 union {
Alex Elder49719772013-02-11 12:33:24 -060089 struct ceph_osd_data raw_data_in;
Alex Elder79528732013-04-03 21:32:51 -050090 struct {
91 u64 offset, length;
92 u64 truncate_size;
93 u32 truncate_seq;
Alex Elder54764922013-04-05 01:27:12 -050094 struct ceph_osd_data osd_data;
Alex Elder79528732013-04-03 21:32:51 -050095 } extent;
96 struct {
Ilya Dryomovd7d5a002014-12-19 14:00:41 +030097 u32 name_len;
98 u32 value_len;
Yan, Zhengd74b50b2014-11-12 14:00:43 +080099 __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */
100 __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */
101 struct ceph_osd_data osd_data;
102 } xattr;
103 struct {
Alex Elder79528732013-04-03 21:32:51 -0500104 const char *class_name;
105 const char *method_name;
Alex Elder54764922013-04-05 01:27:12 -0500106 struct ceph_osd_data request_info;
Alex Elder04017e22013-04-05 14:46:02 -0500107 struct ceph_osd_data request_data;
Alex Elder54764922013-04-05 01:27:12 -0500108 struct ceph_osd_data response_data;
Alex Elder79528732013-04-03 21:32:51 -0500109 __u8 class_len;
110 __u8 method_len;
Ilya Dryomovbb873b5392016-05-26 00:29:52 +0200111 u32 indata_len;
Alex Elder79528732013-04-03 21:32:51 -0500112 } cls;
113 struct {
114 u64 cookie;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200115 __u8 op; /* CEPH_OSD_WATCH_OP_ */
116 u32 gen;
Alex Elder79528732013-04-03 21:32:51 -0500117 } watch;
Ilya Dryomovc647b8a2014-02-25 16:22:27 +0200118 struct {
Ilya Dryomov922dab62016-05-26 01:15:02 +0200119 struct ceph_osd_data request_data;
120 } notify_ack;
121 struct {
Ilya Dryomov19079202016-04-28 16:07:27 +0200122 u64 cookie;
123 struct ceph_osd_data request_data;
124 struct ceph_osd_data response_data;
125 } notify;
126 struct {
Douglas Fullera4ed38d2015-07-17 13:18:07 -0700127 struct ceph_osd_data response_data;
128 } list_watchers;
129 struct {
Ilya Dryomovc647b8a2014-02-25 16:22:27 +0200130 u64 expected_object_size;
131 u64 expected_write_size;
132 } alloc_hint;
Alex Elder79528732013-04-03 21:32:51 -0500133 };
134};
135
Ilya Dryomov63244fa2016-04-28 16:07:23 +0200136struct ceph_osd_request_target {
137 struct ceph_object_id base_oid;
138 struct ceph_object_locator base_oloc;
139 struct ceph_object_id target_oid;
140 struct ceph_object_locator target_oloc;
141
Ilya Dryomovdc98ff72017-06-15 16:30:53 +0200142 struct ceph_pg pgid; /* last raw pg we mapped to */
143 struct ceph_spg spgid; /* last actual spg we mapped to */
Ilya Dryomov63244fa2016-04-28 16:07:23 +0200144 u32 pg_num;
145 u32 pg_num_mask;
146 struct ceph_osds acting;
147 struct ceph_osds up;
148 int size;
149 int min_size;
150 bool sort_bitwise;
Ilya Dryomovae78dd82017-07-27 17:59:14 +0200151 bool recovery_deletes;
Ilya Dryomov63244fa2016-04-28 16:07:23 +0200152
153 unsigned int flags; /* CEPH_OSD_FLAG_* */
154 bool paused;
155
Ilya Dryomov04c7d782017-06-15 16:30:55 +0200156 u32 epoch;
Ilya Dryomovdc93e0e2017-06-05 14:45:00 +0200157 u32 last_force_resend;
158
Ilya Dryomov63244fa2016-04-28 16:07:23 +0200159 int osd;
160};
161
Sage Weilf24e9982009-10-06 11:31:10 -0700162/* an in-flight request */
163struct ceph_osd_request {
164 u64 r_tid; /* unique for this client */
165 struct rb_node r_node;
Ilya Dryomov46092452016-04-28 16:07:27 +0200166 struct rb_node r_mc_node; /* map check */
Sage Weilf24e9982009-10-06 11:31:10 -0700167 struct ceph_osd *r_osd;
Ilya Dryomova66dd382016-04-28 16:07:23 +0200168
169 struct ceph_osd_request_target r_t;
170#define r_base_oid r_t.base_oid
171#define r_base_oloc r_t.base_oloc
172#define r_flags r_t.flags
Sage Weilf24e9982009-10-06 11:31:10 -0700173
174 struct ceph_msg *r_request, *r_reply;
Sage Weilf24e9982009-10-06 11:31:10 -0700175 u32 r_sent; /* >0 if r_request is sending/sent */
Sage Weil1b83bef2013-02-25 16:11:12 -0800176
Alex Elder79528732013-04-03 21:32:51 -0500177 /* request osd ops array */
178 unsigned int r_num_ops;
Alex Elder79528732013-04-03 21:32:51 -0500179
Sage Weil1b83bef2013-02-25 16:11:12 -0800180 int r_result;
Sage Weilf24e9982009-10-06 11:31:10 -0700181
182 struct ceph_osd_client *r_osdc;
Sage Weil415e49a2009-12-07 13:37:03 -0800183 struct kref r_kref;
Sage Weilf24e9982009-10-06 11:31:10 -0700184 bool r_mempool;
Ilya Dryomovb18b9552017-02-11 18:46:08 +0100185 struct completion r_completion; /* private to osd_client.c */
Alex Elder26be8802013-04-15 11:20:42 -0500186 ceph_osdc_callback_t r_callback;
Sage Weilf24e9982009-10-06 11:31:10 -0700187 struct list_head r_unsafe_item;
188
189 struct inode *r_inode; /* for use by callbacks */
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700190 void *r_priv; /* ditto */
Sage Weilf24e9982009-10-06 11:31:10 -0700191
Ilya Dryomovbb873b5392016-05-26 00:29:52 +0200192 /* set by submitter */
193 u64 r_snapid; /* for reads, CEPH_NOSNAP o/w */
194 struct ceph_snap_context *r_snapc; /* for writes */
195 struct timespec r_mtime; /* ditto */
196 u64 r_data_offset; /* ditto */
Ilya Dryomov922dab62016-05-26 01:15:02 +0200197 bool r_linger; /* don't resend on failure */
Jeff Laytona1f40202017-04-04 08:39:37 -0400198 bool r_abort_on_full; /* return ENOSPC when full */
Sage Weilf24e9982009-10-06 11:31:10 -0700199
Ilya Dryomovbb873b5392016-05-26 00:29:52 +0200200 /* internal */
201 unsigned long r_stamp; /* jiffies, send or check time */
Ilya Dryomov7cc5e382017-02-12 17:11:07 +0100202 unsigned long r_start_stamp; /* jiffies */
Ilya Dryomovbb873b5392016-05-26 00:29:52 +0200203 int r_attempts;
Ilya Dryomov46092452016-04-28 16:07:27 +0200204 u32 r_map_dne_bound;
Ilya Dryomov3f1af422016-02-09 17:50:15 +0100205
206 struct ceph_osd_req_op r_ops[];
Sage Weilf24e9982009-10-06 11:31:10 -0700207};
208
Ilya Dryomov205ee1182014-01-27 17:40:20 +0200209struct ceph_request_redirect {
210 struct ceph_object_locator oloc;
211};
212
Ilya Dryomov8cb441c2017-06-15 16:30:54 +0200213/*
214 * osd request identifier
215 *
216 * caller name + incarnation# + tid to unique identify this request
217 */
218struct ceph_osd_reqid {
219 struct ceph_entity_name name;
220 __le64 tid;
221 __le32 inc;
222} __packed;
223
224struct ceph_blkin_trace_info {
225 __le64 trace_id;
226 __le64 span_id;
227 __le64 parent_span_id;
228} __packed;
229
Ilya Dryomov922dab62016-05-26 01:15:02 +0200230typedef void (*rados_watchcb2_t)(void *arg, u64 notify_id, u64 cookie,
231 u64 notifier_id, void *data, size_t data_len);
232typedef void (*rados_watcherrcb_t)(void *arg, u64 cookie, int err);
Yehuda Sadeha40c4f12011-03-21 15:07:16 -0700233
Ilya Dryomov922dab62016-05-26 01:15:02 +0200234struct ceph_osd_linger_request {
235 struct ceph_osd_client *osdc;
236 u64 linger_id;
237 bool committed;
Ilya Dryomov19079202016-04-28 16:07:27 +0200238 bool is_watch; /* watch or notify */
Ilya Dryomov922dab62016-05-26 01:15:02 +0200239
240 struct ceph_osd *osd;
241 struct ceph_osd_request *reg_req;
242 struct ceph_osd_request *ping_req;
243 unsigned long ping_sent;
Ilya Dryomovb07d3c42016-04-28 16:07:27 +0200244 unsigned long watch_valid_thru;
245 struct list_head pending_lworks;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200246
247 struct ceph_osd_request_target t;
Ilya Dryomov46092452016-04-28 16:07:27 +0200248 u32 map_dne_bound;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200249
250 struct timespec mtime;
251
252 struct kref kref;
253 struct mutex lock;
254 struct rb_node node; /* osd */
255 struct rb_node osdc_node; /* osdc */
Ilya Dryomov46092452016-04-28 16:07:27 +0200256 struct rb_node mc_node; /* map check */
Ilya Dryomov922dab62016-05-26 01:15:02 +0200257 struct list_head scan_item;
258
259 struct completion reg_commit_wait;
Ilya Dryomov19079202016-04-28 16:07:27 +0200260 struct completion notify_finish_wait;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200261 int reg_commit_error;
Ilya Dryomov19079202016-04-28 16:07:27 +0200262 int notify_finish_error;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200263 int last_error;
264
265 u32 register_gen;
Ilya Dryomov19079202016-04-28 16:07:27 +0200266 u64 notify_id;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200267
268 rados_watchcb2_t wcb;
269 rados_watcherrcb_t errcb;
270 void *data;
Ilya Dryomov19079202016-04-28 16:07:27 +0200271
272 struct page ***preply_pages;
273 size_t *preply_len;
Yehuda Sadeha40c4f12011-03-21 15:07:16 -0700274};
275
Douglas Fullera4ed38d2015-07-17 13:18:07 -0700276struct ceph_watch_item {
277 struct ceph_entity_name name;
278 u64 cookie;
279 struct ceph_entity_addr addr;
280};
281
Ilya Dryomova02a9462017-06-19 12:18:05 +0200282struct ceph_spg_mapping {
283 struct rb_node node;
284 struct ceph_spg spgid;
285
286 struct rb_root backoffs;
287};
288
289struct ceph_hobject_id {
290 void *key;
291 size_t key_len;
292 void *oid;
293 size_t oid_len;
294 u64 snapid;
295 u32 hash;
296 u8 is_max;
297 void *nspace;
298 size_t nspace_len;
299 s64 pool;
300
301 /* cache */
302 u32 hash_reverse_bits;
303};
304
305static inline void ceph_hoid_build_hash_cache(struct ceph_hobject_id *hoid)
306{
307 hoid->hash_reverse_bits = bitrev32(hoid->hash);
308}
309
310/*
311 * PG-wide backoff: [begin, end)
312 * per-object backoff: begin == end
313 */
314struct ceph_osd_backoff {
315 struct rb_node spg_node;
316 struct rb_node id_node;
317
318 struct ceph_spg spgid;
319 u64 id;
320 struct ceph_hobject_id *begin;
321 struct ceph_hobject_id *end;
322};
323
Ilya Dryomov264048a2016-11-08 15:15:24 +0100324#define CEPH_LINGER_ID_START 0xffff000000000000ULL
325
Sage Weilf24e9982009-10-06 11:31:10 -0700326struct ceph_osd_client {
327 struct ceph_client *client;
328
329 struct ceph_osdmap *osdmap; /* current map */
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +0200330 struct rw_semaphore lock;
Sage Weilf24e9982009-10-06 11:31:10 -0700331
Sage Weilf24e9982009-10-06 11:31:10 -0700332 struct rb_root osds; /* osds */
Yehuda Sadehf5a20412010-02-03 11:00:26 -0800333 struct list_head osd_lru; /* idle osds */
Ilya Dryomov9dd28452016-04-28 16:07:26 +0200334 spinlock_t osd_lru_lock;
Jeff Layton58eb7932017-04-18 09:21:16 -0400335 u32 epoch_barrier;
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +0200336 struct ceph_osd homeless_osd;
337 atomic64_t last_tid; /* tid of last request */
Ilya Dryomov922dab62016-05-26 01:15:02 +0200338 u64 last_linger_id;
339 struct rb_root linger_requests; /* lingering requests */
Ilya Dryomov46092452016-04-28 16:07:27 +0200340 struct rb_root map_checks;
341 struct rb_root linger_map_checks;
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +0200342 atomic_t num_requests;
343 atomic_t num_homeless;
Sage Weilf24e9982009-10-06 11:31:10 -0700344 struct delayed_work timeout_work;
Yehuda Sadehf5a20412010-02-03 11:00:26 -0800345 struct delayed_work osds_timeout_work;
Sage Weil039934b2009-11-12 15:05:52 -0800346#ifdef CONFIG_DEBUG_FS
Sage Weilf24e9982009-10-06 11:31:10 -0700347 struct dentry *debugfs_file;
Sage Weil039934b2009-11-12 15:05:52 -0800348#endif
Sage Weilf24e9982009-10-06 11:31:10 -0700349
350 mempool_t *req_mempool;
351
Yehuda Sadeh0d59ab82010-01-13 17:03:23 -0800352 struct ceph_msgpool msgpool_op;
Sage Weilc16e7862010-03-01 13:02:00 -0800353 struct ceph_msgpool msgpool_op_reply;
Yehuda Sadeha40c4f12011-03-21 15:07:16 -0700354
Yehuda Sadeha40c4f12011-03-21 15:07:16 -0700355 struct workqueue_struct *notify_wq;
Sage Weilf24e9982009-10-06 11:31:10 -0700356};
357
Ilya Dryomovb7ec35b2016-04-28 16:07:25 +0200358static inline bool ceph_osdmap_flag(struct ceph_osd_client *osdc, int flag)
359{
360 return osdc->osdmap->flags & flag;
361}
362
Alex Elder5522ae02013-05-01 12:43:04 -0500363extern int ceph_osdc_setup(void);
364extern void ceph_osdc_cleanup(void);
365
Sage Weilf24e9982009-10-06 11:31:10 -0700366extern int ceph_osdc_init(struct ceph_osd_client *osdc,
367 struct ceph_client *client);
368extern void ceph_osdc_stop(struct ceph_osd_client *osdc);
369
370extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc,
371 struct ceph_msg *msg);
372extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc,
373 struct ceph_msg *msg);
Jeff Layton58eb7932017-04-18 09:21:16 -0400374void ceph_osdc_update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb);
Sage Weilf24e9982009-10-06 11:31:10 -0700375
Alex Elder49719772013-02-11 12:33:24 -0600376extern void osd_req_op_init(struct ceph_osd_request *osd_req,
Yan, Zheng144cba12015-04-27 11:09:54 +0800377 unsigned int which, u16 opcode, u32 flags);
Alex Elder49719772013-02-11 12:33:24 -0600378
379extern void osd_req_op_raw_data_in_pages(struct ceph_osd_request *,
380 unsigned int which,
381 struct page **pages, u64 length,
382 u32 alignment, bool pages_from_pool,
383 bool own_pages);
384
Alex Elderc99d2d42013-04-05 01:27:11 -0500385extern void osd_req_op_extent_init(struct ceph_osd_request *osd_req,
386 unsigned int which, u16 opcode,
Alex Elder33803f32013-03-13 20:50:00 -0500387 u64 offset, u64 length,
388 u64 truncate_size, u32 truncate_seq);
Alex Elderc99d2d42013-04-05 01:27:11 -0500389extern void osd_req_op_extent_update(struct ceph_osd_request *osd_req,
390 unsigned int which, u64 length);
Yan, Zheng2c63f492016-01-07 17:32:54 +0800391extern void osd_req_op_extent_dup_last(struct ceph_osd_request *osd_req,
392 unsigned int which, u64 offset_inc);
Alex Eldera4ce40a2013-04-05 01:27:12 -0500393
394extern struct ceph_osd_data *osd_req_op_extent_osd_data(
395 struct ceph_osd_request *osd_req,
Alex Elder406e2c92013-04-15 14:50:36 -0500396 unsigned int which);
Alex Eldera4ce40a2013-04-05 01:27:12 -0500397
398extern void osd_req_op_extent_osd_data_pages(struct ceph_osd_request *,
Alex Elder406e2c92013-04-15 14:50:36 -0500399 unsigned int which,
Alex Eldera4ce40a2013-04-05 01:27:12 -0500400 struct page **pages, u64 length,
401 u32 alignment, bool pages_from_pool,
402 bool own_pages);
403extern void osd_req_op_extent_osd_data_pagelist(struct ceph_osd_request *,
Alex Elder406e2c92013-04-15 14:50:36 -0500404 unsigned int which,
Alex Eldera4ce40a2013-04-05 01:27:12 -0500405 struct ceph_pagelist *pagelist);
406#ifdef CONFIG_BLOCK
407extern void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *,
Alex Elder406e2c92013-04-15 14:50:36 -0500408 unsigned int which,
Alex Eldera4ce40a2013-04-05 01:27:12 -0500409 struct bio *bio, size_t bio_length);
410#endif /* CONFIG_BLOCK */
411
Alex Elder04017e22013-04-05 14:46:02 -0500412extern void osd_req_op_cls_request_data_pagelist(struct ceph_osd_request *,
413 unsigned int which,
414 struct ceph_pagelist *pagelist);
Alex Elder6c57b552013-04-19 15:34:49 -0500415extern void osd_req_op_cls_request_data_pages(struct ceph_osd_request *,
416 unsigned int which,
417 struct page **pages, u64 length,
418 u32 alignment, bool pages_from_pool,
419 bool own_pages);
Alex Eldera4ce40a2013-04-05 01:27:12 -0500420extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,
Alex Elderc99d2d42013-04-05 01:27:11 -0500421 unsigned int which,
Alex Eldera4ce40a2013-04-05 01:27:12 -0500422 struct page **pages, u64 length,
423 u32 alignment, bool pages_from_pool,
424 bool own_pages);
Alex Elderc99d2d42013-04-05 01:27:11 -0500425extern void osd_req_op_cls_init(struct ceph_osd_request *osd_req,
426 unsigned int which, u16 opcode,
Alex Elder04017e22013-04-05 14:46:02 -0500427 const char *class, const char *method);
Yan, Zhengd74b50b2014-11-12 14:00:43 +0800428extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which,
429 u16 opcode, const char *name, const void *value,
430 size_t size, u8 cmp_op, u8 cmp_mode);
Ilya Dryomovc647b8a2014-02-25 16:22:27 +0200431extern void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req,
432 unsigned int which,
433 u64 expected_object_size,
434 u64 expected_write_size);
Alex Elder33803f32013-03-13 20:50:00 -0500435
Yehuda Sadeh3499e8a2010-04-06 14:51:47 -0700436extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
Yehuda Sadeh3499e8a2010-04-06 14:51:47 -0700437 struct ceph_snap_context *snapc,
Alex Elderacead002013-03-14 14:09:05 -0500438 unsigned int num_ops,
Yehuda Sadeh3499e8a2010-04-06 14:51:47 -0700439 bool use_mempool,
Alex Elder54a54002012-11-13 21:11:15 -0600440 gfp_t gfp_flags);
Ilya Dryomov13d1ad12016-04-27 14:15:51 +0200441int ceph_osdc_alloc_messages(struct ceph_osd_request *req, gfp_t gfp);
Yehuda Sadeh3499e8a2010-04-06 14:51:47 -0700442
Sage Weilf24e9982009-10-06 11:31:10 -0700443extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
444 struct ceph_file_layout *layout,
445 struct ceph_vino vino,
Alex Elderacead002013-03-14 14:09:05 -0500446 u64 offset, u64 *len,
Yan, Zheng715e4cd2014-11-13 14:40:37 +0800447 unsigned int which, int num_ops,
448 int opcode, int flags,
Sage Weilf24e9982009-10-06 11:31:10 -0700449 struct ceph_snap_context *snapc,
Alex Elderacead002013-03-14 14:09:05 -0500450 u32 truncate_seq, u64 truncate_size,
Alex Elder153e5162013-03-01 18:00:15 -0600451 bool use_mempool);
Sage Weilf24e9982009-10-06 11:31:10 -0700452
Ilya Dryomov9e94af22014-06-20 14:14:42 +0400453extern void ceph_osdc_get_request(struct ceph_osd_request *req);
454extern void ceph_osdc_put_request(struct ceph_osd_request *req);
Sage Weilf24e9982009-10-06 11:31:10 -0700455
456extern int ceph_osdc_start_request(struct ceph_osd_client *osdc,
457 struct ceph_osd_request *req,
458 bool nofail);
Ilya Dryomovc9f9b932014-06-19 11:38:13 +0400459extern void ceph_osdc_cancel_request(struct ceph_osd_request *req);
Sage Weilf24e9982009-10-06 11:31:10 -0700460extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc,
461 struct ceph_osd_request *req);
462extern void ceph_osdc_sync(struct ceph_osd_client *osdc);
463
Josh Durgindd935f42013-08-28 21:43:09 -0700464extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc);
Ilya Dryomov7cca78c2016-04-28 16:07:28 +0200465void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc);
Josh Durgindd935f42013-08-28 21:43:09 -0700466
Douglas Fuller428a7152015-06-17 14:49:45 -0400467int ceph_osdc_call(struct ceph_osd_client *osdc,
468 struct ceph_object_id *oid,
469 struct ceph_object_locator *oloc,
470 const char *class, const char *method,
471 unsigned int flags,
472 struct page *req_page, size_t req_len,
473 struct page *resp_page, size_t *resp_len);
474
Sage Weilf24e9982009-10-06 11:31:10 -0700475extern int ceph_osdc_readpages(struct ceph_osd_client *osdc,
476 struct ceph_vino vino,
477 struct ceph_file_layout *layout,
478 u64 off, u64 *plen,
479 u32 truncate_seq, u64 truncate_size,
Sage Weilb7495fc2010-11-09 12:43:12 -0800480 struct page **pages, int nr_pages,
481 int page_align);
Sage Weilf24e9982009-10-06 11:31:10 -0700482
483extern int ceph_osdc_writepages(struct ceph_osd_client *osdc,
484 struct ceph_vino vino,
485 struct ceph_file_layout *layout,
486 struct ceph_snap_context *sc,
487 u64 off, u64 len,
488 u32 truncate_seq, u64 truncate_size,
489 struct timespec *mtime,
Alex Elder24808822013-02-15 11:42:29 -0600490 struct page **pages, int nr_pages);
Sage Weilf24e9982009-10-06 11:31:10 -0700491
Ilya Dryomov922dab62016-05-26 01:15:02 +0200492/* watch/notify */
493struct ceph_osd_linger_request *
494ceph_osdc_watch(struct ceph_osd_client *osdc,
495 struct ceph_object_id *oid,
496 struct ceph_object_locator *oloc,
497 rados_watchcb2_t wcb,
498 rados_watcherrcb_t errcb,
499 void *data);
500int ceph_osdc_unwatch(struct ceph_osd_client *osdc,
501 struct ceph_osd_linger_request *lreq);
502
503int ceph_osdc_notify_ack(struct ceph_osd_client *osdc,
504 struct ceph_object_id *oid,
505 struct ceph_object_locator *oloc,
506 u64 notify_id,
507 u64 cookie,
508 void *payload,
509 size_t payload_len);
Ilya Dryomov19079202016-04-28 16:07:27 +0200510int ceph_osdc_notify(struct ceph_osd_client *osdc,
511 struct ceph_object_id *oid,
512 struct ceph_object_locator *oloc,
513 void *payload,
514 size_t payload_len,
515 u32 timeout,
516 struct page ***preply_pages,
517 size_t *preply_len);
Ilya Dryomovb07d3c42016-04-28 16:07:27 +0200518int ceph_osdc_watch_check(struct ceph_osd_client *osdc,
519 struct ceph_osd_linger_request *lreq);
Douglas Fullera4ed38d2015-07-17 13:18:07 -0700520int ceph_osdc_list_watchers(struct ceph_osd_client *osdc,
521 struct ceph_object_id *oid,
522 struct ceph_object_locator *oloc,
523 struct ceph_watch_item **watchers,
524 u32 *num_watchers);
Sage Weilf24e9982009-10-06 11:31:10 -0700525#endif
526