blob: c6d96a5f46fd6127c712d1cea79e4e47075a24e7 [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;
151
152 unsigned int flags; /* CEPH_OSD_FLAG_* */
153 bool paused;
154
Ilya Dryomov04c7d782017-06-15 16:30:55 +0200155 u32 epoch;
Ilya Dryomovdc93e0e2017-06-05 14:45:00 +0200156 u32 last_force_resend;
157
Ilya Dryomov63244fa2016-04-28 16:07:23 +0200158 int osd;
159};
160
Sage Weilf24e9982009-10-06 11:31:10 -0700161/* an in-flight request */
162struct ceph_osd_request {
163 u64 r_tid; /* unique for this client */
164 struct rb_node r_node;
Ilya Dryomov46092452016-04-28 16:07:27 +0200165 struct rb_node r_mc_node; /* map check */
Sage Weilf24e9982009-10-06 11:31:10 -0700166 struct ceph_osd *r_osd;
Ilya Dryomova66dd382016-04-28 16:07:23 +0200167
168 struct ceph_osd_request_target r_t;
169#define r_base_oid r_t.base_oid
170#define r_base_oloc r_t.base_oloc
171#define r_flags r_t.flags
Sage Weilf24e9982009-10-06 11:31:10 -0700172
173 struct ceph_msg *r_request, *r_reply;
Sage Weilf24e9982009-10-06 11:31:10 -0700174 u32 r_sent; /* >0 if r_request is sending/sent */
Sage Weil1b83bef2013-02-25 16:11:12 -0800175
Alex Elder79528732013-04-03 21:32:51 -0500176 /* request osd ops array */
177 unsigned int r_num_ops;
Alex Elder79528732013-04-03 21:32:51 -0500178
Sage Weil1b83bef2013-02-25 16:11:12 -0800179 int r_result;
Sage Weilf24e9982009-10-06 11:31:10 -0700180
181 struct ceph_osd_client *r_osdc;
Sage Weil415e49a2009-12-07 13:37:03 -0800182 struct kref r_kref;
Sage Weilf24e9982009-10-06 11:31:10 -0700183 bool r_mempool;
Ilya Dryomovb18b9552017-02-11 18:46:08 +0100184 struct completion r_completion; /* private to osd_client.c */
Alex Elder26be8802013-04-15 11:20:42 -0500185 ceph_osdc_callback_t r_callback;
Sage Weilf24e9982009-10-06 11:31:10 -0700186 struct list_head r_unsafe_item;
187
188 struct inode *r_inode; /* for use by callbacks */
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700189 void *r_priv; /* ditto */
Sage Weilf24e9982009-10-06 11:31:10 -0700190
Ilya Dryomovbb873b5392016-05-26 00:29:52 +0200191 /* set by submitter */
192 u64 r_snapid; /* for reads, CEPH_NOSNAP o/w */
193 struct ceph_snap_context *r_snapc; /* for writes */
194 struct timespec r_mtime; /* ditto */
195 u64 r_data_offset; /* ditto */
Ilya Dryomov922dab62016-05-26 01:15:02 +0200196 bool r_linger; /* don't resend on failure */
Jeff Laytona1f40202017-04-04 08:39:37 -0400197 bool r_abort_on_full; /* return ENOSPC when full */
Sage Weilf24e9982009-10-06 11:31:10 -0700198
Ilya Dryomovbb873b5392016-05-26 00:29:52 +0200199 /* internal */
200 unsigned long r_stamp; /* jiffies, send or check time */
Ilya Dryomov7cc5e382017-02-12 17:11:07 +0100201 unsigned long r_start_stamp; /* jiffies */
Ilya Dryomovbb873b5392016-05-26 00:29:52 +0200202 int r_attempts;
Ilya Dryomov46092452016-04-28 16:07:27 +0200203 u32 r_map_dne_bound;
Ilya Dryomov3f1af422016-02-09 17:50:15 +0100204
205 struct ceph_osd_req_op r_ops[];
Sage Weilf24e9982009-10-06 11:31:10 -0700206};
207
Ilya Dryomov205ee1182014-01-27 17:40:20 +0200208struct ceph_request_redirect {
209 struct ceph_object_locator oloc;
210};
211
Ilya Dryomov8cb441c2017-06-15 16:30:54 +0200212/*
213 * osd request identifier
214 *
215 * caller name + incarnation# + tid to unique identify this request
216 */
217struct ceph_osd_reqid {
218 struct ceph_entity_name name;
219 __le64 tid;
220 __le32 inc;
221} __packed;
222
223struct ceph_blkin_trace_info {
224 __le64 trace_id;
225 __le64 span_id;
226 __le64 parent_span_id;
227} __packed;
228
Ilya Dryomov922dab62016-05-26 01:15:02 +0200229typedef void (*rados_watchcb2_t)(void *arg, u64 notify_id, u64 cookie,
230 u64 notifier_id, void *data, size_t data_len);
231typedef void (*rados_watcherrcb_t)(void *arg, u64 cookie, int err);
Yehuda Sadeha40c4f12011-03-21 15:07:16 -0700232
Ilya Dryomov922dab62016-05-26 01:15:02 +0200233struct ceph_osd_linger_request {
234 struct ceph_osd_client *osdc;
235 u64 linger_id;
236 bool committed;
Ilya Dryomov19079202016-04-28 16:07:27 +0200237 bool is_watch; /* watch or notify */
Ilya Dryomov922dab62016-05-26 01:15:02 +0200238
239 struct ceph_osd *osd;
240 struct ceph_osd_request *reg_req;
241 struct ceph_osd_request *ping_req;
242 unsigned long ping_sent;
Ilya Dryomovb07d3c42016-04-28 16:07:27 +0200243 unsigned long watch_valid_thru;
244 struct list_head pending_lworks;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200245
246 struct ceph_osd_request_target t;
Ilya Dryomov46092452016-04-28 16:07:27 +0200247 u32 map_dne_bound;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200248
249 struct timespec mtime;
250
251 struct kref kref;
252 struct mutex lock;
253 struct rb_node node; /* osd */
254 struct rb_node osdc_node; /* osdc */
Ilya Dryomov46092452016-04-28 16:07:27 +0200255 struct rb_node mc_node; /* map check */
Ilya Dryomov922dab62016-05-26 01:15:02 +0200256 struct list_head scan_item;
257
258 struct completion reg_commit_wait;
Ilya Dryomov19079202016-04-28 16:07:27 +0200259 struct completion notify_finish_wait;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200260 int reg_commit_error;
Ilya Dryomov19079202016-04-28 16:07:27 +0200261 int notify_finish_error;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200262 int last_error;
263
264 u32 register_gen;
Ilya Dryomov19079202016-04-28 16:07:27 +0200265 u64 notify_id;
Ilya Dryomov922dab62016-05-26 01:15:02 +0200266
267 rados_watchcb2_t wcb;
268 rados_watcherrcb_t errcb;
269 void *data;
Ilya Dryomov19079202016-04-28 16:07:27 +0200270
271 struct page ***preply_pages;
272 size_t *preply_len;
Yehuda Sadeha40c4f12011-03-21 15:07:16 -0700273};
274
Douglas Fullera4ed38d2015-07-17 13:18:07 -0700275struct ceph_watch_item {
276 struct ceph_entity_name name;
277 u64 cookie;
278 struct ceph_entity_addr addr;
279};
280
Ilya Dryomova02a9462017-06-19 12:18:05 +0200281struct ceph_spg_mapping {
282 struct rb_node node;
283 struct ceph_spg spgid;
284
285 struct rb_root backoffs;
286};
287
288struct ceph_hobject_id {
289 void *key;
290 size_t key_len;
291 void *oid;
292 size_t oid_len;
293 u64 snapid;
294 u32 hash;
295 u8 is_max;
296 void *nspace;
297 size_t nspace_len;
298 s64 pool;
299
300 /* cache */
301 u32 hash_reverse_bits;
302};
303
304static inline void ceph_hoid_build_hash_cache(struct ceph_hobject_id *hoid)
305{
306 hoid->hash_reverse_bits = bitrev32(hoid->hash);
307}
308
309/*
310 * PG-wide backoff: [begin, end)
311 * per-object backoff: begin == end
312 */
313struct ceph_osd_backoff {
314 struct rb_node spg_node;
315 struct rb_node id_node;
316
317 struct ceph_spg spgid;
318 u64 id;
319 struct ceph_hobject_id *begin;
320 struct ceph_hobject_id *end;
321};
322
Ilya Dryomov264048a2016-11-08 15:15:24 +0100323#define CEPH_LINGER_ID_START 0xffff000000000000ULL
324
Sage Weilf24e9982009-10-06 11:31:10 -0700325struct ceph_osd_client {
326 struct ceph_client *client;
327
328 struct ceph_osdmap *osdmap; /* current map */
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +0200329 struct rw_semaphore lock;
Sage Weilf24e9982009-10-06 11:31:10 -0700330
Sage Weilf24e9982009-10-06 11:31:10 -0700331 struct rb_root osds; /* osds */
Yehuda Sadehf5a20412010-02-03 11:00:26 -0800332 struct list_head osd_lru; /* idle osds */
Ilya Dryomov9dd28452016-04-28 16:07:26 +0200333 spinlock_t osd_lru_lock;
Jeff Layton58eb7932017-04-18 09:21:16 -0400334 u32 epoch_barrier;
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +0200335 struct ceph_osd homeless_osd;
336 atomic64_t last_tid; /* tid of last request */
Ilya Dryomov922dab62016-05-26 01:15:02 +0200337 u64 last_linger_id;
338 struct rb_root linger_requests; /* lingering requests */
Ilya Dryomov46092452016-04-28 16:07:27 +0200339 struct rb_root map_checks;
340 struct rb_root linger_map_checks;
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +0200341 atomic_t num_requests;
342 atomic_t num_homeless;
Sage Weilf24e9982009-10-06 11:31:10 -0700343 struct delayed_work timeout_work;
Yehuda Sadehf5a20412010-02-03 11:00:26 -0800344 struct delayed_work osds_timeout_work;
Sage Weil039934b2009-11-12 15:05:52 -0800345#ifdef CONFIG_DEBUG_FS
Sage Weilf24e9982009-10-06 11:31:10 -0700346 struct dentry *debugfs_file;
Sage Weil039934b2009-11-12 15:05:52 -0800347#endif
Sage Weilf24e9982009-10-06 11:31:10 -0700348
349 mempool_t *req_mempool;
350
Yehuda Sadeh0d59ab82010-01-13 17:03:23 -0800351 struct ceph_msgpool msgpool_op;
Sage Weilc16e7862010-03-01 13:02:00 -0800352 struct ceph_msgpool msgpool_op_reply;
Yehuda Sadeha40c4f12011-03-21 15:07:16 -0700353
Yehuda Sadeha40c4f12011-03-21 15:07:16 -0700354 struct workqueue_struct *notify_wq;
Sage Weilf24e9982009-10-06 11:31:10 -0700355};
356
Ilya Dryomovb7ec35b2016-04-28 16:07:25 +0200357static inline bool ceph_osdmap_flag(struct ceph_osd_client *osdc, int flag)
358{
359 return osdc->osdmap->flags & flag;
360}
361
Alex Elder5522ae02013-05-01 12:43:04 -0500362extern int ceph_osdc_setup(void);
363extern void ceph_osdc_cleanup(void);
364
Sage Weilf24e9982009-10-06 11:31:10 -0700365extern int ceph_osdc_init(struct ceph_osd_client *osdc,
366 struct ceph_client *client);
367extern void ceph_osdc_stop(struct ceph_osd_client *osdc);
368
369extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc,
370 struct ceph_msg *msg);
371extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc,
372 struct ceph_msg *msg);
Jeff Layton58eb7932017-04-18 09:21:16 -0400373void ceph_osdc_update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb);
Sage Weilf24e9982009-10-06 11:31:10 -0700374
Alex Elder49719772013-02-11 12:33:24 -0600375extern void osd_req_op_init(struct ceph_osd_request *osd_req,
Yan, Zheng144cba12015-04-27 11:09:54 +0800376 unsigned int which, u16 opcode, u32 flags);
Alex Elder49719772013-02-11 12:33:24 -0600377
378extern void osd_req_op_raw_data_in_pages(struct ceph_osd_request *,
379 unsigned int which,
380 struct page **pages, u64 length,
381 u32 alignment, bool pages_from_pool,
382 bool own_pages);
383
Alex Elderc99d2d42013-04-05 01:27:11 -0500384extern void osd_req_op_extent_init(struct ceph_osd_request *osd_req,
385 unsigned int which, u16 opcode,
Alex Elder33803f32013-03-13 20:50:00 -0500386 u64 offset, u64 length,
387 u64 truncate_size, u32 truncate_seq);
Alex Elderc99d2d42013-04-05 01:27:11 -0500388extern void osd_req_op_extent_update(struct ceph_osd_request *osd_req,
389 unsigned int which, u64 length);
Yan, Zheng2c63f492016-01-07 17:32:54 +0800390extern void osd_req_op_extent_dup_last(struct ceph_osd_request *osd_req,
391 unsigned int which, u64 offset_inc);
Alex Eldera4ce40a2013-04-05 01:27:12 -0500392
393extern struct ceph_osd_data *osd_req_op_extent_osd_data(
394 struct ceph_osd_request *osd_req,
Alex Elder406e2c92013-04-15 14:50:36 -0500395 unsigned int which);
Alex Eldera4ce40a2013-04-05 01:27:12 -0500396
397extern void osd_req_op_extent_osd_data_pages(struct ceph_osd_request *,
Alex Elder406e2c92013-04-15 14:50:36 -0500398 unsigned int which,
Alex Eldera4ce40a2013-04-05 01:27:12 -0500399 struct page **pages, u64 length,
400 u32 alignment, bool pages_from_pool,
401 bool own_pages);
402extern void osd_req_op_extent_osd_data_pagelist(struct ceph_osd_request *,
Alex Elder406e2c92013-04-15 14:50:36 -0500403 unsigned int which,
Alex Eldera4ce40a2013-04-05 01:27:12 -0500404 struct ceph_pagelist *pagelist);
405#ifdef CONFIG_BLOCK
406extern void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *,
Alex Elder406e2c92013-04-15 14:50:36 -0500407 unsigned int which,
Alex Eldera4ce40a2013-04-05 01:27:12 -0500408 struct bio *bio, size_t bio_length);
409#endif /* CONFIG_BLOCK */
410
Alex Elder04017e22013-04-05 14:46:02 -0500411extern void osd_req_op_cls_request_data_pagelist(struct ceph_osd_request *,
412 unsigned int which,
413 struct ceph_pagelist *pagelist);
Alex Elder6c57b552013-04-19 15:34:49 -0500414extern void osd_req_op_cls_request_data_pages(struct ceph_osd_request *,
415 unsigned int which,
416 struct page **pages, u64 length,
417 u32 alignment, bool pages_from_pool,
418 bool own_pages);
Alex Eldera4ce40a2013-04-05 01:27:12 -0500419extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,
Alex Elderc99d2d42013-04-05 01:27:11 -0500420 unsigned int which,
Alex Eldera4ce40a2013-04-05 01:27:12 -0500421 struct page **pages, u64 length,
422 u32 alignment, bool pages_from_pool,
423 bool own_pages);
Alex Elderc99d2d42013-04-05 01:27:11 -0500424extern void osd_req_op_cls_init(struct ceph_osd_request *osd_req,
425 unsigned int which, u16 opcode,
Alex Elder04017e22013-04-05 14:46:02 -0500426 const char *class, const char *method);
Yan, Zhengd74b50b2014-11-12 14:00:43 +0800427extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which,
428 u16 opcode, const char *name, const void *value,
429 size_t size, u8 cmp_op, u8 cmp_mode);
Ilya Dryomovc647b8a2014-02-25 16:22:27 +0200430extern void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req,
431 unsigned int which,
432 u64 expected_object_size,
433 u64 expected_write_size);
Alex Elder33803f32013-03-13 20:50:00 -0500434
Yehuda Sadeh3499e8a2010-04-06 14:51:47 -0700435extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
Yehuda Sadeh3499e8a2010-04-06 14:51:47 -0700436 struct ceph_snap_context *snapc,
Alex Elderacead002013-03-14 14:09:05 -0500437 unsigned int num_ops,
Yehuda Sadeh3499e8a2010-04-06 14:51:47 -0700438 bool use_mempool,
Alex Elder54a54002012-11-13 21:11:15 -0600439 gfp_t gfp_flags);
Ilya Dryomov13d1ad12016-04-27 14:15:51 +0200440int ceph_osdc_alloc_messages(struct ceph_osd_request *req, gfp_t gfp);
Yehuda Sadeh3499e8a2010-04-06 14:51:47 -0700441
Sage Weilf24e9982009-10-06 11:31:10 -0700442extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
443 struct ceph_file_layout *layout,
444 struct ceph_vino vino,
Alex Elderacead002013-03-14 14:09:05 -0500445 u64 offset, u64 *len,
Yan, Zheng715e4cd2014-11-13 14:40:37 +0800446 unsigned int which, int num_ops,
447 int opcode, int flags,
Sage Weilf24e9982009-10-06 11:31:10 -0700448 struct ceph_snap_context *snapc,
Alex Elderacead002013-03-14 14:09:05 -0500449 u32 truncate_seq, u64 truncate_size,
Alex Elder153e5162013-03-01 18:00:15 -0600450 bool use_mempool);
Sage Weilf24e9982009-10-06 11:31:10 -0700451
Ilya Dryomov9e94af22014-06-20 14:14:42 +0400452extern void ceph_osdc_get_request(struct ceph_osd_request *req);
453extern void ceph_osdc_put_request(struct ceph_osd_request *req);
Sage Weilf24e9982009-10-06 11:31:10 -0700454
455extern int ceph_osdc_start_request(struct ceph_osd_client *osdc,
456 struct ceph_osd_request *req,
457 bool nofail);
Ilya Dryomovc9f9b932014-06-19 11:38:13 +0400458extern void ceph_osdc_cancel_request(struct ceph_osd_request *req);
Sage Weilf24e9982009-10-06 11:31:10 -0700459extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc,
460 struct ceph_osd_request *req);
461extern void ceph_osdc_sync(struct ceph_osd_client *osdc);
462
Josh Durgindd935f42013-08-28 21:43:09 -0700463extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc);
Ilya Dryomov7cca78c2016-04-28 16:07:28 +0200464void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc);
Josh Durgindd935f42013-08-28 21:43:09 -0700465
Douglas Fuller428a7152015-06-17 14:49:45 -0400466int ceph_osdc_call(struct ceph_osd_client *osdc,
467 struct ceph_object_id *oid,
468 struct ceph_object_locator *oloc,
469 const char *class, const char *method,
470 unsigned int flags,
471 struct page *req_page, size_t req_len,
472 struct page *resp_page, size_t *resp_len);
473
Sage Weilf24e9982009-10-06 11:31:10 -0700474extern int ceph_osdc_readpages(struct ceph_osd_client *osdc,
475 struct ceph_vino vino,
476 struct ceph_file_layout *layout,
477 u64 off, u64 *plen,
478 u32 truncate_seq, u64 truncate_size,
Sage Weilb7495fc2010-11-09 12:43:12 -0800479 struct page **pages, int nr_pages,
480 int page_align);
Sage Weilf24e9982009-10-06 11:31:10 -0700481
482extern int ceph_osdc_writepages(struct ceph_osd_client *osdc,
483 struct ceph_vino vino,
484 struct ceph_file_layout *layout,
485 struct ceph_snap_context *sc,
486 u64 off, u64 len,
487 u32 truncate_seq, u64 truncate_size,
488 struct timespec *mtime,
Alex Elder24808822013-02-15 11:42:29 -0600489 struct page **pages, int nr_pages);
Sage Weilf24e9982009-10-06 11:31:10 -0700490
Ilya Dryomov922dab62016-05-26 01:15:02 +0200491/* watch/notify */
492struct ceph_osd_linger_request *
493ceph_osdc_watch(struct ceph_osd_client *osdc,
494 struct ceph_object_id *oid,
495 struct ceph_object_locator *oloc,
496 rados_watchcb2_t wcb,
497 rados_watcherrcb_t errcb,
498 void *data);
499int ceph_osdc_unwatch(struct ceph_osd_client *osdc,
500 struct ceph_osd_linger_request *lreq);
501
502int ceph_osdc_notify_ack(struct ceph_osd_client *osdc,
503 struct ceph_object_id *oid,
504 struct ceph_object_locator *oloc,
505 u64 notify_id,
506 u64 cookie,
507 void *payload,
508 size_t payload_len);
Ilya Dryomov19079202016-04-28 16:07:27 +0200509int ceph_osdc_notify(struct ceph_osd_client *osdc,
510 struct ceph_object_id *oid,
511 struct ceph_object_locator *oloc,
512 void *payload,
513 size_t payload_len,
514 u32 timeout,
515 struct page ***preply_pages,
516 size_t *preply_len);
Ilya Dryomovb07d3c42016-04-28 16:07:27 +0200517int ceph_osdc_watch_check(struct ceph_osd_client *osdc,
518 struct ceph_osd_linger_request *lreq);
Douglas Fullera4ed38d2015-07-17 13:18:07 -0700519int ceph_osdc_list_watchers(struct ceph_osd_client *osdc,
520 struct ceph_object_id *oid,
521 struct ceph_object_locator *oloc,
522 struct ceph_watch_item **watchers,
523 u32 *num_watchers);
Sage Weilf24e9982009-10-06 11:31:10 -0700524#endif
525