Lines Matching refs:osdc
69 static inline void verify_osdc_locked(struct ceph_osd_client *osdc) in verify_osdc_locked() argument
71 WARN_ON(!rwsem_is_locked(&osdc->lock)); in verify_osdc_locked()
73 static inline void verify_osdc_wrlocked(struct ceph_osd_client *osdc) in verify_osdc_wrlocked() argument
75 WARN_ON(!rwsem_is_wrlocked(&osdc->lock)); in verify_osdc_wrlocked()
79 struct ceph_osd_client *osdc = osd->o_osdc; in verify_osd_locked() local
82 rwsem_is_locked(&osdc->lock)) && in verify_osd_locked()
83 !rwsem_is_wrlocked(&osdc->lock)); in verify_osd_locked()
90 static inline void verify_osdc_locked(struct ceph_osd_client *osdc) { } in verify_osdc_locked() argument
91 static inline void verify_osdc_wrlocked(struct ceph_osd_client *osdc) { } in verify_osdc_wrlocked() argument
547 struct ceph_osd_client *osdc = req->r_osdc; in request_reinit() local
565 req->r_osdc = osdc; in request_reinit()
575 struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc, in ceph_osdc_alloc_request() argument
585 req = mempool_alloc(osdc->req_mempool, gfp_flags); in ceph_osdc_alloc_request()
596 req->r_osdc = osdc; in ceph_osdc_alloc_request()
616 struct ceph_osd_client *osdc = req->r_osdc; in __ceph_osdc_alloc_messages() local
642 msg = ceph_msgpool_get(&osdc->msgpool_op, msg_size, in __ceph_osdc_alloc_messages()
659 msg = ceph_msgpool_get(&osdc->msgpool_op_reply, msg_size, in __ceph_osdc_alloc_messages()
1063 struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, in ceph_osdc_new_request() argument
1084 req = ceph_osdc_alloc_request(osdc, snapc, num_ops, use_mempool, in ceph_osdc_new_request()
1152 static void for_each_request(struct ceph_osd_client *osdc, in DEFINE_RB_FUNCS()
1158 for (n = rb_first(&osdc->osds); n; n = rb_next(n)) { in DEFINE_RB_FUNCS()
1171 for (p = rb_first(&osdc->homeless_osd.o_requests); p; ) { in DEFINE_RB_FUNCS()
1229 static struct ceph_osd *create_osd(struct ceph_osd_client *osdc, int onum) in create_osd() argument
1237 osd->o_osdc = osdc; in create_osd()
1240 ceph_con_init(&osd->o_con, osd, &osd_con_ops, &osdc->client->msgr); in create_osd()
1271 struct ceph_osd_client *osdc = osd->o_osdc; in DEFINE_RB_FUNCS() local
1276 spin_lock(&osdc->osd_lru_lock); in DEFINE_RB_FUNCS()
1277 list_add_tail(&osd->o_osd_lru, &osdc->osd_lru); in DEFINE_RB_FUNCS()
1278 spin_unlock(&osdc->osd_lru_lock); in DEFINE_RB_FUNCS()
1280 osd->lru_ttl = jiffies + osdc->client->options->osd_idle_ttl; in DEFINE_RB_FUNCS()
1292 struct ceph_osd_client *osdc = osd->o_osdc; in __remove_osd_from_lru() local
1296 spin_lock(&osdc->osd_lru_lock); in __remove_osd_from_lru()
1299 spin_unlock(&osdc->osd_lru_lock); in __remove_osd_from_lru()
1308 struct ceph_osd_client *osdc = osd->o_osdc; in close_osd() local
1311 verify_osdc_wrlocked(osdc); in close_osd()
1324 link_request(&osdc->homeless_osd, req); in close_osd()
1335 link_linger(&osdc->homeless_osd, lreq); in close_osd()
1340 erase_osd(&osdc->osds, osd); in close_osd()
1383 static struct ceph_osd *lookup_create_osd(struct ceph_osd_client *osdc, int o, in lookup_create_osd() argument
1389 verify_osdc_wrlocked(osdc); in lookup_create_osd()
1391 verify_osdc_locked(osdc); in lookup_create_osd()
1394 osd = lookup_osd(&osdc->osds, o); in lookup_create_osd()
1396 osd = &osdc->homeless_osd; in lookup_create_osd()
1401 osd = create_osd(osdc, o); in lookup_create_osd()
1402 insert_osd(&osdc->osds, osd); in lookup_create_osd()
1404 &osdc->osdmap->osd_addr[osd->o_osd]); in lookup_create_osd()
1407 dout("%s osdc %p osd%d -> osd %p\n", __func__, osdc, o, osd); in lookup_create_osd()
1455 static bool have_pool_full(struct ceph_osd_client *osdc) in have_pool_full() argument
1459 for (n = rb_first(&osdc->osdmap->pg_pools); n; n = rb_next(n)) { in have_pool_full()
1470 static bool pool_full(struct ceph_osd_client *osdc, s64 pool_id) in pool_full() argument
1474 pi = ceph_pg_pool_by_id(osdc->osdmap, pool_id); in pool_full()
1485 static bool target_should_be_paused(struct ceph_osd_client *osdc, in target_should_be_paused() argument
1489 bool pauserd = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD); in target_should_be_paused()
1490 bool pausewr = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSEWR) || in target_should_be_paused()
1491 ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in target_should_be_paused()
1497 (osdc->osdmap->epoch < osdc->epoch_barrier); in target_should_be_paused()
1506 static enum calc_target_result calc_target(struct ceph_osd_client *osdc, in calc_target() argument
1517 bool sort_bitwise = ceph_osdmap_flag(osdc, CEPH_OSDMAP_SORTBITWISE); in calc_target()
1518 bool recovery_deletes = ceph_osdmap_flag(osdc, in calc_target()
1522 t->epoch = osdc->osdmap->epoch; in calc_target()
1523 pi = ceph_pg_pool_by_id(osdc->osdmap, t->base_oloc.pool); in calc_target()
1530 if (osdc->osdmap->epoch == pi->last_force_request_resend) { in calc_target()
1548 pi = ceph_pg_pool_by_id(osdc->osdmap, t->target_oloc.pool); in calc_target()
1560 ceph_pg_to_up_acting_osds(osdc->osdmap, pi, &pgid, &up, &acting); in calc_target()
1579 if (t->paused && !target_should_be_paused(osdc, t, pi)) { in calc_target()
1590 ceph_pg_to_primary_shard(osdc->osdmap, pi, &pgid, &t->spgid); in calc_target()
2254 static void maybe_request_map(struct ceph_osd_client *osdc) in maybe_request_map() argument
2258 verify_osdc_locked(osdc); in maybe_request_map()
2259 WARN_ON(!osdc->osdmap->epoch); in maybe_request_map()
2261 if (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in maybe_request_map()
2262 ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD) || in maybe_request_map()
2263 ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSEWR)) { in maybe_request_map()
2264 dout("%s osdc %p continuous\n", __func__, osdc); in maybe_request_map()
2267 dout("%s osdc %p onetime\n", __func__, osdc); in maybe_request_map()
2270 if (ceph_monc_want_map(&osdc->client->monc, CEPH_SUB_OSDMAP, in maybe_request_map()
2271 osdc->osdmap->epoch + 1, continuous)) in maybe_request_map()
2272 ceph_monc_renew_subs(&osdc->client->monc); in maybe_request_map()
2280 struct ceph_osd_client *osdc = req->r_osdc; in __submit_request() local
2291 ct_res = calc_target(osdc, &req->r_t, false); in __submit_request()
2295 osd = lookup_create_osd(osdc, req->r_t.osd, wrlocked); in __submit_request()
2301 if (osdc->abort_err) { in __submit_request()
2302 dout("req %p abort_err %d\n", req, osdc->abort_err); in __submit_request()
2303 err = osdc->abort_err; in __submit_request()
2304 } else if (osdc->osdmap->epoch < osdc->epoch_barrier) { in __submit_request()
2305 dout("req %p epoch %u barrier %u\n", req, osdc->osdmap->epoch, in __submit_request()
2306 osdc->epoch_barrier); in __submit_request()
2308 maybe_request_map(osdc); in __submit_request()
2310 ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSEWR)) { in __submit_request()
2313 maybe_request_map(osdc); in __submit_request()
2315 ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD)) { in __submit_request()
2318 maybe_request_map(osdc); in __submit_request()
2322 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in __submit_request()
2323 pool_full(osdc, req->r_t.base_oloc.pool))) { in __submit_request()
2325 if (ceph_test_opt(osdc->client, ABORT_ON_FULL)) { in __submit_request()
2330 maybe_request_map(osdc); in __submit_request()
2335 maybe_request_map(osdc); in __submit_request()
2344 req->r_tid = atomic64_inc_return(&osdc->last_tid); in __submit_request()
2356 downgrade_write(&osdc->lock); in __submit_request()
2360 up_read(&osdc->lock); in __submit_request()
2361 down_write(&osdc->lock); in __submit_request()
2387 struct ceph_osd_client *osdc = req->r_osdc; in finish_request() local
2389 WARN_ON(lookup_request_mc(&osdc->map_checks, req->r_tid)); in finish_request()
2394 atomic_dec(&osdc->num_requests); in finish_request()
2441 struct ceph_osd_client *osdc = req->r_osdc; in cancel_map_check() local
2444 verify_osdc_wrlocked(osdc); in cancel_map_check()
2446 lookup_req = lookup_request_mc(&osdc->map_checks, req->r_tid); in cancel_map_check()
2451 erase_request_mc(&osdc->map_checks, req); in cancel_map_check()
2485 void ceph_osdc_abort_requests(struct ceph_osd_client *osdc, int err) in ceph_osdc_abort_requests() argument
2487 dout("%s osdc %p err %d\n", __func__, osdc, err); in ceph_osdc_abort_requests()
2488 down_write(&osdc->lock); in ceph_osdc_abort_requests()
2489 for_each_request(osdc, abort_fn, &err); in ceph_osdc_abort_requests()
2490 osdc->abort_err = err; in ceph_osdc_abort_requests()
2491 up_write(&osdc->lock); in ceph_osdc_abort_requests()
2495 void ceph_osdc_clear_abort_err(struct ceph_osd_client *osdc) in ceph_osdc_clear_abort_err() argument
2497 down_write(&osdc->lock); in ceph_osdc_clear_abort_err()
2498 osdc->abort_err = 0; in ceph_osdc_clear_abort_err()
2499 up_write(&osdc->lock); in ceph_osdc_clear_abort_err()
2503 static void update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb) in update_epoch_barrier() argument
2505 if (likely(eb > osdc->epoch_barrier)) { in update_epoch_barrier()
2507 osdc->epoch_barrier, eb); in update_epoch_barrier()
2508 osdc->epoch_barrier = eb; in update_epoch_barrier()
2510 if (eb > osdc->osdmap->epoch) in update_epoch_barrier()
2511 maybe_request_map(osdc); in update_epoch_barrier()
2515 void ceph_osdc_update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb) in ceph_osdc_update_epoch_barrier() argument
2517 down_read(&osdc->lock); in ceph_osdc_update_epoch_barrier()
2518 if (unlikely(eb > osdc->epoch_barrier)) { in ceph_osdc_update_epoch_barrier()
2519 up_read(&osdc->lock); in ceph_osdc_update_epoch_barrier()
2520 down_write(&osdc->lock); in ceph_osdc_update_epoch_barrier()
2521 update_epoch_barrier(osdc, eb); in ceph_osdc_update_epoch_barrier()
2522 up_write(&osdc->lock); in ceph_osdc_update_epoch_barrier()
2524 up_read(&osdc->lock); in ceph_osdc_update_epoch_barrier()
2537 struct ceph_osd_client *osdc = req->r_osdc; in abort_on_full_fn() local
2541 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in abort_on_full_fn()
2542 pool_full(osdc, req->r_t.base_oloc.pool))) { in abort_on_full_fn()
2544 update_epoch_barrier(osdc, osdc->osdmap->epoch); in abort_on_full_fn()
2559 static void ceph_osdc_abort_on_full(struct ceph_osd_client *osdc) in ceph_osdc_abort_on_full() argument
2563 if (ceph_test_opt(osdc->client, ABORT_ON_FULL) && in ceph_osdc_abort_on_full()
2564 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || have_pool_full(osdc))) in ceph_osdc_abort_on_full()
2565 for_each_request(osdc, abort_on_full_fn, &victims); in ceph_osdc_abort_on_full()
2570 struct ceph_osd_client *osdc = req->r_osdc; in check_pool_dne() local
2571 struct ceph_osdmap *map = osdc->osdmap; in check_pool_dne()
2573 verify_osdc_wrlocked(osdc); in check_pool_dne()
2604 struct ceph_osd_client *osdc = &greq->monc->client->osdc; in map_check_cb() local
2610 down_write(&osdc->lock); in map_check_cb()
2611 req = lookup_request_mc(&osdc->map_checks, tid); in map_check_cb()
2621 erase_request_mc(&osdc->map_checks, req); in map_check_cb()
2626 up_write(&osdc->lock); in map_check_cb()
2631 struct ceph_osd_client *osdc = req->r_osdc; in send_map_check() local
2635 verify_osdc_wrlocked(osdc); in send_map_check()
2637 lookup_req = lookup_request_mc(&osdc->map_checks, req->r_tid); in send_map_check()
2644 insert_request_mc(&osdc->map_checks, req); in send_map_check()
2645 ret = ceph_monc_get_version_async(&osdc->client->monc, "osdmap", in send_map_check()
2689 linger_alloc(struct ceph_osd_client *osdc) in linger_alloc() argument
2707 lreq->osdc = osdc; in linger_alloc()
2761 verify_osdc_locked(lreq->osdc); in __linger_registered()
2768 struct ceph_osd_client *osdc = lreq->osdc; in linger_registered() local
2771 down_read(&osdc->lock); in linger_registered()
2773 up_read(&osdc->lock); in linger_registered()
2780 struct ceph_osd_client *osdc = lreq->osdc; in linger_register() local
2782 verify_osdc_wrlocked(osdc); in linger_register()
2786 lreq->linger_id = ++osdc->last_linger_id; in linger_register()
2787 insert_linger_osdc(&osdc->linger_requests, lreq); in linger_register()
2792 struct ceph_osd_client *osdc = lreq->osdc; in linger_unregister() local
2794 verify_osdc_wrlocked(osdc); in linger_unregister()
2796 erase_linger_osdc(&osdc->linger_requests, lreq); in linger_unregister()
2861 struct ceph_osd_client *osdc = lreq->osdc; in lwork_queue() local
2868 queue_work(osdc->notify_wq, &lwork->work); in lwork_queue()
3065 struct ceph_osd_client *osdc = lreq->osdc; in send_linger_ping() local
3069 if (ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD)) { in send_linger_ping()
3095 req->r_tid = atomic64_inc_return(&osdc->last_tid); in send_linger_ping()
3102 struct ceph_osd_client *osdc = lreq->osdc; in linger_submit() local
3105 down_write(&osdc->lock); in linger_submit()
3114 calc_target(osdc, &lreq->t, false); in linger_submit()
3115 osd = lookup_create_osd(osdc, lreq->t.osd, true); in linger_submit()
3119 up_write(&osdc->lock); in linger_submit()
3124 struct ceph_osd_client *osdc = lreq->osdc; in cancel_linger_map_check() local
3127 verify_osdc_wrlocked(osdc); in cancel_linger_map_check()
3129 lookup_lreq = lookup_linger_mc(&osdc->linger_map_checks, in cancel_linger_map_check()
3135 erase_linger_mc(&osdc->linger_map_checks, lreq); in cancel_linger_map_check()
3155 struct ceph_osd_client *osdc = lreq->osdc; in linger_cancel() local
3157 down_write(&osdc->lock); in linger_cancel()
3160 up_write(&osdc->lock); in linger_cancel()
3167 struct ceph_osd_client *osdc = lreq->osdc; in check_linger_pool_dne() local
3168 struct ceph_osdmap *map = osdc->osdmap; in check_linger_pool_dne()
3170 verify_osdc_wrlocked(osdc); in check_linger_pool_dne()
3198 struct ceph_osd_client *osdc = &greq->monc->client->osdc; in linger_map_check_cb() local
3204 down_write(&osdc->lock); in linger_map_check_cb()
3205 lreq = lookup_linger_mc(&osdc->linger_map_checks, linger_id); in linger_map_check_cb()
3216 erase_linger_mc(&osdc->linger_map_checks, lreq); in linger_map_check_cb()
3221 up_write(&osdc->lock); in linger_map_check_cb()
3226 struct ceph_osd_client *osdc = lreq->osdc; in send_linger_map_check() local
3230 verify_osdc_wrlocked(osdc); in send_linger_map_check()
3232 lookup_lreq = lookup_linger_mc(&osdc->linger_map_checks, in send_linger_map_check()
3240 insert_linger_mc(&osdc->linger_map_checks, lreq); in send_linger_map_check()
3241 ret = ceph_monc_get_version_async(&osdc->client->monc, "osdmap", in send_linger_map_check()
3272 struct ceph_osd_client *osdc = in handle_timeout() local
3274 struct ceph_options *opts = osdc->client->options; in handle_timeout()
3280 dout("%s osdc %p\n", __func__, osdc); in handle_timeout()
3281 down_write(&osdc->lock); in handle_timeout()
3288 for (n = rb_first(&osdc->osds); n; n = rb_next(n)) { in handle_timeout()
3329 for (p = rb_first(&osdc->homeless_osd.o_requests); p; ) { in handle_timeout()
3337 req->r_tid, osdc->homeless_osd.o_osd); in handle_timeout()
3343 if (atomic_read(&osdc->num_homeless) || !list_empty(&slow_osds)) in handle_timeout()
3344 maybe_request_map(osdc); in handle_timeout()
3354 up_write(&osdc->lock); in handle_timeout()
3355 schedule_delayed_work(&osdc->timeout_work, in handle_timeout()
3356 osdc->client->options->osd_keepalive_timeout); in handle_timeout()
3361 struct ceph_osd_client *osdc = in handle_osds_timeout() local
3364 unsigned long delay = osdc->client->options->osd_idle_ttl / 4; in handle_osds_timeout()
3367 dout("%s osdc %p\n", __func__, osdc); in handle_osds_timeout()
3368 down_write(&osdc->lock); in handle_osds_timeout()
3369 list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) { in handle_osds_timeout()
3378 up_write(&osdc->lock); in handle_osds_timeout()
3379 schedule_delayed_work(&osdc->osds_timeout_work, in handle_osds_timeout()
3595 struct ceph_osd_client *osdc = osd->o_osdc; in handle_reply() local
3605 down_read(&osdc->lock); in handle_reply()
3689 up_read(&osdc->lock); in handle_reply()
3699 up_read(&osdc->lock); in handle_reply()
3702 static void set_pool_was_full(struct ceph_osd_client *osdc) in set_pool_was_full() argument
3706 for (n = rb_first(&osdc->osdmap->pg_pools); n; n = rb_next(n)) { in set_pool_was_full()
3714 static bool pool_cleared_full(struct ceph_osd_client *osdc, s64 pool_id) in pool_cleared_full() argument
3718 pi = ceph_pg_pool_by_id(osdc->osdmap, pool_id); in pool_cleared_full()
3728 struct ceph_osd_client *osdc = lreq->osdc; in recalc_linger_target() local
3731 ct_res = calc_target(osdc, &lreq->t, true); in recalc_linger_target()
3735 osd = lookup_create_osd(osdc, lreq->t.osd, true); in recalc_linger_target()
3755 struct ceph_osd_client *osdc = osd->o_osdc; in scan_requests() local
3773 pool_cleared_full(osdc, lreq->t.base_oloc.pool)); in scan_requests()
3803 ct_res = calc_target(osdc, &req->r_t, false); in scan_requests()
3808 pool_cleared_full(osdc, req->r_t.base_oloc.pool)); in scan_requests()
3827 static int handle_one_map(struct ceph_osd_client *osdc, in handle_one_map() argument
3837 was_full = ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL); in handle_one_map()
3838 set_pool_was_full(osdc); in handle_one_map()
3841 newmap = osdmap_apply_incremental(&p, end, osdc->osdmap); in handle_one_map()
3847 if (newmap != osdc->osdmap) { in handle_one_map()
3858 old_pi = ceph_pg_pool_by_id(osdc->osdmap, pi->id); in handle_one_map()
3865 if (osdc->osdmap->epoch && in handle_one_map()
3866 osdc->osdmap->epoch + 1 < newmap->epoch) { in handle_one_map()
3871 ceph_osdmap_destroy(osdc->osdmap); in handle_one_map()
3872 osdc->osdmap = newmap; in handle_one_map()
3875 was_full &= !ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL); in handle_one_map()
3876 scan_requests(&osdc->homeless_osd, skipped_map, was_full, true, in handle_one_map()
3879 for (n = rb_first(&osdc->osds); n; ) { in handle_one_map()
3886 if (!ceph_osd_is_up(osdc->osdmap, osd->o_osd) || in handle_one_map()
3888 ceph_osd_addr(osdc->osdmap, osd->o_osd), in handle_one_map()
3896 static void kick_requests(struct ceph_osd_client *osdc, in kick_requests() argument
3911 if (req->r_t.epoch < osdc->osdmap->epoch) { in kick_requests()
3912 ct_res = calc_target(osdc, &req->r_t, false); in kick_requests()
3928 osd = lookup_create_osd(osdc, req->r_t.osd, true); in kick_requests()
3953 void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg) in ceph_osdc_handle_map() argument
3967 dout("%s have %u\n", __func__, osdc->osdmap->epoch); in ceph_osdc_handle_map()
3968 down_write(&osdc->lock); in ceph_osdc_handle_map()
3973 if (ceph_check_fsid(osdc->client, &fsid) < 0) in ceph_osdc_handle_map()
3976 was_pauserd = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD); in ceph_osdc_handle_map()
3977 was_pausewr = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSEWR) || in ceph_osdc_handle_map()
3978 ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in ceph_osdc_handle_map()
3979 have_pool_full(osdc); in ceph_osdc_handle_map()
3989 if (osdc->osdmap->epoch && in ceph_osdc_handle_map()
3990 osdc->osdmap->epoch + 1 == epoch) { in ceph_osdc_handle_map()
3993 err = handle_one_map(osdc, p, p + maplen, true, in ceph_osdc_handle_map()
4019 } else if (osdc->osdmap->epoch >= epoch) { in ceph_osdc_handle_map()
4022 osdc->osdmap->epoch); in ceph_osdc_handle_map()
4025 err = handle_one_map(osdc, p, p + maplen, false, in ceph_osdc_handle_map()
4040 pauserd = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSERD); in ceph_osdc_handle_map()
4041 pausewr = ceph_osdmap_flag(osdc, CEPH_OSDMAP_PAUSEWR) || in ceph_osdc_handle_map()
4042 ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || in ceph_osdc_handle_map()
4043 have_pool_full(osdc); in ceph_osdc_handle_map()
4045 osdc->osdmap->epoch < osdc->epoch_barrier) in ceph_osdc_handle_map()
4046 maybe_request_map(osdc); in ceph_osdc_handle_map()
4048 kick_requests(osdc, &need_resend, &need_resend_linger); in ceph_osdc_handle_map()
4050 ceph_osdc_abort_on_full(osdc); in ceph_osdc_handle_map()
4051 ceph_monc_got_map(&osdc->client->monc, CEPH_SUB_OSDMAP, in ceph_osdc_handle_map()
4052 osdc->osdmap->epoch); in ceph_osdc_handle_map()
4053 up_write(&osdc->lock); in ceph_osdc_handle_map()
4054 wake_up_all(&osdc->client->auth_wq); in ceph_osdc_handle_map()
4060 up_write(&osdc->lock); in ceph_osdc_handle_map()
4099 struct ceph_osd_client *osdc = osd->o_osdc; in osd_fault() local
4103 down_write(&osdc->lock); in osd_fault()
4111 maybe_request_map(osdc); in osd_fault()
4114 up_write(&osdc->lock); in osd_fault()
4333 struct ceph_osd_client *osdc = osd->o_osdc; in handle_backoff() local
4337 down_read(&osdc->lock); in handle_backoff()
4340 up_read(&osdc->lock); in handle_backoff()
4369 up_read(&osdc->lock); in handle_backoff()
4375 static void handle_watch_notify(struct ceph_osd_client *osdc, in handle_watch_notify() argument
4408 down_read(&osdc->lock); in handle_watch_notify()
4409 lreq = lookup_linger_osdc(&osdc->linger_requests, cookie); in handle_watch_notify()
4466 up_read(&osdc->lock); in handle_watch_notify()
4476 int ceph_osdc_start_request(struct ceph_osd_client *osdc, in ceph_osdc_start_request() argument
4480 down_read(&osdc->lock); in ceph_osdc_start_request()
4482 up_read(&osdc->lock); in ceph_osdc_start_request()
4494 struct ceph_osd_client *osdc = req->r_osdc; in ceph_osdc_cancel_request() local
4496 down_write(&osdc->lock); in ceph_osdc_cancel_request()
4499 up_write(&osdc->lock); in ceph_osdc_cancel_request()
4527 int ceph_osdc_wait_request(struct ceph_osd_client *osdc, in ceph_osdc_wait_request() argument
4537 void ceph_osdc_sync(struct ceph_osd_client *osdc) in ceph_osdc_sync() argument
4540 u64 last_tid = atomic64_read(&osdc->last_tid); in ceph_osdc_sync()
4543 down_read(&osdc->lock); in ceph_osdc_sync()
4544 for (n = rb_first(&osdc->osds); n; n = rb_next(n)) { in ceph_osdc_sync()
4560 up_read(&osdc->lock); in ceph_osdc_sync()
4571 up_read(&osdc->lock); in ceph_osdc_sync()
4581 req = ceph_osdc_alloc_request(lreq->osdc, NULL, 1, false, GFP_NOIO); in alloc_linger_request()
4617 ceph_osdc_watch(struct ceph_osd_client *osdc, in ceph_osdc_watch() argument
4627 lreq = linger_alloc(osdc); in ceph_osdc_watch()
4676 int ceph_osdc_unwatch(struct ceph_osd_client *osdc, in ceph_osdc_unwatch() argument
4679 struct ceph_options *opts = osdc->client->options; in ceph_osdc_unwatch()
4683 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_unwatch()
4698 ceph_osdc_start_request(osdc, req, false); in ceph_osdc_unwatch()
4741 int ceph_osdc_notify_ack(struct ceph_osd_client *osdc, in ceph_osdc_notify_ack() argument
4752 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_notify_ack()
4769 ceph_osdc_start_request(osdc, req, false); in ceph_osdc_notify_ack()
4770 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_notify_ack()
4815 int ceph_osdc_notify(struct ceph_osd_client *osdc, in ceph_osdc_notify() argument
4834 lreq = linger_alloc(osdc); in ceph_osdc_notify()
4893 int ceph_osdc_watch_check(struct ceph_osd_client *osdc, in ceph_osdc_watch_check() argument
4899 down_read(&osdc->lock); in ceph_osdc_watch_check()
4918 up_read(&osdc->lock); in ceph_osdc_watch_check()
4988 int ceph_osdc_list_watchers(struct ceph_osd_client *osdc, in ceph_osdc_list_watchers() argument
4998 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_list_watchers()
5021 ceph_osdc_start_request(osdc, req, false); in ceph_osdc_list_watchers()
5022 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_list_watchers()
5040 void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc) in ceph_osdc_flush_notifies() argument
5042 dout("%s osdc %p\n", __func__, osdc); in ceph_osdc_flush_notifies()
5043 flush_workqueue(osdc->notify_wq); in ceph_osdc_flush_notifies()
5047 void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc) in ceph_osdc_maybe_request_map() argument
5049 down_read(&osdc->lock); in ceph_osdc_maybe_request_map()
5050 maybe_request_map(osdc); in ceph_osdc_maybe_request_map()
5051 up_read(&osdc->lock); in ceph_osdc_maybe_request_map()
5061 int ceph_osdc_call(struct ceph_osd_client *osdc, in ceph_osdc_call() argument
5075 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); in ceph_osdc_call()
5098 ceph_osdc_start_request(osdc, req, false); in ceph_osdc_call()
5099 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_call()
5115 void ceph_osdc_reopen_osds(struct ceph_osd_client *osdc) in ceph_osdc_reopen_osds() argument
5119 down_write(&osdc->lock); in ceph_osdc_reopen_osds()
5120 for (n = rb_first(&osdc->osds); n; ) { in ceph_osdc_reopen_osds()
5127 up_write(&osdc->lock); in ceph_osdc_reopen_osds()
5133 int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client) in ceph_osdc_init() argument
5138 osdc->client = client; in ceph_osdc_init()
5139 init_rwsem(&osdc->lock); in ceph_osdc_init()
5140 osdc->osds = RB_ROOT; in ceph_osdc_init()
5141 INIT_LIST_HEAD(&osdc->osd_lru); in ceph_osdc_init()
5142 spin_lock_init(&osdc->osd_lru_lock); in ceph_osdc_init()
5143 osd_init(&osdc->homeless_osd); in ceph_osdc_init()
5144 osdc->homeless_osd.o_osdc = osdc; in ceph_osdc_init()
5145 osdc->homeless_osd.o_osd = CEPH_HOMELESS_OSD; in ceph_osdc_init()
5146 osdc->last_linger_id = CEPH_LINGER_ID_START; in ceph_osdc_init()
5147 osdc->linger_requests = RB_ROOT; in ceph_osdc_init()
5148 osdc->map_checks = RB_ROOT; in ceph_osdc_init()
5149 osdc->linger_map_checks = RB_ROOT; in ceph_osdc_init()
5150 INIT_DELAYED_WORK(&osdc->timeout_work, handle_timeout); in ceph_osdc_init()
5151 INIT_DELAYED_WORK(&osdc->osds_timeout_work, handle_osds_timeout); in ceph_osdc_init()
5154 osdc->osdmap = ceph_osdmap_alloc(); in ceph_osdc_init()
5155 if (!osdc->osdmap) in ceph_osdc_init()
5158 osdc->req_mempool = mempool_create_slab_pool(10, in ceph_osdc_init()
5160 if (!osdc->req_mempool) in ceph_osdc_init()
5163 err = ceph_msgpool_init(&osdc->msgpool_op, CEPH_MSG_OSD_OP, in ceph_osdc_init()
5167 err = ceph_msgpool_init(&osdc->msgpool_op_reply, CEPH_MSG_OSD_OPREPLY, in ceph_osdc_init()
5174 osdc->notify_wq = create_singlethread_workqueue("ceph-watch-notify"); in ceph_osdc_init()
5175 if (!osdc->notify_wq) in ceph_osdc_init()
5178 osdc->completion_wq = create_singlethread_workqueue("ceph-completion"); in ceph_osdc_init()
5179 if (!osdc->completion_wq) in ceph_osdc_init()
5182 schedule_delayed_work(&osdc->timeout_work, in ceph_osdc_init()
5183 osdc->client->options->osd_keepalive_timeout); in ceph_osdc_init()
5184 schedule_delayed_work(&osdc->osds_timeout_work, in ceph_osdc_init()
5185 round_jiffies_relative(osdc->client->options->osd_idle_ttl)); in ceph_osdc_init()
5190 destroy_workqueue(osdc->notify_wq); in ceph_osdc_init()
5192 ceph_msgpool_destroy(&osdc->msgpool_op_reply); in ceph_osdc_init()
5194 ceph_msgpool_destroy(&osdc->msgpool_op); in ceph_osdc_init()
5196 mempool_destroy(osdc->req_mempool); in ceph_osdc_init()
5198 ceph_osdmap_destroy(osdc->osdmap); in ceph_osdc_init()
5203 void ceph_osdc_stop(struct ceph_osd_client *osdc) in ceph_osdc_stop() argument
5205 destroy_workqueue(osdc->completion_wq); in ceph_osdc_stop()
5206 destroy_workqueue(osdc->notify_wq); in ceph_osdc_stop()
5207 cancel_delayed_work_sync(&osdc->timeout_work); in ceph_osdc_stop()
5208 cancel_delayed_work_sync(&osdc->osds_timeout_work); in ceph_osdc_stop()
5210 down_write(&osdc->lock); in ceph_osdc_stop()
5211 while (!RB_EMPTY_ROOT(&osdc->osds)) { in ceph_osdc_stop()
5212 struct ceph_osd *osd = rb_entry(rb_first(&osdc->osds), in ceph_osdc_stop()
5216 up_write(&osdc->lock); in ceph_osdc_stop()
5217 WARN_ON(refcount_read(&osdc->homeless_osd.o_ref) != 1); in ceph_osdc_stop()
5218 osd_cleanup(&osdc->homeless_osd); in ceph_osdc_stop()
5220 WARN_ON(!list_empty(&osdc->osd_lru)); in ceph_osdc_stop()
5221 WARN_ON(!RB_EMPTY_ROOT(&osdc->linger_requests)); in ceph_osdc_stop()
5222 WARN_ON(!RB_EMPTY_ROOT(&osdc->map_checks)); in ceph_osdc_stop()
5223 WARN_ON(!RB_EMPTY_ROOT(&osdc->linger_map_checks)); in ceph_osdc_stop()
5224 WARN_ON(atomic_read(&osdc->num_requests)); in ceph_osdc_stop()
5225 WARN_ON(atomic_read(&osdc->num_homeless)); in ceph_osdc_stop()
5227 ceph_osdmap_destroy(osdc->osdmap); in ceph_osdc_stop()
5228 mempool_destroy(osdc->req_mempool); in ceph_osdc_stop()
5229 ceph_msgpool_destroy(&osdc->msgpool_op); in ceph_osdc_stop()
5230 ceph_msgpool_destroy(&osdc->msgpool_op_reply); in ceph_osdc_stop()
5237 int ceph_osdc_readpages(struct ceph_osd_client *osdc, in ceph_osdc_readpages() argument
5248 req = ceph_osdc_new_request(osdc, layout, vino, off, plen, 0, 1, in ceph_osdc_readpages()
5262 rc = ceph_osdc_start_request(osdc, req, false); in ceph_osdc_readpages()
5264 rc = ceph_osdc_wait_request(osdc, req); in ceph_osdc_readpages()
5275 int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino, in ceph_osdc_writepages() argument
5287 req = ceph_osdc_new_request(osdc, layout, vino, off, &len, 0, 1, in ceph_osdc_writepages()
5300 rc = ceph_osdc_start_request(osdc, req, true); in ceph_osdc_writepages()
5302 rc = ceph_osdc_wait_request(osdc, req); in ceph_osdc_writepages()
5345 int ceph_osdc_copy_from(struct ceph_osd_client *osdc, in ceph_osdc_copy_from() argument
5358 req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_KERNEL); in ceph_osdc_copy_from()
5377 ceph_osdc_start_request(osdc, req, false); in ceph_osdc_copy_from()
5378 ret = ceph_osdc_wait_request(osdc, req); in ceph_osdc_copy_from()
5411 struct ceph_osd_client *osdc = osd->o_osdc; in dispatch() local
5416 ceph_osdc_handle_map(osdc, msg); in dispatch()
5425 handle_watch_notify(osdc, msg); in dispatch()
5446 struct ceph_osd_client *osdc = osd->o_osdc; in get_reply() local
5453 down_read(&osdc->lock); in get_reply()
5499 up_read(&osdc->lock); in get_reply()
5587 struct ceph_osd_client *osdc = o->o_osdc; in get_authorizer() local
5588 struct ceph_auth_client *ac = osdc->client->monc.auth; in get_authorizer()
5615 struct ceph_osd_client *osdc = o->o_osdc; in add_authorizer_challenge() local
5616 struct ceph_auth_client *ac = osdc->client->monc.auth; in add_authorizer_challenge()
5625 struct ceph_osd_client *osdc = o->o_osdc; in verify_authorizer_reply() local
5626 struct ceph_auth_client *ac = osdc->client->monc.auth; in verify_authorizer_reply()
5634 struct ceph_osd_client *osdc = o->o_osdc; in invalidate_authorizer() local
5635 struct ceph_auth_client *ac = osdc->client->monc.auth; in invalidate_authorizer()
5638 return ceph_monc_validate_auth(&osdc->client->monc); in invalidate_authorizer()