ceph: use kref for struct ceph_mds_request
[deliverable/linux.git] / fs / ceph / osd_client.h
CommitLineData
f24e9980
SW
1#ifndef _FS_CEPH_OSD_CLIENT_H
2#define _FS_CEPH_OSD_CLIENT_H
3
4#include <linux/completion.h>
5#include <linux/mempool.h>
6#include <linux/rbtree.h>
7
8#include "types.h"
9#include "osdmap.h"
10#include "messenger.h"
11
12struct ceph_msg;
13struct ceph_snap_context;
14struct ceph_osd_request;
15struct ceph_osd_client;
4e7a5dcd 16struct ceph_authorizer;
f24e9980
SW
17
18/*
19 * completion callback for async writepages
20 */
21typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *,
22 struct ceph_msg *);
23
24/* a given osd we're communicating with */
25struct ceph_osd {
26 atomic_t o_ref;
27 struct ceph_osd_client *o_osdc;
28 int o_osd;
29 int o_incarnation;
30 struct rb_node o_node;
31 struct ceph_connection o_con;
32 struct list_head o_requests;
4e7a5dcd
SW
33 struct ceph_authorizer *o_authorizer;
34 void *o_authorizer_buf, *o_authorizer_reply_buf;
35 size_t o_authorizer_buf_len, o_authorizer_reply_buf_len;
f24e9980
SW
36};
37
38/* an in-flight request */
39struct ceph_osd_request {
40 u64 r_tid; /* unique for this client */
41 struct rb_node r_node;
42 struct list_head r_osd_item;
43 struct ceph_osd *r_osd;
44
45 struct ceph_msg *r_request, *r_reply;
46 int r_result;
47 int r_flags; /* any additional flags for the osd */
48 u32 r_sent; /* >0 if r_request is sending/sent */
49 int r_prepared_pages, r_got_reply;
50
51 struct ceph_osd_client *r_osdc;
52 atomic_t r_ref;
53 bool r_mempool;
54 struct completion r_completion, r_safe_completion;
55 ceph_osdc_callback_t r_callback, r_safe_callback;
56 struct ceph_eversion r_reassert_version;
57 struct list_head r_unsafe_item;
58
59 struct inode *r_inode; /* for use by callbacks */
60 struct writeback_control *r_wbc; /* ditto */
61
62 char r_oid[40]; /* object name */
63 int r_oid_len;
64 unsigned long r_timeout_stamp;
65 bool r_resend; /* msg send failed, needs retry */
66
67 struct ceph_file_layout r_file_layout;
68 struct ceph_snap_context *r_snapc; /* snap context for writes */
69 unsigned r_num_pages; /* size of page array (follows) */
70 struct page **r_pages; /* pages for data payload */
71 int r_pages_from_pool;
72 int r_own_pages; /* if true, i own page list */
73};
74
75struct ceph_osd_client {
76 struct ceph_client *client;
77
78 struct ceph_osdmap *osdmap; /* current map */
79 struct rw_semaphore map_sem;
80 struct completion map_waiters;
81 u64 last_requested_map;
82
83 struct mutex request_mutex;
84 struct rb_root osds; /* osds */
85 u64 timeout_tid; /* tid of timeout triggering rq */
86 u64 last_tid; /* tid of last request */
87 struct rb_root requests; /* pending requests */
88 int num_requests;
89 struct delayed_work timeout_work;
039934b8 90#ifdef CONFIG_DEBUG_FS
f24e9980 91 struct dentry *debugfs_file;
039934b8 92#endif
f24e9980
SW
93
94 mempool_t *req_mempool;
95
96 struct ceph_msgpool msgpool_op;
97 struct ceph_msgpool msgpool_op_reply;
98};
99
100extern int ceph_osdc_init(struct ceph_osd_client *osdc,
101 struct ceph_client *client);
102extern void ceph_osdc_stop(struct ceph_osd_client *osdc);
103
104extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc,
105 struct ceph_msg *msg);
106extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc,
107 struct ceph_msg *msg);
108
109extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
110 struct ceph_file_layout *layout,
111 struct ceph_vino vino,
112 u64 offset, u64 *len, int op, int flags,
113 struct ceph_snap_context *snapc,
114 int do_sync, u32 truncate_seq,
115 u64 truncate_size,
116 struct timespec *mtime,
117 bool use_mempool, int num_reply);
118
119static inline void ceph_osdc_get_request(struct ceph_osd_request *req)
120{
121 atomic_inc(&req->r_ref);
122}
123extern void ceph_osdc_put_request(struct ceph_osd_request *req);
124
125extern int ceph_osdc_start_request(struct ceph_osd_client *osdc,
126 struct ceph_osd_request *req,
127 bool nofail);
128extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc,
129 struct ceph_osd_request *req);
130extern void ceph_osdc_sync(struct ceph_osd_client *osdc);
131
132extern int ceph_osdc_readpages(struct ceph_osd_client *osdc,
133 struct ceph_vino vino,
134 struct ceph_file_layout *layout,
135 u64 off, u64 *plen,
136 u32 truncate_seq, u64 truncate_size,
137 struct page **pages, int nr_pages);
138
139extern int ceph_osdc_writepages(struct ceph_osd_client *osdc,
140 struct ceph_vino vino,
141 struct ceph_file_layout *layout,
142 struct ceph_snap_context *sc,
143 u64 off, u64 len,
144 u32 truncate_seq, u64 truncate_size,
145 struct timespec *mtime,
146 struct page **pages, int nr_pages,
147 int flags, int do_sync, bool nofail);
148
149#endif
150
This page took 0.0516 seconds and 5 git commands to generate.