diff options
Diffstat (limited to 'include/linux/ceph/osd_client.h')
| -rw-r--r-- | include/linux/ceph/osd_client.h | 204 |
1 files changed, 135 insertions, 69 deletions
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index 1dd5d466b6f9..186db0bf4951 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h | |||
| @@ -29,6 +29,7 @@ struct ceph_authorizer; | |||
| 29 | */ | 29 | */ |
| 30 | typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *, | 30 | typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *, |
| 31 | struct ceph_msg *); | 31 | struct ceph_msg *); |
| 32 | typedef void (*ceph_osdc_unsafe_callback_t)(struct ceph_osd_request *, bool); | ||
| 32 | 33 | ||
| 33 | /* a given osd we're communicating with */ | 34 | /* a given osd we're communicating with */ |
| 34 | struct ceph_osd { | 35 | struct ceph_osd { |
| @@ -48,7 +49,67 @@ struct ceph_osd { | |||
| 48 | }; | 49 | }; |
| 49 | 50 | ||
| 50 | 51 | ||
| 51 | #define CEPH_OSD_MAX_OP 10 | 52 | #define CEPH_OSD_MAX_OP 2 |
| 53 | |||
| 54 | enum ceph_osd_data_type { | ||
| 55 | CEPH_OSD_DATA_TYPE_NONE = 0, | ||
| 56 | CEPH_OSD_DATA_TYPE_PAGES, | ||
| 57 | CEPH_OSD_DATA_TYPE_PAGELIST, | ||
| 58 | #ifdef CONFIG_BLOCK | ||
| 59 | CEPH_OSD_DATA_TYPE_BIO, | ||
| 60 | #endif /* CONFIG_BLOCK */ | ||
| 61 | }; | ||
| 62 | |||
| 63 | struct ceph_osd_data { | ||
| 64 | enum ceph_osd_data_type type; | ||
| 65 | union { | ||
| 66 | struct { | ||
| 67 | struct page **pages; | ||
| 68 | u64 length; | ||
| 69 | u32 alignment; | ||
| 70 | bool pages_from_pool; | ||
| 71 | bool own_pages; | ||
| 72 | }; | ||
| 73 | struct ceph_pagelist *pagelist; | ||
| 74 | #ifdef CONFIG_BLOCK | ||
| 75 | struct { | ||
| 76 | struct bio *bio; /* list of bios */ | ||
| 77 | size_t bio_length; /* total in list */ | ||
| 78 | }; | ||
| 79 | #endif /* CONFIG_BLOCK */ | ||
| 80 | }; | ||
| 81 | }; | ||
| 82 | |||
| 83 | struct ceph_osd_req_op { | ||
| 84 | u16 op; /* CEPH_OSD_OP_* */ | ||
| 85 | u32 payload_len; | ||
| 86 | union { | ||
| 87 | struct ceph_osd_data raw_data_in; | ||
| 88 | struct { | ||
| 89 | u64 offset, length; | ||
| 90 | u64 truncate_size; | ||
| 91 | u32 truncate_seq; | ||
| 92 | struct ceph_osd_data osd_data; | ||
| 93 | } extent; | ||
| 94 | struct { | ||
| 95 | const char *class_name; | ||
| 96 | const char *method_name; | ||
| 97 | struct ceph_osd_data request_info; | ||
| 98 | struct ceph_osd_data request_data; | ||
| 99 | struct ceph_osd_data response_data; | ||
| 100 | __u8 class_len; | ||
| 101 | __u8 method_len; | ||
| 102 | __u8 argc; | ||
| 103 | } cls; | ||
| 104 | struct { | ||
| 105 | u64 cookie; | ||
| 106 | u64 ver; | ||
| 107 | u32 prot_ver; | ||
| 108 | u32 timeout; | ||
| 109 | __u8 flag; | ||
| 110 | } watch; | ||
| 111 | }; | ||
| 112 | }; | ||
| 52 | 113 | ||
| 53 | /* an in-flight request */ | 114 | /* an in-flight request */ |
| 54 | struct ceph_osd_request { | 115 | struct ceph_osd_request { |
| @@ -63,15 +124,14 @@ struct ceph_osd_request { | |||
| 63 | int r_pg_osds[CEPH_PG_MAX_SIZE]; | 124 | int r_pg_osds[CEPH_PG_MAX_SIZE]; |
| 64 | int r_num_pg_osds; | 125 | int r_num_pg_osds; |
| 65 | 126 | ||
| 66 | struct ceph_connection *r_con_filling_msg; | ||
| 67 | |||
| 68 | struct ceph_msg *r_request, *r_reply; | 127 | struct ceph_msg *r_request, *r_reply; |
| 69 | int r_flags; /* any additional flags for the osd */ | 128 | int r_flags; /* any additional flags for the osd */ |
| 70 | u32 r_sent; /* >0 if r_request is sending/sent */ | 129 | u32 r_sent; /* >0 if r_request is sending/sent */ |
| 71 | int r_num_ops; | ||
| 72 | 130 | ||
| 73 | /* encoded message content */ | 131 | /* request osd ops array */ |
| 74 | struct ceph_osd_op *r_request_ops; | 132 | unsigned int r_num_ops; |
| 133 | struct ceph_osd_req_op r_ops[CEPH_OSD_MAX_OP]; | ||
| 134 | |||
| 75 | /* these are updated on each send */ | 135 | /* these are updated on each send */ |
| 76 | __le32 *r_request_osdmap_epoch; | 136 | __le32 *r_request_osdmap_epoch; |
| 77 | __le32 *r_request_flags; | 137 | __le32 *r_request_flags; |
| @@ -85,12 +145,14 @@ struct ceph_osd_request { | |||
| 85 | s32 r_reply_op_result[CEPH_OSD_MAX_OP]; | 145 | s32 r_reply_op_result[CEPH_OSD_MAX_OP]; |
| 86 | int r_got_reply; | 146 | int r_got_reply; |
| 87 | int r_linger; | 147 | int r_linger; |
| 148 | int r_completed; | ||
| 88 | 149 | ||
| 89 | struct ceph_osd_client *r_osdc; | 150 | struct ceph_osd_client *r_osdc; |
| 90 | struct kref r_kref; | 151 | struct kref r_kref; |
| 91 | bool r_mempool; | 152 | bool r_mempool; |
| 92 | struct completion r_completion, r_safe_completion; | 153 | struct completion r_completion, r_safe_completion; |
| 93 | ceph_osdc_callback_t r_callback, r_safe_callback; | 154 | ceph_osdc_callback_t r_callback; |
| 155 | ceph_osdc_unsafe_callback_t r_unsafe_callback; | ||
| 94 | struct ceph_eversion r_reassert_version; | 156 | struct ceph_eversion r_reassert_version; |
| 95 | struct list_head r_unsafe_item; | 157 | struct list_head r_unsafe_item; |
| 96 | 158 | ||
| @@ -104,16 +166,6 @@ struct ceph_osd_request { | |||
| 104 | 166 | ||
| 105 | struct ceph_file_layout r_file_layout; | 167 | struct ceph_file_layout r_file_layout; |
| 106 | struct ceph_snap_context *r_snapc; /* snap context for writes */ | 168 | struct ceph_snap_context *r_snapc; /* snap context for writes */ |
| 107 | unsigned r_num_pages; /* size of page array (follows) */ | ||
| 108 | unsigned r_page_alignment; /* io offset in first page */ | ||
| 109 | struct page **r_pages; /* pages for data payload */ | ||
| 110 | int r_pages_from_pool; | ||
| 111 | int r_own_pages; /* if true, i own page list */ | ||
| 112 | #ifdef CONFIG_BLOCK | ||
| 113 | struct bio *r_bio; /* instead of pages */ | ||
| 114 | #endif | ||
| 115 | |||
| 116 | struct ceph_pagelist r_trail; /* trailing part of the data */ | ||
| 117 | }; | 169 | }; |
| 118 | 170 | ||
| 119 | struct ceph_osd_event { | 171 | struct ceph_osd_event { |
| @@ -172,48 +224,8 @@ struct ceph_osd_client { | |||
| 172 | struct workqueue_struct *notify_wq; | 224 | struct workqueue_struct *notify_wq; |
| 173 | }; | 225 | }; |
| 174 | 226 | ||
| 175 | struct ceph_osd_req_op { | 227 | extern int ceph_osdc_setup(void); |
| 176 | u16 op; /* CEPH_OSD_OP_* */ | 228 | extern void ceph_osdc_cleanup(void); |
| 177 | u32 payload_len; | ||
| 178 | union { | ||
| 179 | struct { | ||
| 180 | u64 offset, length; | ||
| 181 | u64 truncate_size; | ||
| 182 | u32 truncate_seq; | ||
| 183 | } extent; | ||
| 184 | struct { | ||
| 185 | const char *name; | ||
| 186 | const char *val; | ||
| 187 | u32 name_len; | ||
| 188 | u32 value_len; | ||
| 189 | __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */ | ||
| 190 | __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */ | ||
| 191 | } xattr; | ||
| 192 | struct { | ||
| 193 | const char *class_name; | ||
| 194 | const char *method_name; | ||
| 195 | const char *indata; | ||
| 196 | u32 indata_len; | ||
| 197 | __u8 class_len; | ||
| 198 | __u8 method_len; | ||
| 199 | __u8 argc; | ||
| 200 | } cls; | ||
| 201 | struct { | ||
| 202 | u64 cookie; | ||
| 203 | u64 count; | ||
| 204 | } pgls; | ||
| 205 | struct { | ||
| 206 | u64 snapid; | ||
| 207 | } snap; | ||
| 208 | struct { | ||
| 209 | u64 cookie; | ||
| 210 | u64 ver; | ||
| 211 | u32 prot_ver; | ||
| 212 | u32 timeout; | ||
| 213 | __u8 flag; | ||
| 214 | } watch; | ||
| 215 | }; | ||
| 216 | }; | ||
| 217 | 229 | ||
| 218 | extern int ceph_osdc_init(struct ceph_osd_client *osdc, | 230 | extern int ceph_osdc_init(struct ceph_osd_client *osdc, |
| 219 | struct ceph_client *client); | 231 | struct ceph_client *client); |
| @@ -224,16 +236,71 @@ extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc, | |||
| 224 | extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc, | 236 | extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc, |
| 225 | struct ceph_msg *msg); | 237 | struct ceph_msg *msg); |
| 226 | 238 | ||
| 239 | extern void osd_req_op_init(struct ceph_osd_request *osd_req, | ||
| 240 | unsigned int which, u16 opcode); | ||
| 241 | |||
| 242 | extern void osd_req_op_raw_data_in_pages(struct ceph_osd_request *, | ||
| 243 | unsigned int which, | ||
| 244 | struct page **pages, u64 length, | ||
| 245 | u32 alignment, bool pages_from_pool, | ||
| 246 | bool own_pages); | ||
| 247 | |||
| 248 | extern void osd_req_op_extent_init(struct ceph_osd_request *osd_req, | ||
| 249 | unsigned int which, u16 opcode, | ||
| 250 | u64 offset, u64 length, | ||
| 251 | u64 truncate_size, u32 truncate_seq); | ||
| 252 | extern void osd_req_op_extent_update(struct ceph_osd_request *osd_req, | ||
| 253 | unsigned int which, u64 length); | ||
| 254 | |||
| 255 | extern struct ceph_osd_data *osd_req_op_extent_osd_data( | ||
| 256 | struct ceph_osd_request *osd_req, | ||
| 257 | unsigned int which); | ||
| 258 | extern struct ceph_osd_data *osd_req_op_cls_response_data( | ||
| 259 | struct ceph_osd_request *osd_req, | ||
| 260 | unsigned int which); | ||
| 261 | |||
| 262 | extern void osd_req_op_extent_osd_data_pages(struct ceph_osd_request *, | ||
| 263 | unsigned int which, | ||
| 264 | struct page **pages, u64 length, | ||
| 265 | u32 alignment, bool pages_from_pool, | ||
| 266 | bool own_pages); | ||
| 267 | extern void osd_req_op_extent_osd_data_pagelist(struct ceph_osd_request *, | ||
| 268 | unsigned int which, | ||
| 269 | struct ceph_pagelist *pagelist); | ||
| 270 | #ifdef CONFIG_BLOCK | ||
| 271 | extern void osd_req_op_extent_osd_data_bio(struct ceph_osd_request *, | ||
| 272 | unsigned int which, | ||
| 273 | struct bio *bio, size_t bio_length); | ||
| 274 | #endif /* CONFIG_BLOCK */ | ||
| 275 | |||
| 276 | extern void osd_req_op_cls_request_data_pagelist(struct ceph_osd_request *, | ||
| 277 | unsigned int which, | ||
| 278 | struct ceph_pagelist *pagelist); | ||
| 279 | extern void osd_req_op_cls_request_data_pages(struct ceph_osd_request *, | ||
| 280 | unsigned int which, | ||
| 281 | struct page **pages, u64 length, | ||
| 282 | u32 alignment, bool pages_from_pool, | ||
| 283 | bool own_pages); | ||
| 284 | extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *, | ||
| 285 | unsigned int which, | ||
| 286 | struct page **pages, u64 length, | ||
| 287 | u32 alignment, bool pages_from_pool, | ||
| 288 | bool own_pages); | ||
| 289 | |||
| 290 | extern void osd_req_op_cls_init(struct ceph_osd_request *osd_req, | ||
| 291 | unsigned int which, u16 opcode, | ||
| 292 | const char *class, const char *method); | ||
| 293 | extern void osd_req_op_watch_init(struct ceph_osd_request *osd_req, | ||
| 294 | unsigned int which, u16 opcode, | ||
| 295 | u64 cookie, u64 version, int flag); | ||
| 296 | |||
| 227 | extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, | 297 | extern struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, |
| 228 | struct ceph_snap_context *snapc, | 298 | struct ceph_snap_context *snapc, |
| 229 | unsigned int num_op, | 299 | unsigned int num_ops, |
| 230 | bool use_mempool, | 300 | bool use_mempool, |
| 231 | gfp_t gfp_flags); | 301 | gfp_t gfp_flags); |
| 232 | 302 | ||
| 233 | extern void ceph_osdc_build_request(struct ceph_osd_request *req, | 303 | extern void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off, |
| 234 | u64 off, u64 len, | ||
| 235 | unsigned int num_op, | ||
| 236 | struct ceph_osd_req_op *src_ops, | ||
| 237 | struct ceph_snap_context *snapc, | 304 | struct ceph_snap_context *snapc, |
| 238 | u64 snap_id, | 305 | u64 snap_id, |
| 239 | struct timespec *mtime); | 306 | struct timespec *mtime); |
| @@ -241,12 +308,11 @@ extern void ceph_osdc_build_request(struct ceph_osd_request *req, | |||
| 241 | extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *, | 308 | extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *, |
| 242 | struct ceph_file_layout *layout, | 309 | struct ceph_file_layout *layout, |
| 243 | struct ceph_vino vino, | 310 | struct ceph_vino vino, |
| 244 | u64 offset, u64 *len, int op, int flags, | 311 | u64 offset, u64 *len, |
| 312 | int num_ops, int opcode, int flags, | ||
| 245 | struct ceph_snap_context *snapc, | 313 | struct ceph_snap_context *snapc, |
| 246 | int do_sync, u32 truncate_seq, | 314 | u32 truncate_seq, u64 truncate_size, |
| 247 | u64 truncate_size, | 315 | bool use_mempool); |
| 248 | struct timespec *mtime, | ||
| 249 | bool use_mempool, int page_align); | ||
| 250 | 316 | ||
| 251 | extern void ceph_osdc_set_request_linger(struct ceph_osd_client *osdc, | 317 | extern void ceph_osdc_set_request_linger(struct ceph_osd_client *osdc, |
| 252 | struct ceph_osd_request *req); | 318 | struct ceph_osd_request *req); |
