Lines Matching refs:req
49 static void link_request(struct ceph_osd *osd, struct ceph_osd_request *req);
50 static void unlink_request(struct ceph_osd *osd, struct ceph_osd_request *req);
475 static void request_release_checks(struct ceph_osd_request *req) in request_release_checks() argument
477 WARN_ON(!RB_EMPTY_NODE(&req->r_node)); in request_release_checks()
478 WARN_ON(!RB_EMPTY_NODE(&req->r_mc_node)); in request_release_checks()
479 WARN_ON(!list_empty(&req->r_private_item)); in request_release_checks()
480 WARN_ON(req->r_osd); in request_release_checks()
485 struct ceph_osd_request *req = container_of(kref, in ceph_osdc_release_request() local
489 dout("%s %p (r_request %p r_reply %p)\n", __func__, req, in ceph_osdc_release_request()
490 req->r_request, req->r_reply); in ceph_osdc_release_request()
491 request_release_checks(req); in ceph_osdc_release_request()
493 if (req->r_request) in ceph_osdc_release_request()
494 ceph_msg_put(req->r_request); in ceph_osdc_release_request()
495 if (req->r_reply) in ceph_osdc_release_request()
496 ceph_msg_put(req->r_reply); in ceph_osdc_release_request()
498 for (which = 0; which < req->r_num_ops; which++) in ceph_osdc_release_request()
499 osd_req_op_data_release(req, which); in ceph_osdc_release_request()
501 target_destroy(&req->r_t); in ceph_osdc_release_request()
502 ceph_put_snap_context(req->r_snapc); in ceph_osdc_release_request()
504 if (req->r_mempool) in ceph_osdc_release_request()
505 mempool_free(req, req->r_osdc->req_mempool); in ceph_osdc_release_request()
506 else if (req->r_num_ops <= CEPH_OSD_SLAB_OPS) in ceph_osdc_release_request()
507 kmem_cache_free(ceph_osd_request_cache, req); in ceph_osdc_release_request()
509 kfree(req); in ceph_osdc_release_request()
512 void ceph_osdc_get_request(struct ceph_osd_request *req) in ceph_osdc_get_request() argument
514 dout("%s %p (was %d)\n", __func__, req, in ceph_osdc_get_request()
515 kref_read(&req->r_kref)); in ceph_osdc_get_request()
516 kref_get(&req->r_kref); in ceph_osdc_get_request()
520 void ceph_osdc_put_request(struct ceph_osd_request *req) in ceph_osdc_put_request() argument
522 if (req) { in ceph_osdc_put_request()
523 dout("%s %p (was %d)\n", __func__, req, in ceph_osdc_put_request()
524 kref_read(&req->r_kref)); in ceph_osdc_put_request()
525 kref_put(&req->r_kref, ceph_osdc_release_request); in ceph_osdc_put_request()
530 static void request_init(struct ceph_osd_request *req) in request_init() argument
533 memset(req, 0, sizeof(*req)); in request_init()
535 kref_init(&req->r_kref); in request_init()
536 init_completion(&req->r_completion); in request_init()
537 RB_CLEAR_NODE(&req->r_node); in request_init()
538 RB_CLEAR_NODE(&req->r_mc_node); in request_init()
539 INIT_LIST_HEAD(&req->r_private_item); in request_init()
541 target_init(&req->r_t); in request_init()
550 struct ceph_osd_request *req; in ceph_osdc_alloc_request() local
554 req = mempool_alloc(osdc->req_mempool, gfp_flags); in ceph_osdc_alloc_request()
556 req = kmem_cache_alloc(ceph_osd_request_cache, gfp_flags); in ceph_osdc_alloc_request()
559 req = kmalloc(struct_size(req, r_ops, num_ops), gfp_flags); in ceph_osdc_alloc_request()
561 if (unlikely(!req)) in ceph_osdc_alloc_request()
564 request_init(req); in ceph_osdc_alloc_request()
565 req->r_osdc = osdc; in ceph_osdc_alloc_request()
566 req->r_mempool = use_mempool; in ceph_osdc_alloc_request()
567 req->r_num_ops = num_ops; in ceph_osdc_alloc_request()
568 req->r_snapid = CEPH_NOSNAP; in ceph_osdc_alloc_request()
569 req->r_snapc = ceph_get_snap_context(snapc); in ceph_osdc_alloc_request()
571 dout("%s req %p\n", __func__, req); in ceph_osdc_alloc_request()
572 return req; in ceph_osdc_alloc_request()
581 static int __ceph_osdc_alloc_messages(struct ceph_osd_request *req, gfp_t gfp, in __ceph_osdc_alloc_messages() argument
585 struct ceph_osd_client *osdc = req->r_osdc; in __ceph_osdc_alloc_messages()
589 WARN_ON(req->r_request || req->r_reply); in __ceph_osdc_alloc_messages()
590 WARN_ON(ceph_oid_empty(&req->r_base_oid)); in __ceph_osdc_alloc_messages()
591 WARN_ON(ceph_oloc_empty(&req->r_base_oloc)); in __ceph_osdc_alloc_messages()
602 ceph_oloc_encoding_size(&req->r_base_oloc); /* oloc */ in __ceph_osdc_alloc_messages()
603 msg_size += 4 + req->r_base_oid.name_len; /* oid */ in __ceph_osdc_alloc_messages()
604 msg_size += 2 + req->r_num_ops * sizeof(struct ceph_osd_op); in __ceph_osdc_alloc_messages()
607 msg_size += 4 + 8 * (req->r_snapc ? req->r_snapc->num_snaps : 0); in __ceph_osdc_alloc_messages()
610 if (req->r_mempool) in __ceph_osdc_alloc_messages()
620 req->r_request = msg; in __ceph_osdc_alloc_messages()
624 msg_size += req->r_base_oid.name_len; in __ceph_osdc_alloc_messages()
625 msg_size += req->r_num_ops * sizeof(struct ceph_osd_op); in __ceph_osdc_alloc_messages()
627 if (req->r_mempool) in __ceph_osdc_alloc_messages()
636 req->r_reply = msg; in __ceph_osdc_alloc_messages()
652 static void get_num_data_items(struct ceph_osd_request *req, in get_num_data_items() argument
661 for (op = req->r_ops; op != &req->r_ops[req->r_num_ops]; op++) { in get_num_data_items()
702 int ceph_osdc_alloc_messages(struct ceph_osd_request *req, gfp_t gfp) in ceph_osdc_alloc_messages() argument
706 get_num_data_items(req, &num_request_data_items, &num_reply_data_items); in ceph_osdc_alloc_messages()
707 return __ceph_osdc_alloc_messages(req, gfp, num_request_data_items, in ceph_osdc_alloc_messages()
888 static void osd_req_op_watch_init(struct ceph_osd_request *req, int which, in osd_req_op_watch_init() argument
893 op = osd_req_op_init(req, which, CEPH_OSD_OP_WATCH, 0); in osd_req_op_watch_init()
903 static void osd_req_op_notify_init(struct ceph_osd_request *req, int which, in osd_req_op_notify_init() argument
908 op = osd_req_op_init(req, which, CEPH_OSD_OP_NOTIFY, 0); in osd_req_op_notify_init()
1066 struct ceph_osd_request *req; in ceph_osdc_new_request() local
1077 req = ceph_osdc_alloc_request(osdc, snapc, num_ops, use_mempool, in ceph_osdc_new_request()
1079 if (!req) { in ceph_osdc_new_request()
1090 osd_req_op_init(req, which, opcode, 0); in ceph_osdc_new_request()
1103 osd_req_op_extent_init(req, which, opcode, objoff, objlen, in ceph_osdc_new_request()
1107 req->r_base_oloc.pool = layout->pool_id; in ceph_osdc_new_request()
1108 req->r_base_oloc.pool_ns = ceph_try_get_string(layout->pool_ns); in ceph_osdc_new_request()
1109 ceph_oid_printf(&req->r_base_oid, "%llx.%08llx", vino.ino, objnum); in ceph_osdc_new_request()
1110 req->r_flags = flags | osdc->client->options->read_from_replica; in ceph_osdc_new_request()
1112 req->r_snapid = vino.snap; in ceph_osdc_new_request()
1114 req->r_data_offset = off; in ceph_osdc_new_request()
1135 r = __ceph_osdc_alloc_messages(req, GFP_NOFS, num_req_ops, in ceph_osdc_new_request()
1138 r = ceph_osdc_alloc_messages(req, GFP_NOFS); in ceph_osdc_new_request()
1143 return req; in ceph_osdc_new_request()
1146 ceph_osdc_put_request(req); in ceph_osdc_new_request()
1175 int (*fn)(struct ceph_osd_request *req, void *arg), in DEFINE_RB_FUNCS()
1184 struct ceph_osd_request *req = in DEFINE_RB_FUNCS() local
1188 if (fn(req, arg)) in DEFINE_RB_FUNCS()
1194 struct ceph_osd_request *req = in DEFINE_RB_FUNCS() local
1198 if (fn(req, arg)) in DEFINE_RB_FUNCS()
1352 struct ceph_osd_request *req = in close_osd() local
1357 dout(" reassigning req %p tid %llu\n", req, req->r_tid); in close_osd()
1358 unlink_request(osd, req); in close_osd()
1359 link_request(&osdc->homeless_osd, req); in close_osd()
1403 struct ceph_osd_request *req = in reopen_osd() local
1405 req->r_stamp = jiffies; in reopen_osd()
1451 static void link_request(struct ceph_osd *osd, struct ceph_osd_request *req) in link_request() argument
1454 WARN_ON(!req->r_tid || req->r_osd); in link_request()
1456 req, req->r_tid); in link_request()
1465 insert_request(&osd->o_requests, req); in link_request()
1467 req->r_osd = osd; in link_request()
1470 static void unlink_request(struct ceph_osd *osd, struct ceph_osd_request *req) in unlink_request() argument
1473 WARN_ON(req->r_osd != osd); in unlink_request()
1475 req, req->r_tid); in unlink_request()
1477 req->r_osd = NULL; in unlink_request()
1479 erase_request(&osd->o_requests, req); in unlink_request()
2012 static bool should_plug_request(struct ceph_osd_request *req) in should_plug_request() argument
2014 struct ceph_osd *osd = req->r_osd; in should_plug_request()
2019 spg = lookup_spg_mapping(&osd->o_backoff_mappings, &req->r_t.spgid); in should_plug_request()
2023 hoid_fill_from_target(&hoid, &req->r_t); in should_plug_request()
2029 __func__, req, req->r_tid, osd->o_osd, backoff->spgid.pgid.pool, in should_plug_request()
2037 static void setup_request_data(struct ceph_osd_request *req) in setup_request_data() argument
2039 struct ceph_msg *request_msg = req->r_request; in setup_request_data()
2040 struct ceph_msg *reply_msg = req->r_reply; in setup_request_data()
2043 if (req->r_request->num_data_items || req->r_reply->num_data_items) in setup_request_data()
2047 for (op = req->r_ops; op != &req->r_ops[req->r_num_ops]; op++) { in setup_request_data()
2140 static void encode_request_partial(struct ceph_osd_request *req, in encode_request_partial() argument
2148 if (req->r_flags & CEPH_OSD_FLAG_WRITE) { in encode_request_partial()
2150 WARN_ON(req->r_snapid != CEPH_NOSNAP); in encode_request_partial()
2152 WARN_ON(req->r_mtime.tv_sec || req->r_mtime.tv_nsec || in encode_request_partial()
2153 req->r_data_offset || req->r_snapc); in encode_request_partial()
2156 setup_request_data(req); in encode_request_partial()
2158 encode_spgid(&p, &req->r_t.spgid); /* actual spg */ in encode_request_partial()
2159 ceph_encode_32(&p, req->r_t.pgid.seed); /* raw hash */ in encode_request_partial()
2160 ceph_encode_32(&p, req->r_osdc->osdmap->epoch); in encode_request_partial()
2161 ceph_encode_32(&p, req->r_flags); in encode_request_partial()
2173 ceph_encode_timespec64(p, &req->r_mtime); in encode_request_partial()
2176 encode_oloc(&p, end, &req->r_t.target_oloc); in encode_request_partial()
2177 ceph_encode_string(&p, end, req->r_t.target_oid.name, in encode_request_partial()
2178 req->r_t.target_oid.name_len); in encode_request_partial()
2181 ceph_encode_16(&p, req->r_num_ops); in encode_request_partial()
2182 for (i = 0; i < req->r_num_ops; i++) { in encode_request_partial()
2183 data_len += osd_req_encode_op(p, &req->r_ops[i]); in encode_request_partial()
2187 ceph_encode_64(&p, req->r_snapid); /* snapid */ in encode_request_partial()
2188 if (req->r_snapc) { in encode_request_partial()
2189 ceph_encode_64(&p, req->r_snapc->seq); in encode_request_partial()
2190 ceph_encode_32(&p, req->r_snapc->num_snaps); in encode_request_partial()
2191 for (i = 0; i < req->r_snapc->num_snaps; i++) in encode_request_partial()
2192 ceph_encode_64(&p, req->r_snapc->snaps[i]); in encode_request_partial()
2198 ceph_encode_32(&p, req->r_attempts); /* retry_attempt */ in encode_request_partial()
2211 msg->hdr.data_off = cpu_to_le16(req->r_data_offset); in encode_request_partial()
2213 dout("%s req %p msg %p oid %s oid_len %d\n", __func__, req, msg, in encode_request_partial()
2214 req->r_t.target_oid.name, req->r_t.target_oid.name_len); in encode_request_partial()
2312 static void send_request(struct ceph_osd_request *req) in send_request() argument
2314 struct ceph_osd *osd = req->r_osd; in send_request()
2317 WARN_ON(osd->o_osd != req->r_t.osd); in send_request()
2320 if (should_plug_request(req)) in send_request()
2327 if (req->r_sent) in send_request()
2328 ceph_msg_revoke(req->r_request); in send_request()
2330 req->r_flags |= CEPH_OSD_FLAG_KNOWN_REDIR; in send_request()
2331 if (req->r_attempts) in send_request()
2332 req->r_flags |= CEPH_OSD_FLAG_RETRY; in send_request()
2334 WARN_ON(req->r_flags & CEPH_OSD_FLAG_RETRY); in send_request()
2336 encode_request_partial(req, req->r_request); in send_request()
2339 __func__, req, req->r_tid, req->r_t.pgid.pool, req->r_t.pgid.seed, in send_request()
2340 req->r_t.spgid.pgid.pool, req->r_t.spgid.pgid.seed, in send_request()
2341 req->r_t.spgid.shard, osd->o_osd, req->r_t.epoch, req->r_flags, in send_request()
2342 req->r_attempts); in send_request()
2344 req->r_t.paused = false; in send_request()
2345 req->r_stamp = jiffies; in send_request()
2346 req->r_attempts++; in send_request()
2348 req->r_sent = osd->o_incarnation; in send_request()
2349 req->r_request->hdr.tid = cpu_to_le64(req->r_tid); in send_request()
2350 ceph_con_send(&osd->o_con, ceph_msg_get(req->r_request)); in send_request()
2374 static void complete_request(struct ceph_osd_request *req, int err);
2375 static void send_map_check(struct ceph_osd_request *req);
2377 static void __submit_request(struct ceph_osd_request *req, bool wrlocked) in __submit_request() argument
2379 struct ceph_osd_client *osdc = req->r_osdc; in __submit_request()
2386 WARN_ON(req->r_tid); in __submit_request()
2387 dout("%s req %p wrlocked %d\n", __func__, req, wrlocked); in __submit_request()
2390 ct_res = calc_target(osdc, &req->r_t, false); in __submit_request()
2394 osd = lookup_create_osd(osdc, req->r_t.osd, wrlocked); in __submit_request()
2401 dout("req %p abort_err %d\n", req, osdc->abort_err); in __submit_request()
2404 dout("req %p epoch %u barrier %u\n", req, osdc->osdmap->epoch, in __submit_request()
2406 req->r_t.paused = true; in __submit_request()
2408 } else if ((req->r_flags & CEPH_OSD_FLAG_WRITE) && in __submit_request()
2410 dout("req %p pausewr\n", req); in __submit_request()
2411 req->r_t.paused = true; in __submit_request()
2413 } else if ((req->r_flags & CEPH_OSD_FLAG_READ) && in __submit_request()
2415 dout("req %p pauserd\n", req); in __submit_request()
2416 req->r_t.paused = true; in __submit_request()
2418 } else if ((req->r_flags & CEPH_OSD_FLAG_WRITE) && in __submit_request()
2419 !(req->r_flags & (CEPH_OSD_FLAG_FULL_TRY | in __submit_request()
2422 pool_full(osdc, req->r_t.base_oloc.pool))) { in __submit_request()
2423 dout("req %p full/pool_full\n", req); in __submit_request()
2431 req->r_t.base_oloc.pool); in __submit_request()
2432 req->r_t.paused = true; in __submit_request()
2447 req->r_tid = atomic64_inc_return(&osdc->last_tid); in __submit_request()
2448 link_request(osd, req); in __submit_request()
2450 send_request(req); in __submit_request()
2452 complete_request(req, err); in __submit_request()
2456 send_map_check(req); in __submit_request()
2470 static void account_request(struct ceph_osd_request *req) in account_request() argument
2472 WARN_ON(req->r_flags & (CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK)); in account_request()
2473 WARN_ON(!(req->r_flags & (CEPH_OSD_FLAG_READ | CEPH_OSD_FLAG_WRITE))); in account_request()
2475 req->r_flags |= CEPH_OSD_FLAG_ONDISK; in account_request()
2476 atomic_inc(&req->r_osdc->num_requests); in account_request()
2478 req->r_start_stamp = jiffies; in account_request()
2479 req->r_start_latency = ktime_get(); in account_request()
2482 static void submit_request(struct ceph_osd_request *req, bool wrlocked) in submit_request() argument
2484 ceph_osdc_get_request(req); in submit_request()
2485 account_request(req); in submit_request()
2486 __submit_request(req, wrlocked); in submit_request()
2489 static void finish_request(struct ceph_osd_request *req) in finish_request() argument
2491 struct ceph_osd_client *osdc = req->r_osdc; in finish_request()
2493 WARN_ON(lookup_request_mc(&osdc->map_checks, req->r_tid)); in finish_request()
2494 dout("%s req %p tid %llu\n", __func__, req, req->r_tid); in finish_request()
2496 req->r_end_latency = ktime_get(); in finish_request()
2498 if (req->r_osd) { in finish_request()
2499 ceph_init_sparse_read(&req->r_osd->o_sparse_read); in finish_request()
2500 unlink_request(req->r_osd, req); in finish_request()
2510 ceph_msg_revoke(req->r_request); in finish_request()
2511 ceph_msg_revoke_incoming(req->r_reply); in finish_request()
2514 static void __complete_request(struct ceph_osd_request *req) in __complete_request() argument
2516 dout("%s req %p tid %llu cb %ps result %d\n", __func__, req, in __complete_request()
2517 req->r_tid, req->r_callback, req->r_result); in __complete_request()
2519 if (req->r_callback) in __complete_request()
2520 req->r_callback(req); in __complete_request()
2521 complete_all(&req->r_completion); in __complete_request()
2522 ceph_osdc_put_request(req); in __complete_request()
2527 struct ceph_osd_request *req = in complete_request_workfn() local
2530 __complete_request(req); in complete_request_workfn()
2536 static void complete_request(struct ceph_osd_request *req, int err) in complete_request() argument
2538 dout("%s req %p tid %llu err %d\n", __func__, req, req->r_tid, err); in complete_request()
2540 req->r_result = err; in complete_request()
2541 finish_request(req); in complete_request()
2543 INIT_WORK(&req->r_complete_work, complete_request_workfn); in complete_request()
2544 queue_work(req->r_osdc->completion_wq, &req->r_complete_work); in complete_request()
2547 static void cancel_map_check(struct ceph_osd_request *req) in cancel_map_check() argument
2549 struct ceph_osd_client *osdc = req->r_osdc; in cancel_map_check()
2554 lookup_req = lookup_request_mc(&osdc->map_checks, req->r_tid); in cancel_map_check()
2558 WARN_ON(lookup_req != req); in cancel_map_check()
2559 erase_request_mc(&osdc->map_checks, req); in cancel_map_check()
2560 ceph_osdc_put_request(req); in cancel_map_check()
2563 static void cancel_request(struct ceph_osd_request *req) in cancel_request() argument
2565 dout("%s req %p tid %llu\n", __func__, req, req->r_tid); in cancel_request()
2567 cancel_map_check(req); in cancel_request()
2568 finish_request(req); in cancel_request()
2569 complete_all(&req->r_completion); in cancel_request()
2570 ceph_osdc_put_request(req); in cancel_request()
2573 static void abort_request(struct ceph_osd_request *req, int err) in abort_request() argument
2575 dout("%s req %p tid %llu err %d\n", __func__, req, req->r_tid, err); in abort_request()
2577 cancel_map_check(req); in abort_request()
2578 complete_request(req, err); in abort_request()
2581 static int abort_fn(struct ceph_osd_request *req, void *arg) in abort_fn() argument
2585 abort_request(req, err); in abort_fn()
2643 static int abort_on_full_fn(struct ceph_osd_request *req, void *arg) in abort_on_full_fn() argument
2645 struct ceph_osd_client *osdc = req->r_osdc; in abort_on_full_fn()
2648 if ((req->r_flags & CEPH_OSD_FLAG_WRITE) && in abort_on_full_fn()
2650 pool_full(osdc, req->r_t.base_oloc.pool))) { in abort_on_full_fn()
2655 abort_request(req, -ENOSPC); in abort_on_full_fn()
2676 static void check_pool_dne(struct ceph_osd_request *req) in check_pool_dne() argument
2678 struct ceph_osd_client *osdc = req->r_osdc; in check_pool_dne()
2684 if (req->r_attempts) { in check_pool_dne()
2690 req->r_map_dne_bound = map->epoch; in check_pool_dne()
2691 dout("%s req %p tid %llu pool disappeared\n", __func__, req, in check_pool_dne()
2692 req->r_tid); in check_pool_dne()
2695 req, req->r_tid, req->r_map_dne_bound, map->epoch); in check_pool_dne()
2698 if (req->r_map_dne_bound) { in check_pool_dne()
2699 if (map->epoch >= req->r_map_dne_bound) { in check_pool_dne()
2702 req->r_tid); in check_pool_dne()
2703 complete_request(req, -ENOENT); in check_pool_dne()
2706 send_map_check(req); in check_pool_dne()
2713 struct ceph_osd_request *req; in map_check_cb() local
2719 req = lookup_request_mc(&osdc->map_checks, tid); in map_check_cb()
2720 if (!req) { in map_check_cb()
2726 req, req->r_tid, req->r_map_dne_bound, greq->u.newest); in map_check_cb()
2727 if (!req->r_map_dne_bound) in map_check_cb()
2728 req->r_map_dne_bound = greq->u.newest; in map_check_cb()
2729 erase_request_mc(&osdc->map_checks, req); in map_check_cb()
2730 check_pool_dne(req); in map_check_cb()
2732 ceph_osdc_put_request(req); in map_check_cb()
2737 static void send_map_check(struct ceph_osd_request *req) in send_map_check() argument
2739 struct ceph_osd_client *osdc = req->r_osdc; in send_map_check()
2745 lookup_req = lookup_request_mc(&osdc->map_checks, req->r_tid); in send_map_check()
2747 WARN_ON(lookup_req != req); in send_map_check()
2751 ceph_osdc_get_request(req); in send_map_check()
2752 insert_request_mc(&osdc->map_checks, req); in send_map_check()
2754 map_check_cb, req->r_tid); in send_map_check()
2911 static void cancel_linger_request(struct ceph_osd_request *req) in cancel_linger_request() argument
2913 struct ceph_osd_linger_request *lreq = req->r_priv; in cancel_linger_request()
2915 WARN_ON(!req->r_linger); in cancel_linger_request()
2916 cancel_request(req); in cancel_linger_request()
3045 static void linger_commit_cb(struct ceph_osd_request *req) in linger_commit_cb() argument
3047 struct ceph_osd_linger_request *lreq = req->r_priv; in linger_commit_cb()
3050 if (req != lreq->reg_req) { in linger_commit_cb()
3052 __func__, lreq, lreq->linger_id, req, lreq->reg_req); in linger_commit_cb()
3057 lreq->linger_id, req->r_result); in linger_commit_cb()
3058 linger_reg_commit_complete(lreq, req->r_result); in linger_commit_cb()
3063 osd_req_op_data(req, 0, notify, response_data); in linger_commit_cb()
3066 WARN_ON(req->r_ops[0].op != CEPH_OSD_OP_NOTIFY || in linger_commit_cb()
3070 if (req->r_ops[0].outdata_len >= sizeof(u64)) { in linger_commit_cb()
3097 static void linger_reconnect_cb(struct ceph_osd_request *req) in linger_reconnect_cb() argument
3099 struct ceph_osd_linger_request *lreq = req->r_priv; in linger_reconnect_cb()
3102 if (req != lreq->reg_req) { in linger_reconnect_cb()
3104 __func__, lreq, lreq->linger_id, req, lreq->reg_req); in linger_reconnect_cb()
3109 lreq, lreq->linger_id, req->r_result, lreq->last_error); in linger_reconnect_cb()
3110 if (req->r_result < 0) { in linger_reconnect_cb()
3112 lreq->last_error = normalize_watch_error(req->r_result); in linger_reconnect_cb()
3125 struct ceph_osd_request *req; in send_linger() local
3138 req = ceph_osdc_alloc_request(osdc, NULL, 1, true, GFP_NOIO); in send_linger()
3139 BUG_ON(!req); in send_linger()
3141 target_copy(&req->r_t, &lreq->t); in send_linger()
3142 req->r_mtime = lreq->mtime; in send_linger()
3145 osd_req_op_watch_init(req, 0, CEPH_OSD_WATCH_OP_RECONNECT, in send_linger()
3148 req->r_ops[0].watch.gen); in send_linger()
3149 req->r_callback = linger_reconnect_cb; in send_linger()
3152 osd_req_op_watch_init(req, 0, CEPH_OSD_WATCH_OP_WATCH, in send_linger()
3158 osd_req_op_notify_init(req, 0, lreq->linger_id, in send_linger()
3161 osd_req_op_data(req, 0, notify, response_data), in send_linger()
3165 req->r_callback = linger_commit_cb; in send_linger()
3168 ret = ceph_osdc_alloc_messages(req, GFP_NOIO); in send_linger()
3171 req->r_priv = linger_get(lreq); in send_linger()
3172 req->r_linger = true; in send_linger()
3173 lreq->reg_req = req; in send_linger()
3176 submit_request(req, true); in send_linger()
3179 static void linger_ping_cb(struct ceph_osd_request *req) in linger_ping_cb() argument
3181 struct ceph_osd_linger_request *lreq = req->r_priv; in linger_ping_cb()
3184 if (req != lreq->ping_req) { in linger_ping_cb()
3186 __func__, lreq, lreq->linger_id, req, lreq->ping_req); in linger_ping_cb()
3191 __func__, lreq, lreq->linger_id, req->r_result, lreq->ping_sent, in linger_ping_cb()
3193 if (lreq->register_gen == req->r_ops[0].watch.gen) { in linger_ping_cb()
3194 if (!req->r_result) { in linger_ping_cb()
3197 lreq->last_error = normalize_watch_error(req->r_result); in linger_ping_cb()
3202 lreq->register_gen, req->r_ops[0].watch.gen); in linger_ping_cb()
3213 struct ceph_osd_request *req; in send_linger_ping() local
3232 req = ceph_osdc_alloc_request(osdc, NULL, 1, true, GFP_NOIO); in send_linger_ping()
3233 BUG_ON(!req); in send_linger_ping()
3235 target_copy(&req->r_t, &lreq->t); in send_linger_ping()
3236 osd_req_op_watch_init(req, 0, CEPH_OSD_WATCH_OP_PING, lreq->linger_id, in send_linger_ping()
3238 req->r_callback = linger_ping_cb; in send_linger_ping()
3240 ret = ceph_osdc_alloc_messages(req, GFP_NOIO); in send_linger_ping()
3243 req->r_priv = linger_get(lreq); in send_linger_ping()
3244 req->r_linger = true; in send_linger_ping()
3245 lreq->ping_req = req; in send_linger_ping()
3247 ceph_osdc_get_request(req); in send_linger_ping()
3248 account_request(req); in send_linger_ping()
3249 req->r_tid = atomic64_inc_return(&osdc->last_tid); in send_linger_ping()
3250 link_request(lreq->osd, req); in send_linger_ping()
3251 send_request(req); in send_linger_ping()
3448 struct ceph_osd_request *req = in handle_timeout() local
3453 if (time_before(req->r_stamp, cutoff)) { in handle_timeout()
3455 req, req->r_tid, osd->o_osd); in handle_timeout()
3459 time_before(req->r_start_stamp, expiry_cutoff)) { in handle_timeout()
3461 req->r_tid, osd->o_osd); in handle_timeout()
3462 abort_request(req, -ETIMEDOUT); in handle_timeout()
3485 struct ceph_osd_request *req = in handle_timeout() local
3490 if (time_before(req->r_start_stamp, expiry_cutoff)) { in handle_timeout()
3492 req->r_tid, osdc->homeless_osd.o_osd); in handle_timeout()
3493 abort_request(req, -ETIMEDOUT); in handle_timeout()
3748 struct ceph_osd_request *req; in handle_reply() local
3765 req = lookup_request(&osd->o_requests, tid); in handle_reply()
3766 if (!req) { in handle_reply()
3771 m.redirect.oloc.pool_ns = req->r_t.target_oloc.pool_ns; in handle_reply()
3776 req->r_tid, ret); in handle_reply()
3781 __func__, req, req->r_tid, m.flags, m.pgid.pool, m.pgid.seed, in handle_reply()
3786 if (m.retry_attempt != req->r_attempts - 1) { in handle_reply()
3788 req, req->r_tid, m.retry_attempt, in handle_reply()
3789 req->r_attempts - 1); in handle_reply()
3797 dout("req %p tid %llu redirect pool %lld\n", req, req->r_tid, in handle_reply()
3799 unlink_request(osd, req); in handle_reply()
3806 req->r_t.target_oloc.pool = m.redirect.oloc.pool; in handle_reply()
3807 req->r_flags |= CEPH_OSD_FLAG_REDIRECTED | in handle_reply()
3810 req->r_tid = 0; in handle_reply()
3811 __submit_request(req, false); in handle_reply()
3816 dout("req %p tid %llu EAGAIN\n", req, req->r_tid); in handle_reply()
3817 unlink_request(osd, req); in handle_reply()
3825 req->r_t.pgid.pool = 0; in handle_reply()
3826 req->r_t.pgid.seed = 0; in handle_reply()
3827 WARN_ON(!req->r_t.used_replica); in handle_reply()
3828 req->r_flags &= ~(CEPH_OSD_FLAG_BALANCE_READS | in handle_reply()
3830 req->r_tid = 0; in handle_reply()
3831 __submit_request(req, false); in handle_reply()
3835 if (m.num_ops != req->r_num_ops) { in handle_reply()
3837 req->r_num_ops, req->r_tid); in handle_reply()
3840 for (i = 0; i < req->r_num_ops; i++) { in handle_reply()
3841 dout(" req %p tid %llu op %d rval %d len %u\n", req, in handle_reply()
3842 req->r_tid, i, m.rval[i], m.outdata_len[i]); in handle_reply()
3843 req->r_ops[i].rval = m.rval[i]; in handle_reply()
3844 req->r_ops[i].outdata_len = m.outdata_len[i]; in handle_reply()
3849 le32_to_cpu(msg->hdr.data_len), req->r_tid); in handle_reply()
3853 req, req->r_tid, m.result, data_len); in handle_reply()
3860 req->r_version = m.user_version; in handle_reply()
3861 req->r_result = m.result ?: data_len; in handle_reply()
3862 finish_request(req); in handle_reply()
3866 __complete_request(req); in handle_reply()
3870 complete_request(req, -EIO); in handle_reply()
3971 struct ceph_osd_request *req = in scan_requests() local
3977 dout("%s req %p tid %llu\n", __func__, req, req->r_tid); in scan_requests()
3978 ct_res = calc_target(osdc, &req->r_t, false); in scan_requests()
3983 pool_cleared_full(osdc, req->r_t.base_oloc.pool)); in scan_requests()
3985 (!(req->r_flags & CEPH_OSD_FLAG_WRITE) || in scan_requests()
3991 cancel_map_check(req); in scan_requests()
3992 unlink_request(osd, req); in scan_requests()
3993 insert_request(need_resend, req); in scan_requests()
3996 check_pool_dne(req); in scan_requests()
4083 struct ceph_osd_request *req = in kick_requests() local
4088 if (req->r_t.epoch < osdc->osdmap->epoch) { in kick_requests()
4089 ct_res = calc_target(osdc, &req->r_t, false); in kick_requests()
4091 erase_request(need_resend, req); in kick_requests()
4092 check_pool_dne(req); in kick_requests()
4098 struct ceph_osd_request *req = in kick_requests() local
4103 erase_request(need_resend, req); /* before link_request() */ in kick_requests()
4105 osd = lookup_create_osd(osdc, req->r_t.osd, true); in kick_requests()
4106 link_request(osd, req); in kick_requests()
4107 if (!req->r_linger) { in kick_requests()
4108 if (!osd_homeless(osd) && !req->r_t.paused) in kick_requests()
4109 send_request(req); in kick_requests()
4111 cancel_linger_request(req); in kick_requests()
4250 struct ceph_osd_request *req = in kick_osd_requests() local
4255 if (!req->r_linger) { in kick_osd_requests()
4256 if (!req->r_t.paused) in kick_osd_requests()
4257 send_request(req); in kick_osd_requests()
4259 cancel_linger_request(req); in kick_osd_requests()
4489 struct ceph_osd_request *req = in handle_backoff_unblock() local
4492 if (!ceph_spg_compare(&req->r_t.spgid, &m->spgid)) { in handle_backoff_unblock()
4497 if (target_contained_by(&req->r_t, m->begin, m->end)) { in handle_backoff_unblock()
4502 send_request(req); in handle_backoff_unblock()
4652 struct ceph_osd_request *req) in ceph_osdc_start_request() argument
4655 submit_request(req, false); in ceph_osdc_start_request()
4669 void ceph_osdc_cancel_request(struct ceph_osd_request *req) in ceph_osdc_cancel_request() argument
4671 struct ceph_osd_client *osdc = req->r_osdc; in ceph_osdc_cancel_request()
4674 if (req->r_osd) in ceph_osdc_cancel_request()
4675 cancel_request(req); in ceph_osdc_cancel_request()
4683 static int wait_request_timeout(struct ceph_osd_request *req, in wait_request_timeout() argument
4688 dout("%s req %p tid %llu\n", __func__, req, req->r_tid); in wait_request_timeout()
4689 left = wait_for_completion_killable_timeout(&req->r_completion, in wait_request_timeout()
4693 ceph_osdc_cancel_request(req); in wait_request_timeout()
4695 left = req->r_result; /* completed */ in wait_request_timeout()
4705 struct ceph_osd_request *req) in ceph_osdc_wait_request() argument
4707 return wait_request_timeout(req, 0); in ceph_osdc_wait_request()
4726 struct ceph_osd_request *req = in ceph_osdc_sync() local
4729 if (req->r_tid > last_tid) in ceph_osdc_sync()
4732 if (!(req->r_flags & CEPH_OSD_FLAG_WRITE)) in ceph_osdc_sync()
4735 ceph_osdc_get_request(req); in ceph_osdc_sync()
4739 __func__, req, req->r_tid, last_tid); in ceph_osdc_sync()
4740 wait_for_completion(&req->r_completion); in ceph_osdc_sync()
4741 ceph_osdc_put_request(req); in ceph_osdc_sync()
4808 struct ceph_osd_request *req; in ceph_osdc_unwatch() local
4811 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_unwatch()
4812 if (!req) in ceph_osdc_unwatch()
4815 ceph_oid_copy(&req->r_base_oid, &lreq->t.base_oid); in ceph_osdc_unwatch()
4816 ceph_oloc_copy(&req->r_base_oloc, &lreq->t.base_oloc); in ceph_osdc_unwatch()
4817 req->r_flags = CEPH_OSD_FLAG_WRITE; in ceph_osdc_unwatch()
4818 ktime_get_real_ts64(&req->r_mtime); in ceph_osdc_unwatch()
4819 osd_req_op_watch_init(req, 0, CEPH_OSD_WATCH_OP_UNWATCH, in ceph_osdc_unwatch()
4822 ret = ceph_osdc_alloc_messages(req, GFP_NOIO); in ceph_osdc_unwatch()
4826 ceph_osdc_start_request(osdc, req); in ceph_osdc_unwatch()
4829 ret = wait_request_timeout(req, opts->mount_timeout); in ceph_osdc_unwatch()
4832 ceph_osdc_put_request(req); in ceph_osdc_unwatch()
4837 static int osd_req_op_notify_ack_init(struct ceph_osd_request *req, int which, in osd_req_op_notify_ack_init() argument
4845 op = osd_req_op_init(req, which, CEPH_OSD_OP_NOTIFY_ACK, 0); in osd_req_op_notify_ack_init()
4877 struct ceph_osd_request *req; in ceph_osdc_notify_ack() local
4880 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_notify_ack()
4881 if (!req) in ceph_osdc_notify_ack()
4884 ceph_oid_copy(&req->r_base_oid, oid); in ceph_osdc_notify_ack()
4885 ceph_oloc_copy(&req->r_base_oloc, oloc); in ceph_osdc_notify_ack()
4886 req->r_flags = CEPH_OSD_FLAG_READ; in ceph_osdc_notify_ack()
4888 ret = osd_req_op_notify_ack_init(req, 0, notify_id, cookie, payload, in ceph_osdc_notify_ack()
4893 ret = ceph_osdc_alloc_messages(req, GFP_NOIO); in ceph_osdc_notify_ack()
4897 ceph_osdc_start_request(osdc, req); in ceph_osdc_notify_ack()
4898 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_notify_ack()
4901 ceph_osdc_put_request(req); in ceph_osdc_notify_ack()
5053 struct ceph_osd_request *req; in ceph_osdc_list_watchers() local
5057 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_list_watchers()
5058 if (!req) in ceph_osdc_list_watchers()
5061 ceph_oid_copy(&req->r_base_oid, oid); in ceph_osdc_list_watchers()
5062 ceph_oloc_copy(&req->r_base_oloc, oloc); in ceph_osdc_list_watchers()
5063 req->r_flags = CEPH_OSD_FLAG_READ; in ceph_osdc_list_watchers()
5071 osd_req_op_init(req, 0, CEPH_OSD_OP_LIST_WATCHERS, 0); in ceph_osdc_list_watchers()
5072 ceph_osd_data_pages_init(osd_req_op_data(req, 0, list_watchers, in ceph_osdc_list_watchers()
5076 ret = ceph_osdc_alloc_messages(req, GFP_NOIO); in ceph_osdc_list_watchers()
5080 ceph_osdc_start_request(osdc, req); in ceph_osdc_list_watchers()
5081 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_list_watchers()
5084 void *const end = p + req->r_ops[0].outdata_len; in ceph_osdc_list_watchers()
5090 ceph_osdc_put_request(req); in ceph_osdc_list_watchers()
5128 struct ceph_osd_request *req; in ceph_osdc_call() local
5134 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_call()
5135 if (!req) in ceph_osdc_call()
5138 ceph_oid_copy(&req->r_base_oid, oid); in ceph_osdc_call()
5139 ceph_oloc_copy(&req->r_base_oloc, oloc); in ceph_osdc_call()
5140 req->r_flags = flags; in ceph_osdc_call()
5142 ret = osd_req_op_cls_init(req, 0, class, method); in ceph_osdc_call()
5147 osd_req_op_cls_request_data_pages(req, 0, &req_page, req_len, in ceph_osdc_call()
5150 osd_req_op_cls_response_data_pages(req, 0, resp_pages, in ceph_osdc_call()
5153 ret = ceph_osdc_alloc_messages(req, GFP_NOIO); in ceph_osdc_call()
5157 ceph_osdc_start_request(osdc, req); in ceph_osdc_call()
5158 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_call()
5160 ret = req->r_ops[0].rval; in ceph_osdc_call()
5162 *resp_len = req->r_ops[0].outdata_len; in ceph_osdc_call()
5166 ceph_osdc_put_request(req); in ceph_osdc_call()
5292 int osd_req_op_copy_from_init(struct ceph_osd_request *req, in osd_req_op_copy_from_init() argument
5309 op = osd_req_op_init(req, 0, CEPH_OSD_OP_COPY_FROM2, in osd_req_op_copy_from_init()
5381 static u64 sparse_data_requested(struct ceph_osd_request *req) in sparse_data_requested() argument
5385 if (req->r_flags & CEPH_OSD_FLAG_READ) { in sparse_data_requested()
5388 for (i = 0; i < req->r_num_ops; ++i) { in sparse_data_requested()
5389 struct ceph_osd_req_op *op = &req->r_ops[i]; in sparse_data_requested()
5410 struct ceph_osd_request *req; in get_reply() local
5425 req = lookup_request(&osd->o_requests, tid); in get_reply()
5426 if (!req) { in get_reply()
5433 ceph_msg_revoke_incoming(req->r_reply); in get_reply()
5435 if (front_len > req->r_reply->front_alloc_len) { in get_reply()
5437 __func__, osd->o_osd, req->r_tid, front_len, in get_reply()
5438 req->r_reply->front_alloc_len); in get_reply()
5443 ceph_msg_put(req->r_reply); in get_reply()
5444 req->r_reply = m; in get_reply()
5447 srlen = sparse_data_requested(req); in get_reply()
5448 if (!srlen && data_len > req->r_reply->data_length) { in get_reply()
5450 __func__, osd->o_osd, req->r_tid, data_len, in get_reply()
5451 req->r_reply->data_length); in get_reply()
5457 m = ceph_msg_get(req->r_reply); in get_reply()
5714 struct ceph_osd_request *req; in prep_next_sparse_read() local
5718 req = lookup_request(&o->o_requests, le64_to_cpu(con->in_msg->hdr.tid)); in prep_next_sparse_read()
5719 if (!req) { in prep_next_sparse_read()
5730 op = &req->r_ops[o->o_sparse_op_idx]; in prep_next_sparse_read()
5750 while (++o->o_sparse_op_idx < req->r_num_ops) { in prep_next_sparse_read()
5751 op = &req->r_ops[o->o_sparse_op_idx]; in prep_next_sparse_read()