Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1 | #include "ceph_debug.h" |
| 2 | |
| 3 | #include <linux/err.h> |
| 4 | #include <linux/highmem.h> |
| 5 | #include <linux/mm.h> |
| 6 | #include <linux/pagemap.h> |
| 7 | #include <linux/slab.h> |
| 8 | #include <linux/uaccess.h> |
| 9 | |
| 10 | #include "super.h" |
| 11 | #include "osd_client.h" |
| 12 | #include "messenger.h" |
| 13 | #include "decode.h" |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 14 | #include "auth.h" |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 15 | |
| 16 | const static struct ceph_connection_operations osd_con_ops; |
| 17 | |
| 18 | static void kick_requests(struct ceph_osd_client *osdc, struct ceph_osd *osd); |
| 19 | |
| 20 | /* |
| 21 | * Implement client access to distributed object storage cluster. |
| 22 | * |
| 23 | * All data objects are stored within a cluster/cloud of OSDs, or |
| 24 | * "object storage devices." (Note that Ceph OSDs have _nothing_ to |
| 25 | * do with the T10 OSD extensions to SCSI.) Ceph OSDs are simply |
| 26 | * remote daemons serving up and coordinating consistent and safe |
| 27 | * access to storage. |
| 28 | * |
| 29 | * Cluster membership and the mapping of data objects onto storage devices |
| 30 | * are described by the osd map. |
| 31 | * |
| 32 | * We keep track of pending OSD requests (read, write), resubmit |
| 33 | * requests to different OSDs when the cluster topology/data layout |
| 34 | * change, or retry the affected requests when the communications |
| 35 | * channel with an OSD is reset. |
| 36 | */ |
| 37 | |
| 38 | /* |
| 39 | * calculate the mapping of a file extent onto an object, and fill out the |
| 40 | * request accordingly. shorten extent as necessary if it crosses an |
| 41 | * object boundary. |
| 42 | * |
| 43 | * fill osd op in request message. |
| 44 | */ |
| 45 | static void calc_layout(struct ceph_osd_client *osdc, |
| 46 | struct ceph_vino vino, struct ceph_file_layout *layout, |
| 47 | u64 off, u64 *plen, |
| 48 | struct ceph_osd_request *req) |
| 49 | { |
| 50 | struct ceph_osd_request_head *reqhead = req->r_request->front.iov_base; |
| 51 | struct ceph_osd_op *op = (void *)(reqhead + 1); |
| 52 | u64 orig_len = *plen; |
| 53 | u64 objoff, objlen; /* extent in object */ |
| 54 | u64 bno; |
| 55 | |
| 56 | reqhead->snapid = cpu_to_le64(vino.snap); |
| 57 | |
| 58 | /* object extent? */ |
| 59 | ceph_calc_file_object_mapping(layout, off, plen, &bno, |
| 60 | &objoff, &objlen); |
| 61 | if (*plen < orig_len) |
| 62 | dout(" skipping last %llu, final file extent %llu~%llu\n", |
| 63 | orig_len - *plen, off, *plen); |
| 64 | |
| 65 | sprintf(req->r_oid, "%llx.%08llx", vino.ino, bno); |
| 66 | req->r_oid_len = strlen(req->r_oid); |
| 67 | |
| 68 | op->extent.offset = cpu_to_le64(objoff); |
| 69 | op->extent.length = cpu_to_le64(objlen); |
| 70 | req->r_num_pages = calc_pages_for(off, *plen); |
| 71 | |
| 72 | dout("calc_layout %s (%d) %llu~%llu (%d pages)\n", |
| 73 | req->r_oid, req->r_oid_len, objoff, objlen, req->r_num_pages); |
| 74 | } |
| 75 | |
| 76 | |
| 77 | /* |
| 78 | * requests |
| 79 | */ |
Sage Weil | 415e49a | 2009-12-07 13:37:03 -0800 | [diff] [blame] | 80 | void ceph_osdc_release_request(struct kref *kref) |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 81 | { |
Sage Weil | 415e49a | 2009-12-07 13:37:03 -0800 | [diff] [blame] | 82 | struct ceph_osd_request *req = container_of(kref, |
| 83 | struct ceph_osd_request, |
| 84 | r_kref); |
| 85 | |
| 86 | if (req->r_request) |
| 87 | ceph_msg_put(req->r_request); |
| 88 | if (req->r_reply) |
| 89 | ceph_msg_put(req->r_reply); |
Sage Weil | 350b1c3 | 2009-12-22 10:45:45 -0800 | [diff] [blame^] | 90 | if (req->r_con_filling_pages) { |
| 91 | dout("release_request revoking pages %p from con %p\n", |
| 92 | req->r_pages, req->r_con_filling_pages); |
| 93 | ceph_con_revoke_pages(req->r_con_filling_pages, |
| 94 | req->r_pages); |
| 95 | ceph_con_put(req->r_con_filling_pages); |
| 96 | } |
Sage Weil | 415e49a | 2009-12-07 13:37:03 -0800 | [diff] [blame] | 97 | if (req->r_own_pages) |
| 98 | ceph_release_page_vector(req->r_pages, |
| 99 | req->r_num_pages); |
| 100 | ceph_put_snap_context(req->r_snapc); |
| 101 | if (req->r_mempool) |
| 102 | mempool_free(req, req->r_osdc->req_mempool); |
| 103 | else |
| 104 | kfree(req); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | /* |
| 108 | * build new request AND message, calculate layout, and adjust file |
| 109 | * extent as needed. |
| 110 | * |
| 111 | * if the file was recently truncated, we include information about its |
| 112 | * old and new size so that the object can be updated appropriately. (we |
| 113 | * avoid synchronously deleting truncated objects because it's slow.) |
| 114 | * |
| 115 | * if @do_sync, include a 'startsync' command so that the osd will flush |
| 116 | * data quickly. |
| 117 | */ |
| 118 | struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, |
| 119 | struct ceph_file_layout *layout, |
| 120 | struct ceph_vino vino, |
| 121 | u64 off, u64 *plen, |
| 122 | int opcode, int flags, |
| 123 | struct ceph_snap_context *snapc, |
| 124 | int do_sync, |
| 125 | u32 truncate_seq, |
| 126 | u64 truncate_size, |
| 127 | struct timespec *mtime, |
| 128 | bool use_mempool, int num_reply) |
| 129 | { |
| 130 | struct ceph_osd_request *req; |
| 131 | struct ceph_msg *msg; |
| 132 | struct ceph_osd_request_head *head; |
| 133 | struct ceph_osd_op *op; |
| 134 | void *p; |
| 135 | int do_trunc = truncate_seq && (off + *plen > truncate_size); |
| 136 | int num_op = 1 + do_sync + do_trunc; |
| 137 | size_t msg_size = sizeof(*head) + num_op*sizeof(*op); |
| 138 | int err, i; |
| 139 | u64 prevofs; |
| 140 | |
| 141 | if (use_mempool) { |
| 142 | req = mempool_alloc(osdc->req_mempool, GFP_NOFS); |
| 143 | memset(req, 0, sizeof(*req)); |
| 144 | } else { |
| 145 | req = kzalloc(sizeof(*req), GFP_NOFS); |
| 146 | } |
| 147 | if (req == NULL) |
| 148 | return ERR_PTR(-ENOMEM); |
| 149 | |
| 150 | err = ceph_msgpool_resv(&osdc->msgpool_op_reply, num_reply); |
| 151 | if (err) { |
| 152 | ceph_osdc_put_request(req); |
| 153 | return ERR_PTR(-ENOMEM); |
| 154 | } |
Yehuda Sadeh | 93c20d9 | 2009-12-15 09:50:36 -0800 | [diff] [blame] | 155 | req->r_num_prealloc_reply = num_reply; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 156 | |
| 157 | req->r_osdc = osdc; |
| 158 | req->r_mempool = use_mempool; |
Sage Weil | 415e49a | 2009-12-07 13:37:03 -0800 | [diff] [blame] | 159 | kref_init(&req->r_kref); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 160 | init_completion(&req->r_completion); |
| 161 | init_completion(&req->r_safe_completion); |
| 162 | INIT_LIST_HEAD(&req->r_unsafe_item); |
| 163 | req->r_flags = flags; |
| 164 | |
| 165 | WARN_ON((flags & (CEPH_OSD_FLAG_READ|CEPH_OSD_FLAG_WRITE)) == 0); |
| 166 | |
| 167 | /* create message; allow space for oid */ |
| 168 | msg_size += 40; |
| 169 | if (snapc) |
| 170 | msg_size += sizeof(u64) * snapc->num_snaps; |
| 171 | if (use_mempool) |
Sage Weil | 8f3bc05 | 2009-10-14 17:36:07 -0700 | [diff] [blame] | 172 | msg = ceph_msgpool_get(&osdc->msgpool_op, 0); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 173 | else |
| 174 | msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, 0, 0, NULL); |
| 175 | if (IS_ERR(msg)) { |
Yehuda Sadeh | 93c20d9 | 2009-12-15 09:50:36 -0800 | [diff] [blame] | 176 | ceph_msgpool_resv(&osdc->msgpool_op_reply, -num_reply); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 177 | ceph_osdc_put_request(req); |
| 178 | return ERR_PTR(PTR_ERR(msg)); |
| 179 | } |
| 180 | msg->hdr.type = cpu_to_le16(CEPH_MSG_OSD_OP); |
| 181 | memset(msg->front.iov_base, 0, msg->front.iov_len); |
| 182 | head = msg->front.iov_base; |
| 183 | op = (void *)(head + 1); |
| 184 | p = (void *)(op + num_op); |
| 185 | |
| 186 | req->r_request = msg; |
| 187 | req->r_snapc = ceph_get_snap_context(snapc); |
| 188 | |
| 189 | head->client_inc = cpu_to_le32(1); /* always, for now. */ |
| 190 | head->flags = cpu_to_le32(flags); |
| 191 | if (flags & CEPH_OSD_FLAG_WRITE) |
| 192 | ceph_encode_timespec(&head->mtime, mtime); |
| 193 | head->num_ops = cpu_to_le16(num_op); |
| 194 | op->op = cpu_to_le16(opcode); |
| 195 | |
| 196 | /* calculate max write size */ |
| 197 | calc_layout(osdc, vino, layout, off, plen, req); |
| 198 | req->r_file_layout = *layout; /* keep a copy */ |
| 199 | |
| 200 | if (flags & CEPH_OSD_FLAG_WRITE) { |
| 201 | req->r_request->hdr.data_off = cpu_to_le16(off); |
| 202 | req->r_request->hdr.data_len = cpu_to_le32(*plen); |
| 203 | op->payload_len = cpu_to_le32(*plen); |
| 204 | } |
| 205 | |
| 206 | /* fill in oid */ |
| 207 | head->object_len = cpu_to_le32(req->r_oid_len); |
| 208 | memcpy(p, req->r_oid, req->r_oid_len); |
| 209 | p += req->r_oid_len; |
| 210 | |
| 211 | /* additional ops */ |
| 212 | if (do_trunc) { |
| 213 | op++; |
| 214 | op->op = cpu_to_le16(opcode == CEPH_OSD_OP_READ ? |
| 215 | CEPH_OSD_OP_MASKTRUNC : CEPH_OSD_OP_SETTRUNC); |
| 216 | op->trunc.truncate_seq = cpu_to_le32(truncate_seq); |
| 217 | prevofs = le64_to_cpu((op-1)->extent.offset); |
| 218 | op->trunc.truncate_size = cpu_to_le64(truncate_size - |
| 219 | (off-prevofs)); |
| 220 | } |
| 221 | if (do_sync) { |
| 222 | op++; |
| 223 | op->op = cpu_to_le16(CEPH_OSD_OP_STARTSYNC); |
| 224 | } |
| 225 | if (snapc) { |
| 226 | head->snap_seq = cpu_to_le64(snapc->seq); |
| 227 | head->num_snaps = cpu_to_le32(snapc->num_snaps); |
| 228 | for (i = 0; i < snapc->num_snaps; i++) { |
| 229 | put_unaligned_le64(snapc->snaps[i], p); |
| 230 | p += sizeof(u64); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | BUG_ON(p > msg->front.iov_base + msg->front.iov_len); |
| 235 | return req; |
| 236 | } |
| 237 | |
| 238 | /* |
| 239 | * We keep osd requests in an rbtree, sorted by ->r_tid. |
| 240 | */ |
| 241 | static void __insert_request(struct ceph_osd_client *osdc, |
| 242 | struct ceph_osd_request *new) |
| 243 | { |
| 244 | struct rb_node **p = &osdc->requests.rb_node; |
| 245 | struct rb_node *parent = NULL; |
| 246 | struct ceph_osd_request *req = NULL; |
| 247 | |
| 248 | while (*p) { |
| 249 | parent = *p; |
| 250 | req = rb_entry(parent, struct ceph_osd_request, r_node); |
| 251 | if (new->r_tid < req->r_tid) |
| 252 | p = &(*p)->rb_left; |
| 253 | else if (new->r_tid > req->r_tid) |
| 254 | p = &(*p)->rb_right; |
| 255 | else |
| 256 | BUG(); |
| 257 | } |
| 258 | |
| 259 | rb_link_node(&new->r_node, parent, p); |
| 260 | rb_insert_color(&new->r_node, &osdc->requests); |
| 261 | } |
| 262 | |
| 263 | static struct ceph_osd_request *__lookup_request(struct ceph_osd_client *osdc, |
| 264 | u64 tid) |
| 265 | { |
| 266 | struct ceph_osd_request *req; |
| 267 | struct rb_node *n = osdc->requests.rb_node; |
| 268 | |
| 269 | while (n) { |
| 270 | req = rb_entry(n, struct ceph_osd_request, r_node); |
| 271 | if (tid < req->r_tid) |
| 272 | n = n->rb_left; |
| 273 | else if (tid > req->r_tid) |
| 274 | n = n->rb_right; |
| 275 | else |
| 276 | return req; |
| 277 | } |
| 278 | return NULL; |
| 279 | } |
| 280 | |
| 281 | static struct ceph_osd_request * |
| 282 | __lookup_request_ge(struct ceph_osd_client *osdc, |
| 283 | u64 tid) |
| 284 | { |
| 285 | struct ceph_osd_request *req; |
| 286 | struct rb_node *n = osdc->requests.rb_node; |
| 287 | |
| 288 | while (n) { |
| 289 | req = rb_entry(n, struct ceph_osd_request, r_node); |
| 290 | if (tid < req->r_tid) { |
| 291 | if (!n->rb_left) |
| 292 | return req; |
| 293 | n = n->rb_left; |
| 294 | } else if (tid > req->r_tid) { |
| 295 | n = n->rb_right; |
| 296 | } else { |
| 297 | return req; |
| 298 | } |
| 299 | } |
| 300 | return NULL; |
| 301 | } |
| 302 | |
| 303 | |
| 304 | /* |
Sage Weil | 81b024e | 2009-10-09 10:29:18 -0700 | [diff] [blame] | 305 | * If the osd connection drops, we need to resubmit all requests. |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 306 | */ |
| 307 | static void osd_reset(struct ceph_connection *con) |
| 308 | { |
| 309 | struct ceph_osd *osd = con->private; |
| 310 | struct ceph_osd_client *osdc; |
| 311 | |
| 312 | if (!osd) |
| 313 | return; |
| 314 | dout("osd_reset osd%d\n", osd->o_osd); |
| 315 | osdc = osd->o_osdc; |
| 316 | osd->o_incarnation++; |
| 317 | down_read(&osdc->map_sem); |
| 318 | kick_requests(osdc, osd); |
| 319 | up_read(&osdc->map_sem); |
| 320 | } |
| 321 | |
| 322 | /* |
| 323 | * Track open sessions with osds. |
| 324 | */ |
| 325 | static struct ceph_osd *create_osd(struct ceph_osd_client *osdc) |
| 326 | { |
| 327 | struct ceph_osd *osd; |
| 328 | |
| 329 | osd = kzalloc(sizeof(*osd), GFP_NOFS); |
| 330 | if (!osd) |
| 331 | return NULL; |
| 332 | |
| 333 | atomic_set(&osd->o_ref, 1); |
| 334 | osd->o_osdc = osdc; |
| 335 | INIT_LIST_HEAD(&osd->o_requests); |
| 336 | osd->o_incarnation = 1; |
| 337 | |
| 338 | ceph_con_init(osdc->client->msgr, &osd->o_con); |
| 339 | osd->o_con.private = osd; |
| 340 | osd->o_con.ops = &osd_con_ops; |
| 341 | osd->o_con.peer_name.type = CEPH_ENTITY_TYPE_OSD; |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 342 | |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 343 | return osd; |
| 344 | } |
| 345 | |
| 346 | static struct ceph_osd *get_osd(struct ceph_osd *osd) |
| 347 | { |
| 348 | if (atomic_inc_not_zero(&osd->o_ref)) { |
| 349 | dout("get_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref)-1, |
| 350 | atomic_read(&osd->o_ref)); |
| 351 | return osd; |
| 352 | } else { |
| 353 | dout("get_osd %p FAIL\n", osd); |
| 354 | return NULL; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | static void put_osd(struct ceph_osd *osd) |
| 359 | { |
| 360 | dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref), |
| 361 | atomic_read(&osd->o_ref) - 1); |
Sage Weil | 42ce56e | 2009-11-18 11:22:36 -0800 | [diff] [blame] | 362 | if (atomic_dec_and_test(&osd->o_ref)) |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 363 | kfree(osd); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | /* |
| 367 | * remove an osd from our map |
| 368 | */ |
| 369 | static void remove_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd) |
| 370 | { |
| 371 | dout("remove_osd %p\n", osd); |
| 372 | BUG_ON(!list_empty(&osd->o_requests)); |
| 373 | rb_erase(&osd->o_node, &osdc->osds); |
| 374 | ceph_con_close(&osd->o_con); |
| 375 | put_osd(osd); |
| 376 | } |
| 377 | |
| 378 | /* |
| 379 | * reset osd connect |
| 380 | */ |
| 381 | static int reset_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd) |
| 382 | { |
| 383 | int ret = 0; |
| 384 | |
| 385 | dout("reset_osd %p osd%d\n", osd, osd->o_osd); |
| 386 | if (list_empty(&osd->o_requests)) { |
| 387 | remove_osd(osdc, osd); |
| 388 | } else { |
| 389 | ceph_con_close(&osd->o_con); |
| 390 | ceph_con_open(&osd->o_con, &osdc->osdmap->osd_addr[osd->o_osd]); |
| 391 | osd->o_incarnation++; |
| 392 | } |
| 393 | return ret; |
| 394 | } |
| 395 | |
| 396 | static void __insert_osd(struct ceph_osd_client *osdc, struct ceph_osd *new) |
| 397 | { |
| 398 | struct rb_node **p = &osdc->osds.rb_node; |
| 399 | struct rb_node *parent = NULL; |
| 400 | struct ceph_osd *osd = NULL; |
| 401 | |
| 402 | while (*p) { |
| 403 | parent = *p; |
| 404 | osd = rb_entry(parent, struct ceph_osd, o_node); |
| 405 | if (new->o_osd < osd->o_osd) |
| 406 | p = &(*p)->rb_left; |
| 407 | else if (new->o_osd > osd->o_osd) |
| 408 | p = &(*p)->rb_right; |
| 409 | else |
| 410 | BUG(); |
| 411 | } |
| 412 | |
| 413 | rb_link_node(&new->o_node, parent, p); |
| 414 | rb_insert_color(&new->o_node, &osdc->osds); |
| 415 | } |
| 416 | |
| 417 | static struct ceph_osd *__lookup_osd(struct ceph_osd_client *osdc, int o) |
| 418 | { |
| 419 | struct ceph_osd *osd; |
| 420 | struct rb_node *n = osdc->osds.rb_node; |
| 421 | |
| 422 | while (n) { |
| 423 | osd = rb_entry(n, struct ceph_osd, o_node); |
| 424 | if (o < osd->o_osd) |
| 425 | n = n->rb_left; |
| 426 | else if (o > osd->o_osd) |
| 427 | n = n->rb_right; |
| 428 | else |
| 429 | return osd; |
| 430 | } |
| 431 | return NULL; |
| 432 | } |
| 433 | |
| 434 | |
| 435 | /* |
| 436 | * Register request, assign tid. If this is the first request, set up |
| 437 | * the timeout event. |
| 438 | */ |
| 439 | static void register_request(struct ceph_osd_client *osdc, |
| 440 | struct ceph_osd_request *req) |
| 441 | { |
| 442 | struct ceph_osd_request_head *head = req->r_request->front.iov_base; |
| 443 | |
| 444 | mutex_lock(&osdc->request_mutex); |
| 445 | req->r_tid = ++osdc->last_tid; |
| 446 | head->tid = cpu_to_le64(req->r_tid); |
| 447 | |
| 448 | dout("register_request %p tid %lld\n", req, req->r_tid); |
| 449 | __insert_request(osdc, req); |
| 450 | ceph_osdc_get_request(req); |
| 451 | osdc->num_requests++; |
| 452 | |
| 453 | req->r_timeout_stamp = |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 454 | jiffies + osdc->client->mount_args->osd_timeout*HZ; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 455 | |
| 456 | if (osdc->num_requests == 1) { |
| 457 | osdc->timeout_tid = req->r_tid; |
| 458 | dout(" timeout on tid %llu at %lu\n", req->r_tid, |
| 459 | req->r_timeout_stamp); |
| 460 | schedule_delayed_work(&osdc->timeout_work, |
| 461 | round_jiffies_relative(req->r_timeout_stamp - jiffies)); |
| 462 | } |
| 463 | mutex_unlock(&osdc->request_mutex); |
| 464 | } |
| 465 | |
| 466 | /* |
| 467 | * called under osdc->request_mutex |
| 468 | */ |
| 469 | static void __unregister_request(struct ceph_osd_client *osdc, |
| 470 | struct ceph_osd_request *req) |
| 471 | { |
| 472 | dout("__unregister_request %p tid %lld\n", req, req->r_tid); |
| 473 | rb_erase(&req->r_node, &osdc->requests); |
| 474 | osdc->num_requests--; |
| 475 | |
Yehuda Sadeh | 93c20d9 | 2009-12-15 09:50:36 -0800 | [diff] [blame] | 476 | ceph_msgpool_resv(&osdc->msgpool_op_reply, -req->r_num_prealloc_reply); |
| 477 | |
Sage Weil | 0ba6478 | 2009-10-08 16:57:16 -0700 | [diff] [blame] | 478 | if (req->r_osd) { |
| 479 | /* make sure the original request isn't in flight. */ |
| 480 | ceph_con_revoke(&req->r_osd->o_con, req->r_request); |
| 481 | |
| 482 | list_del_init(&req->r_osd_item); |
| 483 | if (list_empty(&req->r_osd->o_requests)) |
| 484 | remove_osd(osdc, req->r_osd); |
| 485 | req->r_osd = NULL; |
| 486 | } |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 487 | |
| 488 | ceph_osdc_put_request(req); |
| 489 | |
| 490 | if (req->r_tid == osdc->timeout_tid) { |
| 491 | if (osdc->num_requests == 0) { |
| 492 | dout("no requests, canceling timeout\n"); |
| 493 | osdc->timeout_tid = 0; |
| 494 | cancel_delayed_work(&osdc->timeout_work); |
| 495 | } else { |
| 496 | req = rb_entry(rb_first(&osdc->requests), |
| 497 | struct ceph_osd_request, r_node); |
| 498 | osdc->timeout_tid = req->r_tid; |
| 499 | dout("rescheduled timeout on tid %llu at %lu\n", |
| 500 | req->r_tid, req->r_timeout_stamp); |
| 501 | schedule_delayed_work(&osdc->timeout_work, |
| 502 | round_jiffies_relative(req->r_timeout_stamp - |
| 503 | jiffies)); |
| 504 | } |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | /* |
| 509 | * Cancel a previously queued request message |
| 510 | */ |
| 511 | static void __cancel_request(struct ceph_osd_request *req) |
| 512 | { |
| 513 | if (req->r_sent) { |
| 514 | ceph_con_revoke(&req->r_osd->o_con, req->r_request); |
| 515 | req->r_sent = 0; |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | /* |
| 520 | * Pick an osd (the first 'up' osd in the pg), allocate the osd struct |
| 521 | * (as needed), and set the request r_osd appropriately. If there is |
| 522 | * no up osd, set r_osd to NULL. |
| 523 | * |
| 524 | * Return 0 if unchanged, 1 if changed, or negative on error. |
| 525 | * |
| 526 | * Caller should hold map_sem for read and request_mutex. |
| 527 | */ |
| 528 | static int __map_osds(struct ceph_osd_client *osdc, |
| 529 | struct ceph_osd_request *req) |
| 530 | { |
| 531 | struct ceph_osd_request_head *reqhead = req->r_request->front.iov_base; |
Sage Weil | 5104212 | 2009-11-04 11:39:12 -0800 | [diff] [blame] | 532 | struct ceph_pg pgid; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 533 | int o = -1; |
| 534 | int err; |
| 535 | struct ceph_osd *newosd = NULL; |
| 536 | |
| 537 | dout("map_osds %p tid %lld\n", req, req->r_tid); |
| 538 | err = ceph_calc_object_layout(&reqhead->layout, req->r_oid, |
| 539 | &req->r_file_layout, osdc->osdmap); |
| 540 | if (err) |
| 541 | return err; |
Sage Weil | 5104212 | 2009-11-04 11:39:12 -0800 | [diff] [blame] | 542 | pgid = reqhead->layout.ol_pgid; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 543 | o = ceph_calc_pg_primary(osdc->osdmap, pgid); |
| 544 | |
| 545 | if ((req->r_osd && req->r_osd->o_osd == o && |
| 546 | req->r_sent >= req->r_osd->o_incarnation) || |
| 547 | (req->r_osd == NULL && o == -1)) |
| 548 | return 0; /* no change */ |
| 549 | |
Sage Weil | 5104212 | 2009-11-04 11:39:12 -0800 | [diff] [blame] | 550 | dout("map_osds tid %llu pgid %d.%x osd%d (was osd%d)\n", |
| 551 | req->r_tid, le32_to_cpu(pgid.pool), le16_to_cpu(pgid.ps), o, |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 552 | req->r_osd ? req->r_osd->o_osd : -1); |
| 553 | |
| 554 | if (req->r_osd) { |
| 555 | __cancel_request(req); |
| 556 | list_del_init(&req->r_osd_item); |
| 557 | if (list_empty(&req->r_osd->o_requests)) { |
| 558 | /* try to re-use r_osd if possible */ |
| 559 | newosd = get_osd(req->r_osd); |
| 560 | remove_osd(osdc, newosd); |
| 561 | } |
| 562 | req->r_osd = NULL; |
| 563 | } |
| 564 | |
| 565 | req->r_osd = __lookup_osd(osdc, o); |
| 566 | if (!req->r_osd && o >= 0) { |
| 567 | if (newosd) { |
| 568 | req->r_osd = newosd; |
| 569 | newosd = NULL; |
| 570 | } else { |
| 571 | err = -ENOMEM; |
| 572 | req->r_osd = create_osd(osdc); |
| 573 | if (!req->r_osd) |
| 574 | goto out; |
| 575 | } |
| 576 | |
| 577 | dout("map_osds osd %p is osd%d\n", req->r_osd, o); |
| 578 | req->r_osd->o_osd = o; |
| 579 | req->r_osd->o_con.peer_name.num = cpu_to_le64(o); |
| 580 | __insert_osd(osdc, req->r_osd); |
| 581 | |
| 582 | ceph_con_open(&req->r_osd->o_con, &osdc->osdmap->osd_addr[o]); |
| 583 | } |
| 584 | |
| 585 | if (req->r_osd) |
| 586 | list_add(&req->r_osd_item, &req->r_osd->o_requests); |
| 587 | err = 1; /* osd changed */ |
| 588 | |
| 589 | out: |
| 590 | if (newosd) |
| 591 | put_osd(newosd); |
| 592 | return err; |
| 593 | } |
| 594 | |
| 595 | /* |
| 596 | * caller should hold map_sem (for read) and request_mutex |
| 597 | */ |
| 598 | static int __send_request(struct ceph_osd_client *osdc, |
| 599 | struct ceph_osd_request *req) |
| 600 | { |
| 601 | struct ceph_osd_request_head *reqhead; |
| 602 | int err; |
| 603 | |
| 604 | err = __map_osds(osdc, req); |
| 605 | if (err < 0) |
| 606 | return err; |
| 607 | if (req->r_osd == NULL) { |
| 608 | dout("send_request %p no up osds in pg\n", req); |
| 609 | ceph_monc_request_next_osdmap(&osdc->client->monc); |
| 610 | return 0; |
| 611 | } |
| 612 | |
| 613 | dout("send_request %p tid %llu to osd%d flags %d\n", |
| 614 | req, req->r_tid, req->r_osd->o_osd, req->r_flags); |
| 615 | |
| 616 | reqhead = req->r_request->front.iov_base; |
| 617 | reqhead->osdmap_epoch = cpu_to_le32(osdc->osdmap->epoch); |
| 618 | reqhead->flags |= cpu_to_le32(req->r_flags); /* e.g., RETRY */ |
| 619 | reqhead->reassert_version = req->r_reassert_version; |
| 620 | |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 621 | req->r_timeout_stamp = jiffies+osdc->client->mount_args->osd_timeout*HZ; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 622 | |
| 623 | ceph_msg_get(req->r_request); /* send consumes a ref */ |
| 624 | ceph_con_send(&req->r_osd->o_con, req->r_request); |
| 625 | req->r_sent = req->r_osd->o_incarnation; |
| 626 | return 0; |
| 627 | } |
| 628 | |
| 629 | /* |
| 630 | * Timeout callback, called every N seconds when 1 or more osd |
| 631 | * requests has been active for more than N seconds. When this |
| 632 | * happens, we ping all OSDs with requests who have timed out to |
| 633 | * ensure any communications channel reset is detected. Reset the |
| 634 | * request timeouts another N seconds in the future as we go. |
| 635 | * Reschedule the timeout event another N seconds in future (unless |
| 636 | * there are no open requests). |
| 637 | */ |
| 638 | static void handle_timeout(struct work_struct *work) |
| 639 | { |
| 640 | struct ceph_osd_client *osdc = |
| 641 | container_of(work, struct ceph_osd_client, timeout_work.work); |
| 642 | struct ceph_osd_request *req; |
| 643 | struct ceph_osd *osd; |
Sage Weil | 6b80518 | 2009-10-27 11:50:50 -0700 | [diff] [blame] | 644 | unsigned long timeout = osdc->client->mount_args->osd_timeout * HZ; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 645 | unsigned long next_timeout = timeout + jiffies; |
| 646 | struct rb_node *p; |
| 647 | |
| 648 | dout("timeout\n"); |
| 649 | down_read(&osdc->map_sem); |
| 650 | |
| 651 | ceph_monc_request_next_osdmap(&osdc->client->monc); |
| 652 | |
| 653 | mutex_lock(&osdc->request_mutex); |
| 654 | for (p = rb_first(&osdc->requests); p; p = rb_next(p)) { |
| 655 | req = rb_entry(p, struct ceph_osd_request, r_node); |
| 656 | |
| 657 | if (req->r_resend) { |
| 658 | int err; |
| 659 | |
| 660 | dout("osdc resending prev failed %lld\n", req->r_tid); |
| 661 | err = __send_request(osdc, req); |
| 662 | if (err) |
| 663 | dout("osdc failed again on %lld\n", req->r_tid); |
| 664 | else |
| 665 | req->r_resend = false; |
| 666 | continue; |
| 667 | } |
| 668 | } |
| 669 | for (p = rb_first(&osdc->osds); p; p = rb_next(p)) { |
| 670 | osd = rb_entry(p, struct ceph_osd, o_node); |
| 671 | if (list_empty(&osd->o_requests)) |
| 672 | continue; |
| 673 | req = list_first_entry(&osd->o_requests, |
| 674 | struct ceph_osd_request, r_osd_item); |
| 675 | if (time_before(jiffies, req->r_timeout_stamp)) |
| 676 | continue; |
| 677 | |
| 678 | dout(" tid %llu (at least) timed out on osd%d\n", |
| 679 | req->r_tid, osd->o_osd); |
| 680 | req->r_timeout_stamp = next_timeout; |
| 681 | ceph_con_keepalive(&osd->o_con); |
| 682 | } |
| 683 | |
| 684 | if (osdc->timeout_tid) |
| 685 | schedule_delayed_work(&osdc->timeout_work, |
| 686 | round_jiffies_relative(timeout)); |
| 687 | |
| 688 | mutex_unlock(&osdc->request_mutex); |
| 689 | |
| 690 | up_read(&osdc->map_sem); |
| 691 | } |
| 692 | |
| 693 | /* |
| 694 | * handle osd op reply. either call the callback if it is specified, |
| 695 | * or do the completion to wake up the waiting thread. |
| 696 | */ |
Sage Weil | 350b1c3 | 2009-12-22 10:45:45 -0800 | [diff] [blame^] | 697 | static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg, |
| 698 | struct ceph_connection *con) |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 699 | { |
| 700 | struct ceph_osd_reply_head *rhead = msg->front.iov_base; |
| 701 | struct ceph_osd_request *req; |
| 702 | u64 tid; |
| 703 | int numops, object_len, flags; |
| 704 | |
| 705 | if (msg->front.iov_len < sizeof(*rhead)) |
| 706 | goto bad; |
| 707 | tid = le64_to_cpu(rhead->tid); |
| 708 | numops = le32_to_cpu(rhead->num_ops); |
| 709 | object_len = le32_to_cpu(rhead->object_len); |
| 710 | if (msg->front.iov_len != sizeof(*rhead) + object_len + |
| 711 | numops * sizeof(struct ceph_osd_op)) |
| 712 | goto bad; |
| 713 | dout("handle_reply %p tid %llu\n", msg, tid); |
| 714 | |
| 715 | /* lookup */ |
| 716 | mutex_lock(&osdc->request_mutex); |
| 717 | req = __lookup_request(osdc, tid); |
| 718 | if (req == NULL) { |
| 719 | dout("handle_reply tid %llu dne\n", tid); |
| 720 | mutex_unlock(&osdc->request_mutex); |
| 721 | return; |
| 722 | } |
| 723 | ceph_osdc_get_request(req); |
| 724 | flags = le32_to_cpu(rhead->flags); |
| 725 | |
Sage Weil | 350b1c3 | 2009-12-22 10:45:45 -0800 | [diff] [blame^] | 726 | /* |
| 727 | * if this connection filled our pages, drop our reference now, to |
| 728 | * avoid a (safe but slower) revoke later. |
| 729 | */ |
| 730 | if (req->r_con_filling_pages == con && req->r_pages == msg->pages) { |
| 731 | dout(" got pages, dropping con_filling_pages ref %p\n", con); |
| 732 | req->r_con_filling_pages = NULL; |
| 733 | ceph_con_put(con); |
| 734 | } |
| 735 | |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 736 | if (req->r_reply) { |
| 737 | /* |
| 738 | * once we see the message has been received, we don't |
| 739 | * need a ref (which is only needed for revoking |
| 740 | * pages) |
| 741 | */ |
| 742 | ceph_msg_put(req->r_reply); |
| 743 | req->r_reply = NULL; |
| 744 | } |
| 745 | |
| 746 | if (!req->r_got_reply) { |
| 747 | unsigned bytes; |
| 748 | |
| 749 | req->r_result = le32_to_cpu(rhead->result); |
| 750 | bytes = le32_to_cpu(msg->hdr.data_len); |
| 751 | dout("handle_reply result %d bytes %d\n", req->r_result, |
| 752 | bytes); |
| 753 | if (req->r_result == 0) |
| 754 | req->r_result = bytes; |
| 755 | |
| 756 | /* in case this is a write and we need to replay, */ |
| 757 | req->r_reassert_version = rhead->reassert_version; |
| 758 | |
| 759 | req->r_got_reply = 1; |
| 760 | } else if ((flags & CEPH_OSD_FLAG_ONDISK) == 0) { |
| 761 | dout("handle_reply tid %llu dup ack\n", tid); |
Sage Weil | 34b43a5 | 2009-12-01 12:23:54 -0800 | [diff] [blame] | 762 | mutex_unlock(&osdc->request_mutex); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 763 | goto done; |
| 764 | } |
| 765 | |
| 766 | dout("handle_reply tid %llu flags %d\n", tid, flags); |
| 767 | |
| 768 | /* either this is a read, or we got the safe response */ |
| 769 | if ((flags & CEPH_OSD_FLAG_ONDISK) || |
| 770 | ((flags & CEPH_OSD_FLAG_WRITE) == 0)) |
| 771 | __unregister_request(osdc, req); |
| 772 | |
| 773 | mutex_unlock(&osdc->request_mutex); |
| 774 | |
| 775 | if (req->r_callback) |
| 776 | req->r_callback(req, msg); |
| 777 | else |
| 778 | complete(&req->r_completion); |
| 779 | |
| 780 | if (flags & CEPH_OSD_FLAG_ONDISK) { |
| 781 | if (req->r_safe_callback) |
| 782 | req->r_safe_callback(req, msg); |
| 783 | complete(&req->r_safe_completion); /* fsync waiter */ |
| 784 | } |
| 785 | |
| 786 | done: |
| 787 | ceph_osdc_put_request(req); |
| 788 | return; |
| 789 | |
| 790 | bad: |
| 791 | pr_err("corrupt osd_op_reply got %d %d expected %d\n", |
| 792 | (int)msg->front.iov_len, le32_to_cpu(msg->hdr.front_len), |
| 793 | (int)sizeof(*rhead)); |
Sage Weil | 9ec7cab | 2009-12-14 15:13:47 -0800 | [diff] [blame] | 794 | ceph_msg_dump(msg); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 795 | } |
| 796 | |
| 797 | |
| 798 | /* |
| 799 | * Resubmit osd requests whose osd or osd address has changed. Request |
| 800 | * a new osd map if osds are down, or we are otherwise unable to determine |
| 801 | * how to direct a request. |
| 802 | * |
| 803 | * Close connections to down osds. |
| 804 | * |
| 805 | * If @who is specified, resubmit requests for that specific osd. |
| 806 | * |
| 807 | * Caller should hold map_sem for read and request_mutex. |
| 808 | */ |
| 809 | static void kick_requests(struct ceph_osd_client *osdc, |
| 810 | struct ceph_osd *kickosd) |
| 811 | { |
| 812 | struct ceph_osd_request *req; |
| 813 | struct rb_node *p, *n; |
| 814 | int needmap = 0; |
| 815 | int err; |
| 816 | |
| 817 | dout("kick_requests osd%d\n", kickosd ? kickosd->o_osd : -1); |
| 818 | mutex_lock(&osdc->request_mutex); |
| 819 | if (!kickosd) { |
| 820 | for (p = rb_first(&osdc->osds); p; p = n) { |
| 821 | struct ceph_osd *osd = |
| 822 | rb_entry(p, struct ceph_osd, o_node); |
| 823 | |
| 824 | n = rb_next(p); |
| 825 | if (!ceph_osd_is_up(osdc->osdmap, osd->o_osd) || |
| 826 | !ceph_entity_addr_equal(&osd->o_con.peer_addr, |
| 827 | ceph_osd_addr(osdc->osdmap, |
| 828 | osd->o_osd))) |
| 829 | reset_osd(osdc, osd); |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | for (p = rb_first(&osdc->requests); p; p = rb_next(p)) { |
| 834 | req = rb_entry(p, struct ceph_osd_request, r_node); |
| 835 | |
| 836 | if (req->r_resend) { |
| 837 | dout(" r_resend set on tid %llu\n", req->r_tid); |
Sage Weil | 266673d | 2009-10-09 10:31:32 -0700 | [diff] [blame] | 838 | __cancel_request(req); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 839 | goto kick; |
| 840 | } |
Sage Weil | 266673d | 2009-10-09 10:31:32 -0700 | [diff] [blame] | 841 | if (req->r_osd && kickosd == req->r_osd) { |
| 842 | __cancel_request(req); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 843 | goto kick; |
Sage Weil | 266673d | 2009-10-09 10:31:32 -0700 | [diff] [blame] | 844 | } |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 845 | |
| 846 | err = __map_osds(osdc, req); |
| 847 | if (err == 0) |
| 848 | continue; /* no change */ |
| 849 | if (err < 0) { |
| 850 | /* |
| 851 | * FIXME: really, we should set the request |
| 852 | * error and fail if this isn't a 'nofail' |
| 853 | * request, but that's a fair bit more |
| 854 | * complicated to do. So retry! |
| 855 | */ |
| 856 | dout(" setting r_resend on %llu\n", req->r_tid); |
| 857 | req->r_resend = true; |
| 858 | continue; |
| 859 | } |
| 860 | if (req->r_osd == NULL) { |
| 861 | dout("tid %llu maps to no valid osd\n", req->r_tid); |
| 862 | needmap++; /* request a newer map */ |
| 863 | continue; |
| 864 | } |
| 865 | |
| 866 | kick: |
Sage Weil | c1ea882 | 2009-10-08 16:55:47 -0700 | [diff] [blame] | 867 | dout("kicking %p tid %llu osd%d\n", req, req->r_tid, |
| 868 | req->r_osd->o_osd); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 869 | req->r_flags |= CEPH_OSD_FLAG_RETRY; |
| 870 | err = __send_request(osdc, req); |
| 871 | if (err) { |
| 872 | dout(" setting r_resend on %llu\n", req->r_tid); |
| 873 | req->r_resend = true; |
| 874 | } |
| 875 | } |
| 876 | mutex_unlock(&osdc->request_mutex); |
| 877 | |
| 878 | if (needmap) { |
| 879 | dout("%d requests for down osds, need new map\n", needmap); |
| 880 | ceph_monc_request_next_osdmap(&osdc->client->monc); |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | /* |
| 885 | * Process updated osd map. |
| 886 | * |
| 887 | * The message contains any number of incremental and full maps, normally |
| 888 | * indicating some sort of topology change in the cluster. Kick requests |
| 889 | * off to different OSDs as needed. |
| 890 | */ |
| 891 | void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) |
| 892 | { |
| 893 | void *p, *end, *next; |
| 894 | u32 nr_maps, maplen; |
| 895 | u32 epoch; |
| 896 | struct ceph_osdmap *newmap = NULL, *oldmap; |
| 897 | int err; |
| 898 | struct ceph_fsid fsid; |
| 899 | |
| 900 | dout("handle_map have %u\n", osdc->osdmap ? osdc->osdmap->epoch : 0); |
| 901 | p = msg->front.iov_base; |
| 902 | end = p + msg->front.iov_len; |
| 903 | |
| 904 | /* verify fsid */ |
| 905 | ceph_decode_need(&p, end, sizeof(fsid), bad); |
| 906 | ceph_decode_copy(&p, &fsid, sizeof(fsid)); |
Sage Weil | 0743304 | 2009-11-18 16:50:41 -0800 | [diff] [blame] | 907 | if (ceph_check_fsid(osdc->client, &fsid) < 0) |
| 908 | return; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 909 | |
| 910 | down_write(&osdc->map_sem); |
| 911 | |
| 912 | /* incremental maps */ |
| 913 | ceph_decode_32_safe(&p, end, nr_maps, bad); |
| 914 | dout(" %d inc maps\n", nr_maps); |
| 915 | while (nr_maps > 0) { |
| 916 | ceph_decode_need(&p, end, 2*sizeof(u32), bad); |
Sage Weil | c89136e | 2009-10-14 09:59:09 -0700 | [diff] [blame] | 917 | epoch = ceph_decode_32(&p); |
| 918 | maplen = ceph_decode_32(&p); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 919 | ceph_decode_need(&p, end, maplen, bad); |
| 920 | next = p + maplen; |
| 921 | if (osdc->osdmap && osdc->osdmap->epoch+1 == epoch) { |
| 922 | dout("applying incremental map %u len %d\n", |
| 923 | epoch, maplen); |
| 924 | newmap = osdmap_apply_incremental(&p, next, |
| 925 | osdc->osdmap, |
| 926 | osdc->client->msgr); |
| 927 | if (IS_ERR(newmap)) { |
| 928 | err = PTR_ERR(newmap); |
| 929 | goto bad; |
| 930 | } |
Sage Weil | 30dc638 | 2009-12-21 14:49:37 -0800 | [diff] [blame] | 931 | BUG_ON(!newmap); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 932 | if (newmap != osdc->osdmap) { |
| 933 | ceph_osdmap_destroy(osdc->osdmap); |
| 934 | osdc->osdmap = newmap; |
| 935 | } |
| 936 | } else { |
| 937 | dout("ignoring incremental map %u len %d\n", |
| 938 | epoch, maplen); |
| 939 | } |
| 940 | p = next; |
| 941 | nr_maps--; |
| 942 | } |
| 943 | if (newmap) |
| 944 | goto done; |
| 945 | |
| 946 | /* full maps */ |
| 947 | ceph_decode_32_safe(&p, end, nr_maps, bad); |
| 948 | dout(" %d full maps\n", nr_maps); |
| 949 | while (nr_maps) { |
| 950 | ceph_decode_need(&p, end, 2*sizeof(u32), bad); |
Sage Weil | c89136e | 2009-10-14 09:59:09 -0700 | [diff] [blame] | 951 | epoch = ceph_decode_32(&p); |
| 952 | maplen = ceph_decode_32(&p); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 953 | ceph_decode_need(&p, end, maplen, bad); |
| 954 | if (nr_maps > 1) { |
| 955 | dout("skipping non-latest full map %u len %d\n", |
| 956 | epoch, maplen); |
| 957 | } else if (osdc->osdmap && osdc->osdmap->epoch >= epoch) { |
| 958 | dout("skipping full map %u len %d, " |
| 959 | "older than our %u\n", epoch, maplen, |
| 960 | osdc->osdmap->epoch); |
| 961 | } else { |
| 962 | dout("taking full map %u len %d\n", epoch, maplen); |
| 963 | newmap = osdmap_decode(&p, p+maplen); |
| 964 | if (IS_ERR(newmap)) { |
| 965 | err = PTR_ERR(newmap); |
| 966 | goto bad; |
| 967 | } |
Sage Weil | 30dc638 | 2009-12-21 14:49:37 -0800 | [diff] [blame] | 968 | BUG_ON(!newmap); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 969 | oldmap = osdc->osdmap; |
| 970 | osdc->osdmap = newmap; |
| 971 | if (oldmap) |
| 972 | ceph_osdmap_destroy(oldmap); |
| 973 | } |
| 974 | p += maplen; |
| 975 | nr_maps--; |
| 976 | } |
| 977 | |
| 978 | done: |
| 979 | downgrade_write(&osdc->map_sem); |
| 980 | ceph_monc_got_osdmap(&osdc->client->monc, osdc->osdmap->epoch); |
| 981 | if (newmap) |
| 982 | kick_requests(osdc, NULL); |
| 983 | up_read(&osdc->map_sem); |
| 984 | return; |
| 985 | |
| 986 | bad: |
| 987 | pr_err("osdc handle_map corrupt msg\n"); |
Sage Weil | 9ec7cab | 2009-12-14 15:13:47 -0800 | [diff] [blame] | 988 | ceph_msg_dump(msg); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 989 | up_write(&osdc->map_sem); |
| 990 | return; |
| 991 | } |
| 992 | |
| 993 | |
| 994 | /* |
| 995 | * A read request prepares specific pages that data is to be read into. |
| 996 | * When a message is being read off the wire, we call prepare_pages to |
| 997 | * find those pages. |
| 998 | * 0 = success, -1 failure. |
| 999 | */ |
| 1000 | static int prepare_pages(struct ceph_connection *con, struct ceph_msg *m, |
| 1001 | int want) |
| 1002 | { |
| 1003 | struct ceph_osd *osd = con->private; |
| 1004 | struct ceph_osd_client *osdc; |
| 1005 | struct ceph_osd_reply_head *rhead = m->front.iov_base; |
| 1006 | struct ceph_osd_request *req; |
| 1007 | u64 tid; |
| 1008 | int ret = -1; |
| 1009 | int type = le16_to_cpu(m->hdr.type); |
| 1010 | |
| 1011 | if (!osd) |
| 1012 | return -1; |
| 1013 | osdc = osd->o_osdc; |
| 1014 | |
| 1015 | dout("prepare_pages on msg %p want %d\n", m, want); |
| 1016 | if (unlikely(type != CEPH_MSG_OSD_OPREPLY)) |
| 1017 | return -1; /* hmm! */ |
| 1018 | |
| 1019 | tid = le64_to_cpu(rhead->tid); |
| 1020 | mutex_lock(&osdc->request_mutex); |
| 1021 | req = __lookup_request(osdc, tid); |
| 1022 | if (!req) { |
| 1023 | dout("prepare_pages unknown tid %llu\n", tid); |
| 1024 | goto out; |
| 1025 | } |
| 1026 | dout("prepare_pages tid %llu has %d pages, want %d\n", |
| 1027 | tid, req->r_num_pages, want); |
Sage Weil | 350b1c3 | 2009-12-22 10:45:45 -0800 | [diff] [blame^] | 1028 | if (unlikely(req->r_num_pages < want)) |
| 1029 | goto out; |
| 1030 | |
| 1031 | if (req->r_con_filling_pages) { |
| 1032 | dout("revoking pages %p from old con %p\n", req->r_pages, |
| 1033 | req->r_con_filling_pages); |
| 1034 | ceph_con_revoke_pages(req->r_con_filling_pages, req->r_pages); |
| 1035 | ceph_con_put(req->r_con_filling_pages); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1036 | } |
Sage Weil | 350b1c3 | 2009-12-22 10:45:45 -0800 | [diff] [blame^] | 1037 | req->r_con_filling_pages = ceph_con_get(con); |
| 1038 | req->r_reply = ceph_msg_get(m); /* for duration of read over socket */ |
| 1039 | m->pages = req->r_pages; |
| 1040 | m->nr_pages = req->r_num_pages; |
| 1041 | ret = 0; /* success */ |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1042 | out: |
| 1043 | mutex_unlock(&osdc->request_mutex); |
| 1044 | return ret; |
| 1045 | } |
| 1046 | |
| 1047 | /* |
| 1048 | * Register request, send initial attempt. |
| 1049 | */ |
| 1050 | int ceph_osdc_start_request(struct ceph_osd_client *osdc, |
| 1051 | struct ceph_osd_request *req, |
| 1052 | bool nofail) |
| 1053 | { |
Sage Weil | c1ea882 | 2009-10-08 16:55:47 -0700 | [diff] [blame] | 1054 | int rc = 0; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1055 | |
| 1056 | req->r_request->pages = req->r_pages; |
| 1057 | req->r_request->nr_pages = req->r_num_pages; |
| 1058 | |
| 1059 | register_request(osdc, req); |
| 1060 | |
| 1061 | down_read(&osdc->map_sem); |
| 1062 | mutex_lock(&osdc->request_mutex); |
Sage Weil | c1ea882 | 2009-10-08 16:55:47 -0700 | [diff] [blame] | 1063 | /* |
| 1064 | * a racing kick_requests() may have sent the message for us |
| 1065 | * while we dropped request_mutex above, so only send now if |
| 1066 | * the request still han't been touched yet. |
| 1067 | */ |
| 1068 | if (req->r_sent == 0) { |
| 1069 | rc = __send_request(osdc, req); |
| 1070 | if (rc) { |
| 1071 | if (nofail) { |
| 1072 | dout("osdc_start_request failed send, " |
| 1073 | " marking %lld\n", req->r_tid); |
| 1074 | req->r_resend = true; |
| 1075 | rc = 0; |
| 1076 | } else { |
| 1077 | __unregister_request(osdc, req); |
| 1078 | } |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1079 | } |
| 1080 | } |
| 1081 | mutex_unlock(&osdc->request_mutex); |
| 1082 | up_read(&osdc->map_sem); |
| 1083 | return rc; |
| 1084 | } |
| 1085 | |
| 1086 | /* |
| 1087 | * wait for a request to complete |
| 1088 | */ |
| 1089 | int ceph_osdc_wait_request(struct ceph_osd_client *osdc, |
| 1090 | struct ceph_osd_request *req) |
| 1091 | { |
| 1092 | int rc; |
| 1093 | |
| 1094 | rc = wait_for_completion_interruptible(&req->r_completion); |
| 1095 | if (rc < 0) { |
| 1096 | mutex_lock(&osdc->request_mutex); |
| 1097 | __cancel_request(req); |
Sage Weil | 529cfcc | 2009-12-22 10:29:39 -0800 | [diff] [blame] | 1098 | __unregister_request(osdc, req); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1099 | mutex_unlock(&osdc->request_mutex); |
Sage Weil | 529cfcc | 2009-12-22 10:29:39 -0800 | [diff] [blame] | 1100 | dout("wait_request tid %llu canceled/timed out\n", req->r_tid); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1101 | return rc; |
| 1102 | } |
| 1103 | |
| 1104 | dout("wait_request tid %llu result %d\n", req->r_tid, req->r_result); |
| 1105 | return req->r_result; |
| 1106 | } |
| 1107 | |
| 1108 | /* |
| 1109 | * sync - wait for all in-flight requests to flush. avoid starvation. |
| 1110 | */ |
| 1111 | void ceph_osdc_sync(struct ceph_osd_client *osdc) |
| 1112 | { |
| 1113 | struct ceph_osd_request *req; |
| 1114 | u64 last_tid, next_tid = 0; |
| 1115 | |
| 1116 | mutex_lock(&osdc->request_mutex); |
| 1117 | last_tid = osdc->last_tid; |
| 1118 | while (1) { |
| 1119 | req = __lookup_request_ge(osdc, next_tid); |
| 1120 | if (!req) |
| 1121 | break; |
| 1122 | if (req->r_tid > last_tid) |
| 1123 | break; |
| 1124 | |
| 1125 | next_tid = req->r_tid + 1; |
| 1126 | if ((req->r_flags & CEPH_OSD_FLAG_WRITE) == 0) |
| 1127 | continue; |
| 1128 | |
| 1129 | ceph_osdc_get_request(req); |
| 1130 | mutex_unlock(&osdc->request_mutex); |
| 1131 | dout("sync waiting on tid %llu (last is %llu)\n", |
| 1132 | req->r_tid, last_tid); |
| 1133 | wait_for_completion(&req->r_safe_completion); |
| 1134 | mutex_lock(&osdc->request_mutex); |
| 1135 | ceph_osdc_put_request(req); |
| 1136 | } |
| 1137 | mutex_unlock(&osdc->request_mutex); |
| 1138 | dout("sync done (thru tid %llu)\n", last_tid); |
| 1139 | } |
| 1140 | |
| 1141 | /* |
| 1142 | * init, shutdown |
| 1143 | */ |
| 1144 | int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client) |
| 1145 | { |
| 1146 | int err; |
| 1147 | |
| 1148 | dout("init\n"); |
| 1149 | osdc->client = client; |
| 1150 | osdc->osdmap = NULL; |
| 1151 | init_rwsem(&osdc->map_sem); |
| 1152 | init_completion(&osdc->map_waiters); |
| 1153 | osdc->last_requested_map = 0; |
| 1154 | mutex_init(&osdc->request_mutex); |
| 1155 | osdc->timeout_tid = 0; |
| 1156 | osdc->last_tid = 0; |
| 1157 | osdc->osds = RB_ROOT; |
| 1158 | osdc->requests = RB_ROOT; |
| 1159 | osdc->num_requests = 0; |
| 1160 | INIT_DELAYED_WORK(&osdc->timeout_work, handle_timeout); |
| 1161 | |
Sage Weil | 5f44f14 | 2009-11-18 14:52:18 -0800 | [diff] [blame] | 1162 | err = -ENOMEM; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1163 | osdc->req_mempool = mempool_create_kmalloc_pool(10, |
| 1164 | sizeof(struct ceph_osd_request)); |
| 1165 | if (!osdc->req_mempool) |
Sage Weil | 5f44f14 | 2009-11-18 14:52:18 -0800 | [diff] [blame] | 1166 | goto out; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1167 | |
| 1168 | err = ceph_msgpool_init(&osdc->msgpool_op, 4096, 10, true); |
| 1169 | if (err < 0) |
Sage Weil | 5f44f14 | 2009-11-18 14:52:18 -0800 | [diff] [blame] | 1170 | goto out_mempool; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1171 | err = ceph_msgpool_init(&osdc->msgpool_op_reply, 512, 0, false); |
| 1172 | if (err < 0) |
Sage Weil | 5f44f14 | 2009-11-18 14:52:18 -0800 | [diff] [blame] | 1173 | goto out_msgpool; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1174 | return 0; |
Sage Weil | 5f44f14 | 2009-11-18 14:52:18 -0800 | [diff] [blame] | 1175 | |
| 1176 | out_msgpool: |
| 1177 | ceph_msgpool_destroy(&osdc->msgpool_op); |
| 1178 | out_mempool: |
| 1179 | mempool_destroy(osdc->req_mempool); |
| 1180 | out: |
| 1181 | return err; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1182 | } |
| 1183 | |
| 1184 | void ceph_osdc_stop(struct ceph_osd_client *osdc) |
| 1185 | { |
| 1186 | cancel_delayed_work_sync(&osdc->timeout_work); |
| 1187 | if (osdc->osdmap) { |
| 1188 | ceph_osdmap_destroy(osdc->osdmap); |
| 1189 | osdc->osdmap = NULL; |
| 1190 | } |
| 1191 | mempool_destroy(osdc->req_mempool); |
| 1192 | ceph_msgpool_destroy(&osdc->msgpool_op); |
| 1193 | ceph_msgpool_destroy(&osdc->msgpool_op_reply); |
| 1194 | } |
| 1195 | |
| 1196 | /* |
| 1197 | * Read some contiguous pages. If we cross a stripe boundary, shorten |
| 1198 | * *plen. Return number of bytes read, or error. |
| 1199 | */ |
| 1200 | int ceph_osdc_readpages(struct ceph_osd_client *osdc, |
| 1201 | struct ceph_vino vino, struct ceph_file_layout *layout, |
| 1202 | u64 off, u64 *plen, |
| 1203 | u32 truncate_seq, u64 truncate_size, |
| 1204 | struct page **pages, int num_pages) |
| 1205 | { |
| 1206 | struct ceph_osd_request *req; |
| 1207 | int rc = 0; |
| 1208 | |
| 1209 | dout("readpages on ino %llx.%llx on %llu~%llu\n", vino.ino, |
| 1210 | vino.snap, off, *plen); |
| 1211 | req = ceph_osdc_new_request(osdc, layout, vino, off, plen, |
| 1212 | CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, |
| 1213 | NULL, 0, truncate_seq, truncate_size, NULL, |
| 1214 | false, 1); |
| 1215 | if (IS_ERR(req)) |
| 1216 | return PTR_ERR(req); |
| 1217 | |
| 1218 | /* it may be a short read due to an object boundary */ |
| 1219 | req->r_pages = pages; |
| 1220 | num_pages = calc_pages_for(off, *plen); |
| 1221 | req->r_num_pages = num_pages; |
| 1222 | |
| 1223 | dout("readpages final extent is %llu~%llu (%d pages)\n", |
| 1224 | off, *plen, req->r_num_pages); |
| 1225 | |
| 1226 | rc = ceph_osdc_start_request(osdc, req, false); |
| 1227 | if (!rc) |
| 1228 | rc = ceph_osdc_wait_request(osdc, req); |
| 1229 | |
| 1230 | ceph_osdc_put_request(req); |
| 1231 | dout("readpages result %d\n", rc); |
| 1232 | return rc; |
| 1233 | } |
| 1234 | |
| 1235 | /* |
| 1236 | * do a synchronous write on N pages |
| 1237 | */ |
| 1238 | int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino, |
| 1239 | struct ceph_file_layout *layout, |
| 1240 | struct ceph_snap_context *snapc, |
| 1241 | u64 off, u64 len, |
| 1242 | u32 truncate_seq, u64 truncate_size, |
| 1243 | struct timespec *mtime, |
| 1244 | struct page **pages, int num_pages, |
| 1245 | int flags, int do_sync, bool nofail) |
| 1246 | { |
| 1247 | struct ceph_osd_request *req; |
| 1248 | int rc = 0; |
| 1249 | |
| 1250 | BUG_ON(vino.snap != CEPH_NOSNAP); |
| 1251 | req = ceph_osdc_new_request(osdc, layout, vino, off, &len, |
| 1252 | CEPH_OSD_OP_WRITE, |
| 1253 | flags | CEPH_OSD_FLAG_ONDISK | |
| 1254 | CEPH_OSD_FLAG_WRITE, |
| 1255 | snapc, do_sync, |
| 1256 | truncate_seq, truncate_size, mtime, |
| 1257 | nofail, 1); |
| 1258 | if (IS_ERR(req)) |
| 1259 | return PTR_ERR(req); |
| 1260 | |
| 1261 | /* it may be a short write due to an object boundary */ |
| 1262 | req->r_pages = pages; |
| 1263 | req->r_num_pages = calc_pages_for(off, len); |
| 1264 | dout("writepages %llu~%llu (%d pages)\n", off, len, |
| 1265 | req->r_num_pages); |
| 1266 | |
| 1267 | rc = ceph_osdc_start_request(osdc, req, nofail); |
| 1268 | if (!rc) |
| 1269 | rc = ceph_osdc_wait_request(osdc, req); |
| 1270 | |
| 1271 | ceph_osdc_put_request(req); |
| 1272 | if (rc == 0) |
| 1273 | rc = len; |
| 1274 | dout("writepages result %d\n", rc); |
| 1275 | return rc; |
| 1276 | } |
| 1277 | |
| 1278 | /* |
| 1279 | * handle incoming message |
| 1280 | */ |
| 1281 | static void dispatch(struct ceph_connection *con, struct ceph_msg *msg) |
| 1282 | { |
| 1283 | struct ceph_osd *osd = con->private; |
Julia Lawall | 32c895e | 2009-11-21 16:53:16 +0100 | [diff] [blame] | 1284 | struct ceph_osd_client *osdc; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1285 | int type = le16_to_cpu(msg->hdr.type); |
| 1286 | |
| 1287 | if (!osd) |
| 1288 | return; |
Julia Lawall | 32c895e | 2009-11-21 16:53:16 +0100 | [diff] [blame] | 1289 | osdc = osd->o_osdc; |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1290 | |
| 1291 | switch (type) { |
| 1292 | case CEPH_MSG_OSD_MAP: |
| 1293 | ceph_osdc_handle_map(osdc, msg); |
| 1294 | break; |
| 1295 | case CEPH_MSG_OSD_OPREPLY: |
Sage Weil | 350b1c3 | 2009-12-22 10:45:45 -0800 | [diff] [blame^] | 1296 | handle_reply(osdc, msg, con); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1297 | break; |
| 1298 | |
| 1299 | default: |
| 1300 | pr_err("received unknown message type %d %s\n", type, |
| 1301 | ceph_msg_type_name(type)); |
| 1302 | } |
| 1303 | ceph_msg_put(msg); |
| 1304 | } |
| 1305 | |
| 1306 | static struct ceph_msg *alloc_msg(struct ceph_connection *con, |
| 1307 | struct ceph_msg_header *hdr) |
| 1308 | { |
| 1309 | struct ceph_osd *osd = con->private; |
| 1310 | struct ceph_osd_client *osdc = osd->o_osdc; |
| 1311 | int type = le16_to_cpu(hdr->type); |
Sage Weil | 8f3bc05 | 2009-10-14 17:36:07 -0700 | [diff] [blame] | 1312 | int front = le32_to_cpu(hdr->front_len); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1313 | |
| 1314 | switch (type) { |
| 1315 | case CEPH_MSG_OSD_OPREPLY: |
Sage Weil | 8f3bc05 | 2009-10-14 17:36:07 -0700 | [diff] [blame] | 1316 | return ceph_msgpool_get(&osdc->msgpool_op_reply, front); |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1317 | } |
| 1318 | return ceph_alloc_msg(con, hdr); |
| 1319 | } |
| 1320 | |
| 1321 | /* |
| 1322 | * Wrappers to refcount containing ceph_osd struct |
| 1323 | */ |
| 1324 | static struct ceph_connection *get_osd_con(struct ceph_connection *con) |
| 1325 | { |
| 1326 | struct ceph_osd *osd = con->private; |
| 1327 | if (get_osd(osd)) |
| 1328 | return con; |
| 1329 | return NULL; |
| 1330 | } |
| 1331 | |
| 1332 | static void put_osd_con(struct ceph_connection *con) |
| 1333 | { |
| 1334 | struct ceph_osd *osd = con->private; |
| 1335 | put_osd(osd); |
| 1336 | } |
| 1337 | |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 1338 | /* |
| 1339 | * authentication |
| 1340 | */ |
| 1341 | static int get_authorizer(struct ceph_connection *con, |
Sage Weil | 50b885b | 2009-12-01 14:12:07 -0800 | [diff] [blame] | 1342 | void **buf, int *len, int *proto, |
| 1343 | void **reply_buf, int *reply_len, int force_new) |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 1344 | { |
| 1345 | struct ceph_osd *o = con->private; |
| 1346 | struct ceph_osd_client *osdc = o->o_osdc; |
| 1347 | struct ceph_auth_client *ac = osdc->client->monc.auth; |
| 1348 | int ret = 0; |
| 1349 | |
| 1350 | if (force_new && o->o_authorizer) { |
| 1351 | ac->ops->destroy_authorizer(ac, o->o_authorizer); |
| 1352 | o->o_authorizer = NULL; |
| 1353 | } |
| 1354 | if (o->o_authorizer == NULL) { |
| 1355 | ret = ac->ops->create_authorizer( |
| 1356 | ac, CEPH_ENTITY_TYPE_OSD, |
| 1357 | &o->o_authorizer, |
| 1358 | &o->o_authorizer_buf, |
| 1359 | &o->o_authorizer_buf_len, |
| 1360 | &o->o_authorizer_reply_buf, |
| 1361 | &o->o_authorizer_reply_buf_len); |
| 1362 | if (ret) |
| 1363 | return ret; |
| 1364 | } |
| 1365 | |
| 1366 | *proto = ac->protocol; |
| 1367 | *buf = o->o_authorizer_buf; |
| 1368 | *len = o->o_authorizer_buf_len; |
| 1369 | *reply_buf = o->o_authorizer_reply_buf; |
| 1370 | *reply_len = o->o_authorizer_reply_buf_len; |
| 1371 | return 0; |
| 1372 | } |
| 1373 | |
| 1374 | |
| 1375 | static int verify_authorizer_reply(struct ceph_connection *con, int len) |
| 1376 | { |
| 1377 | struct ceph_osd *o = con->private; |
| 1378 | struct ceph_osd_client *osdc = o->o_osdc; |
| 1379 | struct ceph_auth_client *ac = osdc->client->monc.auth; |
| 1380 | |
| 1381 | return ac->ops->verify_authorizer_reply(ac, o->o_authorizer, len); |
| 1382 | } |
| 1383 | |
| 1384 | |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1385 | const static struct ceph_connection_operations osd_con_ops = { |
| 1386 | .get = get_osd_con, |
| 1387 | .put = put_osd_con, |
| 1388 | .dispatch = dispatch, |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 1389 | .get_authorizer = get_authorizer, |
| 1390 | .verify_authorizer_reply = verify_authorizer_reply, |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1391 | .alloc_msg = alloc_msg, |
Sage Weil | 81b024e | 2009-10-09 10:29:18 -0700 | [diff] [blame] | 1392 | .fault = osd_reset, |
Sage Weil | f24e998 | 2009-10-06 11:31:10 -0700 | [diff] [blame] | 1393 | .alloc_middle = ceph_alloc_middle, |
| 1394 | .prepare_pages = prepare_pages, |
| 1395 | }; |