• Home
  • Raw
  • Download

Lines Matching refs:req

48 static void link_request(struct ceph_osd *osd, struct ceph_osd_request *req);
49 static void unlink_request(struct ceph_osd *osd, struct ceph_osd_request *req);
408 static void request_release_checks(struct ceph_osd_request *req) in request_release_checks() argument
410 WARN_ON(!RB_EMPTY_NODE(&req->r_node)); in request_release_checks()
411 WARN_ON(!RB_EMPTY_NODE(&req->r_mc_node)); in request_release_checks()
412 WARN_ON(!list_empty(&req->r_unsafe_item)); in request_release_checks()
413 WARN_ON(req->r_osd); in request_release_checks()
418 struct ceph_osd_request *req = container_of(kref, in ceph_osdc_release_request() local
422 dout("%s %p (r_request %p r_reply %p)\n", __func__, req, in ceph_osdc_release_request()
423 req->r_request, req->r_reply); in ceph_osdc_release_request()
424 request_release_checks(req); in ceph_osdc_release_request()
426 if (req->r_request) in ceph_osdc_release_request()
427 ceph_msg_put(req->r_request); in ceph_osdc_release_request()
428 if (req->r_reply) in ceph_osdc_release_request()
429 ceph_msg_put(req->r_reply); in ceph_osdc_release_request()
431 for (which = 0; which < req->r_num_ops; which++) in ceph_osdc_release_request()
432 osd_req_op_data_release(req, which); in ceph_osdc_release_request()
434 target_destroy(&req->r_t); in ceph_osdc_release_request()
435 ceph_put_snap_context(req->r_snapc); in ceph_osdc_release_request()
437 if (req->r_mempool) in ceph_osdc_release_request()
438 mempool_free(req, req->r_osdc->req_mempool); in ceph_osdc_release_request()
439 else if (req->r_num_ops <= CEPH_OSD_SLAB_OPS) in ceph_osdc_release_request()
440 kmem_cache_free(ceph_osd_request_cache, req); in ceph_osdc_release_request()
442 kfree(req); in ceph_osdc_release_request()
445 void ceph_osdc_get_request(struct ceph_osd_request *req) in ceph_osdc_get_request() argument
447 dout("%s %p (was %d)\n", __func__, req, in ceph_osdc_get_request()
448 kref_read(&req->r_kref)); in ceph_osdc_get_request()
449 kref_get(&req->r_kref); in ceph_osdc_get_request()
453 void ceph_osdc_put_request(struct ceph_osd_request *req) in ceph_osdc_put_request() argument
455 if (req) { in ceph_osdc_put_request()
456 dout("%s %p (was %d)\n", __func__, req, in ceph_osdc_put_request()
457 kref_read(&req->r_kref)); in ceph_osdc_put_request()
458 kref_put(&req->r_kref, ceph_osdc_release_request); in ceph_osdc_put_request()
463 static void request_init(struct ceph_osd_request *req) in request_init() argument
466 memset(req, 0, sizeof(*req)); in request_init()
468 kref_init(&req->r_kref); in request_init()
469 init_completion(&req->r_completion); in request_init()
470 RB_CLEAR_NODE(&req->r_node); in request_init()
471 RB_CLEAR_NODE(&req->r_mc_node); in request_init()
472 INIT_LIST_HEAD(&req->r_unsafe_item); in request_init()
474 target_init(&req->r_t); in request_init()
484 static void request_reinit(struct ceph_osd_request *req) in request_reinit() argument
486 struct ceph_osd_client *osdc = req->r_osdc; in request_reinit()
487 bool mempool = req->r_mempool; in request_reinit()
488 unsigned int num_ops = req->r_num_ops; in request_reinit()
489 u64 snapid = req->r_snapid; in request_reinit()
490 struct ceph_snap_context *snapc = req->r_snapc; in request_reinit()
491 bool linger = req->r_linger; in request_reinit()
492 struct ceph_msg *request_msg = req->r_request; in request_reinit()
493 struct ceph_msg *reply_msg = req->r_reply; in request_reinit()
495 dout("%s req %p\n", __func__, req); in request_reinit()
496 WARN_ON(kref_read(&req->r_kref) != 1); in request_reinit()
497 request_release_checks(req); in request_reinit()
501 target_destroy(&req->r_t); in request_reinit()
503 request_init(req); in request_reinit()
504 req->r_osdc = osdc; in request_reinit()
505 req->r_mempool = mempool; in request_reinit()
506 req->r_num_ops = num_ops; in request_reinit()
507 req->r_snapid = snapid; in request_reinit()
508 req->r_snapc = snapc; in request_reinit()
509 req->r_linger = linger; in request_reinit()
510 req->r_request = request_msg; in request_reinit()
511 req->r_reply = reply_msg; in request_reinit()
520 struct ceph_osd_request *req; in ceph_osdc_alloc_request() local
524 req = mempool_alloc(osdc->req_mempool, gfp_flags); in ceph_osdc_alloc_request()
526 req = kmem_cache_alloc(ceph_osd_request_cache, gfp_flags); in ceph_osdc_alloc_request()
529 req = kmalloc(sizeof(*req) + num_ops * sizeof(req->r_ops[0]), in ceph_osdc_alloc_request()
532 if (unlikely(!req)) in ceph_osdc_alloc_request()
535 request_init(req); in ceph_osdc_alloc_request()
536 req->r_osdc = osdc; in ceph_osdc_alloc_request()
537 req->r_mempool = use_mempool; in ceph_osdc_alloc_request()
538 req->r_num_ops = num_ops; in ceph_osdc_alloc_request()
539 req->r_snapid = CEPH_NOSNAP; in ceph_osdc_alloc_request()
540 req->r_snapc = ceph_get_snap_context(snapc); in ceph_osdc_alloc_request()
542 dout("%s req %p\n", __func__, req); in ceph_osdc_alloc_request()
543 return req; in ceph_osdc_alloc_request()
552 int ceph_osdc_alloc_messages(struct ceph_osd_request *req, gfp_t gfp) in ceph_osdc_alloc_messages() argument
554 struct ceph_osd_client *osdc = req->r_osdc; in ceph_osdc_alloc_messages()
558 WARN_ON(ceph_oid_empty(&req->r_base_oid)); in ceph_osdc_alloc_messages()
559 WARN_ON(ceph_oloc_empty(&req->r_base_oloc)); in ceph_osdc_alloc_messages()
570 ceph_oloc_encoding_size(&req->r_base_oloc); /* oloc */ in ceph_osdc_alloc_messages()
571 msg_size += 4 + req->r_base_oid.name_len; /* oid */ in ceph_osdc_alloc_messages()
572 msg_size += 2 + req->r_num_ops * sizeof(struct ceph_osd_op); in ceph_osdc_alloc_messages()
575 msg_size += 4 + 8 * (req->r_snapc ? req->r_snapc->num_snaps : 0); in ceph_osdc_alloc_messages()
578 if (req->r_mempool) in ceph_osdc_alloc_messages()
586 req->r_request = msg; in ceph_osdc_alloc_messages()
590 msg_size += req->r_base_oid.name_len; in ceph_osdc_alloc_messages()
591 msg_size += req->r_num_ops * sizeof(struct ceph_osd_op); in ceph_osdc_alloc_messages()
593 if (req->r_mempool) in ceph_osdc_alloc_messages()
600 req->r_reply = msg; in ceph_osdc_alloc_messages()
784 static void osd_req_op_watch_init(struct ceph_osd_request *req, int which, in osd_req_op_watch_init() argument
789 op = _osd_req_op_init(req, which, CEPH_OSD_OP_WATCH, 0); in osd_req_op_watch_init()
930 struct ceph_osd_request *req; in ceph_osdc_new_request() local
940 req = ceph_osdc_alloc_request(osdc, snapc, num_ops, use_mempool, in ceph_osdc_new_request()
942 if (!req) { in ceph_osdc_new_request()
953 osd_req_op_init(req, which, opcode, 0); in ceph_osdc_new_request()
966 osd_req_op_extent_init(req, which, opcode, objoff, objlen, in ceph_osdc_new_request()
970 req->r_abort_on_full = true; in ceph_osdc_new_request()
971 req->r_flags = flags; in ceph_osdc_new_request()
972 req->r_base_oloc.pool = layout->pool_id; in ceph_osdc_new_request()
973 req->r_base_oloc.pool_ns = ceph_try_get_string(layout->pool_ns); in ceph_osdc_new_request()
974 ceph_oid_printf(&req->r_base_oid, "%llx.%08llx", vino.ino, objnum); in ceph_osdc_new_request()
976 req->r_snapid = vino.snap; in ceph_osdc_new_request()
978 req->r_data_offset = off; in ceph_osdc_new_request()
980 r = ceph_osdc_alloc_messages(req, GFP_NOFS); in ceph_osdc_new_request()
984 return req; in ceph_osdc_new_request()
987 ceph_osdc_put_request(req); in ceph_osdc_new_request()
1134 struct ceph_osd_request *req = in close_osd() local
1139 dout(" reassigning req %p tid %llu\n", req, req->r_tid); in close_osd()
1140 unlink_request(osd, req); in close_osd()
1141 link_request(&osdc->homeless_osd, req); in close_osd()
1185 struct ceph_osd_request *req = in reopen_osd() local
1187 req->r_stamp = jiffies; in reopen_osd()
1233 static void link_request(struct ceph_osd *osd, struct ceph_osd_request *req) in link_request() argument
1236 WARN_ON(!req->r_tid || req->r_osd); in link_request()
1238 req, req->r_tid); in link_request()
1246 insert_request(&osd->o_requests, req); in link_request()
1247 req->r_osd = osd; in link_request()
1250 static void unlink_request(struct ceph_osd *osd, struct ceph_osd_request *req) in unlink_request() argument
1253 WARN_ON(req->r_osd != osd); in unlink_request()
1255 req, req->r_tid); in unlink_request()
1257 req->r_osd = NULL; in unlink_request()
1258 erase_request(&osd->o_requests, req); in unlink_request()
1740 static bool should_plug_request(struct ceph_osd_request *req) in should_plug_request() argument
1742 struct ceph_osd *osd = req->r_osd; in should_plug_request()
1747 spg = lookup_spg_mapping(&osd->o_backoff_mappings, &req->r_t.spgid); in should_plug_request()
1751 hoid_fill_from_target(&hoid, &req->r_t); in should_plug_request()
1757 __func__, req, req->r_tid, osd->o_osd, backoff->spgid.pgid.pool, in should_plug_request()
1762 static void setup_request_data(struct ceph_osd_request *req, in setup_request_data() argument
1772 for (i = 0; i < req->r_num_ops; i++) { in setup_request_data()
1773 struct ceph_osd_req_op *op = &req->r_ops[i]; in setup_request_data()
1795 ceph_osdc_msg_data_add(req->r_reply, in setup_request_data()
1799 ceph_osdc_msg_data_add(req->r_reply, in setup_request_data()
1803 ceph_osdc_msg_data_add(req->r_reply, in setup_request_data()
1816 ceph_osdc_msg_data_add(req->r_reply, in setup_request_data()
1822 ceph_osdc_msg_data_add(req->r_reply, in setup_request_data()
1862 static void encode_request_partial(struct ceph_osd_request *req, in encode_request_partial() argument
1870 if (req->r_flags & CEPH_OSD_FLAG_WRITE) { in encode_request_partial()
1872 WARN_ON(req->r_snapid != CEPH_NOSNAP); in encode_request_partial()
1874 WARN_ON(req->r_mtime.tv_sec || req->r_mtime.tv_nsec || in encode_request_partial()
1875 req->r_data_offset || req->r_snapc); in encode_request_partial()
1878 setup_request_data(req, msg); in encode_request_partial()
1880 encode_spgid(&p, &req->r_t.spgid); /* actual spg */ in encode_request_partial()
1881 ceph_encode_32(&p, req->r_t.pgid.seed); /* raw hash */ in encode_request_partial()
1882 ceph_encode_32(&p, req->r_osdc->osdmap->epoch); in encode_request_partial()
1883 ceph_encode_32(&p, req->r_flags); in encode_request_partial()
1895 ceph_encode_timespec(p, &req->r_mtime); in encode_request_partial()
1898 encode_oloc(&p, end, &req->r_t.target_oloc); in encode_request_partial()
1899 ceph_encode_string(&p, end, req->r_t.target_oid.name, in encode_request_partial()
1900 req->r_t.target_oid.name_len); in encode_request_partial()
1903 ceph_encode_16(&p, req->r_num_ops); in encode_request_partial()
1904 for (i = 0; i < req->r_num_ops; i++) { in encode_request_partial()
1905 data_len += osd_req_encode_op(p, &req->r_ops[i]); in encode_request_partial()
1909 ceph_encode_64(&p, req->r_snapid); /* snapid */ in encode_request_partial()
1910 if (req->r_snapc) { in encode_request_partial()
1911 ceph_encode_64(&p, req->r_snapc->seq); in encode_request_partial()
1912 ceph_encode_32(&p, req->r_snapc->num_snaps); in encode_request_partial()
1913 for (i = 0; i < req->r_snapc->num_snaps; i++) in encode_request_partial()
1914 ceph_encode_64(&p, req->r_snapc->snaps[i]); in encode_request_partial()
1920 ceph_encode_32(&p, req->r_attempts); /* retry_attempt */ in encode_request_partial()
1933 msg->hdr.data_off = cpu_to_le16(req->r_data_offset); in encode_request_partial()
1935 dout("%s req %p msg %p oid %s oid_len %d\n", __func__, req, msg, in encode_request_partial()
1936 req->r_t.target_oid.name, req->r_t.target_oid.name_len); in encode_request_partial()
2034 static void send_request(struct ceph_osd_request *req) in send_request() argument
2036 struct ceph_osd *osd = req->r_osd; in send_request()
2039 WARN_ON(osd->o_osd != req->r_t.osd); in send_request()
2042 if (should_plug_request(req)) in send_request()
2049 if (req->r_sent) in send_request()
2050 ceph_msg_revoke(req->r_request); in send_request()
2052 req->r_flags |= CEPH_OSD_FLAG_KNOWN_REDIR; in send_request()
2053 if (req->r_attempts) in send_request()
2054 req->r_flags |= CEPH_OSD_FLAG_RETRY; in send_request()
2056 WARN_ON(req->r_flags & CEPH_OSD_FLAG_RETRY); in send_request()
2058 encode_request_partial(req, req->r_request); in send_request()
2061 __func__, req, req->r_tid, req->r_t.pgid.pool, req->r_t.pgid.seed, in send_request()
2062 req->r_t.spgid.pgid.pool, req->r_t.spgid.pgid.seed, in send_request()
2063 req->r_t.spgid.shard, osd->o_osd, req->r_t.epoch, req->r_flags, in send_request()
2064 req->r_attempts); in send_request()
2066 req->r_t.paused = false; in send_request()
2067 req->r_stamp = jiffies; in send_request()
2068 req->r_attempts++; in send_request()
2070 req->r_sent = osd->o_incarnation; in send_request()
2071 req->r_request->hdr.tid = cpu_to_le64(req->r_tid); in send_request()
2072 ceph_con_send(&osd->o_con, ceph_msg_get(req->r_request)); in send_request()
2096 static void complete_request(struct ceph_osd_request *req, int err);
2097 static void send_map_check(struct ceph_osd_request *req);
2099 static void __submit_request(struct ceph_osd_request *req, bool wrlocked) in __submit_request() argument
2101 struct ceph_osd_client *osdc = req->r_osdc; in __submit_request()
2108 WARN_ON(req->r_tid); in __submit_request()
2109 dout("%s req %p wrlocked %d\n", __func__, req, wrlocked); in __submit_request()
2112 ct_res = calc_target(osdc, &req->r_t, NULL, false); in __submit_request()
2116 osd = lookup_create_osd(osdc, req->r_t.osd, wrlocked); in __submit_request()
2123 dout("req %p epoch %u barrier %u\n", req, osdc->osdmap->epoch, in __submit_request()
2125 req->r_t.paused = true; in __submit_request()
2127 } else if ((req->r_flags & CEPH_OSD_FLAG_WRITE) && in __submit_request()
2129 dout("req %p pausewr\n", req); in __submit_request()
2130 req->r_t.paused = true; in __submit_request()
2132 } else if ((req->r_flags & CEPH_OSD_FLAG_READ) && in __submit_request()
2134 dout("req %p pauserd\n", req); in __submit_request()
2135 req->r_t.paused = true; in __submit_request()
2137 } else if ((req->r_flags & CEPH_OSD_FLAG_WRITE) && in __submit_request()
2138 !(req->r_flags & (CEPH_OSD_FLAG_FULL_TRY | in __submit_request()
2141 pool_full(osdc, req->r_t.base_oloc.pool))) { in __submit_request()
2142 dout("req %p full/pool_full\n", req); in __submit_request()
2144 req->r_t.paused = true; in __submit_request()
2146 if (req->r_abort_on_full) in __submit_request()
2160 req->r_tid = atomic64_inc_return(&osdc->last_tid); in __submit_request()
2161 link_request(osd, req); in __submit_request()
2163 send_request(req); in __submit_request()
2165 complete_request(req, -ENOSPC); in __submit_request()
2169 send_map_check(req); in __submit_request()
2183 static void account_request(struct ceph_osd_request *req) in account_request() argument
2185 WARN_ON(req->r_flags & (CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK)); in account_request()
2186 WARN_ON(!(req->r_flags & (CEPH_OSD_FLAG_READ | CEPH_OSD_FLAG_WRITE))); in account_request()
2188 req->r_flags |= CEPH_OSD_FLAG_ONDISK; in account_request()
2189 atomic_inc(&req->r_osdc->num_requests); in account_request()
2191 req->r_start_stamp = jiffies; in account_request()
2194 static void submit_request(struct ceph_osd_request *req, bool wrlocked) in submit_request() argument
2196 ceph_osdc_get_request(req); in submit_request()
2197 account_request(req); in submit_request()
2198 __submit_request(req, wrlocked); in submit_request()
2201 static void finish_request(struct ceph_osd_request *req) in finish_request() argument
2203 struct ceph_osd_client *osdc = req->r_osdc; in finish_request()
2205 WARN_ON(lookup_request_mc(&osdc->map_checks, req->r_tid)); in finish_request()
2206 dout("%s req %p tid %llu\n", __func__, req, req->r_tid); in finish_request()
2208 if (req->r_osd) in finish_request()
2209 unlink_request(req->r_osd, req); in finish_request()
2218 ceph_msg_revoke(req->r_request); in finish_request()
2219 ceph_msg_revoke_incoming(req->r_reply); in finish_request()
2222 static void __complete_request(struct ceph_osd_request *req) in __complete_request() argument
2224 if (req->r_callback) { in __complete_request()
2225 dout("%s req %p tid %llu cb %pf result %d\n", __func__, req, in __complete_request()
2226 req->r_tid, req->r_callback, req->r_result); in __complete_request()
2227 req->r_callback(req); in __complete_request()
2234 static void complete_request(struct ceph_osd_request *req, int err) in complete_request() argument
2236 dout("%s req %p tid %llu err %d\n", __func__, req, req->r_tid, err); in complete_request()
2238 req->r_result = err; in complete_request()
2239 finish_request(req); in complete_request()
2240 __complete_request(req); in complete_request()
2241 complete_all(&req->r_completion); in complete_request()
2242 ceph_osdc_put_request(req); in complete_request()
2245 static void cancel_map_check(struct ceph_osd_request *req) in cancel_map_check() argument
2247 struct ceph_osd_client *osdc = req->r_osdc; in cancel_map_check()
2252 lookup_req = lookup_request_mc(&osdc->map_checks, req->r_tid); in cancel_map_check()
2256 WARN_ON(lookup_req != req); in cancel_map_check()
2257 erase_request_mc(&osdc->map_checks, req); in cancel_map_check()
2258 ceph_osdc_put_request(req); in cancel_map_check()
2261 static void cancel_request(struct ceph_osd_request *req) in cancel_request() argument
2263 dout("%s req %p tid %llu\n", __func__, req, req->r_tid); in cancel_request()
2265 cancel_map_check(req); in cancel_request()
2266 finish_request(req); in cancel_request()
2267 complete_all(&req->r_completion); in cancel_request()
2268 ceph_osdc_put_request(req); in cancel_request()
2271 static void abort_request(struct ceph_osd_request *req, int err) in abort_request() argument
2273 dout("%s req %p tid %llu err %d\n", __func__, req, req->r_tid, err); in abort_request()
2275 cancel_map_check(req); in abort_request()
2276 complete_request(req, err); in abort_request()
2328 struct ceph_osd_request *req = rb_entry(m, in ceph_osdc_abort_on_full() local
2332 if (req->r_abort_on_full) { in ceph_osdc_abort_on_full()
2356 struct ceph_osd_request *req = rb_entry(m, in ceph_osdc_abort_on_full() local
2360 if (req->r_abort_on_full && in ceph_osdc_abort_on_full()
2362 pool_full(osdc, req->r_t.target_oloc.pool))) in ceph_osdc_abort_on_full()
2363 abort_request(req, -ENOSPC); in ceph_osdc_abort_on_full()
2370 static void check_pool_dne(struct ceph_osd_request *req) in check_pool_dne() argument
2372 struct ceph_osd_client *osdc = req->r_osdc; in check_pool_dne()
2378 if (req->r_attempts) { in check_pool_dne()
2384 req->r_map_dne_bound = map->epoch; in check_pool_dne()
2385 dout("%s req %p tid %llu pool disappeared\n", __func__, req, in check_pool_dne()
2386 req->r_tid); in check_pool_dne()
2389 req, req->r_tid, req->r_map_dne_bound, map->epoch); in check_pool_dne()
2392 if (req->r_map_dne_bound) { in check_pool_dne()
2393 if (map->epoch >= req->r_map_dne_bound) { in check_pool_dne()
2396 req->r_tid); in check_pool_dne()
2397 complete_request(req, -ENOENT); in check_pool_dne()
2400 send_map_check(req); in check_pool_dne()
2407 struct ceph_osd_request *req; in map_check_cb() local
2413 req = lookup_request_mc(&osdc->map_checks, tid); in map_check_cb()
2414 if (!req) { in map_check_cb()
2420 req, req->r_tid, req->r_map_dne_bound, greq->u.newest); in map_check_cb()
2421 if (!req->r_map_dne_bound) in map_check_cb()
2422 req->r_map_dne_bound = greq->u.newest; in map_check_cb()
2423 erase_request_mc(&osdc->map_checks, req); in map_check_cb()
2424 check_pool_dne(req); in map_check_cb()
2426 ceph_osdc_put_request(req); in map_check_cb()
2431 static void send_map_check(struct ceph_osd_request *req) in send_map_check() argument
2433 struct ceph_osd_client *osdc = req->r_osdc; in send_map_check()
2439 lookup_req = lookup_request_mc(&osdc->map_checks, req->r_tid); in send_map_check()
2441 WARN_ON(lookup_req != req); in send_map_check()
2445 ceph_osdc_get_request(req); in send_map_check()
2446 insert_request_mc(&osdc->map_checks, req); in send_map_check()
2448 map_check_cb, req->r_tid); in send_map_check()
2602 static void cancel_linger_request(struct ceph_osd_request *req) in cancel_linger_request() argument
2604 struct ceph_osd_linger_request *lreq = req->r_priv; in cancel_linger_request()
2606 WARN_ON(!req->r_linger); in cancel_linger_request()
2607 cancel_request(req); in cancel_linger_request()
2736 static void linger_commit_cb(struct ceph_osd_request *req) in linger_commit_cb() argument
2738 struct ceph_osd_linger_request *lreq = req->r_priv; in linger_commit_cb()
2742 lreq->linger_id, req->r_result); in linger_commit_cb()
2743 linger_reg_commit_complete(lreq, req->r_result); in linger_commit_cb()
2748 osd_req_op_data(req, 0, notify, response_data); in linger_commit_cb()
2751 WARN_ON(req->r_ops[0].op != CEPH_OSD_OP_NOTIFY || in linger_commit_cb()
2755 if (req->r_ops[0].outdata_len >= sizeof(u64)) { in linger_commit_cb()
2781 static void linger_reconnect_cb(struct ceph_osd_request *req) in linger_reconnect_cb() argument
2783 struct ceph_osd_linger_request *lreq = req->r_priv; in linger_reconnect_cb()
2787 lreq, lreq->linger_id, req->r_result, lreq->last_error); in linger_reconnect_cb()
2788 if (req->r_result < 0) { in linger_reconnect_cb()
2790 lreq->last_error = normalize_watch_error(req->r_result); in linger_reconnect_cb()
2801 struct ceph_osd_request *req = lreq->reg_req; in send_linger() local
2802 struct ceph_osd_req_op *op = &req->r_ops[0]; in send_linger()
2804 verify_osdc_wrlocked(req->r_osdc); in send_linger()
2807 if (req->r_osd) in send_linger()
2808 cancel_linger_request(req); in send_linger()
2810 request_reinit(req); in send_linger()
2811 ceph_oid_copy(&req->r_base_oid, &lreq->t.base_oid); in send_linger()
2812 ceph_oloc_copy(&req->r_base_oloc, &lreq->t.base_oloc); in send_linger()
2813 req->r_flags = lreq->t.flags; in send_linger()
2814 req->r_mtime = lreq->mtime; in send_linger()
2824 req->r_callback = linger_reconnect_cb; in send_linger()
2831 req->r_callback = linger_commit_cb; in send_linger()
2835 req->r_priv = linger_get(lreq); in send_linger()
2836 req->r_linger = true; in send_linger()
2838 submit_request(req, true); in send_linger()
2841 static void linger_ping_cb(struct ceph_osd_request *req) in linger_ping_cb() argument
2843 struct ceph_osd_linger_request *lreq = req->r_priv; in linger_ping_cb()
2847 __func__, lreq, lreq->linger_id, req->r_result, lreq->ping_sent, in linger_ping_cb()
2849 if (lreq->register_gen == req->r_ops[0].watch.gen) { in linger_ping_cb()
2850 if (!req->r_result) { in linger_ping_cb()
2853 lreq->last_error = normalize_watch_error(req->r_result); in linger_ping_cb()
2858 lreq->register_gen, req->r_ops[0].watch.gen); in linger_ping_cb()
2868 struct ceph_osd_request *req = lreq->ping_req; in send_linger_ping() local
2869 struct ceph_osd_req_op *op = &req->r_ops[0]; in send_linger_ping()
2881 if (req->r_osd) in send_linger_ping()
2882 cancel_linger_request(req); in send_linger_ping()
2884 request_reinit(req); in send_linger_ping()
2885 target_copy(&req->r_t, &lreq->t); in send_linger_ping()
2891 req->r_callback = linger_ping_cb; in send_linger_ping()
2892 req->r_priv = linger_get(lreq); in send_linger_ping()
2893 req->r_linger = true; in send_linger_ping()
2895 ceph_osdc_get_request(req); in send_linger_ping()
2896 account_request(req); in send_linger_ping()
2897 req->r_tid = atomic64_inc_return(&osdc->last_tid); in send_linger_ping()
2898 link_request(lreq->osd, req); in send_linger_ping()
2899 send_request(req); in send_linger_ping()
3085 struct ceph_osd_request *req = in handle_timeout() local
3090 if (time_before(req->r_stamp, cutoff)) { in handle_timeout()
3092 req, req->r_tid, osd->o_osd); in handle_timeout()
3096 time_before(req->r_start_stamp, expiry_cutoff)) { in handle_timeout()
3098 req->r_tid, osd->o_osd); in handle_timeout()
3099 abort_request(req, -ETIMEDOUT); in handle_timeout()
3122 struct ceph_osd_request *req = in handle_timeout() local
3127 if (time_before(req->r_start_stamp, expiry_cutoff)) { in handle_timeout()
3129 req->r_tid, osdc->homeless_osd.o_osd); in handle_timeout()
3130 abort_request(req, -ETIMEDOUT); in handle_timeout()
3388 struct ceph_osd_request *req; in handle_reply() local
3405 req = lookup_request(&osd->o_requests, tid); in handle_reply()
3406 if (!req) { in handle_reply()
3411 m.redirect.oloc.pool_ns = req->r_t.target_oloc.pool_ns; in handle_reply()
3416 req->r_tid, ret); in handle_reply()
3421 __func__, req, req->r_tid, m.flags, m.pgid.pool, m.pgid.seed, in handle_reply()
3426 if (m.retry_attempt != req->r_attempts - 1) { in handle_reply()
3428 req, req->r_tid, m.retry_attempt, in handle_reply()
3429 req->r_attempts - 1); in handle_reply()
3437 dout("req %p tid %llu redirect pool %lld\n", req, req->r_tid, in handle_reply()
3439 unlink_request(osd, req); in handle_reply()
3446 req->r_t.target_oloc.pool = m.redirect.oloc.pool; in handle_reply()
3447 req->r_flags |= CEPH_OSD_FLAG_REDIRECTED; in handle_reply()
3448 req->r_tid = 0; in handle_reply()
3449 __submit_request(req, false); in handle_reply()
3453 if (m.num_ops != req->r_num_ops) { in handle_reply()
3455 req->r_num_ops, req->r_tid); in handle_reply()
3458 for (i = 0; i < req->r_num_ops; i++) { in handle_reply()
3459 dout(" req %p tid %llu op %d rval %d len %u\n", req, in handle_reply()
3460 req->r_tid, i, m.rval[i], m.outdata_len[i]); in handle_reply()
3461 req->r_ops[i].rval = m.rval[i]; in handle_reply()
3462 req->r_ops[i].outdata_len = m.outdata_len[i]; in handle_reply()
3467 le32_to_cpu(msg->hdr.data_len), req->r_tid); in handle_reply()
3471 req, req->r_tid, m.result, data_len); in handle_reply()
3478 req->r_result = m.result ?: data_len; in handle_reply()
3479 finish_request(req); in handle_reply()
3483 __complete_request(req); in handle_reply()
3484 complete_all(&req->r_completion); in handle_reply()
3485 ceph_osdc_put_request(req); in handle_reply()
3489 complete_request(req, -EIO); in handle_reply()
3590 struct ceph_osd_request *req = in scan_requests() local
3596 dout("%s req %p tid %llu\n", __func__, req, req->r_tid); in scan_requests()
3597 ct_res = calc_target(osdc, &req->r_t, &req->r_osd->o_con, in scan_requests()
3603 pool_cleared_full(osdc, req->r_t.base_oloc.pool)); in scan_requests()
3605 (!(req->r_flags & CEPH_OSD_FLAG_WRITE) || in scan_requests()
3611 cancel_map_check(req); in scan_requests()
3612 unlink_request(osd, req); in scan_requests()
3613 insert_request(need_resend, req); in scan_requests()
3616 check_pool_dne(req); in scan_requests()
3701 struct ceph_osd_request *req = in kick_requests() local
3706 if (req->r_t.epoch < osdc->osdmap->epoch) { in kick_requests()
3707 ct_res = calc_target(osdc, &req->r_t, NULL, false); in kick_requests()
3709 erase_request(need_resend, req); in kick_requests()
3710 check_pool_dne(req); in kick_requests()
3716 struct ceph_osd_request *req = in kick_requests() local
3721 erase_request(need_resend, req); /* before link_request() */ in kick_requests()
3723 osd = lookup_create_osd(osdc, req->r_t.osd, true); in kick_requests()
3724 link_request(osd, req); in kick_requests()
3725 if (!req->r_linger) { in kick_requests()
3726 if (!osd_homeless(osd) && !req->r_t.paused) in kick_requests()
3727 send_request(req); in kick_requests()
3729 cancel_linger_request(req); in kick_requests()
3868 struct ceph_osd_request *req = in kick_osd_requests() local
3873 if (!req->r_linger) { in kick_osd_requests()
3874 if (!req->r_t.paused) in kick_osd_requests()
3875 send_request(req); in kick_osd_requests()
3877 cancel_linger_request(req); in kick_osd_requests()
4107 struct ceph_osd_request *req = in handle_backoff_unblock() local
4110 if (!ceph_spg_compare(&req->r_t.spgid, &m->spgid)) { in handle_backoff_unblock()
4115 if (target_contained_by(&req->r_t, m->begin, m->end)) { in handle_backoff_unblock()
4120 send_request(req); in handle_backoff_unblock()
4274 struct ceph_osd_request *req, in ceph_osdc_start_request() argument
4278 submit_request(req, false); in ceph_osdc_start_request()
4289 void ceph_osdc_cancel_request(struct ceph_osd_request *req) in ceph_osdc_cancel_request() argument
4291 struct ceph_osd_client *osdc = req->r_osdc; in ceph_osdc_cancel_request()
4294 if (req->r_osd) in ceph_osdc_cancel_request()
4295 cancel_request(req); in ceph_osdc_cancel_request()
4303 static int wait_request_timeout(struct ceph_osd_request *req, in wait_request_timeout() argument
4308 dout("%s req %p tid %llu\n", __func__, req, req->r_tid); in wait_request_timeout()
4309 left = wait_for_completion_killable_timeout(&req->r_completion, in wait_request_timeout()
4313 ceph_osdc_cancel_request(req); in wait_request_timeout()
4315 left = req->r_result; /* completed */ in wait_request_timeout()
4325 struct ceph_osd_request *req) in ceph_osdc_wait_request() argument
4327 return wait_request_timeout(req, 0); in ceph_osdc_wait_request()
4346 struct ceph_osd_request *req = in ceph_osdc_sync() local
4349 if (req->r_tid > last_tid) in ceph_osdc_sync()
4352 if (!(req->r_flags & CEPH_OSD_FLAG_WRITE)) in ceph_osdc_sync()
4355 ceph_osdc_get_request(req); in ceph_osdc_sync()
4359 __func__, req, req->r_tid, last_tid); in ceph_osdc_sync()
4360 wait_for_completion(&req->r_completion); in ceph_osdc_sync()
4361 ceph_osdc_put_request(req); in ceph_osdc_sync()
4376 struct ceph_osd_request *req; in alloc_linger_request() local
4378 req = ceph_osdc_alloc_request(lreq->osdc, NULL, 1, false, GFP_NOIO); in alloc_linger_request()
4379 if (!req) in alloc_linger_request()
4382 ceph_oid_copy(&req->r_base_oid, &lreq->t.base_oid); in alloc_linger_request()
4383 ceph_oloc_copy(&req->r_base_oloc, &lreq->t.base_oloc); in alloc_linger_request()
4385 if (ceph_osdc_alloc_messages(req, GFP_NOIO)) { in alloc_linger_request()
4386 ceph_osdc_put_request(req); in alloc_linger_request()
4390 return req; in alloc_linger_request()
4468 struct ceph_osd_request *req; in ceph_osdc_unwatch() local
4471 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_unwatch()
4472 if (!req) in ceph_osdc_unwatch()
4475 ceph_oid_copy(&req->r_base_oid, &lreq->t.base_oid); in ceph_osdc_unwatch()
4476 ceph_oloc_copy(&req->r_base_oloc, &lreq->t.base_oloc); in ceph_osdc_unwatch()
4477 req->r_flags = CEPH_OSD_FLAG_WRITE; in ceph_osdc_unwatch()
4478 ktime_get_real_ts(&req->r_mtime); in ceph_osdc_unwatch()
4479 osd_req_op_watch_init(req, 0, lreq->linger_id, in ceph_osdc_unwatch()
4482 ret = ceph_osdc_alloc_messages(req, GFP_NOIO); in ceph_osdc_unwatch()
4486 ceph_osdc_start_request(osdc, req, false); in ceph_osdc_unwatch()
4489 ret = wait_request_timeout(req, opts->mount_timeout); in ceph_osdc_unwatch()
4492 ceph_osdc_put_request(req); in ceph_osdc_unwatch()
4497 static int osd_req_op_notify_ack_init(struct ceph_osd_request *req, int which, in osd_req_op_notify_ack_init() argument
4505 op = _osd_req_op_init(req, which, CEPH_OSD_OP_NOTIFY_ACK, 0); in osd_req_op_notify_ack_init()
4538 struct ceph_osd_request *req; in ceph_osdc_notify_ack() local
4541 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_notify_ack()
4542 if (!req) in ceph_osdc_notify_ack()
4545 ceph_oid_copy(&req->r_base_oid, oid); in ceph_osdc_notify_ack()
4546 ceph_oloc_copy(&req->r_base_oloc, oloc); in ceph_osdc_notify_ack()
4547 req->r_flags = CEPH_OSD_FLAG_READ; in ceph_osdc_notify_ack()
4549 ret = ceph_osdc_alloc_messages(req, GFP_NOIO); in ceph_osdc_notify_ack()
4553 ret = osd_req_op_notify_ack_init(req, 0, notify_id, cookie, payload, in ceph_osdc_notify_ack()
4558 ceph_osdc_start_request(osdc, req, false); in ceph_osdc_notify_ack()
4559 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_notify_ack()
4562 ceph_osdc_put_request(req); in ceph_osdc_notify_ack()
4567 static int osd_req_op_notify_init(struct ceph_osd_request *req, int which, in osd_req_op_notify_init() argument
4575 op = _osd_req_op_init(req, which, CEPH_OSD_OP_NOTIFY, 0); in osd_req_op_notify_init()
4777 struct ceph_osd_request *req; in ceph_osdc_list_watchers() local
4781 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_list_watchers()
4782 if (!req) in ceph_osdc_list_watchers()
4785 ceph_oid_copy(&req->r_base_oid, oid); in ceph_osdc_list_watchers()
4786 ceph_oloc_copy(&req->r_base_oloc, oloc); in ceph_osdc_list_watchers()
4787 req->r_flags = CEPH_OSD_FLAG_READ; in ceph_osdc_list_watchers()
4789 ret = ceph_osdc_alloc_messages(req, GFP_NOIO); in ceph_osdc_list_watchers()
4799 osd_req_op_init(req, 0, CEPH_OSD_OP_LIST_WATCHERS, 0); in ceph_osdc_list_watchers()
4800 ceph_osd_data_pages_init(osd_req_op_data(req, 0, list_watchers, in ceph_osdc_list_watchers()
4804 ceph_osdc_start_request(osdc, req, false); in ceph_osdc_list_watchers()
4805 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_list_watchers()
4808 void *const end = p + req->r_ops[0].outdata_len; in ceph_osdc_list_watchers()
4814 ceph_osdc_put_request(req); in ceph_osdc_list_watchers()
4852 struct ceph_osd_request *req; in ceph_osdc_call() local
4858 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_call()
4859 if (!req) in ceph_osdc_call()
4862 ceph_oid_copy(&req->r_base_oid, oid); in ceph_osdc_call()
4863 ceph_oloc_copy(&req->r_base_oloc, oloc); in ceph_osdc_call()
4864 req->r_flags = flags; in ceph_osdc_call()
4866 ret = ceph_osdc_alloc_messages(req, GFP_NOIO); in ceph_osdc_call()
4870 osd_req_op_cls_init(req, 0, CEPH_OSD_OP_CALL, class, method); in ceph_osdc_call()
4872 osd_req_op_cls_request_data_pages(req, 0, &req_page, req_len, in ceph_osdc_call()
4875 osd_req_op_cls_response_data_pages(req, 0, &resp_page, in ceph_osdc_call()
4878 ceph_osdc_start_request(osdc, req, false); in ceph_osdc_call()
4879 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_call()
4881 ret = req->r_ops[0].rval; in ceph_osdc_call()
4883 *resp_len = req->r_ops[0].outdata_len; in ceph_osdc_call()
4887 ceph_osdc_put_request(req); in ceph_osdc_call()
4998 struct ceph_osd_request *req; in ceph_osdc_readpages() local
5003 req = ceph_osdc_new_request(osdc, layout, vino, off, plen, 0, 1, in ceph_osdc_readpages()
5007 if (IS_ERR(req)) in ceph_osdc_readpages()
5008 return PTR_ERR(req); in ceph_osdc_readpages()
5011 osd_req_op_extent_osd_data_pages(req, 0, in ceph_osdc_readpages()
5017 rc = ceph_osdc_start_request(osdc, req, false); in ceph_osdc_readpages()
5019 rc = ceph_osdc_wait_request(osdc, req); in ceph_osdc_readpages()
5021 ceph_osdc_put_request(req); in ceph_osdc_readpages()
5038 struct ceph_osd_request *req; in ceph_osdc_writepages() local
5042 req = ceph_osdc_new_request(osdc, layout, vino, off, &len, 0, 1, in ceph_osdc_writepages()
5046 if (IS_ERR(req)) in ceph_osdc_writepages()
5047 return PTR_ERR(req); in ceph_osdc_writepages()
5050 osd_req_op_extent_osd_data_pages(req, 0, pages, len, page_align, in ceph_osdc_writepages()
5054 req->r_mtime = *mtime; in ceph_osdc_writepages()
5055 rc = ceph_osdc_start_request(osdc, req, true); in ceph_osdc_writepages()
5057 rc = ceph_osdc_wait_request(osdc, req); in ceph_osdc_writepages()
5059 ceph_osdc_put_request(req); in ceph_osdc_writepages()
5131 struct ceph_osd_request *req; in get_reply() local
5145 req = lookup_request(&osd->o_requests, tid); in get_reply()
5146 if (!req) { in get_reply()
5153 ceph_msg_revoke_incoming(req->r_reply); in get_reply()
5155 if (front_len > req->r_reply->front_alloc_len) { in get_reply()
5157 __func__, osd->o_osd, req->r_tid, front_len, in get_reply()
5158 req->r_reply->front_alloc_len); in get_reply()
5163 ceph_msg_put(req->r_reply); in get_reply()
5164 req->r_reply = m; in get_reply()
5167 if (data_len > req->r_reply->data_length) { in get_reply()
5169 __func__, osd->o_osd, req->r_tid, data_len, in get_reply()
5170 req->r_reply->data_length); in get_reply()
5176 m = ceph_msg_get(req->r_reply); in get_reply()